portfinder.d.ts 779 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * portfinder.js typescript definitions.
  3. *
  4. * (C) 2011, Charlie Robbins
  5. */
  6. type PortfinderCallback = (err: Error, port: number) => void;
  7. interface PortFinderOptions{
  8. /**
  9. * Host to find available port on.
  10. */
  11. host?: string;
  12. /**
  13. * Minimum port (takes precedence over `basePort`).
  14. */
  15. port?: number;
  16. }
  17. /**
  18. * The lowest port to begin any port search from.
  19. */
  20. export let basePort: number;
  21. /**
  22. * Responds with a unbound port on the current machine.
  23. */
  24. export function getPort(callback: PortfinderCallback): void;
  25. export function getPort(options: PortFinderOptions, callback: PortfinderCallback): void;
  26. /**
  27. * Responds a promise of an unbound port on the current machine.
  28. */
  29. export function getPortPromise(options?: PortFinderOptions): Promise<number>;