@newdash/newdash
Version:
javascript/typescript utility library
23 lines (22 loc) • 781 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const GLOBAL_1 = require("./GLOBAL");
/**
* Inserts wrapper `details` in a comment at the top of the `source` body.
*
* @private
* @param {string} source The source to modify.
* @returns {Array} details The details to insert.
* @returns {string} Returns the modified source.
*/
function insertWrapDetails(source, details) {
var length = details.length;
if (!length) {
return source;
}
var lastIndex = length - 1;
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
details = details.join(length > 2 ? ', ' : ' ');
return source.replace(GLOBAL_1.reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
}
exports.default = insertWrapDetails;