UNPKG

@typed/new-type

Version:
29 lines 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isCharacter = exports.isNonEmptyString = exports.isEmptyString = exports.isNonPositiveInteger = exports.isNonNegativeInteger = exports.isNegativeInteger = exports.isPositiveInteger = exports.isNonPositive = exports.isNonNegative = exports.isNegative = exports.isPositive = exports.isNonZeroInteger = exports.isNonZero = exports.isZero = exports.isInteger = void 0; const new_type_1 = require("./new-type"); const and = (f, g) => (value) => f(value) && g(value); const or = (f, g) => (value) => f(value) || g(value); exports.isInteger = new_type_1.isNewType((n) => Number.isInteger(n)); exports.isZero = new_type_1.isNewType((x) => x === 0); exports.isNonZero = new_type_1.isNewType((x) => x !== 0); const _isNonZeroInteger = and(exports.isNonZero, exports.isInteger); exports.isNonZeroInteger = new_type_1.isNewType((x) => _isNonZeroInteger(x)); exports.isPositive = new_type_1.isNewType((x) => x > 0); exports.isNegative = new_type_1.isNewType((x) => x < 0); const _isNonNegative = or(exports.isZero, exports.isPositive); exports.isNonNegative = new_type_1.isNewType((x) => _isNonNegative(x)); const _isNonPositive = or(exports.isZero, exports.isNegative); exports.isNonPositive = new_type_1.isNewType((n) => _isNonPositive(n)); const _isPositiveInteger = and(exports.isInteger, exports.isPositive); exports.isPositiveInteger = new_type_1.isNewType((n) => _isPositiveInteger(n)); const _isNegativeInteger = and(exports.isNegative, exports.isInteger); exports.isNegativeInteger = new_type_1.isNewType((n) => _isNegativeInteger(n)); const _isNonNegativeInteger = or(exports.isZero, exports.isPositiveInteger); exports.isNonNegativeInteger = new_type_1.isNewType((n) => _isNonNegativeInteger(n)); const _isNonPositiveInteger = or(exports.isZero, exports.isNegativeInteger); exports.isNonPositiveInteger = new_type_1.isNewType((n) => _isNonPositiveInteger(n)); exports.isEmptyString = new_type_1.isNewType((x) => x === ''); exports.isNonEmptyString = new_type_1.isNewType((x) => x !== ''); exports.isCharacter = new_type_1.isNewType((x) => x.length === 1); //# sourceMappingURL=new-types.js.map