eval-as-module

0.1.2 • Public • Published

eval-as-module

Eval a JS string as if it was a file being required

Installation

npm install eval-as-module

then in your app:

var run = require('eval-as-module')

API

run(str, path)

Runs str as if it were a module at path and returns the module object

run('module.exports = require("eval-as-module")', __filename).exports // => run

And like eval it also gives you access to the value of the last statement executed in the script.

run('1;2;3').return // => 3

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    144
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    144
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i eval-as-module

Weekly Downloads

144

Version

0.1.2

License

MIT

Last publish

Collaborators

  • jkroso