https://github.com/mainick/streak-counter
https://github.com/mainick/streak-counter
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mainick/streak-counter
- Owner: mainick
- Created: 2022-11-08T15:06:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T14:03:17.000Z (over 3 years ago)
- Last Synced: 2025-02-23T02:49:37.676Z (over 1 year ago)
- Language: TypeScript
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `@mainick/ts-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
```shell
npm add @mainick/ts-streak-counter
```
## Usage
[](https://codesandbox.io/s/streak-counter-ts-course-forked-li3jq9?fontsize=14&hidenavigation=1&theme=dark)
```javascript
import {streakCounter} from "@mainick/ts-streak-counter"
const today = new Date();
const streak = streakCounter(localStorage, today);
// streak returns an object:
// {
// currentCount: 1.
// startDate: "11/10/2022",
// lastLoginDate: "11/10/2022"
// }
```