-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcdeditor.js
42 lines (35 loc) · 885 Bytes
/
bcdeditor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2024 Joseph P Medley
'use strict';
const { BCDBuilder } = require('./bcdbuilder.js');
class JSONError extends Error {
constructor(message='', fileName='', lineNumber='') {
super(message, fileName, lineNumber);
}
}
class _BCDEditor {
constructor(source) {
this._tree;
this._validateSourceMakeTree(source);
}
_validateSourceMakeTree(source) {
switch (source.constructor.name) {
case "InterfaceData":
const bcdBuilder = new BCDBuilder(source, 'api', {});
this._tree = bcdBuilder.getBCDObject();
break;
case "Object":
this._tree = source;
break;
case "String":
this._tree = JSON.parse(source);
break;
default:
console.log(source.constructor.name);
break;
}
}
get tree() {
return this._tree;
}
}
module.exports.BCDEditor = _BCDEditor;