Correct a few ts bugs
This commit is contained in:
		
							parent
							
								
									4da752a3ad
								
							
						
					
					
						commit
						79d7d2c99d
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		|  | @ -30,10 +30,11 @@ export class Money { | ||||||
| 
 | 
 | ||||||
|   protected constructor(readonly amountInCents: number, currency: string) { |   protected constructor(readonly amountInCents: number, currency: string) { | ||||||
|     this.currency = currency.toLowerCase() |     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.compare, this.greaterThan, this.greaterThanOrEqual, this.lessThan, | ||||||
|       this.lessThanOrEqual, this.isZero, this.isPositive, this.isNegative, |       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); |     Object.freeze(this); | ||||||
|   } |   } | ||||||
|  | @ -107,7 +108,7 @@ export class Money { | ||||||
|    * @returns {Money} |    * @returns {Money} | ||||||
|    */ |    */ | ||||||
|   multiply(multiplier: number, fn?: Function): Money { |   multiply(multiplier: number, fn?: Function): Money { | ||||||
|     if (!lodash.isFunction(fn)) |     if (!isFunction(fn)) | ||||||
|       fn = Math.round; |       fn = Math.round; | ||||||
| 
 | 
 | ||||||
|     assertOperand(multiplier); |     assertOperand(multiplier); | ||||||
|  | @ -124,7 +125,7 @@ export class Money { | ||||||
|    * @returns {Money} |    * @returns {Money} | ||||||
|    */ |    */ | ||||||
|   divide(divisor: number, fn?: (x: number) => number): Money { |   divide(divisor: number, fn?: (x: number) => number): Money { | ||||||
|     if (!lodash.isFunction(fn)) |     if (!isFunction(fn)) | ||||||
|       fn = Math.round; |       fn = Math.round; | ||||||
| 
 | 
 | ||||||
|     assertOperand(divisor); |     assertOperand(divisor); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Eric
						Eric