Enables deep property manipulation and inspection without worrying about exceptions.
npm install deep-property
var props = require('deep-property'),
sample = { };
props.set(sample, 'name.first', 'John');
props.set(sample, 'name.middle', 'C');
props.set(sample, 'name.last', 'Reilly');
props.set(sample, 'job.title', 'Actor');
props.get(sample, 'name.first'); // John
props.get(sample, 'name.middle'); // C
props.get(sample, 'name.last'); // Reilly
props.get(sample, 'job.title'); // Actor
props.remove(sample, 'name.middle'); // True
props.has(sample, 'name.first'); // True
props.has(sample, 'name.title'); // False
props.has(sample, 'job.title'); // True
props.has(sample, 'job.salary'); // False
// Resulting object
{
name: {
first: 'John',
last: 'Reilly'
},
job: {
title: 'Actor'
}
}
The path
parameter of each function is dot-delimited string. Everything between the dots is considered a property name. Paths can be as long and complex as necessary, with the following constraints and assumptions:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4