Global

Methods

child(input, object, indexopt) → {*}

Retrieve the nth child from an Array
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
index int <optional>
index to retrieve (default: 0)
Source:
Returns:
retrieved element
Type
*
Example
child(4) // =>
child(true) // =>
child(Infinity) // =>
child(null) // =>
child() // =>
child(NaN) // =>
child(4.5) // =>
child([3, 4, 5]) // => 3
child('hello') // => 'h'
child({answer: 42}) // =>
child(function () {}) // =>
child([4, 3, 4, 3], {}, 3) // => 3
child([4, 3, 4, 3], {}, 5) // =>
child([4, 3, 4, 3], {}, -2) // => 4

compact(input) → {Array}

Remove falsey values (ie. false, null, 0, "", undefined, NaN)
Parameters:
Name Type Description
input * current value
Source:
Returns:
Array without falsey values
Type
Array
Example
compact(4) // => []
compact(true) // => []
compact(Infinity) // => []
compact(null) // => []
compact() // => []
compact(NaN) // => []
compact(4.5) // => []
compact([3, 4, 5]) // => [3, 4, 5]
compact('hello') // => ['h', 'e', 'l', 'l', 'o']
compact({answer: 42}) // => []
compact(function () {}) // => []
compact([false, 0, null, , '', NaN, 1]) // => [1]

concat(input, object, valueopt) → {Array}

Concatanate/append/push a new value onto input value to return an Array
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
value * <optional>
value to concatenate/append/push
Source:
Returns:
new Array with value concatanated, appended or pushed
Type
Array
Example
concat(4) // => [4]
concat(true) // => [true]
concat(Infinity) // => [Infinity]
concat(null) // => [null]
concat() // => [undefined]
concat(NaN) // => [NaN]
concat(4.5) // => [4.5]
concat([3, 4, 5]) // => [3, 4, 5]
concat('hello') // => ['hello']
concat({answer: 42}) // => [{answer: 42}]
concat(function () {}) // => [function () {}]
concat([1], {}, 4) // => [1, 4]
concat(1, {}, 4) // => [1, 4]
concat('hello', {}, 4) // => ['hello', 4]
concat([1], {}, true) // => [1, true]
concat([1], {}, {answer: 42}) // => [1, {answer: 42}]

filter(input, object, func) → {Array}

Loop through elements of an Array and filter out values
Parameters:
Name Type Description
input * current value
object Object input object into mapper
func function function to execute on each element
Source:
Returns:
Array with elements filtered out
Type
Array
Example
filter([3, -4, -5], {}, function (a) { return a > 0; }) // => [3]
filter('hello', {}, function (a) { return a === 'l'; }) // => ['l', 'l']

find(input, object, match) → {Object}

Find a match in an Array of Objects
Parameters:
Name Type Description
input * current value
object Object input object into mapper
match * match to look for
Source:
Returns:
matched element
Type
Object
Example
find([{a: 3}, {a: 4}, {b: 5}], {}, 'a') // => {a: 3}
find([{a: 3}, {a: 4}, {b: 5}], {}, {b: 5}) // => {b: 5}
find([{a: 3}, {a: 4}, {b: 5}], {}, {b: 2}) // =>

findWhere(input, object, match) → {Array}

Find all matches in an Array of Objects
Parameters:
Name Type Description
input * current value
object Object input object into mapper
match * match to look for
Source:
Returns:
matched elements
Type
Array
Example
findWhere([{a: 3}, {a: 4}, {b: 5}], {}, 'a') // => [{a: 3}, {a: 4}]
findWhere([{a: 3}, {a: 4}, {b: 5}], {}, {a: 3}) // => [{a: 3}]
findWhere([{a: 3}, {a: 4}, {b: 5}], {}, {a: 1}) // => []

flatten(input, object, flattenDeepopt) → {Array}

Flatten an input Array
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
flattenDeep boolean <optional>
whether to flatten recursively or not (default: false)
Source:
Returns:
flattened Array
Type
Array
Example
flatten(4) // => []
flatten(true) // => []
flatten(Infinity) // => []
flatten(null) // => []
flatten() // => []
flatten(NaN) // []
flatten(4.5) // => []
flatten([3, 4, 5]) // => [3, 4, 5]
flatten('hello') // => ['h', 'e', 'l', 'l', 'o']
flatten({answer: 42}) // => []
flatten(function () {}) // => []
flatten([[3], [[4], 5], [[[[[6]]]]]]) // => [3, [4], 5, [[[[6]]]]]
flatten([[3], [[4], 5], [[[[[6]]]]]], {}, true) // => [3, 4, 5, 6]

get(input, object, path, defaultValueopt) → {*}

Retrieve a value from the mapping object
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
path string flattened path to retrieve
defaultValue * <optional>
value to default to if path not found
Source:
Returns:
retrieved value
Type
*
Example
get(null, {a: {b: {c: {d: [0, 2]}}}}, 'a.b.c.d.1') // => 2
get(null, {a: {b: {c: {d: [0, 2]}}}}, 'a.b.c.d.e.3') // =>
get(null, {a: {b: {c: {d: [0, 2]}}}}, 'a.b.c.d.e.3', 42) // => 42

join(input, object, joinTokenopt) → {string}

Join an Array together given a joinToken
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
joinToken string <optional>
a token to join values together
Source:
Returns:
joined value
Type
string
Example
join(4) // => ''
join(true) // => ''
join(Infinity) // => ''
join(null) // => ''
join() // => ''
join(NaN) // => ''
join(4.5) // => ''
join([3, 4, 5]) // => '345'
join('hello') // => 'hello'
join({answer: 42}) // => ''
join(function () {}) // => ''
join([1, 4, 5], {}, '-') // => '1-4-5'

length(input) → {int}

Get the length of an Array or string else return 0
Parameters:
Name Type Description
input * current value
Source:
Returns:
length of the input Array or 0
Type
int
Example
length(4) // => 0
length(true) // => 0
length(Infinity) // => 0
length(null) // => 0
length() // => 0
length(NaN) // => 0
length(4.5) // => 0
length([3, 4, 5]) // => 3
length('hello') // => 5
length({answer: 42}) // => 0
length(function () {}) // => 0

map(input, object, func) → {Array}

Loop through all the elements of an Array
Parameters:
Name Type Description
input * current value
object Object input object into mapper
func function function to execute on each element
Source:
Returns:
Array with each element executed with input function
Type
Array
Example
map([3, 4, 5], {}, function (a) { return a + 2; }) // => [5, 6, 7]
map('hello', {}, function (a) { return a + '^'; }) // => ['h^', 'e^', 'l^', 'l^', 'o^']

reduce(input, object, func, initial) → {*}

Loop through elements of an Array and reduce to a single value
Parameters:
Name Type Description
input * current value
object Object input object into mapper
func function function to execute on each element
initial * initial value into reducer
Source:
Returns:
reduced value
Type
*
Example
reduce([3, 4, 5], {}, function (p, v) { return p + v; }, 0) // => 12
reduce([3, 4, 5], {}, function (p, v) { return p + v; }, 10) // => 22
reduce('hello', {}, function (p, v) { return p + v; }, 'world ') // => 'world hello'

reverse(input) → {Array}

Reverse the values in an Array
Parameters:
Name Type Description
input Array current value
Source:
Returns:
reversed Array
Type
Array
Example
reverse([3, 4, 5]) // => [5, 4, 3]
reverse(['hello', 'world', '!']) // => ['!', 'world', 'hello']
reverse({answer: 42, me: 2}) // => {answer: 42, me: 2}

set(input, object, setValue) → {*}

Set a new value
Parameters:
Name Type Description
input * current value
object Object input object into mapper
setValue * new value
Source:
Returns:
same as setValue
Type
*
Example
set(null, {}, 42) // => 42
set() // =>

slice(input, object, startopt, endopt) → {Array}

Slice values from an Array
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
start int <optional>
starting point for slicing (default: 0)
end int <optional>
endpoing for slicing
Source:
Returns:
sliced Array
Type
Array
Example
slice(4) // => []
slice(true) // => []
slice(Infinity) // => []
slice(null) // => []
slice() // => []
slice(NaN) // => []
slice(4.5) // => []
slice([3, 4, 5]) // => [3, 4, 5]
slice('hello') // => ['h', 'e', 'l', 'l', 'o']
slice({answer: 42}) // => []
slice(function () {}) // => []
slice([1, 4, 5], {}, 1, 1) // => []
slice([1, 4, 5], {}, 1, 2) // => [4]
slice([1, 4, 5], {}, 0, -1) // => [1, 4]

sort(input, object, func) → {Array}

Loop through elements to sort them
Parameters:
Name Type Description
input * current value
object Object input object into mapper
func function function to execute on each element
Source:
Returns:
sorted Array
Type
Array
Example
sort(4) // => 4
sort(true) // => true
sort(Infinity) // => Infinity
sort(null) // =>
sort() // =>
sort(NaN) // => NaN
sort(4.5) // => 4.5
sort('hello') // => 'hello'
sort([300, 4, 15]) // => [15, 300, 4]
sort([300, 4, 15], {}, function (a, b) { return a - b; }) // => [4, 15, 300]
sort([300, 4, 15], {}, function (a, b) { return b - a; }) // => [300, 15, 4]
sort([300, 4, 15], {}, function (a, b) { return b - a; }) // => [300, 15, 4]
sort(['h', 'e', 'l', 'l', 'o']) // => ['e', 'h', 'l', 'l', 'o']

stringify(input) → {string}

Stringify a value using JSON.stringify
Parameters:
Name Type Description
input * current value
Source:
Returns:
new string value
Type
string
Example
stringify(4) // => '4'
stringify(true) // => 'true'
stringify(Infinity) // => 'null'
stringify(null) // => 'null'
stringify() // =>
stringify(NaN) // => 'null'
stringify(4.5) // => '4.5'
stringify([3.1, 4.2, 5.3]) // => '[3.1,4.2,5.3]'
stringify('Hello World!') // => '"Hello World!"'
stringify({answer: 42}) // => '{"answer":42}'
stringify(function () {}) // =>

sum(input) → {int|float}

Sum up elements in an Array
Parameters:
Name Type Description
input * current value
Source:
Returns:
sum of elements in Array
Type
int | float
Example
sum(4) // => 0
sum(true) // => 0
sum(Infinity) // => 0
sum(null) // => 0
sum() // => 0
sum(NaN) // 0
sum(4.5) // => 0
sum([3, 4, 5]) // => 12
sum('hello') // => 'hello'
sum({answer: 42}) // => 0
sum(function () {}) // => 0

toArray(input) → {Array}

Convert a value to an Array, if it is not already an Array
Parameters:
Name Type Description
input * current value
Source:
Returns:
new Array value
Type
Array
Example
toArray(4) // => [4]
toArray(true) // => [true]
toArray(Infinity) // => [Infinity]
toArray(null) // => [null]
toArray() // => [undefined]
toArray(NaN) // => [NaN]
toArray(4.5) // => [4.5]
toArray([3.1, 4.2, 5.3]) // => [3.1, 4.2, 5.3]
toArray('Hello World!') // => ['Hello World!']
toArray({answer: 42}) // => [{answer: 42}]
toArray(function () {}) // => [function () {}]

toBool(input) → {boolean}

Convert a value to boolean
Parameters:
Name Type Description
input * current value
Source:
Returns:
new boolean value
Type
boolean
Example
toBool(4) // => true
toBool(true) // => true
toBool(Infinity) // => true
toBool(null) // => false
toBool() // => false
toBool(NaN) // => false
toBool(4.5) // => true
toBool([3.1, 4.2, 5.3]) // => true
toBool('Hello World!') // => true
toBool({answer: 42}) // => true
toBool(function () {}) // => true
toBool(0) // => false
toBool(-1) // => true
toBool(0.0) // => false
toBool(-1.0) // => true

toFloat(input) → {float}

Convert a value to float
Parameters:
Name Type Description
input * current value
Source:
Returns:
new float value
Type
float
Example
toFloat(4) // => 4
toFloat(true) // => NaN
toFloat(Infinity) // => Infinity
toFloat(null) // => NaN
toFloat() // => NaN
toFloat(NaN) // => NaN
toFloat(4.5) // => 4.5
toFloat([3.1, 4.2, 5.3]) // => 3.1
toFloat('Hello World!') // => NaN
toFloat({answer: 42}) // => NaN
toFloat(function () {}) // => NaN

toInt(input, object, radixopt) → {int}

Convert a value to integer, with a radix
Parameters:
Name Type Attributes Description
input * current value
object Object input object into mapper
radix int <optional>
radix to be applied on integer conversion (default: 10)
Source:
Returns:
new integer value
Type
int
Example
toInt(4) // => 4
toInt(true) // => NaN
toInt(Infinity) // => NaN
toInt(null) // => NaN
toInt() // => NaN
toInt(NaN) // NaN
toInt(4.5) // => 4
toInt([3.1, 4.2, 5.3]) // => 3
toInt('Hello World!') // => NaN
toInt({answer: 42}) // => NaN
toInt(function () {}) // => NaN

toObject(input, object) → {Object}

Convert a value to an Object, by using JSON.parse
Parameters:
Name Type Description
input * current value
object Object input object into mapper
Source:
Returns:
new Object value
Type
Object
Example
toObject(4) // => 4
toObject(true) // => true
toObject(4.5) // => 4.5
toObject('{"answer":42}') // => {answer: 42}

toStr(input) → {string}

Convert a value to string
Parameters:
Name Type Description
input * current value
Source:
Returns:
new string value
Type
string
Example
toStr(4) // => '4'
toStr(true) // => 'true'
toStr(Infinity) // => 'Infinity'
toStr(null) // => 'null'
toStr() // => 'undefined'
toStr(NaN) // 'NaN'
toStr(4.5) // => '4.5'
toStr([3, 4, 5]) // => '3,4,5'
toStr('Hello World!') // => 'Hello World!'
toStr({answer: 42}) // => '[object Object]'
toStr(function () {}) // => 'function () {}'

unique(input) → {Array}

Retrive only unique values from an Array
Parameters:
Name Type Description
input * current value
Source:
Returns:
set of unique elements
Type
Array
Example
unique(4) // => []
unique(true) // => []
unique(Infinity) // => []
unique(null) // => []
unique() // => []
unique(NaN) // []
unique(4.5) // => []
unique([3, 4, 5]) // => [3, 4, 5]
unique('hello') // => ['h', 'e', 'l', 'o']
unique({answer: 42}) // => []
unique(function () {}) // => []
unique([4, 3, 4, 2, [3]]) // => [4, 3, 2, [3]]