Home Reference Source Test

Function

Static Public Summary
public

simpleDeepAssign(target: Object, source: Object, rest: ...Object)

Recursively copy the values of all enumerable own properties from a source item or more to a target item if the both items are objects

Static Private Summary
private

deepAssign(target: Object, source: Object)

Recursively copy the values of all enumerable own properties from a source item to a target item if the both items are objects

private

deepAssignObject(target: Object, source: Object)

Recursively copy the values of all enumerable own properties from a source object to a target object

private

isArray(item: *): boolean

Check if it is an array

private

isObject(item: *): boolean

Check if it is an object

Static Public

public simpleDeepAssign(target: Object, source: Object, rest: ...Object) source

import simpleDeepAssign from 'simple-deep-assign/simple-deep-assign/index.js'

Recursively copy the values of all enumerable own properties from a source item or more to a target item if the both items are objects

Params:

NameTypeAttributeDescription
target Object

a target object

source Object

a source object

rest ...Object
  • optional

the rest of source objects

Example:

simpleDeepAssign({ a: 'a' }, { b: 'b' }, { c: [ 1, 2 ] }, { d: { a: 'a' } }, { d: { b: 'b' } });
// { a: 'a', b: 'b', c: [ 1, 2 ], d: { a: 'a', b: 'b' } }

Static Private

private deepAssign(target: Object, source: Object) source

Recursively copy the values of all enumerable own properties from a source item to a target item if the both items are objects

Params:

NameTypeAttributeDescription
target Object

a target object

source Object

a source object

Example:

deepAssign({ a: 'a', b: 'b' }, { b: 'B', c: 'c' });
// { a: 'a', b: 'B', c: 'c' }

private deepAssignObject(target: Object, source: Object) source

Recursively copy the values of all enumerable own properties from a source object to a target object

Params:

NameTypeAttributeDescription
target Object

a target object

source Object

a source object

Example:

deepAssignObject({ a: 'a', b: 'b' }, { b: 'B', c: 'c' });
// { a: 'a', b: 'B', c: 'c' }

private isArray(item: *): boolean source

Check if it is an array

Params:

NameTypeAttributeDescription
item *

an item to check

Return:

boolean

array or not

Example:

isArray([0, 1, 2]) // true

private isObject(item: *): boolean source

Check if it is an object

Params:

NameTypeAttributeDescription
item *

an item to check

Return:

boolean

object or not

Example:

isObject({ a: 'a' }) // true