Predicate which checks if a value looks like a Promise
It is probably a Promise if it's an object, and it has a then
property which is a Function
Given an object, returns a new object, where each property is transformed by the callback function
Given a property name and a value, returns a function that returns a boolean based on whether the passed object has a property that matches the value let obj = { foo: 1, name: "blarg" }; let getName = propEq("name", "blarg"); getName(obj) === true
Given an array, and an item, if the item is found in the array, it removes it (in-place). The same array is returned
shallow copy from src to dest
shallow copy from src to dest
note: This is a shallow copy, while angular.copy is a deep copy.
ui-router uses copy
only to make copies of state parameters.
Check if all the elements of an array match a predicate function
Check if all the elements of an array match a predicate function
a predicate function fn1
a function which takes an array and returns true if fn1
is true for all elements of the array
Reduce function that returns true if all of the values are truthy.
Reduce function that returns true if all of the values are truthy.
Finds the common ancestor path between two states.
Finds the common ancestor path between two states.
The first state.
The second state.
Returns an array of state names in descending order, not including the root.
Given two functions that return truthy or falsey values, returns a function that returns truthy if both functions return truthy for the given arguments
Given two functions that return truthy or falsey values, returns a function that returns truthy if both functions return truthy for the given arguments
Reduce function that returns true if any of the values are truthy.
Reduce function that returns true if any of the values are truthy.
let vals = [ 0, null, undefined ]; vals.reduce(anyTrueR, true); // false
vals.push("hello world"); vals.reduce(anyTrueR, true); // true ```
Reduce function which builds an object from an array of [key, value] pairs.
Reduce function which builds an object from an array of [key, value] pairs.
Each iteration sets the key/val pair on the memo object, then returns the memo for the next iteration.
Each keyValueTuple should be an array with values [ key: string, value: any ]
Given two or more parallel arrays, returns an array of tuples where each tuple is composed of [ a[i], b[i], ... z[i] ]
Given two or more parallel arrays, returns an array of tuples where each tuple is composed of [ a[i], b[i], ... z[i] ]
Given a .filter Predicate, builds a .filter Predicate which throws an error if any elements do not pass.
Binds and copies functions onto an object
Binds and copies functions onto an object
Takes functions from the 'from' object, binds those functions to the _this object, and puts the bound functions on the 'to' object.
This example creates an new class instance whose functions are prebound to the new'd object.
The object which contains the functions to be bound
The object which will receive the bound functions
The object which the functions will be bound to
The function names which will be bound (Defaults to all the functions found on the 'from' object)
Given a varargs list of functions, returns a function that composes the argument functions, right-to-left given: f(x), g(x), h(x) let composed = compose(f,g,h) then, composed is: f(g(h(x)))
Given a varargs list of functions, returns a function that composes the argument functions, right-to-left given: f(x), g(x), h(x) let composed = compose(f,g,h) then, composed is: f(g(h(x)))
Returns a new function for Partial Application of the original function.
Returns a new function for Partial Application of the original function.
Given a function with N parameters, returns a new function that supports partial application. The new function accepts anywhere from 1 to N parameters. When that function is called with M parameters, where M is less than N, it returns a new function that accepts the remaining parameters. It continues to accept more parameters until all N parameters have been supplied.
This contrived example uses a partially applied function as an predicate, which returns true if an object is found in both arrays.
Applies a set of defaults to an options object. The options object is filtered to only those properties of the objects in the defaultsList. Earlier objects in the defaultsList take precedence when applying defaults.
Applies a set of defaults to an options object. The options object is filtered to only those properties of the objects in the defaultsList. Earlier objects in the defaultsList take precedence when applying defaults.
Given a value, returns a Predicate function that returns true if another value is === equal to the original value
Given a value, returns a Predicate function that returns true if another value is === equal to the original value
Performs a non-strict comparison of the subset of two objects, defined by a list of keys.
Performs a non-strict comparison of the subset of two objects, defined by a list of keys.
The first object.
The second object.
The list of keys within each object to compare. If the list is empty or not specified,
it defaults to the list of keys in a
.
Returns true
if the keys match, otherwise false
.
Given an array of objects, returns a new array containing only the elements which passed the callback predicate
Given an object, returns a new object with only those properties that passed the callback predicate
Given an array of objects, returns a new array containing only the elements which passed the callback predicate
Given an object, returns a new object with only those properties that passed the callback predicate
Given an object, return the first property of that object which passed the callback predicate
Given an array of objects, returns the first object which passed the callback predicate
Given an object, return the first property of that object which passed the callback predicate
Given an array of objects, returns the first object which passed the callback predicate
Return a completely flattened version of an array.
Return a completely flattened version of an array.
Reduce function which recursively un-nests all arrays
Reduce function which recursively un-nests all arrays
Given an array, returns true if the object is found in the array, (using indexOf)
Given an array, returns true if the object is found in the array, (using indexOf)
prototypal inheritance helper.
Creates a new object which has parent
object as its prototype, and then copies the properties from extra
onto it
prototypal inheritance helper.
Creates a new object which has parent
object as its prototype, and then copies the properties from extra
onto it
Given a class, returns a Predicate function that returns true if the object is of that class
Given a class, returns a Predicate function that returns true if the object is of that class
Predicate which checks if a value is injectable
Predicate which checks if a value is injectable
A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array where all the elements in the array are Strings, except the last one, which is a Function
Given an array, returns a new array, where each element is transformed by the callback function
Maps an array or object properties using a callback function
Given an array, returns a new array, where each element is transformed by the callback function
Maps an array or object properties using a callback function
Returns a string shortened to a maximum length
Returns a string shortened to a maximum length
If the string is already less than the max
length, return the string.
Else return the string, shortened to max - 3
and append three dots ("...").
the maximum length of the string to return
the input string
Merges properties from the list of objects to the destination object. If a property already exists in the destination object, then it is not overwritten.
Merges properties from the list of objects to the destination object. If a property already exists in the destination object, then it is not overwritten.
Reduce function that merges each element of the list into a single object, using extend
Reduce function that merges each element of the list into a single object, using extend
Given a function that returns a truthy or falsey value, returns a function that returns the opposite (falsey or truthy) value given the same inputs
Given a function that returns a truthy or falsey value, returns a function that returns the opposite (falsey or truthy) value given the same inputs
for typedoc
for typedoc
Return a copy of the object omitting the blacklisted properties.
Return a copy of the object omitting the blacklisted properties.
Return a copy of the object omitting the blacklisted properties.
the source object
an Array of strings, which are the blacklisted property names
Return a copy of the object omitting the blacklisted properties.
the source object
1..n strings, which are the blacklisted property names
Given two functions that return truthy or falsey values, returns a function that returns truthy if at least one of the functions returns truthy for the given arguments
Given two functions that return truthy or falsey values, returns a function that returns truthy if at least one of the functions returns truthy for the given arguments
Returns a string, with spaces added to the end, up to a desired str length
Returns a string, with spaces added to the end, up to a desired str length
If the string is already longer than the desired length, return the string.
Else returns the string, with extra spaces on the end, such that it reaches length
characters.
the desired length of the string to return
the input string
Like _.pairs: Given an object, returns an array of key/value pairs
Like _.pairs: Given an object, returns an array of key/value pairs
Given a dotted property name, returns a function that returns a nested property from an object, or undefined let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, }; let getName = prop("nestedObj.name"); getName(obj) === "blarg" let propNotFound = prop("this.property.doesnt.exist"); propNotFound(obj) === undefined
Given a dotted property name, returns a function that returns a nested property from an object, or undefined let obj = { id: 1, nestedObj: { foo: 1, name: "blarg" }, }; let getName = prop("nestedObj.name"); getName(obj) === "blarg" let propNotFound = prop("this.property.doesnt.exist"); propNotFound(obj) === undefined
Sorta like Pattern Matching (a functional programming conditional construct)
Sorta like Pattern Matching (a functional programming conditional construct)
See http://c2.com/cgi/wiki?PatternMatching
This is a conditional construct which allows a series of predicates and output functions to be checked and then applied. Each predicate receives the input. If the predicate returns truthy, then its matching output function (mapping function) is provided with the input and, then the result is returned.
Each combination (2-tuple) of predicate + output function should be placed in an array of size 2: [ predicate, mapFn ]
These 2-tuples should be put in an outer array.
A 2D array. Each element of the array should be an array, a 2-tuple, with a Predicate and a mapping/output function
Return a copy of the object only containing the whitelisted properties.
Return a copy of the object only containing the whitelisted properties.
Return a copy of the object only containing the whitelisted properties.
the source object
an Array of strings, which are the whitelisted property names
Return a copy of the object only containing the whitelisted properties.
the source object
1..n strings, which are the whitelisted property names
Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right given: f(x), g(x), h(x) let piped = pipe(f,g,h); then, piped is: h(g(f(x)))
Given a varargs list of functions, returns a function that is composes the argument functions, left-to-right given: f(x), g(x), h(x) let piped = pipe(f,g,h); then, piped is: h(g(f(x)))
Given an array of objects, maps each element to a named property of the element.
Given an object, maps each property of the object to a named property of the property.
Given an array of objects, maps each element to a named property of the element.
Given an object, maps each property of the object to a named property of the property.
Given a property name, returns a function that returns that property from an object let obj = { foo: 1, name: "blarg" }; let getName = prop("name"); getName(obj) === "blarg"
Given a property name, returns a function that returns that property from an object let obj = { foo: 1, name: "blarg" }; let getName = prop("name"); getName(obj) === "blarg"
Reduce function that pushes an object to an array, then returns the array. Mostly just for flattenR
Reduce function that pushes an object to an array, then returns the array. Mostly just for flattenR
Given an arguments object, converts the arguments at index idx and above to an array. This is similar to es6 rest parameters.
Given an arguments object, converts the arguments at index idx and above to an array. This is similar to es6 rest parameters.
Optionally, the argument at index idx may itself already be an array.
For example, given either: arguments = [ obj, "foo", "bar" ] or: arguments = [ obj, ["foo", "bar"] ] then: restArgs(arguments, 1) == ["foo", "bar"]
This allows functions like pick() to be implemented such that it allows either a bunch of string arguments (like es6 rest parameters), or a single array of strings:
given: var obj = { foo: 1, bar: 2, baz: 3 }; then: pick(obj, "foo", "bar"); // returns { foo: 1, bar: 2 } pick(obj, ["foo", "bar"]); // returns { foo: 1, bar: 2 }
Get the last element of an array
Get the last element of an array
Return a new array with a single level of arrays unnested.
Return a new array with a single level of arrays unnested.
Reduce function which un-nests a single level of arrays
Reduce function which un-nests a single level of arrays
Given a value, returns a function which returns the value
Given a value, returns a function which returns the value
Given an object, return its enumerable property values
Given an object, return its enumerable property values
Generated using TypeDoc
Higher order functions