You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
fix: performance regression due to lazy loading the index file
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
var index
|
||||
function lazyIndex () {
|
||||
return index || require('../')
|
||||
var index = {
|
||||
debugMode: /\bredis\b/i.test(process.env.NODE_DEBUG)
|
||||
}
|
||||
// Lazy load the main file
|
||||
process.nextTick(() => (index = require('../')))
|
||||
|
||||
/**
|
||||
* @description Print a debug statement if in debug mode
|
||||
*/
|
||||
function debug () {
|
||||
if (lazyIndex().debugMode) {
|
||||
if (index.debugMode) {
|
||||
console.error.apply(null, arguments)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user