2.0.1 • Published 7 years ago

wi-jit v2.0.1

Weekly downloads
4
License
MIT
Repository
-
Last release
7 years ago

Wi-Jit Build Status

npm install wi-jit

A very minimal set of functional utilities. Just enough to get you going.

API

Strict

apply :: (a -> b) -> a -> b
compose :: (b -> c) -> (a -> b) -> a -> c
constant :: a -> b -> a
curry :: ((a, b) -> c) -> a -> b -> c
flip :: (a -> b -> c) -> b -> a -> c
id :: a -> a
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
uncurry :: (a -> b -> c) -> (a, b) -> c

Non-Strict

There are also some helpful variations on these functions included to be a bit better-suited to the style of JavaScript's syntax:

  • composeN: takes any number of functions and composes them all together.
composeN(f, g, h) == compose(compose(f, g), h)
  • curryN: take an n-ary function, and return a totally curried version (unlike standard curry, which only works on binary functions).
curryN((a, b, c) => a + b + c)(1)(2)(3) == 6
  • uncurryN: take a curried function, and return a function that takes some (or all) of the arguments. If not given the total list, the result will be uncurryN(f), where f is function that takes the remainder of the arguments.
uncurryN(f)(a, b, c)
  == uncurryN(f)(a, b)(c)
  == uncurryN(f)(a)(b, c)
  == uncurryN(f)(a)(b)(c)

Contributing

Send PRs! Get involved!