UNPKG

money-ts

Version:

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

31 lines (30 loc) 1.57 kB
import { Newtype } from 'newtype-ts'; import { Option } from 'fp-ts/lib/Option'; import { Setoid } from 'fp-ts/lib/Setoid'; import { Ord } from 'fp-ts/lib/Ord'; import { Integer } from './Integer'; import { BigInteger } from 'big-integer'; import { Natural } from './Natural'; /** A NonZeroInteger is also an Integer */ export interface NonZeroInteger extends Newtype<{ Integer: true; NonZero: true; }, BigInteger> { } export declare function wrap(x: BigInteger): Option<NonZeroInteger>; export declare const unwrap: (x: NonZeroInteger) => BigInteger; export declare function fromInteger(i: Integer): Option<NonZeroInteger>; export declare const add: (x: NonZeroInteger, y: NonZeroInteger) => NonZeroInteger; export declare const mul: (x: NonZeroInteger, y: NonZeroInteger) => NonZeroInteger; export declare const one: NonZeroInteger; export declare const negate: (x: NonZeroInteger) => NonZeroInteger; export declare function sub(x: NonZeroInteger, y: NonZeroInteger): Option<NonZeroInteger>; export declare const div: (x: NonZeroInteger, y: NonZeroInteger) => NonZeroInteger; export declare const sign: (x: NonZeroInteger) => -1 | 1; export declare function gcd(x: Integer, y: NonZeroInteger): Natural; export declare function lcm(x: NonZeroInteger, y: NonZeroInteger): Natural; export declare const isPositive: (x: NonZeroInteger) => boolean; export declare function abs(x: NonZeroInteger): Natural; export declare const setoid: Setoid<NonZeroInteger>; export declare const ord: Ord<NonZeroInteger>; export declare const show: (x: NonZeroInteger) => string;