@vielzeug/toolkit 1.0.11 → 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 +12 -12
- 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/logit/dist/logit.cjs +1 -1
- package/dist/logit/dist/logit.cjs.map +1 -1
- package/dist/logit/dist/logit.js +64 -62
- package/dist/logit/dist/logit.js.map +1 -1
- 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/typed/is.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { assert as t } from "../function/assert.js";
|
|
2
|
+
import { ge as e } from "./ge.js";
|
|
3
|
+
import { gt as p } from "./gt.js";
|
|
4
|
+
import { isDefined as f } from "./isDefined.js";
|
|
5
|
+
import { isEmpty as s } from "./isEmpty.js";
|
|
5
6
|
import { isEqual as m } from "./isEqual.js";
|
|
6
|
-
import { isEven as
|
|
7
|
-
import { isMatch as
|
|
7
|
+
import { isEven as n } from "./isEven.js";
|
|
8
|
+
import { isMatch as a } from "./isMatch.js";
|
|
8
9
|
import { isNegative as d } from "./isNegative.js";
|
|
9
10
|
import { isNil as g } from "./isNil.js";
|
|
10
11
|
import { isOdd as l } from "./isOdd.js";
|
|
11
12
|
import { isPositive as v } from "./isPositive.js";
|
|
12
|
-
import { isRegex as
|
|
13
|
-
import { isWithin as
|
|
14
|
-
import { isZero as
|
|
15
|
-
import { le as
|
|
16
|
-
import { lt as
|
|
17
|
-
import { typeOf as
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
match: (i) => n(...i),
|
|
31
|
-
ne: (i) => !m(...i),
|
|
13
|
+
import { isRegex as c } from "./isRegex.js";
|
|
14
|
+
import { isWithin as h } from "./isWithin.js";
|
|
15
|
+
import { isZero as u } from "./isZero.js";
|
|
16
|
+
import { le as E } from "./le.js";
|
|
17
|
+
import { lt as x } from "./lt.js";
|
|
18
|
+
import { typeOf as q } from "./typeOf.js";
|
|
19
|
+
function G(r, i) {
|
|
20
|
+
return t(!!r, "Type must be provided", { args: { type: r }, type: Error }), {
|
|
21
|
+
defined: f,
|
|
22
|
+
empty: s,
|
|
23
|
+
eq: (o) => m(...o),
|
|
24
|
+
even: n,
|
|
25
|
+
ge: (o) => e(...o),
|
|
26
|
+
gt: (o) => p(...o),
|
|
27
|
+
le: (o) => E(...o),
|
|
28
|
+
lt: (o) => x(...o),
|
|
29
|
+
match: (o) => a(...o),
|
|
30
|
+
ne: (o) => !m(...o),
|
|
32
31
|
negative: d,
|
|
33
32
|
nil: g,
|
|
34
33
|
odd: l,
|
|
35
34
|
positive: v,
|
|
36
|
-
regex:
|
|
37
|
-
within: (
|
|
38
|
-
zero:
|
|
39
|
-
}[
|
|
35
|
+
regex: c,
|
|
36
|
+
within: (o) => h(...o),
|
|
37
|
+
zero: u
|
|
38
|
+
}[r]?.(i) ?? q(i) === r;
|
|
40
39
|
}
|
|
41
40
|
export {
|
|
42
|
-
|
|
41
|
+
G as is
|
|
43
42
|
};
|
|
44
43
|
//# sourceMappingURL=is.js.map
|
package/dist/typed/is.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is.js","sources":["../../src/typed/is.ts"],"sourcesContent":["import { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n
|
|
1
|
+
{"version":3,"file":"is.js","sources":["../../src/typed/is.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n assert(Boolean(type), 'Type must be provided', { args: { type }, type: Error });\n\n const compare = {\n defined: isDefined,\n empty: isEmpty,\n eq: (args: Parameters<typeof isEqual>) => isEqual(...args),\n even: isEven,\n ge: (args: Parameters<typeof ge>) => ge(...args),\n gt: (args: Parameters<typeof gt>) => gt(...args),\n le: (args: Parameters<typeof le>) => le(...args),\n lt: (args: Parameters<typeof lt>) => lt(...args),\n match: (args: Parameters<typeof isMatch>) => isMatch(...args),\n ne: (args: Parameters<typeof isEqual>) => !isEqual(...args),\n negative: isNegative,\n nil: isNil,\n odd: isOdd,\n positive: isPositive,\n regex: isRegex,\n within: (args: Parameters<typeof isWithin>) => isWithin(...args),\n zero: isZero,\n };\n\n return compare[type as keyof typeof compare]?.(arg) ?? typeOf(arg) === type;\n}\n"],"names":["is","type","arg","assert","isDefined","isEmpty","args","isEqual","isEven","ge","gt","le","lt","isMatch","isNegative","isNil","isOdd","isPositive","isRegex","isWithin","isZero","typeOf"],"mappings":";;;;;;;;;;;;;;;;;;AAiGO,SAASA,EAAGC,GAAcC,GAAuB;AACtD,SAAAC,EAAO,EAAQF,GAAO,yBAAyB,EAAE,MAAM,EAAE,MAAAA,EAAA,GAAQ,MAAM,OAAO,GAE9D;AAAA,IACd,SAASG;AAAA,IACT,OAAOC;AAAA,IACP,IAAI,CAACC,MAAqCC,EAAQ,GAAGD,CAAI;AAAA,IACzD,MAAME;AAAA,IACN,IAAI,CAACF,MAAgCG,EAAG,GAAGH,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCI,EAAG,GAAGJ,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCK,EAAG,GAAGL,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCM,EAAG,GAAGN,CAAI;AAAA,IAC/C,OAAO,CAACA,MAAqCO,EAAQ,GAAGP,CAAI;AAAA,IAC5D,IAAI,CAACA,MAAqC,CAACC,EAAQ,GAAGD,CAAI;AAAA,IAC1D,UAAUQ;AAAA,IACV,KAAKC;AAAA,IACL,KAAKC;AAAA,IACL,UAAUC;AAAA,IACV,OAAOC;AAAA,IACP,QAAQ,CAACZ,MAAsCa,EAAS,GAAGb,CAAI;AAAA,IAC/D,MAAMc;AAAA,EAAA,EAGOnB,CAA4B,IAAIC,CAAG,KAAKmB,EAAOnB,CAAG,MAAMD;AACzE;"}
|
package/dist/typed/isEmpty.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./isArray.cjs"),i=require("./isNil.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./isArray.cjs"),i=require("./isNil.cjs"),n=require("./isObject.cjs");function s(e){return i.isNil(e)||e===""?!0:t.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:n.isObject(e)?Object.keys(e).length===0:!1}const r="Expected an empty value";exports.IS_EMPTY_ERROR_MSG=r;exports.isEmpty=s;
|
|
2
2
|
//# sourceMappingURL=isEmpty.cjs.map
|
|
@@ -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;"}
|