diff --git a/src/block_manager/index.ts b/src/block_manager/index.ts index 58d742d28..6f2ba10bd 100644 --- a/src/block_manager/index.ts +++ b/src/block_manager/index.ts @@ -286,9 +286,13 @@ export default class BlockManager extends ItemManagerModule { category?: Category; items: Block[] } * * // NOTE: The item without category is the one containing blocks without category. + * + * // You can also get the same output format by passing your own array of Blocks + * const myFilteredBlocks: Block[] = [...]; + * blockManager.getBlocksByCategorymyFilteredBlocks */ - getBlocksByCategory(): BlocksByCategory[] { - return getItemsByCategory(this.getAll().models); + getBlocksByCategory(blocks?: Block[]): BlocksByCategory[] { + return getItemsByCategory(blocks || this.getAll().models); } /** diff --git a/src/trait_manager/index.ts b/src/trait_manager/index.ts index b4fe366fc..7e64ca0c3 100644 --- a/src/trait_manager/index.ts +++ b/src/trait_manager/index.ts @@ -92,9 +92,13 @@ export default class TraitManager extends Module { * // > { category?: Category; items: Trait[] } * * // NOTE: The item without category is the one containing traits without category. + * + * // You can also get the same output format by passing your own array of Traits + * const myFilteredTraits: Trait[] = [...]; + * traitManager.getTraitsByCategory(myFilteredTraits); */ - getTraitsByCategory(): TraitsByCategory[] { - return getItemsByCategory(this.getTraits()); + getTraitsByCategory(traits?: Trait[]): TraitsByCategory[] { + return getItemsByCategory(traits || this.getTraits()); } /**