///////////////////////////////////////////////////////////////////////////////////////////// // Copyright 2026 Garmin International, Inc. // Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you // may not use this file except in compliance with the Flexible and Interoperable Data // Transfer (FIT) Protocol License. ///////////////////////////////////////////////////////////////////////////////////////////// // ****WARNING**** This file is auto-generated! Do NOT edit this file. // Profile Version = 21.222.0Release // Tag = production/release/21.222.0-0-g71fae187 ///////////////////////////////////////////////////////////////////////////////////////////// import { CrcCalculator } from "./crc-calculator.js"; import { FieldValue } from "./mesg.js"; /** Represents a FIT file's bytes and provides sequential read access. */ export class Stream { /** * Creates a Stream containing a FIT file. * @param buffer - `ArrayBuffer` containing the FIT file bytes. */ constructor(buffer: ArrayBuffer); /** * Convenience method for creating a Stream from a byte array. * @param data - An array of bytes or a `Uint8Array`. * @returns A new Stream object. */ static fromByteArray(data: number[] | Uint8Array): Stream; /** * Convenience method for creating a Stream from a Node Buffer. * @param buffer - Node `Buffer` of bytes. * @returns A new Stream object. */ static fromBuffer(buffer: Uint8Array): Stream; /** * Convenience method for creating a Stream from an `ArrayBuffer`. * @param buffer - An `ArrayBuffer` of bytes. * @returns A new Stream object. */ static fromArrayBuffer(buffer: ArrayBuffer): Stream; /** Total length of the underlying buffer in bytes. */ readonly length: number; /** Number of bytes read. */ readonly bytesRead: number; /** Current read position. */ readonly position: number; /** CRC calculator, updated as bytes are read. */ crcCalculator: CrcCalculator; /** Resets the read position to 0. */ reset(): void; /** * Seeks to an absolute byte offset. * @param position - Byte offset to seek to. */ seek(position: number): void; /** * Returns a copy of the underlying buffer for the given range. * @param begin - Start index (inclusive). * @param end - End index (exclusive). */ slice(begin: number, end: number): ArrayBuffer; /** Returns the byte at the current position without advancing. */ peekByte(): number; /** Reads and returns one byte. */ readByte(): number; /** * Reads `size` bytes and returns them as a `Uint8Array`. * @param size - Number of bytes to read. */ readBytes(size: number): Uint8Array; /** * Reads a value of the given FIT base type from the stream. * @param baseType - FIT base type constant. * @param size - Number of bytes to read. * @param opts - Read options. */ readValue(baseType: number, size: number, opts?: ReadValueOptions): FieldValue; /** Reads an unsigned 8-bit integer. */ readUInt8(opts?: ReadValueOptions): number; /** Reads a signed 8-bit integer. */ readInt8(opts?: ReadValueOptions): number; /** Reads an unsigned 16-bit integer. */ readUInt16(opts?: ReadValueOptions): number; /** Reads a signed 16-bit integer. */ readInt16(opts?: ReadValueOptions): number; /** Reads an unsigned 32-bit integer. */ readUInt32(opts?: ReadValueOptions): number; /** Reads a signed 32-bit integer. */ readInt32(opts?: ReadValueOptions): number; /** Reads an unsigned 64-bit integer as a `bigint`. */ readUInt64(opts?: ReadValueOptions): bigint; /** Reads a signed 64-bit integer as a `bigint`. */ readInt64(opts?: ReadValueOptions): bigint; /** Reads a 32-bit IEEE 754 float. */ readFloat32(opts?: ReadValueOptions): number; /** Reads a 64-bit IEEE 754 float. */ readFloat64(opts?: ReadValueOptions): number; /** * Reads a null-terminated UTF-8 string of up to `strlen` bytes. * @param strlen - Maximum number of bytes to read. */ readString(strlen: number): string; } /** Options shared by the typed read methods on {@link Stream}. */ export type ReadValueOptions = { /** Byte order for this read. Defaults to `true`. */ littleEndian?: boolean; /** When `true`, invalid values are returned as `null`. Defaults to `true`. */ convertInvalidToNull?: boolean; }