Skip to main content
Module

x/sfv_parser/stringify.ts>stringifySfv

Structured Field Values for HTTP parser and serializer
Latest
function stringifySfv
import { stringifySfv } from "https://deno.land/x/sfv_parser@1.1.0/stringify.ts";

Serialize Sfv into string.

Examples

Example 1

import { stringifySfv } from "https://deno.land/x/sfv_parser@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

const sfv = {
  "type": "List",
  "value": [
    {
      "type": "Item",
      "value": [
        { "type": "Token", "value": "sugar" },
        { "type": "Parameters", "value": [] },
      ],
    },
    {
      "type": "Item",
      "value": [
        { "type": "Token", "value": "tea" },
        { "type": "Parameters", "value": [] },
      ],
    },
    {
      "type": "Item",
      "value": [
        { "type": "Token", "value": "rum" },
        { "type": "Parameters", "value": [] },
      ],
    },
  ],
} as const;

assertEquals(stringifySfv(sfv), "sugar, tea, rum");

Parameters

input: Sfv

Any Sfv.

Returns

string