Skip to content

Commit

Permalink
improving concurrencyFork
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Aug 2, 2023
1 parent 7698faa commit aac4ef2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ops/concurrency-fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function concurrencyForkSync<T, R>(
work: IConcurrencyWork<T, R>
): Iterable<R> {
try {
return work.onSync?.(iterable) ?? (iterable as Iterable<any>);
const i = typeof work.onSync === 'function' && work.onSync(iterable);
return i || (iterable as Iterable<any>);
} catch (err) {
return {
[$S](): Iterator<R> {
Expand All @@ -113,7 +114,8 @@ function concurrencyForkAsync<T, R>(
work: IConcurrencyWork<T, R>
): AsyncIterable<R> {
try {
return work.onAsync?.(iterable) ?? (iterable as AsyncIterable<any>);
const i = typeof work.onAsync === 'function' && work.onAsync(iterable);
return i || (iterable as AsyncIterable<any>);
} catch (err) {
return {
[$A](): AsyncIterator<R> {
Expand Down

0 comments on commit aac4ef2

Please sign in to comment.