UNPKG

@epicallan/money-ts

Version:

TypeScript library for type-safe and lossless encoding and manipulation of world currencies and precious metals

26 lines (25 loc) 1.13 kB
import { Integer } from './Integer'; import { NonZeroInteger } from './NonZeroInteger'; import { Eq } from 'fp-ts/Eq'; import { Ord } from 'fp-ts/Ord'; export interface Format<D extends string, U extends string | number | symbol> { dimension: D; unit: U; } export declare class Discrete<D extends string, U extends string | number | symbol> { readonly format: Format<D, U>; readonly value: Integer; constructor(format: Format<D, U>, value: Integer); add(y: Discrete<D, U>): Discrete<D, U>; mul(y: Integer): Discrete<D, U>; negate(): Discrete<D, U>; sub(y: Discrete<D, U>): Discrete<D, U>; div(y: NonZeroInteger): Discrete<D, U>; isZero(): boolean; inspect(): string; toString(): string; } export declare function getOne<D extends string, U extends string>(format: Format<D, U>): Discrete<D, U>; export declare function getZero<D extends string, U extends string>(format: Format<D, U>): Discrete<D, U>; export declare function getEq<D extends string, U extends string>(): Eq<Discrete<D, U>>; export declare function getOrd<D extends string, U extends string>(): Ord<Discrete<D, U>>;