amos-tool
Version:
amos ui tool
60 lines (59 loc) • 1.83 kB
JavaScript
var isString = function(r) {
return "[object String]" === Object.prototype.toString.call(r)
},
isArray = Array.isArray || function(r) {
return "[object Array]" === Object.prototype.toString.call(r)
},
property = function(r) {
return function(t) {
return null == t ? void 0 : t[r]
}
},
MAX_ARRAY_INDEX = Math.pow(2, 53) - 1,
getLength = property("length"),
isArrayLike = function(r) {
var t = getLength(r);
return "number" == typeof t && t >= 0 && t <= MAX_ARRAY_INDEX
},
isArguments = function(r) {
return "[object Arguments]" === Object.prototype.toString.call(r)
},
isObject = function(r) {
var t = typeof r;
return "function" === t || "object" === t && !!r
},
has = function(r, t) {
if (!isArray(t)) return null != r && Object.prototype.hasOwnProperty.call(r, t);
for (var e = t.length, n = 0; n < e; n++) {
var i = t[n];
if (null == r || !Object.prototype.hasOwnProperty.call(r, i)) return !1;
r = r[i]
}
return !!e
},
keys = function(r) {
if (!isObject(r)) return [];
if (Object.keys) return Object.keys(r);
var t = [];
for (var e in r) has(r, e) && t.push(e);
return t
},
isEmpty = function(r) {
return null == r || (isArrayLike(r) && (isArray(r) || isString(r) || isArguments(r)) ? 0 === r.length : 0 === keys(r).length)
},
some = function(r, t) {
if (void 0 === r || null === r) throw new TypeError;
var e = Object(r),
n = e.length >>> 0;
if ("function" != typeof t) throw new TypeError;
for (var i = arguments.length >= 3 ? arguments[2] : void 0, o = 0; o < n; o++)
if (o in e && t.call(i, e[o], o, e)) return !0;
return !1
};
module.exports = {
isString: isString,
isArray: isArray,
isObject: isObject,
isEmpty: isEmpty,
some: some
};