@vielzeug/toolkit 1.0.12 → 1.0.14
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/{sortBy.cjs → arrange.cjs} +2 -2
- package/dist/array/arrange.cjs.map +1 -0
- package/dist/array/arrange.js +6 -0
- package/dist/array/arrange.js.map +1 -0
- 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 +87 -50
- 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/array/remoteList.cjs +2 -0
- package/dist/array/remoteList.cjs.map +1 -0
- package/dist/array/remoteList.js +123 -0
- package/dist/array/remoteList.js.map +1 -0
- package/dist/date/expires.cjs.map +1 -1
- package/dist/date/expires.js.map +1 -1
- package/dist/date/interval.cjs.map +1 -1
- package/dist/date/interval.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/parallel.cjs +2 -0
- package/dist/function/parallel.cjs.map +1 -0
- package/dist/function/parallel.js +28 -0
- package/dist/function/parallel.js.map +1 -0
- package/dist/function/proxy.cjs.map +1 -1
- package/dist/function/proxy.js.map +1 -1
- package/dist/function/prune.cjs +2 -0
- package/dist/function/prune.cjs.map +1 -0
- package/dist/function/prune.js +30 -0
- package/dist/function/prune.js.map +1 -0
- 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.cjs +1 -1
- package/dist/index.d.ts +455 -95
- package/dist/index.js +218 -194
- package/dist/index.js.map +1 -1
- package/dist/math/abs.cjs +2 -0
- package/dist/math/abs.cjs.map +1 -0
- package/dist/math/abs.js +7 -0
- package/dist/math/abs.js.map +1 -0
- package/dist/math/add.cjs +2 -0
- package/dist/math/add.cjs.map +1 -0
- package/dist/math/add.js +9 -0
- package/dist/math/add.js.map +1 -0
- package/dist/math/allocate.cjs +2 -0
- package/dist/math/allocate.cjs.map +1 -0
- package/dist/math/allocate.js +29 -0
- package/dist/math/allocate.js.map +1 -0
- 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/distribute.cjs +2 -0
- package/dist/math/distribute.cjs.map +1 -0
- package/dist/math/distribute.js +18 -0
- package/dist/math/distribute.js.map +1 -0
- package/dist/math/divide.cjs +2 -0
- package/dist/math/divide.cjs.map +1 -0
- package/dist/math/divide.js +11 -0
- package/dist/math/divide.js.map +1 -0
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.js.map +1 -1
- package/dist/math/multiply.cjs +2 -0
- package/dist/math/multiply.cjs.map +1 -0
- package/dist/math/multiply.js +9 -0
- package/dist/math/multiply.js.map +1 -0
- 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/subtract.cjs +2 -0
- package/dist/math/subtract.cjs.map +1 -0
- package/dist/math/subtract.js +9 -0
- package/dist/math/subtract.js.map +1 -0
- 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/money/currency.cjs +2 -0
- package/dist/money/currency.cjs.map +1 -0
- package/dist/money/currency.js +49 -0
- package/dist/money/currency.js.map +1 -0
- package/dist/money/exchange.cjs +2 -0
- package/dist/money/exchange.cjs.map +1 -0
- package/dist/money/exchange.js +13 -0
- package/dist/money/exchange.js.map +1 -0
- 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/parseJSON.cjs.map +1 -1
- package/dist/object/parseJSON.js.map +1 -1
- package/dist/object/path.cjs.map +1 -1
- package/dist/object/path.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/array/sortBy.cjs.map +0 -1
- package/dist/array/sortBy.js +0 -6
- package/dist/array/sortBy.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmpty.cjs","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\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 */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n
|
|
1
|
+
{"version":3,"file":"isEmpty.cjs","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\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 */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n if (isNil(arg) || arg === '') return true;\n if (isArray(arg)) return arg.length === 0;\n if (arg instanceof Map || arg instanceof Set) return arg.size === 0;\n if (isObject(arg)) return Object.keys(arg).length === 0;\n return false;\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":"sKA0BO,SAASA,EAAQC,EAAmB,CACzC,OAAIC,EAAAA,MAAMD,CAAG,GAAKA,IAAQ,GAAW,GACjCE,EAAAA,QAAQF,CAAG,EAAUA,EAAI,SAAW,EACpCA,aAAe,KAAOA,aAAe,IAAYA,EAAI,OAAS,EAC9DG,EAAAA,SAASH,CAAG,EAAU,OAAO,KAAKA,CAAG,EAAE,SAAW,EAC/C,EACT,CAEO,MAAMI,EAAqB"}
|
package/dist/typed/isEmpty.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isArray as e } from "./isArray.js";
|
|
2
2
|
import { isNil as i } from "./isNil.js";
|
|
3
|
-
import { isObject as
|
|
4
|
-
function
|
|
5
|
-
return i(t) || t === ""
|
|
3
|
+
import { isObject as n } from "./isObject.js";
|
|
4
|
+
function s(t) {
|
|
5
|
+
return i(t) || t === "" ? !0 : e(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : n(t) ? Object.keys(t).length === 0 : !1;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const m = "Expected an empty value";
|
|
8
8
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
m as IS_EMPTY_ERROR_MSG,
|
|
10
|
+
s as isEmpty
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=isEmpty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmpty.js","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\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 */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n
|
|
1
|
+
{"version":3,"file":"isEmpty.js","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\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 */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n if (isNil(arg) || arg === '') return true;\n if (isArray(arg)) return arg.length === 0;\n if (arg instanceof Map || arg instanceof Set) return arg.size === 0;\n if (isObject(arg)) return Object.keys(arg).length === 0;\n return false;\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":";;;AA0BO,SAASA,EAAQC,GAAmB;AACzC,SAAIC,EAAMD,CAAG,KAAKA,MAAQ,KAAW,KACjCE,EAAQF,CAAG,IAAUA,EAAI,WAAW,IACpCA,aAAe,OAAOA,aAAe,MAAYA,EAAI,SAAS,IAC9DG,EAASH,CAAG,IAAU,OAAO,KAAKA,CAAG,EAAE,WAAW,IAC/C;AACT;AAEO,MAAMI,IAAqB;"}
|
package/dist/typed/isEqual.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 l(e,r){return f(e,r,new WeakMap)}function f(e,r,n){if(e===r)return!0;if(e==null||r==null||typeof e!=typeof r||typeof e!="object"||typeof r!="object")return!1;if(n.has(e))return n.get(e)===r;if(n.set(e,r),Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(!f(e[t],r[t],n))return!1;return!0}if(Array.isArray(e)!==Array.isArray(r))return!1;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();const u=Object.keys(e),s=Object.keys(r);if(u.length!==s.length)return!1;for(const t of u)if(!Object.hasOwn(r,t)||!f(e[t],r[t],n))return!1;return!0}const o="Expected two values to be equal";exports.IS_EQUAL_ERROR_MSG=o;exports.isEqual=l;
|
|
2
2
|
//# sourceMappingURL=isEqual.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEqual.cjs","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\
|
|
1
|
+
{"version":3,"file":"isEqual.cjs","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!safeIsEqual(a[idx], b[idx], visited)) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","safeIsEqual","visited","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"gFAqBO,SAASA,EAAQC,EAAYC,EAAqB,CACvD,OAAOC,EAAYF,EAAGC,EAAG,IAAI,OAAS,CACxC,CAGA,SAASC,EAAYF,EAAYC,EAAYE,EAA2C,CAEtF,GAAIH,IAAMC,EAAG,MAAO,GAGpB,GAAID,GAAK,MAAQC,GAAK,MAAQ,OAAOD,GAAM,OAAOC,GAAK,OAAOD,GAAM,UAAY,OAAOC,GAAM,SAAU,MAAO,GAI9G,GAAIE,EAAQ,IAAIH,CAAW,EACzB,OAAOG,EAAQ,IAAIH,CAAW,IAAMC,EAKtC,GAHAE,EAAQ,IAAIH,EAAaC,CAAW,EAGhC,MAAM,QAAQD,CAAC,GAAK,MAAM,QAAQC,CAAC,EAAG,CACxC,GAAID,EAAE,SAAWC,EAAE,OAAQ,MAAO,GAClC,QAASG,EAAM,EAAGA,EAAMJ,EAAE,OAAQI,IAChC,GAAI,CAACF,EAAYF,EAAEI,CAAG,EAAGH,EAAEG,CAAG,EAAGD,CAAO,EAAG,MAAO,GAEpD,MAAO,EACT,CAGA,GAAI,MAAM,QAAQH,CAAC,IAAM,MAAM,QAAQC,CAAC,EAAG,MAAO,GAGlD,GAAID,aAAa,MAAQC,aAAa,KACpC,OAAOD,EAAE,YAAcC,EAAE,QAAA,EAI3B,MAAMI,EAAQ,OAAO,KAAKL,CAAC,EACrBM,EAAQ,OAAO,KAAKL,CAAC,EAE3B,GAAII,EAAM,SAAWC,EAAM,OAAQ,MAAO,GAE1C,UAAWC,KAAOF,EAChB,GACE,CAAC,OAAO,OAAOJ,EAAGM,CAAG,GACrB,CAACL,EAAaF,EAA8BO,CAAG,EAAIN,EAA8BM,CAAG,EAAGJ,CAAO,EAE9F,MAAO,GAGX,MAAO,EACT,CAEO,MAAMK,EAAqB"}
|
package/dist/typed/isEqual.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function l(e, r) {
|
|
2
|
+
return f(e, r, /* @__PURE__ */ new WeakMap());
|
|
3
|
+
}
|
|
4
|
+
function f(e, r, n) {
|
|
5
|
+
if (e === r) return !0;
|
|
6
|
+
if (e == null || r == null || typeof e != typeof r || typeof e != "object" || typeof r != "object") return !1;
|
|
7
|
+
if (n.has(e))
|
|
8
|
+
return n.get(e) === r;
|
|
9
|
+
if (n.set(e, r), Array.isArray(e) && Array.isArray(r)) {
|
|
10
|
+
if (e.length !== r.length) return !1;
|
|
11
|
+
for (let t = 0; t < e.length; t++)
|
|
12
|
+
if (!f(e[t], r[t], n)) return !1;
|
|
8
13
|
return !0;
|
|
9
14
|
}
|
|
10
|
-
if (Array.isArray(e) !== Array.isArray(
|
|
11
|
-
if (e instanceof Date &&
|
|
12
|
-
return e.getTime() ===
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
for (const
|
|
16
|
-
if (!Object.hasOwn(
|
|
15
|
+
if (Array.isArray(e) !== Array.isArray(r)) return !1;
|
|
16
|
+
if (e instanceof Date && r instanceof Date)
|
|
17
|
+
return e.getTime() === r.getTime();
|
|
18
|
+
const s = Object.keys(e), u = Object.keys(r);
|
|
19
|
+
if (s.length !== u.length) return !1;
|
|
20
|
+
for (const t of s)
|
|
21
|
+
if (!Object.hasOwn(r, t) || !f(e[t], r[t], n))
|
|
17
22
|
return !1;
|
|
18
23
|
return !0;
|
|
19
24
|
}
|
|
20
|
-
const
|
|
25
|
+
const o = "Expected two values to be equal";
|
|
21
26
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
o as IS_EQUAL_ERROR_MSG,
|
|
28
|
+
l as isEqual
|
|
24
29
|
};
|
|
25
30
|
//# sourceMappingURL=isEqual.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEqual.js","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\
|
|
1
|
+
{"version":3,"file":"isEqual.js","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!safeIsEqual(a[idx], b[idx], visited)) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","safeIsEqual","visited","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"AAqBO,SAASA,EAAQC,GAAYC,GAAqB;AACvD,SAAOC,EAAYF,GAAGC,GAAG,oBAAI,SAAS;AACxC;AAGA,SAASC,EAAYF,GAAYC,GAAYE,GAA2C;AAEtF,MAAIH,MAAMC,EAAG,QAAO;AAGpB,MAAID,KAAK,QAAQC,KAAK,QAAQ,OAAOD,KAAM,OAAOC,KAAK,OAAOD,KAAM,YAAY,OAAOC,KAAM,SAAU,QAAO;AAI9G,MAAIE,EAAQ,IAAIH,CAAW;AACzB,WAAOG,EAAQ,IAAIH,CAAW,MAAMC;AAKtC,MAHAE,EAAQ,IAAIH,GAAaC,CAAW,GAGhC,MAAM,QAAQD,CAAC,KAAK,MAAM,QAAQC,CAAC,GAAG;AACxC,QAAID,EAAE,WAAWC,EAAE,OAAQ,QAAO;AAClC,aAASG,IAAM,GAAGA,IAAMJ,EAAE,QAAQI;AAChC,UAAI,CAACF,EAAYF,EAAEI,CAAG,GAAGH,EAAEG,CAAG,GAAGD,CAAO,EAAG,QAAO;AAEpD,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQH,CAAC,MAAM,MAAM,QAAQC,CAAC,EAAG,QAAO;AAGlD,MAAID,aAAa,QAAQC,aAAa;AACpC,WAAOD,EAAE,cAAcC,EAAE,QAAA;AAI3B,QAAMI,IAAQ,OAAO,KAAKL,CAAC,GACrBM,IAAQ,OAAO,KAAKL,CAAC;AAE3B,MAAII,EAAM,WAAWC,EAAM,OAAQ,QAAO;AAE1C,aAAWC,KAAOF;AAChB,QACE,CAAC,OAAO,OAAOJ,GAAGM,CAAG,KACrB,CAACL,EAAaF,EAA8BO,CAAG,GAAIN,EAA8BM,CAAG,GAAGJ,CAAO;AAE9F,aAAO;AAGX,SAAO;AACT;AAEO,MAAMK,IAAqB;"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortBy.cjs","sources":["../../src/array/sortBy.ts"],"sourcesContent":["import { compareBy } from '../function/compareBy';\n\n/**\n * Sorts an array of objects based on multiple selectors.\n *\n * @example\n * ```ts\n * const data = [\n * { name: 'Alice', age: 30 },\n * { name: 'Bob', age: 25 },\n * { name: 'Charlie', age: 35 },\n * { name: 'Alice', age: 25 },\n * { name: 'Bob', age: 30 },\n * { name: 'Charlie', age: 30 },\n * ].sortBy(data, { name: 'asc', age: 'desc' }); // [ { name: 'Alice', age: 30 }, { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }, { name: 'Charlie', age: 30 } ]\n * ```\n *\n * @param array - The array to sort.\n * @param selectors - An object where keys are the properties to sort by and values are 'asc' or 'desc'.\n * @returns A new sorted array.\n */\nexport const sortBy = <T>(array: T[], selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n return [...array].sort(compareBy(selectors));\n};\n"],"names":["sortBy","array","selectors","compareBy"],"mappings":"6HAqBaA,EAAS,CAAIC,EAAYC,IAC7B,CAAC,GAAGD,CAAK,EAAE,KAAKE,EAAAA,UAAUD,CAAS,CAAC"}
|
package/dist/array/sortBy.js
DELETED
package/dist/array/sortBy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sortBy.js","sources":["../../src/array/sortBy.ts"],"sourcesContent":["import { compareBy } from '../function/compareBy';\n\n/**\n * Sorts an array of objects based on multiple selectors.\n *\n * @example\n * ```ts\n * const data = [\n * { name: 'Alice', age: 30 },\n * { name: 'Bob', age: 25 },\n * { name: 'Charlie', age: 35 },\n * { name: 'Alice', age: 25 },\n * { name: 'Bob', age: 30 },\n * { name: 'Charlie', age: 30 },\n * ].sortBy(data, { name: 'asc', age: 'desc' }); // [ { name: 'Alice', age: 30 }, { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }, { name: 'Charlie', age: 30 } ]\n * ```\n *\n * @param array - The array to sort.\n * @param selectors - An object where keys are the properties to sort by and values are 'asc' or 'desc'.\n * @returns A new sorted array.\n */\nexport const sortBy = <T>(array: T[], selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n return [...array].sort(compareBy(selectors));\n};\n"],"names":["sortBy","array","selectors","compareBy"],"mappings":";AAqBO,MAAMA,IAAS,CAAIC,GAAYC,MAC7B,CAAC,GAAGD,CAAK,EAAE,KAAKE,EAAUD,CAAS,CAAC;"}
|