File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- /// <reference path="sys.ts"/>
1+ /// <reference path="sys.ts"/>
22/// <reference path="types.ts"/>
33/// <reference path="core.ts"/>
44/// <reference path="diagnosticInformationMap.generated.ts"/>
@@ -543,7 +543,7 @@ namespace ts {
543543
544544 /* @internal */
545545 export function createCompilerDiagnosticForInvalidCustomType ( opt : CommandLineOptionOfCustomType ) : Diagnostic {
546- const namesOfType = keysOfMap ( opt . type ) . map ( key => `'${ key } '` ) . join ( ", " ) ;
546+ const namesOfType = arrayFrom ( opt . type . keys ( ) ) . map ( key => `'${ key } '` ) . join ( ", " ) ;
547547 return createCompilerDiagnostic ( Diagnostics . Argument_for_0_option_must_be_Colon_1 , `--${ opt . name } ` , namesOfType ) ;
548548 }
549549
@@ -1255,8 +1255,8 @@ namespace ts {
12551255 }
12561256 }
12571257
1258- const literalFiles = valuesOfMap ( literalFileMap ) ;
1259- const wildcardFiles = valuesOfMap ( wildcardFileMap ) ;
1258+ const literalFiles = arrayFrom ( literalFileMap . values ( ) ) ;
1259+ const wildcardFiles = arrayFrom ( wildcardFileMap . values ( ) ) ;
12601260 wildcardFiles . sort ( host . useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive ) ;
12611261 return {
12621262 fileNames : literalFiles . concat ( wildcardFiles ) ,
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ namespace ts {
156156 }
157157
158158 function getKeys ( ) {
159- return keysOfMap ( files ) as Path [ ] ;
159+ return arrayFrom ( files . keys ( ) ) as Path [ ] ;
160160 }
161161
162162 // path should already be well-formed so it does not need to be normalized
@@ -867,27 +867,15 @@ namespace ts {
867867 return keys ;
868868 }
869869
870- function arrayFrom < T > ( iterator : Iterator < T > ) : T [ ] {
870+ /** Shims `Array.from`. */
871+ export function arrayFrom < T > ( iterator : Iterator < T > ) : T [ ] {
871872 const result : T [ ] = [ ] ;
872873 for ( let { value, done } = iterator . next ( ) ; ! done ; { value, done } = iterator . next ( ) ) {
873874 result . push ( value ) ;
874875 }
875876 return result ;
876877 }
877878
878- /**
879- * Array of every key in a map.
880- * May not actually return string[] if numbers were put into the map.
881- */
882- export function keysOfMap ( map : Map < { } > ) : string [ ] {
883- return arrayFrom ( map . keys ( ) ) ;
884- }
885-
886- /** Array of every value in a map. */
887- export function valuesOfMap < T > ( map : Map < T > ) : T [ ] {
888- return arrayFrom ( map . values ( ) ) ;
889- }
890-
891879 /**
892880 * Calls `callback` for each entry in the map, returning the first defined result.
893881 * Use `map.forEach` instead for normal iteration.
Original file line number Diff line number Diff line change @@ -680,7 +680,7 @@ namespace ts {
680680 description = getDiagnosticText ( option . description ) ;
681681 const element = ( < CommandLineOptionOfListType > option ) . element ;
682682 const typeMap = < Map < number | string > > element . type ;
683- optionsDescriptionMap . set ( description , keysOfMap ( typeMap ) . map ( key => `'${ key } '` ) ) ;
683+ optionsDescriptionMap . set ( description , arrayFrom ( typeMap . keys ( ) ) . map ( key => `'${ key } '` ) ) ;
684684 }
685685 else {
686686 description = getDiagnosticText ( option . description ) ;
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ namespace ts.projectSystem {
246246 export function checkMapKeys ( caption : string , map : Map < any > , expectedKeys : string [ ] ) {
247247 assert . equal ( map . size , expectedKeys . length , `${ caption } : incorrect size of map` ) ;
248248 for ( const name of expectedKeys ) {
249- assert . isTrue ( map . has ( name ) , `${ caption } is expected to contain ${ name } , actual keys: ${ keysOfMap ( map ) } ` ) ;
249+ assert . isTrue ( map . has ( name ) , `${ caption } is expected to contain ${ name } , actual keys: ${ arrayFrom ( map . keys ( ) ) } ` ) ;
250250 }
251251 }
252252
Original file line number Diff line number Diff line change 1- /// <reference path="..\services\services.ts" />
1+ /// <reference path="..\services\services.ts" />
22/// <reference path="utilities.ts"/>
33/// <reference path="scriptInfo.ts"/>
44/// <reference path="lsHost.ts"/>
@@ -617,7 +617,7 @@ namespace ts.server {
617617
618618 const added : string [ ] = [ ] ;
619619 const removed : string [ ] = [ ] ;
620- const updated : string [ ] = keysOfMap ( updatedFileNames ) ;
620+ const updated : string [ ] = arrayFrom ( updatedFileNames . keys ( ) ) ;
621621
622622 forEachKeyInMap ( currentFiles , id => {
623623 if ( ! lastReportedFileNames . has ( id ) ) {
@@ -691,7 +691,7 @@ namespace ts.server {
691691 } )
692692 }
693693
694- const allFileNames = keysOfMap ( referencedFiles ) as Path [ ] ;
694+ const allFileNames = arrayFrom ( referencedFiles . keys ( ) ) as Path [ ] ;
695695 return filter ( allFileNames , file => this . projectService . host . fileExists ( file ) ) ;
696696 }
697697
Original file line number Diff line number Diff line change 1- namespace ts {
1+ namespace ts {
22 /**
33 * The document registry represents a store of SourceFile objects that can be shared between
44 * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
@@ -121,7 +121,7 @@ namespace ts {
121121 }
122122
123123 function reportStats ( ) {
124- const bucketInfoArray = keysOfMap ( buckets ) . filter ( name => name && name . charAt ( 0 ) === "_" ) . map ( name => {
124+ const bucketInfoArray = arrayFrom ( buckets . keys ( ) ) . filter ( name => name && name . charAt ( 0 ) === "_" ) . map ( name => {
125125 const entries = buckets . get ( name ) ;
126126 const sourceFiles : { name : string ; refCount : number ; references : string [ ] ; } [ ] = [ ] ;
127127 entries . forEachValue ( ( key , entry ) => {
You can’t perform that action at this time.
0 commit comments