Created
January 17, 2019 09:38
-
-
Save muradm/36e13bc2b51fa9edf4992a870c7dccac to your computer and use it in GitHub Desktop.
node mongodb patch to avoid makeLazyLoader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
patch-package | |
--- a/node_modules/mongodb/lib/operations/collection_ops.js | |
+++ b/node_modules/mongodb/lib/operations/collection_ops.js | |
@@ -18,13 +18,12 @@ const handleCallback = require('../utils').handleCallback; | |
const indexInformationDb = require('./db_ops').indexInformation; | |
const isObject = require('../utils').isObject; | |
const Long = require('mongodb-core').BSON.Long; | |
-const makeLazyLoader = require('../utils').makeLazyLoader; | |
const MongoError = require('mongodb-core').MongoError; | |
const ReadPreference = require('mongodb-core').ReadPreference; | |
const toError = require('../utils').toError; | |
-const loadCollection = makeLazyLoader(`${__dirname}/../collection`); | |
-const loadDb = makeLazyLoader(`${__dirname}/../db`); | |
+const loadCollection = () => require('../collection'); | |
+const loadDb = () => require('../db'); | |
/** | |
* Group function helper | |
--- a/node_modules/mongodb/lib/operations/cursor_ops.js | |
+++ b/node_modules/mongodb/lib/operations/cursor_ops.js | |
@@ -3,11 +3,10 @@ | |
const buildCountCommand = require('./collection_ops').buildCountCommand; | |
const formattedOrderClause = require('../utils').formattedOrderClause; | |
const handleCallback = require('../utils').handleCallback; | |
-const makeLazyLoader = require('../utils').makeLazyLoader; | |
const MongoError = require('mongodb-core').MongoError; | |
const push = Array.prototype.push; | |
-const loadCursor = makeLazyLoader(`${__dirname}/../cursor`); | |
+const loadCursor = () => require('../cursor'); | |
/** | |
* Get the count of documents for this cursor. | |
--- a/node_modules/mongodb/lib/operations/db_ops.js | |
+++ b/node_modules/mongodb/lib/operations/db_ops.js | |
@@ -6,7 +6,6 @@ const resolveReadPreference = require('../utils').resolveReadPreference; | |
const crypto = require('crypto'); | |
const debugOptions = require('../utils').debugOptions; | |
const handleCallback = require('../utils').handleCallback; | |
-const makeLazyLoader = require('../utils').makeLazyLoader; | |
const MongoError = require('mongodb-core').MongoError; | |
const parseIndexOptions = require('../utils').parseIndexOptions; | |
const ReadPreference = require('mongodb-core').ReadPreference; | |
@@ -18,8 +17,8 @@ const findOne = require('./collection_ops').findOne; | |
const remove = require('./collection_ops').remove; | |
const updateOne = require('./collection_ops').updateOne; | |
-const loadCollection = makeLazyLoader(`${__dirname}/../collection`); | |
-const loadDb = makeLazyLoader(`${__dirname}/../db`); | |
+const loadCollection = () => require('../collection'); | |
+const loadDb = () => require('../db'); | |
const debugFields = [ | |
'authSource', | |
--- a/node_modules/mongodb/lib/operations/mongo_client_ops.js | |
+++ b/node_modules/mongodb/lib/operations/mongo_client_ops.js | |
@@ -3,7 +3,6 @@ | |
const authenticate = require('../authenticate'); | |
const deprecate = require('util').deprecate; | |
const Logger = require('mongodb-core').Logger; | |
-const makeLazyLoader = require('../utils').makeLazyLoader; | |
const MongoError = require('mongodb-core').MongoError; | |
const Mongos = require('../topologies/mongos'); | |
const parse = require('mongodb-core').parseConnectionString; | |
@@ -12,7 +11,7 @@ const ReplSet = require('../topologies/replset'); | |
const Server = require('../topologies/server'); | |
const ServerSessionPool = require('mongodb-core').Sessions.ServerSessionPool; | |
-const loadClient = makeLazyLoader(`${__dirname}/../mongo_client`); | |
+const loadClient = () => require('../mongo_client'); | |
const monitoringEvents = [ | |
'timeout', | |
--- a/node_modules/mongodb/lib/utils.js | |
+++ b/node_modules/mongodb/lib/utils.js | |
@@ -694,16 +694,6 @@ function deprecateOptions(config, fn) { | |
return deprecated; | |
} | |
-function makeLazyLoader(modulePath) { | |
- let mod; | |
- return function lazyLoad() { | |
- if (!mod) { | |
- mod = require(modulePath); | |
- } | |
- return mod; | |
- }; | |
-} | |
- | |
module.exports = { | |
filterOptions, | |
mergeOptions, | |
@@ -729,6 +719,5 @@ module.exports = { | |
isPromiseLike, | |
decorateWithCollation, | |
decorateWithReadConcern, | |
- deprecateOptions, | |
- makeLazyLoader | |
+ deprecateOptions | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment