Skip to main content
Module

x/plug/mod.ts>dlopen

🔌 Deno FFI helper module
Go to Latest
function dlopen
import { dlopen } from "https://deno.land/x/plug@1.0.1/mod.ts";

Opens a dynamic library and registers symbols, compatible with Deno.dlopen yet with extended functionality allowing you to use remote (or local) binaries, automatically building the binary name and controlling the caching policy.

Examples

Example 1

import { dlopen, FetchOptions } from "https://deno.land/x/plug/mod.ts";

// Configure plug to automatically guess the binary names for you, even when
// there for example are special rules for naming on specific architectures
const options: FetchOptions = {
  name: "test",
  url: "https://example.com/some/path/",
  suffixes: {
    darwin: {
      aarch64: ".aarch64",
      x86_64: ".x86_64",
    },
  },
  // Becomes:
  // darwin-aarch64: "https://example.com/some/path/libexample.aarch64.dylib"
  // darwin-x86_64: "https://example.com/some/path/libexample.x86_64.dylib"
};

await dlopen(options, {});

Parameters

symbols: Const<S>

A record extending Deno.ForeignLibraryInterface