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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@leancodepl/api-binary-blob

v9.6.6

Published

Binary data conversion utilities for Blob handling

Readme

@leancodepl/api-binary-blob

Blob conversion utilities for ApiBinary with file handling support.

Installation

npm install @leancodepl/api-binary-blob
# or
yarn add @leancodepl/api-binary-blob

API

fromBlob(blob)

Converts Blob to ApiBinary asynchronously.

Parameters:

  • blob: Blob - The Blob to convert to ApiBinary

Returns: Promise resolving to ApiBinary or undefined if blob is undefined

toBlob(apiBinary, contentType)

Converts ApiBinary to Blob with optional content type.

Parameters:

  • apiBinary: ApiBinary - The ApiBinary to convert to Blob
  • contentType?: string - Optional MIME type for the Blob

Returns: Blob instance or undefined if apiBinary is null/undefined

Usage Examples

File Upload

import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"

const handleFileUpload = async (file: File) => {
  const binary = await fromBlob(file)

  await api.post("/upload", {
    fileName: file.name,
    content: binary,
  })
}

File Download

import { toBlob } from "@leancodepl/api-binary-blob"

const downloadFile = async (binary: ApiBinary, filename: string) => {
  const blob = toBlob(binary, "application/octet-stream")
  const url = URL.createObjectURL(blob)

  const link = document.createElement("a")
  link.href = url
  link.download = filename
  link.click()

  URL.revokeObjectURL(url)
}

Image Processing

import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"

const processImage = async (imageFile: File) => {
  const binary = await fromBlob(imageFile)

  const processedBlob = toBlob(binary, "image/jpeg")
  const preview = URL.createObjectURL(processedBlob)

  const img = document.createElement("img")
  img.src = preview
  document.body.appendChild(img)
}