I wouldn't argue that you should use yield*
for performance.
You should use yield*
whenever you want to emit all the events of another stream inside an async*
function.
The yield*
differs from yield
in that the latter emits a single value, and the former emits all the events of another stream.
Doing
yield* someStream;
is almost the same as doing:
await for (var value in someStream) {
yield value;
}
That is, the yield*
emits the same data events as the stream it works on.
The difference is that yield*
also emits error events, and always emits the entire stream, where the await for
stops at the first error event.
You should not make your function recursive unless necessary, just to use yield*
, that's not going to help performance.