@darwish/utils-core
Version:
68 lines (67 loc) • 2.27 kB
JavaScript
;
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 objProtoCallType = function (value, type) {
return Object.prototype.toString.call(value).slice(8, -1).toLowerCase() === type;
};
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) {
return objProtoCallType(value, 'object');
};
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;