keyhole

0.1.0 • Public • Published

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

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i keyhole

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • mostr