class · Browser and Node

# Tagged

A wrapper class for representing a CBOR tag with an arbitrary nested value.

`Tagged` is a symmetric primitive: it can be passed to `encode()` to emit a CBOR tag header followed by the encoded form of `value`, and it can be returned from a tag decoder (via `Tagged.decoder(tag)` or `Tagged.preserve()`) to round-trip a tag through decode without losing the tag number.

Use `Tagged` for one-off tag handling where defining a dedicated `typeEncoders` entry and tag decoder pair would be heavyweight, e.g. when wrapping a structure in a single application-specific tag (COSE, dCBOR envelopes, etc.).

For systematic mapping of a JS type to a tag (e.g. CID -> tag 42), prefer a dedicated `typeEncoders` entry instead.

`@toip-tools/cose` · [View source](https://github.com/yourbuddyconner/toip-tools/blob/main/node_modules/cborg/types/lib/tagged.d.ts#L23)

Import:

```ts
import { Tagged } from "@toip-tools/cose";
```

## Constructor

Constructor:

```ts
new (tag: number, value: any): Tagged;
```

### Parameters

**`tag` (required)**

`number`

- CBOR tag number, a non-negative integer

**`value` (required)**

`any`

- The value to be tagged; encoded recursively

### Returns

`Tagged`

[Usage guide](https://toip.tools/toolkit/cose/#usage) · [Error handling](https://toip.tools/toolkit/cose/#errors) · [All exports](https://toip.tools/toolkit/cose/api/)

---

This is the Markdown version of https://toip.tools/toolkit/cose/api/Tagged/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
