( namespace: Binding, module: SourceModule, name: string, held: Held, exports: HeldExport[] )
| 5467 | // where a namespace's reads of an export may write it, adding the names |
| 5468 | // what holds it next is exported as |
| 5469 | private namespaceWriteOf( |
| 5470 | namespace: Binding, |
| 5471 | module: SourceModule, |
| 5472 | name: string, |
| 5473 | held: Held, |
| 5474 | exports: HeldExport[] |
| 5475 | ): Node | undefined { |
| 5476 | if (namespace.exportNames.length) return this.escape(namespace.id) |
| 5477 | const outer = this.holdings |
| 5478 | const holdings: Holding[] = (this.holdings = []) |
| 5479 | try { |
| 5480 | for (const reference of namespace.references) { |
| 5481 | const [operand, parent] = operatorOf(reference.id) |
| 5482 | const read = |
| 5483 | parent?.type === "MemberExpression" && parent.object === operand ? |
| 5484 | memberNameOf(parent) |
| 5485 | : undefined |
| 5486 | // e.g. `ns.other`, another export |
| 5487 | if (typeof read === "string" && read !== name) continue |
| 5488 | // `ns.name` is the export itself, and `ns` holds it as a member |
| 5489 | const write = |
| 5490 | read === name ? |
| 5491 | this.mayWriteFrom(parent!, module, held) |
| 5492 | : this.mayWriteFrom(reference.id, module, wrapperOf(held)) |
| 5493 | if (write) return write |
| 5494 | } |
| 5495 | } finally { |
| 5496 | this.holdings = outer |
| 5497 | } |
| 5498 | for (const holding of holdings) { |
| 5499 | if ("binding" in holding) { |
| 5500 | exports.push( |
| 5501 | ...this.exportsHolding(holding.binding, holding.module, holding.held) |
| 5502 | ) |
| 5503 | } else exports.push([holding.module, holding.name, holding.held]) |
| 5504 | } |
| 5505 | } |
| 5506 | |
| 5507 | // the names a value is exported as: a binding's own, and those of each |
| 5508 | // binding or default export holding it next |
no test coverage detected