aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/amounts.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/amounts.ts b/src/util/amounts.ts
index c85c4839a..8deeaeccc 100644
--- a/src/util/amounts.ts
+++ b/src/util/amounts.ts
@@ -184,7 +184,7 @@ export function sub(a: AmountJson, ...rest: AmountJson[]): Result {
* Compare two amounts. Returns 0 when equal, -1 when a < b
* and +1 when a > b. Throws when currencies don't match.
*/
-export function cmp(a: AmountJson, b: AmountJson): number {
+export function cmp(a: AmountJson, b: AmountJson): -1 | 0 | 1 {
if (a.currency !== b.currency) {
throw Error(`Mismatched currency: ${a.currency} and ${b.currency}`);
}
@@ -244,6 +244,10 @@ export function isNonZero(a: AmountJson): boolean {
return a.value > 0 || a.fraction > 0;
}
+export function isZero(a: AmountJson): boolean {
+ return a.value === 0 && a.fraction === 0;
+}
+
/**
* Parse an amount like 'EUR:20.5' for 20 Euros and 50 ct.
*/