react-native-firebase-compiled
Version:
A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto
62 lines (47 loc) • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
*
* Path representation wrapper
*/
/**
* @class Path
*/
class Path {
constructor(pathComponents) {
_defineProperty(this, "_parts", void 0);
this._parts = pathComponents;
}
get id() {
return this._parts.length ? this._parts[this._parts.length - 1] : null;
}
get isDocument() {
return this._parts.length % 2 === 0;
}
get isCollection() {
return this._parts.length % 2 === 1;
}
get relativeName() {
return this._parts.join('/');
}
child(relativePath) {
return new Path(this._parts.concat(relativePath.split('/')));
}
parent() {
return this._parts.length > 1 ? new Path(this._parts.slice(0, this._parts.length - 1)) : null;
}
/**
*
* @package
*/
static fromName(name) {
if (!name) return new Path([]);
const parts = name.split('/');
return new Path(parts);
}
}
exports.default = Path;
;