From 00f2240cf7a9b7020360eb430c7d98dfd36b654c Mon Sep 17 00:00:00 2001 From: Black Ram <67595890+BlackRam-oss@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:31:48 +0200 Subject: [PATCH] Add getAllCharacters function to CharacterDecorator.ts --- src/decorators/CharacterDecorator.ts | 12 ++++++++++++ src/decorators/index.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/decorators/CharacterDecorator.ts b/src/decorators/CharacterDecorator.ts index b145bc54..63fd7933 100644 --- a/src/decorators/CharacterDecorator.ts +++ b/src/decorators/CharacterDecorator.ts @@ -46,3 +46,15 @@ export function getCharacterById(id: string): T | return } } + +/** + * is a function that returns all characters + * @returns all characters + * @example + * ```typescript + * const allCharacters = getAllCharacters(); + * ``` + */ +export function getAllCharacters(): T[] { + return Object.values(registeredCharacters) as T[] +} diff --git a/src/decorators/index.ts b/src/decorators/index.ts index 7091519a..e422f419 100644 --- a/src/decorators/index.ts +++ b/src/decorators/index.ts @@ -1,5 +1,5 @@ export { default as canvasElementDecorator } from './CanvasElementDecorator'; -export { getCharacterById, saveCharacter } from './CharacterDecorator'; +export { getAllCharacters, getCharacterById, saveCharacter } from './CharacterDecorator'; export { default as eventDecorator } from './EventDecorator'; export { default as labelDecorator } from './LabelDecorator'; export { default as tickerDecorator } from './TickerDecorator';