-
Notifications
You must be signed in to change notification settings - Fork 1
vitals.remap
Adam Smith edited this page Mar 1, 2016
·
10 revisions
Method | Section | Alias |
---|---|---|
remap | base | |
remap.object | base | remap.obj |
remap.array | base | remap.arr |
remap.string | base | remap.str |
A shortcut for making a new object/array/string by invoking an action over the values of an existing object/array/string.
Params
-
source
!(Object|function|Array|string)
-
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.
-
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).
-
thisArg
Object=
If thisArg is supplied the iteratee or replacement function is bound to its value.
Returns !(Object|function|Array|string)
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.
Params
-
source
!(Object|function)
-
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).
-
thisArg
Object=
If thisArg is supplied the iteratee is bound to its value.
Returns !Object
A shortcut for making a new array by invoking an action over the values of an existing array-like object.
Params
-
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):
- `", "`
- `","`
- `"|"`
- `" "`
-
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).
-
thisArg
Object=
If thisArg is supplied the iteratee is bound to its value.
Returns !Array
A shortcut for String.prototype.replace that defaults to global replacements instead of only the first.
Params
-
source
string
-
pattern
*
If not a RegExp the pattern is converted to a string.
-
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).
-
thisArg
Object=
If thisArg is supplied the replacement function is bound to its value.
Returns string
-- Happy Developing,