Permalink
Browse files

support older versions of node

  • Loading branch information...
1 parent db4b32e commit 5086daf414a1ee3006916659f7c4f095a7a692da @eleith committed Jul 2, 2012
Showing with 8 additions and 3 deletions.
  1. +1 −1 package.json
  2. +7 −2 smtp/message.js
View
@@ -17,7 +17,7 @@
"mailparser": "0.2.27",
"iconv": "1.1.3"
},
- "dependencies":
+ "optionalDependencies":
{
"buffertools" : ">= 1.1.0"
},
View
@@ -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.
@@ -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 = "";
@@ -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;

0 comments on commit 5086daf

Please sign in to comment.