2015-11-30 22:27:39 +00:00
|
|
|
window.common = (function(global) {
|
|
|
|
const {
|
|
|
|
loopProtect,
|
|
|
|
common = { init: [] }
|
|
|
|
} = global;
|
|
|
|
|
|
|
|
loopProtect.hit = function hit(line) {
|
2015-12-19 22:30:56 +00:00
|
|
|
var err = 'Error: Exiting potential infinite loop at line ' +
|
|
|
|
line +
|
|
|
|
'. To disable loop protection, write: \n\\/\\/ noprotect\nas the first' +
|
|
|
|
'line. Beware that if you do have an infinite loop in your code' +
|
|
|
|
'this will crash your browser.';
|
2015-11-30 22:27:39 +00:00
|
|
|
console.error(err);
|
|
|
|
};
|
|
|
|
|
|
|
|
common.addLoopProtect = function addLoopProtect(code = '') {
|
|
|
|
return loopProtect(code);
|
|
|
|
};
|
|
|
|
|
|
|
|
return common;
|
|
|
|
})(window);
|