Skip to content

Commit

Permalink
[firestore] Path - remove unreachable code paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Salakar committed Apr 16, 2018
1 parent b534e02 commit 317b02b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/modules/firestore/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default class Path {
}

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 {
return this._parts.length > 0 && this._parts.length % 2 === 0;
return this._parts.length % 2 === 0;
}

get isCollection(): boolean {
Expand All @@ -34,7 +34,7 @@ export default class Path {
}

parent(): Path | null {
return this._parts.length > 0
return this._parts.length
? new Path(this._parts.slice(0, this._parts.length - 1))
: null;
}
Expand All @@ -44,7 +44,8 @@ export default class Path {
* @package
*/
static fromName(name: string): Path {
if (!name) return new Path([]);
const parts = name.split('/');
return parts.length === 0 ? new Path([]) : new Path(parts);
return new Path(parts);
}
}

0 comments on commit 317b02b

Please sign in to comment.