New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-dot-path

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-dot-path

dot path set & get & has & delete property

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Object可优化get,set,has,delete

安装

npm install node-dot-path

示例

const dot = require( 'node-dot-path' );


// norm
var node = {};
dot.set( node, 'a.b.c.d\\.1', 123 );              // node: { a: { b: { c: { 'd.1': 123 } } } }
console.log( dot.get( node, 'a.b.c.d\\.1' ) );    // 123
console.log( dot.has( node, 'a.b.c.d\\.1' ) );    // true
dot.delete( node, 'a.b.c.d\\.1' );                // node: { a: { b: { c: {} } } }

// batch
var node = {};
var pathArr = dot.makePathArray( 'a.b.c.d\\.1' );
dot.set( node, pathArr, 123 );
console.log( dot.get( node, pathArr ) );
console.log( dot.has( node, pathArr ) );
dot.delete( node, pathArr );

// function
var node = {};
dot.set( node, 'a.b', function() { return { c: 123 }; } );
console.log( node );                              // { a: { b: [Function] } }
console.log( dot.get( node, 'a.b.c', true ) );    // 123
console.log( dot.get( node, 'a.b.c' ) );          // undefined
console.log( dot.get( node, 'a.b', true ) );      // { c: 123 }
console.log( dot.get( node, 'a.b' ) );            // [Function]

// arrayToObject
console.log( dot.arrayToObject( [ 'a.b=123', 'aa', 'a.c\\=2\\.asd.c=asd asd=asd' ] ) );
// echo: { a: { b: '123', 'c=2.asd': { c: 'asd asd=asd' } }, aa: true }

dot.arrayToObject( process.argv.slice( 2 ) );

Keywords

dot

FAQs

Package last updated on 29 Apr 2017

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