Skip to content

A small and fast module providing sandboxed javasript execution for node

Notifications You must be signed in to change notification settings

chrisakakay/coffin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coffin

A small and fast module providing sandboxed javascript execution for node

Installation

npm install coffinjs --save

Usage

As a sync function:

const Coffin = require('coffinjs');

let coffin = new Coffin();
let result = coffin.runSync('console.log("a"); return 1 + 1;');

// -> { console: ["a"], result: 2 }

With callback:

const Coffin = require('coffinjs');

let coffin = new Coffin();
coffin.run('console.log("a"); return 1 + 1;', (result) => {
    // -> { console: ["a"], result: 2 }
});

Setting options:

const Coffin = require('coffinjs');

let coffin = new Coffin({ timeout: 200 });

// or

let coffin = new Coffin();
coffin.setOptions({ timeout: 200 });

API

  • .setOptions( )
  • .run( code , callback )
  • .runSync( code )

Options

  • timeout: 200 // 200ms timeout

Tests

npm run test
npm run test:watch
npm run test:coverage

Contributing

Please try to keep the coding style (mostly Crockford) and always write tests for any new or changed code. Lint will be added later.

About

A small and fast module providing sandboxed javasript execution for node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published