diff --git a/index.js b/index.js index 3b268222..8aa80912 100644 --- a/index.js +++ b/index.js @@ -228,7 +228,12 @@ function fromString (that, string, encoding) { var length = byteLength(string, encoding) | 0 that = createBuffer(that, length) - that.write(string, encoding) + var actual = that.write(string, encoding) + + if (actual !== length) { + that = that.slice(0, actual) + } + return that }