isCustomRecord

See source code

Type guard to check if a record is of a specific custom type.

function isCustomRecord(typeName: string, record?: UnknownRecord): boolean

Example

function handleRecord(record: TLRecord) {
  if (isCustomRecord('comment', record)) {
    // Handle comment record
    console.log(`Comment: ${record.text}`)
  }
}

Parameters

NameDescription

typeName

string

The type name to check against

record

The record to check

Returns

boolean

True if the record is of the specified type

Prev
isBindingId
Next
isCustomRecordId