Initial work on new framework
This commit is contained in:
21
client/new-framework/add-loop-protect.js
Normal file
21
client/new-framework/add-loop-protect.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import loopProtect from 'loopProtect';
|
||||
|
||||
loopProtect.hit = function hit(line) {
|
||||
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.';
|
||||
console.error(err);
|
||||
};
|
||||
|
||||
// Observable[Observable[File]]::addLoopProtect() => Observable[String]
|
||||
export default function addLoopProtect() {
|
||||
const source = this;
|
||||
return source.map(files$ => files$.map(file => {
|
||||
if (file.extname === 'js') {
|
||||
file.contents = loopProtect(file.contents);
|
||||
}
|
||||
return file;
|
||||
}));
|
||||
}
|
Reference in New Issue
Block a user