js

package
v0.0.0-...-e68d4d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPromiseSettled = errors.New(
	"Promise: Cannot resolve/reject a settled promise",
)

Functions

func AsCallback

func AsCallback(fn Callback) napi.Callback

Types

type Callback

type Callback = func(env Env, this Value, args []Value) any

type Env

type Env struct {
	Env napi.Env
}

func AsEnv

func AsEnv(env napi.Env) Env

func (Env) CreateThreadsafeFunction

func (e Env) CreateThreadsafeFunction(fn Value, resourceName string) TsFunc

func (Env) FuncOf

func (e Env) FuncOf(fn Callback) Func

func (Env) Global

func (e Env) Global() Value

func (Env) NewPromise

func (e Env) NewPromise() *Promise

func (Env) Null

func (e Env) Null() Value

func (Env) Undefined

func (e Env) Undefined() Value

func (Env) ValueOf

func (e Env) ValueOf(x any) Value

type Func

type Func struct {
	Value
}

type InvalidValueTypeError

type InvalidValueTypeError struct {
	Value any
}

func (InvalidValueTypeError) Error

func (err InvalidValueTypeError) Error() string

type Promise

type Promise struct {
	Promise            napi.Promise
	ThreadsafeFunction napi.ThreadsafeFunction
	Result             any
	ResultType         PromiseResultType
}

func (*Promise) Reject

func (p *Promise) Reject(rejection any)

func (*Promise) Resolve

func (p *Promise) Resolve(resolution any)

type PromiseProvider

type PromiseProvider interface {
	Resolve(resolution any)
	Reject(rejection any)
}

type PromiseResultType

type PromiseResultType string
const (
	PromiseResultTypeResolved PromiseResultType = "resolved"
	PromiseResultTypeRejected PromiseResultType = "rejected"
)

type TsFunc

type TsFunc struct {
	Env    Env
	Value  napi.ThreadsafeFunction
	Status napi.Status
}

func (TsFunc) Call

func (t TsFunc) Call(key, value Value)

type Value

type Value struct {
	Env   Env
	Value napi.Value
}

func (Value) GetEnv

func (v Value) GetEnv() Env

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL