f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/main/js/common/utils/MapEntry.ts
-rw-r--r--
611
 1export class MapEntry<V> {
 2  readonly key: string;
 3  readonly value: V;
 4
 5  constructor(key: string, value: V) {
 6    this.key = key;
 7    this.value = value;
 8  }
 9
10  static of<V>(key: string, value: V) {
11    return new MapEntry(key, value);
12  }
13
14  static entriesToMap<V>(entries: Array<MapEntry<V>>): { [index: string]: V } {
15    const m: { [index: string]: V } = {};
16    entries.forEach((entry) => {
17      m[entry.key] = entry.value;
18    });
19    return m;
20  }
21
22  static mapToEntires<V>(map: { [index: string]: V }): Array<MapEntry<V>> {
23    return Object.keys(map).map((key) => MapEntry.of(key, map[key]));
24  }
25}