code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function Chalk(options) { // We check for this.template here since calling `chalk.constructor()` // by itself will have a `this` of a previously constructed chalk object if (!this || !(this instanceof Chalk) || this.template) { const chalk = {}; applyOptions(chalk, options); chalk.template = function () { const args = [].slice.call(arguments); return chalkTag.apply(null, [chalk.template].concat(args)); }; Object.setPrototypeOf(chalk, Chalk.prototype); Object.setPrototypeOf(chalk.template, chalk); chalk.template.constructor = Chalk; return chalk.template; } applyOptions(this, options); } // Use bright blue on Windows as the normal blue color is illegible
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
Chalk
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { const codes = ansiStyles$2[key]; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { return build.call(this, this._styles || [], true, 'visible'); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { const level = this.level; return function () { const open = ansiStyles$2.color[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles$2.color.close, closeRe: ansiStyles$2.color.closeRe }; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { const level = this.level; return function () { const open = ansiStyles$2.bgColor[levelMapping[level]][model].apply(null, arguments); const codes = { open, close: ansiStyles$2.bgColor.close, closeRe: ansiStyles$2.bgColor.closeRe }; return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function build(_styles, _empty, key) { const builder = function builder() { return applyStyle.apply(builder, arguments); }; builder._styles = _styles; builder._empty = _empty; const self = this; Object.defineProperty(builder, 'level', { enumerable: true, get() { return self.level; }, set(level) { self.level = level; } }); Object.defineProperty(builder, 'enabled', { enumerable: true, get() { return self.enabled; }, set(enabled) { self.enabled = enabled; } }); // See below for fix regarding invisible grey/dim combination on Windows builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is // no way to create a function with a different prototype builder.__proto__ = proto; // eslint-disable-line no-proto return builder; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
build
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
builder = function builder() { return applyStyle.apply(builder, arguments); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
builder
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
builder = function builder() { return applyStyle.apply(builder, arguments); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
builder
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { return self.level; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
set(level) { self.level = level; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
set
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { return self.enabled; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
set(enabled) { self.enabled = enabled; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
set
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function applyStyle() { // Support varags, but simply cast to string in case there's only one arg const args = arguments; const argsLen = args.length; let str = String(arguments[0]); if (argsLen === 0) { return ''; } if (argsLen > 1) { // Don't slice `arguments`, it prevents V8 optimizations for (let a = 1; a < argsLen; a++) { str += ' ' + args[a]; } } if (!this.enabled || this.level <= 0 || !str) { return this._empty ? '' : str; } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, // see https://github.com/chalk/chalk/issues/58 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. const originalDim = ansiStyles$2.dim.open; if (isSimpleWindowsTerm && this.hasGrey) { ansiStyles$2.dim.open = ''; } for (const code of this._styles.slice().reverse()) { // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen // after next line to fix a bleed issue on macOS // https://github.com/chalk/chalk/pull/92 str = str.replace(/\r?\n/g, "".concat(code.close, "$&").concat(code.open)); } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue ansiStyles$2.dim.open = originalDim; return str; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
applyStyle
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function chalkTag(chalk, strings) { if (!Array.isArray(strings)) { // If chalk() was called by itself or with a string, // return the string itself as a string. return [].slice.call(arguments, 1).join(' '); } const args = [].slice.call(arguments, 2); const parts = [strings.raw[0]]; for (let i = 1; i < strings.length; i++) { parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); parts.push(String(strings.raw[i])); } return templates$2(chalk, parts.join('')); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
chalkTag
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_interopRequireDefault
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_getRequireWildcardCache
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_interopRequireWildcard
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getDefs(chalk) { return { keyword: chalk.cyan, capitalized: chalk.yellow, jsx_tag: chalk.yellow, punctuator: chalk.yellow, number: chalk.magenta, string: chalk.green, regex: chalk.magenta, comment: chalk.grey, invalid: chalk.white.bgRed.bold }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getDefs
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getTokenType(match) { const [offset, text] = match.slice(-2); const token = (0, _jsTokens.matchToToken)(match); if (token.type === "name") { if (_esutils.default.keyword.isReservedWordES6(token.value)) { return "keyword"; } if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { return "jsx_tag"; } if (token.value[0] !== token.value[0].toLowerCase()) { return "capitalized"; } } if (token.type === "punctuator" && BRACKET.test(token.value)) { return "bracket"; } if (token.type === "invalid" && (token.value === "@" || token.value === "#")) { return "punctuator"; } return token.type; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getTokenType
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function highlightTokens(defs, text) { return text.replace(_jsTokens.default, function (...args) { const type = getTokenType(args); const colorize = defs[type]; if (colorize) { return args[0].split(NEWLINE).map(str => colorize(str)).join("\n"); } else { return args[0]; } }); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
highlightTokens
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function shouldHighlight(options) { return _chalk.default.supportsColor || options.forceColor; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
shouldHighlight
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getChalk(options) { let chalk = _chalk.default; if (options.forceColor) { chalk = new _chalk.default.constructor({ enabled: true, level: 1 }); } return chalk; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getChalk
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function highlight(code, options = {}) { if (shouldHighlight(options)) { const chalk = getChalk(options); const defs = getDefs(chalk); return highlightTokens(defs, code); } else { return code; } }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
highlight
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_getRequireWildcardCache
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_interopRequireWildcard
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getDefs(chalk) { return { gutter: chalk.grey, marker: chalk.red.bold, message: chalk.red.bold }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getDefs
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getMarkerLines(loc, source, opts) { const startLoc = Object.assign({ column: 0, line: -1 }, loc.start); const endLoc = Object.assign({}, startLoc, {}, loc.end); const { linesAbove = 2, linesBelow = 3 } = opts || {}; const startLine = startLoc.line; const startColumn = startLoc.column; const endLine = endLoc.line; const endColumn = endLoc.column; let start = Math.max(startLine - (linesAbove + 1), 0); let end = Math.min(source.length, endLine + linesBelow); if (startLine === -1) { start = 0; } if (endLine === -1) { end = source.length; } const lineDiff = endLine - startLine; const markerLines = {}; if (lineDiff) { for (let i = 0; i <= lineDiff; i++) { const lineNumber = i + startLine; if (!startColumn) { markerLines[lineNumber] = true; } else if (i === 0) { const sourceLength = source[lineNumber - 1].length; markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; } else if (i === lineDiff) { markerLines[lineNumber] = [0, endColumn]; } else { const sourceLength = source[lineNumber - i].length; markerLines[lineNumber] = [0, sourceLength]; } } } else { if (startColumn === endColumn) { if (startColumn) { markerLines[startLine] = [startColumn, 0]; } else { markerLines[startLine] = true; } } else { markerLines[startLine] = [startColumn, endColumn - startColumn]; } } return { start, end, markerLines }; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getMarkerLines
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function codeFrameColumns(rawLines, loc, opts = {}) { const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); const chalk = (0, _highlight.getChalk)(opts); const defs = getDefs(chalk); const maybeHighlight = (chalkFn, string) => { return highlighted ? chalkFn(string) : string; }; const lines = rawLines.split(NEWLINE); const { start, end, markerLines } = getMarkerLines(loc, lines, opts); const hasColumns = loc.start && typeof loc.start.column === "number"; const numberMaxWidth = String(end).length; const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => { const number = start + 1 + index; const paddedNumber = " ".concat(number).slice(-numberMaxWidth); const gutter = " ".concat(paddedNumber, " | "); const hasMarker = markerLines[number]; const lastMarkerLine = !markerLines[number + 1]; if (hasMarker) { let markerLine = ""; if (Array.isArray(hasMarker)) { const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " "); const numberOfMarkers = hasMarker[1] || 1; markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join(""); if (lastMarkerLine && opts.message) { markerLine += " " + maybeHighlight(defs.message, opts.message); } } return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); } else { return " ".concat(maybeHighlight(defs.gutter, gutter)).concat(line); } }).join("\n"); if (opts.message && !hasColumns) { frame = "".concat(" ".repeat(numberMaxWidth + 1)).concat(opts.message, "\n").concat(frame); } if (highlighted) { return chalk.reset(frame); } else { return frame; } }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
codeFrameColumns
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
maybeHighlight = (chalkFn, string) => { return highlighted ? chalkFn(string) : string; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
maybeHighlight
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
maybeHighlight = (chalkFn, string) => { return highlighted ? chalkFn(string) : string; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
maybeHighlight
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function _default(rawLines, lineNumber, colNumber, opts = {}) { if (!deprecationWarningShown) { deprecationWarningShown = true; const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`."; if (process.emitWarning) { process.emitWarning(message, "DeprecationWarning"); } else { const deprecationError = new Error(message); deprecationError.name = "DeprecationWarning"; console.warn(new Error(message)); } } colNumber = Math.max(colNumber, 0); const location = { start: { column: colNumber, line: lineNumber } }; return codeFrameColumns(rawLines, location, opts); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
_default
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getParsers(options) { const parsers = {}; for (const plugin of options.plugins) { if (!plugin.parsers) { continue; } for (const name of ownNames(plugin.parsers)) { Object.defineProperty(parsers, name, ownDescriptor(plugin.parsers, name)); } } return parsers; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getParsers
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function resolveParser(opts, parsers) { parsers = parsers || getParsers(opts); if (typeof opts.parser === "function") { // Custom parser API always works with JavaScript. return { parse: opts.parser, astFormat: "estree", locStart: locStart$1, locEnd: locEnd$1 }; } if (typeof opts.parser === "string") { if (Object.prototype.hasOwnProperty.call(parsers, opts.parser)) { return parsers[opts.parser]; } /* istanbul ignore next */ { throw new ConfigError$1("Couldn't resolve parser \"".concat(opts.parser, "\". Parsers must be explicitly added to the standalone bundle.")); } } }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
resolveParser
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function parse(text, opts) { const parsers = getParsers(opts); // Create a new object {parserName: parseFn}. Uses defineProperty() to only call // the parsers getters when actually calling the parser `parse` function. const parsersForCustomParserApi = Object.keys(parsers).reduce((object, parserName) => Object.defineProperty(object, parserName, { enumerable: true, get() { return parsers[parserName].parse; } }), {}); const parser = resolveParser(opts, parsers); try { if (parser.preprocess) { text = parser.preprocess(text, opts); } return { text, ast: parser.parse(text, parsersForCustomParserApi, opts) }; } catch (error) { const { loc } = error; if (loc) { const codeFrame = lib$2; error.codeFrame = codeFrame.codeFrameColumns(text, loc, { highlightCode: true }); error.message += "\n" + error.codeFrame; throw error; } /* istanbul ignore next */ throw error.stack; } }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
parse
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
get() { return parsers[parserName].parse; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
get
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function normalize$1(options, opts) { opts = opts || {}; const rawOptions = Object.assign({}, options); const supportOptions = getSupportInfo$1({ plugins: options.plugins, showUnreleased: true, showDeprecated: true }).options; const defaults = Object.assign(Object.assign({}, hiddenDefaults), fromPairs_1(supportOptions.filter(optionInfo => optionInfo.default !== undefined).map(option => [option.name, option.default]))); if (!rawOptions.parser) { if (!rawOptions.filepath) { const logger = opts.logger || console; logger.warn("No parser and no filepath given, using 'babel' the parser now " + "but this will throw an error in the future. " + "Please specify a parser or a filepath so one can be inferred."); rawOptions.parser = "babel"; } else { rawOptions.parser = inferParser(rawOptions.filepath, rawOptions.plugins); if (!rawOptions.parser) { throw new UndefinedParserError$1("No parser could be inferred for file: ".concat(rawOptions.filepath)); } } } const parser = resolveParser$1(optionsNormalizer.normalizeApiOptions(rawOptions, [supportOptions.find(x => x.name === "parser")], { passThrough: true, logger: false })); rawOptions.astFormat = parser.astFormat; rawOptions.locEnd = parser.locEnd; rawOptions.locStart = parser.locStart; const plugin = getPlugin(rawOptions); rawOptions.printer = plugin.printers[rawOptions.astFormat]; const pluginDefaults = supportOptions.filter(optionInfo => optionInfo.pluginDefaults && optionInfo.pluginDefaults[plugin.name] !== undefined).reduce((reduced, optionInfo) => Object.assign(reduced, { [optionInfo.name]: optionInfo.pluginDefaults[plugin.name] }), {}); const mixedDefaults = Object.assign(Object.assign({}, defaults), pluginDefaults); Object.keys(mixedDefaults).forEach(k => { if (rawOptions[k] == null) { rawOptions[k] = mixedDefaults[k]; } }); if (rawOptions.parser === "json") { rawOptions.trailingComma = "none"; } return optionsNormalizer.normalizeApiOptions(rawOptions, supportOptions, Object.assign({ passThrough: Object.keys(hiddenDefaults) }, opts)); }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
normalize$1
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getPlugin(options) { const { astFormat } = options; if (!astFormat) { throw new Error("getPlugin() requires astFormat to be set"); } const printerPlugin = options.plugins.find(plugin => plugin.printers && plugin.printers[astFormat]); if (!printerPlugin) { throw new Error("Couldn't find plugin for AST format \"".concat(astFormat, "\"")); } return printerPlugin; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getPlugin
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getInterpreter(filepath) { if (typeof filepath !== "string") { return ""; } let fd; try { fd = fs.openSync(filepath, "r"); } catch (err) { // istanbul ignore next return ""; } try { const liner = new readlines(fd); const firstLine = liner.next().toString("utf8"); // #!/bin/env node, #!/usr/bin/env node const m1 = firstLine.match(/^#!\/(?:usr\/)?bin\/env\s+(\S+)/); if (m1) { return m1[1]; } // #!/bin/node, #!/usr/bin/node, #!/usr/local/bin/node const m2 = firstLine.match(/^#!\/(?:usr\/(?:local\/)?)?bin\/(\S+)/); if (m2) { return m2[1]; } return ""; } catch (err) { // There are some weird cases where paths are missing, causing Jest // failures. It's unclear what these correspond to in the real world. return ""; } finally { try { // There are some weird cases where paths are missing, causing Jest // failures. It's unclear what these correspond to in the real world. fs.closeSync(fd); } catch (err) {// nop } } }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
getInterpreter
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function inferParser(filepath, plugins) { const filename = path.basename(filepath).toLowerCase(); const languages = getSupportInfo$1({ plugins }).languages.filter(language => language.since !== null); // If the file has no extension, we can try to infer the language from the // interpreter in the shebang line, if any; but since this requires FS access, // do it last. let language = languages.find(language => language.extensions && language.extensions.some(extension => filename.endsWith(extension)) || language.filenames && language.filenames.find(name => name.toLowerCase() === filename)); if (!language && !filename.includes(".")) { const interpreter = getInterpreter(filepath); language = languages.find(language => language.interpreters && language.interpreters.includes(interpreter)); } return language && language.parsers[0]; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
inferParser
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function massageAST(ast, options, parent) { if (Array.isArray(ast)) { return ast.map(e => massageAST(e, options, parent)).filter(Boolean); } if (!ast || typeof ast !== "object") { return ast; } const newObj = {}; for (const key of Object.keys(ast)) { if (typeof ast[key] !== "function") { newObj[key] = massageAST(ast[key], options, ast); } } if (options.printer.massageAstNode) { const result = options.printer.massageAstNode(ast, newObj, parent); if (result === null) { return undefined; } if (result) { return result; } } return newObj; }
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
massageAST
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function align(n, contents) { return { type: "align", contents, n }; }
@param {number} n @param {Doc} contents @returns Doc
align
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function group(contents, opts) { opts = opts || {}; return { type: "group", id: opts.id, contents, break: !!opts.shouldBreak, expandedStates: opts.expandedStates }; }
@param {Doc} contents @param {object} [opts] - TBD ??? @returns Doc
group
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function conditionalGroup(states, opts) { return group(states[0], Object.assign(Object.assign({}, opts), {}, { expandedStates: states })); }
@param {Doc[]} states @param {object} [opts] - TBD ??? @returns Doc
conditionalGroup
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function ifBreak(breakContents, flatContents, opts) { opts = opts || {}; return { type: "if-break", breakContents, flatContents, groupId: opts.groupId }; }
@param {Doc} [breakContents] @param {Doc} [flatContents] @param {object} [opts] - TBD ??? @returns Doc
ifBreak
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function join(sep, arr) { const res = []; for (let i = 0; i < arr.length; i++) { if (i !== 0) { res.push(sep); } res.push(arr[i]); } return concat(res); }
@param {Doc} sep @param {Doc[]} arr @returns Doc
join
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function addAlignmentToDoc(doc, size, tabWidth) { let aligned = doc; if (size > 0) { // Use indent to add tabs for all the levels of tabs we need for (let i = 0; i < Math.floor(size / tabWidth); ++i) { aligned = indent(aligned); } // Use align for all the spaces that are needed aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current // indentation, so we use -Infinity to reset the indentation to 0 aligned = align(-Infinity, aligned); } return aligned; }
@param {Doc} doc @param {number} size @param {number} tabWidth
addAlignmentToDoc
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
ansiRegex = ({ onlyFirst = false } = {}) => { const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|'); return new RegExp(pattern, onlyFirst ? undefined : 'g'); }
@param {Doc} doc @param {number} size @param {number} tabWidth
ansiRegex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
isFullwidthCodePoint = codePoint => { if (Number.isNaN(codePoint)) { return false; } // Code points are derived from: // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane 0x20000 <= codePoint && codePoint <= 0x3FFFD)) { return true; } return false; }
@param {Doc} doc @param {number} size @param {number} tabWidth
isFullwidthCodePoint
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
isFullwidthCodePoint = codePoint => { if (Number.isNaN(codePoint)) { return false; } // Code points are derived from: // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET // CJK Radicals Supplement .. Enclosed CJK Letters and Months 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane 0x20000 <= codePoint && codePoint <= 0x3FFFD)) { return true; } return false; }
@param {Doc} doc @param {number} size @param {number} tabWidth
isFullwidthCodePoint
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
emojiRegex = function emojiRegex() { // https://mths.be/emoji return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; }
@param {Doc} doc @param {number} size @param {number} tabWidth
emojiRegex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
stringWidth = string => { string = string.replace(emojiRegex(), ' '); if (typeof string !== 'string' || string.length === 0) { return 0; } string = stripAnsi(string); let width = 0; for (let i = 0; i < string.length; i++) { const code = string.codePointAt(i); // Ignore control characters if (code <= 0x1F || code >= 0x7F && code <= 0x9F) { continue; } // Ignore combining characters if (code >= 0x300 && code <= 0x36F) { continue; } // Surrogates if (code > 0xFFFF) { i++; } width += isFullwidthCodePoint_1(code) ? 2 : 1; } return width; }
@param {Doc} doc @param {number} size @param {number} tabWidth
stringWidth
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
stringWidth = string => { string = string.replace(emojiRegex(), ' '); if (typeof string !== 'string' || string.length === 0) { return 0; } string = stripAnsi(string); let width = 0; for (let i = 0; i < string.length; i++) { const code = string.codePointAt(i); // Ignore control characters if (code <= 0x1F || code >= 0x7F && code <= 0x9F) { continue; } // Ignore combining characters if (code >= 0x300 && code <= 0x36F) { continue; } // Surrogates if (code > 0xFFFF) { i++; } width += isFullwidthCodePoint_1(code) ? 2 : 1; } return width; }
@param {Doc} doc @param {number} size @param {number} tabWidth
stringWidth
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getPenultimate(arr) { if (arr.length > 1) { return arr[arr.length - 2]; } return null; }
@param {Doc} doc @param {number} size @param {number} tabWidth
getPenultimate
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function skip(chars) { return (text, index, opts) => { const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having // to check for failures (did someone say monads?). if (index === false) { return false; } const { length } = text; let cursor = index; while (cursor >= 0 && cursor < length) { const c = text.charAt(cursor); if (chars instanceof RegExp) { if (!chars.test(c)) { return cursor; } } else if (!chars.includes(c)) { return cursor; } backwards ? cursor-- : cursor++; } if (cursor === -1 || cursor === length) { // If we reached the beginning or end of the file, return the // out-of-bounds cursor. It's up to the caller to handle this // correctly. We don't want to indicate `false` though if it // actually skipped valid characters. return cursor; } return false; }; }
@param {string | RegExp} chars @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
skip
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function skipInlineComment(text, index) { if (index === false) { return false; } if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") { for (let i = index + 2; i < text.length; ++i) { if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") { return i + 2; } } } return index; }
@param {string} text @param {number | false} index @returns {number | false}
skipInlineComment
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function skipTrailingComment(text, index) { if (index === false) { return false; } if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") { return skipEverythingButNewLine(text, index); } return index; }
@param {string} text @param {number | false} index @returns {number | false}
skipTrailingComment
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function skipNewline(text, index, opts) { const backwards = opts && opts.backwards; if (index === false) { return false; } const atIndex = text.charAt(index); if (backwards) { if (text.charAt(index - 1) === "\r" && atIndex === "\n") { return index - 2; } if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { return index - 1; } } else { if (atIndex === "\r" && text.charAt(index + 1) === "\n") { return index + 2; } if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { return index + 1; } } return index; }
@param {string} text @param {number | false} index @param {SkipOptions=} opts @returns {number | false}
skipNewline
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function hasNewline(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); const idx2 = skipNewline(text, idx, opts); return idx !== idx2; }
@param {string} text @param {number} index @param {SkipOptions=} opts @returns {boolean}
hasNewline
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function hasNewlineInRange(text, start, end) { for (let i = start; i < end; ++i) { if (text.charAt(i) === "\n") { return true; } } return false; }
@param {string} text @param {number} start @param {number} end @returns {boolean}
hasNewlineInRange
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function isPreviousLineEmpty(text, node, locStart) { /** @type {number | false} */ let idx = locStart(node) - 1; idx = skipSpaces(text, idx, { backwards: true }); idx = skipNewline(text, idx, { backwards: true }); idx = skipSpaces(text, idx, { backwards: true }); const idx2 = skipNewline(text, idx, { backwards: true }); return idx !== idx2; }
@template N @param {string} text @param {N} node @param {(node: N) => number} locStart
isPreviousLineEmpty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function isNextLineEmptyAfterIndex(text, index) { /** @type {number | false} */ let oldIdx = null; /** @type {number | false} */ let idx = index; while (idx !== oldIdx) { // We need to skip all the potential trailing inline comments oldIdx = idx; idx = skipToLineEnd(text, idx); idx = skipInlineComment(text, idx); idx = skipSpaces(text, idx); } idx = skipTrailingComment(text, idx); idx = skipNewline(text, idx); return idx !== false && hasNewline(text, idx); }
@param {string} text @param {number} index @returns {boolean}
isNextLineEmptyAfterIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function isNextLineEmpty(text, node, locEnd) { return isNextLineEmptyAfterIndex(text, locEnd(node)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {boolean}
isNextLineEmpty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) { /** @type {number | false} */ let oldIdx = null; /** @type {number | false} */ let nextIdx = idx; while (nextIdx !== oldIdx) { oldIdx = nextIdx; nextIdx = skipSpaces(text, nextIdx); nextIdx = skipInlineComment(text, nextIdx); nextIdx = skipTrailingComment(text, nextIdx); nextIdx = skipNewline(text, nextIdx); } return nextIdx; }
@param {string} text @param {number} idx @returns {number | false}
getNextNonSpaceNonCommentCharacterIndexWithStartIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) { return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {number | false}
getNextNonSpaceNonCommentCharacterIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getNextNonSpaceNonCommentCharacter(text, node, locEnd) { return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback? getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {string}
getNextNonSpaceNonCommentCharacter
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function hasSpaces(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); return idx !== index; }
@param {string} text @param {number} index @param {SkipOptions=} opts @returns {boolean}
hasSpaces
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function setLocStart(node, index) { if (node.range) { node.range[0] = index; } else { node.start = index; } }
@param {{range?: [number, number], start?: number}} node @param {number} index
setLocStart
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function setLocEnd(node, index) { if (node.range) { node.range[1] = index; } else { node.end = index; } }
@param {{range?: [number, number], end?: number}} node @param {number} index
setLocEnd
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getPrecedence(op) { return PRECEDENCE[op]; }
@param {{range?: [number, number], end?: number}} node @param {number} index
getPrecedence
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function shouldFlatten(parentOp, nodeOp) { if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) { return false; } // ** is right-associative // x ** y ** z --> x ** (y ** z) if (parentOp === "**") { return false; } // x == y == z --> (x == y) == z if (equalityOperators[parentOp] && equalityOperators[nodeOp]) { return false; } // x * y % z --> (x * y) % z if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) { return false; } // x * y / z --> (x * y) / z // x / y * z --> (x / y) * z if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) { return false; } // x << y << z --> (x << y) << z if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) { return false; } return true; }
@param {{range?: [number, number], end?: number}} node @param {number} index
shouldFlatten
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function isBitwiseOperator(operator) { return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&"; } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
@param {{range?: [number, number], end?: number}} node @param {number} index
isBitwiseOperator
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) { node = getLeftMost(node); switch (node.type) { case "FunctionExpression": case "ClassExpression": case "DoExpression": return forbidFunctionClassAndDoExpr; case "ObjectExpression": return true; case "MemberExpression": case "OptionalMemberExpression": return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); case "TaggedTemplateExpression": if (node.tag.type === "FunctionExpression") { // IIFEs are always already parenthesized return false; } return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr); case "CallExpression": case "OptionalCallExpression": if (node.callee.type === "FunctionExpression") { // IIFEs are always already parenthesized return false; } return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr); case "ConditionalExpression": return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr); case "UpdateExpression": return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr); case "BindExpression": return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); case "SequenceExpression": return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr); case "TSAsExpression": return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr); default: return false; } }
@param {{range?: [number, number], end?: number}} node @param {number} index
startsWithNoLookaheadToken
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getLeftMost(node) { if (node.left) { return getLeftMost(node.left); } return node; }
@param {{range?: [number, number], end?: number}} node @param {number} index
getLeftMost
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getAlignmentSize(value, tabWidth, startIndex) { startIndex = startIndex || 0; let size = 0; for (let i = startIndex; i < value.length; ++i) { if (value[i] === "\t") { // Tabs behave in a way that they are aligned to the nearest // multiple of tabWidth: // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4 // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ... size = size + tabWidth - size % tabWidth; } else { size++; } } return size; }
@param {string} value @param {number} tabWidth @param {number=} startIndex @returns {number}
getAlignmentSize
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getIndentSize(value, tabWidth) { const lastNewlineIndex = value.lastIndexOf("\n"); if (lastNewlineIndex === -1) { return 0; } return getAlignmentSize( // All the leading whitespaces value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth); }
@param {string} value @param {number} tabWidth @returns {number}
getIndentSize
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getPreferredQuote(raw, preferredQuote) { // `rawContent` is the string exactly like it appeared in the input source // code, without its enclosing quotes. const rawContent = raw.slice(1, -1); /** @type {{ quote: '"', regex: RegExp }} */ const double = { quote: '"', regex: /"/g }; /** @type {{ quote: "'", regex: RegExp }} */ const single = { quote: "'", regex: /'/g }; const preferred = preferredQuote === "'" ? single : double; const alternate = preferred === single ? double : single; let result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing // the string, we might want to enclose with the alternate quote instead, to // minimize the number of escaped quotes. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) { const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length; const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length; result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote; } return result; }
@param {string} raw @param {Quote} preferredQuote @returns {Quote}
getPreferredQuote
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) { const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double). const regex = /\\([\S\s])|(["'])/g; // Escape and unescape single and double quotes as needed to be able to // enclose `rawContent` with `enclosingQuote`. const newContent = rawContent.replace(regex, (match, escaped, quote) => { // If we matched an escape, and the escaped character is a quote of the // other type than we intend to enclose the string with, there's no need for // it to be escaped, so return it _without_ the backslash. if (escaped === otherQuote) { return escaped; } // If we matched an unescaped quote and it is of the _same_ type as we // intend to enclose the string with, it must be escaped, so return it with // a backslash. if (quote === enclosingQuote) { return "\\" + quote; } if (quote) { return quote; } // Unescape any unnecessarily escaped character. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27 return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped; }); return enclosingQuote + newContent + enclosingQuote; }
@param {string} rawContent @param {Quote} enclosingQuote @param {boolean=} unescapeUnnecessaryEscapes @returns {string}
makeString
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printNumber(rawNumber) { return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0). .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot. .replace(/\.(?=e|$)/, ""); }
@param {string} rawContent @param {Quote} enclosingQuote @param {boolean=} unescapeUnnecessaryEscapes @returns {string}
printNumber
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getMaxContinuousCount(str, target) { const results = str.match(new RegExp("(".concat(escapeStringRegexp$2(target), ")+"), "g")); if (results === null) { return 0; } return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0); }
@param {string} str @param {string} target @returns {number}
getMaxContinuousCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getMinNotPresentContinuousCount(str, target) { const matches = str.match(new RegExp("(".concat(escapeStringRegexp$2(target), ")+"), "g")); if (matches === null) { return 0; } const countPresent = new Map(); let max = 0; for (const match of matches) { const count = match.length / target.length; countPresent.set(count, true); if (count > max) { max = count; } } for (let i = 1; i < max; i++) { if (!countPresent.get(i)) { return i; } } return max + 1; }
@param {string} str @param {string} target @returns {number}
getMinNotPresentContinuousCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
match(...predicates) { let stackPointer = this.stack.length - 1; let name = null; let node = this.stack[stackPointer--]; for (const predicate of predicates) { if (node === undefined) { return false; } // skip index/array let number = null; if (typeof name === "number") { number = name; name = this.stack[stackPointer--]; node = this.stack[stackPointer--]; } if (predicate && !predicate(node, name, number)) { return false; } name = this.stack[stackPointer--]; node = this.stack[stackPointer--]; } return true; }
@param {...( | ((node: any, name: string | null, number: number | null) => boolean) | undefined )} predicates
match
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printSubtree(path, print, options, printAstToDoc) { if (options.printer.embed && options.embeddedLanguageFormatting === "auto") { return options.printer.embed(path, print, (text, partialNextOptions) => textToDoc(text, partialNextOptions, options, printAstToDoc), options); } }
@param {...( | ((node: any, name: string | null, number: number | null) => boolean) | undefined )} predicates
printSubtree
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function textToDoc(text, partialNextOptions, parentOptions, printAstToDoc) { const nextOptions = normalize$2(Object.assign(Object.assign(Object.assign({}, parentOptions), partialNextOptions), {}, { parentParser: parentOptions.parser, embeddedInHtml: !!(parentOptions.embeddedInHtml || parentOptions.parser === "html" || parentOptions.parser === "vue" || parentOptions.parser === "angular" || parentOptions.parser === "lwc"), originalText: text }), { passThrough: true }); const result = parser.parse(text, nextOptions); const { ast } = result; text = result.text; const astComments = ast.comments; delete ast.comments; comments.attach(astComments, ast, text, nextOptions); return printAstToDoc(ast, nextOptions); }
@param {...( | ((node: any, name: string | null, number: number | null) => boolean) | undefined )} predicates
textToDoc
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function replaceQuotesInInlineComments(text) { /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */ /** @type {State} */ let state = "initial"; /** @type {State} */ let stateToReturnFromQuotes = "initial"; let inlineCommentStartIndex; let inlineCommentContainsQuotes = false; const inlineCommentsToReplace = []; for (let i = 0; i < text.length; i++) { const c = text[i]; switch (state) { case "initial": if (c === "'") { state = "single-quotes"; continue; } if (c === '"') { state = "double-quotes"; continue; } if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") { state = "url"; i += 3; continue; } if (c === "*" && text[i - 1] === "/") { state = "comment-block"; continue; } if (c === "/" && text[i - 1] === "/") { state = "comment-inline"; inlineCommentStartIndex = i - 1; continue; } continue; case "single-quotes": if (c === "'" && text[i - 1] !== "\\") { state = stateToReturnFromQuotes; stateToReturnFromQuotes = "initial"; } if (c === "\n" || c === "\r") { return text; // invalid input } continue; case "double-quotes": if (c === '"' && text[i - 1] !== "\\") { state = stateToReturnFromQuotes; stateToReturnFromQuotes = "initial"; } if (c === "\n" || c === "\r") { return text; // invalid input } continue; case "url": if (c === ")") { state = "initial"; } if (c === "\n" || c === "\r") { return text; // invalid input } if (c === "'") { state = "single-quotes"; stateToReturnFromQuotes = "url"; continue; } if (c === '"') { state = "double-quotes"; stateToReturnFromQuotes = "url"; continue; } continue; case "comment-block": if (c === "/" && text[i - 1] === "*") { state = "initial"; } continue; case "comment-inline": if (c === '"' || c === "'") { inlineCommentContainsQuotes = true; } if (c === "\n" || c === "\r") { if (inlineCommentContainsQuotes) { inlineCommentsToReplace.push([inlineCommentStartIndex, i]); } state = "initial"; inlineCommentContainsQuotes = false; } continue; } } for (const [start, end] of inlineCommentsToReplace) { text = text.slice(0, start) + text.slice(start, end).replace(/'/g, "\ufffe").replace(/"/g, "\uffff") + text.slice(end); } return text; }
Workaround for a bug: quotes in inline comments corrupt loc data of subsequent nodes. This function replaces the quotes with U+FFFE and U+FFFF. Later, when the comments are printed, their content is extracted from the original text or restored by replacing the placeholder characters back with quotes. - https://github.com/prettier/prettier/issues/7780 - https://github.com/shellscape/postcss-less/issues/145 - About noncharacters (U+FFFE and U+FFFF): http://www.unicode.org/faq/private_use.html#nonchar1 @param text {string}
replaceQuotesInInlineComments
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printStringLiteral(stringLiteral, options) { const double = { quote: '"', regex: /"/g }; const single = { quote: "'", regex: /'/g }; const preferred = options.singleQuote ? single : double; const alternate = preferred === single ? double : single; let shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for // enclosing the string, we might want to enclose with the alternate quote // instead, to minimize the number of escaped quotes. if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) { const numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length; const numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length; shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes; } const enclosingQuote = shouldUseAlternateQuote ? alternate : preferred; const escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, "\\".concat(enclosingQuote.quote)); return concat$7([enclosingQuote.quote, escapedStringLiteral, enclosingQuote.quote]); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printStringLiteral
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printSubExpressionPathAndParams(path, print) { const p = printPath(path, print); const params = printParams(path, print); if (!params) { return p; } return indent$4(concat$7([p, line$4, group$6(params)])); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printSubExpressionPathAndParams
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printPathAndParams(path, print) { const p = printPath(path, print); const params = printParams(path, print); if (!params) { return p; } return indent$4(group$6(concat$7([p, line$4, params]))); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printPathAndParams
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printPath(path, print) { return path.call(print, "path"); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printPath
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printParams(path, print) { const node = path.getValue(); const parts = []; if (node.params.length) { const params = path.map(print, "params"); parts.push(...params); } if (node.hash && node.hash.pairs.length > 0) { const hash = path.call(print, "hash"); parts.push(hash); } if (!parts.length) { return ""; } return join$4(line$4, parts); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printParams
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function printBlockParams(node) { if (!node || !node.blockParams.length) { return ""; } return concat$7([" as |", node.blockParams.join(" "), "|"]); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
printBlockParams
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function locationToOffset(source, line, column) { let seenLines = 0; let seenChars = 0; // eslint-disable-next-line no-constant-condition while (true) { if (seenChars === source.length) { return null; } let nextLine = source.indexOf("\n", seenChars); if (nextLine === -1) { nextLine = source.length; } if (seenLines === line) { if (seenChars + column > nextLine) { return null; } return seenChars + column; } else if (nextLine === -1) { return null; } seenLines += 1; seenChars = nextLine + 1; } }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
locationToOffset
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
clean$3 = function clean(ast, newNode) { delete newNode.sourceSpan; delete newNode.startSourceSpan; delete newNode.endSourceSpan; delete newNode.nameSpan; delete newNode.valueSpan; if (ast.type === "text" || ast.type === "comment") { return null; } // may be formatted by multiparser if (ast.type === "yaml" || ast.type === "toml") { return null; } if (ast.type === "attribute") { delete newNode.value; } if (ast.type === "docType") { delete newNode.value; } }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
clean$3
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
getLeadingAndTrailingHtmlWhitespace = string => { const [, leadingWhitespace, text, trailingWhitespace] = string.match(/^([\t\n\f\r ]*)([\S\s]*?)([\t\n\f\r ]*)$/); return { leadingWhitespace, trailingWhitespace, text }; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
getLeadingAndTrailingHtmlWhitespace
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
getLeadingAndTrailingHtmlWhitespace = string => { const [, leadingWhitespace, text, trailingWhitespace] = string.match(/^([\t\n\f\r ]*)([\S\s]*?)([\t\n\f\r ]*)$/); return { leadingWhitespace, trailingWhitespace, text }; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
getLeadingAndTrailingHtmlWhitespace
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function arrayToMap(array) { const map = Object.create(null); for (const value of array) { map[value] = true; } return map; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
arrayToMap
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function mapObject(object, fn) { const newObject = Object.create(null); for (const key of Object.keys(object)) { newObject[key] = fn(object[key], key); } return newObject; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
mapObject
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function shouldPreserveContent(node, options) { if (!node.endSourceSpan) { return false; } if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") { return true; } // unterminated node in ie conditional comment // e.g. <!--[if lt IE 9]><html><![endif]--> if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) { return true; } // incomplete html in ie conditional comment // e.g. <!--[if lt IE 9]></div><![endif]--> if (node.type === "ieConditionalComment" && !node.complete) { return true; } // TODO: handle non-text children in <pre> if (isPreLikeNode(node) && node.children.some(child => child.type !== "text" && child.type !== "interpolation")) { return true; } if (isVueCustomBlock(node, options) && (options.embeddedLanguageFormatting === "off" || !inferScriptParser(node, options))) { return true; } return false; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
shouldPreserveContent
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function hasPrettierIgnore$2(node) { if (node.type === "attribute") { return false; } if (!node.parent) { return false; } if (typeof node.index !== "number" || node.index === 0) { return false; } const prevNode = node.parent.children[node.index - 1]; return isPrettierIgnore(prevNode); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
hasPrettierIgnore$2
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function isPrettierIgnore(node) { return node.type === "comment" && node.value.trim() === "prettier-ignore"; }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
isPrettierIgnore
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0
function getPrettierIgnoreAttributeCommentData(value) { const match = value.trim().match(/^prettier-ignore-attribute(?:\s+([^]+))?$/); if (!match) { return false; } if (!match[1]) { return true; } return match[1].split(/\s+/); }
Prints a string literal with the correct surrounding quotes based on `options.singleQuote` and the number of escaped quotes contained in the string literal. This function is the glimmer equivalent of `printString` in `common/util`, but has differences because of the way escaped characters are treated in hbs string literals. @param {string} stringLiteral - the string literal value @param {object} options - the prettier options object
getPrettierIgnoreAttributeCommentData
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/standalone.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
Apache-2.0