Skip to content

Commit ca077fd

Browse files
committed
Corrected lint errors
1 parent 05267c2 commit ca077fd

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

src/asyncGeneratorMap.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ async function * asyncGeneratorMap (iterable, iteratee, queueOrConcurrency = 1,
188188
yield result.snapshot.value
189189
yielded = true
190190
} finally {
191-
if (!yielded)
192-
{
191+
if (!yielded) {
193192
await it.return()
194-
return
195193
}
196194
}
197195
}

src/asyncGeneratorMap.test.mjs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
/* eslint-disable require-jsdoc, jsdoc/require-jsdoc */
3+
24
import { expect, test } from '@jest/globals'
35
import asyncGeneratorMap from './asyncGeneratorMap.mjs'
46
import { range } from 'itertools'
@@ -8,7 +10,6 @@ import Deferred from './Deferred.mjs'
810
import asyncSleep from './asyncSleep'
911
import asyncIterableToArray from './asyncIterableToArray.mjs'
1012

11-
// eslint-disable-next-line require-jsdoc
1213
class TestError extends Error {}
1314

1415
test('asyncGeneratorMap base', async () => {
@@ -634,16 +635,15 @@ test('asyncGeneratorMap reaches concurrency', async () => {
634635
})
635636

636637
test('common for await interrupts generator on interrupted iteration', async () => {
638+
let finallyReached = false
637639

638-
let finallyReached = false;
639-
640-
async function *asyncGenWithFinally() {
640+
async function * asyncGenWithFinally () {
641641
try {
642642
for (const element of range(10)) {
643-
yield element;
643+
yield element
644644
}
645645
} finally {
646-
finallyReached = true;
646+
finallyReached = true
647647
}
648648
}
649649

@@ -653,54 +653,51 @@ test('common for await interrupts generator on interrupted iteration', async ()
653653
}
654654
}
655655

656-
expect(finallyReached).toBe(true);
656+
expect(finallyReached).toBe(true)
657657
})
658658

659659
test('common for await calls AsyncGenerator.return() not AsyncGenerator.throw()', async () => {
660+
let catchedException = null
660661

661-
let catchedException = null;
662-
663-
async function *asyncGenWithFinally() {
662+
async function * asyncGenWithFinally () {
664663
try {
665664
for (const element of range(10)) {
666-
yield element;
665+
yield element
667666
}
668667
} catch (e) {
669-
catchedException = e;
668+
catchedException = e
670669
}
671670
}
672671

673672
try {
674673
for await (const n of asyncGenWithFinally()) {
675674
if (n === 2) {
676-
throw new TestError();
675+
throw new TestError()
677676
}
678677
}
679-
} catch (e) // ignore
680-
{
678+
} catch (e) {
681679
expect(e instanceof TestError).toBe(true)
682680
}
683-
expect(catchedException).toBe(null);
681+
expect(catchedException).toBe(null)
684682
})
685683

686684
test('asyncGeneratorMap interrupts generator on interrupted iteration', async () => {
685+
let finallyReached = false
687686

688-
let finallyReached = false;
689-
690-
async function *asyncGenWithFinally() {
687+
async function * asyncGenWithFinally () {
691688
try {
692689
for (const element of range(10)) {
693-
yield element;
690+
yield element
694691
}
695692
} finally {
696-
finallyReached = true;
693+
finallyReached = true
697694
}
698695
}
699696

700-
for await (const n of asyncGeneratorMap(asyncGenWithFinally(), n => n*2)) {
697+
for await (const n of asyncGeneratorMap(asyncGenWithFinally(), n => n * 2)) {
701698
if (n === 4) {
702699
break
703700
}
704701
}
705-
expect(finallyReached).toBe(true);
702+
expect(finallyReached).toBe(true)
706703
})

0 commit comments

Comments
 (0)