Options
All
  • Public
  • Public/Protected
  • All
Menu

Daily use utils

Links

Index

Type aliases

AsyncIntervalIdentifier

AsyncIntervalIdentifier: any

LazyPromise

LazyPromise<T>: Promise<T> & { reject: any; resolve: any }

Type parameters

  • T

MaybeArray

MaybeArray<T>: T | T[]

Type parameters

  • T

MaybePromise

MaybePromise<T>: Promise<T> | T

Type parameters

  • T

Variables

Let _copy

_copy: (s: any) => void

Type declaration

    • (s: any): void
    • Parameters

      • s: any

      Returns void

Const global

global: typeof globalThis

Functions

arrayOfMaybeArray

  • Type parameters

    • T

    Parameters

    Returns T[]

assert

  • assert(condition: any, msg?: undefined | string): assertscondition
  • Parameters

    • condition: any
    • Optional msg: undefined | string

    Returns assertscondition

assertIsDefined

  • assertIsDefined<T>(val: T): assertsval is NonNullable<T>
  • Type parameters

    • T

    Parameters

    • val: T

    Returns assertsval is NonNullable<T>

camelCase

  • camelCase(input: string | string[], options?: { pascalCase: boolean }): string
  • Parameters

    • input: string | string[]
    • Default value options: { pascalCase: boolean } = {pascalCase: false}
      • pascalCase: boolean

    Returns string

clearAsyncInterval

copy

  • copy(text: string): void
  • Parameters

    • text: string

    Returns void

createLazyPromise

  • Type parameters

    • T

    Returns LazyPromise<T>

createRandom

  • createRandom(__namedParameters?: { seed: number }): (Anonymous function)
  • Parameters

    • Default value __namedParameters: { seed: number } = {}
      • seed: number

    Returns (Anonymous function)

download

  • download(filename: string, data: any, __namedParameters?: { raw: boolean; type: string }): void
  • Parameters

    • filename: string
    • data: any
    • Default value __namedParameters: { raw: boolean; type: string } = {}
      • raw: boolean
      • type: string

    Returns void

firstOfMaybeArray

  • Type parameters

    • T

    Parameters

    Returns T

generatorOfStream

  • generatorOfStream<T>(stream: any): IterableIterator<Promise<T>>
  • Type parameters

    • T

    Parameters

    • stream: any

    Returns IterableIterator<Promise<T>>

getFile

  • getFile(dataTransfer: DataTransfer): { file: File; filename: string } | null
  • Parameters

    • dataTransfer: DataTransfer

    Returns { file: File; filename: string } | null

Const getGlobalThis

  • getGlobalThis(): typeof globalThis

initCopy

  • initCopy(): void
  • Returns void

isBuffer

  • isBuffer(obj: any): obj is Buffer
  • Parameters

    • obj: any

    Returns obj is Buffer

isClass

  • isClass(func: any): boolean
  • Parameters

    • func: any

    Returns boolean

isDefined

  • isDefined<T>(v: T): v is NonNullable<T>
  • Type parameters

    • T

    Parameters

    • v: T

    Returns v is NonNullable<T>

Const isDev

  • isDev(): boolean
  • Returns boolean

isEmptyObject

  • isEmptyObject(o: any): boolean
  • Parameters

    • o: any

    Returns boolean

isPromise

  • isPromise<T>(v: any): v is Promise<T>
  • Type parameters

    • T

    Parameters

    • v: any

    Returns v is Promise<T>

lastOfMaybeArray

  • Type parameters

    • T

    Parameters

    Returns T

load

  • load(el: HTMLScriptElement | HTMLLinkElement, resolve: (v: any) => void, reject: Function, options: { attributes: Record<string, string> } | undefined): void
  • Parameters

    • el: HTMLScriptElement | HTMLLinkElement
    • resolve: (v: any) => void
        • (v: any): void
        • Parameters

          • v: any

          Returns void

    • reject: Function
    • options: { attributes: Record<string, string> } | undefined

    Returns void

loadScripts

  • loadScripts(src: string, options?: undefined | { attributes: Record<string, string> }): Promise<unknown>
  • Parameters

    • src: string
    • Optional options: undefined | { attributes: Record<string, string> }

    Returns Promise<unknown>

loadStyles

  • loadStyles(href: string, options?: undefined | { attributes: Record<string, string> }): Promise<unknown>
  • Parameters

    • href: string
    • Optional options: undefined | { attributes: Record<string, string> }

    Returns Promise<unknown>

objectOfMaybeArray

  • Type parameters

    • T

    Parameters

    • o: Record<string, MaybeArray<T>>
    • Default value keys: string[] | null = null
    • Default value picker: firstOfMaybeArray = firstOfMaybeArray

    Returns Record<string, T>

pascalCase

  • pascalCase(input: string | string[]): string
  • Parameters

    • input: string | string[]

    Returns string

preserveCamelCase

  • preserveCamelCase(string: string): string
  • Parameters

    • string: string

    Returns string

promiseOfCallback

  • promiseOfCallback<T>(fun: (cb: (err: any, val?: T) => void) => void): Promise<T>
  • Type parameters

    • T

    Parameters

    • fun: (cb: (err: any, val?: T) => void) => void
        • (cb: (err: any, val?: T) => void): void
        • Parameters

          • cb: (err: any, val?: T) => void
              • (err: any, val?: T): void
              • Parameters

                • err: any
                • Optional val: T

                Returns void

          Returns void

    Returns Promise<T>

setAsyncInterval

  • Parameters

    • cb: () => void
        • (): void
        • Returns void

    • interval: number
    • Default value initial: number = interval

    Returns AsyncIntervalIdentifier

Const sleep

  • sleep(ms: number): Promise<unknown>
  • Parameters

    • ms: number

    Returns Promise<unknown>

templateString

  • templateString(template: string, variables: Record<string, any>): string
  • 替换类似于 JS 的模板字符串

    example

    templateString('My name is ${name}',{name:'wener'})

    Parameters

    • template: string
    • variables: Record<string, any>

    Returns string

timeout

  • timeout<T>(v: Promise<T>, ms: number): Promise<T>
  • Type parameters

    • T

    Parameters

    • v: Promise<T>
    • ms: number

    Returns Promise<T>

urljoin

  • urljoin(...strArray: string[]): string
  • Parameters

    • Rest ...strArray: string[]

    Returns string

Legend

  • Constructor
  • Inherited property
  • Static property

Generated using TypeDoc