@vielzeug/arsenal 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/README.md +31 -75
  2. package/dist/_dev.cjs +1 -1
  3. package/dist/_dev.cjs.map +1 -1
  4. package/dist/_dev.js +2 -5
  5. package/dist/_dev.js.map +1 -1
  6. package/dist/array/chunk.cjs +1 -1
  7. package/dist/array/chunk.cjs.map +1 -1
  8. package/dist/array/chunk.d.ts +2 -1
  9. package/dist/array/chunk.d.ts.map +1 -1
  10. package/dist/array/chunk.js +5 -7
  11. package/dist/array/chunk.js.map +1 -1
  12. package/dist/array/compare.cjs +1 -1
  13. package/dist/array/compare.cjs.map +1 -1
  14. package/dist/array/compare.d.ts.map +1 -1
  15. package/dist/array/compare.js +13 -14
  16. package/dist/array/compare.js.map +1 -1
  17. package/dist/array/index.cjs +1 -0
  18. package/dist/array/index.js +29 -0
  19. package/dist/array/search.cjs +1 -1
  20. package/dist/array/search.cjs.map +1 -1
  21. package/dist/array/search.d.ts +8 -77
  22. package/dist/array/search.d.ts.map +1 -1
  23. package/dist/array/search.js +21 -38
  24. package/dist/array/search.js.map +1 -1
  25. package/dist/array/sort.cjs +1 -1
  26. package/dist/array/sort.cjs.map +1 -1
  27. package/dist/array/sort.d.ts +1 -1
  28. package/dist/array/sort.d.ts.map +1 -1
  29. package/dist/array/sort.js +9 -10
  30. package/dist/array/sort.js.map +1 -1
  31. package/dist/arsenal.cjs +1 -1
  32. package/dist/arsenal.cjs.map +1 -1
  33. package/dist/arsenal.iife.js +1 -1
  34. package/dist/arsenal.iife.js.map +1 -1
  35. package/dist/arsenal.js +1 -1
  36. package/dist/arsenal.js.map +1 -1
  37. package/dist/async/attempt.cjs +1 -1
  38. package/dist/async/attempt.cjs.map +1 -1
  39. package/dist/async/attempt.d.ts +3 -8
  40. package/dist/async/attempt.d.ts.map +1 -1
  41. package/dist/async/attempt.js +3 -10
  42. package/dist/async/attempt.js.map +1 -1
  43. package/dist/async/index.cjs +1 -0
  44. package/dist/async/index.d.ts +1 -1
  45. package/dist/async/index.d.ts.map +1 -1
  46. package/dist/async/index.js +9 -0
  47. package/dist/async/parallel.cjs +1 -1
  48. package/dist/async/parallel.cjs.map +1 -1
  49. package/dist/async/parallel.d.ts +1 -1
  50. package/dist/async/parallel.d.ts.map +1 -1
  51. package/dist/async/parallel.js +15 -16
  52. package/dist/async/parallel.js.map +1 -1
  53. package/dist/async/retry.cjs +1 -1
  54. package/dist/async/retry.cjs.map +1 -1
  55. package/dist/async/retry.d.ts +1 -1
  56. package/dist/async/retry.d.ts.map +1 -1
  57. package/dist/async/retry.js +14 -15
  58. package/dist/async/retry.js.map +1 -1
  59. package/dist/async/taskPool.cjs +2 -0
  60. package/dist/async/taskPool.cjs.map +1 -0
  61. package/dist/async/taskPool.d.ts +14 -0
  62. package/dist/async/taskPool.d.ts.map +1 -0
  63. package/dist/async/taskPool.js +51 -0
  64. package/dist/async/taskPool.js.map +1 -0
  65. package/dist/cache/cache.cjs +2 -0
  66. package/dist/cache/cache.cjs.map +1 -0
  67. package/dist/cache/cache.d.ts +17 -0
  68. package/dist/cache/cache.d.ts.map +1 -0
  69. package/dist/cache/cache.js +59 -0
  70. package/dist/cache/cache.js.map +1 -0
  71. package/dist/cache/index.cjs +1 -0
  72. package/dist/cache/index.d.ts +1 -1
  73. package/dist/cache/index.d.ts.map +1 -1
  74. package/dist/cache/index.js +3 -0
  75. package/dist/cache/memo.cjs +1 -1
  76. package/dist/cache/memo.cjs.map +1 -1
  77. package/dist/cache/memo.d.ts +2 -2
  78. package/dist/cache/memo.js +24 -23
  79. package/dist/cache/memo.js.map +1 -1
  80. package/dist/errors.cjs +1 -1
  81. package/dist/errors.cjs.map +1 -1
  82. package/dist/errors.d.ts +0 -7
  83. package/dist/errors.d.ts.map +1 -1
  84. package/dist/errors.js +2 -2
  85. package/dist/errors.js.map +1 -1
  86. package/dist/function/debounce.cjs +1 -1
  87. package/dist/function/debounce.cjs.map +1 -1
  88. package/dist/function/debounce.js +15 -17
  89. package/dist/function/debounce.js.map +1 -1
  90. package/dist/function/index.cjs +1 -0
  91. package/dist/function/index.d.ts +0 -2
  92. package/dist/function/index.d.ts.map +1 -1
  93. package/dist/function/index.js +8 -0
  94. package/dist/function/pipe.cjs +1 -1
  95. package/dist/function/pipe.cjs.map +1 -1
  96. package/dist/function/pipe.js +1 -1
  97. package/dist/function/pipe.js.map +1 -1
  98. package/dist/guards/index.cjs +1 -0
  99. package/dist/guards/index.d.ts +0 -3
  100. package/dist/guards/index.d.ts.map +1 -1
  101. package/dist/guards/index.js +17 -0
  102. package/dist/guards/isEqual.cjs.map +1 -1
  103. package/dist/guards/isEqual.js.map +1 -1
  104. package/dist/index.cjs +1 -1
  105. package/dist/index.d.ts +2 -91
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +30 -118
  108. package/dist/math/allocate.cjs +1 -1
  109. package/dist/math/allocate.cjs.map +1 -1
  110. package/dist/math/allocate.d.ts +1 -1
  111. package/dist/math/allocate.d.ts.map +1 -1
  112. package/dist/math/allocate.js +13 -14
  113. package/dist/math/allocate.js.map +1 -1
  114. package/dist/math/index.cjs +1 -0
  115. package/dist/math/index.d.ts +0 -3
  116. package/dist/math/index.d.ts.map +1 -1
  117. package/dist/math/index.js +17 -0
  118. package/dist/math/mod.cjs +1 -1
  119. package/dist/math/mod.cjs.map +1 -1
  120. package/dist/math/mod.d.ts +1 -1
  121. package/dist/math/mod.d.ts.map +1 -1
  122. package/dist/math/mod.js +4 -5
  123. package/dist/math/mod.js.map +1 -1
  124. package/dist/math/range.cjs +1 -1
  125. package/dist/math/range.cjs.map +1 -1
  126. package/dist/math/range.d.ts +1 -1
  127. package/dist/math/range.d.ts.map +1 -1
  128. package/dist/math/range.js +14 -15
  129. package/dist/math/range.js.map +1 -1
  130. package/dist/math/sum.cjs +1 -1
  131. package/dist/math/sum.cjs.map +1 -1
  132. package/dist/math/sum.d.ts +2 -2
  133. package/dist/math/sum.d.ts.map +1 -1
  134. package/dist/math/sum.js +6 -7
  135. package/dist/math/sum.js.map +1 -1
  136. package/dist/object/getPath.cjs +1 -1
  137. package/dist/object/getPath.cjs.map +1 -1
  138. package/dist/object/getPath.d.ts +12 -42
  139. package/dist/object/getPath.d.ts.map +1 -1
  140. package/dist/object/getPath.js +21 -22
  141. package/dist/object/getPath.js.map +1 -1
  142. package/dist/object/index.cjs +1 -0
  143. package/dist/object/index.d.ts +1 -1
  144. package/dist/object/index.d.ts.map +1 -1
  145. package/dist/object/index.js +15 -0
  146. package/dist/object/merge.cjs +1 -1
  147. package/dist/object/merge.cjs.map +1 -1
  148. package/dist/object/merge.d.ts +1 -1
  149. package/dist/object/merge.d.ts.map +1 -1
  150. package/dist/object/merge.js +2 -3
  151. package/dist/object/merge.js.map +1 -1
  152. package/dist/object/prune.cjs +1 -1
  153. package/dist/object/prune.cjs.map +1 -1
  154. package/dist/object/prune.d.ts.map +1 -1
  155. package/dist/object/prune.js +22 -23
  156. package/dist/object/prune.js.map +1 -1
  157. package/dist/object/tryParseJson.cjs +2 -0
  158. package/dist/object/tryParseJson.cjs.map +1 -0
  159. package/dist/object/tryParseJson.d.ts +9 -0
  160. package/dist/object/tryParseJson.d.ts.map +1 -0
  161. package/dist/object/tryParseJson.js +18 -0
  162. package/dist/object/tryParseJson.js.map +1 -0
  163. package/dist/random/_index.cjs +2 -0
  164. package/dist/random/_index.cjs.map +1 -0
  165. package/dist/random/_index.d.ts +3 -0
  166. package/dist/random/_index.d.ts.map +1 -0
  167. package/dist/random/_index.js +10 -0
  168. package/dist/random/_index.js.map +1 -0
  169. package/dist/random/draw.cjs +1 -1
  170. package/dist/random/draw.cjs.map +1 -1
  171. package/dist/random/draw.d.ts +3 -2
  172. package/dist/random/draw.d.ts.map +1 -1
  173. package/dist/random/draw.js +12 -12
  174. package/dist/random/draw.js.map +1 -1
  175. package/dist/random/index.cjs +1 -0
  176. package/dist/random/index.d.ts +1 -0
  177. package/dist/random/index.d.ts.map +1 -1
  178. package/dist/random/index.js +5 -0
  179. package/dist/random/random.cjs +1 -1
  180. package/dist/random/random.cjs.map +1 -1
  181. package/dist/random/random.d.ts +2 -1
  182. package/dist/random/random.d.ts.map +1 -1
  183. package/dist/random/random.js +5 -6
  184. package/dist/random/random.js.map +1 -1
  185. package/dist/random/shuffle.cjs +1 -1
  186. package/dist/random/shuffle.cjs.map +1 -1
  187. package/dist/random/shuffle.d.ts +2 -1
  188. package/dist/random/shuffle.d.ts.map +1 -1
  189. package/dist/random/shuffle.js +7 -7
  190. package/dist/random/shuffle.js.map +1 -1
  191. package/dist/random/source.d.ts +4 -0
  192. package/dist/random/source.d.ts.map +1 -0
  193. package/dist/string/index.cjs +1 -0
  194. package/dist/string/index.d.ts +0 -2
  195. package/dist/string/index.d.ts.map +1 -1
  196. package/dist/string/index.js +12 -0
  197. package/dist/string/similarity.cjs +1 -1
  198. package/dist/string/similarity.cjs.map +1 -1
  199. package/dist/string/similarity.d.ts.map +1 -1
  200. package/dist/string/similarity.js +16 -17
  201. package/dist/string/similarity.js.map +1 -1
  202. package/dist/string/truncate.cjs +1 -1
  203. package/dist/string/truncate.cjs.map +1 -1
  204. package/dist/string/truncate.d.ts +2 -1
  205. package/dist/string/truncate.d.ts.map +1 -1
  206. package/dist/string/truncate.js +10 -11
  207. package/dist/string/truncate.js.map +1 -1
  208. package/dist/types.d.ts +1 -1
  209. package/dist/types.d.ts.map +1 -1
  210. package/package.json +11 -16
  211. package/dist/_common/_secureRandomIndex.cjs +0 -2
  212. package/dist/_common/_secureRandomIndex.cjs.map +0 -1
  213. package/dist/_common/_secureRandomIndex.d.ts +0 -2
  214. package/dist/_common/_secureRandomIndex.d.ts.map +0 -1
  215. package/dist/_common/_secureRandomIndex.js +0 -9
  216. package/dist/_common/_secureRandomIndex.js.map +0 -1
  217. package/dist/async/queue.cjs +0 -2
  218. package/dist/async/queue.cjs.map +0 -1
  219. package/dist/async/queue.d.ts +0 -42
  220. package/dist/async/queue.d.ts.map +0 -1
  221. package/dist/async/queue.js +0 -72
  222. package/dist/async/queue.js.map +0 -1
  223. package/dist/cache/stash.cjs +0 -2
  224. package/dist/cache/stash.cjs.map +0 -1
  225. package/dist/cache/stash.d.ts +0 -111
  226. package/dist/cache/stash.d.ts.map +0 -1
  227. package/dist/cache/stash.js +0 -92
  228. package/dist/cache/stash.js.map +0 -1
  229. package/dist/function/constant.cjs +0 -2
  230. package/dist/function/constant.cjs.map +0 -1
  231. package/dist/function/constant.d.ts +0 -5
  232. package/dist/function/constant.d.ts.map +0 -1
  233. package/dist/function/constant.js +0 -8
  234. package/dist/function/constant.js.map +0 -1
  235. package/dist/function/identity.cjs +0 -2
  236. package/dist/function/identity.cjs.map +0 -1
  237. package/dist/function/identity.d.ts +0 -5
  238. package/dist/function/identity.d.ts.map +0 -1
  239. package/dist/function/identity.js +0 -8
  240. package/dist/function/identity.js.map +0 -1
  241. package/dist/guards/isArray.cjs +0 -2
  242. package/dist/guards/isArray.cjs.map +0 -1
  243. package/dist/guards/isArray.d.ts +0 -16
  244. package/dist/guards/isArray.d.ts.map +0 -1
  245. package/dist/guards/isArray.js +0 -8
  246. package/dist/guards/isArray.js.map +0 -1
  247. package/dist/guards/isBoolean.cjs +0 -2
  248. package/dist/guards/isBoolean.cjs.map +0 -1
  249. package/dist/guards/isBoolean.d.ts +0 -23
  250. package/dist/guards/isBoolean.d.ts.map +0 -1
  251. package/dist/guards/isBoolean.js +0 -8
  252. package/dist/guards/isBoolean.js.map +0 -1
  253. package/dist/guards/isString.cjs +0 -2
  254. package/dist/guards/isString.cjs.map +0 -1
  255. package/dist/guards/isString.d.ts +0 -15
  256. package/dist/guards/isString.d.ts.map +0 -1
  257. package/dist/guards/isString.js +0 -8
  258. package/dist/guards/isString.js.map +0 -1
  259. package/dist/math/abs.cjs +0 -2
  260. package/dist/math/abs.cjs.map +0 -1
  261. package/dist/math/abs.d.ts +0 -17
  262. package/dist/math/abs.d.ts.map +0 -1
  263. package/dist/math/abs.js +0 -8
  264. package/dist/math/abs.js.map +0 -1
  265. package/dist/math/max.cjs +0 -2
  266. package/dist/math/max.cjs.map +0 -1
  267. package/dist/math/max.d.ts +0 -21
  268. package/dist/math/max.d.ts.map +0 -1
  269. package/dist/math/max.js +0 -12
  270. package/dist/math/max.js.map +0 -1
  271. package/dist/math/min.cjs +0 -2
  272. package/dist/math/min.cjs.map +0 -1
  273. package/dist/math/min.d.ts +0 -21
  274. package/dist/math/min.d.ts.map +0 -1
  275. package/dist/math/min.js +0 -12
  276. package/dist/math/min.js.map +0 -1
  277. package/dist/object/parseJSON.cjs +0 -2
  278. package/dist/object/parseJSON.cjs.map +0 -1
  279. package/dist/object/parseJSON.d.ts +0 -32
  280. package/dist/object/parseJSON.d.ts.map +0 -1
  281. package/dist/object/parseJSON.js +0 -16
  282. package/dist/object/parseJSON.js.map +0 -1
  283. package/dist/string/endsWith.cjs +0 -2
  284. package/dist/string/endsWith.cjs.map +0 -1
  285. package/dist/string/endsWith.d.ts +0 -5
  286. package/dist/string/endsWith.d.ts.map +0 -1
  287. package/dist/string/endsWith.js +0 -8
  288. package/dist/string/endsWith.js.map +0 -1
  289. package/dist/string/startsWith.cjs +0 -2
  290. package/dist/string/startsWith.cjs.map +0 -1
  291. package/dist/string/startsWith.d.ts +0 -5
  292. package/dist/string/startsWith.d.ts.map +0 -1
  293. package/dist/string/startsWith.js +0 -8
  294. package/dist/string/startsWith.js.map +0 -1
@@ -1,15 +0,0 @@
1
- /**
2
- * Determines if the passed value is a String.
3
- *
4
- * @example
5
- * ```ts
6
- * isString('Hello World'); // true
7
- * isString(42); // false
8
- * ```
9
- *
10
- * @param arg - The argument to be checked.
11
- *
12
- * @returns `true` if the value is a String, else `false`.
13
- */
14
- export declare function isString(arg: unknown): arg is string;
15
- //# sourceMappingURL=isString.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isString.d.ts","sourceRoot":"","sources":["../../src/guards/isString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD"}
@@ -1,8 +0,0 @@
1
- //#region src/guards/isString.ts
2
- function e(e) {
3
- return typeof e == "string";
4
- }
5
- //#endregion
6
- export { e as isString };
7
-
8
- //# sourceMappingURL=isString.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isString.js","names":[],"sources":["../../src/guards/isString.ts"],"sourcesContent":["/**\n * Determines if the passed value is a String.\n *\n * @example\n * ```ts\n * isString('Hello World'); // true\n * isString(42); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a String, else `false`.\n */\nexport function isString(arg: unknown): arg is string {\n return typeof arg === 'string';\n}\n"],"mappings":";AAaA,SAAgB,EAAS,GAA6B;CACpD,OAAO,OAAO,KAAQ;AACxB"}
package/dist/math/abs.cjs DELETED
@@ -1,2 +0,0 @@
1
- function e(e){return typeof e==`bigint`?e<0n?-e:e:Math.abs(e)}exports.abs=e;
2
- //# sourceMappingURL=abs.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abs.cjs","names":[],"sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n\n return Math.abs(value);\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAyC,CAK3D,OAJI,OAAO,GAAU,SACZ,EAAQ,GAAK,CAAC,EAAQ,EAGxB,KAAK,IAAI,CAAK,CACvB"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Returns the absolute value of a number.
3
- * Supports both regular numbers and bigint.
4
- *
5
- * @example
6
- * ```ts
7
- * abs(-5); // 5
8
- * abs(3); // 3
9
- * abs(-100n); // 100n
10
- * ```
11
- *
12
- * @param value - The number or bigint to get absolute value of
13
- * @returns Absolute value
14
- */
15
- export declare function abs(value: number): number;
16
- export declare function abs(value: bigint): bigint;
17
- //# sourceMappingURL=abs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../../src/math/abs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAC3C,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC"}
package/dist/math/abs.js DELETED
@@ -1,8 +0,0 @@
1
- //#region src/math/abs.ts
2
- function e(e) {
3
- return typeof e == "bigint" ? e < 0n ? -e : e : Math.abs(e);
4
- }
5
- //#endregion
6
- export { e as abs };
7
-
8
- //# sourceMappingURL=abs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abs.js","names":[],"sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n\n return Math.abs(value);\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAyC;CAK3D,OAJI,OAAO,KAAU,WACZ,IAAQ,KAAK,CAAC,IAAQ,IAGxB,KAAK,IAAI,CAAK;AACvB"}
package/dist/math/max.cjs DELETED
@@ -1,2 +0,0 @@
1
- const e=require("../array/compare.cjs");function t(t,n){if(t.length===0)return;let r=n??(e=>e),i=t[0];for(let n=1;n<t.length;n++)e.compare(r(t[n]),r(i))>0&&(i=t[n]);return i}exports.max=t;
2
- //# sourceMappingURL=max.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"max.cjs","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) > 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":"wCAqBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,GAAI,EAAM,SAAW,EAAG,OAExB,IAAM,EAAK,IAAc,GAAY,GACjC,EAAU,EAAM,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC5B,EAAA,QAAQ,EAAG,EAAM,EAAE,EAAG,EAAG,CAAO,CAAC,EAAI,IACvC,EAAU,EAAM,IAIpB,OAAO,CACT"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Finds the maximum item in an array.
3
- *
4
- * @description
5
- * This function can be used to find the maximum number, string, or any other type of item in an array.
6
- *
7
- * @example
8
- * ```ts
9
- * max([1, 2, 3]); // 3
10
- * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3
11
- * max(['apple', 'banana', 'cherry']); // 'cherry'
12
- * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01
13
- * ```
14
- *
15
- * @param array - The array to be searched.
16
- * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
17
- *
18
- * @return The item with the maximum value as determined by the callback function.
19
- */
20
- export declare function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
21
- //# sourceMappingURL=max.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../src/math/max.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAahG"}
package/dist/math/max.js DELETED
@@ -1,12 +0,0 @@
1
- import { compare as e } from "../array/compare.js";
2
- //#region src/math/max.ts
3
- function t(t, n) {
4
- if (t.length === 0) return;
5
- let r = n ?? ((e) => e), i = t[0];
6
- for (let n = 1; n < t.length; n++) e(r(t[n]), r(i)) > 0 && (i = t[n]);
7
- return i;
8
- }
9
- //#endregion
10
- export { t as max };
11
-
12
- //# sourceMappingURL=max.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"max.js","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) > 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":";;AAqBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAI,EAAM,WAAW,GAAG;CAExB,IAAM,IAAK,OAAc,MAAY,IACjC,IAAU,EAAM;CAEpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAChC,AAAI,EAAQ,EAAG,EAAM,EAAE,GAAG,EAAG,CAAO,CAAC,IAAI,MACvC,IAAU,EAAM;CAIpB,OAAO;AACT"}
package/dist/math/min.cjs DELETED
@@ -1,2 +0,0 @@
1
- const e=require("../array/compare.cjs");function t(t,n){if(t.length===0)return;let r=n??(e=>e),i=t[0];for(let n=1;n<t.length;n++)e.compare(r(t[n]),r(i))<0&&(i=t[n]);return i}exports.min=t;
2
- //# sourceMappingURL=min.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"min.cjs","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) < 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":"wCAqBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,GAAI,EAAM,SAAW,EAAG,OAExB,IAAM,EAAK,IAAc,GAAY,GACjC,EAAU,EAAM,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC5B,EAAA,QAAQ,EAAG,EAAM,EAAE,EAAG,EAAG,CAAO,CAAC,EAAI,IACvC,EAAU,EAAM,IAIpB,OAAO,CACT"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Finds the minimum item in an array.
3
- *
4
- * @description
5
- * This function can be used to find the minimum number, string, or any other type of item in an array.
6
- *
7
- * @example
8
- * ```ts
9
- * min([1, 2, 3]); // 1
10
- * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1
11
- * min(['apple', 'banana', 'cherry']); // 'apple'
12
- * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01
13
- * ```
14
- *
15
- * @param array - The array to be searched.
16
- * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
17
- *
18
- * @return The item with the minimum value as determined by the callback function.
19
- */
20
- export declare function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
21
- //# sourceMappingURL=min.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../src/math/min.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAahG"}
package/dist/math/min.js DELETED
@@ -1,12 +0,0 @@
1
- import { compare as e } from "../array/compare.js";
2
- //#region src/math/min.ts
3
- function t(t, n) {
4
- if (t.length === 0) return;
5
- let r = n ?? ((e) => e), i = t[0];
6
- for (let n = 1; n < t.length; n++) e(r(t[n]), r(i)) < 0 && (i = t[n]);
7
- return i;
8
- }
9
- //#endregion
10
- export { t as min };
11
-
12
- //# sourceMappingURL=min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"min.js","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) < 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":";;AAqBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAI,EAAM,WAAW,GAAG;CAExB,IAAM,IAAK,OAAc,MAAY,IACjC,IAAU,EAAM;CAEpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAChC,AAAI,EAAQ,EAAG,EAAM,EAAE,GAAG,EAAG,CAAO,CAAC,IAAI,MACvC,IAAU,EAAM;CAIpB,OAAO;AACT"}
@@ -1,2 +0,0 @@
1
- const e=require("../guards/isNil.cjs");function t(t,n={}){let{fallback:r,reviver:i,validator:a}=n;if(e.isNil(t))return r;try{let e=JSON.parse(t,i);return e===void 0||a&&!a(e)?r:e}catch{return r}}exports.parseJSON=t;
2
- //# sourceMappingURL=parseJSON.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseJSON.cjs","names":[],"sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { isNil } from '../guards/isNil';\n\nexport type ParseJSONOptions<T> = {\n fallback?: T;\n reviver?: (key: string, value: unknown) => unknown;\n validator?: (parsed: unknown) => boolean;\n};\n\n/**\n * Parses a JSON string and returns the resulting value.\n * `null` and `undefined` inputs return `fallback` without throwing.\n *\n * @example\n * ```ts\n * parseJSON<Record<string, number>>('{\"a\":1}'); // { a: 1 }\n * parseJSON('bad json', { fallback: {} }); // {}\n * parseJSON(null, { fallback: 0 }); // 0\n *\n * // With a validator — returns fallback when validation fails\n * parseJSON('{\"id\":\"bad\"}', {\n * validator: (v) => typeof (v as Record<string, unknown>).id === 'number',\n * fallback: { id: 0 },\n * }); // { id: 0 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. `null` / `undefined` return `fallback`.\n * @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.\n * @param [options.reviver] - Optional reviver function for `JSON.parse`.\n * @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.\n *\n * @returns The parsed value, or `fallback` on failure.\n */\nexport function parseJSON<T = unknown>(\n json: string | null | undefined,\n options: ParseJSONOptions<T> = {},\n): T | undefined {\n const { fallback, reviver, validator } = options;\n\n if (isNil(json)) return fallback;\n\n try {\n const value = JSON.parse(json, reviver as Parameters<typeof JSON.parse>[1]) as unknown;\n\n if (value === undefined) return fallback;\n\n if (validator && !validator(value)) return fallback;\n\n return value as T | undefined;\n } catch {\n return fallback;\n }\n}\n"],"mappings":"uCAiCA,SAAgB,EACd,EACA,EAA+B,CAAC,EACjB,CACf,GAAM,CAAE,WAAU,UAAS,aAAc,EAEzC,GAAI,EAAA,MAAM,CAAI,EAAG,OAAO,EAExB,GAAI,CACF,IAAM,EAAQ,KAAK,MAAM,EAAM,CAA2C,EAM1E,OAJI,IAAU,IAAA,IAEV,GAAa,CAAC,EAAU,CAAK,EAAU,EAEpC,CACT,MAAQ,CACN,OAAO,CACT,CACF"}
@@ -1,32 +0,0 @@
1
- export type ParseJSONOptions<T> = {
2
- fallback?: T;
3
- reviver?: (key: string, value: unknown) => unknown;
4
- validator?: (parsed: unknown) => boolean;
5
- };
6
- /**
7
- * Parses a JSON string and returns the resulting value.
8
- * `null` and `undefined` inputs return `fallback` without throwing.
9
- *
10
- * @example
11
- * ```ts
12
- * parseJSON<Record<string, number>>('{"a":1}'); // { a: 1 }
13
- * parseJSON('bad json', { fallback: {} }); // {}
14
- * parseJSON(null, { fallback: 0 }); // 0
15
- *
16
- * // With a validator — returns fallback when validation fails
17
- * parseJSON('{"id":"bad"}', {
18
- * validator: (v) => typeof (v as Record<string, unknown>).id === 'number',
19
- * fallback: { id: 0 },
20
- * }); // { id: 0 }
21
- * ```
22
- *
23
- * @template T - The expected type of the parsed JSON.
24
- * @param json - The JSON string to parse. `null` / `undefined` return `fallback`.
25
- * @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.
26
- * @param [options.reviver] - Optional reviver function for `JSON.parse`.
27
- * @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.
28
- *
29
- * @returns The parsed value, or `fallback` on failure.
30
- */
31
- export declare function parseJSON<T = unknown>(json: string | null | undefined, options?: ParseJSONOptions<T>): T | undefined;
32
- //# sourceMappingURL=parseJSON.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/object/parseJSON.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IACnD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EACnC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAChC,CAAC,GAAG,SAAS,CAgBf"}
@@ -1,16 +0,0 @@
1
- import { isNil as e } from "../guards/isNil.js";
2
- //#region src/object/parseJSON.ts
3
- function t(t, n = {}) {
4
- let { fallback: r, reviver: i, validator: a } = n;
5
- if (e(t)) return r;
6
- try {
7
- let e = JSON.parse(t, i);
8
- return e === void 0 || a && !a(e) ? r : e;
9
- } catch {
10
- return r;
11
- }
12
- }
13
- //#endregion
14
- export { t as parseJSON };
15
-
16
- //# sourceMappingURL=parseJSON.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseJSON.js","names":[],"sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { isNil } from '../guards/isNil';\n\nexport type ParseJSONOptions<T> = {\n fallback?: T;\n reviver?: (key: string, value: unknown) => unknown;\n validator?: (parsed: unknown) => boolean;\n};\n\n/**\n * Parses a JSON string and returns the resulting value.\n * `null` and `undefined` inputs return `fallback` without throwing.\n *\n * @example\n * ```ts\n * parseJSON<Record<string, number>>('{\"a\":1}'); // { a: 1 }\n * parseJSON('bad json', { fallback: {} }); // {}\n * parseJSON(null, { fallback: 0 }); // 0\n *\n * // With a validator — returns fallback when validation fails\n * parseJSON('{\"id\":\"bad\"}', {\n * validator: (v) => typeof (v as Record<string, unknown>).id === 'number',\n * fallback: { id: 0 },\n * }); // { id: 0 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. `null` / `undefined` return `fallback`.\n * @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.\n * @param [options.reviver] - Optional reviver function for `JSON.parse`.\n * @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.\n *\n * @returns The parsed value, or `fallback` on failure.\n */\nexport function parseJSON<T = unknown>(\n json: string | null | undefined,\n options: ParseJSONOptions<T> = {},\n): T | undefined {\n const { fallback, reviver, validator } = options;\n\n if (isNil(json)) return fallback;\n\n try {\n const value = JSON.parse(json, reviver as Parameters<typeof JSON.parse>[1]) as unknown;\n\n if (value === undefined) return fallback;\n\n if (validator && !validator(value)) return fallback;\n\n return value as T | undefined;\n } catch {\n return fallback;\n }\n}\n"],"mappings":";;AAiCA,SAAgB,EACd,GACA,IAA+B,CAAC,GACjB;CACf,IAAM,EAAE,aAAU,YAAS,iBAAc;CAEzC,IAAI,EAAM,CAAI,GAAG,OAAO;CAExB,IAAI;EACF,IAAM,IAAQ,KAAK,MAAM,GAAM,CAA2C;EAM1E,OAJI,MAAU,KAAA,KAEV,KAAa,CAAC,EAAU,CAAK,IAAU,IAEpC;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,2 +0,0 @@
1
- function e(e,t){return e.endsWith(t)}exports.endsWith=e;
2
- //# sourceMappingURL=endsWith.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endsWith.cjs","names":[],"sources":["../../src/string/endsWith.ts"],"sourcesContent":["/**\n * Type-safe endsWith wrapper.\n */\nexport function endsWith<S extends string>(value: string, suffix: S): value is `${string}${S}` {\n return value.endsWith(suffix);\n}\n"],"mappings":"AAGA,SAAgB,EAA2B,EAAe,EAAqC,CAC7F,OAAO,EAAM,SAAS,CAAM,CAC9B"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Type-safe endsWith wrapper.
3
- */
4
- export declare function endsWith<S extends string>(value: string, suffix: S): value is `${string}${S}`;
5
- //# sourceMappingURL=endsWith.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endsWith.d.ts","sourceRoot":"","sources":["../../src/string/endsWith.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,EAAE,CAE7F"}
@@ -1,8 +0,0 @@
1
- //#region src/string/endsWith.ts
2
- function e(e, t) {
3
- return e.endsWith(t);
4
- }
5
- //#endregion
6
- export { e as endsWith };
7
-
8
- //# sourceMappingURL=endsWith.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endsWith.js","names":[],"sources":["../../src/string/endsWith.ts"],"sourcesContent":["/**\n * Type-safe endsWith wrapper.\n */\nexport function endsWith<S extends string>(value: string, suffix: S): value is `${string}${S}` {\n return value.endsWith(suffix);\n}\n"],"mappings":";AAGA,SAAgB,EAA2B,GAAe,GAAqC;CAC7F,OAAO,EAAM,SAAS,CAAM;AAC9B"}
@@ -1,2 +0,0 @@
1
- function e(e,t){return e.startsWith(t)}exports.startsWith=e;
2
- //# sourceMappingURL=startsWith.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startsWith.cjs","names":[],"sources":["../../src/string/startsWith.ts"],"sourcesContent":["/**\n * Type-safe startsWith wrapper.\n */\nexport function startsWith<P extends string>(value: string, prefix: P): value is `${P}${string}` {\n return value.startsWith(prefix);\n}\n"],"mappings":"AAGA,SAAgB,EAA6B,EAAe,EAAqC,CAC/F,OAAO,EAAM,WAAW,CAAM,CAChC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Type-safe startsWith wrapper.
3
- */
4
- export declare function startsWith<P extends string>(value: string, prefix: P): value is `${P}${string}`;
5
- //# sourceMappingURL=startsWith.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startsWith.d.ts","sourceRoot":"","sources":["../../src/string/startsWith.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,CAE/F"}
@@ -1,8 +0,0 @@
1
- //#region src/string/startsWith.ts
2
- function e(e, t) {
3
- return e.startsWith(t);
4
- }
5
- //#endregion
6
- export { e as startsWith };
7
-
8
- //# sourceMappingURL=startsWith.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startsWith.js","names":[],"sources":["../../src/string/startsWith.ts"],"sourcesContent":["/**\n * Type-safe startsWith wrapper.\n */\nexport function startsWith<P extends string>(value: string, prefix: P): value is `${P}${string}` {\n return value.startsWith(prefix);\n}\n"],"mappings":";AAGA,SAAgB,EAA6B,GAAe,GAAqC;CAC/F,OAAO,EAAM,WAAW,CAAM;AAChC"}