Skip to main content

getNotSetSentinelForIndexWidth

Callable

  • getNotSetSentinelForIndexWidth(bytesPerIndex: number): number

  • Returns the sentinel value (not-set indicator) for an index channel of a given on-wire width.

    The writer picks each channel's width from that channel's largest index and writes a not-set index as all-ones at that width, so the sentinel follows the width the section header declares - not the length of the table the channel indexes into.

    Only a nullable channel carries a sentinel at all (wire format §5.3). Applying it to a non-nullable channel turns a legitimate top index into a null.

    @example
    const sentinel = getNotSetSentinelForIndexWidth(names.BYTES_PER_ELEMENT);
    if (nameIndex === sentinel) {
    console.log('Name is not set');
    }

    Parameters

    • bytesPerIndex: number

      Bytes per index as declared by the section header (1, 2 or 4)

    Returns number

    The appropriate sentinel value (0xff, 0xffff, or 0xffffffff)