fix(config): add object.entries polyfil

This commit is contained in:
mhartington
2018-04-26 10:06:26 -04:00
parent 9c7b0ca15f
commit c917a3cd48
2 changed files with 12 additions and 1 deletions

View File

@ -1,10 +1,12 @@
import { entries } from '../utils/helpers';
export class Config { export class Config {
private m: Map<string, any>; private m: Map<string, any>;
constructor(configObj: {[key: string]: any}) { constructor(configObj: {[key: string]: any}) {
this.m = new Map<string, any>(Object.entries(configObj)); this.m = new Map<string, any>(entries(configObj));
} }
get(key: string, fallback?: any): any { get(key: string, fallback?: any): any {

View File

@ -41,6 +41,15 @@ export function pointerCoord(ev: any): {x: number, y: number} {
} }
export type Side = 'start' | 'end'; export type Side = 'start' | 'end';
export function entries(obj: {[s: string]: T}): [string, T][] {
const ownProps = Object.keys( obj );
let i = ownProps.length;
const resArray = new Array(i);
while (i--)
resArray[i] = [ownProps[i], obj[ownProps[i]]];
return resArray;
}
/** /**
* @hidden * @hidden
* Given a side, return if it should be on the right * Given a side, return if it should be on the right