This is a basic streak counter - inspired by Duolingo - written in TypeScript and meant for the browser (uses localStorage
).
yarn add @attilam/streak-counter
or
npm install @attilam/streak-counter
import {streakCounter} from '@attilam/streak-counter';
const today = new Date();
const streak = streakCounter(localStorage, today);
// streak returns an Object:
// {
// currentCount: 1,
// lastLoginDate: "06/18/2022",
// startDate: "06/18/2022"
// }
via https://www.typescriptcourse.com/
yarn init -y
yarn add -D typescript jest ts-jest @types/jest
yarn tsc --init
yarn ts-jest config:init