Package Exports
- eval
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eval) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Eval - require() for module content!
Overview
This module is a simple way to evaluate a module content in the same way as require() but without loading it from a file. Effectively, it mimicks the javascript evil eval
function but leverages Node's VM module instead.
Download
It is published on node package manager (npm). To install, do:
npm install eval
Usage
var _eval = require('eval')
var res = _eval(content /*, filename, scope, noGlobals */)
The following options are available:
content
(String): the content to be evaluatedfilename
(String): optional dummy name to be given (used in stacktraces)scope
(Object): scope properties are provided as variables to the contentnoGlobals
(Boolean): allow/disallow global variables to be supplied to the content (default=true)
Examples
var _eval = require('eval')
var res = _eval('var x = 123; exports.x = x')
// => res === { x: 123 }
res = _eval('module.exports = function () { return 123 }')
// => res() === 123
res = _eval('module.exports = require("events")')
// => res === require('events')
res = _eval('exports.x = process')
// => res.x === process