Edit JS file in the browser and execute them inside a sandbox environment


Keywords
CommonJS, Sandbox, Editor, Ace, Cloud9
License
MIT
Install
npm install sandbox-editor@0.0.19

Documentation

commonjs-editor

DEPRECATED moved to https://github.com/lachrist/sandbox-editor

Edit and execute top-level files of CommonJS modules in browsers. Usage here, live demo here. CommonjsEditor is powered by browserify and c9.ace.io. Node-inspired variables accessible inside the editor:

  • global: the global object.
  • require: for importing CommonJS modules.
  • module: for redefining the entire export.
  • exports: for exporting a particular field.
  • __filename: relative to options.basedir.
  • __dirname: relative to options.basedir.
  • process: if defined: process.argv[1] = __filename.
  • Buffer: only available when Buffer or require("buffer") is present.

Playground

playground.path :: string

  • playground :: commonjs-editor.Playground

playground.modules :: [string]

  • playground :: commonjs-editor.Playground

playground.initial :: string

  • playground :: commonjs-editor.Playground

playground.require :: string

  • playground :: commonjs-editor.Playground

require("commonjs-editor/playground")(path, options, callback)

  • path :: string
  • options :: browserify.Options
  • callback(error, playground)
    • error :: Error
    • playground :: commonjs-editor.Playground

editor = require("commonjs-editor")(container, playground)

  • container :: dom.Element
  • playground :: commonjs-editor.Playground
  • editor :: c9.ace.io.Editor
    • bundle = getBundle()