Skip to content

Repository files navigation

chain-simple

npm downloads

The purpose of this library is - build simple and flexible chainable call of the object` methods

import{chainProps}from'chain-simple';importtype{TChainable}from'chain-simple';constobj={asyncmethod1(){returnPromise.resolve(1).then(value=>{console.log('method1',value);returnvalue;});},asyncmethod2(){returnPromise.resolve(2).then(value=>{console.log('method2',value);returnvalue;});},asyncmethod3(){returnPromise.resolve(3).then(value=>{console.log('method3',value);returnvalue;});},};constchainableObj: TChainable<typeofobj>=chainProps(obj);chainableObj.method1().method3().then(val=>console.log(val));// method1 1 \n method3 3 \n 3
const{ chainProps }=require('chain-simple');constobj={asyncmethod1(){returnPromise.resolve(1).then(value=>{console.log('method1',value);returnvalue;});},asyncmethod2(){returnPromise.resolve(2).then(value=>{console.log('method2',value);returnvalue;});},asyncmethod3(){returnPromise.resolve(3).then(value=>{console.log('method3',value);returnvalue;});},};constchainableObj: TChainable<typeofobj> = chainProps(obj);
chainableObj
.method1()
.method3()
.then(val =>console.log(val));// method1 1 \n method3 3 \n 3

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages