Debian Codegraph @

readme.md

raw symbols SCIP
1 ObjectPath
2 ==========
3
4 [![Join the chat at https://gitter.im/mike-marcacci/objectpath](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mike-marcacci/objectpath?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
6 [![Build Status](https://travis-ci.org/mike-marcacci/objectpath.svg?branch=master)](https://travis-ci.org/mike-marcacci/objectpath)
7
8 Parse js object paths using both dot and bracket notation. Stringify an array of properties into a valid path.
9
10 - parse JS object reference fragments
11 - build JS object reference fragments
12 - supports presence of unicode characters
13 - supports presence of control characters in key names
14
15 Parse a Path
16 ------------
17
18 ObjectPath.parse(str)
19
20 ```js
21 var ObjectPath = require('objectpath');
22
23 ObjectPath.parse('a[1].b.c.d["e"]["f"].g');
24 // => ['a','1','b','c','d','e','f','g']
25 ```
26
27 Build a Path String
28 -------------------
29
30 ObjectPath.stringify(arr, [quote='\'']);
31
32 ```js
33 var ObjectPath = require('objectpath');
34
35 ObjectPath.stringify(['a','1','b','c','d','e','f','g']);
36 // => '[\'a\'][\'1\'][\'b\'][\'c\'][\'d\'][\'e\'][\'f\'][\'g\']'
37
38
39 ObjectPath.stringify(['a','1','b','c','d','e','f','g'],'"');
40 // => '["a"]["1"]["b"]["c"]["d"]["e"]["f"]["g"]'
41 ```
42
43 Normalize a Path
44 ----------------
45
46 ObjectPath.normalize(str)
47
48 ```js
49 var ObjectPath = require('objectpath');
50
51 ObjectPath.normalize('a[1].b.c.d["e"]["f"].g');
52 // => '["a"]["1"]["b"]["c"]["d"]["e"]["f"]["g"]'