Skip to content

Commit 251518b

Browse files
natemoo-regithub-actions[bot]
authored andcommitted
[ci] format
1 parent a38b2bc commit 251518b

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

examples/basic/stream.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,28 @@ async function main() {
99

1010
p.intro(`${color.bgCyan(color.black(' create-app '))}`);
1111

12-
await p.stream.step((async function* () {
13-
for (const line of lorem) {
14-
for (const word of line.split(' ')) {
15-
yield word;
16-
yield ' ';
17-
await setTimeout(200);
12+
await p.stream.step(
13+
(async function* () {
14+
for (const line of lorem) {
15+
for (const word of line.split(' ')) {
16+
yield word;
17+
yield ' ';
18+
await setTimeout(200);
19+
}
20+
yield '\n';
21+
if (line !== lorem.at(-1)) {
22+
await setTimeout(1000);
23+
}
1824
}
19-
yield '\n';
20-
if (line !== lorem.at(-1)) {
21-
await setTimeout(1000);
22-
}
23-
}
24-
})())
25+
})()
26+
);
2527

2628
p.outro(`Problems? ${color.underline(color.cyan('https://example.com/issues'))}`);
2729
}
2830

2931
const lorem = [
30-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
32+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
3133
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
32-
]
34+
];
3335

3436
main().catch(console.error);

packages/prompts/src/index.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,10 @@ export const log = {
677677

678678
const prefix = `${color.gray(S_BAR)} `;
679679
export const stream = {
680-
message: async (iterable: Iterable<string>|AsyncIterable<string>, { symbol = color.gray(S_BAR) }: LogMessageOptions = {}) => {
680+
message: async (
681+
iterable: Iterable<string> | AsyncIterable<string>,
682+
{ symbol = color.gray(S_BAR) }: LogMessageOptions = {}
683+
) => {
681684
process.stdout.write(`${color.gray(S_BAR)}\n${symbol} `);
682685
let lineWidth = 3;
683686
for await (let chunk of iterable) {
@@ -686,7 +689,7 @@ export const stream = {
686689
lineWidth = 3 + strip(chunk.slice(chunk.lastIndexOf('\n'))).length;
687690
}
688691
const chunkLen = strip(chunk).length;
689-
if ((lineWidth + chunkLen) < process.stdout.columns) {
692+
if (lineWidth + chunkLen < process.stdout.columns) {
690693
lineWidth += chunkLen;
691694
process.stdout.write(chunk);
692695
} else {
@@ -696,26 +699,26 @@ export const stream = {
696699
}
697700
process.stdout.write('\n');
698701
},
699-
info: (iterable: Iterable<string>|AsyncIterable<string>) => {
702+
info: (iterable: Iterable<string> | AsyncIterable<string>) => {
700703
return stream.message(iterable, { symbol: color.blue(S_INFO) });
701704
},
702-
success: (iterable: Iterable<string>|AsyncIterable<string>) => {
705+
success: (iterable: Iterable<string> | AsyncIterable<string>) => {
703706
return stream.message(iterable, { symbol: color.green(S_SUCCESS) });
704707
},
705-
step: (iterable: Iterable<string>|AsyncIterable<string>) => {
708+
step: (iterable: Iterable<string> | AsyncIterable<string>) => {
706709
return stream.message(iterable, { symbol: color.green(S_STEP_SUBMIT) });
707710
},
708-
warn: (iterable: Iterable<string>|AsyncIterable<string>) => {
711+
warn: (iterable: Iterable<string> | AsyncIterable<string>) => {
709712
return stream.message(iterable, { symbol: color.yellow(S_WARN) });
710713
},
711714
/** alias for `log.warn()`. */
712-
warning: (iterable: Iterable<string>|AsyncIterable<string>) => {
715+
warning: (iterable: Iterable<string> | AsyncIterable<string>) => {
713716
return stream.warn(iterable);
714717
},
715-
error: (iterable: Iterable<string>|AsyncIterable<string>) => {
718+
error: (iterable: Iterable<string> | AsyncIterable<string>) => {
716719
return stream.message(iterable, { symbol: color.red(S_ERROR) });
717720
},
718-
}
721+
};
719722

720723
export const spinner = () => {
721724
const frames = unicode ? ['◒', '◐', '◓', '◑'] : ['•', 'o', 'O', '0'];

0 commit comments

Comments
 (0)