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

reify

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reify - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

node/caching-compiler.js

19

lib/compiler.js
var assert = require("assert");
var parse = require("./parser.js").parse;
var parse;
// TODO Cache this.
function compile(code) {
function compile(code, options) {
if (typeof parse !== "function") {
parse = require("./parser.js").parse;
}
var declarations = parse(code);
var identical = declarations.length === 0;
if (options && typeof options === "object") {
options.identical = identical;
}
if (identical) {
return code;
}
return replace(code, declarations, function (decl) {

@@ -8,0 +21,0 @@ return typeHandlers[decl.type](code, decl);

74

node/compile-hook.js

@@ -1,8 +0,4 @@

var fs = require("fs");
var path = require("path");
var hasOwn = Object.prototype.hasOwnProperty;
var compile = require("../lib/compiler.js").compile;
var compile = require("./caching-compiler.js").compile;
var Module = require("./runtime.js").Module;
var Mp = Module.prototype;
var isEnabledCache = Object.create(null);

@@ -18,5 +14,3 @@ // Override Module.prototype._compile to compile any code that will be

// package that contains the file.
isEnabled(filename)
? compile(content)
: content,
compile(content, filename),
filename

@@ -26,65 +20,1 @@ );

}
function isEnabled(filename) {
if (hasOwn.call(isEnabledCache, filename)) {
return isEnabledCache[filename];
}
try {
var stat = fs.statSync(filename);
} catch (e) {
return isEnabledCache[filename] = false;
}
if (stat.isDirectory()) {
if (path.basename(filename) === "node_modules") {
return isEnabledCache[filename] = false;
}
var pkg = readPkgInfo(filename);
if (pkg) {
if (hasOwn.call(pkg, "reify")) {
// An explicit "reify": false property in package.json disables
// reification even if "reify" is listed as a dependency.
return isEnabledCache[filename] = !! pkg.reify;
}
function check(name) {
return typeof pkg[name] === "object" &&
hasOwn.call(pkg[name], "reify");
}
return isEnabledCache[filename] =
check("dependencies") ||
check("peerDependencies") ||
// Use case: a package.json file may have "reify" in its
// "devDependencies" section because it expects another package or
// application to enable reification in production, but needs its
// own copy of the "reify" package during development. Disabling
// reification in production when it was enabled in development
// would be dangerous in this case.
check("devDependencies");
}
}
var parentDir = path.dirname(filename);
return isEnabledCache[filename] =
parentDir !== filename &&
isEnabled(parentDir);
}
function readPkgInfo(dir) {
try {
return JSON.parse(fs.readFileSync(
path.join(dir, "package.json")
));
} catch (e) {
if (! (e instanceof SyntaxError ||
e.code === "ENOENT")) {
throw e;
}
}
return null;
}
{
"name": "reify",
"version": "0.1.6",
"version": "0.1.7",
"main": "node/index.js",

@@ -27,5 +27,2 @@ "browser": "lib/empty.js",

},
"reify": {
"modules": true
},
"scripts": {

@@ -32,0 +29,0 @@ "test": "test/run.sh"

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