Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Oct 26, 2023
1 parent 3b350b4 commit 0a85ee2
Show file tree
Hide file tree
Showing 4 changed files with 724 additions and 560 deletions.
192 changes: 114 additions & 78 deletions dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,109 +3,74 @@
function getType(payload) {
return Object.prototype.toString.call(payload).slice(8, -1);
}
function isUndefined(payload) {
return getType(payload) === "Undefined";

function isAnyObject(payload) {
return getType(payload) === "Object";
}
function isNull(payload) {
return getType(payload) === "Null";

function isArray(payload) {
return getType(payload) === "Array";
}

function isBlob(payload) {
return getType(payload) === "Blob";
}

function isBoolean(payload) {
return getType(payload) === "Boolean";
}

function isDate(payload) {
return getType(payload) === "Date" && !isNaN(payload);
}

function isEmptyArray(payload) {
return isArray(payload) && payload.length === 0;
}

function isPlainObject(payload) {
if (getType(payload) !== "Object")
return false;
const prototype = Object.getPrototypeOf(payload);
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
}
function isObject(payload) {
return isPlainObject(payload);
}

function isEmptyObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length === 0;
}
function isFullObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length > 0;
}
function isAnyObject(payload) {
return getType(payload) === "Object";
}
function isObjectLike(payload) {
return isAnyObject(payload);

function isEmptyString(payload) {
return payload === "";
}
function isFunction(payload) {
return typeof payload === "function";

function isError(payload) {
return getType(payload) === "Error" || payload instanceof Error;
}
function isArray(payload) {
return getType(payload) === "Array";

function isFile(payload) {
return getType(payload) === "File";
}

function isFullArray(payload) {
return isArray(payload) && payload.length > 0;
}
function isEmptyArray(payload) {
return isArray(payload) && payload.length === 0;

function isFullObject(payload) {
return isPlainObject(payload) && Object.keys(payload).length > 0;
}

function isString(payload) {
return getType(payload) === "String";
}

function isFullString(payload) {
return isString(payload) && payload !== "";
}
function isEmptyString(payload) {
return payload === "";
}
function isNumber(payload) {
return getType(payload) === "Number" && !isNaN(payload);
}
function isPositiveNumber(payload) {
return isNumber(payload) && payload > 0;
}
function isNegativeNumber(payload) {
return isNumber(payload) && payload < 0;
}
function isBoolean(payload) {
return getType(payload) === "Boolean";
}
function isRegExp(payload) {
return getType(payload) === "RegExp";
}
function isMap(payload) {
return getType(payload) === "Map";
}
function isWeakMap(payload) {
return getType(payload) === "WeakMap";
}
function isSet(payload) {
return getType(payload) === "Set";
}
function isWeakSet(payload) {
return getType(payload) === "WeakSet";
}
function isSymbol(payload) {
return getType(payload) === "Symbol";
}
function isDate(payload) {
return getType(payload) === "Date" && !isNaN(payload);
}
function isBlob(payload) {
return getType(payload) === "Blob";
}
function isFile(payload) {
return getType(payload) === "File";
}
function isPromise(payload) {
return getType(payload) === "Promise";
}
function isError(payload) {
return getType(payload) === "Error";
}
function isNaNValue(payload) {
return getType(payload) === "Number" && isNaN(payload);
}
function isPrimitive(payload) {
return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
}
const isNullOrUndefined = isOneOf(isNull, isUndefined);
function isOneOf(a, b, c, d, e) {
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);

function isFunction(payload) {
return typeof payload === "function";
}

function isType(payload, type) {
if (!(type instanceof Function)) {
throw new TypeError("Type must be a function");
Expand All @@ -116,6 +81,7 @@ function isType(payload, type) {
const name = type.name;
return getType(payload) === name || Boolean(payload && payload.constructor === type);
}

function isInstanceOf(value, classOrClassName) {
if (typeof classOrClassName === "function") {
for (let p = value; p; p = Object.getPrototypeOf(p)) {
Expand All @@ -134,6 +100,76 @@ function isInstanceOf(value, classOrClassName) {
}
}

function isMap(payload) {
return getType(payload) === "Map";
}

function isNaNValue(payload) {
return getType(payload) === "Number" && isNaN(payload);
}

function isNumber(payload) {
return getType(payload) === "Number" && !isNaN(payload);
}

function isNegativeNumber(payload) {
return isNumber(payload) && payload < 0;
}

function isNull(payload) {
return getType(payload) === "Null";
}

function isOneOf(a, b, c, d, e) {
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
}

function isUndefined(payload) {
return getType(payload) === "Undefined";
}

const isNullOrUndefined = isOneOf(isNull, isUndefined);

function isObject(payload) {
return isPlainObject(payload);
}

function isObjectLike(payload) {
return isAnyObject(payload);
}

function isPositiveNumber(payload) {
return isNumber(payload) && payload > 0;
}

function isSymbol(payload) {
return getType(payload) === "Symbol";
}

function isPrimitive(payload) {
return isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
}

function isPromise(payload) {
return getType(payload) === "Promise";
}

function isRegExp(payload) {
return getType(payload) === "RegExp";
}

function isSet(payload) {
return getType(payload) === "Set";
}

function isWeakMap(payload) {
return getType(payload) === "WeakMap";
}

function isWeakSet(payload) {
return getType(payload) === "WeakSet";
}

exports.getType = getType;
exports.isAnyObject = isAnyObject;
exports.isArray = isArray;
Expand Down
Loading

0 comments on commit 0a85ee2

Please sign in to comment.