Skip to content

Commit

Permalink
Add comment on Proxy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavohenke committed Dec 8, 2023
1 parent bdbbe6a commit 0c64306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/flow-control/kill-on-signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export class KillOnSignal implements FlowController {
return { ...exitInfo, exitCode };
}),
);
// Return a proxy so that mutations happen on the original Command object.
// If either `Object.assign()` or `Object.create()` were used, it'd be hard to
// reflect the mutations on Command objects referenced by previous flow controllers.
return new Proxy(command, {
get(target, prop: keyof Command) {
return prop === 'close' ? closeStream : target[prop];
Expand Down
3 changes: 3 additions & 0 deletions src/flow-control/restart-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class RestartProcess implements FlowController {
}),
);

// Return a proxy so that mutations happen on the original Command object.
// If either `Object.assign()` or `Object.create()` were used, it'd be hard to
// reflect the mutations on Command objects referenced by previous flow controllers.
return new Proxy(command, {
get(target, prop: keyof Command) {
return prop === 'close' ? closeStream : target[prop];
Expand Down

0 comments on commit 0c64306

Please sign in to comment.