summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-04-01 15:23:39 -0400
committerGitHub <noreply@github.com>2020-04-01 15:23:39 -0400
commit12c6b2395be2bd1371284adf03e4826ba5edc761 (patch)
treeef8bf5a2ef76a43fc044759e98d615fbd1a52e93
parent3a0b617503f4c81fb9773bd99c898270b98b9b5a (diff)
Move encode, decode helpers to /std/encoding/utf8.ts, delete /std/strings/ (#4565)
also removes std/encoding/mod.ts and std/archive/mod.ts which are useless.
-rw-r--r--std/archive/mod.ts1
-rw-r--r--std/bytes/test.ts2
-rw-r--r--std/encoding/mod.ts15
-rw-r--r--std/encoding/utf8.ts15
-rw-r--r--std/examples/tests/xeval_test.ts2
-rw-r--r--std/fs/expand_glob_test.ts2
-rw-r--r--std/http/io.ts2
-rw-r--r--std/http/io_test.ts2
-rw-r--r--std/http/server_test.ts2
-rw-r--r--std/io/readers.ts2
-rw-r--r--std/io/readers_test.ts2
-rw-r--r--std/io/util.ts2
-rw-r--r--std/io/writers.ts2
-rw-r--r--std/mime/multipart.ts2
-rw-r--r--std/strings/README.md26
-rw-r--r--std/strings/decode.ts7
-rw-r--r--std/strings/encode.ts7
-rw-r--r--std/strings/mod.ts4
-rw-r--r--std/textproto/mod.ts2
-rw-r--r--std/ws/example_client.ts2
-rw-r--r--std/ws/mod.ts2
-rw-r--r--std/ws/test.ts2
22 files changed, 30 insertions, 75 deletions
diff --git a/std/archive/mod.ts b/std/archive/mod.ts
deleted file mode 100644
index 254b8266f..000000000
--- a/std/archive/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./tar.ts";
diff --git a/std/bytes/test.ts b/std/bytes/test.ts
index 5efddf77f..13ac7a1fd 100644
--- a/std/bytes/test.ts
+++ b/std/bytes/test.ts
@@ -9,7 +9,7 @@ import {
concat,
} from "./mod.ts";
import { assertEquals, assertThrows, assert } from "../testing/asserts.ts";
-import { encode, decode } from "../strings/mod.ts";
+import { encode, decode } from "../encoding/utf8.ts";
Deno.test("[bytes] findIndex1", () => {
const i = findIndex(
diff --git a/std/encoding/mod.ts b/std/encoding/mod.ts
deleted file mode 100644
index eaa28ae27..000000000
--- a/std/encoding/mod.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export {
- HeaderOptions as CsvHeaderOptions,
- ParseError as CsvParseError,
- ParseOptions as ParseCsvOptions,
- parse as parseCsv,
-} from "./csv.ts";
-export {
- decode as decodeHex,
- decodeString as decodeHexString,
- encode as encodeToHex,
- encodeToString as encodeToHexString,
-} from "./hex.ts";
-export { parse as parseToml, stringify as tomlStringify } from "./toml.ts";
-export { parse as parseYaml, stringify as yamlStringify } from "./yaml.ts";
-export * from "./binary.ts";
diff --git a/std/encoding/utf8.ts b/std/encoding/utf8.ts
new file mode 100644
index 000000000..266c61165
--- /dev/null
+++ b/std/encoding/utf8.ts
@@ -0,0 +1,15 @@
+/** A default TextEncoder instance */
+export const encoder = new TextEncoder();
+
+/** Shorthand for new TextEncoder().encode() */
+export function encode(input?: string): Uint8Array {
+ return encoder.encode(input);
+}
+
+/** A default TextDecoder instance */
+export const decoder = new TextDecoder();
+
+/** Shorthand for new TextDecoder().decode() */
+export function decode(input?: Uint8Array): string {
+ return decoder.decode(input);
+}
diff --git a/std/examples/tests/xeval_test.ts b/std/examples/tests/xeval_test.ts
index 25f99c9f0..38deda686 100644
--- a/std/examples/tests/xeval_test.ts
+++ b/std/examples/tests/xeval_test.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { xeval } from "../xeval.ts";
import { stringsReader } from "../../io/util.ts";
-import { decode, encode } from "../../strings/mod.ts";
+import { decode, encode } from "../../encoding/utf8.ts";
import {
assertEquals,
assertStrContains,
diff --git a/std/fs/expand_glob_test.ts b/std/fs/expand_glob_test.ts
index 6be9c518f..4e6f74551 100644
--- a/std/fs/expand_glob_test.ts
+++ b/std/fs/expand_glob_test.ts
@@ -1,5 +1,5 @@
const { cwd, execPath, run } = Deno;
-import { decode } from "../strings/mod.ts";
+import { decode } from "../encoding/utf8.ts";
import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts";
import {
isWindows,
diff --git a/std/http/io.ts b/std/http/io.ts
index e12c9fb6e..d16489767 100644
--- a/std/http/io.ts
+++ b/std/http/io.ts
@@ -1,7 +1,7 @@
import { BufReader, BufWriter } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts";
import { assert } from "../testing/asserts.ts";
-import { encoder } from "../strings/mod.ts";
+import { encoder } from "../encoding/utf8.ts";
import { ServerRequest, Response } from "./server.ts";
import { STATUS_TEXT } from "./http_status.ts";
diff --git a/std/http/io_test.ts b/std/http/io_test.ts
index c1d6a921b..aa9c86130 100644
--- a/std/http/io_test.ts
+++ b/std/http/io_test.ts
@@ -15,7 +15,7 @@ import {
readRequest,
writeResponse,
} from "./io.ts";
-import { encode, decode } from "../strings/mod.ts";
+import { encode, decode } from "../encoding/utf8.ts";
import { BufReader, ReadLineResult } from "../io/bufio.ts";
import { chunkedBodyReader } from "./io.ts";
import { ServerRequest, Response } from "./server.ts";
diff --git a/std/http/server_test.ts b/std/http/server_test.ts
index d6b2be053..e70c241c7 100644
--- a/std/http/server_test.ts
+++ b/std/http/server_test.ts
@@ -16,7 +16,7 @@ import {
import { Response, ServerRequest, Server, serve } from "./server.ts";
import { BufReader, BufWriter } from "../io/bufio.ts";
import { delay } from "../util/async.ts";
-import { encode, decode } from "../strings/mod.ts";
+import { encode, decode } from "../encoding/utf8.ts";
import { mockConn } from "./mock.ts";
const { Buffer, test } = Deno;
diff --git a/std/io/readers.ts b/std/io/readers.ts
index 2d81e246f..8a567d7d1 100644
--- a/std/io/readers.ts
+++ b/std/io/readers.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
type Reader = Deno.Reader;
-import { encode } from "../strings/mod.ts";
+import { encode } from "../encoding/utf8.ts";
/** Reader utility for strings */
export class StringReader implements Reader {
diff --git a/std/io/readers_test.ts b/std/io/readers_test.ts
index e3aaad0a5..22982c924 100644
--- a/std/io/readers_test.ts
+++ b/std/io/readers_test.ts
@@ -3,7 +3,7 @@ import { assertEquals } from "../testing/asserts.ts";
import { MultiReader, StringReader } from "./readers.ts";
import { StringWriter } from "./writers.ts";
import { copyN } from "./ioutil.ts";
-import { decode } from "../strings/mod.ts";
+import { decode } from "../encoding/utf8.ts";
test(async function ioStringReader(): Promise<void> {
const r = new StringReader("abcdef");
diff --git a/std/io/util.ts b/std/io/util.ts
index 4bcf7d2e9..4479e2c38 100644
--- a/std/io/util.ts
+++ b/std/io/util.ts
@@ -3,7 +3,7 @@ const { Buffer, mkdir, open } = Deno;
type File = Deno.File;
type Reader = Deno.Reader;
import * as path from "../path/mod.ts";
-import { encode } from "../strings/mod.ts";
+import { encode } from "../encoding/utf8.ts";
// `off` is the offset into `dst` where it will at which to begin writing values
// from `src`.
diff --git a/std/io/writers.ts b/std/io/writers.ts
index b9a6a5e70..8e085c84b 100644
--- a/std/io/writers.ts
+++ b/std/io/writers.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
type Writer = Deno.Writer;
-import { decode, encode } from "../strings/mod.ts";
+import { decode, encode } from "../encoding/utf8.ts";
/** Writer utility for buffering string chunks */
export class StringWriter implements Writer {
diff --git a/std/mime/multipart.ts b/std/mime/multipart.ts
index a0f40f3b0..032d4e29d 100644
--- a/std/mime/multipart.ts
+++ b/std/mime/multipart.ts
@@ -11,7 +11,7 @@ import { MultiReader } from "../io/readers.ts";
import { extname } from "../path/mod.ts";
import { tempFile } from "../io/util.ts";
import { BufReader, BufWriter } from "../io/bufio.ts";
-import { encoder } from "../strings/mod.ts";
+import { encoder } from "../encoding/utf8.ts";
import { assertStrictEq, assert } from "../testing/asserts.ts";
import { TextProtoReader } from "../textproto/mod.ts";
import { hasOwnProperty } from "../util/has_own_property.ts";
diff --git a/std/strings/README.md b/std/strings/README.md
deleted file mode 100644
index 43be553b8..000000000
--- a/std/strings/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Strings
-
-This module provides a few basic utilities to manipulate strings.
-
-## Usage
-
-### pad
-
-Input string is processed to output a string with a minimal length. If the
-parameter `strict` is set to true, the output string length is equal to the
-`strLen` parameter.
-
-Basic usage:
-
-```ts
-import { pad } from "https://deno.land/std/strings/pad.ts";
-pad("deno", 6, { char: "*", side: "left" }); // output : "**deno"
-pad("deno", 6, { char: "*", side: "right" }); // output : "deno**"
-pad("denosorusrex", 6, {
- char: "*",
- side: "left",
- strict: true,
- strictSide: "right",
- strictChar: "...",
-}); // output : "den..."
-```
diff --git a/std/strings/decode.ts b/std/strings/decode.ts
deleted file mode 100644
index 2e161d7af..000000000
--- a/std/strings/decode.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/** A default TextDecoder instance */
-export const decoder = new TextDecoder();
-
-/** Shorthand for new TextDecoder().decode() */
-export function decode(input?: Uint8Array): string {
- return decoder.decode(input);
-}
diff --git a/std/strings/encode.ts b/std/strings/encode.ts
deleted file mode 100644
index 285305613..000000000
--- a/std/strings/encode.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-/** A default TextEncoder instance */
-export const encoder = new TextEncoder();
-
-/** Shorthand for new TextEncoder().encode() */
-export function encode(input?: string): Uint8Array {
- return encoder.encode(input);
-}
diff --git a/std/strings/mod.ts b/std/strings/mod.ts
deleted file mode 100644
index def161ae0..000000000
--- a/std/strings/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-export * from "./encode.ts";
-export * from "./decode.ts";
diff --git a/std/textproto/mod.ts b/std/textproto/mod.ts
index 760a068b5..06ffb7364 100644
--- a/std/textproto/mod.ts
+++ b/std/textproto/mod.ts
@@ -6,7 +6,7 @@
import { BufReader } from "../io/bufio.ts";
import { charCode } from "../io/util.ts";
import { concat } from "../bytes/mod.ts";
-import { decode } from "../strings/mod.ts";
+import { decode } from "../encoding/utf8.ts";
function str(buf: Uint8Array | null | undefined): string {
if (buf == null) {
diff --git a/std/ws/example_client.ts b/std/ws/example_client.ts
index e6653362d..3b1c6a33a 100644
--- a/std/ws/example_client.ts
+++ b/std/ws/example_client.ts
@@ -4,7 +4,7 @@ import {
isWebSocketPingEvent,
isWebSocketPongEvent,
} from "../ws/mod.ts";
-import { encode } from "../strings/mod.ts";
+import { encode } from "../encoding/utf8.ts";
import { BufReader } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts";
import { blue, green, red, yellow } from "../fmt/colors.ts";
diff --git a/std/ws/mod.ts b/std/ws/mod.ts
index a9b8cb675..bb377ad6e 100644
--- a/std/ws/mod.ts
+++ b/std/ws/mod.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { decode, encode } from "../strings/mod.ts";
+import { decode, encode } from "../encoding/utf8.ts";
import { hasOwnProperty } from "../util/has_own_property.ts";
import { BufReader, BufWriter } from "../io/bufio.ts";
import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts";
diff --git a/std/ws/test.ts b/std/ws/test.ts
index 583750bb1..20ba2ba61 100644
--- a/std/ws/test.ts
+++ b/std/ws/test.ts
@@ -16,7 +16,7 @@ import {
writeFrame,
createWebSocket,
} from "./mod.ts";
-import { encode, decode } from "../strings/mod.ts";
+import { encode, decode } from "../encoding/utf8.ts";
import Writer = Deno.Writer;
import Reader = Deno.Reader;
import Conn = Deno.Conn;