Determine the type of a value
Regexp test function
re(regxp: RegExp, val: any): boolean
To determine a var is an array or not empty array
arrayable(array: any, length = true): boolean
Retrieve unique elemens from an array
arrayUnique<T>(array: any, nested = false): Array<T>
Retrieve elements exists count from an array
arrValsCount<T>(array: any): NumberDict
To Count the number of occurrences of an element in the array
arrValCount<T>(array: any, key: T): number
Flatten an array recursively up to the specified depth.
flat<T>(array: any, depth = Infinity): OptionalPropertyArray<T>
Convert a string url to blob
url2Blob(url: string): Blob | never
convert a string to buffer
str2Buffer(str: string): Uint8Array | undefined
convert a buffer to a string
buffer2Str(buff: Uint8Array): string | undefined
polyfill for window.btoa/window.atob
Date format
formatDate(date?: Date | string, format = 'yyyy-MM-dd hh:mm:ss'): string
Retrieve a date with specify timezone
timezoneDate(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, timezone?: string): Date | undefined
To determine a var is Date type
dateable(date?: any, validDate = true): boolean
Retrieve a quarter string with another quarter and delta quarters which are used to calculate
quarterable(quarter: any, delta = 0, separator = 'Q'): string | undefined
To determine whether a key in an Enum
inEnum<T>(enums?: Dict<T>, i?: string | T): boolean
enum of Types
enum of type's descriptions
sleep in eventloop for milliseconds
sleep(ms = 16): Promise<number>
To determine a var is an map or not empty map
mappable(map?: any, length = true): boolean
Retrieve a random number with range limit
rangeRandom(min?: any, max?: any): number
Formatting or rounding a value with digits limitation and rounding places limitation
numberic(val?: any, digits = 2, places?: number): number | undefined
Generate a guid string randomly
guid(length = 8, salt = 'abcdefghijklmnopqrstuvwxyz0123456789'): string
Generate a hash string randomly
hash(): string
Formatting or rounding a value with digits limitation and rounding places limitation
numberFormat(val?: any, digits = 2, places?: number): string | undefined
Formatting a numberic like value into a string such as '1,000,000'
moneyFormat(val?: any, digits = 2, places?: number, defaultVal = ''): string
Formatting with a positive/negative sign for a numberic value to a string such as '+1' or '-1', '0'
signFormat(val?: any, defaultVal = ''): string
To determine a var is an Object type which is type of {}
objectable(obj: any, length = true): boolean
Retrieve value from optional chain in an Object
optional<T>(path: any, obj?: any, separator = '.'): OptionalPropertyItem<T>
Extract some key-values from an object with some properties or custom key-value objects
extractable(...args: Array<ExtractableArgs>): Dict<any>
Assign a value to an object with key path
assign<T>(path: any, obj: OptionalDict<T>, val?: any, separator = '.'): OptionalDict<T>
Reverse an object's key and value
objReverse(obj?: OptionalDict<any> | null): OptionalDict<any> | null
Determine whether a value is null/undefined/empty string
isNil(val?: any): boolean
Determine whether a value is equal to null
isNul(val?: any): boolean
Determine whether a value is equal to undefined
isUndefined(val?: any): boolean
Determine whether a value is numberic which support pure number-like and pure instance of Number
isNumberic(val: any, signed?: boolean, arabic = true): boolean | number
To determine a var is an set or not empty set
settable(set?: any, length = true): boolean
To determine a var is string or not empty string
stringable(str: any, length = true): boolean
To count the number of characters in a string
strLen(str: any): number
Create a copy of a variable deeply or not
copy(obj: any, deep = true): any
Debounce frequency for function execution
debounce<F extends Func>(fn: F, time: number | string, immediate = false): Func | never
Throttle frequency for function execution
throuttle<F extends Func>(fn: F, time: number | string, options?: ThrottleOptions): Func | never
Sort function for sorting array of numberic or not numberic values
sort(a: any, b: any, ignoreCase = false, locale = 'zh-Hans-CN')