From: James Halliday Date: Wed, 20 Mar 2013 19:07:09 +0000 (-0700) Subject: fill with 0s for Buffer(num) X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=349bad9ea3b2eea0acb0317778311c3019d9ef95;p=buffer.git fill with 0s for Buffer(num) --- diff --git a/index.js b/index.js index 7e61f58..aa62bdc 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ function Buffer(subject, encoding, offset) { if (!(this instanceof Buffer)) { return new Buffer(subject, encoding, offset); } + this.parent = this; var type; @@ -46,6 +47,10 @@ function Buffer(subject, encoding, offset) { } else if (type == 'string') { // We are a string this.length = this.write(subject, 0, encoding); + } else if (type === 'number') { + for (var i = 0; i < this.length; i++) { + this[i] = 0; + } } } }