<commit_before>var http = require('http');
var https = require('https');

module.exports = MandrillProvider;

/**
 * Creates an instance of the Mandrill email provider.
 *
 * @constructor
 * @this {MandrillProvider}
 * @param {string} apiKey API Key for the Mandrill account.
 * @param {object} [options] Additional optional configuration.
 * @param {string} [options.async=false] See 'async' field: {@link https://mandrillapp.com/api/docs/messages.html#method-send}
 * @param {string} [options.ipPool] See: {@link http://help.mandrill.com/entries/24182062}
 * @param {boolean} [options.apiSecure=true] API connection protocol - true = HTTPS, false = HTTP
 * @param {string} [options.apiHostname=mandrillapp.com] Hostname for the API connection
 * @param {number} [options.apiPort] Port for the API connection - defaults to match the protocol (HTTPS-443, HTTP-80)
 */
function MandrillProvider(apiKey, options) {
	if (typeof apiKey !== 'string') {
		throw new Error('Invalid parameters');
	}

	options = options || {};
	options.async = options.async || false;
	options.apiSecure = options.apiSecure || true;
	options.apiHostname = options.apiHostname || 'mandrillapp.com';
	options.apiPort = options.apiPort || (options.apiSecure ? 443 : 80);

	this.apiKey = apiKey;
	this.options = options;
}

/**
 * Indicates the outcome of a mail-sending attempt.
 * @callback MandrillProvider~onResult
 * @param {error} [error] A non-null value indicates failure.
 */

/**
 * Attempts to send the message through the Mandrill API.
 *
 * @this {MandrillProvider}
 * @param {Message} message The message to send.
 * @param {MandrillProvider~onResult} [callback] Notified when the attempt fails or succeeds.
 */
MandrillProvider.prototype.mail = function (message, callback) {
	var messageObj;

	// this can fail if the message is invalid
	try {
		messageObj = this._objectForMessage(message);
	} catch (error) {
		if (callback)
			callback(error);
<commit_msg>Fixed options defaults - the usual one liner doesn't work with booleans of course...<commit_after>var http = require('http');
var https = require('https');

module.exports = MandrillProvider;

/**
 * Creates an instance of the Mandrill email provider.
 *
 * @constructor
 * @this {MandrillProvider}
 * @param {string} apiKey API Key for the Mandrill account.
 * @param {object} [options] Additional optional configuration.
 * @param {string} [options.async=false] See 'async' field: {@link https://mandrillapp.com/api/docs/messages.html#method-send}
 * @param {string} [options.ipPool] See: {@link http://help.mandrill.com/entries/24182062}
 * @param {boolean} [options.apiSecure=true] API connection protocol - true = HTTPS, false = HTTP
 * @param {string} [options.apiHostname=mandrillapp.com] Hostname for the API connection
 * @param {number} [options.apiPort] Port for the API connection - defaults to match the protocol (HTTPS-443, HTTP-80)
 */
function MandrillProvider(apiKey, options) {
	if (typeof apiKey !== 'string') {
		throw new Error('Invalid parameters');
	}

	options = options || {};
	options.apiHostname = options.apiHostname || 'mandrillapp.com';
	options.apiPort = options.apiPort || (options.apiSecure ? 443 : 80);

	if (typeof options.async === 'undefined')
		options.async = false;

	if (typeof options.apiSecure === 'undefined')
		options.apiSecure = true;

	this.apiKey = apiKey;
	this.options = options;
}

/**
 * Indicates the outcome of a mail-sending attempt.
 * @callback MandrillProvider~onResult
 * @param {error} [error] A non-null value indicates failure.
 */

/**
 * Attempts to send the message through the Mandrill API.
 *
 * @this {MandrillProvider}
 * @param {Message} message The message to send.
 * @param {MandrillProvider~onResult} [callback] Notified when the attempt fails or succeeds.
 */
MandrillProvider.prototype.mail = function (message, callback) {
	var messageObj;

	// this can fail if the message is invalid
	try {
		messageObj = this._objectForMessage(message);
	} catch (error) {
		if (callback)
			callback(error);

{'fraction_non_alphanumeric': 0.12913660114456332, 'fraction_numerical': 0.008957452102513063, 'mean_word_length': 4.552486187845304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2816459', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1199, 'n_words': 376}