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

Class Construct

src/construct.ts:533–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531 * another construct.
532 */
533export class Construct implements IConstruct {
534 /**
535 * Checks if `x` is a construct.
536 *
537 * Use this method instead of `instanceof` to properly detect `Construct`
538 * instances, even when the construct library is symlinked.
539 *
540 * Explanation: in JavaScript, multiple copies of the `constructs` library on
541 * disk are seen as independent, completely different libraries. As a
542 * consequence, the class `Construct` in each copy of the `constructs` library
543 * is seen as a different class, and an instance of one class will not test as
544 * `instanceof` the other class. `npm install` will not create installations
545 * like this, but users may manually symlink construct libraries together or
546 * use a monorepo tool: in those cases, multiple copies of the `constructs`
547 * library can be accidentally installed, and `instanceof` will behave
548 * unpredictably. It is safest to avoid using `instanceof`, and using
549 * this type-testing method instead.
550 *
551 * @returns true if `x` is an object created from a class which extends `Construct`.
552 * @param x Any object
553 */
554 public static isConstruct(x: any): x is Construct {
555 return x && typeof x === 'object' && x[CONSTRUCT_SYM];
556 }
557
558 /**
559 * The tree node.
560 */
561 public readonly node: Node;
562
563 /**
564 * Creates a new construct node.
565 *
566 * @param scope The scope in which to define this construct
567 * @param id The scoped construct ID. Must be unique amongst siblings. If
568 * the ID includes a path separator (`/`), then it will be replaced by double
569 * dash `--`.
570 */
571 constructor(scope: Construct, id: string) {
572 this.node = new Node(this, scope, id);
573
574 // implement IDependable privately
575 Dependable.implement(this, {
576 dependencyRoots: [this],
577 });
578 }
579
580 /**
581 * Applies one or more mixins to this construct.
582 *
583 * Mixins are applied in order. The list of constructs is captured at the
584 * start of the call, so constructs added by a mixin will not be visited.
585 * Use multiple `with()` calls if subsequent mixins should apply to added
586 * constructs.
587 *
588 * @param mixins The mixins to apply
589 * @returns This construct for chaining
590 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected