Skip to content

Commit 500e6b2

Browse files
authored
Lint (#88)
1 parent ac76c60 commit 500e6b2

3 files changed

Lines changed: 33 additions & 33 deletions

File tree

src/amqp-base-client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export abstract class AMQPBaseClient {
103103
})
104104
}
105105

106-
updateSecret(newSecret : string, reason : string) {
106+
updateSecret(newSecret: string, reason: string) {
107107
let j = 0
108108
const frame = new AMQPView(new ArrayBuffer(4096))
109109
frame.setUint8(j, 1); j += 1 // type: method
@@ -164,9 +164,9 @@ export abstract class AMQPBaseClient {
164164
try {
165165
const frameEnd = view.getUint8(i + frameSize)
166166
if (frameEnd !== 206)
167-
throw(new AMQPError(`Invalid frame end ${frameEnd}, expected 206`, this))
167+
throw (new AMQPError(`Invalid frame end ${frameEnd}, expected 206`, this))
168168
} catch (e) {
169-
throw(new AMQPError(`Frame end out of range, frameSize=${frameSize}, pos=${i}, byteLength=${view.byteLength}`, this))
169+
throw (new AMQPError(`Frame end out of range, frameSize=${frameSize}, pos=${i}, byteLength=${view.byteLength}`, this))
170170
}
171171

172172
const channel = this.channels[channelId]
@@ -257,9 +257,9 @@ export abstract class AMQPBaseClient {
257257
case 41: { // openok
258258
i += 1 // reserved1
259259
this.closed = false
260-
const promise = this.connectPromise
260+
const promise = this.connectPromise
261261
if (promise) {
262-
const [resolve, ] = promise
262+
const [resolve,] = promise
263263
delete this.connectPromise
264264
resolve(this)
265265
}
@@ -296,7 +296,7 @@ export abstract class AMQPBaseClient {
296296
this.channels = [new AMQPChannel(this, 0)]
297297
const promise = this.closePromise
298298
if (promise) {
299-
const [resolve, ] = promise
299+
const [resolve,] = promise
300300
delete this.closePromise
301301
resolve()
302302
this.closeSocket()
@@ -491,8 +491,8 @@ export abstract class AMQPBaseClient {
491491
case 71: { // getOk
492492
const deliveryTag = view.getUint64(i); i += 8
493493
const redelivered = view.getUint8(i) === 1; i += 1
494-
const [exchange, exchangeLen]= view.getShortString(i); i += exchangeLen
495-
const [routingKey, routingKeyLen]= view.getShortString(i); i += routingKeyLen
494+
const [exchange, exchangeLen] = view.getShortString(i); i += exchangeLen
495+
const [routingKey, routingKeyLen] = view.getShortString(i); i += routingKeyLen
496496
const messageCount = view.getUint32(i); i += 4
497497
const message = new AMQPMessage(channel)
498498
message.deliveryTag = deliveryTag
@@ -504,7 +504,7 @@ export abstract class AMQPBaseClient {
504504
break
505505
}
506506
case 72: { // getEmpty
507-
const [ , len]= view.getShortString(i); i += len // reserved1
507+
const [, len] = view.getShortString(i); i += len // reserved1
508508
channel.resolveRPC(null)
509509
break
510510
}

src/amqp-socket-client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import * as tls from 'tls'
1111
*/
1212
export class AMQPClient extends AMQPBaseClient {
1313
socket?: net.Socket | undefined
14-
readonly tls : boolean
15-
readonly host : string
16-
readonly port : number
17-
readonly tlsOptions : AMQPTlsOptions | undefined
18-
private readonly insecure : boolean
14+
readonly tls: boolean
15+
readonly host: string
16+
readonly port: number
17+
readonly tlsOptions: AMQPTlsOptions | undefined
18+
private readonly insecure: boolean
1919
private framePos: number
2020
private frameSize: number
2121
private readonly frameBuffer: Buffer
@@ -60,7 +60,7 @@ export class AMQPClient extends AMQPBaseClient {
6060
return new Promise((resolve, reject) => {
6161
socket.on('timeout', () => reject(new AMQPError("timeout", this)))
6262
socket.on('error', (err) => reject(new AMQPError(err.message, this)))
63-
const onConnect = (conn : AMQPBaseClient) => {
63+
const onConnect = (conn: AMQPBaseClient) => {
6464
socket.setTimeout(this.heartbeat * 1000) // reset timeout if heartbeats are disabled
6565
resolve(conn)
6666
}

test/test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('can publish and consume', () => {
4545
.then(conn => conn.channel())
4646
.then(ch => ch.queue(""))
4747
.then(q => q.publish("hello world"))
48-
.then(q => q.subscribe({noAck: false}, msg => {
48+
.then(q => q.subscribe({ noAck: false }, msg => {
4949
msg.ack()
5050
resolve(msg)
5151
}))
@@ -60,7 +60,7 @@ test('can nack a message', () => {
6060
.then(conn => conn.channel())
6161
.then(ch => ch.queue(""))
6262
.then(q => q.publish("hello world"))
63-
.then(q => q.subscribe({noAck: false}, msg => {
63+
.then(q => q.subscribe({ noAck: false }, msg => {
6464
msg.nack()
6565
resolve(msg)
6666
}))
@@ -75,7 +75,7 @@ test('can reject a message', () => {
7575
.then(conn => conn.channel())
7676
.then(ch => ch.queue(""))
7777
.then(q => q.publish("hello world"))
78-
.then(q => q.subscribe({noAck: false}, msg => {
78+
.then(q => q.subscribe({ noAck: false }, msg => {
7979
msg.reject()
8080
resolve(msg)
8181
}))
@@ -115,7 +115,7 @@ test("can get message from a queue", async () => {
115115
const ch = await conn.channel()
116116
const q = await ch.queue("")
117117
await q.publish("message")
118-
const msg = await q.get({noAck: true})
118+
const msg = await q.get({ noAck: true })
119119
expect((msg as AMQPMessage).bodyString()).toEqual("message")
120120
})
121121

@@ -131,7 +131,7 @@ test('will throw an error after consumer timeout', async () => {
131131
const conn = await amqp.connect()
132132
const ch = await conn.channel()
133133
const q = await ch.queue("")
134-
const consumer = await q.subscribe({noAck: false}, () => "")
134+
const consumer = await q.subscribe({ noAck: false }, () => "")
135135
await expect(consumer.wait(1)).rejects.toThrow()
136136
})
137137

@@ -140,7 +140,7 @@ test('will throw an error if consumer is closed', async () => {
140140
const conn = await amqp.connect()
141141
const ch = await conn.channel()
142142
const q = await ch.queue("")
143-
const consumer = await q.subscribe({noAck: false}, () => "")
143+
const consumer = await q.subscribe({ noAck: false }, () => "")
144144
consumer.setClosed(new Error("testing"))
145145
try {
146146
await consumer.wait(1);
@@ -154,7 +154,7 @@ test('can cancel a consumer', () => {
154154
return amqp.connect()
155155
.then((conn) => conn.channel())
156156
.then((ch) => ch.queue(""))
157-
.then((q) => q.subscribe({noAck: false}, console.log))
157+
.then((q) => q.subscribe({ noAck: false }, console.log))
158158
.then((consumer) => consumer.cancel())
159159
.then((channel) => expect(channel.consumers.size).toEqual(0))
160160
})
@@ -164,7 +164,7 @@ test('will clear consumer wait timeout on cancel', async () => {
164164
const conn = await amqp.connect()
165165
const ch = await conn.channel()
166166
const q = await ch.queue("")
167-
const consumer = await q.subscribe({noAck: false}, () => "")
167+
const consumer = await q.subscribe({ noAck: false }, () => "")
168168
const wait = consumer.wait(5000);
169169
consumer.cancel()
170170
await expect(wait).resolves.toBeUndefined()
@@ -241,7 +241,7 @@ test('wait for publish confirms', async () => {
241241
ch.basicPublish("amq.fanout", "rk", "body"),
242242
ch.basicPublish("amq.fanout", "rk", "body")
243243
])
244-
expect(tags).toEqual([3,4])
244+
expect(tags).toEqual([3, 4])
245245
})
246246

247247
test('can handle returned messages', async () => {
@@ -261,7 +261,7 @@ test('can handle nacks on confirm channel', async () => {
261261
const conn = await amqp.connect()
262262
const ch = await conn.channel()
263263

264-
const q = await ch.queue("", {}, {"x-overflow": "reject-publish", "x-max-length": 0})
264+
const q = await ch.queue("", {}, { "x-overflow": "reject-publish", "x-max-length": 0 })
265265
await ch.confirmSelect()
266266
await expect(q.publish("body")).rejects.toThrow("Message rejected")
267267
})
@@ -391,7 +391,7 @@ test('can publish all type of properties', async () => {
391391
const q = await ch.queue()
392392
const headers = {
393393
a: 2, b: true, c: "c", d: 1.5, e: null, f: new Date(1000), g: { a: 1 },
394-
i: 2**32 + 1, j: 2.5**33,
394+
i: 2 ** 32 + 1, j: 2.5 ** 33,
395395
}
396396
const properties = {
397397
contentType: "application/json",
@@ -406,7 +406,7 @@ test('can publish all type of properties', async () => {
406406
appId: "appid",
407407
userId: "guest",
408408
type: "type",
409-
timestamp: new Date(Math.round(Date.now()/1000)*1000) // amqp timestamps does only have second resolution
409+
timestamp: new Date(Math.round(Date.now() / 1000) * 1000) // amqp timestamps does only have second resolution
410410
}
411411
await q.publish("", properties)
412412
const msg = await q.get()
@@ -512,7 +512,7 @@ test("can do basicRecover", async () => {
512512
})
513513

514514
test("can set frameMax", async () => {
515-
const amqp = getNewClient({ frameMax: 16*1024 })
515+
const amqp = getNewClient({ frameMax: 16 * 1024 })
516516
const conn = await amqp.connect()
517517
const ch = await conn.channel()
518518
await ch.confirmSelect()
@@ -536,7 +536,7 @@ test("can't set too small frameMax", () => {
536536
})
537537

538538
test("can handle frames split over socket reads", async () => {
539-
const amqp = getNewClient({ frameMax: 4*1024 })
539+
const amqp = getNewClient({ frameMax: 4 * 1024 })
540540
const conn = await amqp.connect()
541541
const ch = await conn.channel()
542542
const q = await ch.queue("")
@@ -610,8 +610,8 @@ test("will throw on too large headers", async () => {
610610
const amqp = getNewClient({ frameMax: 4096 })
611611
const conn = await amqp.connect()
612612
const ch = await conn.channel()
613-
await expect(ch.basicPublish("", "x".repeat(255), null, {"headers": {a: Array(4000).fill(1)}})).rejects.toThrow(RangeError)
614-
await expect(ch.basicPublish("", "", null, {"headers": {a: "x".repeat(5000)}})).rejects.toThrow(RangeError)
613+
await expect(ch.basicPublish("", "x".repeat(255), null, { "headers": { a: Array(4000).fill(1) } })).rejects.toThrow(RangeError)
614+
await expect(ch.basicPublish("", "", null, { "headers": { a: "x".repeat(5000) } })).rejects.toThrow(RangeError)
615615
})
616616

617617
test("will split body over multiple frames", async () => {
@@ -628,7 +628,7 @@ test("will split body over multiple frames", async () => {
628628
else
629629
assert.fail("no body")
630630
else
631-
assert.fail("no msg")
631+
assert.fail("no msg")
632632
})
633633

634634
test("can republish in consume block without race condition", async () => {
@@ -639,7 +639,7 @@ test("can republish in consume block without race condition", async () => {
639639
const q = await ch.queue("")
640640
await ch.confirmSelect()
641641
await q.publish("x".repeat(500))
642-
const consumer = await q.subscribe({noAck: false}, async (msg) => {
642+
const consumer = await q.subscribe({ noAck: false }, async (msg) => {
643643
if (msg.deliveryTag < 10000) {
644644
await Promise.all([
645645
q.publish(msg.body),

0 commit comments

Comments
 (0)