From 90399181b5d574f6f8bfbd097fed5f8f9baa009f Mon Sep 17 00:00:00 2001 From: Christopher Eck Date: Tue, 20 Jun 2017 11:20:26 -0700 Subject: [PATCH 1/2] Update accounting.formatMoney definition to allow string input --- types/accounting/accounting-tests.ts | 3 +++ types/accounting/index.d.ts | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/types/accounting/accounting-tests.ts b/types/accounting/accounting-tests.ts index a397c559eb..41150f7a37 100644 --- a/types/accounting/accounting-tests.ts +++ b/types/accounting/accounting-tests.ts @@ -3,6 +3,9 @@ // Default usage: accounting.formatMoney(12345678); // $12,345,678.00 +// Stringified usage: +accounting.formatMoney('$4394958309392.9401'); // $4,394,958,309,392.94 + // European formatting (custom symbol and separators), could also use options object as second param: accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99 diff --git a/types/accounting/index.d.ts b/types/accounting/index.d.ts index ef8991999f..9234a79261 100644 --- a/types/accounting/index.d.ts +++ b/types/accounting/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for accounting.js 0.3 +// Type definitions for accounting.js 0.4 // Project: http://josscrowcroft.github.io/accounting.js/ // Definitions by: Sergey Gerasimov +// Christopher Eck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace accounting { @@ -30,9 +31,9 @@ declare namespace accounting { } interface Static { - // format any number into currency - formatMoney(number: number, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string; - formatMoney(number: number, options: CurrencySettings | CurrencySettings): string; + // format any number or stringified number into currency + formatMoney(number: number | string, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string; + formatMoney(number: number | string, options: CurrencySettings | CurrencySettings): string; formatMoney(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[]; formatMoney(numbers: number[], options: CurrencySettings | CurrencySettings): string[]; From 9d1d71714895ce5bb5ec6e06eb129111e4d17e17 Mon Sep 17 00:00:00 2001 From: Christopher Eck Date: Wed, 21 Jun 2017 17:37:33 -0700 Subject: [PATCH 2/2] Updated project link --- types/accounting/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/accounting/index.d.ts b/types/accounting/index.d.ts index 9234a79261..9a990a6519 100644 --- a/types/accounting/index.d.ts +++ b/types/accounting/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for accounting.js 0.4 -// Project: http://josscrowcroft.github.io/accounting.js/ +// Project: http://openexchangerates.github.io/accounting.js/ // Definitions by: Sergey Gerasimov // Christopher Eck // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped