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 splitTextIntoSentences(ast, options) {
return mapAst$1(ast, (node, index, [parentNode]) => {
if (node.type !== "text") {
return node;
}
let {
value
} = node;
if (parentNode.type === "paragraph") {
if (index === 0) {
value = value.trimStart();
}
if (index === parentNode.children.length - 1) {
value = value.trimEnd();
}
}
return {
type: "sentence",
position: node.position,
children: splitText$1(value, options)
};
});
}
|
split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
splitTextIntoSentences
|
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 transformIndentedCodeblockAndMarkItsParentList(ast, options) {
return mapAst$1(ast, (node, index, parentStack) => {
if (node.type === "code") {
// the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
const isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
node.isIndented = isIndented;
if (isIndented) {
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i]; // no need to check checked items
if (parent.hasIndentedCodeblock) {
break;
}
if (parent.type === "list") {
parent.hasIndentedCodeblock = true;
}
}
}
}
return node;
});
}
|
split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
transformIndentedCodeblockAndMarkItsParentList
|
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 markAlignedList(ast, options) {
return mapAst$1(ast, (node, index, parentStack) => {
if (node.type === "list" && node.children.length !== 0) {
// if one of its parents is not aligned, it's not possible to be aligned in sub-lists
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i];
if (parent.type === "list" && !parent.isAligned) {
node.isAligned = false;
return node;
}
}
node.isAligned = isAligned(node);
}
return node;
});
function getListItemStart(listItem) {
return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
}
function isAligned(list) {
if (!list.ordered) {
/**
* - 123
* - 123
*/
return true;
}
const [firstItem, secondItem] = list.children;
const firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText);
if (firstInfo.leadingSpaces.length > 1) {
/**
* 1. 123
*
* 1. 123
* 1. 123
*/
return true;
}
const firstStart = getListItemStart(firstItem);
if (firstStart === -1) {
/**
* 1.
*
* 1.
* 1.
*/
return false;
}
if (list.children.length === 1) {
/**
* aligned:
*
* 11. 123
*
* not aligned:
*
* 1. 123
*/
return firstStart % options.tabWidth === 0;
}
const secondStart = getListItemStart(secondItem);
if (firstStart !== secondStart) {
/**
* 11. 123
* 1. 123
*
* 1. 123
* 11. 123
*/
return false;
}
if (firstStart % options.tabWidth === 0) {
/**
* 11. 123
* 12. 123
*/
return true;
}
/**
* aligned:
*
* 11. 123
* 1. 123
*
* not aligned:
*
* 1. 123
* 2. 123
*/
const secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText);
return secondInfo.leadingSpaces.length > 1;
}
}
|
split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
markAlignedList
|
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 getListItemStart(listItem) {
return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
}
|
split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
getListItemStart
|
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 isAligned(list) {
if (!list.ordered) {
/**
* - 123
* - 123
*/
return true;
}
const [firstItem, secondItem] = list.children;
const firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText);
if (firstInfo.leadingSpaces.length > 1) {
/**
* 1. 123
*
* 1. 123
* 1. 123
*/
return true;
}
const firstStart = getListItemStart(firstItem);
if (firstStart === -1) {
/**
* 1.
*
* 1.
* 1.
*/
return false;
}
if (list.children.length === 1) {
/**
* aligned:
*
* 11. 123
*
* not aligned:
*
* 1. 123
*/
return firstStart % options.tabWidth === 0;
}
const secondStart = getListItemStart(secondItem);
if (firstStart !== secondStart) {
/**
* 11. 123
* 1. 123
*
* 1. 123
* 11. 123
*/
return false;
}
if (firstStart % options.tabWidth === 0) {
/**
* 11. 123
* 12. 123
*/
return true;
}
/**
* aligned:
*
* 11. 123
* 1. 123
*
* not aligned:
*
* 1. 123
* 2. 123
*/
const secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText);
return secondInfo.leadingSpaces.length > 1;
}
|
split text into whitespaces and words
@param {string} text
@return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
|
isAligned
|
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 isNode(value, types) {
return value && typeof value.type === "string" && (!types || types.includes(value.type));
}
|
@param {any} value
@param {string[]=} types
|
isNode
|
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 mapNode(node, callback, parent) {
return callback("children" in node ? Object.assign(Object.assign({}, node), {}, {
children: node.children.map(childNode => mapNode(childNode, callback, node))
}) : node, parent);
}
|
@param {any} value
@param {string[]=} types
|
mapNode
|
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 defineShortcut(x, key, getter) {
Object.defineProperty(x, key, {
get: getter,
enumerable: false
});
}
|
@param {any} value
@param {string[]=} types
|
defineShortcut
|
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$7(node, text) {
let newlineCount = 0;
const textLength = text.length;
for (let i = node.position.end.offset - 1; i < textLength; i++) {
const char = text[i];
if (char === "\n") {
newlineCount++;
}
if (newlineCount === 1 && /\S/.test(char)) {
return false;
}
if (newlineCount === 2) {
return true;
}
}
return false;
}
|
@param {any} value
@param {string[]=} types
|
isNextLineEmpty$7
|
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 isLastDescendantNode(path) {
const node = path.getValue();
switch (node.type) {
case "tag":
case "anchor":
case "comment":
return false;
}
const pathStackLength = path.stack.length;
for (let i = 1; i < pathStackLength; i++) {
const item = path.stack[i];
const parentItem = path.stack[i - 1];
if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
return false;
}
}
return true;
}
|
@param {any} value
@param {string[]=} types
|
isLastDescendantNode
|
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 getLastDescendantNode$1(node) {
return "children" in node && node.children.length !== 0 ? getLastDescendantNode$1(getLast$7(node.children)) : node;
}
|
@param {any} value
@param {string[]=} types
|
getLastDescendantNode$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 isPrettierIgnore$2(comment) {
return comment.value.trim() === "prettier-ignore";
}
|
@param {any} value
@param {string[]=} types
|
isPrettierIgnore$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 hasPrettierIgnore$7(path) {
const node = path.getValue();
if (node.type === "documentBody") {
const document = path.getParentNode();
return hasEndComments(document.head) && isPrettierIgnore$2(getLast$7(document.head.endComments));
}
return hasLeadingComments(node) && isPrettierIgnore$2(getLast$7(node.leadingComments));
}
|
@param {any} value
@param {string[]=} types
|
hasPrettierIgnore$7
|
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 isEmptyNode(node) {
return (!node.children || node.children.length === 0) && !hasComments(node);
}
|
@param {any} value
@param {string[]=} types
|
isEmptyNode
|
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 hasComments(node) {
return hasLeadingComments(node) || hasMiddleComments(node) || hasIndicatorComment(node) || hasTrailingComment$4(node) || hasEndComments(node);
}
|
@param {any} value
@param {string[]=} types
|
hasComments
|
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 hasLeadingComments(node) {
return node && node.leadingComments && node.leadingComments.length !== 0;
}
|
@param {any} value
@param {string[]=} types
|
hasLeadingComments
|
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 hasMiddleComments(node) {
return node && node.middleComments && node.middleComments.length !== 0;
}
|
@param {any} value
@param {string[]=} types
|
hasMiddleComments
|
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 hasIndicatorComment(node) {
return node && node.indicatorComment;
}
|
@param {any} value
@param {string[]=} types
|
hasIndicatorComment
|
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 hasTrailingComment$4(node) {
return node && node.trailingComment;
}
|
@param {any} value
@param {string[]=} types
|
hasTrailingComment$4
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/standalone.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/standalone.js
|
Apache-2.0
|
function hasEndComments(node) {
return node && node.endComments && node.endComments.length !== 0;
}
|
@param {any} value
@param {string[]=} types
|
hasEndComments
|
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 comparativeDistance(x, y) {
return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
comparativeDistance
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function buildGraph() {
var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
var models = Object.keys(conversions);
for (var len = models.length, i = 0; i < len; i++) {
graph[models[i]] = {
// http://jsperf.com/1-vs-infinity
// micro-opt, but this is simple.
distance: -1,
parent: null
};
}
return graph;
} // https://en.wikipedia.org/wiki/Breadth-first_search
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
buildGraph
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function deriveBFS(fromModel) {
var graph = buildGraph();
var queue = [fromModel]; // unshift -> queue -> pop
graph[fromModel].distance = 0;
while (queue.length) {
var current = queue.pop();
var adjacents = Object.keys(conversions[current]);
for (var len = adjacents.length, i = 0; i < len; i++) {
var adjacent = adjacents[i];
var node = graph[adjacent];
if (node.distance === -1) {
node.distance = graph[current].distance + 1;
node.parent = current;
queue.unshift(adjacent);
}
}
}
return graph;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
deriveBFS
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function link(from, to) {
return function (args) {
return to(from(args));
};
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
link
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function wrapConversion(toModel, graph) {
var path = [graph[toModel].parent, toModel];
var fn = conversions[graph[toModel].parent][toModel];
var cur = graph[toModel].parent;
while (graph[cur].parent) {
path.unshift(graph[cur].parent);
fn = link(conversions[graph[cur].parent][cur], fn);
cur = graph[cur].parent;
}
fn.conversion = path;
return fn;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapConversion
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
route = function (fromModel) {
var graph = deriveBFS(fromModel);
var conversion = {};
var models = Object.keys(graph);
for (var len = models.length, i = 0; i < len; i++) {
var toModel = models[i];
var node = graph[toModel];
if (node.parent === null) {
// no possible conversion, or this node is the source model.
continue;
}
conversion[toModel] = wrapConversion(toModel, graph);
}
return conversion;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
route
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function wrapRaw(fn) {
var wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
return fn(args);
}; // preserve .conversion property if there is one
if ('conversion' in fn) {
wrappedFn.conversion = fn.conversion;
}
return wrappedFn;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapRaw
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
return fn(args);
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrappedFn
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function wrapRounded(fn) {
var wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
var result = fn(args); // we're assuming the result is an array here.
// see notice in conversions.js; don't use box types
// in conversion functions.
if (typeof result === 'object') {
for (var len = result.length, i = 0; i < len; i++) {
result[i] = Math.round(result[i]);
}
}
return result;
}; // preserve .conversion property if there is one
if ('conversion' in fn) {
wrappedFn.conversion = fn.conversion;
}
return wrappedFn;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapRounded
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrappedFn = function (args) {
if (args === undefined || args === null) {
return args;
}
if (arguments.length > 1) {
args = Array.prototype.slice.call(arguments);
}
var result = fn(args); // we're assuming the result is an array here.
// see notice in conversions.js; don't use box types
// in conversion functions.
if (typeof result === 'object') {
for (var len = result.length, i = 0; i < len; i++) {
result[i] = Math.round(result[i]);
}
}
return result;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrappedFn
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi16 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${code + offset}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi16
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi16 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${code + offset}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi16
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi256 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};5;${code}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi256
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi256 = (fn, offset) => function () {
const code = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};5;${code}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi256
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi16m = (fn, offset) => function () {
const rgb = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi16m
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
wrapAnsi16m = (fn, offset) => function () {
const rgb = fn.apply(colorConvert, arguments);
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
wrapAnsi16m
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function assembleStyles() {
const codes = new Map();
const styles = {
modifier: {
reset: [0, 0],
// 21 isn't widely supported and 22 does the same thing
bold: [1, 22],
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
color: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
// Bright color
redBright: [91, 39],
greenBright: [92, 39],
yellowBright: [93, 39],
blueBright: [94, 39],
magentaBright: [95, 39],
cyanBright: [96, 39],
whiteBright: [97, 39]
},
bgColor: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49],
// Bright color
bgBlackBright: [100, 49],
bgRedBright: [101, 49],
bgGreenBright: [102, 49],
bgYellowBright: [103, 49],
bgBlueBright: [104, 49],
bgMagentaBright: [105, 49],
bgCyanBright: [106, 49],
bgWhiteBright: [107, 49]
}
}; // Fix humans
styles.color.grey = styles.color.gray;
for (const groupName of Object.keys(styles)) {
const group = styles[groupName];
for (const styleName of Object.keys(group)) {
const style = group[styleName];
styles[styleName] = {
open: `\u001B[${style[0]}m`,
close: `\u001B[${style[1]}m`
};
group[styleName] = styles[styleName];
codes.set(style[0], style[1]);
}
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
Object.defineProperty(styles, 'codes', {
value: codes,
enumerable: false
});
}
const ansi2ansi = n => n;
const rgb2rgb = (r, g, b) => [r, g, b];
styles.color.close = '\u001B[39m';
styles.bgColor.close = '\u001B[49m';
styles.color.ansi = {
ansi: wrapAnsi16(ansi2ansi, 0)
};
styles.color.ansi256 = {
ansi256: wrapAnsi256(ansi2ansi, 0)
};
styles.color.ansi16m = {
rgb: wrapAnsi16m(rgb2rgb, 0)
};
styles.bgColor.ansi = {
ansi: wrapAnsi16(ansi2ansi, 10)
};
styles.bgColor.ansi256 = {
ansi256: wrapAnsi256(ansi2ansi, 10)
};
styles.bgColor.ansi16m = {
rgb: wrapAnsi16m(rgb2rgb, 10)
};
for (let key of Object.keys(colorConvert)) {
if (typeof colorConvert[key] !== 'object') {
continue;
}
const suite = colorConvert[key];
if (key === 'ansi16') {
key = 'ansi';
}
if ('ansi16' in suite) {
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
}
if ('ansi256' in suite) {
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
}
if ('rgb' in suite) {
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
}
}
return styles;
} // Make the export immutable
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
assembleStyles
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
hasFlag = (flag, argv) => {
argv = argv || process.argv;
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
const pos = argv.indexOf(prefix + flag);
const terminatorPos = argv.indexOf('--');
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
hasFlag
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
translateLevel
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function supportsColor(stream) {
if (forceColor === false) {
return 0;
}
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
return 3;
}
if (hasFlag('color=256')) {
return 2;
}
if (stream && !stream.isTTY && forceColor !== true) {
return 0;
}
const min = forceColor ? 1 : 0;
if (process.platform === 'win32') {
// Node.js 7.5.0 is the first version of Node.js to include a patch to
// libuv that enables 256 color output on Windows. Anything earlier and it
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
// release that supports 256 colors. Windows 10 build 14931 is the first release
// that supports 16m/TrueColor.
const osRelease = os.release().split('.');
if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ('CI' in env) {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
return 1;
}
return min;
}
if ('TEAMCITY_VERSION' in env) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if (env.COLORTERM === 'truecolor') {
return 3;
}
if ('TERM_PROGRAM' in env) {
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
switch (env.TERM_PROGRAM) {
case 'iTerm.app':
return version >= 3 ? 3 : 2;
case 'Apple_Terminal':
return 2;
// No default
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ('COLORTERM' in env) {
return 1;
}
if (env.TERM === 'dumb') {
return min;
}
return min;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
supportsColor
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function getSupportLevel(stream) {
const level = supportsColor(stream);
return translateLevel(level);
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
getSupportLevel
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function unescape(c) {
if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
return String.fromCharCode(parseInt(c.slice(1), 16));
}
return ESCAPES.get(c) || c;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
unescape
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function parseArguments(name, args) {
const results = [];
const chunks = args.trim().split(/\s*,\s*/g);
let matches;
for (const chunk of chunks) {
if (!isNaN(chunk)) {
results.push(Number(chunk));
} else if (matches = chunk.match(STRING_REGEX)) {
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
} else {
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
}
}
return results;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
parseArguments
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function parseStyle(style) {
STYLE_REGEX.lastIndex = 0;
const results = [];
let matches;
while ((matches = STYLE_REGEX.exec(style)) !== null) {
const name = matches[1];
if (matches[2]) {
const args = parseArguments(name, matches[2]);
results.push([name].concat(args));
} else {
results.push([name]);
}
}
return results;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
parseStyle
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function buildStyle(chalk, styles) {
const enabled = {};
for (const layer of styles) {
for (const style of layer.styles) {
enabled[style[0]] = layer.inverse ? null : style.slice(1);
}
}
let current = chalk;
for (const styleName of Object.keys(enabled)) {
if (Array.isArray(enabled[styleName])) {
if (!(styleName in current)) {
throw new Error(`Unknown Chalk style: ${styleName}`);
}
if (enabled[styleName].length > 0) {
current = current[styleName].apply(current, enabled[styleName]);
} else {
current = current[styleName];
}
}
}
return current;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
buildStyle
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
templates = (chalk, tmp) => {
const styles = [];
const chunks = [];
let chunk = []; // eslint-disable-next-line max-params
tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
if (escapeChar) {
chunk.push(unescape(escapeChar));
} else if (style) {
const str = chunk.join('');
chunk = [];
chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
styles.push({
inverse,
styles: parseStyle(style)
});
} else if (close) {
if (styles.length === 0) {
throw new Error('Found extraneous } in Chalk template literal');
}
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
chunk = [];
styles.pop();
} else {
chunk.push(chr);
}
});
chunks.push(chunk.join(''));
if (styles.length > 0) {
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
throw new Error(errMsg);
}
return chunks.join('');
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
templates
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function applyOptions(obj, options) {
options = options || {}; // Detect level if not set manually
const scLevel = stdoutColor ? stdoutColor.level : 0;
obj.level = options.level === undefined ? scLevel : options.level;
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
applyOptions
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get() {
const codes = ansiStyles[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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get() {
const level = this.level;
return function () {
const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
const codes = {
open,
close: ansiStyles.color.close,
closeRe: ansiStyles.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get() {
const level = this.level;
return function () {
const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
const codes = {
open,
close: ansiStyles.bgColor.close,
closeRe: ansiStyles.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function build(_styles, _empty, key) {
const builder = function () {
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
builder = function () {
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
builder = function () {
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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.dim.open;
if (isSimpleWindowsTerm && this.hasGrey) {
ansiStyles.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, `${code.close}$&${code.open}`);
} // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
ansiStyles.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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(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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () {
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () {
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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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 = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${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 ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
}
}).join("\n");
if (opts.message && !hasColumns) {
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.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/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
parseJson$1 = (string, reviver, filename) => {
if (typeof reviver === 'string') {
filename = reviver;
reviver = null;
}
try {
try {
return JSON.parse(string, reviver);
} catch (error) {
jsonParseBetterErrors(string, reviver);
throw error;
}
} catch (error) {
error.message = error.message.replace(/\n/g, '');
const indexMatch = error.message.match(/in JSON at position (\d+) while parsing near/);
const jsonError = new JSONError(error);
if (filename) {
jsonError.fileName = filename;
}
if (indexMatch && indexMatch.length > 0) {
const lines = new LinesAndColumns$1(string);
const index = Number(indexMatch[1]);
const location = lines.locationForIndex(index);
const codeFrame = codeFrameColumns(string, {
start: {
line: location.line + 1,
column: location.column + 1
}
}, {
highlightCode: true
});
jsonError.codeFrame = codeFrame;
}
throw jsonError;
}
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
parseJson$1
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function findLineStarts(src) {
const ls = [0];
let offset = src.indexOf('\n');
while (offset !== -1) {
offset += 1;
ls.push(offset);
offset = src.indexOf('\n', offset);
}
return ls;
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
findLineStarts
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function getSrcInfo(cst) {
let lineStarts, src;
if (typeof cst === 'string') {
lineStarts = findLineStarts(cst);
src = cst;
} else {
if (Array.isArray(cst)) cst = cst[0];
if (cst && cst.context) {
if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
lineStarts = cst.lineStarts;
src = cst.context.src;
}
}
return {
lineStarts,
src
};
}
|
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
getSrcInfo
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function getLinePos(offset, cst) {
if (typeof offset !== 'number' || offset < 0) return null;
const {
lineStarts,
src
} = getSrcInfo(cst);
if (!lineStarts || !src || offset > src.length) return null;
for (let i = 0; i < lineStarts.length; ++i) {
const start = lineStarts[i];
if (offset < start) {
return {
line: i,
col: offset - lineStarts[i - 1] + 1
};
}
if (offset === start) return {
line: i + 1,
col: 1
};
}
const line = lineStarts.length;
return {
line,
col: offset - lineStarts[line - 1] + 1
};
}
|
Determine the line/col position matching a character offset.
Accepts a source string or a CST document as the second parameter. With
the latter, starting indices for lines are cached in the document as
`lineStarts: number[]`.
Returns a one-indexed `{ line, col }` location if found, or
`undefined` otherwise.
@param {number} offset
@param {string|Document|Document[]} cst
@returns {?LinePos}
|
getLinePos
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function getLine(line, cst) {
const {
lineStarts,
src
} = getSrcInfo(cst);
if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
const start = lineStarts[line - 1];
let end = lineStarts[line]; // undefined for last line; that's ok for slice()
while (end && end > start && src[end - 1] === '\n') --end;
return src.slice(start, end);
}
|
Get a specified line from the source.
Accepts a source string or a CST document as the second parameter. With
the latter, starting indices for lines are cached in the document as
`lineStarts: number[]`.
Returns the line as a string if found, or `null` otherwise.
@param {number} line One-indexed line number
@param {string|Document|Document[]} cst
@returns {?string}
|
getLine
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
setOrigRange(cr, offset) {
const {
start,
end
} = this;
if (cr.length === 0 || end <= cr[0]) {
this.origStart = start;
this.origEnd = end;
return offset;
}
let i = offset;
while (i < cr.length) {
if (cr[i] > start) break;else ++i;
}
this.origStart = start + i;
const nextOffset = i;
while (i < cr.length) {
// if end was at \n, it should now be at \r
if (cr[i] >= end) break;else ++i;
}
this.origEnd = end + i;
return nextOffset;
}
|
Set `origStart` and `origEnd` to point to the original source range for
this node, which may differ due to dropped CR characters.
@param {number[]} cr - Positions of dropped CR characters
@param {number} offset - Starting index of `cr` from the last call
@returns {number} - The next offset, matching the one found for `origStart`
|
setOrigRange
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
|
Set `origStart` and `origEnd` to point to the original source range for
this node, which may differ due to dropped CR characters.
@param {number[]} cr - Positions of dropped CR characters
@param {number} offset - Starting index of `cr` from the last call
@returns {number} - The next offset, matching the one found for `origStart`
|
_interopRequireDefault
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
static endOfBlockIndent(src, indent, lineStart) {
const inEnd = Node.endOfIndent(src, lineStart);
if (inEnd > lineStart + indent) {
return inEnd;
} else {
const wsEnd = Node.endOfWhiteSpace(src, inEnd);
const ch = src[wsEnd];
if (!ch || ch === '\n') return wsEnd;
}
return null;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
endOfBlockIndent
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
static atBlank(src, offset, endAsBlank) {
const ch = src[offset];
return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
atBlank
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
if (!ch || indentDiff < 0) return false;
if (indentDiff > 0) return true;
return indicatorAsIndent && ch === '-';
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
nextNodeIsIndented
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
static normalizeOffset(src, offset) {
const ch = src[offset];
return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset);
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
normalizeOffset
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
static foldNewline(src, offset, indent) {
let inCount = 0;
let error = false;
let fold = '';
let ch = src[offset + 1];
while (ch === ' ' || ch === '\t' || ch === '\n') {
switch (ch) {
case '\n':
inCount = 0;
offset += 1;
fold += '\n';
break;
case '\t':
if (inCount <= indent) error = true;
offset = Node.endOfWhiteSpace(src, offset + 2) - 1;
break;
case ' ':
inCount += 1;
offset += 1;
break;
}
ch = src[offset + 1];
}
if (!fold) fold = ' ';
if (ch && inCount <= indent) error = true;
return {
fold,
offset,
error
};
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
foldNewline
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
constructor(type, props, context) {
Object.defineProperty(this, 'context', {
value: context || null,
writable: true
});
this.error = null;
this.range = null;
this.valueRange = null;
this.props = props || [];
this.type = type;
this.value = null;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
constructor
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
getPropValue(idx, key, skipKey) {
if (!this.context) return null;
const {
src
} = this.context;
const prop = this.props[idx];
return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
getPropValue
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get anchor() {
for (let i = 0; i < this.props.length; ++i) {
const anchor = this.getPropValue(i, constants.Char.ANCHOR, true);
if (anchor != null) return anchor;
}
return null;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
anchor
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get comment() {
const comments = [];
for (let i = 0; i < this.props.length; ++i) {
const comment = this.getPropValue(i, constants.Char.COMMENT, true);
if (comment != null) comments.push(comment);
}
return comments.length > 0 ? comments.join('\n') : null;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
comment
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
commentHasRequiredWhitespace(start) {
const {
src
} = this.context;
if (this.header && start === this.header.end) return false;
if (!this.valueRange) return false;
const {
end
} = this.valueRange;
return start !== end || Node.atBlank(src, end - 1);
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
commentHasRequiredWhitespace
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get hasComment() {
if (this.context) {
const {
src
} = this.context;
for (let i = 0; i < this.props.length; ++i) {
if (src[this.props[i].start] === constants.Char.COMMENT) return true;
}
}
return false;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
hasComment
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get hasProps() {
if (this.context) {
const {
src
} = this.context;
for (let i = 0; i < this.props.length; ++i) {
if (src[this.props[i].start] !== constants.Char.COMMENT) return true;
}
}
return false;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
hasProps
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get includesTrailingLines() {
return false;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
includesTrailingLines
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get jsonLike() {
const jsonLikeTypes = [constants.Type.FLOW_MAP, constants.Type.FLOW_SEQ, constants.Type.QUOTE_DOUBLE, constants.Type.QUOTE_SINGLE];
return jsonLikeTypes.indexOf(this.type) !== -1;
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
jsonLike
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
get rangeAsLinePos() {
if (!this.range || !this.context) return undefined;
const start = (0, sourceUtils.getLinePos)(this.range.start, this.context.root);
if (!start) return undefined;
const end = (0, sourceUtils.getLinePos)(this.range.end, this.context.root);
return {
start,
end
};
}
|
End of indentation, or null if the line's indent level is not more
than `indent`
@param {string} src
@param {number} indent
@param {number} lineStart
@returns {?number}
|
rangeAsLinePos
|
javascript
|
douyu/juno
|
assets/public/js/prettier/v2.0.5/third-party.js
|
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.