index

@twine-protocol/twine-core v0.1.0Docs


twine-js / @twine-protocol/twine-core

@twine-protocol/twine-core

This is the core javascript (typescript) package for the Twine protocol. It will be used by all other packages.

You will likely be most interested in the Twine class, fromJSON, and fromBytes.

This is a very small subset of twine utilities. It contains utilities defining chains and pulses, storage and resolving interfaces, and signature verification.

To actually create twine data, you need the "@twine-protocol/twine-builder" package.

To retrieve or store twine data you'll need one of these packages:

See

  • Twine for the main class

  • fromJSON for creating Twine objects from JSON

  • fromBytes for creating Twine objects from bytes

Classes

Cache

Class
Description

A map that caches the most recently accessed items

A store that caches twines in memory

Other

Class
Description

Resolving

Class
Description

A helper to restrict the resolution to a specific chain

Storage

Class
Description

A store that keeps twines in memory

Twine Data

Class
Description

Generic class for twine data

Interfaces

Other

Interface
Description

JSON Web Key (JWK). "RSA", "EC", "OKP", and "oct" key types are supported.

Resolving

Interface
Description

Resolves a query into a chain or pulse

Options for combined resolution calls

Options for combined resolution of latest pulse calls

A resolver that combines multiple resolvers

Signer

Interface
Description

Any class implementing this interface can be used as a signer for Twine

Storage

Interface
Description

A store that can fetch and save twines

Type Aliases

Cache

Type alias
Description

Cache options

Crawling

Type alias
Description

Something that could be a value or an iterator over that value type

A path is a list of resolved pulse resolutions

An object that contains a path

Options for the loader

An object containing a load function that represents a pending crawl result

The result of a crawl that is a pulse resolution with a path

The result of a crawl that is a fulfilled pulse resolution with a path

Crawl Guide

Internal

Type alias
Description

Metadata used by the memory store to keep track of chains and pulses

Other

Type alias
Description

Something that can be awaited

An async or sycn iterable

The signature type

Mixins store the information about links between chains

Generic map

Chain metadata

Pulse index (block height)

Pulse content

Chain or pulse content

Value field for chains

Value field for pulses

Value field for chain or pulse

Any type that can be coerced into a CID

Any type that can be coerced into a mixin

A Twine that is a Chain

A Twine that is a Pulse

Resolving

Type alias
Description

A query to resolve a chain

A query to resolve a pulse

A query to resolve a chain strictly using a CID object

A query to resolve a pulse strictly using CID objects

A strict query to resolve a chain or pulse

The product of a successful chain resolution

The product of a successful pulse resolution

The product of a failed chain resolution

The product of a failed pulse resolution

A successful chain or pulse resolution

A failed chain or pulse resolution

A successful or failed chain resolution

A successful or failed pulse resolution

A resolution of any kind

Something that can be coerced into a chain resolution query

Something that can be coerced into a pulse resolution query

Options for all resolvers

CID for a chain lookup

CIDs for a pulse lookup

An object containing methods to fetch twines

Options for combining resolvers

A combined pulse resolution

A combined chain resolution

Variables

Cache

Variable
Description

A singleton cache store

Functions

Comparison

Function
Description

Compare two mixin lists and return the differences

Conversion

Function
Description

Collect an async iterable into an array

Convert something mixin-like into a mixin

Convert bytes into a hex string

Convert a hex string into bytes

Convert something query-like into a query

Convert something into a CID

Coerce something into a CID

Convert a DAG-JSON encoded twine into a twine instance

Converts a bytes array (ipld block) into a twine instance

Converts a pulse's links array into a list of queries.

Coerce something into a query

Crawling

Function
Description

Crawl the tapestry

Find a path between two pulses

Internal

Function
Description

Throttle an async function call

memoize an async function call so that while it is pending, the same call is not made again

Resolving

Function
Description

A helper function for implementing the Resolver.resolve method

memoize an async function call so that while it is pending, the same call is not made again

Combine multiple resolvers into a single resolver

Skiplist

Function
Description

Get an iterator of indices that can be used to skip through the chain.

Get the highest layer for which this (pulse) index is an anchor for. For example: in base 10, for the following indicies...

CrawlGuide

Crawling

Function
Description

Create a guide that moves horizontally across chains

Create a guide that visits all skiplist links as they are seen

Create a guide that moves along chains

Create a guide that spreads out in all directions

Create a guide that does a random walk through the tapestry

Create a guide that moves efficiently towards a target pulse

Errors

Class
Description

General Twine Error class

Signifies that the twine data does not follow specs

Signifies that the signature is invalid

Thrown when crawling cannot resolve a pulse

Internal

Function
Description

Get the hash digest of twine content

Verify the signature of a chain or pulse

Type Guards

Function
Description

Is this string a valid ISO Date

Is this an integer

Is this a positive integer

Is this a sync iterable

Is this an async iterable

Is this a sync or async iterable

Is this a CID object (not a string)

Is this a mixin list

Is this a links list

Is this valid pulse content

Is this valid chain content

Is this a pulse value

Is this a chain value

Is this a twine value (pulse or chain)

Is this a twine

Is this a chain

Is this a pulse

Is this a fulfilled pulse resolution

Is this a fulfilled chain resolution

Is this a pulse query

Last updated