-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
results.ts
43 lines (34 loc) · 754 Bytes
/
results.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Big from 'big.js'
import {CurrencyCode} from './currencies'
export interface Result {}
export class Nothing implements Result {
kind: 'nil' = 'nil'
}
export class Numbr implements Result {
kind: 'numbr' = 'numbr'
constructor(
public value: Big,
public currency?: CurrencyCode,
) {
if (currency?.toUpperCase() != currency) {
throw new Error(`The currency ${currency} is in lowercase!`)
}
}
get hasCurrency(): boolean {
return this.currency != undefined
}
}
export class Percent implements Result {
kind: 'percent' = 'percent'
constructor(
public value: Big,
) {
}
}
export class Header implements Result {
kind: 'header' = 'header'
constructor(
public title: string,
) {
}
}