alwaysEmptyArray Function

a → Array

Always returns a new empty array.

R_.alwaysEmptyArray(); // []

alwaysEmptyObject Function

a → Object

Always returns a new empty object.

R_.alwaysEmptyObject(); // {}

alwaysEmptyString Function

a → String

Always returns empty string.

R_.alwaysEmptyString(); // ''

alwaysNull Function

a → Object

Always returns null.

R_.alwaysNull(); // null

alwaysOne Function

* → Number

Always returns number one.

R_.alwaysOne(); // 1

alwaysZero Function

* → Number

Always returns zero.

R_.alwaysZero(); // 0

applyCompose Function

[(a → b)] → a → b

Applies composition by a list of functions.

R_.applyCompose([multiply(2), add(1)])(3); // 8

applyIfFunction Function

a|(*… → a) → [*] → a
Parameters
  • x

    Function or value

  • args

    Array of arguments

Returns any

If the first argument is a function then we apply the function with args that are passed as the second argument. If the first argument is not a function then we return it as it is.

const ref = { current: null }; const getRef = always(ref); const createRef = (current) => ({ current }); R_.applyIfFunction(ref, []); // { current: null } R_.applyIfFunction(getRef, []); // { current: null } R_.applyIfFunction(createRef, [document.body]); // {"current": [object HTMLBodyElement]}

applyIfNotNil Function

(*… → a) → [*] → a
Parameters
  • fn

    The function which will be called with args when defined

  • args

    The arguments to call fn with

Returns * result The result, equivalent to `fn(...args)` or null

Call apply on function if the function is defined. Otherwise do nothing and return null.

const nums = [1, 2, 3]; R_.applyIfNotNil(R.sum, nums); // 6 R_.applyIfNotNil(undefined, nums); // null

applyPipe Function

[(a → b)] → a → b

Applies pipe by to a list of functions.

R_.applyPipe([multiply(2), add(1)])(3); // 7

argumentsToList Function

(a, b, c, …) → ([a, b, c, …])

Converts arguments to list.

R.compose(R.sum, R_.argumentsToList)(1, 2, 3); // 6

assocDotPath Object

String → a → b
Parameters
  • path

    the dot path to set

  • val

    The new value

  • obj

    The object to clone

Returns Object A new object equivalent to the original except along the specified path.

Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and placing the specific value at the tail end of that path.

R_.assocDotPath("a.b.c", 42, { a: { b: { c: 0 } } }); //=> {a: {b: {c: 42}}} // Any missing or non-object keys in path will be overridden R_.assocDotPath("a.b.c", 42, { a: 5 }); //=> {a: {b: {c: 42}}}

between Type

Parameters
  • a

    Starting value

  • b

    Ending value

  • val

    The value to test

Returns Boolean

See if an number (val) is within an array of two numbers ('list').

R_.between(1, 5, 4); //=> true R_.between(3, 8, 2.1); //=> false R_.between(100.1, 102, 100.1); //=> true

callIfFunction Function

(a|(*… → a),*…) → a
Parameters
  • x

    Function or value

  • args

    Any number of positional arguments.

Returns any

If the first argument x is a function then we return the result of calling x with the remaining arguments. If x is not a function then we return it as it is.

const ref = { current: null }; const getRef = always(ref); const createRef = (current) => ({ current }); R_.callIfFunction(ref); // { current: null } R_.callIfFunction(getRef); // { current: null } R_.callIfFunction(createRef, document.body); // {"current": [object HTMLBodyElement]}

camelizeKeys Object

Parameters
  • x

    Object to transform

Returns any

Recursively camelize all keys within an object or array

camelizeKeys({ "co-obj": { co_string: "foo" }, "co-array": [0, null, { "f-f": "ff" }], "co-number": 1, "co-string": "1", "co-fn": head, }); // { // coArray: [ // 0, // null, // { // fF: 'ff' // } // ], // coFn: [Function], // coNumber: 1, // coObj: { // coString: 'foo' // }, // coString: '1' // }

capitalizeAll String

String → String
Parameters
  • x

    Any string

Returns any String where every word starts with upper-case letter

For not-nil string returns string where every single word starts with a capital letter.

R_.capitalizeAll("seek and destroy"); // Seek And Destroy R_.capitalizeAll("Seek And Destroy"); // Seek And Destroy R_.capitalizeAll(null); // null R_.capitalizeAll(undefined); // undefined

capitalizeFirst String

String → String
Parameters
  • x

    Any string

Returns any String starting with upper-case letter

For not-nil string returns string which starts with capital (upper-case) letter.

R_.capitalizeFirst("metallica"); // Metallica R_.capitalizeFirst("Metallica"); // Metallica R_.capitalizeFirst(null); // null R_.capitalizeFirst(undefined); // undefined

composeC Function

Creates curried compose. The rightmost function determines the arity of curry.

const appendAndRejectNil = R_.composeC(R.rejectNil, R.append); const appendCAndRejectNil = appendAndRejectNil("c"); appendCAndRejectNil(["a", null]); // ['a', 'c'];

constructRegExp Function

Constructs RegExp.

test(R_.constructRegExp("end$", "gi"), "in the end"); // true

containsAll List

[a] → [a] → Boolean
Parameters
  • List
  • List
Returns Boolean If all items from first array are in the second array.

Resolves to true if all elements in first list are found within the second list

R_.containsAll(["a", "b"], ["a", "b", "c"]); // true R_.containsAll(["a", "b", "d"], ["a", "b", "c"]); // false

containsAny List

[a] → [a] → Boolean
Parameters
  • List
  • List
Returns Boolean If any of the items from first array are in the second array.

Returns true if any of the items from first array are in the second array.

R_.containsAny(["a", "e"], ["a", "b", "c"]); // true R_.containsAny(["e", "f"], ["a", "b", "c"]); // false

containsNone List

[a] → [a] → Boolean
Parameters
  • List
  • List
Returns Boolean If any of the items from first array is not in the second array.

Returns true if any of the items from first array is not the second array.

R_.containsNone(["e", "f"], ["a", "b", "c"]); // true R_.containsNone(["a", "f"], ["a", "b", "c"]); // false

cx String

String | [String] | Object → String

Conditionally joining classNames together.

The cx function takes any number of arguments which can be a string, object even nested arrays of strings and objects.

The argument 'foo' is short for { foo: true }.

If the value associated with a given key is falsy, that key won't be included in the output.

R_.cx("Table", ["MagicTable"], { "Table--active": true }); // 'Table MagicTable Table--active' R_.cx("Table", ["MagicTable"], { "Table--active": false }); // 'Table MagicTable' R_.cx(["Table", ["MagicTable"]]); // 'Table MagicTable'

decapitalizeAll String

String → String
Parameters
  • x

    Any string

Returns any String where every word starts with lower-case letter

For not-nil string returns string where every single word starts with a lower-case letter.

R_.decapitalizeAll("Seek And Destroy"); // seek and destroy R_.decapitalizeAll("seek and destroy"); // seek and destroy R_.decapitalizeAll(null); // null R_.decapitalizeAll(undefined); // undefined

decapitalizeFirst String

String → String
Parameters
  • x

    Any String

Returns any String starting with lower-case letter

For not-nil string returns string which starts with lower-case letter.

R_.decapitalizeFirst("Metallica"); // metallica R_.decapitalizeFirst("metallica"); // metallica R_.decapitalizeFirst(null); // null R_.decapitalizeFirst(undefined); // undefined

defaultArgs Function

Creates default arguments for given function

R_.defaultArgs(["a", "b"], R.concat)(undefined, "c"); // ac

defaultToEmptyArray Logic

a → a | Array

Returns the argument if it is not null, undefined or NaN; otherwise the empty array is returned.

R_.defaultToEmptyArray(null); //=> [] R_.defaultToEmptyArray(undefined); //=> [] R_.defaultToEmptyArray("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToEmptyArray(parseInt("string")); //=> []

defaultToEmptyObject Logic

a → a | Object

Returns the argument if it is not null, undefined or NaN; otherwise the empty object is returned.

R_.defaultToEmptyObject(null); //=> {} R_.defaultToEmptyObject(undefined); //=> {} R_.defaultToEmptyObject("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToEmptyObject(parseInt("string")); //=> {}

defaultToEmptyString Logic

a → a | String

Returns the argument if it is not null, undefined or NaN; otherwise the empty string is returned.

R_.defaultToEmptyString(null); //=> "" R_.defaultToEmptyString(undefined); //=> "" R_.defaultToEmptyString("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToEmptyString(parseInt("string")); //=> ""

defaultToFalse Logic

a → a | Boolean

Returns the argument if it is not null, undefined or NaN; otherwise the false is returned.

R_.defaultToFalse(null); //=> false R_.defaultToFalse(undefined); //=> false R_.defaultToFalse("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToFalse(parseInt("string")); //=> false

defaultToOne Logic

a → a | Number

Returns the argument if it is not null, undefined or NaN; otherwise number one is returned.

R_.defaultToOne(null); //=> 1 R_.defaultToOne(undefined); //=> 1 R_.defaultToOne("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToOne(parseInt("string")); //=> 1

defaultToTrue Logic

a → a | Boolean

Returns the argument if it is not null, undefined or NaN; otherwise true is returned.

R_.defaultToTrue(null); //=> true R_.defaultToTrue(undefined); //=> true R_.defaultToTrue("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToTrue(parseInt("string")); //=> true

defaultToZero Logic

a → a | Number

Returns the argument if it is not null, undefined or NaN; otherwise zero is returned.

R_.defaultToZero(null); //=> 0 R_.defaultToZero(undefined); //=> 0 R_.defaultToZero("Ramda"); //=> 'Ramda' // parseInt('string') results in NaN R_.defaultToZero(parseInt("string")); //=> 0

dispatch Function

[a] → b|undefined
Parameters
  • listFns

    List of functions

  • values

    Values applied to functions from listFns

Returns any Returns first not nil result of calling fn from `listFns` with `values`.

Returns first not nil result from evaluation of functions in the list. Returns undefined otherwise.

See also dispatchWith.
const validateName = R_.dispatch([ ifElse(Boolean, R_.noop, always("Name is required.")), ifElse(R_.isString, R_.noop, always("Name must be valid.")), ]); validateName(""); // 'Name is required.' validateName(111); // 'Name must be valid.' validateName("Valid name"); // undefined

dispatchWith Function

[a] → b|undefined
Parameters
  • predicate

    Predicate that is applied to result of calling fn from listFns with values

  • listFns

    List of functions

  • values

    Values applied to functions from listFns

Returns any Returns first result of calling fn from `listFns` with `values` that satisfies `predicate`.

Returns first result from evaluation of functions in the list, that satisfies predicate. Returns undefined otherwise.

See also dispatch.
const firstTruthy = R_.dispatchWith(Boolean)([prop("foo"), prop("bar")]); firstTruthy({ foo: "foo", bar: false }); // "foo" firstTruthy({ foo: false, bar: "bar" }); // "bar"

dissocDotPath Object

Parameters
  • path

    The dot path to the value to omit

  • obj

    The object to clone

Returns Object A new object without the property at path

Makes a shallow clone of an object, omitting the property at the given dot path. Note that this copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

R_.dissocDotPath("a.b.c", { a: { b: { c: 42 } } }); //=> {a: {b: {}}}

dotPath Object

Parameters
  • path

    The dot path to use.

  • obj

    The object to retrieve the nested property from.

Returns * The data at `path`.

Retrieve the value at a given dot path.

R_.dotPath("a.b", { a: { b: 2 } }); //=> 2 R_.dotPath("a.b", { c: { b: 2 } }); //=> undefined

dotPathEq Object

a → String → {a} → Boolean
Parameters
  • eq

    Value for R.equals.

  • path

    The dot path to use.

  • obj

    The object to retrieve the nested property from and compare with eq.

Returns * True if value on dot path equals to `eq`.

Determines whether a dot path on an object has a specific value in R.equals terms.

R_.dotPathEq(2, "a.b", { a: { b: 2 } }); //=> true R_.dotPathEq(2, "a.b", { c: { b: 2 } }); //=> false

dotPathNotEq Object

a → String → {a} → Boolean
Parameters
  • eq

    Value for R_.notEqual.

  • path

    The dot path to use.

  • obj

    The object to retrieve the nested property from and compare with eq.

Returns * True if value on dot path equals to `eq`.

Determines whether a dot path on an object has a specific value in R_.notEqual terms.

R_.dotPathNotEq(2, "a.b", { a: { b: 2 } }); //=> false R_.dotPathNotEq(2, "a.b", { c: { b: 2 } }); //=> true

dotPathNotSatisfies Object

(a → Boolean) → String → {a} → Boolean
Parameters
  • predicate
  • path

    The dot path to use.

  • obj
Returns Boolean

Returns true if the specified object property at given dot path not satisfies the given predicate; false otherwise.

R_.dotPathNotSatisfies((y) => y > 0, "a.b", { a: { b: 1 } }); // false R_.dotPathNotSatisfies((y) => y > 0, "a.b", { a: { b: -1 } }); // true R_.dotPathNotSatisfies((y) => y > 0, "a.b", { a: { c: 1 } }); // true

dotPathOr Object

a → String → {a} → a
Parameters
  • default

    Default value if path does not exist.

  • path

    The dot path to use.

  • obj
Returns * The data at `path` of the supplied object or the default value.

If the given, non-null object has a value at the given dot path, returns the value at that path. Otherwise returns the provided default value.

R_.dotPathOr("N/A", "a.b", { a: { b: 1 } }); // 1 R_.dotPathOr("N/A", "a.b", { a: { c: 1 } }); // "N/A"

dotPathSatisfies Object

(a → Boolean) → String → {a} → Boolean
Parameters
  • predicate
  • path

    The dot path to use.

  • obj
Returns Boolean

Returns true if the specified object property at given dot path satisfies the given predicate; false otherwise.

R_.dotPathSatisfies((y) => y > 0, "a.b", { a: { b: 1 } }); // true R_.dotPathSatisfies((y) => y > 0, "a.b", { a: { b: -1 } }); // false R_.dotPathSatisfies((y) => y > 0, "a.b", { a: { c: 1 } }); // false

duplicate List

a → [a]

Creates pair. Every item of pair equals to input parameter.

R_.duplicate(1); // [1, 1]

endsWithSuffix String

a → b → Boolean
Parameters
  • suffix
  • x
Returns boolean True if `x` ends with `suffix`

Testing string if ends with some suffix.

R_.endsWithSuffix("o", "hello"); // true R_.endsWithSuffix("ello", "hello"); // true R_.endsWithSuffix("y", "good bye"); // false

endsWithSuffixIgnoreCase String

a → b → Boolean
Parameters
  • suffix
  • x
Returns boolean True if `x` ends with `suffix` ignore case

Testing string if ends with some suffix ignoring case.

R_.endsWithSuffixIgnoreCase("o", "HELLO"); // true R_.endsWithSuffixIgnoreCase("ELLO", "hello"); // true R_.endsWithSuffixIgnoreCase("hello", "hello"); // true R_.endsWithSuffixIgnoreCase("o", "good bye"); // false

ensureArray List

a → Array

Wraps input in an Array if it's not an Array already.

R_.ensureArray("A string yo."); // ["A string yo."] R_.ensureArray(["an array item yo"]); // ["an array item yo"] R_.ensureArray([{ consoleLog: "yo" }]); // [{ consoleLog: "yo" }]

equalsEmptyString String

Deprecated true
a → Boolean

Alias for equalsToEmptyString.

R_.equalsEmptyString(""); // true R_.equalsEmptyString("hi"); // false

equalsLength List

Number → [a] → Boolean

Returns true if length of array equals first argument

const lengthEqualsOne = R_.equalsLength(1); lengthEqualsOne([{}]); // true lengthEqualsOne([]); // false

equalsStringIgnoreCase String

a → b → Boolean
Parameters
  • x
  • y
Returns boolean True if `x` equals `y` ignore case

Testing string if equals ignoring case.

R_.equalsStringIgnoreCase("hello", "HELLO"); // true R_.equalsStringIgnoreCase("HELLO", "hello"); // true R_.equalsStringIgnoreCase("hello", "hello"); // true R_.equalsStringIgnoreCase("hello", "good bye"); // false

equalsToEmptyArray Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is empty array.

Testing if argument equals to empty array.

R_.equalsToEmptyArray([]); // true R_.equalsToEmptyArray([""]); // false

equalsToEmptyObject Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is empty object.

Testing if argument equals to empty object.

R_.equalsToEmptyObject({}); // true R_.equalsToEmptyObject(""); // false

equalsToEmptyString Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is empty string

Testing if argument equals to ''

R_.equalsToEmptyString(""); // true R_.equalsToEmptyString("hi"); // false

equalsToFalse Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is false

Testing if argument equals to false

R_.equalsToFalse(false); // true R_.equalsToFalse(null); // false

equalsToNull Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is null

Testing if argument equals to null

R_.equalsToNull(null); // true R_.equalsToNull(undefined); // false

equalsToOne Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is 1

Returns true if argument equals to 1.

R_.equalsToOne(3); // false R_.equalsToOne(1); // true R_.equalsToOne(-3); // false

equalsToTrue Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is true

Testing if argument equals to true

R_.equalsToTrue(true); // true R_.equalsToTrue(false); // false

equalsToZero Relation

a → Boolean
Parameters
  • value
Returns boolean True if `value` is 0

Returns true if argument equals to 0.

R_.equalsToZero(3); // false R_.equalsToZero(0); // true R_.equalsToZero(-3); // false

equalsZero Relation

Deprecated true
a → Boolean

Alias for equalsToZero.

See also equalsToZero.
R_.equalsZero(3); // false R_.equalsZero(0); // true R_.equalsZero(-3); // false

findNotNil List

[a] → a

Returns first not nil value

R_.findNotNil([null, undefined, 0, true]); // 0

flattenArgs List

(a, [b, c]…) → [a, b, c]
Parameters
Returns Array flatten array

Applies flatten on array of arguments

R_.flattenArgs("e", "f", "a"); // ['e', 'f', 'a'] R_.flattenArgs("e", ["f", "a"]); // ['e', 'f', 'a'] R_.flattenArgs("e", ["f", ["a"]]); // ['e', 'f', 'a']

flattenValues List

{k: v} → [v]
Parameters
  • value
Returns Array array of values

Recursively flatten values from object and array.

R_.flattenValues([ "hi", { foo: "bar" }, { foo: { bar: ["baz", { foofoo: "hi" }], }, }, ["bar", "hi"], ["barbar", { hrun: "hi" }], ]); // ['hi','bar','baz','hi','hi','hi']

flipIncludes List

[a] → b → Boolean
Parameters
  • list
  • item
Returns Boolean Returns `true` if `list` includes `item`.

Returns true if list includes item.

R_.flipIncludes(["e", "f"], "e"); // true R_.flipIncludes(["e", "f"], "a"); // false

get Object

a → [a] → a
Parameters
  • x
  • path
Returns any Slice of x

Returns part of the object based on path.

R_.get({ foo: "bar" }, ["foo"]); // "bar"

groupByPath Object

[String] → [a] → {String → [a]}

Groups values in the list by the property found by provided path.

R_.groupByPath(["id"])([{ id: 1 }, { id: 3 }, { id: 1, name: "c" }]); // -> // { // "1": [ // { // id: 1 // }, // { // id: 1, // name: "c" // } // ], // "3": [ // { // id: 3 // } // ] // }

groupByProp Object

String → [a] → {String → [a]}

Groups values in the list by the property found by provided key.

R_.groupByProp("id")([{ id: 1 }, { id: 3 }, { id: 1, name: "c" }]); // -> // { // "1": [ // { // id: 1 // }, // { // id: 1, // name: "c" // } // ], // "3": [ // { // id: 3 // } // ] // }

gteThanLength List

Number → [a] → Boolean

Returns true if length of array is smaller or equals than first argument

const lengthSmallerThanEqualsOne = R_.gteThanLength(1); lengthSmallerThanEqualsTwo([{}, {}]); // false lengthSmallerThanEqualsTwo([{}]); // true lengthSmallerThanEqualsTwo([]); // true

gtThanLength List

Number → [a] → Boolean

Returns true if length of array is smaller than first argument

const lengthSmallerThanTwo = R_.gtThanLength(2); lengthSmallerThanTwo([{}]); // true lengthSmallerThanTwo([{}, {}]); // false

headArg Function

Takes first argument from the arguments

R_.headArg("a", "b", "c"); // a

includes List

Deprecated true
[a] → b → Boolean
Parameters
  • list
  • item
Returns Boolean Returns `true` if `list` includes `item`.

Returns true if if list includes item.

Deprecated due to breaking change in Ramda. Use R_.flipIncludes instead.

R_.includes(["e", "f"], "e"); // true R_.includes(["a", "f"], "a"); // false

isArray Type

a → Boolean

Returns true if argument is type of Array.

R_.isArray([]); // true R_.isArray(""); // false

isBoolean Type

a → Boolean

Returns true if argument is type of Boolean.

R_.isBoolean(true); // true R_.isBoolean(false); // true R_.isBoolean(1); // false R_.isBoolean(""); // false R_.isBoolean("true"); // false R_.isBoolean({}); // false R_.isBoolean([]); // false R_.isBoolean(NaN); // false R_.isBoolean(null); // false R_.isBoolean(undefined); // false

isError Type

a → Boolean

Returns true if the argument is an instance of Error.

R_.isError(new Error()); // true R_.isError(null); // false

isFalsy Logic

a → Boolean
Parameters
  • input
Returns Boolean `true` if `input` is falsy

Returns true for falsy values. Complement of R_.falsy.

R_.isFalsy(true); // false R_.isFalsy({}); // false R_.isFalsy([]); // false R_.isFalsy(1); // false R_.isFalsy("hello"); // false R_.isFalsy(false); // true R_.isFalsy(0); // true R_.isFalsy(""); // true

isFunction Type

a → Boolean

Returns true if argument is type of Function.

R_.isFunction(() => {}); // true R_.isFunction({}); // false R_.isFunction([]); // false R_.isFunction(""); // false R_.isFunction(0); // false

isNegative Math

Number → Boolean

Returns true if argument is lower than 0.

R_.isNegative(3); // false R_.isNegative(0); // false R_.isNegative(-3); // true

isNilOrEmpty Logic

a → Boolean
Parameters
  • input
Returns Boolean

Returns true if input is empty or nil.

R_.isNilOrEmpty(null); // true R_.isNilOrEmpty({}); // true R_.isNilOrEmpty(false); // false R_.isNilOrEmpty(0); // false

isNilOrEmptyString Logic

a → Boolean

Returns true if argument is null, undefined or ''.

R_.isNilOrEmptyString(null); // true R_.isNilOrEmptyString(undefined); // true R_.isNilOrEmptyString(""); // true R_.isNilOrEmptyString(false); // false R_.isNilOrEmptyString(0); // false R_.isNilOrEmptyString([]); // false R_.isNilOrEmptyString({}); // false

isNotEmpty Logic

a → Boolean

Returns true if the given value is not its type's empty value

R_.isNotEmpty([1, 2, 3]); // true R_.isNotEmpty([]); // false R_.isNotEmpty(""); // false R_.isNotEmpty(null); // true R_.isNotEmpty({}); // false R_.isNotEmpty({ length: 0 }); // true

isNotNaN Logic

a → Boolean

Return negation of native isNaN function.

R_.isNotNaN(0); // true R_.isNotNaN(""); // true R_.isNotNaN([]); // true R_.isNotNaN(null); // true R_.isNotNaN({}); // false R_.isNotNaN(NaN); // false R_.isNotNaN(undefined); // false

isNotNil Logic

a → Boolean

Returns true if argument is neither null or undefined.

R_.isNotNil(null); // false R_.isNotNil(undefined); // false R_.isNotNil(""); // true R_.isNotNil(false); // true R_.isNotNil(0); // true R_.isNotNil([]); // true R_.isNotNil({}); // true

isNotNilObject Logic

a → Boolean

Returns true if argument is not nil object.

R_.isNotNilObject({}); // true R_.isNotNilObject([]); // true R_.isNotNilObject(() => {}); // true R_.isNotNilObject(null); // false R_.isNotNilObject(); // false R_.isNotNilObject(1); // false R_.isNotNilObject(""); // false

isNotNumeric Logic

a → Boolean

Returns true if argument is not finite numeric value.

R_.isNotNumeric(-1); // false R_.isNotNumeric(0); // false R_.isNotNumeric(1); // false R_.isNotNumeric(1.1); // false R_.isNotNumeric(Infinity); // true R_.isNotNumeric(NaN); // true R_.isNotNumeric(""); // true R_.isNotNumeric(() => {}); // true R_.isNotNumeric(false); // true R_.isNotNumeric(null); // true R_.isNotNumeric(undefined); // true R_.isNotNumeric({}); // true R_.isNotNumeric([]); // true

isNotRegExp Type

a → Boolean

Returns true if argument is not RegExp.

R_.isNotRegExp(/foo/); // false R_.isNotRegExp(0); // true

isNumber Type

a → Boolean
Parameters
  • x

    Value to test

Returns any True, if value is type of Number

Returns true if value is type of Number.

R_.isNumber(NaN); // true R_.isNumber(Infinite); // true R_.isNumber(1); // true R_.isNumber(false); // false R_.isNumber({}); // false R_.isNumber("1"); // false

isNumeric Logic

a → Boolean

Returns true if argument is finite numeric value.

R_.isNumeric(-1); // true R_.isNumeric(0); // true R_.isNumeric(1); // true R_.isNumeric(1.1); // true R_.isNumeric(Infinity); // false R_.isNumeric(NaN); // false R_.isNumeric(""); // false R_.isNumeric(() => {}); // false R_.isNumeric(false); // false R_.isNumeric(null); // false R_.isNumeric(undefined); // false R_.isNumeric({}); // false R_.isNumeric([]); // false

isObject Type

a → Boolean

Returns true if argument is type of Object.

R_.isObject({}); // true R_.isObject([]); // true R_.isObject(""); // false

isPlainObject Type

a → Boolean
Parameters
  • x

    value to test

Returns boolean whether the argument is a plain object

Returns true if the argument is a plain object.

R_.isPlainObject({}); // true R_.isPlainObject([]); // false R_.isPlainObject(null); // false

isPositive Math

Number → Boolean

Returns true if argument is greater than 0.

R_.isPositive(3); // true R_.isPositive(0); // false R_.isPositive(-3); // false

isPromise Type

a → Boolean

Returns true if argument is Promise.

R_.isPromise(Promise.resolve()); // true R_.isPromise(0); // false

isRegExp Type

a → Boolean

Returns true if argument is RegExp.

R_.isRegExp(/foo/); // true R_.isRegExp(0); // false

isString Type

a → Boolean

Returns true if argument is type of String.

R_.isString({}); // false R_.isString([]); // false R_.isString(""); // true

isTruthy Logic

a → Boolean
Parameters
  • input
Returns Boolean `true` if `input` is truthy

Alias for Boolean constructor. Returns 'true' for truthy values.

R_.isTruthy(true); // true R_.isTruthy({}); // true R_.isTruthy([]); // true R_.isTruthy(1); // true R_.isTruthy("hello"); // true R_.isTruthy(false); // false R_.isTruthy(0); // false R_.isTruthy(""); // false

joinWithDash String

[String] → String

Joins array of string with dash (hyphen) determiner.

R_.joinWithDash(["a", "b", "c"]); // 'a-b-c'

joinWithDot String

[String] → String

Joins array of string with dot determiner.

R_.joinWithDot(["a", "b", "c"]); // 'a.b.c'

joinWithSpace String

[String] → String

Joins array of string with space determiner.

R_.joinWithSpace(["a", "b", "c"]); // 'a b c'

joinWithUnderscore String

[String] → String

Joins array of string with underscore determiner.

R_.joinWithUnderscore(["a", "b", "c"]); // 'a_b_c'

keyMirror Object

Object → Object
Parameters
  • Object

    where should be keys copied as values.

Returns Object

Copies keys of object to appropriate values.

const actionTypes = R_.keyMirror({ ITEM_REQUEST: null, ITEM_SUCCESS: null, ITEM_ERROR: null, }); const action = { type: actionTypes.ITEM_REQUEST }; action.type === actionTypes.ITEM_REQUEST; // true

lastArg Function

Takes last argument from the arguments

R_.lastArg("a", "b", "c"); // c

listToString List

[String] → String

Converts list of strings to string.

R_.listToString(["h", "e", "l", "l", "o"]); // 'hello'

log Debugging

a → a

Function with side-effect. Logs input to console and returns that input. Should be used only in development.

R_.log("hello"); // logs 'hello' compose(R_.log, R.sum)([1, 3]); // logs 4

lteThanLength List

Number → [a] → Boolean

Returns true if length of array is bigger or equals than first argument

const lengthBiggerThanEqualsOne = R_.lteThanLength(1); lengthBiggerThanEqualsOne([{}, {}]); // true lengthBiggerThanEqualsOne([{}]); // true lengthBiggerThanEqualsOne([]); // false

ltThanLength List

Number → [a] → Boolean

Returns true if length of array is bigger than first argument

const lengthBiggerThanZero = R_.ltThanLength(0); lengthBiggerThanZero([{}]); // true lengthBiggerThanZero([]); // false

mapIndexed Object

(a → Number → a) → [a] → a
Parameters
  • fn

    The function to be called on every element of the list and its index.

  • list

    The list to be iterated over.

Returns Array The new list.

Map using function that is provided with each value of the list and its index in the list.

R_.mapIndexed((value, index) => `${value}-${index}`)([1, 2, 3]); // ['1-0', '2-1', '3-2']

mapKeys Object

Parameters
  • fn

    The function to be called on every key of the input object.

  • obj

    The object to be iterated over.

Returns Array The new object with mapped keys.

Use map function over the keys of the given object

R_.mapKeys(R_.toUpperFirst, { x: 1, y: 2, z: 3 }); //=> {X: 2, Y: 4, Z: 6}

mapKeysAndValues Object

([a] → [b]) → Object → Object

Always returns null.

R_.mapKeysAndValues(([a, b]) => [b, a], { foo: "bar", baz: "boo" }); // { bar: "foo", boo: "baz" }

mapKeysWithValue Object

((String, a) → b) → Object → Object

Map object keys. Mapping functions have both key and value as arguments.

R_.mapKeysWithValue((key, value) => value)({ foo: "bar" }); // { bar: "bar" }

mapOver List

Lens s a → (* → *) → [object] → [object]
Parameters
  • lens
  • fn

    The function to be called on every specified property element of the list.

  • list

    The list to be iterated over.

Returns Array The new list.

Maps over a specific property on a list of objects, it returns a new list of objects

const objs = [{ value: 1 }, { value: 2 }, { value: 3 }]; const valueLens = R.lensProp("value"); R_.mapOver(valueLens, R.add(100), objs); // [{ value: 101 }, { value: 102 }, { value: 103 }]

mapOverPath List

string[] → (* → *) → [object] → [object]
Parameters
  • path

    The path to be modified.

  • fn

    The function to be called on every specified path element of the list.

  • list

    The list to be iterated over.

Returns Array The new list.

Maps over a specific path on a list of objects, it returns a new list of objects

const objs = [{ value: { id: 1 } }, { value: { id: 2 } }]; const valueLens = R.lensProp("value"); R_.mapOverPath(["value", "id"], R.add(100), objs); // [{ value: { id: 101 } }, { value: { id: 102 } }]

mapOverProp List

string → (* → *) → [object] → [object]
Parameters
  • prop

    The prop to be modified.

  • fn

    The function to be called on every specified property element of the list.

  • list

    The list to be iterated over.

Returns Array The new list.

Maps over a specific prop on a list of objects, it returns a new list of objects

const objs = [{ value: 1 }, { value: 2 }]; const valueLens = R.lensProp("value"); R_.mapOverProp("value", R.add(100), objs); // [{ value: 101 }, { value: 102 }]

memoizeWithIdentity Function

Creates a new function that, when invoked, caches the result of calling fn for a given argument and returns the result. Subsequent calls to the memoized fn with the same argument will not result in an additional call to fn; instead, the cached result for that argument will be returned

let count = 0; const factorial = R_.memoizeWithIdentity((n) => { count += 1; return R.product(R.range(1, n + 1)); }); factorial(5); // 120 factorial(5); // 120 factorial(5); // 120 count; // 1

mergeDeepAllWith Object

((a, a) → a) → [{a}] → {a}
Parameters
  • reducer

    Function that resolves merging between two same keys

  • objects

    Array of objects to be merged with

Returns Object Returns merged object

Creates a new object with the own properties of the list of provided objects. List of objects is reduced from first object to the last. If a key exists in both compared objects:

  • and both associated values are also objects then the values will be recursively merged.
  • otherwise the provided function is applied to associated values using the resulting value as the new value associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.
R_.mergeDeepAllWith(R.concat, [ { a: { b: [1] } }, { a: { b: [2] } }, { a: { b: [3] } }, ]); // { a: { b: [1, 2, 3] } }

mergeDeepAllWithKey Object

((String, a, a) → a) → [{a}] → {a}
Parameters
  • reducer

    Function that resolves merging between two same keys

  • objects

    Array of objects to be merged with

Returns Object Returns merged object

Creates a new object with the own properties of the list of provided objects. List of objects is reduced from first object to the last. If a key exists in both compared objects:

  • and both associated values are also objects then the values will be recursively merged.
  • otherwise the provided function is applied to the key and associated values using the resulting value as the new value associated with the key. If a key only exists in one object, the value will be associated with the key of the resulting object.
R_.mergeDeepAllWith((key, l, r) => (key === "b" ? R.concat(l, r) : r), [ { a: { b: [1], c: [1] } }, { a: { b: [2], c: [2] } }, { a: { b: [3], c: [3] } }, ]); // { a: { b: [1, 2, 3], c: [3] } }

mergeDeepLeftAll Object

[{a}] → {a}
Parameters
  • list

    Array of objects

Returns object Merged object

Returns deeply merged object by merging all objects in a passed list. Merging is applied from the left. See mergeDeepLeft from Ramda.

const a = { fooA: { bar: "a" }, shared: { baz: 1 } }; const b = { fooB: { bar: "b" }, shared: { baz: 2 } }; const c = { fooC: { bar: "c" }, shared: { baz: 3 } }; R_.mergeDeepLeftAll([a, b, c]); // { // fooA: { bar: 'a' }, // fooB: { bar: 'b' }, // fooC: { bar: 'c' }, // shared: { baz: 1 }, // }

mergeDeepRightAll Object

[{a}] → {a}
Parameters
  • list

    Array of objects

Returns object Merged object

Returns deeply merged object by merging all objects in a passed list. Merging is applied from the right. See mergeDeepRight from Ramda.

const a = { fooA: { bar: "a" }, shared: { baz: 1 } }; const b = { fooB: { bar: "b" }, shared: { baz: 2 } }; const c = { fooC: { bar: "c" }, shared: { baz: 3 } }; R_.mergeDeepRightAll([a, b, c]); // { // fooA: { bar: 'a' }, // fooB: { bar: 'b' }, // fooC: { bar: 'c' }, // shared: { baz: 3 }, // }

mergeWithDotPath Object

Parameters
  • path

    The dot path to the value

  • mergeFn

    The merging function

  • value

    Value to merge

  • obj

    The object to clone

Returns Object A new object with merge data

Merge data in object using custom merge fn.

R_.mergeWithDotPath("a.b", R.mergeRight, { d: 30 }, { a: { b: { c: 20 } } }); //=> {a: {b: { c: 20, d: 30 }}}

noop Function

a → Object

Alias for alwaysNull

R_.noop(); // null

notEmpty Logic

Deprecated true
a → Boolean

Alias for isNotEmpty

See also isNotEmpty.
R_.notEmpty([1, 2, 3]); // true R_.notEmpty([]); // false R_.notEmpty(""); // false R_.notEmpty(null); // true R_.notEmpty({}); // false R_.notEmpty({ length: 0 }); // true

notEqual Logic

a → b → Boolean

Returns true if the arguments are not equal

R_.notEqual(1, 2); // true R_.notEqual(1, 1); // false

notEqualToEmptyArray Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not an empty array.

Returns true if value is not equal to empty array.

R_.notEqualToEmptyArray([]); // false R_.notEqualToEmptyArray([{ ramda: true }]); // true

notEqualToEmptyObject Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not an empty object.

Returns true if value is not equal to empty object.

R_.notEqualToEmptyObject({}); // false R_.notEqualToEmptyObject({ ramda: true }); // true

notEqualToEmptyString Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not an empty string.

Returns true if value is not equal to empty string.

R_.notEqualToEmptyString(""); // false R_.notEqualToEmptyString("Ramda"); // true

notEqualToFalse Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not false.

Returns true if value is not equal to false.

R_.notEqualToFalse(false); // false R_.notEqualToFalse(true); // true

notEqualToNull Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not null.

Returns true if value is not equal to null.

R_.notEqualToNull(null); // false R_.notEqualToNull(false); // true

notEqualToOne Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not number one.

Returns true if value is not equal to number one.

R_.notEqualToOne(1); // false R_.notEqualToOne(0); // true

notEqualToTrue Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not true.

Returns true if value is not equal to true.

R_.notEqualToTrue(true); // false R_.notEqualToTrue(false); // true

notEqualToZero Relation

a → Boolean
Parameters
  • value
Returns Boolean Returns `true` if `value` is not zero.

Returns true if value is not equal to zero.

R_.notEqualToZero(0); // false R_.notEqualToZero(1); // true

notFlipInclude List

[a] → b → Boolean
Parameters
  • list
  • item
Returns Boolean Returns `false` if `list` includes `item`.

Returns false if any of the items from list includes item.

R_.notFlipInclude(["e", "f"], "e"); // false R_.notFlipInclude(["e", "f"], "a"); // true

notInclude List

Deprecated true
[a] → b → Boolean
Parameters
  • list
  • item
Returns Boolean Returns `false` if `list` flipIncludes `item`.

Returns false if any of the items from list flipIncludes item.

Deprecated due to breaking change in Ramda. Use R_.notFlipInclude.

R_.notInclude(["e", "f"], "e"); // false R_.notInclude(["a", "f"], "a"); // true

notNaN Logic

Deprecated [description]
a → Boolean

Alias for isNotNaN.

See also isNotNaN.
R_.notNaN(0); // true R_.notNaN(""); // true R_.notNaN([]); // true R_.notNaN(null); // true R_.notNaN({}); // false R_.notNaN(NaN); // false R_.notNaN(undefined); // false

notNil Logic

Deprecated true
a → Boolean

Alias for isNotNil

See also isNotNil.
R_.notNil(null); // false R_.notNil(undefined); // false R_.notNil(""); // true R_.notNil(false); // true R_.notNil(0); // true R_.notNil([]); // true R_.notNil({}); // true

notNumeric Logic

Deprecated true
a → Boolean

Alias for isNotNumeric.

See also isNotNumeric.
R_.notNumeric(-1); // false R_.notNumeric(0); // false R_.notNumeric(1); // false R_.notNumeric(1.1); // false R_.notNumeric(Infinity); // true R_.notNumeric(NaN); // true R_.notNumeric(""); // true R_.notNumeric(() => {}); // true R_.notNumeric(false); // true R_.notNumeric(null); // true R_.notNumeric(undefined); // true R_.notNumeric({}); // true R_.notNumeric([]); // true

objOfOver Object

Parameters
  • lens

    Lens

  • tranformation

    Transformation function

  • input
Returns Object Firstly applies transformation on `input` according to `lens` (`R.over`) and than returning value is made by the "setting" (`R.set`) the portion of previous result focused by the given `lens`.

Firstly applies transformation on input data structure according to provided "lens". Returning value is made by the "setting" the portion of the result focused by the given lens.

R_.objOfOver(R.lensPath(["a", "b"]), (x) => "Hello " + x, { a: { b: "foo" }, c: "bar", }); // { a: { b: "Hello foo" } }

overHead List

Parameters
  • v
  • x
Returns *

Returns an over lens to the first index of list.

R_.overHead(R.toUpper, ["foo", "bar", "baz"]); //=> ['FOO', 'bar', 'baz']

padLeft String

Number → a → a

Length of the output string, padString and initial value. padString is repeatedly concated to init until the length of the string is equal to lengthString.

R_.padLeft(10, "0")("1"); // '00000000001' R_.padLeft(-9, "0")("1"); // '1' R_.padLeft(1, "0")("1"); // '1'

padLeftUntil String

(a → Boolean) → a → a

Takes a predicate, string padString and initial value. padString is contacted to the output string everytime pred returns falsy value.

R_.padLeftUntil((x) => x.length === 10, "0")("1"); // '0000000001'

padRight String

Number → a → a

Length of the output string, padString and initial value. padString is repeatedly appended to the init until the length of the string is equal to lengthString.

R_.padRight(10, "0")("1"); // '10000000000' R_.padRight(-9, "0")("1"); // '1' R_.padRight(1, "0")("1"); // '1'

padRightUntil String

(a → Boolean) → a → a

Takes a predicate, string padString and initial value. padString is append to the output string everytime pred returns falsy value.

R_.padRightUntil((x) => x.length === 10, "0")("1"); // '1000000000'

pathNotEq Relation

[String | Int] → a → {a} → Boolean

Returns true if nested path of object literal does not contains given value.

R_.pathNotEq(1, ["a", "b"], { a: { b: 1 } }); // false R_.pathNotEq(1, ["a", "b"], { a: { b: 2 } }); // true R_.pathNotEq(1, ["a", "b"], {}); // true R_.pathNotEq(1, ["a", "b"], { a: {} }); // true

pathNotSatisfies Object

(a → Boolean) → String → {a} → Boolean
Parameters
  • predicate
  • path

    The path to use.

  • obj
Returns Boolean

Returns true if the specified object property at given path not satisfies the given predicate; false otherwise.

const positive = (x) => x > 0; R_.pathNotSatisfies(positive, ["a", "b"], {}); // true R_.pathNotSatisfies(positive, ["a", "b"], { a: { b: -1 } }); // true R_.pathNotSatisfies(positive, ["a", "b"], { a: { b: 3 } }); // false

pipeC Function

Creates curried pipe. The leftmost function determines the arity of curry.

const appendAndRejectNil = R_.pipeC(R.append, R.rejectNil); const appendCAndRejectNil = appendAndRejectNil("c"); appendCAndRejectNil(["a", null]); // ['a', 'c'];

propNotEq Relation

a → String → Object → Boolean

Returns true if property of object literal does not equals the given value.

R_.propNotEq(1, "a", { a: 1 }); // false R_.propNotEq(1, "a", { a: 2 }); // true R_.propNotEq(1, "a", {}); // true

propNotSatisfies Object

(a → Boolean) → String → {a} → Boolean
Parameters
  • predicate
  • prop

    The prop to use.

  • obj
Returns Boolean

Returns true if the specified object property at given prop not satisfies the given predicate; false otherwise.

const positive = (x) => x > 0; R_.propNotSatisfies(positive, "a", {}); // true R_.propNotSatisfies(positive, "a", { a: -1 }); // true R_.propNotSatisfies(positive, "a", { a: 3 }); // false

reduceCallable Function

(a → … → b) → [a, …, b] → c

Call function passed as first argument with arguments determined by second parameter in order.

const f = (a) => (b) => a + b; R_.reduceCallable(f, [1, 2]); // 3

reduceSource List

((a, b, a, [b]) → a) → a → [b] → a
Parameters
  • fn

    The iterator function. Receives four arguments, the accumulator, the current element, the source accumulator and the source list.

  • acc

    The initial accumulator value and value passed as the source accumulator value in the iterator function.

  • list

    The list to iterator over and value passed as the source list in the iterator function.

Returns * The reduced result.

Extends the reduce functionality by adding the original accumulator value as a third argument and the original list as a fourth argument to the iterator function.

R_.reduceSource((acc, v, sAcc) => v + acc + sAcc, 1, [1, 2, 3]); // 10 R_.reduceSource(R.pipe(R.unapply(R.flatten), R.sum), 0, [1, 2]); // 9

rejectEq List

a → [b] → [c]

Filters out every value in a list that equals to first argument.

R_.rejectEq("foo", ["foo", "bar", "foo", "bar"]); // ['bar', 'bar']

rejectNil List

[a] → [a]

Filters out every nil value in a list.

R_.rejectNil([null, undefined, ""]); // ['']

replicate List

Number → a → [a]

Creates list of length n. Every item in list equals to input parameter.

R_.replicate(1, 6); // [6] R_.replicate(2, 6); // [6, 6] R_.replicate(3, 6); // [6, 6, 6]

searchInArray Array

Parameters
  • searchFn
  • value
Returns Array filtered array of values

Perform fulltext search with given search function.

R_.searchInArrayWith(R.contains("hi"), [ "hi", { foo: "bar" }, { foo: "hi" }, { foo: { bar: ["cuuus", { foo: "hi" }], }, }, ["haha", "hi"], ["haha", { foo: "hi" }], ]); // [ // 'hi', // { foo: 'hi' }, // { // foo: { // bar: ['cuuus', { foo: 'hi' }], // }, // }, // ['haha', 'hi'], // ['haha', { foo: 'hi' }], // ]

searchInArrayWith Array

Parameters
  • searchFn
  • value
Returns Array filtered array of values

Perform fulltext search with given search function.

R_.searchInArrayWith(R.contains("hi"), [ "hi", { foo: "bar" }, { foo: "hi" }, { foo: { bar: ["cuuus", { foo: "hi" }], }, }, ["haha", "hi"], ["haha", { foo: "hi" }], ]); // [ // 'hi', // { foo: 'hi' }, // { // foo: { // bar: ['cuuus', { foo: 'hi' }], // }, // }, // ['haha', 'hi'], // ['haha', { foo: 'hi' }], // ]

splitByDot String

String → [String]

Splits string by dot into list.

R_.splitByDot("a.b.c"); // ['a', 'b', 'c']

splitByNonAlphaNumeric String

String → [String]

Splits string into list. Delimiter is every sequence of non-alphanumerical values.

R_.splitByNonAlphaNumeric("Hello world/1"); // ['Hello', 'world', '1']

startsWithPrefix String

a → b → Boolean
Parameters
  • prefix
  • x
Returns boolean True if `x` starts with `prefix`

Testing string if starts with some prefix.

R_.startsWithPrefix("h", "hello"); // true R_.startsWithPrefix("hell", "hello"); // true R_.startsWithPrefix("h", "good bye"); // false

startsWithPrefixIgnoreCase String

a → b → Boolean
Parameters
  • prefix
  • x
Returns boolean True if `x` starts with `prefix` ignore case

Testing string if starts with some prefix ignoring case.

R_.startsWithPrefixIgnoreCase("h", "HELLO"); // true R_.startsWithPrefixIgnoreCase("HELL", "hello"); // true R_.startsWithPrefixIgnoreCase("hello", "hello"); // true R_.startsWithPrefixIgnoreCase("h", "good bye"); // false

toCamelCase String

String → String

Converts string into camelCase.

R_.toCamelCase("hello-world"); // 'helloWorld' R_.toCamelCase("hello- world"); // 'helloWorld' R_.toCamelCase(" hello-/ world/ "); // 'helloWorld'

toDotCase String

String → String

Converts string into dot.case.

R_.toDotCase("hello-world"); // 'hello.world' R_.toDotCase("hello/*? world"); // 'hello.world' R_.toDotCase(" hello -/ world/ "); // 'hello.world'

toEntries Object

{String: a, …} → [{String: a}]
Parameters
  • object
Returns Array Description

Creates array of entries from object.

R_.toEntries({ a: "b", c: "d" }); // [{ a: "b" }, { c: "d" }]

toggle Function

Parameters
  • options

    must be array of two items

  • val
Returns * opposite of options

Returns the opposite value comparing against a given set of two values.

R_.toggle("on", "off")("on"); // 'off' R_.toggle("active", "inactive")("inactive"); // 'active' R_.toggle(10, 100)(10); // 100 R_.toggle("on", "off")("other"); // 'other'

toKebabCase String

String → String

Converts string into kebab-case.

R_.toKebabCase("hello-world"); // 'hello-world' R_.toKebabCase("hello- world"); // 'hello-world' R_.toKebabCase(" hello-/ world/ "); // 'hello-world'

toLowerFirst String

String → String

Decapitalize first letter.

R_.toLowerFirst("HELLO WORLD"); // 'hELLO WORLD'

toPascalCase String

String → String

Converts string into PascalCase.

R_.toPascalCase("hello-world"); // 'HelloWorld' R_.toPascalCase("hello- world"); // 'HelloWorld' R_.toPascalCase(" hello-/ world/ "); // 'HelloWorld'

toScreamingSnakeCase String

String → String

Converts string into SCREAMING_SNAKE_CASE.

R_.toScreamingSnakeCase("hello-world"); // 'HELLO_WORLD' R_.toScreamingSnakeCase("hello- world"); // 'HELLO_WORLD' R_.toScreamingSnakeCase(" hello-/ world/ "); // 'HELLO_WORLD'

toSnakeCase String

String → String

Converts string into snake_case.

R_.toSnakeCase("hello-world"); // 'hello_world' R_.toSnakeCase("hello- world"); // 'hello_world' R_.toSnakeCase(" hello-/ world/ "); // 'hello_world'

toUpperFirst String

String → String

Capitalize first letter.

R_.toUpperFirst(""); // '' R_.toUpperFirst("hello world"); // 'Hello world'

trace Debugging

a → b → b

Function with side-effect. Logs input to console and returns that input. Similar to "log" but allows to label logged value. Should be used only in development.

compose(calculation2, R_.trace("Page A"), calculation1); // logs "Page A" and result of calculation1

unfoldObjectDots Object

Object → Object

Unfolds input object by dot delimetered path inside its keys.

R_.unfoldObjectDots({ "a.b.c": 1, "d.e.f": 2, g: 3 }); // {a: {b: {c: 1}}, d: {e: {f: 2}}, g: 3}

uniqAppend List

a → [a] → [a]

Returns a new list containing the unique contents of the given list, followed by the given element.

R_.uniqAppend("a", ["a", "b"]); // ["a", "b"] R_.uniqAppend("d", ["a", "b"]); // ["a", "b", "d"]

uniqDrop List

Number → [a] → [a]
Parameters
  • n
  • xs

    Collection

Returns array

Returns all unique but the first n elements of the given list, or transducer/transformer (or object with a drop method).

R_.uniqDrop(2, ["foo", "foo", "foo"]); // ["foo"]

uniqDropLast List

Number → [a] → [a]
Parameters
  • n
  • xs

    Collection

Returns Array

Returns all unique but the last n elements of the given list, or transducer/transformer (or object with a drop method).

R_.uniqDropLast(2, ["bar", "foo", "foo"]); // ["foo"]

uniqDropLastWhile List

(a → Boolean) → [a] → [a]
Parameters
  • fn

    The function called per iteration.

  • xs

    The collection to iterate over.

Returns array New array

Returns a new unique list excluding the last elements of a given list which satisfy the supplied predicate function. It passes each value to the supplied predicate function, skipping elements while the predicate function returns true.

R_.uniqDropLastWhile((x) => x !== 4, [1, 1, 1, 2, 3, 4, 3, 2, 1]); // [1, 2, 3, 4]

uniqDropWhile List

(a → Boolean) → [a] → [a]
Parameters
  • fn

    The function called per iteration.

  • xs

    The collection to iterate over.

Returns array New array

Returns a new unique list excluding the leading elements of a given list which satisfy the supplied predicate function. It passes each value to the supplied predicate function, skipping elements while the predicate function returns true.

R_.uniqDropWhile((x) => x !== 4, [1, 2, 3, 4, 3, 2, 1, 1, 1]); //=> [4, 3, 2, 1]

uniqFilter List

(a → Boolean) → [a] → [a]
Parameters
  • filtering

    filtering function

  • xs

    Data

Returns array Unique array of values

Returns unique values that were previously filtered by filtering.

R_.uniqFilter(R_.equalsLength(5), ["hello", "hello", "world"]); // ["hello", "world"]

uniqLength List

[a] → Number
Parameters
  • xs

    Data

Returns number Number of Unique values in input array

Returns number of unique values in an input array

R_.uniqLength(["hello", "world", "world"]); // 2

uniqMap List

(a → a) → [a] → [a]
Parameters
  • fn

    mapping function

  • xs

    Data

Returns array Unique array of values

Returns unique values previously returned by mapping.

R_.uniqMap(R_.equalsLength(5))(["hello", "hello", "world"]); // ["hello", "world"]

uniqPrepend List

a → [a] → [a]

Returns a new list containing the unique contents of the given list, starting by the given element.

R_.uniqPrepend("b", ["a", "b"]); // ["b", "a"] R_.uniqPrepend("d", ["a", "b"]); // ["d","a", "b"]

uniqTake List

Number → [a] → [a]
Parameters
  • n
Returns array

Returns the first n of unique elements of the given list, or transducer/transformer (or object with a take method).

R_.uniqTake(2, ["foo", "foo", "baz"]); //=> ['foo'] R_.uniqTake(3, ["foo", "foo", "baz"]); //=> ['foo', 'baz']

uniqTakeLast List

Number → [a] → [a]
Parameters
  • n
Returns array

Returns the last n of unique elements of the given list, or transducer/transformer (or object with a take method).

R_.uniqTakeLast(2, ["foo", "bar", "bar"]); //=> ['bar']

uniqTakeLastWhile List

(a → Boolean) → [a] → [a]
Parameters
  • fn

    The function called per iteration.

  • xs

    The collection to iterate over.

Returns array New array

Returns a new list containing the unique last n elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returns false. Excludes the element that caused the predicate function to fail. The predicate function is passed one argument: (value).

Acts as a transducer if a transformer is given in list position.

R_.uniqTakeLastWhile((x) => x !== 4, [1, 2, 3, 4, 3, 2, 1, 1]); // [3, 2, 1]

uniqTakeWhile List

(a → Boolean) → [a] → [a]
Parameters
  • fn

    The function called per iteration.

  • xs

    The collection to iterate over.

Returns array New array

Returns a new list containing the unique first n elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returns false. Excludes the element that caused the predicate function to fail. The predicate function is passed one argument: (value).

Acts as a transducer if a transformer is given in list position.

R_uniqTakeWhile((x) => x !== 4, [1, 2, 2, 1, 3, 4, 3, 2, 1]); // [1, 2, 3]

valueMirror Object

[String] → Object
Parameters
  • keyList

    List of values representing the keys and values of resulting object.

Returns Object Object, where keys and appropriate values equals to value in `keyList`.

Creates object mirror from list of keys.

const actionTypes = R_.valueMirror([ "ITEM_REQUEST", "ITEM_SUCCESS", "ITEM_ERROR", ]); const action = { type: actionTypes.ITEM_REQUEST }; action.type === actionTypes.ITEM_REQUEST; // true actionTypes.ITEM_SUCCESS; // "ITEM_SUCCESS"

viewEq Object

Parameters
  • lens
  • v

    value to equal

  • x
Returns *

Returns true if the given lens equals to given value

R_.viewEq(R.lensIndex(0), "foo", ["foo", "bar", "baz"]); //=> true

viewWith Object

Parameters
  • lens
  • v

    view function

  • x
Returns *

Applies custom view function on the given lens

R_.viewWith(R.lensIndex(0), R.pathEq(["foo"], "boo"), [{ foo: "boo" }]); //=> true R_.viewWith(R.lensIndex(0), R.divide(R.__, 2), [4]); //=> 2

xPairs List

a → [b] → [[a, b]]

Creates pairs from value and list of values. Value is always prepended to the pair.

See also xPairsRight.
R_.xPairs(1, [2, 3]); // [[1, 2], [1, 3]]

xPairsRight List

a → [b] → [[b, a]]

Creates pairs from value and list of values. Value is always appended as the last item to the pair.

See also xPairs.
R_.xPairsRight(1, [2, 3]); // [[2, 1], [3, 1]]