x/ramda@v0.27.2

🐏 Practical functional Javascript
Latest
dist/
scripts/
source/
test/
import * as ramda from "https://deno.land/x/ramda@v0.27.2/mod.ts";

Variables

__

A special placeholder value used to specify "gaps" within curried functions, allowing partial application of any combination of arguments, regardless of their positions.

add

Adds two values.

addIndex

Creates a new list iteration function from an existing one by adding two new parameters to its callback function: the current index, and the entire list.

adjust

Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

all

Returns true if all elements of the list match the predicate, false if there are any that don't.

allPass

Takes a list of predicates and returns a predicate that returns true for a given list of arguments if every one of the provided predicates is satisfied by those arguments.

always

Returns a function that always returns the given value. Note that for non-primitives the value returned is a reference to the original value.

and

Returns true if both arguments are true; false otherwise.

andThen

Returns the result of applying the onSuccess function to the value inside a successfully resolved promise. This is useful for working with promises inside function compositions.

any

Returns true if at least one of the elements of the list match the predicate, false otherwise.

anyPass

Takes a list of predicates and returns a predicate that returns true for a given list of arguments if at least one of the provided predicates is satisfied by those arguments.

ap

ap applies a list of functions to a list of values.

aperture

Returns a new list, composed of n-tuples of consecutive elements. If n is greater than the length of the list, an empty list is returned.

append

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

apply

Applies function fn to the argument list args. This is useful for creating a fixed-arity function from a variadic function. fn should be a bound function if context is significant.

applySpec

Given a spec object recursively mapping properties to functions, creates a function producing an object of the same structure, by mapping each property to the result of calling its associated function with the supplied arguments.

applyTo

Takes a value and applies a function to it.

ascend

Makes an ascending comparator function out of a function that returns a value that can be compared with < and >.

assoc

Makes a shallow clone of an object, setting or overriding the specified property with the given value. Note that this copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

assocPath

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. Note that this copies and flattens prototype properties onto the new object as well. All non-primitive properties are copied by reference.

binary

Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.

bind

Creates a function that is bound to a context. Note: R.bind does not provide the additional argument-binding capabilities of Function.prototype.bind.

both

A function which calls the two provided functions and returns the && of the results. It returns the result of the first function if it is false-y and the result of the second function otherwise. Note that this is short-circuited, meaning that the second function will not be invoked if the first returns a false-y value.

call

Returns the result of calling its first argument with the remaining arguments. This is occasionally useful as a converging function for R.converge: the first branch can produce a function while the remaining branches produce values to be passed to that function as its arguments.

chain

chain maps a function over a list and concatenates the results. chain is also known as flatMap in some libraries.

clamp

Restricts a number to be within a range.

clone

Creates a deep copy of the source that can be used in place of the source object without retaining any references to it. The source object may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates. Functions are assigned by reference rather than copied.

collectBy

Splits a list into sub-lists, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.

comparator

Makes a comparator function out of a function that reports whether the first element is less than the second.

complement

Takes a function f and returns a function g such that if called with the same arguments when f returns a "truthy" value, g returns false and when f returns a "falsy" value g returns true.

composeWith

Performs right-to-left function composition using transforming function. The last function may have any arity; the remaining functions must be unary.

concat

Returns the result of concatenating the given lists or strings.

cond

Returns a function, fn, which encapsulates if/else, if/else, ... logic. R.cond takes a list of [predicate, transformer] pairs. All of the arguments to fn are applied to each of the predicates in turn until one returns a "truthy" value, at which point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates matches, fn returns undefined.

construct

Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.

constructN

Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. The arity of the function returned is specified to allow using variadic constructor functions.

converge

Accepts a converging function and a list of branching functions and returns a new function. The arity of the new function is the same as the arity of the longest branching function. When invoked, this new function is applied to some arguments, and 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.

countBy

Counts the elements of a list according to how many match each value of a key generated by the supplied function. Returns an object mapping the keys produced by fn to the number of occurrences in the list. Note that all keys are coerced to strings because of how JavaScript objects work.

curry

Returns a curried equivalent of the provided function. The curried function has two unusual capabilities. First, its arguments needn't be provided one at a time. If f is a ternary function and g is R.curry(f), the following are equivalent:

curryN

Returns a curried equivalent of the provided function, with the specified arity. The curried function has two unusual capabilities. First, its arguments needn't be provided one at a time. If g is R.curryN(3, f), the following are equivalent:

dec

Decrements its argument.

defaultTo

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

descend

Makes a descending comparator function out of a function that returns a value that can be compared with < and >.

difference

Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Objects and Arrays are compared in terms of value equality, not reference equality.

differenceWith

Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.

dissoc

Returns a new object that does not contain a prop property.

dissocPath

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

divide

Divides two numbers. Equivalent to a / b.

drop

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

dropLast

Returns a list containing all but the last n elements of the given list.

dropLastWhile

Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function. It passes each value from the right to the supplied predicate function, skipping elements until the predicate function returns a falsy value. The predicate function is applied to one argument: (value).

dropRepeats

Returns a new list without any consecutively repeating elements. R.equals is used to determine equality.

dropRepeatsWith

Returns a new list without any consecutively repeating elements. Equality is determined by applying the supplied predicate to each pair of consecutive elements. The first element in a series of equal elements will be preserved.

dropWhile

Returns a new 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. The predicate function is applied to one argument: (value).

either

A function wrapping calls to the two functions in an || operation, returning the result of the first function if it is truth-y and the result of the second function otherwise. Note that this is short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value.

empty

Returns the empty value of its argument's type. Ramda defines the empty value of Array ([]), Object ({}), String (''), TypedArray (Uint8Array [], Float32Array [], etc), and Arguments. Other types are supported if they define <Type>.empty, <Type>.prototype.empty or implement the FantasyLand Monoid spec.

endsWith

Checks if a list ends with the provided sublist.

eqBy

Takes a function and two values in its domain and returns true if the values map to the same value in the codomain; false otherwise.

eqProps

Reports whether two objects have the same value, in R.equals terms, for the specified property. Useful as a curried predicate.

equals

Returns true if its arguments are equivalent, false otherwise. Handles cyclical data structures.

evolve

Creates a new object by recursively evolving a shallow copy of object, according to the transformation functions. All non-primitive properties are copied by reference.

F

A function that always returns false. Any passed in parameters are ignored.

filter

Takes a predicate and a Filterable, and returns a new filterable of the same type containing the members of the given filterable which satisfy the given predicate. Filterable objects include plain objects or any object that has a filter method such as Array.

find

Returns the first element of the list which matches the predicate, or undefined if no element matches.

findIndex

Returns the index of the first element of the list which matches the predicate, or -1 if no element matches.

findLast

Returns the last element of the list which matches the predicate, or undefined if no element matches.

findLastIndex

Returns the index of the last element of the list which matches the predicate, or -1 if no element matches.

flatten

Returns a new list by pulling every item out of it (and all its sub-arrays) and putting them in a new array, depth-first.

flip

Returns a new function much like the supplied one, except that the first two arguments' order is reversed.

forEach

Iterate over an input list, calling a provided function fn for each element in the list.

forEachObjIndexed

Iterate over an input object, calling a provided function fn for each key and value in the object.

fromPairs

Creates a new object from a list key-value pairs. If a key appears in multiple pairs, the rightmost pair is included in the object.

groupBy

Splits a list into sub-lists stored in an object, based on the result of calling a key-returning function on each element, and grouping the results according to values returned.

groupWith

Takes a list and returns a list of lists where each sublist's elements are all satisfied pairwise comparison according to the provided function. Only adjacent elements are passed to the comparison function.

gt

Returns true if the first argument is greater than the second; false otherwise.

gte

Returns true if the first argument is greater than or equal to the second; false otherwise.

has

Returns whether or not an object has an own property with the specified name

hasIn

Returns whether or not an object or its prototype chain has a property with the specified name

hasPath

Returns whether or not a path exists in an object. Only the object's own properties are checked.

head

Returns the first element of the given list or string. In some libraries this function is named first.

identical

Returns true if its arguments are identical, false otherwise. Values are identical if they reference the same memory. NaN is identical to NaN; 0 and -0 are not identical.

identity

A function that does nothing but return the parameter supplied to it. Good as a default or placeholder function.

ifElse

Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

inc

Increments its argument.

includes

Returns true if the specified value is equal, in R.equals terms, to at least one element of the given list; false otherwise. Also works with strings.

indexBy

Given a function that generates a key, turns a list of objects into an object indexing the objects by the given key. Note that if multiple objects generate the same value for the indexing key only the last value will be included in the generated object.

indexOf

Returns the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. R.equals is used to determine equality.

init

Returns all but the last element of the given list or string.

innerJoin

Takes a predicate pred, a list xs, and a list ys, and returns a list xs' comprising each of the elements of xs which is equal to one or more elements of ys according to pred.

insert

Inserts the supplied element into the list, at the specified index. _Note that

insertAll

Inserts the sub-list into the list, at the specified index. Note that this is not destructive: it returns a copy of the list with the changes. No lists have been harmed in the application of this function.

intersection

Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.

intersperse

Creates a new list with the separator interposed between elements.

into

Transforms the items of the list with the transducer and appends the transformed items to the accumulator using an appropriate iterator function based on the accumulator type.

invert

Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array.

invertObj

Returns a new object with the keys of the given object as values, and the values of the given object, which are coerced to strings, as keys. Note that the last key found is preferred when handling the same value.

invoker

Turns a named method with a specified arity into a function that can be called directly supplied with arguments and a target object.

is

See if an object (val) is an instance of the supplied constructor. This function will check up the inheritance chain, if any.

isEmpty

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

isNil

Checks if the input value is null or undefined.

join

Returns a string made by inserting the separator between each element and concatenating all the elements into a single string.

juxt

juxt applies a list of functions to a list of values.

keys

Returns a list containing the names of all the enumerable own properties of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

keysIn

Returns a list containing the names of all the properties of the supplied object, including prototype properties. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

last

Returns the last element of the given list or string.

lastIndexOf

Returns the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. R.equals is used to determine equality.

length

Returns the number of elements in the array by returning list.length.

lens

Returns a lens for the given getter and setter functions. The getter "gets" the value of the focus; the setter "sets" the value of the focus. The setter should not mutate the data structure.

lensIndex

Returns a lens whose focus is the specified index.

lensPath

Returns a lens whose focus is the specified path.

lensProp

Returns a lens whose focus is the specified property.

lift

"lifts" a function of arity > 1 so that it may "map over" a list, Function or other object that satisfies the FantasyLand Apply spec.

liftN

"lifts" a function to be the specified arity, so that it may "map over" that many lists, Functions or other objects that satisfy the FantasyLand Apply spec.

lt

Returns true if the first argument is less than the second; false otherwise.

lte

Returns true if the first argument is less than or equal to the second; false otherwise.

map

Takes a function and a functor, applies the function to each of the functor's values, and returns a functor of the same shape.

mapAccum

The mapAccum function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.

mapAccumRight

The mapAccumRight function behaves like a combination of map and reduce; it applies a function to each element of a list, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new list.

mapObjIndexed

An Object-specific version of map. The function is applied to three arguments: (value, key, obj). If only the value is significant, use map instead.

match

Tests a regular expression against a String. Note that this function will return an empty array when there are no matches. This differs from String.prototype.match which returns null when there are no matches.

mathMod

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. mathMod requires Integer arguments, and returns NaN when the modulus is zero or negative.

max

Returns the larger of its two arguments.

maxBy

Takes a function and two values, and returns whichever value produces the larger result when passed to the provided function.

mean

Returns the mean of the given list of numbers.

median

Returns the median of the given list of numbers.

memoizeWith

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

mergeAll

Creates one new object with the own properties from a list of objects. If a key exists in more than one object, the value from the last object it exists in will be used.

mergeDeepLeft

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:

  • and both values are objects, the two values will be recursively merged
  • otherwise the value from the first object will be used.
mergeDeepRight

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:

  • and both values are objects, the two values will be recursively merged
  • otherwise the value from the second object will be used.
mergeDeepWith

Creates a new object with the own properties of the two provided objects. If a key exists in both 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.
mergeDeepWithKey

Creates a new object with the own properties of the two provided objects. If a key exists in both 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.
mergeLeft

Create 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, the value from the first object will be used.

mergeRight

Create 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, the value from the second object will be used.

mergeWith

Creates a new object with the own properties of the two provided objects. If a key exists in both objects, the provided function is applied to the values associated with the key in each object, with the result being used as the value associated with the key in the returned object.

mergeWithKey

Creates a new object with the own properties of the two provided objects. If a key exists in both objects, the provided function is applied to the key and the values associated with the key in each object, with the result being used as the value associated with the key in the returned object.

min

Returns the smaller of its two arguments.

minBy

Takes a function and two values, and returns whichever value produces the smaller result when passed to the provided function.

modify

Creates a copy of the passed object by applying an fn function to the given prop property.

modifyPath

Creates a shallow clone of the passed object by applying an fn function to the value at the given path.

modulo

Divides the first parameter by the second and returns the remainder. Note that this function preserves the JavaScript-style behavior for modulo. For mathematical modulo see mathMod.

move

Move an item, at index from, to index to, in a list of elements. A new list will be created containing the new elements order.

multiply

Multiplies two numbers. Equivalent to a * b but curried.

nAry

Wraps a function of any arity (including nullary) in a function that accepts exactly n parameters. Any extraneous parameters will not be passed to the supplied function.

negate

Negates its argument.

none

Returns true if no elements of the list match the predicate, false otherwise.

not

A function that returns the ! of its argument. It will return true when passed false-y value, and false when passed a truth-y one.

nth

Returns the nth element of the given list or string. If n is negative the element at index length + n is returned.

nthArg

Returns a function which returns its nth argument.

o

o is a curried composition function that returns a unary function. Like compose, o performs right-to-left function composition. Unlike compose, the rightmost function passed to o will be invoked with only one argument. Also, unlike compose, o is limited to accepting only 2 unary functions. The name o was chosen because of its similarity to the mathematical composition operator ∘.

objOf

Creates an object containing a single key:value pair.

of

Returns a singleton array containing the value provided.

omit

Returns a partial copy of an object omitting the keys specified.

on

Takes a binary function f, a unary function g, and two values. Applies g to each value, then applies the result of each to f.

once

Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be called once, no matter how many times the returned function is invoked. The first value calculated is returned in subsequent invocations.

or

Returns true if one or both of its arguments are true. Returns false if both arguments are false.

otherwise

Returns the result of applying the onFailure function to the value inside a failed promise. This is useful for handling rejected promises inside function compositions.

over

Returns the result of "setting" the portion of the given data structure focused by the given lens to the result of applying the given function to the focused value.

pair

Takes two arguments, fst and snd, and returns [fst, snd].

partial

Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided initially followed by the arguments provided to g.

partialObject

Takes a function f and an object, and returns a function g. When applied, g returns the result of applying f to the object provided initially merged deeply (right) with the object provided as an argument to g.

partialRight

Takes a function f and a list of arguments, and returns a function g. When applied, g returns the result of applying f to the arguments provided to g followed by the arguments provided initially.

partition

Takes a predicate and a list or other Filterable object and returns the pair of filterable objects of the same type of elements which do and do not satisfy, the predicate, respectively. Filterable objects include plain objects or any object that has a filter method such as Array.

path

Retrieve the value at a given path.

pathEq

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

pathOr

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

paths

Retrieves the values at given paths of an object.

pathSatisfies

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

pick

Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.

pickAll

Similar to pick except that this one includes a key: undefined pair for properties that don't exist.

pickBy

Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.

pipeWith

Performs left-to-right function composition using transforming function. The first function may have any arity; the remaining functions must be unary.

pluck

Returns a new list by plucking the same named property off all objects in the list supplied.

prepend

Returns a new list with the given element at the front, followed by the contents of the list.

product

Multiplies together all the elements of a list.

project

Reasonable analog to SQL select statement.

promap

Takes two functions as pre- and post- processors respectively for a third function, i.e. promap(f, g, h)(x) === g(h(f(x))).

prop

Returns a function that when supplied an object returns the indicated property of that object, if it exists.

propEq

Returns true if the specified object property is equal, in R.equals terms, to the given value; false otherwise. You can test multiple properties with R.whereEq.

propIs

Returns true if the specified object property is of the given type; false otherwise.

propOr

Return the specified property of the given non-null object if the property is present and it's value is not null, undefined or NaN.

props

Acts as multiple prop: array of keys in, array of values out. Preserves order.

propSatisfies

Returns true if the specified object property satisfies the given predicate; false otherwise. You can test multiple properties with R.where.

range

Returns a list of numbers from from (inclusive) to to (exclusive).

reduce

Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

reduceBy

Groups the elements of the list according to the result of calling the String-returning function keyFn on each element and reduces the elements of each group to a single value via the reducer function valueFn.

reduced

Returns a value wrapped to indicate that it is the final value of the reduce and transduce functions. The returned value should be considered a black box: the internal structure is not guaranteed to be stable.

reduceRight

Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

reduceWhile

Like reduce, reduceWhile returns a single item by iterating through the list, successively calling the iterator function. reduceWhile also takes a predicate that is evaluated before each step. If the predicate returns false, it "short-circuits" the iteration and returns the current value of the accumulator.

reject

The complement of filter.

remove

Removes the sub-list of list starting at index start and containing count elements. Note that this is not destructive: it returns a copy of the list with the changes. No lists have been harmed in the application of this function.

repeat

Returns a fixed list of size n containing a specified identical value.

replace

Replace a substring or regex match in a string with a replacement.

reverse

Returns a new list or string with the elements or characters in reverse order.

scan

Scan is similar to reduce, but returns a list of successively reduced values from the left

sequence

Transforms a Traversable of Applicative into an Applicative of Traversable.

set

Returns the result of "setting" the portion of the given data structure focused by the given lens to the given value.

slice

Returns the elements of the given list or string (or object with a slice method) from fromIndex (inclusive) to toIndex (exclusive).

sort

Returns a copy of the list, sorted according to the comparator function, which should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal. Please note that this is a copy of the list. It does not modify the original.

sortBy

Sorts the list according to the supplied function.

sortWith

Sorts a list according to a list of comparators.

split

Splits a string into an array of strings based on the given separator.

splitAt

Splits a given list or string at a given index.

splitEvery

Splits a collection into slices of the specified length.

splitWhen

Takes a list and a predicate and returns a pair of lists with the following properties:

splitWhenever

Splits an array into slices on every occurrence of a value.

startsWith

Checks if a list starts with the provided sublist.

subtract

Subtracts its second argument from its first argument.

sum

Adds together all the elements of a list.

symmetricDifference

Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both.

symmetricDifferenceWith

Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.

T

A function that always returns true. Any passed in parameters are ignored.

tail

Returns all but the first element of the given list or string (or object with a tail method).

take

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

takeLast

Returns a new list containing the last n elements of the given list. If n > list.length, returns a list of list.length elements.

takeLastWhile

Returns a new list containing the 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).

takeWhile

Returns a new list containing the 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).

tap

Runs the given function with the supplied object, then returns the object.

test

Determines whether a given string matches a given regular expression.

thunkify

Creates a thunk out of a function. A thunk delays a calculation until its result is needed, providing lazy evaluation of arguments.

times

Calls an input function n times, returning an array containing the results of those function calls.

toLower

The lower case version of a string.

toPairs

Converts an object into an array of key, value arrays. Only the object's own properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

toPairsIn

Converts an object into an array of key, value arrays. The object's own properties and prototype properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

toString

Returns the string representation of the given value. eval'ing the output should result in a value equivalent to the input value. Many of the built-in toString methods do not satisfy this requirement.

toUpper

The upper case version of a string.

transduce

Initializes a transducer using supplied iterator function. Returns a single item by iterating through the list, successively calling the transformed iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.

transpose

Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n.

traverse

Maps an Applicative-returning function over a Traversable, then uses sequence to transform the resulting Traversable of Applicative into an Applicative of Traversable.

trim

Removes (strips) whitespace from both ends of the string.

tryCatch

tryCatch takes two functions, a tryer and a catcher. The returned function evaluates the tryer; if it does not throw, it simply returns the result. If the tryer does throw, the returned function evaluates the catcher function and returns its result. Note that for effective composition with this function, both the tryer and catcher functions must return the same type of results.

type

Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them all as 'Object'.

unapply

Takes a function fn, which takes a single array argument, and returns a function which:

unary

Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.

uncurryN

Returns a function of arity n from a (manually) curried function. Note that, the returned function is actually a ramda style curryied function, which can accept one or more arguments in each function calling.

unfold

Builds a list from a seed value. Accepts an iterator function, which returns either false to stop iteration or an array of length 2 containing the value to add to the resulting list and the seed to be used in the next call to the iterator function.

union

Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.

unionWith

Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements. If an element exists in both lists, the first element from the first list will be used.

uniq

Returns a new list containing only one copy of each element in the original list. R.equals is used to determine equality.

uniqBy

Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items. R.equals is used for comparison.

uniqWith

Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied predicate to two list elements. Prefers the first item if two items compare equal based on the predicate.

unless

Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, the function will return the result of calling the whenFalseFn function with the same argument. If the predicate is satisfied, the argument is returned as is.

unnest

Shorthand for R.chain(R.identity), which removes one level of nesting from any Chain.

until

Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as the initial value. It does so by applying the transformation until the predicate is satisfied, at which point it returns the satisfactory value.

update

Returns a new copy of the array with the element at the provided index replaced with the given value.

useWith

Accepts a function fn and a list of transformer functions and returns a new curried function. When the new function is invoked, it calls the function fn with parameters consisting of the result of calling each supplied handler on successive arguments to the new function.

values

Returns a list of all the enumerable own properties of the supplied object. Note that the order of the output array is not guaranteed across different JS platforms.

valuesIn

Returns a list of all the properties, including prototype properties, of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.

view

Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which portion of the data structure is visible.

when

Tests the final argument by passing it to the given predicate function. If the predicate is satisfied, the function will return the result of calling the whenTrueFn function with the same argument. If the predicate is not satisfied, the argument is returned as is.

where

Takes a spec object and a test object; returns true if the test satisfies the spec. Each of the spec's own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. where returns true if all the predicates return true, false otherwise.

whereAny

Takes a spec object and a test object; each of the spec's own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. whereAny returns true if at least one of the predicates return true, false otherwise.

whereEq

Takes a spec object and a test object; returns true if the test satisfies the spec, false otherwise. An object satisfies the spec if, for each of the spec's own properties, accessing that property of the object gives the same value (in R.equals terms) as accessing that property of the spec.

without

Returns a new list without values in the first argument. R.equals is used to determine equality.

xor

Exclusive disjunction logical operation. Returns true if one of the arguments is truthy and the other is falsy. Otherwise, it returns false.

xprod

Creates a new list out of the two supplied by creating each possible pair from the lists.

zip

Creates a new list out of the two supplied by pairing up equally-positioned items from both lists. The returned list is truncated to the length of the shorter of the two input lists. Note: zip is equivalent to zipWith(function(a, b) { return [a, b] }).

zipObj

Creates a new object out of a list of keys and a list of values. Key/value pairing is truncated to the length of the shorter of the two lists. Note: zipObj is equivalent to pipe(zip, fromPairs).

zipWith

Creates a new list out of the two supplied by applying the function to each equally-positioned pair in the lists. The returned list is truncated to the length of the shorter of the two input lists.

Functions

compose

Performs right-to-left function composition. The last argument may have any arity; the remaining arguments must be unary.

pipe

Performs left-to-right function composition. The first argument may have any arity; the remaining arguments must be unary.

Ramda=============
A practical functional library for JavaScript programmers.
[![Build Status](https://github.com/ramda/ramda/workflows/Build/badge.svg)](https://github.com/ramda/ramda/actions?query=workflow%3ABuild)[![Test Coverage](https://api.codeclimate.com/v1/badges/953a3c5ee423e5301d18/test_coverage)](https://codeclimate.com/github/ramda/ramda/test_coverage)[![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda)[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/ramda)[![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda)[![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)


Why Ramda?----------
<img src="https://ramdajs.com/ramdaFilled_200x235.png" width="170" height="190" align="right" hspace="12" />
There are already several excellent libraries with a functional flavor. Typically, they are meant to be general-purpose toolkits, suitable for working in multiple paradigms. Ramda has a more focused goal. We wanted a library designed specifically for a functional programming style, one that makes it easy to create functional pipelines, one that never mutates user data.


What's Different?-----------------
The primary distinguishing features of Ramda are:
* Ramda emphasizes a purer functional style. Immutability and side-effect free functions are at the heart of its design philosophy. This can help you get the job done with simple, elegant code.
* Ramda functions are automatically curried. This allows you to easily build up new functions from old ones simply by not supplying the final parameters.
* The parameters to Ramda functions are arranged to make it convenient for currying. The data to be operated on is generally supplied last.
The last two points together make it very easy to build functions as sequences of simpler functions, each of which transforms the data and passes it along to the next. Ramda is designed to support this style of coding.


Introductions-------------
* [Introducing Ramda](http://buzzdecafe.github.io/code/2014/05/16/introducing-ramda) by Buzz de Cafe* [Why Ramda?](http://fr.umio.us/why-ramda/) by Scott Sauyet* [Favoring Curry](http://fr.umio.us/favoring-curry/) by Scott Sauyet* [Why Curry Helps](https://hughfdjackson.com/javascript/why-curry-helps/) by Hugh Jackson* [Hey Underscore, You're Doing It Wrong!](https://www.youtube.com/watch?v=m3svKOdZijA&app=desktop) by Brian Lonsdorf* [Thinking in Ramda](https://randycoulman.com/blog/categories/thinking-in-ramda) by Randy Coulman


Philosophy----------Using Ramda should feel much like just using JavaScript.It is practical, functional JavaScript. We're not introducinglambda expressions in strings, we're not borrowing consed lists, we're not porting over all of the Clojure functions.
Our basic data structures are plain JavaScript objects, and ourusual collections are JavaScript arrays. We also keep othernative features of JavaScript, such as functions as objectswith properties.
Functional programming is in good part about immutable objects and side-effect free functions. While Ramda does not *enforce* this, itenables such style to be as frictionless as possible.
We aim for an implementation both clean and elegant, but the API is king.We sacrifice a great deal of implementation elegance for even a slightlycleaner API.
Last but not least, Ramda strives for performance. A reliable and quickimplementation wins over any notions of functional purity.


Installation------------
To use with node:
```bash$ npm install ramda```
Then in the console:
```javascriptconst R = require('ramda');```
To use directly in [Deno](https://deno.land):```javascriptimport * as R from "https://deno.land/x/ramda/index.js";```
or using Nest.land:```javascriptimport * as R from "https://x.nest.land/ramda@0.27.0/mod.ts";```
To use directly in the browser:
```html<script src="path/to/yourCopyOf/ramda.js"></script>```
or the minified version:
```html<script src="path/to/yourCopyOf/ramda.min.js"></script>```
or from a CDN, either cdnjs:
```html<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>```
or one of the below links from [jsDelivr](http://jsdelivr.com):
```html<script src="//cdn.jsdelivr.net/npm/ramda@0.25.0/dist/ramda.min.js"></script><script src="//cdn.jsdelivr.net/npm/ramda@0.25/dist/ramda.min.js"></script><script src="//cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js"></script>```
(note that using `latest` is taking a significant risk that ramda API changes could break your code.)
These script tags add the variable `R` on the browser's global scope.
Or you can inject ramda into virtually any unsuspecting website using [the bookmarklet](https://github.com/ramda/ramda/blob/master/BOOKMARKLET.md).
**Note for versions > 0.25**Ramda versions > 0.25 don't have a default export.So instead of `import R from 'ramda';`, one has to use `import * as R from 'ramda';`Or better yet, import only the required functions via `import { functionName } from 'ramda';`
### Build
`npm run build` creates `es`, `src` directories and updates both __dist/ramda.js__ and __dist/ramda.min.js__
#### Partial Builds
It is possible to build Ramda with a subset of the functionality to reduce its file size. Ramda's build system supports this with command line flags. For example if you're using `R.compose`, `R.reduce`, and `R.filter` you can create a partial build with:
npm run --silent partial-build compose reduce filter > dist/ramda.custom.js
This requires having Node/io.js installed and ramda's dependencies installed (just use `npm install` before running partial build).
### Install specific functions
[Install individual functions](https://bitsrc.io/ramda/ramda) with bit, npm and yarn without installing the whole library.
Documentation-------------
Please review the [API documentation](https://ramdajs.com/docs/).
Also available is our [Cookbook](https://github.com/ramda/ramda/wiki/Cookbook) of functions built from Ramda that you may find useful.

The Name--------
Ok, so we like sheep. That's all. It's a short name, not already taken. It could as easily have been `eweda`, but then we would be forced to say _eweda lamb!_, and no one wants that. For non-English speakers, lambs are baby sheep, ewes are female sheep, and rams are male sheep. So perhaps ramda is a grown-up lambda... but probably not.



Running The Test Suite----------------------
**Console:**
To run the test suite from the console, you need to have `mocha` installed:
npm install -g mocha
Then from the root of the project, you can just call
mocha
Alternately, if you've installed the dependencies, via:
npm install
then you can run the tests (and get detailed output) by running:
npm test
**Browser:**
You can use [testem](https://github.com/airportyh/testem) totest across different browsers (or even headlessly), with livereloading oftests. Install testem (`npm install -g testem`) and run `testem`. Open thelink provided in your browser and you will see the results in your terminal.
If you have _PhantomJS_ installed, you can run `testem -l phantomjs` to run thetests completely headlessly.

Usage-----------------
For `v0.25` and up, import the whole library or pick ES modules directly from the library:
```jsimport * as R from 'ramda'
const {identity} = RR.map(identity, [1, 2, 3])```
Destructuring imports from ramda *does not necessarily prevent importing the entire library*. You can manually cherry-pick methods like the following, which would only grab the parts necessary for `identity` to work:
```jsimport identity from 'ramda/src/identity'
identity()```
Manually cherry picking methods is cumbersome, however. Most bundlers like Webpack and Rollup offer tree-shaking as a way to drop unused Ramda code and reduce bundle size, but their performance varies, discussed [here](https://github.com/scabbiaza/ramda-webpack-tree-shaking-examples). Here is a summary of the optimal setup based on what technology you are using:
1. Webpack + Babel - use [`babel-plugin-ramda`](https://github.com/megawac/babel-plugin-ramda) to automatically cherry pick methods. Discussion [here](https://www.andrewsouthpaw.com/ramda-webpack-and-tree-shaking/), example [here](https://github.com/AndrewSouthpaw/ramda-webpack-tree-shaking-examples/blob/master/07-webpack-babel-plugin-ramda/package.json)1. Webpack only - use `UglifyJS` plugin for treeshaking along with the `ModuleConcatenationPlugin`. Discussion [here](https://github.com/ramda/ramda/issues/2355), with an example setup [here](https://github.com/scabbiaza/ramda-webpack-tree-shaking-examples/blob/master/06-webpack-scope-hoisted/webpack.config.js)1. Rollup - does a fine job properly treeshaking, no special work needed; example [here](https://github.com/scabbiaza/ramda-webpack-tree-shaking-examples/blob/master/07-rollup-ramda-tree-shaking/rollup.config.js)

Typings-----------------
- [TypeScript](https://www.npmjs.com/package/@types/ramda)- [Flow](https://github.com/flowtype/flow-typed/tree/master/definitions/npm/ramda_v0.x.x)



Translations-----------------
- [Chinese(中文)](http://ramda.cn/)- [Ukrainian(Українська)](https://github.com/ivanzusko/ramda)- [Portuguese(BR)](https://github.com/renansj/ramda)- [Russian(Русский)](https://github.com/Guck111/ramda)- [Spanish(ES)](https://github.com/wirecobweb/ramda)



Acknowledgements-----------------
Thanks to [J. C. Phillipps](http://www.jcphillipps.com) for the Ramda logo.Ramda logo artwork &copy; 2014 J. C. Phillipps. Licensed Creative Commons [CC BY-NC-SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/).