@zag-js/utils 1.40.0 → 1.41.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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/object.d.mts +2 -1
- package/dist/object.d.ts +2 -1
- package/dist/object.js +13 -10
- package/dist/object.mjs +12 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { isEqual } from './equal.mjs';
|
|
|
3
3
|
export { MaybeFunction, Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid } from './functions.mjs';
|
|
4
4
|
export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString } from './guard.mjs';
|
|
5
5
|
export { clampPercent, clampValue, decrementValue, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, incrementValue, isNaN, isValueAtMax, isValueAtMin, isValueWithinRange, mod, nan, roundToDpr, roundToStepPrecision, roundValue, setValueAtIndex, snapValueToStep, toFixedNumber, toPx, wrap } from './number.mjs';
|
|
6
|
-
export { compact, createSplitProps, json, omit, pick, splitProps } from './object.mjs';
|
|
6
|
+
export { compact, createSplitProps, json, keys, omit, pick, splitProps } from './object.mjs';
|
|
7
7
|
export { Store, StoreCompareFn, StoreListener, createStore } from './store.mjs';
|
|
8
8
|
export { Timer, TimerBaseContext, TimerContextFn, setRafInterval, setRafTimeout } from './timers.mjs';
|
|
9
9
|
export { ensure, ensureProps, invariant, warn } from './warning.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { isEqual } from './equal.js';
|
|
|
3
3
|
export { MaybeFunction, Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid } from './functions.js';
|
|
4
4
|
export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString } from './guard.js';
|
|
5
5
|
export { clampPercent, clampValue, decrementValue, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, incrementValue, isNaN, isValueAtMax, isValueAtMin, isValueWithinRange, mod, nan, roundToDpr, roundToStepPrecision, roundValue, setValueAtIndex, snapValueToStep, toFixedNumber, toPx, wrap } from './number.js';
|
|
6
|
-
export { compact, createSplitProps, json, omit, pick, splitProps } from './object.js';
|
|
6
|
+
export { compact, createSplitProps, json, keys, omit, pick, splitProps } from './object.js';
|
|
7
7
|
export { Store, StoreCompareFn, StoreListener, createStore } from './store.js';
|
|
8
8
|
export { Timer, TimerBaseContext, TimerContextFn, setRafInterval, setRafTimeout } from './timers.js';
|
|
9
9
|
export { ensure, ensureProps, invariant, warn } from './warning.js';
|
package/dist/object.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare function compact<T extends Record<string, unknown> | undefined>(obj: T): T;
|
|
2
2
|
declare const json: (v: any) => any;
|
|
3
|
+
declare const keys: <T extends Record<string, any>>(obj: T) => (keyof T)[];
|
|
3
4
|
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
4
5
|
type Dict = Record<string | symbol, any>;
|
|
5
6
|
declare function splitProps<T extends Dict>(props: T, keys: (keyof T)[]): Dict[];
|
|
6
7
|
declare const createSplitProps: <T extends Dict>(keys: (keyof T)[]) => <Props extends T>(props: Props) => [T, Omit<Props, keyof T>];
|
|
7
8
|
declare function omit<T extends Record<string, any>>(obj: T, keys: string[]): Omit<T, string | number>;
|
|
8
9
|
|
|
9
|
-
export { compact, createSplitProps, json, omit, pick, splitProps };
|
|
10
|
+
export { compact, createSplitProps, json, keys, omit, pick, splitProps };
|
package/dist/object.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare function compact<T extends Record<string, unknown> | undefined>(obj: T): T;
|
|
2
2
|
declare const json: (v: any) => any;
|
|
3
|
+
declare const keys: <T extends Record<string, any>>(obj: T) => (keyof T)[];
|
|
3
4
|
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
4
5
|
type Dict = Record<string | symbol, any>;
|
|
5
6
|
declare function splitProps<T extends Dict>(props: T, keys: (keyof T)[]): Dict[];
|
|
6
7
|
declare const createSplitProps: <T extends Dict>(keys: (keyof T)[]) => <Props extends T>(props: Props) => [T, Omit<Props, keyof T>];
|
|
7
8
|
declare function omit<T extends Record<string, any>>(obj: T, keys: string[]): Omit<T, string | number>;
|
|
8
9
|
|
|
9
|
-
export { compact, createSplitProps, json, omit, pick, splitProps };
|
|
10
|
+
export { compact, createSplitProps, json, keys, omit, pick, splitProps };
|
package/dist/object.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(object_exports, {
|
|
|
23
23
|
compact: () => compact,
|
|
24
24
|
createSplitProps: () => createSplitProps,
|
|
25
25
|
json: () => json,
|
|
26
|
+
keys: () => keys,
|
|
26
27
|
omit: () => omit,
|
|
27
28
|
pick: () => pick,
|
|
28
29
|
splitProps: () => splitProps
|
|
@@ -31,9 +32,9 @@ module.exports = __toCommonJS(object_exports);
|
|
|
31
32
|
var import_guard = require("./guard.js");
|
|
32
33
|
function compact(obj) {
|
|
33
34
|
if (!(0, import_guard.isPlainObject)(obj) || obj === void 0) return obj;
|
|
34
|
-
const
|
|
35
|
+
const keys2 = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
35
36
|
const filtered = {};
|
|
36
|
-
for (const key of
|
|
37
|
+
for (const key of keys2) {
|
|
37
38
|
const value = obj[key];
|
|
38
39
|
if (value !== void 0) {
|
|
39
40
|
filtered[key] = compact(value);
|
|
@@ -42,9 +43,10 @@ function compact(obj) {
|
|
|
42
43
|
return filtered;
|
|
43
44
|
}
|
|
44
45
|
var json = (v) => JSON.parse(JSON.stringify(v));
|
|
45
|
-
|
|
46
|
+
var keys = (obj) => Object.keys(obj);
|
|
47
|
+
function pick(obj, keys2) {
|
|
46
48
|
const filtered = {};
|
|
47
|
-
for (const key of
|
|
49
|
+
for (const key of keys2) {
|
|
48
50
|
const value = obj[key];
|
|
49
51
|
if (value !== void 0) {
|
|
50
52
|
filtered[key] = value;
|
|
@@ -52,10 +54,10 @@ function pick(obj, keys) {
|
|
|
52
54
|
}
|
|
53
55
|
return filtered;
|
|
54
56
|
}
|
|
55
|
-
function splitProps(props,
|
|
57
|
+
function splitProps(props, keys2) {
|
|
56
58
|
const rest = {};
|
|
57
59
|
const result = {};
|
|
58
|
-
const keySet = new Set(
|
|
60
|
+
const keySet = new Set(keys2);
|
|
59
61
|
const ownKeys = Reflect.ownKeys(props);
|
|
60
62
|
for (const key of ownKeys) {
|
|
61
63
|
if (keySet.has(key)) {
|
|
@@ -66,19 +68,20 @@ function splitProps(props, keys) {
|
|
|
66
68
|
}
|
|
67
69
|
return [result, rest];
|
|
68
70
|
}
|
|
69
|
-
var createSplitProps = (
|
|
71
|
+
var createSplitProps = (keys2) => {
|
|
70
72
|
return function split(props) {
|
|
71
|
-
return splitProps(props,
|
|
73
|
+
return splitProps(props, keys2);
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
|
-
function omit(obj,
|
|
75
|
-
return createSplitProps(
|
|
76
|
+
function omit(obj, keys2) {
|
|
77
|
+
return createSplitProps(keys2)(obj)[1];
|
|
76
78
|
}
|
|
77
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
80
|
0 && (module.exports = {
|
|
79
81
|
compact,
|
|
80
82
|
createSplitProps,
|
|
81
83
|
json,
|
|
84
|
+
keys,
|
|
82
85
|
omit,
|
|
83
86
|
pick,
|
|
84
87
|
splitProps
|
package/dist/object.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import "./chunk-MXGZDBDQ.mjs";
|
|
|
4
4
|
import { isPlainObject } from "./guard.mjs";
|
|
5
5
|
function compact(obj) {
|
|
6
6
|
if (!isPlainObject(obj) || obj === void 0) return obj;
|
|
7
|
-
const
|
|
7
|
+
const keys2 = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
|
|
8
8
|
const filtered = {};
|
|
9
|
-
for (const key of
|
|
9
|
+
for (const key of keys2) {
|
|
10
10
|
const value = obj[key];
|
|
11
11
|
if (value !== void 0) {
|
|
12
12
|
filtered[key] = compact(value);
|
|
@@ -15,9 +15,10 @@ function compact(obj) {
|
|
|
15
15
|
return filtered;
|
|
16
16
|
}
|
|
17
17
|
var json = (v) => JSON.parse(JSON.stringify(v));
|
|
18
|
-
|
|
18
|
+
var keys = (obj) => Object.keys(obj);
|
|
19
|
+
function pick(obj, keys2) {
|
|
19
20
|
const filtered = {};
|
|
20
|
-
for (const key of
|
|
21
|
+
for (const key of keys2) {
|
|
21
22
|
const value = obj[key];
|
|
22
23
|
if (value !== void 0) {
|
|
23
24
|
filtered[key] = value;
|
|
@@ -25,10 +26,10 @@ function pick(obj, keys) {
|
|
|
25
26
|
}
|
|
26
27
|
return filtered;
|
|
27
28
|
}
|
|
28
|
-
function splitProps(props,
|
|
29
|
+
function splitProps(props, keys2) {
|
|
29
30
|
const rest = {};
|
|
30
31
|
const result = {};
|
|
31
|
-
const keySet = new Set(
|
|
32
|
+
const keySet = new Set(keys2);
|
|
32
33
|
const ownKeys = Reflect.ownKeys(props);
|
|
33
34
|
for (const key of ownKeys) {
|
|
34
35
|
if (keySet.has(key)) {
|
|
@@ -39,18 +40,19 @@ function splitProps(props, keys) {
|
|
|
39
40
|
}
|
|
40
41
|
return [result, rest];
|
|
41
42
|
}
|
|
42
|
-
var createSplitProps = (
|
|
43
|
+
var createSplitProps = (keys2) => {
|
|
43
44
|
return function split(props) {
|
|
44
|
-
return splitProps(props,
|
|
45
|
+
return splitProps(props, keys2);
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
|
-
function omit(obj,
|
|
48
|
-
return createSplitProps(
|
|
48
|
+
function omit(obj, keys2) {
|
|
49
|
+
return createSplitProps(keys2)(obj)[1];
|
|
49
50
|
}
|
|
50
51
|
export {
|
|
51
52
|
compact,
|
|
52
53
|
createSplitProps,
|
|
53
54
|
json,
|
|
55
|
+
keys,
|
|
54
56
|
omit,
|
|
55
57
|
pick,
|
|
56
58
|
splitProps
|