# async-chain-proxy

> async-chain-proxy enable to call member functions by method chains.

Latest version **0.1.6** (published 2019-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-chain-proxy
pnpm add async-chain-proxy
yarn add async-chain-proxy
bun add async-chain-proxy
```

## 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.1.6 |
| Published | 2019-07-31 |
| First published | 2017-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | yamada |
| Maintainers | onetap |

## Links

- npm: https://www.npmjs.com/package/async-chain-proxy
- Repository: https://github.com/OnetapInc/async-chain-proxy
- Homepage: https://github.com/OnetapInc/async-chain-proxy#readme
- Issues: https://github.com/OnetapInc/async-chain-porxy/issues
- npm.io page: https://npm.io/package/async-chain-proxy

## Dependencies (2)

- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.23.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.23.0

## Recent versions

- 0.1.6 (latest) — 2019-07-31
- 0.1.5 — 2017-07-01
- 0.1.4 — 2017-07-01
- 0.1.3 — 2017-06-26
- 0.1.2 — 2017-06-25
- 0.1.1 — 2017-06-24
- 0.1.0 — 2017-05-09

## README

async-chain-proxy provides method chain interfaces for accessing async methods.

## How to use

### method chain

```js
class A {
  async foo () {
    console.log('foo')
  }
  async bar () {
    console.log('bar')
  }
}

const chainProxy = require('async-chain-proxy')
const obj = chainProxy(new A())
obj.foo().bar().end()

// output
>foo
>bar
```

### receive a return value

```js
class A {
  async foo () {
    return 'foo'
  }
}
const chainProxy = require('async-chain-proxy')
const obj = chainProxy(new A())
obj.foo().result((v) => console.log(v)).end()

// output
>foo
```

### API

#### constructor(target, options = {})

##### options

  - resultFuncName(default: 'result') : If you don't prefer result function name, you can change.
  - endFuncName(default: 'end') : If you don't prefer end function name, you can change.
  - onChainFinished(default: null) : this is a callback function that is called after end().

#### result(r)

This function is used for receiving result of previous action.

#### end()

Indicates end of chained actions. If you didn't call end(), all the actions aren't called.

#### target

Returns target object.

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