Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microauth/micro-compose
Higher-order "compose" function
https://github.com/microauth/micro-compose
higher-order
Last synced: 3 months ago
JSON representation
Higher-order "compose" function
- Host: GitHub
- URL: https://github.com/microauth/micro-compose
- Owner: microauth
- License: mit
- Created: 2017-04-12T10:18:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:19:08.000Z (over 4 years ago)
- Last Synced: 2024-10-11T23:41:35.564Z (4 months ago)
- Topics: higher-order
- Language: JavaScript
- Homepage:
- Size: 2.38 MB
- Stars: 24
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-micro - micro-compose - Higher-order "compose" function. (Modules / Higher Order)
README
# micro-compose
> Higher-order `compose` function
[![Build Status](https://travis-ci.org/microauth/micro-compose.svg?branch=master)](https://travis-ci.org/microauth/micro-compose)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![Greenkeeper badge](https://badges.greenkeeper.io/microauth/micro-compose.svg)](https://greenkeeper.io/)`Compose` function from [micro-hoofs](https://github.com/KaleoSoftware/micro-hoofs) extracted into separate npm package and a bit modified.
### Install
```sh
npm install --save micro-compose
# or
yarn add micro-compose
```### Usage
```js
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');
});```