{"_id":"safe-timers","_rev":"1213200","name":"safe-timers","description":"Timers with near-infinite duration support","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"almirkadric","email":"github@almirkadric.com"},{"name":"notawizard","email":"npm@wizcorp.jp"},{"name":"ronkorving","email":"ron@ronkorving.nl"},{"name":"stelcheck","email":"mtrudel@wizcorp.jp"}],"time":{"modified":"2021-10-13T05:46:42.000Z","created":"2016-06-15T09:38:08.394Z","1.1.0":"2017-10-24T03:22:04.609Z","1.0.2":"2017-10-23T05:36:02.051Z","1.0.1":"2016-06-15T10:04:47.935Z","1.0.0":"2016-06-15T09:38:08.394Z"},"users":{},"author":{"name":"Ron Korving","email":"rkorving@wizcorp.jp"},"repository":{"type":"git","url":"git+https://github.com/Wizcorp/safe-timers.git"},"versions":{"1.1.0":{"name":"safe-timers","version":"1.1.0","description":"Timers with near-infinite duration support","main":"index.js","files":["index.js"],"directories":{"test":"test"},"scripts":{"test":"tape test/*.js | tap-spec","cov":"nyc npm test && nyc report --reporter=lcov"},"repository":{"type":"git","url":"git+https://github.com/Wizcorp/safe-timers.git"},"keywords":["setTimeout","setInterval","timer","timeout","interval","timers","timeouts","intervals"],"author":{"name":"Ron Korving","email":"rkorving@wizcorp.jp"},"license":"MIT","bugs":{"url":"https://github.com/Wizcorp/safe-timers/issues"},"homepage":"https://github.com/Wizcorp/safe-timers#readme","devDependencies":{"codecov":"^3.0.0","nyc":"^11.2.1","pre-commit":"^1.2.2","tap-spec":"^4.1.1","tape":"^4.5.1"},"gitHead":"66d7dada4ffb63d8d60a0249709f9e898dcd08fd","_id":"safe-timers@1.1.0","_shasum":"c58ae8325db8d3b067322f0a4ef3a0cad67aad83","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.1","_npmUser":{"name":"ronkorving","email":"ron@ronkorving.nl"},"dist":{"shasum":"c58ae8325db8d3b067322f0a4ef3a0cad67aad83","size":3057,"noattachment":false,"key":"/safe-timers/-/safe-timers-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-timers/download/safe-timers-1.1.0.tgz"},"maintainers":[{"name":"almirkadric","email":"github@almirkadric.com"},{"name":"notawizard","email":"npm@wizcorp.jp"},{"name":"ronkorving","email":"ron@ronkorving.nl"},{"name":"stelcheck","email":"mtrudel@wizcorp.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-timers-1.1.0.tgz_1508815324541_0.32135681086219847"},"publish_time":1508815324609,"_hasShrinkwrap":false,"_cnpm_publish_time":1508815324609},"1.0.2":{"name":"safe-timers","version":"1.0.2","description":"Timers with near-infinite duration support","main":"index.js","directories":{"test":"test"},"scripts":{"test":"tape test/*.js | tap-spec"},"repository":{"type":"git","url":"git+https://github.com/Wizcorp/safe-timers.git"},"keywords":["setTimeout","setInterval","timer","interval","timers","intervals"],"author":{"name":"Ron Korving","email":"rkorving@wizcorp.jp"},"license":"MIT","bugs":{"url":"https://github.com/Wizcorp/safe-timers/issues"},"homepage":"https://github.com/Wizcorp/safe-timers#readme","devDependencies":{"tap-spec":"^4.1.1","tape":"^4.5.1"},"gitHead":"7420305ecddeb35f7ae2dbeae2bcd9ec2d92d275","_id":"safe-timers@1.0.2","_shasum":"b186a0b8fb2067538958f8cd714623bf0294557e","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.1","_npmUser":{"name":"ronkorving","email":"ron@ronkorving.nl"},"dist":{"shasum":"b186a0b8fb2067538958f8cd714623bf0294557e","size":4139,"noattachment":false,"key":"/safe-timers/-/safe-timers-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-timers/download/safe-timers-1.0.2.tgz"},"maintainers":[{"name":"almirkadric","email":"github@almirkadric.com"},{"name":"notawizard","email":"npm@wizcorp.jp"},{"name":"ronkorving","email":"ron@ronkorving.nl"},{"name":"stelcheck","email":"mtrudel@wizcorp.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-timers-1.0.2.tgz_1508736961969_0.9618677806574851"},"publish_time":1508736962051,"_hasShrinkwrap":false,"_cnpm_publish_time":1508736962051},"1.0.1":{"name":"safe-timers","version":"1.0.1","description":"Timers with near-infinite duration support","main":"index.js","directories":{"test":"test"},"scripts":{"test":"tape test/*.js | tap-spec"},"repository":{"type":"git","url":"git+https://github.com/Wizcorp/safe-timers.git"},"keywords":["setTimeout","setInterval","timer","interval","timers","intervals"],"author":{"name":"Ron Korving","email":"rkorving@wizcorp.jp"},"license":"MIT","bugs":{"url":"https://github.com/Wizcorp/safe-timers/issues"},"homepage":"https://github.com/Wizcorp/safe-timers#readme","devDependencies":{"tap-spec":"^4.1.1","tape":"^4.5.1"},"gitHead":"7972f81a1b3d69eb89f33f7c61a441de0765c7c3","_id":"safe-timers@1.0.1","_shasum":"e34549f3f77de522efd5d6ef7f2974688979b0c8","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"ronkorving","email":"ron@ronkorving.nl"},"maintainers":[{"name":"almirkadric","email":"github@almirkadric.com"},{"name":"notawizard","email":"npm@wizcorp.jp"},{"name":"ronkorving","email":"ron@ronkorving.nl"},{"name":"stelcheck","email":"mtrudel@wizcorp.jp"}],"dist":{"shasum":"e34549f3f77de522efd5d6ef7f2974688979b0c8","size":3652,"noattachment":false,"key":"/safe-timers/-/safe-timers-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-timers/download/safe-timers-1.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/safe-timers-1.0.1.tgz_1465985087246_0.6410285013262182"},"publish_time":1465985087935,"_cnpm_publish_time":1465985087935,"_hasShrinkwrap":false},"1.0.0":{"name":"safe-timers","version":"1.0.0","description":"Timers with near-infinite duration support","main":"index.js","directories":{"test":"test"},"scripts":{"test":"tape test/*.js | tap-spec"},"repository":{"type":"git","url":"git+https://github.com/wizcorp/safe-timers.git"},"keywords":["setTimeout","setInterval","timer","interval","timers","intervals"],"author":{"name":"Ron Korving","email":"rkorving@wizcorp.jp"},"license":"MIT","bugs":{"url":"https://github.com/wizcorp/safe-timers/issues"},"homepage":"https://github.com/wizcorp/safe-timers#readme","devDependencies":{"tap-spec":"^4.1.1","tape":"^4.5.1"},"gitHead":"df6a66f5b49faabd05ddf083d189aed2a7d062c4","_id":"safe-timers@1.0.0","_shasum":"cf245a4a0f78d44b8e171e0ee504d6f7859bdc10","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"ronkorving","email":"ron@ronkorving.nl"},"maintainers":[{"name":"almirkadric","email":"github@almirkadric.com"},{"name":"notawizard","email":"npm@wizcorp.jp"},{"name":"ronkorving","email":"ron@ronkorving.nl"},{"name":"stelcheck","email":"mtrudel@wizcorp.jp"}],"dist":{"shasum":"cf245a4a0f78d44b8e171e0ee504d6f7859bdc10","size":3647,"noattachment":false,"key":"/safe-timers/-/safe-timers-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/safe-timers/download/safe-timers-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/safe-timers-1.0.0.tgz_1465983487707_0.867066596634686"},"publish_time":1465983488394,"_cnpm_publish_time":1465983488394,"_hasShrinkwrap":false}},"readme":"# Safe Timers\n\n## About\n\nQ: What's this all about? Aren't JavaScript timers safe?\nA: Long story short: they're a bit broken. This module unbreaks them.\n\nWhether it's by spec, or by accident, **all** major browsers and Node.js limit the interval a setTimeout can accept to a\n32 bit signed integer. What that means in essence is that a timeout can never last longer than 24.85 days. Long enough,\nright?\n\nThe problem is that:\n\n- In human (non-binary) terms, this is a really arbitrary number.\n- In long running processes (whether on the web, or in Node), you are limited.\n- If the interval you provide overflows this limit, **the timer fires immediately**!\n\nAll the arguments about \"you shouldn't need intervals this big anyway\" go out the window the moment you provide a big\none and instead of never firing, it fires immediately. This is a real problem. And so here we are, Safe Timers solves\nthis for you.\n\nDoes that mean you should forego the browser native setTimeout and setInterval altogether? Absolutely not. Most of the\ntime, we pass constant short intervals, in which case Safe Timers are overkill. But when your interval comes from some\nvariable that depends on state or user input, using Safe Timers is a good idea.\n\n## API\n\n**Timer setTimeout(Function callback, number interval, mixed arg1, mixed arg2, ...)**\n\nCalls `callback` after at least `interval` milliseconds have passed. All arguments passed after the `interval` will be\npassed to the callback once it gets invoked. Returns a `Timer` instance.\n\n```js\nconst setTimeout = require('safe-timers').setTimeout;\n\nsetTimeout(function (msg) {\n  console.log(msg);\n}, 5000, 'Hello world');\n```\n\n**Timer setTimeoutAt(Function callback, number timestamp, mixed arg1, mixed arg2, ...)**\n\nCalls `callback` when our clock reaches the given `timestamp` (in milliseconds). All arguments passed after the\n`interval` will be passed to the callback once it gets invoked. Returns a `Timer` instance.\n\n```js\nconst setTimeoutAt = require('safe-timers').setTimeoutAt;\n\nsetTimeoutAt(function (msg) {\n  console.log(msg);\n}, Date.now() + 5000, 'Hello world');\n```\n\n**Interval setInterval(Function callback, number interval, mixed arg1, mixed arg2, ...)**\n\nCalls `callback` after at least every `interval` milliseconds. All arguments passed after the `interval` will be passed\nto the callback when it gets invoked. Returns an `Interval` instance.\n\n```js\nconst setInterval = require('safe-timers').setInterval;\n\nsetInterval(function (msg) {\n  console.log(msg);\n}, 5000, 'Hello world');\n```\n\n**timer.clear() / interval.clear()**\n\nThe response from `safetimers.setTimeout[At]` and `safetimers.setInterval` are `Timer` and `Interval` objects\nrespectively. To cancel a timer or interval, you can call `clear` on it.\n\n```js\nconst setTimeout = require('safe-timers').setTimeout;\n\nconst timer = setTimeout(function (msg) {\n  console.log(msg); // this will never show\n}, 5000, 'Hello world');\n\ntimer.clear();\n```\n","_attachments":{},"homepage":"https://github.com/Wizcorp/safe-timers#readme","bugs":{"url":"https://github.com/Wizcorp/safe-timers/issues"},"license":"MIT"}