composable-utils

Some utilities that are used in functional programming

Usage no npm install needed!

<script type="module">
  import composableUtils from 'https://cdn.skypack.dev/composable-utils';
</script>

README

Composable Utils

A bunch of handy utilities that might be needed in functional programming. They can facilitate the implementation and logics that are required in this paradigm.

Installation

$ npm install composable-utils

Usage

For importing the package you have some different choices.

1. Import all the utilities in a single object (e.g. named fp)

const FP = require('composable-utils');

2. Destruct the object and use the only utils that you need

const {
  compose, curry, List, Either /* and so on */
} = require('composable-utils');

3. Import the utils directly from its own module

const pipe = require('composable-utils/lib/pipe');
const Maybe = require('composable-utils/lib/maybe');

4. Expose all of the utils globally under a namespace

In the example below we pass the namespace as the argument of exposeGlobally function.

// You can expose it in the entry point
require('composable-utils').exposeGlobally('_');

// Now you can access them from everywhere
// In another-file.js
const sum = _.curry((a, b) => a + b);

Note: If you don't pass any argument to exposeGlobally function, the default value is $ character.

Documentation

Read the API documentation in detail (still under construction).


license

MIT