{"author":{"name":"Gajus Kuizinas","email":"gajus@gajus.com","url":"http://gajus.com"},"ava":{"extensions":["ts"],"files":["test/approximate-now/**/*"],"require":["ts-node/register/transpile-only"]},"description":"Approximate (fast) current UNIX time.","devDependencies":{"@istanbuljs/nyc-config-typescript":"^1.0.1","ava":"^3.14.0","benchmark":"^2.1.4","coveralls":"^3.1.0","del-cli":"^3.0.1","delay":"^4.4.0","eslint":"^7.16.0","eslint-config-canonical":"^24.4.4","husky":"^4.3.6","nyc":"^15.1.0","semantic-release":"^17.3.0","ts-node":"^9.1.1","typescript":"^4.1.3"},"engines":{"node":">=10.0"},"husky":{"hooks":{"pre-commit":"npm run lint && npm run test && npm run build"}},"keywords":["log","logger","json"],"license":"BSD-3-Clause","main":"./dist/approximateNow.js","name":"approximate-now","repository":{"type":"git","url":"git+ssh://git@github.com/gajus/approximate-now.git"},"scripts":{"benchmark":"ROARR_LOG=true ts-node --transpile-only test/benchmark.ts","build":"del-cli ./dist && tsc","create-readme":"gitdown ./.README/README.md --output-file ./README.md","dev":"tsc --watch","lint":"eslint ./src ./test && tsc --noEmit","test":"NODE_ENV=test ava --serial --verbose"},"typings":"./dist/approximateNow.d.ts","version":"1.0.0","gitHead":"5dcaff55ea0f3426a049c20c393ea6c9ca8d027e","bugs":{"url":"https://github.com/gajus/approximate-now/issues"},"homepage":"https://github.com/gajus/approximate-now#readme","_id":"approximate-now@1.0.0","_nodeVersion":"15.5.0","_npmVersion":"6.14.10","dist":{"integrity":"sha512-n8SkhunMoE1jYuC70sAof82NvFXhxHRSxQxk2Zl2+SpFraLE9rKkSMi+KumnXXukhPWe5iUa6cO4535ePtovQQ==","shasum":"00f80e42309f2b5518402daba8595c4206e1bf73","tarball":"http://registry-npm.ywwl.com/approximate-now/download/approximate-now-1.0.0.tgz","fileCount":6,"unpackedSize":6819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf5mzCCRA9TVsSAnZWagAAUDcP/0mxEe70OZ9SFwO/rPHk\nKYUDAiv7Om6K8yut0nBDXeqr7d7BliiMufAUoKSYmigwQbusSJlehcIcPn56\n/k3FvIMVQMxXyLmMUmOKDcCss44BZDYG/8ha6J3xL8q8Pn4Pie0ulaF0lMDS\nUWvrDUfBOPJOzKxiCr7CVFMV0FI095ccCyJndok1h6yVBjghozGaLGz1t3YL\n29oQAiN65eFpsFpIM5nIXVEWvQA0HPeqfR3yQyqMN2t96eTkfI3rOuWF2cS6\nug21MC7TCt3Zb9rR8OaV81haZ0gvK4JIRf8fzDcRkUttKyiraQlFLlEGf9kW\nTtQr00Af0x0+9skVr6Jm5RIrX3eW05eAa85ySx7nx0Msxc/gi8qAkp48XcGY\nMCSwZsNFXJFuGVoBDXHzorr3wSrjsuHa+ge+muTamsq/a507nm/0n67kdZYv\nbhGDfZlcJO2KJg+h3Bmr21uG4oddRjF2o2P7MWLu2iqYrVnwMcyBOUtD+Ilh\n8R7YNTwKuBtpCYO8ps48Cm+Jgs0LMzMXtXD1sN4PuAkG5f5yfo86eL+HK2k9\n0tMKPIbfYmnpYBIFARTeqfTgmdp3iS1No6AA+mQPD2SndLauv2mWFtGFTnQJ\nieBgUYIGWKaiw0pkU2oVCyq5eEw3X7psXVqW39wTaQRkRspUeN/dbnBmzrOV\nHNAx\r\n=kdMe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCV7EpoaqVmkQ4F76tsS57h52ZT59VrzPixwPmEnyF2wgIhAIIBH/AC0TN/g+pQwgH6q/kIthqwyQPv1LG5+3sPGVaF"}],"size":3124,"noattachment":false,"key":"/approximate-now/-/approximate-now-1.0.0.tgz"},"_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"directories":{},"maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/approximate-now_1.0.0_1608936641882_0.8685191623913973"},"_hasShrinkwrap":false,"readme":"# approximate-now\n\n[![Travis build status](http://img.shields.io/travis/gajus/approximate-now/master.svg?style=flat-square)](https://travis-ci.org/gajus/approximate-now)\n[![Coveralls](https://img.shields.io/coveralls/gajus/approximate-now.svg?style=flat-square)](https://coveralls.io/github/gajus/approximate-now)\n[![NPM version](http://img.shields.io/npm/v/approximate-now.svg?style=flat-square)](https://www.npmjs.org/package/approximate-now)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)\n\nApproximate (fast) current UNIX time.\n\n## Motivation\n\nSometimes you don't care about the exact time the event took place, but rather need to know approximately when. If your use case is performance sensitive, then `Date.now()` might not be the best option because it has a [measurable impact](#benchmark) to the performance. `approximate-now` provides an approximate (to the error of 50ms) time without a performance penalty of `Date.now()`.\n\n## Usage\n\n```js\nimport {\n  approximateTime,\n} from 'approximate-now';\n\n// `approximateTime.now` value is updated by reference every 50ms.\nconsole.log(approximateTime.now);\n\n```\n\n## Sequence guarantee\n\nIt is guaranteed that two consequent attempts to retrieve time within the same 50ms time window will have unique values, i.e.\n\nAssuming that the current time is `0000000000000`, then:\n\n```js\napproximateTime.now; // 0000000000000\napproximateTime.now; // 0000000000001\napproximateTime.now; // 0000000000002\n\n```\n\nHowever, if `approximateTime.now` is accessed more than 50 times within the same 50ms time window, then the top-most value within that interval is returned repeatedly.\n\n```js\napproximateTime.now; // 0000000000000\napproximateTime.now; // 0000000000001\napproximateTime.now; // 0000000000002\n\n// approximateTime.now x 50\napproximateTime.now; // 0000000000050\napproximateTime.now; // 0000000000050\napproximateTime.now; // 0000000000050\n\n```\n\n## benchmark\n\n```\nDate.now()          x 19,900,411 ops/sec ±0.59% (93 runs sampled)\napproximateTime.now x 82,420,291 ops/sec ±0.83% (92 runs sampled)\n\n```\n\n## Use cases\n\nAny sort of time-sensitive operations when it is sufficient to retrieve an approximate timestamp, e.g. [`roarr`](https://github.com/gajus/roarr) logger uses `approximate-now` to record the time when a log message was produced.\n","publish_time":1608936642026,"_cnpm_publish_time":1608936642026,"dist-tags":{"latest":"1.0.2"}}