Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/timestamp

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/timestamp

Timestamp getter wrapping (in order of preference) `process.hrtime.bigint()`, `performance.now()` or `Date.now()`

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by45.21%
Maintainers
0
Weekly downloads
 
Created
Source

@thi.ng/timestamp

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 200 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Timestamp getter wrapping (in order of preference) process.hrtime.bigint(), performance.now() or Date.now().

[!NOTE] The functions in this package have been extracted from @thi.ng/bench.

This package provides the following functions:

  • now() attempts to use high-res ES BigInt timestamps (in Node via process.hrtime.bigint()), or falls back to performance.now(), or lacking that, uses Date.now(). In all cases, returns a (possibly rounded) nanosec-scale timestamp, either as bigint or number.
  • timeDiff() function can be used to compute the difference between two such timestamp and return it as milliseconds.
  • asMillis() takes a duration (either a number or bigint) in nanosec-scale and converts it to a JS number in milliseconds

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/timestamp

ESM import:

import * as tim from "@thi.ng/timestamp";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/timestamp"></script>

JSDelivr documentation

For Node.js REPL:

const tim = await import("@thi.ng/timestamp");

Package sizes (brotli'd, pre-treeshake): ESM: 214 bytes

Dependencies

None

API

Generated API docs

TODO

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-timestamp,
  title = "@thi.ng/timestamp",
  author = "Karsten Schmidt",
  note = "https://thi.ng/timestamp",
  year = 2018
}

License

© 2018 - 2025 Karsten Schmidt // Apache License 2.0

Keywords

FAQs

Package last updated on 04 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc