1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Removed proprietary require event system

This commit is contained in:
kkapsner 2019-04-07 23:22:56 +02:00
parent b7a6f81ef0
commit 9f3da67cf2
3 changed files with 11 additions and 36 deletions

View File

@ -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");
}());

View File

@ -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;
}();

View File

@ -466,5 +466,5 @@
};
Object.seal(scope);
require.emit("./settings");
logging.setSettings(scope);
}(require));