# index

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

***

[twine-js](/twine-js/index.md) / @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](/twine-js/twine-protocol/twine-core/classes/twine.md) class, [fromJSON](/twine-js/twine-protocol/twine-core/functions/fromjson.md), and [fromBytes](/twine-js/twine-protocol/twine-core/functions/frombytes.md).

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"](/twine-js/twine-protocol/twine-builder/index.md) package.

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

* ["@twine-protocol/twine-http-store"](/twine-js/twine-protocol/twine-http-store/index.md) Store/retrieve data from an http api
* ["@twine-protocol/twine-car-utils"](/twine-js/twine-protocol/twine-car-utils/index.md) Store/retrieve data in CAR files
* ["@twine-protocol/twine-blockstore-store"](/twine-js/twine-protocol/twine-blockstore-store/index.md) Store/retrieve data in BlockStores

### See

* [Twine](/twine-js/twine-protocol/twine-core/classes/twine.md) for the main class
* [fromJSON](/twine-js/twine-protocol/twine-core/functions/fromjson.md) for creating Twine objects from JSON
* [fromBytes](/twine-js/twine-protocol/twine-core/functions/frombytes.md) for creating Twine objects from bytes

### Classes

#### Cache

| Class                                                                   | Description                                        |
| ----------------------------------------------------------------------- | -------------------------------------------------- |
| [CacheMap](/twine-js/twine-protocol/twine-core/classes/cachemap.md)     | A map that caches the most recently accessed items |
| [TwineCache](/twine-js/twine-protocol/twine-core/classes/twinecache.md) | A store that caches twines in memory               |

#### Other

| Class                                                     | Description |
| --------------------------------------------------------- | ----------- |
| [CID](/twine-js/twine-protocol/twine-core/classes/cid.md) | -           |

#### Resolving

| Class                                                                         | Description                                             |
| ----------------------------------------------------------------------------- | ------------------------------------------------------- |
| [ChainResolver](/twine-js/twine-protocol/twine-core/classes/chainresolver.md) | A helper to restrict the resolution to a specific chain |

#### Storage

| Class                                                                     | Description                         |
| ------------------------------------------------------------------------- | ----------------------------------- |
| [MemoryStore](/twine-js/twine-protocol/twine-core/classes/memorystore.md) | A store that keeps twines in memory |

#### Twine Data

| Class                                                         | Description                  |
| ------------------------------------------------------------- | ---------------------------- |
| [Twine](/twine-js/twine-protocol/twine-core/classes/twine.md) | Generic class for twine data |

### Interfaces

#### Other

| Interface                                                    | Description                                                                                                          |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| [JWK](/twine-js/twine-protocol/twine-core/interfaces/jwk.md) | JSON Web Key ([JWK](https://www.rfc-editor.org/rfc/rfc7517)). "RSA", "EC", "OKP", and "oct" key types are supported. |

#### Resolving

| Interface                                                                                                      | Description                                           |
| -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [Resolver](/twine-js/twine-protocol/twine-core/interfaces/resolver.md)                                         | Resolves a query into a chain or pulse                |
| [ResolveOptionsCombined](/twine-js/twine-protocol/twine-core/interfaces/resolveoptionscombined.md)             | Options for combined resolution calls                 |
| [ResolveLatestOptionsCombined](/twine-js/twine-protocol/twine-core/interfaces/resolvelatestoptionscombined.md) | Options for combined resolution of latest pulse calls |
| [CombinedResolver](/twine-js/twine-protocol/twine-core/interfaces/combinedresolver.md)                         | A resolver that combines multiple resolvers           |

#### Signer

| Interface                                                          | Description                                                             |
| ------------------------------------------------------------------ | ----------------------------------------------------------------------- |
| [Signer](/twine-js/twine-protocol/twine-core/interfaces/signer.md) | Any class implementing this interface can be used as a signer for Twine |

#### Storage

| Interface                                                        | Description                            |
| ---------------------------------------------------------------- | -------------------------------------- |
| [Store](/twine-js/twine-protocol/twine-core/interfaces/store.md) | A store that can fetch and save twines |

### Type Aliases

#### Cache

| Type alias                                                                       | Description   |
| -------------------------------------------------------------------------------- | ------------- |
| [CacheOptions](/twine-js/twine-protocol/twine-core/type-aliases/cacheoptions.md) | Cache options |

#### Crawling

| Type alias                                                                                       | Description                                                                 |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| [MaybeIterable](/twine-js/twine-protocol/twine-core/type-aliases/maybeiterable.md)               | Something that could be a value or an iterator over that value type         |
| [Path](/twine-js/twine-protocol/twine-core/type-aliases/path.md)                                 | A path is a list of resolved pulse resolutions                              |
| [CrawlPathContainer](/twine-js/twine-protocol/twine-core/type-aliases/crawlpathcontainer.md)     | An object that contains a path                                              |
| [LoaderOptions](/twine-js/twine-protocol/twine-core/type-aliases/loaderoptions.md)               | Options for the loader                                                      |
| [CrawlPending](/twine-js/twine-protocol/twine-core/type-aliases/crawlpending.md)                 | An object containing a load function that represents a pending crawl result |
| [CrawlResult](/twine-js/twine-protocol/twine-core/type-aliases/crawlresult.md)                   | The result of a crawl that is a pulse resolution with a path                |
| [FulfilledCrawlResult](/twine-js/twine-protocol/twine-core/type-aliases/fulfilledcrawlresult.md) | The result of a crawl that is a fulfilled pulse resolution with a path      |
| [CrawlGuide](/twine-js/twine-protocol/twine-core/type-aliases/crawlguide.md)                     | Crawl Guide                                                                 |

#### Internal

| Type alias                                                                               | Description                                                          |
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [ChainStorageMeta](/twine-js/twine-protocol/twine-core/type-aliases/chainstoragemeta.md) | Metadata used by the memory store to keep track of chains and pulses |

#### Other

| Type alias                                                                       | Description                                             |
| -------------------------------------------------------------------------------- | ------------------------------------------------------- |
| [Awaitable](/twine-js/twine-protocol/twine-core/type-aliases/awaitable.md)       | Something that can be `await`ed                         |
| [AnyIterable](/twine-js/twine-protocol/twine-core/type-aliases/anyiterable.md)   | An async or sycn iterable                               |
| [Signature](/twine-js/twine-protocol/twine-core/type-aliases/signature.md)       | The signature type                                      |
| [Mixin](/twine-js/twine-protocol/twine-core/type-aliases/mixin.md)               | Mixins store the information about links between chains |
| [AnyMap](/twine-js/twine-protocol/twine-core/type-aliases/anymap.md)             | Generic map                                             |
| [ChainContent](/twine-js/twine-protocol/twine-core/type-aliases/chaincontent.md) | Chain metadata                                          |
| [PulseIndex](/twine-js/twine-protocol/twine-core/type-aliases/pulseindex.md)     | Pulse index (block height)                              |
| [PulseContent](/twine-js/twine-protocol/twine-core/type-aliases/pulsecontent.md) | Pulse content                                           |
| [TwineContent](/twine-js/twine-protocol/twine-core/type-aliases/twinecontent.md) | Chain or pulse content                                  |
| [ChainValue](/twine-js/twine-protocol/twine-core/type-aliases/chainvalue.md)     | Value field for chains                                  |
| [PulseValue](/twine-js/twine-protocol/twine-core/type-aliases/pulsevalue.md)     | Value field for pulses                                  |
| [TwineValue](/twine-js/twine-protocol/twine-core/type-aliases/twinevalue.md)     | Value field for chain or pulse                          |
| [IntoCid](/twine-js/twine-protocol/twine-core/type-aliases/intocid.md)           | Any type that can be coerced into a CID                 |
| [IntoMixin](/twine-js/twine-protocol/twine-core/type-aliases/intomixin.md)       | Any type that can be coerced into a mixin               |
| [Chain](/twine-js/twine-protocol/twine-core/type-aliases/chain.md)               | A Twine that is a Chain                                 |
| [Pulse](/twine-js/twine-protocol/twine-core/type-aliases/pulse.md)               | A Twine that is a Pulse                                 |

#### Resolving

| Type alias                                                                                                   | Description                                                 |
| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| [ResolveChainQuery](/twine-js/twine-protocol/twine-core/type-aliases/resolvechainquery.md)                   | A query to resolve a chain                                  |
| [ResolvePulseQuery](/twine-js/twine-protocol/twine-core/type-aliases/resolvepulsequery.md)                   | A query to resolve a pulse                                  |
| [ResolveChainQueryStrict](/twine-js/twine-protocol/twine-core/type-aliases/resolvechainquerystrict.md)       | A query to resolve a chain strictly using a CID object      |
| [ResolvePulseQueryStrict](/twine-js/twine-protocol/twine-core/type-aliases/resolvepulsequerystrict.md)       | A query to resolve a pulse strictly using CID objects       |
| [ResolveQueryStrict](/twine-js/twine-protocol/twine-core/type-aliases/resolvequerystrict.md)                 | A strict query to resolve a chain or pulse                  |
| [FulfilledChainResolution](/twine-js/twine-protocol/twine-core/type-aliases/fulfilledchainresolution.md)     | The product of a successful chain resolution                |
| [FulfilledPulseResolution](/twine-js/twine-protocol/twine-core/type-aliases/fulfilledpulseresolution.md)     | The product of a successful pulse resolution                |
| [UnfulfilledChainResolution](/twine-js/twine-protocol/twine-core/type-aliases/unfulfilledchainresolution.md) | The product of a failed chain resolution                    |
| [UnfulfilledPulseResolution](/twine-js/twine-protocol/twine-core/type-aliases/unfulfilledpulseresolution.md) | The product of a failed pulse resolution                    |
| [FulfilledResolution](/twine-js/twine-protocol/twine-core/type-aliases/fulfilledresolution.md)               | A successful chain or pulse resolution                      |
| [UnfulfilledResolution](/twine-js/twine-protocol/twine-core/type-aliases/unfulfilledresolution.md)           | A failed chain or pulse resolution                          |
| [ChainResolution](/twine-js/twine-protocol/twine-core/type-aliases/chainresolution.md)                       | A successful or failed chain resolution                     |
| [PulseResolution](/twine-js/twine-protocol/twine-core/type-aliases/pulseresolution.md)                       | A successful or failed pulse resolution                     |
| [Resolution](/twine-js/twine-protocol/twine-core/type-aliases/resolution.md)                                 | A resolution of any kind                                    |
| [IntoResolveChainQuery](/twine-js/twine-protocol/twine-core/type-aliases/intoresolvechainquery.md)           | Something that can be coerced into a chain resolution query |
| [IntoResolvePulseQuery](/twine-js/twine-protocol/twine-core/type-aliases/intoresolvepulsequery.md)           | Something that can be coerced into a pulse resolution query |
| [ResolveOptions](/twine-js/twine-protocol/twine-core/type-aliases/resolveoptions.md)                         | Options for all resolvers                                   |
| [FetchChainQuery](/twine-js/twine-protocol/twine-core/type-aliases/fetchchainquery.md)                       | CID for a chain lookup                                      |
| [FetchPulseQuery](/twine-js/twine-protocol/twine-core/type-aliases/fetchpulsequery.md)                       | CIDs for a pulse lookup                                     |
| [ResolveCallers](/twine-js/twine-protocol/twine-core/type-aliases/resolvecallers.md)                         | An object containing methods to fetch twines                |
| [CombineResolversOptions](/twine-js/twine-protocol/twine-core/type-aliases/combineresolversoptions.md)       | Options for combining resolvers                             |
| [CombinedPulseResolution](/twine-js/twine-protocol/twine-core/type-aliases/combinedpulseresolution.md)       | A combined pulse resolution                                 |
| [CombinedChainResolution](/twine-js/twine-protocol/twine-core/type-aliases/combinedchainresolution.md)       | A combined chain resolution                                 |

### Variables

#### Cache

| Variable                                                                             | Description             |
| ------------------------------------------------------------------------------------ | ----------------------- |
| [CACHE\_SINGLETON](/twine-js/twine-protocol/twine-core/variables/cache_singleton.md) | A singleton cache store |

### Functions

#### Comparison

| Function                                                                | Description                                        |
| ----------------------------------------------------------------------- | -------------------------------------------------- |
| [mixinDiff](/twine-js/twine-protocol/twine-core/functions/mixindiff.md) | Compare two mixin lists and return the differences |

#### Conversion

| Function                                                                          | Description                                               |
| --------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [collect](/twine-js/twine-protocol/twine-core/functions/collect.md)               | Collect an async iterable into an array                   |
| [asMixin](/twine-js/twine-protocol/twine-core/functions/asmixin.md)               | Convert something mixin-like into a mixin                 |
| [bytesToHex](/twine-js/twine-protocol/twine-core/functions/bytestohex.md)         | Convert bytes into a hex string                           |
| [hex2bytes](/twine-js/twine-protocol/twine-core/functions/hex2bytes.md)           | Convert a hex string into bytes                           |
| [asQuery](/twine-js/twine-protocol/twine-core/functions/asquery.md)               | Convert something query-like into a query                 |
| [asCid](/twine-js/twine-protocol/twine-core/functions/ascid.md)                   | Convert something into a CID                              |
| [coerceCid](/twine-js/twine-protocol/twine-core/functions/coercecid.md)           | Coerce something into a CID                               |
| [fromJSON](/twine-js/twine-protocol/twine-core/functions/fromjson.md)             | Convert a DAG-JSON encoded twine into a twine instance    |
| [fromBytes](/twine-js/twine-protocol/twine-core/functions/frombytes.md)           | Converts a bytes array (ipld block) into a twine instance |
| [linksAsQueries](/twine-js/twine-protocol/twine-core/functions/linksasqueries.md) | Converts a pulse's links array into a list of queries.    |
| [coerceQuery](/twine-js/twine-protocol/twine-core/functions/coercequery.md)       | Coerce something into a query                             |

#### Crawling

| Function                                                              | Description                    |
| --------------------------------------------------------------------- | ------------------------------ |
| [crawl](/twine-js/twine-protocol/twine-core/functions/crawl.md)       | Crawl the tapestry             |
| [findPath](/twine-js/twine-protocol/twine-core/functions/findpath.md) | Find a path between two pulses |

#### Internal

| Function                                                                        | Description                                                                                 |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [asyncThrottle](/twine-js/twine-protocol/twine-core/functions/asyncthrottle.md) | Throttle an async function call                                                             |
| [memoized](/twine-js/twine-protocol/twine-core/functions/memoized.md)           | memoize an async function call so that while it is pending, the same call is not made again |

#### Resolving

| Function                                                                              | Description                                                                                                                          |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| [resolveHelper](/twine-js/twine-protocol/twine-core/functions/resolvehelper.md)       | A helper function for implementing the [Resolver.resolve](/twine-js/twine-protocol/twine-core/interfaces/resolver.md#resolve) method |
| [memoized](/twine-js/twine-protocol/twine-core/functions/memoized.md)                 | memoize an async function call so that while it is pending, the same call is not made again                                          |
| [combineResolvers](/twine-js/twine-protocol/twine-core/functions/combineresolvers.md) | Combine multiple resolvers into a single resolver                                                                                    |

#### Skiplist

| Function                                                                    | Description                                                                                                                 |
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| [skipList](/twine-js/twine-protocol/twine-core/functions/skiplist.md)       | Get an iterator of indices that can be used to skip through the chain.                                                      |
| [getLayerPos](/twine-js/twine-protocol/twine-core/functions/getlayerpos.md) | 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                                                    |
| ------------------------------------------------------------------------- | -------------------------------------------------------------- |
| [across](/twine-js/twine-protocol/twine-core/functions/across.md)         | Create a guide that moves horizontally across chains           |
| [within](/twine-js/twine-protocol/twine-core/functions/within.md)         | Create a guide that visits all skiplist links as they are seen |
| [along](/twine-js/twine-protocol/twine-core/functions/along.md)           | Create a guide that moves along chains                         |
| [spread](/twine-js/twine-protocol/twine-core/functions/spread.md)         | Create a guide that spreads out in all directions              |
| [randomWalk](/twine-js/twine-protocol/twine-core/functions/randomwalk.md) | Create a guide that does a random walk through the tapestry    |
| [towards](/twine-js/twine-protocol/twine-core/functions/towards.md)       | Create a guide that moves efficiently towards a target pulse   |

### Errors

| Class                                                                                       | Description                                         |
| ------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [TwineError](/twine-js/twine-protocol/twine-core/classes/twineerror.md)                     | General Twine Error class                           |
| [InvalidTwineData](/twine-js/twine-protocol/twine-core/classes/invalidtwinedata.md)         | Signifies that the twine data does not follow specs |
| [InvalidSignature](/twine-js/twine-protocol/twine-core/classes/invalidsignature.md)         | Signifies that the signature is invalid             |
| [IncompleteResolution](/twine-js/twine-protocol/twine-core/classes/incompleteresolution.md) | Thrown when crawling cannot resolve a pulse         |

### Internal

| Function                                                                              | Description                              |
| ------------------------------------------------------------------------------------- | ---------------------------------------- |
| [getContentDigest](/twine-js/twine-protocol/twine-core/functions/getcontentdigest.md) | Get the hash digest of twine content     |
| [verifySignature](/twine-js/twine-protocol/twine-core/functions/verifysignature.md)   | Verify the signature of a chain or pulse |

### Type Guards

| Function                                                                                                  | Description                            |
| --------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| [isISODate](/twine-js/twine-protocol/twine-core/functions/isisodate.md)                                   | Is this string a valid ISO Date        |
| [isInteger](/twine-js/twine-protocol/twine-core/functions/isinteger.md)                                   | Is this an integer                     |
| [isUnsignedInteger](/twine-js/twine-protocol/twine-core/functions/isunsignedinteger.md)                   | Is this a positive integer             |
| [isIterable](/twine-js/twine-protocol/twine-core/functions/isiterable.md)                                 | Is this a sync iterable                |
| [isAsyncIterable](/twine-js/twine-protocol/twine-core/functions/isasynciterable.md)                       | Is this an async iterable              |
| [isAnyIterable](/twine-js/twine-protocol/twine-core/functions/isanyiterable.md)                           | Is this a sync or async iterable       |
| [isCid](/twine-js/twine-protocol/twine-core/functions/iscid.md)                                           | Is this a CID object (not a string)    |
| [isMixins](/twine-js/twine-protocol/twine-core/functions/ismixins.md)                                     | Is this a mixin list                   |
| [isLinks](/twine-js/twine-protocol/twine-core/functions/islinks.md)                                       | Is this a links list                   |
| [isPulseContent](/twine-js/twine-protocol/twine-core/functions/ispulsecontent.md)                         | Is this valid pulse content            |
| [isChainContent](/twine-js/twine-protocol/twine-core/functions/ischaincontent.md)                         | Is this valid chain content            |
| [isPulseValue](/twine-js/twine-protocol/twine-core/functions/ispulsevalue.md)                             | Is this a pulse value                  |
| [isChainValue](/twine-js/twine-protocol/twine-core/functions/ischainvalue.md)                             | Is this a chain value                  |
| [isTwineValue](/twine-js/twine-protocol/twine-core/functions/istwinevalue.md)                             | Is this a twine value (pulse or chain) |
| [isTwine](/twine-js/twine-protocol/twine-core/functions/istwine.md)                                       | Is this a twine                        |
| [isChain](/twine-js/twine-protocol/twine-core/functions/ischain.md)                                       | Is this a chain                        |
| [isPulse](/twine-js/twine-protocol/twine-core/functions/ispulse.md)                                       | Is this a pulse                        |
| [isFulfilledPulseResolution](/twine-js/twine-protocol/twine-core/functions/isfulfilledpulseresolution.md) | Is this a fulfilled pulse resolution   |
| [isFulfilledChainResolution](/twine-js/twine-protocol/twine-core/functions/isfulfilledchainresolution.md) | Is this a fulfilled chain resolution   |
| [isPulseQuery](/twine-js/twine-protocol/twine-core/functions/ispulsequery.md)                             | Is this a pulse query                  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.twine.world/twine-js/twine-protocol/twine-core/index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
