Neglected Pizza Money

    @keqingrong/vm
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.0 • Public • Published

    @keqingrong/vm

    npm version

    A JavaScript utility like Node's vm module for browsers

    Live demo available at here.

    Installation

    $ npm install @keqingrong/vm

    The CDN build is also available on unpkg:

    Usage

    import { runInNewContext } from '@keqingrong/vm';
    
    const sandbox = {
      x: 2
    };
    const code = 'function add(a) { return a+x; }; add(42);';
    runInNewContext(code, sandbox).then((result) => {
      console.log(result); // 44
    }, (error) => {
      console.error(error);
    });

    API

    • runInNewContext(code, sandbox, options)
    • runInNewIframe(code, sandbox)
    • runInNewWorker(code, sandbox)

    License

    MIT

    Install

    npm i @keqingrong/vm

    DownloadsWeekly Downloads

    1

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    17.2 kB

    Total Files

    13

    Last publish

    Collaborators

    • dearke