Object-Scan
Find Keys using Wildcard matching and optional value function.
Install
Install with npm:
$ npm install --save object-scan
Usage
const objectScan = require('object-scan');
objectScan(["a.*.f"])({ a: { b: { c: 'd' }, e: { f: 'g' } } });
Examples
More extensive examples can be found in the tests.
const objectScan = require('object-scan');
const obj = {
a: {
b: {
c: 'd'
},
e: {
f: 'g'
},
h: ["i", "j"]
},
k: "l"
};
objectScan(["*"])(obj);
objectScan(["a.*.f"])(obj);
objectScan(["*.*.*"])(obj);
objectScan(["a.*.{c,f}"])(obj);
objectScan(["*.*[*]"])(obj);
objectScan(["*[*]"])(obj);
objectScan(["**"])(obj);
objectScan(["**.f"])(obj);
objectScan(["**"])(obj, e => typeof e === "string");
objectScan(["**[*]"])(obj);
Special Characters
The characters {
, }
, ,
and *
are considered "special" and should be escaped with a backslash as necessary.