Home Reference Source Repository

Function

Static Public Summary
public

get(obj: Object, path: string | string[]): Object

The shorthand to getPropertyByPath

public

Get specific property by path.

public

Get specific object property by path list.

public

getPropertyByPathString(obj: Object, path: stirng): Object

Get specific property by path string.

public

remove(obj: Object, path: string | string[]): boolean

The shorthand to removePropertyByPath

public

Delete specific property by path.

public

Remove specific object property by path list.

public

Remove specific object property by path string.

public

set(obj: Object, path: string | string[], value: Object): boolean

The shorthand to setPropertyByPath

public

setPropertyByPath(obj: Object, path: string | string[], value: Object): boolean

Set specific property by path.

public

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

The shorthand to getPropertyByPath

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

Return:

Object

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

Return:

Object

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string[]

path list

Return:

Object

specific object property

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:

NameTypeAttributeDescription
obj Object

target object

path stirng

path string

Return:

Object

specific object property

Example:

let obj = {
  a: ['hello']
}
getPropertyByPathString(obj, 'a[0]') // hello

public remove(obj: Object, path: string | string[]): boolean source

The shorthand to removePropertyByPath

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

Return:

boolean

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

Return:

boolean

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string[]

path list

Return:

boolean

always return true

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().

Params:

NameTypeAttributeDescription
obj Object

target object

path string

path string

Return:

boolean

always return true

Example:

let obj = {
  a: ['hello']
}
removePropertyByPathString(obj, 'a[0]')
obj.a // []

public set(obj: Object, path: string | string[], value: Object): boolean source

The shorthand to setPropertyByPath

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

value Object

the value will be assigned

Return:

boolean

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string | string[]

path

value Object

the value will be assigned

Return:

boolean

specific object property

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.

Params:

NameTypeAttributeDescription
obj Object

target object

path string[]

path list

value Object

the value will be assigned

Return:

boolean

return true when no exception

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().

Params:

NameTypeAttributeDescription
obj Object

target object

path stirng

path string

value Object

the value will be assigned

Return:

boolean

return true when no exception

Example:

let obj = {
  a: ['hello']
}
setPropertyByPathString(obj, 'a[1]', 'world')
obj.a // ['hello', 'world']