{"_id":"@arthur.lee945/promise-pool","_rev":"2-810c3d915b291ebeee80e1839e27f5ac","name":"@arthur.lee945/promise-pool","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@arthur.lee945/promise-pool","version":"1.0.0","description":"Queue based promise pool","engines":{"node":">=8"},"main":"dist","types":"dist","homepage":"https://github.com/arthurlee945/promise-pool","repository":{"type":"git","url":"git+https://github.com/arthurlee945/promise-pool.git"},"bugs":{"url":"https://github.com/arthurlee945/promise-pool/issues"},"scripts":{"build":"tsc","test":"jest","test:performance":"ts-node ./src/test/performance.ts","lint":"eslint src --ext .js,.ts","lint:fix":"eslint --fix src --ext .js,.ts","format":"prettier --write src","clean":"rm -rf node_modules pnpm-lock.yaml","prepare":"husky install"},"keywords":["promises","nodejs","async","map"],"publishConfig":{"access":"public"},"author":{"name":"arthur lee","email":"arthur.lee945@gmail.com"},"license":"MIT","devDependencies":{"@babel/core":"^7.23.5","@babel/preset-env":"^7.23.5","@babel/preset-typescript":"^7.23.3","@ianvs/prettier-plugin-sort-imports":"^4.1.1","@supercharge/promise-pool":"^3.1.0","@types/eslint":"^8.44.7","@types/jest":"^29.5.10","@types/node":"^20.10.0","@typescript-eslint/eslint-plugin":"^6.12.0","@typescript-eslint/parser":"^6.12.0","babel-jest":"^29.7.0","eslint":"^8.54.0","eslint-config-prettier":"^9.0.0","eslint-plugin-import":"^2.29.0","husky":"^8.0.3","jest":"^29.7.0","prettier":"^3.1.0","ts-jest":"^29.1.1","ts-node":"^10.9.1","typescript":"^5.3.2"},"gitHead":"0c0c4eab26c82edc5fe1ec64f8019a442439f6a9","_id":"@arthur.lee945/promise-pool@1.0.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-h0nBxLjc/C7puaK8XKF5GEYMCSGa6EJj0VzaNA4qE5l8wGxkHVY04fhBf4C9kMgKwR4yMKg0wbjGWwrflaljVw==","shasum":"fc9bb8571ab64aa1a48cfac31642d8dcf8b743c9","tarball":"https://registry.npmjs.org/@arthur.lee945/promise-pool/-/promise-pool-1.0.0.tgz","fileCount":17,"unpackedSize":27967,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPYl3+7V8RuM/1iWzNQV3uy77JdjkiaKaMoyIOVvVIDQIhAI4sZK3j3EVoKjnfmTvHjhjAbmYHjQ5TXEYGUfrTPAtm"}]},"_npmUser":{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"},"directories":{},"maintainers":[{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-pool_1.0.0_1701748215440_0.37917493903621247"},"_hasShrinkwrap":false},"1.0.1":{"name":"@arthur.lee945/promise-pool","version":"1.0.1","description":"Queue based promise pool","engines":{"node":">=8"},"main":"dist","types":"dist","homepage":"https://github.com/arthurlee945/promise-pool","repository":{"type":"git","url":"git+https://github.com/arthurlee945/promise-pool.git"},"bugs":{"url":"https://github.com/arthurlee945/promise-pool/issues"},"scripts":{"build":"tsc","test":"jest","test:performance":"ts-node ./src/test/performance.ts","lint":"eslint src --ext .js,.ts","lint:fix":"eslint --fix src --ext .js,.ts","format":"prettier --write src","clean":"rm -rf node_modules pnpm-lock.yaml","prepare":"husky install"},"keywords":["promises","nodejs","async","queue","promise-pool"],"publishConfig":{"access":"public"},"author":{"name":"arthur lee","email":"arthur.lee945@gmail.com"},"license":"MIT","devDependencies":{"@babel/core":"^7.23.5","@babel/preset-env":"^7.23.5","@babel/preset-typescript":"^7.23.3","@ianvs/prettier-plugin-sort-imports":"^4.1.1","@supercharge/promise-pool":"^3.1.0","@types/eslint":"^8.44.7","@types/jest":"^29.5.10","@types/node":"^20.10.0","@typescript-eslint/eslint-plugin":"^6.12.0","@typescript-eslint/parser":"^6.12.0","babel-jest":"^29.7.0","eslint":"^8.54.0","eslint-config-prettier":"^9.0.0","eslint-plugin-import":"^2.29.0","husky":"^8.0.3","jest":"^29.7.0","prettier":"^3.1.0","ts-jest":"^29.1.1","ts-node":"^10.9.1","typescript":"^5.3.2"},"gitHead":"ac44e5d235b3932f0c1e41252549551dcf36879d","_id":"@arthur.lee945/promise-pool@1.0.1","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-TBwg2SSlJmIms3SaBw5i/8NmtC1CDFSj9DunhlqfuM4g8xvwJ6tFYNX4+3WhjG5BZJe0dXM9UlPI1Dzt2xWyOA==","shasum":"d2029ed36f126c8aec238d1fd438766623281a39","tarball":"https://registry.npmjs.org/@arthur.lee945/promise-pool/-/promise-pool-1.0.1.tgz","fileCount":17,"unpackedSize":28385,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCej1Rq3xCMgRweN9ZE2+dhFAUOym8/YdHjAGSQ7lyF5QIgKYCOj2zbrhEt/b+r3uv/XBjLAvC7Byk/I0tlGf45470="}]},"_npmUser":{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"},"directories":{},"maintainers":[{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-pool_1.0.1_1701821805695_0.9825876943487484"},"_hasShrinkwrap":false},"1.0.2":{"name":"@arthur.lee945/promise-pool","version":"1.0.2","description":"Queue based promise pool","engines":{"node":">=8"},"main":"dist","types":"dist","homepage":"https://github.com/arthurlee945/promise-pool","repository":{"type":"git","url":"git+https://github.com/arthurlee945/promise-pool.git"},"bugs":{"url":"https://github.com/arthurlee945/promise-pool/issues"},"scripts":{"build":"tsc","test":"jest","test:performance":"ts-node ./src/test/performance.ts","lint":"eslint src --ext .js,.ts","lint:fix":"eslint --fix src --ext .js,.ts","format":"prettier --write src","clean":"rm -rf node_modules pnpm-lock.yaml","prepare":"husky install","prepack":"pnpm build"},"keywords":["promises","nodejs","async","queue","promise-pool"],"publishConfig":{"access":"public"},"author":{"name":"arthur lee","email":"arthur.lee945@gmail.com"},"license":"MIT","devDependencies":{"@ianvs/prettier-plugin-sort-imports":"^4.1.1","@types/eslint":"^8.44.7","@types/jest":"^29.5.10","@types/node":"^20.10.0","@typescript-eslint/eslint-plugin":"^6.12.0","@typescript-eslint/parser":"^6.12.0","eslint":"^8.54.0","eslint-config-prettier":"^9.0.0","eslint-plugin-import":"^2.29.0","husky":"^8.0.3","jest":"^29.7.0","prettier":"^3.1.0","ts-jest":"^29.1.1","ts-node":"^10.9.1","typescript":"^5.3.2"},"gitHead":"a032f5755cc9560eac602208c76801799dab6a1b","_id":"@arthur.lee945/promise-pool@1.0.2","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-fIeezVtp4IRxsbs9E+FDbXifYYSUSNZPQDoIJkeObPuTPt9EeGDJAP0PScMADrSvZGDO2/auLntnVKksNT3U4A==","shasum":"3681bdbc312740971776f23e53bd077ee1de1482","tarball":"https://registry.npmjs.org/@arthur.lee945/promise-pool/-/promise-pool-1.0.2.tgz","fileCount":17,"unpackedSize":28233,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGd9UIZMydDjqg+ZzkDSllMopbSe3HSxNkyY6MliL0vZAiEA+MSGvXzWWtIJwlqu9LMYUQnvnxRs3ZT0kA7P7bhon2Y="}]},"_npmUser":{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"},"directories":{},"maintainers":[{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-pool_1.0.2_1702867738078_0.6482745459260129"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-05T03:50:15.376Z","1.0.0":"2023-12-05T03:50:15.608Z","modified":"2023-12-18T02:48:58.435Z","1.0.1":"2023-12-06T00:16:45.975Z","1.0.2":"2023-12-18T02:48:58.270Z"},"maintainers":[{"name":"arthur.lee945","email":"arthur.lee945@gmail.com"}],"description":"Queue based promise pool","homepage":"https://github.com/arthurlee945/promise-pool","keywords":["promises","nodejs","async","queue","promise-pool"],"repository":{"type":"git","url":"git+https://github.com/arthurlee945/promise-pool.git"},"author":{"name":"arthur lee","email":"arthur.lee945@gmail.com"},"bugs":{"url":"https://github.com/arthurlee945/promise-pool/issues"},"license":"MIT","readme":"<div align=\"center\">\r\n  <p>\r\n    <h3>Promise Pool</h3>\r\n  </p>\r\n  <p>\r\n    Queue based promise pool for node.js.\r\n  </p>\r\n  <p>\r\n    <em>Leave a Like! or check out my portfolio <a href=\"https://arthurlee.bio\">arthurlee.bio</a></em>\r\n  </p>\r\n  <p>\r\n    <a href=\"https://www.npmjs.com/package/@arthur.lee945/promise-pool\"><img src=\"https://img.shields.io/npm/v/@arthur.lee945/promise-pool.svg\" alt=\"Latest Version\"></a>\r\n    <a href=\"https://www.npmjs.com/package/@arthur.lee945/promise-pool\"><img src=\"https://img.shields.io/npm/dm/@arthur.lee945/promise-pool.svg\" alt=\"Monthly downloads\"></a>\r\n  </p>\r\n</div>\r\n\r\n## Usage\r\n\r\nUsing this Promise pool is relatively simple.\r\n\r\nHere’s an example using a concurrency of 2:\r\n\r\n```js\r\nimport { PromisePool } from 'promise-pool';\r\n\r\nconst Tasks = [() => new Promise((resolve) => resolve('Resolving Promise'))];\r\n\r\nconst result = new PromisePool(Tasks).process();\r\n```\r\n\r\nThe promise pool takes in this options\r\n\r\n```js\r\nnew PromisePool(SampleTest, {\r\n    concurrency:10;\r\n    settle: true;\r\n    stream?: (returns) => {\r\n        //DoSomething\r\n    };\r\n})\r\n```\r\n\r\n## Useful Methods\r\n\r\n-   **_enqueue_**\r\n    ```js\r\n    /**\r\n     * Add a promise to the queue\r\n     * @param { ProcessableItem<TReturn> } items (..._args: any[]) => Promise<TReturn>\r\n     * @returns {PromisePool}\r\n     */\r\n    const processOnQueue = true;\r\n    new PromisePool().enqueue(tasks, processOnQueue);\r\n    ```\r\n-   **_dequeue_**\r\n    ```js\r\n    /**\r\n     * Take out next promise in queue or undefined\r\n     * @returns { ProcessableItem<TReturn>[] | undefined }\r\n     */\r\n    new PromisePool().dequeue();\r\n    ```\r\n-   **_peek_**\r\n    ```js\r\n    /**\r\n     * Take a peek at next promise to be processed in queue\r\n     * @returns { ProcessableItem<TReturn> | undefined }\r\n     */\r\n    new PromisePool().peek();\r\n    ```\r\n-   **_isEmpty_**\r\n    ```js\r\n    /**\r\n     * Check if there are processable items in queue\r\n     * @returns { boolean }\r\n     */\r\n    new PromisePool().isEmpty();\r\n    ```\r\n-   **_getTaskMeta_**\r\n    ```js\r\n    /**\r\n     * Take a peek at next promise to be processed in queue\r\n     * @param { \"updated\" | \"stopped\" | \"isProcessing\" } opt\r\n     * @returns { boolean }\r\n     */\r\n    new PromisePool().getTaskMeta('isProcessing');\r\n    ```\r\n-   **_setConcurrency_**\r\n    ```js\r\n    /**\r\n     * @param { number } concurrency number to update\r\n     * @returns { PromisePool<TReturn> }\r\n     */\r\n    new PromisePool().setConcurrency(100);\r\n    ```\r\n-   **_setStream_**\r\n    ```js\r\n    /**\r\n     * @param { (_data: TReturn[]) => void } cb  Add or Update stream callback function\r\n     * @returns { PromisePool<TReturn> }\r\n     */\r\n    new PromisePool().setStream((returns) => {\r\n        //Do something\r\n    });\r\n    ```\r\n-   **_stop_**\r\n    ```js\r\n    /**\r\n     * Stops Currently running process excluding already processing task set\r\n     * @returns {Promise<(TReturn | PromiseSettledResult<TReturn>)[]>}\r\n     */\r\n    ```\r\n-   **_process_**\r\n\r\n    ```js\r\n    /**\r\n     * Starts the process\r\n     * @returns {Promise<(TReturn | PromiseSettledResult<TReturn>)[]>}\r\n     */\r\n    new PromisePool().process();\r\n    ```\r\n","readmeFilename":"ReadMe.md"}