Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | 5x 20x 140x 5x 5x 5x 1x 4x 5x 4x 5x 5x 3x 13x 13x 13x 10x 10x 10x 9x 9x 9x 9x 9x 9x 9x 4x | import { map, filter, I, curry, merge, reduce, keys, pipe } from "f-utility" import uniq from "array-union" import mergeOptions from "merge-options" import { groupBy, macroLens, sortByDate, sortByDateObject, sortByAuthorDate, neue } from "./utils" import { convertStatusAndFilesPerCommit, addAnalysisPerCommit } from "./per-commit" import { getCanon } from "./alias" /** @method createBannersFromGroups @param {Object} grouped - a grouped object of commits @return {Array} ungrouped array with banner objects inserted */ export const createBannersFromGroups = grouped => pipe( keys, sortByDateObject, reduce( (list, key) => list.concat( { date: key, type: `banner` }, sortByAuthorDate(grouped[key]) ), [] ) )(grouped) /** @method insertBanners @param {Array} commits - a list of commit @return {Array} commits with banners inserted (type: `banner`) */ export const insertBanners = pipe( groupBy(`date`), createBannersFromGroups ) /** @method quash @param {Array} x - an array of inputs @returns {Array} a unique, filtered array with no null values and no pass-by-referents */ const quash = pipe( neue, filter(I), uniq ) /** @method booleanMerge @param {Object} a - an object with boolean keys @param {Object} b - another object with boolean keys @returns {Object} an object which is the truthy merge of all keys */ export const booleanMerge = curry((x, y) => pipe( keys, reduce((out, key) => merge(out, { [key]: x[key] || y[key] }), {}) )(x) ) /** @method relearn @param {Object} commit - an object with a changes property @return {Object} an updated object */ const relearn = curry((lookup, x) => pipe( macroLens(convertStatusAndFilesPerCommit, `changes`), addAnalysisPerCommit(lookup) )(x) ) /** @method uniqueFiles @param {*} _ - anything @param {Array} files - a list of files @return {Array} a unique list of files */ const uniqueFiles = (_, files) => uniq(files) /** @method collapseSuccessiveSameAuthor @param {Object} lookup - the lookup / legend object @param {Object} data - the list of commits @return {Object} a potentially collapsed list of commits */ export const collapseSuccessiveSameAuthor = curry((lookup, data) => pipe( sortByDate, reduce((list, next) => { const copy = neue(list) const last = copy[copy.length - 1] if (next && last) { const authorsMatch = getCanon(last.authorName) === getCanon(next.authorName) const datesMatch = last.date === next.date if (authorsMatch && datesMatch) { const raw = mergeOptions(last, next) const status = [].concat(last.status, next.status) const files = [].concat(last.files, next.files) const subject = `${last.subject} + ${next.subject}` const augmented = mergeOptions(raw, { hash: next.hash, files, subject, status, multiple: true, hashes: quash([].concat(raw.hashes || [], last.hash, next.hash)) }) copy[copy.length - 1] = augmented // eslint-disable-line fp/no-mutation return sortByDate(copy) } } return sortByDate(copy.concat(next)) }, []), map( pipe( relearn(lookup), macroLens(uniqueFiles, `files`) ) ) )(data) ) |