@vielzeug/arsenal 1.1.1 → 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 +14 -19
  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,2 +1,2 @@
1
- const e=require("../errors.cjs"),t=require("../_common/_lruMap.cjs");var n=`\0undefined\0`,r=`\0NaN\0`,i=`\0+Infinity\0`,a=`\0-Infinity\0`,o=`\0function\0`,s=0,c=new WeakMap;function l(e){let t=c.get(e);return t===void 0&&(t=s++,c.set(e,t)),t}var u=t=>{try{return JSON.stringify(t,(e,t)=>t===void 0?n:typeof t==`number`&&Number.isNaN(t)?r:t===1/0?i:t===-1/0?a:typeof t==`function`?`${o}${l(t)}`:t)}catch(t){throw new e.ArsenalSerializationError(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${t instanceof Error&&t.message?` Reason: ${t.message}`:``}`,{cause:t})}};function d(n,{key:r,maxSize:i=1/0}={}){if(i!==1/0&&(!Number.isInteger(i)||i<1))throw new e.ArsenalValidationError(`memo: maxSize must be a positive integer or Infinity, got ${i}`);let a=new t.LruMap(i),o=(...e)=>r?r(...e):u(e),s=Object.assign((...e)=>{let t=o(...e);if(a.has(t)){let e=a.get(t);return a.set(t,e),e}let r=n(...e);return a.set(t,r),r},{clear:()=>a.clear(),invalidate:(...e)=>{a.delete(o(...e))}});return Object.defineProperty(s,"size",{get:()=>a.size}),s}exports.memo=d;
1
+ const e=require("../_common/_lruMap.cjs"),t=require("../errors.cjs");var n=`\0undefined\0`,r=`\0NaN\0`,i=`\0+Infinity\0`,a=`\0-Infinity\0`,o=`\0function\0`,s=0,c=new WeakMap;function l(e){let t=c.get(e);return t===void 0&&(t=s++,c.set(e,t)),t}var u=e=>{try{return JSON.stringify(e,(e,t)=>t===void 0?n:typeof t==`number`&&Number.isNaN(t)?r:t===1/0?i:t===-1/0?a:typeof t==`function`?`${o}${l(t)}`:t)}catch(e){let n=e instanceof Error&&e.message?` Reason: ${e.message}`:``;throw new t.ArsenalSerializationError(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${n}`,{cause:e})}};function d(t,{key:n,maxSize:r=1/0}={}){if(r!==1/0&&(!Number.isInteger(r)||r<1))throw RangeError(`memo: maxSize must be a positive integer or Infinity, got ${r}`);let i=new e.LruMap(r),a=(...e)=>n?n(...e):u(e),o=Object.assign((...e)=>{let n=a(...e);if(i.has(n)){let e=i.get(n);return i.set(n,e),e}let r=t(...e);return i.set(n,r),r},{clear:()=>i.clear(),invalidate:(...e)=>{i.delete(a(...e))}});return Object.defineProperty(o,"size",{get:()=>i.size}),o}exports.memo=d;
2
2
  //# sourceMappingURL=memo.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"memo.cjs","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError, ArsenalValidationError } from '../errors';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `stash.getOrSet` for async caching with TTL and stampede prevention.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {ArsenalValidationError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new ArsenalValidationError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"qEAgBA,IAAM,EAAqB,gBACrB,EAAe,UACf,EAA6B,gBAC7B,EAA6B,gBAC7B,EAAoB,eAEtB,EAAoB,EAClB,EAAc,IAAI,QAGxB,SAAS,EAAc,EAAgB,CACrC,IAAI,EAAK,EAAY,IAAI,CAAE,EAO3B,OALI,IAAO,IAAA,KACT,EAAK,IACL,EAAY,IAAI,EAAI,CAAE,GAGjB,CACT,CAEA,IAAM,EAAc,GAA4B,CAC9C,GAAI,CACF,OAAO,KAAK,UAAU,GAAO,EAAG,IAC1B,IAAU,IAAA,GAAkB,EAE5B,OAAO,GAAU,UAAY,OAAO,MAAM,CAAK,EAAU,EAEzD,IAAU,IAAiC,EAE3C,IAAU,KAAiC,EAE3C,OAAO,GAAU,WAAmB,GAAG,IAAoB,EAAc,CAAW,IAEjF,CACR,CACH,OAAS,EAAO,CAGd,MAAM,IAAI,EAAA,0BACR,yGAHa,aAAiB,OAAS,EAAM,QAAU,YAAY,EAAM,UAAY,KAIrF,CAAE,MAAO,CAAM,CACjB,CACF,CACF,EA8BA,SAAgB,EAAmB,EAAe,CAAE,MAAK,UAAU,KAA6B,CAAC,EAAgB,CAC/G,GAAI,IAAY,MAAa,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GACnE,MAAM,IAAI,EAAA,uBAAuB,6DAA6D,GAAS,EAGzG,IAAM,EAAQ,IAAI,EAAA,OAAmC,CAAO,EAEtD,GAAc,GAAG,IAAsC,EAAM,EAAI,GAAG,CAAI,EAAI,EAAW,CAAI,EAoB3F,EAAS,OAAO,QAlBJ,GAAG,IAAuC,CAC1D,IAAM,EAAW,EAAW,GAAG,CAAI,EAEnC,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFA,EAAM,IAAI,EAAU,CAAM,EAEnB,CACT,CAEA,IAAM,EAAQ,EAAG,GAAG,CAAI,EAIxB,OAFA,EAAM,IAAI,EAAU,CAAK,EAElB,CACT,EAEuC,CACrC,UAAa,EAAM,MAAM,EACzB,YAAa,GAAG,IAA8B,CAC5C,EAAM,OAAO,EAAW,GAAG,CAAI,CAAC,CAClC,CACF,CAAC,EAID,OAFA,OAAO,eAAe,EAAQ,OAAQ,CAAE,QAAW,EAAM,IAAK,CAAC,EAExD,CACT"}
1
+ {"version":3,"file":"memo.cjs","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"qEAgBA,IAAM,EAAqB,gBACrB,EAAe,UACf,EAA6B,gBAC7B,EAA6B,gBAC7B,EAAoB,eAEtB,EAAoB,EAClB,EAAc,IAAI,QAGxB,SAAS,EAAc,EAAgB,CACrC,IAAI,EAAK,EAAY,IAAI,CAAE,EAO3B,OALI,IAAO,IAAA,KACT,EAAK,IACL,EAAY,IAAI,EAAI,CAAE,GAGjB,CACT,CAEA,IAAM,EAAc,GAA4B,CAC9C,GAAI,CACF,OAAO,KAAK,UAAU,GAAO,EAAG,IAC1B,IAAU,IAAA,GAAkB,EAE5B,OAAO,GAAU,UAAY,OAAO,MAAM,CAAK,EAAU,EAEzD,IAAU,IAAiC,EAE3C,IAAU,KAAiC,EAE3C,OAAO,GAAU,WAAmB,GAAG,IAAoB,EAAc,CAAW,IAEjF,CACR,CACH,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,OAAS,EAAM,QAAU,YAAY,EAAM,UAAY,GAEvF,MAAM,IAAI,EAAA,0BACR,yGAAyG,IACzG,CAAE,MAAO,CAAM,CACjB,CACF,CACF,EA8BA,SAAgB,EAAmB,EAAe,CAAE,MAAK,UAAU,KAA6B,CAAC,EAAgB,CAC/G,GAAI,IAAY,MAAa,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GACnE,MAAU,WAAW,6DAA6D,GAAS,EAG7F,IAAM,EAAQ,IAAI,EAAA,OAAmC,CAAO,EAEtD,GAAc,GAAG,IAAsC,EAAM,EAAI,GAAG,CAAI,EAAI,EAAW,CAAI,EAoB3F,EAAS,OAAO,QAlBJ,GAAG,IAAuC,CAC1D,IAAM,EAAW,EAAW,GAAG,CAAI,EAEnC,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFA,EAAM,IAAI,EAAU,CAAM,EAEnB,CACT,CAEA,IAAM,EAAQ,EAAG,GAAG,CAAI,EAIxB,OAFA,EAAM,IAAI,EAAU,CAAK,EAElB,CACT,EAEuC,CACrC,UAAa,EAAM,MAAM,EACzB,YAAa,GAAG,IAA8B,CAC5C,EAAM,OAAO,EAAW,GAAG,CAAI,CAAC,CAClC,CACF,CAAC,EAID,OAFA,OAAO,eAAe,EAAQ,OAAQ,CAAE,QAAW,EAAM,IAAK,CAAC,EAExD,CACT"}
@@ -16,7 +16,7 @@ type SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;
16
16
  *
17
17
  * **Do not pass async functions.** `memo` caches the raw `Promise` object, not
18
18
  * the resolved value — subsequent calls return the same stale Promise. Use
19
- * `stash.getOrSet` for async caching with TTL and stampede prevention.
19
+ * `cache.getOrLoad` for async caching with TTL and load deduplication.
20
20
  *
21
21
  * @example
22
22
  * ```ts
@@ -33,7 +33,7 @@ type SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;
33
33
  * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.
34
34
  * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.
35
35
  *
36
- * @throws {ArsenalValidationError} If `maxSize` is not a positive integer or `Infinity`.
36
+ * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.
37
37
  */
38
38
  export declare function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize }?: MemoOptions<T>): Memoized<T>;
39
39
  export {};
@@ -1,37 +1,38 @@
1
- import { ArsenalSerializationError as e, ArsenalValidationError as t } from "../errors.js";
2
- import { LruMap as n } from "../_common/_lruMap.js";
1
+ import { LruMap as e } from "../_common/_lruMap.js";
2
+ import { ArsenalSerializationError as t } from "../errors.js";
3
3
  //#region src/cache/memo.ts
4
- var r = "\0undefined\0", i = "\0NaN\0", a = "\0+Infinity\0", o = "\0-Infinity\0", s = "\0function\0", c = 0, l = /* @__PURE__ */ new WeakMap();
5
- function u(e) {
6
- let t = l.get(e);
7
- return t === void 0 && (t = c++, l.set(e, t)), t;
4
+ var n = "\0undefined\0", r = "\0NaN\0", i = "\0+Infinity\0", a = "\0-Infinity\0", o = "\0function\0", s = 0, c = /* @__PURE__ */ new WeakMap();
5
+ function l(e) {
6
+ let t = c.get(e);
7
+ return t === void 0 && (t = s++, c.set(e, t)), t;
8
8
  }
9
- var d = (t) => {
9
+ var u = (e) => {
10
10
  try {
11
- return JSON.stringify(t, (e, t) => t === void 0 ? r : typeof t == "number" && Number.isNaN(t) ? i : t === Infinity ? a : t === -Infinity ? o : typeof t == "function" ? `${s}${u(t)}` : t);
12
- } catch (t) {
13
- throw new e(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${t instanceof Error && t.message ? ` Reason: ${t.message}` : ""}`, { cause: t });
11
+ return JSON.stringify(e, (e, t) => t === void 0 ? n : typeof t == "number" && Number.isNaN(t) ? r : t === Infinity ? i : t === -Infinity ? a : typeof t == "function" ? `${o}${l(t)}` : t);
12
+ } catch (e) {
13
+ let n = e instanceof Error && e.message ? ` Reason: ${e.message}` : "";
14
+ throw new t(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${n}`, { cause: e });
14
15
  }
15
16
  };
16
- function f(e, { key: r, maxSize: i = Infinity } = {}) {
17
- if (i !== Infinity && (!Number.isInteger(i) || i < 1)) throw new t(`memo: maxSize must be a positive integer or Infinity, got ${i}`);
18
- let a = new n(i), o = (...e) => r ? r(...e) : d(e), s = Object.assign((...t) => {
19
- let n = o(...t);
20
- if (a.has(n)) {
21
- let e = a.get(n);
22
- return a.set(n, e), e;
17
+ function d(t, { key: n, maxSize: r = Infinity } = {}) {
18
+ if (r !== Infinity && (!Number.isInteger(r) || r < 1)) throw RangeError(`memo: maxSize must be a positive integer or Infinity, got ${r}`);
19
+ let i = new e(r), a = (...e) => n ? n(...e) : u(e), o = Object.assign((...e) => {
20
+ let n = a(...e);
21
+ if (i.has(n)) {
22
+ let e = i.get(n);
23
+ return i.set(n, e), e;
23
24
  }
24
- let r = e(...t);
25
- return a.set(n, r), r;
25
+ let r = t(...e);
26
+ return i.set(n, r), r;
26
27
  }, {
27
- clear: () => a.clear(),
28
+ clear: () => i.clear(),
28
29
  invalidate: (...e) => {
29
- a.delete(o(...e));
30
+ i.delete(a(...e));
30
31
  }
31
32
  });
32
- return Object.defineProperty(s, "size", { get: () => a.size }), s;
33
+ return Object.defineProperty(o, "size", { get: () => i.size }), o;
33
34
  }
34
35
  //#endregion
35
- export { f as memo };
36
+ export { d as memo };
36
37
 
37
38
  //# sourceMappingURL=memo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"memo.js","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError, ArsenalValidationError } from '../errors';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `stash.getOrSet` for async caching with TTL and stampede prevention.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {ArsenalValidationError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new ArsenalValidationError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":";;;AAgBA,IAAM,IAAqB,iBACrB,IAAe,WACf,IAA6B,iBAC7B,IAA6B,iBAC7B,IAAoB,gBAEtB,IAAoB,GAClB,oBAAc,IAAI,QAAoB;AAG5C,SAAS,EAAc,GAAgB;CACrC,IAAI,IAAK,EAAY,IAAI,CAAE;CAO3B,OALI,MAAO,KAAA,MACT,IAAK,KACL,EAAY,IAAI,GAAI,CAAE,IAGjB;AACT;AAEA,IAAM,KAAc,MAA4B;CAC9C,IAAI;EACF,OAAO,KAAK,UAAU,IAAO,GAAG,MAC1B,MAAU,KAAA,IAAkB,IAE5B,OAAO,KAAU,YAAY,OAAO,MAAM,CAAK,IAAU,IAEzD,MAAU,WAAiC,IAE3C,MAAU,YAAiC,IAE3C,OAAO,KAAU,aAAmB,GAAG,IAAoB,EAAc,CAAW,MAEjF,CACR;CACH,SAAS,GAAO;EAGd,MAAM,IAAI,EACR,yGAHa,aAAiB,SAAS,EAAM,UAAU,YAAY,EAAM,YAAY,MAIrF,EAAE,OAAO,EAAM,CACjB;CACF;AACF;AA8BA,SAAgB,EAAmB,GAAe,EAAE,QAAK,aAAU,aAA6B,CAAC,GAAgB;CAC/G,IAAI,MAAY,aAAa,CAAC,OAAO,UAAU,CAAO,KAAK,IAAU,IACnE,MAAM,IAAI,EAAuB,6DAA6D,GAAS;CAGzG,IAAM,IAAQ,IAAI,EAAmC,CAAO,GAEtD,KAAc,GAAG,MAAsC,IAAM,EAAI,GAAG,CAAI,IAAI,EAAW,CAAI,GAoB3F,IAAS,OAAO,QAlBJ,GAAG,MAAuC;EAC1D,IAAM,IAAW,EAAW,GAAG,CAAI;EAEnC,IAAI,EAAM,IAAI,CAAQ,GAAG;GACvB,IAAM,IAAS,EAAM,IAAI,CAAQ;GAIjC,OAFA,EAAM,IAAI,GAAU,CAAM,GAEnB;EACT;EAEA,IAAM,IAAQ,EAAG,GAAG,CAAI;EAIxB,OAFA,EAAM,IAAI,GAAU,CAAK,GAElB;CACT,GAEuC;EACrC,aAAa,EAAM,MAAM;EACzB,aAAa,GAAG,MAA8B;GAC5C,EAAM,OAAO,EAAW,GAAG,CAAI,CAAC;EAClC;CACF,CAAC;CAID,OAFA,OAAO,eAAe,GAAQ,QAAQ,EAAE,WAAW,EAAM,KAAK,CAAC,GAExD;AACT"}
1
+ {"version":3,"file":"memo.js","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":";;;AAgBA,IAAM,IAAqB,iBACrB,IAAe,WACf,IAA6B,iBAC7B,IAA6B,iBAC7B,IAAoB,gBAEtB,IAAoB,GAClB,oBAAc,IAAI,QAAoB;AAG5C,SAAS,EAAc,GAAgB;CACrC,IAAI,IAAK,EAAY,IAAI,CAAE;CAO3B,OALI,MAAO,KAAA,MACT,IAAK,KACL,EAAY,IAAI,GAAI,CAAE,IAGjB;AACT;AAEA,IAAM,KAAc,MAA4B;CAC9C,IAAI;EACF,OAAO,KAAK,UAAU,IAAO,GAAG,MAC1B,MAAU,KAAA,IAAkB,IAE5B,OAAO,KAAU,YAAY,OAAO,MAAM,CAAK,IAAU,IAEzD,MAAU,WAAiC,IAE3C,MAAU,YAAiC,IAE3C,OAAO,KAAU,aAAmB,GAAG,IAAoB,EAAc,CAAW,MAEjF,CACR;CACH,SAAS,GAAO;EACd,IAAM,IAAS,aAAiB,SAAS,EAAM,UAAU,YAAY,EAAM,YAAY;EAEvF,MAAM,IAAI,EACR,yGAAyG,KACzG,EAAE,OAAO,EAAM,CACjB;CACF;AACF;AA8BA,SAAgB,EAAmB,GAAe,EAAE,QAAK,aAAU,aAA6B,CAAC,GAAgB;CAC/G,IAAI,MAAY,aAAa,CAAC,OAAO,UAAU,CAAO,KAAK,IAAU,IACnE,MAAU,WAAW,6DAA6D,GAAS;CAG7F,IAAM,IAAQ,IAAI,EAAmC,CAAO,GAEtD,KAAc,GAAG,MAAsC,IAAM,EAAI,GAAG,CAAI,IAAI,EAAW,CAAI,GAoB3F,IAAS,OAAO,QAlBJ,GAAG,MAAuC;EAC1D,IAAM,IAAW,EAAW,GAAG,CAAI;EAEnC,IAAI,EAAM,IAAI,CAAQ,GAAG;GACvB,IAAM,IAAS,EAAM,IAAI,CAAQ;GAIjC,OAFA,EAAM,IAAI,GAAU,CAAM,GAEnB;EACT;EAEA,IAAM,IAAQ,EAAG,GAAG,CAAI;EAIxB,OAFA,EAAM,IAAI,GAAU,CAAK,GAElB;CACT,GAEuC;EACrC,aAAa,EAAM,MAAM;EACzB,aAAa,GAAG,MAA8B;GAC5C,EAAM,OAAO,EAAW,GAAG,CAAI,CAAC;EAClC;CACF,CAAC;CAID,OAFA,OAAO,eAAe,GAAQ,QAAQ,EAAE,WAAW,EAAM,KAAK,CAAC,GAExD;AACT"}
package/dist/errors.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},t=class extends e{},n=class extends e{};exports.ArsenalError=e,exports.ArsenalSerializationError=n,exports.ArsenalValidationError=t;
1
+ var e=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},t=class extends e{};exports.ArsenalError=e,exports.ArsenalSerializationError=t;
2
2
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is ArsenalError {\n return err instanceof ArsenalError;\n }\n}\n\n/**\n * Thrown when a function argument or option is invalid — wrong type, out of range, or an\n * otherwise-unusable value (e.g. a negative `concurrency`, a non-finite `range` bound, an\n * oversized `similarity` input).\n */\nexport class ArsenalValidationError extends ArsenalError {}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"AACA,IAAa,EAAb,MAAa,UAAqB,KAAM,CACtC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,IAAI,OAAO,KACvB,OAAO,eAAe,KAAM,IAAI,OAAO,SAAS,CAClD,CAEA,OAAO,GAAG,EAAmC,CAC3C,OAAO,aAAe,CACxB,CACF,EAOa,EAAb,cAA4C,CAAa,CAAC,EAO7C,EAAb,cAA+C,CAAa,CAAC"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is ArsenalError {\n return err instanceof ArsenalError;\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"AACA,IAAa,EAAb,MAAa,UAAqB,KAAM,CACtC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAEA,OAAO,GAAG,EAAmC,CAC3C,OAAO,aAAe,CACxB,CACF,EAOa,EAAb,cAA+C,CAAa,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -3,13 +3,6 @@ export declare class ArsenalError extends Error {
3
3
  constructor(message: string, opts?: ErrorOptions);
4
4
  static is(err: unknown): err is ArsenalError;
5
5
  }
6
- /**
7
- * Thrown when a function argument or option is invalid — wrong type, out of range, or an
8
- * otherwise-unusable value (e.g. a negative `concurrency`, a non-finite `range` bound, an
9
- * oversized `similarity` input).
10
- */
11
- export declare class ArsenalValidationError extends ArsenalError {
12
- }
13
6
  /**
14
7
  * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default
15
8
  * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;IAMhD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,YAAY;CAG7C;AAED;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,YAAY;CAAG;AAE3D;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,YAAY;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;IAMhD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,YAAY;CAG7C;AAED;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,YAAY;CAAG"}
package/dist/errors.js CHANGED
@@ -6,8 +6,8 @@ var e = class e extends Error {
6
6
  static is(t) {
7
7
  return t instanceof e;
8
8
  }
9
- }, t = class extends e {}, n = class extends e {};
9
+ }, t = class extends e {};
10
10
  //#endregion
11
- export { e as ArsenalError, n as ArsenalSerializationError, t as ArsenalValidationError };
11
+ export { e as ArsenalError, t as ArsenalSerializationError };
12
12
 
13
13
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is ArsenalError {\n return err instanceof ArsenalError;\n }\n}\n\n/**\n * Thrown when a function argument or option is invalid — wrong type, out of range, or an\n * otherwise-unusable value (e.g. a negative `concurrency`, a non-finite `range` bound, an\n * oversized `similarity` input).\n */\nexport class ArsenalValidationError extends ArsenalError {}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":";AACA,IAAa,IAAb,MAAa,UAAqB,MAAM;CACtC,YAAY,GAAiB,GAAqB;EAGhD,AAFA,MAAM,GAAS,CAAI,GACnB,KAAK,OAAO,IAAI,OAAO,MACvB,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS;CAClD;CAEA,OAAO,GAAG,GAAmC;EAC3C,OAAO,aAAe;CACxB;AACF,GAOa,IAAb,cAA4C,EAAa,CAAC,GAO7C,IAAb,cAA+C,EAAa,CAAC"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static is(err: unknown): err is ArsenalError {\n return err instanceof ArsenalError;\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":";AACA,IAAa,IAAb,MAAa,UAAqB,MAAM;CACtC,YAAY,GAAiB,GAAqB;EAGhD,AAFA,MAAM,GAAS,CAAI,GACnB,KAAK,OAAO,WAAW,MACvB,OAAO,eAAe,MAAM,WAAW,SAAS;CAClD;CAEA,OAAO,GAAG,GAAmC;EAC3C,OAAO,aAAe;CACxB;AACF,GAOa,IAAb,cAA+C,EAAa,CAAC"}
@@ -1,2 +1,2 @@
1
- const e=require("../_dev.cjs");function t(t,n=300,r={leading:!1,trailing:!0}){let i=r.leading??!1,a=r.trailing??!0;!i&&!a&&e.warn("debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.");let o,s,c,l=!1,u=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},d=()=>{if(u(),l=!1,!s)return;let e=s;return s=void 0,c=t(...e),c};return Object.assign((...e)=>(s=e,i&&!l&&(l=!0,c=t(...e),s=void 0,!a)?(o=setTimeout(()=>{o=void 0,l=!1},n),c):i&&!a&&l?c:(u(),o=setTimeout(d,n),c)),{cancel:()=>{u(),s=void 0,l=!1},flush:()=>d(),pending:()=>o!==void 0})}exports.debounce=t;
1
+ require("../_dev.cjs");function e(e,t=300,n={leading:!1,trailing:!0}){let r=n.leading??!1,i=n.trailing??!0,a,o,s,c=!1,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=()=>{if(l(),c=!1,!o)return;let t=o;return o=void 0,s=e(...t),s};return Object.assign((...n)=>(o=n,r&&!c&&(c=!0,s=e(...n),o=void 0,!i)?(a=setTimeout(()=>{a=void 0,c=!1},t),s):r&&!i&&c?s:(l(),a=setTimeout(u,t),s)),{cancel:()=>{l(),o=void 0,c=!1},flush:()=>u(),pending:()=>a!==void 0})}exports.debounce=e;
2
2
  //# sourceMappingURL=debounce.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.cjs","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"+BAkCA,SAAgB,EACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAO,SAAU,EAAK,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAEjC,CAAC,GAAW,CAAC,GACf,EAAA,KAAK,iGAAiG,EAGxG,IAAI,EACA,EACA,EACA,EAAe,GAEb,MAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,MAAuB,CAI3B,GAHA,EAAW,EACX,EAAe,GAEX,CAAC,EAAU,OAEf,IAAM,EAAO,EAKb,MAHA,GAAW,IAAA,GACX,EAAa,EAAG,GAAG,CAAI,EAEhB,CACT,EAEA,OAAO,OAAO,QACX,GAAG,KACF,EAAW,EAEP,GAAW,CAAC,IACd,EAAe,GACf,EAAa,EAAG,GAAG,CAAI,EAIvB,EAAW,IAAA,GAEP,CAAC,IAEH,EAAU,eAAiB,CACzB,EAAU,IAAA,GACV,EAAe,EACjB,EAAG,CAAK,EAED,GAKP,GAAW,CAAC,GAAY,EAAqB,GAEjD,EAAW,EACX,EAAU,WAAW,EAAgB,CAAK,EAEnC,IAET,CACE,WAAc,CACZ,EAAW,EACX,EAAW,IAAA,GACX,EAAe,EACjB,EACA,UAAwC,EAAe,EACvD,YAAe,IAAY,IAAA,EAC7B,CACF,CACF"}
1
+ {"version":3,"file":"debounce.cjs","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"uBAkCA,SAAgB,EACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAO,SAAU,EAAK,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAMjC,EACA,EACA,EACA,EAAe,GAEb,MAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,MAAuB,CAI3B,GAHA,EAAW,EACX,EAAe,GAEX,CAAC,EAAU,OAEf,IAAM,EAAO,EAKb,MAHA,GAAW,IAAA,GACX,EAAa,EAAG,GAAG,CAAI,EAEhB,CACT,EAEA,OAAO,OAAO,QACX,GAAG,KACF,EAAW,EAEP,GAAW,CAAC,IACd,EAAe,GACf,EAAa,EAAG,GAAG,CAAI,EAIvB,EAAW,IAAA,GAEP,CAAC,IAEH,EAAU,eAAiB,CACzB,EAAU,IAAA,GACV,EAAe,EACjB,EAAG,CAAK,EAED,GAKP,GAAW,CAAC,GAAY,EAAqB,GAEjD,EAAW,EACX,EAAU,WAAW,EAAgB,CAAK,EAEnC,IAET,CACE,WAAc,CACZ,EAAW,EACX,EAAW,IAAA,GACX,EAAe,EACjB,EACA,UAAwC,EAAe,EACvD,YAAe,IAAY,IAAA,EAC7B,CACF,CACF"}
@@ -1,29 +1,27 @@
1
- import { warn as e } from "../_dev.js";
1
+ import "../_dev.js";
2
2
  //#region src/function/debounce.ts
3
- function t(t, n = 300, r = {
3
+ function e(e, t = 300, n = {
4
4
  leading: !1,
5
5
  trailing: !0
6
6
  }) {
7
- let i = r.leading ?? !1, a = r.trailing ?? !0;
8
- !i && !a && e("debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.");
9
- let o, s, c, l = !1, u = () => {
10
- o !== void 0 && (clearTimeout(o), o = void 0);
11
- }, d = () => {
12
- if (u(), l = !1, !s) return;
13
- let e = s;
14
- return s = void 0, c = t(...e), c;
7
+ let r = n.leading ?? !1, i = n.trailing ?? !0, a, o, s, c = !1, l = () => {
8
+ a !== void 0 && (clearTimeout(a), a = void 0);
9
+ }, u = () => {
10
+ if (l(), c = !1, !o) return;
11
+ let t = o;
12
+ return o = void 0, s = e(...t), s;
15
13
  };
16
- return Object.assign((...e) => (s = e, i && !l && (l = !0, c = t(...e), s = void 0, !a) ? (o = setTimeout(() => {
17
- o = void 0, l = !1;
18
- }, n), c) : i && !a && l ? c : (u(), o = setTimeout(d, n), c)), {
14
+ return Object.assign((...n) => (o = n, r && !c && (c = !0, s = e(...n), o = void 0, !i) ? (a = setTimeout(() => {
15
+ a = void 0, c = !1;
16
+ }, t), s) : r && !i && c ? s : (l(), a = setTimeout(u, t), s)), {
19
17
  cancel: () => {
20
- u(), s = void 0, l = !1;
18
+ l(), o = void 0, c = !1;
21
19
  },
22
- flush: () => d(),
23
- pending: () => o !== void 0
20
+ flush: () => u(),
21
+ pending: () => a !== void 0
24
22
  });
25
23
  }
26
24
  //#endregion
27
- export { t as debounce };
25
+ export { e as debounce };
28
26
 
29
27
  //# sourceMappingURL=debounce.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debounce.js","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":";;AAkCA,SAAgB,EACd,GACA,IAAQ,KACR,IAA2B;CAAE,SAAS;CAAO,UAAU;AAAK,GAC9C;CACd,IAAM,IAAU,EAAQ,WAAW,IAC7B,IAAW,EAAQ,YAAY;CAErC,AAAI,CAAC,KAAW,CAAC,KACf,EAAK,iGAAiG;CAGxG,IAAI,GACA,GACA,GACA,IAAe,IAEb,UAAmB;EACvB,AAAI,MAAY,KAAA,MACd,aAAa,CAAO,GACpB,IAAU,KAAA;CAEd,GAEM,UAAuB;EAI3B,IAHA,EAAW,GACX,IAAe,IAEX,CAAC,GAAU;EAEf,IAAM,IAAO;EAKb,OAHA,IAAW,KAAA,GACX,IAAa,EAAG,GAAG,CAAI,GAEhB;CACT;CAEA,OAAO,OAAO,QACX,GAAG,OACF,IAAW,GAEP,KAAW,CAAC,MACd,IAAe,IACf,IAAa,EAAG,GAAG,CAAI,GAIvB,IAAW,KAAA,GAEP,CAAC,MAEH,IAAU,iBAAiB;EAEzB,AADA,IAAU,KAAA,GACV,IAAe;CACjB,GAAG,CAAK,GAED,KAKP,KAAW,CAAC,KAAY,IAAqB,KAEjD,EAAW,GACX,IAAU,WAAW,GAAgB,CAAK,GAEnC,KAET;EACE,cAAc;GAGZ,AAFA,EAAW,GACX,IAAW,KAAA,GACX,IAAe;EACjB;EACA,aAAwC,EAAe;EACvD,eAAe,MAAY,KAAA;CAC7B,CACF;AACF"}
1
+ {"version":3,"file":"debounce.js","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":";;AAkCA,SAAgB,EACd,GACA,IAAQ,KACR,IAA2B;CAAE,SAAS;CAAO,UAAU;AAAK,GAC9C;CACd,IAAM,IAAU,EAAQ,WAAW,IAC7B,IAAW,EAAQ,YAAY,IAMjC,GACA,GACA,GACA,IAAe,IAEb,UAAmB;EACvB,AAAI,MAAY,KAAA,MACd,aAAa,CAAO,GACpB,IAAU,KAAA;CAEd,GAEM,UAAuB;EAI3B,IAHA,EAAW,GACX,IAAe,IAEX,CAAC,GAAU;EAEf,IAAM,IAAO;EAKb,OAHA,IAAW,KAAA,GACX,IAAa,EAAG,GAAG,CAAI,GAEhB;CACT;CAEA,OAAO,OAAO,QACX,GAAG,OACF,IAAW,GAEP,KAAW,CAAC,MACd,IAAe,IACf,IAAa,EAAG,GAAG,CAAI,GAIvB,IAAW,KAAA,GAEP,CAAC,MAEH,IAAU,iBAAiB;EAEzB,AADA,IAAU,KAAA,GACV,IAAe;CACjB,GAAG,CAAK,GAED,KAKP,KAAW,CAAC,KAAY,IAAqB,KAEjD,EAAW,GACX,IAAU,WAAW,GAAgB,CAAK,GAEnC,KAET;EACE,cAAc;GAGZ,AAFA,EAAW,GACX,IAAW,KAAA,GACX,IAAe;EACjB;EACA,aAAwC,EAAe;EACvD,eAAe,MAAY,KAAA;CAC7B,CACF;AACF"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./assert.cjs"),t=require("./debounce.cjs"),n=require("./once.cjs"),r=require("./pipe.cjs"),i=require("./runAll.cjs"),a=require("./tap.cjs"),o=require("./throttle.cjs");exports.assert=e.assert,exports.debounce=t.debounce,exports.once=n.once,exports.pipe=r.pipe,exports.runAll=i.runAll,exports.tap=a.tap,exports.throttle=o.throttle;
@@ -1,7 +1,5 @@
1
1
  export * from './assert';
2
- export * from './constant';
3
2
  export * from './debounce';
4
- export * from './identity';
5
3
  export * from './once';
6
4
  export * from './pipe';
7
5
  export * from './runAll';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { assert as e } from "./assert.js";
2
+ import { debounce as t } from "./debounce.js";
3
+ import { once as n } from "./once.js";
4
+ import { pipe as r } from "./pipe.js";
5
+ import { runAll as i } from "./runAll.js";
6
+ import { tap as a } from "./tap.js";
7
+ import { throttle as o } from "./throttle.js";
8
+ export { e as assert, t as debounce, n as once, r as pipe, i as runAll, a as tap, o as throttle };
@@ -1,2 +1,2 @@
1
- function e(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>t(e),t(...e))}exports.pipe=e;
1
+ function e(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>Reflect.apply(t,void 0,[e]),Reflect.apply(t,void 0,e))}exports.pipe=e;
2
2
  //# sourceMappingURL=pipe.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.cjs","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: unknown[]) => restFns.reduce((prev: unknown, fn) => fn(prev), firstFn!(...args));\n}\n"],"mappings":"AAoCA,SAAgB,EAAK,GAAG,EAAe,CACrC,GAAI,EAAI,SAAW,EAAG,MAAW,IAAY,EAE7C,GAAM,CAAC,EAAS,GAAG,GAAW,EAE9B,OAAQ,GAAG,IAAoB,EAAQ,QAAQ,EAAe,IAAO,EAAG,CAAI,EAAG,EAAS,GAAG,CAAI,CAAC,CAClG"}
1
+ {"version":3,"file":"pipe.cjs","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce(\n (prev: unknown, fn) => Reflect.apply(fn, undefined, [prev]),\n Reflect.apply(firstFn!, undefined, args),\n );\n}\n"],"mappings":"AAoCA,SAAgB,EAAK,GAAG,EAAe,CACrC,GAAI,EAAI,SAAW,EAAG,MAAW,IAAY,EAE7C,GAAM,CAAC,EAAS,GAAG,GAAW,EAE9B,OAAQ,GAAG,IACT,EAAQ,QACL,EAAe,IAAO,QAAQ,MAAM,EAAI,IAAA,GAAW,CAAC,CAAI,CAAC,EAC1D,QAAQ,MAAM,EAAU,IAAA,GAAW,CAAI,CACzC,CACJ"}
@@ -2,7 +2,7 @@
2
2
  function e(...e) {
3
3
  if (e.length === 0) return (e) => e;
4
4
  let [t, ...n] = e;
5
- return (...e) => n.reduce((e, t) => t(e), t(...e));
5
+ return (...e) => n.reduce((e, t) => Reflect.apply(t, void 0, [e]), Reflect.apply(t, void 0, e));
6
6
  }
7
7
  //#endregion
8
8
  export { e as pipe };
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.js","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: unknown[]) => restFns.reduce((prev: unknown, fn) => fn(prev), firstFn!(...args));\n}\n"],"mappings":";AAoCA,SAAgB,EAAK,GAAG,GAAe;CACrC,IAAI,EAAI,WAAW,GAAG,QAAW,MAAY;CAE7C,IAAM,CAAC,GAAS,GAAG,KAAW;CAE9B,QAAQ,GAAG,MAAoB,EAAQ,QAAQ,GAAe,MAAO,EAAG,CAAI,GAAG,EAAS,GAAG,CAAI,CAAC;AAClG"}
1
+ {"version":3,"file":"pipe.js","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce(\n (prev: unknown, fn) => Reflect.apply(fn, undefined, [prev]),\n Reflect.apply(firstFn!, undefined, args),\n );\n}\n"],"mappings":";AAoCA,SAAgB,EAAK,GAAG,GAAe;CACrC,IAAI,EAAI,WAAW,GAAG,QAAW,MAAY;CAE7C,IAAM,CAAC,GAAS,GAAG,KAAW;CAE9B,QAAQ,GAAG,MACT,EAAQ,QACL,GAAe,MAAO,QAAQ,MAAM,GAAI,KAAA,GAAW,CAAC,CAAI,CAAC,GAC1D,QAAQ,MAAM,GAAU,KAAA,GAAW,CAAI,CACzC;AACJ"}
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./isEqual.cjs"),t=require("./combinators.cjs"),n=require("./isAbortError.cjs"),r=require("./isDate.cjs"),i=require("./isDefined.cjs"),a=require("./isNil.cjs"),o=require("./isPlainObject.cjs"),s=require("./isEmpty.cjs"),c=require("./isError.cjs"),l=require("./isFunction.cjs"),u=require("./isMatch.cjs"),d=require("./isNumber.cjs"),f=require("./isPrimitive.cjs"),p=require("./isPromise.cjs"),m=require("./isRegex.cjs"),h=require("./shallowEqual.cjs");exports.allOf=t.allOf,exports.anyOf=t.anyOf,exports.isAbortError=n.isAbortError,exports.isDate=r.isDate,exports.isDefined=i.isDefined,exports.isEmpty=s.isEmpty,exports.isEqual=e.isEqual,exports.isError=c.isError,exports.isFunction=l.isFunction,exports.isMatch=u.isMatch,exports.isNil=a.isNil,exports.isNumber=d.isNumber,exports.isPlainObject=o.isPlainObject,exports.isPrimitive=f.isPrimitive,exports.isPromise=p.isPromise,exports.isRegex=m.isRegex,exports.noneOf=t.noneOf,exports.not=t.not,exports.shallowEqual=h.shallowEqual;
@@ -1,7 +1,5 @@
1
1
  export * from './combinators';
2
2
  export * from './isAbortError';
3
- export * from './isArray';
4
- export * from './isBoolean';
5
3
  export * from './isDate';
6
4
  export * from './isDefined';
7
5
  export * from './isEmpty';
@@ -15,6 +13,5 @@ export * from './isPlainObject';
15
13
  export * from './isPrimitive';
16
14
  export * from './isPromise';
17
15
  export * from './isRegex';
18
- export * from './isString';
19
16
  export * from './shallowEqual';
20
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { isEqual as e } from "./isEqual.js";
2
+ import { allOf as t, anyOf as n, noneOf as r, not as i } from "./combinators.js";
3
+ import { isAbortError as a } from "./isAbortError.js";
4
+ import { isDate as o } from "./isDate.js";
5
+ import { isDefined as s } from "./isDefined.js";
6
+ import { isNil as c } from "./isNil.js";
7
+ import { isPlainObject as l } from "./isPlainObject.js";
8
+ import { isEmpty as u } from "./isEmpty.js";
9
+ import { isError as d } from "./isError.js";
10
+ import { isFunction as f } from "./isFunction.js";
11
+ import { isMatch as p } from "./isMatch.js";
12
+ import { isNumber as m } from "./isNumber.js";
13
+ import { isPrimitive as h } from "./isPrimitive.js";
14
+ import { isPromise as g } from "./isPromise.js";
15
+ import { isRegex as _ } from "./isRegex.js";
16
+ import { shallowEqual as v } from "./shallowEqual.js";
17
+ export { t as allOf, n as anyOf, a as isAbortError, o as isDate, s as isDefined, u as isEmpty, e as isEqual, d as isError, f as isFunction, p as isMatch, c as isNil, m as isNumber, l as isPlainObject, h as isPrimitive, g as isPromise, _ as isRegex, r as noneOf, i as not, v as shallowEqual };
@@ -1 +1 @@
1
- {"version":3,"file":"isEqual.cjs","names":[],"sources":["../../src/guards/isEqual.ts"],"sourcesContent":["/**\n * Recursively compares two values for deep equality.\n * Supports plain objects, arrays, `Date`, `Map`, `Set`, `RegExp`, and circular references.\n *\n * Uses `===` for the primitive comparison, so `isEqual(NaN, NaN)` is `false` and\n * `isEqual(0, -0)` is `true` — the opposite of `shallowEqual`, which uses `Object.is` and\n * treats `NaN` as equal to itself and `-0` as distinct from `0`.\n *\n * For one-level-deep reference equality, use `shallowEqual` instead.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Map([['k', 1]]), new Map([['k', 1]])); // true\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns `true` if the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n\n return a.every((item, idx) => safeIsEqual(item, b[idx], visited));\n }\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Map comparison\n if (a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n\n for (const [k, v] of a) {\n if (!b.has(k) || !safeIsEqual(v, b.get(k), visited)) return false;\n }\n\n return true;\n }\n\n // Set comparison — fast path for primitive values, deep for objects\n if (a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n\n const bItems = [...b];\n\n for (const v of a) {\n // O(1) path for primitives — avoid the O(n) .some() scan\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null || v === undefined) {\n if (!b.has(v)) return false;\n } else if (!bItems.some((bv) => safeIsEqual(v, bv, visited))) {\n return false;\n }\n }\n\n return true;\n }\n\n // RegExp comparison\n if (a instanceof RegExp || b instanceof RegExp) {\n return a instanceof RegExp && b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n }\n\n // Cross-type guards: Map/Set vs plain objects are never equal\n if (a instanceof Map || b instanceof Map) return false;\n\n if (a instanceof Set || b instanceof Set) return false;\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n"],"mappings":"AAsBA,SAAgB,EAAQ,EAAY,EAAqB,CACvD,OAAO,EAAY,EAAG,EAAG,IAAI,OAAS,CACxC,CAEA,SAAS,EAAY,EAAY,EAAY,EAA2C,CAEtF,GAAI,IAAM,EAAG,MAAO,GAGpB,GAAI,GAAK,MAAQ,GAAK,MAAQ,OAAO,GAAM,OAAO,GAAK,OAAO,GAAM,UAAY,OAAO,GAAM,SAAU,MAAO,GAI9G,GAAI,EAAQ,IAAI,CAAW,EACzB,OAAO,EAAQ,IAAI,CAAW,IAAM,EAMtC,GAHA,EAAQ,IAAI,EAAa,CAAW,EAGhC,MAAM,QAAQ,CAAC,GAAK,MAAM,QAAQ,CAAC,EAGrC,MAFI,CAAC,MAAM,QAAQ,CAAC,GAAK,CAAC,MAAM,QAAQ,CAAC,GAAK,EAAE,SAAW,EAAE,OAAe,GAErE,EAAE,OAAO,EAAM,IAAQ,EAAY,EAAM,EAAE,GAAM,CAAO,CAAC,EAIlE,GAAI,aAAa,MAAQ,aAAa,KACpC,OAAO,EAAE,QAAQ,IAAM,EAAE,QAAQ,EAInC,GAAI,aAAa,KAAO,aAAa,IAAK,CACxC,GAAI,EAAE,OAAS,EAAE,KAAM,MAAO,GAE9B,IAAK,GAAM,CAAC,EAAG,KAAM,EACnB,GAAI,CAAC,EAAE,IAAI,CAAC,GAAK,CAAC,EAAY,EAAG,EAAE,IAAI,CAAC,EAAG,CAAO,EAAG,MAAO,GAG9D,MAAO,EACT,CAGA,GAAI,aAAa,KAAO,aAAa,IAAK,CACxC,GAAI,EAAE,OAAS,EAAE,KAAM,MAAO,GAE9B,IAAM,EAAS,CAAC,GAAG,CAAC,EAEpB,IAAK,IAAM,KAAK,EAEd,GAAI,OAAO,GAAM,UAAY,OAAO,GAAM,UAAY,OAAO,GAAM,WAAa,GAAM,SAChF,CAAC,EAAE,IAAI,CAAC,EAAG,MAAO,EAAA,MACjB,GAAI,CAAC,EAAO,KAAM,GAAO,EAAY,EAAG,EAAI,CAAO,CAAC,EACzD,MAAO,GAIX,MAAO,EACT,CAGA,GAAI,aAAa,QAAU,aAAa,OACtC,OAAO,aAAa,QAAU,aAAa,QAAU,EAAE,SAAW,EAAE,QAAU,EAAE,QAAU,EAAE,MAM9F,GAFI,aAAa,KAAO,aAAa,KAEjC,aAAa,KAAO,aAAa,IAAK,MAAO,GAGjD,IAAM,EAAQ,OAAO,KAAK,CAAC,EACrB,EAAQ,OAAO,KAAK,CAAC,EAE3B,GAAI,EAAM,SAAW,EAAM,OAAQ,MAAO,GAE1C,IAAK,IAAM,KAAO,EAChB,GACE,CAAC,OAAO,OAAO,EAAG,CAAG,GACrB,CAAC,EAAa,EAA8B,GAAO,EAA8B,GAAM,CAAO,EAE9F,MAAO,GAGX,MAAO,EACT"}
1
+ {"version":3,"file":"isEqual.cjs","names":[],"sources":["../../src/guards/isEqual.ts"],"sourcesContent":["/**\n * Recursively compares two values for deep equality.\n * Supports plain objects, arrays, `Date`, `Map`, `Set`, `RegExp`, and circular references.\n *\n * Uses `===` for the primitive comparison, so `isEqual(NaN, NaN)` is `false` and\n * `isEqual(0, -0)` is `true` — the opposite of `shallowEqual`, which uses `Object.is` and\n * treats `NaN` as equal to itself and `-0` as distinct from `0`.\n *\n * For one-level-deep reference equality, use `shallowEqual` instead.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Map([['k', 1]]), new Map([['k', 1]])); // true\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns `true` if the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n\n return a.every((item, idx) => safeIsEqual(item, b[idx], visited));\n }\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Map comparison\n if (a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n\n for (const [k, v] of a) {\n if (!b.has(k) || !safeIsEqual(v, b.get(k), visited)) return false;\n }\n\n return true;\n }\n\n // Set comparison — fast path for primitive values, deep for objects\n if (a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n\n const bItems = [...b];\n\n for (const v of a) {\n // O(1) path for primitives — avoid the O(n) .some() scan\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null || v === undefined) {\n if (!b.has(v)) return false;\n } else if (!bItems.some((bv) => safeIsEqual(v, bv, visited))) {\n return false;\n }\n }\n\n return true;\n }\n\n // RegExp comparison\n if (a instanceof RegExp || b instanceof RegExp) {\n return a instanceof RegExp && b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n }\n\n // Cross-type guards: Map/Set vs plain objects are never equal\n if (a instanceof Map || b instanceof Map) return false;\n\n if (a instanceof Set || b instanceof Set) return false;\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n"],"mappings":"AAsBA,SAAgB,EAAQ,EAAY,EAAqB,CACvD,OAAO,EAAY,EAAG,EAAG,IAAI,OAAS,CACxC,CAEA,SAAS,EAAY,EAAY,EAAY,EAA2C,CAEtF,GAAI,IAAM,EAAG,MAAO,GAGpB,GAAI,GAAK,MAAQ,GAAK,MAAQ,OAAO,GAAM,OAAO,GAAK,OAAO,GAAM,UAAY,OAAO,GAAM,SAAU,MAAO,GAI9G,GAAI,EAAQ,IAAI,CAAW,EACzB,OAAO,EAAQ,IAAI,CAAW,IAAM,EAMtC,GAHA,EAAQ,IAAI,EAAa,CAAW,EAGhC,MAAM,QAAQ,CAAC,GAAK,MAAM,QAAQ,CAAC,EAGrC,MAFI,CAAC,MAAM,QAAQ,CAAC,GAAK,CAAC,MAAM,QAAQ,CAAC,GAAK,EAAE,SAAW,EAAE,OAAe,GAErE,EAAE,OAAO,EAAM,IAAQ,EAAY,EAAM,EAAE,GAAM,CAAO,CAAC,EAIlE,GAAI,aAAa,MAAQ,aAAa,KACpC,OAAO,EAAE,QAAQ,IAAM,EAAE,QAAQ,EAInC,GAAI,aAAa,KAAO,aAAa,IAAK,CACxC,GAAI,EAAE,OAAS,EAAE,KAAM,MAAO,GAE9B,IAAK,GAAM,CAAC,EAAG,KAAM,EACnB,GAAI,CAAC,EAAE,IAAI,CAAC,GAAK,CAAC,EAAY,EAAG,EAAE,IAAI,CAAC,EAAG,CAAO,EAAG,MAAO,GAG9D,MAAO,EACT,CAGA,GAAI,aAAa,KAAO,aAAa,IAAK,CACxC,GAAI,EAAE,OAAS,EAAE,KAAM,MAAO,GAE9B,IAAM,EAAS,CAAC,GAAG,CAAC,EAEpB,IAAK,IAAM,KAAK,EAEd,GAAI,OAAO,GAAM,UAAY,OAAO,GAAM,UAAY,OAAO,GAAM,WAAa,GAAM,KAChF,IAAA,CAAC,EAAE,IAAI,CAAC,EAAG,MAAO,EAAA,MACjB,GAAI,CAAC,EAAO,KAAM,GAAO,EAAY,EAAG,EAAI,CAAO,CAAC,EACzD,MAAO,GAIX,MAAO,EACT,CAGA,GAAI,aAAa,QAAU,aAAa,OACtC,OAAO,aAAa,QAAU,aAAa,QAAU,EAAE,SAAW,EAAE,QAAU,EAAE,QAAU,EAAE,MAM9F,GAFI,aAAa,KAAO,aAAa,KAEjC,aAAa,KAAO,aAAa,IAAK,MAAO,GAGjD,IAAM,EAAQ,OAAO,KAAK,CAAC,EACrB,EAAQ,OAAO,KAAK,CAAC,EAE3B,GAAI,EAAM,SAAW,EAAM,OAAQ,MAAO,GAE1C,IAAK,IAAM,KAAO,EAChB,GACE,CAAC,OAAO,OAAO,EAAG,CAAG,GACrB,CAAC,EAAa,EAA8B,GAAO,EAA8B,GAAM,CAAO,EAE9F,MAAO,GAGX,MAAO,EACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"isEqual.js","names":[],"sources":["../../src/guards/isEqual.ts"],"sourcesContent":["/**\n * Recursively compares two values for deep equality.\n * Supports plain objects, arrays, `Date`, `Map`, `Set`, `RegExp`, and circular references.\n *\n * Uses `===` for the primitive comparison, so `isEqual(NaN, NaN)` is `false` and\n * `isEqual(0, -0)` is `true` — the opposite of `shallowEqual`, which uses `Object.is` and\n * treats `NaN` as equal to itself and `-0` as distinct from `0`.\n *\n * For one-level-deep reference equality, use `shallowEqual` instead.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Map([['k', 1]]), new Map([['k', 1]])); // true\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns `true` if the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n\n return a.every((item, idx) => safeIsEqual(item, b[idx], visited));\n }\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Map comparison\n if (a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n\n for (const [k, v] of a) {\n if (!b.has(k) || !safeIsEqual(v, b.get(k), visited)) return false;\n }\n\n return true;\n }\n\n // Set comparison — fast path for primitive values, deep for objects\n if (a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n\n const bItems = [...b];\n\n for (const v of a) {\n // O(1) path for primitives — avoid the O(n) .some() scan\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null || v === undefined) {\n if (!b.has(v)) return false;\n } else if (!bItems.some((bv) => safeIsEqual(v, bv, visited))) {\n return false;\n }\n }\n\n return true;\n }\n\n // RegExp comparison\n if (a instanceof RegExp || b instanceof RegExp) {\n return a instanceof RegExp && b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n }\n\n // Cross-type guards: Map/Set vs plain objects are never equal\n if (a instanceof Map || b instanceof Map) return false;\n\n if (a instanceof Set || b instanceof Set) return false;\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n"],"mappings":";AAsBA,SAAgB,EAAQ,GAAY,GAAqB;CACvD,OAAO,EAAY,GAAG,mBAAG,IAAI,QAAQ,CAAC;AACxC;AAEA,SAAS,EAAY,GAAY,GAAY,GAA2C;CAEtF,IAAI,MAAM,GAAG,OAAO;CAGpB,IAAI,KAAK,QAAQ,KAAK,QAAQ,OAAO,KAAM,OAAO,KAAK,OAAO,KAAM,YAAY,OAAO,KAAM,UAAU,OAAO;CAI9G,IAAI,EAAQ,IAAI,CAAW,GACzB,OAAO,EAAQ,IAAI,CAAW,MAAM;CAMtC,IAHA,EAAQ,IAAI,GAAa,CAAW,GAGhC,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAGrC,OAFI,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,SAAe,KAErE,EAAE,OAAO,GAAM,MAAQ,EAAY,GAAM,EAAE,IAAM,CAAO,CAAC;CAIlE,IAAI,aAAa,QAAQ,aAAa,MACpC,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;CAInC,IAAI,aAAa,OAAO,aAAa,KAAK;EACxC,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;EAE9B,KAAK,IAAM,CAAC,GAAG,MAAM,GACnB,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAY,GAAG,EAAE,IAAI,CAAC,GAAG,CAAO,GAAG,OAAO;EAG9D,OAAO;CACT;CAGA,IAAI,aAAa,OAAO,aAAa,KAAK;EACxC,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;EAE9B,IAAM,IAAS,CAAC,GAAG,CAAC;EAEpB,KAAK,IAAM,KAAK,GAEd,IAAI,OAAO,KAAM,YAAY,OAAO,KAAM,YAAY,OAAO,KAAM,aAAa,KAAM;OAChF,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO;EAAA,OACjB,IAAI,CAAC,EAAO,MAAM,MAAO,EAAY,GAAG,GAAI,CAAO,CAAC,GACzD,OAAO;EAIX,OAAO;CACT;CAGA,IAAI,aAAa,UAAU,aAAa,QACtC,OAAO,aAAa,UAAU,aAAa,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;CAM9F,IAFI,aAAa,OAAO,aAAa,OAEjC,aAAa,OAAO,aAAa,KAAK,OAAO;CAGjD,IAAM,IAAQ,OAAO,KAAK,CAAC,GACrB,IAAQ,OAAO,KAAK,CAAC;CAE3B,IAAI,EAAM,WAAW,EAAM,QAAQ,OAAO;CAE1C,KAAK,IAAM,KAAO,GAChB,IACE,CAAC,OAAO,OAAO,GAAG,CAAG,KACrB,CAAC,EAAa,EAA8B,IAAO,EAA8B,IAAM,CAAO,GAE9F,OAAO;CAGX,OAAO;AACT"}
1
+ {"version":3,"file":"isEqual.js","names":[],"sources":["../../src/guards/isEqual.ts"],"sourcesContent":["/**\n * Recursively compares two values for deep equality.\n * Supports plain objects, arrays, `Date`, `Map`, `Set`, `RegExp`, and circular references.\n *\n * Uses `===` for the primitive comparison, so `isEqual(NaN, NaN)` is `false` and\n * `isEqual(0, -0)` is `true` — the opposite of `shallowEqual`, which uses `Object.is` and\n * treats `NaN` as equal to itself and `-0` as distinct from `0`.\n *\n * For one-level-deep reference equality, use `shallowEqual` instead.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Map([['k', 1]]), new Map([['k', 1]])); // true\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns `true` if the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;\n\n return a.every((item, idx) => safeIsEqual(item, b[idx], visited));\n }\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Map comparison\n if (a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n\n for (const [k, v] of a) {\n if (!b.has(k) || !safeIsEqual(v, b.get(k), visited)) return false;\n }\n\n return true;\n }\n\n // Set comparison — fast path for primitive values, deep for objects\n if (a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n\n const bItems = [...b];\n\n for (const v of a) {\n // O(1) path for primitives — avoid the O(n) .some() scan\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null || v === undefined) {\n if (!b.has(v)) return false;\n } else if (!bItems.some((bv) => safeIsEqual(v, bv, visited))) {\n return false;\n }\n }\n\n return true;\n }\n\n // RegExp comparison\n if (a instanceof RegExp || b instanceof RegExp) {\n return a instanceof RegExp && b instanceof RegExp && a.source === b.source && a.flags === b.flags;\n }\n\n // Cross-type guards: Map/Set vs plain objects are never equal\n if (a instanceof Map || b instanceof Map) return false;\n\n if (a instanceof Set || b instanceof Set) return false;\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n"],"mappings":";AAsBA,SAAgB,EAAQ,GAAY,GAAqB;CACvD,OAAO,EAAY,GAAG,mBAAG,IAAI,QAAQ,CAAC;AACxC;AAEA,SAAS,EAAY,GAAY,GAAY,GAA2C;CAEtF,IAAI,MAAM,GAAG,OAAO;CAGpB,IAAI,KAAK,QAAQ,KAAK,QAAQ,OAAO,KAAM,OAAO,KAAK,OAAO,KAAM,YAAY,OAAO,KAAM,UAAU,OAAO;CAI9G,IAAI,EAAQ,IAAI,CAAW,GACzB,OAAO,EAAQ,IAAI,CAAW,MAAM;CAMtC,IAHA,EAAQ,IAAI,GAAa,CAAW,GAGhC,MAAM,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,GAGrC,OAFI,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,SAAe,KAErE,EAAE,OAAO,GAAM,MAAQ,EAAY,GAAM,EAAE,IAAM,CAAO,CAAC;CAIlE,IAAI,aAAa,QAAQ,aAAa,MACpC,OAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;CAInC,IAAI,aAAa,OAAO,aAAa,KAAK;EACxC,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;EAE9B,KAAK,IAAM,CAAC,GAAG,MAAM,GACnB,IAAI,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,EAAY,GAAG,EAAE,IAAI,CAAC,GAAG,CAAO,GAAG,OAAO;EAG9D,OAAO;CACT;CAGA,IAAI,aAAa,OAAO,aAAa,KAAK;EACxC,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;EAE9B,IAAM,IAAS,CAAC,GAAG,CAAC;EAEpB,KAAK,IAAM,KAAK,GAEd,IAAI,OAAO,KAAM,YAAY,OAAO,KAAM,YAAY,OAAO,KAAM,aAAa,KAAM,MAChF;OAAA,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO;EAAA,OACjB,IAAI,CAAC,EAAO,MAAM,MAAO,EAAY,GAAG,GAAI,CAAO,CAAC,GACzD,OAAO;EAIX,OAAO;CACT;CAGA,IAAI,aAAa,UAAU,aAAa,QACtC,OAAO,aAAa,UAAU,aAAa,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;CAM9F,IAFI,aAAa,OAAO,aAAa,OAEjC,aAAa,OAAO,aAAa,KAAK,OAAO;CAGjD,IAAM,IAAQ,OAAO,KAAK,CAAC,GACrB,IAAQ,OAAO,KAAK,CAAC;CAE3B,IAAI,EAAM,WAAW,EAAM,QAAQ,OAAO;CAE1C,KAAK,IAAM,KAAO,GAChB,IACE,CAAC,OAAO,OAAO,GAAG,CAAG,KACrB,CAAC,EAAa,EAA8B,IAAO,EAA8B,IAAM,CAAO,GAE9F,OAAO;CAGX,OAAO;AACT"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./errors.cjs"),ee=require("./guards/isString.cjs"),t=require("./array/chunk.cjs"),n=require("./array/compact.cjs"),r=require("./array/compare.cjs"),te=require("./array/compareBy.cjs"),ne=require("./guards/isEqual.cjs"),re=require("./array/contains.cjs"),ie=require("./array/countBy.cjs"),ae=require("./array/difference.cjs"),i=require("./array/drop.cjs"),a=require("./array/dropLast.cjs"),o=require("./array/filterMap.cjs"),s=require("./array/first.cjs"),c=require("./array/flatten.cjs"),l=require("./array/groupBy.cjs"),u=require("./array/indexBy.cjs"),d=require("./array/intersection.cjs"),f=require("./array/last.cjs"),p=require("./array/partition.cjs"),m=require("./array/replace.cjs"),h=require("./array/rotate.cjs"),g=require("./guards/isNil.cjs"),_=require("./guards/isNumber.cjs"),v=require("./string/similarity.cjs"),y=require("./array/search.cjs"),b=require("./array/sort.cjs"),x=require("./array/take.cjs"),S=require("./array/takeLast.cjs"),C=require("./array/toggle.cjs"),w=require("./array/union.cjs"),T=require("./array/uniq.cjs"),E=require("./array/unzip.cjs"),D=require("./array/zip.cjs"),O=require("./async/abortError.cjs"),k=require("./async/attempt.cjs"),A=require("./async/backoff.cjs"),j=require("./async/parallel.cjs"),M=require("./async/queue.cjs"),N=require("./async/sleep.cjs"),P=require("./async/retry.cjs"),F=require("./async/waitFor.cjs"),I=require("./cache/memo.cjs"),L=require("./guards/isPromise.cjs"),R=require("./cache/stash.cjs"),z=require("./function/assert.cjs"),B=require("./function/constant.cjs"),V=require("./function/debounce.cjs"),H=require("./function/identity.cjs"),U=require("./function/once.cjs"),W=require("./function/pipe.cjs"),G=require("./function/runAll.cjs"),K=require("./function/tap.cjs"),q=require("./function/throttle.cjs"),J=require("./guards/combinators.cjs"),oe=require("./guards/isAbortError.cjs"),se=require("./guards/isArray.cjs"),ce=require("./guards/isBoolean.cjs"),le=require("./guards/isDate.cjs"),ue=require("./guards/isDefined.cjs"),Y=require("./guards/isPlainObject.cjs"),de=require("./guards/isEmpty.cjs"),fe=require("./guards/isError.cjs"),pe=require("./guards/isFunction.cjs"),me=require("./guards/isMatch.cjs"),he=require("./guards/isPrimitive.cjs"),ge=require("./guards/isRegex.cjs"),_e=require("./guards/shallowEqual.cjs"),ve=require("./math/abs.cjs"),ye=require("./math/allocate.cjs"),be=require("./math/sum.cjs"),xe=require("./math/average.cjs"),Se=require("./math/clamp.cjs"),Ce=require("./math/gcd.cjs"),we=require("./math/lcm.cjs"),Te=require("./math/lerp.cjs"),Ee=require("./math/linspace.cjs"),De=require("./math/max.cjs"),Oe=require("./math/median.cjs"),ke=require("./math/min.cjs"),Ae=require("./math/mod.cjs"),je=require("./math/normalize.cjs"),Me=require("./math/percent.cjs"),Ne=require("./math/range.cjs"),Pe=require("./math/round.cjs"),Fe=require("./math/variance.cjs"),Ie=require("./math/standardDeviation.cjs"),Le=require("./object/defaults.cjs"),X=require("./object/diff.cjs"),Re=require("./object/filterValues.cjs"),Z=require("./object/flattenPaths.cjs"),ze=require("./object/getPath.cjs"),Be=require("./object/invert.cjs"),Ve=require("./object/mapKeys.cjs"),He=require("./object/mapValues.cjs"),Q=require("./object/merge.cjs"),Ue=require("./object/omit.cjs"),We=require("./object/parseJSON.cjs"),Ge=require("./object/pick.cjs"),Ke=require("./object/prune.cjs"),qe=require("./object/hash.cjs"),Je=require("./random/random.cjs"),$=require("./random/draw.cjs"),Ye=require("./random/shuffle.cjs"),Xe=require("./random/uuid.cjs"),Ze=require("./string/camelCase.cjs"),Qe=require("./string/endsWith.cjs"),$e=require("./string/escape.cjs"),et=require("./string/kebabCase.cjs"),tt=require("./string/pad.cjs"),nt=require("./string/pascalCase.cjs"),rt=require("./string/snakeCase.cjs"),it=require("./string/startsWith.cjs"),at=require("./string/words.cjs"),ot=require("./string/titleCase.cjs"),st=require("./string/truncate.cjs"),ct=require("./string/unescape.cjs");exports.ArsenalError=e.ArsenalError,exports.ArsenalSerializationError=e.ArsenalSerializationError,exports.ArsenalValidationError=e.ArsenalValidationError,exports.abortError=O.abortError,exports.abs=ve.abs,exports.allOf=J.allOf,exports.allocate=ye.allocate,exports.anyOf=J.anyOf,exports.assert=z.assert,exports.attempt=k.attempt,exports.average=xe.average,exports.backoff=A.backoff,exports.camelCase=Ze.camelCase,exports.chunk=t.chunk,exports.clamp=Se.clamp,exports.compact=n.compact,exports.compare=r.compare,exports.compareBy=te.compareBy,exports.constant=B.constant,exports.contains=re.contains,exports.countBy=ie.countBy,exports.debounce=V.debounce,exports.deepMerge=Q.deepMerge,exports.defaults=Le.defaults,exports.diff=X.diff,exports.diffArrays=X.diffArrays,exports.difference=ae.difference,exports.draw=$.draw,exports.drawMany=$.drawMany,exports.drop=i.drop,exports.dropLast=a.dropLast,exports.endsWith=Qe.endsWith,exports.escape=$e.escape,exports.filterMap=o.filterMap,exports.filterValues=Re.filterValues,exports.first=s.first,exports.flatten=c.flatten,exports.flattenPaths=Z.flattenPaths,exports.fuzzy=y.fuzzy,exports.fuzzyFilter=y.fuzzyFilter,exports.fuzzyScore=y.fuzzyScore,exports.gcd=Ce.gcd,exports.getPath=ze.getPath,exports.groupBy=l.groupBy,exports.hash=qe.hash,exports.identity=H.identity,exports.indexBy=u.indexBy,exports.intersection=d.intersection,exports.invert=Be.invert,exports.isAbortError=oe.isAbortError,exports.isArray=se.isArray,exports.isBoolean=ce.isBoolean,exports.isDate=le.isDate,exports.isDefined=ue.isDefined,exports.isEmpty=de.isEmpty,exports.isEqual=ne.isEqual,exports.isError=fe.isError,exports.isFail=k.isFail,exports.isFunction=pe.isFunction,exports.isMatch=me.isMatch,exports.isNil=g.isNil,exports.isNumber=_.isNumber,exports.isOk=k.isOk,exports.isPlainObject=Y.isPlainObject,exports.isPrimitive=he.isPrimitive,exports.isPromise=L.isPromise,exports.isRegex=ge.isRegex,exports.isString=ee.isString,exports.kebabCase=et.kebabCase,exports.last=f.last,exports.lcm=we.lcm,exports.lerp=Te.lerp,exports.linspace=Ee.linspace,exports.mapKeys=Ve.mapKeys,exports.mapValues=He.mapValues,exports.max=De.max,exports.median=Oe.median,exports.memo=I.memo,exports.min=ke.min,exports.mod=Ae.mod,exports.noneOf=J.noneOf,exports.normalize=je.normalize,exports.not=J.not,exports.omit=Ue.omit,exports.once=U.once,exports.pad=tt.pad,exports.parallel=j.parallel,exports.parseJSON=We.parseJSON,exports.partition=p.partition,exports.pascalCase=nt.pascalCase,exports.percent=Me.percent,exports.pick=Ge.pick,exports.pipe=W.pipe,exports.prune=Ke.prune,exports.queue=M.queue,exports.random=Je.random,exports.range=Ne.range,exports.replace=m.replace,exports.retry=P.retry,exports.rotate=h.rotate,exports.round=Pe.round,exports.runAll=G.runAll,exports.shallowEqual=_e.shallowEqual,exports.shallowMerge=Q.shallowMerge,exports.shuffle=Ye.shuffle,exports.similarity=v.similarity,exports.sleep=N.sleep,exports.snakeCase=rt.snakeCase,exports.sort=b.sort,exports.standardDeviation=Ie.standardDeviation,exports.startsWith=it.startsWith,exports.stash=R.stash,exports.sum=be.sum,exports.take=x.take,exports.takeLast=S.takeLast,exports.tap=K.tap,exports.throttle=q.throttle,exports.titleCase=ot.titleCase,exports.toggle=C.toggle,exports.truncate=st.truncate,exports.unescape=ct.unescape,exports.unflattenPaths=Z.unflattenPaths,exports.union=w.union,exports.uniq=T.uniq,exports.unzip=E.unzip,exports.uuid=Xe.uuid,exports.variance=Fe.variance,exports.waitFor=F.waitFor,exports.words=at.words,exports.zip=D.zip;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./array/chunk.cjs"),t=require("./guards/isEqual.cjs"),n=require("./array/filterMap.cjs"),r=require("./array/groupBy.cjs"),i=require("./array/indexBy.cjs"),a=require("./array/partition.cjs"),o=require("./array/sort.cjs"),s=require("./array/uniq.cjs"),c=require("./async/attempt.cjs"),l=require("./async/parallel.cjs"),u=require("./async/sleep.cjs"),d=require("./async/retry.cjs"),f=require("./errors.cjs"),p=require("./function/debounce.cjs"),m=require("./function/once.cjs"),h=require("./function/pipe.cjs"),g=require("./function/throttle.cjs"),_=require("./guards/combinators.cjs"),v=require("./guards/isDefined.cjs"),y=require("./guards/isNil.cjs"),b=require("./guards/isPlainObject.cjs"),x=require("./math/clamp.cjs"),S=require("./math/range.cjs"),C=require("./object/getPath.cjs"),w=require("./object/hash.cjs"),T=require("./object/omit.cjs"),E=require("./object/pick.cjs"),D=require("./random/uuid.cjs"),O=require("./string/camelCase.cjs");exports.ArsenalError=f.ArsenalError,exports.ArsenalSerializationError=f.ArsenalSerializationError,exports.allOf=_.allOf,exports.anyOf=_.anyOf,exports.attempt=c.attempt,exports.camelCase=O.camelCase,exports.chunk=e.chunk,exports.clamp=x.clamp,exports.debounce=p.debounce,exports.filterMap=n.filterMap,exports.getPath=C.getPath,exports.getPathOr=C.getPathOr,exports.groupBy=r.groupBy,exports.hash=w.hash,exports.indexBy=i.indexBy,exports.isDefined=v.isDefined,exports.isEqual=t.isEqual,exports.isFail=c.isFail,exports.isNil=y.isNil,exports.isOk=c.isOk,exports.isPlainObject=b.isPlainObject,exports.noneOf=_.noneOf,exports.not=_.not,exports.omit=T.omit,exports.once=m.once,exports.parallel=l.parallel,exports.partition=a.partition,exports.pick=E.pick,exports.pipe=h.pipe,exports.range=S.range,exports.requirePath=C.requirePath,exports.retry=d.retry,exports.sleep=u.sleep,exports.sort=o.sort,exports.throttle=g.throttle,exports.uniq=s.uniq,exports.uuid=D.uuid;