@doubleedesign/streak-counter
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Streak Counter

A thing that counts a streak, such as visiting a website daily, and stores it in the browser's local storage.

Built as part of the TypeScript Fundamentals workshop at Render(ATL) 2022.

Installation

// TODO

Usage

const streak = getDailyStreak();

If a streak is stored in local storage, it will be incremented if the lastLogin date was yesterday, or reset if it was longer ago. If there is no streak in local storage, a new streak will be initialised.

The returned streak is of the StreakCounter type:

export type StreakCounter = {
    storage: Storage;
    startDate: string;
    lastLogin: string;
    count: number;
};

Readme

Keywords

none

Package Sidebar

Install

npm i @doubleedesign/streak-counter

Weekly Downloads

1

Version

0.0.5

License

none

Unpacked Size

34.9 kB

Total Files

19

Last publish

Collaborators

  • doubleedesign