Introduction | 简体中文 |はじめに
ts-fsrs is a TypeScript toolkit for building spaced repetition systems with FSRS.
This repository contains two main packages:
| Package | Description | FSRS Version | Package Version | Downloads |
|---|---|---|---|---|
ts-fsrs |
the scheduler for review flows | |||
@open-spaced-repetition/binding |
the optimizer for parameter training and CSV conversion |
All current packages in this repository require Node.js >=20.0.0.
Node.js 16 and 18 are end-of-life, so we no longer support versions earlier than Node.js 20. See the official release status page.
pnpm add ts-fsrsIf you also need parameter optimization from review logs:
pnpm add @open-spaced-repetition/bindingUse ts-fsrs to schedule reviews:
import { createEmptyCard, fsrs, Rating } from 'ts-fsrs'
const scheduler = fsrs()
const card = createEmptyCard()
// Preview all four possible outcomes before the user answers.
const preview = scheduler.repeat(card, new Date())
// Apply the final rating after the user has already answered.
const result = scheduler.next(card, new Date(), Rating.Good)
console.log(preview[Rating.Good].card)
console.log(result.card)
console.log(result.log)Use @open-spaced-repetition/binding when you want to train FSRS parameters from review logs. For CSV conversion, timezone handling, browser/WASI setup, and training examples, see packages/binding/README.md.
For detailed usage, advanced examples, browser/WASI setup, and API notes:
packages/fsrs/README.mdpackages/binding/README.md- TypeDoc API docs
- State transition diagram for cards
FSRS is also available in other languages and ecosystems:
For how to setup a local development eniroment, how to set up a Dev Container, and contribution guidelines, see CONTRIBUTING.md.