buffer: refactor redeclared variables
A handful of variable declarations in lib/buffer.js
redeclare the same
variable in the same scope. This change removes each redeclaration by
switching to const
, switching to let
, or explicitly hoisting the
var
declaration.