export class Path { /**
     * Components between separators.
     */ private parts : string [ ] ; /**
     * Whether the path represents a folder.
     */ private folder : boolean ; /**
     * Create a new path.
     */ constructor ( path = '' ) { this . parts = path . split ( '/' ) . filter ( function ( part ) { return part . length > 0 ; } ) ; this . folder = ( path . substring ( path . length - 1 ) === '/' ) ; } /**
     * Create a deep copy of this path.
     */ public clone ( ) { let newPath = new Path ( ) ; newPath . parts = this . parts . slice ( 0 ) ; newPath . folder = this . folder ; return newPath ; } /**
     * Check if this path is equal to the given path.
     */ public equals ( other ) { return ( this . toString ( ) === other . toString ( ) ) ; } /**
     * Get path components.
     */ public components ( ) { return this . parts ; } /**
     * Get the file or folder name.
     */ public name ( ) { if ( this . parts . length === 0 ) { return '' ; } return this . parts [ this . parts . length - 1 ] ; } /**
     * Push one or more components to the path.
     */ public push ( subpath ) { let subparts = subpath . split ( '/' ) . filter ( function ( part ) { return part . length > 0 ; } ) ; this . parts = this . parts . concat ( subparts ) ; this . folder = ( subpath . substring ( subpath . length - 1 ) === '/' ) ; return this ; } /**
     * Pop a component from the path.
     */ public pop ( ) { if ( this . parts . length > 0 ) { this . parts . pop ( ) ; } return this ; } /**
     * Check if this path refers to a folder.
     */ public isFolder ( ) { return this . folder ; } /**
     * Get the string representation.
     */ public toString ( ) { if ( this . parts . length === 0 ) { return '' ; } var uri = this . parts . join ( '/' ) ; if ( this . folder ) { return `${ uri }/` ; } return uri ; } }