diff --git a/io/readers.ts b/io/readers.ts index 915d73e6cb76..2ebfc6b1509c 100644 --- a/io/readers.ts +++ b/io/readers.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. type Reader = Deno.Reader; type ReadResult = Deno.ReadResult; -import { encode } from "../strings/strings.ts"; +import { encode } from "../strings/mod.ts"; /** Reader utility for strings */ export class StringReader implements Reader { diff --git a/io/readers_test.ts b/io/readers_test.ts index a3806fbe2165..e4f159c74547 100644 --- a/io/readers_test.ts +++ b/io/readers_test.ts @@ -4,7 +4,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/strings.ts"; +import { decode } from "../strings/mod.ts"; test(async function ioStringReader(): Promise { const r = new StringReader("abcdef"); diff --git a/io/util.ts b/io/util.ts index 30df2a0e1fbd..a0cf08102937 100644 --- a/io/util.ts +++ b/io/util.ts @@ -2,7 +2,7 @@ const { Buffer, mkdir, open } = Deno; type File = Deno.File; type Reader = Deno.Reader; -import { encode } from "../strings/strings.ts"; +import { encode } from "../strings/mod.ts"; import * as path from "../fs/path.ts"; // `off` is the offset into `dst` where it will at which to begin writing values // from `src`. diff --git a/io/writers.ts b/io/writers.ts index 07c5743adc45..86901872892d 100644 --- a/io/writers.ts +++ b/io/writers.ts @@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. type Writer = Deno.Writer; -import { decode, encode } from "../strings/strings.ts"; +import { decode, encode } from "../strings/mod.ts"; /** Writer utility for buffering string chunks */ export class StringWriter implements Writer { diff --git a/mime/multipart.ts b/mime/multipart.ts index 672b407c2e21..1998335d1017 100644 --- a/mime/multipart.ts +++ b/mime/multipart.ts @@ -17,7 +17,7 @@ import { MultiReader } from "../io/readers.ts"; import { tempFile } from "../io/util.ts"; import { BufReader, BufState, BufWriter } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; -import { encoder } from "../strings/strings.ts"; +import { encoder } from "../strings/mod.ts"; import * as path from "../fs/path.ts"; function randomBoundary(): string { diff --git a/strings/decode.ts b/strings/decode.ts new file mode 100644 index 000000000000..2e161d7af616 --- /dev/null +++ b/strings/decode.ts @@ -0,0 +1,7 @@ +/** 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/strings/encode.ts b/strings/encode.ts new file mode 100644 index 000000000000..285305613737 --- /dev/null +++ b/strings/encode.ts @@ -0,0 +1,7 @@ +/** 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/strings/mod.ts b/strings/mod.ts new file mode 100644 index 000000000000..2acc32600a0e --- /dev/null +++ b/strings/mod.ts @@ -0,0 +1,5 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. + +export * from "./encode.ts"; +export * from "./decode.ts"; +export * from "./pad.ts"; diff --git a/strings/strings.ts b/strings/strings.ts deleted file mode 100644 index 266c61165691..000000000000 --- a/strings/strings.ts +++ /dev/null @@ -1,15 +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); -} - -/** 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/ws/README.md b/ws/README.md index 12cd51094ec0..3b44b6eeaf47 100644 --- a/ws/README.md +++ b/ws/README.md @@ -82,7 +82,7 @@ import { isWebSocketPingEvent, isWebSocketPongEvent } from "https://deno.land/std/ws/mod.ts"; -import { encode } from "https://deno.land/std/strings/strings.ts"; +import { encode } from "https://deno.land/std/strings/mod.ts"; import { BufReader } from "https://deno.land/std/io/bufio.ts"; import { TextProtoReader } from "https://deno.land/std/textproto/mod.ts"; import { blue, green, red, yellow } from "https://deno.land/std/colors/mod.ts"; diff --git a/ws/example_client.ts b/ws/example_client.ts index 16f37d021980..c2be9d76ed26 100644 --- a/ws/example_client.ts +++ b/ws/example_client.ts @@ -4,7 +4,7 @@ import { isWebSocketPingEvent, isWebSocketPongEvent } from "../ws/mod.ts"; -import { encode } from "../strings/strings.ts"; +import { encode } from "../strings/mod.ts"; import { BufReader } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; import { blue, green, red, yellow } from "../colors/mod.ts"; diff --git a/ws/mod.ts b/ws/mod.ts index 44743a2ced22..ced566d45cf5 100644 --- a/ws/mod.ts +++ b/ws/mod.ts @@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { decode, encode } from "../strings/strings.ts"; +import { decode, encode } from "../strings/mod.ts"; type Conn = Deno.Conn; type Writer = Deno.Writer; diff --git a/ws/test.ts b/ws/test.ts index 482d6926dd7b..93936988a395 100644 --- a/ws/test.ts +++ b/ws/test.ts @@ -11,7 +11,7 @@ import { unmask, writeFrame } from "./mod.ts"; -import { encode } from "../strings/strings.ts"; +import { encode } from "../strings/mod.ts"; const { Buffer } = Deno;