Skip to content

Commit

Permalink
docs: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky committed Apr 27, 2020
1 parent 1a7b0dc commit ae0fa05
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ browser support for `process.hrtime()`.
# Install
`npm i browser-hrtime`
# Usage
## NodeJS
```
const hrtime = require('browser-hrtime');
const { hrtime } = require('browser-hrtime');
const NS_PER_SEC = 1e9;
const time = hrtime();
Expand All @@ -25,4 +26,20 @@ process.hrtime = require('browser-hrtime');
const someModule = require('module-that-uses-hrtime');
```

## EMS & Typescript
```
import hrtime from 'browser-hrtime';
const NS_PER_SEC = 1e9;
const time = hrtime();
// [ 1800216, 25 ]
setTimeout(() => {
const diff = hrtime(time);
// [ 1, 552 ]
console.log(`Benchmark took ${diff[0] * NS_PER_SEC + diff[1]} nanoseconds`);
// Benchmark took 1000000552 nanoseconds
}, 1000);
```
see [NodeJS documenation](https://nodejs.org/api/process.html#process_process_hrtime_time) for more examples

0 comments on commit ae0fa05

Please sign in to comment.