attilam / streak-counter

a streak counter for the browser, inspired by Duolingo.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@attilam/streak-counter - a basic streak counter

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

Install

yarn add @attilam/streak-counter

or

npm install @attilam/streak-counter

Usage

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"
// }

Demo

Edit streak-counter (ts-course) (forked)

Course Notes

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

About

a streak counter for the browser, inspired by Duolingo.

License:MIT License


Languages

Language:TypeScript 98.9%Language:JavaScript 1.1%