[firestore] Path - remove unreachable code paths
This commit is contained in:
parent
b534e02016
commit
317b02b901
|
@ -14,11 +14,11 @@ export default class Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
get id(): string | null {
|
get id(): string | null {
|
||||||
return this._parts.length > 0 ? this._parts[this._parts.length - 1] : null;
|
return this._parts.length ? this._parts[this._parts.length - 1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isDocument(): boolean {
|
get isDocument(): boolean {
|
||||||
return this._parts.length > 0 && this._parts.length % 2 === 0;
|
return this._parts.length % 2 === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCollection(): boolean {
|
get isCollection(): boolean {
|
||||||
|
@ -34,7 +34,7 @@ export default class Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
parent(): Path | null {
|
parent(): Path | null {
|
||||||
return this._parts.length > 0
|
return this._parts.length
|
||||||
? new Path(this._parts.slice(0, this._parts.length - 1))
|
? new Path(this._parts.slice(0, this._parts.length - 1))
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ export default class Path {
|
||||||
* @package
|
* @package
|
||||||
*/
|
*/
|
||||||
static fromName(name: string): Path {
|
static fromName(name: string): Path {
|
||||||
|
if (!name) return new Path([]);
|
||||||
const parts = name.split('/');
|
const parts = name.split('/');
|
||||||
return parts.length === 0 ? new Path([]) : new Path(parts);
|
return new Path(parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue