functional programming library
Intended to protect us from api and name changes, allow us a single
place to add our contributions, and potentially cherry pick the best
higher order functions from multiple functional libraries.
The tooling for this project is pretty lightweight, and is run via npm.
Currently available tasks:
* test[:watch]
* build
* coverage
There are a couple of githooks in resource/githooks that can be used
to enforce build quality before pushing/committing - please ensure you
install these to ./.git/githooks on your local machine if you wish to
work on this project
From v6.2.0, this library no longer uses Babel. Node.js 20+ is required. All language features used are supported natively in Node 20, so this change does not affect runtime behavior or the public API.
Calls the fn with the data then attaches the result to the data under the supplied name.
This is the same as ``merge({name: fn(data)}, data)`
A version of attachResult that can be used in a Promise chain and/or when the function returns a promise.
for example:
`
const getAsyncCount = ({n}) => Promise.resolve(n + 1)
const data = {n: 5}
attachResultP("count", getAsyncCount, data)
// returns Promise[{n: 5, count: 6}]
`
essentially the same as compose, but requires an array rather than a variable number of arguments
see composeList
returns a function that will return the evaluation of the function, or
the (single) argument that was provided to the function
returns true if min <= val < max , that is, that val is between min and max where min is inclusive and max is exclusive.
, undefined, "", {}, []$3
returns true when val is a JavaScript object, but not null or an array, which both normally have typeof being equal to "object"$3
applies the provided function to each of the keys on the provided object and returns the updated object$3
applies the lodash camelCase function to each of the keys on the provided object and returns the updated object$3
applies the lodash snakeCase function to each of the keys on the providd object and returns the updated object$3
Takes a function and a list, applies the function to each of the list's values, and returns
a list of the same shape.
#####params
- options Object
There is currently only one option
{concurrency: concurrencyLimit}
The concurrency limit applies to Promises returned by the mapper function and it basically
limits the number of Promises created.
For example, if concurrency is 3 and the mapper callback has been called enough so that there
are three returned Promises currently pending, no further callbacks are called until one of
the pending Promises resolves. So the mapper function will be called three times and it
will be called again only after at least one of the Promises resolves
- fn function
The function to be called on every element of the input list
- list Array
The list to be iterated over. Can be values or Promises
Returns Array:
The new list of Promises$3
takes an array of functions, and partially applies the arguments to them
$3
returns true when the named property is Nile.g.
propIsNil("a", {b: 1}) returns true$3
returns false when the named property is Nil. See propIsNil$3
returns true when the property described by the path is Nile.g.
pathIsNil(["a", "b"], {a: {item: "some-data"}}) returns true$3
returns false when the property described by the path is Nil. See pathIsNil$3
returns true when the named property is nil or empty. see isNilOrEmpty and propIsNil$3
returns true when the path is nil or empty. see isNilOrEmpty and pathIsNil$3
see composeAny. Functions processed left to right.$3
Returns the value of the property in an object, or runs the property through the supplied function$3
Given an object which describes a renaming pattern, and an object to rename, this function will return the
original object with properties renamed according to the patterne.g.
`
rename({bigness: "size"}, {bigness: 4, species: "Elephant"})// returns => {size: 4, species: "Elephant"}
``error can be either an Error or an error returning function, in which case it is passed the data
- this enables throwing an error that describes the cause
takes a predicate and an operation and produces a function. this
function will return the evaluation of operation if predicate
evaluates to true, or it will return the original value
see when. Works inside a promise chain.
takes an array of functions and wraps them in 'wrapper'