Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damianc/obj-path
Getting object property by a path string.
https://github.com/damianc/obj-path
javascript object-path object-property
Last synced: about 1 month ago
JSON representation
Getting object property by a path string.
- Host: GitHub
- URL: https://github.com/damianc/obj-path
- Owner: damianc
- Created: 2022-09-29T12:11:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-29T12:27:08.000Z (over 2 years ago)
- Last Synced: 2024-10-31T14:12:50.674Z (2 months ago)
- Topics: javascript, object-path, object-property
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `ObjPath`
Getting object property by a path string.
## Installation
```
npm i @damianc/obj-path
```## Use
```
const obj = {
foo: {
bar: [10, 20, 30, 40]
}
}ObjPath(obj, 'foo.bar[1]')
// 20
``````
const obj = {
foo: {
bar: [
120,
{ baz: [{
quux: 200
}] }
]
}
};ObjPath(obj, 'foo.bar[1].baz[0].quux')
// 200
``````
const obj = {
foo: [1, 2, [3, 4]]
};ObjPath(obj, 'foo[2][0]')
// 3
```