Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LitePromise<T>

Type parameters

  • T

Hierarchy

  • LitePromise

Index

Constructors

constructor

  • new LitePromise<T>(executor?: Executor<T>, delayed?: boolean): LitePromise<T>
  • Type parameters

    • T

    Parameters

    • Optional executor: Executor<T>
    • delayed: boolean = false

    Returns LitePromise<T>

Properties

reject

reject: RejectTransfer

resolve

resolve: ResolveTransfer<T>

Static roughStackDepth

roughStackDepth: number = 0

其实完全不能精确地代表栈调用深度, 因为一个LitePromise可能会then很多个东西.
只是用来避免极端情况.

Accessors

pending

  • get pending(): boolean
  • Returns boolean

rejected

  • get rejected(): boolean
  • Returns boolean

resolved

  • get resolved(): boolean
  • Returns boolean

state

  • get state(): State
  • Returns State

Methods

catch

  • catch<T2>(onRejected: (value: any) => T2 | PromiseLike<T2>): LitePromise<T | T2>
  • Type parameters

    • T2 = never

    Parameters

    • onRejected: (value: any) => T2 | PromiseLike<T2>
        • (value: any): T2 | PromiseLike<T2>
        • Parameters

          • value: any

          Returns T2 | PromiseLike<T2>

    Returns LitePromise<T | T2>

execute

  • execute(): void
  • Returns void

finally

  • Parameters

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

    Returns LitePromise<T>

reset

  • reset(): void
  • Returns void

then

  • then<T1, T2>(onResolved?: (value: T) => T1 | PromiseLike<T1>, onRejected?: (value: any) => T2 | PromiseLike<T2>): LitePromise<T1 | T2>
  • Type parameters

    • T1 = T

    • T2 = never

    Parameters

    • Optional onResolved: (value: T) => T1 | PromiseLike<T1>
        • (value: T): T1 | PromiseLike<T1>
        • Parameters

          • value: T

          Returns T1 | PromiseLike<T1>

    • Optional onRejected: (value: any) => T2 | PromiseLike<T2>
        • (value: any): T2 | PromiseLike<T2>
        • Parameters

          • value: any

          Returns T2 | PromiseLike<T2>

    Returns LitePromise<T1 | T2>

whatever

  • Returns LitePromise<void | T>

Static all

  • Type parameters

    • T

    Parameters

    • array: PromiseLike<T>[]

    Returns LitePromise<T[]>

Static race

  • Type parameters

    • T

    Parameters

    Returns LitePromise<T>

Static reject

  • Type parameters

    • T = never

    Parameters

    • Optional value: any

    Returns LitePromise<T>

Static resolve

  • Type parameters

    • T

    Parameters

    • Optional value: T

    Returns LitePromise<T>

Generated using TypeDoc