style: use nullish coalescing instead of if/then

This commit is contained in:
Franck Royer 2022-07-25 17:04:41 +10:00 committed by fryorcraken.eth
parent a3e6850b2f
commit 4a193e49e0
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 3 additions and 11 deletions

View File

@ -40,11 +40,7 @@ export class WakuLightPush {
pubSubTopic: string;
constructor(public libp2p: Libp2p, options?: CreateOptions) {
if (options?.pubSubTopic) {
this.pubSubTopic = options.pubSubTopic;
} else {
this.pubSubTopic = DefaultPubSubTopic;
}
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
}
async push(

View File

@ -55,7 +55,7 @@ export class WakuRelay extends GossipSub {
this.observers = {};
this.decryptionKeys = new Map();
this.pubSubTopic = options?.pubSubTopic || DefaultPubSubTopic;
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
options?.decryptionKeys?.forEach((key) => {
this.addDecryptionKey(key);

View File

@ -103,11 +103,7 @@ export class WakuStore {
>;
constructor(public libp2p: Libp2p, options?: CreateOptions) {
if (options?.pubSubTopic) {
this.pubSubTopic = options.pubSubTopic;
} else {
this.pubSubTopic = DefaultPubSubTopic;
}
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
this.decryptionKeys = new Map();
}