Skip to content

Commit

Permalink
fixup(liquidationVisibility): Remove allValuesSetteled()
Browse files Browse the repository at this point in the history
Refs: #35
  • Loading branch information
anilhelvaci committed Jun 17, 2024
1 parent 525f8f4 commit cc1127e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
15 changes: 0 additions & 15 deletions packages/internal/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,21 +349,6 @@ export const allValues = async obj => {
return harden(fromEntries(zip(keys(obj), resolved)));
};

/**
* Just like allValues above but use this when you want to silently handle rejected promises
* and still keep using the values of resolved ones.
*
* @type
* { <T extends Record<string, ERef<any>>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>}> }
*/
export const allValuesSettled = async obj => {
const resolved = await Promise.allSettled(values(obj));
// @ts-expect-error
const valuesMapped = resolved.map(({ value }) => value);
// @ts-expect-error cast
return harden(fromEntries(zip(keys(obj), valuesMapped)));
};

/**
* A tee implementation where all readers are synchronized with each other.
* They all consume the source stream in lockstep, and any one returning or
Expand Down
15 changes: 0 additions & 15 deletions packages/internal/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
forever,
deeplyFulfilledObject,
synchronizedTee,
allValuesSettled,
} from '../src/utils.js';

test('fromUniqueEntries', t => {
Expand Down Expand Up @@ -264,17 +263,3 @@ test('synchronizedTee - consume synchronized', async t => {
t.deepEqual(output1, sourceData.slice(0, i));
t.deepEqual(output2, sourceData.slice(0, i));
});

test('allValuesSettled', async t => {
const result = await allValuesSettled({
promiseOne: Promise.resolve('I am a happy promise - One'),
promiseTwo: Promise.reject(new Error('I am an upset promise')),
promiseThree: Promise.resolve('I am a happy promise - Three'),
});

t.deepEqual(result, {
promiseOne: 'I am a happy promise - One',
promiseTwo: undefined,
promiseThree: 'I am a happy promise - Three',
});
});

0 comments on commit cc1127e

Please sign in to comment.