-
Notifications
You must be signed in to change notification settings - Fork 13
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
Native promises #26
Native promises #26
Conversation
BREAKING CHANGE: updates node version to v8.0.0
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.
Looks good! Good to merge after the changes and please add the breaking change to the changelog/readme. :)
lib/request.js
Outdated
let err; | ||
|
||
if (res.statusCode >= 300) { | ||
err = new Error("Response with status code: " + res.statusCode); | ||
err.statusCode = res.statusCode; | ||
throw err; | ||
reject(err); | ||
} else { |
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 personally prefer something like the following to reduce braces, but it's up to you.
if(res.statusCode >= 300){
reject(err);
return;
}
resolve(body);
lib/request.js
Outdated
return nodefn.call(doRequest, config) | ||
.spread((res, body) => { | ||
return new Promise((resolve, reject) => { | ||
doRequest(config, (res, body) => { |
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 was wondering if there is an error argument as well? What happens if request messes up really badly and won't even return a valid res
at all?
.travis.yml
Outdated
@@ -1,6 +1,8 @@ | |||
language: node_js | |||
node_js: | |||
- "6" |
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.
We have to remove version 6 here.
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.
And maybe add 10 :)
|
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.
👍 Good to merge after the changes. As meaku mentioned, please add the breaking change to the CHANGELOG (regarding the new node version) and bump up the version to 0.5.0
before merging.
@antosan Can you take another look? |
implements native promises (both explicitly and with promisify). Refactors to remove When.js and lodash. Updates node version to v8.0.0. Addresses issue #13