slowpoke

1.0.0 • Public • Published

slowpoke

slowpoke takes as input an AST generated by esprima and injects instrumentation code into all for, while and do loops encountered therein. Any loop which does not terminate after a user-specified timeout will throw an error.

Installation

Get it:

$ npm install slowpoke

Require it:

var slowpoke = require('slowpoke');

API

slowpoke(ast, options)

Modifies ast in-place such that all slow loops will throw an Error. ast must be an esprima-compatible AST structure.

Supported options:

  • timeout: number of milliseconds after which loop should abort. Default: 5000.

Limitations

slowpoke only catches slow for, while and do loops - it cannot detect unbounded recursion.

Because slowpoke uses Error throwing as its abort mechanism, code containing try/catch may not function as intended. Future work could modify catch blocks re-raise errors thrown by slow loops.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1
    • latest

Version History

Package Sidebar

Install

npm i slowpoke

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jaz303