A lightweight utility for generating blob URLs and data URIs with ESM, CJS, and UMD support.
- Supports ESM, CommonJS, and UMD module systems
- Generate blob URLs
- Convert blobs to data URIs
- No external dependencies
- TypeScript definitions included
-
toBlobURL(_blob: File | Blob)
: Creates a blob URL- Returns
{ url: string, revoke: () => void }
- Returns
-
toDataURI(_blob: File | Blob)
: Converts blob to base64 encoded URL- Returns
string
- Returns
// ESM Import
import { toBlobURL, toDataURI } from "blob-to-url";
// CommonJS Require
const { toBlobURL, toDataURI } = require("blob-to-url");
// Browser (UMD)
<script src="https://unpkg.com/blob-to-url"></script>
<script>
const { toBlobURL, toDataURI } = window.blobToUrl;
</script>
// Blob URL Example
const { url, revoke } = toBlobURL(myBlob);
console.log(url); // Blob URL
revoke(); // Clean up resource
// Data URI Example
const dataURI = toDataURI(myBlob);
console.log(dataURI); // Base64 encoded URL
This package uses pkgroll for ESM and CJS build, and Rollup for UMD build.
# Install dependencies
pnpm install
# Build the package
pnpm build
# Run tests
pnpm test
The project uses GitHub Actions for continuous integration and deployment:
- Automated tests run on pull requests
- Automated builds and npm package publishing
- Manual releases via GitHub Actions workflow
- [x] ESM, CJS, and UMD module support
- [x] Implement Vitest test suite with Edge Runtime
- [x] Set up GitHub Actions for CI/CD