@rschedule/rschedule
Version:
A typescript library for working with recurring dates and events.
75 lines (71 loc) • 2.66 kB
TypeScript
import { DateAdapter } from '../date-adapter';
import { OccurrenceGenerator } from '../interfaces';
import { Operator, OperatorFnOutput } from './interface';
declare const OCCURRENCE_STREAM_ID: unique symbol;
/**
* `OccurrenceStream` allows you to combine occurrence generators using
* operator functions to produce new, complex recurrence schedules.
* For example: internally, `Schedule` relies on an `OccurrenceStream` to combine
* rrules, exrules, rdates, and exdates appropriately.
*
* ### Example
```
const schedule1 = new Schedule();
const schedule2 = new Rule();
const dates = new Dates();
const stream = new OccurrenceStream({
operators: [
add(schedule1),
subtract(schedule2, dates)
]
})
stream.occurrences().toArray() // occurrences
new Calendar({ schedules: stream }).occurrences().toArray() // occurrences
```
* In general, you should not need to manually create an `OccurrenceStream`.
* Instead, you can use `OccurrenceGenerater#pipe()` to pass an occurrence
* generator's occurrences through various operator functions (similar to
* rxjs pipes).
*
* ### Example
```
const schedule = new Schedule().pipe(
add(schedule1),
subtract(schedule2, dates)
)
schedule.occurrences().toArray() // occurrences
```
*
* Operator functions:
* - add()
* - subtract()
* - intersection()
* - unique()
*/
export declare class OccurrenceStream<T extends typeof DateAdapter> extends OccurrenceGenerator<T> {
/**
* Similar to `Array.isArray()`, `isOccurrenceStream()` provides a surefire method
* of determining if an object is an `OccurrenceStream` by checking against the
* global symbol registry.
*/
static isOccurrenceStream(object: unknown): object is OccurrenceStream<any>;
pipe: (...operatorFns: OperatorFnOutput<T>[]) => OccurrenceStream<T>;
readonly isInfinite: boolean;
readonly hasDuration: boolean;
readonly timezone: string | null;
readonly operators: ReadonlyArray<Operator<T>>;
protected readonly [OCCURRENCE_STREAM_ID] = true;
private readonly lastOperator;
constructor(args: {
operators: OperatorFnOutput<T>[] | Operator<T>[];
dateAdapter?: T;
timezone?: string | null;
});
set(prop: 'timezone', value: string | null, options?: {
keepLocalTime?: boolean;
}): OccurrenceStream<T>;
private emptyIterator;
}
export declare function pipeFn<T extends typeof DateAdapter>(self: OccurrenceGenerator<T>): (...operatorFns: OperatorFnOutput<T>[]) => OccurrenceStream<T>;
export {};
//# sourceMappingURL=occurrence-stream.d.ts.map