Skip to content

Instantly share code, notes, and snippets.

/-

Created March 28, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7762425a190040d0d576 to your computer and use it in GitHub Desktop.
Save anonymous/7762425a190040d0d576 to your computer and use it in GitHub Desktop.
~/ramda git:master ❯❯❯ grunt test ✱
Running "jshint:files" (jshint) task
>> 529 files lint free.
Running "jscs:files" (jscs) task
>> 529 files without code style errors.
Running "browserify:client" (browserify) task
Running "mochaTest:unit" (mochaTest) task
F
✓ always returns false
T
✓ always returns true
add
✓ adds together two numbers
✓ is curried
all
✓ returns true if all elements satisfy the predicate
✓ returns false if any element fails to satisfy the predicate
✓ returns true for an empty list
✓ returns true into array if all elements satisfy the predicate
✓ returns false into array if any element fails to satisfy the predicate
✓ returns true into array for an empty list
✓ works with more complex objects
✓ dispatches when given a transformer in list position
✓ is curried
allPass
✓ reports whether all predicates are satisfied by a given value
✓ does not have to be curried
✓ reports its arity as the longest predicate length
always
✓ returns a function that returns the object initially supplied
✓ works with various types
and
✓ compares two values with js &&
✓ is curried
any
✓ returns true if any element satisfies the predicate
✓ returns false if all elements fails to satisfy the predicate
✓ returns true into array if any element satisfies the predicate
✓ returns false if all elements fails to satisfy the predicate
✓ works with more complex objects
✓ can use a configurable function
✓ returns false for an empty list
✓ returns false into array for an empty list
✓ dispatches when given a transformer in list position
✓ is curried
anyPass
✓ reports whether any predicates are satisfied by a given value
✓ does not have to be curried
✓ reports its arity as the longest predicate length
ap
✓ applies a list of functions to a list of values
✓ dispatches to the passed object's ap method when values is a non-Array object
✓ is curried
aperture
✓ creates a list of n-tuples from a list
✓ returns an empty list when `n` > `list.length`
✓ is curried
append
✓ adds the element to the end of the list
✓ works on empty list
✓ is curried
apply
✓ applies function to argument list
✓ is curried
✓ provides no way to specify context
arity
✓ returns a function with length set to passed-in `n`
✓ passes through any additional arguments above `n`
✓ throws if n is greater than ten
assoc
✓ makes a shallow clone of an object, overriding only the specified property
✓ is the equivalent of clone and set if the property is not on the original
✓ is curried
assocPath
1) makes a shallow clone of an object, overriding only what is necessary for the path
2) is the equivalent of clone and setPath if the property is not on the original
3) is curried
✓ accepts empty path
binary
✓ turns multiple-argument function into binary one
✓ initial arguments are passed through normally
bind
✓ returns a function
✓ returns a function bound to the specified context object
✓ works with built-in types
✓ works with user-defined types
✓ works with plain objects
✓ does not interefere with existing object methods
✓ is curried
✓ preserves arity
both
✓ combines two boolean-returning functions into one
✓ accepts functions that take multiple parameters
✓ does not evaluate the second expression if the first one is false
✓ is curried
call
✓ returns the result of calling its first argument with the remaining arguments
✓ accepts one or more arguments
✓ provides no way to specify context
chain
✓ maps a function over a nested list and returns the (shallow) flattened result
deep clone integers, strings and booleans
✓ clone integers
✓ clone floats
✓ clone strings
✓ clone booleans
deep clone objects
✓ clone shallow object
✓ clone deep object
✓ clone objects with circular references
✓ clone instances
deep clone arrays
✓ clone shallow arrays
✓ clone deep arrays
deep `clone` functions
✓ keep reference to function
built-in types
✓ clones Date object
✓ clones RegExp object
deep clone deep nested mixed objects
✓ clone array with objects
✓ clone array with arrays
✓ clone array with mutual ref object
deep clone edge cases
✓ nulls, undefineds and empty objects and arrays
commute
✓ "pivots" a list (list of functors => functor of a list)
✓ works on Algebraic Data Types such as "Maybe"
✓ is curried
commuteMap
✓ "pivots" a list (list of functors => functor of a list) and applies a transformation
✓ works on Algebraic Data Types such as "Maybe"
✓ is curried
comparator
✓ builds a comparator function for sorting out of a simple predicate that reports whether the first param is smaller
complement
✓ creates boolean-returning function that reverses another
✓ accepts a function that take multiple parameters
compose
✓ executes its passed in functions in order from right to left
✓ first function is passed multiple args
✓ passes context to functions
✓ returns a function with arity == rightmost argument
✓ throws if given no arguments
✓ can be applied to one argument
composeL
✓ composes gets from right to left
✓ composes sets from right to left
✓ does not mutate the source when setting
✓ can compose multiple lenses
✓ satisfies left identity
✓ satisfies right identity
✓ satisfies associativity
composeP
✓ handles promises
✓ does not get tripped up by fake thenables
✓ returns a function with arity == rightmost argument
concat
✓ adds combines the elements of the two lists
✓ adds combines the elements of the two lists
✓ works on strings
✓ delegates to non-String object with a concat method, as second param
✓ is curried
✓ is curried like a binary operator, that accepts an inital placeholder
✓ throws if not an array, String, or object with a concat method
cond
✓ returns a function
✓ returns a conditional function
✓ returns a function which returns undefined if none of the predicates matches
✓ predicates are tested in order
✓ forwards all arguments to predicates and to transformers
construct
✓ turns a constructor function into one that can be called without `new`
✓ can be used to create Date object
✓ supports constructors with no arguments
✓ does not support constructor with greater than ten arguments
✓ returns a curried function
constructN
✓ turns a constructor function into a function with n arguments
✓ can be used to create Date object
✓ supports constructors with no arguments
✓ does not support constructor with greater than ten arguments
✓ is curried
contains
✓ returns true if an element is in a list
✓ returns false if an element is not in a list
✓ returns false for the empty list
✓ is curried
✓ is curried like a binary operator, that accepts an inital placeholder
containsWith
✓ determines if an element is the list based on the predicate
✓ is curried
converge
✓ passes the results of applying the arguments individually to two separate functions into a single one
countBy
✓ counts by a simple property of the objects
✓ counts by a more complex function on the objects
✓ is curried
✓ ignores inherited properties
createMapEntry
✓ creates an object containing a single key:value pair
✓ is curried
curry
✓ curries a single value
✓ curries multiple values
✓ allows further currying of a curried function
✓ properly reports the length of the curried function
✓ preserves context
✓ supports R.__ placeholder
✓ forwards extra arguments
curryN
✓ accepts an arity
✓ can be partially applied
✓ preserves context
✓ supports R.__ placeholder
✓ forwards extra arguments
dec
✓ decrements its argument
defaultTo
✓ returns the default value if input is null/undefined
✓ returns the input value if it is not null/undefined
✓ returns the input value even if it is considered falsy
✓ can be called with both arguments directly
difference
✓ finds the set of all elements in the first list not contained in the second
✓ does not allow duplicates in the output even if the input lists had duplicates
✓ does not work for non-primitives (use `differenceWith`)
✓ works for arrays of different lengths
✓ returns an empty array if there are no different elements
✓ is curried
differenceWith
✓ combines two lists into the set of all their elements based on the passed-in equality predicate
✓ does not allow duplicates in the output even if the input lists had duplicates
dissoc
✓ copies an object omitting the specified property
✓ includes prototype properties
✓ is curried
dissocPath
4) makes a shallow clone of an object, omitting only what is necessary for the path
✓ does not try to omit inner properties that do not exist
5) leaves an empty object when all properties omitted
6) flattens properties from prototype
7) is curried
✓ accepts empty path
divide
✓ divides two numbers
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
drop
✓ skips the first `n` elements from a list, returning the remainder
✓ returns an empty array if `n` is too large
✓ is curried
dropWhile
✓ skips elements while the function reports `true`
✓ returns an empty list for an ampty list
✓ starts at the right arg and acknowledges undefined
✓ is curried
either
✓ combines two boolean-returning functions into one
✓ accepts functions that take multiple parameters
✓ does not evaluate the second expression if the first one is true
✓ is curried
empty
✓ returns an empty list
eq
✓ tests for strict equality of its operands
✓ is curried
eqDeep
✓ tests for deep equality of its operands
✓ handles objects
✓ handles regex
✓ handles lists
✓ handles recursive data structures
✓ handles dates
✓ handles typed arrays
✓ is curried
eqProps
✓ reports whether two objects have the same value for a given property
✓ is curried
evolve
✓ creates a new object by evolving the `object` according to the `transformation` functions
✓ invokes function with undefined if object does not contain the key
✓ is not destructive
✓ is curried
filter
✓ reduces an array to those matching a filter
✓ returns an empty array if no element matches
✓ returns an empty array if asked to filter an empty array
✓ dispatches to passed-in non-Array object with a `filter` method
✓ is curried
filterIndexed
✓ works just like a normal filter
✓ passes the index as a second parameter to the predicate
✓ passes the entire list as a third parameter to the predicate
✓ returns an empty array if no element matches
✓ returns an empty array if asked to filter an empty array
✓ is curried
find
✓ returns the first element that satisfies the predicate
✓ transduces the first element that satisfies the predicate into an array
✓ returns `undefined` when no element satisfies the predicate
✓ returns `undefined` in array when no element satisfies the predicate into an array
✓ returns `undefined` when given an empty list
✓ returns `undefined` into an array when given an empty list
✓ is curried
findIndex
✓ returns the index of the first element that satisfies the predicate
✓ returns the index of the first element that satisfies the predicate into an array
✓ returns -1 when no element satisfies the predicate
✓ returns -1 in array when no element satisfies the predicate into an array
✓ is curried
findLast
✓ returns the index of the last element that satisfies the predicate
✓ returns the index of the last element that satisfies the predicate into an array
✓ returns `undefined` when no element satisfies the predicate
✓ returns `undefined` into an array when no element satisfies the predicate
✓ works when the first element matches
✓ does not go into an infinite loop on an empty array
✓ is curried
findLastIndex
✓ returns the index of the last element that satisfies the predicate
✓ returns -1 when no element satisfies the predicate
✓ returns the index of the last element into an array that satisfies the predicate
✓ returns -1 into an array when no element satisfies the predicate
✓ works when the first element matches
✓ does not go into an infinite loop on an empty array
✓ is curried
flatten
8) turns a nested list into one flat list
9) is not destructive
10) handles ridiculously large inputs
11) handles array-like objects
12) flattens an array of empty arrays
flip
✓ returns a function which inverts the first two arguments to the supplied function
✓ returns a curried function
forEach
✓ performs the passed in function on each element of the list
✓ returns the original list
✓ handles empty list
✓ is curried
forEachIndexed
✓ performs the passed in function on each element of the list and passes in the index and list as well
✓ returns the original list
✓ handles empty list
✓ is curried
fromPairs
✓ combines an array of two-element arrays into an object
✓ skips empty Arrays and non-Array elements
functions
✓ returns list of functions without prototype functions
✓ returns an empty array if there are no functions on the object or its prototype chain
functionsIn
✓ returns list of functions with prototype functions
✓ returns an empty array if there are no functions on the object or its prototype chain
groupBy
✓ splits the list into groups according to the grouping function
✓ is curried
✓ returns an empty object if given an empty array
✓ dispatches on transformer objects in list position
gt
✓ reports whether one item is less than another
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
gte
✓ reports whether one item is less than another
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
has
✓ returns true if the specified property is present
✓ returns false if the specified property is absent
✓ does not check properties from the prototype chain
✓ is curried, op-style
hasIn
✓ returns a function that checks the appropriate property
✓ checks properties from the prototype chain
✓ works properly when called with two arguments
head
✓ returns undefined for an empty list
✓ returns the first element of a list
✓ throws if applied to null or undefined
identity
✓ returns its first argument
✓ has length 1
ifElse
✓ calls the truth case function if the validator returns a truthy value
✓ calls the false case function if the validator returns a falsey value
✓ calls the true case on array items and the false case on non array items
✓ passes the arguments to the true case function
✓ passes the arguments to the false case function
✓ returns a function whose arity equals the max arity of the three arguments to `ifElse`
✓ returns a curried function
inc
✓ increments its argument
indexOf
✓ returns a number indicating an object's position in a list
✓ returns -1 if the object is not in the list
✓ returns the index of the first item
✓ returns the index of the last item
✓ finds 1
✓ finds 1 and is result strictly it
✓ does not find 4
✓ Uses strict equality
✓ returns -1 for an empty array
✓ is curried
init
✓ returns an empty list for an empty list
✓ returns a new list containing all the elements except the last element of a list
✓ throws if applied to null or undefined
✓ handles array-like object
insert
✓ inserts an element into the given list
✓ inserts another list as an element
✓ appends to the end of the list if the index is too large
✓ is curried
insertAll
✓ inserts a list of elements into the given list
✓ appends to the end of the list if the index is too large
✓ is curried
_curry2
✓ supports R.__ placeholder
_curry3
✓ supports R.__ placeholder
intersection
✓ combines two lists into the set of common elements
✓ does not allow duplicates in the output even if the input lists had duplicates
✓ does not work for non-primitives (use `intersectionWith`)
intersectionWith
✓ combines two lists into the set of all their elements based on the passed-in equality predicate
into
✓ transduces into arrays
✓ transduces into strings
✓ transduces into objects
✓ dispatches to objects that implement `reduce`
✓ is curried
✓ allows custom transformer
✓ correctly reports the arity of curried versions
invariants
✓ -- applying function f with length n (where n > 0) to no arguments gives function with length n
✓ -- applying function f with length n (where n > 0) to R.__ gives function with length n
✓ -- applying function f with length n (where n > 1) to any value other than R.__ gives function with length n - 1
invert
✓ takes a list or object and returns an object of lists
✓ returns an empty object when applied to a primitive
✓ returns an empty object when applied to null/undefined
✓ returns the input's values as keys, and keys as values of an array
✓ puts keys that have the same value into the appropriate an array
✓ is not destructive
✓ ignores inherited properties
invertObj
✓ takes a list or object and returns an object
✓ returns an empty object when applied to a primitive
✓ returns an empty object when applied to null/undefined
✓ returns the input's values as keys, and keys as values
✓ prefers the last key found when handling keys with the same value
✓ is not destructive
invoke
✓ returns a function that applies the appropriate function to the supplied object
✓ passes arguments appropriately when not curried
✓ invokes the function with no arguments when no extra params are supplied
✓ applies additional arguments to the function
invoker
✓ returns a function with correct arity
✓ calls the method on the object
✓ curries the method call
✓ returns a function with correct arity when additional parameters are given
✓ applies additional parameters to the method
is
✓ works with built-in types
✓ works with user-defined types
✓ is curried
✓ considers almost everything an object
✓ does not coerce
✓ recognizes primitives as their object equivalents
✓ does not consider primitives to be instances of Object
✓ is curried
isArrayLike
✓ is true for Arrays
✓ is true for arguments
✓ is false for Strings
✓ is true for arbitrary objects with numeric length, if extreme indices are defined
✓ is false for everything else
isEmpty
✓ returns false for null
✓ returns false for undefined
✓ returns true for empty string
✓ returns true for empty array
✓ returns true for empty arguments object
✓ returns true for object with own length property whose value is 0
✓ returns true for object with inherited length property whose value is 0
✓ returns false for every other value
isNaN
✓ returns true for `NaN`
✓ returns false for `new Number(NaN)`
✓ returns false for any other value
isNil
✓ tests a value for `null` or `undefined`
isSet
✓ returns true if a list is composed of unique elements
✓ returns true for an empty array
join
✓ concatenates a list's elements to a string, with an seperator string between elements
keys
✓ returns an array of the given object's own keys
✓ works with hasOwnProperty override
✓ works for primitives
✓ does not include the given object's prototype properties
keysIn
✓ returns an array of the given object's keys
✓ includes the given object's prototype properties
✓ works for primitives
last
✓ returns undefined for an empty list
✓ returns the first element of a list
✓ throws if applied to null or undefined
lastIndexOf
✓ returns a number indicating an object's last position in a list
✓ returns -1 if the object is not in the list
✓ returns the last index of the first item
✓ returns the index of the last item
✓ finds a
✓ does not find c
✓ Uses strict equality
✓ returns -1 for an empty array
✓ is curried
length
✓ returns the length of a list
✓ returns the length of a string
✓ returns the length of a function
✓ returns the length of an arguments object
✓ returns NaN for value of unexpected type
✓ returns NaN for length property of unexpected type
lens
✓ returns a function with `set` and `map` properties
✓ retrieves values from inside an object as defined by the `getter` function
✓ "sets" properties on an object and return the new object
✓ the setter need not (should not) mutate the object
✓ maps a property from getter to setter
✓ the modifier need not (should not) mutate the object
✓ curries map and set and modifies with composed lens
✓ is curried
lensIndex
✓ retrieves the nth value from an array as defined by the `n` parameter
✓ "sets" a value a position `n`, returning a new array
✓ the setter should not mutate the object
✓ maps an index from getter to setter
✓ the modifier should not mutate the object
✓ curries map and set and modifies with composed lens
lensOn
✓ returns a function with `set` and `map` properties
✓ can "get" a value
✓ can "set" a value
✓ maps to a new object (using get/set functions)
✓ is curried
lensProp
✓ retrieves values from inside an object as defined by the `k` parameter
✓ "sets" properties on an object and return the new object
✓ the setter should not mutate the object
✓ maps a property from getter to setter
✓ the modifier should not mutate the object
✓ curries map and set and modifies with composed lens
lift
✓ returns a function if called with just a function
✓ produces a cross-product of array values
✓ can lift functions of any arity
✓ works with other functors such as "Maybe"
liftN
✓ returns a function
✓ limits a variadic function to the specified arity
✓ produces a cross-product of array values
✓ can lift functions of any arity
✓ is curried
✓ works with other functors such as "Maybe"
lt
✓ reports whether one item is less than another
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
lte
✓ reports whether one item is less than another
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
map
✓ maps simple functions over arrays
✓ maps simple functions into arrays
✓ dispatches to objects that implement `map`
✓ dispatches to transformer objects
✓ composes
✓ can compose transducer-style
✓ is curried
✓ correctly reports the arity of curried versions
mapAccum
✓ map and accumulate simple functions over arrays with the supplied accumulator
✓ returns the list and accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
mapAccumRight
✓ map and accumulate simple functions over arrays with the supplied accumulator
✓ returns the list and accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
mapIndexed
✓ works just like a normal map
✓ passes the index as a second parameter to the callback
✓ passes the entire list as a third parameter to the callback
✓ is curried
mapObj
✓ runs the given function over each of the object properties
mapObjIndexed
✓ works just like a normal mapObj
✓ passes the index as a second parameter to the callback
✓ passes the entire list as a third parameter to the callback
✓ is curried
match
✓ determines whether a string matches a regex
✓ is curried
mathMod
✓ requires integer arguments
✓ behaves differently than JS modulo
✓ computes the true modulo function
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
max
✓ calculates the largest value of a list
✓ accepts negative numbers, decimals, and even strings
✓ finds max in any position
✓ returns -Infinity for an empty list
✓ returns a number
maxBy
✓ calculates the largest value of a list using the supplied comparator
✓ returns undefined for the empty list
✓ is curried
memoize
✓ calculates the value for a given input only once
✓ handles multiple parameters
✓ does not rely on reported arity
✓ memoizes "false" return values
✓ can be applied to nullary function
✓ can be applied to function with optional arguments
✓ differentiates values with same string representation
merge
✓ takes two objects, merges their own properties and returns a new object
✓ overrides properties in the first object with properties in the second object
✓ is not destructive
✓ reports only own properties
✓ is curried
✓ is curried
mergeAll
✓ merges a list of objects together into one object
✓ gives precedence to later objects in the list
✓ ignores inherited properties
min
✓ calculates the smallest value of a list
✓ accepts negative numbers, decimals, and even strings
✓ finds min in any position
✓ returns Infinity for an empty list
✓ returns a number
minBy
✓ calculates the smallest value of a list using the supplied comparator
✓ returns null for the empty list
✓ is curried
modulo
✓ divides the first param by the second and returns the remainder
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
✓ preserves javascript-style modulo evaluation for negative numbers
multiply
✓ adds together two numbers
✓ is curried
nAry
✓ turns multiple-argument function into a nullary one
✓ turns multiple-argument function into a ternary one
✓ creates functions of arity less than or equal to ten
✓ throws if n is greater than ten
negate
✓ negates its argument
none
✓ returns true if no elements satisfy the predicate
✓ returns false if any element satisfies the predicate
✓ returns true for an empty list
✓ works with more complex objects
✓ is curried
not
✓ reverses argument
nth
✓ accepts positive offsets
✓ accepts negative offsets
✓ is curried
✓ throws if applied to null or undefined
nthArg
✓ returns a function which returns its nth argument
✓ accepts negative offsets
✓ returns a function with length 0
nthChar
✓ returns the nth character of the given string
✓ accepts negative offsets
✓ is curried
nthCharCode
✓ returns the character code of the nth character of the given string
✓ accepts negative offsets
✓ is curried
of
✓ returns its argument as an Array
omit
✓ copies an object omitting the listed properties
✓ includes prototype properties
✓ is curried
once
✓ returns a function that calls the supplied function only the first time called
✓ passes along arguments supplied
✓ retains and returns the first value calculated, even if different arguments are passed later
or
✓ compares two values with js &&
✓ is curried
partial
✓ caches the initially supplied left-most parameters in the generated function
✓ correctly reports the arity of the new function
partialRight
✓ caches the initially supplied right-most parameters in the generated function
✓ correctly reports the arity of the new function
partition
✓ splits a list into two lists according to a predicate
✓ is curried
path
✓ takes a path and an object and returns the value at the path or undefined
✓ gets a deep property's value from objects
✓ returns undefined for items not found
✓ returns undefined for null/undefined
✓ works with falsy items
✓ is curried
pathEq
✓ returns true if the path matches the value
✓ returns false for non matches
✓ returns false for non existing values
✓ accepts empty path
pick
✓ copies the named properties of an object to the new object
✓ ignores properties not included
✓ retrieves prototype properties
✓ is curried
pickAll
✓ copies the named properties of an object to the new object
✓ includes properties not present on the input object
✓ is curried
pickBy
✓ creates a copy of the object
✓ when returning truthy, keeps the key
✓ when returning falsy, keeps the key
✓ is called with (val,key,obj)
✓ retrieves prototype properties
✓ is curried
pipe
✓ executes its passed in functions in order from left to right
✓ first function is passed multiple args
✓ passes context to functions
✓ throws if given no arguments
✓ can be applied to one argument
pipeL
✓ composes gets from left to right
✓ composes sets from left to right
✓ does not mutate the source when setting
✓ can compose multiple lenses
pipeP
✓ handles promises
✓ returns a function with arity == leftmost argument
pluck
✓ returns a function that maps the appropriate property over an array
prepend
✓ adds the element to the beginning of the list
✓ works on empty list
✓ is curried
product
✓ multiplies together the array of numbers supplied
project
✓ selects the chosen properties from each element in a list
✓ has an undefined property on the output tuple for any input tuple that does not have the property
✓ is curried
prop
✓ returns a function that fetches the appropriate property
propEq
✓ determines whether a particular property matches a given value for a specific object
✓ is curried
propOr
✓ returns a function that fetches the appropriate property
✓ returns the default value when the property does not exist
✓ does not return properties from the prototype chain
props
✓ returns empty array if no properties requested
✓ returns values for requested properties
✓ preserves order
✓ returns undefined for nonexistent properties
✓ is curried
range
✓ returns list of numbers
✓ returns the empty list if the first parameter is not larger than the second
✓ is curried
✓ returns an empty array if from > to
reduce
✓ folds simple functions over arrays with the supplied accumulator
✓ dispatches to objects that implement `reduce`
✓ returns the accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
reduceIndexed
✓ works just like normal reduce
✓ passes the index as a third parameter to the predicate
✓ passes the entire list as a fourth parameter to the predicate
✓ is curried
reduceRight
✓ folds lists in the right order
✓ folds simple functions over arrays with the supplied accumulator
✓ returns the accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
reduceRightIndexed
✓ folds lists in the right order
✓ folds simple functions over arrays with the supplied accumulator
✓ returns the accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
✓ passes the index as a third parameter to the predicate
✓ passes the entire list as a fourth parameter to the predicate
✓ is curried
reject
✓ reduces an array to those not matching a filter
✓ returns an empty array if no element matches
✓ returns an empty array if asked to filter an empty array
✓ returns an empty array if no element matches
✓ returns an empty array if asked to filter an empty array
✓ dispatches to `filter` method
✓ is curried
rejectIndexed
✓ works just like a normal reject
✓ passes the index as a second parameter to the predicate
✓ passes the entire list as a third parameter to the predicate
✓ returns an empty array if no element matches
✓ returns an empty array if asked to filter an empty array
✓ is curried
remove
✓ splices out a sub-list of the given list
✓ returns the appropriate sublist when start == 0
✓ removes the end of the list if the count is too large
✓ retains the entire list if the start is too large
✓ is curried
repeat
✓ returns a lazy list of identical values
✓ can accept any value, including `null`
✓ is curried
replace
✓ replaces substrings of the input string
✓ replaces regex matches of the input string
✓ is curried up to 3 arguments
reverse
✓ reverses arrays
✓ returns the empty list to itself
scan
✓ scans simple functions over arrays with the supplied accumulator
✓ returns the accumulator for an empty array
✓ is curried
✓ correctly reports the arity of curried versions
slice
✓ retrieves the proper sublist of a list
✓ handles array-like object
✓ dispatches to `slice` method
sort
✓ sorts the elements of a list
✓ does not affect the list passed supplied
✓ is curried
sortBy
✓ sorts by a simple property of the objects
✓ is curried
✓ preserves object identity
✓ sorts array-like object
split
✓ splits a string into an array
✓ the split string can be arbitrary
strIndexOf
✓ finds the index of a substring inside a string
✓ returns -1 if the value is not found
✓ is curried
strLastIndexOf
✓ finds the index of a substring inside a string
✓ returns -1 if the value is not found
✓ is curried
substring
✓ returns the substring of a string
✓ accepts negative offsets
✓ is curried
substringFrom
✓ returns the trailing substring of a string
✓ accepts negative offsets
✓ is curried
substringTo
✓ returns the trailing substring of a string
✓ accepts negative offsets
✓ is curried
subtract
✓ subtracts two numbers
✓ is curried
✓ behaves right curried when passed `R.__` for its first argument
sum
✓ adds together the array of numbers supplied
✓ does not save the state of the accumulator
tail
✓ returns an empty list for an empty list
✓ returns a new list containing all the elements after the first element of a list
✓ throws if applied to null or undefined
take
✓ takes only the first `n` elements from a list
✓ returns only as many as the array can provide
✓ is curried
takeWhile
✓ continues taking elements while the function reports `true`
✓ starts at the right arg and acknowledges undefined
✓ is curried
tap
✓ returns a function that always returns its argument
✓ may take a function as the first argument that executes with tap's argument
test
✓ returns true if string matches pattern
✓ returns false if string does not match pattern
✓ is referentially transparent
times
✓ takes a map func
✓ is curried
✓ throws if second argument is not a valid array length
toLower
✓ returns the lower-case equivalent of the input string
toPairs
✓ converts an object into an array of two-element [key, value] arrays
✓ only iterates the object's own properties
toPairsIn
✓ converts an object into an array of two-element [key, value] arrays
✓ iterates properties on the object's prototype chain
toUpper
✓ returns the upper-case equivalent of the input string
transduce
✓ transduces into arrays
✓ transduces into strings
✓ transduces into objects
✓ folds transformer objects over a collection with the supplied accumulator
✓ dispatches to objects that implement `reduce`
✓ returns the accumulator for an empty collection
✓ is curried
✓ correctly reports the arity of curried versions
trim
✓ trims a string
✓ trims all ES5 whitespace
✓ does not trim the zero-width space
type
✓ "Array" if given an array literal
✓ "Object" if given an object literal
✓ "RegExp" if given a RegExp literal
✓ "Number" if given a numeric value
✓ "Number" if given the NaN value
✓ "String" if given a String literal
✓ "String" if given a String object
✓ "Null" if given the null value
✓ "Undefined" if given the undefined value
unapply
✓ returns a function which is always passed one argument
✓ forwards arguments to decorated function as an array
✓ returns a function with length 0
✓ is the inverse of R.apply
unary
✓ turns multiple-argument function into unary one
✓ initial argument is passed through normally
uncurryN
✓ accepts an arity
✓ returns a function of the specified arity
✓ forwards extra arguments
✓ works with ordinary uncurried functions
✓ works with ramda-curried functions
✓ returns a function that supports R.__ placeholder
unfold
✓ unfolds simple functions with a starting point to create a list
✓ is cool!
union
✓ combines two lists into the set of all their elements
✓ is curried
✓ does not work for non-primitives (use `unionWith`)
unionWith
✓ combines two lists into the set of all their elements based on the passed-in equality predicate
uniq
✓ returns a set from any array (i.e. purges duplicate elements)
✓ keeps elements from the left
✓ returns an empty array for an empty array
uniqWith
✓ returns a set from any array (i.e. purges duplicate elements) based on predicate
✓ keeps elements from the left
✓ returns an empty array for an empty array
✓ is curried
unnest
✓ only flattens one layer deep of a nested list
✓ is not destructive
✓ handles array-like objects
✓ flattens an array of empty arrays
useWith
✓ takes a arbitrary number of function arguments and returns a function
✓ passes the arguments received to their respective functions
✓ passes additional arguments to the main function
✓ nonetheless has the correct arity
values
✓ returns an array of the given object's values
✓ does not include the given object's prototype properties
✓ works for primitives
valuesIn
✓ returns an array of the given object's values
✓ includes the given object's prototype properties
✓ works for primitives
where
✓ takes a spec and a test object and returns true if the test object satisfies the spec
✓ calls any functions in the spec against the test object value for that property
✓ does not need the spec and the test object to have the same interface (the test object will have a superset of the specs properties)
✓ is false if the test object is null-ish
✓ matches specs that have undefined properties
✓ is curried
✓ is true for an empty spec
✓ reports true when the object equals the spec
✓ matches inherited functions
✓ matches inherited props
✓ doesnt match inherited spec
wrap
✓ allows you to modify the parameters
✓ allows you to modify the output
✓ allows you to entirely replace the input function
✓ maintains the arity of the function that is being wrapped
✓ returns a curried function
xprod
✓ returns an empty list if either input list is empty
✓ creates the collection of all cross-product pairs of its parameters
✓ is curried
✓ correctly reports the arity of curried versions
zip
✓ returns an array of "tuples"
✓ returns a list as long as the shorter of the lists input
zipObj
✓ combines an array of keys with an arrau of values into a single object
✓ ignores extra values
✓ extra keys are undefined
✓ last one in wins when there are duplicate keys
zipWith
✓ returns an array created by applying its passed-in function pair-wise on its passed in arrays
✓ returns an array whose length is equal to the shorter of its input arrays
805 passing (316ms)
12 failing
1) assocPath makes a shallow clone of an object, overriding only what is necessary for the path:
ReferenceError: _assocPath is not defined
at _assocPath (/Users/rainevi/ramda/dist/ramda.js:3988:36)
at Object.f3 [as assocPath] (/Users/rainevi/ramda/dist/ramda.js:297:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/assocPath.js:9:18)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
2) assocPath is the equivalent of clone and setPath if the property is not on the original:
ReferenceError: _assocPath is not defined
at _assocPath (/Users/rainevi/ramda/dist/ramda.js:3988:36)
at Object.f3 [as assocPath] (/Users/rainevi/ramda/dist/ramda.js:297:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/assocPath.js:22:18)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
3) assocPath is curried:
ReferenceError: _assocPath is not defined
at _assocPath (/Users/rainevi/ramda/dist/ramda.js:3988:36)
at /Users/rainevi/ramda/dist/ramda.js:254:28
at f2 (/Users/rainevi/ramda/dist/ramda.js:232:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/assocPath.js:35:22)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
4) dissocPath makes a shallow clone of an object, omitting only what is necessary for the path:
ReferenceError: _dissocPath is not defined
at _dissocPath (/Users/rainevi/ramda/dist/ramda.js:4193:59)
at Object.f2 [as dissocPath] (/Users/rainevi/ramda/dist/ramda.js:232:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/dissocPath.js:9:18)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
5) dissocPath leaves an empty object when all properties omitted:
ReferenceError: _dissocPath is not defined
at _dissocPath (/Users/rainevi/ramda/dist/ramda.js:4193:59)
at Object.f2 [as dissocPath] (/Users/rainevi/ramda/dist/ramda.js:232:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/dissocPath.js:32:18)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
6) dissocPath flattens properties from prototype:
ReferenceError: _dissocPath is not defined
at _dissocPath (/Users/rainevi/ramda/dist/ramda.js:4193:59)
at Object.f2 [as dissocPath] (/Users/rainevi/ramda/dist/ramda.js:232:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/dissocPath.js:43:18)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
7) dissocPath is curried:
ReferenceError: _dissocPath is not defined
at _dissocPath (/Users/rainevi/ramda/dist/ramda.js:4193:59)
at /Users/rainevi/ramda/dist/ramda.js:219:28
at f1 (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/dissocPath.js:53:22)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
8) flatten turns a nested list into one flat list:
ReferenceError: flatt is not defined
at flatt (/Users/rainevi/ramda/dist/ramda.js:4229:41)
at Object.f1 [as flatten] (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/flatten.js:9:24)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
9) flatten is not destructive:
ReferenceError: flatt is not defined
at flatt (/Users/rainevi/ramda/dist/ramda.js:4229:41)
at Object.f1 [as flatten] (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/flatten.js:17:29)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
10) flatten handles ridiculously large inputs:
ReferenceError: flatt is not defined
at flatt (/Users/rainevi/ramda/dist/ramda.js:4229:41)
at Object.f1 [as flatten] (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/flatten.js:21:26)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
11) flatten handles array-like objects:
ReferenceError: flatt is not defined
at flatt (/Users/rainevi/ramda/dist/ramda.js:4229:41)
at Object.f1 [as flatten] (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/flatten.js:26:24)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
12) flatten flattens an array of empty arrays:
ReferenceError: flatt is not defined
at flatt (/Users/rainevi/ramda/dist/ramda.js:4229:41)
at Object.f1 [as flatten] (/Users/rainevi/ramda/dist/ramda.js:197:24)
at Context.<anonymous> (/Users/rainevi/ramda/test/flatten.js:30:24)
at callFn (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:223:21)
at Test.Runnable.run (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runnable.js:216:7)
at Runner.runTest (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:373:10)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:451:12
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:298:14)
at /Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:308:7
at next (/Users/rainevi/ramda/node_modules/grunt-mocha-test/node_modules/mocha/lib/runner.js:246:23)
Warning: Task "mochaTest:unit" failed. Use --force to continue.
Aborted due to warnings.
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment