use type coercion and less 'arguments' usage

fork
Brian White 12 years ago
parent ce072c5d84
commit d1cdb06cc1

@ -730,10 +730,6 @@ ImapConnection.prototype.status = function(boxName, cb) {
};
ImapConnection.prototype.removeDeleted = function(cb) {
if (this._state.status !== STATES.BOXSELECTED)
throw new Error('No mailbox is currently selected');
cb = arguments[arguments.length - 1];
this._send('EXPUNGE', cb);
};
@ -746,35 +742,24 @@ ImapConnection.prototype.getBoxes = function(namespace, cb) {
};
ImapConnection.prototype.addBox = function(name, cb) {
cb = arguments[arguments.length - 1];
if (typeof name !== 'string' || name.length === 0)
throw new Error('Mailbox name must be a string describing the full path'
+ ' of a new mailbox to be created');
this._send('CREATE "' + utils.escape(utf7.encode(name)) + '"', cb);
this._send('CREATE "' + utils.escape(utf7.encode(''+name)) + '"', cb);
};
ImapConnection.prototype.delBox = function(name, cb) {
cb = arguments[arguments.length - 1];
if (typeof name !== 'string' || name.length === 0)
throw new Error('Mailbox name must be a string describing the full path'
+ ' of an existing mailbox to be deleted');
this._send('DELETE "' + utils.escape(name) + '"', cb);
this._send('DELETE "' + utils.escape(''+name) + '"', cb);
};
ImapConnection.prototype.renameBox = function(oldname, newname, cb) {
cb = arguments[arguments.length - 1];
if (typeof oldname !== 'string' || oldname.length === 0)
throw new Error('Old mailbox name must be a string describing the full path'
+ ' of an existing mailbox to be renamed');
else if (typeof newname !== 'string' || newname.length === 0)
throw new Error('New mailbox name must be a string describing the full path'
+ ' of a new mailbox to be renamed to');
if (this._state.status === STATES.BOXSELECTED
&& oldname === this._state.box.name && oldname !== 'INBOX')
this._state.box._newName = oldname;
this._state.box._newName = ''+oldname;
this._send('RENAME "' + utils.escape(oldname) + '" "' + utils.escape(newname)
+ '"', cb);
var cmd = 'RENAME "';
cmd += utils.escape(''+oldname);
cmd += '" "';
cmd += utils.escape(''+newname);
cmd += '"';
this._send(cmd, cb);
};
ImapConnection.prototype.append = function(data, options, cb) {

Loading…
Cancel
Save