UNPKG

@modern-js/utils

Version:

A Progressive React Framework for modern web development.

28 lines (27 loc) 893 B
import "node:module"; function isString(str) { return 'string' == typeof str; } function isUndefined(obj) { return void 0 === obj; } function isArray(obj) { return Array.isArray(obj); } function isFunction(func) { return 'function' == typeof func; } function isObject(obj) { return null !== obj && 'object' == typeof obj; } function isPlainObject(obj) { return isObject(obj) && '[object Object]' === Object.prototype.toString.call(obj); } function isPromise(obj) { return Boolean(obj) && ('object' == typeof obj || 'function' == typeof obj) && 'function' == typeof obj.then; } function isRegExp(obj) { return '[object RegExp]' === Object.prototype.toString.call(obj); } const isEmpty = (o)=>0 === Object.entries(o).length && o.constructor === Object; export { isArray, isEmpty, isFunction, isObject, isPlainObject, isPromise, isRegExp, isString, isUndefined };