infestines

A minimalistic library to support writing FP libraries

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
infestines
1210.4.114 years ago6 years agoMinified + gzip package size for infestines in KB

Readme

This is a minimalistic library of basic utilities, such as currying, for writing more interesting high performance FP libraries. This library is not intended to be used for application programming. Primitives that are too specialized to be used as a basis for nearly optimal implementations of higher level operations are not provided.
npm version Bower version Build Status Code Coverage

Contents

Currying
* [`I.arityN(n, (x1, ..., xm) => y) ~> x1 => ... => xn => y`](#I-arityN)
* [`I.curry((x1, ..., xn) => y) ~> x1 => ... => xn => y`](#I-curry)
* [`I.curryN(n, (x1, ..., xn) => y) ~> x1 => ... => xn => y`](#I-curryN)
Function composition
* [`I.compose2U(b => c, (a1, ..., aN) => b) ~> a1 => ... aN => c`](#I-compose2U)
* [`I.pipe2U((a1, ..., an) => b, b => c) ~> a1 => ... aN => c`](#I-pipe2U)
Sequencing
* [`I.seq(value, ...fns) ~> value`](#I-seq)
* [`I.seqPartial(maybeValue, ...fns) ~> maybeValue`](#I-seq)
Basic combinators
* [`I.always(x) ~> _ => x`](#I-always)
* [`I.applyU(x => y, x) ~> y`](#I-applyU)
* [`I.id(x) ~> x`](#I-id)
* [`I.sndU(_, x) ~> x`](#I-sndU)
Constants
* [`I.array0 ~> []`](#I-array0)
* [`I.object0 ~> {}`](#I-object0)
Type predicates
* [`I.isArray(any) ~> boolean`](#I-isArray)
* [`I.isDefined(any) ~> boolean`](#I-isDefined)
* [`I.isFunction(any) ~> boolean`](#I-isFunction)
* [`I.isInstanceOfU(Type, any) ~> boolean`](#I-isInstanceOfU)
* [`I.isNumber(any) ~> boolean`](#I-isNumber)
* [`I.isObject(any) ~> boolean`](#I-isObject)
* [`I.isString(any) ~> boolean`](#I-isString)
* [`I.isThenable(any) ~> boolean`](#I-isThenable)
Equality
* [`I.acyclicEqualsU(any, any) ~> boolean`](#I-acyclicEqualsU)
* [`I.hasKeysOfU(template, object)`](#I-hasKeysOfU)
* [`I.identicalU(any, any) ~> boolean`](#I-identicalU)
* [`I.whereEqU(template, object)`](#I-whereEqU)
Objects
* [`I.assocPartialU(key, value, object) ~> object`](#I-assocPartialU)
* [`I.dissocPartialU(key, object) ~> object|undefined`](#I-dissocPartialU)
* [`I.hasU(propName, object) ~> boolean`](#I-hasU)
* [`I.keys(object) ~> [...keys]`](#I-keys)
* [`I.toObject(object) ~> object`](#I-toObject)
* [`I.unzipObjIntoU(object, keys, values)`](#I-unzipObjIntoU)
* [`I.values(object) ~> [...values]`](#I-values)
OOP
* [`I.inherit(Derived, Base, Methods, Statics) ~> Derived`](#I-inherit)
Meta
* [`I.constructorOf(any) ~> Function|null|undefined`](#I-constructorOf)
* [`I.create(proto[, properties]) ~> object`](#I-create)
* [`I.freeze(any) ~> any`](#I-freeze)
* [`I.defineNameU(function, string) ~> function`](#I-defineNameU)
* [`I.prototypeOf(any) ~> object|null|undefined`](#I-prototypeOf)
Imperative
* [`I.assign(to, ...from) ~> to`](#I-assign)
Promises
* [`I.resolve(any) ~> promise`](#I-resolve)
Algebras
* [Algebra constructors](#algebra-constructors)
  * [`I.Functor(map) ~> functor`](#I-Functor)
  * [`I.Applicative(map, of, ap) ~> applicative`](#I-Applicative)
  * [`I.Monad(map, of, ap, chain) ~> monad`](#I-Monad)
* [Fantasy land](#fantasy-land)
  * [`I.FantasyFunctor ~> functor`](#I-FantasyFunctor)
  * [`I.fromFantasyApplictive(Type) ~> applicative`](#I-fromFantasyApplicative)
  * [`I.fromFantasyMonad(Type) ~> monad`](#I-fromFantasyMonad)
  * [`I.fromFantasy(Type) ~> functor|applicative|monad`](#I-fromFantasy)
* [Base algebras](#base-algebras)
  * [`I.Async ~> monadish`](#I-Async)
  * [`I.Identity ~> monad`](#I-Identity)
  * [`I.IdentityAsync ~> monadish`](#I-IdentityAsync)
* [Algebra combinators](#algebra-combinators)
  * [`I.IdentityOrU(predicate, monad) ~> monad`](#I-IdentityOrU)

Reference

Currying

I.arityN(n, (x1, ..., xm) => y) ~> x1 => ... => xn => y
I.curry((x1, ..., xn) => y) ~> x1 => ... => xn => y
I.curryN(n, (x1, ..., xn) => y) ~> x1 => ... => xn => y
I.curryN(2, x => {
  const x2 = x*x
  return y => x2 + y
})(2, 3)
// 7

Function composition

I.compose2U(b => c, (a1, ..., aN) => b) ~> a1 => ... aN => c
I.pipe2U((a1, ..., an) => b, b => c) ~> a1 => ... aN => c

Sequencing

I.seq(value, ...fns) ~> value
I.seqPartial(maybeValue, ...fns) ~> maybeValue

Basic combinators

I.always(x) ~> _ => x
I.applyU(x => y, x) ~> y
I.id(x) ~> x
I.sndU(_, x) ~> x

Constants

I.array0 ~> []
I.array0 is an empty frozen array [].
I.object0 ~> {}
I.object0 is an empty frozen object {}.

Type predicates

I.isArray(any) ~> boolean
I.isDefined(any) ~> boolean
I.isFunction(any) ~> boolean
I.isInstanceOfU(Type, any) ~> boolean
I.isNumber(any) ~> boolean
I.isObject(any) ~> boolean
I.isString(any) ~> boolean
I.isThenable(any) ~> boolean

Equality

I.acyclicEqualsU(any, any) ~> boolean
I.hasKeysOfU(template, object)
I.identicalU(any, any) ~> boolean
I.whereEqU(template, object)

Objects

I.assocPartialU(key, value, object) ~> object
I.dissocPartialU(key, object) ~> object|undefined
I.hasU(propName, object) ~> boolean
I.keys(object) ~> [...keys]
I.toObject(object) ~> object
I.unzipObjIntoU(object, keys, values)
I.values(object) ~> [...values]

OOP

I.inherit(Derived, Base, Methods, Statics) ~> Derived

Meta

I.constructorOf(any) ~> Function|null|undefined
I.create(proto[, properties]) ~> object
I.freeze(any) ~> any
I.defineNameU(function, string) ~> function
I.prototypeOf(any) ~> object|null|undefined

Imperative

I.assign(to, ...from) ~> to

Promises

I.resolve(any) ~> promise

Algebras

Algebra constructors
I.Functor(map) ~> functor
I.Applicative(map, of, ap) ~> applicative
I.Monad(map, of, ap, chain) ~> monad
Fantasy land
I.FantasyFunctor ~> functor
I.fromFantasyApplictive(Type) ~> applicative
I.fromFantasyMonad(Type) ~> monad
I.fromFantasy(Type) ~> functor|applicative|monad
Base algebras
I.Async ~> monadish
I.Identity ~> monad
I.IdentityAsync ~> monadish
Algebra combinators
I.IdentityOrU(predicate, monad) ~> monad