@anmiles/queue 4.0.1 → 5.0.1
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/.nycrc.json +27 -0
- package/CHANGELOG.md +12 -0
- package/cspell.json +19 -0
- package/dist/lib/queue.d.ts.map +1 -1
- package/dist/lib/queue.js +1 -1
- package/dist/lib/queue.js.map +1 -1
- package/eslint.config.mts +15 -0
- package/jest.config.js +10 -7
- package/package.json +34 -25
- package/src/lib/__tests__/queue.test.ts +3 -2
- package/src/lib/queue.ts +7 -7
- package/tsconfig.build.json +6 -0
- package/tsconfig.json +0 -5
- package/tsconfig.test.json +7 -0
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -9
- package/.vscode/settings.json +0 -7
- package/coverage.config.js +0 -8
package/.nycrc.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"all": true,
|
|
3
|
+
"check-coverage" : true,
|
|
4
|
+
|
|
5
|
+
"statements" : 100,
|
|
6
|
+
"branches" : 100,
|
|
7
|
+
"lines" : 100,
|
|
8
|
+
"functions" : 100,
|
|
9
|
+
|
|
10
|
+
"report-dir" : "./coverage",
|
|
11
|
+
"temp-dir" : "./coverage",
|
|
12
|
+
|
|
13
|
+
"reporter" : [
|
|
14
|
+
"text",
|
|
15
|
+
"html"
|
|
16
|
+
],
|
|
17
|
+
"extension": [
|
|
18
|
+
".js",
|
|
19
|
+
".mjs",
|
|
20
|
+
".cjs",
|
|
21
|
+
".jsx",
|
|
22
|
+
".ts",
|
|
23
|
+
".cts",
|
|
24
|
+
".mts",
|
|
25
|
+
".tsx"
|
|
26
|
+
]
|
|
27
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.0.1](../../tags/v5.0.1) - 2025-07-24
|
|
9
|
+
### Changed
|
|
10
|
+
- Fix vulnerable dependencies
|
|
11
|
+
|
|
12
|
+
## [5.0.0](../../tags/v5.0.0) - 2025-05-18
|
|
13
|
+
__(BREAKING) Dropped support for NodeJS 18 (EOL). Minimum required version is now NodeJS 20.__
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Migrated to NodeJS 20.19
|
|
17
|
+
- Migrated to ESLint V9 flat configs
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
8
20
|
## [4.0.1](../../tags/v4.0.1) - 2024-03-20
|
|
9
21
|
### Changed
|
|
10
22
|
- Update dependencies
|
package/cspell.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"language": "en",
|
|
5
|
+
"minWordLength": 4,
|
|
6
|
+
"enableGlobDot": true,
|
|
7
|
+
"useGitignore": true,
|
|
8
|
+
"ignorePaths": [
|
|
9
|
+
".git",
|
|
10
|
+
"package-lock.json"
|
|
11
|
+
],
|
|
12
|
+
"words": [
|
|
13
|
+
"anmiles",
|
|
14
|
+
"anatoliy",
|
|
15
|
+
"emittery",
|
|
16
|
+
"oblaukhov"
|
|
17
|
+
],
|
|
18
|
+
"flagWords": []
|
|
19
|
+
}
|
package/dist/lib/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,UAAU,SAAS,CAAC,CAAC;IACpB,IAAI,
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,UAAU,SAAS,CAAC,CAAC;IACpB,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,EAAE,MAAK,IAAI,CAAC;CAChB;AAED,cAAM,KAAK,CAAC,KAAK,CAAE,SAAQ,QAAQ,CAAC;KAAG,MAAM,IAAI,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;IACnH,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,IAAI,GAAE,KAAK,EAAO,EAAE,EAAE,QAAY,EAAE,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO;IAO5E,OAAO,CAAC,GAAG,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI;IAU1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B,KAAK,IAAI,MAAM;CAGf;AAED,eAAe,KAAK,CAAC"}
|
package/dist/lib/queue.js
CHANGED
|
@@ -25,7 +25,7 @@ class Queue extends emittery_1.default {
|
|
|
25
25
|
this.done = false;
|
|
26
26
|
if (this.data.length > 0) {
|
|
27
27
|
const now = performance.now();
|
|
28
|
-
await this.emit('item', this.data.shift());
|
|
28
|
+
await this.emit('item', this.data.shift()); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
29
29
|
setTimeout(() => {
|
|
30
30
|
void this.dequeue();
|
|
31
31
|
}, Math.max(0, this.interval - (performance.now() - now)));
|
package/dist/lib/queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/lib/queue.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAOhC,MAAM,KAAa,SAAQ,kBAAyF;IAC3G,IAAI,
|
|
1
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IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACF,CAAC;IAED,KAAK;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;CACD;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { configs } from '@anmiles/eslint-config';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
...configs.base,
|
|
6
|
+
...configs.ts,
|
|
7
|
+
...configs.jest,
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
'coverage/*',
|
|
12
|
+
'dist/*',
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
] as Linter.Config[];
|
package/jest.config.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
preset
|
|
3
|
-
transform
|
|
4
|
-
'^.+\\.tsx?$'
|
|
2
|
+
preset : 'ts-jest',
|
|
3
|
+
transform: {
|
|
4
|
+
'^.+\\.tsx?$': [ 'ts-jest', {
|
|
5
|
+
tsconfig: './tsconfig.test.json',
|
|
6
|
+
} ],
|
|
5
7
|
},
|
|
6
8
|
|
|
7
|
-
clearMocks
|
|
9
|
+
clearMocks: true,
|
|
8
10
|
|
|
9
|
-
roots
|
|
10
|
-
testMatch
|
|
11
|
+
roots : [ '<rootDir>/src' ],
|
|
12
|
+
testMatch: [ '<rootDir>/src/**/__tests__/*.test.{ts,tsx}' ],
|
|
11
13
|
|
|
12
|
-
collectCoverageFrom
|
|
14
|
+
collectCoverageFrom: [
|
|
13
15
|
'<rootDir>/src/**/*.{ts,tsx}',
|
|
14
16
|
'!<rootDir>/src/**/__tests__/**',
|
|
17
|
+
'!<rootDir>/src/**/__mocks__/**',
|
|
15
18
|
],
|
|
16
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anmiles/queue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Queue dispatcher that sequentially processes incoming items",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"queue",
|
|
@@ -12,43 +12,52 @@
|
|
|
12
12
|
"repository": "github:anmiles/queue",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=20.19.0"
|
|
16
16
|
},
|
|
17
17
|
"main": "dist/index.js",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"spellcheck": "cspell .",
|
|
20
|
+
"prebuild": "rimraf dist",
|
|
21
|
+
"build": "tsc -p ./tsconfig.build.json",
|
|
22
|
+
"lint": "eslint",
|
|
23
|
+
"lint:fix": "eslint --fix",
|
|
22
24
|
"test": "jest --verbose",
|
|
23
25
|
"test:coverage": "npm test -- --coverage",
|
|
24
26
|
"test:ci": "npm test -- --ci --coverage",
|
|
25
27
|
"test:watch": "npm test -- --watch",
|
|
26
28
|
"test:watch:coverage": "npm test -- --watch --coverage",
|
|
27
|
-
"test:report:coverage": "nyc report
|
|
29
|
+
"test:report:coverage": "nyc report"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
32
|
"emittery": "^0.13.1"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@anmiles/eslint-config": "^
|
|
34
|
-
"@anmiles/sleep": "^
|
|
35
|
-
"@anmiles/tsconfig": "^
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"eslint": "^
|
|
41
|
-
"eslint-
|
|
35
|
+
"@anmiles/eslint-config": "^9.0.3",
|
|
36
|
+
"@anmiles/sleep": "^5.0.1",
|
|
37
|
+
"@anmiles/tsconfig": "^4.0.0",
|
|
38
|
+
"@eslint/compat": "^1.3.1",
|
|
39
|
+
"@eslint/css": "^0.10.0",
|
|
40
|
+
"@eslint/js": "^9.31.0",
|
|
41
|
+
"@eslint/json": "^0.13.1",
|
|
42
|
+
"@eslint/markdown": "^7.1.0",
|
|
43
|
+
"@stylistic/eslint-plugin": "^5.2.2",
|
|
44
|
+
"@types/jest": "^30.0.0",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
46
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
47
|
+
"cspell": "^9.2.0",
|
|
48
|
+
"eslint": "^9.31.0",
|
|
49
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
42
50
|
"eslint-plugin-align-assignments": "^1.1.2",
|
|
43
|
-
"eslint-plugin-
|
|
44
|
-
"eslint-plugin-
|
|
45
|
-
"eslint-plugin-
|
|
46
|
-
"eslint-plugin-n": "^
|
|
47
|
-
"eslint-plugin-promise": "^
|
|
48
|
-
"jest": "^
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"eslint-plugin-i18next": "^6.1.3",
|
|
52
|
+
"eslint-plugin-import": "^2.32.0",
|
|
53
|
+
"eslint-plugin-jest": "^29.0.1",
|
|
54
|
+
"eslint-plugin-n": "^17.21.0",
|
|
55
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
56
|
+
"jest": "^30.0.5",
|
|
57
|
+
"jiti": "^2.5.0",
|
|
58
|
+
"nyc": "^17.1.0",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"ts-jest": "^29.4.0",
|
|
61
|
+
"typescript": "^5.8.3"
|
|
53
62
|
}
|
|
54
63
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import sleep from '@anmiles/sleep';
|
|
2
|
+
|
|
2
3
|
import Queue from '../queue';
|
|
3
4
|
|
|
4
5
|
describe('src/lib/queue', () => {
|
|
@@ -16,7 +17,7 @@ describe('src/lib/queue', () => {
|
|
|
16
17
|
setTimeoutSpy.mockImplementation((func, timeout) => {
|
|
17
18
|
log.push(`timeout(${Math.floor(timeout ?? 0)})`);
|
|
18
19
|
func();
|
|
19
|
-
return 0 as unknown as ReturnType<typeof setTimeout>;
|
|
20
|
+
return 0 as unknown as ReturnType<typeof setTimeout>; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
|
|
@@ -41,7 +42,7 @@ describe('src/lib/queue', () => {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
it('should be set if specified', () => {
|
|
44
|
-
expect(new Queue([], { interval
|
|
45
|
+
expect(new Queue([], { interval: 10 })['interval']).toEqual(10);
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
});
|
package/src/lib/queue.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import Emittery from 'emittery';
|
|
2
2
|
|
|
3
3
|
interface Listeners<T> {
|
|
4
|
-
item
|
|
5
|
-
done
|
|
4
|
+
item: (item: T)=> Promise<void>;
|
|
5
|
+
done: ()=> void;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
class Queue<TItem> extends Emittery<{ [TEvent in keyof Listeners<TItem>]: Parameters<Listeners<TItem>[TEvent]>[0] }> {
|
|
9
|
-
private done
|
|
10
|
-
private readonly data
|
|
11
|
-
private readonly interval
|
|
9
|
+
private done: boolean;
|
|
10
|
+
private readonly data: TItem[];
|
|
11
|
+
private readonly interval: number;
|
|
12
12
|
|
|
13
|
-
constructor(data: TItem[] = [], { interval = 0 }: { interval
|
|
13
|
+
constructor(data: TItem[] = [], { interval = 0 }: { interval?: number } = {}) {
|
|
14
14
|
super();
|
|
15
15
|
this.done = false;
|
|
16
16
|
this.data = data;
|
|
@@ -32,7 +32,7 @@ class Queue<TItem> extends Emittery<{ [TEvent in keyof Listeners<TItem>]: Parame
|
|
|
32
32
|
|
|
33
33
|
if (this.data.length > 0) {
|
|
34
34
|
const now = performance.now();
|
|
35
|
-
await this.emit('item', this.data.shift() as TItem);
|
|
35
|
+
await this.emit('item', this.data.shift() as TItem); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
|
36
36
|
setTimeout(() => {
|
|
37
37
|
void this.dequeue();
|
|
38
38
|
}, Math.max(0, this.interval - (performance.now() - now)));
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
package/.vscode/settings.json
DELETED