Skip to content

Commit

Permalink
Restore node v0.10.x v0.8.x compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Oct 8, 2015
1 parent bd43433 commit ea1cd01
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function connect(opts) {
// Password
if (password) {
if (password.length) {
length += Buffer.byteLength(password) + 2
length += byteLength(password) + 2
} else {
throw new Error('Invalid password')
}
Expand Down Expand Up @@ -605,4 +605,12 @@ function writeStringOrBuffer(buffer, pos, toWrite) {
return written
}

function byteLength(bufOrString) {
if (Buffer.isBuffer(bufOrString)) {
return bufOrString.length
} else {
return Buffer.byteLength(bufOrString)
}
}

module.exports = generate

0 comments on commit ea1cd01

Please sign in to comment.