Skip to content

Commit

Permalink
Fixed a bug with _objectToCPromise that happens if the thing has …
Browse files Browse the repository at this point in the history
…nullable value;
  • Loading branch information
DigitalBrainJS committed Apr 13, 2021
1 parent c9fd621 commit 7daa396
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/c-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,8 @@ class CPromise extends Promise {
}

static [_objectToCPromise](thing) {
if(!thing) return null;

const convertMethod = thing[_toCPromise];

if (typeof convertMethod === 'function') {
Expand All @@ -1308,7 +1310,7 @@ class CPromise extends Promise {
return returnedValue;
}

if (thing && typeof thing.then === 'function') {
if (typeof thing.then === 'function') {
return new this((resolve, reject, {onCancel}) => {
if (typeof thing.cancel === 'function') {
onCancel(reason => {
Expand Down

0 comments on commit 7daa396

Please sign in to comment.