refactor: clean up deprecated functions and unused code

Remove unused files and implement proper version handling:
- Remove unused files: tensorflowUtils.ts, patched-platform-node.ts, test reporters
- Fix 5 TODO items with centralized version management in utils/version.ts
- Clean up duplicate metadata definitions in examples/basicUsage.ts
- Fix rollup config to use @rollup/plugin-terser instead of deprecated package
- Add comprehensive migration plan for deprecated methods (12 methods identified)

This cleanup removes 370 lines of dead code while maintaining full API compatibility.
All tests pass and build system works correctly.
This commit is contained in:
David Snelling 2025-08-05 10:16:05 -07:00
parent 838a998b6a
commit bbc77f292b
10 changed files with 178 additions and 548 deletions

View file

@ -4,3 +4,4 @@ export * from './workerUtils.js'
export * from './statistics.js'
export * from './jsonProcessing.js'
export * from './fieldNameTracking.js'
export * from './version.js'

View file

@ -1,35 +0,0 @@
/**
* Utility functions for TensorFlow.js compatibility
* This module provides utility functions that TensorFlow.js might need
* and avoids the need to use globalThis.util
*/
// Import the TensorFlowUtilObject interface
import type {
TensorFlowUtilObject,
PlatformNodeObject
} from '../types/tensorflowTypes.js'
// Note: TensorFlow.js platform patch is applied in setup.ts
// This ensures the global PlatformNode class uses our text encoding utilities
/**
* Check if an array is a Float32Array
* @param arr - The array to check
* @returns True if the array is a Float32Array
*/
export function isFloat32Array(arr: unknown): boolean {
return !!(
arr instanceof Float32Array ||
(arr && Object.prototype.toString.call(arr) === '[object Float32Array]')
)
}
/**
* Check if an array is a TypedArray
* @param arr - The array to check
* @returns True if the array is a TypedArray
*/
export function isTypedArray(arr: unknown): boolean {
return !!(ArrayBuffer.isView(arr) && !(arr instanceof DataView))
}

26
src/utils/version.ts Normal file
View file

@ -0,0 +1,26 @@
/**
* Version utilities for Brainy
*/
// Package version - this should be updated during the build process
const BRAINY_VERSION = '0.41.0'
/**
* Get the current Brainy package version
* @returns The current version string
*/
export function getBrainyVersion(): string {
return BRAINY_VERSION
}
/**
* Get version information for augmentation metadata
* @param service The service/augmentation name
* @returns Version metadata object
*/
export function getAugmentationVersion(service: string): { augmentation: string; version: string } {
return {
augmentation: service,
version: getBrainyVersion()
}
}