From 92475e998dd1e99c79cd18987827ca0d442ca57e Mon Sep 17 00:00:00 2001 From: Sebastien Ahkrin Date: Fri, 13 Dec 2019 22:01:47 +0100 Subject: [PATCH] lib: replace Symbol.asyncIterator by SymbolAsyncIterator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30947 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- lib/_stream_readable.js | 4 ++-- lib/internal/fs/dir.js | 3 ++- lib/internal/streams/from.js | 6 +++--- lib/readline.js | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 6226bbf5eb4063..1dcac413caa4f3 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -27,7 +27,7 @@ const { NumberIsNaN, ObjectDefineProperty, ObjectSetPrototypeOf, - Symbol, + SymbolAsyncIterator, } = primordials; module.exports = Readable; @@ -1096,7 +1096,7 @@ Readable.prototype.wrap = function(stream) { return this; }; -Readable.prototype[Symbol.asyncIterator] = function() { +Readable.prototype[SymbolAsyncIterator] = function() { if (createReadableStreamAsyncIterator === undefined) { createReadableStreamAsyncIterator = require('internal/streams/async_iterator'); diff --git a/lib/internal/fs/dir.js b/lib/internal/fs/dir.js index 749e22ee696c6f..1351ce6c245281 100644 --- a/lib/internal/fs/dir.js +++ b/lib/internal/fs/dir.js @@ -3,6 +3,7 @@ const { ObjectDefineProperty, Symbol, + SymbolAsyncIterator, } = primordials; const pathModule = require('path'); @@ -175,7 +176,7 @@ class Dir { } } -ObjectDefineProperty(Dir.prototype, Symbol.asyncIterator, { +ObjectDefineProperty(Dir.prototype, SymbolAsyncIterator, { value: Dir.prototype.entries, enumerable: false, writable: true, diff --git a/lib/internal/streams/from.js b/lib/internal/streams/from.js index 474db60b8930a2..ab6db00a125a0b 100644 --- a/lib/internal/streams/from.js +++ b/lib/internal/streams/from.js @@ -1,7 +1,7 @@ 'use strict'; const { - Symbol, + SymbolAsyncIterator, SymbolIterator } = primordials; const { Buffer } = require('buffer'); @@ -23,8 +23,8 @@ function from(Readable, iterable, opts) { }); } - if (iterable && iterable[Symbol.asyncIterator]) - iterator = iterable[Symbol.asyncIterator](); + if (iterable && iterable[SymbolAsyncIterator]) + iterator = iterable[SymbolAsyncIterator](); else if (iterable && iterable[SymbolIterator]) iterator = iterable[SymbolIterator](); else diff --git a/lib/readline.js b/lib/readline.js index daf30969408222..2823b246519caf 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -37,6 +37,7 @@ const { ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, + SymbolAsyncIterator, } = primordials; const { @@ -1078,7 +1079,7 @@ Interface.prototype._ttyWrite = function(s, key) { } }; -Interface.prototype[Symbol.asyncIterator] = function() { +Interface.prototype[SymbolAsyncIterator] = function() { if (this[kLineObjectStream] === undefined) { if (Readable === undefined) { Readable = require('stream').Readable; @@ -1108,7 +1109,7 @@ Interface.prototype[Symbol.asyncIterator] = function() { this[kLineObjectStream] = readable; } - return this[kLineObjectStream][Symbol.asyncIterator](); + return this[kLineObjectStream][SymbolAsyncIterator](); }; /**