https://github.com/french-exception/node-chained-promise-event-emitter-lib
Small contract which helps chains promises
https://github.com/french-exception/node-chained-promise-event-emitter-lib
Last synced: over 1 year ago
JSON representation
Small contract which helps chains promises
- Host: GitHub
- URL: https://github.com/french-exception/node-chained-promise-event-emitter-lib
- Owner: French-Exception
- Created: 2019-12-02T09:38:13.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2019-12-17T13:42:11.000Z (over 6 years ago)
- Last Synced: 2024-04-25T18:41:42.663Z (about 2 years ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Installation
```bash
npm install --save @frenchex/chained-promise-event-emitter-lib
```
# Information
Small contract which helps developers chain Promises with logging and event-emission.
# Usage example
```typescript
import * as log4j from '@log4js-node/log4js-api';
import {ChainedPromiseEventEmitter} from "@frenchex/chained-promise-event-emitter-lib";
$logger = log4js.getLogger('my-app-main-promise');
$cP = new ChainedPromiseEventEmitter($logger);
$cP
.chain('init.config.init', initConfigInit /** returns a Promise **/)
.chain('init.config.load', initConfigLoad /** returns a Promise **/)
.chain('init.rc.load', initRcLoad /** returns a Promise **/)
.run()
```
# Testing
Testing code is offloaded into another NPM package.
```bash
mkdir chained-promise-event-emitter-lib-test
cd chained-promise-event-emitter-lib-test
npm init -f
npm i --save @frenchex/chained-promise-event-emitter-lib-test
cd node_modules/@frenchex/chained-promise-event-emitter-lib
npm run test
```