Skip to content
Browse files

jshinted, still left 12 errors

  • Loading branch information...
1 parent 70502d9 commit 0f7269c450ebdd81f9ace752ce59aa886288af2e andris9 committed Aug 14, 2011
Showing with 57 additions and 49 deletions.
  1. +4 −4 examples/example_ses.js
  2. +7 −6 examples/example_smtp.js
  3. +6 −6 lib/engines/SES.js
  4. +20 −18 lib/engines/SMTP.js
  5. +4 −3 lib/engines/SMTP/starttls.js
  6. +1 −1 lib/engines/sendmail.js
  7. +15 −11 lib/mail.js
View
8 examples/example_ses.js
@@ -32,7 +32,7 @@ var message = {
cid: cid
}
]
-}
+};
// Callback to be run after the sending is completed
var callback = function(error, success){
@@ -46,9 +46,9 @@ var callback = function(error, success){
}else{
console.log('Message failed, reschedule!');
}
-}
+};
-console.log('Sending Mail')
+console.log('Sending Mail');
// Catch uncaught errors
process.on('uncaughtException', function(e){
@@ -67,4 +67,4 @@ var oldemit = mail.emit;
mail.emit = function(){
console.log('Mail.emit', arguments);
oldemit.apply(mail, arguments);
-}
+};
View
13 examples/example_smtp.js
@@ -9,8 +9,9 @@ nodemailer.SMTP = {
user: undefined,
pass: undefined,
debug: true
-}
-console.log('SMTP Configured')
+};
+
+console.log('SMTP Configured');
// unique cid value for the embedded image
var cid = Date.now() + '.image.png';
@@ -36,7 +37,7 @@ var message = {
cid: cid
}
]
-}
+};
// Callback to be run after the sending is completed
var callback = function(error, success){
@@ -50,9 +51,9 @@ var callback = function(error, success){
}else{
console.log('Message failed, reschedule!');
}
-}
+};
-console.log('Sending Mail')
+console.log('Sending Mail');
// Catch uncaught errors
process.on('uncaughtException', function(e){
@@ -71,4 +72,4 @@ var oldemit = mail.emit;
mail.emit = function(){
console.log('Mail.emit', arguments);
oldemit.apply(mail, arguments);
-}
+};
View
12 lib/engines/SES.js
@@ -4,12 +4,12 @@ var http = require('http'),
//Taken shamelessly from the [MDN](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date)
function ISODateString(d){
- return d.getUTCFullYear()+'-'
- + pad(d.getUTCMonth()+1)+'-'
- + pad(d.getUTCDate())+'T'
- + pad(d.getUTCHours())+':'
- + pad(d.getUTCMinutes())+':'
- + pad(d.getUTCSeconds())+'Z'
+ return d.getUTCFullYear() + '-' +
+ pad(d.getUTCMonth()+1)+'-' +
+ pad(d.getUTCDate())+'T' +
+ pad(d.getUTCHours())+':' +
+ pad(d.getUTCMinutes())+':' +
+ pad(d.getUTCSeconds())+'Z';
}
function pad(n){
View
38 lib/engines/SMTP.js
@@ -245,7 +245,7 @@ SMTPClient.prototype._flushMessages = function() {
//Empty addresses are valid (for server sent notifications).
if(forwardAddress = error.message.match(/^551.*try\s+([<][^>]*[>])/)) {
mail.emit("forward", address,forwardAddress[1]);
- toAddress.splice(i,0,forwardAddress[1])
+ toAddress.splice(i, 0, forwardAddress[1]);
process.nextTick(nextRecipient);
return;
}
@@ -293,15 +293,15 @@ SMTPClient.prototype._flushMessages = function() {
}
});
}
-}
+};
SMTPClient.prototype.sendMail = function sendMail(message, callback) {
this._messageQueue.push({
message:message,
callback:callback
});
if(this._messageQueue.length === 1) this._flushMessages();
-}
+};
/**
* smtp.SMTPClient#send(data, callback) -> undefined
@@ -341,7 +341,7 @@ SMTPClient.prototype.send = function(data, callback){
this._sendData(data);
}
-}
+};
/**
* smtp.SMTPClient#close() -> undefined
@@ -368,9 +368,10 @@ SMTPClient.prototype._sendCommand = function(data, callback){
this._callbackQueue.push({callback: callback});
this._connection.write(data+"\r\n");
- if(this.debug)
+ if(this.debug){
console.log("SEND ("+this.instanceId+"):\n└──"+JSON.stringify(data+"\r\n"));
-}
+ }
+};
/**
* smtp.SMTPClient#_sendData(data) -> undefined
@@ -381,9 +382,10 @@ SMTPClient.prototype._sendCommand = function(data, callback){
SMTPClient.prototype._sendData = function(data){
this._connection.write(data);
- if(this.debug)
+ if(this.debug){
console.log("SEND ("+this.instanceId+"):\n└──"+JSON.stringify(data));
-}
+ }
+};
/**
* smtp.SMTPClient#_loginHandler(callback) -> undefined
@@ -413,7 +415,7 @@ SMTPClient.prototype._loginHandler = function(callback){
}
// TODO: Add CRAM-MD5 authentication as well
}
-}
+};
/**
* smtp.SMTPClient#_authLogin(callback) -> undefined
@@ -438,7 +440,7 @@ SMTPClient.prototype._authPlain = function(callback){
this.emit("auth");
callback();
}).bind(this));
-}
+};
/**
* smtp.SMTPClient#_authLogin(callback) -> undefined
@@ -495,7 +497,7 @@ SMTPClient.prototype._authLogin = function(callback){
}).bind(this));
}).bind(this));
}).bind(this));
-}
+};
/**
* smtp.SMTPClient#_dataListener(data) -> undefined
@@ -524,7 +526,7 @@ SMTPClient.prototype._dataListener = function(data){
// what the hell just happened? this should never occur
}
}
-}
+};
/**
* smtp.SMTPClient#_handshakeListener(data) -> undefined
@@ -553,7 +555,7 @@ SMTPClient.prototype._handshakeListener = function(data, callback){
this.close();
return;
}
-}
+};
/**
* smtp.SMTPClient#_starttlsHandler(callback) -> undefined
@@ -588,7 +590,7 @@ SMTPClient.prototype._starttlsHandler = function(callback){
callback();
}).bind(this));
}).bind(this));
-}
+};
/**
* smtp.SMTPClient#_handshake(callback) -> undefined
@@ -653,7 +655,7 @@ SMTPClient.prototype._handshake = function(callback){
// check login after successful handshake
this._loginHandler(callback);
}).bind(this));
-}
+};
/**
* smtp.SMTPClient#_waitForTimeout() -> function
@@ -666,7 +668,7 @@ SMTPClient.prototype._waitForTimeout = function(time){
this.emit("error", new Error("Timeout waiting for response from server"));
this.close();
}).bind(this), time || 10*1000);
-}
+};
/**
* smtp.SMTPClient#_onData(data) -> function
@@ -700,7 +702,7 @@ SMTPClient.prototype._onData = function(callback, data){
}
return undefined;
-}
+};
/**
* smtp.SMTPClient#_createConnection(callback) -> function
@@ -740,4 +742,4 @@ SMTPClient.prototype._createConnection = function(callback){
//10 seconds for data
this._connection.on("connect", this._waitForTimeout.bind(this));
this._connection.on("data", this._onData = this._onData.bind(this, callback));
-}
+};
View
7 lib/engines/SMTP/starttls.js
@@ -41,10 +41,11 @@ function forwardEvents(events,emitterSource,emitterDestination) {
var map = {}, name, handler;
for(var i = 0; i < events.length; i++) {
name = events[i];
+ // TODO: Review if these functions declarations need to be here
handler = (function generateForwardEvent(){
return function forwardEvent(name) {
return emitterDestination.emit.apply(emitterDestination, arguments);
- }
+ };
})(name);
map[name] = handler;
emitterSource.on(name, handler);
@@ -54,7 +55,7 @@ function forwardEvents(events,emitterSource,emitterDestination) {
function removeEvents(map,emitterSource) {
for(var k in map) {
- emitterSource.removeListener(k,map[k])
+ emitterSource.removeListener(k, map[k]);
}
}
@@ -81,7 +82,7 @@ function pipe(pair, socket) {
function onclose() {
socket.removeListener('error', onerror);
socket.removeListener('close', onclose);
- removeEvents(map,socket)
+ removeEvents(map,socket);
}
socket.on('error', onerror);
View
2 lib/engines/sendmail.js
@@ -10,7 +10,7 @@ exports.send = function(emailMessage, config, callback) {
emailMessage.prepareVariables();
if(!exec){
- return callback(new Error("No support for child processes in this version of Node.JS, use SMTP instead"));
+ return callback && callback(new Error("No support for child processes in this version of Node.JS, use SMTP instead"));
}
var headers = emailMessage.generateHeaders(),
View
26 lib/mail.js
@@ -2,6 +2,7 @@ var mimelib = require("mimelib-noiconv"),
util = require("util"),
EventEmitter = require("events").EventEmitter,
fs = require("fs");
+
/*
* Load all engines, assuming each .js file in the root of the engines
* directory is an engine. To avoid collisions, dependencies should be
@@ -154,7 +155,7 @@ EmailMessage.prototype.prepareVariables = function(){
this.content_type = "text/plain; charset="+this.charset;
this.content_transfer_encoding = this.encoding; // Changed from quoted-printable; 5/23/2011.
}
-}
+};
/**
* mail.EmailMessage#generateHeaders() -> String
@@ -181,7 +182,7 @@ EmailMessage.prototype.generateHeaders = function(){
}
// Date
- var date = new Date;
+ var date = new Date();
headers.push([
upperFirst("Date"),
date.toGMTString()
@@ -262,7 +263,7 @@ EmailMessage.prototype.generateHeaders = function(){
return headers.map(function(elm){
return mimelib.foldLine(elm);
}).join("\r\n");
-}
+};
/**
* mail.EmailMessage#generateBody() -> String
@@ -352,7 +353,7 @@ EmailMessage.prototype.generateBody = function(){
return rows.join("\r\n");
-}
+};
/**
* mail.EmailMessage#generateAddresses(addresses, limit, use_list) -> String
@@ -414,7 +415,7 @@ EmailMessage.prototype.generateAddresses = function(addresses, limit, use_list){
}
return output.join(", ");
-}
+};
/**
* mail.EmailMessage#send(callback) -> undefined
@@ -427,7 +428,8 @@ EmailMessage.prototype.generateAddresses = function(addresses, limit, use_list){
* and success is true, then the message was sent to the recipients
**/
EmailMessage.prototype.send = function(callback){
- var instanceId = ++instancecounter;
+ var instanceId = ++instancecounter,
+ engine, keys, i, len;
if(this.debug){
var str = X_MAILER_NAME+", "+X_MAILER_VERSION+", Node.js "+process.version+": "+instanceId;
@@ -440,14 +442,16 @@ EmailMessage.prototype.send = function(callback){
}
//Use the engine configured by the user
- for(var engine in engines) {
+ keys = Object.keys(engines);
+ for(i=0, len = keys.length; i < len; i++) {
+ engine = keys[i];
if(exports[engine]) {
return this.send_using_engine(exports[engine], engine, instanceId, callback);
}
}
callback(new Error("Transfer method not defined"));
-}
+};
/**
* mail.EmailMessage#send_using_engine(engine, engineId, instanceId, callback) -> undefined
@@ -466,8 +470,8 @@ EmailMessage.prototype.send_using_engine = function(engine, engineId, instanceId
if(this.debug){
console.log("Used transfer method: " + engineId + "\n");
}
-
-}
+
+};
/**
* getMimeType(filename) -> String
@@ -497,7 +501,7 @@ function upperFirst(str, keepUpper){
str = str.toLowerCase();
}
return str.replace(/^\s*[a-z]|[\-\s][a-z]/g,function(c){
- return c.toUpperCase()
+ return c.toUpperCase();
});
}

0 comments on commit 0f7269c

Please sign in to comment.
Something went wrong with that request. Please try again.