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 🙏

© 2026 – Pkg Stats / Ryan Hefner

firebase-stream

v1.2.0

Published

A remote stream connection using the firebase db

Readme

Pipe to firebase and back

Build Status Coverage Status js-standard-style

firebase-stream allows you to pipe any Node.js stream to a database node in google's firebase and read its data back as stream.

Usage

Install the library

$ npm install --save firebase>3 firebase-stream

then you may use it like in the following example:

// -------------  SETUP ------------
const firebase = require('firebase')
const app = firebase.initializeApp({
  // Configure your application here
  databaseURL: "<enter your database configuration here>"
})
// Keep the db reference if you want to later disconnect from it
const db = app.database()

// In order to keep a clean database, lets have a namespace for
const dbRef = db.ref().child('my-streams')




// -------------  WRITING ------------

// This will not work if you don't call `npm install firebase-stream` if you didn't do so already!
const stream = require('firebase-stream')
const output = stream.createWriteStream({
  node: dbRef.push(null) // The new stream will pipe in a new child
})

// Write something to the outstream
output.end('Hello World')




// -------------  READING ------------

// Create a new stream that reads from the same database node
const input = stream.createReadStream({
  node: dbRef.child(output.key)
})
// Receive the data sent to firebase
input.on('data', function (data) {
  console.log(String(data))
})
input.on('end', function () {
  // Go offline in order for the Node.js application to close
  db.goOffline()
})

API

const stream = require('firebase-stream')
stream.createReadStream({/* options */) // equals to stream({mode: 'r', ...})
stream.createWriteStream({/* options */) // equals to stream({mode: 'w', ...})
stream.createDuplexStream({/* options */) // equals to stream({mode: 'rw', ...})

const instance = stream({
  mode: 'r', // (required) r = read, w = write, rw = read/write , kind of stream to be used on the ref
  node: ref, // (required) reference to a data node of firebase
  enableTime: false, // true switches the options to objectMode and stores the timestamp to each output
  binary: false // true uses binary mode when writing the stream to the db
  // Additional options (like objectMode) are directly forwarded to the stream implementation
})

instance.key // key of the node as in ref.key
instance.url // url of the node as in ref.toString()
instance.dispose() // Remove the data

Binary Modes

By default data sent through the stream is stored as utf8 strings. This should mostly work just fine (even with binary data). The reason for this is because big integer arrays do not perform well in firebase. Setting the binary options will store the data as integer Array.

Data Structure

The reference passed-in to the stream will not be written to. Instead firebase-stream will create two children: finished and buffer. finished will be either true or false, depending if the stream is finished or not. buffer will contain a list of children that each contains one "chunk" field and a time field. The first entry with null as data terminates the stream.