diff --git a/.changeset/lucky-ties-sniff.md b/.changeset/lucky-ties-sniff.md new file mode 100644 index 0000000..a7e7c3e --- /dev/null +++ b/.changeset/lucky-ties-sniff.md @@ -0,0 +1,5 @@ +--- +"settle-map": patch +--- + +downgraded the p-limit version for module export/import issue diff --git a/README.md b/README.md index 636d8f5..d2ba4cd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/fahimfaisaal/settle-map/.github%2Fworkflows%2Fmain.yml?branch=main&style=flat&logo=github-actions&label=CI) ![NPM Downloads](https://img.shields.io/npm/dm/settle-map?style=flat&logo=npm&logoColor=red&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fsettle-map) ![GitHub Repo stars](https://img.shields.io/github/stars/fahimfaisaal/settle-map?style=flat&logo=github&link=https%3A%2F%2Fgithub.com%2Ffahimfaisaal%2Fsettle-map) -Settle Map is a tool that combines the features of `Promise.allSettled` and `Array.map`. It simplifies the process of mapping promises and lets you control how many can run at the same time using concurrency. In other words, it will help you prevent being rate-limited. +Settle Map is a tool that combines the features of `Promise.allSettled` and `Array.map`. It simplifies the process of mapping promises, providing results flexibility and lets you control how many can run at the same time using concurrency. In other words, it will help you prevent being rate-limited. ## ⚙️ Installation @@ -125,7 +125,7 @@ const options = { delay: 2000, // ms }, }; -const settled = settleMap(items, asyncMapmethod, options); +const settled = settleMap(items, asyncMapFunction, options); ``` ## 📖 API Reference @@ -138,13 +138,13 @@ A function that settles promises returned by the provided function (`fn`) for ea - `items` (`T[]`): An array of items to be processed. - `fn` (`(item: T, index: number) => Promise`): A function that takes an item and its index as parameters and returns a Promise. -- `options` (`SettleOptions | number`): An object that specifies the concurrency and retry options. If a number is provided, it is treated as the concurrency level. +- `options` (`SettleOptions | number`): An object that specifies the concurrency and retry options. If a number is provided, it is treated as the concurrency level. default option is `1` #### Return Value Returns an object with the following properties and methods: -- `all`: A promise that resolves when all items have been processed. The promise resolves to an array of results in the same order as the input items. +- `all`: A promise that resolves when all items have been processed and return the resolved and rejects items in a single object. - `waitUntilFinished()`: A method that returns a promise that resolves when all items have been processed, regardless of whether they succeeded or failed. - `status()`: A method that returns the current status of the settling process. - `on(event, listener)`: A method that allows you to listen for certain events. diff --git a/package.json b/package.json index 244f372..e72e67e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "release": "pnpm run ci && changeset publish" }, "dependencies": { - "p-limit": "^4.0.0" + "p-limit": "^3.1.0" }, "devDependencies": { "@changesets/cli": "^2.27.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b31004d..f891b65 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: p-limit: - specifier: ^4.0.0 - version: 4.0.0 + specifier: ^3.1.0 + version: 3.1.0 devDependencies: '@changesets/cli': @@ -2097,14 +2097,6 @@ packages: engines: {node: '>=10'} dependencies: yocto-queue: 0.1.0 - dev: true - - /p-limit@4.0.0: - resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - yocto-queue: 1.0.0 - dev: false /p-limit@5.0.0: resolution: {integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==} @@ -3196,8 +3188,8 @@ packages: /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - dev: true /yocto-queue@1.0.0: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} + dev: true diff --git a/src/settler.ts b/src/settler.ts index 20dac32..5ccda31 100644 --- a/src/settler.ts +++ b/src/settler.ts @@ -1,4 +1,4 @@ -import pLimit, { type LimitFunction } from "p-limit"; +import pLimit, { type Limit } from "p-limit"; import { PayloadError, delay } from "./utils"; import type { SettleOptions, @@ -19,7 +19,7 @@ class Settler { errors: [], }; private readonly events = new EventEmitter(); - private readonly limit: LimitFunction; + private readonly limit: Limit; constructor(public readonly options: SettleOptions) { this.validateOptions(options);