deno.land / std@0.224.0 / streams / to_json_test.ts

to_json_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../assert/assert_equals.ts";import { toJson } from "./to_json.ts";
Deno.test("toJson()", async () => { const byteStream = ReadableStream.from(["[", "1, 2, 3, 4", "]"]) .pipeThrough(new TextEncoderStream());
assertEquals(await toJson(byteStream), [1, 2, 3, 4]);
const stringStream = ReadableStream.from([ '{ "a": 2,', ' "b": 3,', ' "c": 4 }', ]);
assertEquals(await toJson(stringStream), { a: 2, b: 3, c: 4, });});
std

Version Info

Tagged at
3 weeks ago