@d-zero/dealer 1.0.0-alpha.1 → 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/dist/deal.d.ts CHANGED
@@ -4,5 +4,5 @@ type Options = DealerOptions & LanesOptions & {
4
4
  header?: (progress: number, done: number, total: number, limit: number) => string;
5
5
  debug?: boolean;
6
6
  };
7
- export declare function deal<T extends WeakKey>(items: readonly T[], setup: (process: T, update: (log: string) => void, index: number) => () => void | Promise<void>, options: Options): Promise<void>;
7
+ export declare function deal<T extends WeakKey>(items: readonly T[], setup: (process: T, update: (log: string) => void, index: number) => Promise<() => void | Promise<void>>, options?: Options): Promise<void>;
8
8
  export {};
package/dist/deal.js CHANGED
@@ -9,15 +9,15 @@ export async function deal(items, setup, options) {
9
9
  lanes.header(options.header(progress, done, total, limit));
10
10
  });
11
11
  }
12
- dealer.setup((process, index) => {
12
+ await dealer.setup(async (process, index) => {
13
13
  const update = (log) => lanes.update(index, log);
14
- const start = setup(process, update, index);
14
+ const start = await setup(process, update, index);
15
15
  return async () => {
16
16
  await start();
17
17
  lanes.delete(index);
18
18
  };
19
19
  });
20
- if (options.debug) {
20
+ if (options?.debug) {
21
21
  dealer.debug((log) => {
22
22
  lanes.update(DEBUG_ID, `[DEBUG]: ${log}`);
23
23
  });
package/dist/dealer.d.ts CHANGED
@@ -9,5 +9,5 @@ export declare class Dealer<T extends WeakKey> {
9
9
  finish(listener: () => void): void;
10
10
  play(): void;
11
11
  progress(listener: (progress: number, done: number, total: number, limit: number) => void): void;
12
- setup(initializer: ProcessInitializer<T>): void;
12
+ setup(initializer: ProcessInitializer<T>): Promise<void>;
13
13
  }
package/dist/dealer.js CHANGED
@@ -24,9 +24,9 @@ export class Dealer {
24
24
  progress(listener) {
25
25
  this.#progress = listener;
26
26
  }
27
- setup(initializer) {
27
+ async setup(initializer) {
28
28
  for (const [index, item] of this.#items.entries()) {
29
- const start = initializer(item, index);
29
+ const start = await initializer(item, index);
30
30
  this.#starts.set(item, async () => await start());
31
31
  }
32
32
  this.#progress(this.#doneCount / this.#items.length, this.#doneCount, this.#items.length, this.#limit);
package/dist/display.js CHANGED
@@ -8,6 +8,7 @@ const animationPresets = {
8
8
  dots: [5, '. ', '.. ', '...'],
9
9
  block: [20, '▘', '▀', '▜', '▉', '▟', '▃', '▖', ' '],
10
10
  propeller: [25, '\\', '|', '/', '-'],
11
+ braille: [10, '⠄', '⠂', '⠁', '⠈', '⠐', '⠠'],
11
12
  };
12
13
  export class Display {
13
14
  #animations;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type Animations = Record<string, [fps: number, ...sprites: string[]]>;
2
2
  export type FPS = 12 | 24 | 30 | 60;
3
3
  export interface ProcessInitializer<T> {
4
- (process: T, index: number): () => Promise<void> | void;
4
+ (process: T, index: number): Promise<() => Promise<void> | void>;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/dealer",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0",
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",
@@ -9,8 +9,12 @@
9
9
  "access": "public"
10
10
  },
11
11
  "type": "module",
12
- "module": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
14
18
  "files": [
15
19
  "dist"
16
20
  ],
@@ -21,5 +25,5 @@
21
25
  "dependencies": {
22
26
  "ansi-colors": "4.1.3"
23
27
  },
24
- "gitHead": "feffce2ac8ca616a0fbca4b19987c3bff5291d3d"
28
+ "gitHead": "db479312eb17afb95785928ae632814897943ba1"
25
29
  }