code stringlengths 28 313k | docstring stringlengths 25 85.3k | func_name stringlengths 1 74 | language stringclasses 1
value | repo stringlengths 5 60 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function statSafeSync(filePath) {
try {
return fs$2.statSync(filePath);
} catch (error) {
/* istanbul ignore next */
if (error.code !== "ENOENT") {
throw error;
}
}
} | Get stats of a given path.
@param {string} filePath The path to target file.
@returns {fs.Stats | undefined} The stats. | statSafeSync | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/bin-prettier.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js | Apache-2.0 |
function fixWindowsSlashes(pattern) {
return isWindows ? pattern.replace(/\\/g, "/") : pattern;
} | Using backslashes in globs is probably not okay, but not accepting
backslashes as path separators on Windows is even more not okay.
https://github.com/prettier/prettier/pull/6776#discussion_r380723717
https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows
@param {string} pattern | fixWindowsSlashes | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/bin-prettier.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js | Apache-2.0 |
function updateContextOptions(context, plugins, pluginSearchDirs) {
const {
options: supportOptions,
languages
} = src.getSupportInfo({
showDeprecated: true,
showUnreleased: true,
showInternal: true,
plugins,
pluginSearchDirs
});
const detailedOptionMap = normalizeDetailedOptionMap(O... | @param {Context} context
@param {string[]} plugins
@param {string[]=} pluginSearchDirs | updateContextOptions | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/bin-prettier.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/bin-prettier.js | Apache-2.0 |
function align(n, contents) {
return {
type: "align",
contents,
n
};
} | @param {number} n
@param {Doc} contents
@returns Doc | align | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/doc.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js | Apache-2.0 |
function ifBreak(breakContents, flatContents, opts) {
opts = opts || {};
return {
type: "if-break",
breakContents,
flatContents,
groupId: opts.groupId
};
} | @param {Doc} [breakContents]
@param {Doc} [flatContents]
@param {object} [opts] - TBD ???
@returns Doc | ifBreak | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/doc.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/doc.js | Apache-2.0 |
function join(sep, arr) {
const res = [];
for (let i = 0; i < arr.length; i++) {
if (i !== 0) {
res.push(sep);
}
res.push(arr[i]);
}
return concat(res);
} | @param {Doc} sep
@param {Doc[]} arr
@returns Doc | join | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/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.sp... | 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 `withPlugi... | 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 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
... | @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;
... | @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 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 (atInd... | @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 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);
... | @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 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 = skipInlineCo... | @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 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 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 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 ->... | @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 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
... | @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... | @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 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 |
make_regex = (pattern, negative, ignorecase) => {
const r = cache[pattern];
if (r) {
return r;
}
const replacers = negative ? NEGATIVE_REPLACERS : POSITIVE_REPLACERS;
const source = replacers.reduce((prev, current) => prev.replace(current[0], current[1].bind(pattern)), pattern);
return cache[pattern] ... | // > A trailing `"/**"` matches everything inside.
// #21: everything inside but it should not include the current folder
: '\\/.+'], // intermediate wildcards
[// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
// 'abc. | make_regex | 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 getFileContentOrNull(filename) {
return new Promise((resolve, reject) => {
fs$3.readFile(filename, "utf8", (error, data) => {
if (error && error.code !== "ENOENT") {
reject(createError(filename, error));
} else {
resolve(error ? null : data);
}
});
});
} | @param {string} filename
@returns {Promise<null | string>} | getFileContentOrNull | 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 createError(filename, error) {
return new Error(`Unable to read ${filename}: ${error.message}`);
} | @param {string} filename
@returns {null | string} | createError | 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 |
async function createIgnorer(ignorePath, withNodeModules) {
const ignoreContent = ignorePath ? await getFileContentOrNull_1(path$2.resolve(ignorePath)) : null;
return _createIgnorer(ignoreContent, withNodeModules);
} | @param {undefined | string} ignorePath
@param {undefined | boolean} withNodeModules | createIgnorer | 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 _createIgnorer(ignoreContent, withNodeModules) {
const ignorer = ignore().add(ignoreContent || "");
if (!withNodeModules) {
ignorer.add("node_modules");
}
return ignorer;
} | @param {null | string} ignoreContent
@param {undefined | boolean} withNodeModules | _createIgnorer | 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 |
changeToString = (to, from, name) => {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString()); // Ensure `to.toString.toString` is non-enumerable and has the same `same`
Object.defineProperty(newToString, 'name', toStringName);
Ob... | /c)
// - b matches b
// - doublestar
// - matchOne(x/y/z/c, c) -> no
// - matchOne(y/z/c, c) -> no
// - matchOne(z/c, c) -> no
// - matchOne(c, c) yes, hit
var fr = fi;
var pr = pi + 1;
if (pr === pl) {
this.debug('** at the... | changeToString | 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 parse(file) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2
/*return*/
, new Promise(function (resolve, reject) {
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
reject(er... | Parses an .ini file
@param file The location of the .ini file | parse | 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 extendProps(props, options) {
if (props === void 0) {
props = {};
}
if (options === void 0) {
options = {};
}
for (var key in options) {
if (options.hasOwnProperty(key)) {
var value = options[key];
var key2 = key.toLowerCase();
var value2 = value;... | /**}');
return fnmatch_1.default(filepath, glob, matchOptions);
}
function getConfigFileNames(filepath, options) {
var paths = [];
do {
filepath = path.dirname(filepath);
paths.push(path.join(filepath, options.config));
} while (filepath !== options.root);
return paths;
}
fun... | extendProps | 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 |
async function getFileInfo(filePath, opts) {
if (typeof filePath !== "string") {
throw new TypeError(`expect \`filePath\` to be a string, got \`${typeof filePath}\``);
}
const ignorer = await createIgnorer_1(opts.ignorePath, opts.withNodeModules);
return _getFileInfo({
ignorer,
filePath: normalizeF... | @param {string} filePath
@param {FileInfoOptions} opts
@returns {Promise<FileInfoResult>}
Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
not an object. A transformation from this array to an object is automatically done
internally by the method wrapper. See withPlugins() in index... | getFileInfo | 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 _getFileInfo({
ignorer,
filePath,
plugins,
resolveConfig = false,
sync = false
}) {
const fileInfo = {
ignored: ignorer.ignores(filePath),
inferredParser: options$1.inferParser(filePath, plugins) || null
};
if (!fileInfo.inferredParser && resolveConfig) {
if (!sync) {
return ... | @param {string} filePath
@param {FileInfoOptions} opts
@returns {FileInfoResult} | _getFileInfo | 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 |
arrayUnion = (...arguments_) => {
return [...new Set([].concat(...arguments_))];
} | Creates an array of elements split into two groups, the first of which
contains elements `predicate` returns truthy for, the second of which
contains elements `predicate` returns falsey for. The predicate is
invoked with one argument: (value).
@static
@memberOf _
@since 3.0.0
@category Collection
@param {Array|Object}... | arrayUnion | 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 templateLiteralHasNewLines(template) {
return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
} | describe.each`table`(name, fn)
describe.only.each`table`(name, fn)
describe.skip.each`table`(name, fn)
test.each`table`(name, fn)
test.only.each`table`(name, fn)
test.skip.each`table`(name, fn)
Ref: https://github.com/facebook/jest/pull/6102 | templateLiteralHasNewLines | 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 isSimpleCallArgument(node, depth) {
if (depth >= 3) {
return false;
}
const plusOne = node => isSimpleCallArgument(node, depth + 1);
const plusTwo = node => isSimpleCallArgument(node, depth + 2);
const regexpPattern = node.type === "Literal" && node.regex && node.regex.pattern || node.type ===... | @param {import('estree').Node} node
@param {number} depth
@returns {boolean} | isSimpleCallArgument | 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 lastGroupWillBreakAndOtherCallsHaveComplexArguments() {
const lastGroupNode = getLast$3(getLast$3(groups)).node;
const lastGroupDoc = getLast$3(printedGroups);
return isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$2(lastGroupDoc) && callExpressions.some((expr, index) => index !== call... | If the last call's argument is a function, it's okay to inline if it fits and there is no other function arguments.
This chain should be split:
const mapped = scopes.filter(scope => scope.value !== '').map((scope, i) => {
// multi line content
});
This chain can be inlined:
const mapped = scopes.f... | lastGroupWillBreakAndOtherCallsHaveComplexArguments | 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 printTernaryOperator(path, options, print, operatorOptions) {
const node = path.getValue();
const consequentNode = node[operatorOptions.consequentNodePropertyName];
const alternateNode = node[operatorOptions.alternateNodePropertyName];
const parts = []; // We print a ConditionalExpression in either "JS... | The following is the shared logic for
ternary operators, namely ConditionalExpression
and TSConditionalType
@typedef {Object} OperatorOptions
@property {() => Array<string | Doc>} beforeParts - Parts to print before the `?`.
@property {(breakClosingParen: boolean) => Array<string | Doc>} afterParts - Parts to print aft... | printTernaryOperator | 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 replaceQuotesInInlineComments(text) {
/** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
/** @type {State} */
let state = "initial";
/** @type {State} */
let stateToReturnFromQuotes = "initial";
let inlineCommentStartIndex;
let i... | Workaround for a bug: quotes in inline comments corrupt loc data of subsequent nodes.
This function replaces the quotes with U+FFFE and U+FFFF. Later, when the comments are printed,
their content is extracted from the original text or restored by replacing the placeholder
characters back with quotes.
- https://github.c... | replaceQuotesInInlineComments | 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 |
setOrigRange(cr, offset) {
const {
start,
end
} = this;
if (cr.length === 0 || end <= cr[0]) {
this.origStart = start;
this.origEnd = end;
return offset;
}
let i = offset;
while (i < cr.length) {
if (cr[i] > start) break;else ++i;
... | Set `origStart` and `origEnd` to point to the original source range for
this node, which may differ due to dropped CR characters.
@param {number[]} cr - Positions of dropped CR characters
@param {number} offset - Starting index of `cr` from the last call
@returns {number} - The next offset, matching the one found for ... | setOrigRange | javascript | douyu/juno | assets/public/js/prettier/v2.0.5/third-party.js | https://github.com/douyu/juno/blob/master/assets/public/js/prettier/v2.0.5/third-party.js | Apache-2.0 |
setOrigRanges(cr, offset) {
if (this.range) offset = this.range.setOrigRange(cr, offset);
if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
this.props.forEach(prop => prop.setOrigRange(cr, offset));
return offset;
} | Populates the `origStart` and `origEnd` values of all ranges for this
node. Extended by child classes to handle descendant nodes.
@param {number[]} cr - Positions of dropped CR characters
@param {number} offset - Starting index of `cr` from the last call
@returns {number} - The next offset, matching the one found for ... | setOrigRanges | 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 |
parse(context, start) {
this.context = context;
const {
src
} = context;
let offset = start + 1;
while (_Node.default.atBlank(src, offset)) {
const lineEnd = _Node.default.endOfWhiteSpace(src, offset);
if (lineEnd === '\n') offset = lineEnd + 1;else break;
}... | Parses blank lines from the source
@param {ParseContext} context
@param {number} start - Index of first \n character
@returns {number} - Index of the character after this | parse | 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 |
parse(context, start) {
this.context = context;
const {
parseNode,
src
} = context;
let {
atLineStart,
lineStart
} = context;
if (!atLineStart && this.type === constants.Type.SEQ_ITEM) this.error = new errors.YAMLSemanticError(this, 'Sequence items mus... | @param {ParseContext} context
@param {number} start - Index of first character
@returns {number} - Index of the character after this | parse | 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 |
parse(context, start) {
this.context = context;
const offset = this.parseComment(start);
this.range = new _Range.default(start, offset);
return offset;
} | Parses a comment line from the source
@param {ParseContext} context
@param {number} start - Index of first character
@returns {number} - Index of the character after this scalar | parse | 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 |
parse(context, start) {
this.context = context;
const {
src
} = context;
let offset = _Node.default.endOfIdentifier(src, start + 1);
this.valueRange = new _Range.default(start + 1, offset);
offset = _Node.default.endOfWhiteSpace(src, offset);
offset = this.parseCommen... | Parses an *alias from the source
@param {ParseContext} context
@param {number} start - Index of first character
@returns {number} - Index of the character after this scalar | parse | 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 |
parse(context, start) {
this.context = context;
const {
src
} = context;
let offset = this.parseBlockHeader(start);
offset = _Node.default.endOfWhiteSpace(src, offset);
offset = this.parseComment(offset);
offset = this.parseBlockValue(offset);
return offset;
} | Parses a block value from the source
Accepted forms are:
```
BS
block
lines
BS #comment
block
lines
```
where the block style BS matches the regexp `[|>][-+1-9]*` and block lines
are empty or have an indent level greater than `indent`.
@param {ParseContext} context
@param {number} start - Index of first character
@r... | parse | 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 |
parse(context, start) {
this.context = context;
const {
inFlow,
src
} = context;
let offset = start;
const ch = src[offset];
if (ch && ch !== '#' && ch !== '\n') {
offset = PlainValue.endOfLine(src, start, inFlow);
}
this.valueRange = new _Range.... | Parses a plain value from the source
Accepted forms are:
```
#comment
first line
first line #comment
first line
block
lines
#comment
block
lines
```
where block lines are empty or have an indent level greater than `indent`.
@param {ParseContext} context
@param {number} start - Index of first character
@returns {n... | parse | 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 strValue() {
if (!this.valueRange || !this.context) return null;
const errors$1 = [];
const {
start,
end
} = this.valueRange;
const {
indent,
src
} = this.context;
if (src[end - 1] !== '"') errors$1.push(new errors.YAMLSyntaxError(this, 'Miss... | @returns {string | { str: string, errors: YAMLSyntaxError[] }} | strValue | 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 |
parse(context, start) {
this.context = context;
const {
src
} = context;
let offset = QuoteDouble.endOfQuote(src, start + 1);
this.valueRange = new _Range.default(start, offset);
offset = _Node.default.endOfWhiteSpace(src, offset);
offset = this.parseComment(offset);
... | Parses a "double quoted" value from the source
@param {ParseContext} context
@param {number} start - Index of first character
@returns {number} - Index of the character after this scalar | parse | 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 |
parse(context, start) {
this.context = context;
const {
src
} = context;
let offset = QuoteSingle.endOfQuote(src, start + 1);
this.valueRange = new _Range.default(start, offset);
offset = _Node.default.endOfWhiteSpace(src, offset);
offset = this.parseComment(offset);
... | Parses a 'single quoted' value from the source
@param {ParseContext} context
@param {number} start - Index of first character
@returns {number} - Index of the character after this scalar | parse | 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/parse-cst' | 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 |
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 |
function parsePairs(doc, cst) {
const seq = (0, _parseSeq.default)(doc, cst);
for (let i = 0; i < seq.items.length; ++i) {
let item = seq.items[i];
if (item instanceof _Pair.default) continue;else if (item instanceof _Map$1.default) {
if (item.items.length > 1) {
const msg = 'Each... | Returns a Buffer in node and an Uint8Array in browsers
To use the resulting buffer as an image, you'll want to do something like:
const blob = new Blob([buffer], { type: 'image/jpeg' })
document.querySelector('#photo').src = URL.createObjectURL(blob) | parsePairs | 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 loop () {
for (var i = 0; i < 100; i++) {
assert.equal(Math.abs(-i), func(-i))
}
(typeof setImmediate != 'undefined' ? setImmediate : process.nextTick)(loop)
} | This example creates an ffi.Callback from the "Math.abs()" JavaScript function
then creates a ffi.ForeignFunction from that callback function pointer.
The result is basically the same as calling "Math.abs()" directly, haha!
This example should basically just run forever, in an endless loop.
This file is a "pummel tes... | loop | javascript | node-ffi/node-ffi | example/abs.js | https://github.com/node-ffi/node-ffi/blob/master/example/abs.js | MIT |
function Callback (retType, argTypes, abi, func) {
debug('creating new Callback')
if (typeof abi === 'function') {
func = abi
abi = void(0)
}
// check args
assert(!!retType, 'expected a return "type" object as the first argument')
assert(Array.isArray(argTypes), 'expected Array of arg "type" objec... | Turns a JavaScript function into a C function pointer.
The function pointer may be used in other C functions that
accept C callback functions. | Callback | javascript | node-ffi/node-ffi | lib/callback.js | https://github.com/node-ffi/node-ffi/blob/master/lib/callback.js | MIT |
function CIF (rtype, types, abi) {
debug('creating `ffi_cif *` instance')
// the return and arg types are expected to be coerced at this point...
assert(!!rtype, 'expected a return "type" object as the first argument')
assert(Array.isArray(types), 'expected an Array of arg "type" objects as the second argument... | JS wrapper for the `ffi_prep_cif` function.
Returns a Buffer instance representing a `ffi_cif *` instance. | CIF | javascript | node-ffi/node-ffi | lib/cif.js | https://github.com/node-ffi/node-ffi/blob/master/lib/cif.js | MIT |
function CIF_var (rtype, types, numFixedArgs, abi) {
debug('creating `ffi_cif *` instance with `ffi_prep_cif_var()`')
// the return and arg types are expected to be coerced at this point...
assert(!!rtype, 'expected a return "type" object as the first argument')
assert(Array.isArray(types), 'expected an Array ... | JS wrapper for the `ffi_prep_cif_var` function.
Returns a Buffer instance representing a variadic `ffi_cif *` instance. | CIF_var | javascript | node-ffi/node-ffi | lib/cif_var.js | https://github.com/node-ffi/node-ffi/blob/master/lib/cif_var.js | MIT |
function DynamicLibrary (path, mode) {
if (!(this instanceof DynamicLibrary)) {
return new DynamicLibrary(path, mode)
}
debug('new DynamicLibrary()', path, mode)
if (null == mode) {
mode = DynamicLibrary.FLAGS.RTLD_LAZY
}
this._handle = dlopen(path, mode)
assert(Buffer.isBuffer(this._handle), 'e... | `DynamicLibrary` loads and fetches function pointers for dynamic libraries
(.so, .dylib, etc). After the libray's function pointer is acquired, then you
call `get(symbol)` to retreive a pointer to an exported symbol. You need to
call `get___()` on the pointer to dereference it into its actual value, or
turn the pointer... | DynamicLibrary | javascript | node-ffi/node-ffi | lib/dynamic_library.js | https://github.com/node-ffi/node-ffi/blob/master/lib/dynamic_library.js | MIT |
function ForeignFunction (funcPtr, returnType, argTypes, abi) {
debug('creating new ForeignFunction', funcPtr)
// check args
assert(Buffer.isBuffer(funcPtr), 'expected Buffer as first argument')
assert(!!returnType, 'expected a return "type" object as the second argument')
assert(Array.isArray(argTypes), 'ex... | Represents a foreign function in another library. Manages all of the aspects
of function execution, including marshalling the data parameters for the
function into native types and also unmarshalling the return from function
execution. | ForeignFunction | javascript | node-ffi/node-ffi | lib/foreign_function.js | https://github.com/node-ffi/node-ffi/blob/master/lib/foreign_function.js | MIT |
function VariadicForeignFunction (funcPtr, returnType, fixedArgTypes, abi) {
debug('creating new VariadicForeignFunction', funcPtr)
// the cache of ForeignFunction instances that this
// VariadicForeignFunction has created so far
var cache = {}
// check args
assert(Buffer.isBuffer(funcPtr), 'expected Buff... | For when you want to call to a C function with variable amount of arguments.
i.e. `printf()`.
This function takes care of caching and reusing ForeignFunction instances that
contain the same ffi_type argument signature. | VariadicForeignFunction | javascript | node-ffi/node-ffi | lib/foreign_function_var.js | https://github.com/node-ffi/node-ffi/blob/master/lib/foreign_function_var.js | MIT |
function Function (retType, argTypes, abi) {
if (!(this instanceof Function)) {
return new Function(retType, argTypes, abi)
}
debug('creating new FunctionType')
// check args
assert(!!retType, 'expected a return "type" object as the first argument')
assert(Array.isArray(argTypes), 'expected Array of a... | Creates and returns a "type" object for a C "function pointer".
@api public | Function | javascript | node-ffi/node-ffi | lib/function.js | https://github.com/node-ffi/node-ffi/blob/master/lib/function.js | MIT |
function Library (libfile, funcs, lib) {
debug('creating Library object for', libfile)
if (libfile && libfile.indexOf(EXT) === -1) {
debug('appending library extension to library name', EXT)
libfile += EXT
}
if (!lib) {
lib = {}
}
var dl = new DynamicLibrary(libfile || null, RTLD_NOW)
Objec... | Provides a friendly abstraction/API on-top of DynamicLibrary and
ForeignFunction. | Library | javascript | node-ffi/node-ffi | lib/library.js | https://github.com/node-ffi/node-ffi/blob/master/lib/library.js | MIT |
function Type (type) {
type = ref.coerceType(type)
debug('Type()', type.name || type)
assert(type.indirection >= 1, 'invalid "type" given: ' + (type.name || type))
var rtn
// first we assume it's a regular "type". if the "indirection" is greater than
// 1, then we can just use "pointer" ffi_type, otherwise... | Returns a `ffi_type *` Buffer appropriate for the given "type".
@param {Type|String} type A "ref" type (or string) to get the `ffi_type` for
@return {Buffer} A buffer pointing to a `ffi_type` instance for "type"
@api private | Type | javascript | node-ffi/node-ffi | lib/type.js | https://github.com/node-ffi/node-ffi/blob/master/lib/type.js | MIT |
proxy = function () {
debug('invoking proxy function')
if (arguments.length !== numArgs) {
throw new TypeError('Expected ' + numArgs +
' arguments, got ' + arguments.length)
}
// storage buffers for input arguments and the return value
var result = new Buffer(resultSize)
, ar... | This is the actual JS function that gets returned.
It handles marshalling input arguments into C values,
and unmarshalling the return value back into a JS value | proxy | javascript | node-ffi/node-ffi | lib/_foreign_function.js | https://github.com/node-ffi/node-ffi/blob/master/lib/_foreign_function.js | MIT |
function finish () {
kill()
gc() // now ensure the inner "cb" Buffer is collected
// should throw an Error asynchronously!,
// because the callback has been garbage collected.
// hijack the "uncaughtException" event for this test
var listeners = process.listeners('uncaughtException... | We should make sure that callbacks or errors gets propagated back to node's main thread
when it called on a non libuv native thread.
See: https://github.com/node-ffi/node-ffi/issues/199 | finish | javascript | node-ffi/node-ffi | test/callback.js | https://github.com/node-ffi/node-ffi/blob/master/test/callback.js | MIT |
function finish () {
bindings.call_cb()
assert.equal(4, invokeCount)
kill()
gc() // now ensure the inner "cb" Buffer is collected
// should throw an Error synchronously
try {
bindings.call_cb()
assert(false) // shouldn't get here
} catch (e) ... | See https://github.com/rbranson/node-ffi/issues/72.
This is a tough issue. If we pass the ffi_closure Buffer to some foreign
C function, we really don't know *when* it's safe to dispose of the Buffer,
so it's left up to the developer.
In this case, we wrap the responsibility in a simple "kill()" function
that, when ca... | finish | javascript | node-ffi/node-ffi | test/callback.js | https://github.com/node-ffi/node-ffi/blob/master/test/callback.js | MIT |
function getNearestIndex(allPoints, intersectedIndexes, ray, maxDistanceFromRay) {
if (intersectedIndexes.length === 0) return;
// This is not necessary the fastest solution, but in practice it is very fast
intersectedIndexes.sort(byProximityToRay);
var candidate = intersectedIndexes[0];
if (getDistanceToR... | Based on octree search results tries to find index of a point which is
nearest to the ray in z-direction, and is closer than maxDistanceFromRay | getNearestIndex | javascript | anvaka/pm | src/galaxy/native/getNearestIndex.js | https://github.com/anvaka/pm/blob/master/src/galaxy/native/getNearestIndex.js | MIT |
function setOrGetLinksVisible(newValue) {
if (newValue === undefined) {
return linksVisible;
}
if (newValue) {
scene.add(linkMesh);
} else {
scene.remove(linkMesh);
}
linksVisible = newValue;
return linksVisible;
} | Gets or sets links visibility. If you pass truthy argument
sets visibility to that value. Otherwise returns current visibility | setOrGetLinksVisible | javascript | anvaka/pm | src/galaxy/native/lineView.js | https://github.com/anvaka/pm/blob/master/src/galaxy/native/lineView.js | MIT |
function sceneRenderer(container) {
var renderer, positions, graphModel, touchControl;
var hitTest, lastHighlight, lastHighlightSize, cameraPosition;
var lineView, links, lineViewNeedsUpdate;
var queryUpdateId = setInterval(updateQuery, 200);
appEvents.positionsDownloaded.on(setPositions);
appEvents.linksD... | This is a bridge between ultrafast particle renderer and react world.
It listens to graph loading events. Once graph positions are loaded it calls
native renderer to show the positions.
It also listens to native renderer for user interaction. When user hovers
over a node or clicks on it - it reports user actions back... | sceneRenderer | javascript | anvaka/pm | src/galaxy/native/renderer.js | https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js | MIT |
function sceneKeyboardBinding(container) {
var api = {
destroy: destroy
};
var lastShiftKey = false;
container.addEventListener('keydown', keydown, false);
container.addEventListener('keyup', keyup, false);
return api;
function destroy() {
container.removeEventListener('keydown', keydown, false)... | This file defines special keyboard bindings for the scene. Most movement
keyboard bindings are handled by `unrender` module (e.g. WASD). Here
we handle additional keyboard shortcuts. For example toggle steering mode | sceneKeyboardBinding | javascript | anvaka/pm | src/galaxy/native/sceneKeyboardBinding.js | https://github.com/anvaka/pm/blob/master/src/galaxy/native/sceneKeyboardBinding.js | MIT |
function nodeDetailsStore() {
var api = {
getSelectedNode: getSelectedNode
};
var currentNodeId, degreeVisible = false,
currentConnectionType;
appEvents.selectNode.on(updateDetails);
appEvents.showDegree.on(updateDegreeDetails);
eventify(api);
return api;
function updateDetails(nodeId) {
... | Prepares data for selected node details | nodeDetailsStore | javascript | anvaka/pm | src/galaxy/nodeDetails/nodeDetailsStore.js | https://github.com/anvaka/pm/blob/master/src/galaxy/nodeDetails/nodeDetailsStore.js | MIT |
function eventMirror(eventNames, eventBus) {
var events = Object.create(null);
eventNames.forEach(setActiveCommand);
return events;
function setActiveCommand(eventName, idx) {
events[eventName] = {
id: eventName,
fire: fire(eventName),
on: on(eventName),
off: off(eventName)
};
... | This is a syntax sugar wrapper which allows consumer to register events on
a given event bus, later clients can have rich API to consume events.
For example:
// Create a simple event bus:
var myBus = require('ngraph.events')({});
// Register several events on this bus:
var events = eventMirror(['sayHi', 'sayBye'], m... | eventMirror | javascript | anvaka/pm | src/galaxy/service/eventMirror.js | https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js | MIT |
function graph(rawGraphLoaderData) {
var {labels, outLinks, inLinks, positions} = rawGraphLoaderData;
var empty = [];
var api = {
getNodeInfo: getNodeInfo,
getConnected: getConnected,
find: find,
findLinks: findLinks
};
return api;
function findLinks(from, to) {
return linkFinder(from... | Wrapper on top of graph data. Not sure where it will go yet. | graph | javascript | anvaka/pm | src/galaxy/service/graph.js | https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js | MIT |
function loadGraph(name, progress) {
var positions, labels;
var outLinks = [];
var inLinks = [];
// todo: handle errors
var manifestEndpoint = config.dataUrl + name;
var galaxyEndpoint = manifestEndpoint;
var manifest;
return loadManifest()
.then(loadPositions)
.then(loadLinks)
.then(load... | @param {string} name of the graph to be downloaded
@param {progressCallback} progress notifies when download progress event is
received
@param {completeCallback} complete notifies when all graph files are downloaded | loadGraph | javascript | anvaka/pm | src/galaxy/service/graphLoader.js | https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js | MIT |
function request(url, options) {
if (!options) options = {};
return new Promise(download);
function download(resolve, reject) {
var req = new XMLHttpRequest();
if (typeof options.progress === 'function') {
req.addEventListener("progress", updateProgress, false);
}
req.addEventListener("l... | A very basic ajax client with promises and progress reporting. | request | javascript | anvaka/pm | src/galaxy/service/request.js | https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js | MIT |
function sceneStore() {
var loadInProgress = true;
var currentGraphName;
var unknownNodeInfo = {
inDegree: '?',
outDegree: '?'
}
var graph;
var api = {
isLoading: isLoading,
getGraph: getGraph,
getGraphName: getGraphName,
getNodeInfo: getNodeInfo,
getConnected: getConnected,
... | Manages graph model life cycle. The low-level rendering of the particles
is handled by ../native/renderer.js | sceneStore | javascript | anvaka/pm | src/galaxy/store/scene.js | https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js | MIT |
function ProcessError(code, message) {
const callee = arguments.callee;
Error.apply(this, [message]);
Error.captureStackTrace(this, callee);
this.code = code;
this.message = message;
this.name = callee.name;
} | @function Object() { [native code] }
@param {number} code Error code.
@param {string} message Error message. | ProcessError | javascript | tschaub/gh-pages | lib/git.js | https://github.com/tschaub/gh-pages/blob/master/lib/git.js | MIT |
function spawn(exe, args, cwd) {
return new Promise((resolve, reject) => {
const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()});
const buffer = [];
child.stderr.on('data', (chunk) => {
buffer.push(chunk.toString());
});
child.stdout.on('data', (chunk) => {
buffer.push(chunk.t... | Util function for handling spawned processes as promises.
@param {string} exe Executable.
@param {Array<string>} args Arguments.
@param {string} cwd Working directory.
@return {Promise} A promise. | spawn | javascript | tschaub/gh-pages | lib/git.js | https://github.com/tschaub/gh-pages/blob/master/lib/git.js | MIT |
function Git(cwd, cmd) {
this.cwd = cwd;
this.cmd = cmd || 'git';
this.output = '';
} | Create an object for executing git commands.
@param {string} cwd Repository directory.
@param {string} cmd Git executable (full path if not already on path).
@function Object() { [native code] } | Git | javascript | tschaub/gh-pages | lib/git.js | https://github.com/tschaub/gh-pages/blob/master/lib/git.js | MIT |
function getCacheDir(optPath) {
const dir = findCacheDir({name: 'gh-pages'});
if (!optPath) {
return dir;
}
return path.join(dir, filenamify(optPath));
} | Get the cache directory.
@param {string} [optPath] Optional path.
@return {string} The full path to the cache directory. | getCacheDir | javascript | tschaub/gh-pages | lib/index.js | https://github.com/tschaub/gh-pages/blob/master/lib/index.js | MIT |
function done(err) {
try {
callback(err);
} catch (err2) {
log('Publish callback threw: %s', err2.message);
}
} | Push a git branch to a remote (pushes gh-pages by default).
@param {string} basePath The base path.
@param {Object} config Publish options.
@param {Function} callback Callback.
@return {Promise} A promise. | done | javascript | tschaub/gh-pages | lib/index.js | https://github.com/tschaub/gh-pages/blob/master/lib/index.js | MIT |
function uniqueDirs(files) {
const dirs = new Set();
files.forEach((filepath) => {
const parts = path.dirname(filepath).split(path.sep);
let partial = parts[0] || '/';
dirs.add(partial);
for (let i = 1, ii = parts.length; i < ii; ++i) {
partial = path.join(partial, parts[i]);
dirs.add(pa... | Generate a list of unique directory paths given a list of file paths.
@param {Array<string>} files List of file paths.
@return {Array<string>} List of directory paths. | uniqueDirs | javascript | tschaub/gh-pages | lib/util.js | https://github.com/tschaub/gh-pages/blob/master/lib/util.js | MIT |
function byShortPath(a, b) {
const aParts = a.split(path.sep);
const bParts = b.split(path.sep);
const aLength = aParts.length;
const bLength = bParts.length;
let cmp = 0;
if (aLength < bLength) {
cmp = -1;
} else if (aLength > bLength) {
cmp = 1;
} else {
let aPart, bPart;
for (let i = ... | Sort function for paths. Sorter paths come first. Paths of equal length are
sorted alphanumerically in path segment order.
@param {string} a First path.
@param {string} b Second path.
@return {number} Comparison. | byShortPath | javascript | tschaub/gh-pages | lib/util.js | https://github.com/tschaub/gh-pages/blob/master/lib/util.js | MIT |
function dirsToCreate(files) {
return uniqueDirs(files).sort(byShortPath);
} | Generate a list of directories to create given a list of file paths.
@param {Array<string>} files List of file paths.
@return {Array<string>} List of directory paths ordered by path length. | dirsToCreate | javascript | tschaub/gh-pages | lib/util.js | https://github.com/tschaub/gh-pages/blob/master/lib/util.js | MIT |
function copyFile(obj, callback) {
let called = false;
function done(err) {
if (!called) {
called = true;
callback(err);
}
}
const read = fs.createReadStream(obj.src);
read.on('error', (err) => {
done(err);
});
const write = fs.createWriteStream(obj.dest);
write.on('error', (er... | Copy a file.
@param {Object} obj Object with src and dest properties.
@param {function(Error):void} callback Callback | copyFile | javascript | tschaub/gh-pages | lib/util.js | https://github.com/tschaub/gh-pages/blob/master/lib/util.js | MIT |
function makeDir(path, callback) {
fs.mkdir(path, (err) => {
if (err) {
// check if directory exists
fs.stat(path, (err2, stat) => {
if (err2 || !stat.isDirectory()) {
callback(err);
} else {
callback();
}
});
} else {
callback();
}
});... | Make directory, ignoring errors if directory already exists.
@param {string} path Directory path.
@param {function(Error):void} callback Callback. | makeDir | javascript | tschaub/gh-pages | lib/util.js | https://github.com/tschaub/gh-pages/blob/master/lib/util.js | MIT |
function mkdtemp() {
return new Promise((resolve, reject) => {
tmp.dir({unsafeCleanup: true}, (err, tmpPath) => {
if (err) {
return reject(err);
}
resolve(tmpPath);
});
});
} | @return {Promise<string>} A promise that resolves to the path. | mkdtemp | javascript | tschaub/gh-pages | test/helper.js | https://github.com/tschaub/gh-pages/blob/master/test/helper.js | MIT |
function setupRepo(fixtureName, options) {
const branch = options.branch || 'gh-pages';
const userEmail = (options.user && options.user.email) || 'user@email.com';
const userName = (options.user && options.user.name) || 'User Name';
return mkdtemp()
.then((dir) => {
const fixturePath = path.join(fixtu... | Creates a git repo with the contents of a fixture.
@param {string} fixtureName Name of fixture.
@param {Object} options Repo options.
@return {Promise<string>} A promise for the path to the repo. | setupRepo | javascript | tschaub/gh-pages | test/helper.js | https://github.com/tschaub/gh-pages/blob/master/test/helper.js | MIT |
function setupRemote(fixtureName, options) {
const branch = options.branch || 'gh-pages';
return setupRepo(fixtureName, options).then((dir) =>
mkdtemp()
.then((remote) => {
return new Git(remote).exec('init', '--bare').then(() => remote);
})
.then((remote) => {
const git = new ... | Creates a git repo with the contents of a fixture and pushes to a remote.
@param {string} fixtureName Name of the fixture.
@param {Object} options Repo options.
@return {Promise} A promise. | setupRemote | javascript | tschaub/gh-pages | test/helper.js | https://github.com/tschaub/gh-pages/blob/master/test/helper.js | MIT |
function assertContentsMatch(dir, url, branch) {
return mkdtemp()
.then((root) => {
const clone = path.join(root, 'repo');
const options = {git: 'git', remote: 'origin', depth: 1};
return Git.clone(url, clone, branch, options);
})
.then((git) => {
const comparison = compare(dir, gi... | @param {string} dir The dir.
@param {string} url The url.
@param {string} branch The branch.
@return {Promise} A promise. | assertContentsMatch | javascript | tschaub/gh-pages | test/helper.js | https://github.com/tschaub/gh-pages/blob/master/test/helper.js | MIT |
function Maplace(args) {
this.VERSION = '@VERSION';
this.loaded = false;
this.markers = [];
this.circles = [];
this.oMap = false;
this.view_all_key = 'all';
this.infowindow = null;
this.maxZIndex = 0;
this.ln = 0;
this.oMap = false;
... | Create a new instance
@class Maplace
@constructor | Maplace | javascript | danielemoraschi/maplace.js | src/maplace.js | https://github.com/danielemoraschi/maplace.js/blob/master/src/maplace.js | MIT |
resolveTests = testComponents => {
if (!isArray(testComponents)) {
return false
}
forEach(testComponents, testComponent => forEach(testComponent, fn => fn()))
} | Calls all reactcards Component tests for mocha/jasmine cli tests
resolveTests calls all component tests instead of having to manually execute all of them
Import all Component tests and resolveTests will run all functions.
import resolveTests from '../../src/utils/resolveTests'
import * as advanced from './a... | resolveTests | javascript | steos/reactcards | src/utils/resolveTests.js | https://github.com/steos/reactcards/blob/master/src/utils/resolveTests.js | BSD-3-Clause |
chainWebpack(config) {
// it can improve the speed of the first screen, it is recommended to turn on preload
config.plugin('preload').tap(() => [
{
rel: 'preload',
// to ignore runtime.js
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
... | You will need to set publicPath if you plan to deploy your site under a sub path,
for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
then publicPath should be set to "/bar/".
In most cases please use '/' !!!
Detail: https://cli.vuejs.org/config/#publicpath | chainWebpack | javascript | PanJiaChen/vue-admin-template | vue.config.js | https://github.com/PanJiaChen/vue-admin-template/blob/master/vue.config.js | MIT |
generateSign = (params) => {
const keys = Object.keys(params).filter(
(key) => key !== 'format' || key !== 'callback'
);
// params has to be ordered alphabetically
keys.sort();
const o = keys.reduce((r, key) => r + key + params[key], '');
// append secret
return forge.md5
.cre... | Computes string for signing request
See https://www.last.fm/api/authspec#8 | generateSign | javascript | listen1/listen1_chrome_extension | js/lastfm.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/lastfm.js | MIT |
play(idx) {
this.load(idx);
const data = this.playlist[this.index];
if (!data.howl || !this._media_uri_list[data.id]) {
this.retrieveMediaUrl(this.index, true);
} else {
this.finishLoad(this.index, true);
}
} | Play a song in the playlist.
@param {Number} index Index of the song in the playlist
(leave empty to play the first or current). | play | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
load(idx) {
let index = typeof idx === 'number' ? idx : this.index;
if (index < 0) return;
if (!this.playlist[index]) {
index = 0;
}
// stop when load new track to avoid multiple songs play in same time
if (index !== this.index) {
Howler.unload();
}
this.i... | Load a song from the playlist.
@param {Number} index Index of the song in the playlist
(leave empty to load the first or current). | load | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
skip(direction) {
Howler.unload();
// Get the next track based on the direction of the track.
const nextIndexFn = (idx) => {
const l = this.playlist.length;
const random_mode = this._loop_mode === 2 || direction === 'random';
let rdx = idx;
if (random_mode) {
... | Skip to the next or previous track.
@param {String} direction 'next' or 'prev'. | skip | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
set volume(val) {
// Update the global volume (affecting all Howls).
if (typeof val === 'number') {
Howler.volume(val);
this.sendVolumeEvent();
this.sendFrameUpdate();
}
} | Set the volume and update the volume slider display.
@param {Number} val Volume between 0 and 1. | volume | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
seek(per) {
if (!this.currentHowl) return;
// Get the Howl we want to manipulate.
const audio = this.currentHowl;
// Convert the percent into a seek position.
// if (audio.playing()) {
// }
audio.seek(audio.duration() * per);
} | Seek to a new position in the currently playing track.
@param {Number} per Percentage through the song to skip. | seek | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
seekTime(seconds) {
if (!this.currentHowl) return;
const audio = this.currentHowl;
audio.seek(seconds);
} | Seek to a new position in the currently playing track.
@param {Number} seconds Seconds through the song to skip. | seekTime | javascript | listen1/listen1_chrome_extension | js/player_thread.js | https://github.com/listen1/listen1_chrome_extension/blob/master/js/player_thread.js | MIT |
function uBlockOrigin_add() {
js_adsRemove(uBlockOrigin.chn0abortcurrentscript);
js_adsRemove(uBlockOrigin.chn0setconstant);
js_adsRemove(uBlockOrigin.abortcurrentscript);
js_adsRemove(uBlockOrigin.abortcurrentscript);
js_adsRemove(uBlockOrigin.abortcurrentscript);
js_adsRemove(uBlockOrigin.abor... | ---------------------------
Author: limbopro
View: https://limbopro.com/archives/12904.html
--------------------------- | uBlockOrigin_add | javascript | limbopro/Adblock4limbo | Adguard/Adblock4limbo.user.10.15.2023.js | https://github.com/limbopro/Adblock4limbo/blob/master/Adguard/Adblock4limbo.user.10.15.2023.js | MIT |
function isInIFrame(w) {
w = w || topWindow;
return w !== w.top;
} | Loads a shader.
@param {WebGLRenderingContext} gl The WebGLRenderingContext to use.
@param {string} shaderSource The shader source.
@param {number} shaderType The type of shader.
@param {module:webgl-utils.ErrorCallback} opt_errorCallback callback for errors.
@return {WebGLShader} The created shader. | isInIFrame | javascript | limbopro/Adblock4limbo | Adguard/twdl.webgl.user.js | https://github.com/limbopro/Adblock4limbo/blob/master/Adguard/twdl.webgl.user.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.