system_assignation/node_modules/strip-indent/index.js

14 lines
254 B
JavaScript
Raw Normal View History

2022-03-24 09:22:39 -04:00
import minIndent from 'min-indent';
export default function stripIndent(string) {
const indent = minIndent(string);
if (indent === 0) {
return string;
}
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
return string.replace(regex, '');
}