UNPKG
dla
Version:
latest (1.0.0)
1.0.0
0.0.1
node.js data loader with caching and support of lists
dla
/
src
/
index.ts
13 lines
(10 loc)
•
298 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
export
*
from
'./collection'
;
export
*
from
'./listable-collection'
;
export
*
from
'./cache'
;
export
function
index<V>(
list
: V[],
idExtractor
:
(
v
: V
) =>
string
): {[
id
:
string
]: V} {
const
res = {};
for
(
const
item
of
list) { res[
idExtractor
(item)] = item; }
return
res; }