# sequence

> Execute async code in chronological order. The sequence module of FuturesJS (Browser, Node.js, Bower, and Pakmanager)

Latest version **3.0.0** (published 2014-01-13) · 0 weekly downloads

## Install

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

## 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 | 3.0.0 |
| Published | 2014-01-13 |
| First published | 2011-07-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | AJ ONeal |
| Maintainers | coolaj86 |
| Keywords | futuresjs, flow-control, async, asynchronous, futures, sequence, chain, step, util, browser |

## Links

- npm: https://www.npmjs.com/package/sequence
- Repository: https://github.com/FuturesJS/sequence
- Issues: https://github.com/FuturesJS/sequence/issues
- npm.io page: https://npm.io/package/sequence

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2014-01-13
- 2.2.1 — 2012-05-31
- 2.2.0 — 2012-05-26
- 2.1.1 — 2011-07-13

## README

Sequence
===

Creates an Asynchronous Stack which execute each enqueued method after the previous function calls the provided `next(err, data [, ...])`.

In many cases [`forEachAsync`](https://github.com/FuturesJS/forEachAsync) or [`forAllAsync`](https://github.com/FuturesJS/forAllAsync) will be a better alternative.

API
---

  * `Sequence.create(defaultContext=null)`
  * `then(function callback(next, err, data [, ...]) {}, context)` - add a callback onto the queue
    * begins or resumes the queue
    * passes the results of the previous function into the next

Node.js Installation
---

Node.JS (Server):

```bash
npm install sequence
```

Browser Installation
---

You can install from bower:

```bash
bower install sequence
```

Or download the raw file from <https://raw.github.com/FuturesJS/sequence/master/sequence.js>:

```bash
wget https://raw.github.com/FuturesJS/sequence/master/sequence.js
```

Or build with pakmanager:

```bash
pakmanager build sequence
```

Usage
---

```javascript
(function (exports) {
  'use strict';

  var Sequence = exports.Sequence || require('sequence').Sequence
    , sequence = Sequence.create()
    , err
    ;

  sequence
    .then(function (next) {
      setTimeout(function () {
        next(err, "Hi", "World!");
      }, 120);
    })
    .then(function (next, err, a, b) {
      setTimeout(function () {
        next(err, "Hello", b);
      }, 270);
    })
    .then(function (next, err, a, b) {
      setTimeout(function () {
        console.log(a, b);
        next();
      }, 50);
    });

// so that this example works in browser and node.js
}('undefined' !== typeof exports && exports || new Function('return this')()));
```

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