Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Sep 9, 2020
1 parent f4e0d36 commit 7b15cb8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 20 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ has lost its relevance to you.
Install for node.js using npm/yarn:

``` bash
$ npm install c-promise
$ npm install c-promise2
```

``` bash
$ yarn add c-promise
$ yarn add c-promise2
```

#### CDN
- [development UMD version](https://unpkg.com/c-promise2@0.1.0/dist/dev/c-promise.umd.js)

- [production UMD version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.umd.js)

- [production CommonJS version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.cjs.js)

- [production ESM version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.mjs)

## Features / Advantages
- there are no any dependencies (except [native] Promise), browser support
- cancellation sequence
Expand All @@ -54,6 +63,10 @@ $ yarn add c-promise

## Live Example

[Live browser example](https://jsfiddle.net/DigitalBrain/g0dv5L8c/3/)

[Live nodejs example](https://runkit.com/digitalbrainjs/runkit-npm-c-promise2)

<img src="http://g.recordit.co/E6e97qRPoY.gif" alt="Browser playground with fetch" width="50%" height="50%">

## Playground
Expand Down Expand Up @@ -111,10 +124,14 @@ echoChainState();

chain
.then((value) => {
log(`Done with value '${value}'`);
}, (err) => {
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
log(`Done with value '${value}'`); // [1006ms] CanceledError: canceled
}).label('final')
.catch((err)=>{
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
}, CPromise.CanceledError)
.catch(err=>{
log(`Some other error occurred: ${err}`);
})
.finally(() => {
echoChainState();
});
Expand Down
27 changes: 22 additions & 5 deletions jsdoc2md/README.hbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ has lost its relevance to you.
Install for node.js using npm/yarn:

``` bash
$ npm install c-promise
$ npm install c-promise2
```

``` bash
$ yarn add c-promise
$ yarn add c-promise2
```

#### CDN
- [development UMD version](https://unpkg.com/c-promise2@0.1.0/dist/dev/c-promise.umd.js)

- [production UMD version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.umd.js)

- [production CommonJS version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.cjs.js)

- [production ESM version](https://unpkg.com/c-promise2@0.1.0/dist/c-promise.mjs)

## Features / Advantages
- there are no any dependencies (except [native] Promise), browser support
- cancellation sequence
Expand All @@ -54,6 +63,10 @@ $ yarn add c-promise

## Live Example

[Live browser example](https://jsfiddle.net/DigitalBrain/g0dv5L8c/3/)

[Live nodejs example](https://runkit.com/digitalbrainjs/runkit-npm-c-promise2)

<img src="http://g.recordit.co/E6e97qRPoY.gif" alt="Browser playground with fetch" width="50%" height="50%">

## Playground
Expand Down Expand Up @@ -111,10 +124,14 @@ echoChainState();

chain
.then((value) => {
log(`Done with value '${value}'`);
}, (err) => {
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
log(`Done with value '${value}'`); // [1006ms] CanceledError: canceled
}).label('final')
.catch((err)=>{
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
}, CPromise.CanceledError)
.catch(err=>{
log(`Some other error occurred: ${err}`);
})
.finally(() => {
echoChainState();
});
Expand Down
8 changes: 2 additions & 6 deletions lib/c-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,6 @@ class CPromise extends Promise {

catch(onRejected, filter){
if(filter){
if(!(filter instanceof Error)){
throw TypeError('filter argument must be an error constructor');
}

return super.catch((err)=>{
if(err instanceof filter){
onRejected(err);
Expand Down Expand Up @@ -776,12 +772,12 @@ function bindMethod(prototype, methodName) {
throw Error(`Property ${methodName} doesn't exists`);
}
const method = descriptor.value;
let bound;
const boundSymbol= Symbol(`${methodName}Bound`);

Object.defineProperty(prototype, methodName, {
get() {
const context = this;
return bound || (bound = function () {
return this[boundSymbol] || (this[boundSymbol] = function () {
return method.apply(context, arguments);
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "c-promise",
"name": "c-promise2",
"version": "0.1.0",
"description": "Cancelable promise chain with progress capturing and other extra features",
"author": {
Expand Down
10 changes: 7 additions & 3 deletions playground/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ echoChainState();

chain
.then((value) => {
log(`Done with value '${value}'`);
}, (err) => {
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
log(`Done with value '${value}'`); // [1006ms] CanceledError: canceled
}).label('final')
.catch((err)=>{
log(`cancelled with error : ${err} on '${err.scope.label()}'`); // [1006ms] CanceledError: canceled
}, CPromise.CanceledError)
.catch(err=>{
log(`Some other error occurred: ${err}`);
})
.finally(() => {
echoChainState();
});
Expand Down

0 comments on commit 7b15cb8

Please sign in to comment.