1
0
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:
Ruben Bridgewater
2017-05-28 04:56:14 +02:00
parent 4fb6ef4997
commit 39da7878d4

View File

@@ -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)
}
}