@zag-js/utils
Advanced tools
Comparing version 0.0.0-dev-20240714222614 to 0.0.0-dev-20240723090825
@@ -48,2 +48,3 @@ declare function toArray<T>(v: T | T[] | undefined | null): T[]; | ||
declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>; | ||
declare function omit<T extends Record<string, any>>(obj: T, keys: string[]): Omit<T, string | number>; | ||
@@ -59,2 +60,2 @@ type Dict = Record<string, any>; | ||
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clear, compact, createSplitProps, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isString, json, last, match, next, nextIndex, noop, pick, prev, prevIndex, remove, removeAt, runIfFn, splitProps, toArray, tryCatch, uniq, uuid, warn }; | ||
export { type IndexOptions, type MaybeFunction, type Nullable, add, addOrRemove, callAll, cast, chunk, clear, compact, createSplitProps, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isString, json, last, match, next, nextIndex, noop, omit, pick, prev, prevIndex, remove, removeAt, runIfFn, splitProps, toArray, tryCatch, uniq, uuid, warn }; |
@@ -52,2 +52,3 @@ "use strict"; | ||
noop: () => noop, | ||
omit: () => omit, | ||
pick: () => pick, | ||
@@ -205,2 +206,22 @@ prev: () => prev, | ||
// src/split-props.ts | ||
function splitProps(props, keys) { | ||
const rest = {}; | ||
const result = {}; | ||
const keySet = new Set(keys); | ||
for (const key in props) { | ||
if (keySet.has(key)) { | ||
result[key] = props[key]; | ||
} else { | ||
rest[key] = props[key]; | ||
} | ||
} | ||
return [result, rest]; | ||
} | ||
var createSplitProps = (keys) => { | ||
return function split(props) { | ||
return splitProps(props, keys); | ||
}; | ||
}; | ||
// src/object.ts | ||
@@ -237,22 +258,5 @@ function compact(obj) { | ||
} | ||
// src/split-props.ts | ||
function splitProps(props, keys) { | ||
const rest = {}; | ||
const result = {}; | ||
const keySet = new Set(keys); | ||
for (const key in props) { | ||
if (keySet.has(key)) { | ||
result[key] = props[key]; | ||
} else { | ||
rest[key] = props[key]; | ||
} | ||
} | ||
return [result, rest]; | ||
function omit(obj, keys) { | ||
return createSplitProps(keys)(obj)[1]; | ||
} | ||
var createSplitProps = (keys) => { | ||
return function split(props) { | ||
return splitProps(props, keys); | ||
}; | ||
}; | ||
@@ -305,2 +309,3 @@ // src/warning.ts | ||
noop, | ||
omit, | ||
pick, | ||
@@ -307,0 +312,0 @@ prev, |
{ | ||
"name": "@zag-js/utils", | ||
"version": "0.0.0-dev-20240714222614", | ||
"version": "0.0.0-dev-20240723090825", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,1 +1,3 @@ | ||
import { createSplitProps } from "./split-props" | ||
export function compact<T extends Record<string, unknown> | undefined>(obj: T): T { | ||
@@ -37,1 +39,5 @@ if (!isPlainObject(obj) || obj === undefined) { | ||
} | ||
export function omit<T extends Record<string, any>>(obj: T, keys: string[]) { | ||
return createSplitProps(keys)(obj)[1] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58914
831