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

objectpath

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

objectpath

Parse js object paths using both dot and bracket notation. Stringify an array of properties into a valid path.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by4.28%
Maintainers
1
Weekly downloads
 
Created
Source

ObjectPath

Join the chat at https://gitter.im/mike-marcacci/objectpath

Build Status

Parse js object paths using both dot and bracket notation. Stringify an array of properties into a valid path.

  • parse JS object reference fragments
  • build JS object reference fragments
  • supports presence of unicode characters
  • supports presence of control characters in key names

Parse a Path

ObjectPath.parse(str)

var ObjectPath = require('objectpath');

ObjectPath.parse('a[1].b.c.d["e"]["f-f"].g');
// => ['a','1','b','c','d','e','f-f','g']

Build a Path String

ObjectPath.stringify(arr, [quote="'"], [forceQuote=false]);

var ObjectPath = require('objectpath');

ObjectPath.stringify(['a','1','b','c','d-d','e']);
// => "a[1].b.c['d-d'].e"


ObjectPath.stringify(['a','1','b','c','d-d','e'],'"');
// => 'a[1].b.c["d-d"].e'


ObjectPath.stringify(['a','1','b','c','d-d','e'],"'", true);
// => "['a']['1']['b']['c']['d-d']['e']"

Normalize a Path

ObjectPath.normalize(str, [quote="'"], [forceQuote=false])

var ObjectPath = require('objectpath');

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g');
// => "a[1].b.c.d.e['f-f'].g"

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g', '"');
// => 'a[1].b.c.d.e["f-f"].g'

ObjectPath.normalize('a[1].b.c.d["e"]["f-f"].g', "'", true);
// => "['a']['1']['b']['c']['d']['e']['f-f']['g']"

Keywords

FAQs

Package last updated on 21 Jan 2020

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