unitimer
Advanced tools
Comparing version 3.8.0 to 3.8.1
@@ -1,6 +0,11 @@ | ||
function now() { | ||
var t = process.hrtime(); | ||
return t[0] * 1000 + t[1] / 1000000; | ||
var nowNode = require('./now-node'); | ||
var nowBrowser = require('./now-browser'); | ||
var now = void 0; | ||
if (process && process.hrtime) { | ||
now = nowNode; | ||
} else { | ||
now = nowBrowser; | ||
} | ||
module.exports = now; |
{ | ||
"name": "unitimer", | ||
"version": "3.8.0", | ||
"version": "3.8.1", | ||
"description": "Universal timer (Node.js and browser)", | ||
"main": "./lib/index.js", | ||
"browser": { | ||
"./lib/now.js": "./lib/browser-now.js" | ||
}, | ||
"scripts": { | ||
@@ -10,0 +7,0 @@ "build": "babel src/ -d lib/", |
@@ -8,23 +8,27 @@ # unitimer | ||
</a> | ||
<a href="https://standardjs.com"> | ||
<img | ||
src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square" | ||
alt="Standard" /> | ||
</a> | ||
<a href="https://npmcdn.com/unitimer/dist/unitimer.min.js"> | ||
<img | ||
src="https://badge-size.herokuapp.com/WebSeed/unitimer/master/dist/unitimer.min.js.svg?compression=gzip" | ||
alt="File size" /> | ||
</a> | ||
Universal timer (Node.js and browser). Super simple i.e. | ||
Universal timer for Node.js and browser: | ||
```js | ||
var createTimer = require('unitimer') | ||
var timer = createTimer().start() | ||
setTimeout(function () { | ||
var ms = timer.stop() // ms ~= 1000.0 | ||
import createTimer from 'unitimer' | ||
const timer = createTimer().start() | ||
setTimeout(() => { | ||
const ms = timer.stop() // ms ~= 1000.0 | ||
timer.log() // output to console | ||
}, 1000) | ||
``` | ||
Multiple timers: | ||
```js | ||
import createTimer from 'unitimer' | ||
const [a, b] = createTimer(['a', 'b']) | ||
a.start() | ||
b.start() | ||
// ... | ||
``` | ||
## API | ||
@@ -31,0 +35,0 @@ |
@@ -1,6 +0,11 @@ | ||
function now() { | ||
const t = process.hrtime() | ||
return (t[0] * 1000) + (t[1] / 1000000) | ||
const nowNode = require('./now-node') | ||
const nowBrowser = require('./now-browser') | ||
let now | ||
if (process && process.hrtime) { | ||
now = nowNode | ||
} else { | ||
now = nowBrowser | ||
} | ||
module.exports = now |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
177762
18
534
80
0