
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Returns the formatted, high-resolution time difference between `start` and `end` times.
Returns the formatted, high-resolution time difference between
start
andend
times.
(TOC generated by verb)
Install with npm
$ npm i time-diff --save
Uses pretty-time to format time diffs.
var Time = require('time-diff');
var time = new Time();
// create a start time for `foo`
time.start('foo');
// call `end` wherever the `foo` process ends
console.log(time.end('foo'));
//=> 12ms
Create an instance of Time
, optionally specifying the time scale to use and the number of decimal places to display.
Params
smallest
: the smallest time scale to showdigits
: the number of decimal places to display (digits
)Examples
(See pretty-time for all available formats)
Given the following:
var time = new Time();
time.start('foo');
Returns milliseconds by default
console.log(time.end('foo'));
//=> 13ms
Milliseconds to 3 decimal places
console.log(time.end('foo', 'ms', 3));
// or
console.log(time.end('foo', 3));
//=> 12.743ms
Seconds to 3 decimal places
console.log(time.end('foo', 's', 3));
//=> 0.013s
Seconds
console.log(time.end('foo', 's'));
//=> 0s
Microseconds
console.log(time.end('foo', 'μs'));
//=> 12ms 934μs
Microseconds to 2 decimal places
console.log(time.end('foo', 'μs', 2));
//=> 14ms 435.78μs
nano-seconds
console.log(time.end('foo', 'n', 3));
//=> 13ms 796μs 677ns
nano-seconds to 3 decimal places
console.log(time.end('foo', 'n', 3));
//=> 13ms 427μs 633.000ns
pretty-time: Easily format the time from node.js process.hrtime
. Works with timescales ranging from weeks to nanoseconds. | homepage
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb on December 20, 2015.
FAQs
Returns the formatted, high-resolution time difference between `start` and `end` times.
The npm package time-diff receives a total of 28,348 weekly downloads. As such, time-diff popularity was classified as popular.
We found that time-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.