Skip to content

Commit

Permalink
fix: downgrade p-limit version for export/import issue (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahimfaisaal authored Jan 23, 2024
1 parent f5bc4d2 commit 86e0576
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-ties-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"settle-map": patch
---

downgraded the p-limit version for module export/import issue
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -125,7 +125,7 @@ const options = {
delay: 2000, // ms
},
};
const settled = settleMap(items, asyncMapmethod, options);
const settled = settleMap(items, asyncMapFunction, options);
```

## 📖 API Reference
Expand All @@ -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<R>`): 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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 3 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/settler.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,7 +19,7 @@ class Settler<T, R> {
errors: [],
};
private readonly events = new EventEmitter<T, R>();
private readonly limit: LimitFunction;
private readonly limit: Limit;

constructor(public readonly options: SettleOptions) {
this.validateOptions(options);
Expand Down

0 comments on commit 86e0576

Please sign in to comment.