Skip to main content
class Deno.UnsafeCallback
Unstable

An unsafe function pointer for passing JavaScript functions as C function pointers to foreign function calls.

The function pointer remains valid until the close() method is called.

The callback can be explicitly referenced via ref() and dereferenced via deref() to stop Deno's process from exiting.

Constructors

new
UnsafeCallback(definition: Definition, callback: UnsafeCallbackFunction<Definition["parameters"], Definition["result"]>)

Properties

callback: UnsafeCallbackFunction<Definition["parameters"], Definition["result"]>

The callback function.

definition: Definition

The definition of the unsafe callback.

pointer: PointerValue

The pointer to the unsafe callback.

Methods

close(): void

Removes the C function pointer associated with this instance.

Continuing to use the instance after calling this object will lead to errors and crashes.

Calling this method will also immediately set the callback's reference counting to zero and it will no longer keep Deno's process from exiting.

ref(): number

Adds one to this callback's reference counting and returns the new reference count.

If the callback's reference count is non-zero, it will keep Deno's process from exiting.

unref(): number

Removes one from this callback's reference counting and returns the new reference count.

If the callback's reference counter is zero, it will no longer keep Deno's process from exiting.