Skip to content

Commit

Permalink
Added getChildPath() method to FSPath class
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 17, 2017
1 parent 3583b74 commit d1053ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/manager/FSPath.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export declare class FSPath {
getParent(): FSPath;
hasParent(): boolean;
removeRoot(): void;
getChildPath(childName: string): FSPath;
clone(): FSPath;
toString(): string;
}
5 changes: 5 additions & 0 deletions lib/manager/FSPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ var FSPath = (function () {
FSPath.prototype.removeRoot = function () {
this.paths.splice(0, 1);
};
FSPath.prototype.getChildPath = function (childName) {
var path = this.clone();
path.paths.push(childName);
return path;
};
FSPath.prototype.clone = function () {
return new FSPath(this);
};
Expand Down
7 changes: 7 additions & 0 deletions src/manager/FSPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class FSPath
this.paths.splice(0, 1);
}

getChildPath(childName : string) : FSPath
{
const path = this.clone();
path.paths.push(childName);
return path;
}

clone() : FSPath
{
return new FSPath(this);
Expand Down

0 comments on commit d1053ec

Please sign in to comment.