@epicallan/money-ts
Version:
TypeScript library for type-safe and lossless encoding and manipulation of world currencies and precious metals
29 lines (28 loc) • 1.24 kB
TypeScript
import { Newtype } from 'newtype-ts';
import { Option } from 'fp-ts/Option';
import * as EQ from 'fp-ts/Eq';
import * as ORD from 'fp-ts/Ord';
import { Integer } from './Integer';
import { BigInteger } from 'big-integer';
import { NonZeroInteger } from './NonZeroInteger';
/** A PositiveInteger is also an Integer */
export interface Natural extends Newtype<{
Integer: true;
NonZero: true;
Positive: true;
}, BigInteger> {
}
export declare function wrap(x: BigInteger): Option<Natural>;
export declare const unwrap: (x: Natural) => BigInteger;
export declare function fromInteger(i: Integer): Option<Natural>;
export declare const add: (x: Natural, y: Natural) => Natural;
export declare const mul: (x: Natural, y: Natural) => Natural;
export declare function sub(x: Natural, y: Natural): Option<Natural>;
export declare const negate: (x: Natural) => NonZeroInteger;
export declare const div: (x: Natural, y: Natural) => Natural;
export declare const gcd: (x: Natural, y: Natural) => Natural;
export declare const lcm: (x: Natural, y: Natural) => Natural;
export declare const Eq: EQ.Eq<Natural>;
export declare const Ord: ORD.Ord<Natural>;
export declare const show: (x: Natural) => string;
export declare const one: Natural;