| 501 | * another construct. |
| 502 | */ |
| 503 | export class Construct implements IConstruct { |
| 504 | /** |
| 505 | * Checks if `x` is a construct. |
| 506 | * |
| 507 | * Use this method instead of `instanceof` to properly detect `Construct` |
| 508 | * instances, even when the construct library is symlinked. |
| 509 | * |
| 510 | * Explanation: in JavaScript, multiple copies of the `constructs` library on |
| 511 | * disk are seen as independent, completely different libraries. As a |
| 512 | * consequence, the class `Construct` in each copy of the `constructs` library |
| 513 | * is seen as a different class, and an instance of one class will not test as |
| 514 | * `instanceof` the other class. `npm install` will not create installations |
| 515 | * like this, but users may manually symlink construct libraries together or |
| 516 | * use a monorepo tool: in those cases, multiple copies of the `constructs` |
| 517 | * library can be accidentally installed, and `instanceof` will behave |
| 518 | * unpredictably. It is safest to avoid using `instanceof`, and using |
| 519 | * this type-testing method instead. |
| 520 | * |
| 521 | * @returns true if `x` is an object created from a class which extends `Construct`. |
| 522 | * @param x Any object |
| 523 | */ |
| 524 | public static isConstruct(x: any): x is Construct { |
| 525 | return x && typeof x === 'object' && x[CONSTRUCT_SYM]; |
| 526 | } |
| 527 | |
| 528 | /** |
| 529 | * The tree node. |
| 530 | */ |
| 531 | public readonly node: Node; |
| 532 | |
| 533 | /** |
| 534 | * Creates a new construct node. |
| 535 | * |
| 536 | * @param scope The scope in which to define this construct |
| 537 | * @param id The scoped construct ID. Must be unique amongst siblings. If |
| 538 | * the ID includes a path separator (`/`), then it will be replaced by double |
| 539 | * dash `--`. |
| 540 | */ |
| 541 | constructor(scope: Construct, id: string) { |
| 542 | this.node = new Node(this, scope, id); |
| 543 | |
| 544 | // implement IDependable privately |
| 545 | Dependable.implement(this, { |
| 546 | dependencyRoots: [this], |
| 547 | }); |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Applies one or more mixins to this construct. |
| 552 | * |
| 553 | * Mixins are applied in order. The list of constructs is captured at the |
| 554 | * start of the call, so constructs added by a mixin will not be visited. |
| 555 | * Use multiple `with()` calls if subsequent mixins should apply to added |
| 556 | * constructs. |
| 557 | * |
| 558 | * @param mixins The mixins to apply |
| 559 | * @returns This construct for chaining |
| 560 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…