# commingle

> A simple way to run functions in series or parallel

Latest version **1.1.1** (published 2026-01-15) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install commingle
pnpm add commingle
yarn add commingle
bun add commingle
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2026-01-15 |
| First published | 2017-06-30 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dan Kolz |
| Maintainers | dankolz |
| Keywords | functions, async, series, parallel |

## Links

- npm: https://www.npmjs.com/package/commingle
- Repository: https://github.com/EmergentIdeas/commingle
- Homepage: https://github.com/EmergentIdeas/commingle#readme
- Issues: https://github.com/EmergentIdeas/commingle/issues
- npm.io page: https://npm.io/package/commingle

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2026-01-15
- 1.1.0 — 2026-01-01
- 1.0.0 — 2025-12-02
- 0.0.4 — 2018-05-03
- 0.0.3 — 2017-11-10
- 0.0.2 — 2017-09-22
- 0.0.1 — 2017-06-30

## README

# commingle
A simple way to run functions in series or parallel. 

Let's run three functions in sequence:

```
var co = require('commingle')
co([function1, function2, function3])()
```

`co` will return immediately and the three listed functions will be run next tick.

Each function is assumed to have a signature:

```
function(arg1, arg2, next) {
		
}
```

Each function will have to call next() before the subsequent function is run.

You'll notice the signature matches the Express middleware signature. (Setting up dependencies 
among express middleware was the reason commingle was written.) If the two arguments
are not specified, then they will be created as empty objects.

Let's say you want to set up a sequence where you acquire a database connection,
load a bunch of data, then render a page. That would look like:

```
var co = require('commingle')
app.get('/somepage', function(req, res, next) {
	co([dbConnect, [loadSlideshow, loadEvents, loadPosts], renderPage])(req, res, () => next())	
})
```

However, what commingle is doing is creating a function which has the same signature
as Express middleware, so if we want, we could also accomplish the same like:

```
var co = require('commingle')
app.get('/somepage', co([dbConnect, [loadSlideshow, loadEvents, loadPosts], renderPage]))
```

For just a little bit of analysis on the code above, what happens is the dbConnect
function is called, probably waiting for connection, adding the connection to the
req object, and calling next when ready. Then three asynchronous load functions are called, running in parallel,
using the db connection from the previous step, all loading independent pieces of data
which are needed for the next step. Once all three of those functions have called
next(), renderPage is called, getting information it needs from the request object
(having been placed there by the load functions).

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