# @cokencode/chainify

> Enable methods to be called in chain

Latest version **0.1.0** (published 2019-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cokencode/chainify
pnpm add @cokencode/chainify
yarn add @cokencode/chainify
bun add @cokencode/chainify
```

## 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.0 |
| Published | 2019-01-31 |
| First published | 2019-01-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jaehwan Moon |
| Maintainers | cokencode |
| Keywords | chain, promise |

## Links

- npm: https://www.npmjs.com/package/@cokencode/chainify
- Repository: https://github.com/cokencode/chainify
- Issues: https://github.com/cokencode/chainify/issues
- npm.io page: https://npm.io/package/@cokencode/chainify

## Alternatives

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

## Recent versions

- 0.1.0 (latest) — 2019-01-31

## README

# **Chainify**

Make functions of an instance chainable

## **How to use `Chainify`**

```js
const chainify = require('@cokencode/chainify');

// An example instance
const calculator = {
  addOne: number => number + 1
  multiplyByTwo: number => number * 2
  addOnePromise: number => Promise.resolve(number + 1)
};

const chainableCaluculator = chainify(calculator, 3);

chainableCalculator
  .addOne()
  .multiplyByTwo()
  .multiplyByTwo()
  .addOne()
  .unwrapChainify()
  .then(result => console.log(result));

```

## **API**
* chainify(instance, initialValue)
  * `instance`: Any `object` whose methods will be able to be chained.
  * `initialValue` (optional): The value that is passed to a first function chained as an parameter

* unwrapChainify(): This method can be called in a chain in order get a result value. It returns `Promise`. Warning: After calling this function, methods can no longer be chained.

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