| 1094 | var hasRequiredCommon; |
| 1095 | |
| 1096 | function requireCommon () { |
| 1097 | if (hasRequiredCommon) return common; |
| 1098 | hasRequiredCommon = 1; |
| 1099 | /** |
| 1100 | * This is the common logic for both the Node.js and web browser |
| 1101 | * implementations of `debug()`. |
| 1102 | */ |
| 1103 | |
| 1104 | function setup(env) { |
| 1105 | createDebug.debug = createDebug; |
| 1106 | createDebug.default = createDebug; |
| 1107 | createDebug.coerce = coerce; |
| 1108 | createDebug.disable = disable; |
| 1109 | createDebug.enable = enable; |
| 1110 | createDebug.enabled = enabled; |
| 1111 | createDebug.humanize = requireMs(); |
| 1112 | createDebug.destroy = destroy; |
| 1113 | |
| 1114 | Object.keys(env).forEach(key => { |
| 1115 | createDebug[key] = env[key]; |
| 1116 | }); |
| 1117 | |
| 1118 | /** |
| 1119 | * The currently active debug mode names, and names to skip. |
| 1120 | */ |
| 1121 | |
| 1122 | createDebug.names = []; |
| 1123 | createDebug.skips = []; |
| 1124 | |
| 1125 | /** |
| 1126 | * Map of special "%n" handling functions, for the debug "format" argument. |
| 1127 | * |
| 1128 | * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". |
| 1129 | */ |
| 1130 | createDebug.formatters = {}; |
| 1131 | |
| 1132 | /** |
| 1133 | * Selects a color for a debug namespace |
| 1134 | * @param {String} namespace The namespace string for the debug instance to be colored |
| 1135 | * @return {Number|String} An ANSI color code for the given namespace |
| 1136 | * @api private |
| 1137 | */ |
| 1138 | function selectColor(namespace) { |
| 1139 | let hash = 0; |
| 1140 | |
| 1141 | for (let i = 0; i < namespace.length; i++) { |
| 1142 | hash = ((hash << 5) - hash) + namespace.charCodeAt(i); |
| 1143 | hash |= 0; // Convert to 32bit integer |
| 1144 | } |
| 1145 | |
| 1146 | return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; |
| 1147 | } |
| 1148 | createDebug.selectColor = selectColor; |
| 1149 | |
| 1150 | /** |
| 1151 | * Create a debugger with the given `namespace`. |
| 1152 | * |
| 1153 | * @param {String} namespace |