-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
25 lines (23 loc) · 891 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var ENV_DEBUG = process.env['NODE_DEBUG'],
debugTagsRe = (typeof ENV_DEBUG === 'string' && ENV_DEBUG.trim().length > 0) &&
new RegExp('^(' + ENV_DEBUG.replace(/\s+/g, '|') + ')(?::\\S+)*$', 'i');
module.exports =
/**
* @example
* let NODE_DEBUG="app lib:hello:world lib:trace"
*
* isDebugEnabledFor('some_module') => false
* isDebugEnabledFor('app') => true
* isDebugEnabledFor('app:main') => true
* isDebugEnabledFor('lib:hello:earth') => false
* isDebugEnabledFor('lib:hello:world') => true
* isDebugEnabledFor('lib') => false
* isDebugEnabledFor('lib:trace:fn') => true
*
* @param {String} tag format: ^[^:]+(\:[^:]+)*
* @returns {Boolean}
*/
function(tag) {
return debugTagsRe && debugTagsRe.test(tag);
};
module.exports.regexp = debugTagsRe;