-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using generators internally + refactoring flow #23
Conversation
In preparation to add more async logic here (such as working with the cache) I've decided to change how this module is structured internally. Primarilly, it now uses generators instead of normal callbacks. I'm using `unyield` so the API _technically_ hasn't changed, although it does now require the `--harmony-generators` flag since it is using generators under the hood. I've also removed `options.retries`, as that is an internal detail that doesn't really need to be configurable at this time.
*/ | ||
|
||
function* get(token, parts, attempts) { | ||
var url = 'https://api.github.com/' + path.join.apply(path, parts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will path.join()
do weird stuff on windows (e.g. "https://api.github.com/foo\\bar\\")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha possibly related? duojs/duo#481
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh snap... you're probably right. We should use url.resolve
instead anyways. Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is directly related to that issue. That's probably somewhere in duo-pack
, if I were to guess.
But it's still a good idea here to use url.resolve()
w/o path.join()
at all.
lgtm :) |
works for me! |
Using generators internally + refactoring flow
In preparation to add more async logic here (such as working with the cache) I've decided to change how this module is structured internally. Primarilly, it now uses generators instead of normal callbacks.
I'm using
unyield
so the API technically hasn't changed, although it does now require the--harmony-generators
flag since it is using generators under the hood. I've also removedoptions.retries
, as that is an internal detail that doesn't really need to be configurable at this time.The main changes here:
index.js
tolib/resolve.js
unyield
to retain same high-level APIdebug
output more consistent and easy to follow even in parallellib/github.js
)I'm going to start working on a branch right away that leverages the new cache to store the results of Github API calls. (which should cut down on the number of API calls counting towards the limit)