UNPKG

prettier-plugin-ember-template-tag

Version:
18 lines (16 loc) 423 B
import type { doc } from 'prettier'; /** * Flattens the given doc into a string array, tossing line breaks, etc, for * analysis. */ export function flattenDoc(doc: doc.builders.Doc): string[] { if (Array.isArray(doc)) { return doc.flatMap(flattenDoc); } else if (typeof doc === 'string') { return [doc]; } else if ('contents' in doc) { return flattenDoc(doc.contents); } else { return []; } }