API reference@evolu/commonObject › objectToEntries

function objectToEntries<T>(
  record: T,
): readonly [Extract<keyof T, string>, T[Extract<keyof T, string>]][];

Defined in: packages/common/src/Object.ts:154

Like Object.entries but preserves branded keys.

Example

import {
  assertEqual,
  assertType,
  objectToEntries,
  type Brand,
  type ReadonlyRecord,
} from "@evolu/common";

type UserId = string & Brand<"UserId">;

const userId = "u1" as UserId;
const users: ReadonlyRecord<UserId, string> = { [userId]: "Alice" };
const entries = objectToEntries(users);

assertType<ReadonlyArray<[UserId, string]>, typeof entries>();
assertEqual(entries, [[userId, "Alice"]]);