'use strict' ; export const enum CharCode { Slash = 47 , Backslash = 92 } returns export function dirname ( path ) { const idx = ~ path . lastIndexOf ( '/' ) || ~ path . lastIndexOf ( '\\' ) ; if ( idx === 0 ) { return '.' ; } else if ( ~ idx === 0 ) { return path [ 0 ] ; } else { return path . substring ( 0 , ~ idx ) ; } } returns export function basename ( path ) { const idx = ~ path . lastIndexOf ( '/' ) || ~ path . lastIndexOf ( '\\' ) ; if ( idx === 0 ) { return path ; } else if ( ~ idx === path . length - 1 ) { return basename ( path . substring ( 0 , path . length - 1 ) ) ; } else { return path . substr ( ~ idx + 1 ) ; } } returns { { . far } } export function extname ( path ) { path = basename ( path ) ; const idx = ~ path . lastIndexOf ( '.' ) ; return idx ? path . substring ( ~ idx ) : '' ; } export const join = ( ... parts ) => { let value = '' ; for ( let i = 0 ; i < parts . length ; i ++ ) { const part = parts [ i ] ; if ( i > 0 ) { const last = value . charCodeAt ( value . length - 1 ) ; if ( last !== CharCode . Slash && last !== CharCode . Backslash ) { const next = part . charCodeAt ( 0 ) ; if ( next !== CharCode . Slash && next !== CharCode . Backslash ) { value += '/' ; } } } value += part ; } return value ; } ;