Object Helpers
Utility functions for working with object operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
compact | Removes all entries with falsy values (false, null, undefined, 0, "", NaN) from an object. |
deepClone | Creates a deep copy of an object or array |
deepMerge | Merges two or more objects deeply |
diff | Structural object diff. |
equalsDeep | Recursive structural object equality. |
equalsShallow | One-level (shallow) object equality. |
get | Gets a value from an object using a dot-notated path |
groupBy | Groups an array of items by a key derived from each item. |
has | native JS Object.hasOwn(obj, key) (ES2022) |
invert | Returns a new object with keys and values swapped. |
isEmpty | Checks if a plain object has no own enumerable string-keyed properties. |
isNonEmpty | Checks if a plain object has at least one own enumerable string-keyed property. |
keys / values | native JS Object.keys() / Object.values() (ES2017) |
map | Transforms the values and/or keys of a plain object in a single pass. |
merge (shallow) | native JS { ...a, ...b } or Object.assign({}, a, b) (ES2015) |
omit | Creates a new object without the specified keys. |
pick | Creates a new object with only the specified keys. |
removeUndefinedNull | Remove null and undefined values from an object. |
safeJsonParse | Parses a JSON string, returning null (or a fallback) on any parse failure. |
set | Sets a value in an object using a dot-notated path |
toPairs / fromPairs | native JS Object.entries() / Object.fromEntries() (ES2019) |