amos-tool
Version:
amos ui tool
72 lines (59 loc) • 2.15 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), MAX_LENGTH = 9007199254740991;
function isInteger(e) {
return Math.floor(e) === e;
}
function isCollection(e) {
return "object" === (0, _typeof2.default)(e) && null !== e && "number" == typeof e.length && isInteger(e.length) && e.length >= 0 && e.length <= MAX_LENGTH;
}
function isString(e) {
return "string" == typeof e;
}
function isBaseNaN(e) {
return e != e || isNaN(e);
}
function isNumber(e) {
return "object" === (0, _typeof2.default)(e) ? e instanceof Number : "number" == typeof e;
}
function isnan(e) {
return isNumber(e) && isBaseNaN(e.valueOf());
}
function contains(e, r, t) {
var n, i, o;
if (!isCollection(e) && !isString(e)) throw new TypeError("invalid argument. First argument must be array-like. Value: '".concat(e, "'"));
if (arguments.length < 2) throw new Error("insufficient arguments. Must provide a search value.");
if (arguments.length > 2) {
if (!isInteger(t)) throw new TypeError("invalid argument. Third argument must be an integer. Value: '".concat(t, "'."));
(i = t) < 0 && (i = 0);
} else i = 0;
if (isString(e)) {
if (!isString(r)) throw new TypeError("invalid argument. Second argument must be a string. Value: '".concat(r, "'."));
return -1 !== e.indexOf(r, i);
}
if (n = e.length, isnan(r)) {
for (o = i; o < n; o++) if (isnan(e[o])) return !0;
return !1;
}
for (o = i; o < n; o++) if (e[o] === r) return !0;
return !1;
}
var isArray = Array.isArray || function(e) {
return "[object Array]" === Object.prototype.toString.call(e);
};
function isObject(e) {
return "object" === (0, _typeof2.default)(e) && null !== e && !isArray(e);
}
var has = Object.prototype.hasOwnProperty;
function hasOwnProp(e, r) {
return null != e && has.call(e, r);
}
module.exports = {
MAX_LENGTH: MAX_LENGTH,
isInteger: isInteger,
isCollection: isCollection,
isString: isString,
contains: contains,
isArray: isArray,
isObject: isObject,
hasOwnProp: hasOwnProp
};