Socket
Socket
Sign inDemoInstall

keypath

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    keypath

Access values in nested properties and arrays using a keypath.


Version published
Weekly downloads
14
decreased by-6.67%
Maintainers
1
Install size
5.66 kB
Created
Weekly downloads
 

Readme

Source

Keypath

Easily access properties in nested objects and arrays using a dot notation syntax.

Installation

Install with NPM: $ npm install keypath

keypath(keypath, object/array[, callback/re-throw]);

Keypath only exposes one function, so require it and use it.

var keypath = require('keypath');
keypath('foo.bar.baz', object);

Keypath takes 2 or 3 arguments.

  • keypath: a string representing the value you want to access.

  • object: the object in which this value resides.

  • callback/rethrow: an optional argument that can be either a function or true. If you give it a function, this function will be called if an error occurs. The error itself will be the callbacks only argument.

    If you pass true any error will be re-thrown and you can catch it yourself.

    If left out keypath() will just return undefined.

Roadmap

I'd like to add setting, that'd be convinient, right? Also adding@avg and the like would be cool. If you don't know what that is read this excellent blogpost about that feature in Cocoa.

License

See LICENSE.

Keywords

FAQs

Last updated on 16 Dec 2012

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc