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

Function getEncodingTransformGenerator

lib/transform/encoding-transform.js:16–30  ·  view source on GitHub ↗
(binary, encoding, skipped)

Source from the content-addressed store, hash-verified

14- on reads: `Duplex.readable` `readableEncoding: null` default option
15*/
16export const getEncodingTransformGenerator = (binary, encoding, skipped) => {
17 if (skipped) {
18 return;
19 }
20
21 if (binary) {
22 return {transform: encodingUint8ArrayGenerator.bind(undefined, new TextEncoder())};
23 }
24
25 const stringDecoder = new StringDecoder(encoding);
26 return {
27 transform: encodingStringGenerator.bind(undefined, stringDecoder),
28 final: encodingStringFinal.bind(undefined, stringDecoder),
29 };
30};
31
32const encodingUint8ArrayGenerator = function * (textEncoder, chunk) {
33 if (Buffer.isBuffer(chunk)) {

Callers 2

getGeneratorsFunction · 0.90
addInternalGeneratorsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected