Skip to content

Commit

Permalink
docs(flushPromises): add flushPromises section to README
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 21, 2024
1 parent 55c6d17 commit b6adcfa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ const p2 = ensurePromise("Not a promise");
console.log(await p2); // Not a promise
```

### flushPromises

`flushPromises` flushes all pending promises in the microtask queue.

```ts
import { flushPromises } from "@core/asyncutil/flush-promises";

let count = 0;
Array.from({ length: 5 }).forEach(() => {
Promise.resolve()
.then(() => count++)
.then(() => count++);
});

console.log(count); // 0
await flushPromises();
console.log(count); // 10
```

### Lock/RwLock

`Lock` is a mutual exclusion lock that provides safe concurrent access to a
Expand Down

0 comments on commit b6adcfa

Please sign in to comment.