# @ngard/tiny-compose

> A minimal-weight composition utility

Latest version **1.0.0** (published 2018-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ngard/tiny-compose
pnpm add @ngard/tiny-compose
yarn add @ngard/tiny-compose
bun add @ngard/tiny-compose
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-12-11 |
| First published | 2018-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nick Gard |
| Maintainers | ngard |
| Keywords | lodash, compose, util, functional programming |

## Links

- npm: https://www.npmjs.com/package/@ngard/tiny-compose
- Repository: https://github.com/NickGard/tiny-compose
- Homepage: https://github.com/NickGard/tiny-compose#readme
- Issues: https://github.com/NickGard/tiny-compose/issues
- npm.io page: https://npm.io/package/@ngard/tiny-compose

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-12-11

## README

# tiny-compose

[![source](https://badgen.net/npm/v/@ngard/tiny-compose)](https://www.npmjs.com/package/@ngard/tiny-compose)
[![bundle size](https://badgen.net/bundlephobia/minzip/@ngard/tiny-compose)](https://bundlephobia.com/result?p=@ngard/tiny-compose)
[![build status](https://badgen.net/travis/NickGard/tiny-compose)](https://travis-ci.org/NickGard/tiny-compose)
[![license](https://badgen.net/badge/license/MIT/blue)](https://badgen.net/badge/license/MIT/blue)

A minimal composition utility. For when every byte counts!
Creates a new function that applies the arguments to the right-most function and applies the result of that call to the function to its left and so on for all functions passed. That function returns the result of these nested calls.

```js
compose(fn1, fn2, fn3)('yeah!')

// is equivalent to
fn1(fn2(fn3('yeah!')))
```

<hr/>

## Install

```bash
npm install @ngard/tiny-compose
```

## Syntax

```javascript
compose(/* function1 [, function2 [, ...] ] */);
```

## Parameters
`function1` - Any function

## Return
A new function that applies the arguments to the right-most function and applies the result of that call to the function to its left and so on for all functions passed. That function returns the result of these nested calls.

<hr/>

## Examples

```javascript
import { compose } from '@ngard/tiny-compose';

function biggerThanZero(n) {
  return Math.max(0, n);
}
function lessThanTen(n) {
  return Math.min(10, n);
}
const betweenZeroAndTen = compose(biggerThanZero, lessThanTen);

betweenZeroAndTen(4); // returns 4
betweenZeroAndTen(14); // returns 10
betweenZeroAndTen(-8); // returns 0
```

```javascript
import { compose } from '@ngard/tiny-compose';

function double(n) {
  return 2 * n;
}
function addFive(n) {
  return 5 + n;
}
const addFiveAndDouble = compose(double, addFive);
addFiveAndDouble(4); // 18

const doubleAndAddFive = compose(addFive, double);
doubleAndAddFive(4); // 13
```

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