Skip to content
Adam Smith edited this page Feb 20, 2016 · 9 revisions

vitals.fuse npm version

Method Section Alias
fuse base
fuse.value base fuse.val
fuse.value.start base fuse.value.top
fuse.object base fuse.obj
fuse.array base fuse.arr
fuse.string base fuse.str

fuse

Merges objects, concatenates arrays, appends properties, and combines strings.

Examples

Params

  1. dest !(Object|function|Array|string)
  2. vals ...*
All rules occur in order of appearance. For object and array dest types `null` is skipped. Remaining details per dest type:
  - object: If only one val is provided and it is an array it is considered an array of vals. Object vals are merged with the dest. All other values are converted to strings and appended as new keys (if the key exists on the dest the property's value is replaced with undefined).
  - array: Array vals are concatenated to the dest. All other values are pushed to the dest.
  - string: If only one val is provided and it is an array it is considered an array of vals. All non-string vals are converted to strings and appended to the dest.

Returns !(Object|function|Array|string)

fuse.value

Appends properties and combines strings.

Examples

Params

  1. dest !(Object|function|Array|string)
  2. vals ...*
Details per dest type:
  - object: All vals are converted to strings and appended as new keys (if the key exists on the dest the property's value is replaced with undefined).
  - array: All vals are pushed to the dest.
  - string: All vals are converted to strings and appended to the dest.

Returns !(Object|function|Array|string)

fuse.value.start

Appends properties and combines strings to the start of their destination.

Examples

Params

  1. dest !(Object|function|Array|string)
  2. vals ...*
Details per dest type:
  - object: All vals are converted to strings and appended as new keys (if the key exists on the dest the property's value remains unchanged).
  - array: All vals are unshifted to the dest.
  - string: All vals are converted to strings and appended to the beginning of the dest.

Returns !(Object|function|Array|string)

fuse.object

Appends properties/keys to an object.

Examples

Params

  1. dest !(Object|function)
  2. vals ...*
Any vals that are `null` are skipped. All other vals that are not objects are converted to a string and appended as new keys (if the key exists on the dest the key's value is replaced with undefined). If only one val is provided and it is an array then it is considered an array of vals. All object vals are merged with the dest (if the key exists on the dest the key's value is with replaced with the value from the merged object).

Returns !(Object|function)

fuse.array

Appends values to an array and concatenates arrays.

Examples

Params

  1. dest !Array
  2. vals ...*
Details per val type:
  - null:  All null vals are skipped.
  - array: All array vals are concatenated to the dest.
  - other: All other vals are pushed to the dest array.

Returns !Array

fuse.string

Appends strings to a string.

Examples

Params

  1. dest string
  2. vals ...*
All non-string vals are converted to strings.

Returns string

-- Happy Developing,

Algorithm IV Logo

Clone this wiki locally