Skip to content

Commit

Permalink
bump ts-fsrs to 4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiko732 authored and xiety committed Sep 6, 2024
1 parent 6b6a3cb commit 63adcd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
20 changes: 5 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"chart.js": "^4.4.3",
"chartjs-plugin-datalabels": "^2.2.0",
"chartjs-plugin-zoom": "^2.0.1",
"ts-fsrs": "^3.5.7",
"ts-fsrs": "^4.1.3",
"vue": "^3.4.30",
"vue-chartjs": "^5.3.1"
},
Expand Down
21 changes: 11 additions & 10 deletions src/tsFsrsCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ export class TsFsrsCalculator implements IFsrsCalculator {

const f = fsrs(generatorParameters({
w: this.w,
request_retention: this.desiredR
request_retention: this.desiredR,
enable_short_term: this.enableShortTerm
}));

for (const review of reviews) {
const date = fsrs_card.due
const scheduling_cards = f.repeat(fsrs_card, date);
fsrs_card = scheduling_cards[<Grade>review].card;
fsrs_card = f.next(fsrs_card, date, <Grade>review, (recordItem) => {
const { card } = recordItem;
const interval = f.next_interval(card.stability, card.elapsed_days)
card.due = new Date(date.getTime() + interval * 24 * 60 * 60 * 1000);
card.scheduled_days = interval;
return card
});

const displayDifficulty = this.calcDisplayDifficulty(fsrs_card.difficulty);
const interval = f.next_interval(fsrs_card.stability, 0)
const interval = fsrs_card.scheduled_days;
const cumulativeInterval = card.cumulativeInterval + interval;

if (fsrs_card.state != State.Review) {
fsrs_card.state = State.Review;
fsrs_card.due = new Date(date.getTime() + interval * 24 * 60 * 60 * 1000);
}

list.push(new Card(0, fsrs_card.difficulty, displayDifficulty, fsrs_card.stability, interval, cumulativeInterval, review));
list.push(new Card(fsrs_card.state, fsrs_card.difficulty, displayDifficulty, fsrs_card.stability, interval, cumulativeInterval, review));
}

return list;
Expand Down

0 comments on commit 63adcd8

Please sign in to comment.