// the find
VienDinhCom/supermemo
A JavaScript and TypeScript implementation of SuperMemo 2, a spaced repetition algorithm for flashcards.
A TypeScript implementation of the SM2 spaced repetition algorithm — the same one behind Anki. Single pure function: takes an item state and a grade, returns the next item state with updated interval, repetition count, and easiness factor. Zero dependencies, works in Node, Deno, and browsers.
Pure function with no side effects — trivially testable and composable into any storage layer. TypeScript types are tight and match the algorithm spec exactly. Ships to both npm and JSR, so Deno users don't need the esm.sh hack. The DayJS integration example in the README is actually useful — shows exactly how to map interval days to a concrete due date.
SM2 is a 1987 algorithm; SM-18 (what modern SuperMemo uses) and FSRS (what Anki switched to in 2023) are meaningfully better at scheduling. No built-in handling for the 'forgotten card' reset path — you have to know that grade < 3 resets repetition to 0 yourself. The repo hasn't been touched in over a year and has 24 forks with no apparent maintenance activity, so expect to fork it yourself if SM2 edge cases bite you. No scheduler or queue — you own all the date math and persistence.