diff options
Diffstat (limited to 'src/amounts.ts')
-rw-r--r-- | src/amounts.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/amounts.ts b/src/amounts.ts index 8b5278330..b90d54a31 100644 --- a/src/amounts.ts +++ b/src/amounts.ts @@ -103,6 +103,14 @@ export function getZero(currency: string): AmountJson { } +export function sum(amounts: AmountJson[]) { + if (amounts.length <= 0) { + throw Error("can't sum zero amounts"); + } + return add(amounts[0], ...amounts.slice(1)); +} + + /** * Add two amounts. Return the result and whether * the addition overflowed. The overflow is always handled |