@zag-js/utils 1.0.0 → 1.0.2
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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +13 -0
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -103,5 +103,8 @@ declare function warn(m: string): void;
|
|
|
103
103
|
declare function warn(c: boolean, m: string): void;
|
|
104
104
|
declare function invariant(m: string): void;
|
|
105
105
|
declare function invariant(c: boolean, m: string): void;
|
|
106
|
+
declare function ensure<T>(c: T | null | undefined, m: string): asserts c is T;
|
|
107
|
+
type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
108
|
+
declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
|
|
106
109
|
|
|
107
|
-
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|
|
110
|
+
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|
package/dist/index.d.ts
CHANGED
|
@@ -103,5 +103,8 @@ declare function warn(m: string): void;
|
|
|
103
103
|
declare function warn(c: boolean, m: string): void;
|
|
104
104
|
declare function invariant(m: string): void;
|
|
105
105
|
declare function invariant(c: boolean, m: string): void;
|
|
106
|
+
declare function ensure<T>(c: T | null | undefined, m: string): asserts c is T;
|
|
107
|
+
type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
108
|
+
declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
|
|
106
109
|
|
|
107
|
-
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|
|
110
|
+
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|
package/dist/index.js
CHANGED
|
@@ -390,6 +390,17 @@ function invariant(...a) {
|
|
|
390
390
|
throw new Error(m);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
+
function ensure(c, m) {
|
|
394
|
+
if (c == null) throw new Error(m);
|
|
395
|
+
}
|
|
396
|
+
function ensureProps(props, keys, scope) {
|
|
397
|
+
let missingKeys = [];
|
|
398
|
+
for (const key of keys) {
|
|
399
|
+
if (props[key] == null) missingKeys.push(key);
|
|
400
|
+
}
|
|
401
|
+
if (missingKeys.length > 0)
|
|
402
|
+
throw new Error(`[zag-js${scope ? ` > ${scope}` : ""}] missing required props: ${missingKeys.join(", ")}`);
|
|
403
|
+
}
|
|
393
404
|
|
|
394
405
|
exports.add = add;
|
|
395
406
|
exports.addOrRemove = addOrRemove;
|
|
@@ -402,6 +413,8 @@ exports.clear = clear;
|
|
|
402
413
|
exports.compact = compact;
|
|
403
414
|
exports.createSplitProps = createSplitProps;
|
|
404
415
|
exports.decrementValue = decrementValue;
|
|
416
|
+
exports.ensure = ensure;
|
|
417
|
+
exports.ensureProps = ensureProps;
|
|
405
418
|
exports.first = first;
|
|
406
419
|
exports.flatArray = flatArray;
|
|
407
420
|
exports.fromLength = fromLength;
|
package/dist/index.mjs
CHANGED
|
@@ -388,5 +388,16 @@ function invariant(...a) {
|
|
|
388
388
|
throw new Error(m);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
+
function ensure(c, m) {
|
|
392
|
+
if (c == null) throw new Error(m);
|
|
393
|
+
}
|
|
394
|
+
function ensureProps(props, keys, scope) {
|
|
395
|
+
let missingKeys = [];
|
|
396
|
+
for (const key of keys) {
|
|
397
|
+
if (props[key] == null) missingKeys.push(key);
|
|
398
|
+
}
|
|
399
|
+
if (missingKeys.length > 0)
|
|
400
|
+
throw new Error(`[zag-js${scope ? ` > ${scope}` : ""}] missing required props: ${missingKeys.join(", ")}`);
|
|
401
|
+
}
|
|
391
402
|
|
|
392
|
-
export { add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|
|
403
|
+
export { add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, decrementValue, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, tryCatch, uniq, uuid, warn, wrap };
|