Add comments field to repeats

This commit is contained in:
Rene Saarsoo 2020-09-24 22:30:11 +03:00
parent 5c462d545f
commit 9b47cfeb99
2 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,7 @@ describe("detectRepeats()", () => {
{ type: "Interval", duration: new Seconds(120), intensity: { from: 1, to: 1 }, comments: [] }, { type: "Interval", duration: new Seconds(120), intensity: { from: 1, to: 1 }, comments: [] },
{ type: "Rest", duration: new Seconds(60), intensity: { from: 0.5, to: 0.5 }, comments: [] }, { type: "Rest", duration: new Seconds(60), intensity: { from: 0.5, to: 0.5 }, comments: [] },
], ],
comments: [],
}, },
]); ]);
}); });
@ -63,6 +64,7 @@ describe("detectRepeats()", () => {
{ type: "Interval", duration: new Seconds(60), intensity: { from: 1, to: 1 }, comments: [] }, { type: "Interval", duration: new Seconds(60), intensity: { from: 1, to: 1 }, comments: [] },
{ type: "Rest", duration: new Seconds(60), intensity: { from: 0.5, to: 0.5 }, comments: [] }, { type: "Rest", duration: new Seconds(60), intensity: { from: 0.5, to: 0.5 }, comments: [] },
], ],
comments: [],
}, },
{ type: "Rest", duration: new Seconds(120), intensity: { from: 0.2, to: 0.2 }, comments: [] }, { type: "Rest", duration: new Seconds(120), intensity: { from: 0.2, to: 0.2 }, comments: [] },
{ type: "Cooldown", duration: new Seconds(60), intensity: { from: 1, to: 0.5 }, comments: [] }, { type: "Cooldown", duration: new Seconds(60), intensity: { from: 1, to: 0.5 }, comments: [] },

View File

@ -1,9 +1,10 @@
import { equals } from "ramda"; import { equals } from "ramda";
import { Interval } from "./ast"; import { Interval, Comment } from "./ast";
export type RepeatedInterval = { export type RepeatedInterval = {
times: number; times: number;
intervals: Interval[]; intervals: Interval[];
comments: Comment[];
}; };
const windowSize = 2; const windowSize = 2;
@ -45,6 +46,7 @@ export const detectRepeats = (intervals: Interval[]): (Interval | RepeatedInterv
processed.push({ processed.push({
times: repeats, times: repeats,
intervals: reference, intervals: reference,
comments: [],
}); });
i += repeats * windowSize; i += repeats * windowSize;
} else { } else {