0.6.1 • Published 5 years ago
extract.js v0.6.1
Extract.js
Check or get nested properties on objects in javascript
Installation
Install the package from npm
npm install --save extract.js
Usage
extract.js is a tiny util library for either extracting or checking properties on a nested object, both dot and bracket notation.
import extract from 'extract.js';
const object = { foo: { bar: 'foobar' }, bar: [{foo: 'foobar'}] }
extract.get(object, 'foo.bar'); // => 'foobar'
extract.get(object, 'bar[0].foo'); // => 'foobar'
extract.get(object, 'foo.bar.foobar'); // => undefined
extract.has(object, 'foo.bar'); // => true
extract.has(object, 'foo.bar.foobar'); // => false
License
MIT. Copyright (c) 2016 Philip Knape.