{"_id":"@animesh0764/streak-engine","name":"@animesh0764/streak-engine","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@animesh0764/streak-engine","version":"0.1.0","description":"Universal streak calculation engine — no dependencies, TypeScript-first","keywords":["streak","habit","calendar","fitness","learning","gamification","contribution-graph"],"author":{"name":"Animesh Singh"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Animesh0764/streak-engine-npm-package.git"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","typecheck":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"devDependencies":{"@vitest/coverage-v8":"^2.0.0","tsup":"^8.0.0","typescript":"^5.0.0","vitest":"^2.0.0"},"_id":"@animesh0764/streak-engine@0.1.0","gitHead":"990939713078b3f1113ea1cdeb651c8293e3eb25","bugs":{"url":"https://github.com/Animesh0764/streak-engine-npm-package/issues"},"homepage":"https://github.com/Animesh0764/streak-engine-npm-package#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-fI0KDhmBSUEP51l8XQNlrP/5EWVvOyz0MjS26i5Hz1ferFK3EEoaaod2asIbIvC8F8PPXghwiGkd0rf8W6+++g==","shasum":"0f08a2fe94968e23a5192b64055bfbbd359c5603","tarball":"https://registry.npmjs.org/@animesh0764/streak-engine/-/streak-engine-0.1.0.tgz","fileCount":9,"unpackedSize":32610,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@animesh0764%2fstreak-engine@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2IYIf258/bNROK/mcmDvvg7epKyn/UnEBdXWSrG+vvwIhAK/yIrs2TATDGyQbBI+4Q+lDygaQg1NxXFmN2h/bDqI/"}]},"_npmUser":{"name":"animesh0764","email":"animeshbksingh@outlook.com"},"directories":{},"maintainers":[{"name":"animesh0764","email":"animeshbksingh@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/streak-engine_0.1.0_1780559017262_0.7540906664315077"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T07:43:37.090Z","0.1.0":"2026-06-04T07:43:37.399Z","modified":"2026-06-04T07:43:37.948Z"},"maintainers":[{"name":"animesh0764","email":"animeshbksingh@outlook.com"}],"description":"Universal streak calculation engine — no dependencies, TypeScript-first","homepage":"https://github.com/Animesh0764/streak-engine-npm-package#readme","keywords":["streak","habit","calendar","fitness","learning","gamification","contribution-graph"],"repository":{"type":"git","url":"git+https://github.com/Animesh0764/streak-engine-npm-package.git"},"author":{"name":"Animesh Singh"},"bugs":{"url":"https://github.com/Animesh0764/streak-engine-npm-package/issues"},"license":"MIT","readme":"# streak-engine\n\nUniversal streak calculation engine. No dependencies. TypeScript-first.\n\n## Install\n\n```bash\nnpm install streak-engine\n```\n\n## Usage\n\n```ts\nimport { calculateStreak } from 'streak-engine'\n\nconst result = calculateStreak([\n  '2026-01-01',\n  '2026-01-02',\n  '2026-01-03',\n  '2026-01-05',\n])\n\nconsole.log(result)\n// {\n//   currentStreak: 1,\n//   longestStreak: 3,\n//   activeDays: 4,\n//   isActiveToday: false,\n//   lastActiveDate: '2026-01-05',\n//   streakHistory: [\n//     { start: '2026-01-01', end: '2026-01-03', length: 3 },\n//     { start: '2026-01-05', end: '2026-01-05', length: 1 },\n//   ]\n// }\n```\n\n## API\n\n### `calculateStreak(dates, options?)`\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `dates` | `(string \\| Date)[]` | Activity dates. Strings must be `YYYY-MM-DD`. |\n| `options` | `StreakOptions` | Optional config (see below). |\n\n**Returns** `StreakResult`:\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `currentStreak` | `number` | Active streak. Stays alive if today **or** yesterday has activity. |\n| `longestStreak` | `number` | Longest streak ever seen in the input. |\n| `activeDays` | `number` | Unique calendar days with activity. |\n| `isActiveToday` | `boolean` | Whether today (this week / month) has activity. |\n| `lastActiveDate` | `string \\| null` | Most recent active date (`YYYY-MM-DD`). |\n| `streakHistory` | `StreakPeriod[]` | All streaks, oldest → newest. |\n\n### Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `mode` | `'daily' \\| 'weekly' \\| 'monthly'` | `'daily'` | How to bucket activity. |\n| `timezone` | `string` | system local | IANA timezone e.g. `'America/New_York'`. |\n| `today` | `string` | current date | Override today (`YYYY-MM-DD`). Useful for tests or as-of queries. |\n\n## Modes\n\n### Daily (default)\n\nA streak increments when you have activity on consecutive calendar days.\n\n### Weekly\n\nA streak increments when you have activity in consecutive calendar weeks (ISO weeks, Monday–Sunday). Multiple days in the same week count as one unit.\n\n### Monthly\n\nA streak increments when you have activity in consecutive calendar months. Multiple days in the same month count as one unit.\n\n## Timezone support\n\nPass an [IANA timezone string](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to ensure \"today\" and date boundaries are resolved in the user's local timezone:\n\n```ts\ncalculateStreak(dates, { timezone: 'Asia/Kolkata' })\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-148f5a6810453f7c5ff86b4b22479df8"}