infinite-loop-loader

A webpack loader to transform ∞ loops so that they throw

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
infinite-loop-loader
6141.0.93 years ago7 years agoMinified + gzip package size for infinite-loop-loader in KB

Readme

infinite-loop-loader
A webpack 2 loader to transform ∞ loops so that they throw
Before:
while(true){
  // your logic here
}

After:
var __ITER = 1000000000;
while(true) {
  if (__ITER <= 0) {
    throw new Error("Loop exceeded maximum allowed iterations");
  }
  // your logic here
  __ITER--;
}

Installation

npm install --save-dev infinite-loop-loader

Usage

Webpack config example
...
module: {
      rules: [
        {
          test: /\.js$/,
          use: [
            loader: 'infinite-loop-loader',
            options: {
              // iteration limit
              limit: 10000,
              // falafel -> acorn options
              opts {
                allowImportExportEverywhere: true
              }
            }
          ]
        }
      ],
      ...
    }
...