money-ts
Version:
TypeScript library for type-safe and lossless encoding and manipulation of world currencies and precious metals
24 lines • 963 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var rational = require("./Rational");
var nonZeroRational = require("./NonZeroRational");
var natural = require("./Natural");
var newtype_ts_1 = require("newtype-ts");
function fromRational(r) {
return natural.fromInteger(r[0]).map(function (n) { return [n, r[1]]; });
}
exports.fromRational = fromRational;
exports.reduce = newtype_ts_1.unsafeCoerce(rational.reduce);
exports.add = newtype_ts_1.unsafeCoerce(rational.add);
exports.mul = newtype_ts_1.unsafeCoerce(rational.mul);
exports.one = newtype_ts_1.unsafeCoerce(rational.one);
function sub(x, y) {
return fromRational(rational.sub(x, y));
}
exports.sub = sub;
exports.div = newtype_ts_1.unsafeCoerce(rational.div);
exports.inverse = newtype_ts_1.unsafeCoerce(nonZeroRational.inverse);
exports.setoid = rational.setoid;
exports.ord = rational.ord;
exports.show = rational.show;
//# sourceMappingURL=PositiveRational.js.map