# func-compose

> Compose a new function from smaller functions `f(g(x))`

Latest version **1.0.2** (published 2025-06-01) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2025-06-01 |
| First published | 2023-06-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | iamkhan21 |

## Links

- npm: https://www.npmjs.com/package/func-compose
- Repository: https://github.com/iamkhan21/func-compose
- Homepage: https://github.com/iamkhan21/func-compose#readme
- Issues: https://github.com/iamkhan21/func-compose/issues
- npm.io page: https://npm.io/package/func-compose

## Recent versions

- 1.0.2 (latest) — 2025-06-01
- 1.0.1 — 2024-11-24
- 0.0.5 — 2023-06-27
- 0.0.4 — 2023-06-27
- 0.0.3 — 2023-06-27
- 0.0.2 — 2023-06-27
- 0.0.1 — 2023-06-26
- 0.0.0 — 2023-06-26

## README

# func-compose

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
[![JSDocs][jsdocs-src]][jsdocs-href]

Compose a new function from smaller functions `f(g(x))`

## Usage

Install package:

```sh
# npm
npm install func-compose

# yarn
yarn add func-compose

# pnpm
pnpm install func-compose
```

Import:

```js
// ESM
import { compose } from "func-compose";

// CommonJS
const { compose } = require("func-compose");

function addOne(x) {
  return x + 1;
}

function multiplyByTwo(x) {
  return x * 2;
}

const result = compose(addOne, multiplyByTwo)(2); // 2 * 2 + 1 = 5
```

## Development

- Clone this repository
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`

## License

Made with 💛

Published under [MIT License](./LICENSE).

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/func-compose?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/func-compose
[npm-downloads-src]: https://img.shields.io/npm/dm/func-compose?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/func-compose
[codecov-src]: https://img.shields.io/codecov/c/gh/iamkhan21/func-compose/master?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/iamkhan21/func-compose
[bundle-src]: https://img.shields.io/bundlephobia/minzip/func-compose?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=func-compose
[license-src]: https://img.shields.io/github/license/iamkhan21/func-compose.svg?style=flat&colorA=18181B&colorB=F0DB4F
[license-href]: https://github.com/iamkhan21/func-compose/blob/master/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
[jsdocs-href]: https://www.jsdocs.io/package/func-compose

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