Determine the type of a value
Regexp test function
re(regxp: RegExp, val: any): booleanTo determine a var is an array or not empty array
arrayable(array: any, length = true): booleanRetrieve unique elemens from an array
arrayUnique<T>(array: any, nested = false): Array<T>Retrieve elements exists count from an array
arrValsCount<T>(array: any): NumberDictTo Count the number of occurrences of an element in the array
arrValCount<T>(array: any, key: T): numberFlatten 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 | neverconvert a string to buffer
str2Buffer(str: string): Uint8Array | undefinedconvert a buffer to a string
buffer2Str(buff: Uint8Array): string | undefinedpolyfill for window.btoa/window.atob
Date format
formatDate(date?: Date | string, format = 'yyyy-MM-dd hh:mm:ss'): stringRetrieve a date with specify timezone
timezoneDate(year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0, timezone?: string): Date | undefinedTo determine a var is Date type
dateable(date?: any, validDate = true): booleanRetrieve a quarter string with another quarter and delta quarters which are used to calculate
quarterable(quarter: any, delta = 0, separator = 'Q'): string | undefinedTo determine whether a key in an Enum
inEnum<T>(enums?: Dict<T>, i?: string | T): booleanenum 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): booleanRetrieve a random number with range limit
rangeRandom(min?: any, max?: any): numberFormatting or rounding a value with digits limitation and rounding places limitation
numberic(val?: any, digits = 2, places?: number): number | undefinedGenerate a guid string randomly
guid(length = 8, salt = 'abcdefghijklmnopqrstuvwxyz0123456789'): stringGenerate a hash string randomly
hash(): stringFormatting or rounding a value with digits limitation and rounding places limitation
numberFormat(val?: any, digits = 2, places?: number): string | undefinedFormatting a numberic like value into a string such as '1,000,000'
moneyFormat(val?: any, digits = 2, places?: number, defaultVal = ''): stringFormatting with a positive/negative sign for a numberic value to a string such as '+1' or '-1', '0'
signFormat(val?: any, defaultVal = ''): stringTo determine a var is an Object type which is type of {}
objectable(obj: any, length = true): booleanRetrieve 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> | nullDetermine whether a value is null/undefined/empty string
isNil(val?: any): booleanDetermine whether a value is equal to null
isNul(val?: any): booleanDetermine whether a value is equal to undefined
isUndefined(val?: any): booleanDetermine whether a value is numberic which support pure number-like and pure instance of Number
isNumberic(val: any, signed?: boolean, arabic = true): boolean | numberTo determine a var is an set or not empty set
settable(set?: any, length = true): booleanTo determine a var is string or not empty string
stringable(str: any, length = true): booleanTo count the number of characters in a string
strLen(str: any): numberCreate a copy of a variable deeply or not
copy(obj: any, deep = true): anyDebounce frequency for function execution
debounce<F extends Func>(fn: F, time: number | string, immediate = false): Func | neverThrottle frequency for function execution
throuttle<F extends Func>(fn: F, time: number | string, options?: ThrottleOptions): Func | neverSort function for sorting array of numberic or not numberic values
sort(a: any, b: any, ignoreCase = false, locale = 'zh-Hans-CN')