MCPcopy
hub / github.com/webpack/webpack / numberToIdentifier

Method numberToIdentifier

lib/Template.js:166–190  ·  view source on GitHub ↗

* Number to identifier. * @param {number} n number to convert to ident * @returns {string} returns single character ident

(n)

Source from the content-addressed store, hash-verified

164 * @returns {string} returns single character ident
165 */
166 static numberToIdentifier(n) {
167 if (n >= NUMBER_OF_IDENTIFIER_START_CHARS) {
168 // use multiple letters
169 return (
170 Template.numberToIdentifier(n % NUMBER_OF_IDENTIFIER_START_CHARS) +
171 Template.numberToIdentifierContinuation(
172 Math.floor(n / NUMBER_OF_IDENTIFIER_START_CHARS)
173 )
174 );
175 }
176
177 // lower case
178 if (n < DELTA_A_TO_Z) {
179 return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
180 }
181 n -= DELTA_A_TO_Z;
182
183 // upper case
184 if (n < DELTA_A_TO_Z) {
185 return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
186 }
187
188 if (n === DELTA_A_TO_Z) return "_";
189 return "$";
190 }
191
192 /**
193 * Number to identifier continuation.

Callers 2

getUsedDependenciesFunction · 0.80

Calls 1

Tested by

no test coverage detected