사소한 리팩토링

This commit is contained in:
static
2025-12-31 02:43:07 +09:00
parent 7b666cf692
commit 182ec18a2b
6 changed files with 22 additions and 20 deletions

View File

@@ -1,16 +1,16 @@
export const monotonicResolve = <T>(
promises: (Promise<T | undefined> | false)[],
promises: (Promise<T> | false)[],
callback: (value: T) => void,
) => {
let latestResolvedIndex = -1;
promises.forEach((promise, index) => {
if (!promise) return;
promise.then((value) => {
if (value !== undefined && index > latestResolvedIndex) {
latestResolvedIndex = index;
callback(value);
}
promises
.filter((promise) => !!promise)
.forEach((promise, index) => {
promise.then((value) => {
if (index > latestResolvedIndex) {
latestResolvedIndex = index;
callback(value);
}
});
});
});
};