MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / configuration

Method configuration

src/monogatari.ts:1266–1293  ·  view source on GitHub ↗

* Get or set the configuration. * * @param {string|object} key * @param {object} object

(key?: string | Record<string, unknown>, object?: Record<string, unknown>)

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 1

triggerMethod · 0.95

Tested by

no test coverage detected