UNPKG

@rschedule/rschedule

Version:

A typescript library for working with recurring dates and events.

78 lines 3.73 kB
import { DateAdapter } from '../date-adapter'; import { IDataContainer, OccurrenceGenerator } from '../interfaces'; import { CollectionIterator, ICollectionsArgs, IOccurrencesArgs, OccurrenceIterator } from '../iterators'; import { OccurrenceStream, OperatorFnOutput } from '../operators'; import { DateInput } from '../utilities'; declare const DATES_ID: unique symbol; export declare class Dates<T extends typeof DateAdapter, D = any> extends OccurrenceGenerator<T> implements IDataContainer<D> { /** * Similar to `Array.isArray()`, `isDates()` provides a surefire method * of determining if an object is a `Dates` by checking against the * global symbol registry. */ static isDates(object: unknown): object is Dates<any>; readonly length: number; readonly adapters: ReadonlyArray<InstanceType<T>>; /** Returns the first occurrence or, if there are no occurrences, null. */ readonly firstDate: InstanceType<T> | null; /** Returns the last occurrence or, if there are no occurrences, null. */ readonly lastDate: InstanceType<T> | null; readonly isInfinite = false; readonly hasDuration: boolean; readonly maxDuration: number; readonly timezone: string | null; pipe: (...operatorFns: OperatorFnOutput<T>[]) => OccurrenceStream<T>; /** * Convenience property for holding arbitrary data. Accessible on individual DateAdapters * generated by this `Dates` object via the `DateAdapter#generators` property. Unlike * the rest of the `Dates` object, the data property is mutable. */ data: D; protected readonly [DATES_ID] = true; private readonly datetimes; constructor(args?: { timezone?: string | null; duration?: number; dates?: ReadonlyArray<DateInput<T>>; data?: D; dateAdapter?: T; }); occurrences(args?: IOccurrencesArgs<T>): OccurrenceIterator<T, [this]>; collections(args?: ICollectionsArgs<T>): CollectionIterator<T, [this]>; add(value: DateInput<T>): Dates<T, D>; remove(value: DateInput<T>): Dates<T, D>; /** * Dates are immutable. This allows you to create a new `Dates` with the * specified property changed. * * ### Important! * * When updating `Dates#timezone`, this does not actually change the timezone of the * underlying date objects wrapped by this `Dates` instance. Instead, when this `Dates` * object is iterated and a specific date is found to be * valid, only then is that date converted to the timezone you specify here and returned to * you. * * This distinction might matter when viewing the timezone associated with * `Dates#adapters`. If you wish to update the timezone associated with the `date` objects * this `Dates` is wrapping, you must update the individual dates themselves by setting * the `dates` property. * */ set(prop: 'timezone', value: string | null, options?: { keepLocalTime?: boolean; }): Dates<T, D>; /** * Dates are immutable. This allows you to create a new `Dates` with new date objects. */ set(prop: 'dates', value: DateInput<T>[]): Dates<T, D>; /** * Dates are immutable. This allows you to create a new `Dates` with all of the underlying * date objects set to have the specified `duration`. Duration is a length of time, * expressed in milliseconds. */ set(prop: 'duration', value: number | undefined): Dates<T, D>; filter(fn: (date: InstanceType<T>, index: number, array: ReadonlyArray<InstanceType<T>>) => boolean): Dates<T, D>; } export {}; //# sourceMappingURL=dates.d.ts.map