2

It's not recommended to send a lot of bytes between processes in Node, proven here: https://stackoverflow.com/a/27327402/2440515

Node first JSON.stringify the object. How can I actually measure a size of a string to avoid transferring to much data? Is length equal to bytes?

3
  • Take in mind, it looks like on that graph that smaller packets do better per byte. Commented Dec 7, 2014 at 18:54
  • possible duplicate of String length in bytes in JavaScript Commented Dec 7, 2014 at 19:07
  • The V8 engine uses UC16 (two bytes per string character) internally, but it may be converting to UTF-8 before transferring between processes since that is the more common interchange format. It would take some more specifics about how you're communicating between the two processes to look into the issue in more detail. Commented Dec 7, 2014 at 19:20

1 Answer 1

2

The easiest way is to use Buffer's helper functions.

Buffer.byteLength(str)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.