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 | 1x 1x 1x 1x 31x 31x 31x 31x 31x 57x 57x 57x 57x 57x 57x 57x 57x 57x 57x 57x 544x 57x 541x 541x 541x 541x 541x 541x 31x 31x 31x 31x 31x 31x 31x 5x 31x 16x 16x 16x 57x 16x 16x 31x 3x 31x 31x 130x 130x 130x 663x 2295x 2295x 2295x 663x 130x 31x 31x 19x 19x 19x 19x 19x 19x 70x 70x 70x 70x 70x 19x 19x 31x | export const blendValues = (values: number[] = [], percentages: number[] = []) => values .reduce((sum, current, index) => sum + current * (percentages[index] || 0), 0) export function morphPaths(paths: String[] = []) { const needMsg = (elements: String, toBe: String) => `${elements} need to ${toBe}!` const emptySpace = ' ' const toLowerCase = (value: String) => value.toLowerCase() const parsePath = (value: String) => value .replace(/,/g, emptySpace) .replace(/$/g, emptySpace) .replace(/ *([a-zA-Z]) */g, '$1') .replace(/(.*) +$/g, '$1') .replace(/([0-9]+)-/g, '$1 -') .replace(/ *(a-zA-Z) */g, '$1') .replace(/ *( ) */g, '$1') .replace(/\s{1,}/g, emptySpace) .replace(/ ($)/g, '$1') .match(/[a-zA-Z][0-9 .-]*/g) ?.filter(([command]) => 'mlthvcsqaz' .includes(toLowerCase(command))) .map(([command, ...values]) => ({ command, values: values .join('') .split(emptySpace) .map(value => +value), })) if (!Array.isArray(paths)) throw (needMsg('Parameter', 'be a array')) if (paths.length < 2) throw (needMsg('Number of paths', 'minimal of 2')) if (paths.some((path: String) => typeof path !== 'string')) throw (needMsg('Paths', 'be String')) const parsedPaths = paths .map(path => parsePath(path)) const commandList = new Set(parsedPaths .map(path => path ?.map(({ command, values }) => `${command}${values.length}`) .join(''))) if (commandList.size > 1) throw (needMsg('Paths', 'have same commands')) const morphPath = parsedPaths[0] ?.map(({ command, values }, commandIndex) => ({ command, values: values .map((_, valueIndex) => parsedPaths .reduce((accumulator: number[], path) => { if (path) accumulator.push(path[commandIndex]?.values[valueIndex]) return accumulator }, [])), })) return (percentages: number[] = []) => { if (percentages.length !== paths.length) throw (needMsg('Count of percentages', 'be equal to paths')) if (percentages.some(percentage => typeof percentage !== 'number')) throw (needMsg('Percentages', 'be numbers')) return morphPath ?.map(({ command, values }) => { const allValues = values .map(values => blendValues(values, percentages)) .join(emptySpace) return `${command}${toLowerCase(command) === 'z' ? '' : emptySpace + allValues}` }) .join(emptySpace) } } |