summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 13:02:54 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 13:02:54 +0100
commit8567ed9397b00729c76cc675e9c554133d2612e7 (patch)
tree3ff8a29c115dd4169b3ec2380d6675cf182ab396
parent8ee24fdbdfb2f64899e68d44e4c4f236c8c34e86 (diff)
downloadrpgedit-8567ed9397b00729c76cc675e9c554133d2612e7.tar
rpgedit-8567ed9397b00729c76cc675e9c554133d2612e7.zip
util: generalize numberArrayToMap
-rw-r--r--src/app.ts2
-rw-r--r--src/util.ts4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/app.ts b/src/app.ts
index 37aae93..acd255a 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -29,7 +29,7 @@ window.onload = () => {
xhr.onload = function() {
var mapDef = new MapData(JSON.parse(this.responseText));
- var inputHandler = new InputHandler(util.numberArrayToMap(relevantKeys));
+ var inputHandler = new InputHandler(util.arrayToObject(relevantKeys));
mapContext = new MapContext(mapDef, inputHandler);
}
diff --git a/src/util.ts b/src/util.ts
index ad2b482..0761d2d 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -12,8 +12,8 @@ export function mapPromises<T>(promises: {[key: string]: Promise<T>}): Promise<{
return Promise.all(p).then(() => ret);
}
-export function numberArrayToMap(arr: number[]): {[key: number]: boolean} {
- var ret: {[key: number]: boolean} = {};
+export function arrayToObject(arr: (number|string)[]): {[key: string]: boolean} {
+ var ret: {[key: string]: boolean} = {};
for (let v of arr)
ret[v] = true;