← 开源
open-spaced-repetition

ts-fsrs (在 GitHub 打开)

ts-fsrs is a versatile package written in TypeScript that supports ES modules, CommonJS, and UMD.

TypeScript
增长势头
+224 小时新增 Star+0.2%
904
Star
77
Fork
+8
本周
22
贡献者
创建于 2023-03-05 · 更新于 2026-12-04 · 今日第 3753 名
主要开发者
ishiko732Luc-Mcgrady2Lavine
README

Introduction | 简体中文 |はじめに


ts-fsrs

ts-fsrs is a TypeScript toolkit for building spaced repetition systems with FSRS.

ts-fsrs-v6.mp4

Packages

This repository contains two main packages:

Package Description Supported FSRS Versions Package Version Downloads
ts-fsrs the scheduler for review flows
@open-spaced-repetition/binding the optimizer for parameter training and CSV conversion

Installation

ts-fsrs v6 and @open-spaced-repetition/binding require Node.js >=24.0.0.

pnpm add ts-fsrs

If you also need parameter optimization from review logs:

pnpm add @open-spaced-repetition/binding

Basic Usage

Use DefaultScheduler() to schedule reviews with ts-fsrs v6. It defaults to FSRS-7; the library version and the FSRS model version are independent.

import { DefaultScheduler, Rating } from 'ts-fsrs'

const now = new Date('2026-01-01T00:00:00.000Z')
const scheduler = await DefaultScheduler()
const card = scheduler.newCard({ now })

// Preview all four possible outcomes before the user answers.
const preview = scheduler.preview({ card, now })
for (const { grade, card: previewCard, revlog } of preview) {
  console.log(grade, previewCard, revlog)
}

// Apply the final rating after the user has already answered.
const result = scheduler.review({ card, grade: Rating.Good, now })

console.log(result.card)
console.log(result.revlog)

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.

More Documentation

For detailed usage, advanced examples, browser/WASI setup, and API notes:

Examples

Other Implementations

FSRS is also available in other languages and ecosystems:

Contribute

For how to setup a local development eniroment, how to set up a Dev Container, and contribution guidelines, see CONTRIBUTING.md.

排名相邻

AI Rank iPhone 版

随时追踪 AI 模型榜单

在 App Store 下载