Skip to content

Commit d6501ac

Browse files
committed
Remove breather from core
Can just as easy be implemented by a consumer
1 parent b7aadbd commit d6501ac

12 files changed

+5
-339
lines changed

benchmark/event-loop-lag-immediate-all.js

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

benchmark/event-loop-lag-immediate-tenth.js

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

benchmark/event-loop-lag-real-immediate.js

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

benchmark/event-loop-lag-real-static.js

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

benchmark/event-loop-lag-static.js

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

benchmark/event-loop-lag.js

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

benchmark/memory.js

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

benchmark/utils/lag.js

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

benchmark/utils/loop.js

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

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
// TODO: Have option to persist order? To not use Promise.race()?
55
// TODO: Make a proper merge for async iterables by accepting multiple input iterables, see: https://twitter.com/matteocollina/status/1392056092482576385
66

7-
import { EventLoopBreather } from './lib/event-loop-breather.js';
87
import { findLeastTargeted } from './lib/find-least-targeted.js';
98
import { makeIterableAsync } from './lib/misc.js';
109
import { isAsyncIterable, isIterable, isPartOfSet } from './lib/type-checks.js';
1110

11+
// FIXME: Export using a better more unique name
1212
/**
1313
* @template T
1414
* @template R
1515
* @param {AsyncIterable<T> | Iterable<T> | T[]} input
1616
* @param {(item: T) => (Promise<R>|AsyncIterable<R>)} callback
17-
* @param {{ queueSize?: number|undefined, escapeToEventLoopEvery?: number|undefined }} [options]
17+
* @param {{ queueSize?: number|undefined }} [options]
1818
* @returns {AsyncIterableIterator<R> & { return: NonNullable<AsyncIterableIterator<R>["return"]>, throw: NonNullable<AsyncIterableIterator<R>["throw"]> }}
1919
*/
2020
export function map (input, callback, options) {
2121
/** @typedef {Promise<IteratorResult<R|AsyncIterable<R>> & { queuePromise: QueuePromise, fromSubIterator?: boolean, isSubIterator?: boolean }>} QueuePromise */
2222

2323
const {
24-
escapeToEventLoopEvery,
24+
// FIXME: Increase to eg 16? Like in eg https://github.com/mcollina/hwp/blob/b13d1e48f3ed656cd7b90e48b9db721cdac5c922/index.js#LL6C51-L6C53
2525
queueSize = 6,
2626
} = options || {};
2727

@@ -47,8 +47,6 @@ export function map (input, callback, options) {
4747
/** @type {WeakMap<QueuePromise, AsyncIterator<T>|AsyncIterator<R>>} */
4848
const promisesToSourceIteratorMap = new WeakMap();
4949

50-
const breather = new EventLoopBreather(escapeToEventLoopEvery);
51-
5250
/** @type {boolean} */
5351
let mainReturnedDone;
5452

@@ -83,7 +81,7 @@ export function map (input, callback, options) {
8381
// FIXME: Handle rejected promises from upstream! And properly mark this iterator as completed
8482
/** @type {QueuePromise} */
8583
const queuePromise = currentSubIterator
86-
? breather.breathe(currentSubIterator.next())
84+
? currentSubIterator.next()
8785
// eslint-disable-next-line promise/prefer-await-to-then
8886
.then(async result => {
8987
if (result.done) {
@@ -99,7 +97,7 @@ export function map (input, callback, options) {
9997

10098
return promiseValue;
10199
})
102-
: breather.breathe(asyncIterator.next())
100+
: asyncIterator.next()
103101
// eslint-disable-next-line promise/prefer-await-to-then
104102
.then(async result => {
105103
if (result.done) {

0 commit comments

Comments
 (0)