• Stars
    star
    282
  • Rank 146,549 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ§‘β€πŸŽ“ A JavaScript/TypeScript implementation of the SuperMemo 2 (SM2) algorithm for spaced based repetition flashcards.

SuperMemo

A JavaScript/TypeScript implementation of the SuperMemo 2 (SM2) algorithm for spaced based repetition flashcards.

Hit the Star button if you love this project ⭐️

Explanation

type SuperMemoItem = {
  interval: number;
  repetition: number;
  efactor: number;
};

type SuperMemoGrade = 0 | 1 | 2 | 3 | 4 | 5;

supermemo(item: SuperMemoItem, grade: SuperMemoGrade): SuperMemoItem
  • item
    • repetition: the number of continous correct responses. The initial repetition value should be 0.
    • interval: inter-repetition interval after the repetitions (in days). The initial interval value should be 0.
    • efactor: easiness factor reflecting the easiness of memorizing and retaining a given item in memory. The initial efactor value should be 2.5.
  • grade:
    • 5: perfect response.
    • 4: correct response after a hesitation.
    • 3: correct response recalled with serious difficulty.
    • 2: incorrect response; where the correct one seemed easy to recall.
    • 1: incorrect response; the correct one remembered.
    • 0: complete blackout.

Installation

For Webpack

npm install --save supermemo
import { supermemo, SuperMemoItem, SuperMemoGrade } from 'supermemo';

For Node

npm install --save supermemo
const { supermemo } = require('supermemo');

For Deno

import { supermemo, SuperMemoItem, SuperMemoGrade } from 'https://deno.land/x/supermemo/mod.ts';

Usage

let item: SuperMemoItem = {
  interval: 0,
  repetition: 0,
  efactor: 2.5,
};

console.log(item);

item = supermemo(item, 5);
console.log(item);

item = supermemo(item, 4);
console.log(item);

How to implement SuperMemo with DayJS?

import dayjs from 'dayjs';
import { supermemo, SuperMemoItem, SuperMemoGrade } from 'supermemo';

interface Flashcard extends SuperMemoItem {
  front: string;
  back: string;
  dueDate: string;
}

function practice(flashcard: Flashcard, grade: SuperMemoGrade): Flashcard {
  const { interval, repetition, efactor } = supermemo(flashcard, grade);

  const dueDate = dayjs(Date.now()).add(interval, 'day').toISOString();

  return { ...flashcard, interval, repetition, efactor, dueDate };
}

let flashcard: Flashcard = {
  front: 'programer',
  back: 'an organism that turns caffeine in software',
  interval: 0,
  repetition: 0,
  efactor: 2.5,
  dueDate: dayjs(Date.now()).toISOString(),
};

console.log(flashcard);

flashcard = practice(flashcard, 5);
console.log(flashcard);

flashcard = practice(flashcard, 3);
console.log(flashcard);

References

More Repositories

1

next-shopify-storefront

πŸ› A Shopping Cart built with TypeScript, Tailwind CSS, Headless UI, Next.js, React.js, Shopify Hydrogen React,... and Shopify Storefront GraphQL API.
TypeScript
722
star
2

bootstrap-shopify-theme

πŸ› A free Shopify Theme built with Bootstrap, BEM, Liquid, Sass, ESNext, Theme Tools, ... and Webpack.
Liquid
128
star
3

next-full-stack

πŸ›  Effective Full Stack Development with Next.js
TypeScript
17
star
4

shopify-data-faker

πŸ› A Shopify development tool for generating dummy store data.
TypeScript
14
star
5

shopify-theme-customizer

πŸ› An effective development tool for customizing existing Shopify themes. It's built with Gulp, Theme Kit, Theme Check, LiveReload, ... and Passion.
Liquid
9
star
6

jsonfile

πŸ“š Easily read/write JSON files in Deno
TypeScript
8
star
7

cool-store

😎 CoolStore is an immutable state store built on top of ImmerJS and RxJS.
TypeScript
6
star
8

hackintosh-lenovo-z5070

πŸ–₯ How to install Mac OS El Capitan 10.11.04 on Lenovo Z50-70
Rich Text Format
4
star
9

teach-bem-css

HTML
3
star
10

angular-services-example

TypeScript
2
star
11

unisafe

Remove invalid Unicode characters out of your string and JSON with unisafe
JavaScript
2
star
12

next-ionic-core

How to use IonicCore in NextJS with TypeScript support?
TypeScript
2
star
13

apollo-codegen-for-shopify-example

Apollo Codegen for Shopify Example
TypeScript
2
star
14

apollo-modulizer

πŸš€ Modularizing your Apollo GraphQL schema code
JavaScript
2
star
15

psd2html

πŸ›  A set of tools for faster and easier front-end development.
JavaScript
2
star
16

env-kit

Env Kit for Node Development
TypeScript
1
star
17

sunfrog-uploader

JavaScript
1
star
18

universal-formdata

TypeScript
1
star
19

sentence-to-clauses

Python
1
star
20

drupal-docker

Drupal Development with Docker
PHP
1
star
21

demp

βš“οΈ DEMP Stack: Docker + Nginx + MySQL + PHP
PHP
1
star
22

maxvien.github.io

JavaScript
1
star
23

graphql-code-generator-for-shopify-example

GraphQL Code Generator for Shopify Example
TypeScript
1
star
24

angular-nest-fullstack

Angular Nest Fullstack
HTML
1
star
25

next-boilerplate

JavaScript
1
star
26

angular-examples

1
star
27

heroku-corenlp

Deploy CoreNLP on Heroku
Dockerfile
1
star
28

freecodecamp

Shell
1
star
29

next-apollo-fullstack

A Starting Point for Full Stack Development with Apollo, Next & TypeScript
TypeScript
1
star
30

electron-updater-example

JavaScript
1
star
31

learn-angular

TypeScript
1
star
32

working-with-supertest

Tesing Express API with Jest & Supertest
TypeScript
1
star
33

fison

Post/Upload JSON and Files in a Single Request.
TypeScript
1
star
34

react-boilerplate

πŸš€ Using ES6, Flow, Prettier, and Eslint for React development
JavaScript
1
star
35

nest-graphql-base

TypeScript
1
star
36

next-gqless-example

Next.js GQLess SSR Example
TypeScript
1
star
37

jquery-helpers

πŸ”Œ A set of jQuery Helpers for front-end development.
JavaScript
1
star
38

use-mousetrap

⌨️ A simple Mousetrap hook for handling keyboard shortcuts in React.
TypeScript
1
star
39

eslint-config-next-app

ESLint configuration for Next.js
JavaScript
1
star
40

node-boilerplate

Using ES6, Jest, Flow, Prettier, and Eslint for NodeJS development
JavaScript
1
star
41

learning

My Learning Examples & Projects
1
star
42

dictation

JavaScript
1
star
43

next-base

TypeScript
1
star
44

emotion-css

Overriding Bootstrap, Foundation, Semantic UI, ... and other CSS styles with Emotion
JavaScript
1
star
45

teach-git

1
star
46

express-mvc

JavaScript
1
star
47

samscloud

HTML
1
star
48

react-pdf-reader

Reader Zone Clone
JavaScript
1
star
49

wpc

PHP
1
star
50

docker-scripts

Docker Scripts for Quick Deployment
Shell
1
star
51

cookie-maker

This is a meta-package of 'cookie' and 'js-cookie' with TypeScript support.
TypeScript
1
star
52

hugo-c

Partial-based (component-based) Workspace for Hugo CMS Development
JavaScript
1
star
53

with-elements

Select existing HTML elements and run the callback with each element.
TypeScript
1
star