Home
/
browser-rts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
final commit including final db schema
[browser-rts.git]
/
src
/
lib
/
util.ts
diff --git
a/src/lib/util.ts
b/src/lib/util.ts
index ebe84e5a4fac8d734d211d64f4034c7df27146fe..03aed1557bdc804fb2034529067b87f007eb87a8 100644
(file)
--- a/
src/lib/util.ts
+++ b/
src/lib/util.ts
@@
-1,9
+1,20
@@
-export function coalesce(...args: any[]): any {
+import { isEmpty } from 'lodash';
+
+export function coalesce(...args) {
let found;
while(args.length) {
found = args.shift();
let found;
while(args.length) {
found = args.shift();
- if(found !== null && found !== undefined &&
found !== ''
) {
+ if(found !== null && found !== undefined &&
!isEmpty(found)
) {
return 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;
+}