@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
42 lines • 2.19 kB
TypeScript
import { DateAdapter } from '../date-adapter';
import { IOccurrenceGenerator } from '../interfaces';
import { IOperatorConfig, Operator, OperatorFnOutput } from './interface';
declare const INTERSECTION_OPERATOR_ID: unique symbol;
/**
* An operator function, which takes a spread of occurrence generators and only
* returns the dates which intersect every occurrence generator.
*
* Because it's possible for all the generators to never intersect,
* and because the intersection operator can't detect this lack of intersection,
* you must call `intersection()` with a `{maxFailedIterations: number}` argument.
* For convenience, you can globally set `RScheduleConfig.defaultMaxFailedIterations`.
* Without further information, I'd probably set `defaultMaxFailedIterations = 50`.
*
* The `maxFailedIterations` argument caps the number of iterations the operator will
* run through without finding a single valid occurrence. If this number is reached, the operator will
* stop iterating (preventing a possible infinite loop).
*
* - Note: `maxFailedIterations` caps the number of iterations which
* *fail to turn up a single valid occurrence*. Every time a valid occurrence is returned,
* the current iteration count is reset to 0.
*
*/
export declare function intersection<T extends typeof DateAdapter>(args: {
maxFailedIterations?: number;
streams: IOccurrenceGenerator<T>[];
}): OperatorFnOutput<T>;
export declare class IntersectionOperator<T extends typeof DateAdapter> extends Operator<T> {
static isIntersectionOperator(object: unknown): object is IntersectionOperator<any>;
readonly maxFailedIterations?: number;
protected readonly [INTERSECTION_OPERATOR_ID] = true;
constructor(args: {
maxFailedIterations?: number;
streams: IOccurrenceGenerator<T>[];
}, config: IOperatorConfig<T>);
/** Not actually used but necessary for IRunnable interface */
set(_: 'timezone', value: string | null): IntersectionOperator<T>;
protected calculateIsInfinite(): boolean;
protected calculateHasDuration(): boolean;
}
export {};
//# sourceMappingURL=intersection.operator.d.ts.map