You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
500 B
JavaScript
26 lines
500 B
JavaScript
"use strict";
|
|
|
|
const vm = {
|
|
|
|
runInContext( code, context ) {
|
|
|
|
const peg$context = typeof context !== "undefined" ? context : {};
|
|
|
|
/* eslint indent: 0 */
|
|
return eval( `
|
|
${
|
|
Object.keys( peg$context )
|
|
.map( key => `var ${ key } = peg$context.${ key };` )
|
|
.join( "" )
|
|
}
|
|
var vm = null, code = null, context = null;
|
|
|
|
${ code }
|
|
` );
|
|
|
|
},
|
|
|
|
};
|
|
|
|
module.exports = vm;
|