# c4s

> Control-flow lib using middleware style handlers and promises.

Latest version **1.0.2** (published 2017-12-22) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2017-12-22 |
| First published | 2017-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | https://github.com/hallh |
| Maintainers | hallh |
| Keywords | control, flow, promise, chain, middleware |

## Links

- npm: https://www.npmjs.com/package/c4s
- Repository: https://github.com/hallh/chains
- Homepage: https://github.com/hallh/chains#readme
- Issues: https://github.com/hallh/chains/issues
- npm.io page: https://npm.io/package/c4s

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-12-22
- 1.0.1 — 2017-09-26
- 1.0.0 — 2017-09-26

## README

# Chains

This library will allow you to use async control flow in a middleware style similar to express.

Basically it will look like this:

```javascript
import Chains from 'c4s';

Chains({ foo: 'bar' })
    .then((state, next) => {
        console.log(state.foo); // Output: bar

        state.new_value = 'Sweet';
        next();
    })
    .then((state, next) => {
        console.log(state.new_value, state.foo); // Output: Sweet bar

        next(new Error('Oh Noes'));
    })
    .then((state, next) => {
        // This is skipped because of the next(new Error())
    })
    .catch((error, state) => {
        console.log(error); // Oh Noes
        console.log(state); // { foo: 'bar', new_value: 'Sweet' }
    });
```

Unhandled and thrown errors are also passed to the catch handler. If you do not specify a catch handler, your code may fail silently.

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