Socket
Socket
Sign inDemoInstall

path-notation

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
2
Maintainers
1
Install size
774 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 09 Oct 2019

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