(query, options = kEmptyObject)
| 28 | |
| 29 | class Interface extends _Interface { |
| 30 | question(query, options = kEmptyObject) { |
| 31 | return new Promise((resolve, reject) => { |
| 32 | let cb = resolve; |
| 33 | |
| 34 | if (options?.signal) { |
| 35 | validateAbortSignal(options.signal, 'options.signal'); |
| 36 | if (options.signal.aborted) { |
| 37 | return reject( |
| 38 | new AbortError(undefined, { cause: options.signal.reason })); |
| 39 | } |
| 40 | |
| 41 | const onAbort = () => { |
| 42 | this[kQuestionCancel](); |
| 43 | reject(new AbortError(undefined, { cause: options.signal.reason })); |
| 44 | }; |
| 45 | addAbortListener ??= require('internal/events/abort_listener').addAbortListener; |
| 46 | const disposable = addAbortListener(options.signal, onAbort); |
| 47 | |
| 48 | cb = (answer) => { |
| 49 | disposable[SymbolDispose](); |
| 50 | resolve(answer); |
| 51 | }; |
| 52 | } |
| 53 | |
| 54 | this[kQuestionReject] = reject; |
| 55 | |
| 56 | this[kQuestion](query, cb); |
| 57 | }); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | function createInterface(input, output, completer, terminal) { |
no test coverage detected