All Projects → microauth → micro-compose

microauth / micro-compose

Licence: MIT License
Higher-order "compose" function

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to micro-compose

stateless
A library which is not recognized as citizen of any infrastructure.
Stars: ✭ 26 (+18.18%)
Mutual labels:  higher-order
nunchaku
Model finder for higher-order logic
Stars: ✭ 40 (+81.82%)
Mutual labels:  higher-order
haskell-schema
A library for describing Haskell data types and obtain free generators, JSON codecs, pretty printers, etc.
Stars: ✭ 16 (-27.27%)
Mutual labels:  higher-order

micro-compose

Higher-order compose function

Build Status XO code style Greenkeeper badge

Compose function from micro-hoofs extracted into separate npm package and a bit modified.

Install

npm install --save micro-compose
# or
yarn add micro-compose

Usage

import test from 'ava';
import compose from './../';

const first = fn => (arg1, arg2) => {
  return fn(arg1, arg2, 'third');
};

const second = fn => (...args) => {
  args.push('another one');
  return fn(...args);
};

test('should compose correct', async t => {
  const composed = compose(
    first,
    second
  )(async (...args) => {
    t.is(args.length, 4);
    t.is(args[0], 'first');
    t.is(args[1], 'second');
    t.is(args[2], 'third');
    t.is(args[3], 'another one');
  });

  await composed('first', 'second');
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].