precision-timestamp

0.2.0 • Public • Published

precision-timestamp

Gets a precise (to the microsecond) UNIX timestamp.

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.

/precision-timestamp/

    Package Sidebar

    Install

    npm i precision-timestamp

    Weekly Downloads

    5

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    2.83 kB

    Total Files

    3

    Last publish

    Collaborators

    • qix