Skip to content

Commit

Permalink
docs(async-queue): jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
njfamirm committed Jan 3, 2024
1 parent 2e54a0a commit 2bbfe04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/async-queue/demo/simple-queue.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const queue = new AsyncQueue();
async function longTask(n) {
console.log('longTask(%s)', n);
await queue.push('longTaskId', () => {
return new Promise(resolve => {
return new Promise((resolve) => {
console.log('longTask %s start', n);
// Simulate a long task
setTimeout(resolve, 1_000)
setTimeout(resolve, 1_000);
});
});
console.log('longTask %s end', n);
Expand All @@ -18,4 +18,4 @@ async function longTask(n) {
longTask(1);
longTask(2);
longTask(3).then(() => console.log('longTask 3 resolved'));
longTask(4)
longTask(4);
3 changes: 3 additions & 0 deletions packages/async-queue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import type {Dictionary} from '@alwatr/type-helper';
* ```
*/
export class AsyncQueue {
/**
* A record of task IDs and their corresponding last queued task promises.
*/
private queue__: Dictionary<Promise<void>> = {};

/**
Expand Down

0 comments on commit 2bbfe04

Please sign in to comment.