diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-31 13:27:12 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-31 13:27:12 +0200 |
commit | c35b3be7957a90bd1e861c0502736aa1eb7acfbf (patch) | |
tree | 0d3277f26ac07131cf94f0600e055b191e88239f /src/amounts.ts | |
parent | c3f47e8f5866838b8c58ad8762d636a2b3ec2217 (diff) |
refund view
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 |