Stay organized with collections
Save and categorize content based on your preferences.
blockly > Workspace > isCapacityAvailable
Workspace.isCapacityAvailable() method
Check if there is remaining capacity for blocks of the given counts to be created. If the total number of blocks represented by the map is more than the total remaining capacity, it returns false. If a type count is more than the remaining capacity for that type, it returns false.
Signature:
isCapacityAvailable(typeCountsMap: {
[key: string]: number;
}): boolean;
Parameters
Parameter |
Type |
Description |
typeCountsMap |
{ [key: string]: number; } |
A map of types to counts (usually representing blocks to be created). |
Returns:
boolean
True if there is capacity for the given map, false otherwise.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eisCapacityAvailable\u003c/code\u003e method checks if a Blockly workspace has enough capacity to create new blocks based on the provided type and count.\u003c/p\u003e\n"],["\u003cp\u003eIt returns \u003ccode\u003efalse\u003c/code\u003e if the total number of blocks or the count of a specific block type exceeds the defined capacity, otherwise it returns \u003ccode\u003etrue\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe method uses a \u003ccode\u003etypeCountsMap\u003c/code\u003e parameter to specify the types and counts of blocks intended for creation.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [Workspace](./blockly.workspace_class.md) \\\u003e [isCapacityAvailable](./blockly.workspace_class.iscapacityavailable_1_method.md)\n\nWorkspace.isCapacityAvailable() method\n--------------------------------------\n\nCheck if there is remaining capacity for blocks of the given counts to be created. If the total number of blocks represented by the map is more than the total remaining capacity, it returns false. If a type count is more than the remaining capacity for that type, it returns false.\n\n**Signature:** \n\n isCapacityAvailable(typeCountsMap: {\n [key: string]: number;\n }): boolean;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|---------------|------------------------------|-----------------------------------------------------------------------|\n| typeCountsMap | { \\[key: string\\]: number; } | A map of types to counts (usually representing blocks to be created). |\n\n**Returns:**\n\nboolean\n\nTrue if there is capacity for the given map, false otherwise."]]