diff --git a/src/pledge-operations.js b/src/pledge-operations.js index 77eb87a..fde253a 100644 --- a/src/pledge-operations.js +++ b/src/pledge-operations.js @@ -64,7 +64,7 @@ export class PledgeCapability { // 25.6.1.2 PromiseReaction Records //----------------------------------------------------------------------------- -class PledgeReaction { +export class PledgeReaction { constructor(capability, type, handler) { this.capability = capability; this.type = type; @@ -72,18 +72,6 @@ class PledgeReaction { } } -export class PledgeFulfillReaction extends PledgeReaction { - constructor(capability, handler) { - super(capability, "fulfill", handler); - } -} - -export class PledgeRejectReaction extends PledgeReaction { - constructor(capability, handler) { - super(capability, "reject", handler); - } -} - //----------------------------------------------------------------------------- // 25.6.1.3 CreateResolvingFunctions( promise ) //----------------------------------------------------------------------------- diff --git a/src/pledge.js b/src/pledge.js index e5fabd7..66b7dc4 100644 --- a/src/pledge.js +++ b/src/pledge.js @@ -13,8 +13,7 @@ import { isObject, isCallable } from "./utilities.js"; import { isPledge, createResolvingFunctions, - PledgeFulfillReaction, - PledgeRejectReaction, + PledgeReaction, PledgeCapability } from "./pledge-operations.js"; @@ -100,8 +99,8 @@ export class Pledge { assertIsPledge(this); const C = this.constructor[Symbol.species]; - const capability = new PledgeCapability(C); - return performPledgeThen(this, onFulfilled, onRejected, capability); + const resultCapability = new PledgeCapability(C); + return performPledgeThen(this, onFulfilled, onRejected, resultCapability); } catch(rejectionHandler) { @@ -157,8 +156,8 @@ function performPledgeThen(pledge, onFulfilled, onRejected, resultCapability) { onRejected = undefined; } - const fulfillReaction = new PledgeFulfillReaction(resultCapability, onFulfilled); - const rejectReaction = new PledgeRejectReaction(resultCapability, onRejected); + const fulfillReaction = new PledgeReaction(resultCapability, "fulfill", onFulfilled); + const rejectReaction = new PledgeReaction(resultCapability, "reject", onRejected); switch (pledge[PledgeSymbol.state]) {