-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(masonry): Create Brick Warehouse module with functions to add, r…
…etrieve and delete instances
- Loading branch information
1 parent
1a72c64
commit 4fba69d
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import BrickStatement from './BrickStatement'; | ||
import BrickExpression from './BrickExpression'; | ||
import BrickData from './BrickData'; | ||
import BrickBlock from './BrickBlock'; | ||
|
||
// Warehouse to manage brick instances | ||
const brickWarehouse: Map<string, BrickStatement | BrickExpression | BrickData | BrickBlock> = | ||
new Map(); | ||
|
||
/** | ||
* Adds a brick instance to the warehouse. | ||
* @param brick - The brick instance to add. | ||
*/ | ||
export function addBrickToWarehouse( | ||
brick: BrickStatement | BrickExpression | BrickData | BrickBlock, | ||
): void { | ||
brickWarehouse.set(brick.id, brick); | ||
} | ||
|
||
/** | ||
* Retrieves a brick instance from the warehouse by its ID. | ||
* @param id - The ID of the brick to retrieve. | ||
* @returns The brick instance if found, otherwise undefined. | ||
*/ | ||
export function getBrickFromWarehouse( | ||
id: string, | ||
): BrickStatement | BrickExpression | BrickData | BrickBlock | undefined { | ||
return brickWarehouse.get(id); | ||
} | ||
|
||
/** | ||
* Deletes a brick instance from the warehouse by its ID. | ||
* @param id - The ID of the brick to delete. | ||
* @returns True if the brick was deleted, false if it was not found. | ||
*/ | ||
export function deleteBrickFromWarehouse(id: string): boolean { | ||
return brickWarehouse.delete(id); | ||
} |