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

ts-scheduley

v1.0.2

Published

A package to help generate schedules

Downloads

8

Readme

Scheduley

Build Status

| Statement Coverage | Function Coverage | Line Coverage | | --------------------------- | ------------------------- | ----------------- | | Statements | Functions | Lines |

Installation

NPM:

npm i scheduley --save

Yarn:

yarn add scheduley

Usage

Methods

Add

The scheduley().add(pattern) method takes a Pattern as a parameter and adds it to the schedule. A pattern describes the frequency at which an event occurs and how long its occurs for.

Examples:

An event which occurs ever day indefinitely:

scheduley().add({
    startDate: new Date(),
    frequency: {
        measure: 1,
        unit: 'day'
    },
    event: {
        title: 'An event',
        description: 'My daily event.'
    }
})

An event which occurs every 2 weeks indefinitely:

scheduley().add({
    startDate: new Date(),
    frequency: {
        measure: 2,
        unit: 'week'
    },
    event: {
        title: 'An event',
        description: 'My bi-weekly event.'
    }
})

An event which occurs every 6 months between two dates:

scheduley().add({
    startDate: new Date('2023-01-01 12:00:00'),
    endDate: new Date('2025-01-01 12:00:00'),
    frequency: {
        measure: 6,
        unit: 'month'
    },
    event: {
        title: 'An event',
        description: 'My bi-annual event.'
    }
})

Calendar

The scheduley().calendar(startDate, endDate) method takes two Date parameters and generates an Array of Occurrences which describes all occurrences of events in the date range.

Example:

const event1 = {
    startDate: new Date('2023-01-01 12:00:00'),
    endDate: new Date('2023-01-05 12:00:00'),
    frequency: {
        measure: 1,
        unit: 'day'
    },
    event: {
        title: 'My first event.',
        description: 'This happens daily.'
    }
}
const event2 = {
    startDate: new Date('2023-01-01 12:00:00'),
    endDate: new Date('2023-01-05 12:00:00'),
    frequency: {
        measure: 2,
        unit: 'day'
    },
    event: {
        title: 'My second event.',
        description: 'This happens every 2 days.'
    }
}

const schedule = scheduley()
    .add(event1)
    .add(event2)

console.log(schedule.calendar());

Would output:

[
    {
        "event": {
            "title": "My first event.",
            "description": "This happens daily."
        },
        "date": "2023-01-01T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My second event.",
            "description": "This happens every 2 days."
        },
        "date": "2023-01-01T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My first event.",
            "description": "This happens daily."
        },
        "date": "2023-01-02T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My first event.",
            "description": "This happens daily."
        },
        "date": "2023-01-03T12:00:00.000Z"
    },
        {
        "event": {
            "title": "My second event.",
            "description": "This happens every 2 days."
        },
        "date": "2023-01-03T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My first event.",
            "description": "This happens daily."
        },
        "date": "2023-01-04T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My first event.",
            "description": "This happens daily."
        },
        "date": "2023-01-05T12:00:00.000Z"
    },
    {
        "event": {
            "title": "My second event.",
            "description": "This happens every 2 days."
        },
        "date": "2023-01-05T12:00:00.000Z"
    }
]

Types

Pattern

A pattern is the duration and frequency in which an event occurs on a schedule.

| Property | Type | Description | | -- | --- | -- | | event | any | An event which occurs within this pattern. | | startDate | Date | The date which the pattern starts from. | | endDate | Date | undefined | The date which the pattern ends on. | | frequency | Frequency | The frequency which the event occurs within the date period for this pattern. |

Frequency

A frequency is the date interval at which an event should occur.

| Property | Type | Description | | -- | -- | -- | | unit | Unit | The unit of frequency: daily, weekly, monthly or yearly. | measure | number | The number of units. |

Unit

The measure of time used to describe the frequency of an event.

| Property | Type | Description | | -- | -- | -- | | day | string | A day. | week | string | A week. | month | string | A month. | year | string | A year.

Occurrence

An concrete of an event on a specific date generated from a pattern on the schedule.

| Property | Type | Description | | -- | -- | -- | | event | any | An event which occurs on a date. | | date | Date | The date on which the event occurs. |