Sha256: 2372ea4179872cb995b3e98d123e23b67b36228a47a4e8b0809852a77af89cb7
Contents?: true
Size: 489 Bytes
Versions: 117
Compression:
Stored size: 489 Bytes
Contents
function trimTrailingUndefined(array) { const trailingUndefinedCount = [...array].reverse().findIndex(x => x !== undefined); return array.slice(0, array.length - trailingUndefinedCount); } export default function transpose(input) { const maxCol = Math.max(0, ...(input.map(row => row.length))); return [...Array(maxCol).keys()].map(col => trimTrailingUndefined(input.map((_v, row) => input[row][col])) .map(charOrUndefined => charOrUndefined || ' ') .join('')); }
Version data entries
117 entries across 117 versions & 1 rubygems