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
syntaxError = (type, char) => { return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`; }
Create the message for a syntax error
syntaxError
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
parse$4 = (input, options) => { if (typeof input !== 'string') { throw new TypeError('Expected a string'); } input = REPLACEMENTS[input] || input; const opts = Object.assign({}, options); const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3; let len = input.length; if (len > max) { throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; const tokens = [bos]; const capture = opts.capture ? '' : '?:'; const win32 = utils$3.isWindows(options); // create constants based on platform, for windows or posix const PLATFORM_CHARS = constants$3.globChars(win32); const EXTGLOB_CHARS = constants$3.extglobChars(PLATFORM_CHARS); const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS; const globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }; const nodot = opts.dot ? '' : NO_DOT; const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; let star = opts.bash === true ? globstar(opts) : STAR; if (opts.capture) { star = `(${star})`; } // minimatch options support if (typeof opts.noext === 'boolean') { opts.noextglob = opts.noext; } const state = { input, index: -1, start: 0, dot: opts.dot === true, consumed: '', output: '', prefix: '', backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens }; input = utils$3.removePrefix(input, state); len = input.length; const extglobs = []; const braces = []; const stack = []; let prev = bos; let value; /** * Tokenizing helpers */ const eos = () => state.index === len - 1; const peek = state.peek = (n = 1) => input[state.index + n]; const advance = state.advance = () => input[++state.index]; const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; state.index += num; }; const append = token => { state.output += token.output != null ? token.output : token.value; consume(token.value); }; const negate = () => { let count = 1; while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { advance(); state.start++; count++; } if (count % 2 === 0) { return false; } state.negated = true; state.start++; return true; }; const increment = type => { state[type]++; stack.push(type); }; const decrement = type => { state[type]--; stack.pop(); }; /** * Push tokens onto the tokens array. This helper speeds up * tokenizing by 1) helping us avoid backtracking as much as possible, * and 2) helping us avoid creating extra tokens when consecutive * characters are plain text. This improves performance and simplifies * lookbehinds. */ const push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }; const extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }; const extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }; /** * Fast paths */ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { if (first === '\\') { backslashes = true; return m; } if (first === '?') { if (esc) { return esc + first + (rest ? QMARK.repeat(rest.length) : ''); } if (index === 0) { return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); } return QMARK.repeat(chars.length); } if (first === '.') { return DOT_LITERAL.repeat(chars.length); } if (first === '*') { if (esc) { return esc + first + (rest ? star : ''); } return star; } return esc ? m : `\\${m}`; }); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; }); } } if (output === input && opts.contains === true) { state.output = input; return state; } state.output = utils$3.wrapOutput(output, state, options); return state; } /** * Tokenize input until we reach end-of-string */ while (!eos()) { value = advance(); if (value === '\u0000') { continue; } /** * Escaped characters */ if (value === '\\') { const next = peek(); if (next === '/' && opts.bash !== true) { continue; } if (next === '.' || next === ';') { continue; } if (!next) { value += '\\'; push({ type: 'text', value }); continue; } // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); let slashes = 0; if (match && match[0].length > 2) { slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; } } if (opts.unescape === true) { value = advance() || ''; } else { value += advance() || ''; } if (state.brackets === 0) { push({ type: 'text', value }); continue; } } /** * If we're inside a regex character class, continue * until we reach the closing bracket. */ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { prev.posix = true; if (inner.includes(':')) { const idx = prev.value.lastIndexOf('['); const pre = prev.value.slice(0, idx); const rest = prev.value.slice(idx + 2); const posix = POSIX_REGEX_SOURCE$1[rest]; if (posix) { prev.value = pre + posix; state.backtrack = true; advance(); if (!bos.output && tokens.indexOf(prev) === 1) { bos.output = ONE_CHAR; } continue; } } } } if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') { value = `\\${value}`; } if (value === ']' && (prev.value === '[' || prev.value === '[^')) { value = `\\${value}`; } if (opts.posix === true && value === '!' && prev.value === '[') { value = '^'; } prev.value += value; append({ value }); continue; } /** * If we're inside a quoted string, continue * until we reach the closing double quote. */ if (state.quotes === 1 && value !== '"') { value = utils$3.escapeRegex(value); prev.value += value; append({ value }); continue; } /** * Double quotes */ if (value === '"') { state.quotes = state.quotes === 1 ? 0 : 1; if (opts.keepQuotes === true) { push({ type: 'text', value }); } continue; } /** * Parentheses */ if (value === '(') { increment('parens'); push({ type: 'paren', value }); continue; } if (value === ')') { if (state.parens === 0 && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '(')); } const extglob = extglobs[extglobs.length - 1]; if (extglob && state.parens === extglob.parens + 1) { extglobClose(extglobs.pop()); continue; } push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); decrement('parens'); continue; } /** * Square brackets */ if (value === '[') { if (opts.nobracket === true || !remaining().includes(']')) { if (opts.nobracket !== true && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('closing', ']')); } value = `\\${value}`; } else { increment('brackets'); } push({ type: 'bracket', value }); continue; } if (value === ']') { if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) { push({ type: 'text', value, output: `\\${value}` }); continue; } if (state.brackets === 0) { if (opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '[')); } push({ type: 'text', value, output: `\\${value}` }); continue; } decrement('brackets'); const prevValue = prev.value.slice(1); if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { value = `/${value}`; } prev.value += value; append({ value }); // when literal brackets are explicitly disabled // assume we should match with a regex character class if (opts.literalBrackets === false || utils$3.hasRegexChars(prevValue)) { continue; } const escaped = utils$3.escapeRegex(prev.value); state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled // assume we should escape the brackets to match literal characters if (opts.literalBrackets === true) { state.output += escaped; prev.value = escaped; continue; } // when the user specifies nothing, try to match both prev.value = `(${capture}${escaped}|${prev.value})`; state.output += prev.value; continue; } /** * Braces */ if (value === '{' && opts.nobrace !== true) { increment('braces'); const open = { type: 'brace', value, output: '(', outputIndex: state.output.length, tokensIndex: state.tokens.length }; braces.push(open); push(open); continue; } if (value === '}') { const brace = braces[braces.length - 1]; if (opts.nobrace === true || !brace) { push({ type: 'text', value, output: value }); continue; } let output = ')'; if (brace.dots === true) { const arr = tokens.slice(); const range = []; for (let i = arr.length - 1; i >= 0; i--) { tokens.pop(); if (arr[i].type === 'brace') { break; } if (arr[i].type !== 'dots') { range.unshift(arr[i].value); } } output = expandRange(range, opts); state.backtrack = true; } if (brace.comma !== true && brace.dots !== true) { const out = state.output.slice(0, brace.outputIndex); const toks = state.tokens.slice(brace.tokensIndex); brace.value = brace.output = '\\{'; value = output = `\\}`; state.output = out; for (const t of toks) { state.output += t.output || t.value; } } push({ type: 'brace', value, output }); decrement('braces'); braces.pop(); continue; } /** * Pipes */ if (value === '|') { if (extglobs.length > 0) { extglobs[extglobs.length - 1].conditions++; } push({ type: 'text', value }); continue; } /** * Commas */ if (value === ',') { let output = value; const brace = braces[braces.length - 1]; if (brace && stack[stack.length - 1] === 'braces') { brace.comma = true; output = '|'; } push({ type: 'comma', value, output }); continue; } /** * Slashes */ if (value === '/') { // if the beginning of the glob is "./", advance the start // to the current index, and don't add the "./" characters // to the state. This greatly simplifies lookbehinds when // checking for BOS characters like "!" and "." (not "./") if (prev.type === 'dot' && state.index === state.start + 1) { state.start = state.index + 1; state.consumed = ''; state.output = ''; tokens.pop(); prev = bos; // reset "prev" to the first token continue; } push({ type: 'slash', value, output: SLASH_LITERAL }); continue; } /** * Dots */ if (value === '.') { if (state.braces > 0 && prev.type === 'dot') { if (prev.value === '.') prev.output = DOT_LITERAL; const brace = braces[braces.length - 1]; prev.type = 'dots'; prev.output += value; prev.value += value; brace.dots = true; continue; } if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') { push({ type: 'text', value, output: DOT_LITERAL }); continue; } push({ type: 'dot', value, output: DOT_LITERAL }); continue; } /** * Question marks */ if (value === '?') { const isGroup = prev && prev.value === '('; if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('qmark', value); continue; } if (prev && prev.type === 'paren') { const next = peek(); let output = value; if (next === '<' && !utils$3.supportsLookbehinds()) { throw new Error('Node.js v10 or higher is required for regex lookbehinds'); } if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) { output = `\\${value}`; } push({ type: 'text', value, output }); continue; } if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { push({ type: 'qmark', value, output: QMARK_NO_DOT }); continue; } push({ type: 'qmark', value, output: QMARK }); continue; } /** * Exclamation */ if (value === '!') { if (opts.noextglob !== true && peek() === '(') { if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { extglobOpen('negate', value); continue; } } if (opts.nonegate !== true && state.index === 0) { negate(); continue; } } /** * Plus */ if (value === '+') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('plus', value); continue; } if (prev && prev.value === '(' || opts.regex === false) { push({ type: 'plus', value, output: PLUS_LITERAL }); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) { push({ type: 'plus', value }); continue; } push({ type: 'plus', value: PLUS_LITERAL }); continue; } /** * Plain text */ if (value === '@') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { push({ type: 'at', extglob: true, value, output: '' }); continue; } push({ type: 'text', value }); continue; } /** * Plain text */ if (value !== '*') { if (value === '$' || value === '^') { value = `\\${value}`; } const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); if (match) { value += match[0]; state.index += match[0].length; } push({ type: 'text', value }); continue; } /** * Stars */ if (prev && (prev.type === 'globstar' || prev.star === true)) { prev.type = 'star'; prev.star = true; prev.value += value; prev.output = star; state.backtrack = true; state.globstar = true; consume(value); continue; } let rest = remaining(); if (opts.noextglob !== true && /^\([^?]/.test(rest)) { extglobOpen('star', value); continue; } if (prev.type === 'star') { if (opts.noglobstar === true) { consume(value); continue; } const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; const afterStar = before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) { push({ type: 'star', value, output: '' }); continue; } const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; } // strip consecutive `/**/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
parse$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
parse$4 = (input, options) => { if (typeof input !== 'string') { throw new TypeError('Expected a string'); } input = REPLACEMENTS[input] || input; const opts = Object.assign({}, options); const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$3, opts.maxLength) : MAX_LENGTH$3; let len = input.length; if (len > max) { throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`); } const bos = { type: 'bos', value: '', output: opts.prepend || '' }; const tokens = [bos]; const capture = opts.capture ? '' : '?:'; const win32 = utils$3.isWindows(options); // create constants based on platform, for windows or posix const PLATFORM_CHARS = constants$3.globChars(win32); const EXTGLOB_CHARS = constants$3.extglobChars(PLATFORM_CHARS); const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS; const globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }; const nodot = opts.dot ? '' : NO_DOT; const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT; let star = opts.bash === true ? globstar(opts) : STAR; if (opts.capture) { star = `(${star})`; } // minimatch options support if (typeof opts.noext === 'boolean') { opts.noextglob = opts.noext; } const state = { input, index: -1, start: 0, dot: opts.dot === true, consumed: '', output: '', prefix: '', backtrack: false, negated: false, brackets: 0, braces: 0, parens: 0, quotes: 0, globstar: false, tokens }; input = utils$3.removePrefix(input, state); len = input.length; const extglobs = []; const braces = []; const stack = []; let prev = bos; let value; /** * Tokenizing helpers */ const eos = () => state.index === len - 1; const peek = state.peek = (n = 1) => input[state.index + n]; const advance = state.advance = () => input[++state.index]; const remaining = () => input.slice(state.index + 1); const consume = (value = '', num = 0) => { state.consumed += value; state.index += num; }; const append = token => { state.output += token.output != null ? token.output : token.value; consume(token.value); }; const negate = () => { let count = 1; while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) { advance(); state.start++; count++; } if (count % 2 === 0) { return false; } state.negated = true; state.start++; return true; }; const increment = type => { state[type]++; stack.push(type); }; const decrement = type => { state[type]--; stack.pop(); }; /** * Push tokens onto the tokens array. This helper speeds up * tokenizing by 1) helping us avoid backtracking as much as possible, * and 2) helping us avoid creating extra tokens when consecutive * characters are plain text. This improves performance and simplifies * lookbehinds. */ const push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }; const extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }; const extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }; /** * Fast paths */ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) { let backslashes = false; let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => { if (first === '\\') { backslashes = true; return m; } if (first === '?') { if (esc) { return esc + first + (rest ? QMARK.repeat(rest.length) : ''); } if (index === 0) { return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : ''); } return QMARK.repeat(chars.length); } if (first === '.') { return DOT_LITERAL.repeat(chars.length); } if (first === '*') { if (esc) { return esc + first + (rest ? star : ''); } return star; } return esc ? m : `\\${m}`; }); if (backslashes === true) { if (opts.unescape === true) { output = output.replace(/\\/g, ''); } else { output = output.replace(/\\+/g, m => { return m.length % 2 === 0 ? '\\\\' : m ? '\\' : ''; }); } } if (output === input && opts.contains === true) { state.output = input; return state; } state.output = utils$3.wrapOutput(output, state, options); return state; } /** * Tokenize input until we reach end-of-string */ while (!eos()) { value = advance(); if (value === '\u0000') { continue; } /** * Escaped characters */ if (value === '\\') { const next = peek(); if (next === '/' && opts.bash !== true) { continue; } if (next === '.' || next === ';') { continue; } if (!next) { value += '\\'; push({ type: 'text', value }); continue; } // collapse slashes to reduce potential for exploits const match = /^\\+/.exec(remaining()); let slashes = 0; if (match && match[0].length > 2) { slashes = match[0].length; state.index += slashes; if (slashes % 2 !== 0) { value += '\\'; } } if (opts.unescape === true) { value = advance() || ''; } else { value += advance() || ''; } if (state.brackets === 0) { push({ type: 'text', value }); continue; } } /** * If we're inside a regex character class, continue * until we reach the closing bracket. */ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) { if (opts.posix !== false && value === ':') { const inner = prev.value.slice(1); if (inner.includes('[')) { prev.posix = true; if (inner.includes(':')) { const idx = prev.value.lastIndexOf('['); const pre = prev.value.slice(0, idx); const rest = prev.value.slice(idx + 2); const posix = POSIX_REGEX_SOURCE$1[rest]; if (posix) { prev.value = pre + posix; state.backtrack = true; advance(); if (!bos.output && tokens.indexOf(prev) === 1) { bos.output = ONE_CHAR; } continue; } } } } if (value === '[' && peek() !== ':' || value === '-' && peek() === ']') { value = `\\${value}`; } if (value === ']' && (prev.value === '[' || prev.value === '[^')) { value = `\\${value}`; } if (opts.posix === true && value === '!' && prev.value === '[') { value = '^'; } prev.value += value; append({ value }); continue; } /** * If we're inside a quoted string, continue * until we reach the closing double quote. */ if (state.quotes === 1 && value !== '"') { value = utils$3.escapeRegex(value); prev.value += value; append({ value }); continue; } /** * Double quotes */ if (value === '"') { state.quotes = state.quotes === 1 ? 0 : 1; if (opts.keepQuotes === true) { push({ type: 'text', value }); } continue; } /** * Parentheses */ if (value === '(') { increment('parens'); push({ type: 'paren', value }); continue; } if (value === ')') { if (state.parens === 0 && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '(')); } const extglob = extglobs[extglobs.length - 1]; if (extglob && state.parens === extglob.parens + 1) { extglobClose(extglobs.pop()); continue; } push({ type: 'paren', value, output: state.parens ? ')' : '\\)' }); decrement('parens'); continue; } /** * Square brackets */ if (value === '[') { if (opts.nobracket === true || !remaining().includes(']')) { if (opts.nobracket !== true && opts.strictBrackets === true) { throw new SyntaxError(syntaxError('closing', ']')); } value = `\\${value}`; } else { increment('brackets'); } push({ type: 'bracket', value }); continue; } if (value === ']') { if (opts.nobracket === true || prev && prev.type === 'bracket' && prev.value.length === 1) { push({ type: 'text', value, output: `\\${value}` }); continue; } if (state.brackets === 0) { if (opts.strictBrackets === true) { throw new SyntaxError(syntaxError('opening', '[')); } push({ type: 'text', value, output: `\\${value}` }); continue; } decrement('brackets'); const prevValue = prev.value.slice(1); if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) { value = `/${value}`; } prev.value += value; append({ value }); // when literal brackets are explicitly disabled // assume we should match with a regex character class if (opts.literalBrackets === false || utils$3.hasRegexChars(prevValue)) { continue; } const escaped = utils$3.escapeRegex(prev.value); state.output = state.output.slice(0, -prev.value.length); // when literal brackets are explicitly enabled // assume we should escape the brackets to match literal characters if (opts.literalBrackets === true) { state.output += escaped; prev.value = escaped; continue; } // when the user specifies nothing, try to match both prev.value = `(${capture}${escaped}|${prev.value})`; state.output += prev.value; continue; } /** * Braces */ if (value === '{' && opts.nobrace !== true) { increment('braces'); const open = { type: 'brace', value, output: '(', outputIndex: state.output.length, tokensIndex: state.tokens.length }; braces.push(open); push(open); continue; } if (value === '}') { const brace = braces[braces.length - 1]; if (opts.nobrace === true || !brace) { push({ type: 'text', value, output: value }); continue; } let output = ')'; if (brace.dots === true) { const arr = tokens.slice(); const range = []; for (let i = arr.length - 1; i >= 0; i--) { tokens.pop(); if (arr[i].type === 'brace') { break; } if (arr[i].type !== 'dots') { range.unshift(arr[i].value); } } output = expandRange(range, opts); state.backtrack = true; } if (brace.comma !== true && brace.dots !== true) { const out = state.output.slice(0, brace.outputIndex); const toks = state.tokens.slice(brace.tokensIndex); brace.value = brace.output = '\\{'; value = output = `\\}`; state.output = out; for (const t of toks) { state.output += t.output || t.value; } } push({ type: 'brace', value, output }); decrement('braces'); braces.pop(); continue; } /** * Pipes */ if (value === '|') { if (extglobs.length > 0) { extglobs[extglobs.length - 1].conditions++; } push({ type: 'text', value }); continue; } /** * Commas */ if (value === ',') { let output = value; const brace = braces[braces.length - 1]; if (brace && stack[stack.length - 1] === 'braces') { brace.comma = true; output = '|'; } push({ type: 'comma', value, output }); continue; } /** * Slashes */ if (value === '/') { // if the beginning of the glob is "./", advance the start // to the current index, and don't add the "./" characters // to the state. This greatly simplifies lookbehinds when // checking for BOS characters like "!" and "." (not "./") if (prev.type === 'dot' && state.index === state.start + 1) { state.start = state.index + 1; state.consumed = ''; state.output = ''; tokens.pop(); prev = bos; // reset "prev" to the first token continue; } push({ type: 'slash', value, output: SLASH_LITERAL }); continue; } /** * Dots */ if (value === '.') { if (state.braces > 0 && prev.type === 'dot') { if (prev.value === '.') prev.output = DOT_LITERAL; const brace = braces[braces.length - 1]; prev.type = 'dots'; prev.output += value; prev.value += value; brace.dots = true; continue; } if (state.braces + state.parens === 0 && prev.type !== 'bos' && prev.type !== 'slash') { push({ type: 'text', value, output: DOT_LITERAL }); continue; } push({ type: 'dot', value, output: DOT_LITERAL }); continue; } /** * Question marks */ if (value === '?') { const isGroup = prev && prev.value === '('; if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('qmark', value); continue; } if (prev && prev.type === 'paren') { const next = peek(); let output = value; if (next === '<' && !utils$3.supportsLookbehinds()) { throw new Error('Node.js v10 or higher is required for regex lookbehinds'); } if (prev.value === '(' && !/[!=<:]/.test(next) || next === '<' && !/<([!=]|\w+>)/.test(remaining())) { output = `\\${value}`; } push({ type: 'text', value, output }); continue; } if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) { push({ type: 'qmark', value, output: QMARK_NO_DOT }); continue; } push({ type: 'qmark', value, output: QMARK }); continue; } /** * Exclamation */ if (value === '!') { if (opts.noextglob !== true && peek() === '(') { if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) { extglobOpen('negate', value); continue; } } if (opts.nonegate !== true && state.index === 0) { negate(); continue; } } /** * Plus */ if (value === '+') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { extglobOpen('plus', value); continue; } if (prev && prev.value === '(' || opts.regex === false) { push({ type: 'plus', value, output: PLUS_LITERAL }); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace') || state.parens > 0) { push({ type: 'plus', value }); continue; } push({ type: 'plus', value: PLUS_LITERAL }); continue; } /** * Plain text */ if (value === '@') { if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') { push({ type: 'at', extglob: true, value, output: '' }); continue; } push({ type: 'text', value }); continue; } /** * Plain text */ if (value !== '*') { if (value === '$' || value === '^') { value = `\\${value}`; } const match = REGEX_NON_SPECIAL_CHARS.exec(remaining()); if (match) { value += match[0]; state.index += match[0].length; } push({ type: 'text', value }); continue; } /** * Stars */ if (prev && (prev.type === 'globstar' || prev.star === true)) { prev.type = 'star'; prev.star = true; prev.value += value; prev.output = star; state.backtrack = true; state.globstar = true; consume(value); continue; } let rest = remaining(); if (opts.noextglob !== true && /^\([^?]/.test(rest)) { extglobOpen('star', value); continue; } if (prev.type === 'star') { if (opts.noglobstar === true) { consume(value); continue; } const prior = prev.prev; const before = prior.prev; const isStart = prior.type === 'slash' || prior.type === 'bos'; const afterStar = before && (before.type === 'star' || before.type === 'globstar'); if (opts.bash === true && (!isStart || rest[0] && rest[0] !== '/')) { push({ type: 'star', value, output: '' }); continue; } const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace'); const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren'); if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) { push({ type: 'star', value, output: '' }); continue; } // strip consecutive `/**/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
parse$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
globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
globstar
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
globstar = opts => { return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
Parse the given input string. @param {String} input @param {Object} options @return {Object}
globstar
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
push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
push
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
push = tok => { if (prev.type === 'globstar') { const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace'); const isExtglob = tok.extglob === true || extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'); if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) { state.output = state.output.slice(0, -prev.output.length); prev.type = 'star'; prev.value = '*'; prev.output = star; state.output += prev.output; } } if (extglobs.length && tok.type !== 'paren' && !EXTGLOB_CHARS[tok.value]) { extglobs[extglobs.length - 1].inner += tok.value; } if (tok.value || tok.output) append(tok); if (prev && prev.type === 'text' && tok.type === 'text') { prev.value += tok.value; prev.output = (prev.output || '') + tok.value; return; } tok.prev = prev; tokens.push(tok); prev = tok; }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
push
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
extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobOpen
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
extglobOpen = (type, value) => { const token = Object.assign(Object.assign({}, EXTGLOB_CHARS[value]), {}, { conditions: 1, inner: '' }); token.prev = prev; token.parens = state.parens; token.output = state.output; const output = (opts.capture ? '(' : '') + token.open; increment('parens'); push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobOpen
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
extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobClose
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
extglobClose = token => { let output = token.close + (opts.capture ? ')' : ''); if (token.type === 'negate') { let extglobStar = star; if (token.inner && token.inner.length > 1 && token.inner.includes('/')) { extglobStar = globstar(opts); } if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) { output = token.close = `)$))${extglobStar}`; } if (token.prev.type === 'bos' && eos()) { state.negatedExtglob = true; } } push({ type: 'paren', extglob: true, value, output }); decrement('parens'); }
Push tokens onto the tokens array. This helper speeds up tokenizing by 1) helping us avoid backtracking as much as possible, and 2) helping us avoid creating extra tokens when consecutive characters are plain text. This improves performance and simplifies lookbehinds.
extglobClose
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
globstar = opts => { if (opts.noglobstar === true) return star; return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
globstar
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
globstar = opts => { if (opts.noglobstar === true) return star; return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`; }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
globstar
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
create = str => { switch (str) { case '*': return `${nodot}${ONE_CHAR}${star}`; case '.*': return `${DOT_LITERAL}${ONE_CHAR}${star}`; case '*.*': return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '*/*': return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; case '**': return nodot + globstar(opts); case '**/*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; case '**/*.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '**/.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; default: { const match = /^(.*?)\.(\w+)$/.exec(str); if (!match) return; const source = create(match[1]); if (!source) return; return source + DOT_LITERAL + match[2]; } } }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
create
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
create = str => { switch (str) { case '*': return `${nodot}${ONE_CHAR}${star}`; case '.*': return `${DOT_LITERAL}${ONE_CHAR}${star}`; case '*.*': return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '*/*': return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`; case '**': return nodot + globstar(opts); case '**/*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`; case '**/*.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`; case '**/.*': return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`; default: { const match = /^(.*?)\.(\w+)$/.exec(str); if (!match) return; const source = create(match[1]); if (!source) return; return source + DOT_LITERAL + match[2]; } } }
/` while (rest.slice(0, 3) === '/**') { const after = input[state.index + 4]; if (after && after !== '/') { break; } rest = rest.slice(3); consume('/**', 3); } if (prior.type === 'bos' && eos()) { prev.type = 'globstar'; prev.value += value; prev.output = globstar(opts); state.output = prev.output; state.globstar = true; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) { state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)'); prev.value += value; state.globstar = true; state.output += prior.output + prev.output; consume(value); continue; } if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') { const end = rest[1] !== void 0 ? '|$' : ''; state.output = state.output.slice(0, -(prior.output + prev.output).length); prior.output = `(?:${prior.output}`; prev.type = 'globstar'; prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`; prev.value += value; state.output += prior.output + prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } if (prior.type === 'bos' && rest[0] === '/') { prev.type = 'globstar'; prev.value += value; prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`; state.output = prev.output; state.globstar = true; consume(value + advance()); push({ type: 'slash', value: '/', output: '' }); continue; } // remove single star from output state.output = state.output.slice(0, -prev.output.length); // reset previous token to globstar prev.type = 'globstar'; prev.output = globstar(opts); prev.value += value; // reset output with globstar state.output += prev.output; state.globstar = true; consume(value); continue; } const token = { type: 'star', value, output: star }; if (opts.bash === true) { token.output = '.*?'; if (prev.type === 'bos' || prev.type === 'slash') { token.output = nodot + token.output; } push(token); continue; } if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) { token.output = value; push(token); continue; } if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') { if (prev.type === 'dot') { state.output += NO_DOT_SLASH; prev.output += NO_DOT_SLASH; } else if (opts.dot === true) { state.output += NO_DOTS_SLASH; prev.output += NO_DOTS_SLASH; } else { state.output += nodot; prev.output += nodot; } if (peek() !== '*') { state.output += ONE_CHAR; prev.output += ONE_CHAR; } } push(token); } while (state.brackets > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']')); state.output = utils$3.escapeLast(state.output, '['); decrement('brackets'); } while (state.parens > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')')); state.output = utils$3.escapeLast(state.output, '('); decrement('parens'); } while (state.braces > 0) { if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}')); state.output = utils$3.escapeLast(state.output, '{'); decrement('braces'); } if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) { push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` }); } // rebuild the output if we had to backtrack at any point if (state.backtrack === true) { state.output = ''; for (const token of state.tokens) { state.output += token.output != null ? token.output : token.value; if (token.suffix) { state.output += token.suffix; } } } return state; }; /** Fast paths for creating regular expressions for common glob patterns. This can significantly speed up processing and has very little downside impact when none of the fast paths match.
create
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
picomatch = (glob, options, returnState = false) => { if (Array.isArray(glob)) { const fns = glob.map(input => picomatch(input, options, returnState)); const arrayMatcher = str => { for (const isMatch of fns) { const state = isMatch(str); if (state) return state; } return false; }; return arrayMatcher; } const isState = isObject$2(glob) && glob.tokens && glob.input; if (glob === '' || typeof glob !== 'string' && !isState) { throw new TypeError('Expected pattern to be a non-empty string'); } const opts = options || {}; const posix = utils$3.isWindows(options); const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true); const state = regex.state; delete regex.state; let isIgnored = () => false; if (opts.ignore) { const ignoreOpts = Object.assign(Object.assign({}, options), {}, { ignore: null, onMatch: null, onResult: null }); isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } const matcher = (input, returnObject = false) => { const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { opts.onResult(result); } if (isMatch === false) { result.isMatch = false; return returnObject ? result : false; } if (isIgnored(input)) { if (typeof opts.onIgnore === 'function') { opts.onIgnore(result); } result.isMatch = false; return returnObject ? result : false; } if (typeof opts.onMatch === 'function') { opts.onMatch(result); } return returnObject ? result : true; }; if (returnState) { matcher.state = state; } return matcher; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
picomatch
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
picomatch = (glob, options, returnState = false) => { if (Array.isArray(glob)) { const fns = glob.map(input => picomatch(input, options, returnState)); const arrayMatcher = str => { for (const isMatch of fns) { const state = isMatch(str); if (state) return state; } return false; }; return arrayMatcher; } const isState = isObject$2(glob) && glob.tokens && glob.input; if (glob === '' || typeof glob !== 'string' && !isState) { throw new TypeError('Expected pattern to be a non-empty string'); } const opts = options || {}; const posix = utils$3.isWindows(options); const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true); const state = regex.state; delete regex.state; let isIgnored = () => false; if (opts.ignore) { const ignoreOpts = Object.assign(Object.assign({}, options), {}, { ignore: null, onMatch: null, onResult: null }); isIgnored = picomatch(opts.ignore, ignoreOpts, returnState); } const matcher = (input, returnObject = false) => { const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { opts.onResult(result); } if (isMatch === false) { result.isMatch = false; return returnObject ? result : false; } if (isIgnored(input)) { if (typeof opts.onIgnore === 'function') { opts.onIgnore(result); } result.isMatch = false; return returnObject ? result : false; } if (typeof opts.onMatch === 'function') { opts.onMatch(result); } return returnObject ? result : true; }; if (returnState) { matcher.state = state; } return matcher; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
picomatch
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
arrayMatcher = str => { for (const isMatch of fns) { const state = isMatch(str); if (state) return state; } return false; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
arrayMatcher
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
arrayMatcher = str => { for (const isMatch of fns) { const state = isMatch(str); if (state) return state; } return false; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
arrayMatcher
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
matcher = (input, returnObject = false) => { const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { opts.onResult(result); } if (isMatch === false) { result.isMatch = false; return returnObject ? result : false; } if (isIgnored(input)) { if (typeof opts.onIgnore === 'function') { opts.onIgnore(result); } result.isMatch = false; return returnObject ? result : false; } if (typeof opts.onMatch === 'function') { opts.onMatch(result); } return returnObject ? result : true; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
matcher
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
matcher = (input, returnObject = false) => { const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix }); const result = { glob, state, regex, posix, input, output, match, isMatch }; if (typeof opts.onResult === 'function') { opts.onResult(result); } if (isMatch === false) { result.isMatch = false; return returnObject ? result : false; } if (isIgnored(input)) { if (typeof opts.onIgnore === 'function') { opts.onIgnore(result); } result.isMatch = false; return returnObject ? result : false; } if (typeof opts.onMatch === 'function') { opts.onMatch(result); } return returnObject ? result : true; }
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information. ```js const picomatch = require('picomatch'); // picomatch(glob[, options]); const isMatch = picomatch('*.!(*a)'); console.log(isMatch('a.a')); //=> false console.log(isMatch('a.b')); //=> true ``` @name picomatch @param {String|Array} `globs` One or more glob patterns. @param {Object=} `options` @return {Function=} Returns a matcher function. @api public
matcher
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
micromatch = (list, patterns, options) => { patterns = [].concat(patterns); list = [].concat(list); let omit = new Set(); let keep = new Set(); let items = new Set(); let negatives = 0; let onResult = state => { items.add(state.output); if (options && options.onResult) { options.onResult(state); } }; for (let i = 0; i < patterns.length; i++) { let isMatch = picomatch$1(String(patterns[i]), Object.assign(Object.assign({}, options), {}, { onResult }), true); let negated = isMatch.state.negated || isMatch.state.negatedExtglob; if (negated) negatives++; for (let item of list) { let matched = isMatch(item, true); let match = negated ? !matched.isMatch : matched.isMatch; if (!match) continue; if (negated) { omit.add(matched.output); } else { omit.delete(matched.output); keep.add(matched.output); } } } let result = negatives === patterns.length ? [...items] : [...keep]; let matches = result.filter(item => !omit.has(item)); if (options && matches.length === 0) { if (options.failglob === true) { throw new Error(`No matches found for "${patterns.join(', ')}"`); } if (options.nonull === true || options.nullglob === true) { return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns; } } return matches; }
Returns an array of strings that match one or more glob patterns. ```js const mm = require('micromatch'); // mm(list, patterns[, options]); console.log(mm(['a.js', 'a.txt'], ['*.js'])); //=> [ 'a.js' ] ``` @param {String|Array<string>} list List of strings to match. @param {String|Array<string>} patterns One or more glob patterns to use for matching. @param {Object} options See available [options](#options) @return {Array} Returns an array of matches @summary false @api public
micromatch
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
micromatch = (list, patterns, options) => { patterns = [].concat(patterns); list = [].concat(list); let omit = new Set(); let keep = new Set(); let items = new Set(); let negatives = 0; let onResult = state => { items.add(state.output); if (options && options.onResult) { options.onResult(state); } }; for (let i = 0; i < patterns.length; i++) { let isMatch = picomatch$1(String(patterns[i]), Object.assign(Object.assign({}, options), {}, { onResult }), true); let negated = isMatch.state.negated || isMatch.state.negatedExtglob; if (negated) negatives++; for (let item of list) { let matched = isMatch(item, true); let match = negated ? !matched.isMatch : matched.isMatch; if (!match) continue; if (negated) { omit.add(matched.output); } else { omit.delete(matched.output); keep.add(matched.output); } } } let result = negatives === patterns.length ? [...items] : [...keep]; let matches = result.filter(item => !omit.has(item)); if (options && matches.length === 0) { if (options.failglob === true) { throw new Error(`No matches found for "${patterns.join(', ')}"`); } if (options.nonull === true || options.nullglob === true) { return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns; } } return matches; }
Returns an array of strings that match one or more glob patterns. ```js const mm = require('micromatch'); // mm(list, patterns[, options]); console.log(mm(['a.js', 'a.txt'], ['*.js'])); //=> [ 'a.js' ] ``` @param {String|Array<string>} list List of strings to match. @param {String|Array<string>} patterns One or more glob patterns to use for matching. @param {Object} options See available [options](#options) @return {Array} Returns an array of matches @summary false @api public
micromatch
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
onResult = state => { items.add(state.output); if (options && options.onResult) { options.onResult(state); } }
Returns an array of strings that match one or more glob patterns. ```js const mm = require('micromatch'); // mm(list, patterns[, options]); console.log(mm(['a.js', 'a.txt'], ['*.js'])); //=> [ 'a.js' ] ``` @param {String|Array<string>} list List of strings to match. @param {String|Array<string>} patterns One or more glob patterns to use for matching. @param {Object} options See available [options](#options) @return {Array} Returns an array of matches @summary false @api public
onResult
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
onResult = state => { items.add(state.output); if (options && options.onResult) { options.onResult(state); } }
Returns an array of strings that match one or more glob patterns. ```js const mm = require('micromatch'); // mm(list, patterns[, options]); console.log(mm(['a.js', 'a.txt'], ['*.js'])); //=> [ 'a.js' ] ``` @param {String|Array<string>} list List of strings to match. @param {String|Array<string>} patterns One or more glob patterns to use for matching. @param {Object} options See available [options](#options) @return {Array} Returns an array of matches @summary false @api public
onResult
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
onResult = state => { if (options.onResult) options.onResult(state); items.push(state.output); }
Returns a list of strings that _**do not match any**_ of the given `patterns`. ```js const mm = require('micromatch'); // mm.not(list, patterns[, options]); console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); //=> ['b.b', 'c.c'] ``` @param {Array} `list` Array of strings to match. @param {String|Array} `patterns` One or more glob pattern to use for matching. @param {Object} `options` See available [options](#options) for changing how matches are performed @return {Array} Returns an array of strings that **do not match** the given patterns. @api public
onResult
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
onResult = state => { if (options.onResult) options.onResult(state); items.push(state.output); }
Returns a list of strings that _**do not match any**_ of the given `patterns`. ```js const mm = require('micromatch'); // mm.not(list, patterns[, options]); console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); //=> ['b.b', 'c.c'] ``` @param {Array} `list` Array of strings to match. @param {String|Array} `patterns` One or more glob pattern to use for matching. @param {Object} `options` See available [options](#options) for changing how matches are performed @return {Array} Returns an array of strings that **do not match** the given patterns. @api public
onResult
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 convertToPositivePattern(pattern) { return isNegativePattern(pattern) ? pattern.slice(1) : pattern; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
convertToPositivePattern
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 convertToNegativePattern(pattern) { return '!' + pattern; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
convertToNegativePattern
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 isNegativePattern(pattern) { return pattern.startsWith('!') && pattern[1] !== '('; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
isNegativePattern
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 isPositivePattern(pattern) { return !isNegativePattern(pattern); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
isPositivePattern
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 getNegativePatterns(patterns) { return patterns.filter(isNegativePattern); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getNegativePatterns
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 getPositivePatterns(patterns) { return patterns.filter(isPositivePattern); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getPositivePatterns
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 getBaseDirectory(pattern) { return globParent(pattern, { flipBackslashes: false }); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getBaseDirectory
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 hasGlobStar(pattern) { return pattern.includes(GLOBSTAR); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
hasGlobStar
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 endsWithSlashGlobStar(pattern) { return pattern.endsWith('/' + GLOBSTAR); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
endsWithSlashGlobStar
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 isAffectDepthOfReadingPattern(pattern) { const basename = path$2.basename(pattern); return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
isAffectDepthOfReadingPattern
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 expandPatternsWithBraceExpansion(patterns) { return patterns.reduce((collection, pattern) => { return collection.concat(expandBraceExpansion(pattern)); }, []); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
expandPatternsWithBraceExpansion
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 expandBraceExpansion(pattern) { return micromatch_1.braces(pattern, { expand: true, nodupes: true }); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
expandBraceExpansion
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 getPatternParts(pattern, options) { const info = picomatch$1.scan(pattern, Object.assign(Object.assign({}, options), { parts: true })); // See micromatch/picomatch#58 for more details if (info.parts.length === 0) { return [pattern]; } return info.parts; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getPatternParts
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 makeRe(pattern, options) { return micromatch_1.makeRe(pattern, options); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
makeRe
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 convertPatternsToRe(patterns, options) { return patterns.map(pattern => makeRe(pattern, options)); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
convertPatternsToRe
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 matchAny(entry, patternsRe) { return patternsRe.some(patternRe => patternRe.test(entry)); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
matchAny
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 merge(streams) { const mergedStream = merge2_1(streams); streams.forEach(stream => { stream.once('error', error => mergedStream.emit('error', error)); }); mergedStream.once('close', () => propagateCloseEventToSources(streams)); mergedStream.once('end', () => propagateCloseEventToSources(streams)); return mergedStream; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
merge
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 propagateCloseEventToSources(streams) { streams.forEach(stream => stream.emit('close')); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
propagateCloseEventToSources
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 isString(input) { return typeof input === 'string'; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
isString
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 isEmpty(input) { return input === ''; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
isEmpty
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 generate(patterns, settings) { const positivePatterns = getPositivePatterns(patterns); const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); const staticPatterns = positivePatterns.filter(pattern => utils$4.pattern.isStaticPattern(pattern, settings)); const dynamicPatterns = positivePatterns.filter(pattern => utils$4.pattern.isDynamicPattern(pattern, settings)); const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); return staticTasks.concat(dynamicTasks); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
generate
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 getPositivePatterns(patterns) { return utils$4.pattern.getPositivePatterns(patterns); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getPositivePatterns
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 getNegativePatternsAsPositive(patterns, ignore) { const negative = utils$4.pattern.getNegativePatterns(patterns).concat(ignore); const positive = negative.map(utils$4.pattern.convertToPositivePattern); return positive; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getNegativePatternsAsPositive
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 groupPatternsByBaseDirectory(patterns) { const group = {}; return patterns.reduce((collection, pattern) => { const base = utils$4.pattern.getBaseDirectory(pattern); if (base in collection) { collection[base].push(pattern); } else { collection[base] = [pattern]; } return collection; }, group); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
groupPatternsByBaseDirectory
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 convertPatternGroupsToTasks(positive, negative, dynamic) { return Object.keys(positive).map(base => { return convertPatternGroupToTask(base, positive[base], negative, dynamic); }); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
convertPatternGroupsToTasks
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 convertPatternGroupToTask(base, positive, negative, dynamic) { return { dynamic, positive, negative, base, patterns: [].concat(positive, negative.map(utils$4.pattern.convertToNegativePattern)) }; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
convertPatternGroupToTask
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 read(path, settings, callback) { settings.fs.lstat(path, (lstatError, lstat) => { if (lstatError !== null) { return callFailureCallback(callback, lstatError); } if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { return callSuccessCallback(callback, lstat); } settings.fs.stat(path, (statError, stat) => { if (statError !== null) { if (settings.throwErrorOnBrokenSymbolicLink) { return callFailureCallback(callback, statError); } return callSuccessCallback(callback, lstat); } if (settings.markSymbolicLink) { stat.isSymbolicLink = () => true; } callSuccessCallback(callback, stat); }); }); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
read
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 callSuccessCallback(callback, result) { callback(null, result); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
callSuccessCallback
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 read(path, settings) { const lstat = settings.fs.lstatSync(path); if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { return lstat; } try { const stat = settings.fs.statSync(path); if (settings.markSymbolicLink) { stat.isSymbolicLink = () => true; } return stat; } catch (error) { if (!settings.throwErrorOnBrokenSymbolicLink) { return lstat; } throw error; } }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
read
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 createFileSystemAdapter(fsMethods) { if (fsMethods === undefined) { return exports.FILE_SYSTEM_ADAPTER; } return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
createFileSystemAdapter
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(_options = {}) { this._options = _options; this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); this.fs = fs_1$1.createFileSystemAdapter(this._options.fs); this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
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
_getValue(option, value) { return option === undefined ? value : option; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
_getValue
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 stat(path, optionsOrSettingsOrCallback, callback) { if (typeof optionsOrSettingsOrCallback === 'function') { return async$1.read(path, getSettings(), optionsOrSettingsOrCallback); } async$1.read(path, getSettings(optionsOrSettingsOrCallback), callback); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
stat
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 statSync(path, optionsOrSettings) { const settings = getSettings(optionsOrSettings); return sync$1.read(path, settings); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
statSync
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 getSettings(settingsOrOptions = {}) { if (settingsOrOptions instanceof settings.default) { return settingsOrOptions; } return new settings.default(settingsOrOptions); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
getSettings
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 runParallel(tasks, cb) { var results, pending, keys; var isSync = true; if (Array.isArray(tasks)) { results = []; pending = tasks.length; } else { keys = Object.keys(tasks); results = {}; pending = keys.length; } function done(err) { function end() { if (cb) cb(err, results); cb = null; } if (isSync) process.nextTick(end);else end(); } function each(i, err, result) { results[i] = result; if (--pending === 0 || err) { done(err); } } if (!pending) { // empty done(null); } else if (keys) { // object keys.forEach(function (key) { tasks[key](function (err, result) { each(key, err, result); }); }); } else { // array tasks.forEach(function (task, i) { task(function (err, result) { each(i, err, result); }); }); } isSync = false; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
runParallel
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 done(err) { function end() { if (cb) cb(err, results); cb = null; } if (isSync) process.nextTick(end);else end(); }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
done
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 end() { if (cb) cb(err, results); cb = null; }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
end
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 each(i, err, result) { results[i] = result; if (--pending === 0 || err) { done(err); } }
When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath directly (without read directory).
each
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(name, stats) { this.name = name; this.isBlockDevice = stats.isBlockDevice.bind(stats); this.isCharacterDevice = stats.isCharacterDevice.bind(stats); this.isDirectory = stats.isDirectory.bind(stats); this.isFIFO = stats.isFIFO.bind(stats); this.isFile = stats.isFile.bind(stats); this.isSocket = stats.isSocket.bind(stats); this.isSymbolicLink = stats.isSymbolicLink.bind(stats); }
IS `true` for Node.js 10.10 and greater.
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
function createDirentFromStats(name, stats) { return new DirentFromStats(name, stats); }
IS `true` for Node.js 10.10 and greater.
createDirentFromStats
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 read(directory, settings, callback) { if (!settings.stats && constants$4.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { return readdirWithFileTypes(directory, settings, callback); } return readdir(directory, settings, callback); }
IS `true` for Node.js 10.10 and greater.
read
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 readdirWithFileTypes(directory, settings, callback) { settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => { if (readdirError !== null) { return callFailureCallback(callback, readdirError); } const entries = dirents.map(dirent => ({ dirent, name: dirent.name, path: `${directory}${settings.pathSegmentSeparator}${dirent.name}` })); if (!settings.followSymbolicLinks) { return callSuccessCallback(callback, entries); } const tasks = entries.map(entry => makeRplTaskEntry(entry, settings)); runParallel_1(tasks, (rplError, rplEntries) => { if (rplError !== null) { return callFailureCallback(callback, rplError); } callSuccessCallback(callback, rplEntries); }); }); }
IS `true` for Node.js 10.10 and greater.
readdirWithFileTypes
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 makeRplTaskEntry(entry, settings) { return done => { if (!entry.dirent.isSymbolicLink()) { return done(null, entry); } settings.fs.stat(entry.path, (statError, stats) => { if (statError !== null) { if (settings.throwErrorOnBrokenSymbolicLink) { return done(statError); } return done(null, entry); } entry.dirent = utils$5.fs.createDirentFromStats(entry.name, stats); return done(null, entry); }); }; }
IS `true` for Node.js 10.10 and greater.
makeRplTaskEntry
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 readdir(directory, settings, callback) { settings.fs.readdir(directory, (readdirError, names) => { if (readdirError !== null) { return callFailureCallback(callback, readdirError); } const filepaths = names.map(name => `${directory}${settings.pathSegmentSeparator}${name}`); const tasks = filepaths.map(filepath => { return done => out.stat(filepath, settings.fsStatSettings, done); }); runParallel_1(tasks, (rplError, results) => { if (rplError !== null) { return callFailureCallback(callback, rplError); } const entries = []; names.forEach((name, index) => { const stats = results[index]; const entry = { name, path: filepaths[index], dirent: utils$5.fs.createDirentFromStats(name, stats) }; if (settings.stats) { entry.stats = stats; } entries.push(entry); }); callSuccessCallback(callback, entries); }); }); }
IS `true` for Node.js 10.10 and greater.
readdir
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 callSuccessCallback(callback, result) { callback(null, result); }
IS `true` for Node.js 10.10 and greater.
callSuccessCallback
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 read(directory, settings) { if (!settings.stats && constants$4.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { return readdirWithFileTypes(directory, settings); } return readdir(directory, settings); }
IS `true` for Node.js 10.10 and greater.
read
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 readdirWithFileTypes(directory, settings) { const dirents = settings.fs.readdirSync(directory, { withFileTypes: true }); return dirents.map(dirent => { const entry = { dirent, name: dirent.name, path: `${directory}${settings.pathSegmentSeparator}${dirent.name}` }; if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { try { const stats = settings.fs.statSync(entry.path); entry.dirent = utils$5.fs.createDirentFromStats(entry.name, stats); } catch (error) { if (settings.throwErrorOnBrokenSymbolicLink) { throw error; } } } return entry; }); }
IS `true` for Node.js 10.10 and greater.
readdirWithFileTypes
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 readdir(directory, settings) { const names = settings.fs.readdirSync(directory); return names.map(name => { const entryPath = `${directory}${settings.pathSegmentSeparator}${name}`; const stats = out.statSync(entryPath, settings.fsStatSettings); const entry = { name, path: entryPath, dirent: utils$5.fs.createDirentFromStats(name, stats) }; if (settings.stats) { entry.stats = stats; } return entry; }); }
IS `true` for Node.js 10.10 and greater.
readdir
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 createFileSystemAdapter(fsMethods) { if (fsMethods === undefined) { return exports.FILE_SYSTEM_ADAPTER; } return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods); }
IS `true` for Node.js 10.10 and greater.
createFileSystemAdapter
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(_options = {}) { this._options = _options; this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); this.fs = fs_1$3.createFileSystemAdapter(this._options.fs); this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path$2.sep); this.stats = this._getValue(this._options.stats, false); this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); this.fsStatSettings = new out.Settings({ followSymbolicLink: this.followSymbolicLinks, fs: this.fs, throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink }); }
IS `true` for Node.js 10.10 and greater.
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
_getValue(option, value) { return option === undefined ? value : option; }
IS `true` for Node.js 10.10 and greater.
_getValue
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 scandir(path, optionsOrSettingsOrCallback, callback) { if (typeof optionsOrSettingsOrCallback === 'function') { return async$2.read(path, getSettings(), optionsOrSettingsOrCallback); } async$2.read(path, getSettings(optionsOrSettingsOrCallback), callback); }
IS `true` for Node.js 10.10 and greater.
scandir
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 scandirSync(path, optionsOrSettings) { const settings = getSettings(optionsOrSettings); return sync$2.read(path, settings); }
IS `true` for Node.js 10.10 and greater.
scandirSync
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 getSettings(settingsOrOptions = {}) { if (settingsOrOptions instanceof settings$1.default) { return settingsOrOptions; } return new settings$1.default(settingsOrOptions); }
IS `true` for Node.js 10.10 and greater.
getSettings
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 reusify(Constructor) { var head = new Constructor(); var tail = head; function get() { var current = head; if (current.next) { head = current.next; } else { head = new Constructor(); tail = head; } current.next = null; return current; } function release(obj) { tail.next = obj; tail = obj; } return { get: get, release: release }; }
IS `true` for Node.js 10.10 and greater.
reusify
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 get() { var current = head; if (current.next) { head = current.next; } else { head = new Constructor(); tail = head; } current.next = null; return current; }
IS `true` for Node.js 10.10 and greater.
get
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 release(obj) { tail.next = obj; tail = obj; }
IS `true` for Node.js 10.10 and greater.
release
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 fastqueue(context, worker, concurrency) { if (typeof context === 'function') { concurrency = worker; worker = context; context = null; } var cache = reusify_1(Task); var queueHead = null; var queueTail = null; var _running = 0; var self = { push: push, drain: noop$1, saturated: noop$1, pause: pause, paused: false, concurrency: concurrency, running: running, resume: resume, idle: idle, length: length, unshift: unshift, empty: noop$1, kill: kill, killAndDrain: killAndDrain }; return self; function running() { return _running; } function pause() { self.paused = true; } function length() { var current = queueHead; var counter = 0; while (current) { current = current.next; counter++; } return counter; } function resume() { if (!self.paused) return; self.paused = false; for (var i = 0; i < self.concurrency; i++) { _running++; release(); } } function idle() { return _running === 0 && self.length() === 0; } function push(value, done) { var current = cache.get(); current.context = context; current.release = release; current.value = value; current.callback = done || noop$1; if (_running === self.concurrency || self.paused) { if (queueTail) { queueTail.next = current; queueTail = current; } else { queueHead = current; queueTail = current; self.saturated(); } } else { _running++; worker.call(context, current.value, current.worked); } } function unshift(value, done) { var current = cache.get(); current.context = context; current.release = release; current.value = value; current.callback = done || noop$1; if (_running === self.concurrency || self.paused) { if (queueHead) { current.next = queueHead; queueHead = current; } else { queueHead = current; queueTail = current; self.saturated(); } } else { _running++; worker.call(context, current.value, current.worked); } } function release(holder) { if (holder) { cache.release(holder); } var next = queueHead; if (next) { if (!self.paused) { if (queueTail === queueHead) { queueTail = null; } queueHead = next.next; next.next = null; worker.call(context, next.value, next.worked); if (queueTail === null) { self.empty(); } } else { _running--; } } else if (--_running === 0) { self.drain(); } } function kill() { queueHead = null; queueTail = null; self.drain = noop$1; } function killAndDrain() { queueHead = null; queueTail = null; self.drain(); self.drain = noop$1; } }
IS `true` for Node.js 10.10 and greater.
fastqueue
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 running() { return _running; }
IS `true` for Node.js 10.10 and greater.
running
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 pause() { self.paused = true; }
IS `true` for Node.js 10.10 and greater.
pause
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 length() { var current = queueHead; var counter = 0; while (current) { current = current.next; counter++; } return counter; }
IS `true` for Node.js 10.10 and greater.
length
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 resume() { if (!self.paused) return; self.paused = false; for (var i = 0; i < self.concurrency; i++) { _running++; release(); } }
IS `true` for Node.js 10.10 and greater.
resume
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 idle() { return _running === 0 && self.length() === 0; }
IS `true` for Node.js 10.10 and greater.
idle
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 push(value, done) { var current = cache.get(); current.context = context; current.release = release; current.value = value; current.callback = done || noop$1; if (_running === self.concurrency || self.paused) { if (queueTail) { queueTail.next = current; queueTail = current; } else { queueHead = current; queueTail = current; self.saturated(); } } else { _running++; worker.call(context, current.value, current.worked); } }
IS `true` for Node.js 10.10 and greater.
push
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 unshift(value, done) { var current = cache.get(); current.context = context; current.release = release; current.value = value; current.callback = done || noop$1; if (_running === self.concurrency || self.paused) { if (queueHead) { current.next = queueHead; queueHead = current; } else { queueHead = current; queueTail = current; self.saturated(); } } else { _running++; worker.call(context, current.value, current.worked); } }
IS `true` for Node.js 10.10 and greater.
unshift
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 release(holder) { if (holder) { cache.release(holder); } var next = queueHead; if (next) { if (!self.paused) { if (queueTail === queueHead) { queueTail = null; } queueHead = next.next; next.next = null; worker.call(context, next.value, next.worked); if (queueTail === null) { self.empty(); } } else { _running--; } } else if (--_running === 0) { self.drain(); } }
IS `true` for Node.js 10.10 and greater.
release
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 kill() { queueHead = null; queueTail = null; self.drain = noop$1; }
IS `true` for Node.js 10.10 and greater.
kill
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 killAndDrain() { queueHead = null; queueTail = null; self.drain(); self.drain = noop$1; }
IS `true` for Node.js 10.10 and greater.
killAndDrain
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 Task() { this.value = null; this.callback = noop$1; this.next = null; this.release = noop$1; this.context = null; var self = this; this.worked = function worked(err, result) { var callback = self.callback; self.value = null; self.callback = noop$1; callback.call(self.context, err, result); self.release(self); }; }
IS `true` for Node.js 10.10 and greater.
Task
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 isFatalError(settings, error) { if (settings.errorFilter === null) { return true; } return !settings.errorFilter(error); }
IS `true` for Node.js 10.10 and greater.
isFatalError
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 isAppliedFilter(filter, value) { return filter === null || filter(value); }
IS `true` for Node.js 10.10 and greater.
isAppliedFilter
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 replacePathSegmentSeparator(filepath, separator) { return filepath.split(/[\\/]/).join(separator); }
IS `true` for Node.js 10.10 and greater.
replacePathSegmentSeparator
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