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

tinysaver

v0.1.0

Published

Modern replacement of file-saver.js.

Downloads

6

Readme

💾 tinysaver

CI NPM VERSION NPM DOWNLOADS LICENSE

Modern replacement of file-saver.js.

📦 Install

npm install tinysaver
yarn add tinysaver
pnpm add tinysaver

🚀 Usage

✨ Basic Usage

import { saveAs, saveText, saveJSON, saveCanvas } from 'tinysaver'

// Save a Blob
saveAs(new Blob(['hello world'], { type: 'text/plain' }), 'hello-world.txt')

// Save text content
saveText('Hello World', 'greeting.txt')

// Save JSON data
saveJSON({ name: 'John', age: 30 }, 'data.json', { space: 2 })

// Save canvas as image
const canvas = document.querySelector('canvas')
saveCanvas(canvas, 'image.png', { quality: 0.95 })

⚙️ With Options

import { saveAs } from 'tinysaver'

saveAs(new Blob(['hello world'], { type: 'text/plain' }), 'hello-world.txt', {
  autoBom: true, // Add UTF-8 BOM for text files
  clickDelay: 100, // Delay before triggering download
  openInNewTab: false, // Open in new tab instead of downloading
  disableClick: false, // Disable automatic click simulation
  onStart() {
    console.log('Download started')
  },
  onComplete() {
    console.log('Download completed')
  },
  onError(err) {
    console.error('Download failed', err)
  },
  onProgress(loaded, total) {
    console.log(`${loaded}/${total}`)
  },
})

👏 Callbacks

All download methods support lifecycle callbacks:

saveText('content', 'file.txt', {
  onStart() {
    // Called when download process starts
  },
  onProgress(loaded, total) {
    // Called during download progress
    console.log(`Downloaded ${loaded}/${total} bytes`)
  },
  onComplete() {
    // Called when download completes
  },
  onError(error) {
    // Called when download fails
    console.error(error)
  },
})

🌐 Browser Support

tinysaver supports all modern browsers with automatic fallback for older versions:

  • ✅ Chrome/Edge (all versions with download attribute support)
  • ✅ Firefox (all versions)
  • ✅ Safari (all versions, including iOS)
  • ✅ Opera (all versions)
  • ⚠️ IE (fallback via msSaveOrOpenBlob)

📚 API

💾 saveAs(blob, filename?, options?)

Save any Blob or URL as a file. Compatible with FileSaver.js saveAs API.

Parameters:

  • blob - Blob object or URL string
  • filename - Name of the file to save (optional)
  • options - Download options (optional)

📝 saveText(text, filename, options?)

Save text content as a file.

Parameters:

  • text - Text content to save
  • filename - Name of the text file
  • options - Download options with optional mimeType property

📄 saveJSON(data, filename, options?)

Save JSON data as a file.

Parameters:

  • data - JavaScript object or value to save
  • filename - Name of the JSON file
  • options - Download options with optional space property for formatting

🎨 saveCanvas(canvas, filename, options?)

Save HTML canvas as an image file.

Parameters:

  • canvas - HTMLCanvasElement to save
  • filename - Name of the image file
  • options - Download options with optional type and quality properties

✅ Testing

The library includes comprehensive unit tests covering:

  • 🔍 BrowserDetector static and instance methods
  • 📥 FileDownloader core functionality and error handling
  • 🏷️ BOM (Byte Order Mark) insertion for text files
  • 📝 Default filename handling
  • 💾 saveText, saveJSON, and saveCanvas implementations
  • ⚠️ Canvas conversion error handling
  • 🔔 Callback invocation during download lifecycle

Run tests with:

pnpm test

🙏 Credits

📄 License

MIT License © 2025-PRESENT ntnyq