@nent/core
Version:
20 lines (17 loc) • 586 B
JavaScript
/*!
* NENT 2022
*/
;
/**
* It removes the leading whitespace from a string
* @param {string} innerText - The text to dedent.
* @returns the string with the leading whitespace removed.
*/
function dedent(innerText) {
const string = innerText === null || innerText === void 0 ? void 0 : innerText.replace(/^\n/, '');
const match = string === null || string === void 0 ? void 0 : string.match(/^\s+/);
return match
? string === null || string === void 0 ? void 0 : string.replace(new RegExp(`^${match[0]}`, 'gm'), '')
: string;
}
exports.dedent = dedent;