Ionică Bizău
Ionică Bizău

Reputation: 113365

Filling a buffer with emptiness

How can I fill a buffer with emptiness?

This was working on v0.10.*:

var b = new Buffer(8192);
b.fill("");

But it just crashes without any error on v0.11.11.

I have this code:

var b = new Buffer(8192);
b.fill("");

console.log(1);

When I run it, 1 doesn't appear in output. What alternatives are to fill a buffer with emptiness?

Upvotes: 0

Views: 89

Answers (1)

brandonscript
brandonscript

Reputation: 72885

Originally I suggested new Buffer(Array(32)), but we determined b.fill(0) was a workable solution.

Upvotes: 2

Related Questions