@vielzeug/arsenal 2.0.1 → 3.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 (313) hide show
  1. package/README.md +5 -18
  2. package/dist/array/chunk.cjs.map +1 -1
  3. package/dist/array/chunk.d.ts +1 -1
  4. package/dist/array/chunk.d.ts.map +1 -1
  5. package/dist/array/chunk.js.map +1 -1
  6. package/dist/array/compact.cjs.map +1 -1
  7. package/dist/array/compact.d.ts +1 -1
  8. package/dist/array/compact.d.ts.map +1 -1
  9. package/dist/array/compact.js.map +1 -1
  10. package/dist/array/contains.cjs.map +1 -1
  11. package/dist/array/contains.d.ts +1 -1
  12. package/dist/array/contains.d.ts.map +1 -1
  13. package/dist/array/contains.js.map +1 -1
  14. package/dist/array/countBy.cjs.map +1 -1
  15. package/dist/array/countBy.d.ts +1 -1
  16. package/dist/array/countBy.d.ts.map +1 -1
  17. package/dist/array/countBy.js.map +1 -1
  18. package/dist/array/difference.cjs.map +1 -1
  19. package/dist/array/difference.d.ts +4 -2
  20. package/dist/array/difference.d.ts.map +1 -1
  21. package/dist/array/difference.js.map +1 -1
  22. package/dist/array/drop.cjs.map +1 -1
  23. package/dist/array/drop.d.ts +1 -1
  24. package/dist/array/drop.d.ts.map +1 -1
  25. package/dist/array/drop.js.map +1 -1
  26. package/dist/array/dropLast.cjs.map +1 -1
  27. package/dist/array/dropLast.d.ts +1 -1
  28. package/dist/array/dropLast.d.ts.map +1 -1
  29. package/dist/array/dropLast.js.map +1 -1
  30. package/dist/array/filterMap.cjs.map +1 -1
  31. package/dist/array/filterMap.d.ts +3 -1
  32. package/dist/array/filterMap.d.ts.map +1 -1
  33. package/dist/array/filterMap.js.map +1 -1
  34. package/dist/array/first.cjs.map +1 -1
  35. package/dist/array/first.d.ts +1 -1
  36. package/dist/array/first.d.ts.map +1 -1
  37. package/dist/array/first.js.map +1 -1
  38. package/dist/array/groupBy.cjs.map +1 -1
  39. package/dist/array/groupBy.d.ts +1 -1
  40. package/dist/array/groupBy.d.ts.map +1 -1
  41. package/dist/array/groupBy.js.map +1 -1
  42. package/dist/array/index.cjs +1 -1
  43. package/dist/array/index.d.ts +0 -1
  44. package/dist/array/index.d.ts.map +1 -1
  45. package/dist/array/index.js +17 -18
  46. package/dist/array/indexBy.cjs.map +1 -1
  47. package/dist/array/indexBy.d.ts +1 -1
  48. package/dist/array/indexBy.d.ts.map +1 -1
  49. package/dist/array/indexBy.js.map +1 -1
  50. package/dist/array/intersection.cjs.map +1 -1
  51. package/dist/array/intersection.d.ts +4 -2
  52. package/dist/array/intersection.d.ts.map +1 -1
  53. package/dist/array/intersection.js.map +1 -1
  54. package/dist/array/last.cjs.map +1 -1
  55. package/dist/array/last.d.ts +1 -1
  56. package/dist/array/last.d.ts.map +1 -1
  57. package/dist/array/last.js.map +1 -1
  58. package/dist/array/partition.cjs.map +1 -1
  59. package/dist/array/partition.d.ts +3 -1
  60. package/dist/array/partition.d.ts.map +1 -1
  61. package/dist/array/partition.js.map +1 -1
  62. package/dist/array/replace.cjs.map +1 -1
  63. package/dist/array/replace.d.ts +2 -15
  64. package/dist/array/replace.d.ts.map +1 -1
  65. package/dist/array/replace.js.map +1 -1
  66. package/dist/array/rotate.cjs.map +1 -1
  67. package/dist/array/rotate.d.ts +5 -17
  68. package/dist/array/rotate.d.ts.map +1 -1
  69. package/dist/array/rotate.js.map +1 -1
  70. package/dist/array/sort.cjs.map +1 -1
  71. package/dist/array/sort.d.ts +2 -2
  72. package/dist/array/sort.d.ts.map +1 -1
  73. package/dist/array/sort.js.map +1 -1
  74. package/dist/array/take.cjs.map +1 -1
  75. package/dist/array/take.d.ts +1 -1
  76. package/dist/array/take.d.ts.map +1 -1
  77. package/dist/array/take.js.map +1 -1
  78. package/dist/array/takeLast.cjs.map +1 -1
  79. package/dist/array/takeLast.d.ts +1 -1
  80. package/dist/array/takeLast.d.ts.map +1 -1
  81. package/dist/array/takeLast.js.map +1 -1
  82. package/dist/array/toggle.cjs.map +1 -1
  83. package/dist/array/toggle.d.ts +1 -1
  84. package/dist/array/toggle.d.ts.map +1 -1
  85. package/dist/array/toggle.js.map +1 -1
  86. package/dist/array/union.cjs.map +1 -1
  87. package/dist/array/union.d.ts +4 -2
  88. package/dist/array/union.d.ts.map +1 -1
  89. package/dist/array/union.js.map +1 -1
  90. package/dist/array/uniq.cjs.map +1 -1
  91. package/dist/array/uniq.d.ts +1 -1
  92. package/dist/array/uniq.d.ts.map +1 -1
  93. package/dist/array/uniq.js.map +1 -1
  94. package/dist/array/zip.cjs.map +1 -1
  95. package/dist/array/zip.d.ts +1 -1
  96. package/dist/array/zip.d.ts.map +1 -1
  97. package/dist/array/zip.js.map +1 -1
  98. package/dist/arsenal.cjs +1 -1
  99. package/dist/arsenal.cjs.map +1 -1
  100. package/dist/arsenal.iife.js +1 -1
  101. package/dist/arsenal.iife.js.map +1 -1
  102. package/dist/arsenal.js +1 -1
  103. package/dist/arsenal.js.map +1 -1
  104. package/dist/async/abortError.cjs +1 -1
  105. package/dist/async/abortError.cjs.map +1 -1
  106. package/dist/async/abortError.d.ts +3 -2
  107. package/dist/async/abortError.d.ts.map +1 -1
  108. package/dist/async/abortError.js +2 -2
  109. package/dist/async/abortError.js.map +1 -1
  110. package/dist/async/abortable.cjs +2 -0
  111. package/dist/async/abortable.cjs.map +1 -0
  112. package/dist/async/abortable.d.ts +26 -0
  113. package/dist/async/abortable.d.ts.map +1 -0
  114. package/dist/async/abortable.js +12 -0
  115. package/dist/async/abortable.js.map +1 -0
  116. package/dist/async/backoff.cjs +1 -1
  117. package/dist/async/backoff.cjs.map +1 -1
  118. package/dist/async/backoff.js +1 -2
  119. package/dist/async/backoff.js.map +1 -1
  120. package/dist/async/index.cjs +1 -1
  121. package/dist/async/index.d.ts +1 -0
  122. package/dist/async/index.d.ts.map +1 -1
  123. package/dist/async/index.js +9 -8
  124. package/dist/async/taskPool.cjs.map +1 -1
  125. package/dist/async/taskPool.d.ts +4 -4
  126. package/dist/async/taskPool.d.ts.map +1 -1
  127. package/dist/async/taskPool.js.map +1 -1
  128. package/dist/cache/cache.cjs +1 -1
  129. package/dist/cache/cache.cjs.map +1 -1
  130. package/dist/cache/cache.d.ts +1 -0
  131. package/dist/cache/cache.d.ts.map +1 -1
  132. package/dist/cache/cache.js +2 -1
  133. package/dist/cache/cache.js.map +1 -1
  134. package/dist/cache/memo.cjs.map +1 -1
  135. package/dist/cache/memo.d.ts.map +1 -1
  136. package/dist/cache/memo.js.map +1 -1
  137. package/dist/errors.cjs +1 -1
  138. package/dist/errors.cjs.map +1 -1
  139. package/dist/errors.d.ts +0 -1
  140. package/dist/errors.d.ts.map +1 -1
  141. package/dist/errors.js +1 -4
  142. package/dist/errors.js.map +1 -1
  143. package/dist/function/assert.cjs.map +1 -1
  144. package/dist/function/assert.d.ts +1 -1
  145. package/dist/function/assert.js.map +1 -1
  146. package/dist/function/debounce.cjs.map +1 -1
  147. package/dist/function/debounce.d.ts.map +1 -1
  148. package/dist/function/debounce.js.map +1 -1
  149. package/dist/function/pipe.cjs +1 -1
  150. package/dist/function/pipe.cjs.map +1 -1
  151. package/dist/function/pipe.js +1 -1
  152. package/dist/function/pipe.js.map +1 -1
  153. package/dist/function/runAll.cjs +1 -1
  154. package/dist/function/runAll.cjs.map +1 -1
  155. package/dist/function/runAll.js +1 -1
  156. package/dist/function/runAll.js.map +1 -1
  157. package/dist/guards/index.cjs +1 -1
  158. package/dist/guards/index.js +7 -7
  159. package/dist/guards/isEmpty.cjs +1 -1
  160. package/dist/guards/isEmpty.cjs.map +1 -1
  161. package/dist/guards/isEmpty.d.ts.map +1 -1
  162. package/dist/guards/isEmpty.js +4 -5
  163. package/dist/guards/isEmpty.js.map +1 -1
  164. package/dist/guards/isFunction.cjs.map +1 -1
  165. package/dist/guards/isFunction.d.ts +1 -1
  166. package/dist/guards/isFunction.d.ts.map +1 -1
  167. package/dist/guards/isFunction.js.map +1 -1
  168. package/dist/guards/isPrimitive.cjs +1 -1
  169. package/dist/guards/isPrimitive.cjs.map +1 -1
  170. package/dist/guards/isPrimitive.d.ts +4 -17
  171. package/dist/guards/isPrimitive.d.ts.map +1 -1
  172. package/dist/guards/isPrimitive.js +1 -2
  173. package/dist/guards/isPrimitive.js.map +1 -1
  174. package/dist/index.cjs +1 -1
  175. package/dist/index.d.ts +7 -2
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.js +27 -22
  178. package/dist/math/average.cjs +1 -1
  179. package/dist/math/average.cjs.map +1 -1
  180. package/dist/math/average.d.ts +3 -2
  181. package/dist/math/average.d.ts.map +1 -1
  182. package/dist/math/average.js +1 -6
  183. package/dist/math/average.js.map +1 -1
  184. package/dist/math/gcd.cjs +1 -1
  185. package/dist/math/gcd.cjs.map +1 -1
  186. package/dist/math/gcd.d.ts.map +1 -1
  187. package/dist/math/gcd.js +1 -0
  188. package/dist/math/gcd.js.map +1 -1
  189. package/dist/math/index.cjs +1 -1
  190. package/dist/math/index.d.ts +0 -1
  191. package/dist/math/index.d.ts.map +1 -1
  192. package/dist/math/index.js +7 -8
  193. package/dist/math/lcm.cjs +1 -1
  194. package/dist/math/lcm.cjs.map +1 -1
  195. package/dist/math/lcm.d.ts.map +1 -1
  196. package/dist/math/lcm.js +5 -1
  197. package/dist/math/lcm.js.map +1 -1
  198. package/dist/math/linspace.cjs +1 -1
  199. package/dist/math/linspace.cjs.map +1 -1
  200. package/dist/math/linspace.d.ts.map +1 -1
  201. package/dist/math/linspace.js +2 -1
  202. package/dist/math/linspace.js.map +1 -1
  203. package/dist/math/median.cjs.map +1 -1
  204. package/dist/math/median.d.ts +1 -1
  205. package/dist/math/median.d.ts.map +1 -1
  206. package/dist/math/median.js.map +1 -1
  207. package/dist/math/standardDeviation.cjs.map +1 -1
  208. package/dist/math/standardDeviation.d.ts +1 -1
  209. package/dist/math/standardDeviation.d.ts.map +1 -1
  210. package/dist/math/standardDeviation.js.map +1 -1
  211. package/dist/math/sum.cjs +1 -1
  212. package/dist/math/sum.cjs.map +1 -1
  213. package/dist/math/sum.d.ts +1 -1
  214. package/dist/math/sum.d.ts.map +1 -1
  215. package/dist/math/sum.js +1 -1
  216. package/dist/math/sum.js.map +1 -1
  217. package/dist/math/variance.cjs.map +1 -1
  218. package/dist/math/variance.d.ts +1 -1
  219. package/dist/math/variance.d.ts.map +1 -1
  220. package/dist/math/variance.js.map +1 -1
  221. package/dist/object/defaults.cjs.map +1 -1
  222. package/dist/object/defaults.d.ts.map +1 -1
  223. package/dist/object/defaults.js.map +1 -1
  224. package/dist/object/diff.cjs.map +1 -1
  225. package/dist/object/diff.d.ts +1 -1
  226. package/dist/object/diff.d.ts.map +1 -1
  227. package/dist/object/diff.js.map +1 -1
  228. package/dist/object/filterValues.cjs.map +1 -1
  229. package/dist/object/filterValues.d.ts.map +1 -1
  230. package/dist/object/filterValues.js.map +1 -1
  231. package/dist/object/getPath.cjs.map +1 -1
  232. package/dist/object/getPath.d.ts.map +1 -1
  233. package/dist/object/getPath.js.map +1 -1
  234. package/dist/object/mapKeys.cjs.map +1 -1
  235. package/dist/object/mapKeys.d.ts.map +1 -1
  236. package/dist/object/mapKeys.js.map +1 -1
  237. package/dist/object/mapValues.cjs.map +1 -1
  238. package/dist/object/mapValues.d.ts.map +1 -1
  239. package/dist/object/mapValues.js.map +1 -1
  240. package/dist/object/merge.cjs.map +1 -1
  241. package/dist/object/merge.d.ts.map +1 -1
  242. package/dist/object/merge.js.map +1 -1
  243. package/dist/object/omit.cjs.map +1 -1
  244. package/dist/object/omit.d.ts.map +1 -1
  245. package/dist/object/omit.js.map +1 -1
  246. package/dist/object/pick.cjs.map +1 -1
  247. package/dist/object/pick.d.ts.map +1 -1
  248. package/dist/object/pick.js.map +1 -1
  249. package/dist/object/prune.cjs +1 -1
  250. package/dist/object/prune.cjs.map +1 -1
  251. package/dist/object/prune.d.ts.map +1 -1
  252. package/dist/object/prune.js +16 -17
  253. package/dist/object/prune.js.map +1 -1
  254. package/dist/random/_index.cjs +1 -1
  255. package/dist/random/_index.cjs.map +1 -1
  256. package/dist/random/_index.d.ts +1 -1
  257. package/dist/random/_index.d.ts.map +1 -1
  258. package/dist/random/_index.js +4 -5
  259. package/dist/random/_index.js.map +1 -1
  260. package/dist/random/draw.cjs.map +1 -1
  261. package/dist/random/draw.d.ts.map +1 -1
  262. package/dist/random/draw.js.map +1 -1
  263. package/dist/random/index.cjs +1 -1
  264. package/dist/random/index.d.ts +0 -1
  265. package/dist/random/index.d.ts.map +1 -1
  266. package/dist/random/index.js +2 -2
  267. package/dist/random/random.cjs.map +1 -1
  268. package/dist/random/random.d.ts.map +1 -1
  269. package/dist/random/random.js.map +1 -1
  270. package/dist/random/shuffle.cjs.map +1 -1
  271. package/dist/random/shuffle.d.ts.map +1 -1
  272. package/dist/random/shuffle.js.map +1 -1
  273. package/dist/random/source.cjs +2 -0
  274. package/dist/random/source.cjs.map +1 -0
  275. package/dist/random/source.d.ts +2 -0
  276. package/dist/random/source.d.ts.map +1 -1
  277. package/dist/random/source.js +10 -0
  278. package/dist/random/source.js.map +1 -0
  279. package/dist/string/index.cjs +1 -1
  280. package/dist/string/index.d.ts +1 -1
  281. package/dist/string/index.d.ts.map +1 -1
  282. package/dist/string/index.js +2 -2
  283. package/dist/string/{pad.cjs → padCenter.cjs} +2 -2
  284. package/dist/string/padCenter.cjs.map +1 -0
  285. package/dist/string/padCenter.d.ts +3 -0
  286. package/dist/string/padCenter.d.ts.map +1 -0
  287. package/dist/string/{pad.js → padCenter.js} +3 -3
  288. package/dist/string/padCenter.js.map +1 -0
  289. package/package.json +32 -27
  290. package/dist/_common/_abortable.d.ts +0 -5
  291. package/dist/_common/_abortable.d.ts.map +0 -1
  292. package/dist/array/flatten.cjs +0 -2
  293. package/dist/array/flatten.cjs.map +0 -1
  294. package/dist/array/flatten.d.ts +0 -5
  295. package/dist/array/flatten.d.ts.map +0 -1
  296. package/dist/array/flatten.js +0 -11
  297. package/dist/array/flatten.js.map +0 -1
  298. package/dist/math/percent.cjs +0 -2
  299. package/dist/math/percent.cjs.map +0 -1
  300. package/dist/math/percent.d.ts +0 -19
  301. package/dist/math/percent.d.ts.map +0 -1
  302. package/dist/math/percent.js +0 -8
  303. package/dist/math/percent.js.map +0 -1
  304. package/dist/random/uuid.cjs +0 -2
  305. package/dist/random/uuid.cjs.map +0 -1
  306. package/dist/random/uuid.d.ts +0 -12
  307. package/dist/random/uuid.d.ts.map +0 -1
  308. package/dist/random/uuid.js +0 -8
  309. package/dist/random/uuid.js.map +0 -1
  310. package/dist/string/pad.cjs.map +0 -1
  311. package/dist/string/pad.d.ts +0 -5
  312. package/dist/string/pad.d.ts.map +0 -1
  313. package/dist/string/pad.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  //#region src/guards/isPrimitive.ts
2
2
  function e(e) {
3
- let t = typeof e;
4
- return t === "string" || t === "boolean" || t === "number" && !Number.isNaN(e);
3
+ return e === null || typeof e != "object" && typeof e != "function";
5
4
  }
6
5
  //#endregion
7
6
  export { e as isPrimitive };
@@ -1 +1 @@
1
- {"version":3,"file":"isPrimitive.js","names":[],"sources":["../../src/guards/isPrimitive.ts"],"sourcesContent":["/**\n * Type guard to check if a value is a primitive\n *\n * @example\n * ```ts\n * isPrimitive('Hello World'); // true\n * isPrimitive(42); // true\n * isPrimitive(true); // true\n * isPrimitive({}); // false\n * isPrimitive([]); // false\n * isPrimitive(() => {}); // false\n * ```\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a primitive, else `false`.\n */\nexport function isPrimitive(arg: unknown): arg is string | number | boolean {\n const type = typeof arg;\n\n return type === 'string' || type === 'boolean' || (type === 'number' && !Number.isNaN(arg));\n}\n"],"mappings":";AAgBA,SAAgB,EAAY,GAAgD;CAC1E,IAAM,IAAO,OAAO;CAEpB,OAAO,MAAS,YAAY,MAAS,aAAc,MAAS,YAAY,CAAC,OAAO,MAAM,CAAG;AAC3F"}
1
+ {"version":3,"file":"isPrimitive.js","names":[],"sources":["../../src/guards/isPrimitive.ts"],"sourcesContent":["/** JavaScript values that are not objects or functions. */\nexport type PrimitiveValue = bigint | boolean | null | number | string | symbol | undefined;\n\n/** Checks whether a value is a JavaScript primitive. */\nexport function isPrimitive(value: unknown): value is PrimitiveValue {\n return value === null || (typeof value !== 'object' && typeof value !== 'function');\n}\n"],"mappings":";AAIA,SAAgB,EAAY,GAAyC;CACnE,OAAO,MAAU,QAAS,OAAO,KAAU,YAAY,OAAO,KAAU;AAC1E"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
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/abortError.cjs"),l=require("./async/abortable.cjs"),u=require("./async/attempt.cjs"),d=require("./async/backoff.cjs"),f=require("./async/parallel.cjs"),p=require("./async/sleep.cjs"),m=require("./async/retry.cjs"),h=require("./errors.cjs"),g=require("./function/debounce.cjs"),_=require("./function/once.cjs"),v=require("./function/pipe.cjs"),y=require("./function/throttle.cjs"),b=require("./guards/combinators.cjs"),x=require("./guards/isDefined.cjs"),S=require("./guards/isPlainObject.cjs"),C=require("./guards/isNil.cjs"),w=require("./math/allocate.cjs"),T=require("./math/clamp.cjs"),E=require("./math/range.cjs"),D=require("./object/getPath.cjs"),O=require("./object/hash.cjs"),k=require("./object/omit.cjs"),A=require("./object/pick.cjs"),j=require("./random/source.cjs"),M=require("./random/random.cjs"),N=require("./string/camelCase.cjs");exports.ArsenalError=h.ArsenalError,exports.ArsenalSerializationError=h.ArsenalSerializationError,exports.abortError=c.abortError,exports.abortable=l.abortable,exports.allOf=b.allOf,exports.allocate=w.allocate,exports.anyOf=b.anyOf,exports.attempt=u.attempt,exports.backoff=d.backoff,exports.camelCase=N.camelCase,exports.chunk=e.chunk,exports.clamp=T.clamp,exports.debounce=g.debounce,exports.filterMap=n.filterMap,exports.getPath=D.getPath,exports.getPathOr=D.getPathOr,exports.groupBy=r.groupBy,exports.hash=O.hash,exports.indexBy=i.indexBy,exports.isDefined=x.isDefined,exports.isEqual=t.isEqual,exports.isFail=u.isFail,exports.isNil=C.isNil,exports.isOk=u.isOk,exports.isPlainObject=S.isPlainObject,exports.noneOf=b.noneOf,exports.not=b.not,exports.omit=k.omit,exports.once=_.once,exports.parallel=f.parallel,exports.partition=a.partition,exports.pick=A.pick,exports.pipe=v.pipe,exports.random=M.random,exports.randomFloat=j.randomFloat,exports.range=E.range,exports.requirePath=D.requirePath,exports.retry=m.retry,exports.sleep=p.sleep,exports.sort=o.sort,exports.throttle=y.throttle,exports.uniq=s.uniq;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './errors';
2
1
  export * from './array/chunk';
3
2
  export * from './array/filterMap';
4
3
  export * from './array/groupBy';
@@ -6,10 +5,14 @@ export * from './array/indexBy';
6
5
  export * from './array/partition';
7
6
  export * from './array/sort';
8
7
  export * from './array/uniq';
8
+ export * from './async/abortable';
9
+ export * from './async/abortError';
9
10
  export * from './async/attempt';
11
+ export * from './async/backoff';
10
12
  export * from './async/parallel';
11
13
  export * from './async/retry';
12
14
  export * from './async/sleep';
15
+ export * from './errors';
13
16
  export * from './function/debounce';
14
17
  export * from './function/once';
15
18
  export * from './function/pipe';
@@ -19,12 +22,14 @@ export * from './guards/isDefined';
19
22
  export * from './guards/isEqual';
20
23
  export * from './guards/isNil';
21
24
  export * from './guards/isPlainObject';
25
+ export * from './math/allocate';
22
26
  export * from './math/clamp';
23
27
  export * from './math/range';
24
28
  export * from './object/getPath';
25
29
  export * from './object/hash';
26
30
  export * from './object/omit';
27
31
  export * from './object/pick';
28
- export * from './random/uuid';
32
+ export * from './random/random';
33
+ export * from './random/source';
29
34
  export * from './string/camelCase';
30
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -6,25 +6,30 @@ import { indexBy as i } from "./array/indexBy.js";
6
6
  import { partition as a } from "./array/partition.js";
7
7
  import { sort as o } from "./array/sort.js";
8
8
  import { uniq as s } from "./array/uniq.js";
9
- import { attempt as c, isFail as l, isOk as u } from "./async/attempt.js";
10
- import { parallel as d } from "./async/parallel.js";
11
- import { sleep as f } from "./async/sleep.js";
12
- import { retry as p } from "./async/retry.js";
13
- import { ArsenalError as m, ArsenalSerializationError as h } from "./errors.js";
14
- import { debounce as g } from "./function/debounce.js";
15
- import { once as _ } from "./function/once.js";
16
- import { pipe as v } from "./function/pipe.js";
17
- import { throttle as y } from "./function/throttle.js";
18
- import { allOf as b, anyOf as x, noneOf as S, not as C } from "./guards/combinators.js";
19
- import { isDefined as w } from "./guards/isDefined.js";
20
- import { isNil as T } from "./guards/isNil.js";
21
- import { isPlainObject as E } from "./guards/isPlainObject.js";
22
- import { clamp as D } from "./math/clamp.js";
23
- import { range as O } from "./math/range.js";
24
- import { getPath as k, getPathOr as A, requirePath as j } from "./object/getPath.js";
25
- import { hash as M } from "./object/hash.js";
26
- import { omit as N } from "./object/omit.js";
27
- import { pick as P } from "./object/pick.js";
28
- import { uuid as F } from "./random/uuid.js";
29
- import { camelCase as I } from "./string/camelCase.js";
30
- export { m as ArsenalError, h as ArsenalSerializationError, b as allOf, x as anyOf, c as attempt, I as camelCase, e as chunk, D as clamp, g as debounce, n as filterMap, k as getPath, A as getPathOr, r as groupBy, M as hash, i as indexBy, w as isDefined, t as isEqual, l as isFail, T as isNil, u as isOk, E as isPlainObject, S as noneOf, C as not, N as omit, _ as once, d as parallel, a as partition, P as pick, v as pipe, O as range, j as requirePath, p as retry, f as sleep, o as sort, y as throttle, s as uniq, F as uuid };
9
+ import { abortError as c } from "./async/abortError.js";
10
+ import { abortable as l } from "./async/abortable.js";
11
+ import { attempt as u, isFail as d, isOk as f } from "./async/attempt.js";
12
+ import { backoff as p } from "./async/backoff.js";
13
+ import { parallel as m } from "./async/parallel.js";
14
+ import { sleep as h } from "./async/sleep.js";
15
+ import { retry as g } from "./async/retry.js";
16
+ import { ArsenalError as _, ArsenalSerializationError as v } from "./errors.js";
17
+ import { debounce as y } from "./function/debounce.js";
18
+ import { once as b } from "./function/once.js";
19
+ import { pipe as x } from "./function/pipe.js";
20
+ import { throttle as S } from "./function/throttle.js";
21
+ import { allOf as C, anyOf as w, noneOf as T, not as E } from "./guards/combinators.js";
22
+ import { isDefined as D } from "./guards/isDefined.js";
23
+ import { isPlainObject as O } from "./guards/isPlainObject.js";
24
+ import { isNil as k } from "./guards/isNil.js";
25
+ import { allocate as A } from "./math/allocate.js";
26
+ import { clamp as j } from "./math/clamp.js";
27
+ import { range as M } from "./math/range.js";
28
+ import { getPath as N, getPathOr as P, requirePath as F } from "./object/getPath.js";
29
+ import { hash as I } from "./object/hash.js";
30
+ import { omit as L } from "./object/omit.js";
31
+ import { pick as R } from "./object/pick.js";
32
+ import { randomFloat as z } from "./random/source.js";
33
+ import { random as B } from "./random/random.js";
34
+ import { camelCase as V } from "./string/camelCase.js";
35
+ export { _ as ArsenalError, v as ArsenalSerializationError, c as abortError, l as abortable, C as allOf, A as allocate, w as anyOf, u as attempt, p as backoff, V as camelCase, e as chunk, j as clamp, y as debounce, n as filterMap, N as getPath, P as getPathOr, r as groupBy, I as hash, i as indexBy, D as isDefined, t as isEqual, d as isFail, k as isNil, f as isOk, O as isPlainObject, T as noneOf, E as not, L as omit, b as once, m as parallel, a as partition, R as pick, x as pipe, B as random, z as randomFloat, M as range, F as requirePath, g as retry, h as sleep, o as sort, S as throttle, s as uniq };
@@ -1,2 +1,2 @@
1
- const e=require("./sum.cjs");function t(t,n){if(t.length!==0)try{let r=e.sum(t,n)/t.length;return Number.isNaN(r)?void 0:r}catch{return}}exports.average=t;
1
+ const e=require("./sum.cjs");function t(t,n){if(t.length!==0)return e.sum(t,n)/t.length}exports.average=t;
2
2
  //# sourceMappingURL=average.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"average.cjs","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty or contains non-numeric values.\n */\nexport function average<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n try {\n const result = sum(array, callback) / array.length;\n\n return Number.isNaN(result) ? undefined : result;\n } catch {\n return undefined;\n }\n}\n"],"mappings":"6BAgBA,SAAgB,EAAW,EAAY,EAAoD,CACrF,KAAM,SAAW,EAErB,GAAI,CACF,IAAM,EAAS,EAAA,IAAI,EAAO,CAAQ,EAAI,EAAM,OAE5C,OAAO,OAAO,MAAM,CAAM,EAAI,IAAA,GAAY,CAC5C,MAAQ,CACN,MACF,CACF"}
1
+ {"version":3,"file":"average.cjs","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty.\n * @throws {TypeError} If a value is not a finite number.\n */\nexport function average<T>(array: readonly T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n return sum(array, callback) / array.length;\n}\n"],"mappings":"6BAiBA,SAAgB,EAAW,EAAqB,EAAoD,CAC9F,KAAM,SAAW,EAErB,OAAO,EAAA,IAAI,EAAO,CAAQ,EAAI,EAAM,MACtC"}
@@ -10,7 +10,8 @@
10
10
  *
11
11
  * @param array - The array to average.
12
12
  * @param callback - (optional) A callback function to map each item to a number.
13
- * @returns The average, or `undefined` if the array is empty or contains non-numeric values.
13
+ * @returns The average, or `undefined` if the array is empty.
14
+ * @throws {TypeError} If a value is not a finite number.
14
15
  */
15
- export declare function average<T>(array: T[], callback?: (item: T) => number): number | undefined;
16
+ export declare function average<T>(array: readonly T[], callback?: (item: T) => number): number | undefined;
16
17
  //# sourceMappingURL=average.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"average.d.ts","sourceRoot":"","sources":["../../src/math/average.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAUzF"}
1
+ {"version":3,"file":"average.d.ts","sourceRoot":"","sources":["../../src/math/average.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAIlG"}
@@ -1,12 +1,7 @@
1
1
  import { sum as e } from "./sum.js";
2
2
  //#region src/math/average.ts
3
3
  function t(t, n) {
4
- if (t.length !== 0) try {
5
- let r = e(t, n) / t.length;
6
- return Number.isNaN(r) ? void 0 : r;
7
- } catch {
8
- return;
9
- }
4
+ if (t.length !== 0) return e(t, n) / t.length;
10
5
  }
11
6
  //#endregion
12
7
  export { t as average };
@@ -1 +1 @@
1
- {"version":3,"file":"average.js","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty or contains non-numeric values.\n */\nexport function average<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n try {\n const result = sum(array, callback) / array.length;\n\n return Number.isNaN(result) ? undefined : result;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;AAgBA,SAAgB,EAAW,GAAY,GAAoD;CACrF,MAAM,WAAW,GAErB,IAAI;EACF,IAAM,IAAS,EAAI,GAAO,CAAQ,IAAI,EAAM;EAE5C,OAAO,OAAO,MAAM,CAAM,IAAI,KAAA,IAAY;CAC5C,QAAQ;EACN;CACF;AACF"}
1
+ {"version":3,"file":"average.js","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty.\n * @throws {TypeError} If a value is not a finite number.\n */\nexport function average<T>(array: readonly T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n return sum(array, callback) / array.length;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAW,GAAqB,GAAoD;CAC9F,MAAM,WAAW,GAErB,OAAO,EAAI,GAAO,CAAQ,IAAI,EAAM;AACtC"}
package/dist/math/gcd.cjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e,t){let n=Math.abs(e),r=Math.abs(t);for(;r!==0;){let e=r;r=n%r,n=e}return n}exports.gcd=e;
1
+ function e(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t))throw RangeError(`gcd: inputs must be safe integers`);let n=Math.abs(e),r=Math.abs(t);for(;r!==0;){let e=r;r=n%r,n=e}return n}exports.gcd=e;
2
2
  //# sourceMappingURL=gcd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"gcd.cjs","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAW,EAAmB,CAChD,IAAI,EAAI,KAAK,IAAI,CAAC,EACd,EAAI,KAAK,IAAI,CAAC,EAElB,KAAO,IAAM,GAAG,CACd,IAAM,EAAO,EAEb,EAAI,EAAI,EACR,EAAI,CACN,CAEA,OAAO,CACT"}
1
+ {"version":3,"file":"gcd.cjs","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b)) {\n throw new RangeError('gcd: inputs must be safe integers');\n }\n\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAW,EAAmB,CAChD,GAAI,CAAC,OAAO,cAAc,CAAC,GAAK,CAAC,OAAO,cAAc,CAAC,EACrD,MAAU,WAAW,mCAAmC,EAG1D,IAAI,EAAI,KAAK,IAAI,CAAC,EACd,EAAI,KAAK,IAAI,CAAC,EAElB,KAAO,IAAM,GAAG,CACd,IAAM,EAAO,EAEb,EAAI,EAAI,EACR,EAAI,CACN,CAEA,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../src/math/gcd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYhD"}
1
+ {"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../src/math/gcd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBhD"}
package/dist/math/gcd.js CHANGED
@@ -1,5 +1,6 @@
1
1
  //#region src/math/gcd.ts
2
2
  function e(e, t) {
3
+ if (!Number.isSafeInteger(e) || !Number.isSafeInteger(t)) throw RangeError("gcd: inputs must be safe integers");
3
4
  let n = Math.abs(e), r = Math.abs(t);
4
5
  for (; r !== 0;) {
5
6
  let e = r;
@@ -1 +1 @@
1
- {"version":3,"file":"gcd.js","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAI,IAAI,KAAK,IAAI,CAAC,GACd,IAAI,KAAK,IAAI,CAAC;CAElB,OAAO,MAAM,IAAG;EACd,IAAM,IAAO;EAGb,AADA,IAAI,IAAI,GACR,IAAI;CACN;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"gcd.js","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b)) {\n throw new RangeError('gcd: inputs must be safe integers');\n }\n\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAI,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,GACrD,MAAU,WAAW,mCAAmC;CAG1D,IAAI,IAAI,KAAK,IAAI,CAAC,GACd,IAAI,KAAK,IAAI,CAAC;CAElB,OAAO,MAAM,IAAG;EACd,IAAM,IAAO;EAGb,AADA,IAAI,IAAI,GACR,IAAI;CACN;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./clamp.cjs"),t=require("./range.cjs"),n=require("./allocate.cjs"),r=require("./sum.cjs"),i=require("./average.cjs"),a=require("./gcd.cjs"),o=require("./lcm.cjs"),s=require("./lerp.cjs"),c=require("./linspace.cjs"),l=require("./median.cjs"),u=require("./mod.cjs"),d=require("./normalize.cjs"),f=require("./percent.cjs"),p=require("./round.cjs"),m=require("./variance.cjs"),h=require("./standardDeviation.cjs");exports.allocate=n.allocate,exports.average=i.average,exports.clamp=e.clamp,exports.gcd=a.gcd,exports.lcm=o.lcm,exports.lerp=s.lerp,exports.linspace=c.linspace,exports.median=l.median,exports.mod=u.mod,exports.normalize=d.normalize,exports.percent=f.percent,exports.range=t.range,exports.round=p.round,exports.standardDeviation=h.standardDeviation,exports.sum=r.sum,exports.variance=m.variance;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./allocate.cjs"),t=require("./clamp.cjs"),n=require("./range.cjs"),r=require("./sum.cjs"),i=require("./average.cjs"),a=require("./gcd.cjs"),o=require("./lcm.cjs"),s=require("./lerp.cjs"),c=require("./linspace.cjs"),l=require("./median.cjs"),u=require("./mod.cjs"),d=require("./normalize.cjs"),f=require("./round.cjs"),p=require("./variance.cjs"),m=require("./standardDeviation.cjs");exports.allocate=e.allocate,exports.average=i.average,exports.clamp=t.clamp,exports.gcd=a.gcd,exports.lcm=o.lcm,exports.lerp=s.lerp,exports.linspace=c.linspace,exports.median=l.median,exports.mod=u.mod,exports.normalize=d.normalize,exports.range=n.range,exports.round=f.round,exports.standardDeviation=m.standardDeviation,exports.sum=r.sum,exports.variance=p.variance;
@@ -8,7 +8,6 @@ export * from './linspace';
8
8
  export * from './median';
9
9
  export * from './mod';
10
10
  export * from './normalize';
11
- export * from './percent';
12
11
  export * from './range';
13
12
  export * from './round';
14
13
  export * from './standardDeviation';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
- import { clamp as e } from "./clamp.js";
2
- import { range as t } from "./range.js";
3
- import { allocate as n } from "./allocate.js";
1
+ import { allocate as e } from "./allocate.js";
2
+ import { clamp as t } from "./clamp.js";
3
+ import { range as n } from "./range.js";
4
4
  import { sum as r } from "./sum.js";
5
5
  import { average as i } from "./average.js";
6
6
  import { gcd as a } from "./gcd.js";
@@ -10,8 +10,7 @@ import { linspace as c } from "./linspace.js";
10
10
  import { median as l } from "./median.js";
11
11
  import { mod as u } from "./mod.js";
12
12
  import { normalize as d } from "./normalize.js";
13
- import { percent as f } from "./percent.js";
14
- import { round as p } from "./round.js";
15
- import { variance as m } from "./variance.js";
16
- import { standardDeviation as h } from "./standardDeviation.js";
17
- export { n as allocate, i as average, e as clamp, a as gcd, o as lcm, s as lerp, c as linspace, l as median, u as mod, d as normalize, f as percent, t as range, p as round, h as standardDeviation, r as sum, m as variance };
13
+ import { round as f } from "./round.js";
14
+ import { variance as p } from "./variance.js";
15
+ import { standardDeviation as m } from "./standardDeviation.js";
16
+ export { e as allocate, i as average, t as clamp, a as gcd, o as lcm, s as lerp, c as linspace, l as median, u as mod, d as normalize, n as range, f as round, m as standardDeviation, r as sum, p as variance };
package/dist/math/lcm.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require("./gcd.cjs");function t(t,n){return t===0||n===0?0:Math.abs(t*n)/e.gcd(t,n)}exports.lcm=t;
1
+ const e=require("./gcd.cjs");function t(t,n){let r=e.gcd(t,n);if(r===0)return 0;let i=Math.abs(t/r*n);if(!Number.isSafeInteger(i))throw RangeError(`lcm: result exceeds the safe integer range`);return i}exports.lcm=t;
2
2
  //# sourceMappingURL=lcm.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lcm.cjs","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n\n return Math.abs(a * b) / gcd(a, b);\n}\n"],"mappings":"6BAeA,SAAgB,EAAI,EAAW,EAAmB,CAGhD,OAFI,IAAM,GAAK,IAAM,EAAU,EAExB,KAAK,IAAI,EAAI,CAAC,EAAI,EAAA,IAAI,EAAG,CAAC,CACnC"}
1
+ {"version":3,"file":"lcm.cjs","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n const divisor = gcd(a, b);\n\n if (divisor === 0) return 0;\n\n const result = Math.abs((a / divisor) * b);\n\n if (!Number.isSafeInteger(result)) throw new RangeError('lcm: result exceeds the safe integer range');\n\n return result;\n}\n"],"mappings":"6BAeA,SAAgB,EAAI,EAAW,EAAmB,CAChD,IAAM,EAAU,EAAA,IAAI,EAAG,CAAC,EAExB,GAAI,IAAY,EAAG,MAAO,GAE1B,IAAM,EAAS,KAAK,IAAK,EAAI,EAAW,CAAC,EAEzC,GAAI,CAAC,OAAO,cAAc,CAAM,EAAG,MAAU,WAAW,4CAA4C,EAEpG,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../../src/math/lcm.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhD"}
1
+ {"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../../src/math/lcm.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAUhD"}
package/dist/math/lcm.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { gcd as e } from "./gcd.js";
2
2
  //#region src/math/lcm.ts
3
3
  function t(t, n) {
4
- return t === 0 || n === 0 ? 0 : Math.abs(t * n) / e(t, n);
4
+ let r = e(t, n);
5
+ if (r === 0) return 0;
6
+ let i = Math.abs(t / r * n);
7
+ if (!Number.isSafeInteger(i)) throw RangeError("lcm: result exceeds the safe integer range");
8
+ return i;
5
9
  }
6
10
  //#endregion
7
11
  export { t as lcm };
@@ -1 +1 @@
1
- {"version":3,"file":"lcm.js","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n\n return Math.abs(a * b) / gcd(a, b);\n}\n"],"mappings":";;AAeA,SAAgB,EAAI,GAAW,GAAmB;CAGhD,OAFI,MAAM,KAAK,MAAM,IAAU,IAExB,KAAK,IAAI,IAAI,CAAC,IAAI,EAAI,GAAG,CAAC;AACnC"}
1
+ {"version":3,"file":"lcm.js","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n const divisor = gcd(a, b);\n\n if (divisor === 0) return 0;\n\n const result = Math.abs((a / divisor) * b);\n\n if (!Number.isSafeInteger(result)) throw new RangeError('lcm: result exceeds the safe integer range');\n\n return result;\n}\n"],"mappings":";;AAeA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAM,IAAU,EAAI,GAAG,CAAC;CAExB,IAAI,MAAY,GAAG,OAAO;CAE1B,IAAM,IAAS,KAAK,IAAK,IAAI,IAAW,CAAC;CAEzC,IAAI,CAAC,OAAO,cAAc,CAAM,GAAG,MAAU,WAAW,4CAA4C;CAEpG,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- function e(e,t,n=5){if(n<=0)return[];if(n===1)return[e];let r=(t-e)/(n-1);return Array.from({length:n},(t,n)=>e+n*r)}exports.linspace=e;
1
+ function e(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t))throw RangeError(`linspace: bounds must be finite`);if(!Number.isSafeInteger(n)||n<1)throw RangeError(`linspace: steps must be a positive integer`);if(n===1)return[e];let r=(t-e)/(n-1);return Array.from({length:n},(t,n)=>e+n*r)}exports.linspace=e;
2
2
  //# sourceMappingURL=linspace.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"linspace.cjs","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":"AAiBA,SAAgB,EAAS,EAAe,EAAa,EAAQ,EAAa,CACxE,GAAI,GAAS,EAAG,MAAO,CAAC,EAExB,GAAI,IAAU,EAAG,MAAO,CAAC,CAAK,EAE9B,IAAM,GAAY,EAAM,IAAU,EAAQ,GAE1C,OAAO,MAAM,KAAK,CAAE,OAAQ,CAAM,GAAI,EAAG,IAAM,EAAQ,EAAI,CAAQ,CACrE"}
1
+ {"version":3,"file":"linspace.cjs","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (!Number.isFinite(start) || !Number.isFinite(end)) throw new RangeError('linspace: bounds must be finite');\n if (!Number.isSafeInteger(steps) || steps < 1) throw new RangeError('linspace: steps must be a positive integer');\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":"AAiBA,SAAgB,EAAS,EAAe,EAAa,EAAQ,EAAa,CACxE,GAAI,CAAC,OAAO,SAAS,CAAK,GAAK,CAAC,OAAO,SAAS,CAAG,EAAG,MAAU,WAAW,iCAAiC,EAC5G,GAAI,CAAC,OAAO,cAAc,CAAK,GAAK,EAAQ,EAAG,MAAU,WAAW,4CAA4C,EAEhH,GAAI,IAAU,EAAG,MAAO,CAAC,CAAK,EAE9B,IAAM,GAAY,EAAM,IAAU,EAAQ,GAE1C,OAAO,MAAM,KAAK,CAAE,OAAQ,CAAM,GAAI,EAAG,IAAM,EAAQ,EAAI,CAAQ,CACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"linspace.d.ts","sourceRoot":"","sources":["../../src/math/linspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,EAAE,CAQxE"}
1
+ {"version":3,"file":"linspace.d.ts","sourceRoot":"","sources":["../../src/math/linspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,EAAE,CASxE"}
@@ -1,6 +1,7 @@
1
1
  //#region src/math/linspace.ts
2
2
  function e(e, t, n = 5) {
3
- if (n <= 0) return [];
3
+ if (!Number.isFinite(e) || !Number.isFinite(t)) throw RangeError("linspace: bounds must be finite");
4
+ if (!Number.isSafeInteger(n) || n < 1) throw RangeError("linspace: steps must be a positive integer");
4
5
  if (n === 1) return [e];
5
6
  let r = (t - e) / (n - 1);
6
7
  return Array.from({ length: n }, (t, n) => e + n * r);
@@ -1 +1 @@
1
- {"version":3,"file":"linspace.js","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":";AAiBA,SAAgB,EAAS,GAAe,GAAa,IAAQ,GAAa;CACxE,IAAI,KAAS,GAAG,OAAO,CAAC;CAExB,IAAI,MAAU,GAAG,OAAO,CAAC,CAAK;CAE9B,IAAM,KAAY,IAAM,MAAU,IAAQ;CAE1C,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAM,IAAI,GAAG,MAAM,IAAQ,IAAI,CAAQ;AACrE"}
1
+ {"version":3,"file":"linspace.js","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (!Number.isFinite(start) || !Number.isFinite(end)) throw new RangeError('linspace: bounds must be finite');\n if (!Number.isSafeInteger(steps) || steps < 1) throw new RangeError('linspace: steps must be a positive integer');\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":";AAiBA,SAAgB,EAAS,GAAe,GAAa,IAAQ,GAAa;CACxE,IAAI,CAAC,OAAO,SAAS,CAAK,KAAK,CAAC,OAAO,SAAS,CAAG,GAAG,MAAU,WAAW,iCAAiC;CAC5G,IAAI,CAAC,OAAO,cAAc,CAAK,KAAK,IAAQ,GAAG,MAAU,WAAW,4CAA4C;CAEhH,IAAI,MAAU,GAAG,OAAO,CAAC,CAAK;CAE9B,IAAM,KAAY,IAAM,MAAU,IAAQ;CAE1C,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAM,IAAI,GAAG,MAAM,IAAQ,IAAI,CAAQ;AACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"median.cjs","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":"AAeA,SAAgB,EAAU,EAAU,EAAoD,CACtF,GAAI,EAAI,SAAW,EAAG,OAEtB,IAAM,EAAS,EAAW,EAAI,IAAI,CAAQ,EAAI,CAAC,GAAI,CAA2B,EAE9E,EAAO,MAAM,EAAG,IAAM,EAAI,CAAC,EAE3B,IAAM,EAAM,KAAK,MAAM,EAAO,OAAS,CAAC,EAExC,OAAO,EAAO,OAAS,GAAM,GAAK,EAAO,EAAM,GAAK,EAAO,IAAQ,EAAI,EAAO,EAChF"}
1
+ {"version":3,"file":"median.cjs","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: readonly T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":"AAeA,SAAgB,EAAU,EAAmB,EAAoD,CAC/F,GAAI,EAAI,SAAW,EAAG,OAEtB,IAAM,EAAS,EAAW,EAAI,IAAI,CAAQ,EAAI,CAAC,GAAI,CAA2B,EAE9E,EAAO,MAAM,EAAG,IAAM,EAAI,CAAC,EAE3B,IAAM,EAAM,KAAK,MAAM,EAAO,OAAS,CAAC,EAExC,OAAO,EAAO,OAAS,GAAM,GAAK,EAAO,EAAM,GAAK,EAAO,IAAQ,EAAI,EAAO,EAChF"}
@@ -13,5 +13,5 @@
13
13
  * @param callback - (optional) A callback function to map each item to a number.
14
14
  * @returns The median, or `undefined` if the array is empty.
15
15
  */
16
- export declare function median<T>(arr: T[], callback?: (item: T) => number): number | undefined;
16
+ export declare function median<T>(arr: readonly T[], callback?: (item: T) => number): number | undefined;
17
17
  //# sourceMappingURL=median.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../src/math/median.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAUtF"}
1
+ {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../src/math/median.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAU/F"}
@@ -1 +1 @@
1
- {"version":3,"file":"median.js","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":";AAeA,SAAgB,EAAU,GAAU,GAAoD;CACtF,IAAI,EAAI,WAAW,GAAG;CAEtB,IAAM,IAAS,IAAW,EAAI,IAAI,CAAQ,IAAI,CAAC,GAAI,CAA2B;CAE9E,EAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAE3B,IAAM,IAAM,KAAK,MAAM,EAAO,SAAS,CAAC;CAExC,OAAO,EAAO,SAAS,KAAM,KAAK,EAAO,IAAM,KAAK,EAAO,MAAQ,IAAI,EAAO;AAChF"}
1
+ {"version":3,"file":"median.js","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: readonly T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":";AAeA,SAAgB,EAAU,GAAmB,GAAoD;CAC/F,IAAI,EAAI,WAAW,GAAG;CAEtB,IAAM,IAAS,IAAW,EAAI,IAAI,CAAQ,IAAI,CAAC,GAAI,CAA2B;CAE9E,EAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAE3B,IAAM,IAAM,KAAK,MAAM,EAAO,SAAS,CAAC;CAExC,OAAO,EAAO,SAAS,KAAM,KAAK,EAAO,IAAM,KAAK,EAAO,MAAQ,IAAI,EAAO;AAChF"}
@@ -1 +1 @@
1
- {"version":3,"file":"standardDeviation.cjs","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":"kCAgBA,SAAgB,EAAqB,EAAY,EAAwC,CACvF,OAAO,KAAK,KAAK,EAAA,SAAS,EAAO,CAAQ,CAAC,CAC5C"}
1
+ {"version":3,"file":"standardDeviation.cjs","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: readonly T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":"kCAgBA,SAAgB,EAAqB,EAAqB,EAAwC,CAChG,OAAO,KAAK,KAAK,EAAA,SAAS,EAAO,CAAQ,CAAC,CAC5C"}
@@ -12,5 +12,5 @@
12
12
  * @param callback - An optional callback to map each item to a number.
13
13
  * @returns The population standard deviation, or `0` for an empty array.
14
14
  */
15
- export declare function standardDeviation<T>(array: T[], callback?: (item: T) => number): number;
15
+ export declare function standardDeviation<T>(array: readonly T[], callback?: (item: T) => number): number;
16
16
  //# sourceMappingURL=standardDeviation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standardDeviation.d.ts","sourceRoot":"","sources":["../../src/math/standardDeviation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAEvF"}
1
+ {"version":3,"file":"standardDeviation.d.ts","sourceRoot":"","sources":["../../src/math/standardDeviation.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAEhG"}
@@ -1 +1 @@
1
- {"version":3,"file":"standardDeviation.js","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":";;AAgBA,SAAgB,EAAqB,GAAY,GAAwC;CACvF,OAAO,KAAK,KAAK,EAAS,GAAO,CAAQ,CAAC;AAC5C"}
1
+ {"version":3,"file":"standardDeviation.js","names":[],"sources":["../../src/math/standardDeviation.ts"],"sourcesContent":["import { variance } from './variance';\n\n/**\n * Computes the population standard deviation (square root of `variance`) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2\n * standardDeviation([]); // 0\n * ```\n *\n * @param array - The array to compute standard deviation over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population standard deviation, or `0` for an empty array.\n */\nexport function standardDeviation<T>(array: readonly T[], callback?: (item: T) => number): number {\n return Math.sqrt(variance(array, callback));\n}\n"],"mappings":";;AAgBA,SAAgB,EAAqB,GAAqB,GAAwC;CAChG,OAAO,KAAK,KAAK,EAAS,GAAO,CAAQ,CAAC;AAC5C"}
package/dist/math/sum.cjs CHANGED
@@ -1,2 +1,2 @@
1
- function e(e,t){return e.length===0?0:e.reduce((e,n)=>{let r=t?t(n):n;if(typeof r!=`number`||Number.isNaN(r))throw TypeError(`sum: encountered a non-numeric value; provide a callback to map non-number items`);return e+r},0)}exports.sum=e;
1
+ function e(e,t){return e.length===0?0:e.reduce((e,n)=>{let r=t?t(n):n;if(!Number.isFinite(r))throw TypeError(`sum: encountered a non-numeric value; provide a callback to map non-number items`);return e+r},0)}exports.sum=e;
2
2
  //# sourceMappingURL=sum.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sum.cjs","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // TypeError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {TypeError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (typeof val !== 'number' || Number.isNaN(val)) {\n throw new TypeError('sum: encountered a non-numeric value; provide a callback to map non-number items');\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":"AAiBA,SAAgB,EAAO,EAAY,EAAwC,CAGzE,OAFI,EAAM,SAAW,EAAU,EAExB,EAAM,QAAgB,EAAK,IAAS,CACzC,IAAM,EAAM,EAAW,EAAS,CAAI,EAAK,EAEzC,GAAI,OAAO,GAAQ,UAAY,OAAO,MAAM,CAAG,EAC7C,MAAU,UAAU,kFAAkF,EAGxG,OAAO,EAAM,CACf,EAAG,CAAC,CACN"}
1
+ {"version":3,"file":"sum.cjs","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // TypeError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {TypeError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: readonly T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (!Number.isFinite(val)) {\n throw new TypeError('sum: encountered a non-numeric value; provide a callback to map non-number items');\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":"AAiBA,SAAgB,EAAO,EAAqB,EAAwC,CAGlF,OAFI,EAAM,SAAW,EAAU,EAExB,EAAM,QAAgB,EAAK,IAAS,CACzC,IAAM,EAAM,EAAW,EAAS,CAAI,EAAK,EAEzC,GAAI,CAAC,OAAO,SAAS,CAAG,EACtB,MAAU,UAAU,kFAAkF,EAGxG,OAAO,EAAM,CACf,EAAG,CAAC,CACN"}
@@ -15,5 +15,5 @@
15
15
  *
16
16
  * @throws {TypeError} If (after an optional `callback` mapping) any item is not a finite number.
17
17
  */
18
- export declare function sum<T>(array: T[], callback?: (item: T) => number): number;
18
+ export declare function sum<T>(array: readonly T[], callback?: (item: T) => number): number;
19
19
  //# sourceMappingURL=sum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sum.d.ts","sourceRoot":"","sources":["../../src/math/sum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAYzE"}
1
+ {"version":3,"file":"sum.d.ts","sourceRoot":"","sources":["../../src/math/sum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAYlF"}
package/dist/math/sum.js CHANGED
@@ -2,7 +2,7 @@
2
2
  function e(e, t) {
3
3
  return e.length === 0 ? 0 : e.reduce((e, n) => {
4
4
  let r = t ? t(n) : n;
5
- if (typeof r != "number" || Number.isNaN(r)) throw TypeError("sum: encountered a non-numeric value; provide a callback to map non-number items");
5
+ if (!Number.isFinite(r)) throw TypeError("sum: encountered a non-numeric value; provide a callback to map non-number items");
6
6
  return e + r;
7
7
  }, 0);
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sum.js","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // TypeError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {TypeError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (typeof val !== 'number' || Number.isNaN(val)) {\n throw new TypeError('sum: encountered a non-numeric value; provide a callback to map non-number items');\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":";AAiBA,SAAgB,EAAO,GAAY,GAAwC;CAGzE,OAFI,EAAM,WAAW,IAAU,IAExB,EAAM,QAAgB,GAAK,MAAS;EACzC,IAAM,IAAM,IAAW,EAAS,CAAI,IAAK;EAEzC,IAAI,OAAO,KAAQ,YAAY,OAAO,MAAM,CAAG,GAC7C,MAAU,UAAU,kFAAkF;EAGxG,OAAO,IAAM;CACf,GAAG,CAAC;AACN"}
1
+ {"version":3,"file":"sum.js","names":[],"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Sum numbers in an array or numbers mapped by a callback function.\n *\n * @example\n * ```ts\n * sum([1, 2, 3]) // 6\n * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6\n * sum(['apple', 'banana', 'cherry']) // TypeError\n * ```\n *\n * @param array - The array to sum.\n * @param callback - An optional callback function to map the values.\n *\n * @returns The sum of the numbers in the array or the sum of the mapped values.\n *\n * @throws {TypeError} If (after an optional `callback` mapping) any item is not a finite number.\n */\nexport function sum<T>(array: readonly T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : (item as unknown as number);\n\n if (!Number.isFinite(val)) {\n throw new TypeError('sum: encountered a non-numeric value; provide a callback to map non-number items');\n }\n\n return acc + val;\n }, 0);\n}\n"],"mappings":";AAiBA,SAAgB,EAAO,GAAqB,GAAwC;CAGlF,OAFI,EAAM,WAAW,IAAU,IAExB,EAAM,QAAgB,GAAK,MAAS;EACzC,IAAM,IAAM,IAAW,EAAS,CAAI,IAAK;EAEzC,IAAI,CAAC,OAAO,SAAS,CAAG,GACtB,MAAU,UAAU,kFAAkF;EAGxG,OAAO,IAAM;CACf,GAAG,CAAC;AACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"variance.cjs","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":"iCAiBA,SAAgB,EAAY,EAAY,EAAwC,CAC9E,GAAI,EAAM,SAAW,EAAG,MAAO,GAE/B,IAAM,EAAS,EAAW,EAAM,IAAI,CAAQ,EAAK,EAC3C,EAAO,EAAA,QAAQ,CAAM,GAAK,EAEhC,OAAO,EAAA,QAAQ,EAAO,IAAK,IAAW,EAAQ,IAAS,CAAC,CAAC,GAAK,CAChE"}
1
+ {"version":3,"file":"variance.cjs","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: readonly T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":"iCAiBA,SAAgB,EAAY,EAAqB,EAAwC,CACvF,GAAI,EAAM,SAAW,EAAG,MAAO,GAE/B,IAAM,EAAS,EAAW,EAAM,IAAI,CAAQ,EAAK,EAC3C,EAAO,EAAA,QAAQ,CAAM,GAAK,EAEhC,OAAO,EAAA,QAAQ,EAAO,IAAK,IAAW,EAAQ,IAAS,CAAC,CAAC,GAAK,CAChE"}
@@ -13,5 +13,5 @@
13
13
  * @param callback - An optional callback to map each item to a number.
14
14
  * @returns The population variance, or `0` for an empty array.
15
15
  */
16
- export declare function variance<T>(array: T[], callback?: (item: T) => number): number;
16
+ export declare function variance<T>(array: readonly T[], callback?: (item: T) => number): number;
17
17
  //# sourceMappingURL=variance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variance.d.ts","sourceRoot":"","sources":["../../src/math/variance.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAO9E"}
1
+ {"version":3,"file":"variance.d.ts","sourceRoot":"","sources":["../../src/math/variance.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAOvF"}
@@ -1 +1 @@
1
- {"version":3,"file":"variance.js","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAY,GAAY,GAAwC;CAC9E,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,IAAS,IAAW,EAAM,IAAI,CAAQ,IAAK,GAC3C,IAAO,EAAQ,CAAM,KAAK;CAEhC,OAAO,EAAQ,EAAO,KAAK,OAAW,IAAQ,MAAS,CAAC,CAAC,KAAK;AAChE"}
1
+ {"version":3,"file":"variance.js","names":[],"sources":["../../src/math/variance.ts"],"sourcesContent":["import { average } from './average';\n\n/**\n * Computes the population variance (average squared deviation from the mean) of an array of\n * numbers, or of values mapped by a callback.\n *\n * @example\n * ```ts\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // 4\n * variance([{ n: 1 }, { n: 3 }], (item) => item.n); // 1\n * variance([]); // 0\n * ```\n *\n * @param array - The array to compute variance over.\n * @param callback - An optional callback to map each item to a number.\n * @returns The population variance, or `0` for an empty array.\n */\nexport function variance<T>(array: readonly T[], callback?: (item: T) => number): number {\n if (array.length === 0) return 0;\n\n const values = callback ? array.map(callback) : (array as unknown as number[]);\n const mean = average(values) ?? 0;\n\n return average(values.map((value) => (value - mean) ** 2)) ?? 0;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAY,GAAqB,GAAwC;CACvF,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,IAAS,IAAW,EAAM,IAAI,CAAQ,IAAK,GAC3C,IAAO,EAAQ,CAAM,KAAK;CAEhC,OAAO,EAAQ,EAAO,KAAK,OAAW,IAAQ,MAAS,CAAC,CAAC,KAAK;AAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.cjs","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":"uFAmBA,SAAgB,EAAwB,EAAW,GAAG,EAA+B,CACnF,IAAM,EAAM,CAAE,GAAG,CAAO,EAExB,IAAK,IAAM,KAAU,EACd,KAAA,cAAc,CAAM,EAEzB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAC9B,EAAA,YAAY,CAAkB,GAE9B,EAAI,KAAS,IAAA,KACf,EAAI,GAAO,EAAO,IAKxB,OAAO,CACT"}
1
+ {"version":3,"file":"defaults.cjs","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":"uFAkBA,SAAgB,EAAwB,EAAW,GAAG,EAA+B,CACnF,IAAM,EAAM,CAAE,GAAG,CAAO,EAExB,IAAK,IAAM,KAAU,EACd,KAAA,cAAc,CAAM,EAEzB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAC9B,EAAA,YAAY,CAAkB,GAE9B,EAAI,KAAS,IAAA,KACf,EAAI,GAAO,EAAO,IAKxB,OAAO,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/object/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAKpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAgBnF"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/object/defaults.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAgBnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":";;;AAmBA,SAAgB,EAAwB,GAAW,GAAG,GAA+B;CACnF,IAAM,IAAM,EAAE,GAAG,EAAO;CAExB,KAAK,IAAM,KAAU,GACd,MAAc,CAAM,GAEzB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAC9B,EAAY,CAAkB,KAE9B,EAAI,OAAS,KAAA,MACf,EAAI,KAAO,EAAO;CAKxB,OAAO;AACT"}
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../src/object/defaults.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\n\n/**\n * Fills in `undefined` properties in `target` with values from `sources`. First source wins\n * — unlike `shallowMerge`, already-set keys are never overwritten.\n *\n * @example\n * ```ts\n * defaults({ a: 1, b: undefined }, { a: 99, b: 2, c: 3 });\n * // { a: 1, b: 2, c: 3 }\n * ```\n *\n * @param target - The object to fill in.\n * @param sources - One or more partial objects supplying default values.\n * @returns A new object with missing keys filled from `sources`.\n */\nexport function defaults<T extends Obj>(target: T, ...sources: Array<Partial<T>>): T {\n const out = { ...target };\n\n for (const source of sources) {\n if (!isPlainObject(source)) continue;\n\n for (const key of Object.keys(source) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (out[key] === undefined) {\n out[key] = source[key] as T[keyof T];\n }\n }\n }\n\n return out;\n}\n"],"mappings":";;;AAkBA,SAAgB,EAAwB,GAAW,GAAG,GAA+B;CACnF,IAAM,IAAM,EAAE,GAAG,EAAO;CAExB,KAAK,IAAM,KAAU,GACd,MAAc,CAAM,GAEzB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAC9B,EAAY,CAAkB,KAE9B,EAAI,OAAS,KAAA,MACf,EAAI,KAAO,EAAO;CAKxB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.cjs","names":[],"sources":["../../src/object/diff.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isEqual } from '../guards/isEqual';\n\nexport type DiffResult<T extends Obj> = {\n /** Keys present in `after` but not in `before`. */\n added: Array<keyof T & string>;\n /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */\n changed: { [K in keyof T]?: { after: T[K]; before: T[K] } };\n /** Keys present in `before` but not in `after`. */\n removed: Array<keyof T & string>;\n};\n\n/**\n * Computes the structural difference between two plain objects.\n * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.\n *\n * @example\n * ```ts\n * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });\n * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }\n *\n * diff({ x: { n: 1 } }, { x: { n: 2 } });\n * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }\n * ```\n *\n * @param before - The original object.\n * @param after - The updated object.\n * @param compareFn - Custom equality function. Defaults to deep `isEqual`.\n */\nexport function diff<T extends Obj>(\n before: T = {} as T,\n after: T = {} as T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): DiffResult<T> {\n const added: Array<keyof T & string> = [];\n const removed: Array<keyof T & string> = [];\n const changed: Record<string, { after: unknown; before: unknown }> = {};\n\n const beforeKeys = new Set(Object.keys(before));\n const afterKeys = new Set(Object.keys(after));\n\n for (const key of afterKeys) {\n if (!beforeKeys.has(key)) {\n added.push(key as keyof T & string);\n } else if (!isUnsafeKey(key) && !compareFn(before[key], after[key])) {\n changed[key] = { after: after[key], before: before[key] };\n }\n }\n\n for (const key of beforeKeys) {\n if (!afterKeys.has(key)) {\n removed.push(key as keyof T & string);\n }\n }\n\n return { added, changed: changed as DiffResult<T>['changed'], removed };\n}\n\nexport type ArrayDiff<T> = {\n added: T[];\n removed: T[];\n};\n\nexport type ArrayDiffOptions<T> = {\n compareFn?: (a: T, b: T) => boolean;\n};\n\n/**\n * Computes the set-difference between two arrays.\n * Items present in `after` but not `before` are `added`.\n * Items present in `before` but not `after` are `removed`.\n * Order-independent; uses deep equality by default.\n *\n * @example\n * ```ts\n * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }\n * diffArrays(\n * [{ id: 1 }, { id: 2 }],\n * [{ id: 2 }, { id: 3 }],\n * { compareFn: (a, b) => a.id === b.id },\n * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }\n * ```\n *\n * @param before - The original array.\n * @param after - The updated array.\n * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.\n * @returns An object with `added` and `removed` arrays.\n */\nexport function diffArrays<T>(before: T[], after: T[], options?: ArrayDiffOptions<T>): ArrayDiff<T> {\n const compareFn = options?.compareFn ?? ((a: T, b: T) => isEqual(a, b));\n\n return {\n added: after.filter((item) => !before.some((b) => compareFn(b, item))),\n removed: before.filter((item) => !after.some((a) => compareFn(item, a))),\n };\n}\n"],"mappings":"iFAgCA,SAAgB,EACd,EAAY,CAAC,EACb,EAAW,CAAC,EACZ,EAAiD,EAAA,QAClC,CACf,IAAM,EAAiC,CAAC,EAClC,EAAmC,CAAC,EACpC,EAA+D,CAAC,EAEhE,EAAa,IAAI,IAAI,OAAO,KAAK,CAAM,CAAC,EACxC,EAAY,IAAI,IAAI,OAAO,KAAK,CAAK,CAAC,EAE5C,IAAK,IAAM,KAAO,EACX,EAAW,IAAI,CAAG,EAEZ,CAAC,EAAA,YAAY,CAAG,GAAK,CAAC,EAAU,EAAO,GAAM,EAAM,EAAI,IAChE,EAAQ,GAAO,CAAE,MAAO,EAAM,GAAM,OAAQ,EAAO,EAAK,GAFxD,EAAM,KAAK,CAAuB,EAMtC,IAAK,IAAM,KAAO,EACX,EAAU,IAAI,CAAG,GACpB,EAAQ,KAAK,CAAuB,EAIxC,MAAO,CAAE,QAAgB,UAAqC,SAAQ,CACxE,CAgCA,SAAgB,EAAc,EAAa,EAAY,EAA6C,CAClG,IAAM,EAAY,GAAS,aAAe,EAAM,IAAS,EAAA,QAAQ,EAAG,CAAC,GAErE,MAAO,CACL,MAAO,EAAM,OAAQ,GAAS,CAAC,EAAO,KAAM,GAAM,EAAU,EAAG,CAAI,CAAC,CAAC,EACrE,QAAS,EAAO,OAAQ,GAAS,CAAC,EAAM,KAAM,GAAM,EAAU,EAAM,CAAC,CAAC,CAAC,CACzE,CACF"}
1
+ {"version":3,"file":"diff.cjs","names":[],"sources":["../../src/object/diff.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isEqual } from '../guards/isEqual';\nimport type { Obj } from '../types';\n\nexport type DiffResult<T extends Obj> = {\n /** Keys present in `after` but not in `before`. */\n added: Array<keyof T & string>;\n /** Keys present in both objects whose values differ. Maps key → `{ before, after }`. */\n changed: { [K in keyof T]?: { after: T[K]; before: T[K] } };\n /** Keys present in `before` but not in `after`. */\n removed: Array<keyof T & string>;\n};\n\n/**\n * Computes the structural difference between two plain objects.\n * Returns an `{ added, removed, changed }` result — no sentinel symbols needed.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are omitted from `changed`.\n *\n * @example\n * ```ts\n * diff({ a: 1, b: 2, c: 3 }, { a: 1, b: 99 });\n * // { added: [], removed: ['c'], changed: { b: { before: 2, after: 99 } } }\n *\n * diff({ x: { n: 1 } }, { x: { n: 2 } });\n * // { added: [], removed: [], changed: { x: { before: { n: 1 }, after: { n: 2 } } } }\n * ```\n *\n * @param before - The original object.\n * @param after - The updated object.\n * @param compareFn - Custom equality function. Defaults to deep `isEqual`.\n */\nexport function diff<T extends Obj>(\n before: T = {} as T,\n after: T = {} as T,\n compareFn: (a: unknown, b: unknown) => boolean = isEqual,\n): DiffResult<T> {\n const added: Array<keyof T & string> = [];\n const removed: Array<keyof T & string> = [];\n const changed: Record<string, { after: unknown; before: unknown }> = {};\n\n const beforeKeys = new Set(Object.keys(before));\n const afterKeys = new Set(Object.keys(after));\n\n for (const key of afterKeys) {\n if (!beforeKeys.has(key)) {\n added.push(key as keyof T & string);\n } else if (!isUnsafeKey(key) && !compareFn(before[key], after[key])) {\n changed[key] = { after: after[key], before: before[key] };\n }\n }\n\n for (const key of beforeKeys) {\n if (!afterKeys.has(key)) {\n removed.push(key as keyof T & string);\n }\n }\n\n return { added, changed: changed as DiffResult<T>['changed'], removed };\n}\n\nexport type ArrayDiff<T> = {\n added: T[];\n removed: T[];\n};\n\nexport type ArrayDiffOptions<T> = {\n compareFn?: (a: T, b: T) => boolean;\n};\n\n/**\n * Computes the set-difference between two arrays.\n * Items present in `after` but not `before` are `added`.\n * Items present in `before` but not `after` are `removed`.\n * Order-independent; uses deep equality by default.\n *\n * @example\n * ```ts\n * diffArrays([1, 2, 3], [2, 3, 4]); // { added: [4], removed: [1] }\n * diffArrays(\n * [{ id: 1 }, { id: 2 }],\n * [{ id: 2 }, { id: 3 }],\n * { compareFn: (a, b) => a.id === b.id },\n * ); // { added: [{ id: 3 }], removed: [{ id: 1 }] }\n * ```\n *\n * @param before - The original array.\n * @param after - The updated array.\n * @param [options.compareFn] - Custom equality function. Defaults to deep `isEqual`.\n * @returns An object with `added` and `removed` arrays.\n */\nexport function diffArrays<T>(before: readonly T[], after: readonly T[], options?: ArrayDiffOptions<T>): ArrayDiff<T> {\n const compareFn = options?.compareFn ?? ((a: T, b: T) => isEqual(a, b));\n\n return {\n added: after.filter((item) => !before.some((b) => compareFn(b, item))),\n removed: before.filter((item) => !after.some((a) => compareFn(item, a))),\n };\n}\n"],"mappings":"iFA+BA,SAAgB,EACd,EAAY,CAAC,EACb,EAAW,CAAC,EACZ,EAAiD,EAAA,QAClC,CACf,IAAM,EAAiC,CAAC,EAClC,EAAmC,CAAC,EACpC,EAA+D,CAAC,EAEhE,EAAa,IAAI,IAAI,OAAO,KAAK,CAAM,CAAC,EACxC,EAAY,IAAI,IAAI,OAAO,KAAK,CAAK,CAAC,EAE5C,IAAK,IAAM,KAAO,EACX,EAAW,IAAI,CAAG,EAEZ,CAAC,EAAA,YAAY,CAAG,GAAK,CAAC,EAAU,EAAO,GAAM,EAAM,EAAI,IAChE,EAAQ,GAAO,CAAE,MAAO,EAAM,GAAM,OAAQ,EAAO,EAAK,GAFxD,EAAM,KAAK,CAAuB,EAMtC,IAAK,IAAM,KAAO,EACX,EAAU,IAAI,CAAG,GACpB,EAAQ,KAAK,CAAuB,EAIxC,MAAO,CAAE,QAAgB,UAAqC,SAAQ,CACxE,CAgCA,SAAgB,EAAc,EAAsB,EAAqB,EAA6C,CACpH,IAAM,EAAY,GAAS,aAAe,EAAM,IAAS,EAAA,QAAQ,EAAG,CAAC,GAErE,MAAO,CACL,MAAO,EAAM,OAAQ,GAAS,CAAC,EAAO,KAAM,GAAM,EAAU,EAAG,CAAI,CAAC,CAAC,EACrE,QAAS,EAAO,OAAQ,GAAS,CAAC,EAAM,KAAM,GAAM,EAAU,EAAM,CAAC,CAAC,CAAC,CACzE,CACF"}