MCPcopy Create free account
hub / github.com/ReactiveX/rxjs / parseTimingPlan

Function parseTimingPlan

packages/test/src/marble-parser.ts:268–312  ·  view source on GitHub ↗
(plan: MarbleTimingPlan)

Source from the content-addressed store, hash-verified

266}
267
268export function parseTimingPlan(plan: MarbleTimingPlan): number[] {
269 if (typeof plan !== 'string') {
270 let previous = -Infinity;
271 return plan.map((time) => {
272 const valid = validateDuration(time);
273 if (valid <= previous) {
274 throw new Error('Timing plan entries must be strictly increasing absolute times.');
275 }
276 previous = valid;
277 return valid;
278 });
279 }
280
281 const characters = [...plan];
282 const opportunities: number[] = [];
283 let frame = 0;
284
285 for (let index = 0; index < characters.length; index++) {
286 const character = characters[index];
287 if (character === undefined) {
288 break;
289 }
290 if (isWhitespace(character)) {
291 continue;
292 }
293
294 const duration = readDuration(characters, index);
295 if (duration) {
296 frame += duration.milliseconds;
297 index += duration.length - 1;
298 continue;
299 }
300
301 if (character === '-') {
302 frame += 1;
303 continue;
304 }
305 if ('|#^!()'.includes(character)) {
306 throw new Error(`Timing plans cannot contain the reserved marker "${character}".`);
307 }
308 opportunities.push(frame);
309 frame += 1;
310 }
311 return opportunities;
312}
313
314export function toSubscriptionLog(subscription: ParsedSubscription): ParsedSubscription {
315 return {

Callers 3

configureAnimationMethod · 0.85
configureIdleMethod · 0.85

Calls 5

validateDurationFunction · 0.85
isWhitespaceFunction · 0.85
readDurationFunction · 0.85
includesMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected