diff options
| author | Axetroy <troy450409405@gmail.com> | 2019-05-27 07:58:31 +0800 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-05-27 02:58:31 +0300 |
| commit | ad3de86604f6bae352e06ef9154e371f4d5d1860 (patch) | |
| tree | fa52c7502697f7e70a294921815bc60d9f59849a | |
| parent | 8d94f70bef6e44d0a0ddb6f8410a35d95a34139a (diff) | |
rename strings/strings.ts to strings/mod.ts (denoland/deno_std#449)
Original: https://github.com/denoland/deno_std/commit/2f003fa35cb354b1b1cc43af196a0d356b334ed3
| -rw-r--r-- | io/readers.ts | 2 | ||||
| -rw-r--r-- | io/readers_test.ts | 2 | ||||
| -rw-r--r-- | io/util.ts | 2 | ||||
| -rw-r--r-- | io/writers.ts | 2 | ||||
| -rw-r--r-- | mime/multipart.ts | 2 | ||||
| -rw-r--r-- | strings/decode.ts | 7 | ||||
| -rw-r--r-- | strings/encode.ts | 7 | ||||
| -rw-r--r-- | strings/mod.ts | 5 | ||||
| -rw-r--r-- | strings/strings.ts | 15 | ||||
| -rw-r--r-- | ws/README.md | 2 | ||||
| -rw-r--r-- | ws/example_client.ts | 2 | ||||
| -rw-r--r-- | ws/mod.ts | 2 | ||||
| -rw-r--r-- | ws/test.ts | 2 |
13 files changed, 28 insertions, 24 deletions
diff --git a/io/readers.ts b/io/readers.ts index 915d73e6c..2ebfc6b15 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 a3806fbe2..e4f159c74 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<void> { const r = new StringReader("abcdef"); diff --git a/io/util.ts b/io/util.ts index 30df2a0e1..a0cf08102 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 07c5743ad..869018728 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 55d8da1c4..832211a27 100644 --- a/mime/multipart.ts +++ b/mime/multipart.ts @@ -12,7 +12,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 000000000..2e161d7af --- /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 000000000..285305613 --- /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 000000000..2acc32600 --- /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 266c61165..000000000 --- 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 12cd51094..3b44b6eea 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 16f37d021..c2be9d76e 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"; @@ -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 482d6926d..93936988a 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; |
