Skip to content

Excessive ^$ regexp. #30

@AlexeyKupershtokh

Description

@AlexeyKupershtokh

the debug module by default creates the ^$ regexp which is unnecessary, harmful, and makes things run slower.
Test case:

var mod = require('..');
var debug = mod('tes');
debug('x1');
var debug2 = mod('');
debug2('x2');

(process.env.DEBUG || '')
  .split(/[\s,]+/)
  .forEach(function(name){
    name = name.replace('*', '.*?');
    console.log('^' + name + '$');
  });

Output:

wicked@wicked-desktop:~/debug$ node example/test2.js 
   x2 +0ms
^$

Consider there's no DEBUG env in the call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions