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

Class Construct

src/construct.ts:530–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected