Files
angular-docs-cn/modules/@angular/router-deprecated/src/utils.ts
T

38 lines
978 B
TypeScript
Raw Normal View History

import {StringMapWrapper} from '../src/facade/collection';
2016-06-08 16:38:52 -07:00
import {isBlank, isPresent} from '../src/facade/lang';
2016-02-09 11:12:41 -08:00
export class TouchMap {
map: {[key: string]: string} = {};
keys: {[key: string]: boolean} = {};
constructor(map: {[key: string]: any}) {
if (isPresent(map)) {
2016-06-08 15:45:15 -07:00
StringMapWrapper.forEach(map, (value: any /** TODO #9100 */, key: any /** TODO #9100 */) => {
2016-02-09 11:12:41 -08:00
this.map[key] = isPresent(value) ? value.toString() : null;
this.keys[key] = true;
});
}
}
get(key: string): string {
StringMapWrapper.delete(this.keys, key);
return this.map[key];
}
getUnused(): {[key: string]: any} {
var unused: {[key: string]: any} = {};
var keys = StringMapWrapper.keys(this.keys);
keys.forEach(key => unused[key] = StringMapWrapper.get(this.map, key));
return unused;
}
}
export function normalizeString(obj: any): string {
if (isBlank(obj)) {
return null;
} else {
return obj.toString();
}
}