Skip to main content

Utils Package Cheatsheet

Dense reference for Cognesy/Utils package capabilities. All examples show public API methods only.

Core Utilities

Json - JSON Processing

Notes:
  • Json::encode() and Json::fromArray() throw InvalidArgumentException on encoding failure.
  • Json::decode() throws JsonException when no default is provided and input is invalid; returns default otherwise.

Result - Monadic Error Handling

Notes:
  • Failure::errorMessage() converts any error to a string representation.

Option - Optional Value Type

Str - String Operations

Arrays - Array Utilities

Files - File System Operations

Data Structures

DataMap - Nested Data Access

ImmutableDataMap - Read-Only DataMap

CachedMap - Lazy-Loading Map

Context - Typed Service Container

Key - Typed Service Token

Layer - Context Composition

Container - DI Container

ArrayList - Immutable Indexed List

ArrayMap - Immutable Key-Value Map

ArraySet - Immutable Hash-Based Set

Deque - Double-Ended Queue

Buffer - FIFO Buffers

TagMap - Tagged Collection

TagQuery - Fluent Tag Querying

Caching & Lazy Loading

Cached - Lazy Value Container

Notes:
  • Cached is final and immutable. There is no fresh() or reset method.

Utilities

Uuid - ID Generation

Time - Clock Abstractions

Profiler - Performance Measurement

XML Processing

Xml - XML to Array/Object

XmlElement - XML DOM Node

SimpleXmlParser - SimpleXML-based Parser

XmlValidator - XML Validation

JSON Schema

JsonSchema - Schema Definition

ToolSchema - Function Tool Wrapper

CanProvideJsonSchema - Contract

CLI Utilities

Console - Terminal Output

Color - ANSI Color Constants

Text & Code Utilities

TextRepresentation - Convert Any Value to String

Tokenizer - GPT-3 Token Counting

ProgrammingLanguage - Language Enum & Helpers

Data Helpers

Metadata - Immutable Key-Value Store

OpaqueExternalId - Abstract Typed Identifier

AbstractResolver - Priority-Based Provider Chain

Markdown

FrontMatter - YAML Front Matter Parser

Specialized Parsers

JsonExtractor - JSON Extraction from Text

JsonDecoder - Resilient JSON Decoder

IncrementalJsonParser - Streaming Chunk Parser

XML Parsers

All classes follow immutable patterns where applicable and use strict typing throughout.