Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: replace Symbol.iterator by SymbolIterator #30859

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const {
Symbol,
SymbolIterator,
} = primordials;

const { Buffer } = require('buffer');
Expand Down Expand Up @@ -94,7 +94,7 @@ module.exports = class BufferList {
return this.head.data;
}

*[Symbol.iterator]() {
*[SymbolIterator]() {
for (let p = this.head; p; p = p.next) {
yield p.data;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/internal/streams/from.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
Symbol,
SymbolIterator
} = primordials;

const {
Expand All @@ -12,8 +13,8 @@ function from(Readable, iterable, opts) {
let iterator;
if (iterable && iterable[Symbol.asyncIterator])
iterator = iterable[Symbol.asyncIterator]();
else if (iterable && iterable[Symbol.iterator])
iterator = iterable[Symbol.iterator]();
else if (iterable && iterable[SymbolIterator])
iterator = iterable[SymbolIterator]();
else
throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);

Expand Down
11 changes: 6 additions & 5 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
ReflectGetOwnPropertyDescriptor,
ReflectOwnKeys,
Symbol,
SymbolIterator,
} = primordials;

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

// https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
const IteratorPrototype = ObjectGetPrototypeOf(
ObjectGetPrototypeOf([][Symbol.iterator]())
ObjectGetPrototypeOf([][SymbolIterator]())
);

const unpairedSurrogateRe =
Expand Down Expand Up @@ -139,8 +140,8 @@ class URLSearchParams {
if (init === null || init === undefined) {
this[searchParams] = [];
} else if (typeof init === 'object' || typeof init === 'function') {
const method = init[Symbol.iterator];
if (method === this[Symbol.iterator]) {
const method = init[SymbolIterator];
if (method === this[SymbolIterator]) {
// While the spec does not have this branch, we can use it as a
// shortcut to avoid having to go through the costly generic iterator.
const childParams = init[searchParams];
Expand All @@ -156,7 +157,7 @@ class URLSearchParams {
for (const pair of init) {
if ((typeof pair !== 'object' && typeof pair !== 'function') ||
pair === null ||
typeof pair[Symbol.iterator] !== 'function') {
typeof pair[SymbolIterator] !== 'function') {
throw new ERR_INVALID_TUPLE('Each query pair', '[name, value]');
}
const convertedPair = [];
Expand Down Expand Up @@ -1149,7 +1150,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', {
});

// https://heycam.github.io/webidl/#es-iterable-entries
ObjectDefineProperty(URLSearchParams.prototype, Symbol.iterator, {
ObjectDefineProperty(URLSearchParams.prototype, SymbolIterator, {
writable: true,
configurable: true,
value: URLSearchParams.prototype.entries
Expand Down