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

dotpath-resolve

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotpath-resolve

Dot-path based object property selector

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

dotpath-resolve

NPM

Build Status Coverage Status

Dot-path based object property selector.

Features

  • dot-path object traversal
  • array traversal
  • reverse traversal

Usage

All possible use cases are described in test code.

var resolve = require('dotpath-resolve');

// object to be searched
var obj = {
  k1: {
    k11: 'k11',
    k2: 'k1.k2',
    k3: [1, 2, 3]
  },
  k2: 'k2'
};

resolve(obj, 'k2');       // k2
resolve(obj, 'k1.k11');   // k11
resolve(obj, 'k2', 'k1'); // k1.k2
resolve(obj, 'k1.k3.1');  // 2
resolve(obj, 'missing');  // undefined
resolve(obj, 'k2', 'k1.k3.0.missing'); // k1.k2

Public API

resolve(obj, selector, [startSelector])

Search given object using dotpath selector and optionally start selector.

Parameters:

  • obj {Object|Array} - Object to be searched
  • selector {String} - Dotpath selector
  • [startSelector] {String} - Optional search start selector

Return Values:

Returns a value of obj key specified by given selector or undefined if a key was not found.

Private API

Complete API Documentation including private and public methods is generated from source code by JSDoc tool and is available here.

Code coverage

Code coverage report for all files is available here.

Scripts

  • npm test - run tests
  • npm run jsdoc - build jsdoc
  • npm run dev - run tests continuously

License

The MIT License (MIT)

Keywords

FAQs

Package last updated on 26 Nov 2014

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