surrogate
Version:
Object method hooks made easy
23 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPromiseLike = exports.isAsync = exports.isObject = exports.isUndefined = exports.isFunction = exports.isBool = exports.isNull = void 0;
const isNull = (value) => value === null;
exports.isNull = isNull;
const isBool = (value) => isType(value, 'boolean');
exports.isBool = isBool;
const isFunction = (value) => isType(value, 'function');
exports.isFunction = isFunction;
const isUndefined = (value) => isType(value, 'undefined');
exports.isUndefined = isUndefined;
const isObject = (value) => isType(value, 'object') && !(0, exports.isNull)(value) && !Array.isArray(value);
exports.isObject = isObject;
const isType = (value, type) => typeof value === type;
const isAsync = (func) => {
return func[Symbol.toStringTag] === 'AsyncFunction';
};
exports.isAsync = isAsync;
const isPromiseLike = (value) => {
return value instanceof Promise || (0, exports.isFunction)(value === null || value === void 0 ? void 0 : value.then);
};
exports.isPromiseLike = isPromiseLike;
//# sourceMappingURL=index.js.map