mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
readline: use internal addAbortListener
PR-URL: https://github.com/nodejs/node/pull/52081 Refs: https://github.com/nodejs/node/pull/48596 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
d89fc73d45
commit
ff93f3e1a8
3 changed files with 5 additions and 4 deletions
|
@ -145,7 +145,7 @@ Interface.prototype.question = function question(query, options, cb) {
|
|||
const onAbort = () => {
|
||||
this[kQuestionCancel]();
|
||||
};
|
||||
addAbortListener ??= require('events').addAbortListener;
|
||||
addAbortListener ??= require('internal/events/abort_listener').addAbortListener;
|
||||
const disposable = addAbortListener(options.signal, onAbort);
|
||||
const originalCb = cb;
|
||||
cb = typeof cb === 'function' ? (answer) => {
|
||||
|
@ -175,7 +175,7 @@ Interface.prototype.question[promisify.custom] = function question(query, option
|
|||
const onAbort = () => {
|
||||
reject(new AbortError(undefined, { cause: options.signal.reason }));
|
||||
};
|
||||
addAbortListener ??= require('events').addAbortListener;
|
||||
addAbortListener ??= require('internal/events/abort_listener').addAbortListener;
|
||||
const disposable = addAbortListener(options.signal, onAbort);
|
||||
cb = (answer) => {
|
||||
disposable[SymbolDispose]();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue