{"_id":"halting-problem","_rev":"10-611d5dd0f64d40e45a4120ec4bc598a5","name":"halting-problem","description":"Solves the halting problem :)","dist-tags":{"latest":"1.1.0"},"versions":{"0.0.1":{"name":"halting-problem","version":"0.0.1","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^0.11.0"},"devDependencies":{"testit":"^1.2.0"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"8ea40d87d8d50d61c908e998ae4222524450b29b","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem","_id":"halting-problem@0.0.1","_shasum":"bfde087dcb937e998e339fd8bc7f95d4b2d0b269","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"dist":{"shasum":"bfde087dcb937e998e339fd8bc7f95d4b2d0b269","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-0.0.1.tgz","integrity":"sha512-1fE/YQ+B/haK2KT3E+x7aUZbJzdgD21irTl1+3isPN0PJJrMUkLF8YeVPhiv9n/U+0nJSJxqjqwz+ht2A7rLSA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtJ9PofBSFD+ipRp1AqOv1cNRNdnjZM07SL9Rh2gmK9gIgGzTonY+RpTFN0hTBg4U8Q7Ykl3dEumYNWYacXd52u0s="}]},"directories":{}},"1.0.0":{"name":"halting-problem","version":"1.0.0","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^0.11.0"},"devDependencies":{"testit":"^2.0.2"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"4d36ab65ac94bf3e0ed2905692cfcb45adc1b16a","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem","_id":"halting-problem@1.0.0","_shasum":"370417c251732058b880113b2a05eaf430125a49","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"dist":{"shasum":"370417c251732058b880113b2a05eaf430125a49","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-1.0.0.tgz","integrity":"sha512-Y/vHf9M1vmbFgPvk/dqTelyNiV7piahPH8YogkK/JkAI3ASJgKWFg/BqUgedgdcxWJY6pUZ3W5ke7AVPxq50oQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG0oCe9EqC7zO7TLck4GIzdZ9M5VFLCS8YwOaNwt0rMBAiEAoMIJ/bwFBYqXtfUtccT0yfuE+z498N5IaBrMt4VZ1GM="}]},"directories":{}},"1.0.1":{"name":"halting-problem","version":"1.0.1","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^2.4.0"},"devDependencies":{"testit":"^2.0.2"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"0cda5b534090ad2752d1acfd50e87b4c8ba121cb","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem","_id":"halting-problem@1.0.1","_shasum":"661cc9e1526c12aeae79fdb0038f8ce958113e49","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"shasum":"661cc9e1526c12aeae79fdb0038f8ce958113e49","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-1.0.1.tgz","integrity":"sha512-fi4TFB6hsHazJBCtA2S7xK2jEm4kiaf3sfQIzjb9r8Rw0UlzTdXZ+qrUMvWfevGZkgZdtpm6lPeNAz/d7LC1sw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCA03r9RKSqCr8WTj00qds0JLlBBZulT1kdQeIn0n8f2wIhAJgHBOCRryt6w0gJE1D03NZEaI1MSw5fuutMzA4MXAC6"}]},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"directories":{}},"1.0.2":{"name":"halting-problem","version":"1.0.2","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^2.4.0"},"devDependencies":{"testit":"^2.0.2"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"6e8c509ff74056b10b54be0b3e8025a24166086a","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem","_id":"halting-problem@1.0.2","_shasum":"3efcdfaa4721f07dd54ea018d41a48c0e0f2329c","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"shasum":"3efcdfaa4721f07dd54ea018d41a48c0e0f2329c","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-1.0.2.tgz","integrity":"sha512-R6T4ix0eDer6z/8+sAoHjbywbcVo/BVZehOa+zEeuY24BM5WWaj/5VlqdQQTRWBxLJvrurInzH43f9R7ZZH5sQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZwlgxSQFF35SfNPb7P1lM2n+FfaUmXPS0YP6sbvjengIgf2bHYm2hRCFtl/amGFyo3NHT4cm1JIgtkbQ0MyJ2rBU="}]},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"directories":{}},"1.0.3":{"name":"halting-problem","version":"1.0.3","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^2.4.0"},"devDependencies":{"testit":"^2.0.2"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"67b2a56bb765d7ed67cc2b2618ed3b0723df78fb","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem#readme","_id":"halting-problem@1.0.3","_shasum":"bb56733e365287e62b227db9033270c7e8df532f","_from":".","_npmVersion":"3.9.5","_nodeVersion":"6.2.2","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"shasum":"bb56733e365287e62b227db9033270c7e8df532f","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-1.0.3.tgz","integrity":"sha512-KE6Aw257LG1/Fg2r+OAwuBYGdINjYPq0LJuFx51hUAFYG2abfVxKzuAariD7WryGAwO3QZuEzHOMtJJ9qPhVvA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGs+lY4fm71wNO4WIkKVh4gm6z72TNfDfxMp6yJBqhWBAiBTCnjV5RP/7NUYXzPgLJvqXaz2BDJXnY59tVSmLejDow=="}]},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/halting-problem-1.0.3.tgz_1469634485631_0.2558228066191077"},"directories":{}},"1.1.0":{"name":"halting-problem","version":"1.1.0","description":"Solves the halting problem :)","keywords":[],"dependencies":{"acorn":"^7.0.0","acorn-walk":"^7.0.0"},"devDependencies":{"testit":"^3.1.0"},"scripts":{"test":"node test"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"1c3a96827d08acea132ae7fb3ed39b910f5a69df","bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"homepage":"https://github.com/ForbesLindesay/halting-problem#readme","_id":"halting-problem@1.1.0","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-0S4+kuOwGFn7HhwjaVq32GTvP5/+ix9juZFmF4EZg3tj4cD3PIoUqi2DfjEhHotN57Xv7lgtBPhnLAdgYJ/PAw==","shasum":"54e03eaf18f9b5a4a7c038de12ef795fe03d151d","tarball":"https://registry.npmjs.org/halting-problem/-/halting-problem-1.1.0.tgz","fileCount":29,"unpackedSize":16860,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdbkevCRA9TVsSAnZWagAAJfAP/12juuXCaRIRg12RRb5w\nGd7j0HQv9MkMdep4Nn/YvkGN+cG2SBT4znuhLbTjReW4aAMpiD3bQ/boC4p9\n4+CIKGWwqmSqTQMc43V7oegsSg00rUIIaHldhdIVCjFZq+f3EeROERMADuqr\n03dA0fjjlB8fUqOe7LlySBMjhRPUAKOdEYdqxqT4houtU3ZNPoCi8TovbeFu\nZ68nzq/934xkJNwZGqLCMPX44RWnCeZQ5GJDnqWyHrxrQaoSP7603kmKTTJJ\nmpt9w2F2sIpaIOLumKgtdjpingM/35ytPlzV33D6I+fbvWRIuMOQClweEwsG\nePfAppZSyD+SpIwLW4WCENXXeU+pgqvcMcrMgetskMXtctQfp0q96+mjVkn9\n5mqwz5oQ+wEtua9GWPKvYCvd6o7bC29ptQKVwKUcKWX8yGUOMWfuH4OF+Wuz\n9Y96IGuFAOVLMQqcP8FXmAqf/wYkzNZ9gVJSlJPQdGBjMZXzZtvEcCWyimah\nVy2Vg1CZZOkpa16DuEGxsurXQFL7hW7HSx9PIXUMgQvSDWcZmdICIuhftfll\noNgK1bqXCZAjRnqYdVAw9eDyjdhe/QFSGIKd1nmTkXCHPZJE0oUHmi+GqMn/\njtIBZgrTcKZYsZiBQZ8bY7Dq2rZfHfC2o5DS84HT6HDbPOCgGNEyYB1mZJhc\nO118\r\n=I49+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkSiDQJIQwEzBLbYE++tjnXup3k3bHz1JQmkM48w8iQwIhAMnJI/+2CV9h6VCnEKsfse9DPxmkLbkgbTC8H8/aSqSB"}]},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/halting-problem_1.1.0_1567508399069_0.4468089437708578"},"_hasShrinkwrap":false}},"readme":"# halting-problem\n\nSolves the halting problem :)\n\nNot really, sadly that's impossible.  What this program does aim to do is pick up on some really simple examples of while loops and for loops that never terminate.  It's extremely limited and written with the aim of only ever picking up programs that definitely never halt.\n\n[![Build Status](https://img.shields.io/travis/ForbesLindesay/halting-problem/master.svg)](https://travis-ci.org/ForbesLindesay/halting-problem)\n[![Dependency Status](https://img.shields.io/david/ForbesLindesay/halting-problem.svg)](https://david-dm.org/ForbesLindesay/halting-problem)\n[![NPM version](https://img.shields.io/npm/v/halting-problem.svg)](https://www.npmjs.org/package/halting-problem)\n\n## Installation\n\n    npm install halting-problem\n\n## Usage\n\n```js\nvar halts = require('halting-problem');\ntry {\n  halts('while (true);');\n  console.log('It halts!');\n} catch (ex) {\n  console.log('oops, this program never halts');\n}\n```\n\nYou can also catch any addtional errors by using `halts.loopProtect`.\n\n```js\nvar halts = require('halting-problem');\ntry {\n  var src = halts.loopProtect('function foo() { return true; } while (foo());');\n  Function('haltingProblem', src)(halts);\n  console.log('It halts!');\n} catch (ex) {\n  console.log('oops, this program never halts');\n}\n```\n\n## API\n\n### halts(src)\n\nAssert that some code might halt.  This will catch **some** really obvious errors where a `while` loop never exits.  It throws an error if `src` is some JavaScript with an obvious infinite loop.\n\n### halts.loopProtect(src, protectFn)\n\nAdds calls to `protectFn` (which defaults to `haltingProblem.protect`) inside any places where an infinite loop might occur.\n\n### halts.protect(lineNumber)\n\nThrows an error if more than 1 second (or the specified timeout) has elapsed since the last time `halts.reset` was called.\n\n### halts.reset(timeout)\n\nResets the timeout (which defaults to 1 second).\n\n## Examples\n\nThis example halts:\n\n```js\nvar n = 10;\nwhile (n > 0) {\n  n--;\n}\n```\n\nIn this example, the user accidentally typed `m` instead of `n`, so this does not halt:\n\n```js\nvar n = 10;\n\nwhile (n > 0) {\n  m--;\n}\n```\n\n## Assumptions\n\nErring on the side of safety, this assumes that any function call results in any loops exiting.  For example, they could throw an error.\n\nErring on the side of pragmatism, this assumes that there is no dead-code.  e.g. it incorrectly states that the following code does not terminate:\n\n```js\nif (false) {\n  while (true) {}\n}\n```\n\nErring on the side of pragmatism, this assumes that no exceptions are thrown other than explicit `throw` statements.\n\nThrowing an error is treated as an acceptable way out of an infinite loop, even if there is no catch block to handle it.\n\n## Contributing\n\nIf you find any program that does eventually halt, but that this library throws an error for (but that doesn't break any of the assumptions) submit a pull request to add the script to `/test/halting` and I will do my best to fix it.\n\nThere are crazy numbers of programs that don't halt, but that this program won't catch.  Please **do not** submit an issue for such programs.  Also **do not** submit pull requests that just add a test case for such a program.  Please do add code to detect such cases though.  I'd love this to catch a more significant number of non-trivial cases where JavaScript will go into an infinite loop.\n\n## License\n\n  MIT\n","maintainers":[{"name":"forbeslindesay","email":"forbes@lindeay.co.uk"}],"time":{"modified":"2022-06-18T18:47:43.923Z","created":"2015-01-14T16:19:28.085Z","0.0.1":"2015-01-14T16:19:28.085Z","1.0.0":"2015-07-20T16:42:20.354Z","1.0.1":"2015-10-20T16:09:04.905Z","1.0.2":"2015-12-17T18:23:39.551Z","1.0.3":"2016-07-27T15:48:07.433Z","1.1.0":"2019-09-03T10:59:59.170Z"},"homepage":"https://github.com/ForbesLindesay/halting-problem#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/halting-problem.git"},"author":{"name":"ForbesLindesay"},"bugs":{"url":"https://github.com/ForbesLindesay/halting-problem/issues"},"license":"MIT","readmeFilename":"README.md"}