Skip to content

Commit

Permalink
fix(*): make sure all functions are named consistently
Browse files Browse the repository at this point in the history
In node 4.x for the bson-ext module we are not getting a valid
function name for these types, and therefore the build breaks.
This change ensures all functions have an accessible type name,
which will additionally be useful during debugging in some cases.
  • Loading branch information
mbroadst committed Mar 2, 2018
1 parent 1289516 commit 6df9022
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/bson/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* @param {Object} [scope] an optional scope for the function.
* @return {Code}
*/
var Code = function Code(code, scope) {
function Code(code, scope) {
if (!(this instanceof Code)) return new Code(code, scope);
this._bsontype = 'Code';
this.code = code;
this.scope = scope;
};
}

/**
* @ignore
Expand Down
4 changes: 2 additions & 2 deletions lib/bson/decimal128.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ var invalidErr = function(string, message) {
* @param {Buffer} bytes a buffer containing the raw Decimal128 bytes.
* @return {Double}
*/
var Decimal128 = function(bytes) {
function Decimal128(bytes) {
this._bsontype = 'Decimal128';
this.bytes = bytes;
};
}

/**
* Create a Decimal128 instance from a string representation
Expand Down
4 changes: 2 additions & 2 deletions lib/bson/int_32.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* @param {number} value the number we want to represent as an int32.
* @return {Int32}
*/
var Int32 = function(value) {
function Int32(value) {
if (!(this instanceof Int32)) return new Int32(value);

this._bsontype = 'Int32';
this.value = value;
};
}

/**
* Access the number value.
Expand Down
2 changes: 1 addition & 1 deletion lib/bson/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (typeof global.Map !== 'undefined') {
module.exports.Map = global.Map;
} else {
// We will return a polyfill
var Map = function(array) {
var Map = function Map(array) {
this._keys = [];
this._values = {};

Expand Down
4 changes: 2 additions & 2 deletions lib/bson/objectid.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {
* @property {number} generationTime The generation time of this ObjectId instance
* @return {ObjectID} instance of ObjectID.
*/
var ObjectID = function ObjectID(id) {
function ObjectID(id) {
// Duck-typing to support ObjectId from different npm packages
if (id instanceof ObjectID) return id;
if (!(this instanceof ObjectID)) return new ObjectID(id);
Expand Down Expand Up @@ -70,7 +70,7 @@ var ObjectID = function ObjectID(id) {
}

if (ObjectID.cacheHexString) this.__id = this.toString('hex');
};
}

// Allow usage of ObjectId as well as ObjectID
// var ObjectId = ObjectID;
Expand Down
4 changes: 2 additions & 2 deletions lib/bson/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ var Long = require('./long');
* @param {number} high the high (signed) 32 bits of the Timestamp.
* @return {Timestamp}
*/
var Timestamp = function(low, high) {
function Timestamp(low, high) {
if (low instanceof Long) {
Long.call(this, low.low_, low.high_);
} else {
Long.call(this, low, high);
}

this._bsontype = 'Timestamp';
};
}

Timestamp.prototype = Object.create(Long.prototype);
Timestamp.prototype.constructor = Timestamp;
Expand Down

0 comments on commit 6df9022

Please sign in to comment.