https://github.com/yuqingc/power-transaction
https://github.com/yuqingc/power-transaction
transaction transaction-processing typescript
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yuqingc/power-transaction
- Owner: yuqingc
- License: other
- Created: 2019-04-17T09:58:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-22T01:47:36.000Z (about 7 years ago)
- Last Synced: 2025-07-03T02:05:36.233Z (10 months ago)
- Topics: transaction, transaction-processing, typescript
- Language: TypeScript
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.996ICU
Awesome Lists containing this project
README
# Power Transaction
[](https://996.icu)
[](https://github.com/996icu/996.ICU/blob/master/LICENSE)
[](https://www.npmjs.com/package/power-transaction)
[](https://github.com/yuqingc/power-transaction/issues)
**DO NOT USE IT AT PRESENT!**
Power Transaction is a tool for handling transactions. Still under development. *NOT* stable.
## Get Started
### Installation
```
$ yarn add power-transaction
```
or with NPM
```
$ npm i --save power-transaction
```
### Code
```ts
import { createTransaction, TransactionConfig } from '../src'
const config: TransactionConfig = {
tasks: [
{
name: 'step1',
action: (data: any) => {
console.log('executing step1', data);
return 'step1 return';
},
rollback: (data: any) => {
console.log('rolling back step1');
}
},
{
name: 'step2',
action: (data: any) => {
console.log('executing step2', data);
return 'step2 return';
},
rollback: (data: any) => {
console.log('rolling back step2');
}
},
{
name: 'step3',
action: (data: any) => {
console.log('executing step3', data);
return 'step3 return';
},
rollback: (data: any) => {
console.log('rolling back step3');
}
},
{
name: 'step4',
action: (data: any) => {
console.log('executing step4', data);
return 'step1 return';
},
rollback: (data: any) => {
console.log('rolling back step4');
}
}
],
}
const t = createTransaction(config)
t.executeAll();
```
## Development
```
$ yarn build
$ yarn test
```
## License
Under [MIT license](https://github.com/yuqingc/power-transaction/blob/master/LICENSE.MIT) with [Anti-996 license](https://github.com/yuqingc/power-transaction/blob/master/LICENSE.996ICU).