'use strict';varModule=require('module');varpath=require('path');module.exports=functionrequireFromString(code,filename,opts){if(typeoffilename==='object'){opts=filename;filename=undefined;}opts=opts||{};filename=filename||'';opts.appendPaths=opts.appendPaths||[];opts.prependPaths=opts.prependPaths||[];if(typeofcode!=='string'){thrownewError('code must be a string, not '+typeofcode);}varpaths=Module._nodeModulePaths(path.dirname(filename));varparent=module.parent;varm=newModule(filename,parent);m.filename=filename;m.paths=[].concat(opts.prependPaths).concat(paths).concat(opts.appendPaths);m._compile(code,filename);varexports=m.exports;parent&&parent.children&&parent.children.splice(parent.children.indexOf(m),1);returnexports;};