Commit identifier, includes type, genesis CID, commit CID.

Encoded as <multibase-prefix><multicodec-streamid><type><genesis-cid-bytes><commit-cid-bytes>.

String representation is base36-encoding of the bytes above.

Hierarchy

  • CommitID

Implements

Constructors

  • Create a new StreamID.

    Example

    new StreamID(<type>, <CID>|<cidStr>)
    new StreamID(<type>, <CID>|<cidStr>, <CommitCID>|<CommitCidStr>)

    Parameters

    • type: string | number
    • cid: string | CID<unknown, number, number, Version>
    • commit: null | string | number | CID<unknown, number, number, Version> = null

      CID. Pass '0', 0, or omit the value as shorthand for the genesis commit.

    Returns CommitID

Properties

_tag: symbol = TAG
fromBytes: ((bytes: Uint8Array) => CommitID) = fromBytes

Type declaration

    • (bytes: Uint8Array): CommitID
    • Parse CommitID from bytes representation.

      Throws

      error on invalid input

      See

      CommitID#bytes

      Parameters

      • bytes: Uint8Array

        bytes representation of CommitID.

      Returns CommitID

fromBytesNoThrow: ((bytes: Uint8Array) => CommitID | Error) = fromBytesNoThrow

Type declaration

    • (bytes: Uint8Array): CommitID | Error
    • Same as fromBytes, but returns an Error instance rather than throwing if there is a problem with the input. Note that some exceptions can still be thrown in certain cases, if they come from lower-level libraries like multibase, for example.

      Parameters

      • bytes: Uint8Array

      Returns CommitID | Error

fromString: ((input: string) => CommitID) = fromString

Type declaration

    • (input: string): CommitID
    • Parse CommitID from string representation.

      See

      • CommitID#toString
      • CommitID#toUrl

      Parameters

      • input: string

        string representation of CommitID, be it base36-encoded string or URL.

      Returns CommitID

fromStringNoThrow: ((input: string) => CommitID | Error) = fromStringNoThrow

Type declaration

    • (input: string): CommitID | Error
    • Same as fromString, but returns an Error instance rather than throwing if there is a problem with the input. Note that some exceptions can still be thrown in certain cases, if they come from lower-level libraries like multibase, for example.

      Parameters

      • input: string

      Returns CommitID | Error

make: ((stream: StreamID, commit: string | number | CID<unknown, number, number, Version>) => CommitID) = make

Type declaration

    • (stream: StreamID, commit: string | number | CID<unknown, number, number, Version>): CommitID
    • Construct new CommitID for a given stream and commit

      Parameters

      • stream: StreamID
      • commit: string | number | CID<unknown, number, number, Version>

      Returns CommitID

Accessors

Methods