
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
timer-stopwatch-dev
Advanced tools
A stopwatch and countdown clock module for node.js, maintained.
npm install timer-stopwatch
The Gist
new Stopwatch([countDownMS], [options]);
Basic timers
var Stopwatch = require("timer-stopwatch");
var timer = new Stopwatch(60000); // A new countdown timer with 60 seconds
var stopwatch = new Stopwatch(); // A new count up stopwatch. Starts at 0.
// Fires every 50ms by default. Change setting the 'refreshRateMS' options
timer.onTime(function(time) {
console.log(time.ms); // number of milliseconds past (or remaining);
console.log(time.seconds); // number of seconds past (or remaining);
});
// Fires when the timer is done
timer.onDone(function() {
console.log("Timer is complete");
});
// Fires when the timer is almost complete - default is 10 seconds remaining. Change with 'almostDoneMS' option
timer.onAlmostDone(function() {
console.log("Timer is almost complete");
});
//These methods are chainable
timer
.onTime(cb)
.onAlmostDone(cb)
.onDone(cb);
timer.start();
timer.stop();
timer.startstop(); // Toggles the running state
timer.reset(countDownMS); // optional countDownMS to reset countdown to that many milliseconds
timer.getState() // Return 0, 1 or 2 if the timer is respectively stopped, running or complete
timer.isStopped()
timer.isRunning()
timer.isComplete()
timer.ms; // Number of milliseconds on the clock
timer.seconds; // Number of seconds on the clock
var options = {
refreshRateMS: 10, // How often the clock should be updated
almostDoneMS: 10000 // When counting down - this event will fire with this many milliseconds remaining on the clock
};
var timer = new Stopwatch(60000, options);
Unit and Integration tests (requires dev dependencies)
npm test
@MickCrozier - The maintainer of the original package.
Other contributors:
MIT License
FAQs
A stopwatch and countdown timer for node, maintained.
The npm package timer-stopwatch-dev receives a total of 0 weekly downloads. As such, timer-stopwatch-dev popularity was classified as not popular.
We found that timer-stopwatch-dev demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.