You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
810 B
21 lines
810 B
export type TokenBucketError = string |
|
export type Fail<T> = (error: T) => void |
|
export type Success<T> = (error: null, data: T) => void |
|
export type RemoveTokensCallback = Fail<TokenBucketError> | Success<number> |
|
|
|
type Interval = number | 'second' | 'sec' | 'minute' | 'min' | 'hour' | 'hr' | 'day' |
|
|
|
export declare class TokenBucket { |
|
constructor(bucketSize: number, tokensPerInterval: number, interval: Interval, parentBucket?: TokenBucket) |
|
|
|
removeTokens(count: number, callback: RemoveTokensCallback): void |
|
tryRemoveTokens(count: number): boolean |
|
drip(): boolean |
|
} |
|
|
|
export declare class RateLimiter { |
|
constructor(tokensPerInterval: number, interval: Interval, fireImmediately?: boolean) |
|
|
|
removeTokens(count: number, callback: RemoveTokensCallback): void |
|
tryRemoveTokens(count: number): boolean |
|
}
|
|
|