Hub JS Package

Hub JS Package

  • Users
  • Buckets
  • Threads
  • Textile Docs

›Common Methods & Classes

Getting Started

  • Introduction
  • Package Overview

Users API

  • Users class

Buckets

  • Buckets class

Threads

  • Client class

Common Methods & Classes

  • ThreadID class
  • createUserAuth() function
  • createAPISig() function

@textile/hub > ThreadID

ThreadID class

ThreadID represents a self-describing Thread identifier.

It is formed by a Version, a Variant, and a random number of a given length.

Signature:

export declare class ThreadID 

Example 1

Create a new random ThreadID

import { ThreadID } from '@textile/hub'

const id = ThreadID.fromRandom()

console.log(id)

Example 2

Convert a ThreadID to/from a Base32 string

import { ThreadID } from '@textile/hub'

const id = ThreadID.fromRandom()
const str = id.toString()
const restored = ThreadID.fromString(str)

Constructors

ConstructorModifiersDescription
(constructor)(buf)Constructs a new instance of the ThreadID class

Properties

PropertyModifiersTypeDescription
bufUint8Array
V1staticnumberVersions. Currently only V1 is supported.
Variantstatictypeof Variant

Methods

MethodModifiersDescription
equals(o)equals checks that two IDs are the same.
fromBytes(data)staticfromBytes takes an ID data slice, parses it and returns an ID. For IDV1, the data bytes are arranged as: <random-number> Please use fromEncoded when parsing a regular ID string, as fromBytes does not expect multibase-encoded data. fromBytes accepts the output of ID.bytes().
fromRandom(variant, size)staticfromRandom creates a new random ID object.
fromString(v)staticfromString parses an ID-encoded string and returns an ID object. For IDV1, an ID-encoded string is primarily a multibase string: <multibase-type-code><base-encoded-string> The base-encoded string represents a: <random-number>
getEncoding(v)staticgetEncoding returns the multibase encoding for a multibase encoded string. Returns the name of the encoding if it is encoded, and throws an error otherwise.
isDefined()isDefined returns true if an ID is defined. Calling any other methods on an undefined ID will result in undefined behavior.
toBytes()toBytes returns the byte representation of an ID. The output of bytes can be parsed back into an ID with fromBytes.
toString(base)toString returns the (multibase encoded) string representation of an ID.
variant()variant returns the variant of an ID.
version()version returns the ID version.
← PreviouscreateUserAuth() function →
  • ThreadID class
  • Example 1
  • Example 2
  • Constructors
  • Properties
  • Methods
Hub JS Package
Docs
Getting StartedThreadDBBuckets
Resources
All DocumentationProject SlackBlog
More
GitHubStar
Follow @textileio