@bassist/utils
Advanced tools
Comparing version 0.14.0 to 0.15.0
/** | ||
* @category interactive | ||
*/ | ||
export type WritableElement = HTMLInputElement | HTMLTextAreaElement; | ||
type WritableElement = HTMLInputElement | HTMLTextAreaElement; | ||
/** | ||
* @category interactive | ||
*/ | ||
export type CopyableElement = HTMLElement | WritableElement; | ||
type CopyableElement = HTMLElement | WritableElement; | ||
/** | ||
* Extensions based on the Clipboard API and with fallback mechanism | ||
* | ||
* @category interactive | ||
*/ | ||
export interface ClipboardInstance { | ||
/** | ||
* Determine whether the clipboard is supported | ||
*/ | ||
isSupported: boolean; | ||
/** | ||
* Copy the text passed in or the text of the specified DOM element | ||
* | ||
* @example | ||
* | ||
* ``` | ||
* clipboard.copy(document.querySelector('.foo')) | ||
* ``` | ||
*/ | ||
copy: (el: CopyableElement) => Promise<boolean>; | ||
/** | ||
* Cut the text passed in or the text of the specified DOM element | ||
* | ||
* @example | ||
* | ||
* ``` | ||
* clipboard.cut(document.querySelector('.foo')) | ||
* ``` | ||
*/ | ||
cut: (el: WritableElement) => Promise<boolean>; | ||
/** | ||
* Read the text content of the clipboard | ||
*/ | ||
read: () => Promise<string>; | ||
/** | ||
* Write text content to clipboard | ||
*/ | ||
write: (text: string) => Promise<boolean>; | ||
declare class ClipboardInstance { | ||
/** | ||
* Determine whether the clipboard is supported | ||
*/ | ||
isSupported: boolean; | ||
constructor(); | ||
/** | ||
* Copy the text passed in or the text of the specified DOM element | ||
* | ||
* @example | ||
* | ||
* ``` | ||
* clipboard.copy(document.querySelector('.foo')) | ||
* ``` | ||
*/ | ||
copy(el: CopyableElement): Promise<boolean>; | ||
/** | ||
* Cut the text passed in or the text of the specified DOM element | ||
* | ||
* @example | ||
* | ||
* ``` | ||
* clipboard.cut(document.querySelector('.foo')) | ||
* ``` | ||
*/ | ||
cut(el: WritableElement): Promise<boolean>; | ||
/** | ||
* Read the text content of the clipboard | ||
*/ | ||
read(): Promise<string>; | ||
/** | ||
* Write text content to clipboard | ||
*/ | ||
write(text: string): Promise<boolean>; | ||
} | ||
/** | ||
* Extensions based on the Clipboard API | ||
* Initialized Clipboard Instance | ||
* | ||
* @category interactive | ||
*/ | ||
export declare const clipboard: ClipboardInstance; | ||
declare const clipboard: ClipboardInstance; | ||
/** | ||
* @category storage | ||
*/ | ||
export type StorageType = "localStorage" | "sessionStorage"; | ||
type StorageType = 'localStorage' | 'sessionStorage'; | ||
/** | ||
* BaseStorage class provides a wrapper for browser storage or fallback storage. | ||
* | ||
* @category storage | ||
*/ | ||
declare class BaseStorage { | ||
prefix: string; | ||
private storage; | ||
/** | ||
* Creates an instance of BaseStorage | ||
* | ||
* @param prefix - The prefix to be added to the storage keys. | ||
* @param storageType - The type of storage to use (localStorage or sessionStorage) | ||
*/ | ||
constructor(prefix: string, storageType: StorageType); | ||
/** | ||
* Read stored data | ||
* @tips The `key` doesn't need to be prefixed | ||
* @returns The data in the format before storage | ||
*/ | ||
get(key: string): any; | ||
/** | ||
* Set storage data | ||
*/ | ||
set(key: string, value: any): void; | ||
/** | ||
* Remove the specified storage data under the current prefix | ||
*/ | ||
remove(key: string): void; | ||
/** | ||
* Clear all stored data under the current prefix | ||
*/ | ||
clear(): void; | ||
/** | ||
* Count the number of storage related to the current prefix | ||
*/ | ||
count(): number; | ||
/** | ||
* List storage keys associated under the current prefix | ||
* @tips All keys without prefix | ||
*/ | ||
list(): string[]; | ||
prefix: string; | ||
private storage; | ||
/** | ||
* Creates an instance of BaseStorage | ||
* | ||
* @param prefix - The prefix to be added to the storage keys. | ||
* @param storageType - The type of storage to use (localStorage or sessionStorage) | ||
*/ | ||
constructor(prefix: string, storageType: StorageType); | ||
/** | ||
* Read stored data | ||
* @tips The `key` doesn't need to be prefixed | ||
* @returns The data in the format before storage | ||
*/ | ||
get(key: string): any; | ||
/** | ||
* Set storage data | ||
*/ | ||
set(key: string, value: any): void; | ||
/** | ||
* Remove the specified storage data under the current prefix | ||
*/ | ||
remove(key: string): void; | ||
/** | ||
* Clear all stored data under the current prefix | ||
*/ | ||
clear(): void; | ||
/** | ||
* Count the number of storage related to the current prefix | ||
*/ | ||
count(): number; | ||
/** | ||
* List storage keys associated under the current prefix | ||
* @tips All keys without prefix | ||
*/ | ||
list(): string[]; | ||
} | ||
/** | ||
@@ -99,4 +109,4 @@ * localStorage that supports prefixes | ||
*/ | ||
export declare class LocalStorage extends BaseStorage { | ||
constructor(prefix: string); | ||
declare class LocalStorage extends BaseStorage { | ||
constructor(prefix: string); | ||
} | ||
@@ -108,5 +118,6 @@ /** | ||
*/ | ||
export declare class SessionStorage extends BaseStorage { | ||
constructor(prefix: string); | ||
declare class SessionStorage extends BaseStorage { | ||
constructor(prefix: string); | ||
} | ||
/** | ||
@@ -117,3 +128,3 @@ * The preferred color scheme for the appearance of the user interface | ||
*/ | ||
export type PrefersColorScheme = "light" | "dark"; | ||
type PrefersColorScheme = 'light' | 'dark'; | ||
/** | ||
@@ -124,3 +135,3 @@ * Dark mode media query | ||
*/ | ||
export declare const darkMediaQuery: MediaQueryList | undefined; | ||
declare const darkMediaQuery: MediaQueryList | undefined; | ||
/** | ||
@@ -131,3 +142,3 @@ * Checks if the user's preferred color scheme is dark | ||
*/ | ||
export declare function isDark(): boolean; | ||
declare function isDark(): boolean; | ||
/** | ||
@@ -138,3 +149,3 @@ * Light mode media query | ||
*/ | ||
export declare const lightMediaQuery: MediaQueryList | undefined; | ||
declare const lightMediaQuery: MediaQueryList | undefined; | ||
/** | ||
@@ -145,3 +156,3 @@ * Checks if the user's preferred color scheme is light | ||
*/ | ||
export declare function isLight(): boolean; | ||
declare function isLight(): boolean; | ||
/** | ||
@@ -152,3 +163,3 @@ * Retrieves the user's preferred color scheme | ||
*/ | ||
export declare function getPrefersColorScheme(): PrefersColorScheme | undefined; | ||
declare function getPrefersColorScheme(): PrefersColorScheme | undefined; | ||
/** | ||
@@ -159,3 +170,3 @@ * Portrait orientation media query | ||
*/ | ||
export declare const portraitMediaQuery: MediaQueryList | undefined; | ||
declare const portraitMediaQuery: MediaQueryList | undefined; | ||
/** | ||
@@ -166,3 +177,3 @@ * Checks if the user's preferred color scheme is light | ||
*/ | ||
export declare function isPortrait(): boolean; | ||
declare function isPortrait(): boolean; | ||
/** | ||
@@ -173,4 +184,5 @@ * Landscape orientation media query | ||
*/ | ||
export declare const landscapeMediaQuery: MediaQueryList | undefined; | ||
export declare function isLandscape(): boolean; | ||
declare const landscapeMediaQuery: MediaQueryList | undefined; | ||
declare function isLandscape(): boolean; | ||
/** | ||
@@ -181,16 +193,133 @@ * 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" | "regexp"; | ||
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 | ||
* | ||
* @description Solve the judgment error of the value wrapped in an Object | ||
* e.g. Object(1n), Object(1) | ||
* | ||
* @category data | ||
*/ | ||
export declare function getDataType(target: any): DataType; | ||
declare function getDataType(target: any): DataType; | ||
/** | ||
* Determine whether the data is an object | ||
* Determine whether the data is boolean | ||
* | ||
* @category data | ||
*/ | ||
export declare function isObject(target: any): boolean; | ||
declare function isBoolean(value: unknown): value is boolean; | ||
/** | ||
* Determine whether the data is string | ||
* | ||
* @category data | ||
*/ | ||
declare function isString(value: unknown): value is string; | ||
/** | ||
* Determine whether the data is number | ||
* | ||
* @category data | ||
*/ | ||
declare function isNumber(value: unknown): value is number; | ||
/** | ||
* Determine whether the data is bigint | ||
* | ||
* @category data | ||
*/ | ||
declare function isBigInt(value: unknown): value is bigint; | ||
/** | ||
* Determine whether the data is symbol | ||
* | ||
* @category data | ||
*/ | ||
declare function isSymbol(value: unknown): value is symbol; | ||
/** | ||
* Determine whether the data is null | ||
* | ||
* @category data | ||
*/ | ||
declare function isNull(value: unknown): value is null; | ||
/** | ||
* Determine whether the data is undefined | ||
* | ||
* @category data | ||
*/ | ||
declare function isUndefined(value: unknown): value is undefined; | ||
/** | ||
* Determine whether the data is function | ||
* | ||
* @category data | ||
*/ | ||
declare function isFunction(value: unknown): value is (...args: any) => any; | ||
/** | ||
* Determine whether the data is object | ||
* | ||
* @category data | ||
*/ | ||
declare function isObject(value: unknown): value is Record<any, any>; | ||
/** | ||
* Determine whether the data is array | ||
* | ||
* @category data | ||
*/ | ||
declare function isArray(value: unknown): value is any[]; | ||
/** | ||
* Determine whether the data is date | ||
* | ||
* @category data | ||
*/ | ||
declare function isDate(value: unknown): value is Date; | ||
/** | ||
* Determine whether the data is error | ||
* | ||
* @category data | ||
*/ | ||
declare function isError(value: unknown): value is Error; | ||
/** | ||
* Determine whether the data is set | ||
* | ||
* @category data | ||
*/ | ||
declare function isSet(value: unknown): value is Set<any>; | ||
/** | ||
* Determine whether the data is map | ||
* | ||
* @category data | ||
*/ | ||
declare function isMap(value: unknown): value is Map<any, any>; | ||
/** | ||
* Determine whether the data is weakset | ||
* | ||
* @category data | ||
*/ | ||
declare function isWeakSet(value: unknown): value is WeakSet<WeakKey>; | ||
/** | ||
* Determine whether the data is weakmap | ||
* | ||
* @category data | ||
*/ | ||
declare function isWeakMap(value: unknown): value is WeakMap<WeakKey, any>; | ||
/** | ||
* Determine whether the data is file | ||
* | ||
* @category data | ||
*/ | ||
declare function isFile(value: unknown): value is File; | ||
/** | ||
* Determine whether the data is blob | ||
* | ||
* @category data | ||
*/ | ||
declare function isBlob(value: unknown): value is Blob; | ||
/** | ||
* Determine whether the data is arraybuffer | ||
* | ||
* @category data | ||
*/ | ||
declare function isArrayBuffer(value: unknown): value is ArrayBuffer; | ||
/** | ||
* Determine whether the data is regexp | ||
* | ||
* @category data | ||
*/ | ||
declare function isRegExp(value: unknown): value is RegExp; | ||
/** | ||
* Determine whether the specified key exists on the object | ||
@@ -200,3 +329,3 @@ * | ||
*/ | ||
export declare function hasKey(obj: Record<string, any>, key: string): boolean; | ||
declare function hasKey<T, K extends keyof T>(obj: T, key: K): key is K; | ||
/** | ||
@@ -207,4 +336,45 @@ * String to byte stream | ||
*/ | ||
export declare function getBytes(value: string): Uint8Array; | ||
declare function getBytes(value: string): Uint8Array; | ||
/** | ||
* @category data | ||
*/ | ||
interface InRangeOptions { | ||
num: number; | ||
min: number; | ||
max: number; | ||
includeMin?: boolean; | ||
includeMax?: boolean; | ||
} | ||
/** | ||
* Checks if a number is between minimum and maximum | ||
* | ||
* @category data | ||
*/ | ||
declare function inRange({ num, min, max, includeMin, includeMax, }: InRangeOptions): boolean; | ||
/** | ||
* No operation function type | ||
* | ||
* @category data | ||
*/ | ||
type NoOperationFunction = (...args: any) => void; | ||
/** | ||
* A no operation function | ||
* | ||
* @category data | ||
*/ | ||
declare const noop: NoOperationFunction; | ||
/** | ||
* Promisify No operation function type | ||
* | ||
* @category data | ||
*/ | ||
type PromisifyNoOperationFunction = (...args: any) => Promise<void>; | ||
/** | ||
* A promisify no operation function | ||
* | ||
* @category data | ||
*/ | ||
declare const pnoop: PromisifyNoOperationFunction; | ||
/** | ||
* Checks if the code is being executed in a browser environment | ||
@@ -214,3 +384,3 @@ * | ||
*/ | ||
export declare const isBrowser: boolean; | ||
declare const isBrowser: boolean; | ||
/** | ||
@@ -221,3 +391,3 @@ * Checks if the code is being executed in a server environment | ||
*/ | ||
export declare const isServer: boolean; | ||
declare const isServer: boolean; | ||
/** | ||
@@ -228,3 +398,3 @@ * Regular expression pattern to match mobile device user agents | ||
*/ | ||
export declare const mobileDevicesRegExp: RegExp; | ||
declare const mobileDevicesRegExp: RegExp; | ||
/** | ||
@@ -235,4 +405,16 @@ * Checks if the code is being executed on a mobile device | ||
*/ | ||
export declare function isMobile(): boolean; | ||
declare function isMobile(): boolean; | ||
/** | ||
* Regular expression pattern to match tablet device user agents | ||
* | ||
* @category device | ||
*/ | ||
declare const tabletDevicesRegExp: RegExp; | ||
/** | ||
* Checks if the code is being executed on a tablet device | ||
* | ||
* @category device | ||
*/ | ||
declare function isTablet(): boolean; | ||
/** | ||
* Checks if the code is being executed on a desktop device | ||
@@ -242,4 +424,16 @@ * | ||
*/ | ||
export declare function isDesktop(): boolean; | ||
declare function isDesktop(): boolean; | ||
/** | ||
* Regular expression pattern to match apple device user agents | ||
* | ||
* @category device | ||
*/ | ||
declare const appleDevicesRegExp: RegExp; | ||
/** | ||
* Checks if the code is being executed on an apple device | ||
* | ||
* @category device | ||
*/ | ||
declare function isAppleDevice(): boolean; | ||
/** | ||
* Checks if the code is running on an Android device | ||
@@ -249,3 +443,3 @@ * | ||
*/ | ||
export declare const isAndroid: boolean; | ||
declare const isAndroid: boolean; | ||
/** | ||
@@ -256,3 +450,3 @@ * Checks if the code is running on an iOS device | ||
*/ | ||
export declare const isIOS: boolean; | ||
declare const isIOS: boolean; | ||
/** | ||
@@ -263,3 +457,3 @@ * Checks if the code is running in a Uni-App environment | ||
*/ | ||
export declare const isUniApp: boolean; | ||
declare const isUniApp: boolean; | ||
/** | ||
@@ -270,3 +464,3 @@ * Checks if the code is running in a WeChat (Weixin) environment | ||
*/ | ||
export declare const isWeixin: boolean; | ||
declare const isWeixin: boolean; | ||
/** | ||
@@ -277,3 +471,3 @@ * Checks if the code is running in a QQ environment | ||
*/ | ||
export declare const isQQ: boolean; | ||
declare const isQQ: boolean; | ||
/** | ||
@@ -284,3 +478,3 @@ * Checks if the code is running in a QQ Browser environment | ||
*/ | ||
export declare const isQQBrowser: boolean; | ||
declare const isQQBrowser: boolean; | ||
/** | ||
@@ -291,3 +485,3 @@ * Checks if the code is running in a Qzone environment | ||
*/ | ||
export declare const isQzone: boolean; | ||
declare const isQzone: boolean; | ||
/** | ||
@@ -298,3 +492,3 @@ * Checks if the code is running in a Weibo environment | ||
*/ | ||
export declare const isWeibo: boolean; | ||
declare const isWeibo: boolean; | ||
/** | ||
@@ -305,8 +499,8 @@ * Checks if the code is running in a Baidu Box App environment | ||
*/ | ||
export declare const isBaidu: boolean; | ||
declare const isBaidu: boolean; | ||
/** | ||
* @category device | ||
*/ | ||
export interface DeviceResizeWatcherOptions { | ||
immediate: boolean; | ||
interface DeviceResizeWatcherOptions { | ||
immediate: boolean; | ||
} | ||
@@ -323,3 +517,4 @@ /** | ||
*/ | ||
export declare function watchResize(callback: () => void, { immediate }?: DeviceResizeWatcherOptions): void; | ||
declare function watchResize(callback: () => void, { immediate }?: DeviceResizeWatcherOptions): void; | ||
/** | ||
@@ -330,9 +525,10 @@ * Get file info via `mime` package | ||
*/ | ||
export declare class FileInfo { | ||
mime: any; | ||
constructor(theMimePackageInstance: any); | ||
getMimeType(path: string): any; | ||
getExtensionFromMimeType(mimeType: string): any; | ||
getExtension(path: string): any; | ||
declare class FileInfo { | ||
mime: any; | ||
constructor(theMimePackageInstance: any); | ||
getMimeType(path: string): any; | ||
getExtensionFromMimeType(mimeType: string): any; | ||
getExtension(path: string): any; | ||
} | ||
/** | ||
@@ -347,3 +543,3 @@ * Extract numbers from text | ||
*/ | ||
export declare function extractNumber(text: string | number, startsWithZero?: boolean): string; | ||
declare function extractNumber(text: string | number, startsWithZero?: boolean): string; | ||
/** | ||
@@ -356,3 +552,3 @@ * Format amount with two decimal places | ||
*/ | ||
export declare function formatAmount(amount: string | number): string; | ||
declare function formatAmount(amount: string | number): string; | ||
/** | ||
@@ -369,3 +565,3 @@ * Add ellipses to words that are out of length | ||
*/ | ||
export declare function ellipsis(word: string, limit: number): string; | ||
declare function ellipsis(word: string, limit: number): string; | ||
/** | ||
@@ -376,3 +572,3 @@ * Capitalize the first letter | ||
*/ | ||
export declare function capitalize([first, ...rest]: string): string; | ||
declare function capitalize([first, ...rest]: string): string; | ||
/** | ||
@@ -383,3 +579,3 @@ * Formatted in `kebab-case` style | ||
*/ | ||
export declare function kebabCase(word: string): string; | ||
declare function kebabCase(word: string): string; | ||
/** | ||
@@ -390,3 +586,3 @@ * Formatted in `camelCase` style | ||
*/ | ||
export declare function camelCase([first, ...rest]: string): string; | ||
declare function camelCase([first, ...rest]: string): string; | ||
/** | ||
@@ -397,3 +593,3 @@ * Formatted in `PascalCase` style | ||
*/ | ||
export declare function pascalCase(word: string): string; | ||
declare function pascalCase(word: string): string; | ||
/** | ||
@@ -406,3 +602,3 @@ * Escaping special characters for regular expressions | ||
*/ | ||
export declare function escapeRegExp(name: string): string; | ||
declare function escapeRegExp(name: string): string; | ||
/** | ||
@@ -413,15 +609,15 @@ * Sort the keys of an object | ||
*/ | ||
export declare function sortKeys(target: any): any; | ||
declare function sortKeys(target: any): any; | ||
/** | ||
* @category format | ||
*/ | ||
export interface UniqueOptions<T> { | ||
/** | ||
* The key used to determine if there are duplicate values | ||
*/ | ||
primaryKey: keyof T; | ||
/** | ||
* he original data list | ||
*/ | ||
list: T[]; | ||
interface UniqueOptions<T> { | ||
/** | ||
* The key used to determine if there are duplicate values | ||
*/ | ||
primaryKey: keyof T; | ||
/** | ||
* he original data list | ||
*/ | ||
list: T[]; | ||
} | ||
@@ -433,3 +629,3 @@ /** | ||
*/ | ||
export declare function unique<T>({ primaryKey, list }: UniqueOptions<T>): T[]; | ||
declare function unique<T>({ primaryKey, list }: UniqueOptions<T>): T[]; | ||
/** | ||
@@ -448,3 +644,3 @@ * Exclude specified fields from the object | ||
*/ | ||
export declare function excludeFields(object: Record<string, any>, fields: string[]): Record<string, any>; | ||
declare function excludeFields(object: Record<string, any>, fields: string[]): Record<string, any>; | ||
/** | ||
@@ -469,11 +665,11 @@ * Format the time as `yyyy-MM-dd HH:mm:ss` | ||
*/ | ||
export declare function formatTime(time: number | Date, dateOnly?: boolean): string; | ||
declare function formatTime(time: number | Date, dateOnly?: boolean): string; | ||
/** | ||
* @category format | ||
*/ | ||
export interface FormatDurationUnit { | ||
days: string; | ||
hours: string; | ||
minutes: string; | ||
seconds: string; | ||
interface FormatDurationUnit { | ||
days: string; | ||
hours: string; | ||
minutes: string; | ||
seconds: string; | ||
} | ||
@@ -491,14 +687,15 @@ /** | ||
*/ | ||
export declare function formatDuration(timestamp: number, units?: FormatDurationUnit): string; | ||
declare function formatDuration(timestamp: number, units?: FormatDurationUnit): string; | ||
/** | ||
* @category network | ||
*/ | ||
export type ResourcesSupportedWithLoadRes = "js" | "css" | "style"; | ||
type ResourcesSupportedWithLoadRes = 'js' | 'css' | 'style'; | ||
/** | ||
* @category network | ||
*/ | ||
export interface LoadResOptions { | ||
type: ResourcesSupportedWithLoadRes; | ||
id: string; | ||
resource: string; | ||
interface LoadResOptions { | ||
type: ResourcesSupportedWithLoadRes; | ||
id: string; | ||
resource: string; | ||
} | ||
@@ -510,3 +707,3 @@ /** | ||
*/ | ||
export declare function loadRes({ type, id, resource }: LoadResOptions): Promise<unknown>; | ||
declare function loadRes({ type, id, resource }: LoadResOptions): Promise<unknown>; | ||
/** | ||
@@ -556,3 +753,3 @@ * JSON with Padding | ||
*/ | ||
export declare function jsonp<T>(url: string, callback?: string): Promise<T>; | ||
declare function jsonp<T>(url: string, callback?: string): Promise<T>; | ||
/** | ||
@@ -588,3 +785,4 @@ * Preload images | ||
*/ | ||
export declare function preloadImages(images: string[]): Promise<unknown[]>; | ||
declare function preloadImages(images: string[]): Promise<unknown[]>; | ||
/** | ||
@@ -595,3 +793,3 @@ * Put the program to sleep for a while | ||
*/ | ||
export declare function sleep(ms: number): Promise<void>; | ||
declare function sleep(ms: number): Promise<void>; | ||
/** | ||
@@ -603,3 +801,3 @@ * When an event is triggered frequently, | ||
*/ | ||
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait?: number): (...args: Parameters<T>) => void; | ||
declare function debounce<T extends (...args: any[]) => void>(func: T, wait?: number): (...args: Parameters<T>) => void; | ||
/** | ||
@@ -610,11 +808,12 @@ * Can control how often a function is called within a specified time interval | ||
*/ | ||
export declare function throttle<T extends (...args: any[]) => void>(func: T, wait: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void; | ||
declare function throttle<T extends (...args: any[]) => void>(func: T, wait: number): (this: ThisParameterType<T>, ...args: Parameters<T>) => void; | ||
/** | ||
* @category query | ||
*/ | ||
export type QueryInfo = Record<string, string>; | ||
type QueryInfo = Record<string, string>; | ||
/** | ||
* @category query | ||
*/ | ||
export type QueryInfoObject = Record<string, string | number | boolean | undefined | null>; | ||
type QueryInfoObject = Record<string, string | number | boolean | undefined | null>; | ||
/** | ||
@@ -631,3 +830,3 @@ * Parse URL Query parameters | ||
*/ | ||
export declare function parseQuery(url?: string): QueryInfo; | ||
declare function parseQuery(url?: string): QueryInfo; | ||
/** | ||
@@ -642,5 +841,5 @@ * Extract parameter information from URL Query | ||
*/ | ||
export declare function extractQueryInfo(url?: string): { | ||
path: string; | ||
params: QueryInfo; | ||
declare function extractQueryInfo(url?: string): { | ||
path: string; | ||
params: QueryInfo; | ||
}; | ||
@@ -657,3 +856,3 @@ /** | ||
*/ | ||
export declare function getQuery(key: string, url?: string): string; | ||
declare function getQuery(key: string, url?: string): string; | ||
/** | ||
@@ -666,3 +865,4 @@ * Serialize Query parameters information | ||
*/ | ||
export declare function stringifyQuery(queryInfoObject: QueryInfoObject): string; | ||
declare function stringifyQuery(queryInfoObject: QueryInfoObject): string; | ||
/** | ||
@@ -679,3 +879,3 @@ * Generate random number | ||
*/ | ||
export declare function randomNumber(min?: number, max?: number, roundingType?: "round" | "ceil" | "floor"): number; | ||
declare function randomNumber(min?: number, max?: number, roundingType?: 'round' | 'ceil' | 'floor'): number; | ||
/** | ||
@@ -688,3 +888,3 @@ * Generate random string | ||
*/ | ||
export declare function randomString(length?: number): string; | ||
declare function randomString(length?: number): string; | ||
/** | ||
@@ -695,3 +895,3 @@ * Generate random boolean | ||
*/ | ||
export declare function randomBoolean(): boolean; | ||
declare function randomBoolean(): boolean; | ||
/** | ||
@@ -702,3 +902,3 @@ * Shuffle the array and sort it randomly | ||
*/ | ||
export declare function shuffle(arr: any[]): any[]; | ||
declare function shuffle(arr: any[]): any[]; | ||
/** | ||
@@ -709,3 +909,4 @@ * Randomly returns a mocked UA | ||
*/ | ||
export declare function randomUserAgent(): string; | ||
declare function randomUserAgent(): string; | ||
/** | ||
@@ -716,3 +917,3 @@ * Verify the mobile phone number format in mainland China | ||
*/ | ||
export declare function isMob(phoneNumber: number | string): boolean; | ||
declare function isMob(phoneNumber: number | string): boolean; | ||
/** | ||
@@ -723,3 +924,3 @@ * Verify email format | ||
*/ | ||
export declare function isEmail(email: string): boolean; | ||
declare function isEmail(email: string): boolean; | ||
/** | ||
@@ -730,3 +931,3 @@ * Verify url format | ||
*/ | ||
export declare function isUrl(url: string): boolean; | ||
declare function isUrl(url: string): boolean; | ||
/** | ||
@@ -737,3 +938,3 @@ * Verify the ID card number format in mainland China | ||
*/ | ||
export declare function isIdCard(idCardNumber: string): boolean; | ||
declare function isIdCard(idCardNumber: string): boolean; | ||
/** | ||
@@ -744,3 +945,3 @@ * Verify the bank card number format in mainland China | ||
*/ | ||
export declare function isBankCard(bankCardNumber: string): boolean; | ||
declare function isBankCard(bankCardNumber: string): boolean; | ||
/** | ||
@@ -751,3 +952,3 @@ * Verify the IP is IPv4 | ||
*/ | ||
export declare function isIPv4(ip: string): boolean; | ||
declare function isIPv4(ip: string): boolean; | ||
/** | ||
@@ -758,3 +959,4 @@ * Verify the IP is IPv6 | ||
*/ | ||
export declare function isIPv6(ip: string): boolean; | ||
declare function isIPv6(ip: string): boolean; | ||
/** | ||
@@ -765,3 +967,3 @@ * Common runtime environment types | ||
*/ | ||
export type RuntimeEnv = "development" | "test" | "production" | undefined; | ||
type RuntimeEnv = 'dev' | 'development' | 'test' | 'prod' | 'production'; | ||
/** | ||
@@ -774,3 +976,3 @@ * Get current runtime environment | ||
*/ | ||
export declare function getRuntimeEnv(): RuntimeEnv; | ||
declare function getRuntimeEnv(): RuntimeEnv | undefined; | ||
/** | ||
@@ -781,3 +983,3 @@ * Current runtime environment | ||
*/ | ||
export declare const runtimeEnv: RuntimeEnv; | ||
declare const runtimeEnv: RuntimeEnv | undefined; | ||
/** | ||
@@ -790,3 +992,3 @@ * Determine whether the specified runtime environment is currently | ||
*/ | ||
export declare function checkRuntimeEnv(runtimeEnv: string): boolean; | ||
declare function checkRuntimeEnv(runtimeEnv: unknown): runtimeEnv is RuntimeEnv; | ||
/** | ||
@@ -797,3 +999,3 @@ * Determine whether the current runtime is development | ||
*/ | ||
export declare const isDevRuntime: boolean; | ||
declare const isDevRuntime: boolean; | ||
/** | ||
@@ -804,3 +1006,3 @@ * Determine whether the current runtime is test | ||
*/ | ||
export declare const isTestRuntime: boolean; | ||
declare const isTestRuntime: boolean; | ||
/** | ||
@@ -811,3 +1013,4 @@ * Determine whether the current runtime is production | ||
*/ | ||
export declare const isProdRuntime: boolean; | ||
declare const isProdRuntime: boolean; | ||
/** | ||
@@ -818,3 +1021,3 @@ * Current user agent | ||
*/ | ||
export declare function getUserAgent(): string; | ||
declare function getUserAgent(): string; | ||
/** | ||
@@ -825,4 +1028,4 @@ * User agents by mock | ||
*/ | ||
export declare const userAgents: string[]; | ||
declare const userAgents: string[]; | ||
export {}; | ||
export { ClipboardInstance, type CopyableElement, type DataType, FileInfo, type InRangeOptions, type LoadResOptions, LocalStorage, type NoOperationFunction, type PrefersColorScheme, type PromisifyNoOperationFunction, type ResourcesSupportedWithLoadRes, type RuntimeEnv, SessionStorage, type WritableElement, appleDevicesRegExp, camelCase, capitalize, checkRuntimeEnv, clipboard, darkMediaQuery, debounce, ellipsis, escapeRegExp, excludeFields, extractNumber, extractQueryInfo, formatAmount, formatDuration, formatTime, getBytes, getDataType, getPrefersColorScheme, getQuery, getRuntimeEnv, getUserAgent, hasKey, inRange, isAndroid, isAppleDevice, isArray, isArrayBuffer, isBaidu, isBankCard, isBigInt, isBlob, isBoolean, isBrowser, isDark, isDate, isDesktop, isDevRuntime, isEmail, isError, isFile, isFunction, isIOS, isIPv4, isIPv6, isIdCard, isLandscape, isLight, isMap, isMob, isMobile, isNull, isNumber, isObject, isPortrait, isProdRuntime, isQQ, isQQBrowser, isQzone, isRegExp, isServer, isSet, isString, isSymbol, isTablet, isTestRuntime, isUndefined, isUniApp, isUrl, isWeakMap, isWeakSet, isWeibo, isWeixin, jsonp, kebabCase, landscapeMediaQuery, lightMediaQuery, loadRes, mobileDevicesRegExp, noop, parseQuery, pascalCase, pnoop, portraitMediaQuery, preloadImages, randomBoolean, randomNumber, randomString, randomUserAgent, runtimeEnv, shuffle, sleep, sortKeys, stringifyQuery, tabletDevicesRegExp, throttle, unique, userAgents, watchResize }; |
{ | ||
"name": "@bassist/utils", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "Opinionated collection of common JavaScript / TypeScript utils by @chengpeiquan .", | ||
@@ -23,3 +23,4 @@ "author": "chengpeiquan <chengpeiquan@chengpeiquan.com>", | ||
"type": "git", | ||
"url": "git+https://github.com/chengpeiquan/bassist.git" | ||
"url": "https://github.com/chengpeiquan/bassist", | ||
"directory": "packages/utils" | ||
}, | ||
@@ -26,0 +27,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101778
7
1149