Skip to content

Commit

Permalink
Require Node.js 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 6, 2020
1 parent 7b978e3 commit b35faf5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
- '6'
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Limit {
Note: This does not cancel promises that are already running.
*/
clearQueue(): void;
clearQueue: () => void;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ const pLimit = concurrency => {
}
};

const run = (fn, resolve, ...args) => {
const run = async (fn, resolve, ...args) => {
activeCount++;

// TODO: Get rid of `pTry`. It's not needed anymore.
const result = pTry(fn, ...args);

resolve(result);

result.then(next, next);
try {
await result;
} catch {}

This comment has been minimized.

Copy link
@tarekch

tarekch Jun 22, 2020

so this is now producing a syntax error in any library using p-limit.
SyntaxError: Unexpected token {
the correct syntax should be catch(err) {}

This comment has been minimized.

Copy link
@sindresorhus

sindresorhus Jun 22, 2020

Author Owner

It is valid syntax on Node.js 10.

This comment has been minimized.

Copy link
@tarekch

tarekch Jun 23, 2020

yep, we were on node 9 in fact. Thanx for the info

This comment has been minimized.

Copy link
@ajrsws

ajrsws Jul 1, 2020

Can you add the catch(error) even the way you have it is support by node 10? I'm having an issue with this library mostly because I have to use node 8, because of firebase functions made me use node 8.

This comment has been minimized.

Copy link
@HerrZatacke

HerrZatacke Jul 5, 2020

In my opinion a change that requires a higher node.js version is a breaking change.
If you follow semantic versioning (which is expected by npm) you should increase the major revision number.
Which means from 3.0.0 the version should go to 4.0.0 and not 3.0.1

This comment has been minimized.

Copy link
@sindresorhus

next();
};

const enqueue = (fn, resolve, ...args) => {
Expand Down Expand Up @@ -62,4 +67,3 @@ const pLimit = concurrency => {
};

module.exports = pLimit;
module.exports.default = pLimit;
4 changes: 2 additions & 2 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {expectType} from 'tsd-check';
import {expectType} from 'tsd';
import pLimit from '.';

const limit = pLimit(1);

const input = [
limit(() => Promise.resolve('foo')),
limit(() => Promise.resolve('bar')),
limit(() => Promise.resolve(undefined)),
limit(() => Promise.resolve(undefined))
];

expectType<Promise<Array<string | undefined>>>(Promise.all(input));
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
Expand All @@ -41,12 +41,12 @@
"p-try": "^2.0.0"
},
"devDependencies": {
"ava": "^1.2.1",
"ava": "^2.4.0",
"delay": "^4.1.0",
"in-range": "^1.0.0",
"random-int": "^1.0.0",
"time-span": "^2.0.0",
"tsd-check": "^0.3.0",
"xo": "^0.24.0"
"in-range": "^2.0.0",
"random-int": "^2.0.1",
"time-span": "^4.0.0",
"tsd": "^0.11.0",
"xo": "^0.26.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# p-limit [![Build Status](https://travis-ci.org/sindresorhus/p-limit.svg?branch=master)](https://travis-ci.org/sindresorhus/p-limit)
# p-limit [![Build Status](https://travis-ci.com/sindresorhus/p-limit.svg?branch=master)](https://travis-ci.com/github/sindresorhus/p-limit)

> Run multiple promise-returning & async functions with limited concurrency
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test('concurrency: 1', async t => {
return value;
});

t.deepEqual(await Promise.all(input.map(mapper)), [10, 20, 30]);
t.true(inRange(end(), 590, 650));
t.deepEqual(await Promise.all(input.map(x => mapper(x))), [10, 20, 30]);
t.true(inRange(end(), {start: 590, end: 650}));
});

test('concurrency: 4', async t => {
Expand Down

0 comments on commit b35faf5

Please sign in to comment.