A utility library to write code in functional programming style in Javascript
KudoJS is a small utility library with a collection of popular Algebraic Data Types and Helper functions to help you write code in a functional programming style in Javascript.
Install and save KudoJS as a dependency in your current project
$ npm install --save fp-kudojs
const kudoJS = require("fp-kudojs")
import kudoJS from "fp-kudojs"
<script src="/path/to/kudo.iife.js"></script>
const compose = require("fp-kudojs/function/compose");
const Maybe = require("fp-kudojs/adt/Maybe");
import compose from "fp-kudojs/function/compose";
import Maybe from "fp-kudojs/adt/Maybe";
These are the functions under the kudoJS.*
namespace
kudoJS.id
kudoJS.once
kudoJS.curry
kudoJS.ocurry
kudoJS.compose
kudoJS.constant
kudoJS.fmap
kudoJS.assoc
kudoJS.bimap
kudoJS.chain
kudoJS.caseOf
kudoJS.liftAn
kudoJS.liftA2
kudoJS.liftA3
kudoJS.liftA4
kudoJS.liftA5
kudoJS.when
kudoJS.pick
kudoJS.prop
kudoJS.eitherToMaybe
kudoJS.maybeToEither
ADTs under the kudoJS.* namespace. All of the data types are compatible with the Fantasy Land Specifications
ADT | Constructors | Static Methods | Instance Methods |
---|---|---|---|
kudoJS.Identity |
Identity , of |
equals , concat ,ap , getValue , map ,chain , toString |
|
kudoJS.Pair |
Pair , of |
equals , concat , fst , snd , ap , getValue , map , bimap , chain , swap , toString |
|
kudoJS.Maybe |
of , Just , Nothing , zero , fromNullable , withDefault |
catMaybes , isNothing , isJust |
equals , ap , alt , map , chain , toString , getValue , isNothing , isJust |
kudoJS.Either |
of , Left , Right , fromNullable , withDefault |
try , isLeft , isRight |
equals , ap , getValue , map , bimap , chain , swap , toString , isLeft , isRight |
kudoJS.Task |
Task , of , rejected |
fork , concat , ap , getValue , map , chain , toPromise , toString |
|
kudoJS.Reader |
Reader , of , ask |
runWith , ap , getValue , map , chain , toString |
|
kudoJS.State |
State , of , get , put |
runWith , execWith , evalWith , ap , getValue , map , chain , toString |
All code and documentation are © 2021 Ritesh Pillai and released under the MIT License. A copy of the MIT License is also included.