In general there’s a balance to be struck between too few files and too many depending on the complexity of your code, but I can think of a few reasons you might want things to be split out for this project. One example would be to split initializing the mastodon client to its own file, then when you’re reading code that uses the client you don’t have to think about how the client was initialized.
You’re right that it can be confusing when tightly coupled code is split between a bunch of files; to use your example it’d probably be cleaner to write petgrabber.ts as an independent function that returns a result, then have a ‘post to mastodon’ function that takes generic arguments, and call them both from the main file, taking the results from the petgrabber function, formatting them and passing them to your post to mastodon function.
In general there’s a balance to be struck between too few files and too many depending on the complexity of your code, but I can think of a few reasons you might want things to be split out for this project. One example would be to split initializing the mastodon client to its own file, then when you’re reading code that uses the client you don’t have to think about how the client was initialized.
You’re right that it can be confusing when tightly coupled code is split between a bunch of files; to use your example it’d probably be cleaner to write petgrabber.ts as an independent function that returns a result, then have a ‘post to mastodon’ function that takes generic arguments, and call them both from the main file, taking the results from the petgrabber function, formatting them and passing them to your post to mastodon function.