dropcap 1.0.0 → 1.1.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.
@@ -11,7 +11,7 @@ declare class Queue {
11
11
  private running;
12
12
  constructor(name?: string | null);
13
13
  add<T>(fn: TaskFn<T>): Promise<T>;
14
- wrap<T extends AsyncFn>(fn: T, thisValue?: unknown): (...args: Parameters<T>) => Promise<any>;
14
+ wrap<T extends AsyncFn>(fn: T, thisValue?: unknown): T;
15
15
  wait(): Promise<void>;
16
16
  isEmpty(): boolean;
17
17
  private start;
@@ -55,9 +55,9 @@ var Queue = class {
55
55
  return await task.result$.promise;
56
56
  }
57
57
  wrap(fn, thisValue = null) {
58
- return async (...args) => {
58
+ return (async (...args) => {
59
59
  return await this.add(() => fn.call(thisValue, ...args));
60
- };
60
+ });
61
61
  }
62
62
  async wait() {
63
63
  const lastTask = this.tasks.at(-1);
@@ -72,6 +72,7 @@ var Queue = class {
72
72
  this.running = true;
73
73
  while (this.tasks.length > 0) {
74
74
  const task = this.tasks[0];
75
+ if (!task) break;
75
76
  const [result, error] = await safe(task.fn);
76
77
  this.tasks.shift();
77
78
  if (error) {
@@ -121,9 +121,9 @@ var Queue = class {
121
121
  return await task.result$.promise;
122
122
  }
123
123
  wrap(fn, thisValue = null) {
124
- return async (...args) => {
124
+ return (async (...args) => {
125
125
  return await this.add(() => fn.call(thisValue, ...args));
126
- };
126
+ });
127
127
  }
128
128
  async wait() {
129
129
  const lastTask = this.tasks.at(-1);
@@ -138,6 +138,7 @@ var Queue = class {
138
138
  this.running = true;
139
139
  while (this.tasks.length > 0) {
140
140
  const task = this.tasks[0];
141
+ if (!task) break;
141
142
  const [result, error] = await safe(task.fn);
142
143
  this.tasks.shift();
143
144
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dropcap",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -12,19 +12,13 @@
12
12
  "release": "sh -c 'npm version ${1:-minor} && npm run build && npm publish' --"
13
13
  },
14
14
  "exports": {
15
- "./utils": {
16
- "source": "./src/utils/utils.ts",
17
- "import": "./dist/utils/utils.js",
18
- "types": "./dist/utils/utils.d.ts"
19
- },
20
- "./types": {
21
- "source": "./src/types/types.ts",
22
- "import": "./dist/types/types.js",
23
- "types": "./dist/types/types.d.ts"
24
- }
15
+ "./utils": "./dist/utils/utils.js",
16
+ "./types": "./dist/types/types.js",
17
+ "./utils/ts": "./src/utils/utils.ts",
18
+ "./types/ts": "./src/types/types.ts"
25
19
  },
26
20
  "files": [
27
- "src",
28
- "dist"
21
+ "dist",
22
+ "src"
29
23
  ]
30
24
  }
@@ -21,9 +21,9 @@ export class Queue {
21
21
  }
22
22
 
23
23
  wrap<T extends AsyncFn>(fn: T, thisValue: unknown = null) {
24
- return async (...args: Parameters<T>) => {
24
+ return (async (...args: Parameters<T>) => {
25
25
  return await this.add(() => fn.call(thisValue, ...args))
26
- }
26
+ }) as T
27
27
  }
28
28
 
29
29
  async wait() {
@@ -43,6 +43,7 @@ export class Queue {
43
43
 
44
44
  while (this.tasks.length > 0) {
45
45
  const task = this.tasks[0]
46
+ if (!task) break
46
47
  const [result, error] = await safe(task.fn)
47
48
  this.tasks.shift()
48
49
  if (error) {