| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8cbd901 commit f32b412
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -458,11 +458,8 @@ async function testWriteWithAbortedSignalRejects() { | |||
| 458 | 458 | const fh = await open(filePath, 'w'); | |
| 459 | 459 | const w = fh.writer(); | |
| 460 | 460 | ||
| 461 | - const ac = new AbortController(); | ||
| 462 | - ac.abort(); | ||
| 463 | - | ||
| 464 | 461 | await assert.rejects( | |
| 465 | - w.write(Buffer.from('data'), { signal: ac.signal }), | ||
| 462 | + w.write(Buffer.from('data'), { signal: AbortSignal.abort() }), | ||
| 466 | 463 | { name: 'AbortError' }, | |
| 467 | 464 | ); | |
| 468 | 465 | ||
@@ -479,11 +476,8 @@ async function testWritevWithAbortedSignalRejects() { | |||
| 479 | 476 | const fh = await open(filePath, 'w'); | |
| 480 | 477 | const w = fh.writer(); | |
| 481 | 478 | ||
| 482 | - const ac = new AbortController(); | ||
| 483 | - ac.abort(); | ||
| 484 | - | ||
| 485 | 479 | await assert.rejects( | |
| 486 | - w.writev([Buffer.from('a'), Buffer.from('b')], { signal: ac.signal }), | ||
| 480 | + w.writev([Buffer.from('a'), Buffer.from('b')], { signal: AbortSignal.abort() }), | ||
| 487 | 481 | { name: 'AbortError' }, | |
| 488 | 482 | ); | |
| 489 | 483 | ||
@@ -501,11 +495,8 @@ async function testEndWithAbortedSignalRejects() { | |||
| 501 | 495 | ||
| 502 | 496 | await w.write(Buffer.from('data')); | |
| 503 | 497 | ||
| 504 | - const ac = new AbortController(); | ||
| 505 | - ac.abort(); | ||
| 506 | - | ||
| 507 | 498 | await assert.rejects( | |
| 508 | - w.end({ signal: ac.signal }), | ||
| 499 | + w.end({ signal: AbortSignal.abort() }), | ||
| 509 | 500 | { name: 'AbortError' }, | |
| 510 | 501 | ); | |
| 511 | 502 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,11 +97,9 @@ describe('Mock Timers Scheduler Test Suite', () => { | |||
| 97 | 97 | ||
| 98 | 98 | it('should abort operation when .abort is called before calling setInterval', async (t) => { | |
| 99 | 99 | t.mock.timers.enable({ apis: ['scheduler.wait'] }); | |
| 100 | - const controller = new AbortController(); | ||
| 101 | - controller.abort(); | ||
| 102 | 100 | const p = nodeTimersPromises.scheduler.wait(2000, { | |
| 103 | 101 | ref: true, | |
| 104 | - signal: controller.signal, | ||
| 102 | + signal: AbortSignal.abort(), | ||
| 105 | 103 | }); | |
| 106 | 104 | ||
| 107 | 105 | await assert.rejects(() => p, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -551,11 +551,9 @@ describe('Mock Timers Test Suite', () => { | |||
| 551 | 551 | it('should abort operation when .abort is called before calling setInterval', async (t) => { | |
| 552 | 552 | t.mock.timers.enable({ apis: ['setTimeout'] }); | |
| 553 | 553 | const expectedResult = 'result'; | |
| 554 | - const controller = new AbortController(); | ||
| 555 | - controller.abort(); | ||
| 556 | 554 | const p = nodeTimersPromises.setTimeout(2000, expectedResult, { | |
| 557 | 555 | ref: true, | |
| 558 | - signal: controller.signal, | ||
| 556 | + signal: AbortSignal.abort(), | ||
| 559 | 557 | }); | |
| 560 | 558 | ||
| 561 | 559 | await assert.rejects(() => p, { | |
@@ -778,10 +776,8 @@ describe('Mock Timers Test Suite', () => { | |||
| 778 | 776 | t.mock.timers.enable({ apis: ['setInterval'] }); | |
| 779 | 777 | ||
| 780 | 778 | const interval = 100; | |
| 781 | - const abortController = new AbortController(); | ||
| 782 | - abortController.abort(); | ||
| 783 | 779 | const intervalIterator = nodeTimersPromises.setInterval(interval, Date.now(), { | |
| 784 | - signal: abortController.signal, | ||
| 780 | + signal: AbortSignal.abort(), | ||
| 785 | 781 | }); | |
| 786 | 782 | ||
| 787 | 783 | const first = intervalIterator.next(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -101,10 +101,7 @@ async function testAbortSignal() { | |||
| 101 | 101 | } | |
| 102 | 102 | ||
| 103 | 103 | async function testAlreadyAbortedSignal() { | |
| 104 | - const ac = new AbortController(); | ||
| 105 | - ac.abort(); | ||
| 106 | - | ||
| 107 | - const { broadcast: bc } = broadcast({ signal: ac.signal }); | ||
| 104 | + const { broadcast: bc } = broadcast({ signal: AbortSignal.abort() }); | ||
| 108 | 105 | const consumer = bc.push(); | |
| 109 | 106 | ||
| 110 | 107 | await assert.rejects(async () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,10 +46,8 @@ async function testBytesAsyncLimit() { | |||
| 46 | 46 | } | |
| 47 | 47 | ||
| 48 | 48 | async function testBytesAsyncAbort() { | |
| 49 | - const ac = new AbortController(); | ||
| 50 | - ac.abort(); | ||
| 51 | 49 | await assert.rejects( | |
| 52 | - () => bytes(from('data'), { signal: ac.signal }), | ||
| 50 | + () => bytes(from('data'), { signal: AbortSignal.abort() }), | ||
| 53 | 51 | { name: 'AbortError' }, | |
| 54 | 52 | ); | |
| 55 | 53 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,10 +55,7 @@ async function testMergeEmpty() { | |||
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | 57 | async function testMergeWithAbortSignal() { | |
| 58 | - const ac = new AbortController(); | ||
| 59 | - ac.abort(); | ||
| 60 | - | ||
| 61 | - const merged = merge(from('data'), { signal: ac.signal }); | ||
| 58 | + const merged = merge(from('data'), { signal: AbortSignal.abort() }); | ||
| 62 | 59 | ||
| 63 | 60 | await assert.rejects( | |
| 64 | 61 | async () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,10 +96,8 @@ async function testTextEmpty() { | |||
| 96 | 96 | ||
| 97 | 97 | // text() with abort signal | |
| 98 | 98 | async function testTextWithSignal() { | |
| 99 | - const ac = new AbortController(); | ||
| 100 | - ac.abort(); | ||
| 101 | 99 | await assert.rejects( | |
| 102 | - () => text(from('data'), { signal: ac.signal }), | ||
| 100 | + () => text(from('data'), { signal: AbortSignal.abort() }), | ||
| 103 | 101 | { name: 'AbortError' }, | |
| 104 | 102 | ); | |
| 105 | 103 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,14 +41,11 @@ async function testPullStatefulTransform() { | |||
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | 43 | async function testPullWithAbortSignal() { | |
| 44 | - const ac = new AbortController(); | ||
| 45 | - ac.abort(); | ||
| 46 | - | ||
| 47 | 44 | async function* gen() { | |
| 48 | 45 | yield [new Uint8Array([1])]; | |
| 49 | 46 | } | |
| 50 | 47 | ||
| 51 | - const result = pull(gen(), { signal: ac.signal }); | ||
| 48 | + const result = pull(gen(), { signal: AbortSignal.abort() }); | ||
| 52 | 49 | await assert.rejects( | |
| 53 | 50 | async () => { | |
| 54 | 51 | // eslint-disable-next-line no-unused-vars | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,9 +109,7 @@ async function testAbortSignal() { | |||
| 109 | 109 | } | |
| 110 | 110 | ||
| 111 | 111 | async function testPreAbortedSignal() { | |
| 112 | - const ac = new AbortController(); | ||
| 113 | - ac.abort(); | ||
| 114 | - const { readable } = push({ signal: ac.signal }); | ||
| 112 | + const { readable } = push({ signal: AbortSignal.abort() }); | ||
| 115 | 113 | await assert.rejects(async () => { | |
| 116 | 114 | // eslint-disable-next-line no-unused-vars | |
| 117 | 115 | for await (const _ of readable) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,12 +61,9 @@ async function testWriteWithSignalRejects() { | |||
| 61 | 61 | async function testWriteWithPreAbortedSignal() { | |
| 62 | 62 | const { writer, readable } = push({ highWaterMark: 1 }); | |
| 63 | 63 | ||
| 64 | - const ac = new AbortController(); | ||
| 65 | - ac.abort(); | ||
| 66 | - | ||
| 67 | 64 | // Pre-aborted signal should reject immediately | |
| 68 | 65 | await assert.rejects( | |
| 69 | - writer.write('data', { signal: ac.signal }), | ||
| 66 | + writer.write('data', { signal: AbortSignal.abort() }), | ||
| 70 | 67 | { name: 'AbortError' }, | |
| 71 | 68 | ); | |
| 72 | 69 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments