-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sentrychris/develop
v0.2.1
- Loading branch information
Showing
6 changed files
with
584 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,74 @@ | ||
/** @public */ | ||
export declare class CircularBuffer { | ||
/** | ||
* The buffer | ||
* The buffer. | ||
*/ | ||
private buffer; | ||
|
||
/** | ||
* The buffer limit | ||
* The buffer size limit. | ||
*/ | ||
private limit; | ||
|
||
/** | ||
* Create a new circular buffer | ||
* Create a new circular buffer. | ||
* | ||
* @param limit - the buffer size limit | ||
* @throws if the provided limit is not a positive integer | ||
* @param limit - the buffer size limit. | ||
* @throws if the provided limit is not a positive integer. | ||
*/ | ||
constructor({ limit }: { | ||
limit: number; | ||
}); | ||
|
||
/** | ||
* Get the current state of the buffer | ||
* Get the current state of the buffer. | ||
* | ||
* @returns the contents of the buffer. | ||
*/ | ||
get(): string; | ||
current(): string; | ||
|
||
/** | ||
* Reset the buffer, fill it with empty strings | ||
* Get the content at the specific position in the buffer. | ||
* | ||
* @param index - the position in the buffer. | ||
* @returns the content at the specified position. | ||
* @throws if the index is out of bounds. | ||
*/ | ||
get(index: number): string; | ||
|
||
/** | ||
* Get the content within a specific range in the buffer. | ||
* | ||
* @param start - the starting position of the range. | ||
* @param len - the length of the range (exclusive). | ||
* @returns the content within the specified range. | ||
* @throws if the start or len indices are out of bounds. | ||
*/ | ||
range(start: number, len: number): string; | ||
|
||
/** | ||
* Reset the buffer, fill it with empty strings. | ||
* | ||
* @returns no return value. | ||
*/ | ||
reset(): void; | ||
|
||
/** | ||
* Move the buffer forward by one position and add | ||
* the provided value at the end of the buffer, if | ||
* the buffer is full, the oldest value is removed | ||
* Move the buffer forward by one position and add the provided | ||
* value at the end of the buffer, if the buffer is full, the | ||
* oldest value is removed. | ||
* | ||
* @param value - the value to add to the buffer | ||
* @param value - the value to add to the buffer. | ||
* @returns no return value. | ||
*/ | ||
forward(value: string): void; | ||
|
||
/** | ||
* Move the buffer backward by one position, removing | ||
* the last value, if the buffer becomes empty, an empty | ||
* string is added at the beginning | ||
* Move the buffer backward by one position, removing the last | ||
* value, if the buffer becomes empty, an empty string is added | ||
* at the beginning. | ||
* | ||
* @returns no return value. | ||
*/ | ||
rewind(): void; | ||
} |
Oops, something went wrong.