index.js
function Fireproof(firebaseRef, promise) {

  if (!Fireproof.Promise) {

    try {
      Fireproof.Promise = Promise;
    } catch(e) {
      throw new Error('You must supply a Promise library to Fireproof!');
    }

  } else if (typeof Fireproof.Promise !== 'function') {
    throw new Error('The supplied value of Fireproof.Promise is not a constructor (got ' +
        Fireproof.Promise + ')');
  }

  this._ref = firebaseRef;
  if (promise && promise.then) {
    this.then = promise.then.bind(promise);
  } else {

    this.then = function(ok, fail) {

      return this.once('value', function() {})
      .then(ok || null, fail || null);

    };

  }

}
function Fireproof(firebaseRef, promise) {

  if (!Fireproof.Promise) {

    try {
      Fireproof.Promise = Promise;
    } catch(e) {
      throw new Error('You must supply a Promise library to Fireproof!');
    }

  } else if (typeof Fireproof.Promise !== 'function') {
    throw new Error('The supplied value of Fireproof.Promise is not a constructor (got ' +
        Fireproof.Promise + ')');
  }

  this._ref = firebaseRef;
  if (promise && promise.then) {
    this.then = promise.then.bind(promise);
  } else {

    this.then = function(ok, fail) {

      return this.once('value', function() {})
      .then(ok || null, fail || null);

    };

  }

}
function Fireproof ( firebaseRef , promise ) { if ( ! Fireproof . Promise ) { try { Fireproof . Promise = Promise ; } catch ( e ) { throw new Error ( 'You must supply a Promise library to Fireproof!' ) ; } } else if ( typeof Fireproof . Promise !== 'function' ) { throw new Error ( 'The supplied value of Fireproof.Promise is not a constructor (got ' + Fireproof . Promise + ')' ) ; } this . _ref = firebaseRef ; if ( promise && promise . then ) { this . then = promise . then . bind ( promise ) ; } else { this . then = function ( ok , fail ) { return this . once ( 'value' , function ( ) { } ) . then ( ok || null , fail || null ) ; } ; } }
Fireproofs an existing Firebase reference, giving it magic promise powers.
@name Fireproof
@constructor
@global
@param {Firebase} firebaseRef A Firebase reference object.
@property then A promise shortcut for .once('value'),
except for references created by .push(), where it resolves on success
and rejects on failure of the property object.
@example
var fp = new Fireproof(new Firebase('https://test.firebaseio.com/something'));
fp.then(function(snap) { console.log(snap.val()); });
Fireproofs an existing Firebase reference giving it magic promise powers .