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

Commit e11ebd5

Browse files
committed
style: Add comments, tidy types.
1 parent 21cf74a commit e11ebd5

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/StreamrClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ export class StreamrClient extends EventEmitter { // eslint-disable-line no-rede
357357
let subTask: Todo
358358
let sub: Todo
359359
const hasResend = !!(opts.resend || opts.from || opts.to || opts.last)
360-
const onEnd = (err: Error) => {
360+
const onEnd = (err?: Error) => {
361361
if (sub && typeof onMessage === 'function') {
362362
sub.off('message', onMessage)
363363
}

src/stream/KeyExchange.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ async function subscribeToKeyExchangeStream(client, onKeyExchangeMessage) {
181181
const publisherId = await client.getUserId()
182182
const streamId = getKeyExchangeStreamId(publisherId)
183183
const sub = await client.subscribe(streamId, onKeyExchangeMessage)
184-
sub.on('error', () => {
185-
186-
})
184+
sub.on('error', () => {}) // errors should not shut down subscription
187185
return sub
188186
}
189187

@@ -362,7 +360,7 @@ async function SubscriberKeyExhangeSubscription(client, getGroupKeyStore, encryp
362360
}
363361

364362
sub = await subscribeToKeyExchangeStream(client, onKeyExchangeMessage)
365-
sub.on('error', () => {})
363+
sub.on('error', () => {}) // errors should not shut down subscription
366364
return sub
367365
}
368366

src/utils/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ export function CacheAsyncFn(asyncFn: Parameters<typeof pMemoize>[0], {
148148
maxSize = 10000,
149149
maxAge = 30 * 60 * 1000, // 30 minutes
150150
cachePromiseRejection = false,
151-
onEviction = () => {
152-
},
151+
onEviction = () => {},
153152
...opts
154153
} = {}) {
155154
const cache = new LRU<unknown, { data: unknown, maxAge: number }>({
@@ -230,7 +229,7 @@ export function Defer<T>(executor: (...args: Parameters<Promise<T>['then']>) =>
230229
reject = _reject
231230
executor(resolve, reject)
232231
})
233-
p.catch(() => {})
232+
p.catch(() => {}) // prevent unhandledrejection
234233

235234
function wrap(fn: F.Function) {
236235
return async (...args: unknown[]) => {

0 commit comments

Comments
 (0)