🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@vtrbo/utils-is

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vtrbo/utils-is - npm Package Compare versions

Comparing version
0.4.0-beta.5
to
0.4.0-beta.7
+96
dist/index.cjs
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/is.ts
var _utilstool = require('@vtrbo/utils-tool');
function isType(data, type) {
return _utilstool.toRawType.call(void 0, data).toLowerCase() === type.toLowerCase();
}
function isString(data) {
return isType(data, "String");
}
function isNumber(data) {
return isType(data, "Number");
}
function isBoolean(data) {
return isType(data, "Boolean");
}
function isObject(data) {
return isType(data, "Object");
}
function isArray(data) {
return isType(data, "Array");
}
function isFunction(data) {
return isType(data, "Function");
}
function isRegExp(data) {
return isType(data, "RegExp");
}
function isDate(data) {
return isType(data, "Date");
}
function isUndefined(data) {
return isType(data, "Undefined");
}
function isNull(data) {
return isType(data, "Null");
}
function isSet(data) {
return isType(data, "Set");
}
function isMap(data) {
return isType(data, "Map");
}
function isHttp(url) {
return url.startsWith("http://") || url.startsWith("https://");
}
function isLowerCase(str) {
const reg = /^[a-z]+$/;
return reg.test(str);
}
function isUpperCase(str) {
const reg = /^[A-Z]+$/;
return reg.test(str);
}
function isMobile(mobile) {
const reg = /^1[3-9]\d{9}$/;
return reg.test(mobile);
}
function isColor(color, type) {
const typeMap = {
HEX: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/g,
RGB: /^[rR][gG][bB][\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,[\s]*){2}([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*){1}[\)]$/g,
RGBA: /^[rR][gG][bB][aA][\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,[\s]*){3}[\s]*(1|1.0|0|0.[0-9])[\s]*[\)]{1}$/g
};
return typeMap[type].test(color);
}
function isEmptyObj(obj) {
return isObject(obj) && !Object.keys(obj).length;
}
function isEmptyArr(arr) {
return isArray(arr) && !arr.length;
}
function isKeyOfObj(obj, k) {
return k in obj;
}
exports.isArray = isArray; exports.isBoolean = isBoolean; exports.isColor = isColor; exports.isDate = isDate; exports.isEmptyArr = isEmptyArr; exports.isEmptyObj = isEmptyObj; exports.isFunction = isFunction; exports.isHttp = isHttp; exports.isKeyOfObj = isKeyOfObj; exports.isLowerCase = isLowerCase; exports.isMap = isMap; exports.isMobile = isMobile; exports.isNull = isNull; exports.isNumber = isNumber; exports.isObject = isObject; exports.isRegExp = isRegExp; exports.isSet = isSet; exports.isString = isString; exports.isType = isType; exports.isUndefined = isUndefined; exports.isUpperCase = isUpperCase;
declare function isType(data: any, type: string): boolean;
declare function isString(data: any): data is string;
declare function isNumber(data: any): data is number;
declare function isBoolean(data: any): data is boolean;
declare function isObject(data: any): data is Record<any, any>;
declare function isArray(data: any): data is any[];
declare function isFunction<T extends Function>(data: any): data is T;
declare function isRegExp(data: any): data is RegExp;
declare function isDate(data: any): data is Date;
declare function isUndefined(data: any): data is undefined;
declare function isNull(data: any): data is null;
declare function isSet(data: any): data is Set<any>;
declare function isMap(data: any): data is Map<any, any>;
declare function isHttp(url: string): boolean;
declare function isLowerCase(str: string): boolean;
declare function isUpperCase(str: string): boolean;
declare function isMobile(mobile: string): boolean;
declare function isColor(color: string, type: 'HEX' | 'RGB' | 'RGBA'): boolean;
declare function isEmptyObj(obj: unknown): boolean;
declare function isEmptyArr(arr: unknown): boolean;
declare function isKeyOfObj<T extends object>(obj: T, k: keyof any): k is keyof T;
export { isArray, isBoolean, isColor, isDate, isEmptyArr, isEmptyObj, isFunction, isHttp, isKeyOfObj, isLowerCase, isMap, isMobile, isNull, isNumber, isObject, isRegExp, isSet, isString, isType, isUndefined, isUpperCase };
declare function isType(data: any, type: string): boolean;
declare function isString(data: any): data is string;
declare function isNumber(data: any): data is number;
declare function isBoolean(data: any): data is boolean;
declare function isObject(data: any): data is Record<any, any>;
declare function isArray(data: any): data is any[];
declare function isFunction<T extends Function>(data: any): data is T;
declare function isRegExp(data: any): data is RegExp;
declare function isDate(data: any): data is Date;
declare function isUndefined(data: any): data is undefined;
declare function isNull(data: any): data is null;
declare function isSet(data: any): data is Set<any>;
declare function isMap(data: any): data is Map<any, any>;
declare function isHttp(url: string): boolean;
declare function isLowerCase(str: string): boolean;
declare function isUpperCase(str: string): boolean;
declare function isMobile(mobile: string): boolean;
declare function isColor(color: string, type: 'HEX' | 'RGB' | 'RGBA'): boolean;
declare function isEmptyObj(obj: unknown): boolean;
declare function isEmptyArr(arr: unknown): boolean;
declare function isKeyOfObj<T extends object>(obj: T, k: keyof any): k is keyof T;
export { isArray, isBoolean, isColor, isDate, isEmptyArr, isEmptyObj, isFunction, isHttp, isKeyOfObj, isLowerCase, isMap, isMobile, isNull, isNumber, isObject, isRegExp, isSet, isString, isType, isUndefined, isUpperCase };
// src/is.ts
import { toRawType } from "@vtrbo/utils-tool";
function isType(data, type) {
return toRawType(data).toLowerCase() === type.toLowerCase();
}
function isString(data) {
return isType(data, "String");
}
function isNumber(data) {
return isType(data, "Number");
}
function isBoolean(data) {
return isType(data, "Boolean");
}
function isObject(data) {
return isType(data, "Object");
}
function isArray(data) {
return isType(data, "Array");
}
function isFunction(data) {
return isType(data, "Function");
}
function isRegExp(data) {
return isType(data, "RegExp");
}
function isDate(data) {
return isType(data, "Date");
}
function isUndefined(data) {
return isType(data, "Undefined");
}
function isNull(data) {
return isType(data, "Null");
}
function isSet(data) {
return isType(data, "Set");
}
function isMap(data) {
return isType(data, "Map");
}
function isHttp(url) {
return url.startsWith("http://") || url.startsWith("https://");
}
function isLowerCase(str) {
const reg = /^[a-z]+$/;
return reg.test(str);
}
function isUpperCase(str) {
const reg = /^[A-Z]+$/;
return reg.test(str);
}
function isMobile(mobile) {
const reg = /^1[3-9]\d{9}$/;
return reg.test(mobile);
}
function isColor(color, type) {
const typeMap = {
HEX: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/g,
RGB: /^[rR][gG][bB][\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,[\s]*){2}([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*){1}[\)]$/g,
RGBA: /^[rR][gG][bB][aA][\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\s]*,[\s]*){3}[\s]*(1|1.0|0|0.[0-9])[\s]*[\)]{1}$/g
};
return typeMap[type].test(color);
}
function isEmptyObj(obj) {
return isObject(obj) && !Object.keys(obj).length;
}
function isEmptyArr(arr) {
return isArray(arr) && !arr.length;
}
function isKeyOfObj(obj, k) {
return k in obj;
}
export {
isArray,
isBoolean,
isColor,
isDate,
isEmptyArr,
isEmptyObj,
isFunction,
isHttp,
isKeyOfObj,
isLowerCase,
isMap,
isMobile,
isNull,
isNumber,
isObject,
isRegExp,
isSet,
isString,
isType,
isUndefined,
isUpperCase
};
+10
-18
{
"name": "@vtrbo/utils-is",
"type": "module",
"version": "0.4.0-beta.5",
"version": "0.4.0-beta.7",
"description": "Collection of common JavaScript or TypeScript utils.",

@@ -24,15 +24,14 @@ "author": {

".": {
"types": "./index.d.ts",
"import": "./index.js",
"require": "./index.cjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./index.js",
"module": "./index.js",
"types": "./index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
"./*",
"./index.d.ts"
"./dist/index.d.ts"
]

@@ -42,13 +41,6 @@ }

"files": [
"README.md",
"index.cjs",
"index.d.cts",
"index.d.ts",
"index.js"
"dist"
],
"peerDependencies": {
"@vtrbo/utils-obj": "0.4.0-beta.5"
},
"dependencies": {
"@vtrbo/utils-tool": "0.4.0-beta.5"
"@vtrbo/utils-tool": "0.4.0-beta.7"
},

@@ -55,0 +47,0 @@ "scripts": {