AlexLakatos / computer-puns

A hand-picked selection of the worst computer puns, really cringe-worthy stuff.
https://puns.dev
GNU General Public License v3.0
100 stars 58 forks source link

Add search functionality #97

Closed AlexStormwood closed 3 years ago

AlexStormwood commented 3 years ago

Added a "search()" function to the package, including documentation & tests.

As an IT teacher, this allows me to refer my students to this package for usage in activities like "make a React app that processes user input to return data to the page".

The search function can also kinda search for multiple keywords, as long as they're space-separated. Not sure if that is worth moving to a separate function though. It doesn't disrupt the search functionality either way.

Also, happy to change how the function handles a "no results found" situation. Currently just throwing an error - not sure if you'd prefer that or a different way to handle errors in this package.

Happy Hacktoberfest! 🎉

github-actions[bot] commented 3 years ago

Thank you for submitting a PR! Here's a pun, while you wait for me to review it.

Q: How do you comfort a JavaScript bug? A: You console it!

Or you can ping me on Twitter, that tends to speed up this process!

AlexLakatos commented 3 years ago

Thanks for the PR!

I've tried to improve the functionality a bit, and opened a PR against your original repo: https://github.com/AlexHolderDeveloper/computer-puns/pull/1

The PR changes the search functionality to accept a list of keywords as an array instead of space-separated values(because this way I can search for multi-word keywords), and to return an empty list instead of throwing an error (because technically not finding a keyword in a list is not an error). With that merged, I think I'm happy to merge it into the main repo, and push a new release to npm.

AlexStormwood commented 3 years ago

Awesome, thankyou for the edits there! All merged into my fork and ready for pulling back into your repo.

AlexLakatos commented 3 years ago

Great! Thanks for this functionality, I think it's really useful!