Skip to content

Commit

Permalink
support older versions of node
Browse files Browse the repository at this point in the history
  • Loading branch information
eleith committed Jul 2, 2012
1 parent db4b32e commit 5086daf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
"mailparser": "0.2.27",
"iconv": "1.1.3"
},
"dependencies":
"optionalDependencies":
{
"buffertools" : ">= 1.1.0"
},
Expand Down
9 changes: 7 additions & 2 deletions smtp/message.js
Expand Up @@ -2,7 +2,6 @@ var stream = require('stream');
var util = require('util');
var fs = require('fs');
var os = require('os');
var buffertools= require('buffertools');
var path = require('path');
var CRLF = "\r\n";
var MIMECHUNK = 76; // MIME standard wants 76 char chunks when sending out.
Expand All @@ -11,6 +10,12 @@ var MIME64CHUNK= MIMECHUNK * 6; // meets both base64 and mime divisibility
var BUFFERSIZE = MIMECHUNK*24*7; // size of the message stream buffer
var counter = 0;

// support for nodejs without Buffer.concat native function
if(!Buffer.concat)
{
require("bufferjs/concat");
}

var generate_boundary = function()
{
var text = "";
Expand Down Expand Up @@ -344,7 +349,7 @@ var MessageStream = function(message)
// do we have bytes from a previous stream data event?
if(previous)
{
var buffer2 = buffertools.concat(previous, buffer);
var buffer2 = Buffer.concat([previous, buffer]);
previous = null; // free up the buffer
buffer = null; // free up the buffer
buffer = buffer2;
Expand Down

0 comments on commit 5086daf

Please sign in to comment.