fixed style.

This commit is contained in:
Yunong Xiao 2012-02-23 16:02:52 -08:00
parent 116bedb487
commit 5135da4b6a
3 changed files with 34 additions and 34 deletions

View File

@ -64,7 +64,7 @@ function xor() {
function validateControls(controls) {
if (Array.isArray(controls)) {
controls.forEach(function(c) {
controls.forEach(function (c) {
if (!(c instanceof Control))
throw new TypeError('controls must be [Control]');
});
@ -202,7 +202,7 @@ Client.prototype.add = function add(name, entry, controls, callback) {
throw new TypeError('callback (function) required');
if (Array.isArray(entry)) {
entry.forEach(function(a) {
entry.forEach(function (a) {
if (!Attribute.isAttribute(a))
throw new TypeError('entry must be an Array of Attributes');
});
@ -210,10 +210,10 @@ Client.prototype.add = function add(name, entry, controls, callback) {
var save = entry;
entry = [];
Object.keys(save).forEach(function(k) {
Object.keys(save).forEach(function (k) {
var attr = new Attribute({type: k});
if (Array.isArray(save[k])) {
save[k].forEach(function(v) {
save[k].forEach(function (v) {
attr.addValue(v.toString());
});
} else {
@ -304,7 +304,7 @@ Client.prototype.compare = function compare(name,
controls: controls
});
return this._send(req, CMP_EXPECT, null, function(err, res) {
return this._send(req, CMP_EXPECT, null, function (err, res) {
if (err)
return callback(err);
@ -380,7 +380,7 @@ Client.prototype.exop = function exop(name, value, controls, callback) {
controls: controls
});
return this._send(req, [errors.LDAP_SUCCESS], null, function(err, res) {
return this._send(req, [errors.LDAP_SUCCESS], null, function (err, res) {
if (err)
return callback(err);
@ -412,7 +412,7 @@ Client.prototype.modify = function modify(name, change, controls, callback) {
if (typeof (change.modification) !== 'object')
throw new Error('change.modification (object) required');
Object.keys(change.modification).forEach(function(k) {
Object.keys(change.modification).forEach(function (k) {
var mod = {};
mod[k] = change.modification[k];
changes.push(new Change({
@ -425,7 +425,7 @@ Client.prototype.modify = function modify(name, change, controls, callback) {
if (change instanceof Change) {
changes.push(change);
} else if (Array.isArray(change)) {
change.forEach(function(c) {
change.forEach(function (c) {
if (c instanceof Change) {
changes.push(c);
} else {
@ -600,7 +600,7 @@ Client.prototype.search = function search(base, options, controls, callback) {
*/
Client.prototype.unbind = function unbind(callback) {
if (!callback)
callback = function() {};
callback = function () {};
if (typeof (callback) !== 'function')
throw new TypeError('callback must be a function');
@ -630,7 +630,7 @@ Client.prototype.connect = function connect(callback) {
c = proto.connect(opts.port, opts.host);
if (this.connectTimeout) {
timer = setTimeout(function() {
timer = setTimeout(function () {
c.destroy();
self.emit('connectTimeout', new ConnectionError('timeout'));
@ -658,7 +658,7 @@ Client.prototype.connect = function connect(callback) {
})
};
c.on('connect', function() {
c.on('connect', function () {
if (timer)
clearTimeout(timer);
@ -675,7 +675,7 @@ Client.prototype.connect = function connect(callback) {
return (typeof (callback) === 'function' ? callback(null, c) : false);
});
c.on('end', function() {
c.on('end', function () {
if (log.trace())
log.trace('%s end event', c.ldap.id);
@ -684,11 +684,11 @@ Client.prototype.connect = function connect(callback) {
// On close we have to walk the outstanding messages and go invoke their
// callback with an error
c.on('close', function(had_err) {
c.on('close', function (had_err) {
if (log.trace())
log.trace('%s close event had_err=%s', c.ldap.id, had_err ? 'yes' : 'no');
Object.keys(c.ldap.messages).forEach(function(msgid) {
Object.keys(c.ldap.messages).forEach(function (msgid) {
var err;
if (c.unbindMessageID !== parseInt(msgid, 10)) {
err = new ConnectionError(c.ldap.id + ' closed');
@ -715,7 +715,7 @@ Client.prototype.connect = function connect(callback) {
});
});
c.on('error', function(err) {
c.on('error', function (err) {
if (log.trace())
log.trace({err: err}, '%s error event', c.ldap.id);
@ -725,7 +725,7 @@ Client.prototype.connect = function connect(callback) {
c.end();
});
c.on('timeout', function() {
c.on('timeout', function () {
if (log.trace())
log.trace('%s timeout event=%s', c.ldap.id);
@ -733,7 +733,7 @@ Client.prototype.connect = function connect(callback) {
c.end();
});
c.on('data', function(data) {
c.on('data', function (data) {
if (log.trace())
log.trace('%s data event: %s', c.ldap.id, util.inspect(data));
@ -741,7 +741,7 @@ Client.prototype.connect = function connect(callback) {
});
// The "router"
c.ldap.parser.on('message', function(message) {
c.ldap.parser.on('message', function (message) {
message.connection = c;
var callback = c.ldap.messages[message.messageID];
@ -753,7 +753,7 @@ Client.prototype.connect = function connect(callback) {
return callback(message);
});
c.ldap.parser.on('error', function(err) {
c.ldap.parser.on('error', function (err) {
log.debug({err: err}, '%s parser error event', c.ldap.id, err);
if (self.listeners('error').length)
@ -830,7 +830,7 @@ Client.prototype._send = function _send(message, expect, emitter, callback) {
// If there's a user specified timeout, pick that up
if (this.timeout) {
timer = setTimeout(function() {
timer = setTimeout(function () {
self.emit('timeout', message);
if (conn.ldap.messages[message.messageID]) {
conn.ldap.messages[message.messageID](new LDAPResult({

View File

@ -22,7 +22,7 @@ var url = require('./url');
/// Hack a few things we need (i.e., "monkey patch" the prototype)
if (!String.prototype.startsWith) {
String.prototype.startsWith = function(str) {
String.prototype.startsWith = function (str) {
var re = new RegExp('^' + str);
return re.test(this);
};
@ -30,7 +30,7 @@ if (!String.prototype.startsWith) {
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(str) {
String.prototype.endsWith = function (str) {
var re = new RegExp(str + '$');
return re.test(this);
};
@ -43,7 +43,7 @@ if (!String.prototype.endsWith) {
module.exports = {
Client: Client,
createClient: function(options) {
createClient: function (options) {
if (typeof (options) !== 'object')
throw new TypeError('options (object) required');
@ -58,7 +58,7 @@ module.exports = {
},
Server: Server,
createServer: function(options) {
createServer: function (options) {
if (options === undefined)
options = {};

View File

@ -13,12 +13,12 @@ function PersistentSearch() {
}
PersistentSearch.prototype.addClient = function(req, res, callback) {
if (typeof(req) !== 'object')
PersistentSearch.prototype.addClient = function (req, res, callback) {
if (typeof (req) !== 'object')
throw new TypeError('req must be an object');
if (typeof(res) !== 'object')
if (typeof (res) !== 'object')
throw new TypeError('res must be an object');
if (callback && typeof(callback) !== 'function')
if (callback && typeof (callback) !== 'function')
throw new TypeError('callback must be a function');
var log = req.log;
@ -39,12 +39,12 @@ PersistentSearch.prototype.addClient = function(req, res, callback) {
};
PersistentSearch.prototype.removeClient = function(req, res, callback) {
if (typeof(req) !== 'object')
PersistentSearch.prototype.removeClient = function (req, res, callback) {
if (typeof (req) !== 'object')
throw new TypeError('req must be an object');
if (typeof(res) !== 'object')
if (typeof (res) !== 'object')
throw new TypeError('res must be an object');
if (callback && typeof(callback) !== 'function')
if (callback && typeof (callback) !== 'function')
throw new TypeError('callback must be a function');
var log = req.log;
@ -54,7 +54,7 @@ PersistentSearch.prototype.removeClient = function(req, res, callback) {
client.res = res;
// remove the client if it exists
this.clientList.forEach(function(element, index, array) {
this.clientList.forEach(function (element, index, array) {
if (element.req === client.req) {
log.debug('%s removing client from list', req.logId);
array.splice(index, 1);
@ -69,7 +69,7 @@ PersistentSearch.prototype.removeClient = function(req, res, callback) {
function getOperationType(requestType) {
switch (requestType) {
switch (requestType) {
case 'AddRequest':
case 'add':
return 1;