code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function applyPatches(uniDiff, options) {
if (typeof uniDiff === 'string') {
uniDiff = parsePatch(uniDiff);
}
var currentIndex = 0;
function processIndex() {
var index = uniDiff[currentIndex++];
if (!index) {
return options.complete();
}
options.loadFile(index, function (err, data) {
if (err) {
return options.complete(err);
}
var updatedContent = applyPatch(data, index, options);
options.patched(index, updatedContent, function (err) {
if (err) {
return options.complete(err);
}
processIndex();
});
});
}
processIndex();
}
|
Checks if the hunk exactly fits on the provided location
|
applyPatches
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function processIndex() {
var index = uniDiff[currentIndex++];
if (!index) {
return options.complete();
}
options.loadFile(index, function (err, data) {
if (err) {
return options.complete(err);
}
var updatedContent = applyPatch(data, index, options);
options.patched(index, updatedContent, function (err) {
if (err) {
return options.complete(err);
}
processIndex();
});
});
}
|
Checks if the hunk exactly fits on the provided location
|
processIndex
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
if (!options) {
options = {};
}
if (typeof options.context === 'undefined') {
options.context = 4;
}
var diff = diffLines(oldStr, newStr, options);
diff.push({
value: '',
lines: []
}); // Append an empty value to make cleanup easier
function contextLines(lines) {
return lines.map(function (entry) {
return ' ' + entry;
});
}
var hunks = [];
var oldRangeStart = 0,
newRangeStart = 0,
curRange = [],
oldLine = 1,
newLine = 1;
var _loop = function _loop(i) {
var current = diff[i],
lines = current.lines || current.value.replace(/\n$/, '').split('\n');
current.lines = lines;
if (current.added || current.removed) {
var _curRange; // If we have previous context, start with that
if (!oldRangeStart) {
var prev = diff[i - 1];
oldRangeStart = oldLine;
newRangeStart = newLine;
if (prev) {
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
oldRangeStart -= curRange.length;
newRangeStart -= curRange.length;
}
} // Output our changes
(_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
return (current.added ? '+' : '-') + entry;
}))); // Track the updated file position
if (current.added) {
newLine += lines.length;
} else {
oldLine += lines.length;
}
} else {
// Identical context lines. Track line changes
if (oldRangeStart) {
// Close out any changes that have been output (or join overlapping)
if (lines.length <= options.context * 2 && i < diff.length - 2) {
var _curRange2; // Overlapping
(_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
} else {
var _curRange3; // end the range and output
var contextSize = Math.min(lines.length, options.context);
(_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
var hunk = {
oldStart: oldRangeStart,
oldLines: oldLine - oldRangeStart + contextSize,
newStart: newRangeStart,
newLines: newLine - newRangeStart + contextSize,
lines: curRange
};
if (i >= diff.length - 2 && lines.length <= options.context) {
// EOF is inside this hunk
var oldEOFNewline = /\n$/.test(oldStr);
var newEOFNewline = /\n$/.test(newStr);
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
if (!oldEOFNewline && noNlBeforeAdds) {
// special case: old has no eol and no trailing context; no-nl can end up before adds
curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
}
if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
curRange.push('\\ No newline at end of file');
}
}
hunks.push(hunk);
oldRangeStart = 0;
newRangeStart = 0;
curRange = [];
}
}
oldLine += lines.length;
newLine += lines.length;
}
};
for (var i = 0; i < diff.length; i++) {
_loop(i);
}
return {
oldFileName: oldFileName,
newFileName: newFileName,
oldHeader: oldHeader,
newHeader: newHeader,
hunks: hunks
};
}
|
Checks if the hunk exactly fits on the provided location
|
structuredPatch
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function contextLines(lines) {
return lines.map(function (entry) {
return ' ' + entry;
});
}
|
Checks if the hunk exactly fits on the provided location
|
contextLines
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
_loop = function _loop(i) {
var current = diff[i],
lines = current.lines || current.value.replace(/\n$/, '').split('\n');
current.lines = lines;
if (current.added || current.removed) {
var _curRange; // If we have previous context, start with that
if (!oldRangeStart) {
var prev = diff[i - 1];
oldRangeStart = oldLine;
newRangeStart = newLine;
if (prev) {
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
oldRangeStart -= curRange.length;
newRangeStart -= curRange.length;
}
} // Output our changes
(_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) {
return (current.added ? '+' : '-') + entry;
}))); // Track the updated file position
if (current.added) {
newLine += lines.length;
} else {
oldLine += lines.length;
}
} else {
// Identical context lines. Track line changes
if (oldRangeStart) {
// Close out any changes that have been output (or join overlapping)
if (lines.length <= options.context * 2 && i < diff.length - 2) {
var _curRange2; // Overlapping
(_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
} else {
var _curRange3; // end the range and output
var contextSize = Math.min(lines.length, options.context);
(_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
var hunk = {
oldStart: oldRangeStart,
oldLines: oldLine - oldRangeStart + contextSize,
newStart: newRangeStart,
newLines: newLine - newRangeStart + contextSize,
lines: curRange
};
if (i >= diff.length - 2 && lines.length <= options.context) {
// EOF is inside this hunk
var oldEOFNewline = /\n$/.test(oldStr);
var newEOFNewline = /\n$/.test(newStr);
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
if (!oldEOFNewline && noNlBeforeAdds) {
// special case: old has no eol and no trailing context; no-nl can end up before adds
curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
}
if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
curRange.push('\\ No newline at end of file');
}
}
hunks.push(hunk);
oldRangeStart = 0;
newRangeStart = 0;
curRange = [];
}
}
oldLine += lines.length;
newLine += lines.length;
}
}
|
Checks if the hunk exactly fits on the provided location
|
_loop
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
var ret = [];
if (oldFileName == newFileName) {
ret.push('Index: ' + oldFileName);
}
ret.push('===================================================================');
ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
for (var i = 0; i < diff.hunks.length; i++) {
var hunk = diff.hunks[i];
ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
ret.push.apply(ret, hunk.lines);
}
return ret.join('\n') + '\n';
}
|
Checks if the hunk exactly fits on the provided location
|
createTwoFilesPatch
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
}
|
Checks if the hunk exactly fits on the provided location
|
createPatch
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function arrayEqual(a, b) {
if (a.length !== b.length) {
return false;
}
return arrayStartsWith(a, b);
}
|
Checks if the hunk exactly fits on the provided location
|
arrayEqual
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function arrayStartsWith(array, start) {
if (start.length > array.length) {
return false;
}
for (var i = 0; i < start.length; i++) {
if (start[i] !== array[i]) {
return false;
}
}
return true;
}
|
Checks if the hunk exactly fits on the provided location
|
arrayStartsWith
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function calcLineCount(hunk) {
var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines),
oldLines = _calcOldNewLineCount.oldLines,
newLines = _calcOldNewLineCount.newLines;
if (oldLines !== undefined) {
hunk.oldLines = oldLines;
} else {
delete hunk.oldLines;
}
if (newLines !== undefined) {
hunk.newLines = newLines;
} else {
delete hunk.newLines;
}
}
|
Checks if the hunk exactly fits on the provided location
|
calcLineCount
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function merge(mine, theirs, base) {
mine = loadPatch(mine, base);
theirs = loadPatch(theirs, base);
var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
// Leaving sanity checks on this to the API consumer that may know more about the
// meaning in their own context.
if (mine.index || theirs.index) {
ret.index = mine.index || theirs.index;
}
if (mine.newFileName || theirs.newFileName) {
if (!fileNameChanged(mine)) {
// No header or no change in ours, use theirs (and ours if theirs does not exist)
ret.oldFileName = theirs.oldFileName || mine.oldFileName;
ret.newFileName = theirs.newFileName || mine.newFileName;
ret.oldHeader = theirs.oldHeader || mine.oldHeader;
ret.newHeader = theirs.newHeader || mine.newHeader;
} else if (!fileNameChanged(theirs)) {
// No header or no change in theirs, use ours
ret.oldFileName = mine.oldFileName;
ret.newFileName = mine.newFileName;
ret.oldHeader = mine.oldHeader;
ret.newHeader = mine.newHeader;
} else {
// Both changed... figure it out
ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
}
}
ret.hunks = [];
var mineIndex = 0,
theirsIndex = 0,
mineOffset = 0,
theirsOffset = 0;
while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
var mineCurrent = mine.hunks[mineIndex] || {
oldStart: Infinity
},
theirsCurrent = theirs.hunks[theirsIndex] || {
oldStart: Infinity
};
if (hunkBefore(mineCurrent, theirsCurrent)) {
// This patch does not overlap with any of the others, yay.
ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
mineIndex++;
theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
} else if (hunkBefore(theirsCurrent, mineCurrent)) {
// This patch does not overlap with any of the others, yay.
ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
theirsIndex++;
mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
} else {
// Overlap, merge as best we can
var mergedHunk = {
oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
oldLines: 0,
newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
newLines: 0,
lines: []
};
mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
theirsIndex++;
mineIndex++;
ret.hunks.push(mergedHunk);
}
}
return ret;
}
|
Checks if the hunk exactly fits on the provided location
|
merge
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function loadPatch(param, base) {
if (typeof param === 'string') {
if (/^@@/m.test(param) || /^Index:/m.test(param)) {
return parsePatch(param)[0];
}
if (!base) {
throw new Error('Must provide a base reference or pass in a patch');
}
return structuredPatch(undefined, undefined, base, param);
}
return param;
}
|
Checks if the hunk exactly fits on the provided location
|
loadPatch
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function fileNameChanged(patch) {
return patch.newFileName && patch.newFileName !== patch.oldFileName;
}
|
Checks if the hunk exactly fits on the provided location
|
fileNameChanged
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function selectField(index, mine, theirs) {
if (mine === theirs) {
return mine;
} else {
index.conflict = true;
return {
mine: mine,
theirs: theirs
};
}
}
|
Checks if the hunk exactly fits on the provided location
|
selectField
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function hunkBefore(test, check) {
return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
}
|
Checks if the hunk exactly fits on the provided location
|
hunkBefore
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function cloneHunk(hunk, offset) {
return {
oldStart: hunk.oldStart,
oldLines: hunk.oldLines,
newStart: hunk.newStart + offset,
newLines: hunk.newLines,
lines: hunk.lines
};
}
|
Checks if the hunk exactly fits on the provided location
|
cloneHunk
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
// This will generally result in a conflicted hunk, but there are cases where the context
// is the only overlap where we can successfully merge the content here.
var mine = {
offset: mineOffset,
lines: mineLines,
index: 0
},
their = {
offset: theirOffset,
lines: theirLines,
index: 0
}; // Handle any leading content
insertLeading(hunk, mine, their);
insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
while (mine.index < mine.lines.length && their.index < their.lines.length) {
var mineCurrent = mine.lines[mine.index],
theirCurrent = their.lines[their.index];
if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
// Both modified ...
mutualChange(hunk, mine, their);
} else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
var _hunk$lines; // Mine inserted
(_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine)));
} else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
var _hunk$lines2; // Theirs inserted
(_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their)));
} else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
// Mine removed or edited
removal(hunk, mine, their);
} else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
// Their removed or edited
removal(hunk, their, mine, true);
} else if (mineCurrent === theirCurrent) {
// Context identity
hunk.lines.push(mineCurrent);
mine.index++;
their.index++;
} else {
// Context mismatch
conflict(hunk, collectChange(mine), collectChange(their));
}
} // Now push anything that may be remaining
insertTrailing(hunk, mine);
insertTrailing(hunk, their);
calcLineCount(hunk);
}
|
Checks if the hunk exactly fits on the provided location
|
mergeLines
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function mutualChange(hunk, mine, their) {
var myChanges = collectChange(mine),
theirChanges = collectChange(their);
if (allRemoves(myChanges) && allRemoves(theirChanges)) {
// Special case for remove changes that are supersets of one another
if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
var _hunk$lines3;
(_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges));
return;
} else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
var _hunk$lines4;
(_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges));
return;
}
} else if (arrayEqual(myChanges, theirChanges)) {
var _hunk$lines5;
(_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges));
return;
}
conflict(hunk, myChanges, theirChanges);
}
|
Checks if the hunk exactly fits on the provided location
|
mutualChange
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function removal(hunk, mine, their, swap) {
var myChanges = collectChange(mine),
theirChanges = collectContext(their, myChanges);
if (theirChanges.merged) {
var _hunk$lines6;
(_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged));
} else {
conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
}
}
|
Checks if the hunk exactly fits on the provided location
|
removal
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function conflict(hunk, mine, their) {
hunk.conflict = true;
hunk.lines.push({
conflict: true,
mine: mine,
theirs: their
});
}
|
Checks if the hunk exactly fits on the provided location
|
conflict
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function insertLeading(hunk, insert, their) {
while (insert.offset < their.offset && insert.index < insert.lines.length) {
var line = insert.lines[insert.index++];
hunk.lines.push(line);
insert.offset++;
}
}
|
Checks if the hunk exactly fits on the provided location
|
insertLeading
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function insertTrailing(hunk, insert) {
while (insert.index < insert.lines.length) {
var line = insert.lines[insert.index++];
hunk.lines.push(line);
}
}
|
Checks if the hunk exactly fits on the provided location
|
insertTrailing
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function collectChange(state) {
var ret = [],
operation = state.lines[state.index][0];
while (state.index < state.lines.length) {
var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
if (operation === '-' && line[0] === '+') {
operation = '+';
}
if (operation === line[0]) {
ret.push(line);
state.index++;
} else {
break;
}
}
return ret;
}
|
Checks if the hunk exactly fits on the provided location
|
collectChange
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function collectContext(state, matchChanges) {
var changes = [],
merged = [],
matchIndex = 0,
contextChanges = false,
conflicted = false;
while (matchIndex < matchChanges.length && state.index < state.lines.length) {
var change = state.lines[state.index],
match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
if (match[0] === '+') {
break;
}
contextChanges = contextChanges || change[0] !== ' ';
merged.push(match);
matchIndex++; // Consume any additions in the other block as a conflict to attempt
// to pull in the remaining context after this
if (change[0] === '+') {
conflicted = true;
while (change[0] === '+') {
changes.push(change);
change = state.lines[++state.index];
}
}
if (match.substr(1) === change.substr(1)) {
changes.push(change);
state.index++;
} else {
conflicted = true;
}
}
if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
conflicted = true;
}
if (conflicted) {
return changes;
}
while (matchIndex < matchChanges.length) {
merged.push(matchChanges[matchIndex++]);
}
return {
merged: merged,
changes: changes
};
}
|
Checks if the hunk exactly fits on the provided location
|
collectContext
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function allRemoves(changes) {
return changes.reduce(function (prev, change) {
return prev && change[0] === '-';
}, true);
}
|
Checks if the hunk exactly fits on the provided location
|
allRemoves
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function skipRemoveSuperset(state, removeChanges, delta) {
for (var i = 0; i < delta; i++) {
var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
if (state.lines[state.index + i] !== ' ' + changeContent) {
return false;
}
}
state.index += delta;
return true;
}
|
Checks if the hunk exactly fits on the provided location
|
skipRemoveSuperset
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function calcOldNewLineCount(lines) {
var oldLines = 0;
var newLines = 0;
lines.forEach(function (line) {
if (typeof line !== 'string') {
var myCount = calcOldNewLineCount(line.mine);
var theirCount = calcOldNewLineCount(line.theirs);
if (oldLines !== undefined) {
if (myCount.oldLines === theirCount.oldLines) {
oldLines += myCount.oldLines;
} else {
oldLines = undefined;
}
}
if (newLines !== undefined) {
if (myCount.newLines === theirCount.newLines) {
newLines += myCount.newLines;
} else {
newLines = undefined;
}
}
} else {
if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
newLines++;
}
if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
oldLines++;
}
}
});
return {
oldLines: oldLines,
newLines: newLines
};
} // See: http://code.google.com/p/google-diff-match-patch/wiki/API
|
Checks if the hunk exactly fits on the provided location
|
calcOldNewLineCount
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function convertChangesToDMP(changes) {
var ret = [],
change,
operation;
for (var i = 0; i < changes.length; i++) {
change = changes[i];
if (change.added) {
operation = 1;
} else if (change.removed) {
operation = -1;
} else {
operation = 0;
}
ret.push([operation, change.value]);
}
return ret;
}
|
Checks if the hunk exactly fits on the provided location
|
convertChangesToDMP
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function convertChangesToXML(changes) {
var ret = [];
for (var i = 0; i < changes.length; i++) {
var change = changes[i];
if (change.added) {
ret.push('<ins>');
} else if (change.removed) {
ret.push('<del>');
}
ret.push(escapeHTML(change.value));
if (change.added) {
ret.push('</ins>');
} else if (change.removed) {
ret.push('</del>');
}
}
return ret.join('');
}
|
Checks if the hunk exactly fits on the provided location
|
convertChangesToXML
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function escapeHTML(s) {
var n = s;
n = n.replace(/&/g, '&');
n = n.replace(/</g, '<');
n = n.replace(/>/g, '>');
n = n.replace(/"/g, '"');
return n;
}
|
Checks if the hunk exactly fits on the provided location
|
escapeHTML
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function getOptions(argv, detailedOptions) {
return fromPairs_1(detailedOptions.filter(({
forwardToApi
}) => forwardToApi).map(({
forwardToApi,
name
}) => [forwardToApi, argv[name]]));
}
|
Checks if the hunk exactly fits on the provided location
|
getOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function cliifyOptions(object, apiDetailedOptionMap) {
return Object.keys(object || {}).reduce((output, key) => {
const apiOption = apiDetailedOptionMap[key];
const cliKey = apiOption ? apiOption.name : key;
output[dashify(cliKey)] = object[key];
return output;
}, {});
}
|
Checks if the hunk exactly fits on the provided location
|
cliifyOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function diff(a, b) {
return require$$3.createTwoFilesPatch("", "", a, b, "", "", {
context: 2
});
}
|
Checks if the hunk exactly fits on the provided location
|
diff
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function handleError(context, filename, error) {
if (error instanceof errors.UndefinedParserError) {
if (context.argv.write && isTty()) {
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
}
if (!context.argv.check && !context.argv["list-different"]) {
process.exitCode = 2;
}
context.logger.error(error.message);
return;
}
if (context.argv.write) {
// Add newline to split errors from filename line.
process.stdout.write("\n");
}
const isParseError = Boolean(error && error.loc);
const isValidationError = /^Invalid \S+ value\./.test(error && error.message);
if (isParseError) {
// `invalid.js: SyntaxError: Unexpected token (1:1)`.
context.logger.error(`${filename}: ${String(error)}`);
} else if (isValidationError || error instanceof errors.ConfigError) {
// `Invalid printWidth value. Expected an integer, but received 0.5.`
context.logger.error(error.message); // If validation fails for one file, it will fail for all of them.
process.exit(1);
} else if (error instanceof errors.DebugError) {
// `invalid.js: Some debug error message`
context.logger.error(`${filename}: ${error.message}`);
} else {
// `invalid.js: Error: Some unexpected error\n[stack trace]`
context.logger.error(filename + ": " + (error.stack || error));
} // Don't exit the process if one file failed
process.exitCode = 2;
}
|
Checks if the hunk exactly fits on the provided location
|
handleError
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function logResolvedConfigPathOrDie(context) {
const configFile = src.resolveConfigFile.sync(context.argv["find-config-path"]);
if (configFile) {
context.logger.log(path.relative(process.cwd(), configFile));
} else {
process.exit(1);
}
}
|
Checks if the hunk exactly fits on the provided location
|
logResolvedConfigPathOrDie
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function logFileInfoOrDie(context) {
const options = {
ignorePath: context.argv["ignore-path"],
withNodeModules: context.argv["with-node-modules"],
plugins: context.argv.plugin,
pluginSearchDirs: context.argv["plugin-search-dir"]
};
context.logger.log(src.format(jsonStableStringify(src.getFileInfo.sync(context.argv["file-info"], options)), {
parser: "json"
}));
}
|
Checks if the hunk exactly fits on the provided location
|
logFileInfoOrDie
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function writeOutput(context, result, options) {
// Don't use `console.log` here since it adds an extra newline at the end.
process.stdout.write(context.argv["debug-check"] ? result.filepath : result.formatted);
if (options && options.cursorOffset >= 0) {
process.stderr.write(result.cursorOffset + "\n");
}
}
|
Checks if the hunk exactly fits on the provided location
|
writeOutput
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function listDifferent(context, input, options, filename) {
if (!context.argv.check && !context.argv["list-different"]) {
return;
}
try {
if (!options.filepath && !options.parser) {
throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
}
if (!src.check(input, options)) {
if (!context.argv.write) {
context.logger.log(filename);
process.exitCode = 1;
}
}
} catch (error) {
context.logger.error(error.message);
}
return true;
}
|
Checks if the hunk exactly fits on the provided location
|
listDifferent
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function format(context, input, opt) {
if (!opt.parser && !opt.filepath) {
throw new errors.UndefinedParserError("No parser and no file path given, couldn't infer a parser.");
}
if (context.argv["debug-print-doc"]) {
const doc = src.__debug.printToDoc(input, opt);
return {
formatted: src.__debug.formatDoc(doc)
};
}
if (context.argv["debug-check"]) {
const pp = src.format(input, opt);
const pppp = src.format(pp, opt);
if (pp !== pppp) {
throw new errors.DebugError("prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp));
} else {
const stringify = obj => JSON.stringify(obj, null, 2);
const ast = stringify(src.__debug.parse(input, opt,
/* massage */
true).ast);
const past = stringify(src.__debug.parse(pp, opt,
/* massage */
true).ast);
/* istanbul ignore next */
if (ast !== past) {
const MAX_AST_SIZE = 2097152; // 2MB
const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past);
throw new errors.DebugError("ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp));
}
}
return {
formatted: pp,
filepath: opt.filepath || "(stdin)\n"
};
}
/* istanbul ignore next */
if (context.argv["debug-benchmark"]) {
let benchmark;
try {
benchmark = require("benchmark");
} catch (err) {
context.logger.debug("'--debug-benchmark' requires the 'benchmark' package to be installed.");
process.exit(2);
}
context.logger.debug("'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module.");
const suite = new benchmark.Suite();
suite.add("format", () => {
src.formatWithCursor(input, opt);
}).on("cycle", event => {
const results = {
benchmark: String(event.target),
hz: event.target.hz,
ms: event.target.times.cycle * 1000
};
context.logger.debug("'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
}).run({
async: false
});
} else if (context.argv["debug-repeat"] > 0) {
const repeat = context.argv["debug-repeat"];
context.logger.debug("'--debug-repeat' option found, running formatWithCursor " + repeat + " times."); // should be using `performance.now()`, but only `Date` is cross-platform enough
const now = Date.now ? () => Date.now() : () => +new Date();
let totalMs = 0;
for (let i = 0; i < repeat; ++i) {
const startMs = now();
src.formatWithCursor(input, opt);
totalMs += now() - startMs;
}
const averageMs = totalMs / repeat;
const results = {
repeat,
hz: 1000 / averageMs,
ms: averageMs
};
context.logger.debug("'--debug-repeat' measurements for formatWithCursor: " + JSON.stringify(results, null, 2));
}
return src.formatWithCursor(input, opt);
}
|
Checks if the hunk exactly fits on the provided location
|
format
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function getOptionsOrDie(context, filePath) {
try {
if (context.argv.config === false) {
context.logger.debug("'--no-config' option found, skip loading config file.");
return null;
}
context.logger.debug(context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`);
const options = src.resolveConfig.sync(filePath, {
editorconfig: context.argv.editorconfig,
config: context.argv.config
});
context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
return options;
} catch (error) {
context.logger.error(`Invalid configuration file \`${filePath}\`: ` + error.message);
process.exit(2);
}
}
|
Checks if the hunk exactly fits on the provided location
|
getOptionsOrDie
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function getOptionsForFile(context, filepath) {
const options = getOptionsOrDie(context, filepath);
const hasPlugins = options && options.plugins;
if (hasPlugins) {
pushContextPlugins(context, options.plugins);
}
const appliedOptions = Object.assign({
filepath
}, applyConfigPrecedence(context, options && optionsNormalizer.normalizeApiOptions(options, context.supportOptions, {
logger: context.logger
})));
context.logger.debug(`applied config-precedence (${context.argv["config-precedence"]}): ` + `${JSON.stringify(appliedOptions)}`);
if (hasPlugins) {
popContextPlugins(context);
}
return appliedOptions;
}
|
Checks if the hunk exactly fits on the provided location
|
getOptionsForFile
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function parseArgsToOptions(context, overrideDefaults) {
const minimistOptions = createMinimistOptions(context.detailedOptions);
const apiDetailedOptionMap = createApiDetailedOptionMap(context.detailedOptions);
return getOptions(optionsNormalizer.normalizeCliOptions(minimist_1(context.args, {
string: minimistOptions.string,
boolean: minimistOptions.boolean,
default: cliifyOptions(overrideDefaults, apiDetailedOptionMap)
}), context.detailedOptions, {
logger: false
}), context.detailedOptions);
}
|
Checks if the hunk exactly fits on the provided location
|
parseArgsToOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function applyConfigPrecedence(context, options) {
try {
switch (context.argv["config-precedence"]) {
case "cli-override":
return parseArgsToOptions(context, options);
case "file-override":
return Object.assign(Object.assign({}, parseArgsToOptions(context)), options);
case "prefer-file":
return options || parseArgsToOptions(context);
}
} catch (error) {
context.logger.error(error.toString());
process.exit(2);
}
}
|
Checks if the hunk exactly fits on the provided location
|
applyConfigPrecedence
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function formatStdin(context) {
const filepath = context.argv["stdin-filepath"] ? path.resolve(process.cwd(), context.argv["stdin-filepath"]) : process.cwd();
const ignorer = createIgnorerFromContextOrDie(context); // If there's an ignore-path set, the filename must be relative to the
// ignore path, not the current working directory.
const relativeFilepath = context.argv["ignore-path"] ? path.relative(path.dirname(context.argv["ignore-path"]), filepath) : path.relative(process.cwd(), filepath);
getStream(process.stdin).then(input => {
if (relativeFilepath && ignorer.ignores(fixWindowsSlashes$1(relativeFilepath))) {
writeOutput(context, {
formatted: input
});
return;
}
const options = getOptionsForFile(context, filepath);
if (listDifferent(context, input, options, "(stdin)")) {
return;
}
writeOutput(context, format(context, input, options), options);
}).catch(error => {
handleError(context, relativeFilepath || "stdin", error);
});
}
|
Checks if the hunk exactly fits on the provided location
|
formatStdin
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createIgnorerFromContextOrDie(context) {
try {
return createIgnorer.sync(context.argv["ignore-path"], context.argv["with-node-modules"]);
} catch (e) {
context.logger.error(e.message);
process.exit(2);
}
}
|
Checks if the hunk exactly fits on the provided location
|
createIgnorerFromContextOrDie
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function formatFiles(context) {
// The ignorer will be used to filter file paths after the glob is checked,
// before any files are actually written
const ignorer = createIgnorerFromContextOrDie(context);
let numberOfUnformattedFilesFound = 0;
if (context.argv.check) {
context.logger.log("Checking formatting...");
}
for (const pathOrError of expandPatterns$1(context)) {
if (typeof pathOrError === "object") {
context.logger.error(pathOrError.error); // Don't exit, but set the exit code to 2
process.exitCode = 2;
continue;
}
const filename = pathOrError; // If there's an ignore-path set, the filename must be relative to the
// ignore path, not the current working directory.
const ignoreFilename = context.argv["ignore-path"] ? path.relative(path.dirname(context.argv["ignore-path"]), filename) : filename;
const fileIgnored = ignorer.ignores(fixWindowsSlashes$1(ignoreFilename));
if (fileIgnored && (context.argv["debug-check"] || context.argv.write || context.argv.check || context.argv["list-different"])) {
continue;
}
const options = Object.assign(Object.assign({}, getOptionsForFile(context, filename)), {}, {
filepath: filename
});
if (isTty()) {
context.logger.log(filename, {
newline: false
});
}
let input;
try {
input = fs$2.readFileSync(filename, "utf8");
} catch (error) {
// Add newline to split errors from filename line.
context.logger.log("");
context.logger.error(`Unable to read file: ${filename}\n${error.message}`); // Don't exit the process if one file failed
process.exitCode = 2;
continue;
}
if (fileIgnored) {
writeOutput(context, {
formatted: input
}, options);
continue;
}
const start = Date.now();
let result;
let output;
try {
result = format(context, input, options);
output = result.formatted;
} catch (error) {
handleError(context, filename, error);
continue;
}
const isDifferent = output !== input;
if (isTty()) {
// Remove previously printed filename to log it with duration.
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0, null);
}
if (context.argv.write) {
// Don't write the file if it won't change in order not to invalidate
// mtime based caches.
if (isDifferent) {
if (!context.argv.check && !context.argv["list-different"]) {
context.logger.log(`${filename} ${Date.now() - start}ms`);
}
try {
fs$2.writeFileSync(filename, output, "utf8");
} catch (error) {
context.logger.error(`Unable to write file: ${filename}\n${error.message}`); // Don't exit the process if one file failed
process.exitCode = 2;
}
} else if (!context.argv.check && !context.argv["list-different"]) {
context.logger.log(`${source.grey(filename)} ${Date.now() - start}ms`);
}
} else if (context.argv["debug-check"]) {
if (result.filepath) {
context.logger.log(result.filepath);
} else {
process.exitCode = 2;
}
} else if (!context.argv.check && !context.argv["list-different"]) {
writeOutput(context, result, options);
}
if ((context.argv.check || context.argv["list-different"]) && isDifferent) {
context.logger.log(filename);
numberOfUnformattedFilesFound += 1;
}
} // Print check summary based on expected exit code
if (context.argv.check) {
context.logger.log(numberOfUnformattedFilesFound === 0 ? "All matched files use Prettier code style!" : context.argv.write ? "Code style issues fixed in the above file(s)." : "Code style issues found in the above file(s). Forgot to run Prettier?");
} // Ensure non-zero exitCode when using --check/list-different is not combined with --write
if ((context.argv.check || context.argv["list-different"]) && numberOfUnformattedFilesFound > 0 && !process.exitCode && !context.argv.write) {
process.exitCode = 1;
}
}
|
Checks if the hunk exactly fits on the provided location
|
formatFiles
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function getOptionsWithOpposites(options) {
// Add --no-foo after --foo.
const optionsWithOpposites = options.map(option => [option.description ? option : null, option.oppositeDescription ? Object.assign(Object.assign({}, option), {}, {
name: `no-${option.name}`,
type: "boolean",
description: option.oppositeDescription
}) : null]);
return flatten_1(optionsWithOpposites).filter(Boolean);
}
|
Checks if the hunk exactly fits on the provided location
|
getOptionsWithOpposites
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createUsage(context) {
const options = getOptionsWithOpposites(context.detailedOptions).filter( // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
option => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-")));
const groupedOptions = groupBy_1(options, option => option.category);
const firstCategories = constant$1.categoryOrder.slice(0, -1);
const lastCategories = constant$1.categoryOrder.slice(-1);
const restCategories = Object.keys(groupedOptions).filter(category => !constant$1.categoryOrder.includes(category));
const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
const optionsUsage = allCategories.map(category => {
const categoryOptions = groupedOptions[category].map(option => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
return `${category} options:\n\n${indent$1(categoryOptions, 2)}`;
});
return [constant$1.usageSummary].concat(optionsUsage, [""]).join("\n\n");
}
|
Checks if the hunk exactly fits on the provided location
|
createUsage
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createOptionUsage(context, option, threshold) {
const header = createOptionUsageHeader(option);
const optionDefaultValue = getOptionDefaultValue(context, option.name);
return createOptionUsageRow(header, `${option.description}${optionDefaultValue === undefined ? "" : `\nDefaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
}
|
Checks if the hunk exactly fits on the provided location
|
createOptionUsage
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createDefaultValueDisplay(value) {
return Array.isArray(value) ? `[${value.map(createDefaultValueDisplay).join(", ")}]` : value;
}
|
Checks if the hunk exactly fits on the provided location
|
createDefaultValueDisplay
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createOptionUsageHeader(option) {
const name = `--${option.name}`;
const alias = option.alias ? `-${option.alias},` : null;
const type = createOptionUsageType(option);
return [alias, name, type].filter(Boolean).join(" ");
}
|
Checks if the hunk exactly fits on the provided location
|
createOptionUsageHeader
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createOptionUsageRow(header, content, threshold) {
const separator = header.length >= threshold ? `\n${" ".repeat(threshold)}` : " ".repeat(threshold - header.length);
const description = content.replace(/\n/g, `\n${" ".repeat(threshold)}`);
return `${header}${separator}${description}`;
}
|
Checks if the hunk exactly fits on the provided location
|
createOptionUsageRow
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createOptionUsageType(option) {
switch (option.type) {
case "boolean":
return null;
case "choice":
return `<${option.choices.filter(choice => !choice.deprecated && choice.since !== null).map(choice => choice.value).join("|")}>`;
default:
return `<${option.type}>`;
}
}
|
Checks if the hunk exactly fits on the provided location
|
createOptionUsageType
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createChoiceUsages(choices, margin, indentation) {
const activeChoices = choices.filter(choice => !choice.deprecated && choice.since !== null);
const threshold = activeChoices.map(choice => choice.value.length).reduce((current, length) => Math.max(current, length), 0) + margin;
return activeChoices.map(choice => indent$1(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
}
|
Checks if the hunk exactly fits on the provided location
|
createChoiceUsages
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createDetailedUsage(context, flag) {
const option = getOptionsWithOpposites(context.detailedOptions).find(option => option.name === flag || option.alias === flag);
const header = createOptionUsageHeader(option);
const description = `\n\n${indent$1(option.description, 2)}`;
const choices = option.type !== "choice" ? "" : `\n\nValid options:\n\n${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
const optionDefaultValue = getOptionDefaultValue(context, option.name);
const defaults = optionDefaultValue !== undefined ? `\n\nDefault: ${createDefaultValueDisplay(optionDefaultValue)}` : "";
const pluginDefaults = option.pluginDefaults && Object.keys(option.pluginDefaults).length ? `\nPlugin defaults:${Object.keys(option.pluginDefaults).map(key => `\n* ${key}: ${createDefaultValueDisplay(option.pluginDefaults[key])}`)}` : "";
return `${header}${description}${choices}${defaults}${pluginDefaults}`;
}
|
Checks if the hunk exactly fits on the provided location
|
createDetailedUsage
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function getOptionDefaultValue(context, optionName) {
// --no-option
if (!(optionName in context.detailedOptionMap)) {
return undefined;
}
const option = context.detailedOptionMap[optionName];
if (option.default !== undefined) {
return option.default;
}
const optionCamelName = camelcase(optionName);
if (optionCamelName in context.apiDefaultOptions) {
return context.apiDefaultOptions[optionCamelName];
}
return undefined;
}
|
Checks if the hunk exactly fits on the provided location
|
getOptionDefaultValue
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function indent$1(str, spaces) {
return str.replace(/^/gm, " ".repeat(spaces));
}
|
Checks if the hunk exactly fits on the provided location
|
indent$1
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createLogger(logLevel) {
return {
warn: createLogFunc("warn", "yellow"),
error: createLogFunc("error", "red"),
debug: createLogFunc("debug", "blue"),
log: createLogFunc("log")
};
function createLogFunc(loggerName, color) {
if (!shouldLog(loggerName)) {
return () => {};
}
const prefix = color ? `[${source[color](loggerName)}] ` : "";
return function (message, opts) {
opts = Object.assign({
newline: true
}, opts);
const stream = process[loggerName === "log" ? "stdout" : "stderr"];
stream.write(message.replace(/^/gm, prefix) + (opts.newline ? "\n" : ""));
};
}
function shouldLog(loggerName) {
switch (logLevel) {
case "silent":
return false;
default:
return true;
case "debug":
if (loggerName === "debug") {
return true;
}
// fall through
case "log":
if (loggerName === "log") {
return true;
}
// fall through
case "warn":
if (loggerName === "warn") {
return true;
}
// fall through
case "error":
return loggerName === "error";
}
}
}
|
Checks if the hunk exactly fits on the provided location
|
createLogger
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createLogFunc(loggerName, color) {
if (!shouldLog(loggerName)) {
return () => {};
}
const prefix = color ? `[${source[color](loggerName)}] ` : "";
return function (message, opts) {
opts = Object.assign({
newline: true
}, opts);
const stream = process[loggerName === "log" ? "stdout" : "stderr"];
stream.write(message.replace(/^/gm, prefix) + (opts.newline ? "\n" : ""));
};
}
|
Checks if the hunk exactly fits on the provided location
|
createLogFunc
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function shouldLog(loggerName) {
switch (logLevel) {
case "silent":
return false;
default:
return true;
case "debug":
if (loggerName === "debug") {
return true;
}
// fall through
case "log":
if (loggerName === "log") {
return true;
}
// fall through
case "warn":
if (loggerName === "warn") {
return true;
}
// fall through
case "error":
return loggerName === "error";
}
}
|
Checks if the hunk exactly fits on the provided location
|
shouldLog
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function normalizeDetailedOption(name, option) {
return Object.assign(Object.assign({
category: coreOptions$1.CATEGORY_OTHER
}, option), {}, {
choices: option.choices && option.choices.map(choice => {
const newChoice = Object.assign({
description: "",
deprecated: false
}, typeof choice === "object" ? choice : {
value: choice
});
if (newChoice.value === true) {
newChoice.value = ""; // backward compatibility for original boolean option
}
return newChoice;
})
});
}
|
Checks if the hunk exactly fits on the provided location
|
normalizeDetailedOption
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function normalizeDetailedOptionMap(detailedOptionMap) {
return fromPairs_1(Object.entries(detailedOptionMap).sort(([leftName], [rightName]) => leftName.localeCompare(rightName)).map(([name, option]) => [name, normalizeDetailedOption(name, option)]));
}
|
Checks if the hunk exactly fits on the provided location
|
normalizeDetailedOptionMap
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createMinimistOptions(detailedOptions) {
return {
// we use vnopts' AliasSchema to handle aliases for better error messages
alias: {},
boolean: detailedOptions.filter(option => option.type === "boolean").map(option => [option.name].concat(option.alias || [])).reduce((a, b) => a.concat(b)),
string: detailedOptions.filter(option => option.type !== "boolean").map(option => [option.name].concat(option.alias || [])).reduce((a, b) => a.concat(b)),
default: detailedOptions.filter(option => !option.deprecated && (!option.forwardToApi || option.name === "plugin" || option.name === "plugin-search-dir") && option.default !== undefined).reduce((current, option) => Object.assign({
[option.name]: option.default
}, current), {})
};
}
|
Checks if the hunk exactly fits on the provided location
|
createMinimistOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createApiDetailedOptionMap(detailedOptions) {
return fromPairs_1(detailedOptions.filter(option => option.forwardToApi && option.forwardToApi !== option.name).map(option => [option.forwardToApi, option]));
}
|
Checks if the hunk exactly fits on the provided location
|
createApiDetailedOptionMap
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function createDetailedOptionMap(supportOptions) {
return fromPairs_1(supportOptions.map(option => {
const newOption = Object.assign(Object.assign({}, option), {}, {
name: option.cliName || dashify(option.name),
description: option.cliDescription || option.description,
category: option.cliCategory || coreOptions$1.CATEGORY_FORMAT,
forwardToApi: option.name
});
if (option.deprecated) {
delete newOption.forwardToApi;
delete newOption.description;
delete newOption.oppositeDescription;
newOption.deprecated = true;
}
return [newOption.name, newOption];
}));
}
|
Checks if the hunk exactly fits on the provided location
|
createDetailedOptionMap
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function updateContextOptions(context, plugins, pluginSearchDirs) {
const {
options: supportOptions,
languages
} = src.getSupportInfo({
showDeprecated: true,
showUnreleased: true,
showInternal: true,
plugins,
pluginSearchDirs
});
const detailedOptionMap = normalizeDetailedOptionMap(Object.assign(Object.assign({}, createDetailedOptionMap(supportOptions)), constant$1.options));
const detailedOptions = arrayify(detailedOptionMap, "name");
const apiDefaultOptions = Object.assign(Object.assign({}, optionsModule.hiddenDefaults), fromPairs_1(supportOptions.filter(({
deprecated
}) => !deprecated).map(option => [option.name, option.default])));
Object.assign(context, {
supportOptions,
detailedOptions,
detailedOptionMap,
apiDefaultOptions,
languages
});
}
|
@param {Context} context
@param {string[]} plugins
@param {string[]=} pluginSearchDirs
|
updateContextOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function pushContextPlugins(context, plugins, pluginSearchDirs) {
context.stack.push(pick_1(context, ["supportOptions", "detailedOptions", "detailedOptionMap", "apiDefaultOptions", "languages"]));
updateContextOptions(context, plugins, pluginSearchDirs);
}
|
@param {Context} context
@param {string[]} plugins
@param {string[]=} pluginSearchDirs
|
pushContextPlugins
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/bin-prettier.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js
|
Apache-2.0
|
function align(n, contents) {
return {
type: "align",
contents,
n
};
}
|
@param {number} n
@param {Doc} contents
@returns Doc
|
align
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function group(contents, opts) {
opts = opts || {};
return {
type: "group",
id: opts.id,
contents,
break: !!opts.shouldBreak,
expandedStates: opts.expandedStates
};
}
|
@param {Doc} contents
@param {object} [opts] - TBD ???
@returns Doc
|
group
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function conditionalGroup(states, opts) {
return group(states[0], Object.assign(Object.assign({}, opts), {}, {
expandedStates: states
}));
}
|
@param {Doc[]} states
@param {object} [opts] - TBD ???
@returns Doc
|
conditionalGroup
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function ifBreak(breakContents, flatContents, opts) {
opts = opts || {};
return {
type: "if-break",
breakContents,
flatContents,
groupId: opts.groupId
};
}
|
@param {Doc} [breakContents]
@param {Doc} [flatContents]
@param {object} [opts] - TBD ???
@returns Doc
|
ifBreak
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function join(sep, arr) {
const res = [];
for (let i = 0; i < arr.length; i++) {
if (i !== 0) {
res.push(sep);
}
res.push(arr[i]);
}
return concat(res);
}
|
@param {Doc} sep
@param {Doc[]} arr
@returns Doc
|
join
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function addAlignmentToDoc(doc, size, tabWidth) {
let aligned = doc;
if (size > 0) {
// Use indent to add tabs for all the levels of tabs we need
for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
aligned = indent(aligned);
} // Use align for all the spaces that are needed
aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
// indentation, so we use -Infinity to reset the indentation to 0
aligned = align(-Infinity, aligned);
}
return aligned;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
addAlignmentToDoc
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
ansiRegex = ({
onlyFirst = false
} = {}) => {
const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
return new RegExp(pattern, onlyFirst ? undefined : 'g');
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
ansiRegex
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
isFullwidthCodePoint = codePoint => {
if (Number.isNaN(codePoint)) {
return false;
} // Code points are derived from:
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
return true;
}
return false;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
isFullwidthCodePoint
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
isFullwidthCodePoint = codePoint => {
if (Number.isNaN(codePoint)) {
return false;
} // Code points are derived from:
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
return true;
}
return false;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
isFullwidthCodePoint
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
emojiRegex = function emojiRegex() {
// https://mths.be/emoji
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
emojiRegex
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
stringWidth = string => {
string = string.replace(emojiRegex(), ' ');
if (typeof string !== 'string' || string.length === 0) {
return 0;
}
string = stripAnsi(string);
let width = 0;
for (let i = 0; i < string.length; i++) {
const code = string.codePointAt(i); // Ignore control characters
if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
continue;
} // Ignore combining characters
if (code >= 0x300 && code <= 0x36F) {
continue;
} // Surrogates
if (code > 0xFFFF) {
i++;
}
width += isFullwidthCodePoint_1(code) ? 2 : 1;
}
return width;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
stringWidth
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
stringWidth = string => {
string = string.replace(emojiRegex(), ' ');
if (typeof string !== 'string' || string.length === 0) {
return 0;
}
string = stripAnsi(string);
let width = 0;
for (let i = 0; i < string.length; i++) {
const code = string.codePointAt(i); // Ignore control characters
if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
continue;
} // Ignore combining characters
if (code >= 0x300 && code <= 0x36F) {
continue;
} // Surrogates
if (code > 0xFFFF) {
i++;
}
width += isFullwidthCodePoint_1(code) ? 2 : 1;
}
return width;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
stringWidth
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
_objectWithoutPropertiesLoose
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function _taggedTemplateLiteral(strings, raw) {
if (!raw) {
raw = strings.slice(0);
}
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
_taggedTemplateLiteral
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
defaultSetTimout
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function defaultClearTimeout() {
throw new Error('clearTimeout has not been defined');
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
defaultClearTimeout
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
} // if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
runTimeout
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
} // if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
runClearTimeout
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
cleanUpNextTick
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
drainQueue
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function nextTick(fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
} // v8 likes predictible objects
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
nextTick
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
Item
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function binding(name) {
throw new Error('process.binding is not supported');
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
binding
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function cwd() {
return '/';
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
cwd
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function chdir(dir) {
throw new Error('process.chdir is not supported');
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
chdir
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function umask() {
return 0;
} // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
umask
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function hrtime(previousTimestamp) {
var clocktime = performanceNow.call(performance) * 1e-3;
var seconds = Math.floor(clocktime);
var nanoseconds = Math.floor(clocktime % 1 * 1e9);
if (previousTimestamp) {
seconds = seconds - previousTimestamp[0];
nanoseconds = nanoseconds - previousTimestamp[1];
if (nanoseconds < 0) {
seconds--;
nanoseconds += 1e9;
}
}
return [seconds, nanoseconds];
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
hrtime
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function uptime() {
var currentTime = new Date();
var dif = currentTime - startTime;
return dif / 1000;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
uptime
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
createCommonjsModule
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
function getCjsExportFromNamespace (n) {
return n && n['default'] || n;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
getCjsExportFromNamespace
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
createToken = (name, value, isGlobal) => {
const index = R++;
debug_1(index, value);
t[name] = index;
src[index] = value;
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
createToken
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
createToken = (name, value, isGlobal) => {
const index = R++;
debug_1(index, value);
t[name] = index;
src[index] = value;
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
createToken
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
compareIdentifiers = (a, b) => {
const anum = numeric.test(a);
const bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
|
@param {Doc} doc
@param {number} size
@param {number} tabWidth
|
compareIdentifiers
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/doc.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.