diff options
Diffstat (limited to 'src/mongo/shell/types.js')
-rw-r--r-- | src/mongo/shell/types.js | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/mongo/shell/types.js b/src/mongo/shell/types.js index 19c1fb272f3..faaa5d00499 100644 --- a/src/mongo/shell/types.js +++ b/src/mongo/shell/types.js @@ -1,5 +1,5 @@ // Date and time types -if (typeof(Timestamp) != "undefined") { +if (typeof (Timestamp) != "undefined") { Timestamp.prototype.tojson = function() { return this.toString(); }; @@ -265,13 +265,13 @@ Array.stdDev = function(arr) { Object.extend = function(dst, src, deep) { for (var k in src) { var v = src[k]; - if (deep && typeof(v) == "object" && v !== null) { + if (deep && typeof (v) == "object" && v !== null) { if (v.constructor === ObjectId) { // convert ObjectId properly eval("v = " + tojson(v)); } else if ("floatApprox" in v) { // convert NumberLong properly eval("v = " + tojson(v)); } else { - v = Object.extend(typeof(v.length) == "number" ? [] : {}, v, true); + v = Object.extend(typeof (v.length) == "number" ? [] : {}, v, true); } } dst[k] = v; @@ -433,7 +433,7 @@ ObjectId.fromDate = function(source) { if (source instanceof Date) { sourceDate = source; } else { - throw Error("Cannot create ObjectId from " + typeof(source) + ": " + tojson(source)); + throw Error("Cannot create ObjectId from " + typeof (source) + ": " + tojson(source)); } // Convert date object to seconds since Unix epoch. @@ -449,7 +449,7 @@ ObjectId.fromDate = function(source) { }; // DBPointer -if (typeof(DBPointer) != "undefined") { +if (typeof (DBPointer) != "undefined") { DBPointer.prototype.fetch = function() { assert(this.ns, "need a ns"); assert(this.id, "need an id"); @@ -476,7 +476,7 @@ if (typeof(DBPointer) != "undefined") { } // DBRef -if (typeof(DBRef) != "undefined") { +if (typeof (DBRef) != "undefined") { DBRef.prototype.fetch = function() { assert(this.$ref, "need a ns"); assert(this.$id, "need an id"); @@ -513,7 +513,7 @@ if (typeof(DBRef) != "undefined") { } // BinData -if (typeof(BinData) != "undefined") { +if (typeof (BinData) != "undefined") { BinData.prototype.tojson = function() { return this.toString(); }; @@ -529,7 +529,7 @@ if (typeof(BinData) != "undefined") { } // Map -if (typeof(Map) == "undefined") { +if (typeof (Map) == "undefined") { Map = function() { this._data = {}; }; @@ -539,7 +539,7 @@ Map.hash = function(val) { if (!val) return val; - switch (typeof(val)) { + switch (typeof (val)) { case 'string': case 'number': case 'date': @@ -553,7 +553,7 @@ Map.hash = function(val) { return s; } - throw Error("can't hash : " + typeof(val)); + throw Error("can't hash : " + typeof (val)); }; Map.prototype.put = function(key, value) { @@ -594,7 +594,7 @@ Map.prototype.values = function() { return all; }; -if (typeof(gc) == "undefined") { +if (typeof (gc) == "undefined") { gc = function() { print("warning: using noop gc()"); }; @@ -640,7 +640,6 @@ tojson = function(x, indent, nolint, depth) { default: throw Error("tojson can't handle type " + (typeof x)); } - }; tojson.MAX_DEPTH = 100; @@ -655,11 +654,11 @@ tojsonObject = function(x, indent, nolint, depth) { if (!indent) indent = ""; - if (typeof(x.tojson) == "function" && x.tojson != tojson) { + if (typeof (x.tojson) == "function" && x.tojson != tojson) { return x.tojson(indent, nolint, depth); } - if (x.constructor && typeof(x.constructor.tojson) == "function" && + if (x.constructor && typeof (x.constructor.tojson) == "function" && x.constructor.tojson != tojson) { return x.constructor.tojson(x, indent, nolint, depth); } @@ -685,7 +684,7 @@ tojsonObject = function(x, indent, nolint, depth) { indent += tabSpace; var keys = x; - if (typeof(x._simpleKeys) == "function") + if (typeof (x._simpleKeys) == "function") keys = x._simpleKeys(); var fieldStrings = []; for (var k in keys) { @@ -721,14 +720,14 @@ printjsononeline = function(x) { }; isString = function(x) { - return typeof(x) == "string"; + return typeof (x) == "string"; }; isNumber = function(x) { - return typeof(x) == "number"; + return typeof (x) == "number"; }; // This function returns true even if the argument is an array. See SERVER-14220. isObject = function(x) { - return typeof(x) == "object"; + return typeof (x) == "object"; }; |