Skip to content

Commit

Permalink
even more strict
Browse files Browse the repository at this point in the history
  • Loading branch information
TrejGun committed Jan 31, 2016
1 parent 94b4a0f commit 7b52888
Show file tree
Hide file tree
Showing 74 changed files with 1,184 additions and 1,169 deletions.
4 changes: 2 additions & 2 deletions benchmarks/benchjs/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {

function closeDB() {
User.count(function (err, res) {
if (res != 0) {
if (res !== 0) {
console.log('Still mongoose entries left...');
}
mongoose.disconnect();
});
user.count({}, function (err, res) {
if (res != 0) {
if (res !== 0) {
console.log('Still driver entries left...');
}
if (err) {
Expand Down
20 changes: 10 additions & 10 deletions benchmarks/benchjs/multiop.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(data);
User.create(nData, function (err) {
if (err) {
Expand All @@ -212,7 +212,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(data);
user.insert(nData, function (err) {
if (err) {
Expand All @@ -234,7 +234,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(blogData);
BlogPost.create(nData, function (err) {
if (err) {
Expand All @@ -256,7 +256,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(blogData);
blogpost.insert(nData, function (err) {
if (err) {
Expand All @@ -280,7 +280,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
User.findOne({_id: getNextmId()}, function (err) {
if (err) {
throw err;
Expand All @@ -303,7 +303,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
user.findOne({_id: getNextdId()}, function (err) {
if (err) {
throw err;
Expand All @@ -326,7 +326,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
BlogPost.findOne({_id: getNextbmId()}, function (err) {
if (err) {
throw err;
Expand All @@ -349,7 +349,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
}
--count || deferred.resolve();
});
if (i % 15 == 0) {
if (i % 15 === 0) {
blogpost.findOne({_id: getNextbdId()}, function (err) {
if (err) {
throw err;
Expand Down Expand Up @@ -384,7 +384,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
--count || deferred.resolve();
}
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(blogData);
BlogPost.create(nData, function (err) {
if (err) {
Expand Down Expand Up @@ -420,7 +420,7 @@ mongoose.connect('mongodb://localhost/mongoose-bench', function (err) {
--count || deferred.resolve();
}
});
if (i % 15 == 0) {
if (i % 15 === 0) {
var nData = utils.clone(blogData);
blogpost.insert(nData, function (err) {
if (err) {
Expand Down
28 changes: 14 additions & 14 deletions bin/mongoose.debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions bin/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ var cast = module.exports = function(schema, obj) {
throw new Error("Must have a string or function for $where");
}

if ('function' === type) {
if (type === 'function') {
obj[path] = val.toString();
}

Expand Down Expand Up @@ -400,7 +400,7 @@ var cast = module.exports = function(schema, obj) {
} else if (val === null || val === undefined) {
obj[path] = null;
continue;
} else if ('Object' === val.constructor.name) {
} else if (val.constructor.name === 'Object') {

any$conditionals = Object.keys(val).some(function(k) {
return k.charAt(0) === '$' && k !== '$id' && k !== '$ref';
Expand Down Expand Up @@ -610,7 +610,7 @@ Document.prototype.$__buildDoc = function(obj, fields, skipId) {

// determine if this doc is a result of a query with
// excluded fields
if (fields && 'Object' === utils.getFunctionName(fields.constructor)) {
if (fields && utils.getFunctionName(fields.constructor) === 'Object') {
keys = Object.keys(fields);
ki = keys.length;

Expand Down Expand Up @@ -957,7 +957,7 @@ Document.prototype.set = function(path, val, type, options) {
this.schema.paths[pathName].options.ref)) {
this.set(path[key], prefix + key, constructing);
} else if (strict) {
if ('real' === pathtype || 'virtual' === pathtype) {
if ('real' === pathtype || pathtype === 'virtual') {
// Check for setting single embedded schema to document (gh-3535)
if (this.schema.paths[pathName] &&
this.schema.paths[pathName].$isSingleNested &&
Expand Down Expand Up @@ -1208,7 +1208,7 @@ Document.prototype.$__set = function(
if (last) {
obj[parts[i]] = val;
} else {
if (obj[parts[i]] && 'Object' === utils.getFunctionName(obj[parts[i]].constructor)) {
if (obj[parts[i]] && utils.getFunctionName(obj[parts[i]].constructor) === 'Object') {
obj = obj[parts[i]];
} else if (obj[parts[i]] && obj[parts[i]] instanceof Embedded) {
obj = obj[parts[i]];
Expand Down Expand Up @@ -1931,7 +1931,7 @@ function compile(tree, proto, prefix, options) {
limb = tree[key];

defineKey(key
, (('Object' === utils.getFunctionName(limb.constructor)
, ((utils.getFunctionName(limb.constructor === 'Object')
&& Object.keys(limb).length)
&& (!limb[options.typeKey] || (options.typeKey === 'type' && limb.type.type))
? limb
Expand Down Expand Up @@ -5091,7 +5091,7 @@ function SchemaArray(key, cast, options) {
if (cast) {
var castOptions = {};

if ('Object' === utils.getFunctionName(cast.constructor)) {
if (utils.getFunctionName(cast.constructor) === 'Object') {
if (cast.type) {
// support { type: Woot }
castOptions = utils.clone(cast); // do not alter user arguments
Expand Down Expand Up @@ -5194,7 +5194,7 @@ SchemaArray.prototype.cast = function(value, doc, init) {

for (var i = 0, l = indexes.length; i < l; ++i) {
var pathIndex = indexes[i][0][this.path];
if ('2dsphere' === pathIndex || '2d' === pathIndex) {
if ('2dsphere' === pathIndex || pathIndex === '2d') {
return;
}
}
Expand Down Expand Up @@ -5506,9 +5506,9 @@ SchemaBoolean.prototype.checkRequired = function(value) {

SchemaBoolean.prototype.cast = function(value) {
if (null === value) return value;
if ('0' === value) return false;
if ('true' === value) return true;
if ('false' === value) return false;
if (value === '0') return false;
if (value === 'true') return true;
if (value === 'false') return false;
return !!value;
};

Expand Down Expand Up @@ -8009,7 +8009,7 @@ SchemaType.prototype.get = function(fn) {
*/

SchemaType.prototype.validate = function(obj, message, type) {
if ('function' == typeof obj || obj && 'RegExp' === utils.getFunctionName(obj.constructor)) {
if ('function' == typeof obj || obj && utils.getFunctionName(obj.constructor) === 'RegExp') {
var properties;
if (message instanceof Object && !type) {
properties = utils.clone(message);
Expand All @@ -8033,7 +8033,7 @@ SchemaType.prototype.validate = function(obj, message, type) {

for (i = 0, length = arguments.length; i < length; i++) {
arg = arguments[i];
if (!(arg && 'Object' === utils.getFunctionName(arg.constructor))) {
if (!(arg && utils.getFunctionName(arg.constructor)) === 'Object') {
var msg = 'Invalid validator. Received (' + typeof arg + ') '
+ arg
+ '. See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate';
Expand Down Expand Up @@ -8892,7 +8892,7 @@ MongooseArray.mixin = {
*/

hasAtomics: function hasAtomics() {
if (!(this._atomics && 'Object' === this._atomics.constructor.name)) {
if (!(this._atomics && this._atomics.constructor.name) === 'Object') {
return 0;
}

Expand Down Expand Up @@ -23994,13 +23994,13 @@ var clone = exports.clone = function clone (obj, options) {
: new obj.constructor(obj.value(true), obj.sub_type);
}

if ('Date' === obj.constructor.name || 'Function' === obj.constructor.name)
if ('Date' === obj.constructor.name || obj.constructor.name === 'Function')
return new obj.constructor(+obj);

if ('RegExp' === obj.constructor.name)
if (obj.constructor.name === 'RegExp')
return RegExpClone(obj);

if ('Buffer' === obj.constructor.name)
if (obj.constructor.name === 'Buffer')
return exports.cloneBuffer(obj);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/helpers/href.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

module.exports = exports = function (str, char) {
if ('string' != typeof str) return str;
if ('string' !== typeof str) return str;
return encodeURIComponent(
str.replace(/\.js$/, '')
.replace(/#/g, char || '-')
Expand Down
2 changes: 1 addition & 1 deletion docs/helpers/linktype.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ types.any = 'nolink';

module.exports= function (type) {
if (types[type]) {
if ('nolink' == types[type]) return 'T';
if ('nolink' === types[type]) return 'T';
return '<a href="' + types[type] + '">' + type + '</a>';
}
return '<a href="#' + type + '">' + type + '</a>';
Expand Down
2 changes: 1 addition & 1 deletion docs/includes/googleanalytics.jade
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ script.

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
2 changes: 1 addition & 1 deletion docs/includes/googlesearch.jade
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ script
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
gcse.src = (document.location.protocol === 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
Expand Down
Loading

0 comments on commit 7b52888

Please sign in to comment.