mini-object-path
v1.0.2
Published
A small lib for get or set object via path
Downloads
4
Maintainers
Readme
Simple Object Path
A small lib for get or set object via path
Advantage
- less than 50rows
- only 1 ko size
✨ Installation
npm i mini-object-path
🚀 Usage
var miniObjectPath = require("mini-object-path")
var obj = {
0: 100,
a: 0,
b: {
c: 'c1',
d: {
'abd': '2',
'ee': 'ff'
},
'd.0': {
'd.1': 'd1'
},
5: 'v5',
6: {
'6': 56
}
}
}
miniObjectPath.get(obj, 0) // 100
miniObjectPath.get(obj, 1) // undefined
miniObjectPath.get(obj, ['b', '6', 6]) // 56
miniObjectPath.set(obj, 1, 'value')
miniObjectPath.get(obj, 1) // 'value'
miniObjectPath.set(obj, ['b', '6', 6], '85')
miniObjectPath.get(obj, ['b', '6', 6]) // '85'
🐛 Bugs
If any bugs are found please report them as a Github Issue