Options
All
  • Public
  • Public/Protected
  • All
Menu
template Prefix

Hierarchy

  • CID

Index

Constructors

  • Parameters

    Returns CID

Properties

byteLength: number
byteOffset: number
bytes: Uint8Array
code: number
multihash: MultihashDigest<number>
version: CIDVersion

Accessors

  • get [toStringTag](): string
  • Returns string

  • get buffer(): void
  • Returns void

  • get codec(): void
  • Returns void

  • get multibaseName(): void
  • Returns void

  • get prefix(): void
  • Returns void

  • get toBaseEncodedString(): void
  • Returns void

Methods

  • equals(other: any): any
  • Parameters

    • other: any

    Returns any

  • toJSON(): { code: number; hash: Uint8Array; version: CIDVersion }
  • Returns { code: number; hash: Uint8Array; version: CIDVersion }

  • Parameters

    Returns string

  • Returns CID

  • Returns CID

  • asCID(value: any): null | CID
  • Takes any input value and returns a CID instance if it was a CID otherwise returns null. If value is instanceof CID it will return value back. If value is not instance of this CID class, but is compatible CID it will return new instance of this CID class. Otherwise returs null.

    This allows two different incompatible versions of CID library to co-exist and interop as long as binary interface is compatible.

    Parameters

    • value: any

    Returns null | CID

  • Parameters

    • version: CIDVersion

      Version of the CID

    • code: number

      Code of the codec content is encoded in.

    • digest: MultihashDigest<number>

      (Multi)hash of the of the content.

    Returns CID

  • Simplified version of create for CIDv0.

    Parameters

    Returns CID

  • Simplified version of create for CIDv1.

    Type parameters

    • Code: number

    Parameters

    • code: Code

      Content encoding format code.

    • digest: MultihashDigest<number>

      Miltihash of the content.

    Returns CID

  • decode(bytes: Uint8Array): CID
  • Decoded a CID from its binary representation. The byte array must contain only the CID with no additional bytes.

    An error will be thrown if the bytes provided do not contain a valid binary representation of a CID.

    Parameters

    • bytes: Uint8Array

    Returns CID

  • decodeFirst(bytes: Uint8Array): [CID, Uint8Array]
  • Decoded a CID from its binary representation at the beginning of a byte array.

    Returns an array with the first element containing the CID and the second element containing the remainder of the original byte array. The remainder will be a zero-length byte array if the provided bytes only contained a binary CID representation.

    Parameters

    • bytes: Uint8Array

    Returns [CID, Uint8Array]

  • inspectBytes(initialBytes: Uint8Array): { codec: number; digestSize: number; multihashCode: number; multihashSize: number; size: number; version: CIDVersion }
  • Inspect the initial bytes of a CID to determine its properties.

    Involves decoding up to 4 varints. Typically this will require only 4 to 6 bytes but for larger multicodec code values and larger multihash digest lengths these varints can be quite large. It is recommended that at least 10 bytes be made available in the initialBytes argument for a complete inspection.

    Parameters

    • initialBytes: Uint8Array

    Returns { codec: number; digestSize: number; multihashCode: number; multihashSize: number; size: number; version: CIDVersion }

    • codec: number
    • digestSize: number
    • multihashCode: number
    • multihashSize: number
    • size: number
    • version: CIDVersion
  • isCID(value: any): value is CID
  • Parameters

    • value: any

    Returns value is CID

  • Takes cid in a string representation and creates an instance. If base decoder is not provided will use a default from the configuration. It will throw an error if encoding of the CID is not compatible with supplied (or a default decoder).

    Type parameters

    • Prefix: string

    Parameters

    Returns CID

Generated using TypeDoc