Skip to content

Commit

Permalink
✨ Add Pledge#getRejectedReason() method
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Apr 27, 2024
1 parent a12004f commit 1e7a1c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add `Blast.isAppleWebkit` boolean
* Add `Blast.environment` string property and `isProduction`, `isDevelopment` and `isStaging` booleans
* Add `Optional` value-wrapper class
* Add `Pledge#getRejectedReason()` method

## 0.9.2 (2024-02-25)

Expand Down
18 changes: 18 additions & 0 deletions lib/pledge.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,24 @@ Pledge.setMethod(function getResolvedValue() {
return this[RESOLVED_VALUE];
});

/**
* Get the rejected reason of this pledge
*
* @author Jelle De Loecker <[email protected]>
* @since 0.9.3
* @version 0.9.3
*
* @return {*}
*/
Pledge.setMethod(function getRejectedReason() {

if (this[STATE] != REJECTED) {
return;
}

return this[REJECTED_REASON];
});

/**
* Resolve with the given value
*
Expand Down

0 comments on commit 1e7a1c1

Please sign in to comment.