Global

Methods

dp(path, obj) → {*}

Description:
  • Retrieve the value at a given nested dotted path.

Source:
Example
dp("a.b", {a: {b: 2}}); //=> 2
dp("a.b.", {c: {b: 2}}); //=> undefined
dp("a.b.0", {a: {b: [1, 2, 3]}}); //=> 1
dp("a.b.-2", {a: {b: [1, 2, 3]}}); //=> 2
Parameters:
Name Type Description
path String

The dotted path to use.

obj Object

The object to retrieve the nested property from.

Returns:

The data at path.

Type
*

dpEq(val, path, obj) → {Boolean}

Description:
  • Determines whether a dotted path on an object has a specific value, in R.equals terms. Most likely used to filter a list.

Source:
Example
const user1 = { address: { zipCode: 90210 } };
const user2 = { address: { zipCode: 55555 } };
const user3 = { name: 'Bob' };
const users = [ user1, user2, user3 ];
const isFamous = dpEq(90210, 'address.zipCode');
R.filter(isFamous, users); //=> [ user1 ]
Parameters:
Name Type Description
val *

The value to compare the nested property with

path String

The dotted path of the nested property to use

obj Object

The object to check the nested property in

Returns:

true if the value equals the nested object property, false otherwise.

Type
Boolean

dpOr(default, path, obj) → {*}

Description:
  • Retrieve the value at a given nested dotted path if it has a value otherwise return the default value.

Source:
Example
dpOr(1, "a.b", {a: {b: 2}}); //=> 2
dpOr(1, "a.b.", {c: {b: 2}}); //=> undefined
dpOr(1, "a.b.1", {a: {b: [1, 2, 3]}}); //=> 2
dpOr(1, "a.b.-2", {a: {b: [1, 2, 3]}}); //=> 2
Parameters:
Name Type Description
default *

The default value

path String

The dotted path to use.

obj Object

The object to retrieve the nested property from.

Returns:

The data at path if it has a value otherwise the default value.

Type
*

dpPluck(key, f) → {Array}

Description:
  • Returns a new list by plucking the same dotted path off all objects in the list supplied.

    pluck will work on any functor in addition to arrays, as it is equivalent to R.map(dp(k), f).

Source:
Example
dpPluck('name.first', [{name: { first: 'fred' }}, {name: { first: 'wilma'} }]); //=> ['fred', 'wilma']
Parameters:
Name Type Description
key String

The dotted path to pluck off of each object.

f Array

The array or functor to consider.

Returns:

The list of values for the given key.

Type
Array

intoArray(transformedArray, transformers) → {Array}

Description:
  • Is a shorthand for into([], compose(), arr ?? [])

Source:
Example
intoArray(map(i => i + 1), map(i => i * 2), [1, 2])
Parameters:
Name Type Description
transformedArray Array

The array to transform

transformers Array.<function()>

A list of functions to transform the input array

Returns:

The transformed input array

Type
Array

invokeMap(func, collection) → {*}

Description:
  • Invokes a function on each object in a collection and returns each result

Source:
Example
const objs = [{ test() { return "a" } }, { test() { return "b" } }];
invokeMap("test", objs); //=> ["a", "b"]
Parameters:
Name Type Description
func function

The function to invoke on each object in the collection.

collection Array

The collection to invoke

Returns:

An array of each result of invoking func on each item in collection

Type
*

leftJoin(rightComparedPath, rightCollection, leftComparedPath, leftCollection) → {Array}

Description:
  • Returns a list of tuples where the first item is the original item from the leftCollection and the second is is the object from the rightCollection that has a rightComparedPath value equal to the value at leftComparedPath

Source:
Example
const leftCollection = [{ a: "a", b: 2 }];
const rightCollection = [{ id: "a", c: 2 }];
const result = leftJoin("id", rightCollection, "a", leftCollection); //=> [[{ a: "a", b: 2 }, { id: "a", c: 2 }]]
Parameters:
Name Type Description
rightComparedPath String

The dotted path to compare to leftComparedPath on each rightCollection object.

rightCollection Array

The right side of the join

leftComparedPath String

The dotted path to compare on each leftCollection object.

leftCollection Array

The left side of the join

Returns:

A list of tuples where the first item is the original item from the leftCollection and the second is the joined item

Type
Array

maxOf(func, collection) → {Number}

Description:
  • Returns the largest value for a function applied to a collection of objects

Source:
Example
maxOf(prop("a"), [{ a: 2 }, { a: 1 }, { a: null }]); //=> 2
Parameters:
Name Type Description
func function

The function to apply to each object in the collection.

collection Array

The collection to check

Returns:

The largest value returned by applying func to each object in collection.

Type
Number

minOf(func, collection) → {Number}

Description:
  • Returns the smallest value for a function applied to a collection of objects

Source:
Example
minOf(prop("a"), [{ a: 2 }, { a: 1 }, { a: null }]); //=> 1
Parameters:
Name Type Description
func function

The function to apply to each object in the collection.

collection Array

The collection to check

Returns:

The smallest value returned by applying func to each object in collection.

Type
Number

upperFirst(str) → {String}

Description:
  • Uppercases the first letter of a string

Source:
Example
upperFirst("test"); //=> "Test"
Parameters:
Name Type Description
str String

The string to uppercase the first letter of

Returns:

The input string with its first letter uppercased

Type
String