@byem.io/sm2

Alg-SM2 Implementation

Usage no npm install needed!

<script type="module">
  import byemIoSm2 from 'https://cdn.skypack.dev/@byem.io/sm2';
</script>

README

Implementation of SuperMemo 2 algorithm

Check this article for detail: https://www.supermemo.com/english/ol/sm2.htm

Install

npm i @byem.io/sm2

Usage

import { ScheduleTrainer, Input } from './index';

const input: Input = {
    currentRepetition: 0, // the current repetition counter
    lastEasinessFactor: 2.5, // the easiness factor (E-Factor) used in last calculation
    lastInterval: 0, // the last interval amount 
    qualityAssessment: 4 // the quality of review [0-5] -> worst to best
};

new ScheduleTrainer().train(input)
    .then(result => {
        // result:         
        // {
        //     repetition: number; // the repetition counter (will be reseted in failures)
        //     interval: number; // the interval amount until next review
        //     easiness: number; // the easiness factor (E-Factor) that next be used in the next training
        //     repeat: boolean; // if is true the item must be reviewed until the quality assesment isn't not less than four
        // }
    })
    .catch(console.error);