From bbb9d7f12cbd8500ce955d25df605597e1300c86 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 23 Sep 2020 12:11:46 -0700 Subject: [PATCH] Fix: Remove call() function --- src/pledge-operations.js | 4 ++-- src/pledge.js | 6 +++--- tests/pledge-operations.test.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pledge-operations.js b/src/pledge-operations.js index 224a449..77eb87a 100644 --- a/src/pledge-operations.js +++ b/src/pledge-operations.js @@ -51,11 +51,11 @@ export class PledgeCapability { this.pledge = new C(executor); if (!isCallable(this.resolve)) { - throw new TypeError("resolve function is not callable."); + throw new TypeError("resolve is not callable."); } if (!isCallable(this.reject)) { - throw new TypeError("reject function is not callable."); + throw new TypeError("reject is not callable."); } } } diff --git a/src/pledge.js b/src/pledge.js index ae59f2b..e5fabd7 100644 --- a/src/pledge.js +++ b/src/pledge.js @@ -9,7 +9,7 @@ import { PledgeSymbol } from "./pledge-symbol.js"; import { PledgeReactionJob, hostEnqueuePledgeJob } from "./pledge-jobs.js"; -import { isObject, isCallable, call } from "./utilities.js"; +import { isObject, isCallable } from "./utilities.js"; import { isPledge, createResolvingFunctions, @@ -120,14 +120,14 @@ export class Pledge { } else { thenFinally = value => { - const result = call(onFinally, undefined); + const result = onFinally.apply(undefined); const pledge = pledgeResolve(C, result); const valueThunk = () => value; return pledge.then(valueThunk); }; catchFinally = reason => { - const result = call(onFinally, undefined); + const result = onFinally.apply(undefined); const pledge = pledgeResolve(C, result); const thrower = () => { throw reason; diff --git a/tests/pledge-operations.test.js b/tests/pledge-operations.test.js index c451156..6d22d89 100644 --- a/tests/pledge-operations.test.js +++ b/tests/pledge-operations.test.js @@ -61,7 +61,7 @@ describe("pledge-operations", () => { it("should throw an error when a regular function is passed", () => { expect(() => { new PledgeCapability(function() {}); - }).to.throw(/resolve function is not callable/); + }).to.throw(/resolve is not callable/); }); it("should throw an error when a regular function is passed without a reject parameter", () => { @@ -71,7 +71,7 @@ describe("pledge-operations", () => { expect(() => { new PledgeCapability(FakePledge); - }).to.throw(/reject function is not callable/); + }).to.throw(/reject is not callable/); }); });