Changeset 79a0317 for imaps-frontend/node_modules/debug/src
- Timestamp:
- 01/21/25 03:08:24 (3 days ago)
- Branches:
- main
- Parents:
- 0c6b92a
- Location:
- imaps-frontend/node_modules/debug/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/debug/src/browser.js
r0c6b92a r79a0317 130 130 // Is webkit? http://stackoverflow.com/a/16459606/376773 131 131 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 132 // eslint-disable-next-line no-return-assign 132 133 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || 133 134 // Is firebug? http://stackoverflow.com/a/398120/376773 -
imaps-frontend/node_modules/debug/src/common.js
r0c6b92a r79a0317 167 167 createDebug.skips = []; 168 168 169 let i; 170 const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); 171 const len = split.length; 172 173 for (i = 0; i < len; i++) { 174 if (!split[i]) { 175 // ignore empty strings 176 continue; 177 } 178 179 namespaces = split[i].replace(/\*/g, '.*?'); 180 181 if (namespaces[0] === '-') { 182 createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); 169 const split = (typeof namespaces === 'string' ? namespaces : '') 170 .trim() 171 .replace(' ', ',') 172 .split(',') 173 .filter(Boolean); 174 175 for (const ns of split) { 176 if (ns[0] === '-') { 177 createDebug.skips.push(ns.slice(1)); 183 178 } else { 184 createDebug.names.push(new RegExp('^' + namespaces + '$')); 185 } 186 } 179 createDebug.names.push(ns); 180 } 181 } 182 } 183 184 /** 185 * Checks if the given string matches a namespace template, honoring 186 * asterisks as wildcards. 187 * 188 * @param {String} search 189 * @param {String} template 190 * @return {Boolean} 191 */ 192 function matchesTemplate(search, template) { 193 let searchIndex = 0; 194 let templateIndex = 0; 195 let starIndex = -1; 196 let matchIndex = 0; 197 198 while (searchIndex < search.length) { 199 if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { 200 // Match character or proceed with wildcard 201 if (template[templateIndex] === '*') { 202 starIndex = templateIndex; 203 matchIndex = searchIndex; 204 templateIndex++; // Skip the '*' 205 } else { 206 searchIndex++; 207 templateIndex++; 208 } 209 } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition 210 // Backtrack to the last '*' and try to match more characters 211 templateIndex = starIndex + 1; 212 matchIndex++; 213 searchIndex = matchIndex; 214 } else { 215 return false; // No match 216 } 217 } 218 219 // Handle trailing '*' in template 220 while (templateIndex < template.length && template[templateIndex] === '*') { 221 templateIndex++; 222 } 223 224 return templateIndex === template.length; 187 225 } 188 226 … … 195 233 function disable() { 196 234 const namespaces = [ 197 ...createDebug.names .map(toNamespace),198 ...createDebug.skips.map( toNamespace).map(namespace => '-' + namespace)235 ...createDebug.names, 236 ...createDebug.skips.map(namespace => '-' + namespace) 199 237 ].join(','); 200 238 createDebug.enable(''); … … 210 248 */ 211 249 function enabled(name) { 212 if (name[name.length - 1] === '*') { 213 return true; 214 } 215 216 let i; 217 let len; 218 219 for (i = 0, len = createDebug.skips.length; i < len; i++) { 220 if (createDebug.skips[i].test(name)) { 250 for (const skip of createDebug.skips) { 251 if (matchesTemplate(name, skip)) { 221 252 return false; 222 253 } 223 254 } 224 255 225 for ( i = 0, len = createDebug.names.length; i < len; i++) {226 if ( createDebug.names[i].test(name)) {256 for (const ns of createDebug.names) { 257 if (matchesTemplate(name, ns)) { 227 258 return true; 228 259 } … … 230 261 231 262 return false; 232 }233 234 /**235 * Convert regexp to namespace236 *237 * @param {RegExp} regxep238 * @return {String} namespace239 * @api private240 */241 function toNamespace(regexp) {242 return regexp.toString()243 .substring(2, regexp.toString().length - 2)244 .replace(/\.\*\?$/, '*');245 263 } 246 264
Note:
See TracChangeset
for help on using the changeset viewer.