Item
import { Item } from "jsr:@ende/http/unstable-structured-fields";interface · experimental
interface ItemAn Item in a Structured Field, consisting of a Bare Item and Parameters.
See also
Properties
value
value: BareItemThe bare item value.
parameters
parameters: ParametersParameters associated with this item.
item
import { item } from "jsr:@ende/http/unstable-structured-fields";function · experimental
function item(value: BareItem, parameters?: Iterable<[string, BareItem]>): ItemCreates an Item from a Bare Item and optional Parameters.
value: BareItemThe Bare Item value.
parameters?: Iterable<[string, BareItem]>Optional parameters as a
Mapor 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")]]),
});