Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rambda/mod.ts

Faster and smaller alternative to Ramda
Go to Latest
import * as rambda from "https://deno.land/x/rambda@9.2.1/mod.ts";

Functions

It adds a and b.

Same as R.addIndex, but it will passed indexes are decreasing, instead of increasing.

It replaces index in array list with the result of replaceFn(list[i]).

It returns true, if all members of array list returns true, when applied as argument to predicate function.

It returns true, if all functions of predicates return true, when input is their argument.

It returns function that always returns x.

Logical AND

It returns true, if at least one member of list returns true, when passed to a predicate function.

It accepts list of predicates and returns a function. This function with its input will return true, if any of predicates returns true for this input.

It takes a list of functions and a list of values. Then it returns a list of values obtained by applying each function to each value.

It returns a new list, composed of consecutive n-tuples from a list.

It adds element x at the end of iterable.

It applies function fn to the list of arguments.

It makes a shallow clone of obj with setting or overriding the property prop with newValue.

It makes a shallow clone of obj with setting or overriding with newValue the property found with path.

Creates a function that is bound to a context.

It returns a function with input argument.

The method is also known as flatMap.

Restrict a number input to be within min and max limits.

It creates a deep copy of the input, which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.

It returns a comparator function that can be used in sort method.

It returns inverted version of origin function that accept input as argument.

It performs right-to-left function composition.

It returns a new string or array, which is the result of merging x and y.

It takes list with conditions and returns a new function fn that expects input as argument.

Accepts a converging function and a list of branching functions and returns a new function. When invoked, this new function is applied to some arguments, each branching function is applied to those same arguments. The results of each branching function are passed as arguments to the converging function to produce the return value.

It counts how many times predicate function returns true, when supplied with iteration of list.

It counts elements in a list after each instance of the input list is passed through transformFn function.

It expects a function as input and returns its curried version.

It returns a curried equivalent of the provided function, with the specified arity.

It decrements a number.

It returns defaultValue, if all of inputArguments are undefined, null or NaN.

It returns the uniq set of all elements in the first list a not contained in the second list b.

It returns a new object that does not contain property prop.

It returns howMany items dropped from beginning of list or string input.

It returns howMany items dropped from the end of list or string input.

It removes any successive duplicates according to R.equals.

It returns a new predicate function from firstPredicate and secondPredicate inputs.

When iterable is a string, then it behaves as String.prototype.endsWith. When iterable is a list, then it uses R.equals to determine if the target list ends in the same way as the given target.

It returns true if property prop in obj1 is equal to property prop in obj2 according to R.equals.

It deeply compares x and y and returns true if they are equal.

It takes object or array of functions as set of rules. These rules are applied to the iterable input to produce the result.

f
F

It filters list or object input using a predicate function.

It returns the first element of list that satisfy the predicate.

It returns the index of the first element of list satisfying the predicate function.

It returns the last element of list satisfying the predicate function.

It returns the index of the last element of list satisfying the predicate function.

It deeply flattens an array.

It returns function which calls fn with exchanged first and second argument.

It applies iterable function over all members of list and returns list.

It transforms a listOfPairs to an object.

It splits list according to a provided groupFn function and returns an object.

It returns separated version of list or string input, where separation is done with equality compareFn function.

It returns true if obj has property prop.

It will return true, if input object has truthy path(calculated with R.path).

It returns the first element of list or string input.

It returns true if its arguments a and b are identical.

It just passes back the supplied input argument.

It expects condition, onTrue and onFalse functions as inputs and it returns a new function with example name of fn.

It increments a number.

If input is string, then this method work as native String.includes.

It generates object with properties provided by condition and values provided by list array.

It returns the index of the first element of list equals to valueToFind.

It returns all but the last element of list or string input.

It returns a new list by applying a predicate function to all elements of list1 and list2 and keeping only these elements where predicate returns true.

It loops through listA and listB and returns the intersection of the two according to R.equals.

It adds a separator between members of list.

It returns true if x is instance of targetPrototype.

It returns true if x is empty.

It returns true if x is either null or undefined.

It returns a string of all list instances joined with a glue.

It applies list of function to a list of inputs.

It applies Object.keys over x and returns its keys.

It returns the last element of input, as the input can be either a string or an array.

It returns the last index of target in list array.

It returns the length property of list or string input.

It returns a lens for the given getter and setter functions.

It returns a lens that focuses on specified index.

It returns a lens that focuses on specified path.

It returns a lens that focuses on specified property prop.

It returns the result of looping through iterable with fn.

It works the same way as R.map does for objects. It is added as Ramda also has this method.

Curried version of String.prototype.match which returns empty array, when there is no match.

R.mathMod behaves like the modulo operator should mathematically, unlike the % operator (and by extension, R.modulo). So while -17 % 5 is -2, mathMod(-17, 5) is 3.

It returns the greater value between x and y.

It returns the greater value between x and y according to compareFn function.

It returns the mean value of list input.

It returns the median value of list input.

Same as R.mergeRight.

It merges all objects of list array sequentially and returns the result.

Creates a new object with the own properties of the first object merged with the own properties of the second object. If a key exists in both objects:

Same as R.merge, but in opposite direction.

It creates a copy of target object with overwritten newProps properties. Previously known as R.merge but renamed after Ramda did the same.

It takes two objects and a function, which will be used when there is an overlap between the keys.

It returns the lesser value between x and y.

It returns the lesser value between x and y according to compareFn function.

It changes a property of object on the base of provided path and transformer function.

Curried version of x%y.

It returns a copy of list with exchanged fromIndex and toIndex elements.

Curried version of x*y.

It returns true, if all members of array list returns false, when applied as argument to predicate function.

It returns a boolean negated version of input.

Curried version of input[index].

It creates an object with a single key-value pair.

It returns a partial copy of an obj without propsToOmit properties.

It passes the two inputs through unaryFn and then the results are passed as inputs the the binaryFn to receive the final result(binaryFn(unaryFn(FIRST_INPUT), unaryFn(SECOND_INPUT))).

It returns a function, which invokes only once fn function.

Logical OR

It returns a copied Object or Array with modified value received by applying function fn to lens focus.

It is very similar to R.curry, but you can pass initial arguments when you create the curried function.

R.partialObject is a curry helper designed specifically for functions accepting object as a single argument.

It will return array of two objects/arrays according to predicate function. The first member holds all instances of input that pass the predicate function, while the second member - those who doesn't.

If pathToSearch is 'a.b' then it will return 1 if obj is {a:{b:1}}.

It returns true if pathToSearch of input object is equal to target value.

It reads obj input and returns either R.path(pathToSearch, Record<string, unknown>) result or defaultValue input.

It loops over members of pathsToSearch as singlePath and returns the array produced by R.path(singlePath, Record<string, unknown>).

It returns a partial copy of an input containing only propsToPick properties.

Same as R.pick but it won't skip the missing props, i.e. it will assign them to undefined.

It performs left-to-right function composition.

It returns list of the values of property taken from the all objects inside list.

It adds element x at the beginning of list.

It returns the value of property propToFind in obj.

It returns true if obj has property propToFind and its value is equal to valueToMatch.

It returns true if property of obj is from target type.

It returns either defaultValue or the value of property in obj.

It takes list with properties propsToPick and returns a list with property values in obj.

It returns true if the object property satisfies a given predicate.

It returns list of numbers between startInclusive to endExclusive markers.

It has the opposite effect of R.filter.

It returns a copy of list input with removed index.

It replaces strOrRegex found in str with replacer.

It returns a reversed copy of list or string input.

It returns a copied Object or Array with modified lens focus set to replacer value.

It returns copy of list sorted by sortFn function, where sortFn needs to return only -1, 0 or 1.

It returns copy of list sorted by sortFn function, where sortFn function returns a value to compare, i.e. it doesn't need to return only -1, 0 or 1.

Curried version of String.prototype.split

It splits string or array at a given index.

It splits input into slices of sliceLength.

It splits list to two arrays according to a predicate function.

When iterable is a string, then it behaves as String.prototype.startsWith. When iterable is a list, then it uses R.equals to determine if the target list starts in the same way as the given target.

Curried version of x - y

It returns a merged list of x and y with all equal elements removed.

f
T

It returns all but the first element of input.

It returns the first howMany elements of input.

It returns the last howMany elements of input.

It applies function fn to input x and returns x.

It determines whether str matches regExpression.

It returns the result of applying function fn over members of range array.

It transforms an object to a list.

It returns function that runs fn in try/catch block. If there was an error, then fallback is used to return the result. Note that fn can be value or asynchronous/synchronous function(unlike Ramda where fallback can only be a synchronous function).

It accepts any input and it returns its type.

It calls a function fn with the list of values of the returned function.

It takes two lists and return a new list containing a merger of both list with removed duplicates.

It returns a new array containing only one copy of each element of list.

It applies uniqueness to input list based on function that defines what to be used for comparison between elements.

It returns a new array containing only one copy of each element in list according to predicate function.

The method returns function that will be called with argument input.

It returns a copy of list with updated element at index with newValue.

With correct input, this is nothing more than Object.values(Record<string, unknown>). If obj is not an object, then it returns an empty array.

It returns the value of lens focus over target object.

It pass input to predicate function and if the result is true, it will return the result of whenTrueFn(input). If the predicate returns false, then it will simply return input.

It returns true if all each property in conditions returns true when applied to corresponding property in input object.

Same as R.where, but it will return true if at least one condition check returns true.

It will return true if all of input object fully or partially include rule object.

It will return a new array, based on all members of source list that are not part of matchAgainst list.

Logical XOR

It will return a new array containing tuples of equally positions items from both x and y lists.

It will return a new object with keys of keys array and values of values array.