Add comments support to AST
This commit is contained in:
parent
77bfbbd0a8
commit
fa8f0c70ad
|
|
@ -12,4 +12,10 @@ export type Interval = {
|
||||||
duration: number;
|
duration: number;
|
||||||
intensity: { from: number; to: number };
|
intensity: { from: number; to: number };
|
||||||
cadence?: number;
|
cadence?: number;
|
||||||
|
comments: Comment[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Comment = {
|
||||||
|
offset: number;
|
||||||
|
text: string;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ Rest: 5:00 45%
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"cadence": undefined,
|
"cadence": undefined,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 300,
|
"duration": 300,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -70,6 +71,7 @@ Rest: 5:00 45%
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"cadence": 90,
|
"cadence": 90,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 600,
|
"duration": 600,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.8,
|
"from": 0.8,
|
||||||
|
|
@ -79,6 +81,7 @@ Rest: 5:00 45%
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"cadence": undefined,
|
"cadence": undefined,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 300,
|
"duration": 300,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.45,
|
"from": 0.45,
|
||||||
|
|
@ -102,6 +105,7 @@ Cooldown: 5:30 70%..45%
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"cadence": 100,
|
"cadence": 100,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 330,
|
"duration": 330,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -111,6 +115,7 @@ Cooldown: 5:30 70%..45%
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"cadence": undefined,
|
"cadence": undefined,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 330,
|
"duration": 330,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.7,
|
"from": 0.7,
|
||||||
|
|
@ -140,6 +145,7 @@ Cooldown: 5:30 70%..45%
|
||||||
expect(parseInterval("Interval: 50% 00:10")).toMatchInlineSnapshot(`
|
expect(parseInterval("Interval: 50% 00:10")).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"cadence": undefined,
|
"cadence": undefined,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 10,
|
"duration": 10,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -151,6 +157,7 @@ Cooldown: 5:30 70%..45%
|
||||||
expect(parseInterval("Interval: 50% 100rpm 00:10")).toMatchInlineSnapshot(`
|
expect(parseInterval("Interval: 50% 100rpm 00:10")).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"cadence": 100,
|
"cadence": 100,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 10,
|
"duration": 10,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -162,6 +169,7 @@ Cooldown: 5:30 70%..45%
|
||||||
expect(parseInterval("Interval: 100rpm 00:10 50%")).toMatchInlineSnapshot(`
|
expect(parseInterval("Interval: 100rpm 00:10 50%")).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"cadence": 100,
|
"cadence": 100,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 10,
|
"duration": 10,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -176,6 +184,7 @@ Cooldown: 5:30 70%..45%
|
||||||
expect(parseInterval("Interval: 50% 00:10 100rpm")).toMatchInlineSnapshot(`
|
expect(parseInterval("Interval: 50% 00:10 100rpm")).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"cadence": 100,
|
"cadence": 100,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 10,
|
"duration": 10,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
@ -187,6 +196,7 @@ Cooldown: 5:30 70%..45%
|
||||||
expect(parseInterval("Interval: \t 50% \t 00:10 \t\t 100rpm \t")).toMatchInlineSnapshot(`
|
expect(parseInterval("Interval: \t 50% \t 00:10 \t\t 100rpm \t")).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
"cadence": 100,
|
"cadence": 100,
|
||||||
|
"comments": Array [],
|
||||||
"duration": 10,
|
"duration": 10,
|
||||||
"intensity": Object {
|
"intensity": Object {
|
||||||
"from": 0.5,
|
"from": 0.5,
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ const parseIntervals = (tokens: Token[]): Interval[] => {
|
||||||
duration,
|
duration,
|
||||||
intensity,
|
intensity,
|
||||||
cadence,
|
cadence,
|
||||||
|
comments: [],
|
||||||
});
|
});
|
||||||
tokens = rest;
|
tokens = rest;
|
||||||
} else if (token.type === "text" && token.value === "") {
|
} else if (token.type === "text" && token.value === "") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue