Socket
Socket
Sign inDemoInstall

nano-seconds

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-seconds


Version published
Maintainers
1
Install size
7.04 kB
Created

Readme

Source

nano-seconds

Get the nano seconds of now

Build Status Coverage Status npm Github Releases

Installation

$ npm install nano-seconds

API

now

Get the nano seconds of current time, it will return [seconds, nanos]

const nano = require('nano-seconds');
// [ 1488895112, 951851969 ]
console.info(nano.now());

toString

Format the nano seconds to string

  • ns if not set the param, it will be nano.now()
const nano = require('nano-seconds');
const ns = nano.now();
// [ 1488895353, 21164240 ]
console.info(ns);
// 1488895353021164240
console.info(nano.toString(ns));
// 1488895353025439741
console.info(nano.toString());

toISOString

Format the nano seconds to ISOString

  • ns if not set the param, it will be nano.now()
const nano = require('nano-seconds');
const ns = nano.now();
// 2017-06-22T14:37:42.506635539Z
console.info(nano.toISOString(ns));
// 2017-06-22T14:37:42.5069231Z
console.info(nano.toISOString());

fromISOString

Get the nano from ISOString

  • iosFormat ISO Date String
const nano = require('nano-seconds');
const arr = nano.fromISOString(str);
// [ 1505477440, 922020280 ]
console.info(arr);

difference

Get the difference of two nano seconds, ns2 - ns1

  • ns1 The start nano seconds

  • ns2 The end nano seconds, default is nano.now()

const ns = nano.now();
setTimeout(() => {
  const diff = nano.difference(ns);
  // 102661874
  console.info(diff);
}, 100);

License

MIT

Keywords

FAQs

Last updated on 15 Sep 2017

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc