harmonize style: no parens after typeof

This commit is contained in:
matt debergalis
2012-02-10 15:43:12 -08:00
parent 8eeba106c5
commit b84f048c75
8 changed files with 33 additions and 33 deletions

View File

@@ -113,7 +113,7 @@
throw new Error("Bad value for element body: " + c);
else if (c instanceof Array)
addChildren(c);
else if (typeof(c) === "string")
else if (typeof c === "string")
elt.appendChild(document.createTextNode(c));
else if ('element' in c)
addChildren([c.element]);

View File

@@ -26,7 +26,7 @@ Meteor.Server = function (url) {
// all socket.io traffic is framed as a "livedata" message.
self.stream.on('livedata', function (msg) {
if (typeof(msg) !== 'object' || !msg.msg) {
if (typeof msg !== 'object' || !msg.msg) {
Meteor._debug("discarding invalid livedata message", msg);
return;
}

View File

@@ -15,7 +15,7 @@ Meteor._LivedataServer = function () {
socket.meteor.pending_method_ids = [];
socket.on('livedata', function (msg) {
if (typeof(msg) !== 'object' || !msg.msg) {
if (typeof msg !== 'object' || !msg.msg) {
Meteor._debug("discarding invalid livedata message", msg);
return;
}

View File

@@ -355,7 +355,7 @@ Collection.prototype._modifyAndNotify = function (doc, mod) {
// XXX findandmodify
Collection._deepcopy = function (v) {
if (typeof(v) !== "object")
if (typeof v !== "object")
return v;
if (v === null)
return null; // null has typeof "object"

View File

@@ -88,7 +88,7 @@ Collection._findModTarget = function (doc, keyparts, no_create,
return null;
if (!numeric)
throw Error("can't append to array using string field name ["
+ keypart + "]")
+ keypart + "]");
keypart = parseInt(keypart);
if (last)
// handle 'a.01'
@@ -98,7 +98,7 @@ Collection._findModTarget = function (doc, keyparts, no_create,
if (!last) {
if (doc.length === keypart)
doc.push({});
else if (typeof(doc[keypart]) !== "object")
else if (typeof doc[keypart] !== "object")
throw Error("can't modify field '" + keyparts[i + 1] +
"' of list value " + JSON.stringify(doc[keypart]));
}
@@ -126,10 +126,10 @@ Collection._noCreateModifiers = {
Collection._modifiers = {
$inc: function (target, field, arg) {
if (typeof(arg) !== "number")
if (typeof arg !== "number")
throw Error("Modifier $inc allowed for numbers only");
if (field in target) {
if (typeof(target[field]) !== "number")
if (typeof target[field] !== "number")
throw Error("Cannot apply $inc modifier to non-number");
target[field] += arg;
} else {
@@ -158,7 +158,7 @@ Collection._modifiers = {
x.push(Collection._deepcopy(arg));
},
$pushAll: function (target, field, arg) {
if (!(typeof(arg) === "object" && arg instanceof Array))
if (!(typeof arg === "object" && arg instanceof Array))
throw Error("Modifier $pushAll/pullAll allowed for arrays only");
var x = target[field];
if (x === undefined)
@@ -178,7 +178,7 @@ Collection._modifiers = {
throw Error("Cannot apply $addToSet modifier to non-array");
else {
var isEach = false;
if (typeof(arg) === "object") {
if (typeof arg === "object") {
for (var k in arg) {
if (k === "$each")
isEach = true;
@@ -203,7 +203,7 @@ Collection._modifiers = {
else if (!(x instanceof Array))
throw Error("Cannot apply $pop modifier to non-array");
else {
if (typeof(arg) === 'number' && arg < 0)
if (typeof arg === 'number' && arg < 0)
x.splice(0, 1);
else
x.pop();
@@ -219,7 +219,7 @@ Collection._modifiers = {
throw Error("Cannot apply $pull/pullAll modifier to non-array");
else {
var out = []
if (typeof(arg) === "object" && !(arg instanceof Array)) {
if (typeof arg === "object" && !(arg instanceof Array)) {
// XXX would be much nicer to compile this once, rather than
// for each document we modify.. but usually we're not
// modifying that many documents, so we'll let it slide for
@@ -242,7 +242,7 @@ Collection._modifiers = {
}
},
$pullAll: function (target, field, arg) {
if (!(typeof(arg) === "object" && arg instanceof Array))
if (!(typeof arg === "object" && arg instanceof Array))
throw Error("Modifier $pushAll/pullAll allowed for arrays only");
if (target === undefined)
return;
@@ -273,7 +273,7 @@ Collection._modifiers = {
throw Error("$rename source must differ from target");
if (target === null)
throw Error("$rename source field invalid");
if (typeof(arg) !== "string")
if (typeof arg !== "string")
throw Error("$rename target must be a string");
if (target === undefined)
return;

View File

@@ -29,7 +29,7 @@ Collection._f = {
},
_in: function (x, qval) {
if (typeof(x) !== "object") {
if (typeof x !== "object") {
// optimization: use scalar equality (fast)
for (var i = 0; i < qval.length; i++)
if (x === qval[i])
@@ -45,11 +45,11 @@ Collection._f = {
},
_type: function (v) {
if (typeof(v) === "number")
if (typeof v === "number")
return 1;
if (typeof(v) === "string")
if (typeof v === "string")
return 2;
if (typeof(v) === "boolean")
if (typeof v === "boolean")
return 8;
if (v instanceof Array)
return 4;
@@ -57,7 +57,7 @@ Collection._f = {
return 10;
if (v instanceof RegExp)
return 11;
if (typeof(v) === "function")
if (typeof v === "function")
// note that typeof(/x/) === "function"
return 13;
return 3; // object
@@ -78,14 +78,14 @@ Collection._f = {
_equal: function (x, qval) {
var match = function (a, b) {
// scalars
if (typeof(a) === 'number' || typeof(a) === 'string' ||
typeof(a) === 'boolean' || a === undefined || a === null)
if (typeof a === 'number' || typeof a === 'string' ||
typeof a === 'boolean' || a === undefined || a === null)
return a === b;
if (typeof(a) === 'function')
if (typeof a === 'function')
return false;
// OK, typeof(a) === 'object'
if (typeof(b) !== 'object')
// OK, typeof a === 'object'
if (typeof b !== 'object')
return false;
// arrays
@@ -262,7 +262,7 @@ Collection._compileSelector = function (selector) {
return function (doc) {return selector.call(doc);};
// shorthand -- scalars match _id
if ((typeof(selector) === "string") || (typeof(selector) === "number"))
if ((typeof selector === "string") || (typeof selector === "number"))
selector = {_id: selector};
// protect against dangerous selectors. falsey and {_id: falsey}
@@ -357,7 +357,7 @@ Collection._exprForKeypathPredicate = function (keypath, value, literals) {
if (value instanceof RegExp) {
predcode = Collection._exprForOperatorTest(value, literals);
} else if (
!(typeof(value) === 'object') ||
!(typeof value === 'object') ||
value === null ||
value instanceof Array) {
// it's something like {x.y: 12} or {x.y: [12]}
@@ -483,7 +483,7 @@ Collection._exprForConstraint = function (type, arg, others,
expr = 'x%' + JSON.stringify(arg[0]) + '===' +
JSON.stringify(arg[1]);
} else if (type === '$ne') {
if (typeof(arg) !== "object")
if (typeof arg !== "object")
expr = 'x===' + JSON.stringify(arg);
else
expr = 'f._equal(x,' + JSON.stringify(arg) + ')';

View File

@@ -19,7 +19,7 @@ Collection._compileSort = function (spec) {
if (spec instanceof Array) {
for (var i = 0; i < spec.length; i++) {
if (typeof(spec[i]) === "string") {
if (typeof spec[i] === "string") {
keys.push(spec[i]);
asc.push(true);
} else {
@@ -27,7 +27,7 @@ Collection._compileSort = function (spec) {
asc.push(spec[i][1] !== "desc");
}
}
} else if (typeof(spec) === "object") {
} else if (typeof spec === "object") {
for (key in spec) {
keys.push(key);
asc.push(!(spec[key] < 0));
@@ -37,7 +37,7 @@ Collection._compileSort = function (spec) {
}
if (keys.length === 0)
return function () {return 0;}
return function () {return 0;};
// eval() does not return a value in IE8, nor does the spec say it
// should. Assign to a local to get the value, instead.

View File

@@ -66,9 +66,9 @@ Session = _.extend({}, {
var self = this;
var context = Meteor.deps.Context.current;
if (typeof(value) !== 'string' &&
typeof(value) !== 'number' &&
typeof(value) !== 'boolean' &&
if (typeof value !== 'string' &&
typeof value !== 'number' &&
typeof value !== 'boolean' &&
value !== null && value !== undefined)
throw new Error("Session.equals: value can't be an object");