Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Firebase runs hot! Don't burn yourself with callbacks. Use promises instead. Fireproof wraps Firebase objects with lightweight promise support.
npm install --save fireproof
See the API documentation here.
The bottom line is this: all Firebase methods are reproduced on a Fireproof object.
You have to "bless" Fireproof with a promise library that follows the deferral model. Q.js, Kew, and Firebase $q are some examples. Just call Fireproof.bless(Q).
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 fb = new Firebase('https://test.firebaseio.com/thing'),
fp = new Fireproof(fb);
fireproof.auth('my_auth_token').then(function() {
console.log('Successfully authenticated.')
}, function(err) {
console.error('Error authenticating to Firebase!');
})
IE back to 9.
FAQs
Promises for Firebase objects.
The npm package fireproof receives a total of 76 weekly downloads. As such, fireproof popularity was classified as not popular.
We found that fireproof demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.