UNPKG

@epicallan/money-ts

Version:

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

31 lines (30 loc) 1.55 kB
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 { BigInteger } from 'big-integer'; import { Natural } from './Natural'; import * as I from './Integer'; /** 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: 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: I.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 Eq: EQ.Eq<NonZeroInteger>; export declare const Ord: ORD.Ord<NonZeroInteger>; export declare const show: (x: NonZeroInteger) => string;