UNPKG

1.32 kBTypeScriptView Raw
1import { QueryMethodTypes, IterResultType } from './types';
2export interface IterArgs {
3 inc: boolean;
4 before: Date;
5 after: Date;
6 dt: Date;
7 _value: Date | Date[] | null;
8}
9/**
10 * This class helps us to emulate python's generators, sorta.
11 */
12export default class IterResult<M extends QueryMethodTypes> {
13 readonly method: M;
14 readonly args: Partial<IterArgs>;
15 readonly minDate: Date | null;
16 readonly maxDate: Date | null;
17 _result: Date[];
18 total: number;
19 constructor(method: M, args: Partial<IterArgs>);
20 /**
21 * Possibly adds a date into the result.
22 *
23 * @param {Date} date - the date isn't necessarly added to the result
24 * list (if it is too late/too early)
25 * @return {Boolean} true if it makes sense to continue the iteration
26 * false if we're done.
27 */
28 accept(date: Date): boolean;
29 /**
30 *
31 * @param {Date} date that is part of the result.
32 * @return {Boolean} whether we are interested in more values.
33 */
34 add(date: Date): boolean;
35 /**
36 * 'before' and 'after' return only one date, whereas 'all'
37 * and 'between' an array.
38 * @return {Date,Array?}
39 */
40 getValue(): IterResultType<M>;
41 clone(): IterResult<M>;
42}
43//# sourceMappingURL=iterresult.d.ts.map
\No newline at end of file