object-assign.ts 536 B

123456789
  1. // Object.assign (heap fix): a free function that mutates its target in place, copying
  2. // each source's props. `Object.assign(target, { f: secret })` makes target.f observe
  3. // secret; the reader ask interpolates target.f.
  4. // Expected: source -> ask#1, ask#1 -> ask#2 (secret through the assigned field), ask#2 -> sink.
  5. const target: { f: string } = { f: "" };
  6. const secret = await agent("writer").ask<string>("secret");
  7. Object.assign(target, { f: secret });
  8. const out = await agent("reader").ask<string>(`use ${target.f}`);
  9. return out;