https://github.com/obsius/quick-seek
Resolve to an object property.
https://github.com/obsius/quick-seek
Last synced: over 1 year ago
JSON representation
Resolve to an object property.
- Host: GitHub
- URL: https://github.com/obsius/quick-seek
- Owner: obsius
- Created: 2020-02-01T05:20:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-19T23:23:12.000Z (over 5 years ago)
- Last Synced: 2025-02-18T07:37:47.707Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Quick Seek
Quick object property resolution. Seek path supports string, array, or number.
No type of property checks.
## Example
```js
import seek from 'quick-seek';
let x = {
y: {
z: 20
},
yy: [1, 2]
};
console.log(get(x, 'y')); // returns y: { z: 20 }
console.log(set(x, 'key', 'value')); // x.key = value | returns x
console.log(get(x, 'y.z')); // returns 20
console.log(set(x, ['y', 'z'], true)); // x.y.z = true | returns x.y
console.log(get(x, 'yy.0')); // returns 1
console.log(get(x, ['yy', '1'])); // returns 2
console.log(set(x, 'y.yy.yyy', 'z')); // x.y.yy.yyy = z (will populate empty objects) | returns y.yy.yyy
```
## Contributing
Feel free to make changes and submit pull requests whenever.
## License
Quick Seek uses the [MIT](https://opensource.org/licenses/MIT) license.