object-lens
v1.0.0
Published
ACL-like filtering of objects
Downloads
4
Readme
object-lens
Information
Usage
Install
npm install object-lens --save
Example
var filter = require('object-lens');
var schema = {
name: ['public', 'admin'],
lastName: ['admin']
};
var data = {
name: 'Todd',
lastName: 'Johnson'
};
// Filtering a single piece of data
filter(schema, ['public'], data); // {name: 'Todd'}
// Filtering an array of data
var mapFn = filter.bind(null, schema, ['public']);
var filtered = [data, data].map(mapFn); // [{name: 'Todd'}, {name: 'Todd'}]
LICENSE
(MIT License)
Copyright (c) 2015 Contra [email protected]
Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:
The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.