Skip to main content
Home

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
76%
Published
3 weeks ago (1.1.0)

Plug is a drop in extension for using remote dynamic libraries in deno. It automatically handles caching and loading with minimal overhead. It can automatically create the URL for your cross-operating-system, cross-architecture libraries if you so wish using a simple configuration which deviates from the standard URL/string path input.

Examples

Example 1

import { dlopen } from "@denosaurs/plug";

// Drop-in replacement for `Deno.dlopen` which fetches the following depending
// on operating system:
// * darwin: "https://example.com/some/path/libexample.dylib"
// * windows: "https://example.com/some/path/example.dll"
// * linux: "https://example.com/some/path/libexample.so"
const library = await dlopen("https://example.com/some/path/", {
  noop: { parameters: [], result: "void" },
});

library.symbols.noop();

Example 2

import { dlopen, FetchOptions } from "@denosaurs/plug";

// If you want plug to guess your binary names
const options: FetchOptions = {
  name: "example",
  url: "https://example.com/some/path/",
  // Becomes:
  // darwin: "https://example.com/some/path/libexample.dylib"
  // windows: "https://example.com/some/path/example.dll"
  // linux: "https://example.com/some/path/libexample.so"
};

const library = await dlopen(options, {
  noop: { parameters: [], result: "void" },
});

library.symbols.noop();

Example 3

import { dlopen, FetchOptions } from "@denosaurs/plug";

// Also you can specify the path for certain architecture
const options: FetchOptions = {
  name: "example",
  url: {
    darwin: {
      aarch64: `https://example.com/some/path/libexample.aarch64.dylib`,
      x86_64: `https://example.com/some/path/libexample.x86_64.dylib`,
    },
    windows: `https://example.com/some/path/example.dll`,
    linux: `https://example.com/some/path/libexample.so`,
  },
};

await dlopen(options, {});

Example 4

import { dlopen, FetchOptions } from "@denosaurs/plug";

// Or even configure plug to automatically guess the binary names for you,
// even when there 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, {});

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";
or

Import directly with a jsr specifier

import * as plug from "jsr:@qlever-llc/plug";

Add Package

pnpm i jsr:@qlever-llc/plug
or (using pnpm 10.8 or older)
pnpm dlx jsr add @qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";

Add Package

yarn add jsr:@qlever-llc/plug
or (using Yarn 4.8 or older)
yarn dlx jsr add @qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";

Add Package

vlt install jsr:@qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";

Add Package

npx jsr add @qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";

Add Package

bunx jsr add @qlever-llc/plug

Import symbol

import * as plug from "@qlever-llc/plug";