0.1.0 • Published 9 years ago
keyhole v0.1.0
keyhole
Make projections on your objects, as you'd look at them via keyhole. Define which object properties you want to see and resulting object will have exactly these properties, nothing more (also supports nested properties via dot notation e.g. foo.bar.baz
).
Installation
$ npm install keyhole
Basic Usage
import keyhole from 'keyhole';
const source = {
name: 'john doe',
age: 29,
emails: {
work: 'john@work.com',
priv: 'john@priv.com',
},
colors: ['red', 'green', 'blue']
};
const projection = keyhole(source, 'name', 'emails.work', 'colors');
projection
will be as follows:
{
name: 'john doe',
emails: {
work: 'john@work.com'
},
colors: ['red', 'green', 'blue']
}
For more examples see tests directory
Build and test
$ npm run build
$ npm test
to run tests in "watch" mode issue npm run test-watch
License
0.1.0
9 years ago