diff options
Diffstat (limited to 'strings')
| -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 |
4 files changed, 19 insertions, 15 deletions
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); -} |
