@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
37 lines (36 loc) • 1.09 kB
JavaScript
const isDev = typeof __DEV__ !== "undefined" && __DEV__;
const isNull = (value) => value === null;
const isFunction = (value) => typeof value === "function";
const isDefined = (value) => typeof value !== "undefined";
const isString = (value) => typeof value === "string";
const isObject = (value) => typeof value === "object" && !!value && value.toString() === "[object Object]";
const isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
const isBoolean = (value) => typeof value === "boolean";
const isArray = Array.isArray;
const isEmptyString = (value) => isString(value) && value.length === 0;
const isEmpty = (value) => {
if (isNull(value) || !isDefined(value)) {
return true;
}
if (isString(value) || isArray(value)) {
return value.length === 0;
}
if (isObject(value)) {
return value.constructor === Object && Object.keys(value).length === 0;
}
return false;
};
export {
isArray,
isBoolean,
isDefined,
isDev,
isEmpty,
isEmptyString,
isFunction,
isNull,
isNumber,
isObject,
isString
};
//# sourceMappingURL=is.js.map