From: Daniel Cousens Date: Wed, 28 May 2014 11:28:01 +0000 (+1000) Subject: use modulus of 256 not writeInt8 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=334e02f7cb17108240b086a7ec308f3cc82b5db2;p=buffer.git use modulus of 256 not writeInt8 --- diff --git a/index.js b/index.js index a4ba764..31539c5 100644 --- a/index.js +++ b/index.js @@ -94,10 +94,7 @@ function Buffer (subject, encoding, noZero) { if (Buffer.isBuffer(subject)) buf[i] = subject.readUInt8(i) else { - if (subject[i] < 0) - buf[i] = subject[i] + 256 - else - buf[i] = subject[i] + buf[i] = ((subject[i] % 256) + 256) % 256 } } } else if (type === 'string') {