Socket
Socket
Sign inDemoInstall

nano-time

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nano-time

Current Time in Nanoseconds


Version published
Weekly downloads
1.4M
increased by1.47%
Maintainers
1
Install size
174 kB
Created
Weekly downloads
 

Package description

What is nano-time?

The nano-time npm package provides high-resolution time stamps based on the Unix epoch. It allows for the generation of nanosecond precision time stamps, which are particularly useful in performance measurement, logging, and other scenarios where more granularity than milliseconds is required.

What are nano-time's main functionalities?

Getting the current time in nanoseconds

This feature allows you to get the current time in nanoseconds since the Unix epoch. It's useful for high-precision time measurements.

const nanoTime = require('nano-time');
let currentTime = nanoTime.now();

Converting a Date object to nanoseconds

This feature converts a JavaScript Date object to a nanosecond precision timestamp. It's useful for when you need to work with both standard JavaScript dates and high-resolution timestamps.

const nanoTime = require('nano-time');
let date = new Date();
let nanoSeconds = nanoTime.fromDate(date);

Other packages similar to nano-time

Readme

Source

NanoTime

Gets the current time in nanoseconds or microseconds.

In node.js you can get high resolution time with process.hrtime(), but it is from an unknown relative time, not epoch. So this library helps that by calculating the difference and adding it to the current time.

Usage

Since javascript can't hold a nanosecond as an INT safely (Number.MAX_SAFE_INTEGER), we return a string instead.

const now = require('nano-time');

now(); // '1476742925219947761' (returns a string)
now.micro(); // '1476742921398373'
now.microseconds(); // alias for now.micro();

Keywords

FAQs

Last updated on 17 Oct 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc