# chainme

> Create a chainable class from an asynchronous one

Latest version **0.0.4** (published 2014-06-29) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2014-06-29 |
| First published | 2014-06-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mike Anderson |
| Maintainers | cambridgemike |
| Keywords | async, chain |

## Links

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

## Dependencies (2)

- [q](https://npm.io/package/q.md) ^1.0.1
- [deferred](https://npm.io/package/deferred.md) ^0.7.1

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@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

## Recent versions

- 0.0.4 (latest) — 2014-06-29
- 0.0.3 — 2014-06-28
- 0.0.2 — 2014-06-28
- 0.0.1 — 2014-06-28

## README

# Another async chaining library

Very similar to https://github.com/vvo/chainit, but with a simpler implementation leveraging deferreds.

Basically -- after you build a class, `Car`, pass it to `ChainMe` and it will return the same class, but now all of your prototype methods will have the ability to be chained, even if they're asynchronous methods! How do the async methods work? Every prototype method _must_ take an extra parameter, `done`, which is a method that must be called to signify the asynchronous method has completed.

## Installation

    npm install chainme

## Usage

I wouldn't actually use this.. it was just an exercise in building such a library.

    var ChainMe = require('chainme');

    // This is the class we will convert to a chained API
    var Car = function() { };

    Car.prototype.drive = function(ms, done) {
        console.log("here we go!");
        setTimeout(function(){
            console.log("That took " + ms + " milliseconds!");
            done();
        }, ms)
    };

    Car.prototype.stop = function(done) {
        Ajax.post('/car/stop', function(resp) {
            console.log("car came to a stop!");
            done();
        })
    };


    var ChainedCar = ChainMe(Car);


    var c = new ChainedCar();

    c.drive(2000).stop().drive(1000).stop();

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