dCBOR Pattern TypeScript - v1.0.0-alpha.20
    Preparing search index...

    Function parsePartial

    • Parses a partial dCBOR pattern expression, returning the parsed pattern and the number of characters consumed.

      Unlike parse(), this function succeeds even if additional characters follow the first pattern. The returned index points to the first unparsed character after the pattern.

      Parameters

      • input: string

        The pattern string to parse

      Returns Result<[Pattern, number]>

      A Result containing a tuple of [Pattern, consumedLength] or an error

      const result = parsePartial("true rest");
      if (result.ok) {
      const [pattern, consumed] = result.value;
      console.log(consumed); // 4 or 5 (includes whitespace)
      }