Skip to content

Commit

Permalink
refactor: rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf authored and roziscoding committed Jul 16, 2024
1 parent 7407571 commit 9303b26
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class Commands<C extends Context> {
private _scopes: Map<string, Array<Command<C>>> = new Map();
private _commands: Command<C>[] = [];

private _dirty: boolean = false;
private _composer: Composer<C> = new Composer();
private _cachedComposer: Composer<C> = new Composer();
private _cachedComposerInvalidated: boolean = false;

private _commandOptions: Partial<CommandOptions> = {};

Expand Down Expand Up @@ -137,7 +137,7 @@ export class Commands<C extends Context> {
if (handler) command.addToScope({ type: "default" }, handler);

this._commands.push(command);
this._dirty = true;
this._cachedComposerInvalidated = true;
return command;
}
/**
Expand Down Expand Up @@ -262,11 +262,11 @@ export class Commands<C extends Context> {
}

middleware() {
if (this._dirty) {
this._composer = new Composer(...this._commands);
this._dirty = false;
if (this._cachedComposerInvalidated) {
this._cachedComposer = new Composer(...this._commands);
this._cachedComposerInvalidated = false;
}
return this._composer.middleware();
return this._cachedComposer.middleware();
}

/**
Expand Down

0 comments on commit 9303b26

Please sign in to comment.