updated npm modules
This commit is contained in:
35
node_modules/p-map/index.js
generated
vendored
35
node_modules/p-map/index.js
generated
vendored
@@ -1,14 +1,15 @@
|
||||
'use strict';
|
||||
module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {
|
||||
opts = Object.assign({
|
||||
|
||||
const pMap = (iterable, mapper, options) => new Promise((resolve, reject) => {
|
||||
options = Object.assign({
|
||||
concurrency: Infinity
|
||||
}, opts);
|
||||
}, options);
|
||||
|
||||
if (typeof mapper !== 'function') {
|
||||
throw new TypeError('Mapper function is required');
|
||||
}
|
||||
|
||||
const concurrency = opts.concurrency;
|
||||
const {concurrency} = options;
|
||||
|
||||
if (!(typeof concurrency === 'number' && concurrency >= 1)) {
|
||||
throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${concurrency}\` (${typeof concurrency})`);
|
||||
@@ -17,9 +18,9 @@ module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {
|
||||
const ret = [];
|
||||
const iterator = iterable[Symbol.iterator]();
|
||||
let isRejected = false;
|
||||
let iterableDone = false;
|
||||
let isIterableDone = false;
|
||||
let resolvingCount = 0;
|
||||
let currentIdx = 0;
|
||||
let currentIndex = 0;
|
||||
|
||||
const next = () => {
|
||||
if (isRejected) {
|
||||
@@ -27,11 +28,11 @@ module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {
|
||||
}
|
||||
|
||||
const nextItem = iterator.next();
|
||||
const i = currentIdx;
|
||||
currentIdx++;
|
||||
const i = currentIndex;
|
||||
currentIndex++;
|
||||
|
||||
if (nextItem.done) {
|
||||
iterableDone = true;
|
||||
isIterableDone = true;
|
||||
|
||||
if (resolvingCount === 0) {
|
||||
resolve(ret);
|
||||
@@ -43,16 +44,16 @@ module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {
|
||||
resolvingCount++;
|
||||
|
||||
Promise.resolve(nextItem.value)
|
||||
.then(el => mapper(el, i))
|
||||
.then(element => mapper(element, i))
|
||||
.then(
|
||||
val => {
|
||||
ret[i] = val;
|
||||
value => {
|
||||
ret[i] = value;
|
||||
resolvingCount--;
|
||||
next();
|
||||
},
|
||||
err => {
|
||||
error => {
|
||||
isRejected = true;
|
||||
reject(err);
|
||||
reject(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -60,8 +61,12 @@ module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {
|
||||
for (let i = 0; i < concurrency; i++) {
|
||||
next();
|
||||
|
||||
if (iterableDone) {
|
||||
if (isIterableDone) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = pMap;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = pMap;
|
||||
|
||||
36
node_modules/p-map/package.json
generated
vendored
36
node_modules/p-map/package.json
generated
vendored
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"_from": "p-map@^1.1.1",
|
||||
"_id": "p-map@1.2.0",
|
||||
"_from": "p-map@^2.0.0",
|
||||
"_id": "p-map@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==",
|
||||
"_integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==",
|
||||
"_location": "/p-map",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "p-map@^1.1.1",
|
||||
"raw": "p-map@^2.0.0",
|
||||
"name": "p-map",
|
||||
"escapedName": "p-map",
|
||||
"rawSpec": "^1.1.1",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/del"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz",
|
||||
"_shasum": "e4e94f311eabbc8633a1e79908165fca26241b6b",
|
||||
"_spec": "p-map@^1.1.1",
|
||||
"_resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz",
|
||||
"_shasum": "310928feef9c9ecc65b68b17693018a665cea175",
|
||||
"_spec": "p-map@^2.0.0",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\del",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
@@ -34,18 +34,20 @@
|
||||
"deprecated": false,
|
||||
"description": "Map over promises concurrently",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"delay": "^2.0.0",
|
||||
"ava": "^1.4.1",
|
||||
"delay": "^4.1.0",
|
||||
"in-range": "^1.0.0",
|
||||
"random-int": "^1.0.0",
|
||||
"time-span": "^2.0.0",
|
||||
"xo": "*"
|
||||
"time-span": "^3.1.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/p-map#readme",
|
||||
"keywords": [
|
||||
@@ -73,7 +75,7 @@
|
||||
"url": "git+https://github.com/sindresorhus/p-map.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "1.2.0"
|
||||
"version": "2.1.0"
|
||||
}
|
||||
|
||||
12
node_modules/p-map/readme.md
generated
vendored
12
node_modules/p-map/readme.md
generated
vendored
@@ -25,15 +25,19 @@ const sites = [
|
||||
'github.com'
|
||||
];
|
||||
|
||||
const mapper = el => got.head(el).then(res => res.requestUrl);
|
||||
(async () => {
|
||||
const mapper = async site => {
|
||||
const {requestUrl} = await got.head(site);
|
||||
return requestUrl;
|
||||
};
|
||||
|
||||
const result = await pMap(sites, mapper, {concurrency: 2});
|
||||
|
||||
pMap(sites, mapper, {concurrency: 2}).then(result => {
|
||||
console.log(result);
|
||||
//=> ['http://sindresorhus.com/', 'http://ava.li/', 'http://todomvc.com/', 'http://github.com/']
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pMap(input, mapper, [options])
|
||||
|
||||
Reference in New Issue
Block a user