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

@stack-upload-orchestrator/core

v0.1.2

Published

Core upload logic — queue, validation, retry, progress tracking, and storage adapter interface

Readme

@stack-upload-orchestrator/core

Core upload logic — queue management, file validation, retry with exponential backoff, progress tracking, and the StorageAdapter interface.

Installation

npm install @stack-upload-orchestrator/core

Quick start

import { UploadQueue } from '@stack-upload-orchestrator/core';

const queue = new UploadQueue({
  concurrency: 3,
  uploader: async (info, signal, onProgress) => {
    // your upload logic here
    return { url: '...', fileId: '...', name: info.name, size: info.size, type: info.type };
  },
  validation: {
    maxFileSize: '10MB',
    allowedTypes: ['image/*', 'application/pdf'],
  },
  retry: { maxAttempts: 3 },
});

queue.addMany(fileList);

API

UploadQueue

new UploadQueue(options?: QueueOptions)

| Option | Type | Default | Description | |---|---|---|---| | uploader | Uploader | — | Function called for each file | | concurrency | number | 3 | Max simultaneous uploads | | autoStart | boolean | true | Begin processing on add | | validation | ValidationOptions | — | File validation rules | | retry | RetryOptions | — | Retry configuration |

Methods

| Method | Description | |---|---| | add(file, options?) | Add a single file | | addMany(files, options?) | Add a FileList or File[] | | cancel(taskId?) | Cancel one task or all | | pause(taskId?) | Pause one task or the whole queue | | resume(taskId?) | Resume one task or the whole queue | | retry(taskId?) | Retry failed task(s) | | remove(taskId) | Remove a task from the queue | | clear() | Remove all tasks | | getTasks() | Returns current UploadTask[] snapshot |

Events: add, remove, start, progress, completed, error, cancelled, empty

FileValidator

import { FileValidator } from '@stack-upload-orchestrator/core';

const validator = new FileValidator({
  maxFileSize: '5MB',
  allowedTypes: ['image/*'],
  allowedExtensions: ['.jpg', '.png'],
  maxFiles: 10,
});

const result = validator.validate({ name: 'photo.jpg', size: 1024 * 1024, type: 'image/jpeg' });
// { valid: true, errors: [] }

ValidationOptions:

| Option | Type | Description | |---|---|---| | maxFileSize | number \| string | e.g. "10MB", 5242880 | | minFileSize | number \| string | Minimum size | | allowedTypes | string[] | MIME types, supports wildcards: ["image/*"] | | allowedExtensions | string[] | e.g. [".jpg", ".pdf"] | | maxFiles | number | Max files in one batch |

RetryManager

import { RetryManager } from '@stack-upload-orchestrator/core';

const retry = new RetryManager({
  maxAttempts: 5,
  initialDelay: 500,
  maxDelay: 15000,
  backoffFactor: 2,
  onRetry: (attempt, error) => console.log(`Retry ${attempt}:`, error.message),
});

ProgressTracker

import { ProgressTracker } from '@stack-upload-orchestrator/core';

const tracker = new ProgressTracker();
tracker.update(taskId, loaded, total);
console.log(tracker.percent); // 0–100

StorageAdapter interface

Implement this to create a custom client-side storage adapter:

import type { StorageAdapter } from '@stack-upload-orchestrator/core';

const myAdapter: StorageAdapter = {
  async upload(file, signal, onProgress) {
    // ...
    return { url, fileId, name, size, type };
  },
  async delete(fileId) { /* optional */ },
  async getSignedUrl(fileId, expiresIn) { /* optional */ },
};

createUploader

Wraps a StorageAdapter into an Uploader function compatible with UploadQueue:

import { createUploader } from '@stack-upload-orchestrator/core';

const uploader = createUploader(myAdapter);
const queue = new UploadQueue({ uploader });

Types

type UploadStatus = 'pending' | 'uploading' | 'paused' | 'completed' | 'failed' | 'cancelled';

interface UploadResult {
  url: string;
  fileId: string;
  name: string;
  size: number;
  type: string;
  metadata?: Record<string, unknown>;
}

License

MIT