-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use native .reverse if available #5
base: master
Are you sure you want to change the base?
Conversation
can you |
idk why but tests fail ... |
// wtf.js
var a = new Buffer("00ff", 'hex')
console.log(a, a.reverse(), a)
var b = new Buffer("ff00", 'hex')
console.log(b, b.reverse(), b)
var c = new Buffer("00ff", 'hex')
console.log(c)
var d = c.slice()
console.log(d, d.reverse())
wtf is going on here o.O |
// wtf2.js
var a = new Buffer("00ff", 'hex')
console.log(a)
console.log(a.reverse())
console.log(a)
var b = new Buffer("ff00", 'hex')
console.log(b)
console.log(b.reverse())
console.log(b)
var c = new Buffer("00ff", 'hex')
console.log(c)
var d = c.slice()
console.log(d)
console.log(d.reverse())
|
oh it reverses in-place and when I console.log them together they all the same xD |
yea, moreover var a = new Buffer("00ff", 'hex')
console.log(a, Buffer.from(a).reverse())
// <Buffer 00 ff> <Buffer ff 00>
console.log(a, a.slice().reverse())
// <Buffer ff 00> <Buffer ff 00> |
ugh made a mess out of the codestyle ... |
there, with safe-buffer / Buffer.from it passes :D |
|
index.js
Outdated
if (typeof src.reverse === "function") { | ||
return Buffer.from(src).reverse() | ||
} else { | ||
var buffer = Buffer.alloc(src.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allocUnsafe
would be fine too
@calvinmetcalf this had |
haha woops |
can you try rebasing on top of master? if you have trouble with that I can do it for you |
@rubensayshi when using For the |
so it sounds like we just want this for the inplace one, which nicely wouldn't conflict with the safebuffer stuff |
No description provided.