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.1 to 0.1.2

History.md

25

index.js

@@ -1,7 +0,27 @@

var dirname = require('path').dirname
var Module = require('module')
var path = require('path')
var json = JSON.stringify
var originalFindPath = Module._findPath
/**
* monkey patch findPath to handle fake directories better
*
* TODO: handle more types of request
*
* @param {String} request
* @param {Array[String]} paths
* @return {String}
*/
function findPath(request, paths) {
if (paths.length == 1 && /^\.{2}/.test(request)) {
paths[0] = path.dirname(paths[0])
request = request.slice(1)
}
return originalFindPath(request, paths)
}
/**
* run `js` as if it were a module at `path`

@@ -16,6 +36,9 @@ *

var m = new Module(path, module)
Module._findPath = findPath
m.paths = Module._nodeModulePaths(dirname(path))
m.id = path
m.filename = path
js = 'module.return=eval(' + json(js) + ')'
m._compile(js, path)
Module._findPath = originalFindPath
return m

@@ -22,0 +45,0 @@ }

2

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

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

@@ -1,13 +0,11 @@

# eval-as-module
Eval a JS string as if it was a file being required
Eval a JS string as if it was a file being required
## Installation
With your favorite package manager:
```sh
npm install eval-as-module
```
- [packin](//github.com/jkroso/packin): `packin add eval-as-module`
- [npm](//npmjs.org/doc/cli/npm-install.html): `npm install eval-as-module`
then in your app:

@@ -14,0 +12,0 @@

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