@darwish/is
Version:
78 lines (77 loc) • 2.72 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUndef = exports.isInfinity = exports.isNumber = exports.isBoolean = exports.isString = exports.isFunction = exports.isSymbol = exports.isArray = exports.isBigint = exports.isNull = exports.isMap = exports.isSet = exports.isObject = exports.isDate = void 0;
var isProxy_1 = __importDefault(require("./isProxy"));
var isDate = function (value) {
return objProtoCallType(value, "date");
};
exports.isDate = isDate;
/**
* Check if the value is an object, excluding proxies
* if excludeProxy is true, it will return false if the value is a proxy
* @param value the value to check
* @param excludeProxy whether to exclude proxies or not, defaults to `true`
* @returns true if the value is an object, false otherwise
*/
var isObject = function (value, excludeProxy) {
if (excludeProxy === void 0) { excludeProxy = true; }
var isObj = objProtoCallType(value, "object");
var a = new Proxy({}, {});
console.log("isProxy", (0, isProxy_1.default)(a));
if (isObj && excludeProxy)
return !(0, isProxy_1.default)(value);
return isObj;
};
exports.isObject = isObject;
var isSet = function (value) {
return objProtoCallType(value, "set");
};
exports.isSet = isSet;
var isMap = function (value) {
return objProtoCallType(value, "map");
};
exports.isMap = isMap;
var isNull = function (value) {
return objProtoCallType(value, "null");
};
exports.isNull = isNull;
var isBigint = function (value) {
return typeof value === "bigint";
};
exports.isBigint = isBigint;
var isArray = function (value) { return Array.isArray(value); };
exports.isArray = isArray;
var isSymbol = function (value) {
return typeof value === "symbol";
};
exports.isSymbol = isSymbol;
var isFunction = function (value) {
return typeof value === "function";
};
exports.isFunction = isFunction;
var isString = function (value) {
return typeof value === "string";
};
exports.isString = isString;
var isBoolean = function (value) {
return typeof value === "boolean";
};
exports.isBoolean = isBoolean;
var isNumber = function (value) {
return typeof value === "number";
};
exports.isNumber = isNumber;
var isInfinity = function (value) {
return value === Infinity || value === -Infinity;
};
exports.isInfinity = isInfinity;
var isUndef = function (value) {
return typeof value === "undefined";
};
exports.isUndef = isUndef;
var objProtoCallType = function (value, type) {
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type;
};