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

@uplnk/core

v0.1.0

Published

Framework-agnostic file uploads with progress for signed URLs and HTTP endpoints

Readme

@uplnk/core

Framework-agnostic file uploads with progress for signed URLs and HTTP endpoints.

Features

  • Simple API — Single function for uploads with progress tracking
  • Retry strategies — Exponential backoff, fixed delay, and custom retry logic
  • File validation — Pre-upload size and type checking with helpful error messages
  • Batch uploads — Upload multiple files concurrently with progress tracking
  • Framework agnostic — Works in any browser environment
  • TypeScript — Full type safety with detailed type definitions
  • Lightweight — Minimal dependencies, focused scope

Install

pnpm add @uplnk/core

or

npm install @uplnk/core

Optional: install @uplnk/types if you only need the TypeScript types.

Quick Start

Basic upload

import { uplnk } from "@uplnk/core";

await uplnk({
  url: signedUrl,
  file: fileOrBlob,
  onProgress: (p) => console.log(`${p.percent ?? 0}%`),
});

With validation

import { uplnk, validateFile, FILE_SIZE_PRESETS } from "@uplnk/core";

// Validate before upload
const error = validateFile(file, {
  maxSize: FILE_SIZE_PRESETS["10MB"],
  allowedTypes: ["image/png", "image/jpeg"],
});

if (error) {
  console.error("Invalid file:", formatValidationError(error));
  return;
}

// Upload with progress
await uplnk({
  url: signedUrl,
  file,
  onProgress: (p) => console.log(`${p.percent}%`),
});

With retry

import { uplnk, exponentialBackoff } from "@uplnk/core";

await uplnk({
  url: signedUrl,
  file,
  retry: exponentialBackoff({ maxAttempts: 3 }),
  onProgress: (p) => updateProgressBar(p.percent),
});

Batch upload

import { batchUpload } from "@uplnk/core";

const uploads = files.map((file, i) => ({
  url: signedUrls[i],
  file,
}));

const result = await batchUpload(uploads, {
  concurrency: 5,
  onProgress: (p) => console.log(`${p.completed}/${p.total} uploaded`),
  onItemError: (item) => console.error(`Failed: ${item.id}`),
});

console.log(`${result.successful} succeeded, ${result.failed} failed`);

API Overview

Core Functions

  • uplnk(options) — Upload a single file with progress
  • batchUpload(uploads, options) — Upload multiple files concurrently
  • sequentialUpload(uploads, options) — Upload files one at a time
  • createUploadQueue(options) — Create a dynamic upload queue

Retry Strategies

  • exponentialBackoff(options) — Retry with exponential backoff and jitter
  • fixedDelay(options) — Retry with fixed delay between attempts
  • networkErrorsOnly(options) — Only retry network failures
  • customRetry(options) — Create custom retry logic

Validation

  • validateFile(file, options) — Validate file size, type, and custom rules
  • validateSize(file, options) — Validate file size only
  • validateType(file, options) — Validate file type only
  • formatValidationError(error) — Convert error to human-readable message
  • formatBytes(bytes) — Format bytes as human-readable size

Presets

  • FILE_TYPE_PRESETS — Common file type groups (images, videos, audio, documents, archives)
  • FILE_SIZE_PRESETS — Common size limits (1MB, 5MB, 10MB, 50MB, 100MB, 500MB, 1GB)

Examples

Error handling

try {
  await uplnk({ url, file });
} catch (err) {
  switch (err.type) {
    case "abort":
      console.log("Upload cancelled");
      break;
    case "timeout":
      console.log("Upload timed out");
      break;
    case "network":
      console.log("Network error");
      break;
    case "http":
      console.log(`HTTP error: ${err.status}`);
      break;
  }
}

Abort upload

const controller = new AbortController();

uplnk({ url, file, signal: controller.signal });

// Cancel after 5 seconds
setTimeout(() => controller.abort(), 5000);

Custom retry strategy

await uplnk({
  url,
  file,
  retry: customRetry({
    attempts: 5,
    shouldRetry: (err, attempt) => {
      // Don't retry client errors
      if (err.type === "http" && err.status >= 400 && err.status < 500) {
        return false;
      }
      return err.type === "network" || err.type === "timeout";
    },
    getDelay: (attempt) => Math.min(1000 * Math.pow(2, attempt), 30000),
  }),
});

Dynamic upload queue

const queue = createUploadQueue({
  concurrency: 3,
  onProgress: (p) => console.log(`${p.percent}%`),
});

// Add files
queue.add({ url: url1, file: file1 });
queue.add({ url: url2, file: file2 });

// Start processing
queue.start();

// Add more files while running
queue.add({ url: url3, file: file3 });

// Wait for completion
await queue.waitForCompletion();

Documentation

Full documentation is available at the documentation site or in the repository.

License

MIT