@d-zero/dealer 1.6.0 → 1.6.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/README.md +3 -3
- package/dist/deal.d.ts +2 -2
- package/dist/dealer.d.ts +3 -3
- package/dist/display.js +13 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ async function deal<T extends WeakKey>(
|
|
|
54
54
|
setLineHeader: (lineHeader: string) => void,
|
|
55
55
|
push: (...items: T[]) => Promise<void>,
|
|
56
56
|
) => Promise<() => void | Promise<void>> | (() => void | Promise<void>),
|
|
57
|
-
options?: DealOptions
|
|
57
|
+
options?: DealOptions<T>,
|
|
58
58
|
): Promise<void>;
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -83,7 +83,7 @@ async function deal<T extends WeakKey>(
|
|
|
83
83
|
### DealOptions型
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
type DealOptions = DealerOptions &
|
|
86
|
+
type DealOptions<T = unknown> = DealerOptions<T> &
|
|
87
87
|
LanesOptions & {
|
|
88
88
|
readonly header?: DealHeader;
|
|
89
89
|
readonly debug?: boolean;
|
|
@@ -135,7 +135,7 @@ type DealHeader = (
|
|
|
135
135
|
#### コンストラクタ
|
|
136
136
|
|
|
137
137
|
```ts
|
|
138
|
-
constructor(items: readonly T[], options?: DealerOptions)
|
|
138
|
+
constructor(items: readonly T[], options?: DealerOptions<T>)
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
- `items`: 処理対象のアイテム
|
package/dist/deal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DealerOptions } from './dealer.js';
|
|
2
2
|
import type { LanesOptions } from './lanes.js';
|
|
3
3
|
import type { DelayOptions } from '@d-zero/shared/delay';
|
|
4
|
-
export type DealOptions = DealerOptions & LanesOptions & {
|
|
4
|
+
export type DealOptions<T = unknown> = DealerOptions<T> & LanesOptions & {
|
|
5
5
|
readonly header?: DealHeader;
|
|
6
6
|
readonly debug?: boolean;
|
|
7
7
|
readonly interval?: number | DelayOptions;
|
|
@@ -41,4 +41,4 @@ export type DealHeader = (progress: number, done: number, total: number, limit:
|
|
|
41
41
|
* @param options - Configuration options including interval delay
|
|
42
42
|
* @returns Promise that resolves when all items are processed
|
|
43
43
|
*/
|
|
44
|
-
export declare function deal<T extends WeakKey>(items: readonly T[], setup: (process: T, update: (log: string) => void, index: number, setLineHeader: (lineHeader: string) => void, push: (...items: T[]) => Promise<void>) => Promise<() => void | Promise<void>> | (() => void | Promise<void>), options?: DealOptions): Promise<void>;
|
|
44
|
+
export declare function deal<T extends WeakKey>(items: readonly T[], setup: (process: T, update: (log: string) => void, index: number, setLineHeader: (lineHeader: string) => void, push: (...items: T[]) => Promise<void>) => Promise<() => void | Promise<void>> | (() => void | Promise<void>), options?: DealOptions<T>): Promise<void>;
|
package/dist/dealer.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ProcessInitializer } from './types.js';
|
|
2
|
-
export interface DealerOptions {
|
|
2
|
+
export interface DealerOptions<T = unknown> {
|
|
3
3
|
limit?: number;
|
|
4
|
-
onPush?: (item:
|
|
4
|
+
onPush?: (item: T) => boolean;
|
|
5
5
|
}
|
|
6
6
|
export declare class Dealer<T extends WeakKey> {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(items: readonly T[], options?: DealerOptions);
|
|
8
|
+
constructor(items: readonly T[], options?: DealerOptions<T>);
|
|
9
9
|
debug(listener: (log: string) => void): void;
|
|
10
10
|
finish(listener: () => void): void;
|
|
11
11
|
play(): void;
|
package/dist/display.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import readline from 'node:readline';
|
|
2
1
|
import c from 'ansi-colors';
|
|
3
2
|
import { countDownFunctionParser } from './count-down-function-parser.js';
|
|
4
3
|
import { riffle } from './riffle.js';
|
|
5
4
|
const RESET = c.reset('');
|
|
5
|
+
const CURSOR_UP = (n) => `\u001B[${n}A`;
|
|
6
|
+
const CURSOR_TO_COL0 = '\u001B[G';
|
|
7
|
+
const ERASE_DOWN = '\u001B[0J';
|
|
6
8
|
const animationPresets = {
|
|
7
9
|
earth: [2, '🌏', '🌍', '🌎'],
|
|
8
10
|
dots: [5, '. ', '.. ', '...'],
|
|
@@ -39,7 +41,9 @@ export class Display {
|
|
|
39
41
|
this.#timer = null;
|
|
40
42
|
}
|
|
41
43
|
this.#write();
|
|
42
|
-
process.stdin.
|
|
44
|
+
if (process.stdin.isTTY) {
|
|
45
|
+
process.stdin.setRawMode(false);
|
|
46
|
+
}
|
|
43
47
|
this.#lastWroteLineNum = 0;
|
|
44
48
|
this.#stack = null;
|
|
45
49
|
}
|
|
@@ -59,16 +63,6 @@ export class Display {
|
|
|
59
63
|
}
|
|
60
64
|
this.#enterFrame();
|
|
61
65
|
}
|
|
62
|
-
#clear() {
|
|
63
|
-
if (this.#verbose) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
for (let i = 0; i < this.#lastWroteLineNum; i++) {
|
|
67
|
-
readline.moveCursor(process.stdout, 0, -1);
|
|
68
|
-
readline.cursorTo(process.stdout, 0);
|
|
69
|
-
readline.clearLine(process.stdout, 0);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
66
|
#countDown(text) {
|
|
73
67
|
const parsed = countDownFunctionParser(text);
|
|
74
68
|
if (!parsed) {
|
|
@@ -114,12 +108,17 @@ export class Display {
|
|
|
114
108
|
if (!this.#stack) {
|
|
115
109
|
return;
|
|
116
110
|
}
|
|
117
|
-
this.#clear();
|
|
118
111
|
const outputBuffer = [];
|
|
119
112
|
for (const stack of this.#stack) {
|
|
120
113
|
outputBuffer.push(this.#text(stack));
|
|
121
114
|
}
|
|
122
|
-
|
|
115
|
+
const content = outputBuffer.join('\n') + '\n';
|
|
116
|
+
let output = '';
|
|
117
|
+
if (this.#lastWroteLineNum > 0) {
|
|
118
|
+
output += CURSOR_UP(this.#lastWroteLineNum) + CURSOR_TO_COL0 + ERASE_DOWN;
|
|
119
|
+
}
|
|
120
|
+
output += content;
|
|
121
|
+
process.stdout.write(output);
|
|
123
122
|
this.#lastWroteLineNum = this.#stack.length;
|
|
124
123
|
}
|
|
125
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/dealer",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "A tool that provides an API and CLI for parallel processing of collections and sequential logging to standard output",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"clean": "tsc --build --clean"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@d-zero/shared": "0.
|
|
26
|
+
"@d-zero/shared": "0.19.0",
|
|
27
27
|
"ansi-colors": "4.1.3"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "7f90e8c637c40b9abee652eac927a3ca257ef29f"
|
|
30
30
|
}
|