From dc6e0c3591709d6f8887bb672af1de54dfc8a974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 15 Mar 2020 15:31:55 +0100 Subject: feat: Deno.core.{encode,decode}; standalone UTF-8 encoding/decoding (#4349) This commits add two new methods to "Deno.core" namespace: "encode" and "decode". Those methods are bound in Rust to provide a) fast b) generally available of encoding and decoding UTF-8 strings. Both methods are now used in "cli/js/dispatch_json.ts". --- cli/js/ops/dispatch_json.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cli/js/ops') diff --git a/cli/js/ops/dispatch_json.ts b/cli/js/ops/dispatch_json.ts index 4aa1f6b8b..9ff0f13f5 100644 --- a/cli/js/ops/dispatch_json.ts +++ b/cli/js/ops/dispatch_json.ts @@ -1,6 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import * as util from "../util.ts"; -import { TextEncoder, TextDecoder } from "../web/text_encoding.ts"; import { core } from "../core.ts"; import { OPS_CACHE } from "../runtime.ts"; import { ErrorKind, getErrorClass } from "../errors.ts"; @@ -30,13 +29,13 @@ function nextPromiseId(): number { } function decode(ui8: Uint8Array): JsonResponse { - const s = new TextDecoder().decode(ui8); + const s = core.decode(ui8); return JSON.parse(s) as JsonResponse; } function encode(args: object): Uint8Array { const s = JSON.stringify(args); - return new TextEncoder().encode(s); + return core.encode(s); } function unwrapResponse(res: JsonResponse): Ok { -- cgit v1.2.3