Feature enhancement
Goal:
Replace all occurrences of JavaScript number[] arrays used as vectors in the codebase (e.g., in OneEuroFilter.ts) with Float32Array (or potentially other TypedArray types, e.g., Float64Array if higher precision is required, but Float32Array is usually sufficient for most filtering operations and is much more efficient for performance and memory).
Rationale:
- Typed arrays like
Float32Array provide more efficient memory layout and computations, especially beneficial for mathematical and signal-processing code like One Euro Filter.
- This may improve performance, lower memory usage, and allows compatibility with libraries and APIs that expect typed arrays.
- It also can reduce hidden bugs/inefficiencies from JavaScript's general-purpose arrays.
Proposed changes:
- Audit and identify all uses of
number[] in OneEuroFilter and related files (especially xPrev, dxPrev, vector math, filter inputs/outputs).
- Propose and implement conversion to
Float32Array where possible.
- Ensure correct initialization and copying (e.g.,
new Float32Array(length) or Float32Array.from(arr))
- Replace
map and similar array methods with equivalent typed array methods as required.
- Adjust any function signatures to accept/return the appropriate type.
- Update tests and examples as needed.
- Add a note in the README or JSDoc about the expected input type.
Confirmation:
Float32Array is generally preferable for numerical processing over plain number[] due to speed and efficiency, unless double precision is required (which is rare in most signal and filtering code). This should be confirmed in project context.
References:
If there are any strong reasons to keep usage of number[] in some places, please document with comments. Otherwise, prefer Float32Array for optimal JavaScript performance.
Feature enhancement
Goal:
Replace all occurrences of JavaScript
number[]arrays used as vectors in the codebase (e.g., inOneEuroFilter.ts) withFloat32Array(or potentially other TypedArray types, e.g.,Float64Arrayif higher precision is required, butFloat32Arrayis usually sufficient for most filtering operations and is much more efficient for performance and memory).Rationale:
Float32Arrayprovide more efficient memory layout and computations, especially beneficial for mathematical and signal-processing code like One Euro Filter.Proposed changes:
number[]inOneEuroFilterand related files (especiallyxPrev,dxPrev, vector math, filter inputs/outputs).Float32Arraywhere possible.new Float32Array(length)orFloat32Array.from(arr))mapand similar array methods with equivalent typed array methods as required.Confirmation:
Float32Arrayis generally preferable for numerical processing over plainnumber[]due to speed and efficiency, unless double precision is required (which is rare in most signal and filtering code). This should be confirmed in project context.number[]as vector/matrix or buffer types.Float32Array(or another relevant TypedArray if appropriate).References:
If there are any strong reasons to keep usage of
number[]in some places, please document with comments. Otherwise, preferFloat32Arrayfor optimal JavaScript performance.