UNPKG

@kvaser/canking-api

Version:

CanKing API to communicate with the CanKing service using Node.js.

104 lines (103 loc) 4.02 kB
/** * An IterableIterator that iterates a DataBuffer from startIndex to endIndex with an optional filter. * @internal */ 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](): IterableIterator<T>; } /** * A read-only data buffer. */ interface ReadOnlyDataBuffer<T> extends Iterable<T>, RelativeIndexable<T> { length: number; } /** * A read-only data buffer. * @internal */ export type IReadOnlyDataBuffer<T> = ReadOnlyDataBuffer<T>; /** * Holds a data in a ring-buffer. * @internal */ 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](): IterableIterator<T>; } export {};