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

addBook handler #29

Open
m4v15 opened this issue Mar 31, 2017 · 6 comments
Open

addBook handler #29

m4v15 opened this issue Mar 31, 2017 · 6 comments
Labels

Comments

@m4v15
Copy link
Member

m4v15 commented Mar 31, 2017

Why do you create an empty array here and then push to it here and then have to unbuffer it all here.

Instead I'm pretty sure it works (I just tested it I think) if you do

let body =''
...
body += chunk

and then you don't need to do the .toString() stuff, as I think when you do the += it auto converts or something

@mattlub
Copy link
Member

mattlub commented Mar 31, 2017

mmm, was just lifted from https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/#request-body
So could be better practice, but I don't really know why and I do agree with you

@jwld jwld assigned jwld and unassigned jwld Mar 31, 2017
@jwld jwld added the wontfix label Mar 31, 2017
@mattlub
Copy link
Member

mattlub commented Mar 31, 2017

maybe it's better because you only perform a concatenation once instead of adding to a string variable again and again. (?)

@mattlub
Copy link
Member

mattlub commented Mar 31, 2017

we'll keep it 😄

@m4v15
Copy link
Member Author

m4v15 commented Mar 31, 2017

But why is it better to add to an array variable over and over again but not a string (data.push())

@m4v15
Copy link
Member Author

m4v15 commented Mar 31, 2017

But yeah I don't know what is better, your way is more explicit as my way does the conversion at the += automatically

@mattlub
Copy link
Member

mattlub commented Mar 31, 2017

any thoughts @des-des

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants