@alwatr/async-queue 5.5.27 → 5.5.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/main.cjs +1 -2
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +1 -2
- package/dist/main.mjs.map +1 -1
- package/package.json +17 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.5.29](https://github.com/Alwatr/nanolib/compare/@alwatr/async-queue@5.5.28...@alwatr/async-queue@5.5.29) (2026-03-16)
|
|
7
|
+
|
|
8
|
+
### 🔨 Code Refactoring
|
|
9
|
+
|
|
10
|
+
* migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
|
|
11
|
+
|
|
12
|
+
## [5.5.28](https://github.com/Alwatr/nanolib/compare/@alwatr/async-queue@5.5.27...@alwatr/async-queue@5.5.28) (2026-02-18)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @alwatr/async-queue
|
|
15
|
+
|
|
6
16
|
## [5.5.27](https://github.com/Alwatr/nanolib/compare/@alwatr/async-queue@5.5.26...@alwatr/async-queue@5.5.27) (2025-12-23)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @alwatr/async-queue
|
package/dist/main.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** 📦 @alwatr/async-queue v5.5.
|
|
2
|
-
__dev_mode__: console.debug("📦 @alwatr/async-queue v5.5.27");
|
|
1
|
+
/** 📦 @alwatr/async-queue v5.5.29 */
|
|
3
2
|
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{AsyncQueue:()=>AsyncQueue});module.exports=__toCommonJS(main_exports);var import_flatomise=require("@alwatr/flatomise");var AsyncQueue=class{constructor(){this.queue__={}}async push(taskId,task){const flatomise=(0,import_flatomise.newFlatomise)();const previousTaskPromise=this.queue__[taskId];this.queue__[taskId]=flatomise.promise;try{await previousTaskPromise}catch(_e){}setTimeout(()=>{task().then(flatomise.resolve,flatomise.reject).then(()=>{if(this.queue__[taskId]===flatomise.promise){delete this.queue__[taskId]}})},0);return flatomise.promise}isRunning(taskId){return this.queue__[taskId]!==void 0}waitForFinish(taskId){return this.queue__[taskId]??Promise.resolve()}waitForAllFinish(){return Promise.all(Object.values(this.queue__))}};0&&(module.exports={AsyncQueue});
|
|
4
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.cjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["import {newFlatomise} from '@alwatr/flatomise';\n\nimport type {} from '@alwatr/type-helper';\n\n/**\n * A queue that executes async tasks in order like mutex and semaphore methodology\n *\n * @example\n * ```ts\n * const queue = new AsyncQueue();\n *\n * function longTask() {\n * queue.push('longTaskId', async () => {\n * // ...\n * });\n * }\n * ```\n */\nexport class AsyncQueue {\n /**\n * A record of task IDs and their corresponding last queued task promises.\n */\n private queue__: DictionaryOpt<Promise<unknown>> = {};\n\n /**\n * Push a async task to the queue.\n *\n * @param taskId task id\n * @param task async task\n * @returns A promise that resolves when the task is done.\n *\n * @example\n * ```typescript\n * const queue = new AsyncQueue();\n *\n * function longTask() {\n * queue.push('longTaskId', async () => {\n * // ...\n * });\n * ```\n */\n public async push<T>(taskId: string, task: () => Promise<T>): Promise<T> {\n const flatomise = newFlatomise<T>();\n\n const previousTaskPromise = this.queue__[taskId];\n this.queue__[taskId] = flatomise.promise;\n\n try {\n await previousTaskPromise;\n }\n catch (_e) {\n // ignore\n }\n\n setTimeout(() => {\n task()\n .then(flatomise.resolve, flatomise.reject)\n .then(() => {\n if (this.queue__[taskId] === flatomise.promise) {\n delete this.queue__[taskId];\n }\n });\n }, 0);\n\n return flatomise.promise;\n }\n\n /**\n * Check if the task running in the queue.\n *\n * @param taskId task id\n * @returns true if the task is running, otherwise false.\n * @example\n * ```typescript\n * if (queue.isRunning('longTaskId')) {\n * // ...\n * }\n * ```\n */\n public isRunning(taskId: string): boolean {\n return this.queue__[taskId] !== undefined;\n }\n\n /**\n * Wait for the all tasks in the queue to finish.\n *\n * @param taskId task id\n * @returns A promise that resolves when all tasks are done.\n * @example\n * ```typescript\n * await queue.waitForFinish('longTaskId');\n * ```\n */\n public waitForFinish(taskId: string): Promise<unknown> {\n return this.queue__[taskId] ?? Promise.resolve();\n }\n\n /**\n * Wait for the all tasks in the queue to finish.\n * @returns A promise that resolves when all tasks are done.\n * @example\n * ```typescript\n * await queue.waitForAllFinish();\n * ```\n */\n public waitForAllFinish(): Promise<unknown[]> {\n return Promise.all(Object.values(this.queue__));\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";qqBAAA,sIAA2B,6BAkBpB,IAAM,WAAN,KAAiB,CAAjB,cAIL,KAAQ,QAA2C,CAAC,EAmBpD,MAAa,KAAQ,OAAgB,KAAoC,CACvE,MAAM,aAAY,+BAAgB,EAElC,MAAM,oBAAsB,KAAK,QAAQ,MAAM,EAC/C,KAAK,QAAQ,MAAM,EAAI,UAAU,QAEjC,GAAI,CACF,MAAM,mBACR,OACO,GAAI,CAEX,CAEA,WAAW,IAAM,CACf,KAAK,EACF,KAAK,UAAU,QAAS,UAAU,MAAM,EACxC,KAAK,IAAM,CACV,GAAI,KAAK,QAAQ,MAAM,IAAM,UAAU,QAAS,CAC9C,OAAO,KAAK,QAAQ,MAAM,CAC5B,CACF,CAAC,CACL,EAAG,CAAC,EAEJ,OAAO,UAAU,OACnB,CAcO,UAAU,OAAyB,CACxC,OAAO,KAAK,QAAQ,MAAM,IAAM,MAClC,CAYO,cAAc,OAAkC,CACrD,OAAO,KAAK,QAAQ,MAAM,GAAK,QAAQ,QAAQ,CACjD,CAUO,kBAAuC,CAC5C,OAAO,QAAQ,IAAI,OAAO,OAAO,KAAK,OAAO,CAAC,CAChD,CACF",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** 📦 @alwatr/async-queue v5.5.
|
|
2
|
-
__dev_mode__: console.debug("📦 @alwatr/async-queue v5.5.27");
|
|
1
|
+
/** 📦 @alwatr/async-queue v5.5.29 */
|
|
3
2
|
import{newFlatomise}from"@alwatr/flatomise";var AsyncQueue=class{constructor(){this.queue__={}}async push(taskId,task){const flatomise=newFlatomise();const previousTaskPromise=this.queue__[taskId];this.queue__[taskId]=flatomise.promise;try{await previousTaskPromise}catch(_e){}setTimeout(()=>{task().then(flatomise.resolve,flatomise.reject).then(()=>{if(this.queue__[taskId]===flatomise.promise){delete this.queue__[taskId]}})},0);return flatomise.promise}isRunning(taskId){return this.queue__[taskId]!==void 0}waitForFinish(taskId){return this.queue__[taskId]??Promise.resolve()}waitForAllFinish(){return Promise.all(Object.values(this.queue__))}};export{AsyncQueue};
|
|
4
3
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["import {newFlatomise} from '@alwatr/flatomise';\n\nimport type {} from '@alwatr/type-helper';\n\n/**\n * A queue that executes async tasks in order like mutex and semaphore methodology\n *\n * @example\n * ```ts\n * const queue = new AsyncQueue();\n *\n * function longTask() {\n * queue.push('longTaskId', async () => {\n * // ...\n * });\n * }\n * ```\n */\nexport class AsyncQueue {\n /**\n * A record of task IDs and their corresponding last queued task promises.\n */\n private queue__: DictionaryOpt<Promise<unknown>> = {};\n\n /**\n * Push a async task to the queue.\n *\n * @param taskId task id\n * @param task async task\n * @returns A promise that resolves when the task is done.\n *\n * @example\n * ```typescript\n * const queue = new AsyncQueue();\n *\n * function longTask() {\n * queue.push('longTaskId', async () => {\n * // ...\n * });\n * ```\n */\n public async push<T>(taskId: string, task: () => Promise<T>): Promise<T> {\n const flatomise = newFlatomise<T>();\n\n const previousTaskPromise = this.queue__[taskId];\n this.queue__[taskId] = flatomise.promise;\n\n try {\n await previousTaskPromise;\n }\n catch (_e) {\n // ignore\n }\n\n setTimeout(() => {\n task()\n .then(flatomise.resolve, flatomise.reject)\n .then(() => {\n if (this.queue__[taskId] === flatomise.promise) {\n delete this.queue__[taskId];\n }\n });\n }, 0);\n\n return flatomise.promise;\n }\n\n /**\n * Check if the task running in the queue.\n *\n * @param taskId task id\n * @returns true if the task is running, otherwise false.\n * @example\n * ```typescript\n * if (queue.isRunning('longTaskId')) {\n * // ...\n * }\n * ```\n */\n public isRunning(taskId: string): boolean {\n return this.queue__[taskId] !== undefined;\n }\n\n /**\n * Wait for the all tasks in the queue to finish.\n *\n * @param taskId task id\n * @returns A promise that resolves when all tasks are done.\n * @example\n * ```typescript\n * await queue.waitForFinish('longTaskId');\n * ```\n */\n public waitForFinish(taskId: string): Promise<unknown> {\n return this.queue__[taskId] ?? Promise.resolve();\n }\n\n /**\n * Wait for the all tasks in the queue to finish.\n * @returns A promise that resolves when all tasks are done.\n * @example\n * ```typescript\n * await queue.waitForAllFinish();\n * ```\n */\n public waitForAllFinish(): Promise<unknown[]> {\n return Promise.all(Object.values(this.queue__));\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAAA,OAAQ,iBAAmB,oBAkBpB,IAAM,WAAN,KAAiB,CAAjB,cAIL,KAAQ,QAA2C,CAAC,EAmBpD,MAAa,KAAQ,OAAgB,KAAoC,CACvE,MAAM,UAAY,aAAgB,EAElC,MAAM,oBAAsB,KAAK,QAAQ,MAAM,EAC/C,KAAK,QAAQ,MAAM,EAAI,UAAU,QAEjC,GAAI,CACF,MAAM,mBACR,OACO,GAAI,CAEX,CAEA,WAAW,IAAM,CACf,KAAK,EACF,KAAK,UAAU,QAAS,UAAU,MAAM,EACxC,KAAK,IAAM,CACV,GAAI,KAAK,QAAQ,MAAM,IAAM,UAAU,QAAS,CAC9C,OAAO,KAAK,QAAQ,MAAM,CAC5B,CACF,CAAC,CACL,EAAG,CAAC,EAEJ,OAAO,UAAU,OACnB,CAcO,UAAU,OAAyB,CACxC,OAAO,KAAK,QAAQ,MAAM,IAAM,MAClC,CAYO,cAAc,OAAkC,CACrD,OAAO,KAAK,QAAQ,MAAM,GAAK,QAAQ,QAAQ,CACjD,CAUO,kBAAuC,CAC5C,OAAO,QAAQ,IAAI,OAAO,OAAO,KAAK,OAAO,CAAC,CAChD,CACF",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/async-queue",
|
|
3
3
|
"description": "A queue that executes async tasks in order like mutex and semaphore methodology for javascript and typescript.",
|
|
4
|
-
"version": "5.5.
|
|
4
|
+
"version": "5.5.29",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Alwatr/nanolib/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@alwatr/flatomise": "5.5.
|
|
8
|
+
"@alwatr/flatomise": "5.5.29"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@alwatr/nano-build": "6.4.
|
|
12
|
-
"@alwatr/prettier-config": "6.0.
|
|
11
|
+
"@alwatr/nano-build": "6.4.2",
|
|
12
|
+
"@alwatr/prettier-config": "6.0.2",
|
|
13
13
|
"@alwatr/tsconfig-base": "6.0.4",
|
|
14
|
-
"@alwatr/type-helper": "7.0.
|
|
15
|
-
"jest": "^30.2.0",
|
|
14
|
+
"@alwatr/type-helper": "7.0.2",
|
|
16
15
|
"typescript": "^5.9.3"
|
|
17
16
|
},
|
|
18
17
|
"exports": {
|
|
@@ -67,22 +66,22 @@
|
|
|
67
66
|
"directory": "packages/async-queue"
|
|
68
67
|
},
|
|
69
68
|
"scripts": {
|
|
70
|
-
"b": "
|
|
71
|
-
"build": "
|
|
69
|
+
"b": "bun run build",
|
|
70
|
+
"build": "bun run build:ts && bun run build:es",
|
|
72
71
|
"build:es": "nano-build --preset=module",
|
|
73
72
|
"build:ts": "tsc --build",
|
|
74
|
-
"c": "
|
|
75
|
-
"cb": "
|
|
73
|
+
"c": "bun run clean",
|
|
74
|
+
"cb": "bun run clean && bun run build",
|
|
76
75
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
77
|
-
"d": "
|
|
78
|
-
"t": "
|
|
79
|
-
"test": "
|
|
80
|
-
"w": "
|
|
81
|
-
"watch": "
|
|
82
|
-
"watch:es": "
|
|
83
|
-
"watch:ts": "
|
|
76
|
+
"d": "bun run build:es && bun --enable-source-maps --trace-warnings",
|
|
77
|
+
"t": "bun run test",
|
|
78
|
+
"test": "echo test-skipped",
|
|
79
|
+
"w": "bun run watch",
|
|
80
|
+
"watch": "bun run watch:ts & bun run watch:es",
|
|
81
|
+
"watch:es": "bun run build:es --watch",
|
|
82
|
+
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
84
83
|
},
|
|
85
84
|
"type": "module",
|
|
86
85
|
"types": "./dist/main.d.ts",
|
|
87
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "c3889e3756b0a0f9b935a1b702a1373ac52cb379"
|
|
88
87
|
}
|