Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

readline.d.ts 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. declare module "readline" {
  2. import * as events from "events";
  3. import * as stream from "stream";
  4. interface Key {
  5. sequence?: string;
  6. name?: string;
  7. ctrl?: boolean;
  8. meta?: boolean;
  9. shift?: boolean;
  10. }
  11. class Interface extends events.EventEmitter {
  12. readonly terminal: boolean;
  13. /**
  14. * NOTE: According to the documentation:
  15. *
  16. * > Instances of the `readline.Interface` class are constructed using the
  17. * > `readline.createInterface()` method.
  18. *
  19. * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
  20. */
  21. protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
  22. /**
  23. * NOTE: According to the documentation:
  24. *
  25. * > Instances of the `readline.Interface` class are constructed using the
  26. * > `readline.createInterface()` method.
  27. *
  28. * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
  29. */
  30. protected constructor(options: ReadLineOptions);
  31. setPrompt(prompt: string): void;
  32. prompt(preserveCursor?: boolean): void;
  33. question(query: string, callback: (answer: string) => void): void;
  34. pause(): this;
  35. resume(): this;
  36. close(): void;
  37. write(data: string | Buffer, key?: Key): void;
  38. /**
  39. * events.EventEmitter
  40. * 1. close
  41. * 2. line
  42. * 3. pause
  43. * 4. resume
  44. * 5. SIGCONT
  45. * 6. SIGINT
  46. * 7. SIGTSTP
  47. */
  48. addListener(event: string, listener: (...args: any[]) => void): this;
  49. addListener(event: "close", listener: () => void): this;
  50. addListener(event: "line", listener: (input: string) => void): this;
  51. addListener(event: "pause", listener: () => void): this;
  52. addListener(event: "resume", listener: () => void): this;
  53. addListener(event: "SIGCONT", listener: () => void): this;
  54. addListener(event: "SIGINT", listener: () => void): this;
  55. addListener(event: "SIGTSTP", listener: () => void): this;
  56. emit(event: string | symbol, ...args: any[]): boolean;
  57. emit(event: "close"): boolean;
  58. emit(event: "line", input: string): boolean;
  59. emit(event: "pause"): boolean;
  60. emit(event: "resume"): boolean;
  61. emit(event: "SIGCONT"): boolean;
  62. emit(event: "SIGINT"): boolean;
  63. emit(event: "SIGTSTP"): boolean;
  64. on(event: string, listener: (...args: any[]) => void): this;
  65. on(event: "close", listener: () => void): this;
  66. on(event: "line", listener: (input: string) => void): this;
  67. on(event: "pause", listener: () => void): this;
  68. on(event: "resume", listener: () => void): this;
  69. on(event: "SIGCONT", listener: () => void): this;
  70. on(event: "SIGINT", listener: () => void): this;
  71. on(event: "SIGTSTP", listener: () => void): this;
  72. once(event: string, listener: (...args: any[]) => void): this;
  73. once(event: "close", listener: () => void): this;
  74. once(event: "line", listener: (input: string) => void): this;
  75. once(event: "pause", listener: () => void): this;
  76. once(event: "resume", listener: () => void): this;
  77. once(event: "SIGCONT", listener: () => void): this;
  78. once(event: "SIGINT", listener: () => void): this;
  79. once(event: "SIGTSTP", listener: () => void): this;
  80. prependListener(event: string, listener: (...args: any[]) => void): this;
  81. prependListener(event: "close", listener: () => void): this;
  82. prependListener(event: "line", listener: (input: string) => void): this;
  83. prependListener(event: "pause", listener: () => void): this;
  84. prependListener(event: "resume", listener: () => void): this;
  85. prependListener(event: "SIGCONT", listener: () => void): this;
  86. prependListener(event: "SIGINT", listener: () => void): this;
  87. prependListener(event: "SIGTSTP", listener: () => void): this;
  88. prependOnceListener(event: string, listener: (...args: any[]) => void): this;
  89. prependOnceListener(event: "close", listener: () => void): this;
  90. prependOnceListener(event: "line", listener: (input: string) => void): this;
  91. prependOnceListener(event: "pause", listener: () => void): this;
  92. prependOnceListener(event: "resume", listener: () => void): this;
  93. prependOnceListener(event: "SIGCONT", listener: () => void): this;
  94. prependOnceListener(event: "SIGINT", listener: () => void): this;
  95. prependOnceListener(event: "SIGTSTP", listener: () => void): this;
  96. [Symbol.asyncIterator](): AsyncIterableIterator<string>;
  97. }
  98. type ReadLine = Interface; // type forwarded for backwards compatiblity
  99. type Completer = (line: string) => CompleterResult;
  100. type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => any;
  101. type CompleterResult = [string[], string];
  102. interface ReadLineOptions {
  103. input: NodeJS.ReadableStream;
  104. output?: NodeJS.WritableStream;
  105. completer?: Completer | AsyncCompleter;
  106. terminal?: boolean;
  107. historySize?: number;
  108. prompt?: string;
  109. crlfDelay?: number;
  110. removeHistoryDuplicates?: boolean;
  111. }
  112. function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
  113. function createInterface(options: ReadLineOptions): Interface;
  114. function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number): void;
  115. function emitKeypressEvents(stream: NodeJS.ReadableStream, interface?: Interface): void;
  116. function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
  117. function clearLine(stream: NodeJS.WritableStream, dir: number): void;
  118. function clearScreenDown(stream: NodeJS.WritableStream): void;
  119. }