Skip to content
Adam Smith edited this page Mar 3, 2016 · 10 revisions

vitals.remap npm version

Method Section Alias
remap base
remap.object base remap.obj
remap.array base remap.arr
remap.string base remap.str

remap

A shortcut for making a new object/array/string by invoking an action over the values of an existing object/array/string.

Examples

Params

  1. source !(Object|function|Array|string)
  2. iteratee *
Details per source type:
  - object: The iteratee must be a function with the optional params - value, key, source. Note this method lazily clones the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  - array: The iteratee must be a function with the optional params - value, index, source. Note this method lazily slices the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  - string: The iteratee must be a pattern to search for within the source. If the pattern is not a string or RegExp it will be converted to a string.
  1. replacement *=
Only use (and required) with string sources. If not a string or function the replacement is converted to a string. For details about using replacement functions see the [String.prototype.replace function param](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter).
  1. thisArg Object=
If thisArg is supplied the iteratee or replacement function is bound to its value.

Returns !(Object|function|Array|string)

remap.object

A shortcut for making a new object with the same keys and new values by invoking an action over the values of an existing object.

Examples

Params

  1. source !(Object|function)
  2. iteratee function(*=, string=, !(Object|function)=)
The iteratee must be a function with the optional params - value, key, source. Note this method lazily clones the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  1. thisArg Object=
If thisArg is supplied the iteratee is bound to its value.

Returns !Object

remap.array

A shortcut for making a new array by invoking an action over the values of an existing array-like object.

Examples

Params

  1. source (!Object|function|string)
If source is a string it is converted to an array using one of the following values as the separator (values listed in order of rank):
  - `", "`
  - `","`
  - `"|"`
  - `" "`
  1. iteratee function(*=, number=, !Array=)=
The iteratee must be a function with the optional params - value, index, source. Note this method lazily slices the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  1. thisArg Object=
If thisArg is supplied the iteratee is bound to its value.

Returns !Array

remap.string

A shortcut for String.prototype.replace that defaults to global replacements instead of only the first.

Examples

Params

  1. source string
  2. pattern *
If not a RegExp the pattern is converted to a string.
  1. replacement *
If not a string or function the replacement is converted to a string. For details about using replacement functions see [String.prototype.replace function param](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter).
  1. thisArg Object=
If thisArg is supplied the replacement function is bound to its value.

Returns string

-- Happy Developing,

Algorithm IV Logo

Clone this wiki locally