OS
The OS module provides system-level information and operations through a simple interface. It allows you to access CPU information, system date and time, and perform basic system operations.
Overview
The OS module is implemented as a singleton, ensuring consistent access to system information throughout your application. It provides a clean and intuitive API for interacting with system-level resources.
Features
CPU Information
Access detailed information about your system's CPU, including:
- Architecture
- Machine type
- Processor details
- Version information
System Date
Get the current system date and time for time-sensitive operations.
Message Echo
A simple utility for echoing messages, useful for testing and debugging.
Examples
import { os } from 'osi.onpremises';
// Get system information
const cpuInfo = await os.cpu();
console.log('System CPU:', cpuInfo.architecture);
// Get current date
const currentDate = await os.date();
console.log('Current time:', currentDate.toISOString());
// Test echo
const message = await os.echo('Test message');
console.log('Echo:', message);
Limitations
- CPU information is read-only
- Date operations are limited to reading current system time
- Echo functionality is primarily for testing purposes