Skip to content
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

Merged
merged 8 commits into from
Oct 11, 2018
Merged

Native promises #26

merged 8 commits into from
Oct 11, 2018

Conversation

tannerbaum
Copy link
Contributor

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

@tannerbaum tannerbaum requested review from meaku and antosan July 19, 2018 13:39
Copy link
Member

@meaku meaku left a 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 Show resolved Hide resolved
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 {
Copy link
Member

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) => {
Copy link
Member

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"
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe add 10 :)

@tannerbaum
Copy link
Contributor Author

  • Test with WWW dev using npm link

Copy link
Contributor

@antosan antosan left a 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.

lib/request.js Outdated Show resolved Hide resolved
lib/request.js Outdated Show resolved Hide resolved
@tannerbaum
Copy link
Contributor Author

@antosan Can you take another look?

@tannerbaum tannerbaum mentioned this pull request Oct 10, 2018
@antosan antosan merged commit 44ba27d into master Oct 11, 2018
@antosan antosan deleted the native-promises branch October 11, 2018 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants