UNPKG

@darwish/is

Version:

58 lines (57 loc) 1.89 kB
import isProxy from "./isProxy"; export var isDate = function (value) { return objProtoCallType(value, "date"); }; /** * 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 */ export var isObject = function (value, excludeProxy) { if (excludeProxy === void 0) { excludeProxy = true; } var isObj = objProtoCallType(value, "object"); var a = new Proxy({}, {}); console.log("isProxy", isProxy(a)); if (isObj && excludeProxy) return !isProxy(value); return isObj; }; export var isSet = function (value) { return objProtoCallType(value, "set"); }; export var isMap = function (value) { return objProtoCallType(value, "map"); }; export var isNull = function (value) { return objProtoCallType(value, "null"); }; export var isBigint = function (value) { return typeof value === "bigint"; }; export var isArray = function (value) { return Array.isArray(value); }; export var isSymbol = function (value) { return typeof value === "symbol"; }; export var isFunction = function (value) { return typeof value === "function"; }; export var isString = function (value) { return typeof value === "string"; }; export var isBoolean = function (value) { return typeof value === "boolean"; }; export var isNumber = function (value) { return typeof value === "number"; }; export var isInfinity = function (value) { return value === Infinity || value === -Infinity; }; export var isUndef = function (value) { return typeof value === "undefined"; }; var objProtoCallType = function (value, type) { return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type; };