Home

Awesome

object-at

Get object's property according to the path.

MIT License

build:? coverage:?

Install

$ npm install --save object-at 

Usage

For more use-cases see the tests

var at     = require('object-at');
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };

at(object, 'a[0].b.c'); // => 3
at(object, 'a[1]');     // => 4
at(['a', 'b', 'c'], 2); // => 'c'

at();                       // => undefined
at(['a', 'b', 'c']);        // => undefined
at(['a', 'b', 'c'], 5);     // => undefined
at(['a', 'b', 'c'], '1.2'); // => undefined

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.