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 🙏

© 2024 – Pkg Stats / Ryan Hefner

multiblob

v1.13.8

Published

A content-addressable store supporting multiple hash algorithms

Downloads

353

Readme

multiblob

A content-addressable-store that supports multiple hashing algorithms, and pull-streams.

example

var Blobs = require('multiblob')

var blobs = Blobs({ dir: '/media/blobCollection' })

pull(
  source, // a buffer stream e.g. from pull-file
  blobs.add(function (err, hash) {
    console.log('added source to blobs:', hash)
  })
)

API

Blobs(config) => blobs

where config is an Object with properties:

  • dir String - the directory to store blobs in
  • alg String (optional) - the algorithm for hashing. Valid options: 'blake2s', 'sha256' (default: 'blake2s')
  • encode Function (optional) - converts a buffer to a string (default: see util.js#encode)
  • decode Function (optional) - recovers a string into an object { hash: Buffer, alg } (default: see util.js#decode)
  • isHash Function (optional) - tests a string to check if it's a valid hash (default: see util.js#isHash)

blobs.add (hash?, cb?) => Sink

Create a sink stream for writing a blob. Expects to receive a buffer stream.

If hash was given, then it will error if the file turned out to be different. If a cb is not given and there was an error, this function will throw.

blobs.get (hash || opts) => Source

Takes the hash of blob already in the store and return a source buffer stream. If the file does not exist this stream will error.

If the argument is a hash string, then return the stream. If the argument is an opts object, with the key: hash property, retrive that blob, but error if the size does not exactly match the size property, or is over max property (in bytes)

blobs.getSlice(opts) => Source

create a source stream that reads a slice of a given blob, from the start property to the end property, in bytes. Error if the file does not exist or if the size of the whole blob does not exactly match the size property, or is over max property (in bytes).

blobs.has(hash, cb)

check if the given hash is in the store. If hash is an array of hashes, size will callback with an array of booleans.

blobs.size(hash, cb)

get the size of this blob. If hash is an array of hashes, size will callback with an array of sizes. If the hash does not exist in the store, size will callback null.

blobs.ls() => Source

source stream that reads the list of hashes available in the store.

blobs.rm(hash, cb)

remove a hash from the store.

blobs.isEmptyHash(hash)

Check if a given hash is actually the empty hash. If something has the empty hash, that is probably a bug. The above methods will act like the empty file is already in the store.

blobs.meta

???

blobs.resolve

???

todo

maybe emit events when blobs are stored?

License

MIT