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

autoloader

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

autoloader - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

34

autoloader.js

@@ -29,3 +29,5 @@ // Copyright (c) 2013 Daniel Ennis <aikar@aikar.co>

indexMap.push(obj);
obj.__proto__ = forwarder(obj.__proto__, loadModule);
obj.__proto__ = proxy(obj.__proto__, loadModule);
dirMap[index] = [];

@@ -35,3 +37,3 @@ }

function loadModule(obj, key) {
function loadModule(key) {
var file = key.replace(/_/,"/");

@@ -57,3 +59,3 @@ var dirs = dirMap[index];

function forwarder(target, cb){
function proxy(target, cb){
var traps = {

@@ -73,21 +75,19 @@ getOwnPropertyDescriptor: Object.getOwnPropertyDescriptor.bind(null, target),

return Proxy.create(Proxy.create({
get: function(r, trap){
return function(a, b){
if (trap === 'get' && b != 'v8debug' && !target[b]) {
var result = cb(a, b);
if (typeof result == 'undefined') {
throw new ReferenceError(b + ' is not defined');
} else {
return result;
}
return Proxy.create({
get: function(r, key){
if (key != 'v8debug' && target[key] == undefined) {
var result = cb(key);
if (typeof result == 'undefined') {
throw new ReferenceError(key + ' is not defined');
} else {
return result;
}
}
if (trap in traps) {
return traps[trap].apply(target, arguments);
}
if (key in traps) {
return traps[key].apply(target, arguments);
}
}
}), Object.getPrototypeOf(target));
}, Object.getPrototypeOf(target));
}

@@ -5,3 +5,3 @@ {

"description": "Autoloads JS Files",
"version": "2.0.0",
"version": "2.0.1",
"homepage": "http://aikar.co",

@@ -8,0 +8,0 @@ "main": "autoloader.js",

## About
Autoloads JS files based on name when the class is needed.
This is designed to be used with Joose classes in the "Foo.Bar.Baz" format

@@ -8,3 +7,3 @@ This module removes the needs of using require() all over your files. Simply

ie lib/Foo/Bar/Baz.js when you load 'lib/' makes Foo.Bar.Baz
ie lib/Foo/Bar/Baz.js when you load 'lib/' makes Foo_Bar_Baz
require('./lib/Foo/Bar/Baz.js') automatically and return the value.

@@ -64,2 +63,8 @@

You may optionally pass an object as the 2nd parameter and the autoloader will bind to that object instead of global.
So consider:
global.App = require('autoloader')(__dirname + '/lib', require('./myapp'));
new App.Foo_Bar();
## Custom Loaders

@@ -66,0 +71,0 @@ If you pass a function as the 1st argument, autoloader will execute that instead of

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