
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
nested-obj
is a simple and lightweight JavaScript utility library for safely accessing and modifying nested properties in objects using string paths.
npm install nested-obj
Retrieve a nested property value from an object.
import objectPath from 'nested-obj';
const obj = {
user: {
name: 'John Doe',
address: {
street: '123 Main St',
city: 'Anytown'
}
}
};
const userName = objectPath.get(obj, 'user.name');
console.log(userName); // 'John Doe'
Set a value at a specific path in an object. If any part of the path does not exist, it will be created.
objectPath.set(obj, 'user.address.zip', '12345');
console.log(obj.user.address.zip); // '12345'
Check if a path exists within an object.
const hasCity = objectPath.has(obj, 'user.address.city');
console.log(hasCity); // true
To run tests, execute the following command:
npm test
or for continuous
npm test:watch
FAQs
manipulate deep objects safely and simply
We found that nested-obj demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.