entities
    Preparing search index...

    Class EntityDecoder

    Token decoder with support of writing partial entities.

    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • decodeTree: Uint16Array

        The tree used to decode entities.

      • emitCodePoint: (cp: number, consumed: number) => void

        The function that is called when a codepoint is decoded.

        For multi-byte named entities, this will be called multiple times, with the second codepoint, and the same consumed value.

          • (cp: number, consumed: number): void
          • Parameters

            • cp: number
            • consumed: number

              The number of bytes consumed by the decoder.

            Returns void

      • Optionalerrors: EntityErrorProducer

        An object that is used to produce errors.

      Returns EntityDecoder

    Methods

    • Signal to the parser that the end of the input was reached.

      Remaining data will be emitted and relevant errors will be produced.

      Returns number

      The number of characters consumed.

    • Write an entity to the decoder. This can be called multiple times with partial entities. If the entity is incomplete, the decoder will return -1.

      Mirrors the implementation of getDecoder, but with the ability to stop decoding if the entity is incomplete, and resume when the next string is written.

      Parameters

      • input: string

        The string containing the entity (or a continuation of the entity).

      • offset: number

        The offset at which the entity begins. Should be 0 if this is not the first call.

      Returns number

      The number of characters that were consumed, or -1 if the entity is incomplete.