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

braid-blob

v0.0.39

Published

Library for collaborative blobs over http using braid.

Readme

braid-blob

A simple, self-contained library for synchronizing binary blobs (files, images, etc.) over HTTP using Braid-HTTP. It provides real-time synchronization with arbitrary-writer-wins (AWW) conflict resolution and persistent storage.

Quick Start

Installation

npm install braid-blob

Basic Server

var braid_blob = require('braid-blob')

require('http').createServer((req, res) => {
    braid_blob.serve(req, res)
}).listen(8888)

That's it! You now have a blob synchronization server.

Usage Examples

First let's upload a file:

curl -X PUT -H "Content-Type: image/png" -T blob.png http://localhost:8888/image.png

View image in browser at http://localhost:8888/image.png

To see updates, let's do a textual example for easy viewing:

curl -X PUT -H "Content-Type: text/plain" -d "hello" http://localhost:8888/text

Next, subscribe for updates:

curl -H "Subscribe: true" http://localhost:8888/text

Now, in another terminal, write over the file:

curl -X PUT -H "Content-Type: text/plain" -d "world" http://localhost:8888/text

Should see activity in the first terminal showing the update.

# Delete a file
curl -X DELETE http://localhost:8888/text

API

Configuration

var braid_blob = require('braid-blob')

// Set custom blob storage location (default: './braid-blob-db')
// This uses url-file-db for efficient URL-to-file mapping
braid_blob.db_folder = './custom_files_folder'

// Set custom metadata storage location (default: './braid-blob-meta')
// Stores version metadata and peer information
braid_blob.meta_folder = './custom_meta_folder'

// Set custom peer ID (default: auto-generated and persisted)
braid_blob.peer = 'my-server-id'

braid_blob.serve(req, res, options)

Handles HTTP requests for blob storage and synchronization.

Parameters:

  • req - HTTP request object
  • res - HTTP response object
  • options - Optional configuration object
    • key - Override the resource key (default: URL path)

Supported HTTP Methods:

  • GET - Retrieve a blob (with optional Subscribe: true header)
  • PUT - Store/update a blob
  • DELETE - Remove a blob

braid_blob.get(key, options)

Retrieves a blob from local storage or a remote URL.

Parameters:

  • key - Local storage key (string) or remote URL (URL object)
  • options - Optional configuration object
    • version - Request a specific version
    • parents - Version parents for subscription fork-point
    • subscribe - Callback function for real-time updates
    • head - If true, returns only metadata (version, content_type) without body
    • content_type / accept - Content type for the request
    • signal - AbortSignal for cancellation

Returns: {version, body, content_type} object, or null if not found.

braid_blob.put(key, body, options)

Stores a blob to local storage or a remote URL.

Parameters:

  • key - Local storage key (string) or remote URL (URL object)
  • body - Buffer or data to store
  • options - Optional configuration object
    • version - Version identifier
    • content_type / accept - Content type of the blob
    • signal - AbortSignal for cancellation

braid_blob.sync(a, b, options)

Bidirectionally synchronizes blobs between two endpoints (local keys or URLs).

Parameters:

  • a - First endpoint (local key or URL)
  • b - Second endpoint (local key or URL)
  • options - Optional configuration object
    • signal - AbortSignal for cancellation (use to stop sync)
    • content_type / accept - Content type for requests
    • on_pre_connect - Async callback before connection attempt
    • on_disconnect - Callback when connection drops
    • on_unauthorized - Callback on 401/403 responses
    • on_res - Callback receiving the response object

Testing

to run unit tests:

first run the test server:

npm install
node test/server.js

then open http://localhost:8889/test.html, and the boxes should turn green as the tests pass.