{"id":18676837,"url":"https://github.com/viendinhcom/supermemo","last_synced_at":"2025-05-15T12:05:23.713Z","repository":{"id":47619061,"uuid":"278576258","full_name":"VienDinhCom/supermemo","owner":"VienDinhCom","description":"A JavaScript and TypeScript implementation of SuperMemo 2, a spaced repetition algorithm for flashcards.","archived":false,"fork":false,"pushed_at":"2025-03-28T05:23:41.000Z","size":426,"stargazers_count":307,"open_issues_count":0,"forks_count":25,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T19:59:19.209Z","etag":null,"topics":["deno","flashcards","javascript","nodejs","sm2","spaced-repetition","supermemo","supermemo2","typescript","webpack"],"latest_commit_sha":null,"homepage":"https://jsr.io/@vien/supermemo","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VienDinhCom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-10T08:07:49.000Z","updated_at":"2025-04-07T23:16:51.000Z","dependencies_parsed_at":"2024-05-31T11:21:51.075Z","dependency_job_id":"59cdf40a-de66-43ff-b22a-7fdc15ff8bff","html_url":"https://github.com/VienDinhCom/supermemo","commit_stats":null,"previous_names":["maxvien/supermemo"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VienDinhCom%2Fsupermemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VienDinhCom%2Fsupermemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VienDinhCom%2Fsupermemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VienDinhCom%2Fsupermemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VienDinhCom","download_url":"https://codeload.github.com/VienDinhCom/supermemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337613,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","flashcards","javascript","nodejs","sm2","spaced-repetition","supermemo","supermemo2","typescript","webpack"],"created_at":"2024-11-07T09:31:16.931Z","updated_at":"2025-05-15T12:05:18.702Z","avatar_url":"https://github.com/VienDinhCom.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SuperMemo\n\nA JavaScript/TypeScript implementation of the [SuperMemo 2](https://super-memory.com/english/ol/sm2.htm) (SM2) algorithm for spaced based repetition flashcards.\n\n[![NPM Downloads](https://img.shields.io/npm/dy/supermemo?label=NPM)](https://www.npmjs.com/package/supermemo)\n[![JSR Version](https://img.shields.io/jsr/v/%40vien/supermemo?label=JSR)](https://jsr.io/@vien/supermemo)\n[![GitHub forks](https://img.shields.io/github/forks/viendinhcom/supermemo)](https://github.com/VienDinhCom/supermemo)\n[![GitHub Repo stars](https://img.shields.io/github/stars/viendinhcom/supermemo)](https://github.com/VienDinhCom/supermemo)\n\n## Explanation\n\n```ts\ntype SuperMemoItem = {\n  interval: number;\n  repetition: number;\n  efactor: number;\n};\n\ntype SuperMemoGrade = 0 | 1 | 2 | 3 | 4 | 5;\n\nsupermemo(item: SuperMemoItem, grade: SuperMemoGrade): SuperMemoItem\n```\n\n- **item**\n  - **repetition**: the number of continous correct responses. The initial `repetition` value should be `0`.\n  - **interval**: inter-repetition interval after the repetitions (in days). The initial `interval` value should be `0`.\n  - **efactor**: easiness factor reflecting the easiness of memorizing and retaining a given item in memory. The initial `efactor` value should be `2.5`.\n- **grade**:\n  - **5**: perfect response.\n  - **4**: correct response after a hesitation.\n  - **3**: correct response recalled with serious difficulty.\n  - **2**: incorrect response; where the correct one seemed easy to recall.\n  - **1**: incorrect response; the correct one remembered.\n  - **0**: complete blackout.\n\nIf you like this project, hit the STAR button to bookmark it ⭐️\n\n## Installation\n\n### For Browser\n\n```ts\nimport { supermemo } from 'https://esm.sh/supermemo@2';\n```\n\n### For Node\n\n```\nnpm install --save supermemo\n```\n\n#### CommonJS\n\n```js\nconst { supermemo } = require('supermemo');\n```\n\n#### ES Modules\n\n```ts\nimport { supermemo, SuperMemoItem, SuperMemoGrade } from 'supermemo';\n```\n\n### For Deno\n\n```\ndeno add jsr:@vien/supermemo\n```\n\n```ts\nimport { supermemo, SuperMemoItem, SuperMemoGrade } from '@vien/supermemo';\n```\n\nOR\n\n```ts\nimport { supermemo, SuperMemoItem, SuperMemoGrade } from 'jsr:@vien/supermemo';\n```\n\n## Usage\n\n```ts\nlet item: SuperMemoItem = {\n  interval: 0,\n  repetition: 0,\n  efactor: 2.5,\n};\n\nconsole.log(item);\n\nitem = supermemo(item, 5);\nconsole.log(item);\n\nitem = supermemo(item, 4);\nconsole.log(item);\n```\n\n### How to implement SuperMemo with DayJS?\n\n```ts\nimport dayjs from 'dayjs';\nimport { supermemo, SuperMemoItem, SuperMemoGrade } from 'supermemo';\n\ninterface Flashcard extends SuperMemoItem {\n  front: string;\n  back: string;\n  dueDate: string;\n}\n\nfunction practice(flashcard: Flashcard, grade: SuperMemoGrade): Flashcard {\n  const { interval, repetition, efactor } = supermemo(flashcard, grade);\n\n  const dueDate = dayjs(Date.now()).add(interval, 'day').toISOString();\n\n  return { ...flashcard, interval, repetition, efactor, dueDate };\n}\n\nlet flashcard: Flashcard = {\n  front: 'programer',\n  back: 'an organism that turns caffeine in software',\n  interval: 0,\n  repetition: 0,\n  efactor: 2.5,\n  dueDate: dayjs(Date.now()).toISOString(),\n};\n\nconsole.log(flashcard);\n\nflashcard = practice(flashcard, 5);\nconsole.log(flashcard);\n\nflashcard = practice(flashcard, 3);\nconsole.log(flashcard);\n```\n\n## Experience\n\nI work remotely, so improving my English is a constant challenge. I needed a way to expand my vocabulary and actually remember it.\n\nThat’s when I found the SuperMemo algorithm. It made sense. Spaced repetition helps lock words into long-term memory. So, I built this JavaScript/TypeScript library from the original Delphi code.\n\nThen, I took it further—created a side project using React.js, Next.js and Hasura GraphQL. I used it to practice common words. Over time, I memorized more than 10,000 words. It worked.\n\nAfter seeing the results, I turned it into a product to help others do the same. But it failed. Maybe I wasn’t good at marketing. Maybe most learners don’t have the patience I did.\n\nStill, I learned something: a good method isn’t enough. People need the right mindset, too. Would I do it again? Probably. Because every failure teaches something new.\n\n## References\n\n- [The explanation of SuperMemo 2 Algorithm](https://super-memory.com/english/ol/sm2.htm)\n- [The Delphi implementation of SuperMemo 2 Algorithm](https://super-memory.com/english/ol/sm2source.htm)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviendinhcom%2Fsupermemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviendinhcom%2Fsupermemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviendinhcom%2Fsupermemo/lists"}