Ramda Adjunct 1.4.0

RA

RA

Source:

Methods

(static) cata(leftFn, rightFn, either) → {*}

Source:
Since:
Signature:
  • (a -> b) -> (a -> c) -> Either a -> b | c
Category:
  • Function
See also:

The catamorphism for either. If the either is right than the right function will be executed with the right value and the value of the function returned. Otherwise the left function will be called with the left value.

Example
const eitherR = Either.Right(1);
const eitherL = Either.Left(2);

RA.cata(identity, identity, eitherR); //=> 1
RA.cata(identity, identity, eitherL); //=> 2
Parameters:
Name Type Description
leftFn function

The left function that consumes the left value

rightFn function

The right function that consumes the right value

either Either

Either monad with catamorphic capabilities (cata or either method)

Returns:
Type
*

(static) defaults(defaultOptions, options) → (non-null) {Object}

Source:
Since:
Signature:
  • DefaultOptions -> Options -> Defaults
          DefaultOptions = Object
          Options = Object
          Defaults = Object
Category:
  • Object
See also:

Set properties only if they don't exist. Useful for passing defaults. Basically this function is the alias of merge.

Example
RA.defaults({ 'a': 2, 'b': 2 })({ 'a': 1 }); //=> { 'a': 1, 'b': 2 }
Parameters:
Name Type Description
defaultOptions Object

The default options

options Object

The options passed

Returns:

Merged option object

Type
Object

(static) isArray(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is Array.

Example
RA.isArray([]); //=> true
RA.isArray(null); //=> false
RA.isArray({}); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isAsyncFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is Async Function.

Example
RA.isAsyncFunction(async function test() { }); //=> true
RA.isAsyncFunction(null); //=> false
RA.isAsyncFunction(function test() { }); //=> false
RA.isAsyncFunction(() => {}); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isBoolean(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is Boolean.

Example
RA.isBoolean(false); //=> true
RA.isBoolean(true); //=> true
RA.isBoolean(null); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isDate(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is Date object.

Example
RA.isDate(new Date()); //=> true
RA.isDate('1997-07-16T19:20+01:00'); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isFinite(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is a finite Number.

Example
RA.isFinite(Infinity); //=> false
RA.isFinite(NaN); //=> false
RA.isFinite(-Infinity); //=> false

RA.isFinite(0); // true
RA.isFinite(2e64); // true

RA.isFinite('0');  // => false
                   // would've been true with global isFinite('0')
RA.isFinite(null); // => false
                   // would've been true with global isFinite(null)
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is Function.

Example
RA.isFunction(function test() { }); //=> true
RA.isFunction(function* test() { }); //=> true
RA.isFunction(async function test() { }); //=> true
RA.isFunction(() => {}); //=> true
RA.isFunction(null); //=> false
RA.isFunction('abc'); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isGeneratorFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is Generator Function.

Example
RA.isGeneratorFunction(function* test() { }); //=> true
RA.isGeneratorFunction(null); //=> false
RA.isGeneratorFunction(function test() { }); //=> false
RA.isGeneratorFunction(() => {}); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isInteger(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is a an integer.

Example
RA.isInteger(0); //=> true
RA.isInteger(1); //=> true
RA.isInteger(-100000); //=> true

RA.isInteger(0.1);       //=> false
RA.isInteger(Math.PI);   //=> false

RA.isInteger(NaN);       //=> false
RA.isInteger(Infinity);  //=> false
RA.isInteger(-Infinity); //=> false
RA.isInteger('10');      //=> false
RA.isInteger(true);      //=> false
RA.isInteger(false);     //=> false
RA.isInteger([1]);       //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNaN(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is NaN and its type is Number. It is a more robust version of the original, global isNaN().

Example
RA.isNaN(NaN); // => true
RA.isNaN(Number.NaN); // => true
RA.isNaN(0 / 0); // => true

// e.g. these would have been true with global isNaN().
RA.isNaN('NaN'); // => false
RA.isNaN(undefined); // => false
RA.isNaN({}); // => false
RA.isNaN('blabla'); // => false

RA.isNaN(true); // => false
RA.isNaN(null); // => false
RA.isNaN(37); // => false
RA.isNaN('37'); // => false
RA.isNaN('37.37'); // => false
RA.isNaN(''); // => false
RA.isNaN(' '); // => false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNilOrEmpty(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Returns true if the given value is its type's empty value, null or undefined.

Example
RA.isNilOrEmpty([1, 2, 3]); //=> false
RA.isNilOrEmpty([]); //=> true
RA.isNilOrEmpty(''); //=> true
RA.isNilOrEmpty(null); //=> true
RA.isNilOrEmpty(undefined): //=> true
RA.isNilOrEmpty({}); //=> true
RA.isNilOrEmpty({length: 0}); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotArray(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of Array

Example
RA.isNotArray([]); //=> false
RA.isNotArray(null); //=> true
RA.isNotArray({}); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotArrayLike(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Tests whether or not an object is similar to an array.

Example
RA.isNotArrayLike([]); //=> false
RA.isNotArrayLike(true); //=> true
RA.isNotArrayLike({}); //=> true
RA.isNotArrayLike({length: 10}); //=> true
RA.isNotArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotAsyncFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of Async Function

Example
RA.isNotAsyncFunction(async function test() { }); //=> false
RA.isNotAsyncFunction(null); //=> true
RA.isNotAsyncFunction(function test() { }); //=> true
RA.isNotAsyncFunction(() => {}); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotBoolean(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of Boolean.

Example
RA.isNotBoolean(false); //=> false
RA.isNotBoolean(true); //=> false
RA.isNotBoolean(null); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotDate(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is complement of Date object.

Example
RA.isNotDate(new Date()); //=> false
RA.isNotDate('1997-07-16T19:20+01:00'); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotEmpty(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Returns true if the given value is not its type's empty value; false otherwise.

Example
RA.isNotEmpty([1, 2, 3]); //=> true
RA.isNotEmpty([]); //=> false
RA.isNotEmpty(''); //=> false
RA.isNotEmpty(null); //=> true
RA.isNotEmpty(undefined): //=> true
RA.isNotEmpty({}); //=> false
RA.isNotEmpty({length: 0}); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotFinite(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is complement of finite Number.

Example
RA.isNotFinite(Infinity); //=> true
RA.isNotFinite(NaN); //=> true
RA.isNotFinite(-Infinity); //=> true

RA.isNotFinite(0); // false
RA.isNotFinite(2e64); // false

RA.isNotFinite('0');  // => true
RA.isNotFinite(null); // => true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of Function.

Example
RA.isNotFunction(function test() { }); //=> false
RA.isNotFunction(function* test() { }); //=> false
RA.isNotFunction(async function test() { }); //=> false
RA.isNotFunction(() => {}); //=> false
RA.isNotFunction(null); //=> true
RA.isNotFunction('abc'); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotGeneratorFunction(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of Generator Function

Example
RA.isNotGeneratorFunction(function* test() { }); //=> false
RA.isNotGeneratorFunction(null); //=> true
RA.isNotGeneratorFunction(function test() { }); //=> true
RA.isNotGeneratorFunction(() => {}); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotInteger(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is complement of an integer.

Example
RA.isNotInteger(0); //=> false
RA.isNotInteger(1); //=> false
RA.isNotInteger(-100000); //=> false

RA.isNotInteger(0.1);       //=> true
RA.isNotInteger(Math.PI);   //=> true

RA.isNotInteger(NaN);       //=> true
RA.isNotInteger(Infinity);  //=> true
RA.isNotInteger(-Infinity); //=> true
RA.isNotInteger('10');      //=> true
RA.isNotInteger(true);      //=> true
RA.isNotInteger(false);     //=> true
RA.isNotInteger([1]);       //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotNaN(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks whether the passed value is complement of NaN and its type is not Number.

Example
RA.isNotNaN(NaN); // => false
RA.isNotNaN(Number.NaN); // => false
RA.isNotNaN(0 / 0); // => false

RA.isNotNaN('NaN'); // => true
RA.isNotNaN(undefined); // => true
RA.isNotNaN({}); // => true
RA.isNotNaN('blabla'); // => true

RA.isNotNaN(true); // => true
RA.isNotNaN(null); // => true
RA.isNotNaN(37); // => true
RA.isNotNaN('37'); // => true
RA.isNotNaN('37.37'); // => true
RA.isNotNaN(''); // => true
RA.isNotNaN(' '); // => true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotNil(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of null or undefined.

Example
RA.isNotNil(null); //=> false
RA.isNotNil(undefined); //=> false
RA.isNotNil(0); //=> true
RA.isNotNil([]); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotNull(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of null.

Example
RA.isNotNull(1); //=> true
RA.isNotNull(undefined); //=> true
RA.isNotNull(null); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotNumber(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is a complement of Number primitive or object.

Example
RA.isNotNumber(5); // => false
RA.isNotNumber(Number.MAX_VALUE); // => false
RA.isNotNumber(-Infinity); // => false
RA.isNotNumber('5'); // => true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotObject(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of language type of Object.

Example
RA.isNotObject({}); //=> false
RA.isNotObject([]); //=> false
RA.isNotObject(() => {}); //=> false
RA.isNotObject(null); //=> true
RA.isNotObject(undefined); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotObjectLike(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is not object-like. A value is object-like if it's not null and has a typeof result of "object".

Example
RA.isNotObjectLike({}); //=> false
RA.isNotObjectLike([]); //=> false
RA.isNotObjectLike(() => {}); //=> true
RA.isNotObjectLike(null); //=> true
RA.isNotObjectLike(undefined); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotPlainObject(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Check to see if an object is a not plain object (created using {}, new Object() or Object.create(null)).

Example
class Bar {
  constructor() {
    this.prop = 'value';
  }
}

RA.isNotPlainObject(new Bar()); //=> true
RA.isNotPlainObject({ prop: 'value' }); //=> false
RA.isNotPlainObject(['a', 'b', 'c']); //=> true
RA.isNotPlainObject(Object.create(null); //=> false
RA.isNotPlainObject(new Object()); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotString(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement of String.

Example
RA.isNotString('abc'); //=> false
RA.isNotString(1); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNotUndefined(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is complement undefined.

Example
RA.isNotUndefined(1); //=> true
RA.isNotUndefined(undefined); //=> false
RA.isNotUndefined(null); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNull(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is null.

Example
RA.isNull(1); //=> false
RA.isNull(undefined); //=> false
RA.isNull(null); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isNumber(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is a Number primitive or object

Example
RA.isNumber(5); // => true
RA.isNumber(Number.MAX_VALUE); // => true
RA.isNumber(-Infinity); // => true
RA.isNumber('5'); // => false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isObject(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is language type of Object.

Example
RA.isObject({}); //=> true
RA.isObject([]); //=> true
RA.isObject(() => {}); //=> true
RA.isObject(null); //=> false
RA.isObject(undefined); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isObjectLike(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if value is object-like. A value is object-like if it's not null and has a typeof result of "object".

Example
RA.isObjectLike({}); //=> true
RA.isObjectLike([]); //=> true
RA.isObjectLike(() => {}); //=> false
RA.isObjectLike(null); //=> false
RA.isObjectLike(undefined); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isPlainObject(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Check to see if an object is a plain object (created using {}, new Object() or Object.create(null)).

Example
class Bar {
  constructor() {
    this.prop = 'value';
  }
}

RA.isPlainObject(new Bar()); //=> false
RA.isPlainObject({ prop: 'value' }); //=> true
RA.isPlainObject(['a', 'b', 'c']); //=> false
RA.isPlainObject(Object.create(null); //=> true
RA.isPlainObject(new Object()); //=> true
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isString(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is String.

Example
RA.isString('abc'); //=> true
RA.isString(1); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) isUndefined(val) → {Boolean}

Source:
Since:
Signature:
  • * -> Boolean
Category:
  • Type
See also:

Checks if input value is undefined.

Example
RA.isUndefined(1); //=> false
RA.isUndefined(undefined); //=> true
RA.isUndefined(null); //=> false
Parameters:
Name Type Description
val *

The value to test

Returns:
Type
Boolean

(static) liftF(fn) → {function}

Source:
Since:
Signature:
  • Apply a => (a... -> a) -> (a... -> a)
Category:
  • Function
See also:

"lifts" a function to be the specified arity, so that it may "map over" objects that satisfy the fantasy land Apply spec of algebraic structures.

Lifting is specific for scalaz and functional java implementations. Old version of fantasy land spec were not compatible with this approach, but as of fantasy land 1.0.0 Apply spec also adopted this approach.

This function acts as interop for ramda <= 0.23.0 and monet.js.

More info here.

Example
const { Maybe } = require('monet');

const add3 = (a, b, c) => a + b + c;
const madd3 = RA.liftF(add3);

madd3(Maybe.Some(10), Maybe.Some(15), Maybe.Some(17)); //=> Maybe.Some(42)
madd3(Maybe.Some(10), Maybe.Nothing(), Maybe.Some(17)); //=> Maybe.Nothing()
Parameters:
Name Type Description
fn function

The function to lift into higher context

Returns:

The lifted function

Type
function

(static) liftFN(arity, fn) → {function}

Source:
Since:
Signature:
  • Apply a => Number -> (a... -> a) -> (a... -> a)
Category:
  • Function
See also:

"lifts" a function to be the specified arity, so that it may "map over" objects that satisfy the fantasy land Apply spec of algebraic structures.

Lifting is specific for scalaz and functional java implementations. Old version of fantasy land spec were not compatible with this approach, but as of fantasy land 1.0.0 Apply spec also adopted this approach.

This function acts as interop for ramda <= 0.23.0 and monet.js.

More info here.

Example
const { Maybe } = require('monet');

const add3 = (a, b, c) => a + b + c;
const madd3 = RA.liftFN(3, add3);

madd3(Maybe.Some(10), Maybe.Some(15), Maybe.Some(17)); //=> Maybe.Some(42)
madd3(Maybe.Some(10), Maybe.Nothing(), Maybe.Some(17)); //=> Maybe.Nothing()
Parameters:
Name Type Description
arity Number

The arity of the lifter function

fn function

The function to lift into higher context

Returns:

The lifted function

Type
function

(static) list(…items) → {Array}

Source:
Since:
Signature:
  • a... -> [a...]
Category:
  • List
See also:

Creates a list from from arguments.

Example
RA.list('a', 'b', 'c'); //=> ['a', 'b', 'c']
Parameters:
Name Type Attributes Description
items * <repeatable>

The items of the feature list

Returns:

New list created from items

Type
Array

(static) noop() → {undefined}

Source:
Since:
Signature:
  • ... -> undefined
Category:
  • Function

A function that performs no operations.

Example
RA.noop(); //=> undefined
RA.noop(1, 2, 3); //=> undefined
Returns:
Type
undefined

(static) paths(ps, obj) → {Array}

Source:
Since:
Signature:
  • [[k]] -> {k: v} - [v]
Category:
  • List
See also:

Acts as multiple path: arrays of paths in, array of values out. Preserves order.

Example
const obj = {
  a: { b: { c: 1 } },
  x: 2,
};

RA.paths([['a', 'b', 'c'], ['x']], obj); //=> [1, 2]
Parameters:
Name Type Description
ps Array

The property paths to fetch

obj Object

The object to query

Returns:

The corresponding values or partially applied function

Type
Array

(static) pickIndexes(indexes, list) → {Array}

Source:
Since:
Signature:
  • [Number] -> [a] -> [a]
Category:
  • List
See also:

Picks values from list by indexes.

Example
RA.pickIndexes([0, 2], ['a', 'b', 'c']); //=> ['a', 'c']
Parameters:
Name Type Description
indexes Array

The indexes to pick

list Array

The list to pick values from

Returns:

New array containing only values at indexes

Type
Array

(static) resetToDefault(defaultOptions, options) → (non-null) {Object}

Source:
Since:
Signature:
  • DefaultOptions -> Options -> Defaults
          DefaultOptions = Object
          Options = Object
          Defaults = Object
Category:
  • Object
See also:

Reset properties of the object to their default values.

Example
RA.resetToDefault({ 'a': 1 }, { 'a': 2, 'b': 2 }); //=> { 'a': 1, 'b': 2 }
Parameters:
Name Type Description
defaultOptions Object

The default options

options Object

The options passed

Returns:

Merged option object

Type
Object

(static) stubUndefined() → {undefined}

Source:
Since:
Signature:
  • ... -> undefined
Category:
  • Function

A function that returns undefined.

Example
RA.stubUndefined(); //=> undefined
RA.stubUndefined(1, 2, 3); //=> undefined
Returns:
Type
undefined