uday-rana / codeshift

A command-line tool that translates source code files into a chosen programming language.
MIT License
5 stars 4 forks source link

Reduce scope of `response` variable #33

Closed uday-rana closed 4 days ago

uday-rana commented 5 days ago

Is your feature request related to a problem? Please describe. In src/index.js, response is initialized outside the scope it is used in and it's scope could be reduced.

let response = "";
...
if (outputFilePath) {
    for await (const chunk of responseStream) {
      response += chunk.choices[0]?.delta?.content || "";
      ...
    }
    fs.writeFile(outputFilePath, `${response}`);
  }

Describe the solution you'd like

if (outputFilePath) {
  let response = "";
  for await (const chunk of responseStream) {
    response += chunk.choices[0]?.delta?.content || "";
      ...
    }
    fs.writeFile(outputFilePath, `${response}`);
  }

Describe alternatives you've considered N/A

Additional context N/A

uday-rana commented 4 days ago

Closed by 8862e87