@vielzeug/arsenal 1.1.2 → 2.0.1
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.
- package/README.md +31 -75
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +2 -5
- package/dist/_dev.js.map +1 -1
- package/dist/array/chunk.cjs +1 -1
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.d.ts +2 -1
- package/dist/array/chunk.d.ts.map +1 -1
- package/dist/array/chunk.js +5 -7
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compare.cjs +1 -1
- package/dist/array/compare.cjs.map +1 -1
- package/dist/array/compare.d.ts.map +1 -1
- package/dist/array/compare.js +13 -14
- package/dist/array/compare.js.map +1 -1
- package/dist/array/index.cjs +1 -0
- package/dist/array/index.js +29 -0
- package/dist/array/search.cjs +1 -1
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.d.ts +8 -77
- package/dist/array/search.d.ts.map +1 -1
- package/dist/array/search.js +21 -38
- package/dist/array/search.js.map +1 -1
- package/dist/array/sort.cjs +1 -1
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.d.ts +1 -1
- package/dist/array/sort.d.ts.map +1 -1
- package/dist/array/sort.js +9 -10
- package/dist/array/sort.js.map +1 -1
- package/dist/arsenal.cjs +1 -1
- package/dist/arsenal.cjs.map +1 -1
- package/dist/arsenal.iife.js +1 -1
- package/dist/arsenal.iife.js.map +1 -1
- package/dist/arsenal.js +1 -1
- package/dist/arsenal.js.map +1 -1
- package/dist/async/attempt.cjs +1 -1
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.d.ts +3 -8
- package/dist/async/attempt.d.ts.map +1 -1
- package/dist/async/attempt.js +3 -10
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/index.cjs +1 -0
- package/dist/async/index.d.ts +1 -1
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +9 -0
- package/dist/async/parallel.cjs +1 -1
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.d.ts +1 -1
- package/dist/async/parallel.d.ts.map +1 -1
- package/dist/async/parallel.js +15 -16
- package/dist/async/parallel.js.map +1 -1
- package/dist/async/retry.cjs +1 -1
- package/dist/async/retry.cjs.map +1 -1
- package/dist/async/retry.d.ts +1 -1
- package/dist/async/retry.d.ts.map +1 -1
- package/dist/async/retry.js +14 -15
- package/dist/async/retry.js.map +1 -1
- package/dist/async/taskPool.cjs +2 -0
- package/dist/async/taskPool.cjs.map +1 -0
- package/dist/async/taskPool.d.ts +14 -0
- package/dist/async/taskPool.d.ts.map +1 -0
- package/dist/async/taskPool.js +51 -0
- package/dist/async/taskPool.js.map +1 -0
- package/dist/cache/cache.cjs +2 -0
- package/dist/cache/cache.cjs.map +1 -0
- package/dist/cache/cache.d.ts +17 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +59 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/index.cjs +1 -0
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +3 -0
- package/dist/cache/memo.cjs +1 -1
- package/dist/cache/memo.cjs.map +1 -1
- package/dist/cache/memo.d.ts +2 -2
- package/dist/cache/memo.js +24 -23
- package/dist/cache/memo.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +0 -7
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/function/debounce.cjs +1 -1
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.js +15 -17
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/index.cjs +1 -0
- package/dist/function/index.d.ts +0 -2
- package/dist/function/index.d.ts.map +1 -1
- package/dist/function/index.js +8 -0
- package/dist/function/pipe.cjs +1 -1
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.js +1 -1
- package/dist/function/pipe.js.map +1 -1
- package/dist/guards/index.cjs +1 -0
- package/dist/guards/index.d.ts +0 -3
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +17 -0
- package/dist/guards/isEqual.cjs.map +1 -1
- package/dist/guards/isEqual.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -91
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -118
- package/dist/math/allocate.cjs +1 -1
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.d.ts +1 -1
- package/dist/math/allocate.d.ts.map +1 -1
- package/dist/math/allocate.js +13 -14
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/index.cjs +1 -0
- package/dist/math/index.d.ts +0 -3
- package/dist/math/index.d.ts.map +1 -1
- package/dist/math/index.js +17 -0
- package/dist/math/mod.cjs +1 -1
- package/dist/math/mod.cjs.map +1 -1
- package/dist/math/mod.d.ts +1 -1
- package/dist/math/mod.d.ts.map +1 -1
- package/dist/math/mod.js +4 -5
- package/dist/math/mod.js.map +1 -1
- package/dist/math/range.cjs +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.d.ts +1 -1
- package/dist/math/range.d.ts.map +1 -1
- package/dist/math/range.js +14 -15
- package/dist/math/range.js.map +1 -1
- package/dist/math/sum.cjs +1 -1
- package/dist/math/sum.cjs.map +1 -1
- package/dist/math/sum.d.ts +2 -2
- package/dist/math/sum.d.ts.map +1 -1
- package/dist/math/sum.js +6 -7
- package/dist/math/sum.js.map +1 -1
- package/dist/object/getPath.cjs +1 -1
- package/dist/object/getPath.cjs.map +1 -1
- package/dist/object/getPath.d.ts +12 -42
- package/dist/object/getPath.d.ts.map +1 -1
- package/dist/object/getPath.js +21 -22
- package/dist/object/getPath.js.map +1 -1
- package/dist/object/index.cjs +1 -0
- package/dist/object/index.d.ts +1 -1
- package/dist/object/index.d.ts.map +1 -1
- package/dist/object/index.js +15 -0
- package/dist/object/merge.cjs +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.d.ts +1 -1
- package/dist/object/merge.d.ts.map +1 -1
- package/dist/object/merge.js +2 -3
- package/dist/object/merge.js.map +1 -1
- package/dist/object/prune.cjs +1 -1
- package/dist/object/prune.cjs.map +1 -1
- package/dist/object/prune.d.ts.map +1 -1
- package/dist/object/prune.js +22 -23
- package/dist/object/prune.js.map +1 -1
- package/dist/object/tryParseJson.cjs +2 -0
- package/dist/object/tryParseJson.cjs.map +1 -0
- package/dist/object/tryParseJson.d.ts +9 -0
- package/dist/object/tryParseJson.d.ts.map +1 -0
- package/dist/object/tryParseJson.js +18 -0
- package/dist/object/tryParseJson.js.map +1 -0
- package/dist/random/_index.cjs +2 -0
- package/dist/random/_index.cjs.map +1 -0
- package/dist/random/_index.d.ts +3 -0
- package/dist/random/_index.d.ts.map +1 -0
- package/dist/random/_index.js +10 -0
- package/dist/random/_index.js.map +1 -0
- package/dist/random/draw.cjs +1 -1
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.d.ts +3 -2
- package/dist/random/draw.d.ts.map +1 -1
- package/dist/random/draw.js +12 -12
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.cjs +1 -0
- package/dist/random/index.d.ts +1 -0
- package/dist/random/index.d.ts.map +1 -1
- package/dist/random/index.js +5 -0
- package/dist/random/random.cjs +1 -1
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.d.ts +2 -1
- package/dist/random/random.d.ts.map +1 -1
- package/dist/random/random.js +5 -6
- package/dist/random/random.js.map +1 -1
- package/dist/random/shuffle.cjs +1 -1
- package/dist/random/shuffle.cjs.map +1 -1
- package/dist/random/shuffle.d.ts +2 -1
- package/dist/random/shuffle.d.ts.map +1 -1
- package/dist/random/shuffle.js +7 -7
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/source.d.ts +4 -0
- package/dist/random/source.d.ts.map +1 -0
- package/dist/string/index.cjs +1 -0
- package/dist/string/index.d.ts +0 -2
- package/dist/string/index.d.ts.map +1 -1
- package/dist/string/index.js +12 -0
- package/dist/string/similarity.cjs +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.d.ts.map +1 -1
- package/dist/string/similarity.js +16 -17
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/truncate.cjs +1 -1
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.d.ts +2 -1
- package/dist/string/truncate.d.ts.map +1 -1
- package/dist/string/truncate.js +10 -11
- package/dist/string/truncate.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +41 -25
- package/dist/_common/_secureRandomIndex.cjs +0 -2
- package/dist/_common/_secureRandomIndex.cjs.map +0 -1
- package/dist/_common/_secureRandomIndex.d.ts +0 -2
- package/dist/_common/_secureRandomIndex.d.ts.map +0 -1
- package/dist/_common/_secureRandomIndex.js +0 -9
- package/dist/_common/_secureRandomIndex.js.map +0 -1
- package/dist/async/queue.cjs +0 -2
- package/dist/async/queue.cjs.map +0 -1
- package/dist/async/queue.d.ts +0 -42
- package/dist/async/queue.d.ts.map +0 -1
- package/dist/async/queue.js +0 -72
- package/dist/async/queue.js.map +0 -1
- package/dist/cache/stash.cjs +0 -2
- package/dist/cache/stash.cjs.map +0 -1
- package/dist/cache/stash.d.ts +0 -111
- package/dist/cache/stash.d.ts.map +0 -1
- package/dist/cache/stash.js +0 -92
- package/dist/cache/stash.js.map +0 -1
- package/dist/function/constant.cjs +0 -2
- package/dist/function/constant.cjs.map +0 -1
- package/dist/function/constant.d.ts +0 -5
- package/dist/function/constant.d.ts.map +0 -1
- package/dist/function/constant.js +0 -8
- package/dist/function/constant.js.map +0 -1
- package/dist/function/identity.cjs +0 -2
- package/dist/function/identity.cjs.map +0 -1
- package/dist/function/identity.d.ts +0 -5
- package/dist/function/identity.d.ts.map +0 -1
- package/dist/function/identity.js +0 -8
- package/dist/function/identity.js.map +0 -1
- package/dist/guards/isArray.cjs +0 -2
- package/dist/guards/isArray.cjs.map +0 -1
- package/dist/guards/isArray.d.ts +0 -16
- package/dist/guards/isArray.d.ts.map +0 -1
- package/dist/guards/isArray.js +0 -8
- package/dist/guards/isArray.js.map +0 -1
- package/dist/guards/isBoolean.cjs +0 -2
- package/dist/guards/isBoolean.cjs.map +0 -1
- package/dist/guards/isBoolean.d.ts +0 -23
- package/dist/guards/isBoolean.d.ts.map +0 -1
- package/dist/guards/isBoolean.js +0 -8
- package/dist/guards/isBoolean.js.map +0 -1
- package/dist/guards/isString.cjs +0 -2
- package/dist/guards/isString.cjs.map +0 -1
- package/dist/guards/isString.d.ts +0 -15
- package/dist/guards/isString.d.ts.map +0 -1
- package/dist/guards/isString.js +0 -8
- package/dist/guards/isString.js.map +0 -1
- package/dist/math/abs.cjs +0 -2
- package/dist/math/abs.cjs.map +0 -1
- package/dist/math/abs.d.ts +0 -17
- package/dist/math/abs.d.ts.map +0 -1
- package/dist/math/abs.js +0 -8
- package/dist/math/abs.js.map +0 -1
- package/dist/math/max.cjs +0 -2
- package/dist/math/max.cjs.map +0 -1
- package/dist/math/max.d.ts +0 -21
- package/dist/math/max.d.ts.map +0 -1
- package/dist/math/max.js +0 -12
- package/dist/math/max.js.map +0 -1
- package/dist/math/min.cjs +0 -2
- package/dist/math/min.cjs.map +0 -1
- package/dist/math/min.d.ts +0 -21
- package/dist/math/min.d.ts.map +0 -1
- package/dist/math/min.js +0 -12
- package/dist/math/min.js.map +0 -1
- package/dist/object/parseJSON.cjs +0 -2
- package/dist/object/parseJSON.cjs.map +0 -1
- package/dist/object/parseJSON.d.ts +0 -32
- package/dist/object/parseJSON.d.ts.map +0 -1
- package/dist/object/parseJSON.js +0 -16
- package/dist/object/parseJSON.js.map +0 -1
- package/dist/string/endsWith.cjs +0 -2
- package/dist/string/endsWith.cjs.map +0 -1
- package/dist/string/endsWith.d.ts +0 -5
- package/dist/string/endsWith.d.ts.map +0 -1
- package/dist/string/endsWith.js +0 -8
- package/dist/string/endsWith.js.map +0 -1
- package/dist/string/startsWith.cjs +0 -2
- package/dist/string/startsWith.cjs.map +0 -1
- package/dist/string/startsWith.d.ts +0 -5
- package/dist/string/startsWith.d.ts.map +0 -1
- package/dist/string/startsWith.js +0 -8
- package/dist/string/startsWith.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,119 +1,30 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './errors';
|
|
2
2
|
export * from './array/chunk';
|
|
3
|
-
export * from './array/compact';
|
|
4
|
-
export * from './array/compare';
|
|
5
|
-
export * from './array/compareBy';
|
|
6
|
-
export * from './array/contains';
|
|
7
|
-
export * from './array/countBy';
|
|
8
|
-
export * from './array/difference';
|
|
9
|
-
export * from './array/drop';
|
|
10
|
-
export * from './array/dropLast';
|
|
11
3
|
export * from './array/filterMap';
|
|
12
|
-
export * from './array/first';
|
|
13
|
-
export * from './array/flatten';
|
|
14
4
|
export * from './array/groupBy';
|
|
15
5
|
export * from './array/indexBy';
|
|
16
|
-
export * from './array/intersection';
|
|
17
|
-
export * from './array/last';
|
|
18
6
|
export * from './array/partition';
|
|
19
|
-
export * from './array/replace';
|
|
20
|
-
export * from './array/rotate';
|
|
21
|
-
export * from './array/search';
|
|
22
7
|
export * from './array/sort';
|
|
23
|
-
export * from './array/take';
|
|
24
|
-
export * from './array/takeLast';
|
|
25
|
-
export * from './array/toggle';
|
|
26
|
-
export * from './array/union';
|
|
27
8
|
export * from './array/uniq';
|
|
28
|
-
export * from './array/unzip';
|
|
29
|
-
export * from './array/zip';
|
|
30
|
-
export * from './async/abortError';
|
|
31
9
|
export * from './async/attempt';
|
|
32
|
-
export * from './async/backoff';
|
|
33
10
|
export * from './async/parallel';
|
|
34
|
-
export * from './async/queue';
|
|
35
11
|
export * from './async/retry';
|
|
36
12
|
export * from './async/sleep';
|
|
37
|
-
export * from './async/waitFor';
|
|
38
|
-
export * from './cache/memo';
|
|
39
|
-
export * from './cache/stash';
|
|
40
|
-
export * from './function/assert';
|
|
41
|
-
export * from './function/constant';
|
|
42
13
|
export * from './function/debounce';
|
|
43
|
-
export * from './function/identity';
|
|
44
14
|
export * from './function/once';
|
|
45
15
|
export * from './function/pipe';
|
|
46
|
-
export * from './function/runAll';
|
|
47
|
-
export * from './function/tap';
|
|
48
16
|
export * from './function/throttle';
|
|
49
17
|
export * from './guards/combinators';
|
|
50
|
-
export * from './guards/isAbortError';
|
|
51
|
-
export * from './guards/isArray';
|
|
52
|
-
export * from './guards/isBoolean';
|
|
53
|
-
export * from './guards/isDate';
|
|
54
18
|
export * from './guards/isDefined';
|
|
55
|
-
export * from './guards/isEmpty';
|
|
56
19
|
export * from './guards/isEqual';
|
|
57
|
-
export * from './guards/isError';
|
|
58
|
-
export * from './guards/isFunction';
|
|
59
|
-
export * from './guards/isMatch';
|
|
60
20
|
export * from './guards/isNil';
|
|
61
|
-
export * from './guards/isNumber';
|
|
62
21
|
export * from './guards/isPlainObject';
|
|
63
|
-
export * from './guards/isPrimitive';
|
|
64
|
-
export * from './guards/isPromise';
|
|
65
|
-
export * from './guards/isRegex';
|
|
66
|
-
export * from './guards/isString';
|
|
67
|
-
export * from './guards/shallowEqual';
|
|
68
|
-
export * from './math/abs';
|
|
69
|
-
export * from './math/allocate';
|
|
70
|
-
export * from './math/average';
|
|
71
22
|
export * from './math/clamp';
|
|
72
|
-
export * from './math/gcd';
|
|
73
|
-
export * from './math/lcm';
|
|
74
|
-
export * from './math/lerp';
|
|
75
|
-
export * from './math/linspace';
|
|
76
|
-
export * from './math/max';
|
|
77
|
-
export * from './math/median';
|
|
78
|
-
export * from './math/min';
|
|
79
|
-
export * from './math/mod';
|
|
80
|
-
export * from './math/normalize';
|
|
81
|
-
export * from './math/percent';
|
|
82
23
|
export * from './math/range';
|
|
83
|
-
export * from './math/round';
|
|
84
|
-
export * from './math/standardDeviation';
|
|
85
|
-
export * from './math/sum';
|
|
86
|
-
export * from './math/variance';
|
|
87
|
-
export * from './object/defaults';
|
|
88
|
-
export * from './object/diff';
|
|
89
|
-
export * from './object/filterValues';
|
|
90
|
-
export * from './object/flattenPaths';
|
|
91
24
|
export * from './object/getPath';
|
|
92
|
-
export * from './object/
|
|
93
|
-
export * from './object/mapKeys';
|
|
94
|
-
export * from './object/mapValues';
|
|
95
|
-
export * from './object/merge';
|
|
25
|
+
export * from './object/hash';
|
|
96
26
|
export * from './object/omit';
|
|
97
|
-
export * from './object/parseJSON';
|
|
98
27
|
export * from './object/pick';
|
|
99
|
-
export * from './object/prune';
|
|
100
|
-
export * from './object/hash';
|
|
101
|
-
export * from './random/draw';
|
|
102
|
-
export * from './random/random';
|
|
103
|
-
export * from './random/shuffle';
|
|
104
28
|
export * from './random/uuid';
|
|
105
29
|
export * from './string/camelCase';
|
|
106
|
-
export * from './string/endsWith';
|
|
107
|
-
export * from './string/escape';
|
|
108
|
-
export * from './string/kebabCase';
|
|
109
|
-
export * from './string/pad';
|
|
110
|
-
export * from './string/pascalCase';
|
|
111
|
-
export * from './string/similarity';
|
|
112
|
-
export * from './string/snakeCase';
|
|
113
|
-
export * from './string/startsWith';
|
|
114
|
-
export * from './string/titleCase';
|
|
115
|
-
export * from './string/truncate';
|
|
116
|
-
export * from './string/unescape';
|
|
117
|
-
export * from './string/words';
|
|
118
|
-
export * from './types';
|
|
119
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,118 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
import { union as P } from "./array/union.js";
|
|
32
|
-
import { uniq as F } from "./array/uniq.js";
|
|
33
|
-
import { unzip as I } from "./array/unzip.js";
|
|
34
|
-
import { zip as L } from "./array/zip.js";
|
|
35
|
-
import { abortError as R } from "./async/abortError.js";
|
|
36
|
-
import { attempt as z, isFail as B, isOk as V } from "./async/attempt.js";
|
|
37
|
-
import { backoff as H } from "./async/backoff.js";
|
|
38
|
-
import { parallel as U } from "./async/parallel.js";
|
|
39
|
-
import { queue as W } from "./async/queue.js";
|
|
40
|
-
import { sleep as G } from "./async/sleep.js";
|
|
41
|
-
import { retry as K } from "./async/retry.js";
|
|
42
|
-
import { waitFor as q } from "./async/waitFor.js";
|
|
43
|
-
import { memo as J } from "./cache/memo.js";
|
|
44
|
-
import { isPromise as Y } from "./guards/isPromise.js";
|
|
45
|
-
import { stash as X } from "./cache/stash.js";
|
|
46
|
-
import { assert as Z } from "./function/assert.js";
|
|
47
|
-
import { constant as Q } from "./function/constant.js";
|
|
48
|
-
import { debounce as $ } from "./function/debounce.js";
|
|
49
|
-
import { identity as ee } from "./function/identity.js";
|
|
50
|
-
import { once as te } from "./function/once.js";
|
|
51
|
-
import { pipe as ne } from "./function/pipe.js";
|
|
52
|
-
import { runAll as re } from "./function/runAll.js";
|
|
53
|
-
import { tap as ie } from "./function/tap.js";
|
|
54
|
-
import { throttle as ae } from "./function/throttle.js";
|
|
55
|
-
import { allOf as oe, anyOf as se, noneOf as ce, not as le } from "./guards/combinators.js";
|
|
56
|
-
import { isAbortError as ue } from "./guards/isAbortError.js";
|
|
57
|
-
import { isArray as de } from "./guards/isArray.js";
|
|
58
|
-
import { isBoolean as fe } from "./guards/isBoolean.js";
|
|
59
|
-
import { isDate as pe } from "./guards/isDate.js";
|
|
60
|
-
import { isDefined as me } from "./guards/isDefined.js";
|
|
61
|
-
import { isPlainObject as he } from "./guards/isPlainObject.js";
|
|
62
|
-
import { isEmpty as ge } from "./guards/isEmpty.js";
|
|
63
|
-
import { isError as _e } from "./guards/isError.js";
|
|
64
|
-
import { isFunction as ve } from "./guards/isFunction.js";
|
|
65
|
-
import { isMatch as ye } from "./guards/isMatch.js";
|
|
66
|
-
import { isPrimitive as be } from "./guards/isPrimitive.js";
|
|
67
|
-
import { isRegex as xe } from "./guards/isRegex.js";
|
|
68
|
-
import { shallowEqual as Se } from "./guards/shallowEqual.js";
|
|
69
|
-
import { abs as Ce } from "./math/abs.js";
|
|
70
|
-
import { allocate as we } from "./math/allocate.js";
|
|
71
|
-
import { sum as Te } from "./math/sum.js";
|
|
72
|
-
import { average as Ee } from "./math/average.js";
|
|
73
|
-
import { clamp as De } from "./math/clamp.js";
|
|
74
|
-
import { gcd as Oe } from "./math/gcd.js";
|
|
75
|
-
import { lcm as ke } from "./math/lcm.js";
|
|
76
|
-
import { lerp as Ae } from "./math/lerp.js";
|
|
77
|
-
import { linspace as je } from "./math/linspace.js";
|
|
78
|
-
import { max as Me } from "./math/max.js";
|
|
79
|
-
import { median as Ne } from "./math/median.js";
|
|
80
|
-
import { min as Pe } from "./math/min.js";
|
|
81
|
-
import { mod as Fe } from "./math/mod.js";
|
|
82
|
-
import { normalize as Ie } from "./math/normalize.js";
|
|
83
|
-
import { percent as Le } from "./math/percent.js";
|
|
84
|
-
import { range as Re } from "./math/range.js";
|
|
85
|
-
import { round as ze } from "./math/round.js";
|
|
86
|
-
import { variance as Be } from "./math/variance.js";
|
|
87
|
-
import { standardDeviation as Ve } from "./math/standardDeviation.js";
|
|
88
|
-
import { defaults as He } from "./object/defaults.js";
|
|
89
|
-
import { diff as Ue, diffArrays as We } from "./object/diff.js";
|
|
90
|
-
import { filterValues as Ge } from "./object/filterValues.js";
|
|
91
|
-
import { flattenPaths as Ke, unflattenPaths as qe } from "./object/flattenPaths.js";
|
|
92
|
-
import { getPath as Je } from "./object/getPath.js";
|
|
93
|
-
import { invert as Ye } from "./object/invert.js";
|
|
94
|
-
import { mapKeys as Xe } from "./object/mapKeys.js";
|
|
95
|
-
import { mapValues as Ze } from "./object/mapValues.js";
|
|
96
|
-
import { deepMerge as Qe, shallowMerge as $e } from "./object/merge.js";
|
|
97
|
-
import { omit as et } from "./object/omit.js";
|
|
98
|
-
import { parseJSON as tt } from "./object/parseJSON.js";
|
|
99
|
-
import { pick as nt } from "./object/pick.js";
|
|
100
|
-
import { prune as rt } from "./object/prune.js";
|
|
101
|
-
import { hash as it } from "./object/hash.js";
|
|
102
|
-
import { random as at } from "./random/random.js";
|
|
103
|
-
import { draw as ot, drawMany as st } from "./random/draw.js";
|
|
104
|
-
import { shuffle as ct } from "./random/shuffle.js";
|
|
105
|
-
import { uuid as lt } from "./random/uuid.js";
|
|
106
|
-
import { camelCase as ut } from "./string/camelCase.js";
|
|
107
|
-
import { endsWith as dt } from "./string/endsWith.js";
|
|
108
|
-
import { escape as ft } from "./string/escape.js";
|
|
109
|
-
import { kebabCase as pt } from "./string/kebabCase.js";
|
|
110
|
-
import { pad as mt } from "./string/pad.js";
|
|
111
|
-
import { pascalCase as ht } from "./string/pascalCase.js";
|
|
112
|
-
import { snakeCase as gt } from "./string/snakeCase.js";
|
|
113
|
-
import { startsWith as _t } from "./string/startsWith.js";
|
|
114
|
-
import { words as vt } from "./string/words.js";
|
|
115
|
-
import { titleCase as yt } from "./string/titleCase.js";
|
|
116
|
-
import { truncate as bt } from "./string/truncate.js";
|
|
117
|
-
import { unescape as xt } from "./string/unescape.js";
|
|
118
|
-
export { e as ArsenalError, t as ArsenalSerializationError, n as ArsenalValidationError, R as abortError, Ce as abs, oe as allOf, we as allocate, se as anyOf, Z as assert, z as attempt, Ee as average, H as backoff, ut as camelCase, i as chunk, De as clamp, a as compact, o as compare, s as compareBy, Q as constant, l as contains, u as countBy, $ as debounce, Qe as deepMerge, He as defaults, Ue as diff, We as diffArrays, d as difference, ot as draw, st as drawMany, f as drop, p as dropLast, dt as endsWith, ft as escape, m as filterMap, Ge as filterValues, h as first, g as flatten, Ke as flattenPaths, D as fuzzy, O as fuzzyFilter, k as fuzzyScore, Oe as gcd, Je as getPath, _ as groupBy, it as hash, ee as identity, v as indexBy, y as intersection, Ye as invert, ue as isAbortError, de as isArray, fe as isBoolean, pe as isDate, me as isDefined, ge as isEmpty, c as isEqual, _e as isError, B as isFail, ve as isFunction, ye as isMatch, w as isNil, T as isNumber, V as isOk, he as isPlainObject, be as isPrimitive, Y as isPromise, xe as isRegex, r as isString, pt as kebabCase, b as last, ke as lcm, Ae as lerp, je as linspace, Xe as mapKeys, Ze as mapValues, Me as max, Ne as median, J as memo, Pe as min, Fe as mod, ce as noneOf, Ie as normalize, le as not, et as omit, te as once, mt as pad, U as parallel, tt as parseJSON, x as partition, ht as pascalCase, Le as percent, nt as pick, ne as pipe, rt as prune, W as queue, at as random, Re as range, S as replace, K as retry, C as rotate, ze as round, re as runAll, Se as shallowEqual, $e as shallowMerge, ct as shuffle, E as similarity, G as sleep, gt as snakeCase, A as sort, Ve as standardDeviation, _t as startsWith, X as stash, Te as sum, j as take, M as takeLast, ie as tap, ae as throttle, yt as titleCase, N as toggle, bt as truncate, xt as unescape, qe as unflattenPaths, P as union, F as uniq, I as unzip, lt as uuid, Be as variance, q as waitFor, vt as words, L as zip };
|
|
1
|
+
import { chunk as e } from "./array/chunk.js";
|
|
2
|
+
import { isEqual as t } from "./guards/isEqual.js";
|
|
3
|
+
import { filterMap as n } from "./array/filterMap.js";
|
|
4
|
+
import { groupBy as r } from "./array/groupBy.js";
|
|
5
|
+
import { indexBy as i } from "./array/indexBy.js";
|
|
6
|
+
import { partition as a } from "./array/partition.js";
|
|
7
|
+
import { sort as o } from "./array/sort.js";
|
|
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 };
|
package/dist/math/allocate.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t){if(typeof t==`number`&&(!Number.isInteger(t)||t<1))throw RangeError(`allocate: parts must be a positive integer, got ${t}`);let n=Array.isArray(t)?t:Array(t).fill(1);if(n.length===0)throw RangeError(`Ratios array cannot be empty`);if(n.some(e=>e<0))throw RangeError(`Ratios must be non-negative`);let r=n.reduce((e,t)=>e+t,0);if(r===0)throw RangeError(`Total ratio cannot be zero`);if(typeof e==`bigint`){let t=BigInt(r),i=Array.from({length:n.length-1},(r,i)=>e*BigInt(n[i])/t);return i.push(e-i.reduce((e,t)=>e+t,0n)),i}let i=Array.from({length:n.length-1},(t,i)=>Math.floor(e*n[i]/r));return i.push(e-i.reduce((e,t)=>e+t,0)),i}exports.allocate=e;
|
|
2
2
|
//# sourceMappingURL=allocate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allocate.cjs","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"allocate.cjs","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * The indivisible remainder is allocated to the last bucket.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3 (total ratio = 6)\n * allocate(100, [1, 2, 3]);\n * // [16, 33, 51] - sum is exactly 100\n *\n * // Split $100 evenly among 3 parts\n * allocate(100, 3);\n * // [33, 33, 34] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3333n, 3333n, 3334n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution or number of equal parts\n * @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)\n * @throws {RangeError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer.\n */\nexport function allocate(amount: number, ratios: number[] | number): number[];\nexport function allocate(amount: bigint, ratios: number[] | number): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[] | number): (number | bigint)[] {\n // If second param is a number, validate and treat it as number of equal parts\n if (typeof ratios === 'number') {\n if (!Number.isInteger(ratios) || ratios < 1) {\n throw new RangeError(`allocate: parts must be a positive integer, got ${ratios}`);\n }\n }\n\n const actualRatios = Array.isArray(ratios) ? ratios : Array(ratios).fill(1);\n\n if (actualRatios.length === 0) {\n throw new RangeError('Ratios array cannot be empty');\n }\n\n if (actualRatios.some((r) => r < 0)) {\n throw new RangeError('Ratios must be non-negative');\n }\n\n const totalRatio = actualRatios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new RangeError('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const totalRatioBigInt = BigInt(totalRatio);\n const results = Array.from(\n { length: actualRatios.length - 1 },\n (_, i) => (amount * BigInt(actualRatios[i])) / totalRatioBigInt,\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0n));\n\n return results;\n }\n\n // For number type, use proportional allocation for all ratios uniformly\n const results = Array.from({ length: actualRatios.length - 1 }, (_, i) =>\n Math.floor((amount * actualRatios[i]) / totalRatio),\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0));\n\n return results;\n}\n"],"mappings":"AA4BA,SAAgB,EAAS,EAAyB,EAAgD,CAEhG,GAAI,OAAO,GAAW,WAChB,CAAC,OAAO,UAAU,CAAM,GAAK,EAAS,GACxC,MAAU,WAAW,mDAAmD,GAAQ,EAIpF,IAAM,EAAe,MAAM,QAAQ,CAAM,EAAI,EAAS,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC,EAE1E,GAAI,EAAa,SAAW,EAC1B,MAAU,WAAW,8BAA8B,EAGrD,GAAI,EAAa,KAAM,GAAM,EAAI,CAAC,EAChC,MAAU,WAAW,6BAA6B,EAGpD,IAAM,EAAa,EAAa,QAAQ,EAAK,IAAU,EAAM,EAAO,CAAC,EAErE,GAAI,IAAe,EACjB,MAAU,WAAW,4BAA4B,EAGnD,GAAI,OAAO,GAAW,SAAU,CAC9B,IAAM,EAAmB,OAAO,CAAU,EACpC,EAAU,MAAM,KACpB,CAAE,OAAQ,EAAa,OAAS,CAAE,GACjC,EAAG,IAAO,EAAS,OAAO,EAAa,EAAE,EAAK,CACjD,EAIA,OAFA,EAAQ,KAAK,EAAS,EAAQ,QAAQ,EAAG,IAAM,EAAI,EAAG,EAAE,CAAC,EAElD,CACT,CAGA,IAAM,EAAU,MAAM,KAAK,CAAE,OAAQ,EAAa,OAAS,CAAE,GAAI,EAAG,IAClE,KAAK,MAAO,EAAS,EAAa,GAAM,CAAU,CACpD,EAIA,OAFA,EAAQ,KAAK,EAAS,EAAQ,QAAQ,EAAG,IAAM,EAAI,EAAG,CAAC,CAAC,EAEjD,CACT"}
|
package/dist/math/allocate.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @param amount - Total amount to allocate
|
|
23
23
|
* @param ratios - Array of ratios for distribution or number of equal parts
|
|
24
24
|
* @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)
|
|
25
|
-
* @throws {
|
|
25
|
+
* @throws {RangeError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer.
|
|
26
26
|
*/
|
|
27
27
|
export declare function allocate(amount: number, ratios: number[] | number): number[];
|
|
28
28
|
export declare function allocate(amount: bigint, ratios: number[] | number): bigint[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allocate.d.ts","sourceRoot":"","sources":["../../src/math/allocate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"allocate.d.ts","sourceRoot":"","sources":["../../src/math/allocate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC"}
|
package/dist/math/allocate.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
1
|
//#region src/math/allocate.ts
|
|
3
|
-
function
|
|
4
|
-
if (typeof
|
|
5
|
-
let
|
|
6
|
-
if (
|
|
7
|
-
if (
|
|
8
|
-
let
|
|
9
|
-
if (
|
|
10
|
-
if (typeof
|
|
11
|
-
let
|
|
12
|
-
return
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (typeof t == "number" && (!Number.isInteger(t) || t < 1)) throw RangeError(`allocate: parts must be a positive integer, got ${t}`);
|
|
4
|
+
let n = Array.isArray(t) ? t : Array(t).fill(1);
|
|
5
|
+
if (n.length === 0) throw RangeError("Ratios array cannot be empty");
|
|
6
|
+
if (n.some((e) => e < 0)) throw RangeError("Ratios must be non-negative");
|
|
7
|
+
let r = n.reduce((e, t) => e + t, 0);
|
|
8
|
+
if (r === 0) throw RangeError("Total ratio cannot be zero");
|
|
9
|
+
if (typeof e == "bigint") {
|
|
10
|
+
let t = BigInt(r), i = Array.from({ length: n.length - 1 }, (r, i) => e * BigInt(n[i]) / t);
|
|
11
|
+
return i.push(e - i.reduce((e, t) => e + t, 0n)), i;
|
|
13
12
|
}
|
|
14
|
-
let
|
|
15
|
-
return
|
|
13
|
+
let i = Array.from({ length: n.length - 1 }, (t, i) => Math.floor(e * n[i] / r));
|
|
14
|
+
return i.push(e - i.reduce((e, t) => e + t, 0)), i;
|
|
16
15
|
}
|
|
17
16
|
//#endregion
|
|
18
|
-
export {
|
|
17
|
+
export { e as allocate };
|
|
19
18
|
|
|
20
19
|
//# sourceMappingURL=allocate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allocate.js","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"allocate.js","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * The indivisible remainder is allocated to the last bucket.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3 (total ratio = 6)\n * allocate(100, [1, 2, 3]);\n * // [16, 33, 51] - sum is exactly 100\n *\n * // Split $100 evenly among 3 parts\n * allocate(100, 3);\n * // [33, 33, 34] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3333n, 3333n, 3334n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution or number of equal parts\n * @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)\n * @throws {RangeError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer.\n */\nexport function allocate(amount: number, ratios: number[] | number): number[];\nexport function allocate(amount: bigint, ratios: number[] | number): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[] | number): (number | bigint)[] {\n // If second param is a number, validate and treat it as number of equal parts\n if (typeof ratios === 'number') {\n if (!Number.isInteger(ratios) || ratios < 1) {\n throw new RangeError(`allocate: parts must be a positive integer, got ${ratios}`);\n }\n }\n\n const actualRatios = Array.isArray(ratios) ? ratios : Array(ratios).fill(1);\n\n if (actualRatios.length === 0) {\n throw new RangeError('Ratios array cannot be empty');\n }\n\n if (actualRatios.some((r) => r < 0)) {\n throw new RangeError('Ratios must be non-negative');\n }\n\n const totalRatio = actualRatios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new RangeError('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const totalRatioBigInt = BigInt(totalRatio);\n const results = Array.from(\n { length: actualRatios.length - 1 },\n (_, i) => (amount * BigInt(actualRatios[i])) / totalRatioBigInt,\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0n));\n\n return results;\n }\n\n // For number type, use proportional allocation for all ratios uniformly\n const results = Array.from({ length: actualRatios.length - 1 }, (_, i) =>\n Math.floor((amount * actualRatios[i]) / totalRatio),\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0));\n\n return results;\n}\n"],"mappings":";AA4BA,SAAgB,EAAS,GAAyB,GAAgD;CAEhG,IAAI,OAAO,KAAW,aAChB,CAAC,OAAO,UAAU,CAAM,KAAK,IAAS,IACxC,MAAU,WAAW,mDAAmD,GAAQ;CAIpF,IAAM,IAAe,MAAM,QAAQ,CAAM,IAAI,IAAS,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC;CAE1E,IAAI,EAAa,WAAW,GAC1B,MAAU,WAAW,8BAA8B;CAGrD,IAAI,EAAa,MAAM,MAAM,IAAI,CAAC,GAChC,MAAU,WAAW,6BAA6B;CAGpD,IAAM,IAAa,EAAa,QAAQ,GAAK,MAAU,IAAM,GAAO,CAAC;CAErE,IAAI,MAAe,GACjB,MAAU,WAAW,4BAA4B;CAGnD,IAAI,OAAO,KAAW,UAAU;EAC9B,IAAM,IAAmB,OAAO,CAAU,GACpC,IAAU,MAAM,KACpB,EAAE,QAAQ,EAAa,SAAS,EAAE,IACjC,GAAG,MAAO,IAAS,OAAO,EAAa,EAAE,IAAK,CACjD;EAIA,OAFA,EAAQ,KAAK,IAAS,EAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,GAElD;CACT;CAGA,IAAM,IAAU,MAAM,KAAK,EAAE,QAAQ,EAAa,SAAS,EAAE,IAAI,GAAG,MAClE,KAAK,MAAO,IAAS,EAAa,KAAM,CAAU,CACpD;CAIA,OAFA,EAAQ,KAAK,IAAS,EAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,CAAC,CAAC,GAEjD;AACT"}
|
|
@@ -0,0 +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;
|
package/dist/math/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './abs';
|
|
2
1
|
export * from './allocate';
|
|
3
2
|
export * from './average';
|
|
4
3
|
export * from './clamp';
|
|
@@ -6,9 +5,7 @@ export * from './gcd';
|
|
|
6
5
|
export * from './lcm';
|
|
7
6
|
export * from './lerp';
|
|
8
7
|
export * from './linspace';
|
|
9
|
-
export * from './max';
|
|
10
8
|
export * from './median';
|
|
11
|
-
export * from './min';
|
|
12
9
|
export * from './mod';
|
|
13
10
|
export * from './normalize';
|
|
14
11
|
export * from './percent';
|
package/dist/math/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,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,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { clamp as e } from "./clamp.js";
|
|
2
|
+
import { range as t } from "./range.js";
|
|
3
|
+
import { allocate as n } from "./allocate.js";
|
|
4
|
+
import { sum as r } from "./sum.js";
|
|
5
|
+
import { average as i } from "./average.js";
|
|
6
|
+
import { gcd as a } from "./gcd.js";
|
|
7
|
+
import { lcm as o } from "./lcm.js";
|
|
8
|
+
import { lerp as s } from "./lerp.js";
|
|
9
|
+
import { linspace as c } from "./linspace.js";
|
|
10
|
+
import { median as l } from "./median.js";
|
|
11
|
+
import { mod as u } from "./mod.js";
|
|
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 };
|
package/dist/math/mod.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t){if(t===0)throw RangeError(`mod: divisor cannot be 0`);return(e%t+t)%t}exports.mod=e;
|
|
2
2
|
//# sourceMappingURL=mod.cjs.map
|
package/dist/math/mod.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.cjs","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"mod.cjs","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["/**\n * Sign-correct modulo — unlike the native `%` operator, the result always has the same sign\n * as the divisor `b` (e.g. `mod(-1, 4)` is `3`, not `-1`).\n *\n * @example\n * ```ts\n * mod(-1, 4); // 3\n * mod(5, 3); // 2\n * ```\n *\n * @param a - The dividend.\n * @param b - The divisor. Must not be `0`.\n * @returns The sign-correct modulo of `a` by `b`.\n *\n * @throws {RangeError} If `b` is `0`.\n */\nexport function mod(a: number, b: number): number {\n if (b === 0) throw new RangeError('mod: divisor cannot be 0');\n\n return ((a % b) + b) % b;\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAW,EAAmB,CAChD,GAAI,IAAM,EAAG,MAAU,WAAW,0BAA0B,EAE5D,OAAS,EAAI,EAAK,GAAK,CACzB"}
|
package/dist/math/mod.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @param b - The divisor. Must not be `0`.
|
|
13
13
|
* @returns The sign-correct modulo of `a` by `b`.
|
|
14
14
|
*
|
|
15
|
-
* @throws {
|
|
15
|
+
* @throws {RangeError} If `b` is `0`.
|
|
16
16
|
*/
|
|
17
17
|
export declare function mod(a: number, b: number): number;
|
|
18
18
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/math/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/math/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/math/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhD"}
|
package/dist/math/mod.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
1
|
//#region src/math/mod.ts
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
5
|
-
return (
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (t === 0) throw RangeError("mod: divisor cannot be 0");
|
|
4
|
+
return (e % t + t) % t;
|
|
6
5
|
}
|
|
7
6
|
//#endregion
|
|
8
|
-
export {
|
|
7
|
+
export { e as mod };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=mod.js.map
|
package/dist/math/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../src/math/mod.ts"],"sourcesContent":["/**\n * Sign-correct modulo — unlike the native `%` operator, the result always has the same sign\n * as the divisor `b` (e.g. `mod(-1, 4)` is `3`, not `-1`).\n *\n * @example\n * ```ts\n * mod(-1, 4); // 3\n * mod(5, 3); // 2\n * ```\n *\n * @param a - The dividend.\n * @param b - The divisor. Must not be `0`.\n * @returns The sign-correct modulo of `a` by `b`.\n *\n * @throws {RangeError} If `b` is `0`.\n */\nexport function mod(a: number, b: number): number {\n if (b === 0) throw new RangeError('mod: divisor cannot be 0');\n\n return ((a % b) + b) % b;\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAI,MAAM,GAAG,MAAU,WAAW,0BAA0B;CAE5D,QAAS,IAAI,IAAK,KAAK;AACzB"}
|
package/dist/math/range.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t,n){let[r,i,a]=t===void 0?[0,e,1]:n===void 0?[e,t,1]:[e,t,n];if(!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))throw RangeError(`range: start, stop, and step must be finite numbers`);if(a===0)throw RangeError(`range: step cannot be 0`);if(r===i)return[];let o=(i-r)/a,s=Math.max(0,Number.isInteger(o)?o:Math.ceil(o+2**-52));if(s>1e7)throw RangeError(`range: exceeds maximum allowed size of 10,000,000`);return Array.from({length:s},(e,t)=>r+t*a)}exports.range=e;
|
|
2
2
|
//# sourceMappingURL=range.cjs.map
|
package/dist/math/range.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.cjs","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"range.cjs","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["/**\n * Creates an array of numbers from `0` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(5) // [0, 1, 2, 3, 4]\n * ```\n */\nexport function range(stop: number): number[];\n/**\n * Creates an array of numbers from `start` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(2, 6) // [2, 3, 4, 5]\n * ```\n */\nexport function range(start: number, stop: number): number[];\n/**\n * Creates an array of numbers progressing from `start` up to, but not including, `stop` with a given `step`.\n *\n * @example\n * ```ts\n * range(0, 10, 2) // [0, 2, 4, 6, 8]\n * range(10, 0, -2) // [10, 8, 6, 4, 2]\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range (exclusive).\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {RangeError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number): number[];\nexport function range(startOrStop: number, stop?: number, step?: number): number[] {\n const [resolvedStart, resolvedStop, resolvedStep] =\n stop === undefined ? [0, startOrStop, 1] : step === undefined ? [startOrStop, stop, 1] : [startOrStop, stop, step];\n\n if (!Number.isFinite(resolvedStart) || !Number.isFinite(resolvedStop) || !Number.isFinite(resolvedStep)) {\n throw new RangeError('range: start, stop, and step must be finite numbers');\n }\n\n if (resolvedStep === 0) throw new RangeError('range: step cannot be 0');\n\n if (resolvedStart === resolvedStop) {\n return [];\n }\n\n const raw = (resolvedStop - resolvedStart) / resolvedStep;\n const length = Math.max(0, Number.isInteger(raw) ? raw : Math.ceil(raw + Number.EPSILON));\n\n if (length > 10_000_000) throw new RangeError('range: exceeds maximum allowed size of 10,000,000');\n\n return Array.from({ length }, (_, i) => resolvedStart + i * resolvedStep);\n}\n"],"mappings":"AAoCA,SAAgB,EAAM,EAAqB,EAAe,EAAyB,CACjF,GAAM,CAAC,EAAe,EAAc,GAClC,IAAS,IAAA,GAAY,CAAC,EAAG,EAAa,CAAC,EAAI,IAAS,IAAA,GAAY,CAAC,EAAa,EAAM,CAAC,EAAI,CAAC,EAAa,EAAM,CAAI,EAEnH,GAAI,CAAC,OAAO,SAAS,CAAa,GAAK,CAAC,OAAO,SAAS,CAAY,GAAK,CAAC,OAAO,SAAS,CAAY,EACpG,MAAU,WAAW,qDAAqD,EAG5E,GAAI,IAAiB,EAAG,MAAU,WAAW,yBAAyB,EAEtE,GAAI,IAAkB,EACpB,MAAO,CAAC,EAGV,IAAM,GAAO,EAAe,GAAiB,EACvC,EAAS,KAAK,IAAI,EAAG,OAAO,UAAU,CAAG,EAAI,EAAM,KAAK,KAAK,QAAoB,CAAC,EAExF,GAAI,EAAS,IAAY,MAAU,WAAW,mDAAmD,EAEjG,OAAO,MAAM,KAAK,CAAE,QAAO,GAAI,EAAG,IAAM,EAAgB,EAAI,CAAY,CAC1E"}
|
package/dist/math/range.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function range(start: number, stop: number): number[];
|
|
|
31
31
|
*
|
|
32
32
|
* @returns The range of numbers.
|
|
33
33
|
*
|
|
34
|
-
* @throws {
|
|
34
|
+
* @throws {RangeError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.
|
|
35
35
|
*/
|
|
36
36
|
export declare function range(start: number, stop: number, step: number): number[];
|
|
37
37
|
//# sourceMappingURL=range.d.ts.map
|
package/dist/math/range.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/math/range.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/math/range.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9C;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;AAC7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC"}
|
package/dist/math/range.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
1
|
//#region src/math/range.ts
|
|
3
|
-
function
|
|
4
|
-
let [i, a
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let [r, i, a] = t === void 0 ? [
|
|
5
4
|
0,
|
|
6
|
-
|
|
5
|
+
e,
|
|
7
6
|
1
|
|
8
|
-
] :
|
|
7
|
+
] : n === void 0 ? [
|
|
8
|
+
e,
|
|
9
9
|
t,
|
|
10
|
-
n,
|
|
11
10
|
1
|
|
12
11
|
] : [
|
|
12
|
+
e,
|
|
13
13
|
t,
|
|
14
|
-
n
|
|
15
|
-
r
|
|
14
|
+
n
|
|
16
15
|
];
|
|
17
|
-
if (!Number.isFinite(
|
|
18
|
-
if (
|
|
19
|
-
if (
|
|
20
|
-
let
|
|
21
|
-
if (
|
|
22
|
-
return Array.from({ length:
|
|
16
|
+
if (!Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(a)) throw RangeError("range: start, stop, and step must be finite numbers");
|
|
17
|
+
if (a === 0) throw RangeError("range: step cannot be 0");
|
|
18
|
+
if (r === i) return [];
|
|
19
|
+
let o = (i - r) / a, s = Math.max(0, Number.isInteger(o) ? o : Math.ceil(o + 2 ** -52));
|
|
20
|
+
if (s > 1e7) throw RangeError("range: exceeds maximum allowed size of 10,000,000");
|
|
21
|
+
return Array.from({ length: s }, (e, t) => r + t * a);
|
|
23
22
|
}
|
|
24
23
|
//#endregion
|
|
25
|
-
export {
|
|
24
|
+
export { e as range };
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=range.js.map
|
package/dist/math/range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"range.js","names":[],"sources":["../../src/math/range.ts"],"sourcesContent":["/**\n * Creates an array of numbers from `0` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(5) // [0, 1, 2, 3, 4]\n * ```\n */\nexport function range(stop: number): number[];\n/**\n * Creates an array of numbers from `start` up to, but not including, `stop` with step `1`.\n *\n * @example\n * ```ts\n * range(2, 6) // [2, 3, 4, 5]\n * ```\n */\nexport function range(start: number, stop: number): number[];\n/**\n * Creates an array of numbers progressing from `start` up to, but not including, `stop` with a given `step`.\n *\n * @example\n * ```ts\n * range(0, 10, 2) // [0, 2, 4, 6, 8]\n * range(10, 0, -2) // [10, 8, 6, 4, 2]\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range (exclusive).\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {RangeError} If start, stop, or step are not finite numbers, step is 0, or range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number): number[];\nexport function range(startOrStop: number, stop?: number, step?: number): number[] {\n const [resolvedStart, resolvedStop, resolvedStep] =\n stop === undefined ? [0, startOrStop, 1] : step === undefined ? [startOrStop, stop, 1] : [startOrStop, stop, step];\n\n if (!Number.isFinite(resolvedStart) || !Number.isFinite(resolvedStop) || !Number.isFinite(resolvedStep)) {\n throw new RangeError('range: start, stop, and step must be finite numbers');\n }\n\n if (resolvedStep === 0) throw new RangeError('range: step cannot be 0');\n\n if (resolvedStart === resolvedStop) {\n return [];\n }\n\n const raw = (resolvedStop - resolvedStart) / resolvedStep;\n const length = Math.max(0, Number.isInteger(raw) ? raw : Math.ceil(raw + Number.EPSILON));\n\n if (length > 10_000_000) throw new RangeError('range: exceeds maximum allowed size of 10,000,000');\n\n return Array.from({ length }, (_, i) => resolvedStart + i * resolvedStep);\n}\n"],"mappings":";AAoCA,SAAgB,EAAM,GAAqB,GAAe,GAAyB;CACjF,IAAM,CAAC,GAAe,GAAc,KAClC,MAAS,KAAA,IAAY;EAAC;EAAG;EAAa;CAAC,IAAI,MAAS,KAAA,IAAY;EAAC;EAAa;EAAM;CAAC,IAAI;EAAC;EAAa;EAAM;CAAI;CAEnH,IAAI,CAAC,OAAO,SAAS,CAAa,KAAK,CAAC,OAAO,SAAS,CAAY,KAAK,CAAC,OAAO,SAAS,CAAY,GACpG,MAAU,WAAW,qDAAqD;CAG5E,IAAI,MAAiB,GAAG,MAAU,WAAW,yBAAyB;CAEtE,IAAI,MAAkB,GACpB,OAAO,CAAC;CAGV,IAAM,KAAO,IAAe,KAAiB,GACvC,IAAS,KAAK,IAAI,GAAG,OAAO,UAAU,CAAG,IAAI,IAAM,KAAK,KAAK,YAAoB,CAAC;CAExF,IAAI,IAAS,KAAY,MAAU,WAAW,mDAAmD;CAEjG,OAAO,MAAM,KAAK,EAAE,UAAO,IAAI,GAAG,MAAM,IAAgB,IAAI,CAAY;AAC1E"}
|
package/dist/math/sum.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
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;
|
|
2
2
|
//# sourceMappingURL=sum.cjs.map
|