Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
748 bytes
|
Rev | Line | |
---|
[6a3a178] | 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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.