| 99 | let addAbortListener; |
| 100 | |
| 101 | function Interface(input, output, completer, terminal) { |
| 102 | if (!(this instanceof Interface)) { |
| 103 | return new Interface(input, output, completer, terminal); |
| 104 | } |
| 105 | |
| 106 | if (input?.input && |
| 107 | typeof input.completer === 'function' && input.completer.length !== 2) { |
| 108 | const { completer } = input; |
| 109 | input.completer = (v, cb) => cb(null, completer(v)); |
| 110 | } else if (typeof completer === 'function' && completer.length !== 2) { |
| 111 | const realCompleter = completer; |
| 112 | completer = (v, cb) => cb(null, realCompleter(v)); |
| 113 | } |
| 114 | |
| 115 | FunctionPrototypeCall(InterfaceConstructor, this, |
| 116 | input, output, completer, terminal); |
| 117 | |
| 118 | if (process.env.TERM === 'dumb') { |
| 119 | this._ttyWrite = FunctionPrototypeBind(_ttyWriteDumb, this); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | ObjectSetPrototypeOf(Interface.prototype, _Interface.prototype); |
| 124 | ObjectSetPrototypeOf(Interface, _Interface); |