Skip to content

Commit 22df5dc

Browse files
Sebastien-Ahkrintargos
authored andcommitted
lib: replace Symbol.iterator by SymbolIterator
PR-URL: #30859 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 54aa3b9 commit 22df5dc

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/internal/streams/buffer_list.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const {
4-
Symbol,
4+
SymbolIterator,
55
} = primordials;
66

77
const { Buffer } = require('buffer');
@@ -94,7 +94,7 @@ module.exports = class BufferList {
9494
return this.head.data;
9595
}
9696

97-
*[Symbol.iterator]() {
97+
*[SymbolIterator]() {
9898
for (let p = this.head; p; p = p.next) {
9999
yield p.data;
100100
}

lib/internal/streams/from.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
Symbol,
5+
SymbolIterator
56
} = primordials;
67

78
const {
@@ -12,8 +13,8 @@ function from(Readable, iterable, opts) {
1213
let iterator;
1314
if (iterable && iterable[Symbol.asyncIterator])
1415
iterator = iterable[Symbol.asyncIterator]();
15-
else if (iterable && iterable[Symbol.iterator])
16-
iterator = iterable[Symbol.iterator]();
16+
else if (iterable && iterable[SymbolIterator])
17+
iterator = iterable[SymbolIterator]();
1718
else
1819
throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
1920

lib/internal/url.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
ReflectGetOwnPropertyDescriptor,
1313
ReflectOwnKeys,
1414
Symbol,
15+
SymbolIterator,
1516
} = primordials;
1617

1718
const { inspect } = require('internal/util/inspect');
@@ -87,7 +88,7 @@ const kFormat = Symbol('format');
8788

8889
// https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
8990
const IteratorPrototype = ObjectGetPrototypeOf(
90-
ObjectGetPrototypeOf([][Symbol.iterator]())
91+
ObjectGetPrototypeOf([][SymbolIterator]())
9192
);
9293

9394
const unpairedSurrogateRe =
@@ -139,8 +140,8 @@ class URLSearchParams {
139140
if (init === null || init === undefined) {
140141
this[searchParams] = [];
141142
} else if (typeof init === 'object' || typeof init === 'function') {
142-
const method = init[Symbol.iterator];
143-
if (method === this[Symbol.iterator]) {
143+
const method = init[SymbolIterator];
144+
if (method === this[SymbolIterator]) {
144145
// While the spec does not have this branch, we can use it as a
145146
// shortcut to avoid having to go through the costly generic iterator.
146147
const childParams = init[searchParams];
@@ -156,7 +157,7 @@ class URLSearchParams {
156157
for (const pair of init) {
157158
if ((typeof pair !== 'object' && typeof pair !== 'function') ||
158159
pair === null ||
159-
typeof pair[Symbol.iterator] !== 'function') {
160+
typeof pair[SymbolIterator] !== 'function') {
160161
throw new ERR_INVALID_TUPLE('Each query pair', '[name, value]');
161162
}
162163
const convertedPair = [];
@@ -1149,7 +1150,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
11491150
});
11501151

11511152
// https://heycam.github.io/webidl/#es-iterable-entries
1152-
ObjectDefineProperty(URLSearchParams.prototype, Symbol.iterator, {
1153+
ObjectDefineProperty(URLSearchParams.prototype, SymbolIterator, {
11531154
writable: true,
11541155
configurable: true,
11551156
value: URLSearchParams.prototype.entries

0 commit comments

Comments
 (0)