/ cloudformation-templates / node_modules / lodash / _insertWrapDetails.js
_insertWrapDetails.js
 1  /** Used to match wrap detail comments. */
 2  var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
 3  
 4  /**
 5   * Inserts wrapper `details` in a comment at the top of the `source` body.
 6   *
 7   * @private
 8   * @param {string} source The source to modify.
 9   * @returns {Array} details The details to insert.
10   * @returns {string} Returns the modified source.
11   */
12  function insertWrapDetails(source, details) {
13    var length = details.length;
14    if (!length) {
15      return source;
16    }
17    var lastIndex = length - 1;
18    details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
19    details = details.join(length > 2 ? ', ' : ' ');
20    return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
21  }
22  
23  module.exports = insertWrapDetails;