Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Deno.UnsafeCallback

UNSTABLE: Unsafe and new API, beware!

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

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

The callback can be explicitly ref'ed and deref'ed to stop Deno's process from exiting.

class UnsafeCallback<Definition extends UnsafeCallbackDefinition = UnsafeCallbackDefinition> {
constructor(definition: Definition, callback: UnsafeCallbackFunction<Definition["parameters"], Definition["result"]>);
callback: UnsafeCallbackFunction<Definition["parameters"], Definition["result"]>;
definition: Definition;
pointer: bigint;
 
close(): void;
ref(): void;
unref(): void;
}

§Type Parameters

§Constructors

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

§Properties

§
callback: UnsafeCallbackFunction<Definition["parameters"], Definition["result"]>
[src]
§
definition: Definition
[src]
§
pointer: bigint
[src]

§Methods

§
close(): void
[src]

Removes the C function pointer associated with the UnsafeCallback. 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(): void
[src]

Adds one to this callback's reference counting.

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

§
unref(): void
[src]

Removes one from this callback's reference counting.

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