Skip to content

Commit

Permalink
lib: replace Symbol.iterator by SymbolIterator
Browse files Browse the repository at this point in the history
PR-URL: #30859
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Sebastien-Ahkrin authored and targos committed Dec 11, 2019
1 parent 11465d3 commit c101251
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/internal/streams/buffer_list.js
@@ -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
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
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

0 comments on commit c101251

Please sign in to comment.