(addon)
| 156 | |
| 157 | static _registeredAddons = new Set(); |
| 158 | static registerAddon(addon) { |
| 159 | const lifecycles = {}; |
| 160 | |
| 161 | // Don't re-register an addon. This allows addons |
| 162 | // to register dependency addons without worrying about |
| 163 | // them getting double-added. |
| 164 | if (p5._registeredAddons.has(addon)) return; |
| 165 | p5._registeredAddons.add(addon); |
| 166 | |
| 167 | addon(p5, p5.prototype, lifecycles); |
| 168 | |
| 169 | const validLifecycles = Object.keys(p5.lifecycleHooks); |
| 170 | for(const name of validLifecycles){ |
| 171 | if(typeof lifecycles[name] === 'function'){ |
| 172 | p5.lifecycleHooks[name].push(lifecycles[name]); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | static decorations = new Map(); |
| 178 | static registerDecorator(pattern, decoration){ |
no test coverage detected