question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How i can manually convert to buffer?

See original GitHub issue

If i pass buffer: true, I have no problem, it works.

The problem is that i don’t want all requests to be a buffer, so i removed the property and instead i’m doing Buffer.from(ctx.request.body) but i’m getting a different buffer instead.

Any idea why?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
felixsanzcommented, Dec 31, 2016

You can’t send a normal array over the wire 😛 An array is not a data structure outside of JS.

The Uint8Array is a representation of the binary data (byte by byte). It’s a buffer basically.

I’ll try to create a test case tomorrow but now i have to run! 🎉

0reactions
felixsanzcommented, Jan 3, 2017

But it should be:

empty -> no encoding, and works with buffer. utf8 -> utf8 etc -> etc

So basically i need the case where empty value or no value, doesn’t add any encoding.

And right now, the empty case will trigger the default encoding of utf8.

So… removing the default value will break compatibility since people usually don’t specify utf8 manually, they omit the value and make use of the default, which is utf8. This people will now get a buffer instead of the expected utf8 string. Thats why i claim that it will break compatibility but i may be wrong

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to convert a String to Buffer and vice versa in Node.js
To convert a Buffer to a String, you can use the toString() in the Buffer object. // buffer const str = "Hey. this...
Read more >
Convert Node.js Buffer to String: An Easy-To-Follow Guide
Learn how to convert Node.js Buffer to string by using this simple guide with straightforward instructions.
Read more >
Node.js: How to read a stream into a buffer? - Stack Overflow
You can convert your readable stream to a buffer and integrate it in your code in ... Its easy to do manually, or...
Read more >
How to Use Buffers in Node.js
The Buffer class in Node.js is designed to handle raw binary data. Each buffer corresponds to some raw memory allocated outside V8.
Read more >
AVSpeechSynthesizer buffer conversion, write format bug?
When I apply it to the speech buffer, I get back noise. When I attempt to manually convert format and to stereo with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found