Skip to content

Commit

Permalink
make max optional
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Aug 10, 2024
1 parent 6e3a6c8 commit 47a03ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/curry/bottleneck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ declare const setTimeout: (callback: () => void, delay: number) => unknown
export interface BottleneckOptions {
/**
* The maximum number of calls to allow per interval.
*
* @default 1
*/
max: number
max?: number
/**
* The interval at which to allow the maximum number of calls.
*/
Expand Down Expand Up @@ -68,7 +70,11 @@ export interface BottledFunction<TArgs extends any[], TReturn> {
* ```
*/
export function bottleneck<TArgs extends any[], TReturn>(
{ max, interval, concurrency = Number.POSITIVE_INFINITY }: BottleneckOptions,
{
max = 1,
interval,
concurrency = Number.POSITIVE_INFINITY,
}: BottleneckOptions,
fn: (...args: TArgs) => TReturn,
): BottledFunction<TArgs, TReturn> {
let numCalls = 0
Expand Down

0 comments on commit 47a03ef

Please sign in to comment.