ts-fsrs 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +46 -46
- package/{lib → dist}/fsrs.d.ts +126 -126
- package/{lib → dist}/fsrs.js +203 -189
- package/dist/fsrs_version.d.ts +2 -0
- package/dist/fsrs_version.js +7 -0
- package/{lib → dist}/help.d.ts +20 -19
- package/dist/help.js +94 -0
- package/{lib → dist}/index.d.ts +26 -25
- package/{lib → dist}/index.js +64 -64
- package/{lib → dist}/models.d.ts +52 -52
- package/{lib → dist}/models.js +25 -23
- package/{lib → dist}/scheduler.d.ts +53 -53
- package/{lib → dist}/scheduler.js +104 -95
- package/package.json +54 -43
- package/lib/help.js +0 -70
package/{lib → dist}/index.js
RENAMED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.show_diff_message = exports.formatDate = exports.date_diff = exports.date_scheduler = exports.default_enable_fuzz = exports.default_w = exports.default_hard_factor = exports.default_easy_bonus = exports.default_maximum_interval = exports.default_request_retention = exports.generatorParameters = exports.createEmptyCard = exports.SchedulingCard = exports.Rating = exports.State = exports.
|
|
7
|
-
const fsrs_1 = __importDefault(require("./fsrs"));
|
|
8
|
-
const models_1 = require("./models");
|
|
9
|
-
Object.defineProperty(exports, "default_easy_bonus", { enumerable: true, get: function () { return models_1.default_easy_bonus; } });
|
|
10
|
-
Object.defineProperty(exports, "default_enable_fuzz", { enumerable: true, get: function () { return models_1.default_enable_fuzz; } });
|
|
11
|
-
Object.defineProperty(exports, "default_hard_factor", { enumerable: true, get: function () { return models_1.default_hard_factor; } });
|
|
12
|
-
Object.defineProperty(exports, "default_maximum_interval", { enumerable: true, get: function () { return models_1.default_maximum_interval; } });
|
|
13
|
-
Object.defineProperty(exports, "default_request_retention", { enumerable: true, get: function () { return models_1.default_request_retention; } });
|
|
14
|
-
Object.defineProperty(exports, "default_w", { enumerable: true, get: function () { return models_1.default_w; } });
|
|
15
|
-
Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return models_1.Rating; } });
|
|
16
|
-
Object.defineProperty(exports, "State", { enumerable: true, get: function () { return models_1.State; } });
|
|
17
|
-
const scheduler_1 = require("./scheduler");
|
|
18
|
-
Object.defineProperty(exports, "SchedulingCard", { enumerable: true, get: function () { return scheduler_1.SchedulingCard; } });
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exports.
|
|
60
|
-
var help_1 = require("./help");
|
|
61
|
-
Object.defineProperty(exports, "date_scheduler", { enumerable: true, get: function () { return help_1.date_scheduler; } });
|
|
62
|
-
Object.defineProperty(exports, "date_diff", { enumerable: true, get: function () { return help_1.date_diff; } });
|
|
63
|
-
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return help_1.formatDate; } });
|
|
64
|
-
Object.defineProperty(exports, "show_diff_message", { enumerable: true, get: function () { return help_1.show_diff_message; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.show_diff_message = exports.formatDate = exports.date_diff = exports.date_scheduler = exports.default_enable_fuzz = exports.default_w = exports.default_hard_factor = exports.default_easy_bonus = exports.default_maximum_interval = exports.default_request_retention = exports.generatorParameters = exports.createEmptyCard = exports.SchedulingCard = exports.Rating = exports.State = exports.FSRSVersion = exports.fsrs = void 0;
|
|
7
|
+
const fsrs_1 = __importDefault(require("./fsrs"));
|
|
8
|
+
const models_1 = require("./models");
|
|
9
|
+
Object.defineProperty(exports, "default_easy_bonus", { enumerable: true, get: function () { return models_1.default_easy_bonus; } });
|
|
10
|
+
Object.defineProperty(exports, "default_enable_fuzz", { enumerable: true, get: function () { return models_1.default_enable_fuzz; } });
|
|
11
|
+
Object.defineProperty(exports, "default_hard_factor", { enumerable: true, get: function () { return models_1.default_hard_factor; } });
|
|
12
|
+
Object.defineProperty(exports, "default_maximum_interval", { enumerable: true, get: function () { return models_1.default_maximum_interval; } });
|
|
13
|
+
Object.defineProperty(exports, "default_request_retention", { enumerable: true, get: function () { return models_1.default_request_retention; } });
|
|
14
|
+
Object.defineProperty(exports, "default_w", { enumerable: true, get: function () { return models_1.default_w; } });
|
|
15
|
+
Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return models_1.Rating; } });
|
|
16
|
+
Object.defineProperty(exports, "State", { enumerable: true, get: function () { return models_1.State; } });
|
|
17
|
+
const scheduler_1 = require("./scheduler");
|
|
18
|
+
Object.defineProperty(exports, "SchedulingCard", { enumerable: true, get: function () { return scheduler_1.SchedulingCard; } });
|
|
19
|
+
const fsrs_version_1 = __importDefault(require("./fsrs_version"));
|
|
20
|
+
exports.FSRSVersion = fsrs_version_1.default;
|
|
21
|
+
const fsrs = (param) => {
|
|
22
|
+
return new fsrs_1.default(param);
|
|
23
|
+
};
|
|
24
|
+
exports.fsrs = fsrs;
|
|
25
|
+
const createEmptyCard = (now) => {
|
|
26
|
+
return {
|
|
27
|
+
due: now || new Date(),
|
|
28
|
+
stability: 0,
|
|
29
|
+
difficulty: 0,
|
|
30
|
+
elapsed_days: 0,
|
|
31
|
+
scheduled_days: 0,
|
|
32
|
+
reps: 0,
|
|
33
|
+
lapses: 0,
|
|
34
|
+
state: models_1.State.New,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.createEmptyCard = createEmptyCard;
|
|
38
|
+
const generatorParameters = (props) => {
|
|
39
|
+
if (!props) {
|
|
40
|
+
return {
|
|
41
|
+
request_retention: models_1.default_request_retention,
|
|
42
|
+
maximum_interval: models_1.default_maximum_interval,
|
|
43
|
+
easy_bonus: models_1.default_easy_bonus,
|
|
44
|
+
hard_factor: models_1.default_hard_factor,
|
|
45
|
+
w: models_1.default_w,
|
|
46
|
+
enable_fuzz: models_1.default_enable_fuzz,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const { w, request_retention, hard_factor, maximum_interval, enable_fuzz, easy_bonus, } = props;
|
|
50
|
+
return {
|
|
51
|
+
request_retention: request_retention || models_1.default_request_retention,
|
|
52
|
+
maximum_interval: maximum_interval || models_1.default_maximum_interval,
|
|
53
|
+
easy_bonus: easy_bonus || models_1.default_easy_bonus,
|
|
54
|
+
hard_factor: hard_factor || models_1.default_hard_factor,
|
|
55
|
+
w: w || models_1.default_w,
|
|
56
|
+
enable_fuzz: enable_fuzz || models_1.default_enable_fuzz,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.generatorParameters = generatorParameters;
|
|
60
|
+
var help_1 = require("./help");
|
|
61
|
+
Object.defineProperty(exports, "date_scheduler", { enumerable: true, get: function () { return help_1.date_scheduler; } });
|
|
62
|
+
Object.defineProperty(exports, "date_diff", { enumerable: true, get: function () { return help_1.date_diff; } });
|
|
63
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return help_1.formatDate; } });
|
|
64
|
+
Object.defineProperty(exports, "show_diff_message", { enumerable: true, get: function () { return help_1.show_diff_message; } });
|
package/{lib → dist}/models.d.ts
RENAMED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
export type StateType = "Learning" | "New" | "Review" | "Relearning";
|
|
2
|
-
export declare enum State {
|
|
3
|
-
New = 0,
|
|
4
|
-
Learning = 1,
|
|
5
|
-
Review = 2,
|
|
6
|
-
Relearning = 3
|
|
7
|
-
}
|
|
8
|
-
export type RatingType = "Again" | "Hard" | "Good" | "Easy";
|
|
9
|
-
export declare enum Rating {
|
|
10
|
-
Again = 0,
|
|
11
|
-
Hard = 1,
|
|
12
|
-
Good = 2,
|
|
13
|
-
Easy = 3
|
|
14
|
-
}
|
|
15
|
-
export interface ReviewLog {
|
|
16
|
-
rating: Rating;
|
|
17
|
-
state: State;
|
|
18
|
-
elapsed_days: number;
|
|
19
|
-
scheduled_days: number;
|
|
20
|
-
review: Date;
|
|
21
|
-
}
|
|
22
|
-
export interface Card {
|
|
23
|
-
due: Date;
|
|
24
|
-
stability: number;
|
|
25
|
-
difficulty: number;
|
|
26
|
-
elapsed_days: number;
|
|
27
|
-
scheduled_days: number;
|
|
28
|
-
reps: number;
|
|
29
|
-
lapses: number;
|
|
30
|
-
state: State;
|
|
31
|
-
last_review?: Date;
|
|
32
|
-
}
|
|
33
|
-
export interface SchedulingLog {
|
|
34
|
-
[key: number]: {
|
|
35
|
-
card: Card;
|
|
36
|
-
log: ReviewLog;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export interface FSRSParameters {
|
|
40
|
-
request_retention: number;
|
|
41
|
-
maximum_interval: number;
|
|
42
|
-
easy_bonus: number;
|
|
43
|
-
hard_factor: number;
|
|
44
|
-
w: number[];
|
|
45
|
-
enable_fuzz: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare const default_request_retention = 0.9;
|
|
48
|
-
export declare const default_maximum_interval = 36500;
|
|
49
|
-
export declare const default_easy_bonus = 1.3;
|
|
50
|
-
export declare const default_hard_factor = 1.2;
|
|
51
|
-
export declare const default_w: number[];
|
|
52
|
-
export declare const default_enable_fuzz = false;
|
|
1
|
+
export type StateType = "Learning" | "New" | "Review" | "Relearning";
|
|
2
|
+
export declare enum State {
|
|
3
|
+
New = 0,
|
|
4
|
+
Learning = 1,
|
|
5
|
+
Review = 2,
|
|
6
|
+
Relearning = 3
|
|
7
|
+
}
|
|
8
|
+
export type RatingType = "Again" | "Hard" | "Good" | "Easy";
|
|
9
|
+
export declare enum Rating {
|
|
10
|
+
Again = 0,
|
|
11
|
+
Hard = 1,
|
|
12
|
+
Good = 2,
|
|
13
|
+
Easy = 3
|
|
14
|
+
}
|
|
15
|
+
export interface ReviewLog {
|
|
16
|
+
rating: Rating;
|
|
17
|
+
state: State;
|
|
18
|
+
elapsed_days: number;
|
|
19
|
+
scheduled_days: number;
|
|
20
|
+
review: Date;
|
|
21
|
+
}
|
|
22
|
+
export interface Card {
|
|
23
|
+
due: Date;
|
|
24
|
+
stability: number;
|
|
25
|
+
difficulty: number;
|
|
26
|
+
elapsed_days: number;
|
|
27
|
+
scheduled_days: number;
|
|
28
|
+
reps: number;
|
|
29
|
+
lapses: number;
|
|
30
|
+
state: State;
|
|
31
|
+
last_review?: Date;
|
|
32
|
+
}
|
|
33
|
+
export interface SchedulingLog {
|
|
34
|
+
[key: number]: {
|
|
35
|
+
card: Card;
|
|
36
|
+
log: ReviewLog;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface FSRSParameters {
|
|
40
|
+
request_retention: number;
|
|
41
|
+
maximum_interval: number;
|
|
42
|
+
easy_bonus: number;
|
|
43
|
+
hard_factor: number;
|
|
44
|
+
w: number[];
|
|
45
|
+
enable_fuzz: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const default_request_retention = 0.9;
|
|
48
|
+
export declare const default_maximum_interval = 36500;
|
|
49
|
+
export declare const default_easy_bonus = 1.3;
|
|
50
|
+
export declare const default_hard_factor = 1.2;
|
|
51
|
+
export declare const default_w: number[];
|
|
52
|
+
export declare const default_enable_fuzz = false;
|
package/{lib → dist}/models.js
RENAMED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default_enable_fuzz = exports.default_w = exports.default_hard_factor = exports.default_easy_bonus = exports.default_maximum_interval = exports.default_request_retention = exports.Rating = exports.State = void 0;
|
|
4
|
-
var State;
|
|
5
|
-
(function (State) {
|
|
6
|
-
State[State["New"] = 0] = "New";
|
|
7
|
-
State[State["Learning"] = 1] = "Learning";
|
|
8
|
-
State[State["Review"] = 2] = "Review";
|
|
9
|
-
State[State["Relearning"] = 3] = "Relearning";
|
|
10
|
-
})(State
|
|
11
|
-
var Rating;
|
|
12
|
-
(function (Rating) {
|
|
13
|
-
Rating[Rating["Again"] = 0] = "Again";
|
|
14
|
-
Rating[Rating["Hard"] = 1] = "Hard";
|
|
15
|
-
Rating[Rating["Good"] = 2] = "Good";
|
|
16
|
-
Rating[Rating["Easy"] = 3] = "Easy";
|
|
17
|
-
})(Rating
|
|
18
|
-
exports.default_request_retention = 0.9;
|
|
19
|
-
exports.default_maximum_interval = 36500;
|
|
20
|
-
exports.default_easy_bonus = 1.3;
|
|
21
|
-
exports.default_hard_factor = 1.2;
|
|
22
|
-
exports.default_w = [
|
|
23
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default_enable_fuzz = exports.default_w = exports.default_hard_factor = exports.default_easy_bonus = exports.default_maximum_interval = exports.default_request_retention = exports.Rating = exports.State = void 0;
|
|
4
|
+
var State;
|
|
5
|
+
(function (State) {
|
|
6
|
+
State[State["New"] = 0] = "New";
|
|
7
|
+
State[State["Learning"] = 1] = "Learning";
|
|
8
|
+
State[State["Review"] = 2] = "Review";
|
|
9
|
+
State[State["Relearning"] = 3] = "Relearning";
|
|
10
|
+
})(State || (exports.State = State = {}));
|
|
11
|
+
var Rating;
|
|
12
|
+
(function (Rating) {
|
|
13
|
+
Rating[Rating["Again"] = 0] = "Again";
|
|
14
|
+
Rating[Rating["Hard"] = 1] = "Hard";
|
|
15
|
+
Rating[Rating["Good"] = 2] = "Good";
|
|
16
|
+
Rating[Rating["Easy"] = 3] = "Easy";
|
|
17
|
+
})(Rating || (exports.Rating = Rating = {}));
|
|
18
|
+
exports.default_request_retention = 0.9;
|
|
19
|
+
exports.default_maximum_interval = 36500;
|
|
20
|
+
exports.default_easy_bonus = 1.3;
|
|
21
|
+
exports.default_hard_factor = 1.2;
|
|
22
|
+
exports.default_w = [
|
|
23
|
+
1, 1, 5, -0.5, -0.5, 0.2, 1.4, -0.12, 0.8, 2, -0.2, 0.2, 1,
|
|
24
|
+
];
|
|
25
|
+
exports.default_enable_fuzz = false;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { Card, Rating, State } from
|
|
2
|
-
export declare class SchedulingCard {
|
|
3
|
-
again: Card;
|
|
4
|
-
hard: Card;
|
|
5
|
-
good: Card;
|
|
6
|
-
easy: Card;
|
|
7
|
-
private copy;
|
|
8
|
-
constructor(card: Card);
|
|
9
|
-
update_state(state: State): this;
|
|
10
|
-
schedule(now: Date, hard_interval: number, good_interval: number, easy_interval: number): SchedulingCard;
|
|
11
|
-
record_log(card: Card, now: Date): {
|
|
12
|
-
0: {
|
|
13
|
-
card: Card;
|
|
14
|
-
log: {
|
|
15
|
-
rating: Rating;
|
|
16
|
-
state: State;
|
|
17
|
-
elapsed_days: number;
|
|
18
|
-
scheduled_days: number;
|
|
19
|
-
review: Date;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
1: {
|
|
23
|
-
card: Card;
|
|
24
|
-
log: {
|
|
25
|
-
rating: Rating;
|
|
26
|
-
state: State;
|
|
27
|
-
elapsed_days: number;
|
|
28
|
-
scheduled_days: number;
|
|
29
|
-
review: Date;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
2: {
|
|
33
|
-
card: Card;
|
|
34
|
-
log: {
|
|
35
|
-
rating: Rating;
|
|
36
|
-
state: State;
|
|
37
|
-
elapsed_days: number;
|
|
38
|
-
scheduled_days: number;
|
|
39
|
-
review: Date;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
3: {
|
|
43
|
-
card: Card;
|
|
44
|
-
log: {
|
|
45
|
-
rating: Rating;
|
|
46
|
-
state: State;
|
|
47
|
-
elapsed_days: number;
|
|
48
|
-
scheduled_days: number;
|
|
49
|
-
review: Date;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}
|
|
1
|
+
import { Card, Rating, State } from "./models";
|
|
2
|
+
export declare class SchedulingCard {
|
|
3
|
+
again: Card;
|
|
4
|
+
hard: Card;
|
|
5
|
+
good: Card;
|
|
6
|
+
easy: Card;
|
|
7
|
+
private copy;
|
|
8
|
+
constructor(card: Card);
|
|
9
|
+
update_state(state: State): this;
|
|
10
|
+
schedule(now: Date, hard_interval: number, good_interval: number, easy_interval: number): SchedulingCard;
|
|
11
|
+
record_log(card: Card, now: Date): {
|
|
12
|
+
0: {
|
|
13
|
+
card: Card;
|
|
14
|
+
log: {
|
|
15
|
+
rating: Rating;
|
|
16
|
+
state: State;
|
|
17
|
+
elapsed_days: number;
|
|
18
|
+
scheduled_days: number;
|
|
19
|
+
review: Date;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
1: {
|
|
23
|
+
card: Card;
|
|
24
|
+
log: {
|
|
25
|
+
rating: Rating;
|
|
26
|
+
state: State;
|
|
27
|
+
elapsed_days: number;
|
|
28
|
+
scheduled_days: number;
|
|
29
|
+
review: Date;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
2: {
|
|
33
|
+
card: Card;
|
|
34
|
+
log: {
|
|
35
|
+
rating: Rating;
|
|
36
|
+
state: State;
|
|
37
|
+
elapsed_days: number;
|
|
38
|
+
scheduled_days: number;
|
|
39
|
+
review: Date;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
3: {
|
|
43
|
+
card: Card;
|
|
44
|
+
log: {
|
|
45
|
+
rating: Rating;
|
|
46
|
+
state: State;
|
|
47
|
+
elapsed_days: number;
|
|
48
|
+
scheduled_days: number;
|
|
49
|
+
review: Date;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -1,95 +1,104 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SchedulingCard = void 0;
|
|
4
|
-
const models_1 = require("./models");
|
|
5
|
-
const help_1 = require("./help");
|
|
6
|
-
class SchedulingCard {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
}
|
|
30
|
-
else if (state === models_1.State.
|
|
31
|
-
this.again.state =
|
|
32
|
-
this.hard.state =
|
|
33
|
-
this.good.state = models_1.State.Review;
|
|
34
|
-
this.easy.state = models_1.State.Review;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchedulingCard = void 0;
|
|
4
|
+
const models_1 = require("./models");
|
|
5
|
+
const help_1 = require("./help");
|
|
6
|
+
class SchedulingCard {
|
|
7
|
+
again;
|
|
8
|
+
hard;
|
|
9
|
+
good;
|
|
10
|
+
easy;
|
|
11
|
+
copy(card) {
|
|
12
|
+
return {
|
|
13
|
+
...card,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
constructor(card) {
|
|
17
|
+
this.again = this.copy(card);
|
|
18
|
+
this.hard = this.copy(card);
|
|
19
|
+
this.good = this.copy(card);
|
|
20
|
+
this.easy = this.copy(card);
|
|
21
|
+
}
|
|
22
|
+
update_state(state) {
|
|
23
|
+
if (state === models_1.State.New) {
|
|
24
|
+
this.again.state = models_1.State.Learning;
|
|
25
|
+
this.hard.state = models_1.State.Learning;
|
|
26
|
+
this.good.state = models_1.State.Learning;
|
|
27
|
+
this.easy.state = models_1.State.Review;
|
|
28
|
+
this.again.lapses += 1;
|
|
29
|
+
}
|
|
30
|
+
else if (state === models_1.State.Learning || state === models_1.State.Relearning) {
|
|
31
|
+
this.again.state = state;
|
|
32
|
+
this.hard.state = state;
|
|
33
|
+
this.good.state = models_1.State.Review;
|
|
34
|
+
this.easy.state = models_1.State.Review;
|
|
35
|
+
}
|
|
36
|
+
else if (state === models_1.State.Review) {
|
|
37
|
+
this.again.state = models_1.State.Relearning;
|
|
38
|
+
this.hard.state = models_1.State.Review;
|
|
39
|
+
this.good.state = models_1.State.Review;
|
|
40
|
+
this.easy.state = models_1.State.Review;
|
|
41
|
+
this.again.lapses += 1;
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
schedule(now, hard_interval, good_interval, easy_interval) {
|
|
46
|
+
this.again.scheduled_days = 0;
|
|
47
|
+
this.hard.scheduled_days = hard_interval;
|
|
48
|
+
this.good.scheduled_days = good_interval;
|
|
49
|
+
this.easy.scheduled_days = easy_interval;
|
|
50
|
+
this.again.due = (0, help_1.date_scheduler)(now, 5);
|
|
51
|
+
this.hard.due =
|
|
52
|
+
hard_interval > 0
|
|
53
|
+
? (0, help_1.date_scheduler)(now, hard_interval, true)
|
|
54
|
+
: (0, help_1.date_scheduler)(now, 10);
|
|
55
|
+
this.good.due = (0, help_1.date_scheduler)(now, good_interval, true);
|
|
56
|
+
this.easy.due = (0, help_1.date_scheduler)(now, easy_interval, true);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
record_log(card, now) {
|
|
60
|
+
return {
|
|
61
|
+
[models_1.Rating.Again]: {
|
|
62
|
+
card: this.again,
|
|
63
|
+
log: {
|
|
64
|
+
rating: models_1.Rating.Again,
|
|
65
|
+
state: card.state,
|
|
66
|
+
elapsed_days: this.again.scheduled_days,
|
|
67
|
+
scheduled_days: card.elapsed_days,
|
|
68
|
+
review: now,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
[models_1.Rating.Hard]: {
|
|
72
|
+
card: this.hard,
|
|
73
|
+
log: {
|
|
74
|
+
rating: models_1.Rating.Hard,
|
|
75
|
+
state: card.state,
|
|
76
|
+
elapsed_days: this.hard.scheduled_days,
|
|
77
|
+
scheduled_days: card.elapsed_days,
|
|
78
|
+
review: now,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
[models_1.Rating.Good]: {
|
|
82
|
+
card: this.good,
|
|
83
|
+
log: {
|
|
84
|
+
rating: models_1.Rating.Good,
|
|
85
|
+
state: card.state,
|
|
86
|
+
elapsed_days: this.good.scheduled_days,
|
|
87
|
+
scheduled_days: card.elapsed_days,
|
|
88
|
+
review: now,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
[models_1.Rating.Easy]: {
|
|
92
|
+
card: this.easy,
|
|
93
|
+
log: {
|
|
94
|
+
rating: models_1.Rating.Easy,
|
|
95
|
+
state: card.state,
|
|
96
|
+
elapsed_days: this.easy.scheduled_days,
|
|
97
|
+
scheduled_days: card.elapsed_days,
|
|
98
|
+
review: now,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.SchedulingCard = SchedulingCard;
|