https://github.com/avoidwork/precise
Nanosecond timer for node.js
https://github.com/avoidwork/precise
Last synced: 10 months ago
JSON representation
Nanosecond timer for node.js
- Host: GitHub
- URL: https://github.com/avoidwork/precise
- Owner: avoidwork
- License: bsd-3-clause
- Created: 2014-04-25T10:27:09.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2025-04-07T18:23:00.000Z (10 months ago)
- Last Synced: 2025-04-12T19:08:07.053Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 789 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# precise
Nanosecond timer for node.js
## Using the factory
```javascript
import {precise} from "precise";
const timer = precise().start();
setTimeout(() => console.log(timer.stop().diff()), 1000);
```
## Using the Class
```javascript
import {Precise} from "precise";
const timer = new Precise().start();
setTimeout(() => console.log(timer.stop().diff()), 1000);
```
```javascript
import {Precise} from "precise";
class MyTimer extends Precise {}
```
## Testing
Precise has 100% code coverage with its tests.
```console
-------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
precise.cjs | 100 | 100 | 100 | 100 |
-------------|---------|----------|---------|---------|-------------------
```
## API
### diff(ms = false)
Returns the time delta between `start()` & `stop()`; setting optional parameter to `true` will return the delta as milliseconds
### reset()
Reset a timer
### start()
Starts a timer
### stop()
Stops a timer
## License
Copyright (c) 2023 Jason Mulligan
Licensed under the BSD-3 license