deno.land / x / rambda@v9.1.1 / source / indexBy.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { path } from './path.js'
function indexByPath(pathInput, list){ const toReturn = {} for (let i = 0; i < list.length; i++){ const item = list[ i ] toReturn[ path(pathInput, item) ] = item }
return toReturn}
export function indexBy(condition, list){ if (arguments.length === 1){ return _list => indexBy(condition, _list) }
if (typeof condition === 'string'){ return indexByPath(condition, list) }
const toReturn = {} for (let i = 0; i < list.length; i++){ const item = list[ i ] toReturn[ condition(item) ] = item }
return toReturn}
rambda

Version Info

Tagged at
2 months ago