@vielzeug/toolkit 1.0.12 → 1.0.13
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/dist/array/chunk.cjs +1 -1
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.js +15 -12
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/group.cjs +1 -1
- package/dist/array/group.cjs.map +1 -1
- package/dist/array/group.js +9 -9
- package/dist/array/group.js.map +1 -1
- package/dist/array/list.cjs +1 -1
- package/dist/array/list.cjs.map +1 -1
- package/dist/array/list.js +28 -24
- package/dist/array/list.js.map +1 -1
- package/dist/array/pick.cjs.map +1 -1
- package/dist/array/pick.js.map +1 -1
- package/dist/date/timeDiff.cjs +1 -1
- package/dist/date/timeDiff.cjs.map +1 -1
- package/dist/date/timeDiff.js +10 -12
- package/dist/date/timeDiff.js.map +1 -1
- package/dist/function/curry.cjs +1 -1
- package/dist/function/curry.cjs.map +1 -1
- package/dist/function/curry.js +3 -3
- package/dist/function/curry.js.map +1 -1
- package/dist/function/debounce.cjs +1 -1
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.js +22 -5
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/memo.cjs +1 -1
- package/dist/function/memo.cjs.map +1 -1
- package/dist/function/memo.js +14 -13
- package/dist/function/memo.js.map +1 -1
- package/dist/function/retry.cjs +1 -1
- package/dist/function/retry.cjs.map +1 -1
- package/dist/function/retry.js +13 -13
- package/dist/function/retry.js.map +1 -1
- package/dist/function/sleep.cjs +1 -1
- package/dist/function/sleep.cjs.map +1 -1
- package/dist/function/sleep.js +8 -3
- package/dist/function/sleep.js.map +1 -1
- package/dist/function/throttle.cjs +1 -1
- package/dist/function/throttle.cjs.map +1 -1
- package/dist/function/throttle.js +33 -6
- package/dist/function/throttle.js.map +1 -1
- package/dist/index.d.ts +62 -51
- package/dist/math/average.cjs +1 -1
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.js +18 -12
- package/dist/math/average.js.map +1 -1
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.js.map +1 -1
- package/dist/math/range.cjs +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.js +14 -6
- 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.js +11 -18
- package/dist/math/sum.js.map +1 -1
- package/dist/object/clone.cjs +1 -1
- package/dist/object/clone.cjs.map +1 -1
- package/dist/object/clone.js +13 -3
- package/dist/object/clone.js.map +1 -1
- package/dist/object/merge.cjs +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.js +11 -15
- package/dist/object/merge.js.map +1 -1
- package/dist/object/seek.cjs +1 -1
- package/dist/object/seek.cjs.map +1 -1
- package/dist/object/seek.js +8 -6
- package/dist/object/seek.js.map +1 -1
- package/dist/random/uuid.cjs +1 -1
- package/dist/random/uuid.cjs.map +1 -1
- package/dist/random/uuid.js +6 -3
- package/dist/random/uuid.js.map +1 -1
- package/dist/string/camelCase.cjs +1 -1
- package/dist/string/camelCase.cjs.map +1 -1
- package/dist/string/camelCase.js +3 -3
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/similarity.cjs +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.js +24 -21
- 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.js +14 -5
- package/dist/string/truncate.js.map +1 -1
- package/dist/typed/is.cjs +1 -1
- package/dist/typed/is.cjs.map +1 -1
- package/dist/typed/is.js +30 -31
- package/dist/typed/is.js.map +1 -1
- package/dist/typed/isEmpty.cjs +1 -1
- package/dist/typed/isEmpty.cjs.map +1 -1
- package/dist/typed/isEmpty.js +6 -6
- package/dist/typed/isEmpty.js.map +1 -1
- package/dist/typed/isEqual.cjs +1 -1
- package/dist/typed/isEqual.cjs.map +1 -1
- package/dist/typed/isEqual.js +22 -17
- package/dist/typed/isEqual.js.map +1 -1
- package/package.json +1 -1
package/dist/math/median.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"median.cjs","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 * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return allDates ? new Date(medianValue) : medianValue;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"gFAgBO,SAASA,EAAUC,EAAUC,EAAkE,CACpG,GAAID,EAAI,SAAW,EAAG,OAEtB,MAAME,EAASD,EAAWD,EAAI,IAAIC,CAAQ,EAAKD,EACzCG,EAAWD,EAAO,MAAOE,GAAMA,aAAa,IAAI,EAChDC,EAAgBH,EAAO,IAAKE,GAAOA,aAAa,KAAOA,EAAE,QAAA,EAAaA,CAAa,EAEzFC,EAAc,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EAElC,MAAMC,EAAM,KAAK,MAAMH,EAAc,OAAS,CAAC,EACzCI,EACJJ,EAAc,OAAS,IAAM,GAAKA,EAAcG,EAAM,CAAC,EAAIH,EAAcG,CAAG,GAAK,EAAIH,EAAcG,CAAG,EAExG,
|
|
1
|
+
{"version":3,"file":"median.cjs","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 * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return (allDates ? new Date(medianValue) : medianValue) as unknown as number | Date;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"gFAgBO,SAASA,EAAUC,EAAUC,EAAkE,CACpG,GAAID,EAAI,SAAW,EAAG,OAEtB,MAAME,EAASD,EAAWD,EAAI,IAAIC,CAAQ,EAAKD,EACzCG,EAAWD,EAAO,MAAOE,GAAMA,aAAa,IAAI,EAChDC,EAAgBH,EAAO,IAAKE,GAAOA,aAAa,KAAOA,EAAE,QAAA,EAAaA,CAAa,EAEzFC,EAAc,KAAK,CAACC,EAAGC,IAAMD,EAAIC,CAAC,EAElC,MAAMC,EAAM,KAAK,MAAMH,EAAc,OAAS,CAAC,EACzCI,EACJJ,EAAc,OAAS,IAAM,GAAKA,EAAcG,EAAM,CAAC,EAAIH,EAAcG,CAAG,GAAK,EAAIH,EAAcG,CAAG,EAExG,OAAQL,EAAW,IAAI,KAAKM,CAAW,EAAIA,CAC7C"}
|
package/dist/math/median.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"median.js","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 * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return allDates ? new Date(medianValue) : medianValue;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"AAgBO,SAASA,EAAUC,GAAUC,GAAkE;AACpG,MAAID,EAAI,WAAW,EAAG;AAEtB,QAAME,IAASD,IAAWD,EAAI,IAAIC,CAAQ,IAAKD,GACzCG,IAAWD,EAAO,MAAM,CAACE,MAAMA,aAAa,IAAI,GAChDC,IAAgBH,EAAO,IAAI,CAACE,MAAOA,aAAa,OAAOA,EAAE,QAAA,IAAaA,CAAa;AAEzF,EAAAC,EAAc,KAAK,CAACC,GAAGC,MAAMD,IAAIC,CAAC;AAElC,QAAMC,IAAM,KAAK,MAAMH,EAAc,SAAS,CAAC,GACzCI,IACJJ,EAAc,SAAS,MAAM,KAAKA,EAAcG,IAAM,CAAC,IAAIH,EAAcG,CAAG,KAAK,IAAIH,EAAcG,CAAG;AAExG,
|
|
1
|
+
{"version":3,"file":"median.js","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 * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map the numbers.\n * @returns The median of the numbers.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : (arr as unknown as (number | Date)[]);\n const allDates = values.every((v) => v instanceof Date);\n const numericValues = values.map((v) => (v instanceof Date ? v.getTime() : (v as number)));\n\n numericValues.sort((a, b) => a - b);\n\n const mid = Math.floor(numericValues.length / 2);\n const medianValue =\n numericValues.length % 2 === 0 ? (numericValues[mid - 1] + numericValues[mid]) / 2 : numericValues[mid];\n\n return (allDates ? new Date(medianValue) : medianValue) as unknown as number | Date;\n}\n"],"names":["median","arr","callback","values","allDates","v","numericValues","a","b","mid","medianValue"],"mappings":"AAgBO,SAASA,EAAUC,GAAUC,GAAkE;AACpG,MAAID,EAAI,WAAW,EAAG;AAEtB,QAAME,IAASD,IAAWD,EAAI,IAAIC,CAAQ,IAAKD,GACzCG,IAAWD,EAAO,MAAM,CAACE,MAAMA,aAAa,IAAI,GAChDC,IAAgBH,EAAO,IAAI,CAACE,MAAOA,aAAa,OAAOA,EAAE,QAAA,IAAaA,CAAa;AAEzF,EAAAC,EAAc,KAAK,CAACC,GAAGC,MAAMD,IAAIC,CAAC;AAElC,QAAMC,IAAM,KAAK,MAAMH,EAAc,SAAS,CAAC,GACzCI,IACJJ,EAAc,SAAS,MAAM,KAAKA,EAAcG,IAAM,CAAC,IAAIH,EAAcG,CAAG,KAAK,IAAIH,EAAcG,CAAG;AAExG,SAAQL,IAAW,IAAI,KAAKM,CAAW,IAAIA;AAC7C;"}
|
package/dist/math/range.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../function/assert.cjs");function m(r,i,e){if(a.assert(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(e),"start, stop, and step must be finite numbers",{args:{start:r,step:e,stop:i},type:TypeError}),a.assert(e!==0,"Step cannot be 0",{args:{step:e},type:Error}),r===i)return[];const n=Math.max(0,Math.ceil((i-r)/e+Number.EPSILON));return a.assert(n<=1e7,"Range exceeds maximum allowed size of 10,000,000",{args:{length:n,start:r,step:e,stop:i},type:Error}),Array.from({length:n},(t,u)=>r+u*e)}exports.range=m;
|
|
2
2
|
//# sourceMappingURL=range.cjs.map
|
package/dist/math/range.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.cjs","sources":["../../src/math/range.ts"],"sourcesContent":["/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n */\nexport function range(start: number, stop: number, step: number) {\n
|
|
1
|
+
{"version":3,"file":"range.cjs","sources":["../../src/math/range.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {TypeError} If start, stop, or step are not finite numbers.\n * @throws {Error} If step is 0 or if range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number) {\n assert(\n Number.isFinite(start) && Number.isFinite(stop) && Number.isFinite(step),\n 'start, stop, and step must be finite numbers',\n { args: { start, step, stop }, type: TypeError },\n );\n assert(step !== 0, 'Step cannot be 0', { args: { step }, type: Error });\n\n if (start === stop) {\n return [];\n }\n\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n\n assert(length <= 10_000_000, 'Range exceeds maximum allowed size of 10,000,000', {\n args: { length, start, step, stop },\n type: Error,\n });\n\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"names":["range","start","stop","step","assert","length","_","i"],"mappings":"0HAuBO,SAASA,EAAMC,EAAeC,EAAcC,EAAc,CAQ/D,GAPAC,EAAAA,OACE,OAAO,SAASH,CAAK,GAAK,OAAO,SAASC,CAAI,GAAK,OAAO,SAASC,CAAI,EACvE,+CACA,CAAE,KAAM,CAAE,MAAAF,EAAO,KAAAE,EAAM,KAAAD,CAAA,EAAQ,KAAM,SAAA,CAAU,EAEjDE,SAAOD,IAAS,EAAG,mBAAoB,CAAE,KAAM,CAAE,KAAAA,CAAA,EAAQ,KAAM,MAAO,EAElEF,IAAUC,EACZ,MAAO,CAAA,EAGT,MAAMG,EAAS,KAAK,IAAI,EAAG,KAAK,MAAMH,EAAOD,GAASE,EAAO,OAAO,OAAO,CAAC,EAE5EC,OAAAA,SAAOC,GAAU,IAAY,mDAAoD,CAC/E,KAAM,CAAE,OAAAA,EAAQ,MAAAJ,EAAO,KAAAE,EAAM,KAAAD,CAAA,EAC7B,KAAM,KAAA,CACP,EAEM,MAAM,KAAK,CAAE,OAAAG,CAAA,EAAU,CAACC,EAAGC,IAAMN,EAAQM,EAAIJ,CAAI,CAC1D"}
|
package/dist/math/range.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { assert as m } from "../function/assert.js";
|
|
2
|
+
function b(r, i, e) {
|
|
3
|
+
if (m(
|
|
4
|
+
Number.isFinite(r) && Number.isFinite(i) && Number.isFinite(e),
|
|
5
|
+
"start, stop, and step must be finite numbers",
|
|
6
|
+
{ args: { start: r, step: e, stop: i }, type: TypeError }
|
|
7
|
+
), m(e !== 0, "Step cannot be 0", { args: { step: e }, type: Error }), r === i)
|
|
8
|
+
return [];
|
|
9
|
+
const n = Math.max(0, Math.ceil((i - r) / e + Number.EPSILON));
|
|
10
|
+
return m(n <= 1e7, "Range exceeds maximum allowed size of 10,000,000", {
|
|
11
|
+
args: { length: n, start: r, step: e, stop: i },
|
|
12
|
+
type: Error
|
|
13
|
+
}), Array.from({ length: n }, (u, a) => r + a * e);
|
|
6
14
|
}
|
|
7
15
|
export {
|
|
8
|
-
|
|
16
|
+
b as range
|
|
9
17
|
};
|
|
10
18
|
//# sourceMappingURL=range.js.map
|
package/dist/math/range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sources":["../../src/math/range.ts"],"sourcesContent":["/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n */\nexport function range(start: number, stop: number, step: number) {\n
|
|
1
|
+
{"version":3,"file":"range.js","sources":["../../src/math/range.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.\n *\n * @example\n * ```ts\n * const start = 0;\n * const stop = 10;\n * const step = 2;\n *\n * range(start, stop, step) // [0, 2, 4, 6, 8];\n * ```\n *\n * @param start - The start of the range.\n * @param stop - The end of the range.\n * @param step - The value to increment or decrement by.\n *\n * @returns The range of numbers.\n *\n * @throws {TypeError} If start, stop, or step are not finite numbers.\n * @throws {Error} If step is 0 or if range exceeds maximum size.\n */\nexport function range(start: number, stop: number, step: number) {\n assert(\n Number.isFinite(start) && Number.isFinite(stop) && Number.isFinite(step),\n 'start, stop, and step must be finite numbers',\n { args: { start, step, stop }, type: TypeError },\n );\n assert(step !== 0, 'Step cannot be 0', { args: { step }, type: Error });\n\n if (start === stop) {\n return [];\n }\n\n const length = Math.max(0, Math.ceil((stop - start) / step + Number.EPSILON));\n\n assert(length <= 10_000_000, 'Range exceeds maximum allowed size of 10,000,000', {\n args: { length, start, step, stop },\n type: Error,\n });\n\n return Array.from({ length }, (_, i) => start + i * step);\n}\n"],"names":["range","start","stop","step","assert","length","_","i"],"mappings":";AAuBO,SAASA,EAAMC,GAAeC,GAAcC,GAAc;AAQ/D,MAPAC;AAAA,IACE,OAAO,SAASH,CAAK,KAAK,OAAO,SAASC,CAAI,KAAK,OAAO,SAASC,CAAI;AAAA,IACvE;AAAA,IACA,EAAE,MAAM,EAAE,OAAAF,GAAO,MAAAE,GAAM,MAAAD,EAAA,GAAQ,MAAM,UAAA;AAAA,EAAU,GAEjDE,EAAOD,MAAS,GAAG,oBAAoB,EAAE,MAAM,EAAE,MAAAA,EAAA,GAAQ,MAAM,OAAO,GAElEF,MAAUC;AACZ,WAAO,CAAA;AAGT,QAAMG,IAAS,KAAK,IAAI,GAAG,KAAK,MAAMH,IAAOD,KAASE,IAAO,OAAO,OAAO,CAAC;AAE5E,SAAAC,EAAOC,KAAU,KAAY,oDAAoD;AAAA,IAC/E,MAAM,EAAE,QAAAA,GAAQ,OAAAJ,GAAO,MAAAE,GAAM,MAAAD,EAAA;AAAA,IAC7B,MAAM;AAAA,EAAA,CACP,GAEM,MAAM,KAAK,EAAE,QAAAG,EAAA,GAAU,CAACC,GAAGC,MAAMN,IAAQM,IAAIJ,CAAI;AAC1D;"}
|
package/dist/math/sum.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(r,t){if(r.length!==0)return r.reduce((o,n)=>{const e=t?t(n):n;if(typeof e!="number")throw new TypeError(`Expected number, got ${typeof e}`);if(Number.isNaN(e))throw new TypeError("Cannot sum NaN values");return o+e},0)}exports.sum=u;
|
|
2
2
|
//# sourceMappingURL=sum.cjs.map
|
package/dist/math/sum.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sum.cjs","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 *
|
|
1
|
+
{"version":3,"file":"sum.cjs","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 */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : item;\n if (typeof val !== 'number') {\n throw new TypeError(`Expected number, got ${typeof val}`);\n }\n if (Number.isNaN(val)) {\n throw new TypeError('Cannot sum NaN values');\n }\n return acc + val;\n }, 0);\n}\n"],"names":["sum","array","callback","acc","item","val"],"mappings":"gFAeO,SAASA,EAAOC,EAAYC,EAAoD,CACrF,GAAID,EAAM,SAAW,EAErB,OAAOA,EAAM,OAAe,CAACE,EAAKC,IAAS,CACzC,MAAMC,EAAMH,EAAWA,EAASE,CAAI,EAAIA,EACxC,GAAI,OAAOC,GAAQ,SACjB,MAAM,IAAI,UAAU,wBAAwB,OAAOA,CAAG,EAAE,EAE1D,GAAI,OAAO,MAAMA,CAAG,EAClB,MAAM,IAAI,UAAU,uBAAuB,EAE7C,OAAOF,EAAME,CACf,EAAG,CAAC,CACN"}
|
package/dist/math/sum.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (
|
|
3
|
-
return
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
function i(t, e) {
|
|
13
|
-
const n = t.getTime();
|
|
14
|
-
return e === void 0 ? new Date(n) : e instanceof Date ? new Date(e.getTime() + n) : new Date(e + n);
|
|
15
|
-
}
|
|
16
|
-
function o(t, e) {
|
|
17
|
-
return t === void 0 ? e : t instanceof Date ? new Date(t.getTime() + e) : t + e;
|
|
1
|
+
function u(r, n) {
|
|
2
|
+
if (r.length !== 0)
|
|
3
|
+
return r.reduce((o, t) => {
|
|
4
|
+
const e = n ? n(t) : t;
|
|
5
|
+
if (typeof e != "number")
|
|
6
|
+
throw new TypeError(`Expected number, got ${typeof e}`);
|
|
7
|
+
if (Number.isNaN(e))
|
|
8
|
+
throw new TypeError("Cannot sum NaN values");
|
|
9
|
+
return o + e;
|
|
10
|
+
}, 0);
|
|
18
11
|
}
|
|
19
12
|
export {
|
|
20
|
-
|
|
13
|
+
u as sum
|
|
21
14
|
};
|
|
22
15
|
//# sourceMappingURL=sum.js.map
|
package/dist/math/sum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sum.js","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 *
|
|
1
|
+
{"version":3,"file":"sum.js","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 */\nexport function sum<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n return array.reduce<number>((acc, item) => {\n const val = callback ? callback(item) : item;\n if (typeof val !== 'number') {\n throw new TypeError(`Expected number, got ${typeof val}`);\n }\n if (Number.isNaN(val)) {\n throw new TypeError('Cannot sum NaN values');\n }\n return acc + val;\n }, 0);\n}\n"],"names":["sum","array","callback","acc","item","val"],"mappings":"AAeO,SAASA,EAAOC,GAAYC,GAAoD;AACrF,MAAID,EAAM,WAAW;AAErB,WAAOA,EAAM,OAAe,CAACE,GAAKC,MAAS;AACzC,YAAMC,IAAMH,IAAWA,EAASE,CAAI,IAAIA;AACxC,UAAI,OAAOC,KAAQ;AACjB,cAAM,IAAI,UAAU,wBAAwB,OAAOA,CAAG,EAAE;AAE1D,UAAI,OAAO,MAAMA,CAAG;AAClB,cAAM,IAAI,UAAU,uBAAuB;AAE7C,aAAOF,IAAME;AAAA,IACf,GAAG,CAAC;AACN;"}
|
package/dist/object/clone.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){return structuredClone(e)}exports.clone=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){if(typeof structuredClone=="function")try{return structuredClone(e)}catch(r){throw new Error(`Failed to clone item: ${r instanceof Error?r.message:String(r)}`)}try{return JSON.parse(JSON.stringify(e))}catch(r){throw new Error(`Failed to clone item using JSON: ${r instanceof Error?r.message:String(r)}`)}}exports.clone=t;
|
|
2
2
|
//# sourceMappingURL=clone.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.cjs","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n */\nexport function clone<T>(item: T): T {\n return structuredClone(item);\n}\n"],"names":["clone","item"],"mappings":"
|
|
1
|
+
{"version":3,"file":"clone.cjs","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n *\n * @throws {Error} If the item cannot be cloned.\n */\nexport function clone<T>(item: T): T {\n if (typeof structuredClone === 'function') {\n try {\n return structuredClone(item);\n } catch (error) {\n throw new Error(`Failed to clone item: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n try {\n return JSON.parse(JSON.stringify(item));\n } catch (error) {\n throw new Error(`Failed to clone item using JSON: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n"],"names":["clone","item","error"],"mappings":"gFAmBO,SAASA,EAASC,EAAY,CACnC,GAAI,OAAO,iBAAoB,WAC7B,GAAI,CACF,OAAO,gBAAgBA,CAAI,CAC7B,OAASC,EAAO,CACd,MAAM,IAAI,MAAM,yBAAyBA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAE,CACnG,CAEF,GAAI,CACF,OAAO,KAAK,MAAM,KAAK,UAAUD,CAAI,CAAC,CACxC,OAASC,EAAO,CACd,MAAM,IAAI,MAAM,oCAAoCA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAE,CAC9G,CACF"}
|
package/dist/object/clone.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
1
|
+
function t(e) {
|
|
2
|
+
if (typeof structuredClone == "function")
|
|
3
|
+
try {
|
|
4
|
+
return structuredClone(e);
|
|
5
|
+
} catch (r) {
|
|
6
|
+
throw new Error(`Failed to clone item: ${r instanceof Error ? r.message : String(r)}`);
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(JSON.stringify(e));
|
|
10
|
+
} catch (r) {
|
|
11
|
+
throw new Error(`Failed to clone item using JSON: ${r instanceof Error ? r.message : String(r)}`);
|
|
12
|
+
}
|
|
3
13
|
}
|
|
4
14
|
export {
|
|
5
|
-
|
|
15
|
+
t as clone
|
|
6
16
|
};
|
|
7
17
|
//# sourceMappingURL=clone.js.map
|
package/dist/object/clone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.js","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n */\nexport function clone<T>(item: T): T {\n return structuredClone(item);\n}\n"],"names":["clone","item"],"mappings":"
|
|
1
|
+
{"version":3,"file":"clone.js","sources":["../../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a deep copy of the provided data using the structuredClone algorithm.\n *\n * @example\n * ```ts\n * const obj = { a: 1, b: { c: 2 } };\n * const dup = clone(obj);\n *\n * dup.b.c = 3;\n * console.log(obj.b.c); // logs 2\n * console.log(dup.b.c); // logs 3\n * ```\n *\n * @param item - The data to clone.\n *\n * @returns A deep copy of the provided data.\n *\n * @throws {Error} If the item cannot be cloned.\n */\nexport function clone<T>(item: T): T {\n if (typeof structuredClone === 'function') {\n try {\n return structuredClone(item);\n } catch (error) {\n throw new Error(`Failed to clone item: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n try {\n return JSON.parse(JSON.stringify(item));\n } catch (error) {\n throw new Error(`Failed to clone item using JSON: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n"],"names":["clone","item","error"],"mappings":"AAmBO,SAASA,EAASC,GAAY;AACnC,MAAI,OAAO,mBAAoB;AAC7B,QAAI;AACF,aAAO,gBAAgBA,CAAI;AAAA,IAC7B,SAASC,GAAO;AACd,YAAM,IAAI,MAAM,yBAAyBA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC,EAAE;AAAA,IACnG;AAEF,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,UAAUD,CAAI,CAAC;AAAA,EACxC,SAASC,GAAO;AACd,UAAM,IAAI,MAAM,oCAAoCA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC,EAAE;AAAA,EAC9G;AACF;"}
|
package/dist/object/merge.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../typed/isArray.cjs"),f=require("../typed/isObject.cjs");function a(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../typed/isArray.cjs"),f=require("../typed/isObject.cjs");function a(i="deep",...n){return n.length===0?{}:i==="shallow"?Object.assign({},...n):n.reduce((e,r)=>l(e,r,i),{})}function l(i,n,e){if(!f.isObject(n))return n;const r={...i};for(const c in n){if(!Object.hasOwn(n,c))continue;const t=n[c],u=r[c];r[c]=o.isArray(t)&&o.isArray(u)?b(u,t,e):f.isObject(t)&&f.isObject(u)?l(u,t,e):O(u,t,e)}return r}function b(i,n,e){return i?e==="arrayConcat"?i.concat(n):e==="arrayReplace"?n:Array.from(new Set([...i,...n])):n}function O(i,n,e){return typeof e=="function"?e(i,n):e==="lastWins"||n!==void 0?n:i}exports.merge=a;
|
|
2
2
|
//# sourceMappingURL=merge.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.cjs","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n
|
|
1
|
+
{"version":3,"file":"merge.cjs","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n return items.reduce((acc, obj) => deepMerge(acc, obj, strategy) as unknown as Merge<T>, {} as Merge<T>);\n}\n\n/**\n * Deeply merges two objects based on the provided strategy.\n *\n * - Uses **direct property access** for performance.\n * - **Avoids redundant deep merging** where unnecessary.\n * - Optimized **array merging strategies**.\n *\n * @param target - The target object.\n * @param source - The source object.\n * @param strategy - The merge strategy.\n * @returns A new merged object.\n */\nfunction deepMerge<T extends Obj, U extends Obj>(target: T, source: U, strategy: MergeStrategy): DeepMerge<T, U> {\n if (!isObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key in source) {\n if (!Object.hasOwn(source, key)) continue; // Prevent prototype pollution\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n // biome-ignore lint/suspicious/noExplicitAny: -\n (result as any)[key] =\n isArray(sourceValue) && isArray(targetValue)\n ? handleArrayMerge(targetValue, sourceValue, strategy)\n : isObject(sourceValue) && isObject(targetValue)\n ? deepMerge(targetValue, sourceValue, strategy)\n : applyMergeStrategy(targetValue, sourceValue, strategy);\n }\n\n return result;\n}\n\n/**\n * Optimized array merge based on strategy.\n *\n * - `\"arrayConcat\"` → Concatenates arrays.\n * - `\"arrayReplace\"` → Replaces the existing array.\n * - Default: **Unique merge** (Set-based optimization).\n */\nfunction handleArrayMerge<T, U>(targetArray: T[] | undefined, sourceArray: U[], strategy: MergeStrategy): (T | U)[] {\n if (!targetArray) return sourceArray;\n // biome-ignore lint/suspicious/noExplicitAny: -\n if (strategy === 'arrayConcat') return targetArray.concat(sourceArray as any);\n if (strategy === 'arrayReplace') return sourceArray;\n return Array.from(new Set([...targetArray, ...sourceArray])); // Unique merge\n}\n\n/**\n * Determines the appropriate value to assign based on the merge strategy.\n *\n * - `\"lastWins\"` → Overwrites with the latest value.\n * - Custom functions → Allows user-defined behavior.\n */\nfunction applyMergeStrategy<T, U>(target: T, source: U, strategy: MergeStrategy): T | U {\n if (typeof strategy === 'function') return strategy(target, source);\n return strategy === 'lastWins' || source !== undefined ? source : target;\n}\n"],"names":["merge","strategy","items","acc","obj","deepMerge","target","source","isObject","result","key","sourceValue","targetValue","isArray","handleArrayMerge","applyMergeStrategy","targetArray","sourceArray"],"mappings":"2JAoDO,SAASA,EAAuBC,EAA0B,UAAWC,EAAyB,CACnG,OAAIA,EAAM,SAAW,EAAU,CAAA,EAE3BD,IAAa,UACR,OAAO,OAAO,CAAA,EAAI,GAAGC,CAAK,EAG5BA,EAAM,OAAO,CAACC,EAAKC,IAAQC,EAAUF,EAAKC,EAAKH,CAAQ,EAA0B,EAAc,CACxG,CAcA,SAASI,EAAwCC,EAAWC,EAAWN,EAA0C,CAC/G,GAAI,CAACO,EAAAA,SAASD,CAAM,EAAG,OAAOA,EAE9B,MAAME,EAAS,CAAE,GAAGH,CAAA,EAEpB,UAAWI,KAAOH,EAAQ,CACxB,GAAI,CAAC,OAAO,OAAOA,EAAQG,CAAG,EAAG,SAEjC,MAAMC,EAAcJ,EAAOG,CAAG,EACxBE,EAAcH,EAAOC,CAAG,EAG7BD,EAAeC,CAAG,EACjBG,EAAAA,QAAQF,CAAW,GAAKE,EAAAA,QAAQD,CAAW,EACvCE,EAAiBF,EAAaD,EAAaV,CAAQ,EACnDO,EAAAA,SAASG,CAAW,GAAKH,EAAAA,SAASI,CAAW,EAC3CP,EAAUO,EAAaD,EAAaV,CAAQ,EAC5Cc,EAAmBH,EAAaD,EAAaV,CAAQ,CAC/D,CAEA,OAAOQ,CACT,CASA,SAASK,EAAuBE,EAA8BC,EAAkBhB,EAAoC,CAClH,OAAKe,EAEDf,IAAa,cAAsBe,EAAY,OAAOC,CAAkB,EACxEhB,IAAa,eAAuBgB,EACjC,MAAM,KAAK,IAAI,IAAI,CAAC,GAAGD,EAAa,GAAGC,CAAW,CAAC,CAAC,EAJlCA,CAK3B,CAQA,SAASF,EAAyBT,EAAWC,EAAWN,EAAgC,CACtF,OAAI,OAAOA,GAAa,WAAmBA,EAASK,EAAQC,CAAM,EAC3DN,IAAa,YAAcM,IAAW,OAAYA,EAASD,CACpE"}
|
package/dist/object/merge.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { isArray as c } from "../typed/isArray.js";
|
|
2
2
|
import { isObject as u } from "../typed/isObject.js";
|
|
3
|
-
function m(
|
|
4
|
-
return n.length === 0 ? {} :
|
|
5
|
-
// @ts-expect-error
|
|
6
|
-
(e, i) => l(e, i, r),
|
|
7
|
-
{}
|
|
8
|
-
);
|
|
3
|
+
function m(i = "deep", ...n) {
|
|
4
|
+
return n.length === 0 ? {} : i === "shallow" ? Object.assign({}, ...n) : n.reduce((e, r) => l(e, r, i), {});
|
|
9
5
|
}
|
|
10
|
-
function l(
|
|
6
|
+
function l(i, n, e) {
|
|
11
7
|
if (!u(n)) return n;
|
|
12
|
-
const
|
|
8
|
+
const r = { ...i };
|
|
13
9
|
for (const o in n) {
|
|
14
10
|
if (!Object.hasOwn(n, o)) continue;
|
|
15
|
-
const
|
|
16
|
-
|
|
11
|
+
const f = n[o], t = r[o];
|
|
12
|
+
r[o] = c(f) && c(t) ? p(t, f, e) : u(f) && u(t) ? l(t, f, e) : a(t, f, e);
|
|
17
13
|
}
|
|
18
|
-
return
|
|
14
|
+
return r;
|
|
19
15
|
}
|
|
20
|
-
function p(
|
|
21
|
-
return
|
|
16
|
+
function p(i, n, e) {
|
|
17
|
+
return i ? e === "arrayConcat" ? i.concat(n) : e === "arrayReplace" ? n : Array.from(/* @__PURE__ */ new Set([...i, ...n])) : n;
|
|
22
18
|
}
|
|
23
|
-
function a(
|
|
24
|
-
return typeof e == "function" ? e(
|
|
19
|
+
function a(i, n, e) {
|
|
20
|
+
return typeof e == "function" ? e(i, n) : e === "lastWins" || n !== void 0 ? n : i;
|
|
25
21
|
}
|
|
26
22
|
export {
|
|
27
23
|
m as merge
|
package/dist/object/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n
|
|
1
|
+
{"version":3,"file":"merge.js","sources":["../../src/object/merge.ts"],"sourcesContent":["import { isArray } from '../typed/isArray';\nimport { isObject } from '../typed/isObject';\nimport type { Obj } from '../types';\n\ntype MergeStrategy =\n | 'deep'\n | 'shallow'\n | 'lastWins'\n | 'arrayConcat'\n | 'arrayReplace'\n // biome-ignore lint/suspicious/noExplicitAny: -\n | ((target: any, source: any) => any);\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\n/**\n * Merges multiple objects based on a specified merge strategy.\n *\n * @example\n * ```ts\n * const obj1 = { a: 1, b: { x: 10, y: \"hello\" }, c: [1] };\n * const obj2 = { b: { y: 20, z: true }, c: [2] };\n * const obj3 = { d: false, c: [3] };\n *\n * merge(\"deep\", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }\n * merge(\"shallow\", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }\n * ```\n *\n * @param [strategy='deep'] - The merging strategy to use.\n * @param items - The objects to merge.\n * @returns A new merged object.\n */\nexport function merge<T extends Obj[]>(strategy: MergeStrategy = 'deep', ...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n if (strategy === 'shallow') {\n return Object.assign({}, ...items) as Merge<T>;\n }\n\n return items.reduce((acc, obj) => deepMerge(acc, obj, strategy) as unknown as Merge<T>, {} as Merge<T>);\n}\n\n/**\n * Deeply merges two objects based on the provided strategy.\n *\n * - Uses **direct property access** for performance.\n * - **Avoids redundant deep merging** where unnecessary.\n * - Optimized **array merging strategies**.\n *\n * @param target - The target object.\n * @param source - The source object.\n * @param strategy - The merge strategy.\n * @returns A new merged object.\n */\nfunction deepMerge<T extends Obj, U extends Obj>(target: T, source: U, strategy: MergeStrategy): DeepMerge<T, U> {\n if (!isObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key in source) {\n if (!Object.hasOwn(source, key)) continue; // Prevent prototype pollution\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n // biome-ignore lint/suspicious/noExplicitAny: -\n (result as any)[key] =\n isArray(sourceValue) && isArray(targetValue)\n ? handleArrayMerge(targetValue, sourceValue, strategy)\n : isObject(sourceValue) && isObject(targetValue)\n ? deepMerge(targetValue, sourceValue, strategy)\n : applyMergeStrategy(targetValue, sourceValue, strategy);\n }\n\n return result;\n}\n\n/**\n * Optimized array merge based on strategy.\n *\n * - `\"arrayConcat\"` → Concatenates arrays.\n * - `\"arrayReplace\"` → Replaces the existing array.\n * - Default: **Unique merge** (Set-based optimization).\n */\nfunction handleArrayMerge<T, U>(targetArray: T[] | undefined, sourceArray: U[], strategy: MergeStrategy): (T | U)[] {\n if (!targetArray) return sourceArray;\n // biome-ignore lint/suspicious/noExplicitAny: -\n if (strategy === 'arrayConcat') return targetArray.concat(sourceArray as any);\n if (strategy === 'arrayReplace') return sourceArray;\n return Array.from(new Set([...targetArray, ...sourceArray])); // Unique merge\n}\n\n/**\n * Determines the appropriate value to assign based on the merge strategy.\n *\n * - `\"lastWins\"` → Overwrites with the latest value.\n * - Custom functions → Allows user-defined behavior.\n */\nfunction applyMergeStrategy<T, U>(target: T, source: U, strategy: MergeStrategy): T | U {\n if (typeof strategy === 'function') return strategy(target, source);\n return strategy === 'lastWins' || source !== undefined ? source : target;\n}\n"],"names":["merge","strategy","items","acc","obj","deepMerge","target","source","isObject","result","key","sourceValue","targetValue","isArray","handleArrayMerge","applyMergeStrategy","targetArray","sourceArray"],"mappings":";;AAoDO,SAASA,EAAuBC,IAA0B,WAAWC,GAAyB;AACnG,SAAIA,EAAM,WAAW,IAAU,CAAA,IAE3BD,MAAa,YACR,OAAO,OAAO,CAAA,GAAI,GAAGC,CAAK,IAG5BA,EAAM,OAAO,CAACC,GAAKC,MAAQC,EAAUF,GAAKC,GAAKH,CAAQ,GAA0B,EAAc;AACxG;AAcA,SAASI,EAAwCC,GAAWC,GAAWN,GAA0C;AAC/G,MAAI,CAACO,EAASD,CAAM,EAAG,QAAOA;AAE9B,QAAME,IAAS,EAAE,GAAGH,EAAA;AAEpB,aAAWI,KAAOH,GAAQ;AACxB,QAAI,CAAC,OAAO,OAAOA,GAAQG,CAAG,EAAG;AAEjC,UAAMC,IAAcJ,EAAOG,CAAG,GACxBE,IAAcH,EAAOC,CAAG;AAG7B,IAAAD,EAAeC,CAAG,IACjBG,EAAQF,CAAW,KAAKE,EAAQD,CAAW,IACvCE,EAAiBF,GAAaD,GAAaV,CAAQ,IACnDO,EAASG,CAAW,KAAKH,EAASI,CAAW,IAC3CP,EAAUO,GAAaD,GAAaV,CAAQ,IAC5Cc,EAAmBH,GAAaD,GAAaV,CAAQ;AAAA,EAC/D;AAEA,SAAOQ;AACT;AASA,SAASK,EAAuBE,GAA8BC,GAAkBhB,GAAoC;AAClH,SAAKe,IAEDf,MAAa,gBAAsBe,EAAY,OAAOC,CAAkB,IACxEhB,MAAa,iBAAuBgB,IACjC,MAAM,KAAK,oBAAI,IAAI,CAAC,GAAGD,GAAa,GAAGC,CAAW,CAAC,CAAC,IAJlCA;AAK3B;AAQA,SAASF,EAAyBT,GAAWC,GAAWN,GAAgC;AACtF,SAAI,OAAOA,KAAa,aAAmBA,EAASK,GAAQC,CAAM,IAC3DN,MAAa,cAAcM,MAAW,SAAYA,IAASD;AACpE;"}
|
package/dist/object/seek.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../function/assert.cjs"),l=require("../string/similarity.cjs"),s=require("../typed/is.cjs"),a=require("../typed/isWithin.cjs");function t(r,n,i=1){return u.assert(a.isWithin(i,0,1),a.IS_WITHIN_ERROR_MSG,{args:{max:1,min:0,tone:i},type:TypeError}),s.is("nil",r)?!1:s.is("string",r)||s.is("number",r)?l.similarity(r,n)>=i:s.is("array",r)?r.some(e=>t(e,n,i)):s.is("object",r)?Object.values(r).some(e=>s.is("nil",e)?!1:t(e,n,i)):!1}exports.seek=t;
|
|
2
2
|
//# sourceMappingURL=seek.cjs.map
|
package/dist/object/seek.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seek.cjs","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n
|
|
1
|
+
{"version":3,"file":"seek.cjs","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('nil', item)) return false;\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n // Handle arrays\n if (is('array', item)) {\n return (item as unknown[]).some((value) => seek(value, query, tone));\n }\n\n // Handle objects but skip dates/regex/etc which are technically objects\n if (is('object', item)) {\n return Object.values(item as Record<string, unknown>).some((value) =>\n is('nil', value) ? false : seek(value, query, tone),\n );\n }\n\n return false;\n}\n"],"names":["seek","item","query","tone","assert","isWithin","IS_WITHIN_ERROR_MSG","is","similarity","value"],"mappings":"gOA6BO,SAASA,EAAQC,EAASC,EAAeC,EAAO,EAAY,CAGjE,OAFAC,EAAAA,OAAOC,EAAAA,SAASF,EAAM,EAAG,CAAC,EAAGG,EAAAA,oBAAqB,CAAE,KAAM,CAAE,IAAK,EAAG,IAAK,EAAG,KAAAH,GAAQ,KAAM,UAAW,EAEjGI,KAAG,MAAON,CAAI,EAAU,GAExBM,EAAAA,GAAG,SAAUN,CAAI,GAAKM,EAAAA,GAAG,SAAUN,CAAI,EAElCO,aAAWP,EAAMC,CAAK,GAAKC,EAIhCI,EAAAA,GAAG,QAASN,CAAI,EACVA,EAAmB,KAAMQ,GAAUT,EAAKS,EAAOP,EAAOC,CAAI,CAAC,EAIjEI,EAAAA,GAAG,SAAUN,CAAI,EACZ,OAAO,OAAOA,CAA+B,EAAE,KAAMQ,GAC1DF,KAAG,MAAOE,CAAK,EAAI,GAAQT,EAAKS,EAAOP,EAAOC,CAAI,CAAA,EAI/C,EACT"}
|
package/dist/object/seek.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { assert as
|
|
2
|
-
import { similarity as
|
|
1
|
+
import { assert as n } from "../function/assert.js";
|
|
2
|
+
import { similarity as m } from "../string/similarity.js";
|
|
3
3
|
import { is as s } from "../typed/is.js";
|
|
4
|
-
import { IS_WITHIN_ERROR_MSG as
|
|
5
|
-
function
|
|
6
|
-
return
|
|
4
|
+
import { IS_WITHIN_ERROR_MSG as p, isWithin as t } from "../typed/isWithin.js";
|
|
5
|
+
function a(r, o, i = 1) {
|
|
6
|
+
return n(t(i, 0, 1), p, { args: { max: 1, min: 0, tone: i }, type: TypeError }), s("nil", r) ? !1 : s("string", r) || s("number", r) ? m(r, o) >= i : s("array", r) ? r.some((f) => a(f, o, i)) : s("object", r) ? Object.values(r).some(
|
|
7
|
+
(f) => s("nil", f) ? !1 : a(f, o, i)
|
|
8
|
+
) : !1;
|
|
7
9
|
}
|
|
8
10
|
export {
|
|
9
|
-
|
|
11
|
+
a as seek
|
|
10
12
|
};
|
|
11
13
|
//# sourceMappingURL=seek.js.map
|
package/dist/object/seek.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seek.js","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n
|
|
1
|
+
{"version":3,"file":"seek.js","sources":["../../src/object/seek.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { similarity } from '../string/similarity';\nimport { is } from '../typed/is';\nimport { IS_WITHIN_ERROR_MSG, isWithin } from '../typed/isWithin';\n\n/**\n * Recursively checks if an object contains a value similar to the search string.\n *\n * @example\n * ```ts\n * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };\n *\n * seek(obj, 'hello'); // true\n * seek(obj, 'world'); // true\n * seek(obj, 'foo'); // false\n * seek(obj, 'hello', 0.5); // true\n * seek(obj, 'hello', 0.8); // true\n * seek(obj, 'hello', 1); // true\n * seek(obj, 'hello', 1.5); // false\n * seek(obj, 'hello', -1); // false\n * seek(obj, 'hello', 0); // false\n * ```\n *\n * @param item - The object to search within.\n * @param query - The search string.\n * @param [tone=1] - The similarity threshold.\n *\n * @returns Whether the object contains a matching value.\n */\nexport function seek<T>(item: T, query: string, tone = 1): boolean {\n assert(isWithin(tone, 0, 1), IS_WITHIN_ERROR_MSG, { args: { max: 1, min: 0, tone }, type: TypeError });\n\n if (is('nil', item)) return false;\n\n if (is('string', item) || is('number', item)) {\n // Lowercase both sides for case-insensitive comparison\n return similarity(item, query) >= tone;\n }\n\n // Handle arrays\n if (is('array', item)) {\n return (item as unknown[]).some((value) => seek(value, query, tone));\n }\n\n // Handle objects but skip dates/regex/etc which are technically objects\n if (is('object', item)) {\n return Object.values(item as Record<string, unknown>).some((value) =>\n is('nil', value) ? false : seek(value, query, tone),\n );\n }\n\n return false;\n}\n"],"names":["seek","item","query","tone","assert","isWithin","IS_WITHIN_ERROR_MSG","is","similarity","value"],"mappings":";;;;AA6BO,SAASA,EAAQC,GAASC,GAAeC,IAAO,GAAY;AAGjE,SAFAC,EAAOC,EAASF,GAAM,GAAG,CAAC,GAAGG,GAAqB,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAAH,KAAQ,MAAM,WAAW,GAEjGI,EAAG,OAAON,CAAI,IAAU,KAExBM,EAAG,UAAUN,CAAI,KAAKM,EAAG,UAAUN,CAAI,IAElCO,EAAWP,GAAMC,CAAK,KAAKC,IAIhCI,EAAG,SAASN,CAAI,IACVA,EAAmB,KAAK,CAACQ,MAAUT,EAAKS,GAAOP,GAAOC,CAAI,CAAC,IAIjEI,EAAG,UAAUN,CAAI,IACZ,OAAO,OAAOA,CAA+B,EAAE;AAAA,IAAK,CAACQ,MAC1DF,EAAG,OAAOE,CAAK,IAAI,KAAQT,EAAKS,GAAOP,GAAOC,CAAI;AAAA,EAAA,IAI/C;AACT;"}
|
package/dist/random/uuid.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/x/g,r=>{const x=Math.random()*16|0;return(r==="x"?x:x&3|8).toString(16)})}exports.uuid=t;
|
|
2
2
|
//# sourceMappingURL=uuid.cjs.map
|
package/dist/random/uuid.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.cjs","sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n
|
|
1
|
+
{"version":3,"file":"uuid.cjs","sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/x/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n"],"names":["uuid","c","r"],"mappings":"gFAUO,SAASA,GAAe,CAC7B,OAAI,OAAO,OAAW,KAAe,OAAO,WACnC,OAAO,WAAA,EAGT,uCAAuC,QAAQ,KAAOC,GAAM,CACjE,MAAMC,EAAK,KAAK,OAAA,EAAW,GAAM,EAEjC,OADUD,IAAM,IAAMC,EAAKA,EAAI,EAAO,GAC7B,SAAS,EAAE,CACtB,CAAC,CACH"}
|
package/dist/random/uuid.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
return crypto
|
|
1
|
+
function n() {
|
|
2
|
+
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".replace(/x/g, (r) => {
|
|
3
|
+
const x = Math.random() * 16 | 0;
|
|
4
|
+
return (r === "x" ? x : x & 3 | 8).toString(16);
|
|
5
|
+
});
|
|
3
6
|
}
|
|
4
7
|
export {
|
|
5
|
-
|
|
8
|
+
n as uuid
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=uuid.js.map
|
package/dist/random/uuid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.js","sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n
|
|
1
|
+
{"version":3,"file":"uuid.js","sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/x/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n"],"names":["uuid","c","r"],"mappings":"AAUO,SAASA,IAAe;AAC7B,SAAI,OAAO,SAAW,OAAe,OAAO,aACnC,OAAO,WAAA,IAGT,uCAAuC,QAAQ,MAAM,CAACC,MAAM;AACjE,UAAMC,IAAK,KAAK,OAAA,IAAW,KAAM;AAEjC,YADUD,MAAM,MAAMC,IAAKA,IAAI,IAAO,GAC7B,SAAS,EAAE;AAAA,EACtB,CAAC;AACH;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./_caseUtils.cjs");function o(a){return t.normalizeCase(a," ").replace(/[^a-zA-Z0-9]+(.)/g,(e,r)=>r.toUpperCase()).replace(/^./,e=>e.toLowerCase())}exports.camelCase=o;
|
|
2
2
|
//# sourceMappingURL=camelCase.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.cjs","sources":["../../src/string/camelCase.ts"],"sourcesContent":["import { normalizeCase } from './_caseUtils';\n\n/**\n * Converts a string to camel case.\n *\n * @example\n * ```ts\n * const text = 'hello world';\n * camelCase(text); // 'helloWorld'\n * ```\n *\n * @param str - The string to convert.\n * @returns The converted string.\n */\nexport function camelCase(str: string): string {\n return normalizeCase(str, ' ')\n .replace(/(
|
|
1
|
+
{"version":3,"file":"camelCase.cjs","sources":["../../src/string/camelCase.ts"],"sourcesContent":["import { normalizeCase } from './_caseUtils';\n\n/**\n * Converts a string to camel case.\n *\n * @example\n * ```ts\n * const text = 'hello world';\n * camelCase(text); // 'helloWorld'\n * ```\n *\n * @param str - The string to convert.\n * @returns The converted string.\n */\nexport function camelCase(str: string): string {\n return normalizeCase(str, ' ')\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, char) => char.toUpperCase()) // Basic split by non-alphanumeric\n .replace(/^./, (char) => char.toLowerCase());\n}\n"],"names":["camelCase","str","normalizeCase","_","char"],"mappings":"oHAcO,SAASA,EAAUC,EAAqB,CAC7C,OAAOC,EAAAA,cAAcD,EAAK,GAAG,EAC1B,QAAQ,oBAAqB,CAACE,EAAGC,IAASA,EAAK,YAAA,CAAa,EAC5D,QAAQ,KAAOA,GAASA,EAAK,aAAa,CAC/C"}
|
package/dist/string/camelCase.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { normalizeCase as o } from "./_caseUtils.js";
|
|
2
|
-
function
|
|
3
|
-
return o(r, " ").replace(/(
|
|
2
|
+
function t(r) {
|
|
3
|
+
return o(r, " ").replace(/[^a-zA-Z0-9]+(.)/g, (e, a) => a.toUpperCase()).replace(/^./, (e) => e.toLowerCase());
|
|
4
4
|
}
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
t as camelCase
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=camelCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.js","sources":["../../src/string/camelCase.ts"],"sourcesContent":["import { normalizeCase } from './_caseUtils';\n\n/**\n * Converts a string to camel case.\n *\n * @example\n * ```ts\n * const text = 'hello world';\n * camelCase(text); // 'helloWorld'\n * ```\n *\n * @param str - The string to convert.\n * @returns The converted string.\n */\nexport function camelCase(str: string): string {\n return normalizeCase(str, ' ')\n .replace(/(
|
|
1
|
+
{"version":3,"file":"camelCase.js","sources":["../../src/string/camelCase.ts"],"sourcesContent":["import { normalizeCase } from './_caseUtils';\n\n/**\n * Converts a string to camel case.\n *\n * @example\n * ```ts\n * const text = 'hello world';\n * camelCase(text); // 'helloWorld'\n * ```\n *\n * @param str - The string to convert.\n * @returns The converted string.\n */\nexport function camelCase(str: string): string {\n return normalizeCase(str, ' ')\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, char) => char.toUpperCase()) // Basic split by non-alphanumeric\n .replace(/^./, (char) => char.toLowerCase());\n}\n"],"names":["camelCase","str","normalizeCase","_","char"],"mappings":";AAcO,SAASA,EAAUC,GAAqB;AAC7C,SAAOC,EAAcD,GAAK,GAAG,EAC1B,QAAQ,qBAAqB,CAACE,GAAGC,MAASA,EAAK,YAAA,CAAa,EAC5D,QAAQ,MAAM,CAACA,MAASA,EAAK,aAAa;AAC/C;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../function/assert.cjs");function y(l,g){f.assert(["string","number"].includes(typeof l)&&["string","number"].includes(typeof g),"Invalid arguments",{args:{str1:l,str2:g},type:TypeError});const n=String(l).toLowerCase(),t=String(g).toLowerCase();if(n===t)return 1;if(n.length===0)return t.length===0?1:0;if(t.length===0)return 0;const[a,c]=n.length<t.length?[n,t]:[t,n],s=a.length,h=c.length;let r=Array.from({length:s+1},(i,e)=>e),o=new Array(s+1);for(let i=1;i<=h;i++){o[0]=i;for(let e=1;e<=s;e++){const u=c[i-1]===a[e-1]?0:1;o[e]=Math.min(o[e-1]+1,r[e]+1,r[e-1]+u)}[r,o]=[o,r]}return 1-r[s]/Math.max(n.length,t.length)}exports.similarity=y;
|
|
2
2
|
//# sourceMappingURL=similarity.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"similarity.cjs","sources":["../../src/string/similarity.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n */\nexport function similarity(str1: unknown, str2: unknown): number {\n assert(\n ['string', 'number'].includes(typeof str1) && ['string', 'number'].includes(typeof str2),\n 'Invalid arguments',\n {\n args: { str1, str2 },\n type: TypeError,\n },\n );\n\n const a = String(str1).toLowerCase();\n const b = String(str2).toLowerCase();\n\n if (a === b) return 1;\n if (
|
|
1
|
+
{"version":3,"file":"similarity.cjs","sources":["../../src/string/similarity.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n */\nexport function similarity(str1: unknown, str2: unknown): number {\n assert(\n ['string', 'number'].includes(typeof str1) && ['string', 'number'].includes(typeof str2),\n 'Invalid arguments',\n {\n args: { str1, str2 },\n type: TypeError,\n },\n );\n\n const a = String(str1).toLowerCase();\n const b = String(str2).toLowerCase();\n\n if (a === b) return 1;\n if (a.length === 0) return b.length === 0 ? 1 : 0;\n if (b.length === 0) return 0;\n\n // Swap to ensure we use the smaller string for columns (O(min(A,B)) space)\n const [shorter, longer] = a.length < b.length ? [a, b] : [b, a];\n const shorterLength = shorter.length;\n const longerLength = longer.length;\n\n let prevRow = Array.from({ length: shorterLength + 1 }, (_, i) => i);\n let currRow = new Array(shorterLength + 1);\n\n for (let i = 1; i <= longerLength; i++) {\n currRow[0] = i;\n for (let j = 1; j <= shorterLength; j++) {\n const cost = longer[i - 1] === shorter[j - 1] ? 0 : 1;\n currRow[j] = Math.min(\n currRow[j - 1] + 1, // insertion\n prevRow[j] + 1, // deletion\n prevRow[j - 1] + cost, // substitution\n );\n }\n // Swap rows for the next iteration (avoid allocation)\n [prevRow, currRow] = [currRow, prevRow];\n }\n\n // After the loop, a result is in prevRow because of the swap\n const distance = prevRow[shorterLength];\n\n return 1 - distance / Math.max(a.length, b.length);\n}\n"],"names":["similarity","str1","str2","assert","a","b","shorter","longer","shorterLength","longerLength","prevRow","_","i","currRow","j","cost"],"mappings":"0HAoBO,SAASA,EAAWC,EAAeC,EAAuB,CAC/DC,EAAAA,OACE,CAAC,SAAU,QAAQ,EAAE,SAAS,OAAOF,CAAI,GAAK,CAAC,SAAU,QAAQ,EAAE,SAAS,OAAOC,CAAI,EACvF,oBACA,CACE,KAAM,CAAE,KAAAD,EAAM,KAAAC,CAAA,EACd,KAAM,SAAA,CACR,EAGF,MAAME,EAAI,OAAOH,CAAI,EAAE,YAAA,EACjBI,EAAI,OAAOH,CAAI,EAAE,YAAA,EAEvB,GAAIE,IAAMC,EAAG,MAAO,GACpB,GAAID,EAAE,SAAW,SAAUC,EAAE,SAAW,EAAI,EAAI,EAChD,GAAIA,EAAE,SAAW,EAAG,MAAO,GAG3B,KAAM,CAACC,EAASC,CAAM,EAAIH,EAAE,OAASC,EAAE,OAAS,CAACD,EAAGC,CAAC,EAAI,CAACA,EAAGD,CAAC,EACxDI,EAAgBF,EAAQ,OACxBG,EAAeF,EAAO,OAE5B,IAAIG,EAAU,MAAM,KAAK,CAAE,OAAQF,EAAgB,GAAK,CAACG,EAAGC,IAAMA,CAAC,EAC/DC,EAAU,IAAI,MAAML,EAAgB,CAAC,EAEzC,QAAS,EAAI,EAAG,GAAKC,EAAc,IAAK,CACtCI,EAAQ,CAAC,EAAI,EACb,QAASC,EAAI,EAAGA,GAAKN,EAAeM,IAAK,CACvC,MAAMC,EAAOR,EAAO,EAAI,CAAC,IAAMD,EAAQQ,EAAI,CAAC,EAAI,EAAI,EACpDD,EAAQC,CAAC,EAAI,KAAK,IAChBD,EAAQC,EAAI,CAAC,EAAI,EACjBJ,EAAQI,CAAC,EAAI,EACbJ,EAAQI,EAAI,CAAC,EAAIC,CAAA,CAErB,CAEA,CAACL,EAASG,CAAO,EAAI,CAACA,EAASH,CAAO,CACxC,CAKA,MAAO,GAFUA,EAAQF,CAAa,EAEhB,KAAK,IAAIJ,EAAE,OAAQC,EAAE,MAAM,CACnD"}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import { assert as
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
["string", "number"].includes(typeof
|
|
1
|
+
import { assert as f } from "../function/assert.js";
|
|
2
|
+
function y(i, s) {
|
|
3
|
+
f(
|
|
4
|
+
["string", "number"].includes(typeof i) && ["string", "number"].includes(typeof s),
|
|
5
5
|
"Invalid arguments",
|
|
6
6
|
{
|
|
7
|
-
args: { str1:
|
|
7
|
+
args: { str1: i, str2: s },
|
|
8
8
|
type: TypeError
|
|
9
9
|
}
|
|
10
10
|
);
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
e[t][n - 1] + 1,
|
|
11
|
+
const n = String(i).toLowerCase(), e = String(s).toLowerCase();
|
|
12
|
+
if (n === e) return 1;
|
|
13
|
+
if (n.length === 0) return e.length === 0 ? 1 : 0;
|
|
14
|
+
if (e.length === 0) return 0;
|
|
15
|
+
const [h, a] = n.length < e.length ? [n, e] : [e, n], l = h.length, c = a.length;
|
|
16
|
+
let r = Array.from({ length: l + 1 }, (g, t) => t), o = new Array(l + 1);
|
|
17
|
+
for (let g = 1; g <= c; g++) {
|
|
18
|
+
o[0] = g;
|
|
19
|
+
for (let t = 1; t <= l; t++) {
|
|
20
|
+
const u = a[g - 1] === h[t - 1] ? 0 : 1;
|
|
21
|
+
o[t] = Math.min(
|
|
22
|
+
o[t - 1] + 1,
|
|
24
23
|
// insertion
|
|
25
|
-
|
|
24
|
+
r[t] + 1,
|
|
25
|
+
// deletion
|
|
26
|
+
r[t - 1] + u
|
|
26
27
|
// substitution
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
[r, o] = [o, r];
|
|
31
|
+
}
|
|
32
|
+
return 1 - r[l] / Math.max(n.length, e.length);
|
|
30
33
|
}
|
|
31
34
|
export {
|
|
32
|
-
|
|
35
|
+
y as similarity
|
|
33
36
|
};
|
|
34
37
|
//# sourceMappingURL=similarity.js.map
|