# compose-function

> Compose new functions f(g(x))

Latest version **3.0.3** (published 2015-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install compose-function
pnpm add compose-function
yarn add compose-function
bun add compose-function
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2015-10-04 |
| First published | 2015-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/compose-function) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | stoeffel |
| Maintainers | schtoeffel |
| Keywords | function, compose, functional |

## Links

- npm: https://www.npmjs.com/package/compose-function
- Repository: https://github.com/stoeffel/compose-function
- Homepage: http://github.com/stoeffel/compose-function
- Issues: http://github.com/stoeffel/compose-function/issues
- npm.io page: https://npm.io/package/compose-function

## Dependencies (1)

- [arity-n](https://npm.io/package/arity-n.md) ^1.0.4

## Recent versions

- 3.0.3 (latest) — 2015-10-04
- 3.0.2 — 2015-09-24
- 3.0.1 — 2015-09-24
- 3.0.0 — 2015-09-24
- 2.0.0 — 2015-04-07
- 1.5.0 — 2015-02-10
- 1.4.1 — 2015-01-20
- 1.4.0 — 2015-01-20
- 1.3.0 — 2015-01-07
- 1.1.1 — 2015-01-06
- 1.0.1 — 2015-01-04
- 1.0.0 — 2015-01-04

## README

[![Travis](https://img.shields.io/travis/stoeffel/compose-function.svg?style=flat-square)](https://travis-ci.org/stoeffel/compose-function)
[![npm](https://img.shields.io/npm/v/compose-function.svg?style=flat-square)](https://www.npmjs.com/package/compose-function)
[![Dependency Status](https://david-dm.org/stoeffel/compose-function.svg?style=flat-square)](https://david-dm.org/stoeffel/compose-function)
[![Coveralls](https://img.shields.io/coveralls/stoeffel/compose-function.svg?style=flat-square)](https://coveralls.io/github/stoeffel/compose-function)


<h1 align="center">Compose-Function</h1>

<p align="center">
  <a href="#installation">Installation</a> |
  <a href="#usage">Usage</a> |
  <a href="#related">Related</a> |
  <a href="#license">License</a>
  <br><br>
  <img align="center" height="300" src="http://33.media.tumblr.com/006dfad04f93ec5b3680ec7cdae3fafa/tumblr_n8kgl18uU41qcung4o1_1280.gif">
  <br>
  <sub>logo by <a href="http://justinmezzell.tumblr.com/">Justin Mezzell</a></sub>
  <blockquote align="center">Compose a new function from smaller functions `f(g(x))`</blockquote>
</p>

Installation
------------

`npm install compose-function`

Usage
-----

## Basic usage

```js
import compose from 'compose-function';

const composition = compose(sqr, add2); // sqr(add2(x))

composition(2) // => 16

compose(sqr, inc)(2); // => 9
compose(inc, sqr)(2); // => 5
```


## with curry

```js
import compose from 'compose-function';
import { curry, _ } from 'curry-this';


const add = (x, y) => x + y;

// add(6, sqr(add(2, x)))
compose(
  add::curry(6),
  sqr,
  add::curry(2),
);

// map(filter(list, even), sqr)
compose(
  map::curry(_, sqr),
  filter::curry(_, even),
)([1,2,3,4,5,6,7,8]) // => [4, 16, 36, 64]
```

### `::` huh?

If you’re wondering what the `::` thing means, you’d better read this excellent [overview](https://github.com/jussi-kalliokoski/trine/blob/5b735cbfb6b28ae94bac0446d9ecd5ce51fb149b/README.md#why) by [@jussi-kalliokoski](https://github.com/jussi-kalliokoski) or have a look at the [function bind syntax proposal](https://github.com/zenparsing/es-function-bind).
Or checkout the [curry-this docs][ct].


Related
----

* [curry-this][ct]

License
----

MIT © [Christoph Hermann](http://stoeffel.github.io)

[r]: http://ramdajs.com
[ct]: https://github.com/stoeffel/curry-this

---
_Source: https://npm.io/package/compose-function · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
