@@ -176,44 +176,6 @@ namespace ts.server {
176
176
return [ ] as SortedArray < T > ;
177
177
}
178
178
179
- export function toSortedArray ( arr : string [ ] ) : SortedArray < string > ;
180
- export function toSortedArray < T > ( arr : T [ ] , comparer : Comparer < T > ) : SortedArray < T > ;
181
- export function toSortedArray < T > ( arr : T [ ] , comparer ?: Comparer < T > ) : SortedArray < T > {
182
- arr . sort ( comparer ) ;
183
- return arr as SortedArray < T > ;
184
- }
185
-
186
- export function enumerateInsertsAndDeletes < T > ( newItems : SortedReadonlyArray < T > , oldItems : SortedReadonlyArray < T > , inserted : ( newItem : T ) => void , deleted : ( oldItem : T ) => void , compare ?: Comparer < T > ) {
187
- compare = compare || compareValues ;
188
- let newIndex = 0 ;
189
- let oldIndex = 0 ;
190
- const newLen = newItems . length ;
191
- const oldLen = oldItems . length ;
192
- while ( newIndex < newLen && oldIndex < oldLen ) {
193
- const newItem = newItems [ newIndex ] ;
194
- const oldItem = oldItems [ oldIndex ] ;
195
- const compareResult = compare ( newItem , oldItem ) ;
196
- if ( compareResult === Comparison . LessThan ) {
197
- inserted ( newItem ) ;
198
- newIndex ++ ;
199
- }
200
- else if ( compareResult === Comparison . GreaterThan ) {
201
- deleted ( oldItem ) ;
202
- oldIndex ++ ;
203
- }
204
- else {
205
- newIndex ++ ;
206
- oldIndex ++ ;
207
- }
208
- }
209
- while ( newIndex < newLen ) {
210
- inserted ( newItems [ newIndex ++ ] ) ;
211
- }
212
- while ( oldIndex < oldLen ) {
213
- deleted ( oldItems [ oldIndex ++ ] ) ;
214
- }
215
- }
216
-
217
179
export class ThrottledOperations {
218
180
private pendingTimeouts : Map < any > = createMap < any > ( ) ;
219
181
constructor ( private readonly host : ServerHost ) {
@@ -261,7 +223,10 @@ namespace ts.server {
261
223
}
262
224
}
263
225
}
226
+ }
264
227
228
+ /* @internal */
229
+ namespace ts . server {
265
230
export function insertSorted < T > ( array : SortedArray < T > , insert : T , compare : Comparer < T > ) : void {
266
231
if ( array . length === 0 ) {
267
232
array . push ( insert ) ;
@@ -289,4 +254,42 @@ namespace ts.server {
289
254
array . splice ( removeIndex , 1 ) ;
290
255
}
291
256
}
257
+
258
+ export function toSortedArray ( arr : string [ ] ) : SortedArray < string > ;
259
+ export function toSortedArray < T > ( arr : T [ ] , comparer : Comparer < T > ) : SortedArray < T > ;
260
+ export function toSortedArray < T > ( arr : T [ ] , comparer ?: Comparer < T > ) : SortedArray < T > {
261
+ arr . sort ( comparer ) ;
262
+ return arr as SortedArray < T > ;
263
+ }
264
+
265
+ export function enumerateInsertsAndDeletes < T > ( newItems : SortedReadonlyArray < T > , oldItems : SortedReadonlyArray < T > , inserted : ( newItem : T ) => void , deleted : ( oldItem : T ) => void , compare ?: Comparer < T > ) {
266
+ compare = compare || compareValues ;
267
+ let newIndex = 0 ;
268
+ let oldIndex = 0 ;
269
+ const newLen = newItems . length ;
270
+ const oldLen = oldItems . length ;
271
+ while ( newIndex < newLen && oldIndex < oldLen ) {
272
+ const newItem = newItems [ newIndex ] ;
273
+ const oldItem = oldItems [ oldIndex ] ;
274
+ const compareResult = compare ( newItem , oldItem ) ;
275
+ if ( compareResult === Comparison . LessThan ) {
276
+ inserted ( newItem ) ;
277
+ newIndex ++ ;
278
+ }
279
+ else if ( compareResult === Comparison . GreaterThan ) {
280
+ deleted ( oldItem ) ;
281
+ oldIndex ++ ;
282
+ }
283
+ else {
284
+ newIndex ++ ;
285
+ oldIndex ++ ;
286
+ }
287
+ }
288
+ while ( newIndex < newLen ) {
289
+ inserted ( newItems [ newIndex ++ ] ) ;
290
+ }
291
+ while ( oldIndex < oldLen ) {
292
+ deleted ( oldItems [ oldIndex ++ ] ) ;
293
+ }
294
+ }
292
295
}
0 commit comments