@@ -25,6 +25,10 @@ namespace ts {
2525/* @internal */
2626namespace ts {
2727 export const emptyArray : never [ ] = [ ] as never [ ] ;
28+ export function closeFileWatcher ( watcher : FileWatcher ) {
29+ watcher . close ( ) ;
30+ }
31+
2832 /** Create a MapLike with good performance. */
2933 function createDictionaryObject < T > ( ) : MapLike < T > {
3034 const map = Object . create ( /*prototype*/ null ) ; // tslint:disable-line:no-null-keyword
@@ -2539,7 +2543,6 @@ namespace ts {
25392543 path = normalizePath ( path ) ;
25402544 currentDirectory = normalizePath ( currentDirectory ) ;
25412545
2542- const comparer = useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ;
25432546 const patterns = getFileMatcherPatterns ( path , excludes , includes , useCaseSensitiveFileNames , currentDirectory ) ;
25442547
25452548 const regexFlag = useCaseSensitiveFileNames ? "" : "i" ;
@@ -2560,7 +2563,7 @@ namespace ts {
25602563 function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
25612564 const { files, directories } = getFileSystemEntries ( path ) ;
25622565
2563- for ( const current of sort ( files , comparer ) ) {
2566+ for ( const current of sort ( files , compareStringsCaseSensitive ) ) {
25642567 const name = combinePaths ( path , current ) ;
25652568 const absoluteName = combinePaths ( absolutePath , current ) ;
25662569 if ( extensions && ! fileExtensionIsOneOf ( name , extensions ) ) continue ;
@@ -2583,7 +2586,7 @@ namespace ts {
25832586 }
25842587 }
25852588
2586- for ( const current of sort ( directories , comparer ) ) {
2589+ for ( const current of sort ( directories , compareStringsCaseSensitive ) ) {
25872590 const name = combinePaths ( path , current ) ;
25882591 const absoluteName = combinePaths ( absolutePath , current ) ;
25892592 if ( ( ! includeDirectoryRegex || includeDirectoryRegex . test ( absoluteName ) ) &&
@@ -3143,4 +3146,36 @@ namespace ts {
31433146 export function singleElementArray < T > ( t : T | undefined ) : T [ ] | undefined {
31443147 return t === undefined ? undefined : [ t ] ;
31453148 }
3149+
3150+ export function enumerateInsertsAndDeletes < T , U > ( newItems : ReadonlyArray < T > , oldItems : ReadonlyArray < U > , comparer : ( a : T , b : U ) => Comparison , inserted : ( newItem : T ) => void , deleted : ( oldItem : U ) => void , unchanged ?: ( oldItem : U , newItem : T ) => void ) {
3151+ unchanged = unchanged || noop ;
3152+ let newIndex = 0 ;
3153+ let oldIndex = 0 ;
3154+ const newLen = newItems . length ;
3155+ const oldLen = oldItems . length ;
3156+ while ( newIndex < newLen && oldIndex < oldLen ) {
3157+ const newItem = newItems [ newIndex ] ;
3158+ const oldItem = oldItems [ oldIndex ] ;
3159+ const compareResult = comparer ( newItem , oldItem ) ;
3160+ if ( compareResult === Comparison . LessThan ) {
3161+ inserted ( newItem ) ;
3162+ newIndex ++ ;
3163+ }
3164+ else if ( compareResult === Comparison . GreaterThan ) {
3165+ deleted ( oldItem ) ;
3166+ oldIndex ++ ;
3167+ }
3168+ else {
3169+ unchanged ( oldItem , newItem ) ;
3170+ newIndex ++ ;
3171+ oldIndex ++ ;
3172+ }
3173+ }
3174+ while ( newIndex < newLen ) {
3175+ inserted ( newItems [ newIndex ++ ] ) ;
3176+ }
3177+ while ( oldIndex < oldLen ) {
3178+ deleted ( oldItems [ oldIndex ++ ] ) ;
3179+ }
3180+ }
31463181}
0 commit comments