@nent/core
Version:
18 lines (16 loc) • 570 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;
}
export { dedent as d };