0.0.5 • Published 3 years ago

@repeatnotes/sm2 v0.0.5

Weekly downloads
19
License
AGPL
Repository
github
Last release
3 years ago

SM2

SuperMemo2 algorithm, written in Rust

Large part of the code in this repo was ported from Anki, which implements SM2 algorithm.

Copyright: Ankitects Pty Ltd and contributors

License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

Installation

# NPM
npm install @repeatnotes/sm2

# Yarn
yarn add @repeatnotes/sm2

Usage

const main = async () => {
    const wasm = await import('@repeatnotes/sm2')

    const sm2 = new wasm.Sm2({
      learn_steps: [1.0, 10.0],
      relearn_steps: [10.0],
      initial_ease: 2500,
      easy_multiplier: 1.3,
      hard_multiplier: 1.2,
      lapse_multiplier: 0.0,
      interval_multiplier: 1.0,
      maximum_review_interval: 36500,
      minimum_review_interval: 1,
      graduating_interval_good: 1,
      graduating_interval_easy: 4,
      leech_threshold: 8,
    })

    const card = {
      card_type: 0,
      card_queue: 0,
      due: 0,
      interval: 0,
      ease_factor: 0,
      reps: 0,
      lapses: 0,
      remaining_steps: 0,
    }

    console.log("Next due with Ok answer:", sm2.next_interval(card, 3))
    console.log("Answer Ok:", sm2.answer_card(card, 3))
}

See lib.rs for full API.

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0-next2

3 years ago

0.0.0-next1

3 years ago

0.0.0-next0

3 years ago

0.0.0

3 years ago