index.d.ts
 1  /// <reference types="node" />
 2  import { Context } from 'vm';
 3  import { CompileOptions } from 'degenerator';
 4  /**
 5   * Returns an asynchronous `FindProxyForURL()` function
 6   * from the given JS string (from a PAC file).
 7   *
 8   * @param {String} str JS string
 9   * @param {Object} opts optional "options" object
10   * @return {Function} async resolver function
11   */
12  declare function createPacResolver(_str: string | Buffer, _opts?: createPacResolver.PacResolverOptions): {
13      (url: string, host?: string | undefined): Promise<string>;
14      (url: string, callback: createPacResolver.FindProxyForURLCallback): void;
15      (url: string, host: string, callback: createPacResolver.FindProxyForURLCallback): void;
16  };
17  declare namespace createPacResolver {
18      type GMT = 'GMT';
19      type Hour = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23;
20      type Day = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31;
21      type Weekday = 'SUN' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT';
22      type Month = 'JAN' | 'FEB' | 'MAR' | 'APR' | 'MAY' | 'JUN' | 'JUL' | 'AUG' | 'SEP' | 'OCT' | 'NOV' | 'DEC';
23      interface PacResolverOptions extends CompileOptions {
24      }
25      interface FindProxyForURLCallback {
26          (err?: Error | null, result?: string): void;
27      }
28      type FindProxyForURL = ReturnType<typeof createPacResolver>;
29      const sandbox: Readonly<Context>;
30  }
31  export = createPacResolver;