Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4e99b1

Browse filesBrowse files
authored
stream: remove asIndexedPairs
PR-URL: #48150 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent d402e2a commit d4e99b1
Copy full SHA for d4e99b1

File tree

Expand file treeCollapse file tree

4 files changed

+0
-125
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+0
-125
lines changed
Open diff view settings
Collapse file

‎doc/api/stream.md‎

Copy file name to clipboardExpand all lines: doc/api/stream.md
-31Lines changed: 0 additions & 31 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2447,37 +2447,6 @@ import { Readable } from 'node:stream';
24472447
await Readable.from([1, 2, 3, 4]).take(2).toArray(); // [1, 2]
24482448
```
24492449

2450-
##### `readable.asIndexedPairs([options])`
2451-
2452-
<!-- YAML
2453-
added:
2454-
- v17.5.0
2455-
- v16.15.0
2456-
changes:
2457-
- version: v20.3.0
2458-
pr-url: https://github.com/nodejs/node/pull/48102
2459-
description: Using the `asIndexedPairs` method emits a runtime warning that
2460-
it will be removed in a future version.
2461-
-->
2462-
2463-
> Stability: 1 - Experimental
2464-
2465-
* `options` {Object}
2466-
* `signal` {AbortSignal} allows destroying the stream if the signal is
2467-
aborted.
2468-
* Returns: {Readable} a stream of indexed pairs.
2469-
2470-
This method returns a new stream with chunks of the underlying stream paired
2471-
with a counter in the form `[index, chunk]`. The first index value is 0 and it
2472-
increases by 1 for each chunk produced.
2473-
2474-
```mjs
2475-
import { Readable } from 'node:stream';
2476-
2477-
const pairs = await Readable.from(['a', 'b', 'c']).asIndexedPairs().toArray();
2478-
console.log(pairs); // [[0, 'a'], [1, 'b'], [2, 'c']]
2479-
```
2480-
24812450
##### `readable.reduce(fn[, initial[, options]])`
24822451

24832452
<!-- YAML
Collapse file

‎lib/internal/streams/operators.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/operators.js
-21Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const {
2323
addAbortSignalNoValidate,
2424
} = require('internal/streams/add-abort-signal');
2525
const { isWritable, isNodeStream } = require('internal/streams/utils');
26-
const { deprecate } = require('internal/util');
2726

2827
const {
2928
ArrayPrototypePush,
@@ -199,25 +198,6 @@ function map(fn, options) {
199198
}.call(this);
200199
}
201200

202-
function asIndexedPairs(options = undefined) {
203-
if (options != null) {
204-
validateObject(options, 'options');
205-
}
206-
if (options?.signal != null) {
207-
validateAbortSignal(options.signal, 'options.signal');
208-
}
209-
210-
return async function* asIndexedPairs() {
211-
let index = 0;
212-
for await (const val of this) {
213-
if (options?.signal?.aborted) {
214-
throw new AbortError({ cause: options.signal.reason });
215-
}
216-
yield [index++, val];
217-
}
218-
}.call(this);
219-
}
220-
221201
async function some(fn, options = undefined) {
222202
for await (const unused of filter.call(this, fn, options)) {
223203
return true;
@@ -421,7 +401,6 @@ function take(number, options = undefined) {
421401
}
422402

423403
module.exports.streamReturningOperators = {
424-
asIndexedPairs: deprecate(asIndexedPairs, 'readable.asIndexedPairs will be removed in a future version.'),
425404
drop,
426405
filter,
427406
flatMap,
Collapse file

‎test/parallel/test-stream-asIndexedPairs.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-asIndexedPairs.mjs
-53Lines changed: 0 additions & 53 deletions
This file was deleted.
Collapse file

‎test/parallel/test-stream-iterator-helpers-test262-tests.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-iterator-helpers-test262-tests.mjs
-20Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,6 @@ import assert from 'assert';
4848

4949
// Note all the tests that check AsyncIterator's prototype itself and things
5050
// that happen before stream conversion were not ported.
51-
{
52-
// asIndexedPairs/is-function
53-
assert.strictEqual(typeof Readable.prototype.asIndexedPairs, 'function');
54-
// asIndexedPairs/indexed-pairs.js
55-
const iterator = Readable.from([0, 1]);
56-
const indexedPairs = iterator.asIndexedPairs();
57-
58-
for await (const [i, v] of indexedPairs) {
59-
assert.strictEqual(i, v);
60-
}
61-
// asIndexedPairs/length.js
62-
assert.strictEqual(Readable.prototype.asIndexedPairs.length, 0);
63-
const descriptor = Object.getOwnPropertyDescriptor(
64-
Readable.prototype,
65-
'asIndexedPairs'
66-
);
67-
assert.strictEqual(descriptor.enumerable, false);
68-
assert.strictEqual(descriptor.configurable, true);
69-
assert.strictEqual(descriptor.writable, true);
70-
}
7151
{
7252
// drop/length
7353
assert.strictEqual(Readable.prototype.drop.length, 1);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.