38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
// @flow
|
|
declare type $currency$any = number | string | currency;
|
|
|
|
declare type formatFunction = (currency: currency, options: $currency$opts) => string;
|
|
|
|
declare type $currency$opts = {
|
|
symbol?: string,
|
|
separator?: string,
|
|
decimal?: string,
|
|
errorOnInvalid?: boolean,
|
|
precision?: number,
|
|
increment?: number,
|
|
useVedic?: boolean,
|
|
pattern?: string,
|
|
negativePattern?: string,
|
|
format?: formatFunction,
|
|
fromCents?: boolean
|
|
}
|
|
|
|
declare class currency {
|
|
static (value: $currency$any, opts?: $currency$opts): currency,
|
|
constructor(value: $currency$any, opts?: $currency$opts): currency,
|
|
add(number: $currency$any): currency;
|
|
subtract(number: $currency$any): currency;
|
|
multiply(number: $currency$any): currency;
|
|
divide(number: $currency$any): currency;
|
|
distribute(count: number): Array<currency>;
|
|
dollars(): number;
|
|
cents(): number;
|
|
format(options?: $currency$opts | formatFunction): string;
|
|
toString(): string;
|
|
toJSON(): number;
|
|
+intValue: number;
|
|
+value: number;
|
|
}
|
|
|
|
declare module.exports: typeof currency;
|