aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/p-map
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/p-map')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/p-map/index.d.ts67
-rw-r--r--sandbox/testAppNevena/Front/node_modules/p-map/index.js81
-rw-r--r--sandbox/testAppNevena/Front/node_modules/p-map/license9
-rw-r--r--sandbox/testAppNevena/Front/node_modules/p-map/package.json53
-rw-r--r--sandbox/testAppNevena/Front/node_modules/p-map/readme.md89
5 files changed, 299 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/p-map/index.d.ts b/sandbox/testAppNevena/Front/node_modules/p-map/index.d.ts
new file mode 100644
index 00000000..bcbe0afc
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/p-map/index.d.ts
@@ -0,0 +1,67 @@
+declare namespace pMap {
+ interface Options {
+ /**
+ Number of concurrently pending promises returned by `mapper`.
+
+ Must be an integer from 1 and up or `Infinity`.
+
+ @default Infinity
+ */
+ readonly concurrency?: number;
+
+ /**
+ When set to `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
+
+ @default true
+ */
+ readonly stopOnError?: boolean;
+ }
+
+ /**
+ Function which is called for every item in `input`. Expected to return a `Promise` or value.
+
+ @param element - Iterated element.
+ @param index - Index of the element in the source array.
+ */
+ type Mapper<Element = any, NewElement = unknown> = (
+ element: Element,
+ index: number
+ ) => NewElement | Promise<NewElement>;
+}
+
+/**
+@param input - Iterated over concurrently in the `mapper` function.
+@param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
+@returns A `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
+
+@example
+```
+import pMap = require('p-map');
+import got = require('got');
+
+const sites = [
+ getWebsiteFromUsername('https://sindresorhus'), //=> Promise
+ 'https://ava.li',
+ 'https://github.com'
+];
+
+(async () => {
+ const mapper = async site => {
+ const {requestUrl} = await got.head(site);
+ return requestUrl;
+ };
+
+ const result = await pMap(sites, mapper, {concurrency: 2});
+
+ console.log(result);
+ //=> ['https://sindresorhus.com/', 'https://ava.li/', 'https://github.com/']
+})();
+```
+*/
+declare function pMap<Element, NewElement>(
+ input: Iterable<Element>,
+ mapper: pMap.Mapper<Element, NewElement>,
+ options?: pMap.Options
+): Promise<NewElement[]>;
+
+export = pMap;
diff --git a/sandbox/testAppNevena/Front/node_modules/p-map/index.js b/sandbox/testAppNevena/Front/node_modules/p-map/index.js
new file mode 100644
index 00000000..c11a2851
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/p-map/index.js
@@ -0,0 +1,81 @@
+'use strict';
+const AggregateError = require('aggregate-error');
+
+module.exports = async (
+ iterable,
+ mapper,
+ {
+ concurrency = Infinity,
+ stopOnError = true
+ } = {}
+) => {
+ return new Promise((resolve, reject) => {
+ if (typeof mapper !== 'function') {
+ throw new TypeError('Mapper function is required');
+ }
+
+ if (!((Number.isSafeInteger(concurrency) || concurrency === Infinity) && concurrency >= 1)) {
+ throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
+ }
+
+ const result = [];
+ const errors = [];
+ const iterator = iterable[Symbol.iterator]();
+ let isRejected = false;
+ let isIterableDone = false;
+ let resolvingCount = 0;
+ let currentIndex = 0;
+
+ const next = () => {
+ if (isRejected) {
+ return;
+ }
+
+ const nextItem = iterator.next();
+ const index = currentIndex;
+ currentIndex++;
+
+ if (nextItem.done) {
+ isIterableDone = true;
+
+ if (resolvingCount === 0) {
+ if (!stopOnError && errors.length !== 0) {
+ reject(new AggregateError(errors));
+ } else {
+ resolve(result);
+ }
+ }
+
+ return;
+ }
+
+ resolvingCount++;
+
+ (async () => {
+ try {
+ const element = await nextItem.value;
+ result[index] = await mapper(element, index);
+ resolvingCount--;
+ next();
+ } catch (error) {
+ if (stopOnError) {
+ isRejected = true;
+ reject(error);
+ } else {
+ errors.push(error);
+ resolvingCount--;
+ next();
+ }
+ }
+ })();
+ };
+
+ for (let i = 0; i < concurrency; i++) {
+ next();
+
+ if (isIterableDone) {
+ break;
+ }
+ }
+ });
+};
diff --git a/sandbox/testAppNevena/Front/node_modules/p-map/license b/sandbox/testAppNevena/Front/node_modules/p-map/license
new file mode 100644
index 00000000..fa7ceba3
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/p-map/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/sandbox/testAppNevena/Front/node_modules/p-map/package.json b/sandbox/testAppNevena/Front/node_modules/p-map/package.json
new file mode 100644
index 00000000..042b1af5
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/p-map/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "p-map",
+ "version": "4.0.0",
+ "description": "Map over promises concurrently",
+ "license": "MIT",
+ "repository": "sindresorhus/p-map",
+ "funding": "https://github.com/sponsors/sindresorhus",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "https://sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "promise",
+ "map",
+ "resolved",
+ "wait",
+ "collection",
+ "iterable",
+ "iterator",
+ "race",
+ "fulfilled",
+ "async",
+ "await",
+ "promises",
+ "concurrently",
+ "concurrency",
+ "parallel",
+ "bluebird"
+ ],
+ "dependencies": {
+ "aggregate-error": "^3.0.0"
+ },
+ "devDependencies": {
+ "ava": "^2.2.0",
+ "delay": "^4.1.0",
+ "in-range": "^2.0.0",
+ "random-int": "^2.0.0",
+ "time-span": "^3.1.0",
+ "tsd": "^0.7.4",
+ "xo": "^0.27.2"
+ }
+}
diff --git a/sandbox/testAppNevena/Front/node_modules/p-map/readme.md b/sandbox/testAppNevena/Front/node_modules/p-map/readme.md
new file mode 100644
index 00000000..53a37157
--- /dev/null
+++ b/sandbox/testAppNevena/Front/node_modules/p-map/readme.md
@@ -0,0 +1,89 @@
+# p-map [![Build Status](https://travis-ci.org/sindresorhus/p-map.svg?branch=master)](https://travis-ci.org/sindresorhus/p-map)
+
+> Map over promises concurrently
+
+Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently.
+
+## Install
+
+```
+$ npm install p-map
+```
+
+## Usage
+
+```js
+const pMap = require('p-map');
+const got = require('got');
+
+const sites = [
+ getWebsiteFromUsername('https://sindresorhus'), //=> Promise
+ 'https://ava.li',
+ 'https://github.com'
+];
+
+(async () => {
+ const mapper = async site => {
+ const {requestUrl} = await got.head(site);
+ return requestUrl;
+ };
+
+ const result = await pMap(sites, mapper, {concurrency: 2});
+
+ console.log(result);
+ //=> ['https://sindresorhus.com/', 'https://ava.li/', 'https://github.com/']
+})();
+```
+
+## API
+
+### pMap(input, mapper, options?)
+
+Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
+
+#### input
+
+Type: `Iterable<Promise | unknown>`
+
+Iterated over concurrently in the `mapper` function.
+
+#### mapper(element, index)
+
+Type: `Function`
+
+Expected to return a `Promise` or value.
+
+#### options
+
+Type: `object`
+
+##### concurrency
+
+Type: `number` (Integer)\
+Default: `Infinity`\
+Minimum: `1`
+
+Number of concurrently pending promises returned by `mapper`.
+
+##### stopOnError
+
+Type: `boolean`\
+Default: `true`
+
+When set to `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
+
+## p-map for enterprise
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of p-map and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-p-map?utm_source=npm-p-map&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
+
+## Related
+
+- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
+- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
+- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently
+- [p-props](https://github.com/sindresorhus/p-props) - Like `Promise.all()` but for `Map` and `Object`
+- [p-map-series](https://github.com/sindresorhus/p-map-series) - Map over promises serially
+- [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
+- [Moreā€¦](https://github.com/sindresorhus/promise-fun)