From 8567ed9397b00729c76cc675e9c554133d2612e7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 8 Jan 2016 13:02:54 +0100 Subject: util: generalize numberArrayToMap --- src/app.ts | 2 +- src/util.ts | 4 ++-- 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(promises: {[key: string]: Promise}): 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; -- cgit v1.2.3