ciorent 1.0.3 → 1.0.5

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.
@@ -0,0 +1,29 @@
1
+ import { bench, do_not_optimize, run, summary } from 'mitata';
2
+
3
+ // Example benchmark
4
+ summary(() => {
5
+ bench('Await', function* () {
6
+ yield {
7
+ [0]() {
8
+ return Promise.resolve(1);
9
+ },
10
+ async bench(data: any) {
11
+ do_not_optimize(await data);
12
+ },
13
+ };
14
+ });
15
+
16
+ bench('Await non-promise', function* () {
17
+ yield {
18
+ [0]() {
19
+ return 1;
20
+ },
21
+ async bench(data: any) {
22
+ do_not_optimize(await data);
23
+ },
24
+ };
25
+ });
26
+ });
27
+
28
+ // Start the benchmark
29
+ run();
package/bench/bun.lock ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 0,
4
+ "workspaces": {
5
+ "": {
6
+ "dependencies": {
7
+ "@types/mutexify": "^1.2.4",
8
+ "async-mutex": "^0.5.0",
9
+ "async-sema": "^3.1.1",
10
+ "bottleneck": "^2.19.5",
11
+ "limit-concur": "^4.0.0",
12
+ "mutexify": "^1.4.0",
13
+ "p-limit": "^6.2.0",
14
+ },
15
+ },
16
+ },
17
+ "packages": {
18
+ "@types/mutexify": ["@types/mutexify@1.2.4", "", {}, "sha512-mKNLg7IdppIDCNXiC1hNkNhdEdYnd5ErNnoNgEOERwU3DwD/S1/TBseob0Uq/QXWADBz7OWaWUoHa6IEUtrOEQ=="],
19
+
20
+ "async-mutex": ["async-mutex@0.5.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA=="],
21
+
22
+ "async-sema": ["async-sema@3.1.1", "", {}, "sha512-tLRNUXati5MFePdAk8dw7Qt7DpxPB60ofAgn8WRhW6a2rcimZnYBP9oxHiv0OHy+Wz7kPMG+t4LGdt31+4EmGg=="],
23
+
24
+ "bottleneck": ["bottleneck@2.19.5", "", {}, "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw=="],
25
+
26
+ "limit-concur": ["limit-concur@4.0.0", "", {}, "sha512-BXUCP52gLz8JA8/cRKkXswOV6FnA2gl8hL8DbgQuo8XA9NKcwU3Oq/Cg1JyAZ+gyNmFEZXI+ZYLes0BrZkl+7g=="],
27
+
28
+ "mutexify": ["mutexify@1.4.0", "", { "dependencies": { "queue-tick": "^1.0.0" } }, "sha512-pbYSsOrSB/AKN5h/WzzLRMFgZhClWccf2XIB4RSMC8JbquiB0e0/SH5AIfdQMdyHmYtv4seU7yV/TvAwPLJ1Yg=="],
29
+
30
+ "p-limit": ["p-limit@6.2.0", "", { "dependencies": { "yocto-queue": "^1.1.1" } }, "sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA=="],
31
+
32
+ "queue-tick": ["queue-tick@1.0.1", "", {}, "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag=="],
33
+
34
+ "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
35
+
36
+ "yocto-queue": ["yocto-queue@1.2.1", "", {}, "sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg=="],
37
+ }
38
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "type": "module",
3
+ "dependencies": {
4
+ "@types/mutexify": "^1.2.4",
5
+ "async-mutex": "^0.5.0",
6
+ "async-sema": "^3.1.1",
7
+ "limit-concur": "^4.0.0",
8
+ "mutexify": "^1.4.0",
9
+ "p-limit": "^6.2.0"
10
+ }
11
+ }
@@ -0,0 +1,42 @@
1
+ import { bench, do_not_optimize, run, summary } from 'mitata';
2
+
3
+ // Example benchmark
4
+ summary(() => {
5
+ bench('Fill with null', function* () {
6
+ const DAT = new Array(6).fill(null);
7
+
8
+ yield {
9
+ [0]() {
10
+ return [...DAT];
11
+ },
12
+ [1]() {
13
+ return Promise.resolve(15);
14
+ },
15
+ async bench(data: any[], p: any) {
16
+ data[0] = p;
17
+ do_not_optimize(await Promise.all(data));
18
+ },
19
+ };
20
+ });
21
+
22
+ bench('Fill with resolved promises', function* () {
23
+ const resolvedPromise = Promise.resolve();
24
+ const DAT = new Array(6).fill(resolvedPromise);
25
+
26
+ yield {
27
+ [0]() {
28
+ return [...DAT];
29
+ },
30
+ [1]() {
31
+ return Promise.resolve(15);
32
+ },
33
+ async bench(data: any[], p: any) {
34
+ data[0] = p;
35
+ do_not_optimize(await Promise.all(data));
36
+ },
37
+ };
38
+ });
39
+ });
40
+
41
+ // Start the benchmark
42
+ run();
@@ -0,0 +1,101 @@
1
+ import { semaphore, mutex } from 'ciorent';
2
+ import limitConcur from 'limit-concur';
3
+ import { limitFunction } from 'p-limit';
4
+ import { Mutex, Semaphore } from 'async-mutex';
5
+ import mutexify from 'mutexify/promise.js';
6
+ import { Sema } from 'async-sema';
7
+
8
+ import { bench, do_not_optimize, run, summary } from 'mitata';
9
+
10
+
11
+ const task = async () => {
12
+ await 0;
13
+ do_not_optimize(Math.random());
14
+ };
15
+
16
+ const setup = (label: string, limited: () => Promise<any>) => {
17
+ bench(label, Function('f', `return async () => { await Promise.all([${
18
+ 'f(),'.repeat(200)
19
+ }]); }`)(limited)).gc('inner');
20
+ };
21
+
22
+ const setupSemaphoreCases = (permit: number) => {
23
+ setup(`permit ${permit} - limit-concur`, limitConcur(permit, task));
24
+ setup(`permit ${permit} - p-limit`, limitFunction(task, { concurrency: permit }));
25
+
26
+ {
27
+ const sem = semaphore.init(permit, 200 - permit);
28
+ setup(`permit ${permit} - ciorent (semaphore)`, async () => {
29
+ await semaphore.acquire(sem);
30
+ try {
31
+ await task();
32
+ } finally {
33
+ semaphore.release(sem);
34
+ }
35
+ });
36
+ }
37
+
38
+ {
39
+ const sem = new Semaphore(permit);
40
+ setup(`permit ${permit} - async-mutex (semaphore)`, () => sem.runExclusive(task));
41
+ }
42
+
43
+ {
44
+ const sem = new Sema(permit);
45
+ setup(`permit ${permit} - async-sema`, async () => {
46
+ await sem.acquire();
47
+ try {
48
+ return await task();
49
+ } finally {
50
+ sem.release();
51
+ }
52
+ });
53
+ }
54
+
55
+ {
56
+ const sem = new Sema(permit, {
57
+ capacity: 200 - permit
58
+ });
59
+ setup(`permit ${permit} - async-sema (pre-allocated)`, async () => {
60
+ await sem.acquire();
61
+ try {
62
+ return await task();
63
+ } finally {
64
+ sem.release();
65
+ }
66
+ });
67
+ }
68
+ }
69
+
70
+ summary(() => {
71
+ setupSemaphoreCases(1);
72
+
73
+ {
74
+ const mu = mutex.init();
75
+ setup('permit 1 - ciorent (mutex)', () => mutex.run(mu, task));
76
+ }
77
+
78
+ {
79
+ const mu = new Mutex();
80
+ setup('permit 1 - async-mutex (mutex)', () => mu.runExclusive(task));
81
+ }
82
+
83
+ {
84
+ const acquire = mutexify();
85
+ setup('permit 1 - mutexify', async () => {
86
+ const release = await acquire();
87
+ try {
88
+ return await task();
89
+ } finally {
90
+ release();
91
+ }
92
+ })
93
+ }
94
+ });
95
+
96
+ for (let permit = 2; permit < 128; permit <<= 1)
97
+ summary(() => {
98
+ setupSemaphoreCases(permit);
99
+ });
100
+
101
+ run();
@@ -0,0 +1,69 @@
1
+ import { bench, do_not_optimize, type k_state, run, summary } from 'mitata';
2
+
3
+ // Example benchmark
4
+ summary(() => {
5
+ bench('Clone 2 arrays - Concat', function* (state: k_state) {
6
+ const DAT = new Array(state.get('len')).fill(0).map(Math.random);
7
+ const DAT2 = new Array(state.get('len')).map(Math.random);
8
+
9
+ yield {
10
+ [0]() {
11
+ return DAT;
12
+ },
13
+ [1]() {
14
+ return DAT2;
15
+ },
16
+ bench(data: any[], data1: any[]) {
17
+ do_not_optimize(data.concat(data1));
18
+ },
19
+ };
20
+ }).range('len', 2 ** 3, 2 ** 12);
21
+
22
+ bench('Clone 2 arrays - Spread', function* (state: k_state) {
23
+ const DAT = new Array(state.get('len')).fill(0).map(Math.random);
24
+ const DAT2 = new Array(state.get('len')).map(Math.random);
25
+
26
+ yield {
27
+ [0]() {
28
+ return DAT;
29
+ },
30
+ [1]() {
31
+ return DAT2;
32
+ },
33
+ bench(data: any[], data1: any[]) {
34
+ do_not_optimize([...data, ...data1]);
35
+ },
36
+ };
37
+ }).range('len', 2 ** 3, 2 ** 12);
38
+ });
39
+
40
+ summary(() => {
41
+ bench('Clone 1 array - Concat', function* (state: k_state) {
42
+ const DAT = new Array(state.get('len')).fill(0).map(Math.random);
43
+
44
+ yield {
45
+ [0]() {
46
+ return DAT;
47
+ },
48
+ bench(data: any[]) {
49
+ do_not_optimize(data.concat([]));
50
+ },
51
+ };
52
+ }).range('len', 2 ** 3, 2 ** 12);
53
+
54
+ bench('Clone 1 array - Spread', function* (state: k_state) {
55
+ const DAT = new Array(state.get('len')).fill(0).map(Math.random);
56
+
57
+ yield {
58
+ [0]() {
59
+ return DAT;
60
+ },
61
+ bench(data: any[]) {
62
+ do_not_optimize([...data]);
63
+ },
64
+ };
65
+ }).range('len', 2 ** 3, 2 ** 12);
66
+ });
67
+
68
+ // Start the benchmark
69
+ run();
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../scripts/tsconfig.json"
3
+ }
package/biome.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
3
+ "vcs": {
4
+ "enabled": false
5
+ },
6
+ "files": {
7
+ "experimentalScannerIgnores": ["node_modules"],
8
+ "includes": [
9
+ "**/*.{js,ts,jsx,tsx,json,astro,svelte,vue}",
10
+ "!{lib,bench}/**/*"
11
+ ]
12
+ },
13
+ "javascript": {
14
+ "formatter": {
15
+ "quoteStyle": "single",
16
+ "arrowParentheses": "always",
17
+ "semicolons": "always"
18
+ }
19
+ },
20
+ "formatter": {
21
+ "enabled": true,
22
+ "indentStyle": "space",
23
+ "indentWidth": 2,
24
+ "bracketSpacing": true
25
+ },
26
+ "linter": {
27
+ "enabled": true,
28
+ "rules": {
29
+ "style": {
30
+ "noEnum": "error",
31
+ "noCommonJs": "error",
32
+ "useConsistentArrayType": "error",
33
+ "noNamespace": "error",
34
+ "noImplicitBoolean": "warn",
35
+ "noUselessElse": "error",
36
+ "useCollapsedElseIf": "error",
37
+ "useConst": "error",
38
+ "useNodejsImportProtocol": "error",
39
+ "useImportType": "error",
40
+ "useExponentiationOperator": "info"
41
+ },
42
+ "complexity": {
43
+ "noForEach": "info",
44
+ "noUselessCatch": "info",
45
+ "useArrowFunction": "warn"
46
+ },
47
+ "nursery": {
48
+ "noShadow": "warn",
49
+ "noGlobalDirnameFilename": "error",
50
+ "useIndexOf": "warn",
51
+ "noImportCycles": "error"
52
+ },
53
+ "correctness": {
54
+ "useYield": "warn",
55
+ "noUnusedImports": "warn",
56
+ "useImportExtensions": "error",
57
+ "useIsNan": "warn"
58
+ },
59
+ "recommended": false
60
+ }
61
+ }
62
+ }
package/bun.lock ADDED
@@ -0,0 +1,117 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 0,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "ciorent",
7
+ "devDependencies": {
8
+ "@biomejs/biome": "^2.1.3",
9
+ "@types/bun": "^1.2.19",
10
+ "ciorent": "./lib",
11
+ "jiti": "^2.5.1",
12
+ "mitata": "^1.0.34",
13
+ "oxc-minify": "^0.64.0",
14
+ "oxc-transform": "^0.65.0",
15
+ "typescript": "^5.9.2",
16
+ },
17
+ },
18
+ },
19
+ "trustedDependencies": [
20
+ "@biomejs/biome",
21
+ ],
22
+ "packages": {
23
+ "@biomejs/biome": ["@biomejs/biome@2.1.3", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.1.3", "@biomejs/cli-darwin-x64": "2.1.3", "@biomejs/cli-linux-arm64": "2.1.3", "@biomejs/cli-linux-arm64-musl": "2.1.3", "@biomejs/cli-linux-x64": "2.1.3", "@biomejs/cli-linux-x64-musl": "2.1.3", "@biomejs/cli-win32-arm64": "2.1.3", "@biomejs/cli-win32-x64": "2.1.3" }, "bin": { "biome": "bin/biome" } }, "sha512-KE/tegvJIxTkl7gJbGWSgun7G6X/n2M6C35COT6ctYrAy7SiPyNvi6JtoQERVK/VRbttZfgGq96j2bFmhmnH4w=="],
24
+
25
+ "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.1.3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-LFLkSWRoSGS1wVUD/BE6Nlt2dSn0ulH3XImzg2O/36BoToJHKXjSxzPEMAqT9QvwVtk7/9AQhZpTneERU9qaXA=="],
26
+
27
+ "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.1.3", "", { "os": "darwin", "cpu": "x64" }, "sha512-Q/4OTw8P9No9QeowyxswcWdm0n2MsdCwWcc5NcKQQvzwPjwuPdf8dpPPf4r+x0RWKBtl1FLiAUtJvBlri6DnYw=="],
28
+
29
+ "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.1.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-2hS6LgylRqMFmAZCOFwYrf77QMdUwJp49oe8PX/O8+P2yKZMSpyQTf3Eo5ewnsMFUEmYbPOskafdV1ds1MZMJA=="],
30
+
31
+ "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.1.3", "", { "os": "linux", "cpu": "arm64" }, "sha512-KXouFSBnoxAWZYDQrnNRzZBbt5s9UJkIm40hdvSL9mBxSSoxRFQJbtg1hP3aa8A2SnXyQHxQfpiVeJlczZt76w=="],
32
+
33
+ "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.1.3", "", { "os": "linux", "cpu": "x64" }, "sha512-NxlSCBhLvQtWGagEztfAZ4WcE1AkMTntZV65ZvR+J9jp06+EtOYEBPQndA70ZGhHbEDG57bR6uNvqkd1WrEYVA=="],
34
+
35
+ "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.1.3", "", { "os": "linux", "cpu": "x64" }, "sha512-KaLAxnROouzIWtl6a0Y88r/4hW5oDUJTIqQorOTVQITaKQsKjZX4XCUmHIhdEk8zMnaiLZzRTAwk1yIAl+mIew=="],
36
+
37
+ "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.1.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-V9CUZCtWH4u0YwyCYbQ3W5F4ZGPWp2C2TYcsiWFNNyRfmOW1j/TY/jAurl33SaRjgZPO5UUhGyr9m6BN9t84NQ=="],
38
+
39
+ "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.1.3", "", { "os": "win32", "cpu": "x64" }, "sha512-dxy599q6lgp8ANPpR8sDMscwdp9oOumEsVXuVCVT9N2vAho8uYXlCz53JhxX6LtJOXaE73qzgkGQ7QqvFlMC0g=="],
40
+
41
+ "@emnapi/core": ["@emnapi/core@1.4.3", "", { "dependencies": { "@emnapi/wasi-threads": "1.0.2", "tslib": "^2.4.0" } }, "sha512-4m62DuCE07lw01soJwPiBGC0nAww0Q+RY70VZ+n49yDIO13yyinhbWCeNnaob0lakDtWQzSdtNWzJeOJt2ma+g=="],
42
+
43
+ "@emnapi/runtime": ["@emnapi/runtime@1.4.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ=="],
44
+
45
+ "@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.0.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA=="],
46
+
47
+ "@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@0.2.9", "", { "dependencies": { "@emnapi/core": "^1.4.0", "@emnapi/runtime": "^1.4.0", "@tybys/wasm-util": "^0.9.0" } }, "sha512-OKRBiajrrxB9ATokgEQoG87Z25c67pCpYcCwmXYX8PBftC9pBfN18gnm/fh1wurSLEKIAt+QRFLFCQISrb66Jg=="],
48
+
49
+ "@oxc-minify/binding-darwin-arm64": ["@oxc-minify/binding-darwin-arm64@0.64.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-vjkAMgzTmoLxBVMNtueUPF3Zc9g42+T0kFy/vHnnyt+8UgMwiqakcPpbYwjUk0lRIGpIR9eMQ/ygoIaLp9J0YA=="],
50
+
51
+ "@oxc-minify/binding-darwin-x64": ["@oxc-minify/binding-darwin-x64@0.64.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-5drEZMsjPND+P6xygTsK2Avhpqsc61yoFRfIQxpsryFT3Ryf8Vz3tXzgxUVYItzwv3OlHBKfvQJfmN1KrGlAiw=="],
52
+
53
+ "@oxc-minify/binding-linux-arm-gnueabihf": ["@oxc-minify/binding-linux-arm-gnueabihf@0.64.0", "", { "os": "linux", "cpu": "arm" }, "sha512-7U6pA+1vCDYBtkrv5Uy51Lu8x4vZgUGV01aCFm5gMymkj5EVU595iiqPo/59wkJ9U/3ia6UeSi7ANxiG7LtrOQ=="],
54
+
55
+ "@oxc-minify/binding-linux-arm64-gnu": ["@oxc-minify/binding-linux-arm64-gnu@0.64.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-LLuw+y498KXqosUPiv5szXK0ZHCHZudiclDSiSghYj3jFH3eLo47XOiQNIWYyOsErTMdzg1yI/J79ZcfxUrhVg=="],
56
+
57
+ "@oxc-minify/binding-linux-arm64-musl": ["@oxc-minify/binding-linux-arm64-musl@0.64.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-5JC2tdDmyn4GpbwJjgTpb7wu/H59l4tXd8gE8Cb26k49Ir2cmijAS+X24wB7qO+iPj+xfGFzhBCcoT/6hIxeOw=="],
58
+
59
+ "@oxc-minify/binding-linux-x64-gnu": ["@oxc-minify/binding-linux-x64-gnu@0.64.0", "", { "os": "linux", "cpu": "x64" }, "sha512-YpJv27iwyf7oE8dbPV8I8cyaijmIe2TwBwSHJtQIv/hDv1jZWTcFzV9gxkd10MLwzZ802VGwGuiH7dEscTcXqQ=="],
60
+
61
+ "@oxc-minify/binding-linux-x64-musl": ["@oxc-minify/binding-linux-x64-musl@0.64.0", "", { "os": "linux", "cpu": "x64" }, "sha512-YOyL3lUQw0vJ7ZvU5TATA0PDzbgNy4aMac3H8C20aZ35Mamde1GlRhMC7nh8h4Cp2a2X6ios/mFn1nqFMPTWGA=="],
62
+
63
+ "@oxc-minify/binding-wasm32-wasi": ["@oxc-minify/binding-wasm32-wasi@0.64.0", "", { "dependencies": { "@napi-rs/wasm-runtime": "^0.2.9" }, "cpu": "none" }, "sha512-87ycAkjA0dkMlUruNCT39YEFPIe18CJ0bwZww2ZFzi2ImWMcttmovWX+MoSdHAbP2bu0DURM/A9WjcNusg+xxw=="],
64
+
65
+ "@oxc-minify/binding-win32-arm64-msvc": ["@oxc-minify/binding-win32-arm64-msvc@0.64.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-e1eh4pmBh09gOfroAmaTK9TgBN4FtOpuov0BkbWOBcDPh0kH0722YmAq/f/p85xAHjS284fXwkK8DlLeHQapDA=="],
66
+
67
+ "@oxc-minify/binding-win32-x64-msvc": ["@oxc-minify/binding-win32-x64-msvc@0.64.0", "", { "os": "win32", "cpu": "x64" }, "sha512-BQkLBUjobThdSVR2eL+iudr7X/RISk7uj8Z93yixBX89puwQxa/oAxBZQ9TbXgXXLBg5nkxoJgHwL++UHY3lYQ=="],
68
+
69
+ "@oxc-transform/binding-darwin-arm64": ["@oxc-transform/binding-darwin-arm64@0.65.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-hHfhOKyH+8DOj0VUmWl6RPLy3F0jCMCUMuKICzfelvSEs5uu8YRJ7fmQSsQD9E0oTrbbdkNVjq/1mcAPHzIBsg=="],
70
+
71
+ "@oxc-transform/binding-darwin-x64": ["@oxc-transform/binding-darwin-x64@0.65.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-MNeaCPBVB1oOdb4kMZnKej8kSoxqf4XqAfFIKgx2mV1gJnW3PfwAbpqhad+XH3QM49dB++Gyaw7SPNwQLpL3YQ=="],
72
+
73
+ "@oxc-transform/binding-linux-arm-gnueabihf": ["@oxc-transform/binding-linux-arm-gnueabihf@0.65.0", "", { "os": "linux", "cpu": "arm" }, "sha512-YpmBf4AhtAdsLV7XYY9/UxVmgewumgVlNVcPXXXAQ5shMEYhu2K/fCvlWBFe6vYNXFmXAAnDihOjLrq8n+NhnA=="],
74
+
75
+ "@oxc-transform/binding-linux-arm64-gnu": ["@oxc-transform/binding-linux-arm64-gnu@0.65.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-HbGl1QBvxCBVfRJdrcZliOsvjeoyMJQn6UUbYzQR8ud7SY2Ozp0Qf5VG0yjXvt/9BPcmOYMIxVCeKqSSkQ74XA=="],
76
+
77
+ "@oxc-transform/binding-linux-arm64-musl": ["@oxc-transform/binding-linux-arm64-musl@0.65.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-80gSeSVY9fm+xoLBkTYdJT2RYCqMy/NAqT6azQoJj3DczoNKU/4GV4F6jpINRWYUqIUAZt3RSvAQtdW3tWAjfw=="],
78
+
79
+ "@oxc-transform/binding-linux-x64-gnu": ["@oxc-transform/binding-linux-x64-gnu@0.65.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Wsl+qLcaC3EeZT/ZjPuGTOtcHYu25HeEO1jCnZmIhFfz+1RWmaEK5P5xVVJbrAgNPMVOfqbUM0EwMCfvNmmPaQ=="],
80
+
81
+ "@oxc-transform/binding-linux-x64-musl": ["@oxc-transform/binding-linux-x64-musl@0.65.0", "", { "os": "linux", "cpu": "x64" }, "sha512-0kvRnt7EsKeGxxyt90l7yotSH5Ik5G9fbFJxkDCzPT23FzIQC8U4O1GzqNxnSj8VT/lRJGKcCL6KfSa6ttzQRQ=="],
82
+
83
+ "@oxc-transform/binding-wasm32-wasi": ["@oxc-transform/binding-wasm32-wasi@0.65.0", "", { "dependencies": { "@napi-rs/wasm-runtime": "^0.2.9" }, "cpu": "none" }, "sha512-gKfpf5BY28Cq0scUV//oBlzXg+XFbi2tKpKDqE/ee4Z0ySeDQ66pwBUp3nnEG7EsVZjKhE8yksPN4YOCoZhG9g=="],
84
+
85
+ "@oxc-transform/binding-win32-arm64-msvc": ["@oxc-transform/binding-win32-arm64-msvc@0.65.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-InHZNcL6hB2QLaiw3KNe+Aqnk+FRt4vuVmDXUibZ0fZSQorcFw/T267PtVVuWIzFNa6CQPU4ie0rxIdP0sHcFg=="],
86
+
87
+ "@oxc-transform/binding-win32-x64-msvc": ["@oxc-transform/binding-win32-x64-msvc@0.65.0", "", { "os": "win32", "cpu": "x64" }, "sha512-qvLEPowed0OcSEgztGXw1QF53KhLYYYWGxOK2H+9PSXpkNcYaeUQ1XOngR9kO8yIhpBt1/EOrVFeNK8biy0c7g=="],
88
+
89
+ "@tybys/wasm-util": ["@tybys/wasm-util@0.9.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw=="],
90
+
91
+ "@types/bun": ["@types/bun@1.2.19", "", { "dependencies": { "bun-types": "1.2.19" } }, "sha512-d9ZCmrH3CJ2uYKXQIUuZ/pUnTqIvLDS0SK7pFmbx8ma+ziH/FRMoAq5bYpRG7y+w1gl+HgyNZbtqgMq4W4e2Lg=="],
92
+
93
+ "@types/node": ["@types/node@22.14.0", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA=="],
94
+
95
+ "@types/react": ["@types/react@19.1.9", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-WmdoynAX8Stew/36uTSVMcLJJ1KRh6L3IZRx1PZ7qJtBqT3dYTgyDTx8H1qoRghErydW7xw9mSJ3wS//tCRpFA=="],
96
+
97
+ "bun-types": ["bun-types@1.2.19", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-uAOTaZSPuYsWIXRpj7o56Let0g/wjihKCkeRqUBhlLVM/Bt+Fj9xTo+LhC1OV1XDaGkz4hNC80et5xgy+9KTHQ=="],
98
+
99
+ "ciorent": ["ciorent@file:lib", {}],
100
+
101
+ "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
102
+
103
+ "jiti": ["jiti@2.5.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w=="],
104
+
105
+ "mitata": ["mitata@1.0.34", "", {}, "sha512-Mc3zrtNBKIMeHSCQ0XqRLo1vbdIx1wvFV9c8NJAiyho6AjNfMY8bVhbS12bwciUdd1t4rj8099CH3N3NFahaUA=="],
106
+
107
+ "oxc-minify": ["oxc-minify@0.64.0", "", { "optionalDependencies": { "@oxc-minify/binding-darwin-arm64": "0.64.0", "@oxc-minify/binding-darwin-x64": "0.64.0", "@oxc-minify/binding-linux-arm-gnueabihf": "0.64.0", "@oxc-minify/binding-linux-arm64-gnu": "0.64.0", "@oxc-minify/binding-linux-arm64-musl": "0.64.0", "@oxc-minify/binding-linux-x64-gnu": "0.64.0", "@oxc-minify/binding-linux-x64-musl": "0.64.0", "@oxc-minify/binding-wasm32-wasi": "0.64.0", "@oxc-minify/binding-win32-arm64-msvc": "0.64.0", "@oxc-minify/binding-win32-x64-msvc": "0.64.0" } }, "sha512-nyQ4qGRlr210mVSkS9whn+ghhe2o6ba22ksTBWMj4CHUhNJWfY0S/h1yEUvDZxNFtuxSReLSlQATUzUyo7/wzQ=="],
108
+
109
+ "oxc-transform": ["oxc-transform@0.65.0", "", { "optionalDependencies": { "@oxc-transform/binding-darwin-arm64": "0.65.0", "@oxc-transform/binding-darwin-x64": "0.65.0", "@oxc-transform/binding-linux-arm-gnueabihf": "0.65.0", "@oxc-transform/binding-linux-arm64-gnu": "0.65.0", "@oxc-transform/binding-linux-arm64-musl": "0.65.0", "@oxc-transform/binding-linux-x64-gnu": "0.65.0", "@oxc-transform/binding-linux-x64-musl": "0.65.0", "@oxc-transform/binding-wasm32-wasi": "0.65.0", "@oxc-transform/binding-win32-arm64-msvc": "0.65.0", "@oxc-transform/binding-win32-x64-msvc": "0.65.0" } }, "sha512-TWAMi8zVvORQw545O1/1irpbMPDQGD6ernen5QyY5PCL9nj3RqgR1ULlQiHVDXEl2rW+OtHF8KS0ItAUyOfQ+Q=="],
110
+
111
+ "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
112
+
113
+ "typescript": ["typescript@5.9.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A=="],
114
+
115
+ "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
116
+ }
117
+ }
package/package.json CHANGED
@@ -1,21 +1,38 @@
1
1
  {
2
- "name": "ciorent",
3
- "version": "1.0.3",
4
- "description": "A lightweight, low-overhead concurrency library",
5
- "homepage": "https://re-utils.pages.dev/concurrency",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/re-utils/ciorent.git"
9
- },
10
- "keywords": ["low-overhead", "lightweight", "concurrency", "cross-runtime"],
11
- "license": "MIT",
12
- "type": "module",
13
- "exports": {
14
- "./utils": "./utils.js",
15
- "./signal": "./signal.js",
16
- "./rate-limit": "./rate-limit.js",
17
- "./semaphore": "./semaphore.js",
18
- "./mutex": "./mutex.js",
19
- ".": "./index.js"
2
+ "name": "ciorent",
3
+ "version": "1.0.5",
4
+ "description": "A lightweight, low-overhead concurrency library",
5
+ "homepage": "https://re-utils.pages.dev/concurrency",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/re-utils/ciorent.git"
9
+ },
10
+ "keywords": [
11
+ "low-overhead",
12
+ "lightweight",
13
+ "concurrency",
14
+ "cross-runtime"
15
+ ],
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "scripts": {
19
+ "task": "bun scripts/task.ts",
20
+ "fmt": "biome format .",
21
+ "lint": "biome check",
22
+ "build:test": "bun task build && bun test",
23
+ "build:publish": "bun task build && bun task report-size && bun task publish"
24
+ },
25
+ "devDependencies": {
26
+ "@biomejs/biome": "^2.1.3",
27
+ "@types/bun": "^1.2.19",
28
+ "mitata": "^1.0.34",
29
+ "oxc-minify": "^0.64.0",
30
+ "oxc-transform": "^0.65.0",
31
+ "typescript": "^5.9.2",
32
+ "jiti": "^2.5.1",
33
+ "ciorent": "./lib"
34
+ },
35
+ "trustedDependencies": [
36
+ "@biomejs/biome"
37
+ ]
20
38
  }
21
- }
@@ -0,0 +1,38 @@
1
+ import { parseArgs } from 'node:util';
2
+ import { Glob } from 'bun';
3
+ import { BENCH, cd, exec } from './utils.ts';
4
+
5
+ const CMD: Dict<string> = {
6
+ bun: 'bun run',
7
+ node: 'node --import jiti/register --expose-gc --allow-natives-syntax',
8
+ deno: 'deno run --allow-all --v8-flags=--expose-gc,--allow-natives-syntax',
9
+ };
10
+
11
+ const args = parseArgs({
12
+ options: {
13
+ runtime: {
14
+ type: 'string',
15
+ default: 'node',
16
+ short: 'r',
17
+ },
18
+ target: {
19
+ type: 'string',
20
+ short: 't',
21
+ },
22
+ },
23
+ }).values;
24
+
25
+ const EXE = CMD[args.runtime];
26
+ if (EXE == null) throw new Error('Unrecognized runtime: ' + args.runtime);
27
+
28
+ cd(BENCH);
29
+
30
+ if (args.target != null) {
31
+ const path = `${args.target}.bench.ts`;
32
+ console.log('Running benchmark:', path);
33
+ await exec`${{ raw: EXE }} ${path}`;
34
+ } else
35
+ for (const path of new Glob('**/*.bench.ts').scanSync(BENCH)) {
36
+ console.log('Running benchmark:', path);
37
+ await exec`${{ raw: EXE }} ${path}`;
38
+ }
@@ -0,0 +1,62 @@
1
+ /// <reference types='bun-types' />
2
+ import { existsSync, rmSync } from 'node:fs';
3
+ import { minify } from 'oxc-minify';
4
+ import { transform } from 'oxc-transform';
5
+ import pkg from '../package.json';
6
+ import { cp, LIB, ROOT, SOURCE } from './utils.ts';
7
+
8
+ // Remove old content
9
+ if (existsSync(LIB)) rmSync(LIB, { recursive: true });
10
+
11
+ // @ts-ignore
12
+ const exports = (pkg.exports = {} as Record<string, string>);
13
+
14
+ await Promise.all(
15
+ [...new Bun.Glob('**/*.ts').scanSync(SOURCE)].map(async (path) => {
16
+ const pathNoExt = path.slice(0, path.lastIndexOf('.') >>> 0);
17
+
18
+ const transformed = transform(
19
+ path,
20
+ await Bun.file(`${SOURCE}/${path}`).text(),
21
+ {
22
+ sourceType: 'module',
23
+ typescript: {
24
+ declaration: {
25
+ stripInternal: true,
26
+ },
27
+ },
28
+ lang: 'ts',
29
+ },
30
+ );
31
+
32
+ if (transformed.code !== '')
33
+ Bun.write(
34
+ `${LIB}/${pathNoExt}.js`,
35
+ minify(
36
+ path,
37
+ transformed.code.replace(/const (.*) =/g, (a) =>
38
+ a.replace('const', 'let'),
39
+ ),
40
+ {
41
+ compress: false,
42
+ mangle: false,
43
+ },
44
+ ).code,
45
+ );
46
+
47
+ if (transformed.declaration) {
48
+ Bun.write(`${LIB}/${pathNoExt}.d.ts`, transformed.declaration);
49
+ exports[
50
+ pathNoExt === 'index'
51
+ ? '.'
52
+ : './' +
53
+ (pathNoExt.endsWith('/index') ? pathNoExt.slice(0, -6) : pathNoExt)
54
+ ] = './' + pathNoExt + (transformed.code === '' ? '.d.ts' : '.js');
55
+ }
56
+ }),
57
+ );
58
+
59
+ pkg.trustedDependencies = pkg.devDependencies = pkg.scripts = undefined as any;
60
+
61
+ Bun.write(LIB + '/package.json', JSON.stringify(pkg));
62
+ cp(ROOT, LIB, 'README.md');
@@ -0,0 +1,4 @@
1
+ import { cd, exec, LIB } from './utils.ts';
2
+
3
+ cd(LIB);
4
+ await exec`bun publish --access=public`;