feat: add Blockly.Extensions.isRegistered function (#5500)

Co-authored-by: Monica Kozbial <6621618+moniika@users.noreply.github.com>
This commit is contained in:
Aaron Imming
2021-10-08 01:15:00 +08:00
committed by GitHub
parent ca61d8cbc6
commit 2b1f33cc7b

View File

@@ -127,7 +127,7 @@ exports.registerMutator = registerMutator;
* @alias Blockly.Extensions.unregister
*/
const unregister = function(name) {
if (allExtensions[name]) {
if (isRegistered(name)) {
delete allExtensions[name];
} else {
console.warn(
@@ -136,6 +136,18 @@ const unregister = function(name) {
};
exports.unregister = unregister;
/**
* Returns whether an extension is registered with the given name.
* @param {string} name The name of the extension to check for.
* @return {boolean} True if the extension is registered. False if it is
* not registered.
* @alias Blockly.Extensions.isRegistered
*/
const isRegistered = function(name) {
return !!allExtensions[name];
};
exports.isRegistered = isRegistered;
/**
* Applies an extension method to a block. This should only be called during
* block construction.