@zag-js/utils 0.10.2 → 0.10.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.
- package/dist/array.d.ts +16 -18
- package/dist/array.js +28 -65
- package/dist/array.mjs +56 -33
- package/dist/functions.d.ts +5 -7
- package/dist/functions.js +14 -41
- package/dist/functions.mjs +20 -13
- package/dist/guard.d.ts +8 -10
- package/dist/guard.js +20 -50
- package/dist/guard.mjs +10 -20
- package/dist/index.d.ts +5 -5
- package/dist/index.js +39 -212
- package/dist/index.mjs +5 -76
- package/dist/object.d.ts +2 -4
- package/dist/object.js +7 -31
- package/dist/object.mjs +21 -7
- package/dist/warning.d.ts +4 -6
- package/dist/warning.js +6 -30
- package/dist/warning.mjs +16 -8
- package/package.json +2 -7
- package/dist/chunk-27EXK2DH.mjs +0 -74
- package/dist/chunk-FZD3QLPB.mjs +0 -20
- package/dist/chunk-JEERFXPQ.mjs +0 -20
- package/dist/chunk-Q55U6R3S.mjs +0 -26
- package/dist/chunk-YKQM3BDH.mjs +0 -28
package/dist/array.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
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: any) => boolean;
|
|
7
|
-
declare const add: <T>(v: T[], ...items: T[]) => T[];
|
|
8
|
-
declare const remove: <T>(v: T[], item: T) => T[];
|
|
9
|
-
declare const removeAt: <T>(v: T[], i: number) => T[];
|
|
10
|
-
declare function clear<T>(v: T[]): T[];
|
|
11
|
-
type IndexOptions = {
|
|
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: any) => boolean;
|
|
7
|
+
export declare const add: <T>(v: T[], ...items: T[]) => T[];
|
|
8
|
+
export declare const remove: <T>(v: T[], item: T) => T[];
|
|
9
|
+
export declare const removeAt: <T>(v: T[], i: number) => T[];
|
|
10
|
+
export declare function clear<T>(v: T[]): T[];
|
|
11
|
+
export type IndexOptions = {
|
|
12
12
|
step?: number;
|
|
13
13
|
loop?: boolean;
|
|
14
14
|
};
|
|
15
|
-
declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
|
|
16
|
-
declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
|
|
17
|
-
declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
|
|
18
|
-
declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
|
|
19
|
-
declare const chunk: <T>(v: T[], size: number) => T[][];
|
|
20
|
-
|
|
21
|
-
export { IndexOptions, add, chunk, clear, first, fromLength, has, isEmpty, last, next, nextIndex, prev, prevIndex, remove, removeAt, toArray };
|
|
15
|
+
export declare function nextIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
|
|
16
|
+
export declare function next<T>(v: T[], idx: number, opts?: IndexOptions): T | undefined;
|
|
17
|
+
export declare function prevIndex<T>(v: T[], idx: number, opts?: IndexOptions): number;
|
|
18
|
+
export declare function prev<T>(v: T[], index: number, opts?: IndexOptions): T | undefined;
|
|
19
|
+
export declare const chunk: <T>(v: T[], size: number) => T[][];
|
package/dist/array.js
CHANGED
|
@@ -1,55 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
19
4
|
|
|
20
|
-
// src/array.ts
|
|
21
|
-
var array_exports = {};
|
|
22
|
-
__export(array_exports, {
|
|
23
|
-
add: () => add,
|
|
24
|
-
chunk: () => chunk,
|
|
25
|
-
clear: () => clear,
|
|
26
|
-
first: () => first,
|
|
27
|
-
fromLength: () => fromLength,
|
|
28
|
-
has: () => has,
|
|
29
|
-
isEmpty: () => isEmpty,
|
|
30
|
-
last: () => last,
|
|
31
|
-
next: () => next,
|
|
32
|
-
nextIndex: () => nextIndex,
|
|
33
|
-
prev: () => prev,
|
|
34
|
-
prevIndex: () => prevIndex,
|
|
35
|
-
remove: () => remove,
|
|
36
|
-
removeAt: () => removeAt,
|
|
37
|
-
toArray: () => toArray
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(array_exports);
|
|
40
5
|
function toArray(v) {
|
|
41
6
|
if (!v)
|
|
42
7
|
return [];
|
|
43
8
|
return Array.isArray(v) ? v : [v];
|
|
44
9
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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, item) => removeAt(v, v.indexOf(item));
|
|
17
|
+
const removeAt = (v, i) => {
|
|
53
18
|
if (i > -1)
|
|
54
19
|
v.splice(i, 1);
|
|
55
20
|
return v;
|
|
@@ -82,7 +47,7 @@ function prevIndex(v, idx, opts = {}) {
|
|
|
82
47
|
function prev(v, index, opts = {}) {
|
|
83
48
|
return v[prevIndex(v, index, opts)];
|
|
84
49
|
}
|
|
85
|
-
|
|
50
|
+
const chunk = (v, size) => {
|
|
86
51
|
const res = [];
|
|
87
52
|
return v.reduce((rows, value, index) => {
|
|
88
53
|
if (index % size === 0)
|
|
@@ -92,21 +57,19 @@ var chunk = (v, size) => {
|
|
|
92
57
|
return rows;
|
|
93
58
|
}, res);
|
|
94
59
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
toArray
|
|
112
|
-
});
|
|
60
|
+
|
|
61
|
+
exports.add = add;
|
|
62
|
+
exports.chunk = chunk;
|
|
63
|
+
exports.clear = clear;
|
|
64
|
+
exports.first = first;
|
|
65
|
+
exports.fromLength = fromLength;
|
|
66
|
+
exports.has = has;
|
|
67
|
+
exports.isEmpty = isEmpty;
|
|
68
|
+
exports.last = last;
|
|
69
|
+
exports.next = next;
|
|
70
|
+
exports.nextIndex = nextIndex;
|
|
71
|
+
exports.prev = prev;
|
|
72
|
+
exports.prevIndex = prevIndex;
|
|
73
|
+
exports.remove = remove;
|
|
74
|
+
exports.removeAt = removeAt;
|
|
75
|
+
exports.toArray = toArray;
|
package/dist/array.mjs
CHANGED
|
@@ -1,34 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./chunk-27EXK2DH.mjs";
|
|
18
|
-
export {
|
|
19
|
-
add,
|
|
20
|
-
chunk,
|
|
21
|
-
clear,
|
|
22
|
-
first,
|
|
23
|
-
fromLength,
|
|
24
|
-
has,
|
|
25
|
-
isEmpty,
|
|
26
|
-
last,
|
|
27
|
-
next,
|
|
28
|
-
nextIndex,
|
|
29
|
-
prev,
|
|
30
|
-
prevIndex,
|
|
31
|
-
remove,
|
|
32
|
-
removeAt,
|
|
33
|
-
toArray
|
|
1
|
+
function toArray(v) {
|
|
2
|
+
if (!v)
|
|
3
|
+
return [];
|
|
4
|
+
return Array.isArray(v) ? v : [v];
|
|
5
|
+
}
|
|
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, item) => removeAt(v, v.indexOf(item));
|
|
13
|
+
const removeAt = (v, i) => {
|
|
14
|
+
if (i > -1)
|
|
15
|
+
v.splice(i, 1);
|
|
16
|
+
return v;
|
|
34
17
|
};
|
|
18
|
+
function clear(v) {
|
|
19
|
+
while (v.length > 0)
|
|
20
|
+
v.pop();
|
|
21
|
+
return v;
|
|
22
|
+
}
|
|
23
|
+
function nextIndex(v, idx, opts = {}) {
|
|
24
|
+
const { step = 1, loop = true } = opts;
|
|
25
|
+
const next2 = idx + step;
|
|
26
|
+
const len = v.length;
|
|
27
|
+
const last2 = len - 1;
|
|
28
|
+
if (idx === -1)
|
|
29
|
+
return step > 0 ? 0 : last2;
|
|
30
|
+
if (next2 < 0)
|
|
31
|
+
return loop ? last2 : 0;
|
|
32
|
+
if (next2 >= len)
|
|
33
|
+
return loop ? 0 : idx > len ? len : idx;
|
|
34
|
+
return next2;
|
|
35
|
+
}
|
|
36
|
+
function next(v, idx, opts = {}) {
|
|
37
|
+
return v[nextIndex(v, idx, opts)];
|
|
38
|
+
}
|
|
39
|
+
function prevIndex(v, idx, opts = {}) {
|
|
40
|
+
const { step = 1, loop = true } = opts;
|
|
41
|
+
return nextIndex(v, idx, { step: -step, loop });
|
|
42
|
+
}
|
|
43
|
+
function prev(v, index, opts = {}) {
|
|
44
|
+
return v[prevIndex(v, index, opts)];
|
|
45
|
+
}
|
|
46
|
+
const chunk = (v, size) => {
|
|
47
|
+
const res = [];
|
|
48
|
+
return v.reduce((rows, value, index) => {
|
|
49
|
+
if (index % size === 0)
|
|
50
|
+
rows.push([value]);
|
|
51
|
+
else
|
|
52
|
+
last(rows)?.push(value);
|
|
53
|
+
return rows;
|
|
54
|
+
}, res);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { add, chunk, clear, first, fromLength, has, isEmpty, last, next, nextIndex, prev, prevIndex, remove, removeAt, toArray };
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
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>;
|
|
2
|
-
declare const cast: <T>(v: unknown) => T;
|
|
3
|
-
declare const noop: () => void;
|
|
4
|
-
declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) => (...a: Parameters<T>) => void;
|
|
5
|
-
declare const uuid: () => string;
|
|
6
|
-
|
|
7
|
-
export { callAll, cast, noop, runIfFn, uuid };
|
|
1
|
+
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>;
|
|
2
|
+
export declare const cast: <T>(v: unknown) => T;
|
|
3
|
+
export declare const noop: () => void;
|
|
4
|
+
export declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) => (...a: Parameters<T>) => void;
|
|
5
|
+
export declare const uuid: () => string;
|
package/dist/functions.js
CHANGED
|
@@ -1,56 +1,29 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
callAll: () => callAll,
|
|
24
|
-
cast: () => cast,
|
|
25
|
-
noop: () => noop,
|
|
26
|
-
runIfFn: () => runIfFn,
|
|
27
|
-
uuid: () => uuid
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(functions_exports);
|
|
30
|
-
var runIfFn = (v, ...a) => {
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const runIfFn = (v, ...a) => {
|
|
31
6
|
const res = typeof v === "function" ? v(...a) : v;
|
|
32
7
|
return res ?? void 0;
|
|
33
8
|
};
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
const cast = (v) => v;
|
|
10
|
+
const noop = () => {
|
|
36
11
|
};
|
|
37
|
-
|
|
12
|
+
const callAll = (...fns) => (...a) => {
|
|
38
13
|
fns.forEach(function(fn) {
|
|
39
14
|
fn?.(...a);
|
|
40
15
|
});
|
|
41
16
|
};
|
|
42
|
-
|
|
17
|
+
const uuid = /* @__PURE__ */ (() => {
|
|
43
18
|
let id = 0;
|
|
44
19
|
return () => {
|
|
45
20
|
id++;
|
|
46
21
|
return id.toString(36);
|
|
47
22
|
};
|
|
48
23
|
})();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
uuid
|
|
56
|
-
});
|
|
24
|
+
|
|
25
|
+
exports.callAll = callAll;
|
|
26
|
+
exports.cast = cast;
|
|
27
|
+
exports.noop = noop;
|
|
28
|
+
exports.runIfFn = runIfFn;
|
|
29
|
+
exports.uuid = uuid;
|
package/dist/functions.mjs
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
noop,
|
|
5
|
-
runIfFn,
|
|
6
|
-
uuid
|
|
7
|
-
} from "./chunk-YKQM3BDH.mjs";
|
|
8
|
-
export {
|
|
9
|
-
callAll,
|
|
10
|
-
cast,
|
|
11
|
-
noop,
|
|
12
|
-
runIfFn,
|
|
13
|
-
uuid
|
|
1
|
+
const runIfFn = (v, ...a) => {
|
|
2
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
3
|
+
return res ?? void 0;
|
|
14
4
|
};
|
|
5
|
+
const cast = (v) => v;
|
|
6
|
+
const noop = () => {
|
|
7
|
+
};
|
|
8
|
+
const callAll = (...fns) => (...a) => {
|
|
9
|
+
fns.forEach(function(fn) {
|
|
10
|
+
fn?.(...a);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
const uuid = /* @__PURE__ */ (() => {
|
|
14
|
+
let id = 0;
|
|
15
|
+
return () => {
|
|
16
|
+
id++;
|
|
17
|
+
return id.toString(36);
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
|
|
21
|
+
export { callAll, cast, noop, runIfFn, uuid };
|
package/dist/guard.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
declare const isDev: () => boolean;
|
|
2
|
-
declare const isArray: (v: any) => v is any[];
|
|
3
|
-
declare const isBoolean: (v: any) => v is boolean;
|
|
4
|
-
declare const isObject: (v: any) => v is Record<string, any>;
|
|
5
|
-
declare const isNumber: (v: any) => v is number;
|
|
6
|
-
declare const isString: (v: any) => v is string;
|
|
7
|
-
declare const isFunction: (v: any) => v is Function;
|
|
8
|
-
declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
|
|
9
|
-
|
|
10
|
-
export { hasProp, isArray, isBoolean, isDev, isFunction, isNumber, isObject, isString };
|
|
1
|
+
export declare const isDev: () => boolean;
|
|
2
|
+
export declare const isArray: (v: any) => v is any[];
|
|
3
|
+
export declare const isBoolean: (v: any) => v is boolean;
|
|
4
|
+
export declare const isObject: (v: any) => v is Record<string, any>;
|
|
5
|
+
export declare const isNumber: (v: any) => v is number;
|
|
6
|
+
export declare const isString: (v: any) => v is string;
|
|
7
|
+
export declare const isFunction: (v: any) => v is Function;
|
|
8
|
+
export declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
|
package/dist/guard.js
CHANGED
|
@@ -1,51 +1,21 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var isFunction = (v) => typeof v === "function";
|
|
40
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
hasProp,
|
|
44
|
-
isArray,
|
|
45
|
-
isBoolean,
|
|
46
|
-
isDev,
|
|
47
|
-
isFunction,
|
|
48
|
-
isNumber,
|
|
49
|
-
isObject,
|
|
50
|
-
isString
|
|
51
|
-
});
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const isDev = () => process.env.NODE_ENV !== "production";
|
|
6
|
+
const isArray = (v) => Array.isArray(v);
|
|
7
|
+
const isBoolean = (v) => v === true || v === false;
|
|
8
|
+
const isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
9
|
+
const isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
10
|
+
const isString = (v) => typeof v === "string";
|
|
11
|
+
const isFunction = (v) => typeof v === "function";
|
|
12
|
+
const hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
|
|
14
|
+
exports.hasProp = hasProp;
|
|
15
|
+
exports.isArray = isArray;
|
|
16
|
+
exports.isBoolean = isBoolean;
|
|
17
|
+
exports.isDev = isDev;
|
|
18
|
+
exports.isFunction = isFunction;
|
|
19
|
+
exports.isNumber = isNumber;
|
|
20
|
+
exports.isObject = isObject;
|
|
21
|
+
exports.isString = isString;
|
package/dist/guard.mjs
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
hasProp,
|
|
13
|
-
isArray,
|
|
14
|
-
isBoolean,
|
|
15
|
-
isDev,
|
|
16
|
-
isFunction,
|
|
17
|
-
isNumber,
|
|
18
|
-
isObject,
|
|
19
|
-
isString
|
|
20
|
-
};
|
|
1
|
+
const isDev = () => process.env.NODE_ENV !== "production";
|
|
2
|
+
const isArray = (v) => Array.isArray(v);
|
|
3
|
+
const isBoolean = (v) => v === true || v === false;
|
|
4
|
+
const isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
5
|
+
const isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
6
|
+
const isString = (v) => typeof v === "string";
|
|
7
|
+
const isFunction = (v) => typeof v === "function";
|
|
8
|
+
const hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
9
|
+
|
|
10
|
+
export { hasProp, isArray, isBoolean, isDev, isFunction, isNumber, isObject, isString };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export * from "./array";
|
|
2
|
+
export * from "./functions";
|
|
3
|
+
export * from "./guard";
|
|
4
|
+
export * from "./object";
|
|
5
|
+
export * from "./warning";
|
package/dist/index.js
CHANGED
|
@@ -1,217 +1,44 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
add: () => add,
|
|
24
|
-
callAll: () => callAll,
|
|
25
|
-
cast: () => cast,
|
|
26
|
-
chunk: () => chunk,
|
|
27
|
-
clear: () => clear,
|
|
28
|
-
compact: () => compact,
|
|
29
|
-
first: () => first,
|
|
30
|
-
fromLength: () => fromLength,
|
|
31
|
-
has: () => has,
|
|
32
|
-
hasProp: () => hasProp,
|
|
33
|
-
invariant: () => invariant,
|
|
34
|
-
isArray: () => isArray,
|
|
35
|
-
isBoolean: () => isBoolean,
|
|
36
|
-
isDev: () => isDev,
|
|
37
|
-
isEmpty: () => isEmpty,
|
|
38
|
-
isFunction: () => isFunction,
|
|
39
|
-
isNumber: () => isNumber,
|
|
40
|
-
isObject: () => isObject,
|
|
41
|
-
isString: () => isString,
|
|
42
|
-
json: () => json,
|
|
43
|
-
last: () => last,
|
|
44
|
-
next: () => next,
|
|
45
|
-
nextIndex: () => nextIndex,
|
|
46
|
-
noop: () => noop,
|
|
47
|
-
prev: () => prev,
|
|
48
|
-
prevIndex: () => prevIndex,
|
|
49
|
-
remove: () => remove,
|
|
50
|
-
removeAt: () => removeAt,
|
|
51
|
-
runIfFn: () => runIfFn,
|
|
52
|
-
toArray: () => toArray,
|
|
53
|
-
uuid: () => uuid,
|
|
54
|
-
warn: () => warn
|
|
55
|
-
});
|
|
56
|
-
module.exports = __toCommonJS(src_exports);
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
57
4
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
var fromLength = (length) => Array.from(Array(length).keys());
|
|
65
|
-
var first = (v) => v[0];
|
|
66
|
-
var last = (v) => v[v.length - 1];
|
|
67
|
-
var isEmpty = (v) => v.length === 0;
|
|
68
|
-
var has = (v, t) => v.indexOf(t) !== -1;
|
|
69
|
-
var add = (v, ...items) => v.concat(items);
|
|
70
|
-
var remove = (v, item) => removeAt(v, v.indexOf(item));
|
|
71
|
-
var removeAt = (v, i) => {
|
|
72
|
-
if (i > -1)
|
|
73
|
-
v.splice(i, 1);
|
|
74
|
-
return v;
|
|
75
|
-
};
|
|
76
|
-
function clear(v) {
|
|
77
|
-
while (v.length > 0)
|
|
78
|
-
v.pop();
|
|
79
|
-
return v;
|
|
80
|
-
}
|
|
81
|
-
function nextIndex(v, idx, opts = {}) {
|
|
82
|
-
const { step = 1, loop = true } = opts;
|
|
83
|
-
const next2 = idx + step;
|
|
84
|
-
const len = v.length;
|
|
85
|
-
const last2 = len - 1;
|
|
86
|
-
if (idx === -1)
|
|
87
|
-
return step > 0 ? 0 : last2;
|
|
88
|
-
if (next2 < 0)
|
|
89
|
-
return loop ? last2 : 0;
|
|
90
|
-
if (next2 >= len)
|
|
91
|
-
return loop ? 0 : idx > len ? len : idx;
|
|
92
|
-
return next2;
|
|
93
|
-
}
|
|
94
|
-
function next(v, idx, opts = {}) {
|
|
95
|
-
return v[nextIndex(v, idx, opts)];
|
|
96
|
-
}
|
|
97
|
-
function prevIndex(v, idx, opts = {}) {
|
|
98
|
-
const { step = 1, loop = true } = opts;
|
|
99
|
-
return nextIndex(v, idx, { step: -step, loop });
|
|
100
|
-
}
|
|
101
|
-
function prev(v, index, opts = {}) {
|
|
102
|
-
return v[prevIndex(v, index, opts)];
|
|
103
|
-
}
|
|
104
|
-
var chunk = (v, size) => {
|
|
105
|
-
const res = [];
|
|
106
|
-
return v.reduce((rows, value, index) => {
|
|
107
|
-
if (index % size === 0)
|
|
108
|
-
rows.push([value]);
|
|
109
|
-
else
|
|
110
|
-
last(rows)?.push(value);
|
|
111
|
-
return rows;
|
|
112
|
-
}, res);
|
|
113
|
-
};
|
|
5
|
+
const array = require('./array.js');
|
|
6
|
+
const functions = require('./functions.js');
|
|
7
|
+
const guard = require('./guard.js');
|
|
8
|
+
const object = require('./object.js');
|
|
9
|
+
const warning = require('./warning.js');
|
|
114
10
|
|
|
115
|
-
// src/functions.ts
|
|
116
|
-
var runIfFn = (v, ...a) => {
|
|
117
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
118
|
-
return res ?? void 0;
|
|
119
|
-
};
|
|
120
|
-
var cast = (v) => v;
|
|
121
|
-
var noop = () => {
|
|
122
|
-
};
|
|
123
|
-
var callAll = (...fns) => (...a) => {
|
|
124
|
-
fns.forEach(function(fn) {
|
|
125
|
-
fn?.(...a);
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
var uuid = /* @__PURE__ */ (() => {
|
|
129
|
-
let id = 0;
|
|
130
|
-
return () => {
|
|
131
|
-
id++;
|
|
132
|
-
return id.toString(36);
|
|
133
|
-
};
|
|
134
|
-
})();
|
|
135
11
|
|
|
136
|
-
// src/guard.ts
|
|
137
|
-
var isDev = () => process.env.NODE_ENV !== "production";
|
|
138
|
-
var isArray = (v) => Array.isArray(v);
|
|
139
|
-
var isBoolean = (v) => v === true || v === false;
|
|
140
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
141
|
-
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
142
|
-
var isString = (v) => typeof v === "string";
|
|
143
|
-
var isFunction = (v) => typeof v === "function";
|
|
144
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
145
12
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const c = a.length === 2 ? a[0] : true;
|
|
179
|
-
if (c && process.env.NODE_ENV !== "production") {
|
|
180
|
-
throw new Error(m);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
-
0 && (module.exports = {
|
|
185
|
-
add,
|
|
186
|
-
callAll,
|
|
187
|
-
cast,
|
|
188
|
-
chunk,
|
|
189
|
-
clear,
|
|
190
|
-
compact,
|
|
191
|
-
first,
|
|
192
|
-
fromLength,
|
|
193
|
-
has,
|
|
194
|
-
hasProp,
|
|
195
|
-
invariant,
|
|
196
|
-
isArray,
|
|
197
|
-
isBoolean,
|
|
198
|
-
isDev,
|
|
199
|
-
isEmpty,
|
|
200
|
-
isFunction,
|
|
201
|
-
isNumber,
|
|
202
|
-
isObject,
|
|
203
|
-
isString,
|
|
204
|
-
json,
|
|
205
|
-
last,
|
|
206
|
-
next,
|
|
207
|
-
nextIndex,
|
|
208
|
-
noop,
|
|
209
|
-
prev,
|
|
210
|
-
prevIndex,
|
|
211
|
-
remove,
|
|
212
|
-
removeAt,
|
|
213
|
-
runIfFn,
|
|
214
|
-
toArray,
|
|
215
|
-
uuid,
|
|
216
|
-
warn
|
|
217
|
-
});
|
|
13
|
+
exports.add = array.add;
|
|
14
|
+
exports.chunk = array.chunk;
|
|
15
|
+
exports.clear = array.clear;
|
|
16
|
+
exports.first = array.first;
|
|
17
|
+
exports.fromLength = array.fromLength;
|
|
18
|
+
exports.has = array.has;
|
|
19
|
+
exports.isEmpty = array.isEmpty;
|
|
20
|
+
exports.last = array.last;
|
|
21
|
+
exports.next = array.next;
|
|
22
|
+
exports.nextIndex = array.nextIndex;
|
|
23
|
+
exports.prev = array.prev;
|
|
24
|
+
exports.prevIndex = array.prevIndex;
|
|
25
|
+
exports.remove = array.remove;
|
|
26
|
+
exports.removeAt = array.removeAt;
|
|
27
|
+
exports.toArray = array.toArray;
|
|
28
|
+
exports.callAll = functions.callAll;
|
|
29
|
+
exports.cast = functions.cast;
|
|
30
|
+
exports.noop = functions.noop;
|
|
31
|
+
exports.runIfFn = functions.runIfFn;
|
|
32
|
+
exports.uuid = functions.uuid;
|
|
33
|
+
exports.hasProp = guard.hasProp;
|
|
34
|
+
exports.isArray = guard.isArray;
|
|
35
|
+
exports.isBoolean = guard.isBoolean;
|
|
36
|
+
exports.isDev = guard.isDev;
|
|
37
|
+
exports.isFunction = guard.isFunction;
|
|
38
|
+
exports.isNumber = guard.isNumber;
|
|
39
|
+
exports.isObject = guard.isObject;
|
|
40
|
+
exports.isString = guard.isString;
|
|
41
|
+
exports.compact = object.compact;
|
|
42
|
+
exports.json = object.json;
|
|
43
|
+
exports.invariant = warning.invariant;
|
|
44
|
+
exports.warn = warning.warn;
|
package/dist/index.mjs
CHANGED
|
@@ -1,76 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
fromLength,
|
|
7
|
-
has,
|
|
8
|
-
isEmpty,
|
|
9
|
-
last,
|
|
10
|
-
next,
|
|
11
|
-
nextIndex,
|
|
12
|
-
prev,
|
|
13
|
-
prevIndex,
|
|
14
|
-
remove,
|
|
15
|
-
removeAt,
|
|
16
|
-
toArray
|
|
17
|
-
} from "./chunk-27EXK2DH.mjs";
|
|
18
|
-
import {
|
|
19
|
-
callAll,
|
|
20
|
-
cast,
|
|
21
|
-
noop,
|
|
22
|
-
runIfFn,
|
|
23
|
-
uuid
|
|
24
|
-
} from "./chunk-YKQM3BDH.mjs";
|
|
25
|
-
import {
|
|
26
|
-
hasProp,
|
|
27
|
-
isArray,
|
|
28
|
-
isBoolean,
|
|
29
|
-
isDev,
|
|
30
|
-
isFunction,
|
|
31
|
-
isNumber,
|
|
32
|
-
isObject,
|
|
33
|
-
isString
|
|
34
|
-
} from "./chunk-FZD3QLPB.mjs";
|
|
35
|
-
import {
|
|
36
|
-
compact,
|
|
37
|
-
json
|
|
38
|
-
} from "./chunk-Q55U6R3S.mjs";
|
|
39
|
-
import {
|
|
40
|
-
invariant,
|
|
41
|
-
warn
|
|
42
|
-
} from "./chunk-JEERFXPQ.mjs";
|
|
43
|
-
export {
|
|
44
|
-
add,
|
|
45
|
-
callAll,
|
|
46
|
-
cast,
|
|
47
|
-
chunk,
|
|
48
|
-
clear,
|
|
49
|
-
compact,
|
|
50
|
-
first,
|
|
51
|
-
fromLength,
|
|
52
|
-
has,
|
|
53
|
-
hasProp,
|
|
54
|
-
invariant,
|
|
55
|
-
isArray,
|
|
56
|
-
isBoolean,
|
|
57
|
-
isDev,
|
|
58
|
-
isEmpty,
|
|
59
|
-
isFunction,
|
|
60
|
-
isNumber,
|
|
61
|
-
isObject,
|
|
62
|
-
isString,
|
|
63
|
-
json,
|
|
64
|
-
last,
|
|
65
|
-
next,
|
|
66
|
-
nextIndex,
|
|
67
|
-
noop,
|
|
68
|
-
prev,
|
|
69
|
-
prevIndex,
|
|
70
|
-
remove,
|
|
71
|
-
removeAt,
|
|
72
|
-
runIfFn,
|
|
73
|
-
toArray,
|
|
74
|
-
uuid,
|
|
75
|
-
warn
|
|
76
|
-
};
|
|
1
|
+
export { add, chunk, clear, first, fromLength, has, isEmpty, last, next, nextIndex, prev, prevIndex, remove, removeAt, toArray } from './array.mjs';
|
|
2
|
+
export { callAll, cast, noop, runIfFn, uuid } from './functions.mjs';
|
|
3
|
+
export { hasProp, isArray, isBoolean, isDev, isFunction, isNumber, isObject, isString } from './guard.mjs';
|
|
4
|
+
export { compact, json } from './object.mjs';
|
|
5
|
+
export { invariant, warn } from './warning.mjs';
|
package/dist/object.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
declare function compact<T extends Record<string, unknown> | undefined>(obj: T): T;
|
|
2
|
-
declare function json(value: any): any;
|
|
3
|
-
|
|
4
|
-
export { compact, json };
|
|
1
|
+
export declare function compact<T extends Record<string, unknown> | undefined>(obj: T): T;
|
|
2
|
+
export declare function json(value: any): any;
|
package/dist/object.js
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
19
4
|
|
|
20
|
-
// src/object.ts
|
|
21
|
-
var object_exports = {};
|
|
22
|
-
__export(object_exports, {
|
|
23
|
-
compact: () => compact,
|
|
24
|
-
json: () => json
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(object_exports);
|
|
27
5
|
function compact(obj) {
|
|
28
6
|
if (!isPlainObject(obj) || obj === void 0) {
|
|
29
7
|
return obj;
|
|
@@ -41,11 +19,9 @@ function compact(obj) {
|
|
|
41
19
|
function json(value) {
|
|
42
20
|
return JSON.parse(JSON.stringify(value));
|
|
43
21
|
}
|
|
44
|
-
|
|
22
|
+
const isPlainObject = (value) => {
|
|
45
23
|
return value && typeof value === "object" && value.constructor === Object;
|
|
46
24
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
json
|
|
51
|
-
});
|
|
25
|
+
|
|
26
|
+
exports.compact = compact;
|
|
27
|
+
exports.json = json;
|
package/dist/object.mjs
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function compact(obj) {
|
|
2
|
+
if (!isPlainObject(obj) || obj === void 0) {
|
|
3
|
+
return obj;
|
|
4
|
+
}
|
|
5
|
+
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
6
|
+
const filtered = {};
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
const value = obj[key];
|
|
9
|
+
if (value !== void 0) {
|
|
10
|
+
filtered[key] = compact(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return filtered;
|
|
14
|
+
}
|
|
15
|
+
function json(value) {
|
|
16
|
+
return JSON.parse(JSON.stringify(value));
|
|
17
|
+
}
|
|
18
|
+
const isPlainObject = (value) => {
|
|
19
|
+
return value && typeof value === "object" && value.constructor === Object;
|
|
8
20
|
};
|
|
21
|
+
|
|
22
|
+
export { compact, json };
|
package/dist/warning.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
declare function warn(m: string): void;
|
|
2
|
-
declare function warn(c: boolean, m: string): void;
|
|
3
|
-
declare function invariant(m: string): void;
|
|
4
|
-
declare function invariant(c: boolean, m: string): void;
|
|
5
|
-
|
|
6
|
-
export { invariant, warn };
|
|
1
|
+
export declare function warn(m: string): void;
|
|
2
|
+
export declare function warn(c: boolean, m: string): void;
|
|
3
|
+
export declare function invariant(m: string): void;
|
|
4
|
+
export declare function invariant(c: boolean, m: string): void;
|
package/dist/warning.js
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
19
4
|
|
|
20
|
-
// src/warning.ts
|
|
21
|
-
var warning_exports = {};
|
|
22
|
-
__export(warning_exports, {
|
|
23
|
-
invariant: () => invariant,
|
|
24
|
-
warn: () => warn
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(warning_exports);
|
|
27
5
|
function warn(...a) {
|
|
28
6
|
const m = a.length === 1 ? a[0] : a[1];
|
|
29
7
|
const c = a.length === 2 ? a[0] : true;
|
|
@@ -38,8 +16,6 @@ function invariant(...a) {
|
|
|
38
16
|
throw new Error(m);
|
|
39
17
|
}
|
|
40
18
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
warn
|
|
45
|
-
});
|
|
19
|
+
|
|
20
|
+
exports.invariant = invariant;
|
|
21
|
+
exports.warn = warn;
|
package/dist/warning.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function warn(...a) {
|
|
2
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
3
|
+
const c = a.length === 2 ? a[0] : true;
|
|
4
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
5
|
+
console.warn(m);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function invariant(...a) {
|
|
9
|
+
const m = a.length === 1 ? a[0] : a[1];
|
|
10
|
+
const c = a.length === 2 ? a[0] : true;
|
|
11
|
+
if (c && process.env.NODE_ENV !== "production") {
|
|
12
|
+
throw new Error(m);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { invariant, warn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/utils",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -38,13 +38,8 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build
|
|
42
|
-
"start": "pnpm build --watch",
|
|
43
|
-
"build": "tsup src --dts",
|
|
44
|
-
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
41
|
+
"build": "vite build -c ../../../vite.config.ts",
|
|
45
42
|
"lint": "eslint src --ext .ts,.tsx",
|
|
46
|
-
"test-ci": "pnpm test --ci --runInBand",
|
|
47
|
-
"test-watch": "pnpm test --watch -u",
|
|
48
43
|
"typecheck": "tsc --noEmit"
|
|
49
44
|
}
|
|
50
45
|
}
|
package/dist/chunk-27EXK2DH.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// src/array.ts
|
|
2
|
-
function toArray(v) {
|
|
3
|
-
if (!v)
|
|
4
|
-
return [];
|
|
5
|
-
return Array.isArray(v) ? v : [v];
|
|
6
|
-
}
|
|
7
|
-
var fromLength = (length) => Array.from(Array(length).keys());
|
|
8
|
-
var first = (v) => v[0];
|
|
9
|
-
var last = (v) => v[v.length - 1];
|
|
10
|
-
var isEmpty = (v) => v.length === 0;
|
|
11
|
-
var has = (v, t) => v.indexOf(t) !== -1;
|
|
12
|
-
var add = (v, ...items) => v.concat(items);
|
|
13
|
-
var remove = (v, item) => removeAt(v, v.indexOf(item));
|
|
14
|
-
var removeAt = (v, i) => {
|
|
15
|
-
if (i > -1)
|
|
16
|
-
v.splice(i, 1);
|
|
17
|
-
return v;
|
|
18
|
-
};
|
|
19
|
-
function clear(v) {
|
|
20
|
-
while (v.length > 0)
|
|
21
|
-
v.pop();
|
|
22
|
-
return v;
|
|
23
|
-
}
|
|
24
|
-
function nextIndex(v, idx, opts = {}) {
|
|
25
|
-
const { step = 1, loop = true } = opts;
|
|
26
|
-
const next2 = idx + step;
|
|
27
|
-
const len = v.length;
|
|
28
|
-
const last2 = len - 1;
|
|
29
|
-
if (idx === -1)
|
|
30
|
-
return step > 0 ? 0 : last2;
|
|
31
|
-
if (next2 < 0)
|
|
32
|
-
return loop ? last2 : 0;
|
|
33
|
-
if (next2 >= len)
|
|
34
|
-
return loop ? 0 : idx > len ? len : idx;
|
|
35
|
-
return next2;
|
|
36
|
-
}
|
|
37
|
-
function next(v, idx, opts = {}) {
|
|
38
|
-
return v[nextIndex(v, idx, opts)];
|
|
39
|
-
}
|
|
40
|
-
function prevIndex(v, idx, opts = {}) {
|
|
41
|
-
const { step = 1, loop = true } = opts;
|
|
42
|
-
return nextIndex(v, idx, { step: -step, loop });
|
|
43
|
-
}
|
|
44
|
-
function prev(v, index, opts = {}) {
|
|
45
|
-
return v[prevIndex(v, index, opts)];
|
|
46
|
-
}
|
|
47
|
-
var chunk = (v, size) => {
|
|
48
|
-
const res = [];
|
|
49
|
-
return v.reduce((rows, value, index) => {
|
|
50
|
-
if (index % size === 0)
|
|
51
|
-
rows.push([value]);
|
|
52
|
-
else
|
|
53
|
-
last(rows)?.push(value);
|
|
54
|
-
return rows;
|
|
55
|
-
}, res);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
toArray,
|
|
60
|
-
fromLength,
|
|
61
|
-
first,
|
|
62
|
-
last,
|
|
63
|
-
isEmpty,
|
|
64
|
-
has,
|
|
65
|
-
add,
|
|
66
|
-
remove,
|
|
67
|
-
removeAt,
|
|
68
|
-
clear,
|
|
69
|
-
nextIndex,
|
|
70
|
-
next,
|
|
71
|
-
prevIndex,
|
|
72
|
-
prev,
|
|
73
|
-
chunk
|
|
74
|
-
};
|
package/dist/chunk-FZD3QLPB.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// src/guard.ts
|
|
2
|
-
var isDev = () => process.env.NODE_ENV !== "production";
|
|
3
|
-
var isArray = (v) => Array.isArray(v);
|
|
4
|
-
var isBoolean = (v) => v === true || v === false;
|
|
5
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
6
|
-
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
7
|
-
var isString = (v) => typeof v === "string";
|
|
8
|
-
var isFunction = (v) => typeof v === "function";
|
|
9
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
isDev,
|
|
13
|
-
isArray,
|
|
14
|
-
isBoolean,
|
|
15
|
-
isObject,
|
|
16
|
-
isNumber,
|
|
17
|
-
isString,
|
|
18
|
-
isFunction,
|
|
19
|
-
hasProp
|
|
20
|
-
};
|
package/dist/chunk-JEERFXPQ.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// src/warning.ts
|
|
2
|
-
function warn(...a) {
|
|
3
|
-
const m = a.length === 1 ? a[0] : a[1];
|
|
4
|
-
const c = a.length === 2 ? a[0] : true;
|
|
5
|
-
if (c && process.env.NODE_ENV !== "production") {
|
|
6
|
-
console.warn(m);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function invariant(...a) {
|
|
10
|
-
const m = a.length === 1 ? a[0] : a[1];
|
|
11
|
-
const c = a.length === 2 ? a[0] : true;
|
|
12
|
-
if (c && process.env.NODE_ENV !== "production") {
|
|
13
|
-
throw new Error(m);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
warn,
|
|
19
|
-
invariant
|
|
20
|
-
};
|
package/dist/chunk-Q55U6R3S.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/object.ts
|
|
2
|
-
function compact(obj) {
|
|
3
|
-
if (!isPlainObject(obj) || obj === void 0) {
|
|
4
|
-
return obj;
|
|
5
|
-
}
|
|
6
|
-
const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
7
|
-
const filtered = {};
|
|
8
|
-
for (const key of keys) {
|
|
9
|
-
const value = obj[key];
|
|
10
|
-
if (value !== void 0) {
|
|
11
|
-
filtered[key] = compact(value);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return filtered;
|
|
15
|
-
}
|
|
16
|
-
function json(value) {
|
|
17
|
-
return JSON.parse(JSON.stringify(value));
|
|
18
|
-
}
|
|
19
|
-
var isPlainObject = (value) => {
|
|
20
|
-
return value && typeof value === "object" && value.constructor === Object;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export {
|
|
24
|
-
compact,
|
|
25
|
-
json
|
|
26
|
-
};
|
package/dist/chunk-YKQM3BDH.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// src/functions.ts
|
|
2
|
-
var runIfFn = (v, ...a) => {
|
|
3
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
4
|
-
return res ?? void 0;
|
|
5
|
-
};
|
|
6
|
-
var cast = (v) => v;
|
|
7
|
-
var noop = () => {
|
|
8
|
-
};
|
|
9
|
-
var callAll = (...fns) => (...a) => {
|
|
10
|
-
fns.forEach(function(fn) {
|
|
11
|
-
fn?.(...a);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
var uuid = /* @__PURE__ */ (() => {
|
|
15
|
-
let id = 0;
|
|
16
|
-
return () => {
|
|
17
|
-
id++;
|
|
18
|
-
return id.toString(36);
|
|
19
|
-
};
|
|
20
|
-
})();
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
runIfFn,
|
|
24
|
-
cast,
|
|
25
|
-
noop,
|
|
26
|
-
callAll,
|
|
27
|
-
uuid
|
|
28
|
-
};
|