fireproof
Version:
Promises for Firebase objects.
45 lines (33 loc) • 1.27 kB
JavaScript
FireproofSnapshot.prototype.ref = ref;
FireproofSnapshot.prototype.child = child;
FireproofSnapshot.prototype.forEach = forEach;
FireproofSnapshot.prototype.exists = proxy('exists');
FireproofSnapshot.prototype.val = proxy('val');
FireproofSnapshot.prototype.hasChild = proxy('hasChild');
FireproofSnapshot.prototype.hasChildren = proxy('hasChildren');
FireproofSnapshot.prototype.numChildren = proxy('numChildren');
FireproofSnapshot.prototype.getPriority = proxy('getPriority');
FireproofSnapshot.prototype.exportVal = proxy('exportVal');
FireproofSnapshot.prototype.key = proxy('key');
FireproofSnapshot.prototype.name = proxy('name');
function FireproofSnapshot(snap) {
this._snap = snap;
}
function proxy(name) {
var self = this;
return function() {
self._snap[name].apply(self._snap, arguments);
};
}
function ref() {
return new Fireproof(this._snap.ref());
}
function child(childPath) {
return new FireproofSnapshot(this._snap.child(childPath));
}
function forEach(childAction) {
this._snap.forEach(function(childSnap) {
return childAction(new FireproofSnapshot(childSnap));
});
}
;