@cimo/queue 1.0.0
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/LICENSE.md +21 -0
- package/README.md +58 -0
- package/dist/eslint.customRule.d.ts +22 -0
- package/dist/eslint.customRule.js +35 -0
- package/dist/eslint.customRule.js.map +1 -0
- package/dist/src/Main.d.ts +2 -0
- package/dist/src/Main.js +3 -0
- package/dist/src/Main.js.map +1 -0
- package/dist/src/Model.d.ts +3 -0
- package/dist/src/Model.js +2 -0
- package/dist/src/Model.js.map +1 -0
- package/dist/src/Service.d.ts +4 -0
- package/dist/src/Service.js +31 -0
- package/dist/src/Service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsconfig.tsc.tsbuildinfo +1 -0
- package/package.json +45 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 cimo - reinventsoftware.org
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Npm_queue
|
|
2
|
+
|
|
3
|
+
Npm package, queue job. Light, fast and secure.
|
|
4
|
+
Writed with native Typescript code and no dependencies are used.
|
|
5
|
+
|
|
6
|
+
## Pack
|
|
7
|
+
|
|
8
|
+
1. npm run build
|
|
9
|
+
2. Copy the file "/build/package_name-x.x.x.tgz" in the project root folder.
|
|
10
|
+
3. In the "package.json" file insert: "@cimo/package_name": "file:package_name-x.x.x.tgz"
|
|
11
|
+
|
|
12
|
+
## Publish
|
|
13
|
+
|
|
14
|
+
1. npm run build
|
|
15
|
+
2. npm login --auth-type=legacy
|
|
16
|
+
3. npm publish --auth-type=legacy --access public
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
1. Link for npm package -> https://www.npmjs.com/package/@cimo/queue
|
|
21
|
+
|
|
22
|
+
## Server
|
|
23
|
+
|
|
24
|
+
- Server.ts
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
import { Cu } from "@cimo/queue/dist/src/Main";
|
|
30
|
+
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
post("/api/v1/test1", () => {
|
|
34
|
+
cu.list.push(() => {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
resolve();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
cu.processSerial();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
post("/api/v1/test2", () => {
|
|
46
|
+
cu.list.push(() => {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
...
|
|
49
|
+
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
cu.processParallel(2);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
...
|
|
58
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TSESLint, TSESTree } from "@typescript-eslint/utils";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
rules: {
|
|
4
|
+
"no-array-assignment-for-object-type": {
|
|
5
|
+
meta: {
|
|
6
|
+
type: string;
|
|
7
|
+
docs: {
|
|
8
|
+
description: string;
|
|
9
|
+
recommended: boolean;
|
|
10
|
+
};
|
|
11
|
+
messages: {
|
|
12
|
+
noArrayAssignmentForObjectType: string;
|
|
13
|
+
};
|
|
14
|
+
schema: never[];
|
|
15
|
+
};
|
|
16
|
+
create(context: TSESLint.RuleContext<"noArrayAssignmentForObjectType", []>): {
|
|
17
|
+
TSArrayType(node: TSESTree.TSArrayType): void;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
const rules = {
|
|
3
|
+
"no-array-assignment-for-object-type": {
|
|
4
|
+
meta: {
|
|
5
|
+
type: "problem",
|
|
6
|
+
docs: {
|
|
7
|
+
description: "Safe array assignment for object type.",
|
|
8
|
+
recommended: false
|
|
9
|
+
},
|
|
10
|
+
messages: {
|
|
11
|
+
noArrayAssignmentForObjectType: "Array assign for object type is disallowed."
|
|
12
|
+
},
|
|
13
|
+
schema: []
|
|
14
|
+
},
|
|
15
|
+
create(context) {
|
|
16
|
+
const parserServices = ESLintUtils.getParserServices(context);
|
|
17
|
+
return {
|
|
18
|
+
TSArrayType(node) {
|
|
19
|
+
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node.elementType);
|
|
20
|
+
const checker = parserServices.program.getTypeChecker();
|
|
21
|
+
const type = checker.getTypeAtLocation(tsNode);
|
|
22
|
+
const indexType = type.getStringIndexType();
|
|
23
|
+
if (indexType) {
|
|
24
|
+
context.report({
|
|
25
|
+
node,
|
|
26
|
+
messageId: "noArrayAssignmentForObjectType"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default { rules };
|
|
35
|
+
//# sourceMappingURL=eslint.customRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.customRule.js","sourceRoot":"","sources":["../eslint.customRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,KAAK,GAAG;IACV,qCAAqC,EAAE;QACnC,IAAI,EAAE;YACF,IAAI,EAAE,SAAS;YACf,IAAI,EAAE;gBACF,WAAW,EAAE,wCAAwC;gBACrD,WAAW,EAAE,KAAK;aACrB;YACD,QAAQ,EAAE;gBACN,8BAA8B,EAAE,6CAA6C;aAChF;YACD,MAAM,EAAE,EAAE;SACb;QACD,MAAM,CAAC,OAAmE;YACtE,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE9D,OAAO;gBACH,WAAW,CAAC,IAA0B;oBAClC,MAAM,MAAM,GAAG,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC1E,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;oBACxD,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAE5C,IAAI,SAAS,EAAE,CAAC;wBACZ,OAAO,CAAC,MAAM,CAAC;4BACX,IAAI;4BACJ,SAAS,EAAE,gCAAgC;yBAC9C,CAAC,CAAC;oBACP,CAAC;gBACL,CAAC;aACJ,CAAC;QACN,CAAC;KACJ;CACJ,CAAC;AAEF,eAAe,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/src/Main.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Main.js","sourceRoot":"","sources":["../../src/Main.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../src/Model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
let serialIsBusy = false;
|
|
2
|
+
let parallelCountRunning = 0;
|
|
3
|
+
export const list = [];
|
|
4
|
+
export const processSerial = () => {
|
|
5
|
+
if (serialIsBusy) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const job = list.shift();
|
|
9
|
+
if (!job) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
serialIsBusy = true;
|
|
13
|
+
job().finally(() => {
|
|
14
|
+
serialIsBusy = false;
|
|
15
|
+
processSerial();
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export const processParallel = (parralelMax) => {
|
|
19
|
+
while (parallelCountRunning < parralelMax) {
|
|
20
|
+
const job = list.shift();
|
|
21
|
+
if (!job) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
parallelCountRunning++;
|
|
25
|
+
job().finally(() => {
|
|
26
|
+
parallelCountRunning--;
|
|
27
|
+
processParallel(parralelMax);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=Service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Service.js","sourceRoot":"","sources":["../../src/Service.ts"],"names":[],"mappings":"AAGA,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,IAAI,GAAiB,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAS,EAAE;IACpC,IAAI,YAAY,EAAE,CAAC;QACf,OAAO;IACX,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAEzB,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,OAAO;IACX,CAAC;IAED,YAAY,GAAG,IAAI,CAAC;IAEpB,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;QACf,YAAY,GAAG,KAAK,CAAC;QAErB,aAAa,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAQ,EAAE;IACzD,OAAO,oBAAoB,GAAG,WAAW,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAEzB,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO;QACX,CAAC;QAED,oBAAoB,EAAE,CAAC;QAEvB,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;YACf,oBAAoB,EAAE,CAAC;YAEvB,eAAe,CAAC,WAAW,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../eslint.customRule.ts","../global.d.ts","../src/Main.ts","../src/Model.ts","../src/Service.ts"],"version":"5.7.2"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../eslint.customRule.ts","../global.d.ts"],"version":"5.7.2"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cimo/queue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Queue job. Light, fast and secure.",
|
|
5
|
+
"author": "cimo",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cimo/Npm_queue.git"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"remove_dist": "node -e \"const fs = require('fs'); try{ fs.rmdirSync('./dist/', { recursive: true }) } catch{}; process.exit(0);\"",
|
|
14
|
+
"remove_build": "node -e \"const fs = require('fs'); try{ fs.rmdirSync('./build/', { recursive: true }) } catch{}; process.exit(0);\"",
|
|
15
|
+
"check": "eslint --no-cache --config eslint.config.js",
|
|
16
|
+
"build_tsc": "npm run remove_dist && tsc --build tsconfig.tsc.json",
|
|
17
|
+
"build_library": "npm run remove_build && tsc --build tsconfig.json && npm pack && mkdir -p ./build/ && mv *.tgz ./build/",
|
|
18
|
+
"build": "npm audit && npm run build_tsc && npm run check && npm run build_library"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "5.7.2",
|
|
23
|
+
"eslint": "9.31.0",
|
|
24
|
+
"@typescript-eslint/parser": "8.24.1",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "8.24.1",
|
|
26
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
27
|
+
"prettier": "3.4.2",
|
|
28
|
+
"@types/node": "22.10.2"
|
|
29
|
+
},
|
|
30
|
+
"resolutions": {},
|
|
31
|
+
"files": [
|
|
32
|
+
"./dist/"
|
|
33
|
+
],
|
|
34
|
+
"main": "./dist/Main.js",
|
|
35
|
+
"types": "./dist/Main.d.ts",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"queue",
|
|
38
|
+
"job",
|
|
39
|
+
"nodejs",
|
|
40
|
+
"typescript",
|
|
41
|
+
"cimo",
|
|
42
|
+
"native",
|
|
43
|
+
"no dependencies"
|
|
44
|
+
]
|
|
45
|
+
}
|