Skip to content

Commit

Permalink
Update: Bring more in line with spec
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Sep 24, 2020
1 parent bbb9d7f commit f1fa2df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
14 changes: 1 addition & 13 deletions src/pledge-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,14 @@ export class PledgeCapability {
// 25.6.1.2 PromiseReaction Records
//-----------------------------------------------------------------------------

class PledgeReaction {
export class PledgeReaction {
constructor(capability, type, handler) {
this.capability = capability;
this.type = type;
this.handler = handler;
}
}

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 )
//-----------------------------------------------------------------------------
Expand Down
11 changes: 5 additions & 6 deletions src/pledge.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { isObject, isCallable } from "./utilities.js";
import {
isPledge,
createResolvingFunctions,
PledgeFulfillReaction,
PledgeRejectReaction,
PledgeReaction,
PledgeCapability
} from "./pledge-operations.js";

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]) {

Expand Down

0 comments on commit f1fa2df

Please sign in to comment.