defer
function defer(func, ...args) {
if (typeof func !== "function") {
throw new TypeError("Expected a function");
}
return settimout(func, 1, ...args);
}
delay
function delay(func, wait, ...args) {
if (typeof func !== "function") {
throw new TypeError("Expected a function");
}
return settimout(func, +wait || 0, ...args);
}
getTag
const toString = Object.prototype.toString;
function getTag(value) {
if (value == null) {
return value === undefined ? "[object Undefined]" : "[object Null]";
}
return toString.call(value);
}
isNil
function isNil(value){
return value == null;
}
isNull
function isNull(value){
return value === null;
}
isUndefined
function isUndefined(value){
return value === undefined;
}
isObjectLike
function isObjectLike(value) {
return value != null && typeof value === "object";
}
isObject
function isObject(value) {
const type = typeof value;
return value != null && (type === "function" || type === "object");
}