Object Helpers
Utility functions for working with object operations.
Functions
Section titled “Functions”| Function | Description |
|---|---|
camelCaseKeys | Recursively transforms every key of a plain object (including keys nested inside arrays and nested objects) to camelC… |
clone | Creates a shallow copy of a value — one level deep, unlike cloneDeep. |
cloneDeep | Creates a deep copy of an object or array. |
compact | Removes all entries with falsy values (`false`, `null`, `undefined`, `0`, `""`, `NaN`) from an object. |
diff | Structural object diff. |
equalsDeep | Recursive structural object equality. |
equalsShallow | One-level (shallow) object equality. |
flatten | Flattens a nested object into a single-level object whose keys are the dot-notation path to each leaf value. |
get | Gets a value from an object using a dot/bracket-notated path or explicit key array. |
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. |
kebabCaseKeys | Recursively transforms every key of a plain object (including keys nested inside arrays and nested objects) to kebab-… |
keys / values | native JS Object.keys() / Object.values() (ES2017) |
map | Transforms the values and/or keys of a plain object in a single pass. |
mapDeep | Recursively transforms the keys and/or values of a plain object — the deep counterpart to map, which only transforms … |
merge (shallow) | native JS { ...a, ...b } or Object.assign({}, a, b) (ES2015) |
mergeDeep | Merges two or more objects deeply, returning a **new** object without mutating any input. |
omit | Creates a new object without the specified keys. |
omitBy | Creates a new object without the own enumerable entries for which `predicate` returns `true`. |
parsePropertyPath | Parses a dot/bracket-notation property path into an array of string/number key segments — the same notation accepted … |
pascalCaseKeys | Recursively transforms every key of a plain object (including keys nested inside arrays and nested objects) to Pascal… |
pick | Creates a new object with only the specified keys. |
pickBy | Creates a new object with only the own enumerable entries for which `predicate` returns `true`. |
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 at the given path, creating intermediate objects as needed. |
snakeCaseKeys | Recursively transforms every key of a plain object (including keys nested inside arrays and nested objects) to snake_… |
sortKeys | Creates a new object with the same entries as the input, but with its own keys sorted. |
titleCaseKeys | Recursively transforms every key of a plain object (including keys nested inside arrays and nested objects) to Title … |
toPairs / fromPairs | native JS Object.entries() / Object.fromEntries() (ES2019) |
unflatten | Rebuilds a nested object from a single-level object whose keys are dot-notation paths. |
unset | Removes the value at a dot/bracket-notation path or explicit key array, mutating the object in place. |
update | Updates the value at a path by applying a function to its current value, creating intermediate objects as needed. |