From ea36fe1680180747cac6cd2dcfaa31213b34dbec Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 23 Mar 2023 15:44:58 +0700 Subject: [PATCH] move `Iterator.range` proposal to Stage 2 https://github.com/babel/proposals/issues/87#issuecomment-1480266760 --- CHANGELOG.md | 1 + README.md | 48 ++++++++++++++++++------------------- packages/core-js/stage/1.js | 1 - packages/core-js/stage/2.js | 1 + 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 422b10e36e88..7e257f40b52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog ##### Unreleased +- [`Iterator.range` proposal](https://github.com/tc39/proposal-Number.range) moved to Stage 2, [March 2023 TC39 meeting](https://github.com/babel/proposals/issues/87#issuecomment-1480266760) - `(Async)DisposableStack.prototype.move` marks the original stack as disposed, [#1226](https://github.com/zloirock/core-js/issues/1226) - Compat data improvements: - [`URLSearchParams.prototype.size`](https://github.com/whatwg/url/pull/734) marked as supported from FF112, NodeJS 19.8 and Deno 1.32 diff --git a/README.md b/README.md index 3550f31f023e..d68787c6e2b5 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,7 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [Well-formed unicode strings](#well-formed-unicode-strings) - [Stage 2 proposals](#stage-2-proposals) - [`AsyncIterator` helpers](#asynciterator-helpers) + - [`Iterator.range`](#iteratorrange) - [`Map.prototype.emplace`](#mapprototypeemplace) - [`Array.isTemplateObject`](#arrayistemplateobject) - [`String.dedent`](#stringdedent) @@ -175,7 +176,6 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`Array` filtering](#array-filtering) - [`Array` deduplication](#array-deduplication) - [Getting last item from `Array`](#getting-last-item-from-array) - - [`Iterator.range`](#iteratorrange) - [`Number.fromString`](#numberfromstring) - [`Math` extensions](#math-extensions) - [`Math.signbit`](#mathsignbit) @@ -2473,6 +2473,29 @@ require('core-js/actual/async-iterator'); (async function * () { /* empty */ })() instanceof AsyncIterator; // => true ``` +##### [`Iterator.range`](https://github.com/tc39/proposal-Number.range)[⬆](#index) +Module [`esnext.iterator.range`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.range.js) +```js +class Iterator { + range(start: number, end: number, options: { step: number = 1, inclusive: boolean = false } | step: number = 1): NumericRangeIterator; + range(start: bigint, end: bigint | Infinity | -Infinity, options: { step: bigint = 1n, inclusive: boolean = false } | step: bigint = 1n): NumericRangeIterator; +} +``` +[*CommonJS entry points:*](#commonjs-api) +```js +core-js/proposals/number-range +core-js(-pure)/full/iterator/range +``` +[*Example*](https://tinyurl.com/2gobe777): +```js +for (const i of Iterator.range(1, 10)) { + console.log(i); // => 1, 2, 3, 4, 5, 6, 7, 8, 9 +} + +for (const i of Iterator.range(1, 10, { step: 3, inclusive: true })) { + console.log(i); // => 1, 4, 7, 10 +} +``` ##### [`Map.prototype.emplace`](https://github.com/thumbsupep/proposal-upsert)[⬆](#index) Modules [`esnext.map.emplace`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.map.emplace.js) and [`esnext.weak-map.emplace`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.weak-map.emplace.js) ```js @@ -2852,29 +2875,6 @@ array.lastItem = 4; array; // => [1, 2, 4] ``` -##### [`Iterator.range`](https://github.com/tc39/proposal-Number.range)[⬆](#index) -Module [`esnext.iterator.range`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.iterator.range.js) -```js -class Iterator { - range(start: number, end: number, options: { step: number = 1, inclusive: boolean = false } | step: number = 1): NumericRangeIterator; - range(start: bigint, end: bigint | Infinity | -Infinity, options: { step: bigint = 1n, inclusive: boolean = false } | step: bigint = 1n): NumericRangeIterator; -} -``` -[*CommonJS entry points:*](#commonjs-api) -```js -core-js/proposals/number-range -core-js(-pure)/full/iterator/range -``` -[*Example*](https://tinyurl.com/2gobe777): -```js -for (const i of Iterator.range(1, 10)) { - console.log(i); // => 1, 2, 3, 4, 5, 6, 7, 8, 9 -} - -for (const i of Iterator.range(1, 10, { step: 3, inclusive: true })) { - console.log(i); // => 1, 4, 7, 10 -} -``` ##### [`Number.fromString`](https://github.com/tc39/proposal-number-fromstring)[⬆](#index) Module [`esnext.number.from-string`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.number.from-string.js) ```js diff --git a/packages/core-js/stage/1.js b/packages/core-js/stage/1.js index f17677d3d767..24c86acd89d4 100644 --- a/packages/core-js/stage/1.js +++ b/packages/core-js/stage/1.js @@ -5,7 +5,6 @@ require('../proposals/array-last'); require('../proposals/array-unique'); require('../proposals/collection-methods'); require('../proposals/collection-of-from'); -require('../proposals/iterator-range'); require('../proposals/keys-composition'); require('../proposals/math-extensions'); require('../proposals/math-signbit'); diff --git a/packages/core-js/stage/2.js b/packages/core-js/stage/2.js index 4cf2a06ad840..cd1360fb933b 100644 --- a/packages/core-js/stage/2.js +++ b/packages/core-js/stage/2.js @@ -4,6 +4,7 @@ require('../proposals/array-is-template-object'); require('../proposals/async-explicit-resource-management'); require('../proposals/async-iterator-helpers'); require('../proposals/decorator-metadata'); +require('../proposals/iterator-range'); require('../proposals/map-upsert-stage-2'); require('../proposals/string-dedent'); require('../proposals/symbol-predicates');