Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buildmail

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buildmail - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

10

package.json
{
"name": "buildmail",
"version": "0.1.0",
"version": "0.1.1",
"description": "buildmail is a low level rfc2822 message composer. Define your own mime tree, no magic included.",

@@ -23,3 +23,4 @@ "author": "Andris Reinman <andris@kreata.ee>",

"libbase64": "^0.1.0",
"libqp": "^0.1.1"
"libqp": "^0.1.1",
"hyperquest": "^0.3.0"
},

@@ -31,5 +32,4 @@ "devDependencies": {

"grunt-mocha-test": "~0.10.0",
"sinon": "^1.9.0",
"slow-stream": "0.0.4"
"sinon": "^1.9.0"
}
}
}

@@ -289,4 +289,9 @@ # buildmail

* **body** - *String|Buffer|Stream* body content
* **body** - *String|Buffer|Stream|Object* body content
If the value is an object, it should include one of the following properties
* **path** - path to a file that will be used as the content
* **href** - URL that will be used as the content
**Example**

@@ -293,0 +298,0 @@

@@ -10,2 +10,4 @@ 'use strict';

var PassThrough = stream.PassThrough;
var fs = require('fs');
var hyperquest = require('hyperquest');

@@ -491,2 +493,3 @@ module.exports = MimeNode;

var contentStream;
var localStream;

@@ -519,24 +522,16 @@ // pushes node content

if (typeof _self.content.pipe === 'function') {
_self.content.pipe(contentStream);
} else {
contentStream.write(_self.content);
contentStream.end();
}
localStream = _self._getStream(_self.content);
localStream.pipe(contentStream);
return;
} else {
if (_self._isFlowedContent) {
outputStream.write(libmime.encodeFlowed(_self.content));
localStream = _self._getStream(libmime.encodeFlowed(_self.content));
} else {
if (typeof _self.content.pipe === 'function') {
_self.content.pipe(outputStream, {
end: false
});
_self.content.once('end', finalize);
return;
} else {
outputStream.write(_self.content);
}
localStream = _self._getStream(_self.content);
}
return setImmediate(finalize);
localStream.pipe(outputStream, {
end: false
});
localStream.once('end', finalize);
return;
}

@@ -577,2 +572,23 @@ } else {

/**
* Detects and returns handle to a stream related with the content.
*
* @param {Mixed} content Node content
* @returns {Object} Stream object
*/
MimeNode.prototype._getStream = function(content) {
var contentStream;
if (typeof content.pipe === 'function') {
return content;
} else if (content && typeof content.path === 'string') {
return fs.createReadStream(content.path);
} else if (content && typeof content.href === 'string') {
return hyperquest(content.href);
} else {
contentStream = new PassThrough();
contentStream.end(content || '');
return contentStream;
}
};
/**
* Generates and returns SMTP envelope with the sender address and a list of recipients addresses

@@ -579,0 +595,0 @@ *

@@ -6,2 +6,3 @@ 'use strict';

var Buildmail = require('../src/buildmail');
var http = require('http');

@@ -713,2 +714,45 @@ var expect = chai.expect;

});
describe('HTTP streaming', function() {
var port = 10337;
var server;
beforeEach(function(done) {
server = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain'
});
var data = new Buffer(new Array(1024 + 1).join('ä'), 'utf-8');
var i = 0;
var sendByte = function() {
if (i >= data.length) {
return res.end();
}
res.write(new Buffer([data[i++]]));
setImmediate(sendByte);
};
sendByte();
});
server.listen(port, done);
});
afterEach(function(done) {
server.close(done);
});
it('should pipe URL as an attachment', function(done) {
var mb = new Buildmail('text/plain').
setContent({
href: 'http://localhost:' + port
});
mb.build(function(err, msg) {
msg = msg.toString();
expect(/^=C3=A4/m.test(msg)).to.be.true;
done();
});
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc