@ts-utilkit/object
v0.4.0
Published
Object manipulation utilities for deep merging, cloning, path access, and transformation
Maintainers
Readme
@ts-utilkit/object
object Functions - TypeScript utility functions for object operations.
Installation
npm install @ts-utilkit/objectFeatures
- 🚀 TypeScript-first with complete type definitions
- ✅ Comprehensive test coverage (>95%)
- 📦 CommonJS builds with import and require entry points
- 🔒 Type-safe with strict TypeScript configuration
- 📖 Extensive JSDoc documentation
Available Functions (44)
applyDefaults- Apply default values to objectcompactObject- Remove undefined/null valuescountProperties- Count object propertiesdeepClone- Deep clone objectsdeepCloneWith- Deep clone with custom handlerdeepEqual- Deep equality comparisondeepFreeze- Recursively freeze objectdeepMerge- Deep merge objectsdifferenceBy- Get object difference by keyentriesToObject- Convert entries to objectflattenObject- Flatten nested objectsflipObject- Swap keys and valuesfromDotNotation- Convert dot notation to nested objectgetDeepEqualityHash- Generate equality hashgetObjectDifference- Get difference between objectsgroupByObject- Group array into objecthasKey- Check if object has keyinvertObject- Invert object keys/valuesisDeepSubset- Check if object is subsetisObjectEmpty- Check if object is emptykeyBy- Convert array to object keyed by fieldkeysToCamelCase- Convert keys to camelCasekeysToSnakeCase- Convert keys to snake_caseobjectMap- Map object valuesobjectSize- Get number of propertiesobjectToQueryString- Convert object to query stringomitBy- Omit properties by predicateomitKeys- Omit specific keyspickBy- Pick properties by predicatepickKeys- Pick specific keysqueryStringToObject- Parse query string to objectremoveEmptyValues- Remove empty valuessafeGet- Safe property access with defaultsafeSet- Safe property settingsetNestedValue- Set nested property valueshallowEqual- Shallow equality comparisonsortObjectKeys- Sort object keys alphabeticallyunflattenObject- Unflatten dot notation objectuniqueValues- Get unique values from object
Additional exports
findKey— Returns the first key in an object whose value satisfies the given predicate. Returnsundefinedif no key matches.renameKey— Returns a new object with a single key renamed, preserving all other keys and values unchanged. The key order in the result follows the original object's insertion order, with the renamed key at its original position.transformKeys— Returns a new object with all keys transformed by a given function, while keeping values unchanged.zipObject— Creates an object from two separate arrays: one of keys and one of values. Pairs each key with the value at the same index.
Quick Example
import {
deepMerge,
safeGet,
flattenObject,
pickKeys,
} from '@ts-utilkit/object';
deepMerge({ a: 1 }, { b: 2 }); // {a: 1, b: 2}
safeGet({ a: { b: 'c' } }, 'a.b'); // 'c'
flattenObject({ a: { b: { c: 1 } } }); // {'a.b.c': 1}
const obj = { id: 1, name: 'Alice', active: true };
pickKeys(obj, ['id', 'name']); // {id: 1, name: 'Alice'}License
MIT © Mykyta Forofontov
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
Added utilities
omitDeep— see the signature, examples, and contract in omitDeep.ts.
Full examples and boundary behavior are documented in FUNCTION_IDEAS.md.
