@woltsu/chainify-object
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

chainify-object

[!NOTE] This tool is primarly a POC and has not been battle-tested in production

Make any object's functions chainable, without losing the types! Works for class instances as well.

Usage

Considering the following builder-like object:

const obj = {
  doWorkA: async () => {...},
  doWorkB: () => {...},
  doWorkC: () => async () => {...}
}

Normally, we would use its functions like so:

await obj.doWorkA();
obj.doWorkB();
await obj.doWorkC();

With chainify-object, we can instead make the object's functions chainable:

import { chainify } from "chainify-object";

await chainify(obj).doWorkA().doWorkB().doWorkC();

Readme

Keywords

none

Package Sidebar

Install

npm i @woltsu/chainify-object

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

7.88 kB

Total Files

9

Last publish

Collaborators

  • woltsu