API reference / @evolu/common / Object / createRecord

Function: createRecord()

function createRecord<K, V>(): Record<K, V>;

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

Creates a prototype-less object typed as Record<K, V>.

Use this function when you need a plain record without a prototype chain (e.g. when keys are controlled by external sources) to avoid prototype pollution and accidental collisions with properties like __proto__.

Example:

const values = createRecord<string, SqliteValue>();
values["__proto__"] = someValue; // safe, no prototype pollution

Type Parameters

Type ParameterDefault type
K extends stringstring
Vunknown

Returns

Record<K, V>

Was this page helpful?