diff --git a/.changeset/tall-bees-cheer.md b/.changeset/tall-bees-cheer.md new file mode 100644 index 000000000..82610c181 --- /dev/null +++ b/.changeset/tall-bees-cheer.md @@ -0,0 +1,5 @@ +--- +'@hey-api/client-fetch': minor +--- + +feat: Function to clear and check if exist an interceptor in client-fetch diff --git a/packages/client-fetch/src/utils.ts b/packages/client-fetch/src/utils.ts index d5ae551d8..3fbc16855 100644 --- a/packages/client-fetch/src/utils.ts +++ b/packages/client-fetch/src/utils.ts @@ -440,6 +440,14 @@ class Interceptors<Interceptor> { this._fns = []; } + clear() { + this._fns = []; + } + + exists(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap index d5ae551d8..3fbc16855 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle/core/utils.ts.snap @@ -440,6 +440,14 @@ class Interceptors<Interceptor> { this._fns = []; } + clear() { + this._fns = []; + } + + exists(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) { diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap index d5ae551d8..3fbc16855 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-bundle_transform/core/utils.ts.snap @@ -440,6 +440,14 @@ class Interceptors<Interceptor> { this._fns = []; } + clear() { + this._fns = []; + } + + exists(fn: Interceptor) { + return this._fns.indexOf(fn) !== -1; + } + eject(fn: Interceptor) { const index = this._fns.indexOf(fn); if (index !== -1) {