Comparing version 4.3.7 to 4.4.0
{ | ||
"name": "debug", | ||
"version": "4.3.7", | ||
"version": "4.4.0", | ||
"repository": { | ||
@@ -59,3 +59,8 @@ "type": "git", | ||
"node": ">=6.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"import/extensions": "off" | ||
} | ||
} | ||
} |
@@ -132,2 +132,3 @@ /* eslint-env browser */ | ||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 | ||
// eslint-disable-next-line no-return-assign | ||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || | ||
@@ -134,0 +135,0 @@ // Is firebug? http://stackoverflow.com/a/398120/376773 |
@@ -169,20 +169,58 @@ | ||
let i; | ||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); | ||
const len = split.length; | ||
const split = (typeof namespaces === 'string' ? namespaces : '') | ||
.trim() | ||
.replace(' ', ',') | ||
.split(',') | ||
.filter(Boolean); | ||
for (i = 0; i < len; i++) { | ||
if (!split[i]) { | ||
// ignore empty strings | ||
continue; | ||
for (const ns of split) { | ||
if (ns[0] === '-') { | ||
createDebug.skips.push(ns.slice(1)); | ||
} else { | ||
createDebug.names.push(ns); | ||
} | ||
} | ||
} | ||
namespaces = split[i].replace(/\*/g, '.*?'); | ||
/** | ||
* Checks if the given string matches a namespace template, honoring | ||
* asterisks as wildcards. | ||
* | ||
* @param {String} search | ||
* @param {String} template | ||
* @return {Boolean} | ||
*/ | ||
function matchesTemplate(search, template) { | ||
let searchIndex = 0; | ||
let templateIndex = 0; | ||
let starIndex = -1; | ||
let matchIndex = 0; | ||
if (namespaces[0] === '-') { | ||
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); | ||
while (searchIndex < search.length) { | ||
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { | ||
// Match character or proceed with wildcard | ||
if (template[templateIndex] === '*') { | ||
starIndex = templateIndex; | ||
matchIndex = searchIndex; | ||
templateIndex++; // Skip the '*' | ||
} else { | ||
searchIndex++; | ||
templateIndex++; | ||
} | ||
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition | ||
// Backtrack to the last '*' and try to match more characters | ||
templateIndex = starIndex + 1; | ||
matchIndex++; | ||
searchIndex = matchIndex; | ||
} else { | ||
createDebug.names.push(new RegExp('^' + namespaces + '$')); | ||
return false; // No match | ||
} | ||
} | ||
// Handle trailing '*' in template | ||
while (templateIndex < template.length && template[templateIndex] === '*') { | ||
templateIndex++; | ||
} | ||
return templateIndex === template.length; | ||
} | ||
@@ -198,4 +236,4 @@ | ||
const namespaces = [ | ||
...createDebug.names.map(toNamespace), | ||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) | ||
...createDebug.names, | ||
...createDebug.skips.map(namespace => '-' + namespace) | ||
].join(','); | ||
@@ -214,11 +252,4 @@ createDebug.enable(''); | ||
function enabled(name) { | ||
if (name[name.length - 1] === '*') { | ||
return true; | ||
} | ||
let i; | ||
let len; | ||
for (i = 0, len = createDebug.skips.length; i < len; i++) { | ||
if (createDebug.skips[i].test(name)) { | ||
for (const skip of createDebug.skips) { | ||
if (matchesTemplate(name, skip)) { | ||
return false; | ||
@@ -228,4 +259,4 @@ } | ||
for (i = 0, len = createDebug.names.length; i < len; i++) { | ||
if (createDebug.names[i].test(name)) { | ||
for (const ns of createDebug.names) { | ||
if (matchesTemplate(name, ns)) { | ||
return true; | ||
@@ -239,15 +270,2 @@ } | ||
/** | ||
* Convert regexp to namespace | ||
* | ||
* @param {RegExp} regxep | ||
* @return {String} namespace | ||
* @api private | ||
*/ | ||
function toNamespace(regexp) { | ||
return regexp.toString() | ||
.substring(2, regexp.toString().length - 2) | ||
.replace(/\.\*\?$/, '*'); | ||
} | ||
/** | ||
* Coerce `val`. | ||
@@ -254,0 +272,0 @@ * |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42798
735