0.2.0 • Published 5 years ago

precision-timestamp v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

precision-timestamp

Gets a precise (to the microsecond) UNIX timestamp.

npm.io

Installation

$ yarn add precision-timestamp

Usage

The returned function is a wrapper for either microtime (see Optimizing), process.hrtime() or Date.now().

const ptime = require('precision-timestamp');

console.log(ptime()); //-> [12184342834, 23942834]
                      //         ^           ^
                      //      seconds   microseconds

Optimizing

By default, most Node instances are going to default to the process.hrtime() implementation which should be entirely sufficient.

However, for a considerable performance improvement, install the microtime package alongside this one. This package will automatically detect and wrap it for you.

In the worst of cases where process.hrtime() and microtime are unavailable, the library defaults to Date.now(), which is only accurate to the nearest millisecond. In these situations, a process warning is emitted.

License

Copyright © 2017 The STDTRACE organization and ZEIT, Inc. Released under the MIT License.

0.2.0

5 years ago

0.1.0

6 years ago