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 assertPatternsInput(input) {
const source = [].concat(input);
const isValidSource = source.every(item => utils$4.string.isString(item) && !utils$4.string.isEmpty(item));
if (!isValidSource) {
throw new TypeError('Patterns must be a string (non empty) or an array of strings');
}
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | assertPatternsInput | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
async function isType(fsStatType, statsMethodName, filePath) {
if (typeof filePath !== 'string') {
throw new TypeError(`Expected a string, got ${typeof filePath}`);
}
try {
const stats = await promisify(fs$3[fsStatType])(filePath);
return stats[statsMethodName]();
} catch (error) {
if (error.co... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | isType | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function isTypeSync(fsStatType, statsMethodName, filePath) {
if (typeof filePath !== 'string') {
throw new TypeError(`Expected a string, got ${typeof filePath}`);
}
try {
return fs$3[fsStatType](filePath)[statsMethodName]();
} catch (error) {
if (error.code === 'ENOENT') {
return false;
}... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | isTypeSync | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
getPath = (filepath, cwd) => {
const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
return path$2.isAbsolute(pth) ? pth : path$2.join(cwd, pth);
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | getPath | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
getPath = (filepath, cwd) => {
const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
return path$2.isAbsolute(pth) ? pth : path$2.join(cwd, pth);
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | getPath | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
addExtensions = (file, extensions) => {
if (path$2.extname(file)) {
return `**/${file}`;
}
return `**/${file}.${getExtensions(extensions)}`;
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | addExtensions | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
addExtensions = (file, extensions) => {
if (path$2.extname(file)) {
return `**/${file}`;
}
return `**/${file}.${getExtensions(extensions)}`;
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | addExtensions | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
getGlob = (directory, options) => {
if (options.files && !Array.isArray(options.files)) {
throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
}
if (options.extensions && !Array.isArray(options.extensions)) {
throw new TypeError(`Expected \`exte... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | getGlob | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
getGlob = (directory, options) => {
if (options.files && !Array.isArray(options.files)) {
throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
}
if (options.extensions && !Array.isArray(options.extensions)) {
throw new TypeError(`Expected \`exte... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | getGlob | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
dirGlob = async (input, options) => {
options = Object.assign({
cwd: process.cwd()
}, options);
if (typeof options.cwd !== 'string') {
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
}
const globs = await Promise.all([].concat(input).map(... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | dirGlob | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
sync$7 = (input, options) => {
options = Object.assign({
cwd: process.cwd()
}, options);
if (typeof options.cwd !== 'string') {
throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
}
const globs = [].concat(input).map(x => pathType.isDirectory... | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | sync$7 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function makeArray(subject) {
return Array.isArray(subject) ? subject : [subject];
} | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | makeArray | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
// fatal for JavaScript regular expression, so eliminate it.
: '') | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | sanitizeRange$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
sanitizeRange$1 = range => range.replace(REGEX_REGEXP_RANGE$1, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match // Invalid range (out of order) which is ok for gitignore rules but
// fatal for JavaScript regular expression, so eliminate it.
: '') | The stream returned by the provider cannot work with an asynchronous iterator.
To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
This affects performance (+25%). I don't see best solution right now. | sanitizeRange$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
makeRegex = (pattern, negative, ignorecase) => {
const r = regexCache[pattern];
if (r) {
return r;
} // const replacers = negative
// ? NEGATIVE_REPLACERS
// : POSITIVE_REPLACERS
const source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
ret... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | makeRegex | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
makeRegex = (pattern, negative, ignorecase) => {
const r = regexCache[pattern];
if (r) {
return r;
} // const replacers = negative
// ? NEGATIVE_REPLACERS
// : POSITIVE_REPLACERS
const source = REPLACERS.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
ret... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | makeRegex | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
checkPattern$1 = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
&& pattern.indexOf('#') !== 0 | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | checkPattern$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
checkPattern$1 = pattern => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) // > A line starting with # serves as a comment.
&& pattern.indexOf('#') !== 0 | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | checkPattern$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
constructor(origin, pattern, negative, regex) {
this.origin = origin;
this.pattern = pattern;
this.negative = negative;
this.regex = regex;
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | constructor | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
createRule$1 = (pattern, ignorecase) => {
const origin = pattern;
let negative = false; // > An optional prefix "!" which negates the pattern;
if (pattern.indexOf('!') === 0) {
negative = true;
pattern = pattern.substr(1);
}
pattern = pattern // > Put a backslash ("\") in front of the first "!" for ... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | createRule$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
createRule$1 = (pattern, ignorecase) => {
const origin = pattern;
let negative = false; // > An optional prefix "!" which negates the pattern;
if (pattern.indexOf('!') === 0) {
negative = true;
pattern = pattern.substr(1);
}
pattern = pattern // > Put a backslash ("\") in front of the first "!" for ... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | createRule$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
throwError = (message, Ctor) => {
throw new Ctor(message);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | throwError | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
throwError = (message, Ctor) => {
throw new Ctor(message);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | throwError | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
checkPath = (path, originalPath, doThrow) => {
if (!isString(path)) {
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
} // We don't know if we should ignore '', so throw
if (!path) {
return doThrow(`path must not be empty`, TypeError);
} // Check if it is a relative pa... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | checkPath | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
checkPath = (path, originalPath, doThrow) => {
if (!isString(path)) {
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
} // We don't know if we should ignore '', so throw
if (!path) {
return doThrow(`path must not be empty`, TypeError);
} // Check if it is a relative pa... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | checkPath | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
constructor({
ignorecase = true
} = {}) {
this._rules = [];
this._ignorecase = ignorecase;
define$1(this, KEY_IGNORE$1, true);
this._initCache();
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | constructor | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
_initCache() {
this._ignoreCache = Object.create(null);
this._testCache = Object.create(null);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | _initCache | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
_addPattern(pattern) {
// #32
if (pattern && pattern[KEY_IGNORE$1]) {
this._rules = this._rules.concat(pattern._rules);
this._added = true;
return;
}
if (checkPattern$1(pattern)) {
const rule = createRule$1(pattern, this._ignorecase);
this._added = true;
this._rules... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | _addPattern | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
add(pattern) {
this._added = false;
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this); // Some rules have just added to the ignore,
// making the behavior changed.
if (this._added) {
this._initCache();
}
return this;
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | add | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
addPattern(pattern) {
return this.add(pattern);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | addPattern | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
_testOne(path, checkUnignored) {
let ignored = false;
let unignored = false;
this._rules.forEach(rule => {
const {
negative
} = rule;
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
return;
}
con... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | _testOne | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
_test(originalPath, cache, checkUnignored, slices) {
const path = originalPath // Supports nullable path
&& checkPath.convert(originalPath);
checkPath(path, originalPath, throwError);
return this._t(path, cache, checkUnignored, slices);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | _test | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
_t(path, cache, checkUnignored, slices) {
if (path in cache) {
return cache[path];
}
if (!slices) {
// path/to/a.js
// ['path', 'to', 'a.js']
slices = path.split(SLASH$1);
}
slices.pop(); // If the path has no parent directory, just test it
if (!slices.length) {
... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | _t | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
ignores(path) {
return this._test(path, this._ignoreCache, false).ignored;
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | ignores | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
createFilter() {
return path => !this.ignores(path);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | createFilter | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
filter(paths) {
return makeArray(paths).filter(this.createFilter());
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | filter | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
test(path) {
return this._test(path, this._testCache, true);
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | test | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
slash$1 = path => {
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
if (isExtendedLengthPath || hasNonAscii) {
return path;
}
return path.replace(/\\/g, '/');
} | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | slash$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 === "style" &&... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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" && n... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function isTemplateOnItsOwnLine(n, text, options) {
return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function needsHardlineAfterDanglingComment(node) {
if (!node.comments) {
return false;
}
const lastDanglingComment = getLast$1(node.comments.filter(comment => !comment.leading && !comment.trailing));
return lastDanglingComment && !comments$1.isBlockComment(lastDanglingComment);
} // If we have nested condi... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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),
// consequent... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 || node.type ===... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | isSimpleCallArgument | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function shouldPrintComma(options, level) {
level = level || "es5";
switch (options.trailingComma) {
case "all":
if (level === "all") {
return true;
}
// fallthrough
case "es5":
if (level === "es5") {
return true;
}
// fallthrough
case "none":
def... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | shouldPrintComma | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 objects (in
/... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | needsParens | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 > 1) {
//... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printCallArguments(path, options, print) {
const node = path.getValue();
const args = node.arguments;
if (args.length === 0) {
return concat$6(["(", comments.printDanglingComments(path, options,
/* sameIndent */
true), ")"]);
} // useEffect(() => { ... }, [foo, bar, baz])
if (args.leng... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 => {
const printed... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function allArgsBrokenOut() {
return group$2(concat$6(["(", indent$3(concat$6([line$4, concat$6(printedArguments)])), maybeTrailingComma, line$4, ")"]), {
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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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.ex... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function shouldGroupLastArg(args) {
const lastArg = getLast$2(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.
!penul... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 === "BlockStatement") &&... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 === "OptionalCallEx... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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$7([optional, ".", property]);
}
if (!n.property || isNumericLiteral$1(n.property)) {
return conca... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printBindExpressionCallee(path, options, print) {
return concat$7(["::", 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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:
// CallExpression(Mem... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 for one 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] | shouldInsertEmptyLineAfter | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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$8([comments.printComments(path, () => concat$8([printOptionalToken... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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) || isExpressionStatemen... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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$8(["(", ...printed, "... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printIndentedGroup(groups) {
if (groups.length === 0) {
return "";
}
return indent$5(group$4(concat$8([hardline$5, join$4(hardline$5, 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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.arguments.leng... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function lastGroupWillBreakAndOtherCallsHaveComplexArguments() {
const lastGroupNode = getLast$3(getLast$3(groups)).node;
const lastGroupDoc = getLast$3(printedGroups);
return isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$2(lastGroupDoc) && callExpressions.some((expr, index) => index !== call... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function genericPrint(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 = getParentExpo... | 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 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printDecorators(path, options, print) {
const node = path.getValue();
return group$5(concat$9([join$5(line$5, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators$1(node, options) ? hardline$6 : line$5]));
} | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.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 either "JS... | 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/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function replaceQuotesInInlineComments(text) {
/** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
/** @type {State} */
let state = "initial";
/** @type {State} */
let stateToReturnFromQuotes = "initial";
let inlineCommentStartIndex;
let i... | Workaround for a bug: quotes in inline comments corrupt loc data of subsequent nodes.
This function replaces the quotes with U+FFFE and U+FFFF. Later, when the comments are printed,
their content is extracted from the original text or restored by replacing the placeholder
characters back with quotes.
- https://github.c... | replaceQuotesInInlineComments | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printStringLiteral(stringLiteral, options) {
const double = {
quote: '"',
regex: /"/g
};
const single = {
quote: "'",
regex: /'/g
};
const preferred = options.singleQuote ? single : double;
const alternate = preferred === single ? double : single;
let shouldUseAlternateQuote = fal... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printStringLiteral | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printSubExpressionPathAndParams(path, print) {
const p = printPath(path, print);
const params = printParams(path, print);
if (!params) {
return p;
}
return indent$9(concat$d([p, line$7, group$d(params)]));
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printSubExpressionPathAndParams | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printPathAndParams(path, print) {
const p = printPath(path, print);
const params = printParams(path, print);
if (!params) {
return p;
}
return indent$9(group$d(concat$d([p, line$7, params])));
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printPathAndParams | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printPath(path, print) {
return path.call(print, "path");
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printPath | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printParams(path, print) {
const node = path.getValue();
const parts = [];
if (node.params.length) {
const params = path.map(print, "params");
parts.push(...params);
}
if (node.hash && node.hash.pairs.length > 0) {
const hash = path.call(print, "hash");
parts.push(hash);
}
if (... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printParams | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printBlockParams(node) {
if (!node || !node.blockParams.length) {
return "";
}
return concat$d([" as |", node.blockParams.join(" "), "|"]);
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printBlockParams | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function locationToOffset(source, line, column) {
let seenLines = 0;
let seenChars = 0; // eslint-disable-next-line no-constant-condition
while (true) {
if (seenChars === source.length) {
return null;
}
let nextLine = source.indexOf("\n", seenChars);
if (nextLine === -1) {
nextLine ... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | locationToOffset | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function hasPragma$2(text) {
return /^\s*#[^\S\n]*@(format|prettier)\s*(\n|$)/.test(text);
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | hasPragma$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function insertPragma$4(text) {
return "# @format\n\n" + text;
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | insertPragma$4 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function genericPrint$3(path, options, print) {
const n = path.getValue();
if (!n) {
return "";
}
if (typeof n === "string") {
return n;
}
switch (n.kind) {
case "Document":
{
const parts = [];
path.map((pathChild, index) => {
parts.push(concat$e([pathChild.cal... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | genericPrint$3 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printDirectives(path, print, n) {
if (n.directives.length === 0) {
return "";
}
return group$f(concat$e([line$8, join$9(line$8, path.map(print, "directives"))]));
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printDirectives | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printSequence(sequencePath, options, print) {
const count = sequencePath.getValue().length;
return sequencePath.map((path, i) => {
const printed = print(path);
if (isNextLineEmpty$6(options.originalText, path.getValue(), options.locEnd) && i < count - 1) {
return concat$e([printed, hardline$... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printSequence | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function canAttachComment$1(node) {
return node.kind && node.kind !== "Comment";
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | canAttachComment$1 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printComment$2(commentPath) {
const comment = commentPath.getValue();
if (comment.kind === "Comment") {
return "#" + comment.value.trimEnd();
}
throw new Error("Not a comment: " + JSON.stringify(comment));
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printComment$2 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function printInterfaces(path, options, print) {
const node = path.getNode();
const parts = [];
const {
interfaces
} = node;
const printed = path.map(node => print(node), "interfaces");
for (let index = 0; index < interfaces.length; index++) {
const interfaceNode = interfaces[index];
parts.push... | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | printInterfaces | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
function clean$4(node, newNode
/*, parent*/
) {
delete newNode.loc;
delete newNode.comments;
} | Prints a string literal with the correct surrounding quotes based on
`options.singleQuote` and the number of escaped quotes contained in
the string literal. This function is the glimmer equivalent of `printString`
in `common/util`, but has differences because of the way escaped characters
are treated in hbs string lite... | clean$4 | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/index.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.