@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
51 lines • 2.52 kB
TypeScript
import { DateTime } from '../../date-time';
import { INormalizedRuleOptions } from '../rule-options';
import { Omit } from '../../basic-utilities';
import { IRunArgs } from '../../interfaces';
import { FrequencyPipe } from './01-frequency.pipe';
import { RevFrequencyPipe } from './rev-01-frequency.pipe';
export declare class PipeController {
readonly options: INormalizedRuleOptions;
private readonly args;
readonly firstPipe: FrequencyPipe | RevFrequencyPipe;
readonly start: DateTime;
readonly end?: DateTime;
readonly reverse: boolean;
readonly isInfinite: boolean;
readonly hasDuration: boolean;
private readonly reversePipes;
private readonly pipes;
constructor(options: INormalizedRuleOptions, args: Omit<IRunArgs, 'take'>);
/**
* In the pipe controller, we have an extra level of indirection with
* the `run()` and `iterate()` methods. The `iterate()` method is the
* method which actually runs the logic in the pipes. If we didn't
* need to account for the `count` property of a rule, we would *only*
* need the iterate method... so much simpler. But we do need to account
* for rules with a `count` property.
*
* Rules with a `count` property need to begin iteration at the beginning
* because the `count` is always from the rule's start time. So if someone
* passes in a new start time as an argument to a rule with `count`, we
* need to secretly iterate from the beginning, tracking the number of
* iterations, and then only start yielding dates when we reach the section
* the user cares about (or, if we hit our `count` quota, cancel iterating).
*
* Additionally, we need to handle iterating in reverse. In this case, we build
* up a cache of dates between the rule's start time and the reverse iteration
* start date. Once we hit the reverse iteration start date, we start
* yielding dates in the cache, in reverse order.
*
* In general, I imagine the count number, if used, will be small. But a large
* count will definitely have a negative performance affect. I don't think
* there's anything to be done about this.
*/
readonly _run: () => IterableIterator<DateTime>;
private iterateWithReverseCount;
private iterateWithCount;
private iterate;
private initialize;
private addPipe;
private normalizeRunOutput;
}
//# sourceMappingURL=pipe-controller.d.ts.map