Skip to content

Commit

Permalink
feat: add CommandRepository#clear()
Browse files Browse the repository at this point in the history
 Also add default implementation and addition to ReadonlyCommandRepository
  • Loading branch information
Amgelo563 committed Sep 5, 2024
1 parent 2329a96 commit 4cfefd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,7 @@ export interface CommandRepository

/** Returns an iterator of all [ID, {@link TopLevelCommand}] pairs. */
entries(): IterableIterator<[string, TopLevelCommand]>;

/** Removes all stored commands. */
clear(): void;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2023 Amgelo563
* Copyright (c) 2024 Amgelo563
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,4 +26,4 @@ import type { CommandRepository } from './CommandRepository.js';

/** Type of immutable {@link CommandRepository}. */
export interface ReadonlyCommandRepository
extends Omit<CommandRepository, 'addCommand' | 'removeCommand'> {}
extends Omit<CommandRepository, 'addCommand' | 'removeCommand' | 'clear'> {}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export class DefaultCommandRepository implements CommandRepository {
return this.commands;
}

public clear() {
this.commands.clear();
}

public *entries(): IterableIterator<[string, TopLevelCommand]> {
yield* this.commands.entries();
}
Expand Down

0 comments on commit 4cfefd5

Please sign in to comment.