Skip to content

Commit

Permalink
stream: remove asIndexedPairs
Browse files Browse the repository at this point in the history
PR-URL: nodejs#48150
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
atlowChemi authored and Ceres6 committed Aug 14, 2023
1 parent 4316fd0 commit f8ed71b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 125 deletions.
31 changes: 0 additions & 31 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -2447,37 +2447,6 @@ import { Readable } from 'node:stream';
await Readable.from([1, 2, 3, 4]).take(2).toArray(); // [1, 2]
```

##### `readable.asIndexedPairs([options])`

<!-- YAML
added:
- v17.5.0
- v16.15.0
changes:
- version: v20.3.0
pr-url: https://github.com/nodejs/node/pull/48102
description: Using the `asIndexedPairs` method emits a runtime warning that
it will be removed in a future version.
-->

> Stability: 1 - Experimental
* `options` {Object}
* `signal` {AbortSignal} allows destroying the stream if the signal is
aborted.
* Returns: {Readable} a stream of indexed pairs.

This method returns a new stream with chunks of the underlying stream paired
with a counter in the form `[index, chunk]`. The first index value is 0 and it
increases by 1 for each chunk produced.

```mjs
import { Readable } from 'node:stream';

const pairs = await Readable.from(['a', 'b', 'c']).asIndexedPairs().toArray();
console.log(pairs); // [[0, 'a'], [1, 'b'], [2, 'c']]
```

##### `readable.reduce(fn[, initial[, options]])`

<!-- YAML
Expand Down
21 changes: 0 additions & 21 deletions lib/internal/streams/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const {
addAbortSignalNoValidate,
} = require('internal/streams/add-abort-signal');
const { isWritable, isNodeStream } = require('internal/streams/utils');
const { deprecate } = require('internal/util');

const {
ArrayPrototypePush,
Expand Down Expand Up @@ -199,25 +198,6 @@ function map(fn, options) {
}.call(this);
}

function asIndexedPairs(options = undefined) {
if (options != null) {
validateObject(options, 'options');
}
if (options?.signal != null) {
validateAbortSignal(options.signal, 'options.signal');
}

return async function* asIndexedPairs() {
let index = 0;
for await (const val of this) {
if (options?.signal?.aborted) {
throw new AbortError({ cause: options.signal.reason });
}
yield [index++, val];
}
}.call(this);
}

async function some(fn, options = undefined) {
for await (const unused of filter.call(this, fn, options)) {
return true;
Expand Down Expand Up @@ -421,7 +401,6 @@ function take(number, options = undefined) {
}

module.exports.streamReturningOperators = {
asIndexedPairs: deprecate(asIndexedPairs, 'readable.asIndexedPairs will be removed in a future version.'),
drop,
filter,
flatMap,
Expand Down
53 changes: 0 additions & 53 deletions test/parallel/test-stream-asIndexedPairs.mjs

This file was deleted.

20 changes: 0 additions & 20 deletions test/parallel/test-stream-iterator-helpers-test262-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,6 @@ import assert from 'assert';

// Note all the tests that check AsyncIterator's prototype itself and things
// that happen before stream conversion were not ported.
{
// asIndexedPairs/is-function
assert.strictEqual(typeof Readable.prototype.asIndexedPairs, 'function');
// asIndexedPairs/indexed-pairs.js
const iterator = Readable.from([0, 1]);
const indexedPairs = iterator.asIndexedPairs();

for await (const [i, v] of indexedPairs) {
assert.strictEqual(i, v);
}
// asIndexedPairs/length.js
assert.strictEqual(Readable.prototype.asIndexedPairs.length, 0);
const descriptor = Object.getOwnPropertyDescriptor(
Readable.prototype,
'asIndexedPairs'
);
assert.strictEqual(descriptor.enumerable, false);
assert.strictEqual(descriptor.configurable, true);
assert.strictEqual(descriptor.writable, true);
}
{
// drop/length
assert.strictEqual(Readable.prototype.drop.length, 1);
Expand Down

0 comments on commit f8ed71b

Please sign in to comment.