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.1 to 0.2.0

6

lib/index.min.js
/**
* name: @bassist/utils
* version: v0.1.1
* version: v0.2.0
* description: Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .
* author: chengpeiquan <chengpeiquan@chengpeiquan.com>
* homepage: https://github.com/chengpeiquan/bassist/tree/main/packages/utils
* homepage: https://paka.dev/npm/@bassist/utils
* license: MIT
*/
(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"})});
(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(i){return Object.prototype.toString.call(i).slice(8,-1).toLowerCase()}function a(i){return o(i)==="object"}function m(i,t){return a(i)?Object.prototype.hasOwnProperty.call(i,t):!1}const u=typeof window<"u",b=!u,e=u?navigator.userAgent.toLowerCase():"",c=/iPhone|phone|android|iPod|pad|iPad/i,h=c.test(e),w=!c.test(e),g=/Android/i.test(e),v=/iPhone|iPod|iPad|iOS/i.test(e),y=/uni-app|html5plus/.test(e),E=/MicroMessenger/i.test(e),A=/\sQQ|mqqbrowser|qzone|qqbrowser/i.test(e),M=/mqqbrowser|qqbrowser/i.test(e),Q=/qzone\/.*_qz_([\d.]+)/i.test(e),R=/(weibo).*weibo__([\d.]+)/i.test(e),q=/(baiduboxapp)\/([\d.]+)/i.test(e);function f(i=0,t=100,s="round"){return Math[s](Math.random()*(t-i)+i)}function O(i=10){const t="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let s="",r=i;const U=t.length;for(;r--;)s+=t[Math.random()*U|0];return s}function S(){const i=f(0,1);return[!0,!1][i]}function _(i){if(!Array.isArray(i))return i;for(let t=i.length-1;t>0;t--){const s=Math.floor(Math.random()*(t+1)),r=i[t];i[t]=i[s],i[s]=r}return i}function B(i){return/^1[3456789]\d{9}$/.test(String(i))}function D(i){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(i)}function P(i){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(i)}function z(i){const t=/^([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]$/,s=/^([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 t.test(i)||s.test(i)}function j(i){return/^([1-9]{1})(\d{15}|\d{16}|\d{18})$/.test(i)}function l(){return process.env.NODE_ENV}const T=l();function d(i){return process.env.NODE_ENV===i}const k=d("development"),C=d("test"),N=d("production");n.checkRuntimeEnv=d,n.getDataType=o,n.getRuntimeEnv=l,n.hasKey=m,n.isAndroid=g,n.isBaidu=q,n.isBankCard=j,n.isBrowser=u,n.isDesktop=w,n.isDevRuntime=k,n.isEmail=D,n.isIOS=v,n.isIdCard=z,n.isMob=B,n.isMobile=h,n.isObject=a,n.isProdRuntime=N,n.isQQ=A,n.isQQBrowser=M,n.isQzone=Q,n.isServer=b,n.isTestRuntime=C,n.isUniApp=y,n.isUrl=P,n.isWeibo=R,n.isWeixin=E,n.mobileDevicesRegExp=c,n.randomBoolean=S,n.randomNumber=f,n.randomString=O,n.runtimeEnv=T,n.shuffle=_,n.ua=e,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
{
"name": "@bassist/utils",
"version": "0.1.1",
"version": "0.2.0",
"description": "Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .",
"author": "chengpeiquan <chengpeiquan@chengpeiquan.com>",
"license": "MIT",
"homepage": "https://github.com/chengpeiquan/bassist/tree/main/packages/utils",
"homepage": "https://paka.dev/npm/@bassist/utils",
"files": [

@@ -9,0 +9,0 @@ "lib",

/**
* The actual type of the data
*
* @category data
*/

@@ -8,3 +10,3 @@ export type DataType = "boolean" | "string" | "number" | "bigint" | "symbol" | "null" | "undefined" | "function" | "object" | "array" | "date" | "error" | "set" | "map" | "weakSet" | "weakMap" | "file" | "blob" | "arraybuffer" | "regexp";

*
* @category Data
* @category data
*/

@@ -15,3 +17,3 @@ export declare function getDataType(target: any): DataType;

*
* @category Data
* @category data
*/

@@ -22,6 +24,68 @@ export declare function isObject(target: any): boolean;

*
* @category Data
* @category data
*/
export declare function hasKey(obj: Record<string, any>, key: string): boolean;
/**
* @category env
*/
export declare const isBrowser: boolean;
/**
* @category env
*/
export declare const isServer: boolean;
/**
* Current user agent
*
* @category env
*/
export declare const ua: string;
/**
* @category env
*/
export declare const mobileDevicesRegExp: RegExp;
/**
* @category env
*/
export declare const isMobile: boolean;
/**
* @category env
*/
export declare const isDesktop: boolean;
/**
* @category env
*/
export declare const isAndroid: boolean;
/**
* @category env
*/
export declare const isIOS: boolean;
/**
* @category env
*/
export declare const isUniApp: boolean;
/**
* @category env
*/
export declare const isWeixin: boolean;
/**
* @category env
*/
export declare const isQQ: boolean;
/**
* @category env
*/
export declare const isQQBrowser: boolean;
/**
* @category env
*/
export declare const isQzone: boolean;
/**
* @category env
*/
export declare const isWeibo: boolean;
/**
* @category env
*/
export declare const isBaidu: boolean;
/**
* Generate random number

@@ -32,3 +96,3 @@ * @param min - The minimum value in the range

*
* @category Random
* @category random
*/

@@ -40,3 +104,3 @@ export declare function randomNumber(min?: number, max?: number, roundingType?: "round" | "ceil" | "floor"): number;

*
* @category Random
* @category random
*/

@@ -47,3 +111,3 @@ export declare function randomString(length?: number): string;

*
* @category Random
* @category random
*/

@@ -54,3 +118,3 @@ export declare function randomBoolean(): boolean;

*
* @category Random
* @category random
*/

@@ -61,3 +125,3 @@ export declare function shuffle(arr: any[]): any[];

*
* @category Regexp
* @category regexp
*/

@@ -68,3 +132,3 @@ export declare function isMob(phoneNumber: number | string): boolean;

*
* @category Regexp
* @category regexp
*/

@@ -75,3 +139,3 @@ export declare function isEmail(email: string): boolean;

*
* @category Regexp
* @category regexp
*/

@@ -82,3 +146,3 @@ export declare function isUrl(url: string): boolean;

*
* @category Regexp
* @category regexp
*/

@@ -89,6 +153,50 @@ export declare function isIdCard(idCardNumber: string): boolean;

*
* @category Regexp
* @category regexp
*/
export declare function isBankCard(bankCard: string): boolean;
/**
* Common runtime environment types
*
* @category runtime
*/
export type RuntimeEnv = "development" | "test" | "production" | undefined;
/**
* Get current runtime environment
* @precondition The `cross-env` package is installed
*
* @category runtime
*/
export declare function getRuntimeEnv(): RuntimeEnv;
/**
* Current runtime environment
*
* @category runtime
*/
export declare const runtimeEnv: RuntimeEnv;
/**
* Determine whether the specified runtime environment is currently
* @precondition The `cross-env` package is installed
*
* @category runtime
*/
export declare function checkRuntimeEnv(runtimeEnv: string): boolean;
/**
* Determine whether the current runtime is development
*
* @category runtime
*/
export declare const isDevRuntime: boolean;
/**
* Determine whether the current runtime is test
*
* @category runtime
*/
export declare const isTestRuntime: boolean;
/**
* Determine whether the current runtime is production
*
* @category runtime
*/
export declare const isProdRuntime: boolean;
export {};

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