]> zoso.dev Git - buffer.git/commitdiff
use modulus of 256 not writeInt8
authorDaniel Cousens <github@dcousens.com>
Wed, 28 May 2014 11:28:01 +0000 (21:28 +1000)
committerDaniel Cousens <github@dcousens.com>
Wed, 28 May 2014 11:41:24 +0000 (21:41 +1000)
index.js

index a4ba7647e5c9c1e579f26de88993955d94eefbed..31539c56add7401e245dcaaa1630745105f875d1 100644 (file)
--- 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') {