Utilities Module

Data Utilities (obj & arr)

High-performance operations for deep object manipulation and collection management.

Object Utilities (obj)

.deepClone(obj)

Creates a complete, recursive copy of an object. Handles circular references and complex prototypes.

typescript
const originalConfig = { api: { timeout: 5000 }, plugins: ["auth"] };
const newConfig = __sys__.utils.obj.deepClone(originalConfig);

.parse(json, fallback?)

A safe alternative to JSON.parse. Returns a fallback value instead of throwing on malformed strings.

typescript
const prefs = __sys__.utils.obj.parse(raw, { theme: "light" });

.pick() / .omit()

Filters object properties based on a whitelist (pick) or blacklist (omit).

typescript
const user = { id: 1, email: "j@d.com", password: "HIDDEN" };
const publicProfile = __sys__.utils.obj.omit(user, ["password"]); // { id: 1, email: "j@d.com" }

.flattenObject(obj, separator?)

Recursively reduces a nested object into a single-level object with path-based keys.

typescript
const flat = __sys__.utils.obj.flattenObject({ user: { profile: { name: "John" } } });
// → { "user.profile.name": "John" }

Array Utilities (arr)

.chunk(array, size)

Splits an array into smaller sub-arrays of a defined maximum size. Ideal for batch processing.

typescript
const batches = __sys__.utils.arr.chunk([1, 2, 3, 4, 5, 6, 7], 3);
// → [[1, 2, 3], [4, 5, 6], [7]]

.unique(array)

Removes duplicate elements while preserving the original order of the first occurrence.

typescript
const uniqueIds = __sys__.utils.arr.unique(["A", "B", "A", "C"]); // → ["A", "B", "C"]

.groupBy(array, keyFn)

Buckets elements of an array into an object based on a discriminator function.

typescript
const categorized = __sys__.utils.arr.groupBy(products, (p) => p.category);
Logic Utilities

Master asynchronous control flow and validation guards.