BC-DCBOR-Parse TypeScript Library - v1.0.0-alpha.20
    Preparing search index...

    Function parseDcborItemPartial

    • Parses a dCBOR item from the beginning of a string and returns the parsed Cbor along with the number of bytes consumed.

      Unlike parseDcborItem, this function succeeds even if additional characters follow the first item. The returned index points to the first unparsed character after skipping any trailing whitespace or comments.

      Parameters

      • src: string

        A string containing the dCBOR-encoded data.

      Returns ParseResult<[Cbor, number]>

      Ok([Cbor, number]) with the parsed item and bytes consumed.

      const result = parseDcborItemPartial("true )");
      if (result.ok) {
      const [cbor, used] = result.value;
      console.log(cbor.toDiagnostic()); // "true"
      console.log(used); // 5
      }