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

ssb-blob-files

v1.2.1

Published

handle processing and addition of files to the blob store

Downloads

136

Readme

ssb-blob-files

Channel a bunch of files from a dom event into the blob store. Get some tweaks and checks made along the way.

Usage

var h = require('mutant/h')
var blobFiles = require('ssb-blob-files')

var opts = {
  stripExif: true,
  resize: { width: 640, height: 480 },
  isPrivate: true
}

var fileInput = h('input', {
  type: 'file',
  attributes: { multiple: true }, // permit multiple files to be attached
  'ev-change': (ev) => {
    var files = ev.target.files
    blobFiles(files, server, opts, (err, result) => {  // server is a connection to scuttlebutt server
      ev.target.value = ''

      if (err) console.log('oh noes') 
      else // do something with the result data
    }
  })
})

API

blobFiles(files, server, opts cb)

files - an Array of files of the format delivered by file input events

server - a connection to a scuttlebot server (either an ssb-client instance, or an observeable which resolves to one)

opts - (optional) an options Object of the form:

{
  stripExif: Boolean,   // (default: false) removes exif data from images (geo-location, camera meta data, etc)
  resize: Object,       // (default: undefined) resizes image if possible. Expected properties: width, height
  quality: Number,      // (default: 0.85) tune the compression of jpegs. value between 0 and 1
  isPrivate: Boolean    // (default: false) encrypts the blob
}

If a blob is private, it gets encryted and the unbox key is attached to the end of the link property in the result output (see cb details)

cb - a callback with signature (err, result) which is run for each file that is processed. The shape of the result object is

{
  link: BlobId,  // hash id in the blob store, will have an unbox key on the end if isPrivate was true
  name: String,  // the filename
  size: Integer, // size in bytes
  type: String   // the MimeType
}