lazy-aggregator
Create lazy-initialized dictionary based on source
dictionary handled with fn
Parameters
source
Object<string, any> dictionary of configs forfn
call (optional, default{}
)fn
function function which will be used to create elements in aggregation (optional, defaultfunction(key,value){returnvalue}
)
Examples
;const fn = a * 2;const source = el1: 1 el2: 2; const aggregation = source fn;aggregation'el1'; // 1aggregationel2; // 2
- Throws Error if
fn
is not a function
add
add element to aggregation
Parameters
key
String first argument tofn
value
any? data forfn
call
Examples
;;const fn = a * 2;const source = el1: 1 el2: 2;const aggregation = {} fn;aggregationadd'newEl' 2;aggregationnewEl; // 4
Returns Object this
del
delete element from aggregation
Parameters
key
String key of aggregation member to delete
Examples
;;const fn = a * 2;const aggregation = newEl: 3 fn;aggregationdel'newEl';aggregationnewEl; // undefined
Returns Object this
Installation
npm install --save lazy-aggregator