diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-01-08 13:02:54 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2016-01-08 13:02:54 +0100 |
commit | 8567ed9397b00729c76cc675e9c554133d2612e7 (patch) | |
tree | 3ff8a29c115dd4169b3ec2380d6675cf182ab396 | |
parent | 8ee24fdbdfb2f64899e68d44e4c4f236c8c34e86 (diff) | |
download | rpgedit-8567ed9397b00729c76cc675e9c554133d2612e7.tar rpgedit-8567ed9397b00729c76cc675e9c554133d2612e7.zip |
util: generalize numberArrayToMap
-rw-r--r-- | src/app.ts | 2 | ||||
-rw-r--r-- | src/util.ts | 4 |
2 files changed, 3 insertions, 3 deletions
@@ -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; |