UNPKG

@fernandomg/streak-counter

Version:

This is a basic streak counter - inspired by Duolingo - written in TypeScript and ment for the browser (uses `localStorage`).

31 lines (22 loc) 749 B
# `@fernandomg/streak-counter` - a basic streak counter This is a basic streak counter - inspired by Duolingo - written in TypeScript and ment for the browser (uses `localStorage`). ## Install ```shell yarn add @fernandomg/streak-counter ``` ```shell npm install @fernandomg/streak-counter ``` ## Usage [![Edit streak-counter](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/streak-counter-808hzm?fontsize=14&hidenavigation=1&theme=dark) ```ts import { streakCounter } from '@fernandomg/streak-counter' const today = new Date() const streak = streakCounter(localStorage, today) // streak returns an object: // { // currentCount: 1, // lastLoginDate: "11/11/2021", // startDate: "11/11/2021", // } ```