Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bassist/utils

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bassist/utils - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

lib/index.min.js
/**
* name: @bassist/utils
* version: v0.1.0
* version: v0.1.1
* description: Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .

@@ -9,2 +9,2 @@ * author: chengpeiquan <chengpeiquan@chengpeiquan.com>

*/
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.Utils={}))})(this,function(n){"use strict";function o(t){return Object.prototype.toString.call(t).slice(8,-1)}function u(t){return o(t)==="Object"}function a(t,e){return u(t)?Object.prototype.hasOwnProperty.call(t,e):!1}function r(t=0,e=100,i="round"){return Math[i](Math.random()*(e-t)+t)}function f(t=10){const e="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let i="",d=t;const b=e.length;for(;d--;)i+=e[Math.random()*b|0];return i}function s(){const t=r(0,1);return[!0,!1][t]}function c(t){if(!Array.isArray(t))return t;for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1)),d=t[e];t[e]=t[i],t[i]=d}return t}function l(t){return/^1[3456789]\d{9}$/.test(String(t))}function h(t){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(t)}function m(t){return/https?:\/\/[\w-]+(\.[\w-]+){1,2}(\/[\w-]{3,6}){0,2}(\?[\w_]{4,6}=[\w_]{4,6}(&[\w_]{4,6}=[\w_]{4,6}){0,2})?/.test(t)}function y(t){const e=/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,i=/^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/;return e.test(t)||i.test(t)}function g(t){return/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(t)}n.getDataType=o,n.hasKey=a,n.isBankCard=g,n.isEmail=h,n.isIdCard=y,n.isMob=l,n.isObject=u,n.isUrl=m,n.randomBoolean=s,n.randomNumber=r,n.randomString=f,n.shuffle=c,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.Utils={}))})(this,function(n){"use strict";function o(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function r(t){return o(t)==="object"}function a(t,e){return r(t)?Object.prototype.hasOwnProperty.call(t,e):!1}function u(t=0,e=100,i="round"){return Math[i](Math.random()*(e-t)+t)}function s(t=10){const e="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let i="",d=t;const b=e.length;for(;d--;)i+=e[Math.random()*b|0];return i}function f(){const t=u(0,1);return[!0,!1][t]}function c(t){if(!Array.isArray(t))return t;for(let e=t.length-1;e>0;e--){const i=Math.floor(Math.random()*(e+1)),d=t[e];t[e]=t[i],t[i]=d}return t}function l(t){return/^1[3456789]\d{9}$/.test(String(t))}function h(t){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(t)}function m(t){return/https?:\/\/[\w-]+(\.[\w-]+){1,2}(\/[\w-]{3,6}){0,2}(\?[\w_]{4,6}=[\w_]{4,6}(&[\w_]{4,6}=[\w_]{4,6}){0,2})?/.test(t)}function y(t){const e=/^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,i=/^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/;return e.test(t)||i.test(t)}function g(t){return/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(t)}n.getDataType=o,n.hasKey=a,n.isBankCard=g,n.isEmail=h,n.isIdCard=y,n.isMob=l,n.isObject=r,n.isUrl=m,n.randomBoolean=f,n.randomNumber=u,n.randomString=s,n.shuffle=c,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
{
"name": "@bassist/utils",
"version": "0.1.0",
"version": "0.1.1",
"description": "Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .",

@@ -5,0 +5,0 @@ "author": "chengpeiquan <chengpeiquan@chengpeiquan.com>",

@@ -23,3 +23,3 @@ # @bassist/utils

- 💡 No bundler required
- ☁ SSR Friendly
- 🦄 SSR Friendly

@@ -26,0 +26,0 @@ ## Documentation

/**
* The actual type of the data
*/
export type DataType = "Boolean" | "String" | "Number" | "BigInt" | "Symbol" | "Null" | "Undefined" | "Function" | "Object" | "Array" | "Date" | "Error" | "Set" | "Map" | "WeakSet" | "WeakMap" | "File" | "Blob" | "ArrayBuffer";
export type DataType = "boolean" | "string" | "number" | "bigint" | "symbol" | "null" | "undefined" | "function" | "object" | "array" | "date" | "error" | "set" | "map" | "weakSet" | "weakMap" | "file" | "blob" | "arraybuffer" | "regexp";
/**
* Get the real data type
*
* @category Data
*/

@@ -11,2 +13,4 @@ export declare function getDataType(target: any): DataType;

* Determine whether the data is an object
*
* @category Data
*/

@@ -16,2 +20,4 @@ export declare function isObject(target: any): boolean;

* Determine whether the specified key exists on the object
*
* @category Data
*/

@@ -24,2 +30,4 @@ export declare function hasKey(obj: Record<string, any>, key: string): boolean;

* @param roundingType - Round the result
*
* @category Random
*/

@@ -30,2 +38,4 @@ export declare function randomNumber(min?: number, max?: number, roundingType?: "round" | "ceil" | "floor"): number;

* @param length - The length of the string to be returned
*
* @category Random
*/

@@ -35,2 +45,4 @@ export declare function randomString(length?: number): string;

* Generate random boolean
*
* @category Random
*/

@@ -40,2 +52,4 @@ export declare function randomBoolean(): boolean;

* Shuffle the array and sort it randomly
*
* @category Random
*/

@@ -45,2 +59,4 @@ export declare function shuffle(arr: any[]): any[];

* Verify the mobile phone number format in mainland China
*
* @category Regexp
*/

@@ -50,2 +66,4 @@ export declare function isMob(phoneNumber: number | string): boolean;

* Verify email format
*
* @category Regexp
*/

@@ -55,2 +73,4 @@ export declare function isEmail(email: string): boolean;

* Verify url format
*
* @category Regexp
*/

@@ -60,2 +80,4 @@ export declare function isUrl(url: string): boolean;

* Verify the ID card number format in mainland China
*
* @category Regexp
*/

@@ -65,2 +87,4 @@ export declare function isIdCard(idCardNumber: string): boolean;

* Verify the bank card number format in mainland China
*
* @category Regexp
*/

@@ -67,0 +91,0 @@ export declare function isBankCard(bankCard: string): boolean;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc