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

query-client

v1.3.0

Published

A lightweight and efficient query client for managing server state in JavaScript/TypeScript applications. Features include automatic caching, garbage collection, retry logic, and subscription-based updates.

Readme

⚡️ QueryClient

License: MIT GitHub license GitHub issues GitHub stars GitHub forks npm version npm downloads npm downloads npm downloads npm bundle size npm

Una ligera y poderosa biblioteca en TypeScript para la gestión de datos asíncronos y el almacenamiento en caché. QueryClient simplifica la lógica de manejo de peticiones, reintentos, cacheo y recolección de basura, permitiendo a los desarrolladores centrarse en la lógica de negocio.


📋 Tabla de Contenidos

  1. ✨ Características
  2. 📦 Instalación
  3. 🚀 Uso
  4. ⚙️ Configuración
  5. 🧪 Tests
  6. 🤝 Contribución
  7. 📜 Licencia

✨ Características

  • Patrón Singleton: Un único punto de acceso global a la instancia del cliente.
  • Gestión de Caché: Almacena los resultados de las peticiones para evitar llamadas repetidas.
  • Reintentos Automáticos: Configura el número de reintentos en caso de que una petición falle.
  • Backoff Exponencial: Aumenta el tiempo de espera entre reintentos para no saturar el servidor.
  • Tiempo de Caducidad (staleTime): Define cuándo los datos en caché deben considerarse caducados y ser refrescados.
  • Recolección de Basura (gcTime): Elimina automáticamente las queries inactivas del caché para optimizar la memoria.
  • Invalidación: Invalida manualmente los datos en caché para forzar una nueva petición.
  • Escritura en TypeScript: Tipado estricto para un desarrollo más seguro y predecible.

📦 Instalación

Instala el paquete usando npm o yarn:

npm install query-client
# o
yarn add query-client

🚀 Uso

import { QueryClient } from 'query-client';

// Obtener la instancia singleton
const client = QueryClient.getInstance();

// Configurar el cliente (opcional)
client.setConfig({
  retry: 2,
  staleTime: 1000 * 60, // 1 minuto
});

const myQueryFn = async () => {
  const response = await fetch('https://api.example.com/data');
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
};

async function fetchData() {
  try {
    // La primera vez, hará la petición. La segunda, usará el caché.
    const response = await client.fetchQuery({
      queryKey: ['my-data'],
      queryFn: myQueryFn,
    });
    console.log('Datos obtenidos:', response.data.data);
  } catch (error) {
    console.error('Error al obtener los datos:', error);
  }
}

Invalidar y refrescar:

// Forzar una nueva petición invalidando la caché
client.invalidateQueryData({ queryKey: ['my-data'] });

// La próxima llamada a fetchQuery hará una nueva petición
client.fetchQuery({
  queryKey: ['my-data'],
  queryFn: myQueryFn,
});

🤝 Contribución

¡Las contribuciones son bienvenidas! Si encuentras un bug o tienes una sugerencia, por favor, abre un issue o un pull request.


📜 Licencia

Este proyecto está bajo la Licencia MIT. Para más detalles, consulta el archivo LICENSE.


👨‍💻 Autor

Ivan - @ElJijuna