A utility library to get, set, delete, and check properties in nested objects using dot-path strings or arrays.
dot-prop is a JavaScript utility library that enables developers to easily access, modify, and delete properties within deeply nested objects using dot-path strings or arrays. It solves the problem of verbose and error-prone manual property traversal by providing a clean API for common operations on complex data structures.
JavaScript and Node.js developers who frequently work with nested objects, such as those handling configuration files, API responses, or state management in applications.
Developers choose dot-prop for its simplicity, performance with array paths, and robust handling of edge cases like escaped dots and array indices, making it a reliable alternative to manual property access or more complex libraries.
Get, set, or delete a property from a nested object using a dot path
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports both dot-string paths and array paths, with array paths offering better performance by avoiding parsing, as highlighted in the README's interoperability section.
Handles escaped dots in keys and supports both bracket and dot notation for array indices, ensuring reliability with complex data structures, demonstrated in the usage examples.
Provides deepKeys for flattening objects and unflatten for reconstruction, plus escapePath for input sanitization, making it versatile beyond basic get/set operations.
Offers a minimal set of functions for nested property access without the bloat of larger libraries, focusing on simplicity and performance as per its philosophy.
Using string paths incurs parsing overhead, which can be a bottleneck in hot code paths, a trade-off acknowledged in the README's array path documentation.
Functions like setProperty and deleteProperty mutate the input object, which can lead to unintended side effects and conflicts with functional programming patterns.
Primarily designed for plain objects and arrays; it may not work correctly with exotic objects like Proxies or built-in types like Map and Set, limiting its use in advanced scenarios.