0.0.1 • Published 2 years ago
@woltsu/chainify-object v0.0.1
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();0.0.1
2 years ago