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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@art-suite/art-core-ts-communication-status

v0.8.0

Published

A TypeScript string utility library

Readme

@art-suite/art-core-ts-communication-status

When writing HTTP APIs, error handling doesn't need to be such a pain!

Simplifies all API communication-related state down to just 9, human-readable AND machine-interptable statuses, 4 of which HTTP doesn't even handle!

  • "success"
  • "missing"
  • "clientFailure"
  • "clientFailureNotAuthorized"
  • "serverFailure"
  • "networkFailure"
  • "timeoutFailure"
  • "aborted"
  • "pending"

Why This Module?

HTTP status codes confound two distinct purposes: providing machine-actionable status codes and conveying semantic information about errors to humans. This dual purpose leads to complexity and confusion in client-side code that needs to handle different types of failures appropriately.

Further, not all errors are captured by the HTTP status codes - i.e. network failures.

This library teases apart these concerns by focusing solely on what software can act on. It reduces the complex space of HTTP status codes and other communication states into a small set of actionable categories that make client-side code simpler and more robust.

A comprehensive set of status types (simple enumerated strings e.g. "success") that cover all possible machine-actionable communication states, including situations HTTP status codes don't address (like network failures and aborted requests).

Example Installation and Use (Required)

Install with npm:

npm install @art-suite/art-core-ts-communication-status

Basic usage:

import {
  isSuccess,
  isServerFailure,
  success, // === "success"
  missing, // === "missing"
} from "@art-suite/art-core-ts-communication-status";

// Handle success
if (isSuccess(status)) {...}

// Simply handle all server failures
if (isServerFailure(status)) {...}

// or Handle multiple statues as a simple switch:
switch (status) {
  case success:
    /*...*/ break; // Request completed successfully
  case missing:
    /*...*/ break; // Resource not found, ask the user to fix
  default:
    /*...*/ break; // handle all other failures as one
}

Functional Overview

Status Types

Status are strings, or you can import constants with the identical name referencing the strings:

  • Success Status:

    • success — hurray! (2xx)
  • Missing Status:

    • missingresource not available (404, 501)
  • Client-side Failures:

    • clientFailureclient bug (4xx except 404, 505, 530)
    • clientFailureNotAuthorizedbad auth (401, 403, 407, 451, 511)
  • Server-side Failures:

    • serverFailureserver/infra bug (5xx other than 501, 505, 511, 530)
  • Non HTTP Failure Statuses:

    • networkFailure — Network connectivity issues
    • timeoutFailure - Request timed out
  • Liminal Statuses: (not errors, not success)

    • aborted — Request was cancelled
    • pending — Request is in progress

Type Guards

  • isSuccess(status) — Checks if status indicates success
  • isMissing(status) — Checks if status indicates missing resource
  • isClientFailure(status) — Checks if status indicates client failure
  • isClientFailureNotAuthorized(status) — Checks if status indicates auth failure
  • isServerFailure(status) — Checks if status indicates server failure
  • isNetworkFailure(status) — Checks if status indicates network issues
  • isAborted(status) — Checks if status indicates aborted request
  • isPending(status) — Checks if status indicates pending request

HTTP Status Code Mapping

The library handles mapping HTTP status codes to these simplified states:

  • 2xx → success
  • 404, 501 → missing
  • 401, 403, 407, 451, 511 → clientFailureNotAuthorized
  • 4xx, 505, 530 → clientFailure
  • 5xx → serverFailure

Note: HTTP redirects (3xx) are considered protocol-level signals and should be handled by the HTTP client library, not exposed to application code.

API Documentation Reference

For detailed information on all exported functions and their parameters, please refer to the TypeScript typings and JSDoc comments within the source code.