https://github.com/brickifyjs/module-get-object-by-path
Find an object by giving it a path with or without context
https://github.com/brickifyjs/module-get-object-by-path
bricksjs browser javascript module nodejs object path string
Last synced: about 14 hours ago
JSON representation
Find an object by giving it a path with or without context
- Host: GitHub
- URL: https://github.com/brickifyjs/module-get-object-by-path
- Owner: brickifyjs
- License: mit
- Created: 2017-09-26T22:47:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-10T19:12:20.000Z (over 8 years ago)
- Last Synced: 2024-08-09T02:36:44.410Z (almost 2 years ago)
- Topics: bricksjs, browser, javascript, module, nodejs, object, path, string
- Language: JavaScript
- Homepage: https://m-gobp.js.brickify.io
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Module Get object by path
> Find an object by giving it a path with or without context. \
Returns an object containing information about the object and paths.
## Statistics
[](https://github.com/brickifyjs/module-get-object-by-path)
[](https://www.npmjs.com/package/@brickify/m-gobp)
## Social
[](https://github.com/brickifyjs/module-get-object-by-path)
[](https://github.com/brickifyjs/module-get-object-by-path)
[](https://github.com/brickifyjs/module-get-object-by-path)
[](https://gitter.im/brickifyjs/module-get-object-by-path)
## Project Health
[](https://travis-ci.org/brickifyjs/module-get-object-by-path)
[](https://codecov.io/gh/brickifyjs/module-get-object-by-path)
[](https://www.bithound.io/github/brickifyjs/module-get-object-by-path/master/dependencies/npm)
[](https://www.bithound.io/github/brickifyjs/module-get-object-by-path/master/dependencies/npm)
[](https://m-gobp.js.brickify.io)
## Install
```bash
$ npm install @brickify/m-gobp
```
## Usage
```js
var getObject = require('@brickify/m-gobp');
var context = {
foo: {
bar: {
baz: function() {
}
}
}
};
// Use defined context
getObject('foo.bar.baz', context);
process.foo = {
bar: {
baz: function() {
}
}
};
// Use global context
getObject('foo.bar.baz');
```
## Returns
```js
{
context: object|process|global|window,
object: {
decomposed: [...objects],
first: object|process|global|window,
last: End object value,
parent: End parent object
},
paths: {
decomposed: [...paths],
first: first path,
last: End parent object path
}
}
```