* Get or set the configuration. * * @param {string|object} key * @param {object} object
(key?: string | Record<string, unknown>, object?: Record<string, unknown>)
| 1264 | * @param {object} object |
| 1265 | */ |
| 1266 | static configuration (key?: string | Record<string, unknown>, object?: Record<string, unknown>): unknown { |
| 1267 | if (typeof key === 'string') { |
| 1268 | if (typeof object !== 'undefined') { |
| 1269 | this.trigger ('configurationElementWillUpdate'); |
| 1270 | |
| 1271 | this.trigger (`configurationElementUpdate::${key}`, { |
| 1272 | newConfiguration: object, |
| 1273 | oldConfiguration: this._configuration[key] |
| 1274 | }); |
| 1275 | |
| 1276 | if (typeof this._configuration[key] !== 'object' || this._configuration[key] === null) { |
| 1277 | this._configuration[key] = {}; |
| 1278 | } |
| 1279 | |
| 1280 | this._configuration[key] = merge (this._configuration[key] as object, object); |
| 1281 | |
| 1282 | this.trigger ('configurationElementDidUpdate'); |
| 1283 | } |
| 1284 | return this._configuration[key]; |
| 1285 | } else if (typeof key === 'object') { |
| 1286 | this.trigger ('configurationWillUpdate'); |
| 1287 | this._configuration = merge (this._configuration, object ?? {}); |
| 1288 | this.trigger ('configurationDidUpdate'); |
| 1289 | return this._configuration; |
| 1290 | } else if (typeof key === 'undefined') { |
| 1291 | return this._configuration; |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | static storage (object: string | Record<string, unknown> | null = null): unknown { |
| 1296 | if (object !== null) { |