Skip to content

Commit 5c167d2

Browse files
committed
init
0 parents  commit 5c167d2

18 files changed

+838
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_size = 4
10+
indent_style = space
11+
max_line_length = 140

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: axetroy # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: https://github.com/axetroy/buy-me-a-cup-of-tea

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
node: ["22"]
11+
os: [ubuntu-latest, macOS-latest]
12+
name: node.js ${{ matrix.node }} test in ${{ matrix.os }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: ${{ matrix.node }}
21+
22+
- name: Install
23+
run: npm i
24+
25+
- name: Test
26+
run: npm run test
27+
28+
- name: Build
29+
run: npm run build

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
package-lock.json
3+
dist
4+
.DS_Store

LICENSE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Copyright (c) 2025 Axetroy
2+
3+
"Anti 996" License Version 1.0 (Draft)
4+
5+
Permission is hereby granted to any individual or legal entity
6+
obtaining a copy of this licensed work (including the source code,
7+
documentation and/or related items, hereinafter collectively referred
8+
to as the "licensed work"), free of charge, to deal with the licensed
9+
work for any purpose, including without limitation, the rights to use,
10+
reproduce, modify, prepare derivative works of, distribute, publish
11+
and sublicense the licensed work, subject to the following conditions:
12+
13+
1. The individual or the legal entity must conspicuously display,
14+
without modification, this License and the notice on each redistributed
15+
or derivative copy of the Licensed Work.
16+
17+
2. The individual or the legal entity must strictly comply with all
18+
applicable laws, regulations, rules and standards of the jurisdiction
19+
relating to labor and employment where the individual is physically
20+
located or where the individual was born or naturalized; or where the
21+
legal entity is registered or is operating (whichever is stricter). In
22+
case that the jurisdiction has no such laws, regulations, rules and
23+
standards or its laws, regulations, rules and standards are
24+
unenforceable, the individual or the legal entity are required to
25+
comply with Core International Labor Standards.
26+
27+
3. The individual or the legal entity shall not induce, suggest or force
28+
its employee(s), whether full-time or part-time, or its independent
29+
contractor(s), in any methods, to agree in oral or written form, to
30+
directly or indirectly restrict, weaken or relinquish his or her
31+
rights or remedies under such laws, regulations, rules and standards
32+
relating to labor and employment as mentioned above, no matter whether
33+
such written or oral agreements are enforceable under the laws of the
34+
said jurisdiction, nor shall such individual or the legal entity
35+
limit, in any methods, the rights of its employee(s) or independent
36+
contractor(s) from reporting or complaining to the copyright holder or
37+
relevant authorities monitoring the compliance of the license about
38+
its violation(s) of the said license.
39+
40+
THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
41+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM,
44+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
45+
OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE
46+
LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# async-queue.js
2+
3+
[![Badge](https://img.shields.io/badge/link-996.icu-%23FF4D5B.svg?style=flat-square)](https://996.icu/#/en_US)
4+
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg?style=flat-square)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
5+
![Node](https://img.shields.io/badge/node-%3E=14-blue.svg?style=flat-square)
6+
[![npm version](https://badge.fury.io/js/@axetroy/async-queue.svg)](https://badge.fury.io/js/async-queue)
7+
8+
A library to limit the number of concurrent asynchronous tasks.
9+
10+
## Installation
11+
12+
```bash
13+
npm install @axetroy/async-queue --save
14+
```
15+
16+
## Usage
17+
18+
```js
19+
// import via esm
20+
import { AsyncQueue } from "@axetroy/async-queue";
21+
22+
// import via cjs
23+
const { AsyncQueue } = require("@axetroy/async-queue");
24+
```
25+
26+
```js
27+
// import via esm
28+
import { AsyncQueue } from "@axetroy/async-queue";
29+
30+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
31+
32+
const queue = new AsyncTaskQueue(2);
33+
// Add task to the queue
34+
queue.enqueue(() => delay(1000).then(() => console.log("Task 1 completed")));
35+
queue.enqueue(() => delay(500).then(() => console.log("Task 2 completed")));
36+
queue.enqueue(() => delay(300).then(() => console.log("Task 3 completed")));
37+
queue.enqueue(() => delay(400).then(() => console.log("Task 4 completed")));
38+
39+
// Wait for all tasks to complete
40+
await queue.waitForAll();
41+
```
42+
43+
## License
44+
45+
The [Anti 996 License](LICENSE)

package.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "async-queue",
3+
"version": "0.1.0",
4+
"private": false,
5+
"description": "A simple async queue",
6+
"sideEffects": false,
7+
"files": [
8+
"dist"
9+
],
10+
"main": "./dist/cjs/index.cjs",
11+
"module": "./dist/esm/index.mjs",
12+
"exports": {
13+
"./package.json": {
14+
"import": "./package.json",
15+
"require": "./package.json"
16+
},
17+
".": {
18+
"require": {
19+
"default": "./dist/cjs/index.cjs",
20+
"types": "./dist/cjs/index.d.ts"
21+
},
22+
"import": {
23+
"default": "./dist/esm/index.mjs",
24+
"types": "./dist/esm/index.d.ts"
25+
}
26+
}
27+
},
28+
"scripts": {
29+
"test": "node --import tsx --test **/*.test.ts",
30+
"test:update-snapshot": "node --import tsx --test --test-update-snapshots **/*.test.ts",
31+
"build": "npm run build:esm && npm run build:cjs",
32+
"build:esm": "tsc -p ./tsconfig.esm.json && node script/covert2mjs.cjs",
33+
"build:cjs": "tsc -p ./tsconfig.cjs.json && node script/covert2cjs.cjs",
34+
"prepack": "npm run build"
35+
},
36+
"author": "Axetroy <[email protected]>",
37+
"license": "MIT",
38+
"devDependencies": {
39+
"@types/node": "^22.13.10",
40+
"tsx": "^4.19.2",
41+
"typescript": "^5.7.2"
42+
},
43+
"keywords": [
44+
"queue",
45+
"async",
46+
"async-queue"
47+
],
48+
"homepage": "https://github.com/axetroy/async-queue.js#readme",
49+
"bugs": {
50+
"url": "https://github.com/axetroy/async-queue.js/issues"
51+
},
52+
"repository": {
53+
"type": "https",
54+
"url": "https://github.com/axetroy/async-queue.js.git"
55+
}
56+
}

script/covert2cjs.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const path = require("path");
2+
3+
// 定义要处理的文件夹路径
4+
const dirPath = path.join(__dirname, "../dist/cjs"); // 根据实际情况设置
5+
6+
require("./renameModule.cjs")(dirPath, "cjs");

script/covert2mjs.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const path = require("path");
2+
3+
// 定义要处理的文件夹路径
4+
const dirPath = path.join(__dirname, "../dist/esm"); // 根据实际情况设置
5+
6+
require("./renameModule.cjs")(dirPath, "mjs");

0 commit comments

Comments
 (0)