@kvaser/canking-api
Version:
CanKing API to communicate with the CanKing service using Node.js.
101 lines (100 loc) • 3.94 kB
TypeScript
/**
* An IterableIterator that iterates a DataBuffer from startIndex to endIndex with an optional filter.
*/
export declare class DataBufferView<T> implements IterableIterator<T> {
private data;
private index;
private size;
private endIndex;
private length;
private normalizedIndex;
private filterCallback?;
constructor(data: T[], size: number, startIndex: number, endIndex: number, length: number, filter?: (value: T) => boolean);
next(): IteratorResult<T, T>;
findIndex(filter: (value: T) => boolean): number;
/**
* Returns an iterator of a section of this buffer.
* @param start The beginning index of the specified portion of the buffer.
* @param end The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'.
* If end is undefined, then the slice extends to the end of the buffer.
*/
slice(start: number, end?: number): IterableIterator<T>;
/**
* Returns an iterator of a section of this buffer.
* @param filter An optional callback filter.
*/
filter(filter: (value: T) => boolean): IterableIterator<T>;
/**
* Returns an iterator of a section of this buffer.
* @param start The beginning index of the specified portion of the buffer.
* @param end The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'.
* If end is undefined, then the slice extends to the end of the buffer.
* @param filter An optional callback filter.
*/
sliceAndFilter(start: number, end?: number, filter?: (value: T) => boolean): IterableIterator<T>;
[Symbol.iterator](): this;
}
/**
* A read-only data buffer.
*/
interface ReadOnlyDataBuffer<T> extends Iterable<T>, RelativeIndexable<T> {
length: number;
}
/**
* A read-only data buffer.
*/
export type IReadOnlyDataBuffer<T> = ReadOnlyDataBuffer<T>;
/**
* Holds a data in a ring-buffer.
*/
export default class DataBuffer<T> implements IReadOnlyDataBuffer<T> {
length: number;
private size;
private startIndex;
private endIndex;
private data;
/**
* Constructor.
* @param size An optional buffer size.
*/
constructor(size?: number);
/**
* Clears this DataBuffer.
* @param size An optional new buffer size.
*/
clear(size?: number): void;
/**
* Adds data to this DataBuffer.
* @param elements The new elements.
*/
push(...elements: T[]): void;
/**
* Takes an integer value and returns the item at that index,
* allowing for positive and negative integers.
* Negative integers count back from the last item in the array.
*/
at(index: number): T | undefined;
/**
* Returns an iterator of a section of this buffer.
* @param start The beginning index of the specified portion of the buffer.
* @param end The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'.
* If end is undefined, then the slice extends to the end of the buffer.
*/
slice(start: number, end?: number): DataBufferView<T>;
/**
* Returns an iterator of a section of this buffer.
* @param filter An optional callback filter.
*/
filter(filter: (value: T) => boolean): DataBufferView<T>;
/**
* Returns an iterator of a section of this buffer.
* @param start The beginning index of the specified portion of the buffer.
* @param end The end index of the specified portion of the buffer. This is exclusive of the element at the index 'end'.
* If end is undefined, then the slice extends to the end of the buffer.
* @param filter An optional callback filter.
*/
sliceAndFilter(start: number, end?: number, filter?: (value: T) => boolean): DataBufferView<T>;
view(): DataBufferView<T>;
[Symbol.iterator](): DataBufferView<T>;
}
export {};