@chakra-ui/object-utils
Advanced tools
Comparing version 0.0.0-dev-20221223180742 to 0.0.0-dev-20230102093714
declare function compact<T extends Record<any, any>>(object: T): {} & T; | ||
declare function omit<T extends Record<any, any>, K extends keyof T>(object: T, keysToOmit?: K[]): Omit<T, K>; | ||
declare function pick<T extends Record<any, any>, K extends keyof T>(object: T, keysToPick: K[]): { [P in K]: T[P]; }; | ||
declare function omit<T extends Record<string, any>, K extends keyof T>(object: T, keysToOmit?: K[]): Omit<T, K>; | ||
declare function pick<T extends Record<string, any>, K extends keyof T>(object: T, keysToPick: K[]): { [P in K]: T[P]; }; | ||
declare function split<T extends Record<string, any>, K extends keyof T>(object: T, keys: K[]): [{ [P in K]: T[P]; }, Omit<T, K>]; | ||
declare function assignAfter(target: Record<string, any>, ...sources: any[]): Record<string, unknown>; | ||
export { compact, omit, pick, split }; | ||
export { assignAfter, compact, omit, pick, split }; |
@@ -23,2 +23,3 @@ "use strict"; | ||
__export(src_exports, { | ||
assignAfter: () => assignAfter, | ||
compact: () => compact, | ||
@@ -41,4 +42,5 @@ omit: () => omit, | ||
for (const key of keysToOmit) { | ||
if (key in clone) | ||
if (key in clone) { | ||
delete clone[key]; | ||
} | ||
} | ||
@@ -67,4 +69,23 @@ return clone; | ||
} | ||
function assignAfter(target, ...sources) { | ||
if (target == null) { | ||
throw new TypeError("Cannot convert undefined or null to object"); | ||
} | ||
const result = { ...target }; | ||
for (const nextSource of sources) { | ||
if (nextSource == null) | ||
continue; | ||
for (const nextKey in nextSource) { | ||
if (!Object.prototype.hasOwnProperty.call(nextSource, nextKey)) | ||
continue; | ||
if (nextKey in result) | ||
delete result[nextKey]; | ||
result[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
return result; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
assignAfter, | ||
compact, | ||
@@ -71,0 +92,0 @@ omit, |
{ | ||
"name": "@chakra-ui/object-utils", | ||
"version": "0.0.0-dev-20221223180742", | ||
"version": "0.0.0-dev-20230102093714", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
7379
160
0