Add type:repeat

This commit is contained in:
Rene Saarsoo 2020-09-24 22:31:08 +03:00
parent 9b47cfeb99
commit 083f5ea3a5
2 changed files with 4 additions and 0 deletions

View File

@ -30,6 +30,7 @@ describe("detectRepeats()", () => {
];
expect(detectRepeats(intervals)).toEqual([
{
type: "repeat",
times: 4,
intervals: [
{ type: "Interval", duration: new Seconds(120), intensity: { from: 1, to: 1 }, comments: [] },
@ -59,6 +60,7 @@ describe("detectRepeats()", () => {
{ type: "Warmup", duration: new Seconds(60), intensity: { from: 0.5, to: 1 }, comments: [] },
{ type: "Rest", duration: new Seconds(120), intensity: { from: 0.2, to: 0.2 }, comments: [] },
{
type: "repeat",
times: 4,
intervals: [
{ type: "Interval", duration: new Seconds(60), intensity: { from: 1, to: 1 }, comments: [] },

View File

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