dpo
v1.0.2
Published
dpo module
Downloads
3
Readme
DPO - Dinamyc pseudo-object for flexible usage
Usage:
import dpo from 'dpo'; //-- create a global object (can be used for some data storage)
dpo.prop = 'value'; //-- save some properties
dpo.prop2 = function () { ... } ; //-- may be not only scalar
dpo({prop3: 'value3', prop4: 'value4', }); //-- extend current object by structure
console.log (dpo.prop); //-- return value
console.log (dpo('prop')); //-- same way
var Users = dpo([{userId: 1, userName: 'John'}, {userId: 2, userName: 'Alice'}], 'userName'); //-- create new structured object by second field's key
console.log (Users.John);
var Users2 = dpo([{userId: 1, userName: 'John'}, {userId: 2, userName: 'Alice'}], 'userId'); //-- create new structured object by second field's key
console.log (Users2(1)); //-- return value by number index
var dpoClone = dpo(dpo); //-- make clone if same object in arguments
var dpoBlank = dpo(); //-- make blank dpo (without previous data)
var Obj = dpo(null); //-- return current data as object