npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

standsit-timer

v3.1.0

Published

Timer package that counts down from specified minutes & seconds

Downloads

18

Readme

Stand-Sit Timer

This is a simple JavaScript countdown timer module that allows you to create and manage countdown timers. It provides methods for setting the initial countdown time, starting, stopping, resetting, and retrieving the current countdown value.

Installation

Install the module using npm:

npm install standsit-timer

Usage

const Timer = require('my-countdown-timer').timer;

// Create a new timer with default values (0 hours, 25 minutes)
const myTimer = new Timer();

// Start the timer with a callback function to handle each second tick
myTimer.start((timeLeft) => {
  console.log(`Time left: ${timeLeft} seconds`);
}, () => {
  console.log('Timer has stopped');
});

// Stop the timer after 2000 milliseconds
setTimeout(() => {
  myTimer.stop();
}, 2000);

API

new Timer([inputHours], [inputMinutes])

Creates a new timer with the specified initial countdown values in hours and minutes. Default values are 0 hours and 25 minutes. If negative values are provided, an error will be logged, and the timer won't be created.

getCountDownFrom()

Returns the initial countdown value in seconds.

setCountDownFrom(inputHours, inputMinutes)

Sets a new countdown value based on the provided hours and minutes. If negative values are provided, the function returns an 'Invalid Input' message.

start(callback, stopCallback)

Starts the countdown timer. The callback function is called every second with the current time left. The stopCallback function is optional and is called when the timer reaches zero or is manually stopped.

The callback will be called with an argument array that contains minutes and seconds [minutes, seconds] ex: callback([minutes, seconds])

stop(callback)

Stops the countdown timer. The optional callback function is called after the timer is stopped. It's important to note that this callback is a different callback than the one passed to start function (stopCallback).

reset()

Resets the timer, setting the remaining time to 0. When start gets called again, it will start from the user inputted time.

License

This countdown timer module is released under the MIT License.


Pomodoro Timer

This Pomodoro Timer extends the functionality of the basic countdown timer, adding features specifically tailored for the Pomodoro technique. It allows for alternating between work and rest intervals, with customizable durations for each.

Usage

const Pomodoro = require('../timer/timer.js').pomodoro;

// Create a new Pomodoro timer with default work and rest durations (25 minutes work, 5 minutes rest)
const myPomodoro = new Pomodoro();

// Start the Pomodoro timer with callbacks for work and rest intervals
myPomodoro.start(workStartCallback, workStopCallback, restStartCallback, restStopCallback);

// Stop the Pomodoro timer
myPomodoro.stop();

API

new Pomodoro([workInputHours], [workInputMinutes], [restInputHours], [restInputMinutes])

Creates a new Pomodoro timer with specified initial work and rest durations in hours and minutes. Default values are 25 minutes for work and 5 minutes for rest. If negative values are provided, an error will be logged, and the timer won't be created.

getWorkTime()

Returns the duration of the work interval in seconds.

setWorkTime(inputHours, inputMinutes)

Sets a new duration for the work interval based on the provided hours and minutes. If negative values are provided, the function returns an 'Invalid Input' message.

getRestTime()

Returns the duration of the rest interval in seconds.

setRestTime(inputHours, inputMinutes)

Sets a new duration for the rest interval based on the provided hours and minutes. If negative values are provided, the function returns an 'Invalid Input' message.

start(workStartCallback, workStopCallback, restStartCallback, restStopCallback)

Starts the Pomodoro timer, alternating between work and rest intervals. Callback functions are provided for each interval to handle start and stop events.

stop()

Stops the Pomodoro timer.

reset()

Resets the Pomodoro timer, setting both work and rest intervals to their initial durations.

License

This Pomodoro Timer module is released under the MIT License.