Package Exports
- spacerepetition
- spacerepetition/dist/spacerepetition.min.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spacerepetition) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Space Repetition
A Spaced Repetition Library
Install + Import
$ npm install spacerepetitionAnd import it
import { createFlashcards } from 'spacerepetition'Or you can include it from a CDN:
<script src="https://cdn.jsdelivr.net/npm/spacerepetition/dist/spacerepetition.min.js"></script>And use it:
<script>
const flashcards = Spacerepetition.createFlashcards([1, 2, 3])
</script>Usage
It doesn't matter what your data looks like, it will always return an array of flashcards:
const flashcards = createFlashcards([{ front: "Question", back: "Answer" }])/* returns:
[
{
front: 'Question',
back: 'Answer',
learningAlgorithm: 'default',
easeFactor: 2.7,
minEaseFactor: 1.3,
interval: 1,
repetition: 0,
dueDate: 1733666742133,
updateDifficulty: [Function: updateDifficulty],
again: [Function: again],
hard: [Function: hard],
good: [Function: good],
easy: [Function: easy]
}
]
*/
Spaced Repetition Algorithms
There's currently only support for sm-2.
But you could also pass your own algorithm. Both parameters are optional:
You can also specify your own algorithm as long as it adhers to XXXXXXXX:
function myAlgorithm(card, difficulty) {
return "use the card that you pass to update the internal state of the card"
}
const flashcards = createFlashcards([], myAlgorithm)Config
You can also pass a config object as the third parameter:
const config = {
interval: 7
}
const flashcards = createFlashcards([], undefined, config)| Key | Default Value | Target Algorithm |
|---|---|---|
| easeFactor | 2.7 | SM-2 |
| minEaseFactor | 1.3 | SM-2 |
| interval | 1 | SM-2 |
| repetition | 0 | SM-2 |