Core Library API Reference

Introduction

The Core Library provides fundamental classes, functions, and data structures that form the backbone of the MSDN platform. It offers essential utilities for everyday programming tasks, ensuring consistency and efficiency across your applications.

This documentation details the various components of the Core Library, including their purpose, usage, and examples.

Data Structures

Explore the efficient and robust data structures available for managing your data.

Array

A dynamic array that automatically resizes as needed. Provides methods for adding, removing, and accessing elements.

Array<T>()
Parameters:

No parameters.

Returns:

A new, empty Array instance.

Array<T>.Add(item: T)
Parameters:

item (T): The element to add to the end of the array.

Array<T>.RemoveAt(index: number)
Parameters:

index (number): The zero-based index of the element to remove.

Array<T>.Get(index: number): T
Parameters:

index (number): The zero-based index of the element to retrieve.

Example:
let myArray = new Array<string>();
myArray.Add("Hello");
myArray.Add("World");
console.log(myArray.Get(0)); // Output: Hello

Dictionary

A collection of key-value pairs that allows for fast lookups, insertions, and deletions based on the key.

Dictionary<TKey, TValue>()
Dictionary<TKey, TValue>.Add(key: TKey, value: TValue)
Dictionary<TKey, TValue>.Get(key: TKey): TValue | undefined
Dictionary<TKey, TValue>.Remove(key: TKey): boolean
Example:
let userSettings = new Dictionary<string, boolean>();
userSettings.Add("darkMode", true);
console.log(userSettings.Get("darkMode")); // Output: true

String Manipulation

Utilities for common string operations like formatting, parsing, and manipulation.

StringFormatter

Provides static methods for formatting strings, similar to `String.format` in other languages.

StringFormatter.Format(format: string, ...args: any[]): string
Parameters:

format (string): The format string, using placeholders like `{0}`, `{1}`.

...args (any[]): The arguments to insert into the placeholders.

Example:
let message = StringFormatter.Format("Welcome, {0}! You have {1} new messages.", "Alice", 5);
console.log(message); // Output: Welcome, Alice! You have 5 new messages.

StringUtils

A collection of utility functions for string processing.

StringUtils.IsNullOrEmpty(str: string | null | undefined): boolean
Parameters:

str (string | null | undefined): The string to check.

StringUtils.Trim(str: string): string
Parameters:

str (string): The string to trim.

Example:
let input = "   Some text   ";
if (!StringUtils.IsNullOrEmpty(input)) {
    console.log(StringUtils.Trim(input)); // Output: Some text
}

Math Operations

Essential mathematical functions and constants.

MathUtils

Provides enhanced mathematical utilities beyond the standard `Math` object.

MathUtils.Clamp(value: number, min: number, max: number): number
Parameters:

value (number): The value to clamp.

min (number): The minimum allowed value.

max (number): The maximum allowed value.

Example:
let clampedValue = MathUtils.Clamp(150, 0, 100);
console.log(clampedValue); // Output: 100

System Services

Interactions with the underlying system and environment.

Environment

Provides information about the runtime environment.

Environment.GetVariable(name: string): string | undefined
Parameters:

name (string): The name of the environment variable.

Example:
let apiKey = Environment.GetVariable("MY_API_KEY");
if (apiKey) {
    console.log("API Key found.");
} else {
    console.log("API Key not set.");
}