Skip to content

Commit 1d49e82

Browse files
committed
[JSC] merge Iterator.prototype.sliding into Iterator.prototype.windows
https://bugs.webkit.org/show_bug.cgi?id=299380 Reviewed by Yusuke Suzuki. Rather than having two different methods that are almost identical, merge them into one with an argument to control the behavior. - `iter.windows(num)` and `iter.windows(num, "only-full")` behave the same as before. - `iter.windows(num, "allow-partial")` behaves the same as `iter.sliding(num)`. Proposal: <https://github.com/tc39/proposal-iterator-chunking> Spec: <https://tc39.es/proposal-iterator-chunking/> * Source/JavaScriptCore/builtins/JSIteratorPrototype.js: (windows): (sliding): Deleted. * Source/JavaScriptCore/runtime/JSIteratorPrototype.cpp: (JSC::JSIteratorPrototype::finishCreation): * JSTests/stress/iterator-prototype-sliding.js: Removed. * JSTests/stress/iterator-prototype-windows.js: * JSTests/stress/iterator-prototype-chunks.js: Drive-by: tweak wording of error messages for clarity. Canonical link: https://commits.webkit.org/300551@main
1 parent 2d11a78 commit 1d49e82

File tree

5 files changed

+235
-239
lines changed

5 files changed

+235
-239
lines changed

JSTests/stress/iterator-prototype-chunks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function shouldThrow(fn, error, message) {
151151
for (const invalidChunkSize of invalidChunkSizes) {
152152
shouldThrow(function () {
153153
Iterator.prototype.chunks.call(validIter, invalidChunkSize);
154-
}, RangeError, "Iterator.prototype.chunks requires that argument not be NaN.");
154+
}, RangeError, "Iterator.prototype.chunks requires that first argument not be NaN.");
155155
}
156156
}
157157

@@ -166,6 +166,6 @@ function shouldThrow(fn, error, message) {
166166
for (const invalidChunkSize of invalidChunkSizes) {
167167
shouldThrow(function () {
168168
Iterator.prototype.chunks.call(validIter, invalidChunkSize);
169-
}, RangeError, "Iterator.prototype.chunks requires that argument be between 1 and 2**32 - 1.");
169+
}, RangeError, "Iterator.prototype.chunks requires that first argument be between 1 and 2**32 - 1.");
170170
}
171171
}

JSTests/stress/iterator-prototype-sliding.js

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)