Open Danielv123 opened 6 years ago
That's also a good idea. I'll definitely look into that if everything goes smoothly and if I've got the time for it. I wonder if making a command line progress bar would be possible. Kind of like the package managers on Linux if you know what I'm talking about. I'm not sure if that would be possible and if that would also work on non-unix systems though. Yeah, actually, npm has a progress bar too, so maybe it'll work. Anyway, I'll try to find a way to show the progress.
I recommend either making showing the progress bar disabled by default and enabled with an options object, or allowing the users of the library to sort it out for themselves based on the data you are returning. When libraries start doing user facing stuff, confusion happens.
Yeah, I get that. Maybe a way to trigger some kind of event when the download progresses would be nice.
But adding a callback as an additional argument seems a little silly in my opinion, but it wouldn't be a big deal to implement either and it wouldn't affect anything if it's an optional argument. I would still recommend using the promise, it's basically the same, but instead of adding the callback as an argument, you would put your callback inside then
. Like this: myFunction.then(callback)
. But that still doesn't give you the ability to view the progress though... I wonder if there would be a nice way to do this with promises... I'll see if I can find something, and if I have to, I'll use a callback for the progress. I also don't know why I was talking about a progress bar in the command line since this is just a backend and not a cli application. I'm sorry, I'm getting tired already.
Maybe I'll use this: https://www.npmjs.com/package/progress-promise ?
Yeah, that sounds good. You will have to decide whether to only return key stats, some pre parsed format or just the data chunk you have recieved allowing for the user of your library to track the statistics they want.
I'm apparently also using request-progress for individual mod downloads, but I never really used the feature to get the progress. I should be able to give a lot of information like total download size, percentage, time remaining, ... I can easily calculate the total percentage of all the mods you're downloading by dividing each individual mod progress percentage by the total amount of mods and adding the results. But first I need to implement #6 which seems to be harder than expected, because it requires some web scraping for authentication, but I still haven't got it to work properly.
Either the object you get from request-progress or just the plain data events returned from a normal https.get. Either way, something to show progress would be nice as I have had some quite large downloads (a few 70mb mods...)
Not sure if it would be more useful to have it as an optional function parameter, or somehow an event returned (not sure if you can do that in addition to the promise)
This will be even more important if you implement #6