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

sync-later

v1.0.1

Published

Zero-dependency, offline-first mutation engine for REST APIs. Features reliable persistence, dependency chaining, automatic retries with backoff, and file upload support.

Readme

Sync Later

Offline Mutation Engine for Standard REST API

sync-later is a robust, lightweight library designed to ensure your data mutations (POST, PUT, DELETE, PATCH) never fail, even in unstable network conditions. It persists requests, handles retries with exponential backoff, manages complex dependency chains between requests, and now supports file uploads and reactive event updates.

Unlike heavyweight solutions like TanStack Query or Apollo Client which focus on fetching, sync-later focuses purely on reliable mutations.

Features 🚀

  • Zero Dependencies: Pure TypeScript, tiny bundle size.
  • Offline-First: Requests are persisted to IndexedDB immediately.
  • Resilient: Automatic retries with exponential backoff strategy.
  • Dependency Chaining: Create parent-child request chains (e.g., create Post -> create Comment) where the child relies on the parent's ID before the parent even succeeds.
  • Reactive Event System: Subscribe to queue updates (queue_update, process_success, process_fail).
  • File Support: First-class support for FormData, Blob, and File uploads.
  • Cancellable: Cancel pending requests easily.
  • Concurrency Control: Serial processing guarantees order.

Installation

npm install sync-later
# or
pnpm add sync-later
# or
yarn add sync-later

Quick Start

import { RequestQueue } from 'sync-later';

// 1. Initialize the queue
const queue = new RequestQueue({
  retryPolicy: { maxRetries: 3, initialDelayMs: 1000 },
  onQueueChange: (items) => console.log('Queue updated:', items.length)
});

// 2. Add a request (returns a unique ID)
const id = await queue.add({
  url: 'https://api.example.com/posts',
  method: 'POST',
  body: { title: 'Hello World' }
});

// That's it! The library handles the rest:
// - Saves to IndexedDB
// - Checks network status
// - Sends request
// - Retries on failure
// - Removes on success

Core Concepts

1. Dependency Chaining 🔗

Execute dependent requests without waiting for the first one to finish. Use a tempId that gets replaced automatically when the parent request succeeds.

const tempId = 'temp-123';

// 1. Create Parent (Post)
await queue.add({
  tempId, // Assign a temporary ID
  url: '/posts',
  method: 'POST',
  body: { title: 'New Post' }
});

// 2. Create Child (Comment) - Uses tempId
await queue.add({
  url: '/comments',
  method: 'POST',
  body: { 
    postId: tempId, // Will be replaced by real ID (e.g., 101) after parent succeeds
    content: 'Nice post!' 
  }
});

2. File Uploads 📁

Upload files seamlessly. The library detects FormData and skips JSON serialization.

const formData = new FormData();
formData.append('file', myFile);

await queue.add({
  url: '/upload',
  method: 'POST',
  body: formData
});

3. Events & Reactivity ⚡

Update your UI in real-time.

queue.addListener('queue_update', (items) => {
  // Update your UI with the latest queue state
  setQueueItems(items);
});

queue.addListener('process_success', ({ id, response }) => {
  console.log(`Request ${id} succeeded!`, response);
});

API Reference

RequestQueue

The main class.

Constructor new RequestQueue(config?)

  • config.retryPolicy: { maxRetries: number, initialDelayMs: number }
  • config.userId: string (Optional, for multi-user isolation support)
  • config.onBeforeSend: (item) => Promise<item> (Hook to modify request before sending, e.g., attach tokens)
  • config.onQueueChange: (items) => void (Shortcut for queue_update event)

Methods

  • add(request): Adds a request. Returns Promise<string> (the request ID).
  • remove(id): Cancels a pending request.
  • getQueue(): Returns all current queue items.
  • addListener(event, callback): Subscribe to events.
  • removeListener(event, callback): Unsubscribe.

Events

  • queue_update: Fired whenever the queue adds, removes, or updates an item.
  • process_success: Fired when a request succeeds.
  • process_fail: Fired when a request permanently fails (after retries).

License

ISC © 2026 denisetiya