https://github.com/simple-automation-testing/chain-simple
https://github.com/simple-automation-testing/chain-simple
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/simple-automation-testing/chain-simple
- Owner: Simple-Automation-Testing
- License: mit
- Created: 2020-11-03T11:17:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-15T09:45:59.000Z (over 1 year ago)
- Last Synced: 2025-03-28T21:38:20.637Z (9 months ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# chain-simple

The purpose of this library is - build simple and flexible chainable call of the object` methods
```ts
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 = makePropertiesChainable(obj);
chainableObj
.method1()
.method3()
.then(val => console.log(val)); // method1 1 \n method3 3 \n 3
```
```js
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 = makePropertiesChainable(obj);
chainableObj
.method1()
.method3()
.then(val => console.log(val)); // method1 1 \n method3 3 \n 3
```