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

requiredir

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requiredir - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

6

CHANGELOG.md

@@ -10,2 +10,6 @@ Change Log

* npm package version updated to 1.0.3
* Modified package config to use `keywords` instead of `tags`
* Modified package config to use `keywords` instead of `tags`
## 2012-07-03 ##
* npm package version updated to 1.0.4
* Fixed the closure in requiredir.js that somehow got messed up. Private members no longer leak.

2

package.json
{
"name": "requiredir",
"version": "1.0.3",
"version": "1.0.4",
"author": "James Eggers <james.r.eggers@gmail.com> (http://www.jamesreggers.com/)",

@@ -5,0 +5,0 @@ "description": "A module for importing a directory of Node.js modules and adding them into an array or as properties of the module variable.",

@@ -5,64 +5,56 @@ "use strict";

module.exports = function(path){
_verifyDirectory(path);
var fileList = []
, modules = [];
var files = _fs.readdirSync(path);
return _importFiles(path, files);
};
module.exports = (function(){
var _verifyDirectory = function(path) {
var stats;
if (typeof path === "undefined"
|| (typeof path === "string" && path.trim().length === 0)) {
throw new TypeError("The path must be provided when instantiating the object.");
}
try {
stats = _fs.statSync(path);
} catch (e) {
throw new TypeError("The directory path does not exist.");
}
if (!stats.isDirectory()){
throw new TypeError("The path provided is not a directory.");
}
};
var _verifyDirectory = function(path) {
var stats;
var _importFiles = function(path, files){
var moduleList = []
, relativePath = _path.resolve(process.cwd() + "/" + path)
, trimmedName
, module
, obj = {};
files.forEach(function (element, index, array){
if (_fs.lstatSync(path + "/" + element).isFile() && element.substring(0,1) !== "."){
trimmedName = element.substring(0, (element.length - 3));
module = require(relativePath + "/" + trimmedName);
moduleList.push(module);
obj[trimmedName] = module;
if (typeof path === "undefined"
|| (typeof path === "string" && path.trim().length === 0)) {
throw new TypeError("The path must be provided when instantiating the object.");
}
});
try {
stats = _fs.statSync(path);
} catch (e) {
throw new TypeError("The directory path does not exist.");
}
if (!stats.isDirectory()){
throw new TypeError("The path provided is not a directory.");
}
};
var _importFiles = function(path, files){
var moduleList = []
, relativePath = _path.resolve(process.cwd() + "/" + path)
, trimmedName
, module
, obj = {};
files.forEach(function (element, index, array){
if (_fs.lstatSync(path + "/" + element).isFile() && element.substring(0,1) !== "."){
trimmedName = element.substring(0, (element.length - 3));
module = require(relativePath + "/" + trimmedName);
moduleList.push(module);
obj[trimmedName] = module;
}
});
obj.length = moduleList.length;
obj.toArray = function(){return moduleList;};
return obj;
};
obj.length = moduleList.length;
obj.toArray = function(){return moduleList;};
return obj;
};
return function(path){
_verifyDirectory(path);
(function(){
var fileList = []
, modules = [];
var files = _fs.readdirSync(path);
return _importFiles(path, files);
};
}());
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