@opra/common
Version:
Opra common package
39 lines (38 loc) • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntegerType = void 0;
const tslib_1 = require("tslib");
const valgen_1 = require("valgen");
const constants_js_1 = require("../../constants.js");
const simple_type_js_1 = require("../simple-type.js");
const number_type_js_1 = require("./number.type.js");
let IntegerType = class IntegerType extends number_type_js_1.NumberType {
constructor(properties) {
super(properties);
}
[constants_js_1.DECODER](properties) {
const x = [];
if (properties.minValue != null)
x.push(valgen_1.vg.isGte(properties.minValue));
if (properties.maxValue != null)
x.push(valgen_1.vg.isLte(properties.maxValue));
return x.length > 0
? valgen_1.vg.pipe([valgen_1.toInteger, ...x], { returnIndex: 0 })
: valgen_1.toInteger;
}
[constants_js_1.ENCODER](properties) {
return this[constants_js_1.DECODER](properties);
}
};
exports.IntegerType = IntegerType;
exports.IntegerType = IntegerType = tslib_1.__decorate([
(0, simple_type_js_1.SimpleType)({
name: 'integer',
description: 'An integer number',
nameMappings: {
js: 'number',
json: 'number',
},
}),
tslib_1.__metadata("design:paramtypes", [Object])
], IntegerType);