File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const pTry = require('p-try');
3
3
4
4
const pLimit = concurrency => {
5
5
if ( ! ( ( Number . isInteger ( concurrency ) || concurrency === Infinity ) && concurrency > 0 ) ) {
6
- return Promise . reject ( new TypeError ( 'Expected `concurrency` to be a number from 1 and up' ) ) ;
6
+ throw new TypeError ( 'Expected `concurrency` to be a number from 1 and up' ) ;
7
7
}
8
8
9
9
const queue = [ ] ;
Original file line number Diff line number Diff line change @@ -138,10 +138,24 @@ test('clearQueue', async t => {
138
138
t . is ( limit . pendingCount , 0 ) ;
139
139
} ) ;
140
140
141
- test ( 'throws on invalid concurrency argument' , async t => {
142
- await t . throwsAsync ( pLimit ( 0 ) ) ;
143
- await t . throwsAsync ( pLimit ( - 1 ) ) ;
144
- await t . throwsAsync ( pLimit ( 1.2 ) ) ;
145
- await t . throwsAsync ( pLimit ( undefined ) ) ;
146
- await t . throwsAsync ( pLimit ( true ) ) ;
141
+ test ( 'throws on invalid concurrency argument' , t => {
142
+ t . throws ( ( ) => {
143
+ pLimit ( 0 ) ;
144
+ } ) ;
145
+
146
+ t . throws ( ( ) => {
147
+ pLimit ( - 1 ) ;
148
+ } ) ;
149
+
150
+ t . throws ( ( ) => {
151
+ pLimit ( 1.2 ) ;
152
+ } ) ;
153
+
154
+ t . throws ( ( ) => {
155
+ pLimit ( undefined ) ;
156
+ } ) ;
157
+
158
+ t . throws ( ( ) => {
159
+ pLimit ( true ) ;
160
+ } ) ;
147
161
} ) ;
You can’t perform that action at this time.
0 commit comments