@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
27 lines • 883 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.trimmed = trimmed;
/**
* A tag function trimming the leading and trailing whitespace from multi-line strings.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals
*
* @param templates
* @param placeholders
*/
function trimmed(templates, ...placeholders) {
const lines = templates
.map((template, i) => i < placeholders.length
? [template, placeholders[i]]
: [template])
.reduce((acc, tuple) => acc.concat(tuple))
.join('')
.split('\n');
const nonEmptyLines = lines
.map(line => line.trim())
.filter(line => !!line);
return nonEmptyLines
.map(line => line.replace(/\|\s?(.*)$/, '$1'))
.join('\n');
}
//# sourceMappingURL=trimmed.js.map
;