UNPKG

@fcc-cdc/it-events

Version:
57 lines (56 loc) 2.56 kB
/// <reference types="node" /> /// <reference types="node" /> /// <reference types="node" /> import 'array-unique-proposal'; import { JSDOM } from 'jsdom'; import { URL } from 'url'; export declare const logTime: <This, Args extends any[], Return>(target: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>) => (...input: Args) => any; export declare function makeDate(raw: string): Date; export declare function stringifyCSV(list: Record<string, any>[]): string; export declare function saveFile(data: string | NodeJS.ArrayBufferView, ...pathParts: string[]): Promise<string>; export declare enum CSSSelectorPrecision { Low = 0, Medium = 1, High = 2 } export declare function getCSSSelector(toElement: Element, fromElement?: Node, precision?: CSSSelectorPrecision): string; export declare function sameParentOf(first: Element, second: Element): ParentNode; export interface Event { title: string; start: Date; end?: Date; address?: string; banner?: URL; link?: URL; tags?: string[]; } /** * @param source - Web URL or document * @param list - CSS Selector of Event container * @param title - CSS Selector of Event title * @param start - CSS Selector of Event start date * @param address - CSS Selector of Event address * @param banner - CSS Selector of Event banner image * @param link - CSS Selector of Event URL * @param tags - CSS Selector of Event tags */ export declare function eventList(source: string | JSDOM, list: string, title: string, start: string, address?: string, banner?: string, link?: string, tags?: string): AsyncGenerator<{ title: string | string[] | URL; start: string | string[] | URL; end?: string | string[] | URL; address?: string | string[] | URL; banner?: string | string[] | URL; link?: string | string[] | URL; tags?: string | string[] | URL; }, void, unknown>; export declare function diffEvent(Old: Event, New: Event): Record<keyof Event, any>; export declare const delay: typeof import("timers/promises").setTimeout; /** * @param list * @param sorter - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters * @param interval - Seconds * * @yield Data from `list` of Iterators */ export declare function mergeStream<T>(list: AsyncIterator<T>[], sorter: (A: T, B: T) => number, interval?: number): AsyncGenerator<T>; export declare function descendDate({ start: A }: Event, { start: B }: Event): number;