nlkitai / nlux

The π—£π—Όπ˜„π—²π—Ώπ—³π˜‚π—Ή Conversational AI JavaScript Library πŸ’¬ β€”Β UI for any LLM, supporting LangChain / HuggingFace / Vercel AI, and more 🧑 React, Next.js, and plain JavaScript ⭐️
https://docs.nlkit.com/nlux
Other
937 stars 48 forks source link

Simplify control flow in sample code. #79

Closed mattparlane closed 3 weeks ago

mattparlane commented 3 weeks ago

eslint's default rule set includes the no-continue rule, which disallows any use of the continue keyword. This keyword is used in the project's sample code.

no-continue rule eslint's default rule set

This PR removes the continue keyword, and removes the doneReading variable from most of the sample code, and is functionally equivalent.

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
nlux-docs βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 10, 2024 1:21am
salmenus commented 3 weeks ago

Thank you for this contribution @mattparlane Merging it

Feel free to apply the same change to the main code base. I'm sure you'll find some continue statements

mattparlane commented 3 weeks ago

Thanks for accepting. The thing is that I don't actually agree that the continue keyword is a problem, the only reason I thought the sample code should change is that the rule is in eslint's default config, so anyone using eslint in their project would have errors if they copied the sample code (like I did). If you're not using eslint in nlux (or you have that rule disabled), then it's not a problem, so I don't think anything else needs to change.

salmenus commented 3 weeks ago

Fair enough. We're using eslint on the main codebase, but with different config.

Thanks for fixing it for examples to match default eslint config.