Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/add debugging folder #102

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .vscode/launch.json
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
}
]
}
6 changes: 6 additions & 0 deletions .vscode/setting.json
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"
}
7 changes: 7 additions & 0 deletions debug/index.ts
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()
60 changes: 60 additions & 0 deletions debug/short-term.ts
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()
}
6 changes: 6 additions & 0 deletions nodemon.json
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"
}
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,12 @@
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"],
"detectCycles": true
"detectCycles": true,
"ts-node": {
"experimentalSpecifierResolution": "node",
"transpileOnly": true, // you can specify ts-node options here
"compilerOptions": {
"module": "commonjs" // you can also override compilerOptions. Only ts-node will use these overrides
}
},
}