1.0.1 • Published 4 years ago

objsub v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Object Subset

(objsub)

an easy way to clone specified object properties into a new returned object.

(useful in minimizing IO)

example:

const subs = require('objsub');
//
// API: (object, arrayOfKeys)
//
var obj = {
    asdfas: 5,
    foo: 'bar'
}

console.log(subs(obj, ['foo'])); // returns { foo: 'bar' }
//
//

var cachedObj = subs(obj, ['foo']);

obj.asdfas = 100;
obj.foo = 'panda';

console.log(cachedObj); // returns { foo: 'bar' } // not panda
//
//

var obj2 = {
    number: 65,
    pants: 'green',
    monkey: 'Colobus',
}

console.log(subs(obj2, ['pants', 'number'])); // returns { pants: 'green', number: 65 }
1.0.1

4 years ago

1.0.0

4 years ago