Skip to content

An extraction of JS Bin's loop protection functionality.

License

Notifications You must be signed in to change notification settings

jsbin/loop-protect

Repository files navigation

loop-protect

JS Bin's loop protection implementation.

Note that this does not solve the halting problem but simply rewrites JavaScript (without an AST) wrapping loops with a conditional break.

Example

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.

while (true) {
  doSomething();
}

console.log('All finished');

Usage

The loop protection can be used both on the client side and server side. It supports AMD and CommonJS module loading, or can be included as vanilla JavaScript (as it is in JS Bin).

Methods

  • loopProtect.method
  • loopProtect.hit

License

http://jsbin.mit-license.org

Contributors