Skip to main content

Utilities Overview

io-oidis-commons provides a comprehensive set of utility classes that handle common programming tasks with null-safety, consistent APIs, and edge-case handling. These utilities are available on both frontend and backend unless noted otherwise.

Package: io-oidis-commons

Quick Selection Guide​

TaskUseNot
Check for null/empty/undefinedObjectValidator.IsEmptyOrNull()=== null, typeof x
Convert string ↔ number ↔ booleanConvertparseInt(), Number()
Format, split, search stringsStringUtilsManual regex or .split()
Deep merge or clone objectsJsonUtils.Extend(), JsonUtils.Clone()Object.assign(), spread
Log for development/debuggingLogItconsole.log()
Log for audit trail (persisted)SystemLogLogIt (not persisted)
Run child processesTerminal.Execute()child_process.exec()
Read/write filesFileSystemHandlerfs.readFileSync()
Measure execution timeStopwatchDate.now()
Yield to the event loop in a long loopTimeoutManager.YieldToIO(), .Map(), .ForEach()tight for / for await over big data
Validate JSON schemasSchemaValidatorManual checks

Core Utilities​

UtilityPurposePage
LogIt & SystemLogDevelopment logging (LogIt) and persistent audit trail (SystemLog)Logging
ObjectValidatorNull-safe type checking — IsEmptyOrNull, IsSet, IsString, IsDigit, IsArray, and moreObjectValidator
StringUtilsString manipulation — search, replace, split, format, hash, case conversion, version comparisonStringUtils
JsonUtilsObject operations — deep merge, clone, JSONP generation, binary serializationJsonUtils
ConvertType conversion — string/number/boolean parsing, date boundaries, time formatting, encoding, mathConvert
EchoScreen output — formatted printing to HTML elements or custom handlers, stream captureEcho
StopwatchPerformance timing — start/stop/restart, elapsed time measurement, block timingStopwatch
ReflectionRuntime OOP metadata — class discovery, hierarchy inspection, type checking, dynamic instantiation, @Partial resolutionReflection
PersistenceHandlerCross-environment persistent key-value storage — auto-selects localStorage or cookies, CRC integrity, complex object serializationPersistenceHandler
PropertyCombined getter/setter helpers — null-safe, auto-coercing, range-validating. The standard pattern for all model and args propertiesProperty
TimeoutManagerTiming and event-loop cooperation — Sleep, YieldToIO, and the yielding ForEach/Map helpers that keep long in-memory loops from starving the event loopTimeoutManager

Backend Utilities​

These utilities are available only on the backend (Node.js) and provide infrastructure-level functionality.

UtilityPurposePage
TerminalCross-platform child process execution — Execute, Spawn, Elevate, Open, Kill, and async variants. Never use child_process directly.Terminal
CSVHandlerCSV import/export with encoding support — wraps the csv npm package with Windows-1250 defaultsCSVHandler
FileSystemHandlerCross-platform file I/O, directory operations, glob matching, HTTP downloads, and archive management (ZIP/TAR)FileSystemHandler
LogProcessorServer-side logging with pluggable adapters — Std, File, JSON, and Sentry — plus automatic path anonymizationLogProcessor
CertsManagerTLS certificate management with ACME (Let's Encrypt) integration and automatic renewalCertsManager
CronTask scheduling using cron expressions with node-cron — recurring tasks, master stop, remote controlCron
FirewallWindows firewall rule management — registers inbound service rules via netsh.exeFirewall
MetricsServer metrics collection and APM reporting via Elastic APM — HTTP/WebSocket traffic statisticsMetrics
SchemaValidatorJSON schema validation for configuration files and runtime data — backed by z-schemaSchemaValidator
StringReplaceToken replacement engine for HTML, JS, and CSS — variable interpolation, file imports, and iterationStringReplace
EventsServer-side event infrastructure — EventsManager for HTTP request wiring and lifecycle eventsEvents

Supporting Utilities​

These smaller utilities serve specific infrastructure needs. They are used internally by the framework and occasionally by application code.

TraceBack​

Captures and parses JavaScript stack traces into structured call-site objects. Used internally by LogIt and SystemLog for caller identification.

import { TraceBack } from "@io-oidis-commons/.../Utils/TraceBack.js";

// Capture the current call site (who called this method?)
const entry = TraceBack.CaptureEntry();
// entry.at → "Io.Oidis.MyProject.MyClass.MyMethod"
// entry.from → "Io.Oidis.MyProject.OtherClass.Caller"

// Parse an Error stack trace into structured objects
const sites = TraceBack.Parse(new Error());
sites.forEach(($site) => {
LogIt.Info($site.getFileName(), $site.getLineNumber());
});

Key methods: CaptureEntry($offset?, $infinityTrace?), getTrace(), Parse($error)

Counters​

Global named counter registry for generating sequential IDs or tracking invocation counts.

import { Counters } from "@io-oidis-commons/.../Utils/Counters.js";

const id1 = Counters.getNext("Invoice"); // → 1
const id2 = Counters.getNext("Invoice"); // → 2
const id3 = Counters.getNext("Order"); // → 1 (separate counter)

Counters.Clear("Invoice"); // Reset "Invoice" counter
Counters.Clear(); // Reset all counters

Key methods: getNext($owner), Clear($owner?)

EnvironmentHelper​

Re-exports global runtime environment variables from globalThis for centralized access.

import { isBrowser, buildTime } from "@io-oidis-commons/.../Utils/EnvironmentHelper.js";

if (isBrowser) {
// Running in browser — safe to access DOM
} else {
// Running in Node.js — safe to access fs, process, etc.
}

LogIt.Info("Build:", buildTime);

Exports: isBrowser : boolean, buildTime : string, appExceptionHandler

FileSystemFilter​

Enumeration utility for composing file system filter strings. Used with Oidis file system operations to specify which items to include.

import { FileSystemFilter } from "@io-oidis-commons/.../Utils/FileSystemFilter.js";

// Pre-defined filters
FileSystemFilter.ALL // "*"
FileSystemFilter.DIRECTORIES // Directories only
FileSystemFilter.HIDDEN_ALL // Including hidden items

// Compose custom filters
const filter = FileSystemFilter.Create("*.ts", "*.js");

Key methods: Create(...$options) — concatenates filter options with | delimiter

ReflectionEmitter​

Provides dynamic class/module registration into the global namespace tree. Used by Loader.ts and ForceCompile.ts to register classes at runtime.

import { ReflectionEmitter } from "@io-oidis-commons/.../Utils/ReflectionEmitter.js";

// Synchronous registration
ReflectionEmitter.RegisterSync("Io.Oidis.MyProject.MyClass", MyClass);

// Async registration (dynamic import)
await ReflectionEmitter.Register("Io.Oidis.MyProject.LazyClass");

Key methods: Register($namespace, $class?) (async), RegisterSync($namespace, $class) (sync)

tip

ReflectionEmitter populates the global namespace tree that Reflection then queries. In most projects, you interact with this indirectly through Loader.ts and ForceCompile.ts — direct use is rare.


See also: Architecture Overview | Vanilla vs Framework