scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
120 lines (119 loc) • 7.05 kB
TypeScript
import { FloatVector as FloatVector2D, IntVector as IntVector2D, SCRTDoubleVector as SCRTDoubleVector2D, SCRTUintVector as SCRTUintVector2D, TSciChart, UIntVector as UIntVector2D } from "../types/TSciChart";
import { SCRTDoubleVector as SCRTDoubleVector3D, SCRTFloatVector as SCRTFloatVector3D, SCRTUintVector as SCRTUintVector3D, TSciChart3D } from "../types/TSciChart3D";
/**
* Converts a WebAssembly vector to a JavaScript number array by creating a copy of the data.
*
* @remarks
* This function creates a new JavaScript array containing a copy of all values from the WebAssembly vector.
* The returned array is independent of the underlying WebAssembly memory, so it's safe to use even after
* the original vector is deleted or modified.
*
* Use this function when you need to:
* - Store vector data beyond the lifetime of the WebAssembly vector
* - Pass data to JavaScript APIs that expect regular arrays
* - Ensure data immutability
*
* @param vector - The WebAssembly vector to convert (SCRTDoubleVector2D, SCRTDoubleVector3D, FloatVector2D, UIntVector2D, or IntVector2D)
* @param wasmContext - The WebAssembly context (TSciChart or TSciChart3D) that owns the vector
* @returns A new number[] array containing a copy of all values from the vector
*/
export declare function vectorToArray(vector: SCRTDoubleVector2D | SCRTDoubleVector3D | FloatVector2D | SCRTFloatVector3D | UIntVector2D | SCRTUintVector2D | SCRTUintVector3D | IntVector2D, wasmContext: TSciChart | TSciChart3D): number[];
/**
* Creates a Float64Array view directly onto the WebAssembly memory backing the vector.
*
* @remarks
* **IMPORTANT**: This function returns a view onto the underlying WebAssembly memory, NOT a copy.
*
* The returned Float64Array:
* - Shares memory with the WebAssembly vector - changes to the underlying data will be reflected in the view
* - Should be used for READ operations only - writing to this view may cause undefined behaviour
* - Becomes invalid if the vector is deleted or resized
* - Has zero-copy performance characteristics, making it very efficient for reading large datasets
*
* Use this function when you need:
* - High-performance read access to vector data
* - To avoid memory allocation overhead
* - Temporary access to data that won't outlive the vector
*
* If used with a FIFO vector (ie from a dataSeries with fifoCapacity set) you will get the raw buffer
* and will need to use (index + fifoStartIndex) % fifoCapacity to access the data in the original order
*
* If you need to modify data or keep it beyond the vector's lifetime, use {@link vectorToArray} instead.
*
* @param vector - The WebAssembly vector to create a view for (SCRTDoubleVector2D or SCRTDoubleVector3D)
* @param wasmContext - The WebAssembly context (TSciChart or TSciChart3D) that owns the vector
* @returns A Float64Array view onto the WebAssembly memory - DO NOT write to this array
*/
export declare function vectorToArrayViewF64(vector: SCRTDoubleVector2D | SCRTDoubleVector3D, wasmContext: TSciChart | TSciChart3D): Float64Array;
/**
* Creates a Float32Array view directly onto the WebAssembly memory backing the vector.
*
* @remarks
* **IMPORTANT**: This function returns a view onto the underlying WebAssembly memory, NOT a copy.
*
* The returned Float32Array:
* - Shares memory with the WebAssembly vector - changes to the underlying data will be reflected in the view
* - Should be used for READ operations only - writing to this view may cause undefined behaviour
* - Becomes invalid if the vector is deleted or resized
* - Has zero-copy performance characteristics, making it very efficient for reading large datasets
*
* Use this function when you need:
* - High-performance read access to vector data
* - To avoid memory allocation overhead
* - Temporary access to data that won't outlive the vector
*
* If you need to modify data or keep it beyond the vector's lifetime, use {@link vectorToArray} instead.
*
* @param vector - The WebAssembly vector to create a view for (FloatVector2D)
* @param wasmContext - The WebAssembly context (TSciChart) that owns the vector
* @returns A Float32Array view onto the WebAssembly memory - DO NOT write to this array
*/
export declare function vectorToArrayViewF32(vector: FloatVector2D | SCRTFloatVector3D, wasmContext: TSciChart | TSciChart3D): Float32Array;
/**
* Creates a Uint32Array view directly onto the WebAssembly memory backing the vector.
*
* @remarks
* **IMPORTANT**: This function returns a view onto the underlying WebAssembly memory, NOT a copy.
*
* The returned Uint32Array:
* - Shares memory with the WebAssembly vector - changes to the underlying data will be reflected in the view
* - Should be used for READ operations only - writing to this view may cause undefined behaviour
* - Becomes invalid if the vector is deleted or resized
* - Has zero-copy performance characteristics, making it very efficient for reading large datasets
*
* Use this function when you need:
* - High-performance read access to vector data
* - To avoid memory allocation overhead
* - Temporary access to data that won't outlive the vector
*
* If you need to modify data or keep it beyond the vector's lifetime, use {@link vectorToArray} instead.
*
* @param vector - The WebAssembly vector to create a view for (UIntVector2D)
* @param wasmContext - The WebAssembly context (TSciChart) that owns the vector
* @returns A Uint32Array view onto the WebAssembly memory - DO NOT write to this array
*/
export declare function vectorToArrayViewUi32(vector: UIntVector2D | SCRTUintVector2D | SCRTUintVector3D, wasmContext: TSciChart | TSciChart3D): Uint32Array;
/**
* Creates a Int32Array view directly onto the WebAssembly memory backing the vector.
*
* @remarks
* **IMPORTANT**: This function returns a view onto the underlying WebAssembly memory, NOT a copy.
*
* The returned Int32Array:
* - Shares memory with the WebAssembly vector - changes to the underlying data will be reflected in the view
* - Should be used for READ operations only - writing to this view may cause undefined behaviour
* - Becomes invalid if the vector is deleted or resized
* - Has zero-copy performance characteristics, making it very efficient for reading large datasets
*
* Use this function when you need:
* - High-performance read access to vector data
* - To avoid memory allocation overhead
* - Temporary access to data that won't outlive the vector
*
* If you need to modify data or keep it beyond the vector's lifetime, use {@link vectorToArray} instead.
*
* @param vector - The WebAssembly vector to create a view for (IntVector2D)
* @param wasmContext - The WebAssembly context (TSciChart) that owns the vector
* @returns A Int32Array view onto the WebAssembly memory - DO NOT write to this array
*/
export declare function vectorToArrayViewI32(vector: IntVector2D, wasmContext: TSciChart): Int32Array;