From 6cac3dc20da3d5bf9682b1897e1deada5faf93d6 Mon Sep 17 00:00:00 2001 From: Graham Fisher Date: Sun, 25 Aug 2024 09:38:51 -0400 Subject: [PATCH] a.toSorted(f) -> structuredClone(a).sort(f) (former not avalailable in node18) --- test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test.js b/test.js index 7285d5d..7530da1 100644 --- a/test.js +++ b/test.js @@ -839,7 +839,9 @@ test('pMapIterable - preserveOrder: false - more complex example - async iterabl yield * testData; } - t.deepEqual(await collectAsyncIterable(pMapIterable(asyncIterable(), mapper, {concurrency: Number.POSITIVE_INFINITY, preserveOrder: false})), testData.toSorted(([_aId, aMs], [_bId, bMs]) => aMs - bMs).map(([id, _ms]) => id)); + const sortedTestData = structuredClone(testData).sort(([_aId, aMs], [_bId, bMs]) => aMs - bMs); + + t.deepEqual(await collectAsyncIterable(pMapIterable(asyncIterable(), mapper, {concurrency: Number.POSITIVE_INFINITY, preserveOrder: false})), sortedTestData.map(([id, _ms]) => id)); }); test('pMapIterable - preserveOrder: false - more complex example - sync promise-returning iterable and unbounded concurrency', async t => { @@ -855,7 +857,9 @@ test('pMapIterable - preserveOrder: false - more complex example - sync promise- yield * testData.map(d => Promise.resolve(d)); } - t.deepEqual(await collectAsyncIterable(pMapIterable(syncPromiseReturningIterable(), mapper, {concurrency: Number.POSITIVE_INFINITY, preserveOrder: false})), testData.toSorted(([_aId, aMs], [_bId, bMs]) => aMs - bMs).map(([id, _ms]) => id)); + const sortedTestData = structuredClone(testData).sort(([_aId, aMs], [_bId, bMs]) => aMs - bMs); + + t.deepEqual(await collectAsyncIterable(pMapIterable(syncPromiseReturningIterable(), mapper, {concurrency: Number.POSITIVE_INFINITY, preserveOrder: false})), sortedTestData.map(([id, _ms]) => id)); }); test('pMapIterable - preserveOrder: false - concurrency: 2', async t => {