This commit is contained in:
Jason 2022-02-19 00:10:57 -05:00
parent 82f5f76588
commit 2c06fed426
25 changed files with 1131 additions and 604 deletions

View file

@ -90,33 +90,4 @@ class JS extends EventEmitter {
};
};
class NodeEvent extends EventEmitter {
constructor(node, parent = null) {
super();
this._node = node;
for (let key in node) {
Object.defineProperty(this, key, {
get: () => node[key],
sel: val => node[key] = val,
});
};
this.parent = parent;
};
iterate(handler) {
for (const key in this._node) {
if (key === 'parent') continue;
if (Array.isArray(this._node[key])) {
this._node[key].forEach(entry => {
const child = new this.constructor(entry, this._node);
handler(child);
});
} else {
const child = new this.constructor(entry, this._node);
walk(this._node[key], this._node, handler);
};
};
};
};
export default JS;
export { NodeEvent };
export default JS;