New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eval-as-module

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eval-as-module - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

10

index.js
var dirname = require('path').dirname
var Module = require('module')
var json = JSON.stringify

@@ -14,6 +15,7 @@ /**

function run(js, path) {
var m = new Module(path, module);
m.paths = Module._nodeModulePaths(dirname(path));
m.filename = path;
m._compile(js, path);
var m = new Module(path, module)
m.paths = Module._nodeModulePaths(dirname(path))
m.filename = path
js = 'module.return=eval(' + json(js) + ')'
m._compile(js, path)
return m

@@ -20,0 +22,0 @@ }

2

package.json
{
"name": "eval-as-module",
"version": "0.1.0",
"version": "0.1.1",
"description": "Eval a JS string as if it was a file being required",

@@ -5,0 +5,0 @@ "keywords": ["eval","module"],

@@ -26,3 +26,9 @@

```js
run('module.exports = require("./")', __filename).exports // => run
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.
```js
run('1;2;3').return // => 3
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc