Skip to content

Commit ab12443

Browse files
authoredSep 23, 2024
refactor: reuse createTextEvent() in createAckEvent() (copilot-extensions#109)
### What are you trying to accomplish? A refactoring opportunity: after reading `createAckEvent()` and `createTextEvent`'s definitions, I noticed that the only difference was that the former passes in an empty string for its content. ### What approach did you choose and why? I chose to update the body to use `createTextEvent()` directly, passing an empty string for its `message` argument. Ran tests locally and in CI to verify this works 👍 ### What should reviewers focus on? Nothing I haven't mentioned 😉
1 parent ecf55b9 commit ab12443

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed
 

‎lib/response.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22

33
/** @type {import('..').CreateAckEventInterface} */
44
export function createAckEvent() {
5-
const data = {
6-
choices: [
7-
{
8-
index: 0,
9-
delta: { content: ``, role: "assistant" },
10-
},
11-
],
12-
};
13-
return `data: ${JSON.stringify(data)}\n\n`;
5+
return createTextEvent("");
146
}
157

168
/** @type {import('..').CreateTextEventInterface} */

0 commit comments

Comments
 (0)
Failed to load comments.