diff options
author | Yusuke Sakurai <kerokerokerop@gmail.com> | 2020-03-23 03:49:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 14:49:09 -0400 |
commit | c337d2c4349abd710b1ab0d4de3f1041cd02715c (patch) | |
tree | d6677ed54142beb192bbb48b2dfc2a1b3e4690d5 /std/ws/mod.ts | |
parent | 07ea145ec4d1defe4481035432bb63234560ba8d (diff) |
clean up textproto code in std (#4458)
- moved and renamed append() into bytes from ws and textproto
- renamed textproto/readder_tests.ts -> textproto/test.ts
Diffstat (limited to 'std/ws/mod.ts')
-rw-r--r-- | std/ws/mod.ts | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/std/ws/mod.ts b/std/ws/mod.ts index 3332ed8dd..6101260e9 100644 --- a/std/ws/mod.ts +++ b/std/ws/mod.ts @@ -9,6 +9,7 @@ import { writeResponse } from "../http/io.ts"; import { TextProtoReader } from "../textproto/mod.ts"; import { Deferred, deferred } from "../util/async.ts"; import { assertNotEOF } from "../testing/asserts.ts"; +import { concat } from "../bytes/mod.ts"; import Conn = Deno.Conn; import Writer = Deno.Writer; @@ -57,20 +58,6 @@ export function isWebSocketPongEvent( export type WebSocketMessage = string | Uint8Array; -// TODO move this to common/util module -export function append(a: Uint8Array, b: Uint8Array): Uint8Array { - if (a == null || !a.length) { - return b; - } - if (b == null || !b.length) { - return a; - } - const output = new Uint8Array(a.length + b.length); - output.set(a, 0); - output.set(b, a.length); - return output; -} - export interface WebSocketFrame { isLastFrame: boolean; opcode: OpCode; @@ -148,10 +135,10 @@ export async function writeFrame( ]); } if (frame.mask) { - header = append(header, frame.mask); + header = concat(header, frame.mask); } unmask(frame.payload, frame.mask); - header = append(header, frame.payload); + header = concat(header, frame.payload); const w = BufWriter.create(writer); await w.write(header); await w.flush(); |