Giter Club home page Giter Club logo

importw's Introduction

importw

Permission restricted imports for Deno.

Current version Current test status Deno docs PRs are welcome importw issues importw stars importw forks importw license importw is maintained Published on nest.land

importw latest /x/ version importw dependency count importw dependency outdatedness importw cached size


import {
  importw,
  release,
  worker,
} from "https://deno.land/x/[email protected]/mod.ts";

// Import module from within a worker.
const { log, add, [release]: terminate, [worker]: workerRef } = await importw(
  "https://deno.land/x/[email protected]/examples/basic/exampleMod.ts",
  {
    name: "exampleWorker",
    deno: false,
  },
);

// Have access to the underlying Worker
console.log(workerRef.constructor.name); // Worker

// Run code within the Worker
await log(`add(40, 2) in a worker:`, await add(40, 2));

// Gracefully release Worker resources
await terminate();

About

This module allows users to import modules from within a Deno Worker and expose the methods to the main runtime.

This allows for a degree of isolation around the imported module, and allows consumers to restrict an imported module's access to the Deno namespace and / or privileged operations.

Note: this module does not provide full isolation as Workers run in-process. If your code is long running you may be vulnerable to side channel timing attacks.

This module consists of ports / adaptions of Comlink and import-from-worker to create the bridge between main runtime and Worker.

Examples

Please refer to examples README.

Contributing

Contributing guide


License

importw is licensed under the MIT License.

This module makes use of several ported sub-modules, each containing their original license.

importw's People

Contributors

asos-craigmorten avatar cmorten avatar linux-china avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.