MCPcopy Index your code
hub / github.com/nodejs/node / InterfaceConstructor

Function InterfaceConstructor

lib/internal/readline/interface.js:160–356  ·  view source on GitHub ↗
(input, output, completer, terminal)

Source from the content-addressed store, hash-verified

158const kAddNewLineOnTTY = Symbol('_addNewLineOnTTY');
159
160function InterfaceConstructor(input, output, completer, terminal) {
161 this[kSawReturnAt] = 0;
162 // TODO(BridgeAR): Document this property. The name is not ideal, so we
163 // might want to expose an alias and document that instead.
164 this.isCompletionEnabled = true;
165 this[kSawKeyPress] = false;
166 this[kPreviousKey] = null;
167 this.escapeCodeTimeout = ESCAPE_CODE_TIMEOUT;
168 this.tabSize = 8;
169
170 FunctionPrototypeCall(EventEmitter, this);
171
172 let crlfDelay;
173 let prompt = '> ';
174 let signal;
175
176 if (input?.input) {
177 // An options object was given
178 output = input.output;
179 completer = input.completer;
180 terminal = input.terminal;
181 signal = input.signal;
182
183 // It is possible to configure the history through the input object
184 const historySize = input.historySize;
185 const history = input.history;
186 const removeHistoryDuplicates = input.removeHistoryDuplicates;
187
188 if (input.tabSize !== undefined) {
189 validateUint32(input.tabSize, 'tabSize', true);
190 this.tabSize = input.tabSize;
191 }
192 if (input.prompt !== undefined) {
193 prompt = input.prompt;
194 }
195 if (input.escapeCodeTimeout !== undefined) {
196 if (NumberIsFinite(input.escapeCodeTimeout)) {
197 this.escapeCodeTimeout = input.escapeCodeTimeout;
198 } else {
199 throw new ERR_INVALID_ARG_VALUE(
200 'input.escapeCodeTimeout',
201 this.escapeCodeTimeout,
202 );
203 }
204 }
205
206 if (signal) {
207 validateAbortSignal(signal, 'options.signal');
208 }
209
210 crlfDelay = input.crlfDelay;
211 input = input.input;
212
213 input.size = historySize;
214 input.history = history;
215 input.removeHistoryDuplicates = removeHistoryDuplicates;
216 }
217

Callers

nothing calls this directly

Calls 9

validateAbortSignalFunction · 0.85
emitKeypressEventsFunction · 0.85
setupHistoryManagerMethod · 0.80
resumeMethod · 0.65
requireFunction · 0.50
addAbortListenerFunction · 0.50
setPromptMethod · 0.45
onMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…