Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 01c0690

Browse files
authored
Final TS tidyup (#2120)
1 parent 47eafca commit 01c0690

12 files changed

+39
-42
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { BinaryMessageFormat } from "../src/BinaryMessageFormat"
4+
import { BinaryMessageFormat } from "../src/BinaryMessageFormat";
55

66
describe("Binary Message Formatter", () => {
77
([
8-
[[], <Uint8Array[]>[]],
9-
[[0x00], <Uint8Array[]>[ new Uint8Array([])]],
10-
[[0x01, 0xff], <Uint8Array[]>[ new Uint8Array([0xff])]],
8+
[[], [] as Uint8Array[]],
9+
[[0x00], [ new Uint8Array([])] as Uint8Array[]],
10+
[[0x01, 0xff], [ new Uint8Array([0xff])] as Uint8Array[]],
1111
[[0x01, 0xff,
12-
0x01, 0x7f], <Uint8Array[]>[ new Uint8Array([0xff]), new Uint8Array([0x7f])]],
13-
] as [number[], Uint8Array[]][]).forEach(([payload, expected_messages]) => {
12+
0x01, 0x7f], [ new Uint8Array([0xff]), new Uint8Array([0x7f])] as Uint8Array[]],
13+
] as Array<[number[], Uint8Array[]]>).forEach(([payload, expectedMessages]) => {
1414
it(`should parse '${payload}' correctly`, () => {
15-
let messages = BinaryMessageFormat.parse(new Uint8Array(payload).buffer);
16-
expect(messages).toEqual(expected_messages);
17-
})
15+
const messages = BinaryMessageFormat.parse(new Uint8Array(payload).buffer);
16+
expect(messages).toEqual(expectedMessages);
17+
});
1818
});
1919

2020
([
@@ -26,34 +26,34 @@ describe("Binary Message Formatter", () => {
2626
[[0x80, 0x80, 0x80, 0x80, 0x08], new Error("Messages bigger than 2GB are not supported.")],
2727
[[0x80, 0x80, 0x80, 0x80, 0x80], new Error("Messages bigger than 2GB are not supported.")],
2828
[[0x02, 0x00], new Error("Incomplete message.")],
29-
[[0xff, 0xff, 0xff, 0xff, 0x07], new Error("Incomplete message.")]
30-
] as [number[], Error][]).forEach(([payload, expected_error]) => {
29+
[[0xff, 0xff, 0xff, 0xff, 0x07], new Error("Incomplete message.")],
30+
] as Array<[number[], Error]>).forEach(([payload, expectedError]) => {
3131
it(`should fail to parse '${payload}'`, () => {
32-
expect(() => BinaryMessageFormat.parse(new Uint8Array(payload).buffer)).toThrow(expected_error);
33-
})
32+
expect(() => BinaryMessageFormat.parse(new Uint8Array(payload).buffer)).toThrow(expectedError);
33+
});
3434
});
3535

3636
([
3737
[[], [0x00]],
3838
[[0x20], [0x01, 0x20]],
39-
] as [number[], number[]][]).forEach(([input, expected_payload]) => {
39+
] as Array<[number[], number[]]>).forEach(([input, expectedPayload]) => {
4040
it(`should write '${input}'`, () => {
41-
let actual = new Uint8Array(BinaryMessageFormat.write(new Uint8Array(input)));
42-
let expected = new Uint8Array(expected_payload);
41+
const actual = new Uint8Array(BinaryMessageFormat.write(new Uint8Array(input)));
42+
const expected = new Uint8Array(expectedPayload);
4343
expect(actual).toEqual(expected);
44-
})
44+
});
4545
});
4646

47-
([0x0000, 0x0001, 0x007f, 0x0080, 0x3fff, 0x4000, 0xc0de] as number[]).forEach(size => {
47+
([0x0000, 0x0001, 0x007f, 0x0080, 0x3fff, 0x4000, 0xc0de] as number[]).forEach((size) => {
4848
it(`messages should be roundtrippable (message size: '${size}')`, () => {
4949
const message = [];
5050
for (let i = 0; i < size; i++) {
5151
message.push(i & 0xff);
5252
}
5353

54-
var payload = new Uint8Array(message);
54+
const payload = new Uint8Array(message);
5555
expect(payload).toEqual(BinaryMessageFormat.parse(BinaryMessageFormat.write(payload))[0]);
56-
})
56+
});
5757
});
5858

59-
});
59+
});

clients/ts/signalr-protocol-msgpack/src/MessagePackHubProtocol.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { CompletionMessage, HubMessage, IHubProtocol, ILogger, InvocationMessage, LogLevel, MessageHeaders, MessageType, NullLogger, StreamInvocationMessage, StreamItemMessage, TransferFormat } from "@aspnet/signalr";
54
import { Buffer } from "buffer";
65
import * as msgpack5 from "msgpack5";
6+
7+
import { CompletionMessage, HubMessage, IHubProtocol, ILogger, InvocationMessage, LogLevel, MessageHeaders, MessageType, NullLogger, StreamInvocationMessage, StreamItemMessage, TransferFormat } from "@aspnet/signalr";
8+
79
import { BinaryMessageFormat } from "./BinaryMessageFormat";
810

911
export class MessagePackHubProtocol implements IHubProtocol {

clients/ts/signalr/spec/Common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { HttpTransportType, ITransport } from "../src/ITransport";
4+
import { HttpTransportType } from "../src/ITransport";
55

66
export function eachTransport(action: (transport: HttpTransportType) => void) {
77
const transportTypes = [

clients/ts/signalr/spec/HubConnection.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HubConnection } from "../src/HubConnection";
55
import { IConnection } from "../src/IConnection";
66
import { HubMessage, IHubProtocol, MessageType } from "../src/IHubProtocol";
77
import { ILogger, LogLevel } from "../src/ILogger";
8-
import { HttpTransportType, ITransport, TransferFormat } from "../src/ITransport";
8+
import { TransferFormat } from "../src/ITransport";
99
import { JsonHubProtocol } from "../src/JsonHubProtocol";
1010
import { NullLogger } from "../src/Loggers";
1111
import { IStreamSubscriber } from "../src/Stream";

clients/ts/signalr/spec/HubConnectionBuilder.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { HubConnectionBuilder } from "../src/HubConnectionBuilder";
5-
64
import { HttpRequest, HttpResponse } from "../src/HttpClient";
75
import { HubConnection } from "../src/HubConnection";
6+
import { HubConnectionBuilder } from "../src/HubConnectionBuilder";
87
import { IHttpConnectionOptions } from "../src/IHttpConnectionOptions";
98
import { HubMessage, IHubProtocol } from "../src/IHubProtocol";
109
import { ILogger, LogLevel } from "../src/ILogger";

clients/ts/signalr/spec/TextMessageFormatter.spec.ts renamed to clients/ts/signalr/spec/TextMessageFormat.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { TextMessageFormat } from "../src/TextMessageFormat";
55

6-
describe("Text Message Formatter", () => {
6+
describe("TextMessageFormat", () => {
77
([
88
["\u001e", [""]],
99
["\u001e\u001e", ["", ""]],

clients/ts/signalr/spec/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ export class PromiseSource<T = void> {
5858
public reject(reason?: any) {
5959
this.rejecter(reason);
6060
}
61-
}
61+
}

clients/ts/signalr/src/HandshakeProtocol.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { ILogger, LogLevel } from "./ILogger";
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
24
import { TextMessageFormat } from "./TextMessageFormat";
35

46
export interface HandshakeRequestMessage {

clients/ts/signalr/src/HubConnection.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
import { HandshakeProtocol, HandshakeRequestMessage, HandshakeResponseMessage } from "./HandshakeProtocol";
5-
import { HttpConnection } from "./HttpConnection";
65
import { IConnection } from "./IConnection";
7-
import { CancelInvocationMessage, CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, StreamInvocationMessage, StreamItemMessage } from "./IHubProtocol";
6+
import { CancelInvocationMessage, CompletionMessage, IHubProtocol, InvocationMessage, MessageType, StreamInvocationMessage, StreamItemMessage } from "./IHubProtocol";
87
import { ILogger, LogLevel } from "./ILogger";
9-
import { JsonHubProtocol } from "./JsonHubProtocol";
10-
import { NullLogger } from "./Loggers";
118
import { IStreamResult } from "./Stream";
12-
import { TextMessageFormat } from "./TextMessageFormat";
13-
import { Arg, createLogger, Subject } from "./Utils";
9+
import { Arg, Subject } from "./Utils";
1410

1511
const DEFAULT_TIMEOUT_IN_MS: number = 30 * 1000;
1612

clients/ts/signalr/src/IHubProtocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { ILogger } from "./ILogger";
2-
import { TransferFormat } from "./ITransport";
3-
4-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
52
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
63

4+
import { ILogger } from "./ILogger";
5+
import { TransferFormat } from "./ITransport";
6+
77
export const enum MessageType {
88
Invocation = 1,
99
StreamItem = 2,

clients/ts/signalr/src/ITransport.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { IConnection } from "./IConnection";
5-
64
export enum HttpTransportType {
75
WebSockets,
86
ServerSentEvents,

clients/ts/signalr/src/JsonHubProtocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
import { CloseMessage, CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, PingMessage, StreamItemMessage } from "./IHubProtocol";
4+
import { CompletionMessage, HubMessage, IHubProtocol, InvocationMessage, MessageType, StreamItemMessage } from "./IHubProtocol";
55
import { ILogger, LogLevel } from "./ILogger";
66
import { TransferFormat } from "./ITransport";
77
import { NullLogger } from "./Loggers";

0 commit comments

Comments
 (0)