From 79d7d2c99dbfa6c5e823ec822305023ef48b081f Mon Sep 17 00:00:00 2001 From: Eric <eric@commitchange.com> Date: Wed, 24 Jun 2020 16:42:03 -0500 Subject: [PATCH] Correct a few ts bugs --- app/javascript/common/money.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/javascript/common/money.ts b/app/javascript/common/money.ts index 12bc1b0d..09662a9e 100644 --- a/app/javascript/common/money.ts +++ b/app/javascript/common/money.ts @@ -30,10 +30,11 @@ export class Money { protected constructor(readonly amountInCents: number, currency: string) { this.currency = currency.toLowerCase() - [this.equals, this.add, this.subtract, this.multiply, this.divide, this.allocate, + const methodsToBind = [this.equals, this.add, this.subtract, this.multiply, this.divide, this.allocate, this.compare, this.greaterThan, this.greaterThanOrEqual, this.lessThan, this.lessThanOrEqual, this.isZero, this.isPositive, this.isNegative, - this.toJSON].forEach((func) => Object.bind(func)) + this.toJSON] + methodsToBind.forEach((func:Function) => Object.bind(func)) Object.freeze(this); } @@ -107,7 +108,7 @@ export class Money { * @returns {Money} */ multiply(multiplier: number, fn?: Function): Money { - if (!lodash.isFunction(fn)) + if (!isFunction(fn)) fn = Math.round; assertOperand(multiplier); @@ -124,7 +125,7 @@ export class Money { * @returns {Money} */ divide(divisor: number, fn?: (x: number) => number): Money { - if (!lodash.isFunction(fn)) + if (!isFunction(fn)) fn = Math.round; assertOperand(divisor);