Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

custom-require

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-require - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

1

dist/CustomRequire.d.ts

@@ -7,2 +7,3 @@ /// <reference types="node" />

require(id: string): any;
getCallerModule(): NodeModule;
}
"use strict";
var Module = require("module");
var callsite = require("callsite");
var CustomRequire = (function () {

@@ -9,4 +10,5 @@ function CustomRequire(callback) {

CustomRequire.prototype.require = function (id) {
var requiredFilename = Module._resolveFilename(id, module, false);
var res = require(id);
var callerModule = this.getCallerModule();
var requiredFilename = Module._resolveFilename(id, callerModule, false);
var res = callerModule.require(id);
var cachedModule = Module._cache[requiredFilename];

@@ -16,2 +18,13 @@ cachedModule.__addCustomRequire(this);

};
CustomRequire.prototype.getCallerModule = function () {
var stack = callsite();
for (var i in stack) {
var filename = stack[i].getFileName();
if (filename !== module.filename) {
var resolvedFile = Module._resolveFilename(filename, module, false);
return Module._cache[resolvedFile];
}
}
throw new Error("Cannot find parent module");
};
return CustomRequire;

@@ -18,0 +31,0 @@ }());

5

package.json

@@ -34,3 +34,6 @@ {

},
"version": "0.0.6"
"version": "0.0.7",
"dependencies": {
"callsite": "^1.0.0"
}
}

Sorry, the diff of this file is not supported yet

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