MCPcopy Index your code
hub / github.com/nodejs/node / normalizeEncoding

Function normalizeEncoding

lib/internal/util.js:258–261  ·  view source on GitHub ↗

* Move the "slow cases" to a separate function to make sure this function gets * inlined properly. That prioritizes the common case. * @param {unknown} enc * @returns {string | undefined} Returns undefined if there is no match.

(enc)

Source from the content-addressed store, hash-verified

256 * @returns {string | undefined} Returns undefined if there is no match.
257 */
258function normalizeEncoding(enc) {
259 if (enc == null || enc === 'utf8' || enc === 'utf-8') return 'utf8';
260 return slowCases(enc);
261}
262
263function slowCases(enc) {
264 switch (enc.length) {

Callers 9

buffer.jsFile · 0.85
_fillFunction · 0.85
StringDecoderFunction · 0.85
validators.jsFile · 0.85
getDecoderFunction · 0.85
hashFunction · 0.85
writeFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 1

slowCasesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…