@zag-js/utils 1.47.0 → 1.49.0
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/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/assertClassBrand.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/assertClassBrand.mjs +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/checkPrivateRedeclaration.mjs +5 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/classPrivateFieldGet2.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/classPrivateFieldGet2.mjs +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/classPrivateFieldInitSpec.mjs +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/defineProperty.js +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/defineProperty.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/toPrimitive.mjs +13 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/toPropertyKey.js +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/typeof.js +15 -0
- package/dist/_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/typeof.mjs +10 -0
- package/dist/array.d.mts +24 -26
- package/dist/array.d.ts +24 -26
- package/dist/array.js +76 -117
- package/dist/array.mjs +52 -74
- package/dist/equal.d.mts +1 -3
- package/dist/equal.d.ts +1 -3
- package/dist/equal.js +26 -60
- package/dist/equal.mjs +22 -37
- package/dist/functions.d.mts +13 -15
- package/dist/functions.d.ts +13 -15
- package/dist/functions.js +82 -121
- package/dist/functions.mjs +68 -88
- package/dist/guard.d.mts +12 -13
- package/dist/guard.d.ts +12 -13
- package/dist/guard.js +37 -70
- package/dist/guard.mjs +23 -37
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +101 -39
- package/dist/index.mjs +10 -10
- package/dist/number.d.mts +37 -38
- package/dist/number.d.ts +37 -38
- package/dist/number.js +136 -185
- package/dist/number.mjs +104 -134
- package/dist/object.d.mts +11 -16
- package/dist/object.d.ts +11 -16
- package/dist/object.js +52 -91
- package/dist/object.mjs +41 -61
- package/dist/store.d.mts +10 -12
- package/dist/store.d.ts +10 -12
- package/dist/store.js +42 -67
- package/dist/store.mjs +38 -44
- package/dist/timers.d.mts +21 -22
- package/dist/timers.d.ts +21 -22
- package/dist/timers.js +83 -112
- package/dist/timers.mjs +77 -83
- package/dist/warning.d.mts +7 -8
- package/dist/warning.d.ts +7 -8
- package/dist/warning.js +16 -51
- package/dist/warning.mjs +9 -25
- package/package.json +3 -3
- package/dist/chunk-MXGZDBDQ.mjs +0 -15
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/assertClassBrand.js
|
|
2
|
+
function _assertClassBrand(e, t, n) {
|
|
3
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
4
|
+
throw new TypeError("Private element is not present on this object");
|
|
5
|
+
}
|
|
6
|
+
exports.default = _assertClassBrand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/assertClassBrand.js
|
|
2
|
+
function _assertClassBrand(e, t, n) {
|
|
3
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
4
|
+
throw new TypeError("Private element is not present on this object");
|
|
5
|
+
}
|
|
6
|
+
export { _assertClassBrand as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/checkPrivateRedeclaration.js
|
|
2
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
3
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
+
}
|
|
5
|
+
exports.default = _checkPrivateRedeclaration;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/checkPrivateRedeclaration.js
|
|
2
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
3
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
+
}
|
|
5
|
+
export { _checkPrivateRedeclaration as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_assertClassBrand = require("./assertClassBrand.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/classPrivateFieldGet2.js
|
|
3
|
+
function _classPrivateFieldGet2(s, a) {
|
|
4
|
+
return s.get(require_assertClassBrand.default(s, a));
|
|
5
|
+
}
|
|
6
|
+
exports.default = _classPrivateFieldGet2;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
3
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
4
|
+
require_checkPrivateRedeclaration.default(e, t), t.set(e, a);
|
|
5
|
+
}
|
|
6
|
+
exports.default = _classPrivateFieldInitSpec;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import _checkPrivateRedeclaration from "./checkPrivateRedeclaration.mjs";
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
3
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
4
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
5
|
+
}
|
|
6
|
+
export { _classPrivateFieldInitSpec as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_toPropertyKey = require("./toPropertyKey.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = require_toPropertyKey.default(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
exports.default = _defineProperty;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import toPropertyKey from "./toPropertyKey.mjs";
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
export { _defineProperty as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, e) {
|
|
4
|
+
if ("object" != require_typeof.default(t) || !t) return t;
|
|
5
|
+
var r;
|
|
6
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
7
|
+
var i = r.call(t, e || "default");
|
|
8
|
+
if ("object" != require_typeof.default(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === e ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
exports.default = toPrimitive;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import _typeof from "./typeof.mjs";
|
|
2
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, e) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var r;
|
|
6
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
7
|
+
var i = r.call(t, e || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === e ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
export { toPrimitive as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const require_typeof = require("./typeof.js");
|
|
2
|
+
const require_toPrimitive = require("./toPrimitive.js");
|
|
3
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = require_toPrimitive.default(t, "string");
|
|
6
|
+
return "symbol" == require_typeof.default(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
exports.default = toPropertyKey;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _typeof from "./typeof.mjs";
|
|
2
|
+
import toPrimitive from "./toPrimitive.mjs";
|
|
3
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
export { toPropertyKey as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(exports, "default", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return _typeof;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// \0@oxc-project+runtime@0.159.0/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
export { _typeof as default };
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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);
|
|
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
|
-
|
|
5
|
+
// src/array.ts
|
|
46
6
|
function toArray(v) {
|
|
47
|
-
|
|
48
|
-
|
|
7
|
+
if (v == null) return [];
|
|
8
|
+
return Array.isArray(v) ? v : [v];
|
|
49
9
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
28
|
+
const addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
|
|
65
29
|
function clear(v) {
|
|
66
|
-
|
|
67
|
-
|
|
30
|
+
while (v.length > 0) v.pop();
|
|
31
|
+
return v;
|
|
68
32
|
}
|
|
69
33
|
function nextIndex(v, idx, opts = {}) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
44
|
+
return v[nextIndex(v, idx, opts)];
|
|
81
45
|
}
|
|
82
46
|
function prevIndex(v, idx, opts = {}) {
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
54
|
+
return v[prevIndex(v, index, opts)];
|
|
88
55
|
}
|
|
89
56
|
function chunk(v, size) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
6
|
-
|
|
3
|
+
if (v == null) return [];
|
|
4
|
+
return Array.isArray(v) ? v : [v];
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
24
|
+
const addOrRemove = (v, item) => has(v, item) ? remove(v, item) : add(v, item);
|
|
23
25
|
function clear(v) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
while (v.length > 0) v.pop();
|
|
27
|
+
return v;
|
|
26
28
|
}
|
|
27
29
|
function nextIndex(v, idx, opts = {}) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
+
return v[nextIndex(v, idx, opts)];
|
|
39
41
|
}
|
|
40
42
|
function prevIndex(v, idx, opts = {}) {
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
50
|
+
return v[prevIndex(v, index, opts)];
|
|
46
51
|
}
|
|
47
52
|
function chunk(v, size) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
package/dist/equal.d.ts
CHANGED