Skip to content

agnostio/objsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 }

About

Object Subset

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published