From 6dd5e4acbbd2dba1c23105a6b5e73f7ba9025fbc Mon Sep 17 00:00:00 2001 From: ishiko Date: Mon, 21 Oct 2024 20:54:49 +0800 Subject: [PATCH 1/2] Fix/update FSRS-4.5 param into FSRS-5 properly --- __tests__/default.test.ts | 13 +++++++++++++ src/fsrs/default.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/__tests__/default.test.ts b/__tests__/default.test.ts index 4e91809e..844382d0 100644 --- a/__tests__/default.test.ts +++ b/__tests__/default.test.ts @@ -32,6 +32,19 @@ describe('default params', () => { it('default_enable_fuzz ', () => { expect(params.enable_fuzz).toEqual(default_enable_fuzz) }) + + it('convert FSRS 4.5 to FSRS-5', () => { + const params = generatorParameters({ + w: [ + 0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, + 0.05, 0.34, 1.26, 0.29, 2.61, + ], + }) + expect(params.w).toEqual([ + 0.4, 0.6, 2.4, 5.8, 6.81, 0.44675014, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, + 0.05, 0.34, 1.26, 0.29, 2.61, 0.0, 0.0, + ]) + }) }) describe('default Card', () => { diff --git a/src/fsrs/default.ts b/src/fsrs/default.ts index 6a5eecf2..53c27d58 100644 --- a/src/fsrs/default.ts +++ b/src/fsrs/default.ts @@ -22,6 +22,8 @@ export const generatorParameters = ( w = props?.w } else if (props.w.length === 17) { w = props?.w.concat([0.0, 0.0]) + w[4] = +(w[5] * 2.0 + w[4]).toFixed(8) + w[5] = +(Math.log(w[5] * 3.0 + 1.0) / 3.0).toFixed(8) console.debug('[FSRS V5]auto fill w to 19 length') } } From 638e3c08460615fbd6af4e88cd6ff4fca944510b Mon Sep 17 00:00:00 2001 From: ishiko Date: Mon, 21 Oct 2024 20:55:45 +0800 Subject: [PATCH 2/2] bump version to 4.4.2 --- package.json | 2 +- src/fsrs/default.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c946dda7..f7ceb487 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-fsrs", - "version": "4.4.1", + "version": "4.4.2", "description": "ts-fsrs is a versatile package based on TypeScript that supports ES modules, CommonJS, and UMD. It implements the Free Spaced Repetition Scheduler (FSRS) algorithm, enabling developers to integrate FSRS into their flashcard applications to enhance the user learning experience.", "main": "dist/index.cjs", "umd": "dist/index.umd.js", diff --git a/src/fsrs/default.ts b/src/fsrs/default.ts index 53c27d58..60a2fe62 100644 --- a/src/fsrs/default.ts +++ b/src/fsrs/default.ts @@ -11,7 +11,7 @@ export const default_w = [ export const default_enable_fuzz = false export const default_enable_short_term = true -export const FSRSVersion: string = 'v4.4.1 using FSRS V5.0' +export const FSRSVersion: string = 'v4.4.2 using FSRS V5.0' export const generatorParameters = ( props?: Partial