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

@dgkit/blob-saver

v0.1.0

Published

Framework-free helper for triggering a browser file download from a Blob, with no memory leaks.

Readme

@dgkit/blob-saver

npm

A tiny, framework-free helper for triggering a browser download from a Blob — the "create an object URL, click a hidden <a download>, clean up" dance every app ends up hand-rolling for CSV/Excel exports, generated PDFs, file previews saved to disk, etc.

const csv = new Blob([content], { type: 'text/csv' });
downloadBlob('report.csv', csv);
  • No memory leaks — revokes the object URL after the download starts, unlike the common hand-rolled version that never calls URL.revokeObjectURL at all
  • Framework-agnostic — zero dependencies, works anywhere JavaScript runs in a browser (Angular, React, Vue, plain DOM)
  • ✅ Cleans up its temporary <a> element even if click() throws
  • isDownloadSupported() to guard the call in environments without a DOM

Installation

yarn add @dgkit/blob-saver

Compatibility

Framework-agnostic. @dgkit/blob-saver has no Angular — or any framework — dependency. It is pure TypeScript with zero runtime dependencies, so it works with any Angular version (or React, Vue, plain Node… anywhere JavaScript runs).

Usage

import { downloadBlob } from '@dgkit/blob-saver';

function exportReport(rows: Row[]): void {
  const csv = new Blob([toCsv(rows)], { type: 'text/csv' });
  downloadBlob('report.csv', csv);
}

Guard it in code that might run outside a browser (e.g. during SSR):

import { downloadBlob, isDownloadSupported } from '@dgkit/blob-saver';

if (isDownloadSupported()) {
  downloadBlob('report.csv', csv);
}

API

downloadBlob(filename, blob)

Triggers a browser download of blob, saved as filename.

Creates a temporary object URL and an off-screen <a download>, clicks it, then removes the element and revokes the URL. The revoke is deferred to a macrotask so the browser has already started the download by the time the URL is released — calling URL.revokeObjectURL synchronously right after click() is a common reason hand-rolled versions of this function occasionally fail to download.

Throws if called where downloads aren't possible (see isDownloadSupported below) — this is an imperative, user-triggered action with no meaningful non-browser behavior.

isDownloadSupported()

Returns whether triggering a download is possible in the current environment — false under SSR/Node, or in any environment missing document or URL.createObjectURL.

Development

This package lives in the dgkit Nx monorepo.

yarn nx build blob-saver        # ng-packagr production build
yarn nx test blob-saver         # Vitest + coverage
yarn nx lint blob-saver         # ESLint
yarn nx typecheck blob-saver    # tsc --noEmit

Contributing

Contributions are welcome — see the repository CONTRIBUTING guide.

License

MIT