New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

count-to-day

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

count-to-day

A simple javascript package that calculates countdown to a particular day of the week

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

count-to-day

It is a lightweight javascript package that calculates countdown to a particular day of the week.

Installation

npm install count-to-day --save
//or with yarn
yarn add count-to-day

Params

ParamsTypeDescription
dayOfWeek'sunday' | 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday'the day of the week you want to count down to
countDownCbfunctioncall back function whose params contains the countdown object: {days: number, hours: number, minutes: number, seconds: number }
timeToCountTostringnot mandatory. The time to count to, uses 24 hours clock time, e.g '12:00:00', '16:00:00', '1:00:00'. Defaults to '00:00:00' (12 midnight)
isInfinitebooleanA boolean flag that determines if the time should restart after the date to countdown to is reached. Defaults to false

Usage

import { CountDownToDay } from "count-to-day";

CountDownToDay("wednesday", (count) => console.log("count=", count), "10:42:00");
//=> count =  { days: number, hours: number, minutes: number, seconds: number }
//(logs an object like this that contains the countdown)

Or use in a custom hook

import { useEffect, useState } from "react";
import { CountDownToDay, StopCountdown } from "count-to-day";

const useCountdown = (dayOfWeek = "friday", timeToCountTo = "00:00:00") => {
  const [count, setCount] = useState({
    days: "",
    hours: "",
    minutes: "",
    seconds: ""
  });

  useEffect(() => {
    CountDownToDay(dayOfWeek, setCount, timeToCountTo);

    return () => {
      StopCountdown();
    };
  }, [dayOfWeek, timeToCountTo]);

  return { count };
};

export default useCountdown;

Keywords

FAQs

Package last updated on 28 Dec 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc