Skip to content

Commit

Permalink
fix(config): add object.entries polyfil
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartington committed Apr 26, 2018
1 parent 9c7b0ca commit c917a3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/global/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { entries } from '../utils/helpers';

export class Config {

private m: Map<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 {
Expand Down
9 changes: 9 additions & 0 deletions core/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export function pointerCoord(ev: any): {x: number, y: number} {
}
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
* Given a side, return if it should be on the right
Expand Down

0 comments on commit c917a3c

Please sign in to comment.