@@ -10,6 +10,7 @@ type Task<TaskResultType> =
10
10
| ( ( ) => PromiseLike < TaskResultType > )
11
11
| ( ( ) => TaskResultType ) ;
12
12
13
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
13
14
const empty = ( ) : void => { } ;
14
15
15
16
const timeoutError = new TimeoutError ( ) ;
@@ -56,7 +57,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
56
57
constructor ( options ?: Options < QueueType , EnqueueOptionsType > ) {
57
58
super ( ) ;
58
59
59
- // eslint-disable-next-line @typescript-eslint/no-object-literal- type-assertion
60
+ // eslint-disable-next-line @typescript-eslint/consistent- type-assertions
60
61
options = {
61
62
carryoverConcurrencyCount : false ,
62
63
intervalCap : Infinity ,
@@ -65,15 +66,14 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
65
66
autoStart : true ,
66
67
queueClass : PriorityQueue ,
67
68
...options
68
- // TODO: Remove this `as`.
69
69
} as Options < QueueType , EnqueueOptionsType > ;
70
70
71
71
if ( ! ( typeof options . intervalCap === 'number' && options . intervalCap >= 1 ) ) {
72
- throw new TypeError ( `Expected \`intervalCap\` to be a number from 1 and up, got \`${ options . intervalCap } \` (${ typeof options . intervalCap } )` ) ;
72
+ throw new TypeError ( `Expected \`intervalCap\` to be a number from 1 and up, got \`${ options . intervalCap ?. toString ( ) ?? '' } \` (${ typeof options . intervalCap } )` ) ;
73
73
}
74
74
75
75
if ( options . interval === undefined || ! ( Number . isFinite ( options . interval ) && options . interval >= 0 ) ) {
76
- throw new TypeError ( `Expected \`interval\` to be a finite number >= 0, got \`${ options . interval } \` (${ typeof options . interval } )` ) ;
76
+ throw new TypeError ( `Expected \`interval\` to be a finite number >= 0, got \`${ options . interval ?. toString ( ) ?? '' } \` (${ typeof options . interval } )` ) ;
77
77
}
78
78
79
79
this . _carryoverConcurrencyCount = options . carryoverConcurrencyCount ! ;
@@ -226,6 +226,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
226
226
/**
227
227
Adds a sync or async task to the queue. Always returns a promise.
228
228
*/
229
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
229
230
async add < TaskResultType > ( fn : Task < TaskResultType > , options : Partial < EnqueueOptionsType > = { } ) : Promise < TaskResultType > {
230
231
return new Promise < TaskResultType > ( ( resolve , reject ) => {
231
232
const run = async ( ) : Promise < void > => {
@@ -349,7 +350,7 @@ export default class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsT
349
350
350
351
For example, this can be used to find the number of items remaining in the queue with a specific priority level.
351
352
*/
352
- sizeBy ( options : Partial < EnqueueOptionsType > ) : number {
353
+ sizeBy ( options : Readonly < Partial < EnqueueOptionsType > > ) : number {
353
354
return this . _queue . filter ( options ) . length ;
354
355
}
355
356
0 commit comments