Core API
Overview
The Core API provides the fundamental functionality for the ECO SDK components.
Memory Manager API
Functions
allocate(size: number): Pointer
Allocates memory of the specified size.
Parameters:
size: The size of memory to allocate in bytes
Returns:
Pointer: A pointer to the allocated memory
Example:
const ptr = allocate(1024); // Allocate 1KBdeallocate(pointer: Pointer): void
Deallocates the memory at the specified pointer.
Parameters:
pointer: The pointer to the memory to deallocate
Example:
deallocate(ptr); // Free allocated memoryFile System API
Functions
readFile(path: string): Buffer
Reads the contents of a file.
Parameters:
path: The path to the file to read
Returns:
Buffer: The contents of the file
Example:
const contents = readFile('/path/to/file.txt');writeFile(path: string, data: Buffer): void
Writes data to a file.
Parameters:
path: The path to the file to writedata: The data to write to the file
Example:
writeFile('/path/to/file.txt', Buffer.from('Hello World'));Interface Bus API
Functions
sendMessage(target: string, message: Message): void
Sends a message to a target component.
Parameters:
target: The target component identifiermessage: The message to send
Example:
sendMessage('memory-manager', { type: 'allocate', size: 1024 });registerHandler messageType: string, handler: Function): void
Registers a handler for a specific message type.
Parameters:
messageType: The message type to handlehandler: The handler function
Example:
registerHandler('allocation-request', (message) => {
// Handle allocation request
});DateTime API
Functions
getCurrentTime(): Date
Gets the current date and time.
Returns:
Date: The current date and time
Example:
const now = getCurrentTime();formatDate(date: Date, format: string): string
Formats a date according to the specified format.
Parameters:
date: The date to formatformat: The format string
Returns:
string: The formatted date string
Example:
const formatted = formatDate(new Date(), 'YYYY-MM-DD');Logging API
Functions
log(level: LogLevel, message: string): void
Logs a message at the specified level.
Parameters:
level: The log level (DEBUG, INFO, WARN, ERROR)message: The message to log
Example:
log('INFO', 'Application started successfully');setLogLevel(level: LogLevel): void
Sets the minimum log level.
Parameters:
level: The minimum log level to output
Example:
setLogLevel('DEBUG'); // Show all log levelsMath FFT API
Functions
fft(input: Float32Array): Float32Array
Performs Fast Fourier Transform on the input data.
Parameters:
input: The input data array
Returns:
Float32Array: The FFT result
Example:
const result = fft(signalData);ifft(input: Float32Array): Float32Array
Performs Inverse Fast Fourier Transform on the input data.
Parameters:
input: The input data array
Returns:
Float32Array: The IFFT result
Example:
const result = ifft(fftData);
