import stripAnsi from 'strip-ansi'; /** * @ignore */ export function padNoAnsi(str, length, place) { const noAnsiStr = stripAnsi(str); if (length < noAnsiStr.length) return str; const pad = Array(length - noAnsiStr.length + 1).join(' '); if (place === 'end') { return str + pad; } else { return pad + str; } } /** * Group an array by a function that returns the key * * @ignore */ export function groupBy(objs, f) { var _a; const result = {}; for (const obj of objs) { const key = f(obj); result[key] = (_a = result[key]) !== null && _a !== void 0 ? _a : []; result[key].push(obj); } return result; } /** * A better typed version of `Object.entries` * * @ignore */ export function entries(obj) { return Object.entries(obj); } /** * Enumerate over a list, to get a pair of [index, value] * * @ignore */ export function* enumerate(arr) { for (let i = 0; i < arr.length; i++) { yield [i, arr[i]]; } } /** * Array#flatMap polyfill * * @ignore */ export function flatMap(xs, fn) { const results = []; for (const x of xs) { results.push(...fn(x)); } return results; } /** * Flatten an array * * @ignore */ export function flatten(xs) { const results = []; for (const x of xs) { results.push(...x); } return results; } //# sourceMappingURL=utils.js.map