{"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.2","gitHead":"6ea8bab38d13a6afbe456714136c9adfa0590f96","bugs":{"url":"https://github.com/gajus/approximate-now/issues"},"homepage":"https://github.com/gajus/approximate-now#readme","_id":"approximate-now@1.0.2","_nodeVersion":"15.5.1","_npmVersion":"6.14.10","dist":{"integrity":"sha512-r0PAP7S9VaWCQEZT+loOnZRM0gj30L/S5oB9SKTuMXGhQLycvnh9gKFhu2Kq89dJkjAWf7m8PH4xy7OamBElwQ==","shasum":"f72310c2aae8625d5f1ed8031005ce8ae16a0000","tarball":"http://registry-npm.ywwl.com/approximate-now/download/approximate-now-1.0.2.tgz","fileCount":6,"unpackedSize":6892,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/eGtCRA9TVsSAnZWagAAPfMP/3DnYNaiRoiZiRB8xlI/\ngu++R1G7DgBpBuXP+VeFLwoescr55SI5DDK9EdA5/xjy+fCLnhzfNIjXUsNh\ne3dn8UHF+Fvz+UYucRrLo8kIyJxwcdDwLR+8lDZqVHWWyTYYYs3kUWGDEn5L\nSWv0mvuov7htdpYUmnNBejlV0P5kDvyJUdgNsXdTzoBLxm1KQDMpsqEs7gO/\nSedaQvHIJIN/wj0hRqCVYfufOrlmpIZ9wm0rR0xBgzNA1r94sK8lfs1mgNlM\n2V23oUwjmxxpzhIejdFaChc5XEy7yLu4W7pShuuc6xMe0ugfXwi2ziYiHZi+\nWZ/JFJgSSE82s8Kp9Arrd+SHrezC33vUnglEwjx+eCvmZYWIqz0lfMtC2Bwy\nXfbXL3nAlmoo31sbDEQ6iaCoVTUctqL0keztvIoJEpOiNbMLRYWHu1kc33Bj\n8D+V9UAqhCb0keG6m3b2Rhkbu08NtdXl0RVBH1aC/dxfuFP/OZ2v5XgYIa7k\nCA9Hx0l7SaREn9CElMqR1PjaE/BCGUS1H0jmqE96SA0vf+7rycBfYwWD1MiG\nw1+K0B37zKeuccBnJJl2u+3zOGYWOqv8uKQerwH3ocMTlbljI2+2jY+pZEpi\nmNWfQRH9PVtiXZJyh1nH41m7v0JOBShKy2MlH7fwYDudnDkOGO2N6nkmqj0d\nQtSD\r\n=alk3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCLW4HqUq2+lU74WL5NdaUjwinQGN5zUJjKcuDE5z3VewIhAKO2YdxuPVWjkG27oSsR70SwjpZJRRjOhhRVncmK02sC"}],"size":3141,"noattachment":false,"key":"/approximate-now/-/approximate-now-1.0.2.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.2_1610473900739_0.8289720405846814"},"_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":1610473900898,"_cnpm_publish_time":1610473900898,"dist-tags":{"latest":"1.0.2"}}