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

Function transform

packages/bitcore-cli/test/proposals.test.ts:41–68  ·  view source on GitHub ↗
(chunk, encoding, respond)

Source from the content-addressed store, hash-verified

39 const io = new Transform({
40 encoding: 'utf-8',
41 transform(chunk, encoding, respond) {
42 chunk = chunk.toString();
43 if (checkpoints.has(step)) {
44 checkpointOutput += chunk;
45 } else {
46 checkpointOutput = '';
47 }
48 // Uncomment to see CLI output during test
49 // process.stdout.write(chunk);
50
51 const isStep = chunk.endsWith(OUTPUT_END_SEQ);
52 if (isStep) {
53 for (const input of stepInputs[step]) {
54 this.push(input);
55 }
56 if (checkpoints.has(step)) {
57 // Assert proposals output contains expected info for no pending proposals
58 assert.match(checkpointOutput, /No more proposals/);
59 }
60 step++;
61 } else if (chunk.includes('Error:')) {
62 return respond(chunk);
63 }
64 if (chunk.includes('👋')) {
65 child.stdin.end(); // send EOF to child so it can exit cleanly
66 }
67 respond();
68 }
69 });
70 const child = spawn('node', [CLI_EXEC, WALLETS.BTC.SINGLE_SIG, ...cmdOpts], CLI_OPTS);
71 child.stderr.pipe(process.stderr);

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected