1.1.0 • Published 4 years ago
ginlibs-set-key v1.1.0
ginlibs-set-key
ginlibs-set-key
可以通过路径字符串读取或修改 object 的内层的值
使用例子
import { setKey, getKey } from 'ginlibs-set-key'
const obj = {}
setKey('a.b[0]', 1, obj)
// obj 的值变成
// {
// a: {
// b: [1],
// },
// }
getKey('a.b[0]', obj)
// 得到值 1API
setKey(key, val, obj)
key是赋值的路径val是要赋予的值obj是要处理的对象
setKey('a.b[0]', 1, obj)getKey(key, obj)
key是赋值的路径obj是要处理的对象
getKey('a.b[0]', obj)Test Report
Tests are using jest, to run the tests use:
$ npm run test:covreport detail
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 95 | 100 | 100 |
index.ts | 100 | 95 | 100 | 100 | 19,50
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 4.053 s
Ran all test suites.License
MIT