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
compareIdentifiers = (a, b) => { const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }
@param {Doc} doc @param {number} size @param {number} tabWidth
compareIdentifiers
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
constructor(version, options) { if (!options || typeof options !== 'object') { options = { loose: !!options, includePrerelease: false }; } if (version instanceof SemVer) { if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) { return version; } else { version = version.version; } } else if (typeof version !== 'string') { throw new TypeError("Invalid Version: ".concat(version)); } if (version.length > MAX_LENGTH$1) { throw new TypeError("version is longer than ".concat(MAX_LENGTH$1, " characters")); } debug_1('SemVer', version, options); this.options = options; this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we // don't run into trouble passing this.options around. this.includePrerelease = !!options.includePrerelease; const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); if (!m) { throw new TypeError("Invalid Version: ".concat(version)); } this.raw = version; // these are actually numbers this.major = +m[1]; this.minor = +m[2]; this.patch = +m[3]; if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) { throw new TypeError('Invalid major version'); } if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) { throw new TypeError('Invalid minor version'); } if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) { throw new TypeError('Invalid patch version'); } // numberify any prerelease numeric ids if (!m[4]) { this.prerelease = []; } else { this.prerelease = m[4].split('.').map(id => { if (/^[0-9]+$/.test(id)) { const num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER$1) { return num; } } return id; }); } this.build = m[5] ? m[5].split('.') : []; this.format(); }
@param {Doc} doc @param {number} size @param {number} tabWidth
constructor
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
format() { this.version = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (this.prerelease.length) { this.version += "-".concat(this.prerelease.join('.')); } return this.version; }
@param {Doc} doc @param {number} size @param {number} tabWidth
format
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
toString() { return this.version; }
@param {Doc} doc @param {number} size @param {number} tabWidth
toString
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
compare(other) { debug_1('SemVer.compare', this.version, this.options, other); if (!(other instanceof SemVer)) { if (typeof other === 'string' && other === this.version) { return 0; } other = new SemVer(other, this.options); } if (other.version === this.version) { return 0; } return this.compareMain(other) || this.comparePre(other); }
@param {Doc} doc @param {number} size @param {number} tabWidth
compare
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
compareMain(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch); }
@param {Doc} doc @param {number} size @param {number} tabWidth
compareMain
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
comparePre(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } // NOT having a prerelease is > having one if (this.prerelease.length && !other.prerelease.length) { return -1; } else if (!this.prerelease.length && other.prerelease.length) { return 1; } else if (!this.prerelease.length && !other.prerelease.length) { return 0; } let i = 0; do { const a = this.prerelease[i]; const b = other.prerelease[i]; debug_1('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers$1(a, b); } } while (++i); }
@param {Doc} doc @param {number} size @param {number} tabWidth
comparePre
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
compareBuild(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } let i = 0; do { const a = this.build[i]; const b = other.build[i]; debug_1('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers$1(a, b); } } while (++i); }
@param {Doc} doc @param {number} size @param {number} tabWidth
compareBuild
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
inc(release, identifier) { switch (release) { case 'premajor': this.prerelease.length = 0; this.patch = 0; this.minor = 0; this.major++; this.inc('pre', identifier); break; case 'preminor': this.prerelease.length = 0; this.patch = 0; this.minor++; this.inc('pre', identifier); break; case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0; this.inc('patch', identifier); this.inc('pre', identifier); break; // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { this.inc('patch', identifier); } this.inc('pre', identifier); break; case 'major': // If this is a pre-major version, bump up to the same major version. // Otherwise increment major. // 1.0.0-5 bumps to 1.0.0 // 1.1.0 bumps to 2.0.0 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { this.major++; } this.minor = 0; this.patch = 0; this.prerelease = []; break; case 'minor': // If this is a pre-minor version, bump up to the same minor version. // Otherwise increment minor. // 1.2.0-5 bumps to 1.2.0 // 1.2.1 bumps to 1.3.0 if (this.patch !== 0 || this.prerelease.length === 0) { this.minor++; } this.patch = 0; this.prerelease = []; break; case 'patch': // If this is not a pre-release version, it will increment the patch. // If it is a pre-release it will bump up to the same patch version. // 1.2.0-5 patches to 1.2.0 // 1.2.0 patches to 1.2.1 if (this.prerelease.length === 0) { this.patch++; } this.prerelease = []; break; // This probably shouldn't be used publicly. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. case 'pre': if (this.prerelease.length === 0) { this.prerelease = [0]; } else { let i = this.prerelease.length; while (--i >= 0) { if (typeof this.prerelease[i] === 'number') { this.prerelease[i]++; i = -2; } } if (i === -1) { // didn't increment anything this.prerelease.push(0); } } if (identifier) { // 1.2.0-beta.1 bumps to 1.2.0-beta.2, // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 if (this.prerelease[0] === identifier) { if (isNaN(this.prerelease[1])) { this.prerelease = [identifier, 0]; } } else { this.prerelease = [identifier, 0]; } } break; default: throw new Error("invalid increment argument: ".concat(release)); } this.format(); this.raw = this.version; return this; }
@param {Doc} doc @param {number} size @param {number} tabWidth
inc
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({ [keyName]: key }, value))
@param {Doc} doc @param {number} size @param {number} tabWidth
arrayify
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getSupportInfo({ plugins = [], showUnreleased = false, showDeprecated = false, showInternal = false } = {}) { // pre-release version is smaller than the normal version in semver, // we need to treat it as the normal one so as to test new features. const version = currentVersion.split("-", 1)[0]; const options = arrayify(Object.assign({}, ...plugins.map(({ options }) => options), coreOptions$1), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => { option = Object.assign({}, option); if (Array.isArray(option.default)) { option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value; } if (Array.isArray(option.choices)) { option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option)); } const filteredPlugins = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined); const pluginDefaults = filteredPlugins.reduce((reduced, plugin) => { reduced[plugin.name] = plugin.defaultOptions[option.name]; return reduced; }, {}); return Object.assign(Object.assign({}, option), {}, { pluginDefaults }); }); const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince); return { languages, options }; function filterSince(object) { return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since); } function filterDeprecated(object) { return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated); } function mapInternal(object) { if (showInternal) { return object; } const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]); return newObject; } }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
getSupportInfo
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function filterSince(object) { return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
filterSince
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function filterDeprecated(object) { return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
filterDeprecated
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function mapInternal(object) { if (showInternal) { return object; } const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]); return newObject; }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
mapInternal
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getPenultimate(arr) { if (arr.length > 1) { return arr[arr.length - 2]; } return null; }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
getPenultimate
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function skip(chars) { return (text, index, opts) => { const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having // to check for failures (did someone say monads?). if (index === false) { return false; } const { length } = text; let cursor = index; while (cursor >= 0 && cursor < length) { const c = text.charAt(cursor); if (chars instanceof RegExp) { if (!chars.test(c)) { return cursor; } } else if (!chars.includes(c)) { return cursor; } backwards ? cursor-- : cursor++; } if (cursor === -1 || cursor === length) { // If we reached the beginning or end of the file, return the // out-of-bounds cursor. It's up to the caller to handle this // correctly. We don't want to indicate `false` though if it // actually skipped valid characters. return cursor; } return false; }; }
@param {string | RegExp} chars @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
skip
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function skipInlineComment(text, index) { if (index === false) { return false; } if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") { for (let i = index + 2; i < text.length; ++i) { if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") { return i + 2; } } } return index; }
@param {string} text @param {number | false} index @returns {number | false}
skipInlineComment
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function skipTrailingComment(text, index) { if (index === false) { return false; } if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") { return skipEverythingButNewLine(text, index); } return index; }
@param {string} text @param {number | false} index @returns {number | false}
skipTrailingComment
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function skipNewline(text, index, opts) { const backwards = opts && opts.backwards; if (index === false) { return false; } const atIndex = text.charAt(index); if (backwards) { if (text.charAt(index - 1) === "\r" && atIndex === "\n") { return index - 2; } if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { return index - 1; } } else { if (atIndex === "\r" && text.charAt(index + 1) === "\n") { return index + 2; } if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") { return index + 1; } } return index; }
@param {string} text @param {number | false} index @param {SkipOptions=} opts @returns {number | false}
skipNewline
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function hasNewline(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); const idx2 = skipNewline(text, idx, opts); return idx !== idx2; }
@param {string} text @param {number} index @param {SkipOptions=} opts @returns {boolean}
hasNewline
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function hasNewlineInRange(text, start, end) { for (let i = start; i < end; ++i) { if (text.charAt(i) === "\n") { return true; } } return false; }
@param {string} text @param {number} start @param {number} end @returns {boolean}
hasNewlineInRange
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function isPreviousLineEmpty(text, node, locStart) { /** @type {number | false} */ let idx = locStart(node) - 1; idx = skipSpaces(text, idx, { backwards: true }); idx = skipNewline(text, idx, { backwards: true }); idx = skipSpaces(text, idx, { backwards: true }); const idx2 = skipNewline(text, idx, { backwards: true }); return idx !== idx2; }
@template N @param {string} text @param {N} node @param {(node: N) => number} locStart
isPreviousLineEmpty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function isNextLineEmptyAfterIndex(text, index) { /** @type {number | false} */ let oldIdx = null; /** @type {number | false} */ let idx = index; while (idx !== oldIdx) { // We need to skip all the potential trailing inline comments oldIdx = idx; idx = skipToLineEnd(text, idx); idx = skipInlineComment(text, idx); idx = skipSpaces(text, idx); } idx = skipTrailingComment(text, idx); idx = skipNewline(text, idx); return idx !== false && hasNewline(text, idx); }
@param {string} text @param {number} index @returns {boolean}
isNextLineEmptyAfterIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function isNextLineEmpty(text, node, locEnd) { return isNextLineEmptyAfterIndex(text, locEnd(node)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {boolean}
isNextLineEmpty
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) { /** @type {number | false} */ let oldIdx = null; /** @type {number | false} */ let nextIdx = idx; while (nextIdx !== oldIdx) { oldIdx = nextIdx; nextIdx = skipSpaces(text, nextIdx); nextIdx = skipInlineComment(text, nextIdx); nextIdx = skipTrailingComment(text, nextIdx); nextIdx = skipNewline(text, nextIdx); } return nextIdx; }
@param {string} text @param {number} idx @returns {number | false}
getNextNonSpaceNonCommentCharacterIndexWithStartIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) { return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {number | false}
getNextNonSpaceNonCommentCharacterIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getNextNonSpaceNonCommentCharacter(text, node, locEnd) { return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback? getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd)); }
@template N @param {string} text @param {N} node @param {(node: N) => number} locEnd @returns {string}
getNextNonSpaceNonCommentCharacter
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function hasSpaces(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); return idx !== index; }
@param {string} text @param {number} index @param {SkipOptions=} opts @returns {boolean}
hasSpaces
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function setLocStart(node, index) { if (node.range) { node.range[0] = index; } else { node.start = index; } }
@param {{range?: [number, number], start?: number}} node @param {number} index
setLocStart
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function setLocEnd(node, index) { if (node.range) { node.range[1] = index; } else { node.end = index; } }
@param {{range?: [number, number], end?: number}} node @param {number} index
setLocEnd
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getPrecedence(op) { return PRECEDENCE[op]; }
@param {{range?: [number, number], end?: number}} node @param {number} index
getPrecedence
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function shouldFlatten(parentOp, nodeOp) { if (getPrecedence(nodeOp) !== getPrecedence(parentOp)) { return false; } // ** is right-associative // x ** y ** z --> x ** (y ** z) if (parentOp === "**") { return false; } // x == y == z --> (x == y) == z if (equalityOperators[parentOp] && equalityOperators[nodeOp]) { return false; } // x * y % z --> (x * y) % z if (nodeOp === "%" && multiplicativeOperators[parentOp] || parentOp === "%" && multiplicativeOperators[nodeOp]) { return false; } // x * y / z --> (x * y) / z // x / y * z --> (x / y) * z if (nodeOp !== parentOp && multiplicativeOperators[nodeOp] && multiplicativeOperators[parentOp]) { return false; } // x << y << z --> (x << y) << z if (bitshiftOperators[parentOp] && bitshiftOperators[nodeOp]) { return false; } return true; }
@param {{range?: [number, number], end?: number}} node @param {number} index
shouldFlatten
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function isBitwiseOperator(operator) { return !!bitshiftOperators[operator] || operator === "|" || operator === "^" || operator === "&"; } // Tests if an expression starts with `{`, or (if forbidFunctionClassAndDoExpr
@param {{range?: [number, number], end?: number}} node @param {number} index
isBitwiseOperator
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function startsWithNoLookaheadToken(node, forbidFunctionClassAndDoExpr) { node = getLeftMost(node); switch (node.type) { case "FunctionExpression": case "ClassExpression": case "DoExpression": return forbidFunctionClassAndDoExpr; case "ObjectExpression": return true; case "MemberExpression": case "OptionalMemberExpression": return startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); case "TaggedTemplateExpression": if (node.tag.type === "FunctionExpression") { // IIFEs are always already parenthesized return false; } return startsWithNoLookaheadToken(node.tag, forbidFunctionClassAndDoExpr); case "CallExpression": case "OptionalCallExpression": if (node.callee.type === "FunctionExpression") { // IIFEs are always already parenthesized return false; } return startsWithNoLookaheadToken(node.callee, forbidFunctionClassAndDoExpr); case "ConditionalExpression": return startsWithNoLookaheadToken(node.test, forbidFunctionClassAndDoExpr); case "UpdateExpression": return !node.prefix && startsWithNoLookaheadToken(node.argument, forbidFunctionClassAndDoExpr); case "BindExpression": return node.object && startsWithNoLookaheadToken(node.object, forbidFunctionClassAndDoExpr); case "SequenceExpression": return startsWithNoLookaheadToken(node.expressions[0], forbidFunctionClassAndDoExpr); case "TSAsExpression": return startsWithNoLookaheadToken(node.expression, forbidFunctionClassAndDoExpr); default: return false; } }
@param {{range?: [number, number], end?: number}} node @param {number} index
startsWithNoLookaheadToken
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getLeftMost(node) { if (node.left) { return getLeftMost(node.left); } return node; }
@param {{range?: [number, number], end?: number}} node @param {number} index
getLeftMost
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getAlignmentSize(value, tabWidth, startIndex) { startIndex = startIndex || 0; let size = 0; for (let i = startIndex; i < value.length; ++i) { if (value[i] === "\t") { // Tabs behave in a way that they are aligned to the nearest // multiple of tabWidth: // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4 // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ... size = size + tabWidth - size % tabWidth; } else { size++; } } return size; }
@param {string} value @param {number} tabWidth @param {number=} startIndex @returns {number}
getAlignmentSize
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getIndentSize(value, tabWidth) { const lastNewlineIndex = value.lastIndexOf("\n"); if (lastNewlineIndex === -1) { return 0; } return getAlignmentSize( // All the leading whitespaces value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth); }
@param {string} value @param {number} tabWidth @returns {number}
getIndentSize
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getPreferredQuote(raw, preferredQuote) { // `rawContent` is the string exactly like it appeared in the input source // code, without its enclosing quotes. const rawContent = raw.slice(1, -1); /** @type {{ quote: '"', regex: RegExp }} */ const double = { quote: '"', regex: /"/g }; /** @type {{ quote: "'", regex: RegExp }} */ const single = { quote: "'", regex: /'/g }; const preferred = preferredQuote === "'" ? single : double; const alternate = preferred === single ? double : single; let result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing // the string, we might want to enclose with the alternate quote instead, to // minimize the number of escaped quotes. if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) { const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length; const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length; result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote; } return result; }
@param {string} raw @param {Quote} preferredQuote @returns {Quote}
getPreferredQuote
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) { const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double). const regex = /\\([\S\s])|(["'])/g; // Escape and unescape single and double quotes as needed to be able to // enclose `rawContent` with `enclosingQuote`. const newContent = rawContent.replace(regex, (match, escaped, quote) => { // If we matched an escape, and the escaped character is a quote of the // other type than we intend to enclose the string with, there's no need for // it to be escaped, so return it _without_ the backslash. if (escaped === otherQuote) { return escaped; } // If we matched an unescaped quote and it is of the _same_ type as we // intend to enclose the string with, it must be escaped, so return it with // a backslash. if (quote === enclosingQuote) { return "\\" + quote; } if (quote) { return quote; } // Unescape any unnecessarily escaped character. // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27 return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped; }); return enclosingQuote + newContent + enclosingQuote; }
@param {string} rawContent @param {Quote} enclosingQuote @param {boolean=} unescapeUnnecessaryEscapes @returns {string}
makeString
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function printNumber(rawNumber) { return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation. .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0). .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit. .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes. .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot. .replace(/\.(?=e|$)/, ""); }
@param {string} rawContent @param {Quote} enclosingQuote @param {boolean=} unescapeUnnecessaryEscapes @returns {string}
printNumber
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getMaxContinuousCount(str, target) { const results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g")); if (results === null) { return 0; } return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0); }
@param {string} str @param {string} target @returns {number}
getMaxContinuousCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function getMinNotPresentContinuousCount(str, target) { const matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g")); if (matches === null) { return 0; } const countPresent = new Map(); let max = 0; for (const match of matches) { const count = match.length / target.length; countPresent.set(count, true); if (count > max) { max = count; } } for (let i = 1; i < max; i++) { if (!countPresent.get(i)) { return i; } } return max + 1; }
@param {string} str @param {string} target @returns {number}
getMinNotPresentContinuousCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/doc.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js
Apache-2.0
function hunkFits(hunk, toPos) { for (var j = 0; j < hunk.lines.length; j++) { var line = hunk.lines[j], operation = line.length > 0 ? line[0] : ' ', content = line.length > 0 ? line.substr(1) : line; if (operation === ' ' || operation === '-') { // Context sanity check if (!compareLine(toPos + 1, lines[toPos], operation, content)) { errorCount++; if (errorCount > fuzzFactor) { return false; } } toPos++; } } return true; } // Search best fit offsets for each hunk based on the previous ones
Checks if the hunk exactly fits on the provided location
hunkFits
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function applyPatches(uniDiff, options) { if (typeof uniDiff === 'string') { uniDiff = parsePatch(uniDiff); } var currentIndex = 0; function processIndex() { var index = uniDiff[currentIndex++]; if (!index) { return options.complete(); } options.loadFile(index, function (err, data) { if (err) { return options.complete(err); } var updatedContent = applyPatch(data, index, options); options.patched(index, updatedContent, function (err) { if (err) { return options.complete(err); } processIndex(); }); }); } processIndex(); }
Checks if the hunk exactly fits on the provided location
applyPatches
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function processIndex() { var index = uniDiff[currentIndex++]; if (!index) { return options.complete(); } options.loadFile(index, function (err, data) { if (err) { return options.complete(err); } var updatedContent = applyPatch(data, index, options); options.patched(index, updatedContent, function (err) { if (err) { return options.complete(err); } processIndex(); }); }); }
Checks if the hunk exactly fits on the provided location
processIndex
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { if (!options) { options = {}; } if (typeof options.context === 'undefined') { options.context = 4; } var diff = diffLines(oldStr, newStr, options); diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier function contextLines(lines) { return lines.map(function (entry) { return ' ' + entry; }); } var hunks = []; var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1; var _loop = function _loop(i) { var current = diff[i], lines = current.lines || current.value.replace(/\n$/, '').split('\n'); current.lines = lines; if (current.added || current.removed) { var _curRange; // If we have previous context, start with that if (!oldRangeStart) { var prev = diff[i - 1]; oldRangeStart = oldLine; newRangeStart = newLine; if (prev) { curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; oldRangeStart -= curRange.length; newRangeStart -= curRange.length; } } // Output our changes (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { return (current.added ? '+' : '-') + entry; }))); // Track the updated file position if (current.added) { newLine += lines.length; } else { oldLine += lines.length; } } else { // Identical context lines. Track line changes if (oldRangeStart) { // Close out any changes that have been output (or join overlapping) if (lines.length <= options.context * 2 && i < diff.length - 2) { var _curRange2; // Overlapping (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); } else { var _curRange3; // end the range and output var contextSize = Math.min(lines.length, options.context); (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); var hunk = { oldStart: oldRangeStart, oldLines: oldLine - oldRangeStart + contextSize, newStart: newRangeStart, newLines: newLine - newRangeStart + contextSize, lines: curRange }; if (i >= diff.length - 2 && lines.length <= options.context) { // EOF is inside this hunk var oldEOFNewline = /\n$/.test(oldStr); var newEOFNewline = /\n$/.test(newStr); var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; if (!oldEOFNewline && noNlBeforeAdds) { // special case: old has no eol and no trailing context; no-nl can end up before adds curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); } if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { curRange.push('\\ No newline at end of file'); } } hunks.push(hunk); oldRangeStart = 0; newRangeStart = 0; curRange = []; } } oldLine += lines.length; newLine += lines.length; } }; for (var i = 0; i < diff.length; i++) { _loop(i); } return { oldFileName: oldFileName, newFileName: newFileName, oldHeader: oldHeader, newHeader: newHeader, hunks: hunks }; }
Checks if the hunk exactly fits on the provided location
structuredPatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function contextLines(lines) { return lines.map(function (entry) { return ' ' + entry; }); }
Checks if the hunk exactly fits on the provided location
contextLines
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
_loop = function _loop(i) { var current = diff[i], lines = current.lines || current.value.replace(/\n$/, '').split('\n'); current.lines = lines; if (current.added || current.removed) { var _curRange; // If we have previous context, start with that if (!oldRangeStart) { var prev = diff[i - 1]; oldRangeStart = oldLine; newRangeStart = newLine; if (prev) { curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; oldRangeStart -= curRange.length; newRangeStart -= curRange.length; } } // Output our changes (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { return (current.added ? '+' : '-') + entry; }))); // Track the updated file position if (current.added) { newLine += lines.length; } else { oldLine += lines.length; } } else { // Identical context lines. Track line changes if (oldRangeStart) { // Close out any changes that have been output (or join overlapping) if (lines.length <= options.context * 2 && i < diff.length - 2) { var _curRange2; // Overlapping (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); } else { var _curRange3; // end the range and output var contextSize = Math.min(lines.length, options.context); (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); var hunk = { oldStart: oldRangeStart, oldLines: oldLine - oldRangeStart + contextSize, newStart: newRangeStart, newLines: newLine - newRangeStart + contextSize, lines: curRange }; if (i >= diff.length - 2 && lines.length <= options.context) { // EOF is inside this hunk var oldEOFNewline = /\n$/.test(oldStr); var newEOFNewline = /\n$/.test(newStr); var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; if (!oldEOFNewline && noNlBeforeAdds) { // special case: old has no eol and no trailing context; no-nl can end up before adds curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); } if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { curRange.push('\\ No newline at end of file'); } } hunks.push(hunk); oldRangeStart = 0; newRangeStart = 0; curRange = []; } } oldLine += lines.length; newLine += lines.length; } }
Checks if the hunk exactly fits on the provided location
_loop
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); var ret = []; if (oldFileName == newFileName) { ret.push('Index: ' + oldFileName); } ret.push('==================================================================='); ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); for (var i = 0; i < diff.hunks.length; i++) { var hunk = diff.hunks[i]; ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); ret.push.apply(ret, hunk.lines); } return ret.join('\n') + '\n'; }
Checks if the hunk exactly fits on the provided location
createTwoFilesPatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); }
Checks if the hunk exactly fits on the provided location
createPatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function arrayEqual(a, b) { if (a.length !== b.length) { return false; } return arrayStartsWith(a, b); }
Checks if the hunk exactly fits on the provided location
arrayEqual
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function arrayStartsWith(array, start) { if (start.length > array.length) { return false; } for (var i = 0; i < start.length; i++) { if (start[i] !== array[i]) { return false; } } return true; }
Checks if the hunk exactly fits on the provided location
arrayStartsWith
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function calcLineCount(hunk) { var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), oldLines = _calcOldNewLineCount.oldLines, newLines = _calcOldNewLineCount.newLines; if (oldLines !== undefined) { hunk.oldLines = oldLines; } else { delete hunk.oldLines; } if (newLines !== undefined) { hunk.newLines = newLines; } else { delete hunk.newLines; } }
Checks if the hunk exactly fits on the provided location
calcLineCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function merge(mine, theirs, base) { mine = loadPatch(mine, base); theirs = loadPatch(theirs, base); var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. // Leaving sanity checks on this to the API consumer that may know more about the // meaning in their own context. if (mine.index || theirs.index) { ret.index = mine.index || theirs.index; } if (mine.newFileName || theirs.newFileName) { if (!fileNameChanged(mine)) { // No header or no change in ours, use theirs (and ours if theirs does not exist) ret.oldFileName = theirs.oldFileName || mine.oldFileName; ret.newFileName = theirs.newFileName || mine.newFileName; ret.oldHeader = theirs.oldHeader || mine.oldHeader; ret.newHeader = theirs.newHeader || mine.newHeader; } else if (!fileNameChanged(theirs)) { // No header or no change in theirs, use ours ret.oldFileName = mine.oldFileName; ret.newFileName = mine.newFileName; ret.oldHeader = mine.oldHeader; ret.newHeader = mine.newHeader; } else { // Both changed... figure it out ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); } } ret.hunks = []; var mineIndex = 0, theirsIndex = 0, mineOffset = 0, theirsOffset = 0; while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity }, theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity }; if (hunkBefore(mineCurrent, theirsCurrent)) { // This patch does not overlap with any of the others, yay. ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); mineIndex++; theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; } else if (hunkBefore(theirsCurrent, mineCurrent)) { // This patch does not overlap with any of the others, yay. ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); theirsIndex++; mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; } else { // Overlap, merge as best we can var mergedHunk = { oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), oldLines: 0, newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), newLines: 0, lines: [] }; mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); theirsIndex++; mineIndex++; ret.hunks.push(mergedHunk); } } return ret; }
Checks if the hunk exactly fits on the provided location
merge
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function loadPatch(param, base) { if (typeof param === 'string') { if (/^@@/m.test(param) || /^Index:/m.test(param)) { return parsePatch(param)[0]; } if (!base) { throw new Error('Must provide a base reference or pass in a patch'); } return structuredPatch(undefined, undefined, base, param); } return param; }
Checks if the hunk exactly fits on the provided location
loadPatch
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function fileNameChanged(patch) { return patch.newFileName && patch.newFileName !== patch.oldFileName; }
Checks if the hunk exactly fits on the provided location
fileNameChanged
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function selectField(index, mine, theirs) { if (mine === theirs) { return mine; } else { index.conflict = true; return { mine: mine, theirs: theirs }; } }
Checks if the hunk exactly fits on the provided location
selectField
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function hunkBefore(test, check) { return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; }
Checks if the hunk exactly fits on the provided location
hunkBefore
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function cloneHunk(hunk, offset) { return { oldStart: hunk.oldStart, oldLines: hunk.oldLines, newStart: hunk.newStart + offset, newLines: hunk.newLines, lines: hunk.lines }; }
Checks if the hunk exactly fits on the provided location
cloneHunk
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { // This will generally result in a conflicted hunk, but there are cases where the context // is the only overlap where we can successfully merge the content here. var mine = { offset: mineOffset, lines: mineLines, index: 0 }, their = { offset: theirOffset, lines: theirLines, index: 0 }; // Handle any leading content insertLeading(hunk, mine, their); insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. while (mine.index < mine.lines.length && their.index < their.lines.length) { var mineCurrent = mine.lines[mine.index], theirCurrent = their.lines[their.index]; if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { // Both modified ... mutualChange(hunk, mine, their); } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { var _hunk$lines; // Mine inserted (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine))); } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { var _hunk$lines2; // Theirs inserted (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their))); } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { // Mine removed or edited removal(hunk, mine, their); } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { // Their removed or edited removal(hunk, their, mine, true); } else if (mineCurrent === theirCurrent) { // Context identity hunk.lines.push(mineCurrent); mine.index++; their.index++; } else { // Context mismatch conflict(hunk, collectChange(mine), collectChange(their)); } } // Now push anything that may be remaining insertTrailing(hunk, mine); insertTrailing(hunk, their); calcLineCount(hunk); }
Checks if the hunk exactly fits on the provided location
mergeLines
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function mutualChange(hunk, mine, their) { var myChanges = collectChange(mine), theirChanges = collectChange(their); if (allRemoves(myChanges) && allRemoves(theirChanges)) { // Special case for remove changes that are supersets of one another if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { var _hunk$lines3; (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges)); return; } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { var _hunk$lines4; (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges)); return; } } else if (arrayEqual(myChanges, theirChanges)) { var _hunk$lines5; (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges)); return; } conflict(hunk, myChanges, theirChanges); }
Checks if the hunk exactly fits on the provided location
mutualChange
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function removal(hunk, mine, their, swap) { var myChanges = collectChange(mine), theirChanges = collectContext(their, myChanges); if (theirChanges.merged) { var _hunk$lines6; (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged)); } else { conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); } }
Checks if the hunk exactly fits on the provided location
removal
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function conflict(hunk, mine, their) { hunk.conflict = true; hunk.lines.push({ conflict: true, mine: mine, theirs: their }); }
Checks if the hunk exactly fits on the provided location
conflict
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function insertLeading(hunk, insert, their) { while (insert.offset < their.offset && insert.index < insert.lines.length) { var line = insert.lines[insert.index++]; hunk.lines.push(line); insert.offset++; } }
Checks if the hunk exactly fits on the provided location
insertLeading
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function insertTrailing(hunk, insert) { while (insert.index < insert.lines.length) { var line = insert.lines[insert.index++]; hunk.lines.push(line); } }
Checks if the hunk exactly fits on the provided location
insertTrailing
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function collectChange(state) { var ret = [], operation = state.lines[state.index][0]; while (state.index < state.lines.length) { var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. if (operation === '-' && line[0] === '+') { operation = '+'; } if (operation === line[0]) { ret.push(line); state.index++; } else { break; } } return ret; }
Checks if the hunk exactly fits on the provided location
collectChange
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function collectContext(state, matchChanges) { var changes = [], merged = [], matchIndex = 0, contextChanges = false, conflicted = false; while (matchIndex < matchChanges.length && state.index < state.lines.length) { var change = state.lines[state.index], match = matchChanges[matchIndex]; // Once we've hit our add, then we are done if (match[0] === '+') { break; } contextChanges = contextChanges || change[0] !== ' '; merged.push(match); matchIndex++; // Consume any additions in the other block as a conflict to attempt // to pull in the remaining context after this if (change[0] === '+') { conflicted = true; while (change[0] === '+') { changes.push(change); change = state.lines[++state.index]; } } if (match.substr(1) === change.substr(1)) { changes.push(change); state.index++; } else { conflicted = true; } } if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { conflicted = true; } if (conflicted) { return changes; } while (matchIndex < matchChanges.length) { merged.push(matchChanges[matchIndex++]); } return { merged: merged, changes: changes }; }
Checks if the hunk exactly fits on the provided location
collectContext
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function allRemoves(changes) { return changes.reduce(function (prev, change) { return prev && change[0] === '-'; }, true); }
Checks if the hunk exactly fits on the provided location
allRemoves
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function skipRemoveSuperset(state, removeChanges, delta) { for (var i = 0; i < delta; i++) { var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); if (state.lines[state.index + i] !== ' ' + changeContent) { return false; } } state.index += delta; return true; }
Checks if the hunk exactly fits on the provided location
skipRemoveSuperset
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function calcOldNewLineCount(lines) { var oldLines = 0; var newLines = 0; lines.forEach(function (line) { if (typeof line !== 'string') { var myCount = calcOldNewLineCount(line.mine); var theirCount = calcOldNewLineCount(line.theirs); if (oldLines !== undefined) { if (myCount.oldLines === theirCount.oldLines) { oldLines += myCount.oldLines; } else { oldLines = undefined; } } if (newLines !== undefined) { if (myCount.newLines === theirCount.newLines) { newLines += myCount.newLines; } else { newLines = undefined; } } } else { if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { newLines++; } if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { oldLines++; } } }); return { oldLines: oldLines, newLines: newLines }; } // See: http://code.google.com/p/google-diff-match-patch/wiki/API
Checks if the hunk exactly fits on the provided location
calcOldNewLineCount
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function convertChangesToDMP(changes) { var ret = [], change, operation; for (var i = 0; i < changes.length; i++) { change = changes[i]; if (change.added) { operation = 1; } else if (change.removed) { operation = -1; } else { operation = 0; } ret.push([operation, change.value]); } return ret; }
Checks if the hunk exactly fits on the provided location
convertChangesToDMP
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function convertChangesToXML(changes) { var ret = []; for (var i = 0; i < changes.length; i++) { var change = changes[i]; if (change.added) { ret.push('<ins>'); } else if (change.removed) { ret.push('<del>'); } ret.push(escapeHTML(change.value)); if (change.added) { ret.push('</ins>'); } else if (change.removed) { ret.push('</del>'); } } return ret.join(''); }
Checks if the hunk exactly fits on the provided location
convertChangesToXML
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function escapeHTML(s) { var n = s; n = n.replace(/&/g, '&amp;'); n = n.replace(/</g, '&lt;'); n = n.replace(/>/g, '&gt;'); n = n.replace(/"/g, '&quot;'); return n; }
Checks if the hunk exactly fits on the provided location
escapeHTML
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function fromPairs(pairs) { var index = -1, length = pairs == null ? 0 : pairs.length, result = {}; while (++index < length) { var pair = pairs[index]; result[pair[0]] = pair[1]; } return result; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
fromPairs
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
_objectWithoutPropertiesLoose
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
unwrapExports
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
createCommonjsModule
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function getCjsExportFromNamespace (n) { return n && n['default'] || n; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
getCjsExportFromNamespace
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
createToken = (name, value, isGlobal) => { const index = R++; debug_1(index, value); t[name] = index; src[index] = value; re[index] = new RegExp(value, isGlobal ? 'g' : undefined); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
createToken
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
createToken = (name, value, isGlobal) => { const index = R++; debug_1(index, value); t[name] = index; src[index] = value; re[index] = new RegExp(value, isGlobal ? 'g' : undefined); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
createToken
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
compareIdentifiers = (a, b) => { const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
compareIdentifiers
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
compareIdentifiers = (a, b) => { const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
compareIdentifiers
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
constructor(version, options) { if (!options || typeof options !== 'object') { options = { loose: !!options, includePrerelease: false }; } if (version instanceof SemVer) { if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) { return version; } else { version = version.version; } } else if (typeof version !== 'string') { throw new TypeError(`Invalid Version: ${version}`); } if (version.length > MAX_LENGTH$1) { throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`); } debug_1('SemVer', version, options); this.options = options; this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we // don't run into trouble passing this.options around. this.includePrerelease = !!options.includePrerelease; const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); if (!m) { throw new TypeError(`Invalid Version: ${version}`); } this.raw = version; // these are actually numbers this.major = +m[1]; this.minor = +m[2]; this.patch = +m[3]; if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) { throw new TypeError('Invalid major version'); } if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) { throw new TypeError('Invalid minor version'); } if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) { throw new TypeError('Invalid patch version'); } // numberify any prerelease numeric ids if (!m[4]) { this.prerelease = []; } else { this.prerelease = m[4].split('.').map(id => { if (/^[0-9]+$/.test(id)) { const num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER$1) { return num; } } return id; }); } this.build = m[5] ? m[5].split('.') : []; this.format(); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
constructor
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
format() { this.version = `${this.major}.${this.minor}.${this.patch}`; if (this.prerelease.length) { this.version += `-${this.prerelease.join('.')}`; } return this.version; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
format
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
toString() { return this.version; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
toString
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
compare(other) { debug_1('SemVer.compare', this.version, this.options, other); if (!(other instanceof SemVer)) { if (typeof other === 'string' && other === this.version) { return 0; } other = new SemVer(other, this.options); } if (other.version === this.version) { return 0; } return this.compareMain(other) || this.comparePre(other); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
compare
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
compareMain(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
compareMain
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
comparePre(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } // NOT having a prerelease is > having one if (this.prerelease.length && !other.prerelease.length) { return -1; } else if (!this.prerelease.length && other.prerelease.length) { return 1; } else if (!this.prerelease.length && !other.prerelease.length) { return 0; } let i = 0; do { const a = this.prerelease[i]; const b = other.prerelease[i]; debug_1('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers$1(a, b); } } while (++i); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
comparePre
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
compareBuild(other) { if (!(other instanceof SemVer)) { other = new SemVer(other, this.options); } let i = 0; do { const a = this.build[i]; const b = other.build[i]; debug_1('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers$1(a, b); } } while (++i); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
compareBuild
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
inc(release, identifier) { switch (release) { case 'premajor': this.prerelease.length = 0; this.patch = 0; this.minor = 0; this.major++; this.inc('pre', identifier); break; case 'preminor': this.prerelease.length = 0; this.patch = 0; this.minor++; this.inc('pre', identifier); break; case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0; this.inc('patch', identifier); this.inc('pre', identifier); break; // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { this.inc('patch', identifier); } this.inc('pre', identifier); break; case 'major': // If this is a pre-major version, bump up to the same major version. // Otherwise increment major. // 1.0.0-5 bumps to 1.0.0 // 1.1.0 bumps to 2.0.0 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { this.major++; } this.minor = 0; this.patch = 0; this.prerelease = []; break; case 'minor': // If this is a pre-minor version, bump up to the same minor version. // Otherwise increment minor. // 1.2.0-5 bumps to 1.2.0 // 1.2.1 bumps to 1.3.0 if (this.patch !== 0 || this.prerelease.length === 0) { this.minor++; } this.patch = 0; this.prerelease = []; break; case 'patch': // If this is not a pre-release version, it will increment the patch. // If it is a pre-release it will bump up to the same patch version. // 1.2.0-5 patches to 1.2.0 // 1.2.0 patches to 1.2.1 if (this.prerelease.length === 0) { this.patch++; } this.prerelease = []; break; // This probably shouldn't be used publicly. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. case 'pre': if (this.prerelease.length === 0) { this.prerelease = [0]; } else { let i = this.prerelease.length; while (--i >= 0) { if (typeof this.prerelease[i] === 'number') { this.prerelease[i]++; i = -2; } } if (i === -1) { // didn't increment anything this.prerelease.push(0); } } if (identifier) { // 1.2.0-beta.1 bumps to 1.2.0-beta.2, // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 if (this.prerelease[0] === identifier) { if (isNaN(this.prerelease[1])) { this.prerelease = [identifier, 0]; } } else { this.prerelease = [identifier, 0]; } } break; default: throw new Error(`invalid increment argument: ${release}`); } this.format(); this.raw = this.version; return this; }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
inc
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({ [keyName]: key }, value))
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
arrayify
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function dedent(strings) { var raw = void 0; if (typeof strings === "string") { // dedent can be used as a plain function raw = [strings]; } else { raw = strings.raw; } // first, perform interpolation var result = ""; for (var i = 0; i < raw.length; i++) { result += raw[i]. // join lines when there is a suppressed newline replace(/\\\n[ \t]*/g, ""). // handle escaped backticks replace(/\\`/g, "`"); if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) { result += arguments.length <= i + 1 ? undefined : arguments[i + 1]; } } // now strip indentation var lines = result.split("\n"); var mindent = null; lines.forEach(function (l) { var m = l.match(/^(\s+)\S+/); if (m) { var indent = m[1].length; if (!mindent) { // this is the first indented line mindent = indent; } else { mindent = Math.min(mindent, indent); } } }); if (mindent !== null) { result = lines.map(function (l) { return l[0] === " " ? l.slice(mindent) : l; }).join("\n"); } // dedent eats leading and trailing whitespace too result = result.trim(); // handle escaped newlines at the end to ensure they don't get stripped too return result.replace(/\\n/g, "\n"); }
The inverse of `_.toPairs`; this method returns an object composed from key-value `pairs`. @static @memberOf _ @since 4.0.0 @category Array @param {Array} pairs The key-value pairs. @returns {Object} Returns the new object. @example _.fromPairs([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 }
dedent
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function getSupportInfo({ plugins = [], showUnreleased = false, showDeprecated = false, showInternal = false } = {}) { // pre-release version is smaller than the normal version in semver, // we need to treat it as the normal one so as to test new features. const version = currentVersion.split("-", 1)[0]; const options = arrayify(Object.assign({}, ...plugins.map(({ options }) => options), coreOptions$1), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => { option = Object.assign({}, option); if (Array.isArray(option.default)) { option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value; } if (Array.isArray(option.choices)) { option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option)); } const filteredPlugins = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined); const pluginDefaults = filteredPlugins.reduce((reduced, plugin) => { reduced[plugin.name] = plugin.defaultOptions[option.name]; return reduced; }, {}); return Object.assign(Object.assign({}, option), {}, { pluginDefaults }); }); const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince); return { languages, options }; function filterSince(object) { return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since); } function filterDeprecated(object) { return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated); } function mapInternal(object) { if (showInternal) { return object; } const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]); return newObject; } }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
getSupportInfo
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function filterSince(object) { return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
filterSince
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function filterDeprecated(object) { return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
filterDeprecated
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function mapInternal(object) { if (showInternal) { return object; } const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]); return newObject; }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
mapInternal
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
extendStatics
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
__extends
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
function __() { this.constructor = d; }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
__
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0
__assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }
Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version of this function created by `withPlugins`. Don't pass them here directly. @param {object} param0 @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`. @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`. @param {boolean=} param0.showUnreleased @param {boolean=} param0.showDeprecated @param {boolean=} param0.showInternal
__assign
javascript
douyu/juno
assets/public/js/prettier/v2.0.5/index.js
https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/index.js
Apache-2.0