Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-dig

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-dig

This allow you to use method like Ruby's hash#dig in JavaScript.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9K
increased by9.65%
Maintainers
1
Weekly downloads
 
Created
Source

object-dig

Build Status

This allow you to use method like Ruby's hash#dig in JavaScript.

http://ruby-doc.org/core-2.3.0_preview1/Hash.html#method-i-dig

Retrieves the value object corresponding to the each key objects repeatedly.

Install

$ npm install --save object-dig

Usage

var dig = require('object-dig');

var object = { a: { b: { c: 'c' } } };

dig(object, 'a', 'b');
// => { c: 'c' }

dig(object, 'a', 'b', 'c');
// => 'c'

dig(object, 'a', 'unknownProp', 'c');
// =>undefined

and you can give function object to dig. Function object's argument is result of just before evaluating.

dig(object, 'a', 'b', 'c', (val) => `${val} was changed`);
// => 'c was changed'

dig(object, 'a', 'b', 'c', (val) => `${val} was changed`, (val) => `${val} more`);
// => 'c was changed more'

License

MIT © joe-re

Keywords

FAQs

Package last updated on 17 May 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc