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 isTextLikeNode(node) {
return node.type === "text" || node.type === "comment";
} | there's no opening/closing tag or it's considered not breakable | isTextLikeNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isScriptLikeTag(node) {
return node.type === "element" && (node.fullName === "script" || node.fullName === "style" || node.fullName === "svg:style" || isUnknownNamespace(node) && (node.name === "script" || node.name === "style"));
} | there's no opening/closing tag or it's considered not breakable | isScriptLikeTag | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isFrontMatterNode(node) {
return node.type === "yaml" || node.type === "toml";
} | there's no opening/closing tag or it's considered not breakable | isFrontMatterNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function canHaveInterpolation(node) {
return node.children && !isScriptLikeTag(node);
} | there's no opening/closing tag or it's considered not breakable | canHaveInterpolation | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isWhitespaceSensitiveNode(node) {
return isScriptLikeTag(node) || node.type === "interpolation" || isIndentationSensitiveNode(node);
} | there's no opening/closing tag or it's considered not breakable | isWhitespaceSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isIndentationSensitiveNode(node) {
return getNodeCssStyleWhiteSpace(node).startsWith("pre");
} | there's no opening/closing tag or it's considered not breakable | isIndentationSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isLeadingSpaceSensitiveNode(node, options) {
const isLeadingSpaceSensitive = _isLeadingSpaceSensitiveNode();
if (isLeadingSpaceSensitive && !node.prev && node.parent && node.parent.tagDefinition && node.parent.tagDefinition.ignoreFirstLf) {
return node.type === "interpolation";
}
return... | there's no opening/closing tag or it's considered not breakable | isLeadingSpaceSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function _isLeadingSpaceSensitiveNode() {
if (isFrontMatterNode(node)) {
return false;
}
if ((node.type === "text" || node.type === "interpolation") && node.prev && (node.prev.type === "text" || node.prev.type === "interpolation")) {
return true;
}
if (!node.parent || nod... | there's no opening/closing tag or it's considered not breakable | _isLeadingSpaceSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isTrailingSpaceSensitiveNode(node, options) {
if (isFrontMatterNode(node)) {
return false;
}
if ((node.type === "text" || node.type === "interpolation") && node.next && (node.next.type === "text" || node.next.type === "interpolation")) {
return true;
}
if (!node.parent || node... | there's no opening/closing tag or it's considered not breakable | isTrailingSpaceSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isDanglingSpaceSensitiveNode(node) {
return isDanglingSpaceSensitiveCssDisplay(node.cssDisplay) && !isScriptLikeTag(node);
} | there's no opening/closing tag or it's considered not breakable | isDanglingSpaceSensitiveNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function forceNextEmptyLine(node) {
return isFrontMatterNode(node) || node.next && node.sourceSpan.end.line + 1 < node.next.sourceSpan.start.line;
} | there's no opening/closing tag or it's considered not breakable | forceNextEmptyLine | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function extractWhitespaces(ast
/*, options*/
) {
const TYPE_WHITESPACE = "whitespace";
return ast.map(node => {
if (!node.children) {
return node;
}
if (node.children.length === 0 || node.children.length === 1 && node.children[0].type === "text" && htmlTrim$1(node.children[0].val... | - add `hasLeadingSpaces` field
- add `hasTrailingSpaces` field
- add `hasDanglingSpaces` field for parent nodes
- add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
- remove insensitive whitespaces | extractWhitespaces | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function addIsSelfClosing(ast
/*, options */
) {
return ast.map(node => Object.assign(node, {
isSelfClosing: !node.children || node.type === "element" && (node.tagDefinition.isVoid || // self-closing
node.startSourceSpan === node.endSourceSpan)
}));
} | - add `hasLeadingSpaces` field
- add `hasTrailingSpaces` field
- add `hasDanglingSpaces` field for parent nodes
- add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
- remove insensitive whitespaces | addIsSelfClosing | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function addHasHtmComponentClosingTag(ast, options) {
return ast.map(node => node.type !== "element" ? node : Object.assign(node, {
hasHtmComponentClosingTag: node.endSourceSpan && /^<\s*\/\s*\/\s*>$/.test(options.originalText.slice(node.endSourceSpan.start.offset, node.endSourceSpan.end.offset))
}));
} | - add `hasLeadingSpaces` field
- add `hasTrailingSpaces` field
- add `hasDanglingSpaces` field for parent nodes
- add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
- remove insensitive whitespaces | addHasHtmComponentClosingTag | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function addCssDisplay(ast, options) {
return ast.map(node => Object.assign(node, {
cssDisplay: getNodeCssStyleDisplay$1(node, options)
}));
} | - add `hasLeadingSpaces` field
- add `hasTrailingSpaces` field
- add `hasDanglingSpaces` field for parent nodes
- add `isWhitespaceSensitive`, `isIndentationSensitive` field for text nodes
- remove insensitive whitespaces | addCssDisplay | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function addIsSpaceSensitive(ast, options) {
return ast.map(node => {
if (!node.children) {
return node;
}
if (node.children.length === 0) {
return node.clone({
isDanglingSpaceSensitive: isDanglingSpaceSensitiveNode$1(node)
});
}
return node.clone({
... | - add `isLeadingSpaceSensitive` field
- add `isTrailingSpaceSensitive` field
- add `isDanglingSpaceSensitive` field for parent nodes | addIsSpaceSensitive | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function hasPragma$3(text) {
return /^\s*<!--\s*@(format|prettier)\s*-->/.test(text);
} | - add `isLeadingSpaceSensitive` field
- add `isTrailingSpaceSensitive` field
- add `isDanglingSpaceSensitive` field for parent nodes | hasPragma$3 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function insertPragma$5(text) {
return "<!-- @format -->\n\n" + text.replace(/^\s*\n/, "");
} | - add `isLeadingSpaceSensitive` field
- add `isTrailingSpaceSensitive` field
- add `isDanglingSpaceSensitive` field for parent nodes | insertPragma$5 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printVueFor(value, textToDoc) {
const {
left,
operator,
right
} = parseVueFor(value);
return concat$8([group$8(textToDoc("function _(".concat(left, ") {}"), {
parser: "babel",
__isVueForBindingLeft: true
})), " ", operator, " ", textToDoc(right, {
parser: "__... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | printVueFor | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function parseVueFor(value) {
const forAliasRE = /([^]*?)\s+(in|of)\s+([^]*)/;
const forIteratorRE = /,([^,\]}]*)(?:,([^,\]}]*))?$/;
const stripParensRE = /^\(|\)$/g;
const inMatch = value.match(forAliasRE);
if (!inMatch) {
return;
}
const res = {};
res.for = inMatch[3].trim();
... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | parseVueFor | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printVueSlotScope(value, textToDoc) {
return textToDoc("function _(".concat(value, ") {}"), {
parser: "babel",
__isVueSlotScope: true
});
} | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | printVueSlotScope | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isVueEventBindingExpression(eventBindingValue) {
// https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
// arrow function or anonymous function
const fnExpRE = /^([\w$]+|\([^)]*?\))\s*=>|^function\s*\(/; // simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | isVueEventBindingExpression | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function deepUnique(array) {
return array.sort().filter((element, index) => {
return JSON.stringify(element) !== JSON.stringify(array[index - 1]);
});
} | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | deepUnique | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
parse$2 = string => {
return deepUnique(string.split(',').map(part => {
const result = {};
part.trim().split(/\s+/).forEach((element, index) => {
if (index === 0) {
result.url = element;
return;
}
const value = element.slice(0, element.length - 1);
co... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | parse$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
stringify = array => {
return [...new Set(array.map(element => {
if (!element.url) {
throw new Error('URL is required');
}
const result = [element.url];
if (element.width) {
result.push("".concat(element.width, "w"));
}
if (element.height) {
result.push... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | stringify | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printImgSrcset(value) {
const srcset = parseSrcset(value);
const hasW = srcset.some(src => src.width);
const hasH = srcset.some(src => src.height);
const hasX = srcset.some(src => src.density);
if (hasW + hasH + hasX > 1) {
throw new Error("Mixed descriptor in srcset is not supported... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | printImgSrcset | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printClassNames(value) {
return value.trim().split(/\s+/).join(" ");
} | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | printClassNames | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function concat$a(parts) {
const newParts = normalizeParts$1(parts);
return newParts.length === 0 ? "" : newParts.length === 1 ? newParts[0] : builders.concat(newParts);
} | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | concat$a | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function embed$2(path, print, textToDoc, options) {
const node = path.getValue();
switch (node.type) {
case "text":
{
if (isScriptLikeTag$1(node.parent)) {
const parser = inferScriptParser$1(node.parent);
if (parser) {
const value = parser === "mar... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | embed$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function genericPrint$2(path, options, print) {
const node = path.getValue();
switch (node.type) {
case "root":
if (options.__onHtmlRoot) {
options.__onHtmlRoot(node);
} // use original concat to not break stripTrailingHardline
return builders.concat([group$9(printChil... | v-for="... in ..."
v-for="... of ..."
v-for="(..., ...) in ..."
v-for="(..., ...) of ..." | genericPrint$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printOpeningTag(path, options, print) {
const node = path.getValue();
const forceNotToBreakAttrContent = node.type === "element" && node.fullName === "script" && node.attrs.length === 1 && node.attrs[0].fullName === "src" && node.children.length === 0;
return concat$a([printOpeningTagStart(node, op... | Want to write us a letter? Use our<a
><b><a>mailing address</a></b></a
~
>. | printOpeningTag | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isStyledJsx(path) {
const node = path.getValue();
const parent = path.getParentNode();
const parentParent = path.getParentNode(1);
return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "s... | Template literal in these contexts:
<style jsx>{`div{color:red}`}</style>
css``
css.global``
css.resolve`` | isStyledJsx | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isAngularComponentStyles(path) {
return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "styles" &&... | Angular Components can have:
- Inline HTML template
- Inline CSS styles
...which are both within template literals somewhere
inside of the Component decorator factory.
E.g.
@Component({
template: `<div>...</div>`,
styles: [`h1 { color: blue; }`]
}) | isAngularComponentStyles | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isAngularComponentTemplate(path) {
return path.match(node => node.type === "TemplateLiteral", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
... | Angular Components can have:
- Inline HTML template
- Inline CSS styles
...which are both within template literals somewhere
inside of the Component decorator factory.
E.g.
@Component({
template: `<div>...</div>`,
styles: [`h1 { color: blue; }`]
}) | isAngularComponentTemplate | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function hasNgSideEffect(path) {
return hasNode(path.getValue(), node => {
switch (node.type) {
case undefined:
return false;
case "CallExpression":
case "OptionalCallExpression":
case "AssignmentExpression":
return true;
}
});
} | identify if an angular expression seems to have side effects | hasNgSideEffect | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isNgForOf(node, index, parentNode) {
return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
} | identify if an angular expression seems to have side effects | isNgForOf | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function templateLiteralHasNewLines(template) {
return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
} | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | templateLiteralHasNewLines | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isTemplateOnItsOwnLine(n, text, options) {
return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$4(text, options.locStart(n), {
backwards: true
});
} | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | isTemplateOnItsOwnLine | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function needsHardlineAfterDanglingComment(node) {
if (!node.comments) {
return false;
}
const lastDanglingComment = getLast$2(node.comments.filter(comment => !comment.leading && !comment.trailing));
return lastDanglingComment && !comments$1.isBlockComment(lastDanglingComment);
} // If we have ... | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | needsHardlineAfterDanglingComment | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function getConditionalChainContents(node) {
// Given this code:
//
// // Using a ConditionalExpression as the consequent is uncommon, but should
// // be handled.
// A ? B : C ? D : E ? F ? G : H : I
//
// which has this AST:
//
// ConditionalExpression {
// test: Identifier(A... | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | getConditionalChainContents | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function recurse(node) {
if (node.type === "ConditionalExpression") {
recurse(node.test);
recurse(node.consequent);
recurse(node.alternate);
} else {
nonConditionalExpressions.push(node);
}
} | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | recurse | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function conditionalExpressionChainContainsJSX(node) {
return Boolean(getConditionalChainContents(node).find(isJSXNode));
} // Logic to check for args with multiple anonymous functions. For instance, | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | conditionalExpressionChainContainsJSX | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isLongCurriedCallExpression(path) {
const node = path.getValue();
const parent = path.getParentNode();
return isCallOrOptionalCallExpression(node) && isCallOrOptionalCallExpression(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
... | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | isLongCurriedCallExpression | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isSimpleCallArgument(node, depth) {
if (depth >= 3) {
return false;
}
const plusOne = node => isSimpleCallArgument(node, depth + 1);
const plusTwo = node => isSimpleCallArgument(node, depth + 2);
const regexpPattern = node.type === "Literal" && node.regex && node.regex.pattern || n... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | isSimpleCallArgument | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function rawText(node) {
return node.extra ? node.extra.raw : node.raw;
} | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | rawText | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function identity$1(x) {
return x;
} | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | identity$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isTSXFile(options) {
return options.filepath && /\.tsx$/i.test(options.filepath);
} | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | isTSXFile | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldPrintComma$1(options, level) {
level = level || "es5";
switch (options.trailingComma) {
case "all":
if (level === "all") {
return true;
}
// fallthrough
case "es5":
if (level === "es5") {
return true;
}
// fallthrough... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | shouldPrintComma$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function needsParens(path, options) {
const parent = path.getParentNode();
if (!parent) {
return false;
}
const name = path.getName();
const node = path.getNode(); // If the value of this path is some child of a Node and not a Node
// itself, then it doesn't need parentheses. Only Node o... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | needsParens | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
} | Appends the elements of `values` to `array`.
@private
@param {Array} array The array to modify.
@param {Array} values The values to append.
@returns {Array} Returns `array`. | arrayPush | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
... | A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
@private
@param {*} value The value to query.
@returns {string} Returns the raw `toStringTag`. | getRawTag | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function objectToString(value) {
return nativeObjectToString$1.call(value);
} | Converts `value` to a string using `Object.prototype.toString`.
@private
@param {*} value The value to convert.
@returns {string} Returns the converted string. | objectToString | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return symToStringTag$1 && symToStringTag$1 in Object(value) ? _getRawTag(value) : _objectToString(value);
} | The base implementation of `getTag` without fallbacks for buggy environments.
@private
@param {*} value The value to query.
@returns {string} Returns the `toStringTag`. | baseGetTag | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isObjectLike(value) {
return value != null && typeof value == 'object';
} | Checks if `value` is object-like. A value is object-like if it's not `null`
and has a `typeof` result of "object".
@static
@memberOf _
@since 4.0.0
@category Lang
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is object-like, else `false`.
@example
_.isObjectLike({});
// => true
_.... | isObjectLike | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function baseIsArguments(value) {
return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
} | The base implementation of `_.isArguments`.
@private
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is an `arguments` object, | baseIsArguments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isFlattenable(value) {
return isArray_1(value) || isArguments_1(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
} | Checks if `value` is a flattenable `arguments` object or array.
@private
@param {*} value The value to check.
@returns {boolean} Returns `true` if `value` is flattenable, else `false`. | isFlattenable | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = _isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth >... | The base implementation of `_.flatten` with support for restricting flattening.
@private
@param {Array} array The array to flatten.
@param {number} depth The maximum recursion depth.
@param {boolean} [predicate=isFlattenable] The function invoked per iteration.
@param {boolean} [isStrict] Restrict to values that pass ... | baseFlatten | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function flatten(array) {
var length = array == null ? 0 : array.length;
return length ? _baseFlatten(array, 1) : [];
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | flatten | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printCallArguments(path, options, print) {
const node = path.getValue();
const args = node.arguments;
if (args.length === 0) {
return concat$d(["(", comments.printDanglingComments(path, options,
/* sameIndent */
true), ")"]);
} // useEffect(() => { ... }, [foo, bar, baz])
... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printCallArguments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldBreakForArrowFunctionInArguments(arg, argPath) {
if (!arg || arg.type !== "ArrowFunctionExpression" || !arg.body || arg.body.type !== "BlockStatement" || !arg.params || arg.params.length < 1) {
return false;
}
let shouldBreak = false;
argPath.each(paramPath => {
c... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | shouldBreakForArrowFunctionInArguments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function allArgsBrokenOut() {
return group$b(concat$d(["(", indent$7(concat$d([line$9, concat$d(printedArguments)])), maybeTrailingComma, line$9, ")"]), {
shouldBreak: true
});
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | allArgsBrokenOut | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function couldGroupArg(arg) {
return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | couldGroupArg | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldGroupLastArg(args) {
const lastArg = getLast$3(args);
const penultimateArg = getPenultimate$1(args);
return !hasLeadingComment$3(lastArg) && !hasTrailingComment$1(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
// disable last element expansion.
... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | shouldGroupLastArg | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldGroupFirstArg(args) {
if (args.length !== 2) {
return false;
}
const [firstArg, secondArg] = args;
return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStat... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | shouldGroupFirstArg | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printOptionalToken(path) {
const node = path.getValue();
if (!node.optional || // It's an optional computed method parsed by typescript-estree.
// "?" is printed in `printMethod`.
node.type === "Identifier" && node === path.getParentNode().key) {
return "";
}
if (node.type === "... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printOptionalToken | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printFunctionTypeParameters(path, options, print) {
const fun = path.getValue();
if (fun.typeArguments) {
return path.call(print, "typeArguments");
}
if (fun.typeParameters) {
return path.call(print, "typeParameters");
}
return "";
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printFunctionTypeParameters | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printMemberLookup(path, options, print) {
const property = path.call(print, "property");
const n = path.getValue();
const optional = printOptionalToken(path);
if (!n.computed) {
return concat$e([optional, ".", property]);
}
if (!n.property || isNumericLiteral$1(n.property)) {
... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printMemberLookup | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printBindExpressionCallee(path, options, print) {
return concat$e(["::", path.call(print, "callee")]);
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printBindExpressionCallee | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printMemberChain(path, options, print) {
const parent = path.getParentNode();
const isExpressionStatement = !parent || parent.type === "ExpressionStatement"; // The first phase is to linearize the AST by traversing it down.
//
// a().b()
// has the following AST structure:
// CallEx... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printMemberChain | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldInsertEmptyLineAfter(node) {
const {
originalText
} = options;
const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$3(originalText, node, options.locEnd);
const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account fo... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | shouldInsertEmptyLineAfter | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function rec(path) {
const node = path.getValue();
if (isCallOrOptionalCallExpression$1(node) && (isMemberish$1(node.callee) || isCallOrOptionalCallExpression$1(node.callee))) {
printedNodes.unshift({
node,
printed: concat$f([comments.printComments(path, () => concat$f([printOpt... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | rec | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isFactory(name) {
return /^[A-Z]|^[$_]+$/.test(name);
} // In case the Identifier is shorter than tab width, we can keep the | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | isFactory | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isShort(name) {
return name.length <= options.tabWidth;
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | isShort | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function shouldNotWrap(groups) {
const hasComputed = groups[1].length && groups[1][0].node.computed;
if (groups[0].length === 1) {
const firstNode = groups[0][0].node;
return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | shouldNotWrap | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printGroup(printedGroup) {
const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
// accordingly
if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
return concat$f(["(", ...pr... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printGroup | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printIndentedGroup(groups) {
if (groups.length === 0) {
return "";
}
return indent$9(group$d(concat$f([hardline$a, join$9(hardline$a, groups.map(printGroup))])));
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | printIndentedGroup | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function looksLikeFluentConfigurationPattern() {
if (isExpressionStatement && callExpressions.length > 1 && // Keep simple chains like this on one line:
// req.checkBody("name").notEmpty().optional();
!(callExpressions[0].arguments.length <= 1 && callExpressions.slice(1).every(expr => expr.argument... | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | looksLikeFluentConfigurationPattern | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function callHasComplexArguments(expr, index) {
return index !== 0 && expr.arguments.length > 2 || !expr.arguments.every(arg => isSimpleCallArgument$1(arg, 0));
} | Flattens `array` a single level deep.
@static
@memberOf _
@since 0.1.0
@category Array
@param {Array} array The array to flatten.
@returns {Array} Returns the new flattened array.
@example
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5] | callHasComplexArguments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function lastGroupWillBreakAndOtherCallsHaveComplexArguments() {
const lastGroupNode = getLast$4(getLast$4(groups)).node;
const lastGroupDoc = getLast$4(printedGroups);
return isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$2(lastGroupDoc) && callExpressions.some((expr, index) => index !=... | If the last call's argument is a function, it's okay to inline if it fits and there is no other function arguments.
This chain should be split:
const mapped = scopes.filter(scope => scope.value !== '').map((scope, i) => {
// multi line content
});
This chain can be inlined:
const mapped = scopes.f... | lastGroupWillBreakAndOtherCallsHaveComplexArguments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function genericPrint$3(path, options, printPath, args) {
const node = path.getValue();
let needsParens = false;
const linesWithoutParens = printPathNoParens(path, options, printPath, args);
if (!node || isEmpty$1(linesWithoutParens)) {
return linesWithoutParens;
}
const parentExportDecl... | If the last call's argument is a function, it's okay to inline if it fits and there is no other function arguments.
This chain should be split:
const mapped = scopes.filter(scope => scope.value !== '').map((scope, i) => {
// multi line content
});
This chain can be inlined:
const mapped = scopes.f... | genericPrint$3 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printDecorators(path, options, print) {
const node = path.getValue();
return group$e(concat$g([join$a(line$a, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators$1(node, options) ? hardline$b : line$a]));
} | If the last call's argument is a function, it's okay to inline if it fits and there is no other function arguments.
This chain should be split:
const mapped = scopes.filter(scope => scope.value !== '').map((scope, i) => {
// multi line content
});
This chain can be inlined:
const mapped = scopes.f... | printDecorators | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function printTernaryOperator(path, options, print, operatorOptions) {
const node = path.getValue();
const consequentNode = node[operatorOptions.consequentNodePropertyName];
const alternateNode = node[operatorOptions.alternateNodePropertyName];
const parts = []; // We print a ConditionalExpression in ei... | The following is the shared logic for
ternary operators, namely ConditionalExpression
and TSConditionalType
@typedef {Object} OperatorOptions
@property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
@property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print aft... | printTernaryOperator | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function splitText(text, options) {
const KIND_NON_CJK = "non-cjk";
const KIND_CJ_LETTER = "cj-letter";
const KIND_K_LETTER = "k-letter";
const KIND_CJK_PUNCTUATION = "cjk-punctuation";
const nodes = [];
(options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | splitText | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function appendNode(node) {
const lastNode = getLast$6(nodes);
if (lastNode && lastNode.type === "word") {
if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunc... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | appendNode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function isBetween(kind1, kind2) {
return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | isBetween | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function getOrderedListItemInfo(orderListItem, originalText) {
const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
return {
numberText,
marker,
leadingSpaces
};
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | getOrderedListItemInfo | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function hasGitDiffFriendlyOrderedList(node, options) {
if (!node.ordered) {
return false;
}
if (node.children.length < 2) {
return false;
}
const firstNumber = Number(getOrderedListItemInfo(node.children[0], options.originalText).numberText);
const secondNumber = Number(getOrdered... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | hasGitDiffFriendlyOrderedList | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function getFencedCodeBlockValue(node, originalText) {
const text = originalText.slice(node.position.start.offset, node.position.end.offset);
const leadingSpaceCount = text.match(/^\s*/)[0].length;
const replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}"));
const lineContents = text.split... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | getFencedCodeBlockValue | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function getIndent(lineIndex) {
return node.position.indent[lineIndex - 1] - 1;
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | getIndent | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function mapAst(ast, handler) {
return function preorder(node, index, parentStack) {
parentStack = parentStack || [];
const newNode = Object.assign({}, handler(node, index, parentStack));
if (newNode.children) {
newNode.children = newNode.children.map((child, index) => {
return ... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | mapAst | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function embed$4(path, print, textToDoc, options) {
const node = path.getValue();
if (node.type === "code" && node.lang !== null) {
// only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
const langMatch = no... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | embed$4 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function replaceNewlinesWithLiterallines(doc) {
return mapDoc$4(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$i(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$5)) : currentDoc);
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | replaceNewlinesWithLiterallines | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function startWithPragma(text) {
const pragma = "@(".concat(pragmas.join("|"), ")");
const regex = new RegExp(["<!--\\s*".concat(pragma, "\\s*-->"), "<!--.*\r?\n[\\s\\S]*(^|\n)[^\\S\n]*".concat(pragma, "[^\\S\n]*($|\n)[\\s\\S]*\n.*-->")].join("|"), "m");
const matched = text.match(regex);
return matched... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | startWithPragma | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function preprocess$2(ast, options) {
ast = restoreUnescapedCharacter(ast, options);
ast = mergeContinuousTexts(ast);
ast = transformInlineCode(ast);
ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
ast = markAlignedList(ast, options);
ast = splitTextIntoSentences(ast, options... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | preprocess$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function transformImportExport(ast) {
return mapAst$1(ast, node => {
if (node.type !== "import" && node.type !== "export") {
return node;
}
return Object.assign(Object.assign({}, node), {}, {
type: "importExport"
});
});
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | transformImportExport | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function transformInlineCode(ast) {
return mapAst$1(ast, node => {
if (node.type !== "inlineCode") {
return node;
}
return Object.assign(Object.assign({}, node), {}, {
value: node.value.replace(/\s+/g, " ")
});
});
} | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | transformInlineCode | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function restoreUnescapedCharacter(ast, options) {
return mapAst$1(ast, node => {
return node.type !== "text" ? node : Object.assign(Object.assign({}, node), {}, {
value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
isSingleCharRegex.test(n... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | restoreUnescapedCharacter | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function mergeContinuousImportExport(ast) {
return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
type: "importExport",
value: prevNode.value + "\n\n" + node.value,
position: {
start: prevNode.position.start,
... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | mergeContinuousImportExport | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function mergeChildren(ast, shouldMerge, mergeNode) {
return mapAst$1(ast, node => {
if (!node.children) {
return node;
}
const children = node.children.reduce((current, child) => {
const lastChild = current[current.length - 1];
if (lastChild && shouldMerge(lastChild, chi... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | mergeChildren | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
function mergeContinuousTexts(ast) {
return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
type: "text",
value: prevNode.value + node.value,
position: {
start: prevNode.position.start,
end: node.position.end
}
... | split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>} | mergeContinuousTexts | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/standalone.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.