iter-object
An object iterator and object replacer with callbacks for key-value pairs
Installation
npm install iter-object
or
yarn add iter-object
Usage
Method | Params | Description |
---|---|---|
iter_obj | (src: Object, fn: Function ) | Iterate over objects and display key-value pairs |
iter_repl | (src: Object, fn: Function ) => any | Iterate over object and return modified or new values |
iterObject
Example:
; const src = owner: 'Alex' car: make: 'Toyota' model: 'Matrix' year: 2013 ; // output:// owner Alex// car { make: 'Toyota', model: 'Matrix', year: 2013 }// make Toyota// model Matrix// year 2013
iterReplace
Example:
; const sellerContent = owner: 'Alex' car: make: 'Toyota' model: 'Matrix' year: 2013 ; const buyerContent = ; console; // output:// {// "owner": "New Buyer",// "car": {// "make": "Toyota",// "model": "Matrix",// "year": 2013,// "color": "White"// }