mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Removed proprietary require event system
This commit is contained in:
parent
b7a6f81ef0
commit
9f3da67cf2
@ -10,19 +10,19 @@
|
||||
scope = exports;
|
||||
}
|
||||
else {
|
||||
if (require.exists("./logging")){
|
||||
scope = require("./logging");
|
||||
}
|
||||
else {
|
||||
scope = require.register("./logging", {});
|
||||
}
|
||||
scope = require.register("./logging", {});
|
||||
}
|
||||
|
||||
let settings = false;
|
||||
require.on("./settings", function(realSettings){
|
||||
settings = realSettings;
|
||||
settings.loaded.then(scope.clearQueue);
|
||||
});
|
||||
scope.setSettings = function(realSettings){
|
||||
if (!settings){
|
||||
settings = realSettings;
|
||||
settings.loaded.then(scope.clearQueue);
|
||||
}
|
||||
else {
|
||||
warning("logging: Settings can only be set once.");
|
||||
}
|
||||
};
|
||||
|
||||
var prefix = "";
|
||||
|
||||
@ -108,7 +108,5 @@
|
||||
scope.notice = notice;
|
||||
scope.verbose = verbose;
|
||||
|
||||
require.emit("./logging");
|
||||
|
||||
metaLog("logging available");
|
||||
}());
|
@ -38,28 +38,5 @@ const require = function(){
|
||||
return scope.hasOwnProperty(getScopeName(module));
|
||||
};
|
||||
|
||||
var events = {};
|
||||
require.on = function(module, callback){
|
||||
var scopeName = getScopeName(module);
|
||||
if (scope.hasOwnProperty(scopeName)){
|
||||
callback(scope[scopeName]);
|
||||
}
|
||||
else {
|
||||
if (!events.hasOwnProperty(scopeName)){
|
||||
events[scopeName] = [];
|
||||
}
|
||||
events[scopeName].push(callback);
|
||||
}
|
||||
};
|
||||
require.emit = function(module){
|
||||
var scopeName = getScopeName(module);
|
||||
if (events[scopeName]){
|
||||
events[scopeName].forEach(function(callback){
|
||||
callback(scope[scopeName]);
|
||||
});
|
||||
events[scopeName] = [];
|
||||
}
|
||||
};
|
||||
|
||||
return require;
|
||||
}();
|
@ -466,5 +466,5 @@
|
||||
};
|
||||
Object.seal(scope);
|
||||
|
||||
require.emit("./settings");
|
||||
logging.setSettings(scope);
|
||||
}(require));
|
Loading…
x
Reference in New Issue
Block a user