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
toString(ctx, onComment, onChompKeep) { if (!ctx || !ctx.doc) return JSON.stringify(this); const { simpleKeys } = ctx.doc.options; let { key, value } = this; let keyComment = key instanceof _Node.default && key.comment; if (simpleKeys) { if (keyComment) { throw new Error('With simple keys, key nodes cannot have comments'); } if (key instanceof _Collection.default) { const msg = 'With simple keys, collection cannot be used as a key value'; throw new Error(msg); } } const explicitKey = !simpleKeys && (!key || keyComment || key instanceof _Collection.default || key.type === constants.Type.BLOCK_FOLDED || key.type === constants.Type.BLOCK_LITERAL); const { doc, indent } = ctx; ctx = Object.assign({}, ctx, { implicitKey: !explicitKey, indent: indent + ' ' }); let chompKeep = false; let str = doc.schema.stringify(key, ctx, () => keyComment = null, () => chompKeep = true); str = (0, _addComment.default)(str, ctx.indent, keyComment); if (ctx.allNullValues && !simpleKeys) { if (this.comment) { str = (0, _addComment.default)(str, ctx.indent, this.comment); if (onComment) onComment(); } else if (chompKeep && !keyComment && onChompKeep) onChompKeep(); return ctx.inFlow ? str : `? ${str}`; } str = explicitKey ? `? ${str}\n${indent}:` : `${str}:`; if (this.comment) { // expected (but not strictly required) to be a single-line comment str = (0, _addComment.default)(str, ctx.indent, this.comment); if (onComment) onComment(); } let vcb = ''; let valueComment = null; if (value instanceof _Node.default) { if (value.spaceBefore) vcb = '\n'; if (value.commentBefore) { const cs = value.commentBefore.replace(/^/gm, `${ctx.indent}#`); vcb += `\n${cs}`; } valueComment = value.comment; } else if (value && typeof value === 'object') { value = doc.schema.createNode(value, true); } ctx.implicitKey = false; if (!explicitKey && !this.comment && value instanceof _Scalar.default) ctx.indentAtStart = str.length + 1; chompKeep = false; const valueStr = doc.schema.stringify(value, ctx, () => valueComment = null, () => chompKeep = true); let ws = ' '; if (vcb || this.comment) { ws = `${vcb}\n${ctx.indent}`; } else if (!explicitKey && value instanceof _Collection.default) { const flow = valueStr[0] === '[' || valueStr[0] === '{'; if (!flow || valueStr.includes('\n')) ws = `\n${ctx.indent}`; } if (chompKeep && !valueComment && onChompKeep) onChompKeep(); return (0, _addComment.default)(str + ws + valueStr, ctx.indent, valueComment); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
toString
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 }; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
_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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
_defineProperty
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 collectionFromPath(schema, path, value) { let v = value; for (let i = path.length - 1; i >= 0; --i) { const k = path[i]; const o = Number.isInteger(k) && k >= 0 ? [] : {}; o[k] = v; v = o; } return schema.createNode(v, false); } // null, undefined, or an empty non-string iterable (e.g. [])
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
collectionFromPath
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(schema) { super(); _defineProperty(this, "items", []); this.schema = schema; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
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
addIn(path, value) { if (isEmptyPath(path)) this.add(value);else { const [key, ...rest] = path; const node = this.get(key, true); if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
addIn
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
deleteIn([key, ...rest]) { if (rest.length === 0) return this.delete(key); const node = this.get(key, true); if (node instanceof Collection) return node.deleteIn(rest);else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
deleteIn
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
getIn([key, ...rest], keepScalar) { const node = this.get(key, true); if (rest.length === 0) return !keepScalar && node instanceof _Scalar.default ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
getIn
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
hasAllNullValues() { return this.items.every(node => { if (!(node instanceof _Pair.default)) return false; const n = node.value; return n == null || n instanceof _Scalar.default && n.value == null && !n.commentBefore && !n.comment && !n.tag; }); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
hasAllNullValues
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
hasIn([key, ...rest]) { if (rest.length === 0) return this.has(key); const node = this.get(key, true); return node instanceof Collection ? node.hasIn(rest) : false; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
hasIn
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
setIn([key, ...rest], value) { if (rest.length === 0) { this.set(key, value); } else { const node = this.get(key, true); if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
setIn
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
toJSON() { return null; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
toJSON
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
toString(ctx, { blockItem, flowChars, isMap, itemIndent }, onComment, onChompKeep) { const { doc, indent } = ctx; const inFlow = this.type && this.type.substr(0, 4) === 'FLOW' || ctx.inFlow; if (inFlow) itemIndent += ' '; const allNullValues = isMap && this.hasAllNullValues(); ctx = Object.assign({}, ctx, { allNullValues, indent: itemIndent, inFlow, type: null }); let chompKeep = false; let hasItemWithNewLine = false; const nodes = this.items.reduce((nodes, item, i) => { let comment; if (item) { if (!chompKeep && item.spaceBefore) nodes.push({ type: 'comment', str: '' }); if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(line => { nodes.push({ type: 'comment', str: `#${line}` }); }); if (item.comment) comment = item.comment; if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true; } chompKeep = false; let str = doc.schema.stringify(item, ctx, () => comment = null, () => chompKeep = true); if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true; if (inFlow && i < this.items.length - 1) str += ','; str = (0, _addComment.default)(str, itemIndent, comment); if (chompKeep && (comment || inFlow)) chompKeep = false; nodes.push({ type: 'item', str }); return nodes; }, []); let str; if (nodes.length === 0) { str = flowChars.start + flowChars.end; } else if (inFlow) { const { start, end } = flowChars; const strings = nodes.map(n => n.str); if (hasItemWithNewLine || strings.reduce((sum, str) => sum + str.length + 2, 2) > Collection.maxFlowStringSingleLineLength) { str = start; for (const s of strings) { str += s ? `\n ${indent}${s}` : '\n'; } str += `\n${indent}${end}`; } else { str = `${start} ${strings.join(' ')} ${end}`; } } else { const strings = nodes.map(blockItem); str = strings.shift(); for (const s of strings) str += s ? `\n${indent}${s}` : '\n'; } if (this.comment) { str += '\n' + this.comment.replace(/^/gm, `${indent}#`); if (onComment) onComment(); } else if (chompKeep && onChompKeep) onChompKeep(); return str; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
toString
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 }; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
_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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
_defineProperty
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
getAliasCount = (node, anchors) => { if (node instanceof Alias) { const anchor = anchors.find(a => a.node === node.source); return anchor.count * anchor.aliasCount; } else if (node instanceof _Collection.default) { let count = 0; for (const item of node.items) { const c = getAliasCount(item, anchors); if (c > count) count = c; } return count; } else if (node instanceof _Pair.default) { const kc = getAliasCount(node.key, anchors); const vc = getAliasCount(node.value, anchors); return Math.max(kc, vc); } return 1; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
getAliasCount
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
getAliasCount = (node, anchors) => { if (node instanceof Alias) { const anchor = anchors.find(a => a.node === node.source); return anchor.count * anchor.aliasCount; } else if (node instanceof _Collection.default) { let count = 0; for (const item of node.items) { const c = getAliasCount(item, anchors); if (c > count) count = c; } return count; } else if (node instanceof _Pair.default) { const kc = getAliasCount(node.key, anchors); const vc = getAliasCount(node.value, anchors); return Math.max(kc, vc); } return 1; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
getAliasCount
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 stringify({ range, source }, { anchors, doc, implicitKey, inStringifyKey }) { let anchor = Object.keys(anchors).find(a => anchors[a] === source); if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName(); if (anchor) return `*${anchor}${implicitKey ? ' ' : ''}`; const msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node'; throw new Error(`${msg} [${range}]`); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
stringify
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(source) { super(); this.source = source; this.type = constants.Type.ALIAS; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
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
set tag(t) { throw new Error('Alias nodes cannot have tags'); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
tag
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
toJSON(arg, ctx) { if (!ctx) return (0, _toJSON.default)(this.source, arg, ctx); const { anchors, maxAliasCount } = ctx; const anchor = anchors.find(a => a.node === this.source); /* istanbul ignore if */ if (!anchor || anchor.res === undefined) { const msg = 'This should not happen: Alias anchor was not resolved?'; if (this.cstNode) throw new errors.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg); } if (maxAliasCount >= 0) { anchor.count += 1; if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors); if (anchor.count * anchor.aliasCount > maxAliasCount) { const msg = 'Excessive alias count indicates a resource exhaustion attack'; if (this.cstNode) throw new errors.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg); } } return anchor.res; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
toJSON
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
toString(ctx) { return Alias.stringify(this, ctx); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
toString
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 }; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
_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 findPair(items, key) { const k = key instanceof _Scalar.default ? key.value : key; for (const it of items) { if (it instanceof _Pair.default) { if (it.key === key || it.key === k) return it; if (it.key && it.key.value === k) return it; } } return undefined; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
findPair
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
add(pair, overwrite) { if (!pair) pair = new _Pair.default(pair);else if (!(pair instanceof _Pair.default)) pair = new _Pair.default(pair.key || pair, pair.value); const prev = findPair(this.items, pair.key); const sortEntries = this.schema && this.schema.sortMapEntries; if (prev) { if (overwrite) prev.value = pair.value;else throw new Error(`Key ${pair.key} already set`); } else if (sortEntries) { const i = this.items.findIndex(item => sortEntries(pair, item) < 0); if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair); } else { this.items.push(pair); } }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
add
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
delete(key) { const it = findPair(this.items, key); if (!it) return false; const del = this.items.splice(this.items.indexOf(it), 1); return del.length > 0; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
delete
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(key, keepScalar) { const it = findPair(this.items, key); const node = it && it.value; return !keepScalar && node instanceof _Scalar.default ? node.value : node; }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
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
has(key) { return !!findPair(this.items, key); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
has
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(key, value) { this.add(new _Pair.default(key, value), true); }
Parses a node from the source @param {ParseContext} overlay @param {number} start - Index of first non-whitespace character for the node @returns {?Node} - null if at a document boundary
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
toJSON(_, ctx, Type) { const map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {}; if (ctx && ctx.onCreate) ctx.onCreate(map); for (const item of this.items) item.addToJSMap(ctx, map); return map; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
toJSON
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
toString(ctx, onComment, onChompKeep) { if (!ctx) return JSON.stringify(this); for (const item of this.items) { if (!(item instanceof _Pair.default)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`); } return super.toString(ctx, { blockItem: n => n.str, flowChars: { start: '{', end: '}' }, isMap: true, itemIndent: ctx.indent || '' }, onComment, onChompKeep); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
toString
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 }; } // Published as 'yaml/seq'
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
_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 asItemIndex(key) { let idx = key instanceof _Scalar.default ? key.value : key; if (idx && typeof idx === 'string') idx = Number(idx); return Number.isInteger(idx) && idx >= 0 ? idx : null; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
asItemIndex
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
delete(key) { const idx = asItemIndex(key); if (typeof idx !== 'number') return false; const del = this.items.splice(idx, 1); return del.length > 0; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
delete
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(key, keepScalar) { const idx = asItemIndex(key); if (typeof idx !== 'number') return undefined; const it = this.items[idx]; return !keepScalar && it instanceof _Scalar.default ? it.value : it; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
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
has(key) { const idx = asItemIndex(key); return typeof idx === 'number' && idx < this.items.length; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
has
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(key, value) { const idx = asItemIndex(key); if (typeof idx !== 'number') throw new Error(`Expected a valid index, not ${key}.`); this.items[idx] = value; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
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
toJSON(_, ctx) { const seq = []; if (ctx && ctx.onCreate) ctx.onCreate(seq); let i = 0; for (const item of this.items) seq.push((0, _toJSON.default)(item, String(i++), ctx)); return seq; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
toJSON
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
toString(ctx, onComment, onChompKeep) { if (!ctx) return JSON.stringify(this); return super.toString(ctx, { blockItem: n => n.type === 'comment' ? n.str : `- ${n.str}`, flowChars: { start: '[', end: ']' }, isMap: false, itemIndent: (ctx.indent || '') + ' ' }, onComment, onChompKeep); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
toString
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 }; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
_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
constructor(pair) { if (pair instanceof _Pair.default) { let seq = pair.value; if (!(seq instanceof _Seq.default)) { seq = new _Seq.default(); seq.items.push(pair.value); seq.range = pair.value.range; } super(pair.key, seq); this.range = pair.range; } else { super(new _Scalar.default(MERGE_KEY), new _Seq.default()); } this.type = 'MERGE_PAIR'; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
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
addToJSMap(ctx, map) { for (const { source } of this.value.items) { if (!(source instanceof _Map$1.default)) throw new Error('Merge sources must be maps'); const srcMap = source.toJSON(null, ctx, Map); for (const [key, value] of srcMap) { if (map instanceof Map) { if (!map.has(key)) map.set(key, value); } else if (map instanceof Set) { map.add(key); } else { if (!Object.prototype.hasOwnProperty.call(map, key)) map[key] = value; } } } return map; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
addToJSMap
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
toString(ctx, onComment) { const seq = this.value; if (seq.items.length > 1) return super.toString(ctx, onComment); this.value = seq.items[0]; const str = super.toString(ctx, onComment); this.value = seq; return str; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
toString
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 }; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
_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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
_defineProperty
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 validAnchorNode(node) { return node instanceof _Scalar.default || node instanceof _Seq.default || node instanceof _Map$1.default; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
validAnchorNode
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(prefix) { _defineProperty(this, "map", {}); this.prefix = prefix; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
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
createAlias(node, name) { this.setAnchor(node, name); return new _Alias.default(node); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
createAlias
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
createMergePair(...sources) { const merge = new _Merge.default(); merge.value.items = sources.map(s => { if (s instanceof _Alias.default) { if (s.source instanceof _Map$1.default) return s; } else if (s instanceof _Map$1.default) { return this.createAlias(s); } throw new Error('Merge sources must be Map nodes or their Aliases'); }); return merge; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
createMergePair
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
getName(node) { const { map } = this; return Object.keys(map).find(a => map[a] === node); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
getName
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
getNode(name) { return this.map[name]; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
getNode
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
newName(prefix) { if (!prefix) prefix = this.prefix; const names = Object.keys(this.map); for (let i = 1; true; ++i) { const name = `${prefix}${i}`; if (!names.includes(name)) return name; } }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
newName
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
resolveNodes() { const { map, _cstAliases } = this; Object.keys(map).forEach(a => { map[a] = map[a].resolved; }); _cstAliases.forEach(a => { a.source = a.source.resolved; }); delete this._cstAliases; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
resolveNodes
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
setAnchor(node, name) { if (node != null && !Anchors.validAnchorNode(node)) { throw new Error('Anchors may only be set for Scalar, Seq and Map nodes'); } if (name && /[\x00-\x19\s,[\]{}]/.test(name)) { throw new Error('Anchor names must not contain whitespace or control characters'); } const { map } = this; const prev = node && Object.keys(map).find(a => map[a] === node); if (prev) { if (!name) { return prev; } else if (prev !== name) { delete map[prev]; map[name] = node; } } else { if (!name) { if (!node) return null; name = this.newName(); } map[name] = node; } return name; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
setAnchor
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 }; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
_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
visit = (node, tags) => { if (node && typeof node === 'object') { const { tag } = node; if (node instanceof _Collection.default) { if (tag) tags[tag] = true; node.items.forEach(n => visit(n, tags)); } else if (node instanceof _Pair.default) { visit(node.key, tags); visit(node.value, tags); } else if (node instanceof _Scalar.default) { if (tag) tags[tag] = true; } } return tags; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
visit
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
visit = (node, tags) => { if (node && typeof node === 'object') { const { tag } = node; if (node instanceof _Collection.default) { if (tag) tags[tag] = true; node.items.forEach(n => visit(n, tags)); } else if (node instanceof _Pair.default) { visit(node.key, tags); visit(node.value, tags); } else if (node instanceof _Scalar.default) { if (tag) tags[tag] = true; } } return tags; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
visit
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 warn(warning, type) { if (global && global._YAML_SILENCE_WARNINGS) return; const { emitWarning } = global && global.process; // This will throw in Jest if `warning` is an Error instance due to // https://github.com/facebook/jest/issues/2549 if (emitWarning) emitWarning(warning, type);else { // eslint-disable-next-line no-console console.warn(type ? `${type}: ${warning}` : warning); } }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
warn
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 warnFileDeprecation(filename) { if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return; const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/'); warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning'); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
warnFileDeprecation
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 warnOptionDeprecation(name, alternative) { if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return; if (warned[name]) return; warned[name] = true; let msg = `The option '${name}' will be removed in a future release`; msg += alternative ? `, use '${alternative}' instead.` : '.'; warn(msg, 'DeprecationWarning'); }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
warnOptionDeprecation
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
consumeMoreIndentedLines = (text, i) => { let ch = text[i + 1]; while (ch === ' ' || ch === '\t') { do { ch = text[i += 1]; } while (ch && ch !== '\n'); ch = text[i + 1]; } return i; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
consumeMoreIndentedLines
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
consumeMoreIndentedLines = (text, i) => { let ch = text[i + 1]; while (ch === ' ' || ch === '\t') { do { ch = text[i += 1]; } while (ch && ch !== '\n'); ch = text[i + 1]; } return i; }
@param {*} arg ignored @param {*} ctx Conversion context, originally set in Document#toJSON() @param {Class} Type If set, forces the returned collection type @returns {*} Instance of Type, Map, or Object
consumeMoreIndentedLines
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 foldFlowLines(text, indent, mode, { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow }) { if (!lineWidth || lineWidth < 0) return text; const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); if (text.length <= endStep) return text; const folds = []; const escapedFolds = {}; let end = lineWidth - (typeof indentAtStart === 'number' ? indentAtStart : indent.length); let split = undefined; let prev = undefined; let overflow = false; let i = -1; if (mode === FOLD_BLOCK) { i = consumeMoreIndentedLines(text, i); if (i !== -1) end = i + endStep; } for (let ch; ch = text[i += 1];) { if (mode === FOLD_QUOTED && ch === '\\') { switch (text[i + 1]) { case 'x': i += 3; break; case 'u': i += 5; break; case 'U': i += 9; break; default: i += 1; } } if (ch === '\n') { if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i); end = i + endStep; split = undefined; } else { if (ch === ' ' && prev && prev !== ' ' && prev !== '\n' && prev !== '\t') { // space surrounded by non-space can be replaced with newline + indent const next = text[i + 1]; if (next && next !== ' ' && next !== '\n' && next !== '\t') split = i; } if (i >= end) { if (split) { folds.push(split); end = split + endStep; split = undefined; } else if (mode === FOLD_QUOTED) { // white-space collected at end may stretch past lineWidth while (prev === ' ' || prev === '\t') { prev = ch; ch = text[i += 1]; overflow = true; } // i - 2 accounts for not-dropped last char + newline-escaping \ folds.push(i - 2); escapedFolds[i - 2] = true; end = i - 2 + endStep; split = undefined; } else { overflow = true; } } } prev = ch; } if (overflow && onOverflow) onOverflow(); if (folds.length === 0) return text; if (onFold) onFold(); let res = text.slice(0, folds[0]); for (let i = 0; i < folds.length; ++i) { const fold = folds[i]; const end = folds[i + 1] || text.length; if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`; res += `\n${indent}${text.slice(fold + 1, end)}`; } return res; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
foldFlowLines
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; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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
getFoldOptions = ({ indentAtStart }) => indentAtStart ? Object.assign({ indentAtStart }, options.strOptions.fold) : options.strOptions.fold
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
getFoldOptions
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
getFoldOptions = ({ indentAtStart }) => indentAtStart ? Object.assign({ indentAtStart }, options.strOptions.fold) : options.strOptions.fold
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
getFoldOptions
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 stringifyNumber({ format, minFractionDigits, tag, value }) { if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf'; let n = JSON.stringify(value); if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) { let i = n.indexOf('.'); if (i < 0) { i = n.length; n += '.'; } let d = minFractionDigits - (n.length - i - 1); while (d-- > 0) n += '0'; } return n; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
stringifyNumber
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 lineLengthOverLimit(str, limit) { const strLen = str.length; if (strLen <= limit) return false; for (let i = 0, start = 0; i < strLen; ++i) { if (str[i] === '\n') { if (i - start > limit) return true; start = i + 1; if (strLen - start <= limit) return false; } } return true; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
lineLengthOverLimit
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 doubleQuotedString(value, ctx) { const { implicitKey, indent } = ctx; const { jsonEncoding, minMultiLineLength } = options.strOptions.doubleQuoted; const json = JSON.stringify(value); if (jsonEncoding) return json; let str = ''; let start = 0; for (let i = 0, ch = json[i]; ch; ch = json[++i]) { if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') { // space before newline needs to be escaped to not be folded str += json.slice(start, i) + '\\ '; i += 1; start = i; ch = '\\'; } if (ch === '\\') switch (json[i + 1]) { case 'u': { str += json.slice(start, i); const code = json.substr(i + 2, 4); switch (code) { case '0000': str += '\\0'; break; case '0007': str += '\\a'; break; case '000b': str += '\\v'; break; case '001b': str += '\\e'; break; case '0085': str += '\\N'; break; case '00a0': str += '\\_'; break; case '2028': str += '\\L'; break; case '2029': str += '\\P'; break; default: if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6); } i += 5; start = i + 1; } break; case 'n': if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) { i += 1; } else { // folding will eat first newline str += json.slice(start, i) + '\n\n'; while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') { str += '\n'; i += 2; } str += indent; // space after newline needs to be escaped to not be folded if (json[i + 2] === ' ') str += '\\'; i += 1; start = i + 1; } break; default: i += 1; } } str = start ? str + json.slice(start) : json; return implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx)); }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
doubleQuotedString
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 singleQuotedString(value, ctx) { const { indent, implicitKey } = ctx; if (implicitKey) { if (/\n/.test(value)) return doubleQuotedString(value, ctx); } else { // single quoted string can't have leading or trailing whitespace around newline if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx); } const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'"; return implicitKey ? res : (0, _foldFlowLines.default)(res, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx)); }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
singleQuotedString
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 blockString({ comment, type, value }, ctx, onComment, onChompKeep) { // 1. Block can't end in whitespace unless the last line is non-empty. // 2. Strings consisting of only whitespace are best rendered explicitly. if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) { return doubleQuotedString(value, ctx); } const indent = ctx.indent || (ctx.forceBlockIndent ? ' ' : ''); const indentSize = indent ? '2' : '1'; // root is at -1 const literal = type === constants.Type.BLOCK_FOLDED ? false : type === constants.Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, options.strOptions.fold.lineWidth - indent.length); let header = literal ? '|' : '>'; if (!value) return header + '\n'; let wsStart = ''; let wsEnd = ''; value = value.replace(/[\n\t ]*$/, ws => { const n = ws.indexOf('\n'); if (n === -1) { header += '-'; // strip } else if (value === ws || n !== ws.length - 1) { header += '+'; // keep if (onChompKeep) onChompKeep(); } wsEnd = ws.replace(/\n$/, ''); return ''; }).replace(/^[\n ]*/, ws => { if (ws.indexOf(' ') !== -1) header += indentSize; const m = ws.match(/ +$/); if (m) { wsStart = ws.slice(0, -m[0].length); return m[0]; } else { wsStart = ws; return ''; } }); if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, `$&${indent}`); if (wsStart) wsStart = wsStart.replace(/\n+/g, `$&${indent}`); if (comment) { header += ' #' + comment.replace(/ ?[\r\n]+/g, ' '); if (onComment) onComment(); } if (!value) return `${header}${indentSize}\n${indent}${wsEnd}`; if (literal) { value = value.replace(/\n+/g, `$&${indent}`); return `${header}\n${indent}${wsStart}${value}${wsEnd}`; } value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded // ^ ind.line ^ empty ^ capture next empty lines only at end of indent .replace(/\n+/g, `$&${indent}`); const body = (0, _foldFlowLines.default)(`${wsStart}${value}${wsEnd}`, indent, _foldFlowLines.FOLD_BLOCK, options.strOptions.fold); return `${header}\n${indent}${body}`; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
blockString
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 plainString(item, ctx, onComment, onChompKeep) { const { comment, type, value } = item; const { actualString, implicitKey, indent, inFlow, tags } = ctx; if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) { return doubleQuotedString(value, ctx); } if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) { // not allowed: // - empty string, '-' or '?' // - start with an indicator character (except [?:-]) or /[?-] / // - '\n ', ': ' or ' \n' anywhere // - '#' not preceded by a non-space char // - end with ' ' or ':' return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep); } if (!implicitKey && !inFlow && type !== constants.Type.PLAIN && value.indexOf('\n') !== -1) { // Where allowed & type not set explicitly, prefer block style for multiline strings return blockString(item, ctx, onComment, onChompKeep); } const str = value.replace(/\n+/g, `$&\n${indent}`); // Verify that output will be parsed as a string, as e.g. plain numbers and // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'), // and others in v1.1. if (actualString && typeof tags.resolveScalar(str).value !== 'string') { return doubleQuotedString(value, ctx); } const body = implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx)); if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) { if (onComment) onComment(); return (0, addComment_1.addCommentBefore)(body, indent, comment); } return body; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
plainString
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 stringifyString(item, ctx, onComment, onChompKeep) { const { defaultType } = options.strOptions; const { implicitKey, inFlow } = ctx; let { type, value } = item; if (typeof value !== 'string') { value = String(value); item = Object.assign({}, item, { value }); } const _stringify = _type => { switch (_type) { case constants.Type.BLOCK_FOLDED: case constants.Type.BLOCK_LITERAL: return blockString(item, ctx, onComment, onChompKeep); case constants.Type.QUOTE_DOUBLE: return doubleQuotedString(value, ctx); case constants.Type.QUOTE_SINGLE: return singleQuotedString(value, ctx); case constants.Type.PLAIN: return plainString(item, ctx, onComment, onChompKeep); default: return null; } }; if (type !== constants.Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) { // force double quotes on control characters type = constants.Type.QUOTE_DOUBLE; } else if ((implicitKey || inFlow) && (type === constants.Type.BLOCK_FOLDED || type === constants.Type.BLOCK_LITERAL)) { // should not happen; blocks are not valid inside flow containers type = constants.Type.QUOTE_DOUBLE; } let res = _stringify(type); if (res === null) { res = _stringify(defaultType); if (res === null) throw new Error(`Unsupported default string type ${defaultType}`); } return res; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
stringifyString
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
_stringify = _type => { switch (_type) { case constants.Type.BLOCK_FOLDED: case constants.Type.BLOCK_LITERAL: return blockString(item, ctx, onComment, onChompKeep); case constants.Type.QUOTE_DOUBLE: return doubleQuotedString(value, ctx); case constants.Type.QUOTE_SINGLE: return singleQuotedString(value, ctx); case constants.Type.PLAIN: return plainString(item, ctx, onComment, onChompKeep); default: return null; } }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_stringify
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
_stringify = _type => { switch (_type) { case constants.Type.BLOCK_FOLDED: case constants.Type.BLOCK_LITERAL: return blockString(item, ctx, onComment, onChompKeep); case constants.Type.QUOTE_DOUBLE: return doubleQuotedString(value, ctx); case constants.Type.QUOTE_SINGLE: return singleQuotedString(value, ctx); case constants.Type.PLAIN: return plainString(item, ctx, onComment, onChompKeep); default: return null; } }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_stringify
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 checkFlowCollectionEnd(errors$1, cst) { let char, name; switch (cst.type) { case constants.Type.FLOW_MAP: char = '}'; name = 'flow map'; break; case constants.Type.FLOW_SEQ: char = ']'; name = 'flow sequence'; break; default: errors$1.push(new errors.YAMLSemanticError(cst, 'Not a flow collection!?')); return; } let lastItem; for (let i = cst.items.length - 1; i >= 0; --i) { const item = cst.items[i]; if (!item || item.type !== constants.Type.COMMENT) { lastItem = item; break; } } if (lastItem && lastItem.char !== char) { const msg = `Expected ${name} to end with ${char}`; let err; if (typeof lastItem.offset === 'number') { err = new errors.YAMLSemanticError(cst, msg); err.offset = lastItem.offset + 1; } else { err = new errors.YAMLSemanticError(lastItem, msg); if (lastItem.range && lastItem.range.end) err.offset = lastItem.range.end - lastItem.range.start; } errors$1.push(err); } }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
checkFlowCollectionEnd
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 checkKeyLength(errors$1, node, itemIdx, key, keyStart) { if (!key || typeof keyStart !== 'number') return; const item = node.items[itemIdx]; let keyEnd = item && item.range && item.range.start; if (!keyEnd) { for (let i = itemIdx - 1; i >= 0; --i) { const it = node.items[i]; if (it && it.range) { keyEnd = it.range.end + 2 * (itemIdx - i); break; } } } if (keyEnd > keyStart + 1024) { const k = String(key).substr(0, 8) + '...' + String(key).substr(-8); errors$1.push(new errors.YAMLSemanticError(node, `The "${k}" key is too long`)); } }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
checkKeyLength
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 resolveComments(collection, comments) { for (const { afterKey, before, comment } of comments) { let item = collection.items[before]; if (!item) { if (comment !== undefined) { if (collection.comment) collection.comment += '\n' + comment;else collection.comment = comment; } } else { if (afterKey && item.value) item = item.value; if (comment === undefined) { if (afterKey || !item.commentBefore) item.spaceBefore = true; } else { if (item.commentBefore) item.commentBefore += '\n' + comment;else item.commentBefore = comment; } } } }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveComments
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; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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 parseMap(doc, cst) { if (cst.type !== constants.Type.MAP && cst.type !== constants.Type.FLOW_MAP) { const msg = `A ${cst.type} node cannot be resolved as a mapping`; doc.errors.push(new errors.YAMLSyntaxError(cst, msg)); return null; } const { comments, items } = cst.type === constants.Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst); const map = new _Map$1.default(); map.items = items; (0, parseUtils.resolveComments)(map, comments); let hasCollectionKey = false; for (let i = 0; i < items.length; ++i) { const { key: iKey } = items[i]; if (iKey instanceof _Collection.default) hasCollectionKey = true; if (doc.schema.merge && iKey && iKey.value === _Merge.MERGE_KEY) { items[i] = new _Merge.default(items[i]); const sources = items[i].value.items; let error = null; sources.some(node => { if (node instanceof _Alias.default) { // During parsing, alias sources are CST nodes; to account for // circular references their resolved values can't be used here. const { type } = node.source; if (type === constants.Type.MAP || type === constants.Type.FLOW_MAP) return false; return error = 'Merge nodes aliases can only point to maps'; } return error = 'Merge nodes can only have Alias nodes as values'; }); if (error) doc.errors.push(new errors.YAMLSemanticError(cst, error)); } else { for (let j = i + 1; j < items.length; ++j) { const { key: jKey } = items[j]; if (iKey === jKey || iKey && jKey && Object.prototype.hasOwnProperty.call(iKey, 'value') && iKey.value === jKey.value) { const msg = `Map keys must be unique; "${iKey}" is repeated`; doc.errors.push(new errors.YAMLSemanticError(cst, msg)); break; } } } } if (hasCollectionKey && !doc.options.mapAsMap) { const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; doc.warnings.push(new errors.YAMLWarning(cst, warn)); } cst.resolved = map; return map; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
parseMap
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
valueHasPairComment = ({ context: { lineStart, node, src }, props }) => { if (props.length === 0) return false; const { start } = props[0]; if (node && start > node.valueRange.start) return false; if (src[start] !== constants.Char.COMMENT) return false; for (let i = lineStart; i < start; ++i) if (src[i] === '\n') return false; return true; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
valueHasPairComment
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
valueHasPairComment = ({ context: { lineStart, node, src }, props }) => { if (props.length === 0) return false; const { start } = props[0]; if (node && start > node.valueRange.start) return false; if (src[start] !== constants.Char.COMMENT) return false; for (let i = lineStart; i < start; ++i) if (src[i] === '\n') return false; return true; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
valueHasPairComment
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 resolvePairComment(item, pair) { if (!valueHasPairComment(item)) return; const comment = item.getPropValue(0, constants.Char.COMMENT, true); let found = false; const cb = pair.value.commentBefore; if (cb && cb.startsWith(comment)) { pair.value.commentBefore = cb.substr(comment.length + 1); found = true; } else { const cc = pair.value.comment; if (!item.node && cc && cc.startsWith(comment)) { pair.value.comment = cc.substr(comment.length + 1); found = true; } } if (found) pair.comment = comment; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolvePairComment
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 resolveBlockMapItems(doc, cst) { const comments = []; const items = []; let key = undefined; let keyStart = null; for (let i = 0; i < cst.items.length; ++i) { const item = cst.items[i]; switch (item.type) { case constants.Type.BLANK_LINE: comments.push({ afterKey: !!key, before: items.length }); break; case constants.Type.COMMENT: comments.push({ afterKey: !!key, before: items.length, comment: item.comment }); break; case constants.Type.MAP_KEY: if (key !== undefined) items.push(new _Pair.default(key)); if (item.error) doc.errors.push(item.error); key = doc.resolveNode(item.node); keyStart = null; break; case constants.Type.MAP_VALUE: { if (key === undefined) key = null; if (item.error) doc.errors.push(item.error); if (!item.context.atLineStart && item.node && item.node.type === constants.Type.MAP && !item.node.context.atLineStart) { const msg = 'Nested mappings are not allowed in compact mappings'; doc.errors.push(new errors.YAMLSemanticError(item.node, msg)); } let valueNode = item.node; if (!valueNode && item.props.length > 0) { // Comments on an empty mapping value need to be preserved, so we // need to construct a minimal empty node here to use instead of the // missing `item.node`. -- eemeli/yaml#19 valueNode = new _PlainValue.default(constants.Type.PLAIN, []); valueNode.context = { parent: item, src: item.context.src }; const pos = item.range.start + 1; valueNode.range = { start: pos, end: pos }; valueNode.valueRange = { start: pos, end: pos }; if (typeof item.range.origStart === 'number') { const origPos = item.range.origStart + 1; valueNode.range.origStart = valueNode.range.origEnd = origPos; valueNode.valueRange.origStart = valueNode.valueRange.origEnd = origPos; } } const pair = new _Pair.default(key, doc.resolveNode(valueNode)); resolvePairComment(item, pair); items.push(pair); (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart); key = undefined; keyStart = null; } break; default: if (key !== undefined) items.push(new _Pair.default(key)); key = doc.resolveNode(item); keyStart = item.range.start; if (item.error) doc.errors.push(item.error); next: for (let j = i + 1;; ++j) { const nextItem = cst.items[j]; switch (nextItem && nextItem.type) { case constants.Type.BLANK_LINE: case constants.Type.COMMENT: continue next; case constants.Type.MAP_VALUE: break next; default: doc.errors.push(new errors.YAMLSemanticError(item, 'Implicit map keys need to be followed by map values')); break next; } } if (item.valueRangeContainsNewline) { const msg = 'Implicit map keys need to be on a single line'; doc.errors.push(new errors.YAMLSemanticError(item, msg)); } } } if (key !== undefined) items.push(new _Pair.default(key)); return { comments, items }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveBlockMapItems
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 resolveFlowMapItems(doc, cst) { const comments = []; const items = []; let key = undefined; let keyStart = null; let explicitKey = false; let next = '{'; for (let i = 0; i < cst.items.length; ++i) { (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart); const item = cst.items[i]; if (typeof item.char === 'string') { const { char, offset } = item; if (char === '?' && key === undefined && !explicitKey) { explicitKey = true; next = ':'; continue; } if (char === ':') { if (key === undefined) key = null; if (next === ':') { next = ','; continue; } } else { if (explicitKey) { if (key === undefined && char !== ',') key = null; explicitKey = false; } if (key !== undefined) { items.push(new _Pair.default(key)); key = undefined; keyStart = null; if (char === ',') { next = ':'; continue; } } } if (char === '}') { if (i === cst.items.length - 1) continue; } else if (char === next) { next = ':'; continue; } const msg = `Flow map contains an unexpected ${char}`; const err = new errors.YAMLSyntaxError(cst, msg); err.offset = offset; doc.errors.push(err); } else if (item.type === constants.Type.BLANK_LINE) { comments.push({ afterKey: !!key, before: items.length }); } else if (item.type === constants.Type.COMMENT) { comments.push({ afterKey: !!key, before: items.length, comment: item.comment }); } else if (key === undefined) { if (next === ',') doc.errors.push(new errors.YAMLSemanticError(item, 'Separator , missing in flow map')); key = doc.resolveNode(item); keyStart = explicitKey ? null : item.range.start; // TODO: add error for non-explicit multiline plain key } else { if (next !== ',') doc.errors.push(new errors.YAMLSemanticError(item, 'Indicator : missing in flow map entry')); items.push(new _Pair.default(key, doc.resolveNode(item))); key = undefined; explicitKey = false; } } (0, parseUtils.checkFlowCollectionEnd)(doc.errors, cst); if (key !== undefined) items.push(new _Pair.default(key)); return { comments, items }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveFlowMapItems
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 }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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 createMap(schema, obj, ctx) { const map = new _Map$1.default(schema); if (obj instanceof Map) { for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx)); } else if (obj && typeof obj === 'object') { for (const key of Object.keys(obj)) map.items.push(schema.createPair(key, obj[key], ctx)); } if (typeof schema.sortMapEntries === 'function') { map.items.sort(schema.sortMapEntries); } return map; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
createMap
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 }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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 parseSeq(doc, cst) { if (cst.type !== constants.Type.SEQ && cst.type !== constants.Type.FLOW_SEQ) { const msg = `A ${cst.type} node cannot be resolved as a sequence`; doc.errors.push(new errors.YAMLSyntaxError(cst, msg)); return null; } const { comments, items } = cst.type === constants.Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst); const seq = new _Seq.default(); seq.items = items; (0, parseUtils.resolveComments)(seq, comments); if (!doc.options.mapAsMap && items.some(it => it instanceof _Pair.default && it.key instanceof _Collection.default)) { const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; doc.warnings.push(new errors.YAMLWarning(cst, warn)); } cst.resolved = seq; return seq; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
parseSeq
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 resolveBlockSeqItems(doc, cst) { const comments = []; const items = []; for (let i = 0; i < cst.items.length; ++i) { const item = cst.items[i]; switch (item.type) { case constants.Type.BLANK_LINE: comments.push({ before: items.length }); break; case constants.Type.COMMENT: comments.push({ comment: item.comment, before: items.length }); break; case constants.Type.SEQ_ITEM: if (item.error) doc.errors.push(item.error); items.push(doc.resolveNode(item.node)); if (item.hasProps) { const msg = 'Sequence items cannot have tags or anchors before the - indicator'; doc.errors.push(new errors.YAMLSemanticError(item, msg)); } break; default: if (item.error) doc.errors.push(item.error); doc.errors.push(new errors.YAMLSyntaxError(item, `Unexpected ${item.type} node in sequence`)); } } return { comments, items }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveBlockSeqItems
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 resolveFlowSeqItems(doc, cst) { const comments = []; const items = []; let explicitKey = false; let key = undefined; let keyStart = null; let next = '['; for (let i = 0; i < cst.items.length; ++i) { const item = cst.items[i]; if (typeof item.char === 'string') { const { char, offset } = item; if (char !== ':' && (explicitKey || key !== undefined)) { if (explicitKey && key === undefined) key = next ? items.pop() : null; items.push(new _Pair.default(key)); explicitKey = false; key = undefined; keyStart = null; } if (char === next) { next = null; } else if (!next && char === '?') { explicitKey = true; } else if (next !== '[' && char === ':' && key === undefined) { if (next === ',') { key = items.pop(); if (key instanceof _Pair.default) { const msg = 'Chaining flow sequence pairs is invalid'; const err = new errors.YAMLSemanticError(cst, msg); err.offset = offset; doc.errors.push(err); } if (!explicitKey) (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart); } else { key = null; } keyStart = null; explicitKey = false; // TODO: add error for non-explicit multiline plain key next = null; } else if (next === '[' || char !== ']' || i < cst.items.length - 1) { const msg = `Flow sequence contains an unexpected ${char}`; const err = new errors.YAMLSyntaxError(cst, msg); err.offset = offset; doc.errors.push(err); } } else if (item.type === constants.Type.BLANK_LINE) { comments.push({ before: items.length }); } else if (item.type === constants.Type.COMMENT) { comments.push({ comment: item.comment, before: items.length }); } else { if (next) { const msg = `Expected a ${next} in flow sequence`; doc.errors.push(new errors.YAMLSemanticError(item, msg)); } const value = doc.resolveNode(item); if (key === undefined) { items.push(value); } else { items.push(new _Pair.default(key, value)); key = undefined; } keyStart = item.range.start; next = ','; } } (0, parseUtils.checkFlowCollectionEnd)(doc.errors, cst); if (key !== undefined) items.push(new _Pair.default(key)); return { comments, items }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveFlowSeqItems
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 }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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 createSeq(schema, obj, ctx) { const seq = new _Seq.default(schema); if (obj && obj[Symbol.iterator]) { for (const it of obj) { const v = schema.createNode(it, ctx.wrapScalars, null, ctx); seq.items.push(v); } } return seq; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
createSeq
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
resolveString = (doc, node) => { // on error, will return { str: string, errors: Error[] } const res = node.strValue; if (!res) return ''; if (typeof res === 'string') return res; res.errors.forEach(error => { if (!error.source) error.source = node; doc.errors.push(error); }); return res.str; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveString
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
resolveString = (doc, node) => { // on error, will return { str: string, errors: Error[] } const res = node.strValue; if (!res) return ''; if (typeof res === 'string') return res; res.errors.forEach(error => { if (!error.source) error.source = node; doc.errors.push(error); }); return res.str; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
resolveString
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
stringify(item, ctx, onComment, onChompKeep) { ctx = Object.assign({ actualString: true }, ctx); return (0, stringify.stringifyString)(item, ctx, onComment, onChompKeep); }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
stringify
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 }; }
Tries to keep input at up to `lineWidth` characters, splitting only on spaces not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are terminated with `\n` and started with `indent`. @param {string} text @param {string} indent @param {string} [mode='flow'] `'block'` prevents more-indented lines from being folded; `'quoted'` allows for `\` escapes, including escaped newlines @param {Object} options @param {number} [options.indentAtStart] Accounts for leading contents on the first line, defaulting to `indent.length` @param {number} [options.lineWidth=80] @param {number} [options.minContentWidth=20] Allow highly indented lines to stretch the line width @param {function} options.onFold Called once if the text is folded @param {function} options.onFold Called once if any line of text exceeds lineWidth characters
_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