Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of nullish operator as react-create-app will fail to build #141

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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