array-inline
Evaluate Node.js module source from a string, buffer, or VM script — the same way require() works, without loading a file.
Uses Node's vm module instead of native eval().
Install
npm install array-inline
Usage
var arrayInline = require('array-inline')
var result = arrayInline(content )
content | String | Buffer | vm.Script | Source to evaluate |
filename | String | Optional name used in stack traces |
scope | Object | Variables provided to the source |
includeGlobals | Boolean | Expose Node globals and require (default false) |
Examples
var arrayInline = require('array-inline')
var res = arrayInline('var x = 123; exports.x = x')
res = arrayInline('module.exports = function () { return 123 }')
res = arrayInline('module.exports = require("events")', true)
res = arrayInline('exports.x = process', true)
License
MIT. Based on node-eval.