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
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
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 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.
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
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
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
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 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
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 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"
Given a value, returns a function which returns the value
Given a value, returns a function which returns the value
Generated using TypeDoc
Higher order functions
common_hof