1.3.2 • Published 1 month ago

chain-simple v1.3.2

Weekly downloads
46
License
ISC
Repository
github
Last release
1 month ago

chain-simple

npm downloads

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

import { makePropertiesChainable } from 'chain-simple';
import type { TChainable } from 'chain-simple';

const obj = {
  async method1() {
    return Promise.resolve(1).then(value => {
      console.log('method1', value);
      return value;
    });
  },
  async method2() {
    return Promise.resolve(2).then(value => {
      console.log('method2', value);
      return value;
    });
  },
  async method3() {
    return Promise.resolve(3).then(value => {
      console.log('method3', value);
      return value;
    });
  },
};

const chainableObj: TChainable<typeof obj> = makePropertiesChainable(obj);

chainableObj
  .method1()
  .method3()
  .then(val => console.log(val)); // method1 1 \n method3 3 \n 3
const { makePropertiesChainable } = require('chain-simple');

const obj = {
  async method1() {
    return Promise.resolve(1).then(value => {
      console.log('method1', value);
      return value;
    });
  },
  async method2() {
    return Promise.resolve(2).then(value => {
      console.log('method2', value);
      return value;
    });
  },
  async method3() {
    return Promise.resolve(3).then(value => {
      console.log('method3', value);
      return value;
    });
  },
};

const chainableObj: TChainable<typeof obj> = makePropertiesChainable(obj);

chainableObj
  .method1()
  .method3()
  .then(val => console.log(val)); // method1 1 \n method3 3 \n 3
1.3.2

1 month ago

1.3.1

10 months ago

1.3.0

12 months ago

1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.4

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago