index.d.ts 1.5 KB

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