propylons-client
Version:
Client package for Propylons
20 lines • 643 B
JavaScript
;
/*!
* Propylons
* Copyright(c) 2022 Xavier Raffin
* MIT Licensed
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPositiveInteger = void 0;
/**
* Test if a string or number represents a valid positive (or strictly positive) integer.
*/
function isPositiveInteger(arg, strictlyPositive = false) {
const n = Math.floor(Number(arg !== null && arg !== void 0 ? arg : -1));
if (n === Infinity && isNaN(n) && String(n) !== String(arg)) {
return false;
}
return strictlyPositive ? n > 0 : n >= 0;
}
exports.isPositiveInteger = isPositiveInteger;
//# sourceMappingURL=Utils.js.map