mirror of
https://github.com/kmc7468/arkvault.git
synced 2026-02-04 08:06:56 +00:00
사소한 리팩토링
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user