Function
Static Public Summary | ||
public |
The shorthand to getPropertyByPath |
|
public |
getPropertyByPath(obj: Object, path: string | string[]): Object Get specific property by path. |
|
public |
getPropertyByPathList(obj: Object, path: string[]): Object Get specific object property by path list. |
|
public |
getPropertyByPathString(obj: Object, path: stirng): Object Get specific property by path string. |
|
public |
The shorthand to removePropertyByPath |
|
public |
removePropertyByPath(obj: Object, path: string | string[]): boolean Delete specific property by path. |
|
public |
removePropertyByPathList(obj: Object, path: string[]): boolean Remove specific object property by path list. |
|
public |
removePropertyByPathString(obj: Object, path: string): boolean Remove specific object property by path string. |
|
public |
The shorthand to setPropertyByPath |
|
public |
Set specific property by path. |
|
public |
setPropertyByPathList(obj: Object, path: string[], value: Object): boolean Set specific object property by path list. |
|
public |
setPropertyByPathString(obj: Object, path: stirng, value: Object): boolean Set specific property by path string. |
Static Public
public get(obj: Object, path: string | string[]): Object source
import {get} from 'object-path-operator/src/object-path-operator.js'
The shorthand to getPropertyByPath
public getPropertyByPath(obj: Object, path: string | string[]): Object source
import {getPropertyByPath} from 'object-path-operator/src/object-path-operator.js'
Get specific property by path. Automatically match getPropertyByPathList or getPropertyByPathString.
public getPropertyByPathList(obj: Object, path: string[]): Object source
import {getPropertyByPathList} from 'object-path-operator/src/object-path-operator.js'
Get specific object property by path list.
Example:
let obj = {
a: ['hello']
}
getPropertyByPathList(obj, ['a', '0']) // hello
public getPropertyByPathString(obj: Object, path: stirng): Object source
import {getPropertyByPathString} from 'object-path-operator/src/object-path-operator.js'
Get specific property by path string. Path string parsed by eval().
Params:
Name | Type | Attribute | Description |
obj | Object | target object |
|
path | stirng | path string |
Example:
let obj = {
a: ['hello']
}
getPropertyByPathString(obj, 'a[0]') // hello
public remove(obj: Object, path: string | string[]): boolean source
import {remove} from 'object-path-operator/src/object-path-operator.js'
The shorthand to removePropertyByPath
public removePropertyByPath(obj: Object, path: string | string[]): boolean source
import {removePropertyByPath} from 'object-path-operator/src/object-path-operator.js'
Delete specific property by path. Automatically match removePropertyByPathList or removePropertyByPathString.
public removePropertyByPathList(obj: Object, path: string[]): boolean source
import {removePropertyByPathList} from 'object-path-operator/src/object-path-operator.js'
Remove specific object property by path list.
Example:
let obj = {
a: ['hello']
}
removePropertyByPathList(obj, ['a', '0'])
obj.a // []
public removePropertyByPathString(obj: Object, path: string): boolean source
import {removePropertyByPathString} from 'object-path-operator/src/object-path-operator.js'
Remove specific object property by path string. Path string parsed by eval().
Example:
let obj = {
a: ['hello']
}
removePropertyByPathString(obj, 'a[0]')
obj.a // []
public set(obj: Object, path: string | string[], value: Object): boolean source
import {set} from 'object-path-operator/src/object-path-operator.js'
The shorthand to setPropertyByPath
public setPropertyByPath(obj: Object, path: string | string[], value: Object): boolean source
import {setPropertyByPath} from 'object-path-operator/src/object-path-operator.js'
Set specific property by path. Automatically match setPropertyByPathList or setPropertyByPathString.
public setPropertyByPathList(obj: Object, path: string[], value: Object): boolean source
import {setPropertyByPathList} from 'object-path-operator/src/object-path-operator.js'
Set specific object property by path list.
Example:
let obj = {
a: ['hello']
}
setPropertyByPathList(obj, ['a', '1'], 'world')
obj.a // ['hello', 'world']
public setPropertyByPathString(obj: Object, path: stirng, value: Object): boolean source
import {setPropertyByPathString} from 'object-path-operator/src/object-path-operator.js'
Set specific property by path string. Path string parsed by eval().
Example:
let obj = {
a: ['hello']
}
setPropertyByPathString(obj, 'a[1]', 'world')
obj.a // ['hello', 'world']