Skip to content

gearcase/object-at

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • object-has - Checks if path is a direct property of object.
  • object-set - Sets the value at path of object.
  • object-unset - Removes the property at path of object.
  • to-path - Converts string to a property path array.

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.

About

Get object's property according to the path.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published