JS Bin's loop protection implementation as a reusable library.
This code protects use cases where user code includes an infinite loop using a
With loop protection in place, it means that a user can enter the code as follows on JS Bin, and the final
console.log will still work.
The code is transformed from this:
let i = 0;var _LP = Date;while trueif Date - _LP > 100break;;console;
The loop protection is a babel transform, so can be used on the server or in the client.
The previous implementation used an injected library to handle tracking loops - this version does not.
Example (client) implementation