UNPKG

@epicallan/money-ts

Version:

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

65 lines 1.9 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Ring = exports.Ord = exports.Eq = exports.lcm = exports.gcd = exports.sub = exports.negate = exports.mul = exports.add = exports.two = exports.one = exports.zero = exports.wrap = void 0; var Option_1 = require("fp-ts/Option"); var bigInteger = require("big-integer"); var function_1 = require("fp-ts/function"); function wrap(x) { try { return Option_1.some(bigInteger(function_1.unsafeCoerce(x))); } catch (e) { return Option_1.none; } } exports.wrap = wrap; exports.zero = bigInteger.zero; exports.one = bigInteger.one; exports.two = bigInteger['2']; function add(x, y) { return x.add(y); } exports.add = add; function mul(x, y) { return x.multiply(y); } exports.mul = mul; function negate(x) { return x.negate(); } exports.negate = negate; function sub(x, y) { return x.subtract(y); } exports.sub = sub; function gcd(x, y) { return bigInteger.gcd(x, y); } exports.gcd = gcd; function lcm(x, y) { return bigInteger.lcm(x, y); } exports.lcm = lcm; exports.Eq = { equals: function (x, y) { return x.equals(y); } }; exports.Ord = __assign(__assign({}, exports.Eq), { compare: function (x, y) { return x.compare(y); } }); exports.Ring = { add: function (x, y) { return add(x, y); }, zero: exports.zero, mul: function (x, y) { return mul(x, y); }, one: exports.one, sub: function (x, y) { return sub(x, y); } }; //# sourceMappingURL=BigInteger.js.map