MCPcopy Create free account
hub / github.com/sindresorhus/execa / getCorrectEncoding

Function getCorrectEncoding

lib/arguments/encoding-option.js:22–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20const ENCODINGS = TEXT_ENCODINGS.union(BINARY_ENCODINGS);
21
22const getCorrectEncoding = encoding => {
23 if (encoding === null) {
24 return 'buffer';
25 }
26
27 if (typeof encoding !== 'string') {
28 return;
29 }
30
31 const lowerEncoding = encoding.toLowerCase();
32 if (lowerEncoding in ENCODING_ALIASES) {
33 return ENCODING_ALIASES[lowerEncoding];
34 }
35
36 if (ENCODINGS.has(lowerEncoding)) {
37 return lowerEncoding;
38 }
39};
40
41const ENCODING_ALIASES = {
42 // eslint-disable-next-line unicorn/text-encoding-identifier-case

Callers 1

validateEncodingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected