From d816f741d107866f0f693f9e1bb4b50d0c63ffa8 Mon Sep 17 00:00:00 2001 From: beefchimi Date: Tue, 30 Jul 2024 12:10:12 -0400 Subject: [PATCH] :art: [Format] All helpers folder files --- pkg/helpers/fetch-audio-buffer.ts | 9 ++++++++- pkg/helpers/tests/fetch-audio-buffer.test.ts | 3 ++- pkg/helpers/tests/linear-ramp.test.ts | 2 +- pkg/helpers/tests/scratch-buffer.test.ts | 2 +- pkg/helpers/tests/unlock-audio-context.test.ts | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/helpers/fetch-audio-buffer.ts b/pkg/helpers/fetch-audio-buffer.ts index 7184fbd..77e5b9b 100644 --- a/pkg/helpers/fetch-audio-buffer.ts +++ b/pkg/helpers/fetch-audio-buffer.ts @@ -1,8 +1,12 @@ async function fetchRequest(path: string, options?: RequestInit) { const audioRequest = new Request(path, options); + // eslint-disable-next-line ts/return-await return await fetch(audioRequest).then((response) => { - if (!response.ok) throw new Error(`Network status: ${response.status}`); + if (!response.ok) { + throw new Error(`Network status: ${response.status}`); + } + return response; }); } @@ -12,7 +16,10 @@ export async function fetchAudioBuffer( context: AudioContext, options?: RequestInit, ) { + // eslint-disable-next-line ts/return-await return await fetchRequest(path, options) + // eslint-disable-next-line ts/return-await .then(async (response) => await response.arrayBuffer()) + // eslint-disable-next-line ts/return-await .then(async (arrayBuffer) => await context.decodeAudioData(arrayBuffer)); } diff --git a/pkg/helpers/tests/fetch-audio-buffer.test.ts b/pkg/helpers/tests/fetch-audio-buffer.test.ts index 14bcc3d..6441046 100644 --- a/pkg/helpers/tests/fetch-audio-buffer.test.ts +++ b/pkg/helpers/tests/fetch-audio-buffer.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from 'vitest'; +import {describe, expect, it} from 'vitest'; import {mockData} from '@earwurm/mocks'; import {fetchAudioBuffer} from '../fetch-audio-buffer'; @@ -13,6 +13,7 @@ describe('fetchAudioBuffer()', () => { // `Failed to parse URL from ${mockPath}` // However, we now get back a `[object Request]`, await expect( + // eslint-disable-next-line ts/return-await async () => await fetchAudioBuffer(mockPath, mockContext), ).rejects.toThrowError(); }); diff --git a/pkg/helpers/tests/linear-ramp.test.ts b/pkg/helpers/tests/linear-ramp.test.ts index f552158..c8b4056 100644 --- a/pkg/helpers/tests/linear-ramp.test.ts +++ b/pkg/helpers/tests/linear-ramp.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect, vi} from 'vitest'; +import {describe, expect, it, vi} from 'vitest'; import {linearRamp} from '../linear-ramp'; diff --git a/pkg/helpers/tests/scratch-buffer.test.ts b/pkg/helpers/tests/scratch-buffer.test.ts index 7ea2270..3decc12 100644 --- a/pkg/helpers/tests/scratch-buffer.test.ts +++ b/pkg/helpers/tests/scratch-buffer.test.ts @@ -1,4 +1,4 @@ -import {describe, it, expect} from 'vitest'; +import {describe, expect, it} from 'vitest'; import {scratchBuffer} from '../scratch-buffer'; diff --git a/pkg/helpers/tests/unlock-audio-context.test.ts b/pkg/helpers/tests/unlock-audio-context.test.ts index 8c6a1e3..39691db 100644 --- a/pkg/helpers/tests/unlock-audio-context.test.ts +++ b/pkg/helpers/tests/unlock-audio-context.test.ts @@ -1,4 +1,4 @@ -import {afterEach, describe, it, expect, vi} from 'vitest'; +import {afterEach, describe, expect, it, vi} from 'vitest'; import {audioBufferSourceNodeEndedEvent} from '@earwurm/mocks'; import {unlockAudioContext} from '../unlock-audio-context';