Item

import { Item } from "jsr:@ende/http/unstable-structured-fields";

interface · experimental

interface Item

An Item in a Structured Field, consisting of a Bare Item and Parameters.

See also

Properties

value

value: BareItem

The bare item value.

parameters

parameters: Parameters

Parameters associated with this item.

Source

item

import { item } from "jsr:@ende/http/unstable-structured-fields";

function · experimental

function item(value: BareItem, parameters?: Iterable<[string, BareItem]>): Item

Creates an Item from a Bare Item and optional Parameters.

value: BareItem

The Bare Item value.

parameters?: Iterable<[string, BareItem]>

Optional parameters as a Map or iterable of key-value pairs.

Returns

An Item with the given value and parameters.

Example: Usage

import { item, integer, token } from "@ende/http/unstable-structured-fields";
import { assertEquals } from "@ende/assert";

assertEquals(item(integer(42)), {
  value: { type: "integer", value: 42 },
  parameters: new Map(),
});

assertEquals(item(integer(42), [["q", token("fast")]]), {
  value: { type: "integer", value: 42 },
  parameters: new Map([["q", token("fast")]]),
});

Source