How to use the flatten function from ramda
Find comprehensive JavaScript ramda.flatten code examples handpicked from public code repositorys.
48 49 50 51 52 53 54 55 56 57 58 59
if (data.results[index].label === "undefined") { data.results[index] = data.results[index].children; } }); return R.flatten(data.results); }; const buildHierarchy = (nodes, nodeMap) => { let structure = {
65
619
41
GitHub: 0xjjpa/github-patterns
276 277 278 279 280 281 282 283 284 285
if (currentStorage > 30) { store.clear(); } projects = R.flatten(nestedProjects); // const projectsByMonth = R.reduce( // (accum, project) => R.set( // dateLens(project),
6
57
4
GitHub: Morozzko/React_Blank_App
5 6 7 8 9 10 11 12 13 14
if (gathered) { const [middleware, transforms] = type(gathered) === 'Array' ? partition(isMiddleware, gathered) : [false, gathered] const padded = insertAll(1, transforms, [identity, identity]) const newMiddlewares = middleware && intersperse(middleware, padded) const normalizedArray = flatten(newMiddlewares || padded) const transform = compose(...normalizedArray) const resolved = require.resolve(path) const config = require(resolved)
2
5
0
+ 2 other calls in file
GitHub: mcamac/jmux
62 63 64 65 66 67 68 69 70 71 72 73 74
}, config.windows) subcommands.push(allWindowCommands) if (!process.env.TMUX) subcommands.push(`kill-window -t 0`) return 'tmux ' + R.flatten(subcommands).join(' \\; ') } var tmuxCommand = parseTmuxConfig(require(resolve(process.cwd(), program.config))) if (program.justPrint) {
1
3
0
216 217 218 219 220 221 222 223 224 225
} statements () { var stmts = JsonLdItemSerializer.prototype.statements.call(this) if (this.body.parentUri) stmts.memberOf = R.flatten([util.eachValue(this.body.parentUri, (id) => ({ '@type': 'nypl:Resource', '@id': `res:${id}` }))]) // Parse all contributor_(aut|ill|...) statements: Object.keys(this.body).forEach((field) => { var match = null
0
6
3
164 165 166 167 168 169 170 171 172 173 174 175
var getPrices = (0, _reselect.createSelector)(searchByKey, R.prop('prices')); exports.getPrices = getPrices; var getFlattenPrices = function getFlattenPrices() { return (0, _reselect.createSelector)(getPrices, function (prices) { return prices ? R.flatten(prices) : EMPTY_ARRAY; }); }; exports.getFlattenPrices = getFlattenPrices;
0
3
4
+ 41 other calls in file
GitHub: muqsitnawaz/deepcoin
183 184 185 186 187 188 189 190 191 192
console.error(`Invalid block balance: inputs sum '${sumOfInputsAmount}', outputs sum '${sumOfOutputsAmount}'`); throw new BlockAssertionError(`Invalid block balance: inputs sum '${sumOfInputsAmount}', outputs sum '${sumOfOutputsAmount}'`, { sumOfInputsAmount, sumOfOutputsAmount }); } // Check if there is double spending let listOfTransactionIndexInputs = R.flatten(R.map(R.compose(R.map(R.compose(R.join('|'), R.props(['transaction', 'index']))), R.prop('inputs'), R.prop('data')), newBlock.transactions)); let doubleSpendingList = R.filter((x) => x >= 2, R.map(R.length, R.groupBy(x => x)(listOfTransactionIndexInputs))); if (R.keys(doubleSpendingList).length) { console.error(`There are unspent output transactions being used more than once: unspent output transaction: '${R.keys(doubleSpendingList).join(', ')}'`);
0
1
0
GitHub: muqsitnawaz/deepcoin
92 93 94 95 96 97 98 99 100 101
const index = previousBlock.index + 1; const previousHash = previousBlock.hash; const timestamp = new Date().getTime() / 1000; const blocks = blockchain.getAllBlocks(); const candidateTransactions = blockchain.transactions; const transactionsInBlocks = R.flatten(R.map(R.prop('transactions'), blocks)); const inputTransactionsInTransaction = R.compose(R.flatten, R.map(R.compose(R.prop('inputs'), R.prop('data')))); // Select transactions that can be mined let rejectedTransactions = [];
0
1
0
5888 5889 5890 5891 5892 5893 5894 5895 5896
* @param {Array} list The array to consider. * @return {Array} The flattened list. * @see R.unnest * @example * * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] */ var flatten = _curry1(_makeFlat(true));
0
0
0
+ 17 other calls in file
GitHub: octachrome/t2
222 223 224 225 226 227 228 229 230 231
isValidAction(action) { return action in this.actions; } getRequiredRoles(action) { return R.flatten([this.actions[action].roles || []]); } getBlockingRoles(action) { return R.flatten([this.actions[action].blockedBy || []]);
0
0
0
+ 20 other calls in file
168 169 170 171 172 173 174 175 176 177
const step = (population, n) => { console.log('step:', n) if (n > maxSteps) return population const newPopulation = R.flatten(R.unfold(pop => { if (R.isEmpty(pop)) return false // Choose 2 chromosomes using roulette wheel const [chrom1, pop_] = rouletteSelect(target, pop) const [chrom2, pop__] = rouletteSelect(target, pop_)
0
0
0
+ 2 other calls in file
GitHub: octachrome/t2
102 103 104 105 106 107 108 109 110 111
Action.listAvailable = R.cond([ [State.eq(State.START_OF_TURN), game => [ Action.tax(), Action.income(), ]], [State.eq(State.ACTION_RESPONSE), game => R.flatten([ R.map(Action.challenge, Game.opponents(game)), Action.allow(), ])], [State.eq(State.CHALLENGE_RESPONSE), R.pipe(
0
0
0
+ 3 other calls in file
926 927 928 929 930 931 932 933 934 935
query } ${this.baseWhere(filters.concat(inlineWhereConditions))}`; } keysSelect(primaryKeyDimension) { return R.flatten( this.keyDimensions(primaryKeyDimension) .map(s => s.selectColumns()) ).filter(s => !!s).join(', '); }
0
0
0
+ 3 other calls in file
GitHub: znevrly/new-report
143 144 145 146 147 148 149 150 151 152 153
}); R.compose(R.map(function (status) { scenarios[index].all++; scenarios[index][status]++; }), R.flatten(), R.map(function (scenario) { return scenario.status; }), R.filter(isScenarioType))(feature.elements); });
0
0
0
+ 2 other calls in file
129 130 131 132 133 134 135 136 137 138 139
// Returns shallow copy of rungSpecs with newRung inserted, keeping result sorted by dim in descending order const insertIntoArray = R.curry( (newRung, rungSpecs) => R.pipe( R.splitWhen(r => r.dim < newRung.dim), R.insert(1, newRung), R.flatten )(rungSpecs) )
0
0
0
GitHub: evanlh/code2pdf
28 29 30 31 32 33 34 35 36 37
let $ = cheerio.load(html); this.recurseNodes($(':root'), undefined, $); // put \n's in their own nodes by themselves this.textNodes = R.flatten(this.textNodes.map(n => { let splitText = this._newlineSplitter(n.text); return splitText.map(t => { return R.merge(n, { text: t }); })
0
0
0
6 7 8 9 10 11 12 13 14 15 16 17 18 19
}); // -------------------------------------------- function parse(lines) { const step1 = R.flatten(lines.map(x => R.startsWith('$', x) ? ['$', R.tail(x.split(' ')).join(' ')] : x)); U.log('step 1', step1); const step2 = R.splitWhenever(R.startsWith('$'), step1);
0
0
0
GitHub: jcla1/AdventOfCode
51 52 53 54 55 56 57 58 59 60 61 62 63
}, [0, board]))(R.range(0, 100)); console.log(noFlashes); const firstAllFlash = R.reduce((board, i) => { if (R.all(R.equals(0), R.flatten(board))) return R.reduced(i); return doStep(board)[1]; }, board, R.range(0, 100000)); console.log(firstAllFlash);
0
0
0
ramda.clone is the most popular function in ramda (30311 examples)