Skip to content

Commit

Permalink
chore: remove shallowClone util helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Mar 9, 2020
1 parent 6aa2434 commit 79cbe09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
7 changes: 3 additions & 4 deletions lib/gridfs-stream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var Emitter = require('events').EventEmitter;
var GridFSBucketReadStream = require('./download');
var GridFSBucketWriteStream = require('./upload');
var shallowClone = require('../utils').shallowClone;
var toError = require('../utils').toError;
var util = require('util');
var executeLegacyOperation = require('../utils').executeLegacyOperation;
Expand Down Expand Up @@ -33,7 +32,7 @@ function GridFSBucket(db, options) {
this.setMaxListeners(0);

if (options && typeof options === 'object') {
options = shallowClone(options);
options = Object.assign({}, options);
var keys = Object.keys(DEFAULT_GRIDFS_BUCKET_OPTIONS);
for (var i = 0; i < keys.length; ++i) {
if (!options[keys[i]]) {
Expand Down Expand Up @@ -85,7 +84,7 @@ util.inherits(GridFSBucket, Emitter);

GridFSBucket.prototype.openUploadStream = function(filename, options) {
if (options) {
options = shallowClone(options);
options = Object.assign({}, options);
} else {
options = {};
}
Expand Down Expand Up @@ -113,7 +112,7 @@ GridFSBucket.prototype.openUploadStream = function(filename, options) {

GridFSBucket.prototype.openUploadStreamWithId = function(id, filename, options) {
if (options) {
options = shallowClone(options);
options = Object.assign({}, options);
} else {
options = {};
}
Expand Down
3 changes: 1 addition & 2 deletions lib/gridfs/grid_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const util = require('util');
const MongoError = require('../core').MongoError;
const inherits = util.inherits;
const Duplex = require('stream').Duplex;
const shallowClone = require('../utils').shallowClone;
const executeLegacyOperation = require('../utils').executeLegacyOperation;
const deprecate = require('util').deprecate;

Expand Down Expand Up @@ -221,7 +220,7 @@ var open = function(self, options, callback) {
// Get chunk collection
var chunkCollection = self.chunkCollection();
// Make an unique index for compatibility with mongo-cxx-driver:legacy
var chunkIndexOptions = shallowClone(writeConcern);
var chunkIndexOptions = Object.assign({}, writeConcern);
chunkIndexOptions.unique = true;
// Ensure index on chunk collection
chunkCollection.ensureIndex(
Expand Down
9 changes: 1 addition & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ const MongoError = require('./core/error').MongoError;
const ReadPreference = require('./core/topologies/read_preference');
const WriteConcern = require('./write_concern');

var shallowClone = function(obj) {
var copy = {};
for (var name in obj) copy[name] = obj[name];
return copy;
};

// Figure out the read preference
var translateReadPreference = function(options) {
function translateReadPreference(options) {
var r = null;
if (options.readPreference) {
r = options.readPreference;
Expand Down Expand Up @@ -733,7 +727,6 @@ module.exports = {
filterOptions,
mergeOptions,
translateOptions,
shallowClone,
getSingleProperty,
checkCollectionName,
toError,
Expand Down

0 comments on commit 79cbe09

Please sign in to comment.