Stopwatch timer object
npm install @matrixai/timerThis library provides a reified Timer replacing the imperative setTimeout in JS. This is useful for keeping track of elapsed time and calculating how time is left. Think of this as a "Stopwatch".
This does not use Date.now(), it uses Performance API.
``sh`
npm install --save @matrixai/timer
`ts
import { Timer } from '@matrixai/timer';
const t1 = new Timer(() => 2, 10);
const result = await t1;
`
Run nix develop, and once you're inside, you can use:
`sh`install (or reinstall packages from package.json)
npm installbuild the dist
npm run buildrun the repl (this allows you to import from ./src)
npm run tsxrun the tests
npm run testlint the source code
npm run lintautomatically fix the source
npm run lintfix
`sh`
npm run docs
See the docs at: https://matrixai.github.io/js-timer/
Publishing is handled automatically by the staging pipeline.
Prerelease:
`sh`npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
Release:
`sh`npm login
npm version patch # major/minor/patch
git push --follow-tags
Manually:
`sh``npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags