Library API
    Preparing search index...

    Library API

    Magma Library (Internal Reference)

    Note

    Internal Reference Package: packages/library is an internal monorepo utility suite used across Tempo packages. It is not published as a standalone package on npm, and is provided in the documentation as a reference guide for internal architectural utilities and shared routines.

    Magma Library provides platform-agnostic utilities for type-safe development, data manipulation, and asynchronous operations across Browser and Node.js environments.

    License: MIT TypeScript Ready Native ESM


    The library is organized into specialized modules, each designed for maximum efficiency and tree-shakability.

    Module Description
    Type System Advanced runtime type detection (getType), strict type-guards, and complex TS utility types.
    Array Sorted insertion, multi-key sorting, grouping (byKey), and cartesian products.
    String Proper-casing, pluralization helpers, sprintf-style formatting, and template evaluation.
    Serialization JSON-compatible stabilization with deep support for Temporal, BigInt, and custom Classes.
    Cipher Simple, secure class-based encryption and decryption wrappers.
    Pledge A robust wrapper for native Promises with settled-state tracking and timeout support.
    Reflection Clean access to own-properties, values, and entries without prototype pollution.
    Temporal Lightweight helpers and polyfill integration for the native Temporal API.

    The getType utility provides human-readable, proper-cased type names, even for custom classes that have been registered.

    import { getType, isType } from '@magmacomputing/tempo/library';

    getType([]); // "Array"
    getType(new Map()); // "Map"
    getType(42n); // "BigInt"

    if (isType(val, 'String', 'Number')) {
    // val is now narrowed to string | number
    }

    Sort complex collections of objects by multiple fields with ease.

    import { sortKey } from '@magmacomputing/tempo/library';

    const users = [
    { name: 'Alice', age: 30 },
    { name: 'Bob', age: 25 },
    { name: 'Alice', age: 22 }
    ];

    // Sort by name (ASC) then age (DESC)
    const sorted = sortKey(users, 'name', { field: 'age', dir: 'desc' });

    Unlike standard JSON.stringify, Magma's serialization handles complex types like Temporal and BigInt out of the box.

    import { stringify, objectify } from '@magmacomputing/tempo/library';

    const data = {
    at: Temporal.Now.instant(),
    count: 100n,
    pattern: /abc/gi
    };

    const json = stringify(data);
    const restored = objectify(json); // Fully restored types!

    For deep dives into specific APIs, please refer to the internal documentation:


    If you have questions, need architectural consulting, or want to report a bug, please reach out to us:


    Distributed under the MIT License. See LICENSE for more information.

    © 2026 Magma Computing.