object-reader
This module allows you to access deep properties and make operations on objects using a path.
What is a "path" ?
A path is a string which describes how an object will be read.
Install
Node.js
npm install object-reader --save
Usage
var obj = a: b: 0 c: 1 2 d: e: 0 f: 1 g: 2 e: 0 f: 2 g: 2 h: 3 g: 0 1 1 2 "b.c": "escaping works !"; var objectReader = ; // get propertyobjectReader // 0objectReader // 0objectReader // 1objectReader // 1 // get filtered array of objectsobjectReader // [ {e: 0, f: 1, g: 2 } ], get array of objects where e = 0 and f = 1objectReader // [ {e: 0, f: 1, g: 2 }, {e: 0, f: 2, g: 2, h: 3 } ], get array of objects where g = 2objectReader // [], return an empty array because there is no object having e = 1 // apply operationobjectReader // [0, 1, 1, 2], concat array keeping duplicatesobjectReader // {e: [0, 0], f: [1, 2], g: [2, 2], h: [3] }, make array with object fields // escaping dotsobjectReader // "escaping works !"
Immutability
Reading operations are guarantee without side effects.
Tests
To run the test suite, first install the dependencies, then run npm test
:
npm installnpm test