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 🙏

© 2026 – Pkg Stats / Ryan Hefner

isdayoff-ts

v2.5.1

Published

[![NPM Version](https://img.shields.io/npm/v/isdayoff-ts.svg?style=flat-square)](https://www.npmjs.com/package/isdayoff-ts) [![NPM Downloads](https://img.shields.io/npm/dt/isdayoff-ts.svg?style=flat-square)](https://www.npmjs.com/package/isdayoff-ts)

Downloads

248

Readme

isdayoff-ts

NPM Version NPM Downloads

English | Русский

Changelog (English) | Список изменений

isdayoff-ts — это TypeScript форк и улучшенная версия isdayoff, клиента для isdayoff.ru.

  • никаких внешних зависимостей
  • получение статуса дня на сегодня, завтра или любую дату
  • получение статуса дня для любого месяца, года или произвольного периода времени не более 366 дней
  • проверка, является ли год високосным

Требования

Node.js v18 и выше

Установка

npm install isdayoff-ts --save

Использование

Основные функции

Вызовы API IsDayOff для дат возвращают экземпляр IsDayOffValue:

IsDayOffValue.bool() возвращает:

  • true для нерабочих дней и праздников
  • false для остальных значений

IsDayOffValue.value() возвращает:

  • 0 для рабочих дней
  • 1 для нерабочих дней
  • 2 для сокращенных дней при использовании { pre: true }
  • 4 для рабочих дней в период пандемии с { covid: true }
  • 8 для праздников при использовании { holidays: true }

Пользовательский провайдер API

Ваш пользовательский API должен иметь следующие эндпоинты:

  • /today - без параметров
  • /tomorrow - без параметров
  • /api/getdata
    • year ГГГГ или ГГ
    • month ММ
    • day ДД
    • date1 и date2 ГГГГММДД
    • другие опции API (см. тип ApiOptions)
    • булевы опции должны быть числовыми
  • /api/isleap
    • year ГГГГ или ГГ
import isDayOff from "isdayoff-ts";

await isDayOff
  .setUrl("https://your.api.url") 
  .today() // ..и т.д.

Сегодня

import isDayOff from "isdayoff-ts";

/** возвращает значение для сегодняшнего дня */
isDayOff
  .today()
  .then((
    res // объект IsDayOffDay
    ) => {
    const bool = res.bool(); // получает IsDayOffValue как boolean: true для выходных и праздников, иначе false;
    const val = res.value(); // получает IsDayOffValue из объекта IsDayOffDay;

    console.log(`${date} — это ${bool ? "не" : ""}рабочий день.`);

  })
  .catch((err) => console.log(err.message));

Завтра

import isDayOff from "isdayoff-ts";

/** возвращает значение для завтрашнего дня */
isDayOff
  .tomorrow()
  .then((res) =>
    console.log(`${date} — это ${res.bool() ? "не" : ""}рабочий день.`)
  )
  .catch((err) => console.log(err.message));

Любая дата

import isDayOff from "isdayoff-ts";

/** возвращает false, если 10 сентября рабочий день, или true, если нет */
const date = new Date("2020-09-10");
isDayOff
  .day(date)
  .then((res) =>
    console.log(`${date} — это ${res.bool() ? "не" : ""}рабочий день.`)
  )
  .catch((err) => console.log(err.message));

Месяц

import isDayOff from "isdayoff-ts";

/** возвращает массив объектов IsDayOffDay для сентября 2020 года */
isDayOff
  .month(new Date("2020-09-01"))
  .then((res) => {
    res.forEach((v, i) => {
      console.log(
        `${i + 1}.${date.getMonth() + 1}.${date.getFullYear()} — это ${v.bool() ? "не" : ""}рабочий день.`
      );
    });
  })
  .catch((err) => console.log(err.message));

Год

import isDayOff from "isdayoff-ts";

// возвращает массив объектов IsDayOffDay для 2021 года
isDayOff
  .year(new Date(2021))
  .then((res) => {
    res.forEach((v, i) => {
      console.log(
        `День ${i + 1} в году ${date.getFullYear()} — это ${v.bool() ? "не" : ""}рабочий день.`
      );
    });
  })
  .catch((err) => console.log(err.message));

Интервал

import isDayOff from "isdayoff-ts";

// возвращает массив объектов IsDayOffDay для интервала
isDayOff
  .interval(new Date("2020-09-10"), new Date("2020-09-15"))
  .then((res) =>
    res.forEach((v, i) => {
      console.log(
        `День ${i + 1} в месяце ${date.getMonth() + 1} года ${date.getFullYear()} — это ${v.bool() ? "не" : ""}рабочий день.`
      );
    })
  )
  .catch((err) => console.log(err.message));

Високосный год

import isDayOff from "isdayoff-ts";

// возвращает true, если год високосный, иначе false
const leapDate = new Date("2020-09-10");
isDayOff
  .isLeapYear(leapDate)
  .then((res) =>
    console.log(
      `${leapDate.getFullYear()} ${res ? "является" : "не является"} високосным годом`
    )
  )
  .catch((err) => console.log(err.message));

Лицензия

MIT