Skip to content

Commit

Permalink
remove use of nullish operator as react-create-app will fail to build
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed Apr 9, 2021
1 parent 6b25e37 commit ce797b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion nats-base-client/jsbaseclient_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const defaultPrefix = "$JS.API";
const defaultTimeout = 5000;

export function defaultJsOptions(opts?: JetStreamOptions): JetStreamOptions {
opts = opts ?? {} as JetStreamOptions;
opts = opts || {} as JetStreamOptions;
return extend({ apiPrefix: defaultPrefix, timeout: defaultTimeout }, opts);
}

Expand Down
28 changes: 14 additions & 14 deletions nats-base-client/jsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export class JetStreamClientImpl extends BaseApiClient
data: Uint8Array = Empty,
opts?: Partial<JetStreamPublishOptions>,
): Promise<PubAck> {
opts = opts ?? {};
opts.expect = opts.expect ?? {};
const mh = opts?.headers ?? headers();
opts = opts || {};
opts.expect = opts.expect || {};
const mh = opts?.headers || headers();
if (opts) {
if (opts.msgID) {
mh.set(PubHeaders.MsgIdHdr, opts.msgID);
Expand All @@ -104,7 +104,7 @@ export class JetStreamClientImpl extends BaseApiClient
}
}

const to = opts.timeout ?? this.timeout;
const to = opts.timeout || this.timeout;
const ro = {} as RequestOptions;
if (to) {
ro.timeout = to;
Expand Down Expand Up @@ -159,9 +159,9 @@ export class JetStreamClientImpl extends BaseApiClient
let timer: Timeout<void> | null = null;

const args: Partial<PullOptions> = {};
args.batch = opts.batch ?? 1;
args.no_wait = opts.no_wait ?? false;
const expires = opts.expires ?? 0;
args.batch = opts.batch || 1;
args.no_wait = opts.no_wait || false;
const expires = opts.expires || 0;
if (expires) {
args.expires = nanos(expires);
}
Expand Down Expand Up @@ -321,7 +321,7 @@ export class JetStreamClientImpl extends BaseApiClient
: opts) as JetStreamSubscriptionInfo;

jsi.api = this;
jsi.config = jsi.config ?? {} as ConsumerConfig;
jsi.config = jsi.config || {} as ConsumerConfig;
jsi.stream = jsi.stream ? jsi.stream : await this.findStream(subject);

jsi.attached = false;
Expand Down Expand Up @@ -351,7 +351,7 @@ export class JetStreamClientImpl extends BaseApiClient
// createInbox(this.nc.options.inboxPrefix);
}

jsi.deliver = jsi.config.deliver_subject ??
jsi.deliver = jsi.config.deliver_subject ||
createInbox(this.nc.options.inboxPrefix);

return jsi;
Expand All @@ -368,7 +368,7 @@ export class JetStreamClientImpl extends BaseApiClient
if (!jsi.mack) {
so.dispatchedFn = autoAckJsMsg;
}
so.max = jsi.max ?? 0;
so.max = jsi.max || 0;
return so;
}

Expand Down Expand Up @@ -412,14 +412,14 @@ class JetStreamSubscriptionImpl extends TypedSubscription<JsMsg>
await this.drain();
}
const jinfo = this.sub.info as JetStreamSubscriptionInfo;
const name = jinfo.config.durable_name ?? jinfo.name;
const name = jinfo.config.durable_name || jinfo.name;
const subj = `${jinfo.api.prefix}.CONSUMER.DELETE.${jinfo.stream}.${name}`;
await jinfo.api._request(subj);
}

async consumerInfo(): Promise<ConsumerInfo> {
const jinfo = this.sub.info as JetStreamSubscriptionInfo;
const name = jinfo.config.durable_name ?? jinfo.name;
const name = jinfo.config.durable_name || jinfo.name;
const subj = `${jinfo.api.prefix}.CONSUMER.INFO.${jinfo.stream}.${name}`;
return await jinfo.api._request(subj) as ConsumerInfo;
}
Expand All @@ -438,8 +438,8 @@ class JetStreamPullSubscriptionImpl extends JetStreamSubscriptionImpl
const { stream, config } = this.sub.info as JetStreamSubscriptionInfo;
const consumer = config.durable_name;
const args: Partial<PullOptions> = {};
args.batch = opts.batch ?? 1;
args.no_wait = opts.no_wait ?? false;
args.batch = opts.batch || 1;
args.no_wait = opts.no_wait || false;
// FIXME: this is nanos
if (opts.expires && opts.expires > 0) {
args.expires = opts.expires;
Expand Down
2 changes: 1 addition & 1 deletion nats-base-client/jsmsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class JsMsgImpl implements JsMsg {
}

get reply(): string {
return this.msg.reply ?? "";
return this.msg.reply || "";
}

get seq(): number {
Expand Down

0 comments on commit ce797b8

Please sign in to comment.