Skip to content

Commit

Permalink
Change buffer[] to buffer.set()/get()
Browse files Browse the repository at this point in the history
for it to work both in node.js and browserify
  • Loading branch information
qjack committed Dec 4, 2012
1 parent 100925a commit b56b8b5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/mimelib.js
Expand Up @@ -188,11 +188,11 @@ module.exports.mimeFunctions = {
result = "";

for(var i=0, len = buffer.length; i<len; i++){
if(checkRanges(buffer[i], ranges)){
result += String.fromCharCode(buffer[i]);
if(checkRanges(buffer.get(i), ranges)){
result += String.fromCharCode(buffer.get(i));
continue;
}
result += "="+(buffer[i]<0x10?"0":"")+buffer[i].toString(16).toUpperCase();
result += "="+(buffer.get(i)<0x10?"0":"")+buffer.get(i).toString(16).toUpperCase();
}

return result;
Expand All @@ -212,11 +212,11 @@ module.exports.mimeFunctions = {
for(var i=0, len = str.length; i<len; i++){
chr = str.charAt(i);
if(chr == "=" && (hex = str.substr(i+1, 2)) && /[\da-fA-F]{2}/.test(hex)){
buffer[bufferPos++] = parseInt(hex, 16);
buffer.set(bufferPos++, parseInt(hex, 16));
i+=2;
continue;
}
buffer[bufferPos++] = chr.charCodeAt(0);
buffer.set(bufferPos++, chr.charCodeAt(0));
}

if(fromCharset.toUpperCase().trim() == "BINARY"){
Expand Down

0 comments on commit b56b8b5

Please sign in to comment.