source: node_modules/@swagger-api/apidom-ast/es/Node.mjs

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 804 bytes
Line 
1class Node {
2 static type = 'node';
3 type = 'node';
4 isMissing;
5 children;
6 position;
7 constructor({
8 children = [],
9 position,
10 isMissing = false
11 } = {}) {
12 this.type = this.constructor.type;
13 this.isMissing = isMissing;
14 this.children = children;
15 this.position = position;
16 }
17
18 // creates shallow clone of node
19 clone() {
20 // 1. copy has same prototype as orig
21 const copy = Object.create(Object.getPrototypeOf(this));
22
23 // 2. copy has all of orig’s properties
24 Object.getOwnPropertyNames(this) // (1)
25 .forEach(propKey => {
26 // (2)
27 const descriptor = Object.getOwnPropertyDescriptor(this, propKey); // (3)
28 // @ts-ignore
29 Object.defineProperty(copy, propKey, descriptor); // (4)
30 });
31 return copy;
32 }
33}
34export default Node;
Note: See TracBrowser for help on using the repository browser.