@zag-js/utils 2.0.0-next.2 → 2.0.0-next.4

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.
Files changed (46) hide show
  1. package/dist/array.d.mts +24 -26
  2. package/dist/array.d.ts +24 -26
  3. package/dist/array.js +76 -117
  4. package/dist/array.mjs +52 -74
  5. package/dist/equal.d.mts +1 -2
  6. package/dist/equal.d.ts +1 -2
  7. package/dist/equal.js +23 -46
  8. package/dist/equal.mjs +19 -23
  9. package/dist/functions.d.mts +13 -15
  10. package/dist/functions.d.ts +13 -15
  11. package/dist/functions.js +82 -121
  12. package/dist/functions.mjs +68 -88
  13. package/dist/guard.d.mts +12 -13
  14. package/dist/guard.d.ts +12 -13
  15. package/dist/guard.js +37 -70
  16. package/dist/guard.mjs +23 -37
  17. package/dist/index.d.mts +10 -10
  18. package/dist/index.d.ts +10 -10
  19. package/dist/index.js +97 -41
  20. package/dist/index.mjs +9 -11
  21. package/dist/lifecycle.d.mts +2 -4
  22. package/dist/lifecycle.d.ts +2 -4
  23. package/dist/lifecycle.js +4 -18
  24. package/dist/lifecycle.mjs +1 -0
  25. package/dist/number.d.mts +37 -38
  26. package/dist/number.d.ts +37 -38
  27. package/dist/number.js +136 -185
  28. package/dist/number.mjs +104 -134
  29. package/dist/object.d.mts +11 -16
  30. package/dist/object.d.ts +11 -16
  31. package/dist/object.js +52 -91
  32. package/dist/object.mjs +41 -61
  33. package/dist/store.d.mts +10 -12
  34. package/dist/store.d.ts +10 -12
  35. package/dist/store.js +42 -67
  36. package/dist/store.mjs +38 -44
  37. package/dist/warning.d.mts +7 -8
  38. package/dist/warning.d.ts +7 -8
  39. package/dist/warning.js +16 -51
  40. package/dist/warning.mjs +9 -25
  41. package/package.json +2 -2
  42. package/dist/chunk-MXGZDBDQ.mjs +0 -15
  43. package/dist/timers.d.mts +0 -26
  44. package/dist/timers.d.ts +0 -26
  45. package/dist/timers.js +0 -119
  46. package/dist/timers.mjs +0 -90
package/dist/array.d.mts CHANGED
@@ -1,27 +1,25 @@
1
- declare function toArray<T>(v: T | T[] | undefined | null): T[];
2
- declare const fromLength: (length: number) => number[];
3
- declare const first: <T>(v: T[]) => T | undefined;
4
- declare const last: <T>(v: T[]) => T | undefined;
5
- declare const isEmpty: <T>(v: T[]) => boolean;
6
- declare const has: <T>(v: T[], t: T) => boolean;
7
- declare const add: <T>(v: T[], ...items: T[]) => T[];
8
- declare const remove: <T>(v: T[], ...items: T[]) => T[];
9
- declare const removeAt: <T>(v: T[], i: number) => T[];
10
- declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
11
- declare const uniq: <T>(v: T[]) => T[];
12
- declare const diff: <T>(a: T[], b: T[]) => T[];
13
- declare const addOrRemove: <T>(v: T[], item: T) => T[];
14
- declare function clear<T>(v: T[]): T[];
15
- type IndexOptions = {
16
- step?: number | undefined;
17
- loop?: boolean | undefined;
1
+ export declare function toArray<T>(v: T | T[] | undefined | null): T[];
2
+ export declare const fromLength: (length: number) => number[];
3
+ export declare const first: <T>(v: T[]) => T | undefined;
4
+ export declare const last: <T>(v: T[]) => T | undefined;
5
+ export declare const isEmpty: <T>(v: T[]) => boolean;
6
+ export declare const has: <T>(v: T[], t: T) => boolean;
7
+ export declare const add: <T>(v: T[], ...items: T[]) => T[];
8
+ export declare const remove: <T>(v: T[], ...items: T[]) => T[];
9
+ export declare const removeAt: <T>(v: T[], i: number) => T[];
10
+ export declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
11
+ export declare const uniq: <T>(v: T[]) => T[];
12
+ export declare const diff: <T>(a: T[], b: T[]) => T[];
13
+ export declare const addOrRemove: <T>(v: T[], item: T) => T[];
14
+ export declare function clear<T>(v: T[]): T[];
15
+ export type IndexOptions = {
16
+ step?: number | undefined;
17
+ loop?: boolean | undefined;
18
18
  };
19
- declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
20
- declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
21
- declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
22
- declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
23
- declare function chunk<T>(v: T[], size: number): T[][];
24
- declare function flatArray<T>(arr: T[]): T[];
25
- declare function partition<T>(arr: T[], fn: (value: T) => boolean): [T[], T[]];
26
-
27
- export { type IndexOptions, add, addOrRemove, chunk, clear, diff, first, flatArray, fromLength, has, insertAt, isEmpty, last, next, nextIndex, partition, prev, prevIndex, remove, removeAt, toArray, uniq };
19
+ export declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
20
+ export declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
21
+ export declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
22
+ export declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
23
+ export declare function chunk<T>(v: T[], size: number): T[][];
24
+ export declare function flatArray<T>(arr: T[]): T[];
25
+ export declare function partition<T>(arr: T[], fn: (value: T) => boolean): [T[], T[]];
package/dist/array.d.ts CHANGED
@@ -1,27 +1,25 @@
1
- declare function toArray<T>(v: T | T[] | undefined | null): T[];
2
- declare const fromLength: (length: number) => number[];
3
- declare const first: <T>(v: T[]) => T | undefined;
4
- declare const last: <T>(v: T[]) => T | undefined;
5
- declare const isEmpty: <T>(v: T[]) => boolean;
6
- declare const has: <T>(v: T[], t: T) => boolean;
7
- declare const add: <T>(v: T[], ...items: T[]) => T[];
8
- declare const remove: <T>(v: T[], ...items: T[]) => T[];
9
- declare const removeAt: <T>(v: T[], i: number) => T[];
10
- declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
11
- declare const uniq: <T>(v: T[]) => T[];
12
- declare const diff: <T>(a: T[], b: T[]) => T[];
13
- declare const addOrRemove: <T>(v: T[], item: T) => T[];
14
- declare function clear<T>(v: T[]): T[];
15
- type IndexOptions = {
16
- step?: number | undefined;
17
- loop?: boolean | undefined;
1
+ export declare function toArray<T>(v: T | T[] | undefined | null): T[];
2
+ export declare const fromLength: (length: number) => number[];
3
+ export declare const first: <T>(v: T[]) => T | undefined;
4
+ export declare const last: <T>(v: T[]) => T | undefined;
5
+ export declare const isEmpty: <T>(v: T[]) => boolean;
6
+ export declare const has: <T>(v: T[], t: T) => boolean;
7
+ export declare const add: <T>(v: T[], ...items: T[]) => T[];
8
+ export declare const remove: <T>(v: T[], ...items: T[]) => T[];
9
+ export declare const removeAt: <T>(v: T[], i: number) => T[];
10
+ export declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
11
+ export declare const uniq: <T>(v: T[]) => T[];
12
+ export declare const diff: <T>(a: T[], b: T[]) => T[];
13
+ export declare const addOrRemove: <T>(v: T[], item: T) => T[];
14
+ export declare function clear<T>(v: T[]): T[];
15
+ export type IndexOptions = {
16
+ step?: number | undefined;
17
+ loop?: boolean | undefined;
18
18
  };
19
- declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
20
- declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
21
- declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
22
- declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
23
- declare function chunk<T>(v: T[], size: number): T[][];
24
- declare function flatArray<T>(arr: T[]): T[];
25
- declare function partition<T>(arr: T[], fn: (value: T) => boolean): [T[], T[]];
26
-
27
- export { type IndexOptions, add, addOrRemove, chunk, clear, diff, first, flatArray, fromLength, has, insertAt, isEmpty, last, next, nextIndex, partition, prev, prevIndex, remove, removeAt, toArray, uniq };
19
+ export declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
20
+ export declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
21
+ export declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
22
+ export declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
23
+ export declare function chunk<T>(v: T[], size: number): T[][];
24
+ export declare function flatArray<T>(arr: T[]): T[];
25
+ export declare function partition<T>(arr: T[], fn: (value: T) => boolean): [T[], T[]];
package/dist/array.js CHANGED
@@ -1,137 +1,96 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/array.ts
21
- var array_exports = {};
22
- __export(array_exports, {
23
- add: () => add,
24
- addOrRemove: () => addOrRemove,
25
- chunk: () => chunk,
26
- clear: () => clear,
27
- diff: () => diff,
28
- first: () => first,
29
- flatArray: () => flatArray,
30
- fromLength: () => fromLength,
31
- has: () => has,
32
- insertAt: () => insertAt,
33
- isEmpty: () => isEmpty,
34
- last: () => last,
35
- next: () => next,
36
- nextIndex: () => nextIndex,
37
- partition: () => partition,
38
- prev: () => prev,
39
- prevIndex: () => prevIndex,
40
- remove: () => remove,
41
- removeAt: () => removeAt,
42
- toArray: () => toArray,
43
- uniq: () => uniq
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
44
4
  });
45
- module.exports = __toCommonJS(array_exports);
5
+ // src/array.ts
46
6
  function toArray(v) {
47
- if (v == null) return [];
48
- return Array.isArray(v) ? v : [v];
7
+ if (v == null) return [];
8
+ return Array.isArray(v) ? v : [v];
49
9
  }
50
- var fromLength = (length) => Array.from(Array(length).keys());
51
- var first = (v) => v[0];
52
- var last = (v) => v[v.length - 1];
53
- var isEmpty = (v) => v.length === 0;
54
- var has = (v, t) => v.indexOf(t) !== -1;
55
- var add = (v, ...items) => v.concat(items);
56
- var remove = (v, ...items) => v.filter((t) => !items.includes(t));
57
- var removeAt = (v, i) => v.filter((_, idx) => idx !== i);
58
- var insertAt = (v, i, ...items) => [...v.slice(0, i), ...items, ...v.slice(i)];
59
- var uniq = (v) => Array.from(new Set(v));
60
- var diff = (a, b) => {
61
- const set = new Set(b);
62
- return a.filter((t) => !set.has(t));
10
+ const fromLength = (length) => Array.from(Array(length).keys());
11
+ const first = (v) => v[0];
12
+ const last = (v) => v[v.length - 1];
13
+ const isEmpty = (v) => v.length === 0;
14
+ const has = (v, t) => v.indexOf(t) !== -1;
15
+ const add = (v, ...items) => v.concat(items);
16
+ const remove = (v, ...items) => v.filter((t) => !items.includes(t));
17
+ const removeAt = (v, i) => v.filter((_, idx) => idx !== i);
18
+ const insertAt = (v, i, ...items) => [
19
+ ...v.slice(0, i),
20
+ ...items,
21
+ ...v.slice(i)
22
+ ];
23
+ const uniq = (v) => Array.from(new Set(v));
24
+ const diff = (a, b) => {
25
+ const set = new Set(b);
26
+ return a.filter((t) => !set.has(t));
63
27
  };
64
- var addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
28
+ const addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
65
29
  function clear(v) {
66
- while (v.length > 0) v.pop();
67
- return v;
30
+ while (v.length > 0) v.pop();
31
+ return v;
68
32
  }
69
33
  function nextIndex(v, idx, opts = {}) {
70
- const { step = 1, loop = true } = opts;
71
- const next2 = idx + step;
72
- const len = v.length;
73
- const last2 = len - 1;
74
- if (idx === -1) return step > 0 ? 0 : last2;
75
- if (next2 < 0) return loop ? last2 : 0;
76
- if (next2 >= len) return loop ? 0 : idx > len ? len : idx;
77
- return next2;
34
+ const { step = 1, loop = true } = opts;
35
+ const next = idx + step;
36
+ const len = v.length;
37
+ const last = len - 1;
38
+ if (idx === -1) return step > 0 ? 0 : last;
39
+ if (next < 0) return loop ? last : 0;
40
+ if (next >= len) return loop ? 0 : idx > len ? len : idx;
41
+ return next;
78
42
  }
79
43
  function next(v, idx, opts = {}) {
80
- return v[nextIndex(v, idx, opts)];
44
+ return v[nextIndex(v, idx, opts)];
81
45
  }
82
46
  function prevIndex(v, idx, opts = {}) {
83
- const { step = 1, loop = true } = opts;
84
- return nextIndex(v, idx, { step: -step, loop });
47
+ const { step = 1, loop = true } = opts;
48
+ return nextIndex(v, idx, {
49
+ step: -step,
50
+ loop
51
+ });
85
52
  }
86
53
  function prev(v, index, opts = {}) {
87
- return v[prevIndex(v, index, opts)];
54
+ return v[prevIndex(v, index, opts)];
88
55
  }
89
56
  function chunk(v, size) {
90
- return v.reduce((rows, value, index) => {
91
- if (index % size === 0) rows.push([value]);
92
- else last(rows)?.push(value);
93
- return rows;
94
- }, []);
57
+ return v.reduce((rows, value, index) => {
58
+ if (index % size === 0) rows.push([value]);
59
+ else last(rows)?.push(value);
60
+ return rows;
61
+ }, []);
95
62
  }
96
63
  function flatArray(arr) {
97
- return arr.reduce((flat, item) => {
98
- if (Array.isArray(item)) {
99
- return flat.concat(flatArray(item));
100
- }
101
- return flat.concat(item);
102
- }, []);
64
+ return arr.reduce((flat, item) => {
65
+ if (Array.isArray(item)) return flat.concat(flatArray(item));
66
+ return flat.concat(item);
67
+ }, []);
103
68
  }
104
69
  function partition(arr, fn) {
105
- return arr.reduce(
106
- ([pass, fail], value) => {
107
- if (fn(value)) pass.push(value);
108
- else fail.push(value);
109
- return [pass, fail];
110
- },
111
- [[], []]
112
- );
70
+ return arr.reduce(([pass, fail], value) => {
71
+ if (fn(value)) pass.push(value);
72
+ else fail.push(value);
73
+ return [pass, fail];
74
+ }, [[], []]);
113
75
  }
114
- // Annotate the CommonJS export names for ESM import in node:
115
- 0 && (module.exports = {
116
- add,
117
- addOrRemove,
118
- chunk,
119
- clear,
120
- diff,
121
- first,
122
- flatArray,
123
- fromLength,
124
- has,
125
- insertAt,
126
- isEmpty,
127
- last,
128
- next,
129
- nextIndex,
130
- partition,
131
- prev,
132
- prevIndex,
133
- remove,
134
- removeAt,
135
- toArray,
136
- uniq
137
- });
76
+ exports.add = add;
77
+ exports.addOrRemove = addOrRemove;
78
+ exports.chunk = chunk;
79
+ exports.clear = clear;
80
+ exports.diff = diff;
81
+ exports.first = first;
82
+ exports.flatArray = flatArray;
83
+ exports.fromLength = fromLength;
84
+ exports.has = has;
85
+ exports.insertAt = insertAt;
86
+ exports.isEmpty = isEmpty;
87
+ exports.last = last;
88
+ exports.next = next;
89
+ exports.nextIndex = nextIndex;
90
+ exports.partition = partition;
91
+ exports.prev = prev;
92
+ exports.prevIndex = prevIndex;
93
+ exports.remove = remove;
94
+ exports.removeAt = removeAt;
95
+ exports.toArray = toArray;
96
+ exports.uniq = uniq;
package/dist/array.mjs CHANGED
@@ -1,94 +1,72 @@
1
- import "./chunk-MXGZDBDQ.mjs";
2
-
3
1
  // src/array.ts
4
2
  function toArray(v) {
5
- if (v == null) return [];
6
- return Array.isArray(v) ? v : [v];
3
+ if (v == null) return [];
4
+ return Array.isArray(v) ? v : [v];
7
5
  }
8
- var fromLength = (length) => Array.from(Array(length).keys());
9
- var first = (v) => v[0];
10
- var last = (v) => v[v.length - 1];
11
- var isEmpty = (v) => v.length === 0;
12
- var has = (v, t) => v.indexOf(t) !== -1;
13
- var add = (v, ...items) => v.concat(items);
14
- var remove = (v, ...items) => v.filter((t) => !items.includes(t));
15
- var removeAt = (v, i) => v.filter((_, idx) => idx !== i);
16
- var insertAt = (v, i, ...items) => [...v.slice(0, i), ...items, ...v.slice(i)];
17
- var uniq = (v) => Array.from(new Set(v));
18
- var diff = (a, b) => {
19
- const set = new Set(b);
20
- return a.filter((t) => !set.has(t));
6
+ const fromLength = (length) => Array.from(Array(length).keys());
7
+ const first = (v) => v[0];
8
+ const last = (v) => v[v.length - 1];
9
+ const isEmpty = (v) => v.length === 0;
10
+ const has = (v, t) => v.indexOf(t) !== -1;
11
+ const add = (v, ...items) => v.concat(items);
12
+ const remove = (v, ...items) => v.filter((t) => !items.includes(t));
13
+ const removeAt = (v, i) => v.filter((_, idx) => idx !== i);
14
+ const insertAt = (v, i, ...items) => [
15
+ ...v.slice(0, i),
16
+ ...items,
17
+ ...v.slice(i)
18
+ ];
19
+ const uniq = (v) => Array.from(new Set(v));
20
+ const diff = (a, b) => {
21
+ const set = new Set(b);
22
+ return a.filter((t) => !set.has(t));
21
23
  };
22
- var addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
24
+ const addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
23
25
  function clear(v) {
24
- while (v.length > 0) v.pop();
25
- return v;
26
+ while (v.length > 0) v.pop();
27
+ return v;
26
28
  }
27
29
  function nextIndex(v, idx, opts = {}) {
28
- const { step = 1, loop = true } = opts;
29
- const next2 = idx + step;
30
- const len = v.length;
31
- const last2 = len - 1;
32
- if (idx === -1) return step > 0 ? 0 : last2;
33
- if (next2 < 0) return loop ? last2 : 0;
34
- if (next2 >= len) return loop ? 0 : idx > len ? len : idx;
35
- return next2;
30
+ const { step = 1, loop = true } = opts;
31
+ const next = idx + step;
32
+ const len = v.length;
33
+ const last = len - 1;
34
+ if (idx === -1) return step > 0 ? 0 : last;
35
+ if (next < 0) return loop ? last : 0;
36
+ if (next >= len) return loop ? 0 : idx > len ? len : idx;
37
+ return next;
36
38
  }
37
39
  function next(v, idx, opts = {}) {
38
- return v[nextIndex(v, idx, opts)];
40
+ return v[nextIndex(v, idx, opts)];
39
41
  }
40
42
  function prevIndex(v, idx, opts = {}) {
41
- const { step = 1, loop = true } = opts;
42
- return nextIndex(v, idx, { step: -step, loop });
43
+ const { step = 1, loop = true } = opts;
44
+ return nextIndex(v, idx, {
45
+ step: -step,
46
+ loop
47
+ });
43
48
  }
44
49
  function prev(v, index, opts = {}) {
45
- return v[prevIndex(v, index, opts)];
50
+ return v[prevIndex(v, index, opts)];
46
51
  }
47
52
  function chunk(v, size) {
48
- return v.reduce((rows, value, index) => {
49
- if (index % size === 0) rows.push([value]);
50
- else last(rows)?.push(value);
51
- return rows;
52
- }, []);
53
+ return v.reduce((rows, value, index) => {
54
+ if (index % size === 0) rows.push([value]);
55
+ else last(rows)?.push(value);
56
+ return rows;
57
+ }, []);
53
58
  }
54
59
  function flatArray(arr) {
55
- return arr.reduce((flat, item) => {
56
- if (Array.isArray(item)) {
57
- return flat.concat(flatArray(item));
58
- }
59
- return flat.concat(item);
60
- }, []);
60
+ return arr.reduce((flat, item) => {
61
+ if (Array.isArray(item)) return flat.concat(flatArray(item));
62
+ return flat.concat(item);
63
+ }, []);
61
64
  }
62
65
  function partition(arr, fn) {
63
- return arr.reduce(
64
- ([pass, fail], value) => {
65
- if (fn(value)) pass.push(value);
66
- else fail.push(value);
67
- return [pass, fail];
68
- },
69
- [[], []]
70
- );
66
+ return arr.reduce(([pass, fail], value) => {
67
+ if (fn(value)) pass.push(value);
68
+ else fail.push(value);
69
+ return [pass, fail];
70
+ }, [[], []]);
71
71
  }
72
- export {
73
- add,
74
- addOrRemove,
75
- chunk,
76
- clear,
77
- diff,
78
- first,
79
- flatArray,
80
- fromLength,
81
- has,
82
- insertAt,
83
- isEmpty,
84
- last,
85
- next,
86
- nextIndex,
87
- partition,
88
- prev,
89
- prevIndex,
90
- remove,
91
- removeAt,
92
- toArray,
93
- uniq
94
- };
72
+ export { add, addOrRemove, chunk, clear, diff, first, flatArray, fromLength, has, insertAt, isEmpty, last, next, nextIndex, partition, prev, prevIndex, remove, removeAt, toArray, uniq };
package/dist/equal.d.mts CHANGED
@@ -1,3 +1,2 @@
1
1
  declare const isEqual: (a: any, b: any) => boolean;
2
-
3
- export { isEqual };
2
+ export { isEqual };
package/dist/equal.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  declare const isEqual: (a: any, b: any) => boolean;
2
-
3
- export { isEqual };
2
+ export { isEqual };
package/dist/equal.js CHANGED
@@ -1,48 +1,25 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/equal.ts
21
- var equal_exports = {};
22
- __export(equal_exports, {
23
- isEqual: () => isEqual
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
24
4
  });
25
- module.exports = __toCommonJS(equal_exports);
26
- var hasOwn = Object.prototype.hasOwnProperty;
27
- var isEqual = (a, b) => {
28
- if (Object.is(a, b)) return true;
29
- if (a == null || b == null) return false;
30
- if (typeof a.isEqual === "function" && typeof b.isEqual === "function") return a.isEqual(b);
31
- if (Array.isArray(a) && Array.isArray(b)) {
32
- if (a.length !== b.length) return false;
33
- for (let i = 0; i < a.length; i++) if (!isEqual(a[i], b[i])) return false;
34
- return true;
35
- }
36
- if (typeof a !== "object" || typeof b !== "object") return false;
37
- const keys = Object.keys(b);
38
- if (Object.keys(a).length !== keys.length) return false;
39
- for (let i = 0; i < keys.length; i++) {
40
- const key = keys[i];
41
- if (!hasOwn.call(a, key) || !isEqual(a[key], b[key])) return false;
42
- }
43
- return true;
5
+ // src/equal.ts
6
+ const hasOwn = Object.prototype.hasOwnProperty;
7
+ const isEqual = (a, b) => {
8
+ if (Object.is(a, b)) return true;
9
+ if (a == null || b == null) return false;
10
+ if (typeof a.isEqual === "function" && typeof b.isEqual === "function") return a.isEqual(b);
11
+ if (Array.isArray(a) && Array.isArray(b)) {
12
+ if (a.length !== b.length) return false;
13
+ for (let i = 0; i < a.length; i++) if (!isEqual(a[i], b[i])) return false;
14
+ return true;
15
+ }
16
+ if (typeof a !== "object" || typeof b !== "object") return false;
17
+ const keys = Object.keys(b);
18
+ if (Object.keys(a).length !== keys.length) return false;
19
+ for (let i = 0; i < keys.length; i++) {
20
+ const key = keys[i];
21
+ if (!hasOwn.call(a, key) || !isEqual(a[key], b[key])) return false;
22
+ }
23
+ return true;
44
24
  };
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- isEqual
48
- });
25
+ exports.isEqual = isEqual;
package/dist/equal.mjs CHANGED
@@ -1,25 +1,21 @@
1
- import "./chunk-MXGZDBDQ.mjs";
2
-
3
1
  // src/equal.ts
4
- var hasOwn = Object.prototype.hasOwnProperty;
5
- var isEqual = (a, b) => {
6
- if (Object.is(a, b)) return true;
7
- if (a == null || b == null) return false;
8
- if (typeof a.isEqual === "function" && typeof b.isEqual === "function") return a.isEqual(b);
9
- if (Array.isArray(a) && Array.isArray(b)) {
10
- if (a.length !== b.length) return false;
11
- for (let i = 0; i < a.length; i++) if (!isEqual(a[i], b[i])) return false;
12
- return true;
13
- }
14
- if (typeof a !== "object" || typeof b !== "object") return false;
15
- const keys = Object.keys(b);
16
- if (Object.keys(a).length !== keys.length) return false;
17
- for (let i = 0; i < keys.length; i++) {
18
- const key = keys[i];
19
- if (!hasOwn.call(a, key) || !isEqual(a[key], b[key])) return false;
20
- }
21
- return true;
22
- };
23
- export {
24
- isEqual
2
+ const hasOwn = Object.prototype.hasOwnProperty;
3
+ const isEqual = (a, b) => {
4
+ if (Object.is(a, b)) return true;
5
+ if (a == null || b == null) return false;
6
+ if (typeof a.isEqual === "function" && typeof b.isEqual === "function") return a.isEqual(b);
7
+ if (Array.isArray(a) && Array.isArray(b)) {
8
+ if (a.length !== b.length) return false;
9
+ for (let i = 0; i < a.length; i++) if (!isEqual(a[i], b[i])) return false;
10
+ return true;
11
+ }
12
+ if (typeof a !== "object" || typeof b !== "object") return false;
13
+ const keys = Object.keys(b);
14
+ if (Object.keys(a).length !== keys.length) return false;
15
+ for (let i = 0; i < keys.length; i++) {
16
+ const key = keys[i];
17
+ if (!hasOwn.call(a, key) || !isEqual(a[key], b[key])) return false;
18
+ }
19
+ return true;
25
20
  };
21
+ export { isEqual };
@@ -1,15 +1,13 @@
1
- type MaybeFunction<T> = T | (() => T);
2
- type Nullable<T> = T | null | undefined;
3
- declare const runIfFn: <T>(v: T | undefined, ...a: T extends (...a: any[]) => void ? Parameters<T> : never) => T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T>;
4
- declare const cast: <T>(v: unknown) => T;
5
- declare const identity: (v: VoidFunction) => void;
6
- declare const noop: () => void;
7
- declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | null | undefined)[]) => (...a: Parameters<T>) => void;
8
- declare const uuid: () => string;
9
- declare function match<V extends string | number = string, R = unknown>(key: V, record: Record<V, R | ((...args: any[]) => R)>, ...args: any[]): R;
10
- declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
11
- declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
12
- declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
13
- declare const hash: (value: string) => string;
14
-
15
- export { type MaybeFunction, type Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid };
1
+ export type MaybeFunction<T> = T | (() => T);
2
+ export type Nullable<T> = T | null | undefined;
3
+ export declare const runIfFn: <T>(v: T | undefined, ...a: T extends ((...a: any[]) => void) ? Parameters<T> : never) => T extends ((...a: any[]) => void) ? NonNullable<ReturnType<T>> : NonNullable<T>;
4
+ export declare const cast: <T>(v: unknown) => T;
5
+ export declare const identity: (v: VoidFunction) => void;
6
+ export declare const noop: () => void;
7
+ export declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | null | undefined)[]) => (...a: Parameters<T>) => void;
8
+ export declare const uuid: () => string;
9
+ export declare function match<V extends string | number = string, R = unknown>(key: V, record: Record<V, R | ((...args: any[]) => R)>, ...args: any[]): R;
10
+ export declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
11
+ export declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
12
+ export declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
13
+ export declare const hash: (value: string) => string;