-export function coalesce(...args: any[]): any {
+import { isEmpty } from 'lodash';
+
+export function coalesce(...args) {
let found;
while(args.length) {
found = args.shift();
- if(found !== null && found !== undefined && found !== '') {
+ if(found !== null && found !== undefined && !isEmpty(found)) {
return found;
}
}
-}
\ No newline at end of file
+}
+
+export function pluck<T>(arr: T[], field: string): Map<string, T> {
+ const map = new Map<string, T>();
+ arr.forEach(obj => {
+ map[obj[field]] = obj;
+ });
+
+ return map;
+}