@@ -15,35 +15,39 @@ module ts {
1515 True = - 1
1616 }
1717
18- export class FileMap < T > {
19- private files : Map < T > = { } ;
20-
21- constructor ( private getCanonicalFileName : ( fileName : string ) => string ) {
18+ export function createFileMap < T > ( getCanonicalFileName : ( fileName : string ) => string ) : FileMap < T > {
19+ let files : Map < T > = { } ;
20+ return {
21+ get,
22+ set,
23+ contains,
24+ delete : deleteItem ,
25+ forEachValue : forEachValueInMap
2226 }
2327
24- public set ( fileName : string , value : T ) {
25- this . files [ this . normalizeKey ( fileName ) ] = value ;
28+ function set ( fileName : string , value : T ) {
29+ files [ normalizeKey ( fileName ) ] = value ;
2630 }
2731
28- public get ( fileName : string ) {
29- return this . files [ this . normalizeKey ( fileName ) ] ;
32+ function get ( fileName : string ) {
33+ return files [ normalizeKey ( fileName ) ] ;
3034 }
3135
32- public contains ( fileName : string ) {
33- return hasProperty ( this . files , this . normalizeKey ( fileName ) ) ;
36+ function contains ( fileName : string ) {
37+ return hasProperty ( files , normalizeKey ( fileName ) ) ;
3438 }
3539
36- public delete ( fileName : string ) {
37- let key = this . normalizeKey ( fileName ) ;
38- delete this . files [ key ] ;
40+ function deleteItem ( fileName : string ) {
41+ let key = normalizeKey ( fileName ) ;
42+ delete files [ key ] ;
3943 }
4044
41- public forEachValue ( f : ( value : T ) => void ) {
42- forEachValue ( this . files , f ) ;
45+ function forEachValueInMap ( f : ( value : T ) => void ) {
46+ forEachValue ( files , f ) ;
4347 }
4448
45- private normalizeKey ( key : string ) {
46- return this . getCanonicalFileName ( normalizeSlashes ( key ) ) ;
49+ function normalizeKey ( key : string ) {
50+ return getCanonicalFileName ( normalizeSlashes ( key ) ) ;
4751 }
4852 }
4953
0 commit comments