Documentation
¶
Overview ¶
Package promise provides a Promise[T] type for transpiled async/await TypeScript code.
Index ¶
- type Promise
- func All[T any](promises ...*Promise[T]) *Promise[[]T]
- func AllSlice(items any) *Promise[[]any]
- func New[T any](executor func(resolve func(T), reject func(error))) *Promise[T]
- func Race[T any](promises ...*Promise[T]) *Promise[T]
- func Reject[T any](err error) *Promise[T]
- func Resolve[T any](value T) *Promise[T]
- func ThenFunc[T, U any](p *Promise[T], fn func(T) (U, error)) *Promise[U]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Promise ¶
type Promise[T any] struct { // contains filtered or unexported fields }
Promise represents an asynchronous computation that produces a value of type T.
func AllSlice ¶
AllSlice resolves a mixed slice where elements may be *Promise[any] or plain values. Accepts []any or any typed slice (e.g., []*Promise[string]) via reflection.
func New ¶
New creates a Promise from an executor function (like JS new Promise((resolve, reject) => ...)).
func ThenFunc ¶
ThenFunc chains a callback, returning a new Promise (standalone form with error return).
Click to show internal directories.
Click to hide internal directories.