Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fireproof

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fireproof

Promises for Firebase objects.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

fireproof

Firebase runs hot! Don't burn yourself with callbacks. Use promises instead. Fireproof wraps Firebase objects with lightweight promise support.

Installation

npm install --save fireproof

Usage

See the API documentation here.

The bottom line is this: all Firebase methods are reproduced on a Fireproof object.

By default, Fireproof uses the built-in Promise constructor, which is available in Node > 0.12 and many modern web browsers. You can override this behavior by providing a standards-compliant Promise constructor on Fireproof's constructor, like so:

Fireproof.Promise = require('bluebird');

You can also choose to "bless" Fireproof with a promise library that follows the deferral model:

Fireproof.bless(require('Q'));

If a Promise constructor is not supplied and none exists natively, Fireproof will explode spectacularly.

  • If the corresponding Firebase method has no return value but does something asynchronously, Fireproof returns a promise that fulfills if the interaction succeeds and rejects if an error occurs. This is true of, e.g., transaction(), auth(), set(), update(), remove(), and once().

  • For on(), Firebase returns the callback method that you passed in. Fireproof returns your wrapped callback method with an extra method, then(), attached. So the callback is effectively a promise!

  • For push(), Firebase returns the reference to the new child. Fireproof does the same, but the reference is also a promise that resolves if the push succeeds and rejects if the push fails.

  • All Fireproof objects are themselves promises. Except for the case of push() mentioned above, their then() is a shortcut for fp.once('value'). This means you can get the value of any Fireproof object at any time just by treating it as a promise!

var Fireproof = require('fireproof'),
  Firebase = require('firebase');

var firebase = new Firebase('https://test.firebaseio.com/thing'),
  fireproof = new Fireproof(firebase);

fireproof.auth('my_auth_token').then(function() {
  console.log('Successfully authenticated.')
}, function(err) {
  console.error('Error authenticating to Firebase!');
})

Support

IE back to 9.

Keywords

FAQs

Package last updated on 23 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc