MCPcopy Create free account
hub / github.com/aws/constructs / constructor

Method constructor

src/construct.ts:82–100  ·  view source on GitHub ↗
(private readonly host: Construct, scope: IConstruct, id: string)

Source from the content-addressed store, hash-verified

80
81
82 public constructor(private readonly host: Construct, scope: IConstruct, id: string) {
83 id = id ?? ''; // if undefined, convert to empty string
84
85 this.id = sanitizeId(id);
86 this.scope = scope;
87
88 if (scope && !this.id) {
89 throw new Error('Only root constructs may have an empty ID');
90 }
91
92 if (scope) {
93 scope.node.addChild(host, this.id);
94 this.path = scope.node.path ? `${scope.node.path}${Node.PATH_SEP}${this.id}` : this.id;
95 this._scopes = [...scope.node._scopes, this.host];
96 } else {
97 this.path = this.id;
98 this._scopes = [this.host];
99 }
100 }
101
102 /**
103 * All parent scopes of this construct.

Callers

nothing calls this directly

Calls 2

sanitizeIdFunction · 0.85
addChildMethod · 0.80

Tested by

no test coverage detected