/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45export class RateLimiter {6private _lastRun: number;7private readonly _minimumTimeBetweenRuns: number;89constructor(public readonly timesPerSecond: number = 5) {10this._lastRun = 0;11this._minimumTimeBetweenRuns = 1000 / timesPerSecond;12}1314public runIfNotLimited(callback: () => void): void {15const now = Date.now();16if (now - this._lastRun >= this._minimumTimeBetweenRuns) {17this._lastRun = now;18callback();19}20}21}222324