MCPcopy Index your code
hub / github.com/bitpay/bitcore / transform

Function transform

packages/bitcore-cli/test/create.test.ts:43–60  ·  view source on GitHub ↗
(chunk, encoding, respond)

Source from the content-addressed store, hash-verified

41 const io = new Transform({
42 encoding: 'utf-8',
43 transform(chunk, encoding, respond) {
44 chunk = chunk.toString();
45 // Uncomment to see CLI output during test
46 // process.stdout.write(chunk);
47
48 const isStep = chunk.endsWith(OUTPUT_END_SEQ) || step == stepInputs.length - 1; // viewing mnemonic (vim)
49 if (isStep) {
50 for (const input of stepInputs[step]) {
51 this.push(input);
52 }
53 step++;
54 } else if (chunk.includes('Error:')) {
55 return respond(chunk);
56 } else if (chunk.endsWith(' created successfully!\n\n')) {
57 child.stdin.end(); // send EOF to child so it can exit cleanly
58 }
59 respond();
60 }
61 });
62 const child = spawn('node', [CLI_EXEC, walletName, ...commonOpts], CLI_OPTS);
63 child.stderr.pipe(helpers.filterStderr()).pipe(process.stderr);

Callers

nothing calls this directly

Calls 5

endMethod · 0.80
hasMethod · 0.80
splitMethod · 0.80
matchMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected