How to use the indexBy function from ramda
Find comprehensive JavaScript ramda.indexBy code examples handpicked from public code repositorys.
63 64 65 66 67 68 69 70 71 72
{} ) // Setup services object from service defs. const services = R.compose( R.indexBy(R.prop('id')), R.map( createService({ adapters, auths,
2
10
0
165 166 167 168 169 170 171 172 173 174
const getWhoFilePath = tableName => `${__dirname}/tables/${tableName}_zscores.json`; const loadWhoFiles = R.pipe(getWhoFilePath, R.pipeP(fs.readFile, JSON.parse)); const allowedIndexKeys = ['Length', 'Height', 'Month', 'Week']; const operativeIndexKey = R.pipe(R.keysIn, R.intersection(allowedIndexKeys), R.head); const reIndex = R.indexBy(R.chain(R.prop, operativeIndexKey)); // find first allowed index key within object keys — this is the operative index key // index by the values of the operative index key // reindex all
2
6
0
17 18 19 20 21 22 23 24 25 26 27
id: tune.tune, type: tune.type, names: [tune.name], })), R.uniqBy(R.prop('id')), R.indexBy(R.prop('id')) ) const transformAliases = R.pipe(R.groupBy(R.prop('tune_id')), R.map(R.pluck('alias')))
0
4
0
GitHub: alvaro-cuesta/aoc-js
14 15 16 17 18 19 20 21 22 23 24
rate: parseDecimal, tunnels: R.split(', '), }), ), ), R.indexBy(R.prop('valve')), ) const candidateToKey = ({ current, openValves, steps }) => `${current}@${steps}-${openValves.sort().join(',')}`
0
1
0
7419 7420 7421 7422 7423 7424 7425 7426 7427 7428
* @param {Array} array The array of objects to index * @return {Object} An object indexing each array element by the given property. * @example * * var list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; * R.indexBy(R.prop('id'), list); * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} */ var indexBy = reduceBy(function (acc, elem) { return elem;
0
0
0
+ 17 other calls in file
16 17 18 19 20 21 22 23 24 25 26 27 28
const describeStackResult = await cloudFormation.describeStacks({ StackName: prefixGlobalResourceName(stackName), }).promise(); const { Outputs: outputs } = describeStackResult.Stacks[0]; return indexBy(prop('ExportName'), outputs); } (async function () {
0
0
0
127 128 129 130 131 132 133 134 135
const ids = input.map(R.prop('id')) const trackData = await this.#trackService.asyncTrackData(ids) const dataMap = R.indexBy(R.prop('id'))(trackData) return input.map((entity) => ({ ...entity, ...dataMap[entity.id] })) }
0
0
0
GitHub: yerlanyr/adventofcode
1 2 3 4 5 6 7 8 9 10 11 12
const R = require('ramda') const fs = require('fs') function solution(input) { const parsedInput = parseInput(input) const indexedInput = R.indexBy(x => x[0], parsedInput) return solve(indexedInput, 'root') } function solve(indexInput, name) {
0
0
0
+ 3 other calls in file
118 119 120 121 122 123 124 125 126
const ids = input.map(R.prop('id')) const songData = await this.#enrichmentService.enrichSongData(ids) const dataMap = R.indexBy(R.prop('id'))(songData) return input.map((entity) => ({ ...entity, ...dataMap[entity.id] })) }
0
0
0
ramda.clone is the most popular function in ramda (30311 examples)