Skip to content

Commit

Permalink
feat: add Blockly.Extensions.isRegistered function (google#5500)
Browse files Browse the repository at this point in the history
Co-authored-by: Monica Kozbial <6621618+moniika@users.noreply.github.com>
  • Loading branch information
aaimio and moniika authored Oct 7, 2021
1 parent ca61d8c commit 2b1f33c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down

0 comments on commit 2b1f33c

Please sign in to comment.