Skip to content

Repository files navigation

Extract.js

Build Status Coverage Status Code Climate

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.

About

Get or check if nested object contains properties

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages