News for hackers. Stuff that matters.
Re:Ask HN: What are some cool but obscure data structures yo... by ralusek on Friday July 22, 2022 @11:18AM (#32192877)
So if the promise still exists, that means that there is an active call out for a promise using this key already, so we'll just return it. We know this because when the function that is executing finishes, we delete the promise from the map.

A purpose of this might be, let's say you rebuild some structure very frequently, like hundreds of times per second or whatever. You can call this function for a given key as many times as you want while that async process is executing, and it will only execute it once, always returning the same promise.

There are no comments on this comment yet.