| 9 | * Note: class is exported for typedoc |
| 10 | */ |
| 11 | export class Registry { |
| 12 | constructor() { |
| 13 | this.controllers = new TypedRegistry(DatasetController, 'datasets', true); |
| 14 | this.elements = new TypedRegistry(Element, 'elements'); |
| 15 | this.plugins = new TypedRegistry(Object, 'plugins'); |
| 16 | this.scales = new TypedRegistry(Scale, 'scales'); |
| 17 | // Order is important, Scale has Element in prototype chain, |
| 18 | // so Scales must be before Elements. Plugins are a fallback, so not listed here. |
| 19 | this._typedRegistries = [this.controllers, this.scales, this.elements]; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @param {...any} args |
| 24 | */ |
| 25 | add(...args) { |
| 26 | this._each('register', args); |
| 27 | } |
| 28 | |
| 29 | remove(...args) { |
| 30 | this._each('unregister', args); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @param {...typeof DatasetController} args |
| 35 | */ |
| 36 | addControllers(...args) { |
| 37 | this._each('register', args, this.controllers); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @param {...typeof Element} args |
| 42 | */ |
| 43 | addElements(...args) { |
| 44 | this._each('register', args, this.elements); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @param {...any} args |
| 49 | */ |
| 50 | addPlugins(...args) { |
| 51 | this._each('register', args, this.plugins); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @param {...typeof Scale} args |
| 56 | */ |
| 57 | addScales(...args) { |
| 58 | this._each('register', args, this.scales); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @param {string} id |
| 63 | * @returns {typeof DatasetController} |
| 64 | */ |
| 65 | getController(id) { |
| 66 | return this._get(id, this.controllers, 'controller'); |
| 67 | } |
| 68 |
nothing calls this directly
no outgoing calls
no test coverage detected