-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "ts-fsrs debug", | ||
"skipFiles": ["<node_internals>/**"], | ||
"env": { | ||
// "DEBUG": "*", | ||
}, | ||
"outputCapture": "std", | ||
"runtimeExecutable": "nodemon", | ||
"restart": true, | ||
"console": "integratedTerminal", | ||
"cwd": "${workspaceFolder}", | ||
"args": ["${workspaceFolder}/debug/index.ts"] | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Node: Nodemon", | ||
"processId": "${command:PickProcess}", | ||
"restart": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"typescript.preferences.importModuleSpecifier": "non-relative", | ||
"typescript.preferences.quoteStyle": "single", | ||
"typescript.preferGoToSourceDefinition": true, | ||
"typescript.tsdk": "./node_modules/typescript/lib" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FSRSVersion } from '../src/fsrs' | ||
import { runShortTerm } from './short-term' | ||
|
||
console.log(FSRSVersion) | ||
|
||
|
||
runShortTerm() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import assert from 'assert' | ||
import { createEmptyCard, fsrs, Grade, Rating } from '../src/fsrs' | ||
|
||
const f = fsrs() | ||
|
||
function test1() { | ||
let card = createEmptyCard() | ||
let now = new Date(2022, 11, 29, 12, 30, 0, 0) | ||
const ratings: Grade[] = [ | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Again, | ||
Rating.Again, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
Rating.Good, | ||
] | ||
const ivl_history: number[] = [] | ||
const s_history: number[] = [] | ||
const d_history: number[] = [] | ||
for (const rating of ratings) { | ||
const record = f.repeat(card, now)[rating] | ||
card = record.card | ||
ivl_history.push(card.scheduled_days) | ||
s_history.push(card.stability) | ||
d_history.push(card.difficulty) | ||
now = card.due | ||
} | ||
|
||
assert.deepStrictEqual( | ||
ivl_history, | ||
[0, 4, 17, 57, 163, 412, 0, 0, 8, 15, 27, 49, 86] | ||
) | ||
assert.deepStrictEqual( | ||
s_history, | ||
[ | ||
3.0412, 4.17286168, 16.55123695, 56.74378762, 163.35708827, 411.77071586, | ||
11.15423471, 5.75442486, 7.89570531, 14.90748589, 27.437534, 48.90521597, | ||
85.82782993, | ||
] | ||
) | ||
assert.deepStrictEqual( | ||
d_history, | ||
[ | ||
4.49094334, 4.66971892, 4.83644502, 4.99193379, 5.13694261, 5.27217784, | ||
7.26480385, 9.12312687, 8.98969328, 8.86525311, 8.74920021, 8.64096928, | ||
8.54003311, | ||
] | ||
) | ||
} | ||
|
||
export function runShortTerm() { | ||
test1() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"watch": ["./src/..","./debug/.."], | ||
"ext": "ts", | ||
"ignore": ["src/**/*.spec.ts"], | ||
"exec": "npx ts-node --project ./tsconfig.json ./debug/index.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters