mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
AsyncCompleter for readline
Previous Completer interface required implementation of BOTH types (sync and async). Sync type could be assigned to async type, but not vice versa, forcing implementers to always implement the sync interface.
This commit is contained in:
Vendored
+4
-6
@@ -1546,22 +1546,20 @@ declare module "readline" {
|
||||
prependOnceListener(event: "SIGTSTP", listener: () => void): this;
|
||||
}
|
||||
|
||||
export interface Completer {
|
||||
(line: string): CompleterResult;
|
||||
(line: string, callback: (err: any, result: CompleterResult) => void): any;
|
||||
}
|
||||
type Completer = (line: string) => CompleterResult;
|
||||
type AsyncCompleter = (line: string, callback: (err: any, result: CompleterResult) => void) => any;
|
||||
|
||||
export type CompleterResult = [string[], string];
|
||||
|
||||
export interface ReadLineOptions {
|
||||
input: NodeJS.ReadableStream;
|
||||
output?: NodeJS.WritableStream;
|
||||
completer?: Completer;
|
||||
completer?: Completer | AsyncCompleter;
|
||||
terminal?: boolean;
|
||||
historySize?: number;
|
||||
}
|
||||
|
||||
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
|
||||
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine;
|
||||
export function createInterface(options: ReadLineOptions): ReadLine;
|
||||
|
||||
export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
|
||||
|
||||
@@ -1265,6 +1265,12 @@ namespace readline_tests {
|
||||
return [['test'], 'test'];
|
||||
}
|
||||
});
|
||||
result = readline.createInterface({
|
||||
input: input,
|
||||
completer: function(str: string, callback: (err: any, result: readline.CompleterResult) => void): any {
|
||||
callback(null, [['test'], 'test']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user