UNPKG

money-ts

Version:

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

10 lines 682 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var io_ts_1 = require("io-ts"); var Discrete_1 = require("../Discrete"); var Integer_1 = require("./Integer"); exports.getDiscrete = function (dimension, unit) { var format = { dimension: dimension, unit: unit }; return new io_ts_1.Type('Discrete', function (m) { return m instanceof Discrete_1.Discrete && m.format.dimension === dimension && m.format.unit === unit; }, function (m, c) { return Integer_1.Integer.validate(m, c).map(function (r) { return new Discrete_1.Discrete(format, r); }); }, function (a) { return Integer_1.Integer.encode(a.value); }); }; //# sourceMappingURL=Discrete.js.map