util: generalize numberArrayToMap
This commit is contained in:
parent
8ee24fdbdf
commit
8567ed9397
2 changed files with 3 additions and 3 deletions
|
@ -29,7 +29,7 @@ window.onload = () => {
|
||||||
|
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
var mapDef = new MapData(JSON.parse(this.responseText));
|
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);
|
mapContext = new MapContext(mapDef, inputHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ export function mapPromises<T>(promises: {[key: string]: Promise<T>}): Promise<{
|
||||||
return Promise.all(p).then(() => ret);
|
return Promise.all(p).then(() => ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function numberArrayToMap(arr: number[]): {[key: number]: boolean} {
|
export function arrayToObject(arr: (number|string)[]): {[key: string]: boolean} {
|
||||||
var ret: {[key: number]: boolean} = {};
|
var ret: {[key: string]: boolean} = {};
|
||||||
|
|
||||||
for (let v of arr)
|
for (let v of arr)
|
||||||
ret[v] = true;
|
ret[v] = true;
|
||||||
|
|
Reference in a new issue