Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

precise

avoidwork692BSD-3-Clause4.0.3TypeScript support: included

Precision timer for nanosecond differences

cpu, precise, precision, nanosecond, timer, time, difference, elasped

readme

precise

Nanosecond timer for node.js

Using the factory

import {precise} from "precise";
const timer = precise().start();
setTimeout(() => console.log(timer.stop().diff()), 1000);

Using the Class

import {Precise} from "precise";
const timer = new Precise().start();
setTimeout(() => console.log(timer.stop().diff()), 1000);
import {Precise} from "precise";
class MyTimer extends Precise {}

Testing

Precise has 100% code coverage with its tests.

-------------|---------|----------|---------|---------|-------------------
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

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

4.0.3

4.0.3

10 October 2023

  • Bump eslint from 8.50.0 to 8.51.0 #5
  • Bump rollup from 4.0.0 to 4.0.2 #4
  • Setting extension of main to .cjs for deprecated tooling 50059e8
  • Generating CHANGELOG.md 937ed5d
  • Testing with node.js 20 only (for now) d68e451

4.0.2

6 October 2023

  • Bump rollup from 3.29.4 to 4.0.0 #3
  • Updating casing on old constants 108382a
  • Generating CHANGELOG.md 06b226b

4.0.1

5 October 2023

  • Adding a conditional & assertion for a diff() case 147438b
  • Generating CHANGELOG.md bc45b96

4.0.0

4 October 2023

  • Adding reset(), adding CoPilot generated tests, updating README.md, version bump 786a756
  • Generating CHANGELOG.md 3b754c0
  • Adding a test for different values across time fa76a21

3.1.0

4 October 2023

  • Refactoring to utilize process.hrtime.bigint() dda0a39
  • Generating CHANGELOG.md 05199ba
  • Updating tests to use strictEqual() 9276f74

3.0.0

4 October 2023

  • Adding husky for precommit hook, fixing reference errors in tests, adding nyc to report test coverage, updating README.md, updating LICENSE, updating .gitignore, updating .npmignore, changing filenames in dist, version bump 39f6d37
  • Adding .github files d66de7a
  • Updating types with manual specification ba9ae0d

2.0.1

3 January 2023

  • Updating dependencies, lowering 'engine' constraint to 10.4.0 to align with bigint support for required vm c929505
  • Adding changelog 484fbcd
  • Updating CHANGELOG.md e1b0260

2.0.0

5 September 2022

  • ES Module #1
  • Rewriting as an ES module, updating tests, refactoring diff() to return milliseconds via optional parameter c5bc236

1.1.0

3 September 2015

  • Switching to an ES6 code base, implementing eslint & babel, fixing type mutation of started & stopped properties cfa6f1e
  • Reducing banner 60af287
  • Updating license 2f27604

1.0.1

25 April 2014

  • Removing dependencies from package.json (copy error) dae4f9c
  • Updating CHANGELOG 930721a

1.0.0

25 April 2014

  • Initial commit of code 42e6344
  • Initial commit 119f74a
  • Updating CHANGELOG & fixing package.json for travis-ci c74df13