# functions-call-chain

> Functions call chain factory

Latest version **0.0.4** (published 2020-08-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install functions-call-chain
pnpm add functions-call-chain
yarn add functions-call-chain
bun add functions-call-chain
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2020-08-21 |
| First published | 2019-06-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 29 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sergey Egorov |
| Maintainers | egorov |

## Links

- npm: https://www.npmjs.com/package/functions-call-chain
- Repository: https://github.com/egorov/call-chain
- Homepage: https://github.com/egorov/call-chain#readme
- Issues: https://github.com/egorov/call-chain/issues
- npm.io page: https://npm.io/package/functions-call-chain

## Recent versions

- 0.0.4 (latest) — 2020-08-21
- 0.0.3 — 2020-08-20
- 0.0.2 — 2019-06-04
- 0.0.1 — 2019-06-04

## README

# Functions call chain factory

How to use it?

    const Chain = require('../src/Chain');
    const methodsValidationError =
      new TypeError('"methods" argument must not empty be array of functions!');
    let result = null;
    let methods = null;

    beforeEach(() => {
      result = [];
      methods = [
        (error, data, callback) => {
          if (error)
            return callback(error);

          const value = `${data} first`;

          result.push(value);

          return process.nextTick(() => callback(null, value));
        },
        (error, data, callback) => {
          if (error)
            return callback(error);

          const value = `${data} second`;

          result.push(value);

          return process.nextTick(() => callback(null, value));
        },
        (error, data, callback) => {
          if (error)
            return callback(error);

          const value = `${data} third`;

          result.push(value);

          return process.nextTick(() => callback(null, value));
        }
      ];
    });

    it('should execute functions in array', (done) => {

      function checkResult() {      
        expect(result.length).toEqual(3);
        expect(result[0]).toEqual('Count... first');
        expect(result[1]).toEqual('Count... first second');
        expect(result[2]).toEqual('Count... first second third');  
        done();
      }

      methods.push(checkResult);

      const chain = new Chain(methods, 'Count...');

      chain.start();
    });

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