🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

path-notation

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path-notation

A dot-notation based path string which yields key literals, allows for the inclusion of the "."character in keys and square bracket notation in path strings, promotes readability of path strings and provides other useful utilities for reasoning and workin

2.1.0
latest
Source
npm
Version published
Weekly downloads
4
-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

PathNotation

A dot-notation based path string which yields key literals, allows for the inclusion of the "." character in keys and square bracket notation in path strings, promotes readability of path strings and provides other useful utilities for reasoning and working with objects paths.

Example:

import PathNotation from 'path-notation';

const path = new PathNotation('foo', 'bar', 2, '10','baz\\.qux');

console.log(`Path notation string: ${path}`); 
// Path notation string: foo.bar[2].10[baz.qux]

console.log(`Number of keys in the path: ${path.length}`);
// Number of keys in the path: 5

console.log(`First key in the path: ${path.firstKey}`);
// First key in the path: foo

console.log(`Last key in the path: ${path.lastKey}`);
// Last key in the path: baz.qux

// Create a PathNotation instance from a path notation string.
const pathStr = new PathNotation('foo.bar[2].10[baz.qux]');

console.log('\nKeys')
for(const key of pathStr) {
  console.log(`  Key: ${key}; Type ${typeof key}`);
}
// Keys
//   Key: foo; Type string
//   Key: bar; Type string
//   Key: 2; Type number
//   Key: 10; Type string
//   Key: baz.qux; Type string

Full docs.

Keywords

Javascript

FAQs

Package last updated on 09 Oct 2019

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