@vielzeug/arsenal 2.1.0 → 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.
- package/README.md +5 -18
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.d.ts +1 -1
- package/dist/array/chunk.d.ts.map +1 -1
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compact.cjs.map +1 -1
- package/dist/array/compact.d.ts +1 -1
- package/dist/array/compact.d.ts.map +1 -1
- package/dist/array/compact.js.map +1 -1
- package/dist/array/contains.cjs.map +1 -1
- package/dist/array/contains.d.ts +1 -1
- package/dist/array/contains.d.ts.map +1 -1
- package/dist/array/contains.js.map +1 -1
- package/dist/array/countBy.cjs.map +1 -1
- package/dist/array/countBy.d.ts +1 -1
- package/dist/array/countBy.d.ts.map +1 -1
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/difference.cjs.map +1 -1
- package/dist/array/difference.d.ts +4 -2
- package/dist/array/difference.d.ts.map +1 -1
- package/dist/array/difference.js.map +1 -1
- package/dist/array/drop.cjs.map +1 -1
- package/dist/array/drop.d.ts +1 -1
- package/dist/array/drop.d.ts.map +1 -1
- package/dist/array/drop.js.map +1 -1
- package/dist/array/dropLast.cjs.map +1 -1
- package/dist/array/dropLast.d.ts +1 -1
- package/dist/array/dropLast.d.ts.map +1 -1
- package/dist/array/dropLast.js.map +1 -1
- package/dist/array/filterMap.cjs.map +1 -1
- package/dist/array/filterMap.d.ts +3 -1
- package/dist/array/filterMap.d.ts.map +1 -1
- package/dist/array/filterMap.js.map +1 -1
- package/dist/array/first.cjs.map +1 -1
- package/dist/array/first.d.ts +1 -1
- package/dist/array/first.d.ts.map +1 -1
- package/dist/array/first.js.map +1 -1
- package/dist/array/groupBy.cjs.map +1 -1
- package/dist/array/groupBy.d.ts +1 -1
- package/dist/array/groupBy.d.ts.map +1 -1
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/index.cjs +1 -1
- package/dist/array/index.d.ts +0 -1
- package/dist/array/index.d.ts.map +1 -1
- package/dist/array/index.js +17 -18
- package/dist/array/indexBy.cjs.map +1 -1
- package/dist/array/indexBy.d.ts +1 -1
- package/dist/array/indexBy.d.ts.map +1 -1
- package/dist/array/indexBy.js.map +1 -1
- package/dist/array/intersection.cjs.map +1 -1
- package/dist/array/intersection.d.ts +4 -2
- package/dist/array/intersection.d.ts.map +1 -1
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/last.cjs.map +1 -1
- package/dist/array/last.d.ts +1 -1
- package/dist/array/last.d.ts.map +1 -1
- package/dist/array/last.js.map +1 -1
- package/dist/array/partition.cjs.map +1 -1
- package/dist/array/partition.d.ts +3 -1
- package/dist/array/partition.d.ts.map +1 -1
- package/dist/array/partition.js.map +1 -1
- package/dist/array/replace.cjs.map +1 -1
- package/dist/array/replace.d.ts +2 -15
- package/dist/array/replace.d.ts.map +1 -1
- package/dist/array/replace.js.map +1 -1
- package/dist/array/rotate.cjs.map +1 -1
- package/dist/array/rotate.d.ts +5 -17
- package/dist/array/rotate.d.ts.map +1 -1
- package/dist/array/rotate.js.map +1 -1
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.d.ts +2 -2
- package/dist/array/sort.d.ts.map +1 -1
- package/dist/array/sort.js.map +1 -1
- package/dist/array/take.cjs.map +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.d.ts.map +1 -1
- package/dist/array/take.js.map +1 -1
- package/dist/array/takeLast.cjs.map +1 -1
- package/dist/array/takeLast.d.ts +1 -1
- package/dist/array/takeLast.d.ts.map +1 -1
- package/dist/array/takeLast.js.map +1 -1
- package/dist/array/toggle.cjs.map +1 -1
- package/dist/array/toggle.d.ts +1 -1
- package/dist/array/toggle.d.ts.map +1 -1
- package/dist/array/toggle.js.map +1 -1
- package/dist/array/union.cjs.map +1 -1
- package/dist/array/union.d.ts +4 -2
- package/dist/array/union.d.ts.map +1 -1
- package/dist/array/union.js.map +1 -1
- package/dist/array/uniq.cjs.map +1 -1
- package/dist/array/uniq.d.ts +1 -1
- package/dist/array/uniq.d.ts.map +1 -1
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/zip.cjs.map +1 -1
- package/dist/array/zip.d.ts +1 -1
- package/dist/array/zip.d.ts.map +1 -1
- package/dist/array/zip.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/abortError.cjs +1 -1
- package/dist/async/abortError.cjs.map +1 -1
- package/dist/async/abortError.d.ts +3 -2
- package/dist/async/abortError.d.ts.map +1 -1
- package/dist/async/abortError.js +2 -2
- package/dist/async/abortError.js.map +1 -1
- package/dist/cache/cache.cjs +1 -1
- package/dist/cache/cache.cjs.map +1 -1
- package/dist/cache/cache.d.ts +1 -0
- package/dist/cache/cache.d.ts.map +1 -1
- package/dist/cache/cache.js +1 -0
- package/dist/cache/cache.js.map +1 -1
- package/dist/function/assert.cjs.map +1 -1
- package/dist/function/assert.d.ts +1 -1
- package/dist/function/assert.js.map +1 -1
- package/dist/guards/index.cjs +1 -1
- package/dist/guards/index.js +7 -7
- package/dist/guards/isEmpty.cjs +1 -1
- package/dist/guards/isEmpty.cjs.map +1 -1
- package/dist/guards/isEmpty.d.ts.map +1 -1
- package/dist/guards/isEmpty.js +4 -5
- package/dist/guards/isEmpty.js.map +1 -1
- package/dist/guards/isFunction.cjs.map +1 -1
- package/dist/guards/isFunction.d.ts +1 -1
- package/dist/guards/isFunction.d.ts.map +1 -1
- package/dist/guards/isFunction.js.map +1 -1
- package/dist/guards/isPrimitive.cjs +1 -1
- package/dist/guards/isPrimitive.cjs.map +1 -1
- package/dist/guards/isPrimitive.d.ts +4 -17
- package/dist/guards/isPrimitive.d.ts.map +1 -1
- package/dist/guards/isPrimitive.js +1 -2
- package/dist/guards/isPrimitive.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -22
- package/dist/math/average.cjs +1 -1
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.d.ts +3 -2
- package/dist/math/average.d.ts.map +1 -1
- package/dist/math/average.js +1 -6
- package/dist/math/average.js.map +1 -1
- package/dist/math/gcd.cjs +1 -1
- package/dist/math/gcd.cjs.map +1 -1
- package/dist/math/gcd.d.ts.map +1 -1
- package/dist/math/gcd.js +1 -0
- package/dist/math/gcd.js.map +1 -1
- package/dist/math/index.cjs +1 -1
- package/dist/math/index.d.ts +0 -1
- package/dist/math/index.d.ts.map +1 -1
- package/dist/math/index.js +7 -8
- package/dist/math/lcm.cjs +1 -1
- package/dist/math/lcm.cjs.map +1 -1
- package/dist/math/lcm.d.ts.map +1 -1
- package/dist/math/lcm.js +5 -1
- package/dist/math/lcm.js.map +1 -1
- package/dist/math/linspace.cjs +1 -1
- package/dist/math/linspace.cjs.map +1 -1
- package/dist/math/linspace.d.ts.map +1 -1
- package/dist/math/linspace.js +2 -1
- package/dist/math/linspace.js.map +1 -1
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.d.ts +1 -1
- package/dist/math/median.d.ts.map +1 -1
- package/dist/math/median.js.map +1 -1
- package/dist/math/standardDeviation.cjs.map +1 -1
- package/dist/math/standardDeviation.d.ts +1 -1
- package/dist/math/standardDeviation.d.ts.map +1 -1
- package/dist/math/standardDeviation.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 +1 -1
- package/dist/math/sum.d.ts.map +1 -1
- package/dist/math/sum.js +1 -1
- package/dist/math/sum.js.map +1 -1
- package/dist/math/variance.cjs.map +1 -1
- package/dist/math/variance.d.ts +1 -1
- package/dist/math/variance.d.ts.map +1 -1
- package/dist/math/variance.js.map +1 -1
- package/dist/object/diff.cjs.map +1 -1
- package/dist/object/diff.d.ts +1 -1
- package/dist/object/diff.d.ts.map +1 -1
- package/dist/object/diff.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 +16 -17
- package/dist/object/prune.js.map +1 -1
- package/dist/random/_index.cjs +1 -1
- package/dist/random/_index.cjs.map +1 -1
- package/dist/random/_index.d.ts +1 -1
- package/dist/random/_index.d.ts.map +1 -1
- package/dist/random/_index.js +4 -5
- package/dist/random/_index.js.map +1 -1
- package/dist/random/index.cjs +1 -1
- package/dist/random/index.d.ts +0 -1
- package/dist/random/index.d.ts.map +1 -1
- package/dist/random/index.js +2 -2
- package/dist/random/source.cjs +2 -0
- package/dist/random/source.cjs.map +1 -0
- package/dist/random/source.d.ts +2 -0
- package/dist/random/source.d.ts.map +1 -1
- package/dist/random/source.js +10 -0
- package/dist/random/source.js.map +1 -0
- package/dist/string/index.cjs +1 -1
- package/dist/string/index.d.ts +1 -1
- package/dist/string/index.d.ts.map +1 -1
- package/dist/string/index.js +2 -2
- package/dist/string/{pad.cjs → padCenter.cjs} +2 -2
- package/dist/string/padCenter.cjs.map +1 -0
- package/dist/string/padCenter.d.ts +3 -0
- package/dist/string/padCenter.d.ts.map +1 -0
- package/dist/string/{pad.js → padCenter.js} +3 -3
- package/dist/string/padCenter.js.map +1 -0
- package/package.json +7 -7
- package/dist/array/flatten.cjs +0 -2
- package/dist/array/flatten.cjs.map +0 -1
- package/dist/array/flatten.d.ts +0 -5
- package/dist/array/flatten.d.ts.map +0 -1
- package/dist/array/flatten.js +0 -11
- package/dist/array/flatten.js.map +0 -1
- package/dist/math/percent.cjs +0 -2
- package/dist/math/percent.cjs.map +0 -1
- package/dist/math/percent.d.ts +0 -19
- package/dist/math/percent.d.ts.map +0 -1
- package/dist/math/percent.js +0 -8
- package/dist/math/percent.js.map +0 -1
- package/dist/random/uuid.cjs +0 -2
- package/dist/random/uuid.cjs.map +0 -1
- package/dist/random/uuid.d.ts +0 -12
- package/dist/random/uuid.d.ts.map +0 -1
- package/dist/random/uuid.js +0 -8
- package/dist/random/uuid.js.map +0 -1
- package/dist/string/pad.cjs.map +0 -1
- package/dist/string/pad.d.ts +0 -5
- package/dist/string/pad.d.ts.map +0 -1
- package/dist/string/pad.js.map +0 -1
package/dist/guards/isEmpty.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isPlainObject as t } from "./isPlainObject.js";
|
|
1
|
+
import { isPlainObject as e } from "./isPlainObject.js";
|
|
3
2
|
//#region src/guards/isEmpty.ts
|
|
4
|
-
function
|
|
5
|
-
return
|
|
3
|
+
function t(t) {
|
|
4
|
+
return t == null || t === "" ? !0 : Array.isArray(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : e(t) ? Object.keys(t).length === 0 : !1;
|
|
6
5
|
}
|
|
7
6
|
//#endregion
|
|
8
|
-
export {
|
|
7
|
+
export { t as isEmpty };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=isEmpty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmpty.js","names":[],"sources":["../../src/guards/isEmpty.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"isEmpty.js","names":[],"sources":["../../src/guards/isEmpty.ts"],"sourcesContent":["import { isPlainObject } from './isPlainObject';\n\n/**\n * Checks if the given argument is empty.\n *\n * @example\n * ```ts\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(''); // true\n * isEmpty(0); // false\n * isEmpty(123); // false\n * isEmpty('abc'); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1, b: 2 }); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.\n */\nexport function isEmpty(arg: unknown): boolean {\n if (arg === null || arg === undefined || arg === '') return true;\n\n if (Array.isArray(arg)) return arg.length === 0;\n\n if (arg instanceof Map || arg instanceof Set) return arg.size === 0;\n\n if (isPlainObject(arg)) return Object.keys(arg).length === 0;\n\n return false;\n}\n"],"mappings":";;AAuBA,SAAgB,EAAQ,GAAuB;CAS7C,OARI,KAAQ,QAA6B,MAAQ,KAAW,KAExD,MAAM,QAAQ,CAAG,IAAU,EAAI,WAAW,IAE1C,aAAe,OAAO,aAAe,MAAY,EAAI,SAAS,IAE9D,EAAc,CAAG,IAAU,OAAO,KAAK,CAAG,CAAC,CAAC,WAAW,IAEpD;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFunction.cjs","names":[],"sources":["../../src/guards/isFunction.ts"],"sourcesContent":["/**\n * Determines if the passed value is a function.\n *\n * @example\n * ```ts\n * isFunction(function() {}) // true\n * isFunction(() => {}) // true\n * isFunction('hello world') // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a function, else `false`.\n */\nexport function isFunction(arg: unknown): arg is (...args:
|
|
1
|
+
{"version":3,"file":"isFunction.cjs","names":[],"sources":["../../src/guards/isFunction.ts"],"sourcesContent":["/**\n * Determines if the passed value is a function.\n *\n * @example\n * ```ts\n * isFunction(function() {}) // true\n * isFunction(() => {}) // true\n * isFunction('hello world') // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a function, else `false`.\n */\nexport function isFunction(arg: unknown): arg is (...args: never[]) => unknown {\n return typeof arg === 'function';\n}\n"],"mappings":"AAcA,SAAgB,EAAW,EAAoD,CAC7E,OAAO,OAAO,GAAQ,UACxB"}
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @returns `true` if the value is a function, else `false`.
|
|
14
14
|
*/
|
|
15
|
-
export declare function isFunction(arg: unknown): arg is (...args:
|
|
15
|
+
export declare function isFunction(arg: unknown): arg is (...args: never[]) => unknown;
|
|
16
16
|
//# sourceMappingURL=isFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFunction.d.ts","sourceRoot":"","sources":["../../src/guards/isFunction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"isFunction.d.ts","sourceRoot":"","sources":["../../src/guards/isFunction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAE7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isFunction.js","names":[],"sources":["../../src/guards/isFunction.ts"],"sourcesContent":["/**\n * Determines if the passed value is a function.\n *\n * @example\n * ```ts\n * isFunction(function() {}) // true\n * isFunction(() => {}) // true\n * isFunction('hello world') // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a function, else `false`.\n */\nexport function isFunction(arg: unknown): arg is (...args:
|
|
1
|
+
{"version":3,"file":"isFunction.js","names":[],"sources":["../../src/guards/isFunction.ts"],"sourcesContent":["/**\n * Determines if the passed value is a function.\n *\n * @example\n * ```ts\n * isFunction(function() {}) // true\n * isFunction(() => {}) // true\n * isFunction('hello world') // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if the value is a function, else `false`.\n */\nexport function isFunction(arg: unknown): arg is (...args: never[]) => unknown {\n return typeof arg === 'function';\n}\n"],"mappings":";AAcA,SAAgB,EAAW,GAAoD;CAC7E,OAAO,OAAO,KAAQ;AACxB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){
|
|
1
|
+
function e(e){return e===null||typeof e!=`object`&&typeof e!=`function`}exports.isPrimitive=e;
|
|
2
2
|
//# sourceMappingURL=isPrimitive.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPrimitive.cjs","names":[],"sources":["../../src/guards/isPrimitive.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"isPrimitive.cjs","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,EAAyC,CACnE,OAAO,IAAU,MAAS,OAAO,GAAU,UAAY,OAAO,GAAU,UAC1E"}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* ```ts
|
|
6
|
-
* isPrimitive('Hello World'); // true
|
|
7
|
-
* isPrimitive(42); // true
|
|
8
|
-
* isPrimitive(true); // true
|
|
9
|
-
* isPrimitive({}); // false
|
|
10
|
-
* isPrimitive([]); // false
|
|
11
|
-
* isPrimitive(() => {}); // false
|
|
12
|
-
* ```
|
|
13
|
-
* @param arg - The argument to be checked.
|
|
14
|
-
*
|
|
15
|
-
* @returns `true` if the value is a primitive, else `false`.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isPrimitive(arg: unknown): arg is string | number | boolean;
|
|
1
|
+
/** JavaScript values that are not objects or functions. */
|
|
2
|
+
export type PrimitiveValue = bigint | boolean | null | number | string | symbol | undefined;
|
|
3
|
+
/** Checks whether a value is a JavaScript primitive. */
|
|
4
|
+
export declare function isPrimitive(value: unknown): value is PrimitiveValue;
|
|
18
5
|
//# sourceMappingURL=isPrimitive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPrimitive.d.ts","sourceRoot":"","sources":["../../src/guards/isPrimitive.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"isPrimitive.d.ts","sourceRoot":"","sources":["../../src/guards/isPrimitive.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5F,wDAAwD;AACxD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAEnE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//#region src/guards/isPrimitive.ts
|
|
2
2
|
function e(e) {
|
|
3
|
-
|
|
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":["
|
|
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/
|
|
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
|
@@ -5,7 +5,10 @@ export * from './array/indexBy';
|
|
|
5
5
|
export * from './array/partition';
|
|
6
6
|
export * from './array/sort';
|
|
7
7
|
export * from './array/uniq';
|
|
8
|
+
export * from './async/abortable';
|
|
9
|
+
export * from './async/abortError';
|
|
8
10
|
export * from './async/attempt';
|
|
11
|
+
export * from './async/backoff';
|
|
9
12
|
export * from './async/parallel';
|
|
10
13
|
export * from './async/retry';
|
|
11
14
|
export * from './async/sleep';
|
|
@@ -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/
|
|
32
|
+
export * from './random/random';
|
|
33
|
+
export * from './random/source';
|
|
29
34
|
export * from './string/camelCase';
|
|
30
35
|
//# 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,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,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,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,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 {
|
|
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
|
-
|
|
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 };
|
package/dist/math/average.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./sum.cjs");function t(t,n){if(t.length!==0)
|
|
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
|
|
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"}
|
package/dist/math/average.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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"}
|
package/dist/math/average.js
CHANGED
|
@@ -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)
|
|
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 };
|
package/dist/math/average.js.map
CHANGED
|
@@ -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
|
|
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
|
package/dist/math/gcd.cjs.map
CHANGED
|
@@ -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"}
|
package/dist/math/gcd.d.ts.map
CHANGED
|
@@ -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,
|
|
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
package/dist/math/gcd.js.map
CHANGED
|
@@ -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"}
|
package/dist/math/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
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;
|
package/dist/math/index.d.ts
CHANGED
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,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,
|
|
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"}
|
package/dist/math/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
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){
|
|
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
|
package/dist/math/lcm.cjs.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/math/lcm.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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 };
|
package/dist/math/lcm.js.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/math/linspace.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,n=5){if(n
|
|
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
|
|
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,
|
|
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"}
|
package/dist/math/linspace.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/math/linspace.ts
|
|
2
2
|
function e(e, t, n = 5) {
|
|
3
|
-
if (
|
|
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
|
|
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"}
|
package/dist/math/median.cjs.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/math/median.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/math/median.js.map
CHANGED
|
@@ -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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
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
|
package/dist/math/sum.cjs.map
CHANGED
|
@@ -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 (
|
|
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"}
|
package/dist/math/sum.d.ts
CHANGED
|
@@ -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
|
package/dist/math/sum.d.ts.map
CHANGED
|
@@ -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,
|
|
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 (
|
|
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
|
}
|
package/dist/math/sum.js.map
CHANGED
|
@@ -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 (
|
|
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"}
|