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

generate-month-structure

v0.2.2

Published

This library have as objective generate a month structure according to the month and year. The month generate have the necessary rows and is fulfilled with the previous and the next month on the empty positions. The main advantage of this library is that

Downloads

3

Readme

Generate Month Structure

This library have as objective generate a month structure according to the month and year. The month generate have the necessary rows and is fulfilled with the previous and the next month on the empty positions. The main advantage of this library is that it complete lack of third packages for generate the month.

Features:

  • Generate the month structure with all the days of the necessary rows for represent the month fulfilled with the previous and the next month

Installation:

This library could be installed using npm as:

    npm install generate-month-structure

Usage

The lib export a object with the function createMonthStructure, that requeries a js Date object, and return the full structure of the current month, with the required rows of the current month passed to the createMonthStructure, and the remaining days of the previous and the next month.Therefore an array with all the rows necessary for represent the current month are returned, including previous and next positions of the current month filled.


    const { createMonthStructure } = require("generate-month-structure");
    const currentMonth = createMonthStructure(new Date(2023, 03, 01));

In the above example, the current month passed is 2023-04-01, and will return the structure of all rows of the current month, and the remaining days of the previous month 2023-03, and the next month 2023-05 that are empty in the necessary rows for display the current month. The array returned will be:


[ 26, 27, 28, 29, 30, 31, 1,
  2,  3,  4,  5,  6,  7,  8,
  9,  10, 11, 12, 13, 14, 15,
  16, 17, 18, 19, 20, 21, 22,
  23, 24, 25, 26, 27, 28, 29,
  30, 1,  2,  3,  4,  5,  6 ]

The lib export the function createMonthStructureFlaggingDaysAccordingMonth that return an array with the similar struture as createMonthStructure, but instead of numbers, it returns a interface called Day, that contains the content(the day number), and the flagging, that is a enum, that inform if the months is previous, current or next month. This feature could be used for generate different behaviours, according to the flagging status.


interface Day {
content: number;
flagging: BellongMonth;
}

The Day interface as the enum BellongMonth are exported by this package, and can being access and used in typescript projects. Above the BellongMonth enum description:


export enum BellongMonth {
  previous = 'previous',
  current = 'current',
  next = 'next',
}

Tecnologies Used:

  • Typescript
  • Jest

Author

Lucas Rocha github