npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adaskothebeast/angular-date-http-interceptor

v11.0.1

Published

Angular HttpClient interceptor that deeply converts ISO 8601 date strings in JSON responses with a pluggable hierarchical converter.

Readme

🅰️ Angular Date HTTP Interceptor

@adaskothebeast/angular-date-http-interceptor converts date-like values in Angular HttpClient JSON responses. Supply any hierarchical converter—for example, the native-Date, Day.js, Luxon, or Temporal converter packages.

📦 Install

npm install @adaskothebeast/angular-date-http-interceptor @adaskothebeast/hierarchical-convert-to-date

⚙️ Standalone configuration

Pass the converter to withHierarchicalDateHttpInterceptor(converter). No separate provider is needed.

import { withHierarchicalDateHttpInterceptor } from '@adaskothebeast/angular-date-http-interceptor';
import { hierarchicalConvertToDate } from '@adaskothebeast/hierarchical-convert-to-date';
import { provideHttpClient, withFetch } from '@angular/common/http';

export const appConfig = {
  providers: [provideHttpClient(withFetch(), withHierarchicalDateHttpInterceptor(hierarchicalConvertToDate))],
};

When the converter should come from dependency injection instead (for example, to replace it in tests), call withHierarchicalDateHttpInterceptor() without an argument and register the converter with provideHierarchicalDateConverter(converter), which provides HIERARCHICAL_DATE_ADJUST_FUNCTION:

providers: [
  provideHierarchicalDateConverter(hierarchicalConvertToDate),
  provideHttpClient(withHierarchicalDateHttpInterceptor()),
],

If neither is configured, the first request fails with an error that names both options (instead of Angular's generic NullInjectorError).

The functional interceptor works with Angular's Fetch backend, XHR configuration, and httpResource().

🧱 NgModule configuration

For applications that use class-based interceptors, import AngularDateHttpInterceptorModule.forRoot(converter). The module registers the interceptor through HTTP_INTERCEPTORS, so the application must enable DI interceptors with withInterceptorsFromDi().

@NgModule({
  imports: [AngularDateHttpInterceptorModule.forRoot(hierarchicalConvertToDate)],
  providers: [provideHttpClient(withInterceptorsFromDi())],
})
export class AppModule {}

Importing AngularDateHttpInterceptorModule without forRoot still works when HIERARCHICAL_DATE_ADJUST_FUNCTION is provided separately.

🔍 Behavior

The interceptor converts an HttpResponse only when all of the following hold:

  • the request's responseType is 'json' (Angular's default); arraybuffer, blob, and text responses are never touched, even when the server labels them as JSON;
  • the Content-Type media type is application/json or any structured JSON suffix type such as application/vnd.api+json, application/hal+json, or application/ld+json (case-insensitive, parameters such as charset ignored);
  • the body is not null.

Responses without a Content-Type header are passed through unconverted. Angular may still parse such bodies as JSON, but without the header the interceptor cannot tell JSON from other payloads, so it leaves the decision to the server's labelling.

For a matching response, the interceptor clones the body with structuredClone, invokes the converter, and returns a cloned response containing the adjusted body. This leaves the original response body untouched. Non-response events pass through unchanged.

💡 The converter is responsible for deciding which values to transform. For native Date instances, use hierarchicalConvertToDate; substitute a converter from another hierarchical-convert-to-* package when your application uses a different date type.

⚠️ Interceptor order with class-transformer

structuredClone does not preserve class prototypes. When you combine this interceptor with class-based hydration (for example @adaskothebeast/angular-typed-http-client), the date interceptor must see the response before hydration. Angular passes responses through interceptors in reverse registration order, so register the hydrating interceptor first:

provideHttpClient(
  withFetch(),
  withTypedHttpClient(), // hydrates second
  withHierarchicalDateHttpInterceptor(hierarchicalConvertToDate), // converts first
);

With HTTP_INTERCEPTORS, register ClassTransformerHttpInterceptor before HierarchicalDateHttpInterceptor. In the reverse order the hydrated instances are cloned back into plain objects and their methods are lost.

Problem Details

JSON Problem Details (application/problem+json) bypass success conversion, including HTTP 200 responses. Use the exported isProblemDetailsError(error) guard to read httpStatus, typed problem members, and the original decoded body. Extension members such as errors and traceId are preserved. See the repository conversion contract for transport-specific behavior.