{"_id":"isotimer","name":"isotimer","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"isotimer","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/isotimer.git"},"description":"An isomorphic setImmediate/setInterval/setTimeout implementation.","license":"MIT","version":"1.0.0","type":"module","sideEffects":false,"main":"dist/node/index.js","types":"./dist/node/index.d.ts","exports":{"node":"./dist/node/index.js","default":"./dist/browser/index.js"},"scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["isomorphic","timer","timeout","interval","ref","unref"],"dependencies":{"immediato":"^1.1.0"},"devDependencies":{"@types/node":"^18.19.74","fava":"^0.3.4","tsex":"^4.0.2","typescript":"^5.7.3"},"_id":"isotimer@1.0.0","gitHead":"ac0326242a206985d347037c5fb2e43e12bab344","bugs":{"url":"https://github.com/fabiospampinato/isotimer/issues"},"homepage":"https://github.com/fabiospampinato/isotimer#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-1p1wborMl9fFbulXx9YBpIqFnfUn/2tN8Ne9g3GLMaiQAPmN/wLlpNOKCNT822div3Sq7LKkApZJ+6JipDUusQ==","shasum":"7f1bd8ff0b78119dac4fc2ceb0f21d74e6359a04","tarball":"https://registry.npmjs.org/isotimer/-/isotimer-1.0.0.tgz","fileCount":22,"unpackedSize":10953,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDGFt+VgrvN9piYF9aHnfeUJVtbSbakHTebVwcrN0ei/AiAegCLV1ZtUVd2vDQ+zDywoxx5h3nVX5I4tsR5+ht+8WQ=="}]},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/isotimer_1.0.0_1737933826863_0.34193366265090375"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-26T23:23:46.862Z","1.0.0":"2025-01-26T23:23:47.081Z","modified":"2025-01-26T23:23:47.353Z"},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"description":"An isomorphic setImmediate/setInterval/setTimeout implementation.","homepage":"https://github.com/fabiospampinato/isotimer#readme","keywords":["isomorphic","timer","timeout","interval","ref","unref"],"repository":{"type":"git","url":"git+https://github.com/fabiospampinato/isotimer.git"},"bugs":{"url":"https://github.com/fabiospampinato/isotimer/issues"},"license":"MIT","readme":"# IsoTimer\n\nAn isomorphic setImmediate/setInterval/setTimeout implementation.\n\nThis package exists to smooth out differences between Node and the browser, and to clean up some nonsense.\n\n## Features\n\n- This library works everywhere, with the same API.\n- setTimeout/setInterval don't return numbers under Node, this library eliminates that ugliness.\n- setImmediate is not natively available in the browser, this library polyfills it.\n- setImmediate will also return a number, for consistency.\n- .ref/.unref methods are not browser functions, this library exposes dedicated functions for them.\n- If the number of milliseconds is too high it would [overflow](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value), this library clamps it within the supported range.\n\n## Install\n\n```sh\nnpm install isotimer\n```\n\n## Usage\n\nVery similar APIs are available for setImmediate/setInterval/setTimeout.\n\nThe following code will just look at timeouts, for convenience, but they all work the same way basically.\n\n```ts\nimport {setImmediate, clearImmediate, refImmediate, unrefImmediate} from 'isotimer';\nimport {setInterval, clearInterval, refInterval, unrefInterval} from 'isotimer';\nimport {setTimeout, clearTimeout, refTimeout, unrefTimeout} from 'isotimer';\n\n// Let's schedule a timeout, which will always return us a number\n\nconst timeoutId = setTimeout ( () => {\n  console.log ( 'Hello' );\n}, 1000 );\n\n// Let's unref and ref it back again, just to show how to do it\n\nunrefTimeout ( timeoutId );\nrefTimeout ( timeoutId );\n\n// Let's clear it\n\nclearTimeout ( timeoutId );\n```\n\n## License\n\nMIT © Fabio Spampinato\n","readmeFilename":"readme.md"}