Skip to content

Commit

Permalink
2.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
VienDinhCom committed Sep 13, 2020
1 parent 769009a commit 95ed21f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"typescript"
],
"author": "Vien Dinh",
"version": "2.0.13",
"version": "2.0.14",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
12 changes: 10 additions & 2 deletions src/supermemo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ describe('supermemo', () => {
it('Grade: 2', () => {
item = supermemo(item, 2);

expect(item).toEqual({ interval: 1, repetition: 0, efactor: 2.1399999999999997 });
expect(item).toEqual({
interval: 1,
repetition: 0,
efactor: 2.1399999999999997,
});
});

it('Grade: 1', () => {
item = supermemo(item, 1);

expect(item).toEqual({ interval: 1, repetition: 0, efactor: 1.5999999999999996 });
expect(item).toEqual({
interval: 1,
repetition: 0,
efactor: 1.5999999999999996,
});
});

it('Grade: 0', () => {
Expand Down
8 changes: 6 additions & 2 deletions src/supermemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export type SuperMemoItem = {

export type SuperMemoGrade = 0 | 1 | 2 | 3 | 4 | 5;

export function supermemo(item: SuperMemoItem, grade: SuperMemoGrade): SuperMemoItem {
export function supermemo(
item: SuperMemoItem,
grade: SuperMemoGrade
): SuperMemoItem {
let nextInterval: number;
let nextRepetition: number;
let nextEfactor: number;
Expand All @@ -27,7 +30,8 @@ export function supermemo(item: SuperMemoItem, grade: SuperMemoGrade): SuperMemo
nextRepetition = 0;
}

nextEfactor = item.efactor + (0.1 - (5 - grade) * (0.08 + (5 - grade) * 0.02));
nextEfactor =
item.efactor + (0.1 - (5 - grade) * (0.08 + (5 - grade) * 0.02));

if (nextEfactor < 1.3) nextEfactor = 1.3;

Expand Down

0 comments on commit 95ed21f

Please sign in to comment.