Befor generating

This commit is contained in:
marys
2026-06-01 13:17:37 +02:00
parent 3383f4bf4a
commit 1aa1b5f625
6756 changed files with 649946 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
const ParserError = require('../errors/parser-error');
/**
* Implements common functionality for all the models.
* @class
* @alias module:@asyncapi/parser#Base
* @returns {Base}
*/
class Base {
constructor(json) {
if (json === undefined || json === null) throw new ParserError(`Invalid JSON to instantiate the ${this.constructor.name} object.`);
this._json = json;
}
/**
* @param {string} [key] A key to retrieve from the JSON object.
* @returns {any}
*/
json(key) {
if (key === undefined) return this._json;
if (!this._json) return;
return this._json[String(key)];
}
}
module.exports = Base;