summaryrefslogtreecommitdiff
path: root/cli/js/ops/dispatch_json.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-15 15:31:55 +0100
committerGitHub <noreply@github.com>2020-03-15 15:31:55 +0100
commitdc6e0c3591709d6f8887bb672af1de54dfc8a974 (patch)
tree0239d62e419b840f1c4e5cd631a7b87689ed2a3b /cli/js/ops/dispatch_json.ts
parentec3f44581bf4312cbbe36b71daca7f0474177cf3 (diff)
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".
Diffstat (limited to 'cli/js/ops/dispatch_json.ts')
-rw-r--r--cli/js/ops/dispatch_json.ts5
1 files changed, 2 insertions, 3 deletions
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 {