UNPKG

miniml

Version:

A minimal, embeddable semantic data modeling language for generating SQL queries from YAML model definitions. Inspired by LookML.

20 lines 743 B
export function collapseWhitespace(text, { singleSpaced = false, singleLine = false, collapseSpaces = true, unindent = false } = {}) { if (typeof text === "string") { text = text .replace(/\r\n/g, "\n") .replace(/\n(?:[\t ]*\n)+/g, "\n\n") .replace(/^\s+|\s+$/g, '') .replace(/\n{3,}/g, "\n\n"); if (singleSpaced) text = text.replace(/\n{2,}/g, "\n"); if (singleLine) text = text.replace(/\n/g, " "); if (collapseSpaces) text = text.replace(/[ \t]{2,}/g, " "); if (unindent) text = text.replace(/^[ \t]+/gm, ""); text = text.trim(); } return text; } //# sourceMappingURL=utilities.js.map