| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,12 @@ | |||
| 22 | 22 | ||
| 23 | 23 | 'use strict'; | |
| 24 | 24 | ||
| 25 | + const { | ||
| 26 | + RegExpPrototypeTest, | ||
| 27 | + StringPrototypeSplit, | ||
| 28 | + StringPrototypeToLowerCase, | ||
| 29 | + } = primordials; | ||
| 30 | + | ||
| 25 | 31 | const { | |
| 26 | 32 | ERR_INVALID_ARG_TYPE, | |
| 27 | 33 | ERR_OUT_OF_RANGE | |
@@ -134,7 +140,7 @@ function getColorDepth(env = process.env) { | |||
| 134 | 140 | // Lazy load for startup performance. | |
| 135 | 141 | if (OSRelease === undefined) { | |
| 136 | 142 | const { release } = require('os'); | |
| 137 | - OSRelease = release().split('.'); | ||
| 143 | + OSRelease = StringPrototypeSplit(release(), '.'); | ||
| 138 | 144 | } | |
| 139 | 145 | // Windows 10 build 10586 is the first Windows release that supports 256 | |
| 140 | 146 | // colors. Windows 10 build 14931 is the first release that supports | |
@@ -163,14 +169,15 @@ function getColorDepth(env = process.env) { | |||
| 163 | 169 | } | |
| 164 | 170 | ||
| 165 | 171 | if ('TEAMCITY_VERSION' in env) { | |
| 166 | - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? | ||
| 172 | + return RegExpPrototypeTest(/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/, env.TEAMCITY_VERSION) ? | ||
| 167 | 173 | COLORS_16 : COLORS_2; | |
| 168 | 174 | } | |
| 169 | 175 | ||
| 170 | 176 | switch (env.TERM_PROGRAM) { | |
| 171 | 177 | case 'iTerm.app': | |
| 172 | 178 | if (!env.TERM_PROGRAM_VERSION || | |
| 173 | - /^[0-2]\./.test(env.TERM_PROGRAM_VERSION)) { | ||
| 179 | + RegExpPrototypeTest(/^[0-2]\./, env.TERM_PROGRAM_VERSION) | ||
| 180 | + ) { | ||
| 174 | 181 | return COLORS_256; | |
| 175 | 182 | } | |
| 176 | 183 | return COLORS_16m; | |
@@ -186,16 +193,17 @@ function getColorDepth(env = process.env) { | |||
| 186 | 193 | } | |
| 187 | 194 | ||
| 188 | 195 | if (env.TERM) { | |
| 189 | - if (/^xterm-256/.test(env.TERM)) | ||
| 196 | + if (RegExpPrototypeTest(/^xterm-256/, env.TERM)) { | ||
| 190 | 197 | return COLORS_256; | |
| 198 | + } | ||
| 191 | 199 | ||
| 192 | - const termEnv = env.TERM.toLowerCase(); | ||
| 200 | + const termEnv = StringPrototypeToLowerCase(env.TERM); | ||
| 193 | 201 | ||
| 194 | 202 | if (TERM_ENVS[termEnv]) { | |
| 195 | 203 | return TERM_ENVS[termEnv]; | |
| 196 | 204 | } | |
| 197 | 205 | for (const term of TERM_ENVS_REG_EXP) { | |
| 198 | - if (term.test(termEnv)) { | ||
| 206 | + if (RegExpPrototypeTest(term, termEnv)) { | ||
| 199 | 207 | return COLORS_16; | |
| 200 | 208 | } | |
| 201 | 209 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments