Utilium: TypeScript Utilities

3.1.1 · active · verified Sun Apr 19

Utilium is a comprehensive TypeScript utility library offering a diverse set of functionalities for both compile-time and runtime operations. The current stable version is 3.1.1, with recent releases indicating active development, typically involving feature additions or minor bug fixes within patch versions, and significant refactorings in major versions like 3.0.0. Key differentiators include advanced compile-time mathematical types, utilities for HTTP range requests using `fetch`, robust `Buffer` extension capabilities, and convenience functions for strings and objects. It also features a unique `List` class that merges array and `Set` functionalities, `JSONFileMap` for file system interactions, and specialized tools for Xterm.js shell handling. The library targets modern Node.js environments, requiring Node.js >=22.0.0, and ships with full TypeScript support.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the `List` class, `splitIntoArgs` function, and access to namespaced utilities like `requests.Issue`.

import { List, splitIntoArgs, requests } from 'utilium';

// Demonstrate the List class
const myList = new List([1, 2, 2, 3]);
console.log(`Initial List: ${myList.toArray()}`); // Output: Initial List: 1,2,3
myList.add(4);
myList.remove(2);
console.log(`Modified List: ${myList.toArray()}`); // Output: Modified List: 1,3,4

// Demonstrate splitIntoArgs
const args = splitIntoArgs('command --flag value -x "quoted arg"');
console.log('Parsed arguments:', args); // Output: Parsed arguments: [ 'command', '--flag', 'value', '-x', 'quoted arg' ]

// Demonstrate usage of nested exports (requests namespace)
const issue: requests.Issue = {
  code: 'FETCH_ERROR',
  message: 'Network request failed'
};
console.log('Request Issue:', issue);

// You can also demonstrate compile-time types, but they don't produce runtime output directly.
// Example of a compile-time type (cannot be run directly, but shows intent):
// import type { Add } from 'utilium/types';
// type Sum = Add<5, 3>; // Sum will be 8 at compile-time

view raw JSON →