Skip to content

Commit

Permalink
Refactor callback function to remove unused error parameter
Browse files Browse the repository at this point in the history
Removed the unnecessary error parameter from the callback function in the get method to streamline the code. Corrected the handling of errors by ensuring the check is done on the 'done' object directly, improving code clarity and maintainability.

Signed-off-by: Alberto Ricart <[email protected]>
  • Loading branch information
aricart committed Nov 22, 2024
1 parent 5df905f commit 6a080dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions jetstream/src/jsapi_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ export type DirectMsgRequest =
| NextMsgRequest
| StartTimeMsgRequest;

export type Done = { err?: Error };
export type BatchCallback<T> = (done: Done | null, d: T) => void;
export type CompletionResult = { err?: Error };
export type BatchCallback<T> = (done: CompletionResult | null, d: T) => void;
export type StartSeq = { seq?: number };
export type StartTime = { start_time?: Date | string };
export type DirectBatchLimits = {
Expand Down
6 changes: 3 additions & 3 deletions jetstream/src/jsm_direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ import {
TD,
} from "@nats-io/nats-core/internal";
import type {
CompletionResult,
DirectBatchOptions,
DirectLastFor,
DirectMsgRequest,
Done,
LastForMsgRequest,
} from "./jsapi_types.ts";
import { validateStreamName } from "./jsutil.ts";
Expand Down Expand Up @@ -127,7 +127,7 @@ export class DirectStreamAPIImpl extends BaseApiClientImpl
const iter = new QueuedIteratorImpl<StoredMsg>();

function pushIter(
done: Done | null,
done: CompletionResult | null,
d: StoredMsg | CallbackFn,
) {
if (done) {
Expand All @@ -140,7 +140,7 @@ export class DirectStreamAPIImpl extends BaseApiClientImpl
}

function pushCb(
done: Done | null,
done: CompletionResult | null,
m: StoredMsg | CallbackFn,
) {
const cb = callback!;
Expand Down

0 comments on commit 6a080dd

Please sign in to comment.