repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tgriesser/knex | src/query/joinclause.js | JoinClause | function JoinClause(table, type, schema) {
this.schema = schema;
this.table = table;
this.joinType = type;
this.and = this;
this.clauses = [];
} | javascript | function JoinClause(table, type, schema) {
this.schema = schema;
this.table = table;
this.joinType = type;
this.and = this;
this.clauses = [];
} | [
"function",
"JoinClause",
"(",
"table",
",",
"type",
",",
"schema",
")",
"{",
"this",
".",
"schema",
"=",
"schema",
";",
"this",
".",
"table",
"=",
"table",
";",
"this",
".",
"joinType",
"=",
"type",
";",
"this",
".",
"and",
"=",
"this",
";",
"this... | The "JoinClause" is an object holding any necessary info about a join, including the type, and any associated tables & columns being joined. | [
"The",
"JoinClause",
"is",
"an",
"object",
"holding",
"any",
"necessary",
"info",
"about",
"a",
"join",
"including",
"the",
"type",
"and",
"any",
"associated",
"tables",
"&",
"columns",
"being",
"joined",
"."
] | 6a4fecfe7822442ee5c43d924958eadfe6e17a93 | https://github.com/tgriesser/knex/blob/6a4fecfe7822442ee5c43d924958eadfe6e17a93/src/query/joinclause.js#L9-L15 | train | A join clause | [
30522,
3853,
3693,
20464,
20559,
2063,
1006,
2795,
1010,
2828,
1010,
8040,
28433,
1007,
1063,
2023,
1012,
8040,
28433,
1027,
8040,
28433,
1025,
2023,
1012,
2795,
1027,
2795,
1025,
2023,
1012,
4101,
18863,
1027,
2828,
1025,
2023,
1012,
1998,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/modifiers/summary/removeArticle.js | removeArticle | function removeArticle(summary, level) {
// Coerce to level
level = is.string(level)? level : level.getLevel();
var parent = summary.getParent(level);
var articles = parent.getArticles();
// Find the index to remove
var index = articles.findIndex(function(art) {
return art.getLevel() === level;
});
if (index === -1) {
return summary;
}
// Remove from children
articles = articles.remove(index);
parent = parent.set('articles', articles);
// Reindex the level from here
parent = indexArticleLevels(parent);
return mergeAtLevel(summary, parent.getLevel(), parent);
} | javascript | function removeArticle(summary, level) {
// Coerce to level
level = is.string(level)? level : level.getLevel();
var parent = summary.getParent(level);
var articles = parent.getArticles();
// Find the index to remove
var index = articles.findIndex(function(art) {
return art.getLevel() === level;
});
if (index === -1) {
return summary;
}
// Remove from children
articles = articles.remove(index);
parent = parent.set('articles', articles);
// Reindex the level from here
parent = indexArticleLevels(parent);
return mergeAtLevel(summary, parent.getLevel(), parent);
} | [
"function",
"removeArticle",
"(",
"summary",
",",
"level",
")",
"{",
"// Coerce to level",
"level",
"=",
"is",
".",
"string",
"(",
"level",
")",
"?",
"level",
":",
"level",
".",
"getLevel",
"(",
")",
";",
"var",
"parent",
"=",
"summary",
".",
"getParent"... | Remove an article from a level.
@param {Summary} summary
@param {String|SummaryArticle} level: level to remove
@return {Summary} | [
"Remove",
"an",
"article",
"from",
"a",
"level",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/removeArticle.js#L12-L35 | train | Remove an article from a summary | [
30522,
3853,
6366,
8445,
25128,
1006,
12654,
1010,
2504,
1007,
1063,
1013,
1013,
24873,
19170,
2000,
2504,
2504,
1027,
2003,
1012,
5164,
1006,
2504,
1007,
1029,
2504,
1024,
2504,
1012,
2131,
20414,
2884,
1006,
1007,
1025,
13075,
6687,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/Pane.js | _ensurePaneIsFocused | function _ensurePaneIsFocused(paneId) {
var pane = MainViewManager._getPane(paneId);
// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the given pane.
pane.focus();
this._lastFocusedElement = pane.$el[0];
MainViewManager.setActivePaneId(paneId);
}, 1);
} | javascript | function _ensurePaneIsFocused(paneId) {
var pane = MainViewManager._getPane(paneId);
// Defer the focusing until other focus events have occurred.
setTimeout(function () {
// Focus has most likely changed: give it back to the given pane.
pane.focus();
this._lastFocusedElement = pane.$el[0];
MainViewManager.setActivePaneId(paneId);
}, 1);
} | [
"function",
"_ensurePaneIsFocused",
"(",
"paneId",
")",
"{",
"var",
"pane",
"=",
"MainViewManager",
".",
"_getPane",
"(",
"paneId",
")",
";",
"// Defer the focusing until other focus events have occurred.",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"// Focus has mos... | Ensures that the given pane is focused after other focus related events occur
@params {string} paneId - paneId of the pane to focus
@private | [
"Ensures",
"that",
"the",
"given",
"pane",
"is",
"focused",
"after",
"other",
"focus",
"related",
"events",
"occur"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/Pane.js#L216-L226 | train | Ensure that the pane is focused. | [
30522,
3853,
1035,
5676,
9739,
17580,
14876,
7874,
2098,
1006,
6090,
7416,
2094,
1007,
1063,
13075,
6090,
2063,
1027,
2364,
8584,
24805,
4590,
1012,
1035,
2131,
9739,
2063,
1006,
6090,
7416,
2094,
1007,
1025,
1013,
1013,
13366,
2121,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/arrow-spacing.js | spaces | function spaces(node) {
const tokens = getTokens(node);
const countSpace = countSpaces(tokens);
if (rule.before) {
// should be space(s) before arrow
if (countSpace.before === 0) {
context.report({
node: tokens.before,
messageId: "expectedBefore",
fix(fixer) {
return fixer.insertTextBefore(tokens.arrow, " ");
}
});
}
} else {
// should be no space before arrow
if (countSpace.before > 0) {
context.report({
node: tokens.before,
messageId: "unexpectedBefore",
fix(fixer) {
return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
}
});
}
}
if (rule.after) {
// should be space(s) after arrow
if (countSpace.after === 0) {
context.report({
node: tokens.after,
messageId: "expectedAfter",
fix(fixer) {
return fixer.insertTextAfter(tokens.arrow, " ");
}
});
}
} else {
// should be no space after arrow
if (countSpace.after > 0) {
context.report({
node: tokens.after,
messageId: "unexpectedAfter",
fix(fixer) {
return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
}
});
}
}
} | javascript | function spaces(node) {
const tokens = getTokens(node);
const countSpace = countSpaces(tokens);
if (rule.before) {
// should be space(s) before arrow
if (countSpace.before === 0) {
context.report({
node: tokens.before,
messageId: "expectedBefore",
fix(fixer) {
return fixer.insertTextBefore(tokens.arrow, " ");
}
});
}
} else {
// should be no space before arrow
if (countSpace.before > 0) {
context.report({
node: tokens.before,
messageId: "unexpectedBefore",
fix(fixer) {
return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
}
});
}
}
if (rule.after) {
// should be space(s) after arrow
if (countSpace.after === 0) {
context.report({
node: tokens.after,
messageId: "expectedAfter",
fix(fixer) {
return fixer.insertTextAfter(tokens.arrow, " ");
}
});
}
} else {
// should be no space after arrow
if (countSpace.after > 0) {
context.report({
node: tokens.after,
messageId: "unexpectedAfter",
fix(fixer) {
return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
}
});
}
}
} | [
"function",
"spaces",
"(",
"node",
")",
"{",
"const",
"tokens",
"=",
"getTokens",
"(",
"node",
")",
";",
"const",
"countSpace",
"=",
"countSpaces",
"(",
"tokens",
")",
";",
"if",
"(",
"rule",
".",
"before",
")",
"{",
"// should be space(s) before arrow",
"... | Determines whether space(s) before after arrow(`=>`) is satisfy rule.
if before/after value is `true`, there should be space(s).
if before/after value is `false`, there should be no space.
@param {ASTNode} node The arrow function node.
@returns {void} | [
"Determines",
"whether",
"space",
"(",
"s",
")",
"before",
"after",
"arrow",
"(",
"=",
">",
")",
"is",
"satisfy",
"rule",
".",
"if",
"before",
"/",
"after",
"value",
"is",
"true",
"there",
"should",
"be",
"space",
"(",
"s",
")",
".",
"if",
"before",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/arrow-spacing.js#L100-L155 | train | Check if node has spaces | [
30522,
3853,
7258,
1006,
13045,
1007,
1063,
9530,
3367,
19204,
2015,
1027,
2131,
18715,
6132,
1006,
13045,
1007,
1025,
9530,
3367,
9294,
15327,
1027,
9294,
15327,
2015,
1006,
19204,
2015,
1007,
1025,
2065,
1006,
3627,
1012,
2077,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/node/TernNodeDomain.js | getFile | function getFile(name, next) {
// save the callback
fileCallBacks[name] = next;
setImmediate(function () {
try {
ExtractContent.extractContent(name, handleGetFile, _requestFileContent);
} catch (error) {
console.log(error);
}
});
} | javascript | function getFile(name, next) {
// save the callback
fileCallBacks[name] = next;
setImmediate(function () {
try {
ExtractContent.extractContent(name, handleGetFile, _requestFileContent);
} catch (error) {
console.log(error);
}
});
} | [
"function",
"getFile",
"(",
"name",
",",
"next",
")",
"{",
"// save the callback",
"fileCallBacks",
"[",
"name",
"]",
"=",
"next",
";",
"setImmediate",
"(",
"function",
"(",
")",
"{",
"try",
"{",
"ExtractContent",
".",
"extractContent",
"(",
"name",
",",
"... | Provide the contents of the requested file to tern
@param {string} name - the name of the file
@param {Function} next - the function to call with the text of the file
once it has been read in. | [
"Provide",
"the",
"contents",
"of",
"the",
"requested",
"file",
"to",
"tern"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L133-L144 | train | get a file from the server | [
30522,
3853,
2131,
8873,
2571,
1006,
2171,
1010,
2279,
1007,
1063,
1013,
1013,
3828,
1996,
2655,
5963,
5371,
9289,
20850,
8684,
2015,
1031,
2171,
1033,
1027,
2279,
1025,
2275,
5714,
16969,
2618,
1006,
3853,
1006,
1007,
1063,
3046,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_HyperlinkString | function parse_HyperlinkString(blob) {
var len = blob.read_shift(4);
var o = len > 0 ? blob.read_shift(len, 'utf16le').replace(chr0, "") : "";
return o;
} | javascript | function parse_HyperlinkString(blob) {
var len = blob.read_shift(4);
var o = len > 0 ? blob.read_shift(len, 'utf16le').replace(chr0, "") : "";
return o;
} | [
"function",
"parse_HyperlinkString",
"(",
"blob",
")",
"{",
"var",
"len",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"var",
"o",
"=",
"len",
">",
"0",
"?",
"blob",
".",
"read_shift",
"(",
"len",
",",
"'utf16le'",
")",
".",
"replace",
"(",
... | /* [MS-OSHARED] 2.3.7.9 HyperlinkString | [
"/",
"*",
"[",
"MS",
"-",
"OSHARED",
"]",
"2",
".",
"3",
".",
"7",
".",
"9",
"HyperlinkString"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5499-L5503 | train | Parse Hyperlink String | [
30522,
3853,
11968,
3366,
1035,
23760,
13767,
3367,
4892,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
18798,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1018,
1007,
1025,
13075,
1051,
1027,
18798,
1028,
1014,
1029,
1038,
4135,
2497... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/animation/animate.js | function (element, originator) {
var slideTemplate = "translate3d( {centerX}px, {centerY}px, 0 )";
var buildSlide = angular.bind(null, $mdUtil.supplant, slideTemplate);
return buildSlide(self.calculateTransformValues(element, originator));
} | javascript | function (element, originator) {
var slideTemplate = "translate3d( {centerX}px, {centerY}px, 0 )";
var buildSlide = angular.bind(null, $mdUtil.supplant, slideTemplate);
return buildSlide(self.calculateTransformValues(element, originator));
} | [
"function",
"(",
"element",
",",
"originator",
")",
"{",
"var",
"slideTemplate",
"=",
"\"translate3d( {centerX}px, {centerY}px, 0 )\"",
";",
"var",
"buildSlide",
"=",
"angular",
".",
"bind",
"(",
"null",
",",
"$mdUtil",
".",
"supplant",
",",
"slideTemplate",
")",
... | Calculate the slide transform from panel to origin.
NOTE: all values are rounded to the nearest integer | [
"Calculate",
"the",
"slide",
"transform",
"from",
"panel",
"to",
"origin",
".",
"NOTE",
":",
"all",
"values",
"are",
"rounded",
"to",
"the",
"nearest",
"integer"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L154-L159 | train | Calculate the transform values for the slide | [
30522,
3853,
1006,
5783,
1010,
4761,
8844,
1007,
1063,
13075,
7358,
18532,
15725,
1027,
1000,
17637,
29097,
1006,
1063,
2415,
2595,
1065,
1052,
2595,
1010,
1063,
2415,
2100,
1065,
1052,
2595,
1010,
1014,
1007,
1000,
1025,
13075,
16473,
2419... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function(state, x, y)
{
var index = -1;
if (state.absolutePoints.length > 0)
{
var last = state.absolutePoints[0];
var min = null;
for (var i = 1; i < state.absolutePoints.length; i++)
{
var current = state.absolutePoints[i];
var dist = mxUtils.ptSegDistSq(last.x, last.y,
current.x, current.y, x, y);
if (min == null || dist < min)
{
min = dist;
index = i - 1;
}
last = current;
}
}
return index;
} | javascript | function(state, x, y)
{
var index = -1;
if (state.absolutePoints.length > 0)
{
var last = state.absolutePoints[0];
var min = null;
for (var i = 1; i < state.absolutePoints.length; i++)
{
var current = state.absolutePoints[i];
var dist = mxUtils.ptSegDistSq(last.x, last.y,
current.x, current.y, x, y);
if (min == null || dist < min)
{
min = dist;
index = i - 1;
}
last = current;
}
}
return index;
} | [
"function",
"(",
"state",
",",
"x",
",",
"y",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"if",
"(",
"state",
".",
"absolutePoints",
".",
"length",
">",
"0",
")",
"{",
"var",
"last",
"=",
"state",
".",
"absolutePoints",
"[",
"0",
"]",
";",
"v... | Function: findNearestSegment
Finds the index of the nearest segment on the given cell state for
the specified coordinate pair. | [
"Function",
":",
"findNearestSegment"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4417-L4443 | train | Returns the index of the segment in the state where the segment is closest to the given point | [
30522,
3853,
1006,
2110,
1010,
1060,
1010,
1061,
1007,
1063,
13075,
5950,
1027,
1011,
1015,
1025,
2065,
1006,
2110,
1012,
7619,
26521,
1012,
3091,
1028,
1014,
1007,
1063,
13075,
2197,
1027,
2110,
1012,
7619,
26521,
1031,
1014,
1033,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Microsoft/vscode | src/bootstrap-fork.js | safeToArray | function safeToArray(args) {
const seen = [];
const argsArray = [];
let res;
// Massage some arguments with special treatment
if (args.length) {
for (let i = 0; i < args.length; i++) {
// Any argument of type 'undefined' needs to be specially treated because
// JSON.stringify will simply ignore those. We replace them with the string
// 'undefined' which is not 100% right, but good enough to be logged to console
if (typeof args[i] === 'undefined') {
args[i] = 'undefined';
}
// Any argument that is an Error will be changed to be just the error stack/message
// itself because currently cannot serialize the error over entirely.
else if (args[i] instanceof Error) {
const errorObj = args[i];
if (errorObj.stack) {
args[i] = errorObj.stack;
} else {
args[i] = errorObj.toString();
}
}
argsArray.push(args[i]);
}
}
// Add the stack trace as payload if we are told so. We remove the message and the 2 top frames
// to start the stacktrace where the console message was being written
if (process.env.VSCODE_LOG_STACK === 'true') {
const stack = new Error().stack;
argsArray.push({ __$stack: stack.split('\n').slice(3).join('\n') });
}
try {
res = JSON.stringify(argsArray, function (key, value) {
// Objects get special treatment to prevent circles
if (isObject(value) || Array.isArray(value)) {
if (seen.indexOf(value) !== -1) {
return '[Circular]';
}
seen.push(value);
}
return value;
});
} catch (error) {
return 'Output omitted for an object that cannot be inspected (' + error.toString() + ')';
}
if (res && res.length > MAX_LENGTH) {
return 'Output omitted for a large object that exceeds the limits';
}
return res;
} | javascript | function safeToArray(args) {
const seen = [];
const argsArray = [];
let res;
// Massage some arguments with special treatment
if (args.length) {
for (let i = 0; i < args.length; i++) {
// Any argument of type 'undefined' needs to be specially treated because
// JSON.stringify will simply ignore those. We replace them with the string
// 'undefined' which is not 100% right, but good enough to be logged to console
if (typeof args[i] === 'undefined') {
args[i] = 'undefined';
}
// Any argument that is an Error will be changed to be just the error stack/message
// itself because currently cannot serialize the error over entirely.
else if (args[i] instanceof Error) {
const errorObj = args[i];
if (errorObj.stack) {
args[i] = errorObj.stack;
} else {
args[i] = errorObj.toString();
}
}
argsArray.push(args[i]);
}
}
// Add the stack trace as payload if we are told so. We remove the message and the 2 top frames
// to start the stacktrace where the console message was being written
if (process.env.VSCODE_LOG_STACK === 'true') {
const stack = new Error().stack;
argsArray.push({ __$stack: stack.split('\n').slice(3).join('\n') });
}
try {
res = JSON.stringify(argsArray, function (key, value) {
// Objects get special treatment to prevent circles
if (isObject(value) || Array.isArray(value)) {
if (seen.indexOf(value) !== -1) {
return '[Circular]';
}
seen.push(value);
}
return value;
});
} catch (error) {
return 'Output omitted for an object that cannot be inspected (' + error.toString() + ')';
}
if (res && res.length > MAX_LENGTH) {
return 'Output omitted for a large object that exceeds the limits';
}
return res;
} | [
"function",
"safeToArray",
"(",
"args",
")",
"{",
"const",
"seen",
"=",
"[",
"]",
";",
"const",
"argsArray",
"=",
"[",
"]",
";",
"let",
"res",
";",
"// Massage some arguments with special treatment",
"if",
"(",
"args",
".",
"length",
")",
"{",
"for",
"(",
... | Prevent circular stringify and convert arguments to real array | [
"Prevent",
"circular",
"stringify",
"and",
"convert",
"arguments",
"to",
"real",
"array"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/src/bootstrap-fork.js#L50-L112 | train | Converts an array of arguments to an array of objects. | [
30522,
3853,
3647,
3406,
2906,
9447,
1006,
12098,
5620,
1007,
1063,
9530,
3367,
2464,
1027,
1031,
1033,
1025,
9530,
3367,
12098,
5620,
2906,
9447,
1027,
1031,
1033,
1025,
2292,
24501,
1025,
1013,
1013,
21881,
2070,
9918,
2007,
2569,
3949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | i18n/js_to_json.js | function (str) {
if (str.indexOf('Blockly.Msg.') !== 0) return false;
assert.notStrictEqual(str.indexOf('";'), str.length - 2, `[${str}] uses double quoted string, should use single quotes.`);
if (str.indexOf("';") !== str.length - 2) return false;
return true;
} | javascript | function (str) {
if (str.indexOf('Blockly.Msg.') !== 0) return false;
assert.notStrictEqual(str.indexOf('";'), str.length - 2, `[${str}] uses double quoted string, should use single quotes.`);
if (str.indexOf("';") !== str.length - 2) return false;
return true;
} | [
"function",
"(",
"str",
")",
"{",
"if",
"(",
"str",
".",
"indexOf",
"(",
"'Blockly.Msg.'",
")",
"!==",
"0",
")",
"return",
"false",
";",
"assert",
".",
"notStrictEqual",
"(",
"str",
".",
"indexOf",
"(",
"'\";'",
")",
",",
"str",
".",
"length",
"-",
... | Match function | [
"Match",
"function"
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/i18n/js_to_json.js#L14-L19 | train | Check if string is a blockly. Msg. | [
30522,
3853,
1006,
2358,
2099,
1007,
1063,
2065,
1006,
2358,
2099,
1012,
5950,
11253,
1006,
1005,
3796,
2135,
1012,
5796,
2290,
1012,
1005,
1007,
999,
1027,
1027,
1014,
1007,
2709,
6270,
1025,
20865,
1012,
2025,
3367,
7277,
2618,
26426,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jiahaog/nativefier | app/src/static/preload.js | setNotificationCallback | function setNotificationCallback(createCallback, clickCallback) {
const OldNotify = window.Notification;
const newNotify = (title, opt) => {
createCallback(title, opt);
const instance = new OldNotify(title, opt);
instance.addEventListener('click', clickCallback);
return instance;
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => OldNotify.permission,
});
window.Notification = newNotify;
} | javascript | function setNotificationCallback(createCallback, clickCallback) {
const OldNotify = window.Notification;
const newNotify = (title, opt) => {
createCallback(title, opt);
const instance = new OldNotify(title, opt);
instance.addEventListener('click', clickCallback);
return instance;
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => OldNotify.permission,
});
window.Notification = newNotify;
} | [
"function",
"setNotificationCallback",
"(",
"createCallback",
",",
"clickCallback",
")",
"{",
"const",
"OldNotify",
"=",
"window",
".",
"Notification",
";",
"const",
"newNotify",
"=",
"(",
"title",
",",
"opt",
")",
"=>",
"{",
"createCallback",
"(",
"title",
",... | Patches window.Notification to:
- set a callback on a new Notification
- set a callback for clicks on notifications
@param createCallback
@param clickCallback | [
"Patches",
"window",
".",
"Notification",
"to",
":",
"-",
"set",
"a",
"callback",
"on",
"a",
"new",
"Notification",
"-",
"set",
"a",
"callback",
"for",
"clicks",
"on",
"notifications"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/app/src/static/preload.js#L30-L44 | train | Sets a callback function to be called when the user clicks on a notification. | [
30522,
3853,
2275,
17048,
9031,
9289,
20850,
8684,
1006,
3443,
9289,
20850,
8684,
1010,
11562,
9289,
20850,
8684,
1007,
1063,
9530,
3367,
2214,
17048,
8757,
1027,
3332,
1012,
26828,
1025,
9530,
3367,
2047,
17048,
8757,
1027,
1006,
2516,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/Support.js | line | function line(buffer, right, border, label, content) {
buffer.push("<tr class='sapUiSelectable'><td class='sapUiSupportTechInfoBorder sapUiSelectable'><label class='sapUiSupportLabel sapUiSelectable'>", encodeXML(label), "</label><br>");
var ctnt = content;
if (jQuery.isFunction(content)) {
ctnt = content(buffer) || "";
}
buffer.push(encodeXML(ctnt));
buffer.push("</td></tr>");
} | javascript | function line(buffer, right, border, label, content) {
buffer.push("<tr class='sapUiSelectable'><td class='sapUiSupportTechInfoBorder sapUiSelectable'><label class='sapUiSupportLabel sapUiSelectable'>", encodeXML(label), "</label><br>");
var ctnt = content;
if (jQuery.isFunction(content)) {
ctnt = content(buffer) || "";
}
buffer.push(encodeXML(ctnt));
buffer.push("</td></tr>");
} | [
"function",
"line",
"(",
"buffer",
",",
"right",
",",
"border",
",",
"label",
",",
"content",
")",
"{",
"buffer",
".",
"push",
"(",
"\"<tr class='sapUiSelectable'><td class='sapUiSupportTechInfoBorder sapUiSelectable'><label class='sapUiSupportLabel sapUiSelectable'>\"",
",",
... | variable used to open the support dialog on windows phone copied from core | [
"variable",
"used",
"to",
"open",
"the",
"support",
"dialog",
"on",
"windows",
"phone",
"copied",
"from",
"core"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/Support.js#L79-L87 | train | adds a line to the buffer | [
30522,
3853,
2240,
1006,
17698,
1010,
2157,
1010,
3675,
1010,
3830,
1010,
4180,
1007,
1063,
17698,
1012,
5245,
1006,
1000,
1026,
19817,
2465,
1027,
1005,
20066,
27020,
12260,
23576,
1005,
1028,
1026,
14595,
2465,
1027,
1005,
20066,
27020,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | validateChecksum | function validateChecksum(requester, params) {
params = params || {
filePath: installerPath,
expectedChecksum: _updateParams.checksum
};
var hash = crypto.createHash('sha256'),
currentRequester = requester || "";
if (fs.existsSync(params.filePath)) {
var stream = fs.createReadStream(params.filePath);
stream.on('data', function (data) {
hash.update(data);
});
stream.on('end', function () {
var calculatedChecksum = hash.digest('hex'),
isValidChecksum = (params.expectedChecksum === calculatedChecksum),
status;
if (isValidChecksum) {
if (process.platform === "darwin") {
status = {
valid: true,
installerPath: installerPath,
logFilePath: logFilePath,
installStatusFilePath: installStatusFilePath
};
} else if (process.platform === "win32") {
status = {
valid: true,
installerPath: quoteAndConvert(installerPath, true),
logFilePath: quoteAndConvert(logFilePath, true),
installStatusFilePath: installStatusFilePath
};
}
} else {
status = {
valid: false,
err: nodeErrorMessages.CHECKSUM_DID_NOT_MATCH
};
}
postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
});
} else {
var status = {
valid: false,
err: nodeErrorMessages.INSTALLER_NOT_FOUND
};
postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
}
} | javascript | function validateChecksum(requester, params) {
params = params || {
filePath: installerPath,
expectedChecksum: _updateParams.checksum
};
var hash = crypto.createHash('sha256'),
currentRequester = requester || "";
if (fs.existsSync(params.filePath)) {
var stream = fs.createReadStream(params.filePath);
stream.on('data', function (data) {
hash.update(data);
});
stream.on('end', function () {
var calculatedChecksum = hash.digest('hex'),
isValidChecksum = (params.expectedChecksum === calculatedChecksum),
status;
if (isValidChecksum) {
if (process.platform === "darwin") {
status = {
valid: true,
installerPath: installerPath,
logFilePath: logFilePath,
installStatusFilePath: installStatusFilePath
};
} else if (process.platform === "win32") {
status = {
valid: true,
installerPath: quoteAndConvert(installerPath, true),
logFilePath: quoteAndConvert(logFilePath, true),
installStatusFilePath: installStatusFilePath
};
}
} else {
status = {
valid: false,
err: nodeErrorMessages.CHECKSUM_DID_NOT_MATCH
};
}
postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
});
} else {
var status = {
valid: false,
err: nodeErrorMessages.INSTALLER_NOT_FOUND
};
postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
}
} | [
"function",
"validateChecksum",
"(",
"requester",
",",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"filePath",
":",
"installerPath",
",",
"expectedChecksum",
":",
"_updateParams",
".",
"checksum",
"}",
";",
"var",
"hash",
"=",
"crypto",
".",
"cre... | Validates the checksum of a file against a given checksum
@param {object} params - json containing {
filePath - path to the file,
expectedChecksum - the checksum to validate against } | [
"Validates",
"the",
"checksum",
"of",
"a",
"file",
"against",
"a",
"given",
"checksum"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L128-L180 | train | Validate Checksum | [
30522,
3853,
9398,
3686,
5403,
10603,
2819,
1006,
5227,
2121,
1010,
11498,
5244,
1007,
1063,
11498,
5244,
1027,
11498,
5244,
1064,
1064,
1063,
5371,
15069,
1024,
16500,
2121,
15069,
1010,
3517,
5403,
10603,
2819,
1024,
1035,
10651,
28689,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/features/ParameterHintsManager.js | positionHint | function positionHint(xpos, ypos, ybot) {
var hintWidth = $hintContainer.width(),
hintHeight = $hintContainer.height(),
top = ypos - hintHeight - POINTER_TOP_OFFSET,
left = xpos,
$editorHolder = $("#editor-holder"),
editorLeft;
if ($editorHolder.offset() === undefined) {
// this happens in jasmine tests that run
// without a windowed document.
return;
}
editorLeft = $editorHolder.offset().left;
left = Math.max(left, editorLeft);
left = Math.min(left, editorLeft + $editorHolder.width() - hintWidth);
if (top < 0) {
$hintContainer.removeClass("preview-bubble-above");
$hintContainer.addClass("preview-bubble-below");
top = ybot + POSITION_BELOW_OFFSET;
$hintContainer.offset({
left: left,
top: top
});
} else {
$hintContainer.removeClass("preview-bubble-below");
$hintContainer.addClass("preview-bubble-above");
$hintContainer.offset({
left: left,
top: top - POINTER_TOP_OFFSET
});
}
} | javascript | function positionHint(xpos, ypos, ybot) {
var hintWidth = $hintContainer.width(),
hintHeight = $hintContainer.height(),
top = ypos - hintHeight - POINTER_TOP_OFFSET,
left = xpos,
$editorHolder = $("#editor-holder"),
editorLeft;
if ($editorHolder.offset() === undefined) {
// this happens in jasmine tests that run
// without a windowed document.
return;
}
editorLeft = $editorHolder.offset().left;
left = Math.max(left, editorLeft);
left = Math.min(left, editorLeft + $editorHolder.width() - hintWidth);
if (top < 0) {
$hintContainer.removeClass("preview-bubble-above");
$hintContainer.addClass("preview-bubble-below");
top = ybot + POSITION_BELOW_OFFSET;
$hintContainer.offset({
left: left,
top: top
});
} else {
$hintContainer.removeClass("preview-bubble-below");
$hintContainer.addClass("preview-bubble-above");
$hintContainer.offset({
left: left,
top: top - POINTER_TOP_OFFSET
});
}
} | [
"function",
"positionHint",
"(",
"xpos",
",",
"ypos",
",",
"ybot",
")",
"{",
"var",
"hintWidth",
"=",
"$hintContainer",
".",
"width",
"(",
")",
",",
"hintHeight",
"=",
"$hintContainer",
".",
"height",
"(",
")",
",",
"top",
"=",
"ypos",
"-",
"hintHeight",... | Position a function hint.
@param {number} xpos
@param {number} ypos
@param {number} ybot | [
"Position",
"a",
"function",
"hint",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L81-L115 | train | Position hint in the editor | [
30522,
3853,
2597,
10606,
2102,
1006,
26726,
2891,
1010,
1061,
6873,
2015,
1010,
1061,
18384,
1007,
1063,
13075,
9374,
9148,
11927,
2232,
1027,
1002,
9374,
8663,
18249,
2121,
1012,
9381,
1006,
1007,
1010,
9374,
26036,
13900,
1027,
1002,
937... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/bar/PictorialBarView.js | getSymbolMeta | function getSymbolMeta(data, dataIndex, itemModel, opt) {
var layout = data.getItemLayout(dataIndex);
var symbolRepeat = itemModel.get('symbolRepeat');
var symbolClip = itemModel.get('symbolClip');
var symbolPosition = itemModel.get('symbolPosition') || 'start';
var symbolRotate = itemModel.get('symbolRotate');
var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
var isAnimationEnabled = itemModel.isAnimationEnabled();
var symbolMeta = {
dataIndex: dataIndex,
layout: layout,
itemModel: itemModel,
symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
color: data.getItemVisual(dataIndex, 'color'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
z2: itemModel.getShallow('z', true) || 0
};
prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
prepareSymbolSize(
data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
);
prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
var symbolSize = symbolMeta.symbolSize;
var symbolOffset = itemModel.get('symbolOffset');
if (zrUtil.isArray(symbolOffset)) {
symbolOffset = [
parsePercent(symbolOffset[0], symbolSize[0]),
parsePercent(symbolOffset[1], symbolSize[1])
];
}
prepareLayoutInfo(
itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
opt, symbolMeta
);
return symbolMeta;
} | javascript | function getSymbolMeta(data, dataIndex, itemModel, opt) {
var layout = data.getItemLayout(dataIndex);
var symbolRepeat = itemModel.get('symbolRepeat');
var symbolClip = itemModel.get('symbolClip');
var symbolPosition = itemModel.get('symbolPosition') || 'start';
var symbolRotate = itemModel.get('symbolRotate');
var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
var isAnimationEnabled = itemModel.isAnimationEnabled();
var symbolMeta = {
dataIndex: dataIndex,
layout: layout,
itemModel: itemModel,
symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
color: data.getItemVisual(dataIndex, 'color'),
symbolClip: symbolClip,
symbolRepeat: symbolRepeat,
symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
symbolPatternSize: symbolPatternSize,
rotation: rotation,
animationModel: isAnimationEnabled ? itemModel : null,
hoverAnimation: isAnimationEnabled && itemModel.get('hoverAnimation'),
z2: itemModel.getShallow('z', true) || 0
};
prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
prepareSymbolSize(
data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength,
symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta
);
prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
var symbolSize = symbolMeta.symbolSize;
var symbolOffset = itemModel.get('symbolOffset');
if (zrUtil.isArray(symbolOffset)) {
symbolOffset = [
parsePercent(symbolOffset[0], symbolSize[0]),
parsePercent(symbolOffset[1], symbolSize[1])
];
}
prepareLayoutInfo(
itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset,
symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength,
opt, symbolMeta
);
return symbolMeta;
} | [
"function",
"getSymbolMeta",
"(",
"data",
",",
"dataIndex",
",",
"itemModel",
",",
"opt",
")",
"{",
"var",
"layout",
"=",
"data",
".",
"getItemLayout",
"(",
"dataIndex",
")",
";",
"var",
"symbolRepeat",
"=",
"itemModel",
".",
"get",
"(",
"'symbolRepeat'",
... | Set or calculate default value about symbol, and calculate layout info. | [
"Set",
"or",
"calculate",
"default",
"value",
"about",
"symbol",
"and",
"calculate",
"layout",
"info",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/bar/PictorialBarView.js#L144-L195 | train | Get symbol meta | [
30522,
3853,
4152,
24335,
14956,
11368,
2050,
1006,
2951,
1010,
2951,
22254,
10288,
1010,
8875,
5302,
9247,
1010,
23569,
1007,
1063,
13075,
9621,
1027,
2951,
1012,
2131,
4221,
19968,
28852,
4904,
1006,
2951,
22254,
10288,
1007,
1025,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | handleFileAddToWorkingSetAndOpen | function handleFileAddToWorkingSetAndOpen(commandData) {
return handleFileOpen(commandData).done(function (file) {
var paneId = (commandData && commandData.paneId) || MainViewManager.ACTIVE_PANE;
MainViewManager.addToWorkingSet(paneId, file, commandData.index, commandData.forceRedraw);
HealthLogger.fileOpened(file.fullPath, true);
});
} | javascript | function handleFileAddToWorkingSetAndOpen(commandData) {
return handleFileOpen(commandData).done(function (file) {
var paneId = (commandData && commandData.paneId) || MainViewManager.ACTIVE_PANE;
MainViewManager.addToWorkingSet(paneId, file, commandData.index, commandData.forceRedraw);
HealthLogger.fileOpened(file.fullPath, true);
});
} | [
"function",
"handleFileAddToWorkingSetAndOpen",
"(",
"commandData",
")",
"{",
"return",
"handleFileOpen",
"(",
"commandData",
")",
".",
"done",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"paneId",
"=",
"(",
"commandData",
"&&",
"commandData",
".",
"paneId",
... | Opens the given file, makes it the current file, AND adds it to the workingset
@param {!PaneCommandData} commandData - record with the following properties:
fullPath: File to open;
index: optional index to position in workingset (defaults to last);
silent: optional flag to suppress error messages;
forceRedraw: flag to force the working set view redraw;
paneId: optional PaneId (defaults to active pane)
@return {$.Promise} a jQuery promise that will be resolved with a @type {File} | [
"Opens",
"the",
"given",
"file",
"makes",
"it",
"the",
"current",
"file",
"AND",
"adds",
"it",
"to",
"the",
"workingset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L554-L560 | train | Add a file to the working set and open it | [
30522,
3853,
5047,
8873,
19738,
14141,
18790,
2953,
6834,
13462,
28574,
11837,
1006,
3094,
2850,
2696,
1007,
1063,
2709,
5047,
8873,
2571,
26915,
1006,
3094,
2850,
2696,
1007,
1012,
2589,
1006,
3853,
1006,
5371,
1007,
1063,
13075,
6090,
741... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/aws-containers/prompts.js | askRegion | function askRegion() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'region',
message: 'Which region?',
choices: regionList,
default: this.aws.region ? _.indexOf(regionList, this.aws.region) : this.awsFacts.defaultRegion
}
];
return this.prompt(prompts).then(props => {
const region = props.region;
if (region) {
this.aws.region = region;
done();
} else {
this.abort = true;
done();
}
});
} | javascript | function askRegion() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'region',
message: 'Which region?',
choices: regionList,
default: this.aws.region ? _.indexOf(regionList, this.aws.region) : this.awsFacts.defaultRegion
}
];
return this.prompt(prompts).then(props => {
const region = props.region;
if (region) {
this.aws.region = region;
done();
} else {
this.abort = true;
done();
}
});
} | [
"function",
"askRegion",
"(",
")",
"{",
"if",
"(",
"this",
".",
"abort",
")",
"return",
"null",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'list'",
",",
"name",
":",
"'region'",
... | Ask user what type of Region is to be created? | [
"Ask",
"user",
"what",
"type",
"of",
"Region",
"is",
"to",
"be",
"created?"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/prompts.js#L155-L178 | train | Ask what region is in the list of regions | [
30522,
3853,
3198,
23784,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
11113,
11589,
1007,
2709,
19701,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
25732,
2015,
1027,
1031,
1063,
2828,
1024,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jiahaog/nativefier | app/src/helpers/helpers.js | debugLog | function debugLog(browserWindow, message) {
// need the timeout as it takes time for the preload javascript to be loaded in the window
setTimeout(() => {
browserWindow.webContents.send('debug', message);
}, 3000);
log.info(message);
} | javascript | function debugLog(browserWindow, message) {
// need the timeout as it takes time for the preload javascript to be loaded in the window
setTimeout(() => {
browserWindow.webContents.send('debug', message);
}, 3000);
log.info(message);
} | [
"function",
"debugLog",
"(",
"browserWindow",
",",
"message",
")",
"{",
"// need the timeout as it takes time for the preload javascript to be loaded in the window",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"browserWindow",
".",
"webContents",
".",
"send",
"(",
"'debug'",
... | Helper method to print debug messages from the main process in the browser window
@param {BrowserWindow} browserWindow
@param message | [
"Helper",
"method",
"to",
"print",
"debug",
"messages",
"from",
"the",
"main",
"process",
"in",
"the",
"browser",
"window"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/app/src/helpers/helpers.js#L54-L60 | train | debug log | [
30522,
3853,
2139,
8569,
23296,
8649,
1006,
16602,
11101,
5004,
1010,
4471,
1007,
1063,
1013,
1013,
2342,
1996,
2051,
5833,
2004,
2009,
3138,
2051,
2005,
1996,
3653,
11066,
9262,
22483,
2000,
2022,
8209,
1999,
1996,
3332,
2275,
7292,
5833,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | function( elems, callback, arg ) {
var value, key, ret = [],
i = 0,
length = elems.length,
// jquery objects are treated as arrays
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
// Go through the array, translating each of the items to their
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
// Go through every key on the object,
} else {
for ( key in elems ) {
value = callback( elems[ key ], key, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
}
// Flatten any nested arrays
return ret.concat.apply( [], ret );
} | javascript | function( elems, callback, arg ) {
var value, key, ret = [],
i = 0,
length = elems.length,
// jquery objects are treated as arrays
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
// Go through the array, translating each of the items to their
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
// Go through every key on the object,
} else {
for ( key in elems ) {
value = callback( elems[ key ], key, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
}
// Flatten any nested arrays
return ret.concat.apply( [], ret );
} | [
"function",
"(",
"elems",
",",
"callback",
",",
"arg",
")",
"{",
"var",
"value",
",",
"key",
",",
"ret",
"=",
"[",
"]",
",",
"i",
"=",
"0",
",",
"length",
"=",
"elems",
".",
"length",
",",
"// jquery objects are treated as arrays",
"isArray",
"=",
"ele... | arg is for internal usage only | [
"arg",
"is",
"for",
"internal",
"usage",
"only"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L761-L791 | train | This function is a bit of a hack to get the array of items from the array | [
30522,
3853,
1006,
3449,
6633,
2015,
1010,
2655,
5963,
1010,
12098,
2290,
1007,
1063,
13075,
3643,
1010,
3145,
1010,
2128,
2102,
1027,
1031,
1033,
1010,
1045,
1027,
1014,
1010,
3091,
1027,
3449,
6633,
2015,
1012,
3091,
1010,
1013,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/func-call-spacing.js | checkSpacing | function checkSpacing(node) {
const lastToken = sourceCode.getLastToken(node);
const lastCalleeToken = sourceCode.getLastToken(node.callee);
const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken);
const prevToken = parenToken && sourceCode.getTokenBefore(parenToken);
// Parens in NewExpression are optional
if (!(parenToken && parenToken.range[1] < node.range[1])) {
return;
}
const textBetweenTokens = text.slice(prevToken.range[1], parenToken.range[0]).replace(/\/\*.*?\*\//gu, "");
const hasWhitespace = /\s/u.test(textBetweenTokens);
const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
/*
* never allowNewlines hasWhitespace hasNewline message
* F F F F Missing space between function name and paren.
* F F F T (Invalid `!hasWhitespace && hasNewline`)
* F F T T Unexpected newline between function name and paren.
* F F T F (OK)
* F T T F (OK)
* F T T T (OK)
* F T F T (Invalid `!hasWhitespace && hasNewline`)
* F T F F Missing space between function name and paren.
* T T F F (Invalid `never && allowNewlines`)
* T T F T (Invalid `!hasWhitespace && hasNewline`)
* T T T T (Invalid `never && allowNewlines`)
* T T T F (Invalid `never && allowNewlines`)
* T F T F Unexpected space between function name and paren.
* T F T T Unexpected space between function name and paren.
* T F F T (Invalid `!hasWhitespace && hasNewline`)
* T F F F (OK)
*
* T T Unexpected space between function name and paren.
* F F Missing space between function name and paren.
* F F T Unexpected newline between function name and paren.
*/
if (never && hasWhitespace) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "unexpected",
fix(fixer) {
/*
* Only autofix if there is no newline
* https://github.com/eslint/eslint/issues/7787
*/
if (!hasNewline) {
return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
}
return null;
}
});
} else if (!never && !hasWhitespace) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "missing",
fix(fixer) {
return fixer.insertTextBefore(parenToken, " ");
}
});
} else if (!never && !allowNewlines && hasNewline) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "unexpected",
fix(fixer) {
return fixer.replaceTextRange([prevToken.range[1], parenToken.range[0]], " ");
}
});
}
} | javascript | function checkSpacing(node) {
const lastToken = sourceCode.getLastToken(node);
const lastCalleeToken = sourceCode.getLastToken(node.callee);
const parenToken = sourceCode.getFirstTokenBetween(lastCalleeToken, lastToken, astUtils.isOpeningParenToken);
const prevToken = parenToken && sourceCode.getTokenBefore(parenToken);
// Parens in NewExpression are optional
if (!(parenToken && parenToken.range[1] < node.range[1])) {
return;
}
const textBetweenTokens = text.slice(prevToken.range[1], parenToken.range[0]).replace(/\/\*.*?\*\//gu, "");
const hasWhitespace = /\s/u.test(textBetweenTokens);
const hasNewline = hasWhitespace && astUtils.LINEBREAK_MATCHER.test(textBetweenTokens);
/*
* never allowNewlines hasWhitespace hasNewline message
* F F F F Missing space between function name and paren.
* F F F T (Invalid `!hasWhitespace && hasNewline`)
* F F T T Unexpected newline between function name and paren.
* F F T F (OK)
* F T T F (OK)
* F T T T (OK)
* F T F T (Invalid `!hasWhitespace && hasNewline`)
* F T F F Missing space between function name and paren.
* T T F F (Invalid `never && allowNewlines`)
* T T F T (Invalid `!hasWhitespace && hasNewline`)
* T T T T (Invalid `never && allowNewlines`)
* T T T F (Invalid `never && allowNewlines`)
* T F T F Unexpected space between function name and paren.
* T F T T Unexpected space between function name and paren.
* T F F T (Invalid `!hasWhitespace && hasNewline`)
* T F F F (OK)
*
* T T Unexpected space between function name and paren.
* F F Missing space between function name and paren.
* F F T Unexpected newline between function name and paren.
*/
if (never && hasWhitespace) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "unexpected",
fix(fixer) {
/*
* Only autofix if there is no newline
* https://github.com/eslint/eslint/issues/7787
*/
if (!hasNewline) {
return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
}
return null;
}
});
} else if (!never && !hasWhitespace) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "missing",
fix(fixer) {
return fixer.insertTextBefore(parenToken, " ");
}
});
} else if (!never && !allowNewlines && hasNewline) {
context.report({
node,
loc: lastCalleeToken.loc.start,
messageId: "unexpected",
fix(fixer) {
return fixer.replaceTextRange([prevToken.range[1], parenToken.range[0]], " ");
}
});
}
} | [
"function",
"checkSpacing",
"(",
"node",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"lastCalleeToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
".",
"callee",
")",
";",
"const",
"parenT... | Check if open space is present in a function name
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"open",
"space",
"is",
"present",
"in",
"a",
"function",
"name"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-call-spacing.js#L84-L160 | train | Check spacing between function name and function name | [
30522,
3853,
14148,
19498,
2075,
1006,
13045,
1007,
1063,
9530,
3367,
2197,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
1007,
1025,
9530,
3367,
2197,
9289,
10559,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
85... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.dt/src/sap/ui/dt/ContextMenuControl.js | function() {
var sOverflowButtonId = "OVERFLOW_BUTTON",
oButtonOptions = {
icon: "sap-icon://overflow",
type: "Transparent",
enabled: true,
press: this._onOverflowPress.bind(this),
layoutData: new FlexItemData({})
};
return this._addButton(sOverflowButtonId, oButtonOptions);
} | javascript | function() {
var sOverflowButtonId = "OVERFLOW_BUTTON",
oButtonOptions = {
icon: "sap-icon://overflow",
type: "Transparent",
enabled: true,
press: this._onOverflowPress.bind(this),
layoutData: new FlexItemData({})
};
return this._addButton(sOverflowButtonId, oButtonOptions);
} | [
"function",
"(",
")",
"{",
"var",
"sOverflowButtonId",
"=",
"\"OVERFLOW_BUTTON\"",
",",
"oButtonOptions",
"=",
"{",
"icon",
":",
"\"sap-icon://overflow\"",
",",
"type",
":",
"\"Transparent\"",
",",
"enabled",
":",
"true",
",",
"press",
":",
"this",
".",
"_onOv... | Adds a overflowButton to the ContextMenu.
@return {sap.m.ContextMenu} Reference to this in order to allow method chaining
@public | [
"Adds",
"a",
"overflowButton",
"to",
"the",
"ContextMenu",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.dt/src/sap/ui/dt/ContextMenuControl.js#L555-L565 | train | Adds an overflow button to the toolbar. | [
30522,
3853,
1006,
1007,
1063,
13075,
2061,
6299,
12314,
8569,
15474,
3593,
1027,
1000,
2058,
12314,
1035,
6462,
1000,
1010,
27885,
4904,
2669,
7361,
9285,
1027,
1063,
12696,
1024,
1000,
20066,
1011,
30524,
1024,
1000,
13338,
1000,
1010,
91... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/webdriver/logging.js | getLevel | function getLevel(nameOrValue) {
// DEBUG is not a predefined Closure log level, but maps to CONFIG. Since
// DEBUG is a predefined level for the WebDriver protocol, we prefer it over
// CONFIG.
if ('DEBUG' === nameOrValue || Logger.Level.DEBUG.value === nameOrValue) {
return Logger.Level.DEBUG;
} else if (goog.isString(nameOrValue)) {
return Logger.Level.getPredefinedLevel(/** @type {string} */(nameOrValue))
|| Logger.Level.ALL;
} else {
return Logger.Level.getPredefinedLevelByValue(
/** @type {number} */(nameOrValue)) || Logger.Level.ALL;
}
} | javascript | function getLevel(nameOrValue) {
// DEBUG is not a predefined Closure log level, but maps to CONFIG. Since
// DEBUG is a predefined level for the WebDriver protocol, we prefer it over
// CONFIG.
if ('DEBUG' === nameOrValue || Logger.Level.DEBUG.value === nameOrValue) {
return Logger.Level.DEBUG;
} else if (goog.isString(nameOrValue)) {
return Logger.Level.getPredefinedLevel(/** @type {string} */(nameOrValue))
|| Logger.Level.ALL;
} else {
return Logger.Level.getPredefinedLevelByValue(
/** @type {number} */(nameOrValue)) || Logger.Level.ALL;
}
} | [
"function",
"getLevel",
"(",
"nameOrValue",
")",
"{",
"// DEBUG is not a predefined Closure log level, but maps to CONFIG. Since",
"// DEBUG is a predefined level for the WebDriver protocol, we prefer it over",
"// CONFIG.",
"if",
"(",
"'DEBUG'",
"===",
"nameOrValue",
"||",
"Logger",
... | Converts a level name or value to a {@link webdriver.logging.Level} value.
If the name/value is not recognized, {@link webdriver.logging.Level.ALL}
will be returned.
@param {(number|string)} nameOrValue The log level name, or value, to
convert .
@return {!Logger.Level} The converted level. | [
"Converts",
"a",
"level",
"name",
"or",
"value",
"to",
"a",
"{"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/webdriver/logging.js#L185-L198 | train | Returns the level of the given log message. | [
30522,
3853,
2131,
20414,
2884,
1006,
2171,
2953,
10175,
5657,
1007,
1063,
1013,
1013,
2139,
8569,
2290,
2003,
2025,
1037,
3653,
3207,
23460,
2094,
8503,
8833,
2504,
1010,
2021,
7341,
2000,
9530,
8873,
2290,
1012,
2144,
1013,
1013,
2139,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/TokenUtils.js | moveNextToken | function moveNextToken(ctx, precise) {
var eol = ctx.editor.getLine(ctx.pos.line).length;
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch >= eol || ctx.token.end >= eol) {
//move down a line
if (ctx.pos.line >= ctx.editor.lineCount() - 1) {
return false; //at the bottom
}
ctx.pos.line++;
ctx.pos.ch = 0;
} else {
ctx.pos.ch = ctx.token.end + 1;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | javascript | function moveNextToken(ctx, precise) {
var eol = ctx.editor.getLine(ctx.pos.line).length;
if (precise === undefined) {
precise = true;
}
if (ctx.pos.ch >= eol || ctx.token.end >= eol) {
//move down a line
if (ctx.pos.line >= ctx.editor.lineCount() - 1) {
return false; //at the bottom
}
ctx.pos.line++;
ctx.pos.ch = 0;
} else {
ctx.pos.ch = ctx.token.end + 1;
}
ctx.token = getTokenAt(ctx.editor, ctx.pos, precise);
return true;
} | [
"function",
"moveNextToken",
"(",
"ctx",
",",
"precise",
")",
"{",
"var",
"eol",
"=",
"ctx",
".",
"editor",
".",
"getLine",
"(",
"ctx",
".",
"pos",
".",
"line",
")",
".",
"length",
";",
"if",
"(",
"precise",
"===",
"undefined",
")",
"{",
"precise",
... | Moves the given context forward by one token.
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@param {boolean=} precise If code is being edited, use true (default) for accuracy.
If parsing unchanging code, use false to use cache for performance.
@return {boolean} whether the context changed | [
"Moves",
"the",
"given",
"context",
"forward",
"by",
"one",
"token",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L143-L161 | train | move the next token to the next line | [
30522,
3853,
2693,
2638,
18413,
18715,
2368,
1006,
14931,
2595,
1010,
10480,
1007,
1063,
13075,
1041,
4747,
1027,
14931,
2595,
1012,
3559,
1012,
2131,
4179,
1006,
14931,
2595,
1012,
13433,
2015,
1012,
2240,
1007,
1012,
3091,
1025,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js | tryToLoadNextProperties | function tryToLoadNextProperties(oBundle, bAsync) {
// get the next fallback locale and calculate the next but one locale
var sLocale = oBundle._sNextLocale;
oBundle._sNextLocale = nextFallbackLocale(sLocale);
var aSupportedLanguages = window.sap && window.sap.ui && sap.ui.getCore && sap.ui.getCore().getConfiguration().getSupportedLanguages();
if ( sLocale != null && isSupported(sLocale, aSupportedLanguages) ) {
var oUrl = oBundle.oUrlInfo,
sUrl, mHeaders;
if ( oUrl.ext === '.hdbtextbundle' ) {
if ( M_SUPPORTABILITY_TO_XS[sLocale] ) {
// Add technical support languages also as URL parameter (as XS engine can't handle private extensions in Accept-Language header)
sUrl = oUrl.prefix + oUrl.suffix + '?' + (oUrl.query ? oUrl.query + "&" : "") + "sap-language=" + M_SUPPORTABILITY_TO_XS[sLocale] + (oUrl.hash ? "#" + oUrl.hash : "");
} else {
sUrl = oUrl.url;
}
// Alternative: add locale as query:
// url: oUrl.prefix + oUrl.suffix + '?' + (oUrl.query ? oUrl.query + "&" : "") + "locale=" + sLocale + (oUrl.hash ? "#" + oUrl.hash : ""),
mHeaders = {
"Accept-Language": convertLocaleToBCP47(sLocale) || ""
};
} else {
sUrl = oUrl.prefix + (sLocale ? "_" + sLocale : "") + oUrl.suffix;
}
var vProperties = Properties.create({
url: sUrl,
headers: mHeaders,
async: !!bAsync,
returnNullIfMissing: true
});
var addProperties = function(oProps) {
if ( oProps ) {
oBundle.aPropertyFiles.push(oProps);
oBundle.aLocales.push(sLocale);
}
return oProps;
};
return bAsync ? vProperties.then( addProperties ) : addProperties( vProperties );
}
return bAsync ? Promise.resolve(null) : null;
} | javascript | function tryToLoadNextProperties(oBundle, bAsync) {
// get the next fallback locale and calculate the next but one locale
var sLocale = oBundle._sNextLocale;
oBundle._sNextLocale = nextFallbackLocale(sLocale);
var aSupportedLanguages = window.sap && window.sap.ui && sap.ui.getCore && sap.ui.getCore().getConfiguration().getSupportedLanguages();
if ( sLocale != null && isSupported(sLocale, aSupportedLanguages) ) {
var oUrl = oBundle.oUrlInfo,
sUrl, mHeaders;
if ( oUrl.ext === '.hdbtextbundle' ) {
if ( M_SUPPORTABILITY_TO_XS[sLocale] ) {
// Add technical support languages also as URL parameter (as XS engine can't handle private extensions in Accept-Language header)
sUrl = oUrl.prefix + oUrl.suffix + '?' + (oUrl.query ? oUrl.query + "&" : "") + "sap-language=" + M_SUPPORTABILITY_TO_XS[sLocale] + (oUrl.hash ? "#" + oUrl.hash : "");
} else {
sUrl = oUrl.url;
}
// Alternative: add locale as query:
// url: oUrl.prefix + oUrl.suffix + '?' + (oUrl.query ? oUrl.query + "&" : "") + "locale=" + sLocale + (oUrl.hash ? "#" + oUrl.hash : ""),
mHeaders = {
"Accept-Language": convertLocaleToBCP47(sLocale) || ""
};
} else {
sUrl = oUrl.prefix + (sLocale ? "_" + sLocale : "") + oUrl.suffix;
}
var vProperties = Properties.create({
url: sUrl,
headers: mHeaders,
async: !!bAsync,
returnNullIfMissing: true
});
var addProperties = function(oProps) {
if ( oProps ) {
oBundle.aPropertyFiles.push(oProps);
oBundle.aLocales.push(sLocale);
}
return oProps;
};
return bAsync ? vProperties.then( addProperties ) : addProperties( vProperties );
}
return bAsync ? Promise.resolve(null) : null;
} | [
"function",
"tryToLoadNextProperties",
"(",
"oBundle",
",",
"bAsync",
")",
"{",
"// get the next fallback locale and calculate the next but one locale",
"var",
"sLocale",
"=",
"oBundle",
".",
"_sNextLocale",
";",
"oBundle",
".",
"_sNextLocale",
"=",
"nextFallbackLocale",
"(... | /*
Tries to load the properties file for the next fallback locale.
If there is no further fallback locale or when requests for the next fallback locale are
suppressed by configuration or when the file cannot be loaded, <code>null</code> is returned.
@param {ResourceBundle} oBundle ResourceBundle to extend
@param {boolean} [bAsync=false] Whether the resource should be loaded asynchronously
@returns The newly loaded properties (sync mode) or a Promise on the properties (async mode);
value / Promise fulfillment will be <code>null</code> when the properties for the
next fallback locale should not be loaded or when loading failed or when there
was no more fallback locale
@private | [
"/",
"*",
"Tries",
"to",
"load",
"the",
"properties",
"file",
"for",
"the",
"next",
"fallback",
"locale",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js#L497-L546 | train | Loads the next properties in the bundle | [
30522,
3853,
3046,
3406,
11066,
2638,
18413,
21572,
4842,
7368,
1006,
27885,
8630,
2571,
1010,
19021,
6038,
2278,
1007,
1063,
1013,
1013,
2131,
1996,
2279,
2991,
5963,
2334,
2063,
1998,
18422,
1996,
2279,
2021,
2028,
2334,
2063,
13075,
2288... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2MetadataConverter.js | V2MetadataConverter | function V2MetadataConverter() {
this.association = null; // the current association
this.associations = {}; // maps qualified name -> association
this.associationSet = null; // the current associationSet
this.associationSets = []; // list of associationSets
this.aBoundOperations = []; // list of bound operations
this.constraintRole = null; // the current Principal/Dependent
// maps annotatable path to a map of converted V2 annotations for current Schema
this.convertedV2Annotations = {};
this.defaultEntityContainer = null; // the name of the default EntityContainer
this.mEntityContainersOfSchema = {}; // all EntityContainers of current Schema by name
// converted V2 annotations for EntitySets, identified by EntityType's name
this.mEntityType2EntitySetAnnotation = {};
this.mProperty2Semantics = {}; // maps a property's path to its sap:semantics value
this.sPropertyName = null; // the name of the current property
this.navigationProperties = []; // a list of navigation property data
this.mSapAnnotations = {}; // map of the current Element's SAP annotations by name
this.sTypeName = null; // the name of the current EntityType/ComplexType
this.mProperty2Unit = {}; // maps a property's path to its sap:unit value
_MetadataConverter.call(this);
} | javascript | function V2MetadataConverter() {
this.association = null; // the current association
this.associations = {}; // maps qualified name -> association
this.associationSet = null; // the current associationSet
this.associationSets = []; // list of associationSets
this.aBoundOperations = []; // list of bound operations
this.constraintRole = null; // the current Principal/Dependent
// maps annotatable path to a map of converted V2 annotations for current Schema
this.convertedV2Annotations = {};
this.defaultEntityContainer = null; // the name of the default EntityContainer
this.mEntityContainersOfSchema = {}; // all EntityContainers of current Schema by name
// converted V2 annotations for EntitySets, identified by EntityType's name
this.mEntityType2EntitySetAnnotation = {};
this.mProperty2Semantics = {}; // maps a property's path to its sap:semantics value
this.sPropertyName = null; // the name of the current property
this.navigationProperties = []; // a list of navigation property data
this.mSapAnnotations = {}; // map of the current Element's SAP annotations by name
this.sTypeName = null; // the name of the current EntityType/ComplexType
this.mProperty2Unit = {}; // maps a property's path to its sap:unit value
_MetadataConverter.call(this);
} | [
"function",
"V2MetadataConverter",
"(",
")",
"{",
"this",
".",
"association",
"=",
"null",
";",
"// the current association",
"this",
".",
"associations",
"=",
"{",
"}",
";",
"// maps qualified name -> association",
"this",
".",
"associationSet",
"=",
"null",
";",
... | ********************************************************************************************* V2MetadataConverter *********************************************************************************************
Creates a converter for V2 metadata.
@constructor | [
"*********************************************************************************************",
"V2MetadataConverter",
"*********************************************************************************************",
"Creates",
"a",
"converter",
"for",
"V2",
"metadata",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2MetadataConverter.js#L372-L393 | train | V2 Metadata Converter | [
30522,
3853,
1058,
2475,
11368,
8447,
2696,
8663,
16874,
2121,
1006,
1007,
1063,
2023,
1012,
2523,
1027,
19701,
1025,
1013,
1013,
1996,
2783,
2523,
2023,
1012,
8924,
1027,
1063,
1065,
1025,
1013,
1013,
7341,
4591,
2171,
1011,
1028,
2523,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.suite/src/sap/ui/suite/QuickViewUtils.js | function(sServiceUrl,sConfigName,sThingKey,mFormatter) {
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,false);
var oQV = new sap.ui.ux3.QuickView({firstTitle: "{title}", firstTitleHref: "{titleLinkURL}", type:"{Thing/text}", icon:"{imageURL}"});
oQV.setModel(oModel);
oQV.bindObject("/QuickviewConfigs(name='" + sConfigName + "',thingKey='" + sThingKey + "')",{expand:"Thing,QVAttributes/Attribute,QVActions/Action"});
var oMQVC = new QvContent();
oMQVC.bindAggregation("items",{path:"QVAttributes",factory: function(sId, oContext) {
var oQVItem = new QvItem(sId, {label:"{Attribute/label}",link: "{valueLinkURL}",order:"{order}"});
oQVItem.bindProperty("value","value",mFormatter && mFormatter[oContext.getProperty("Attribute/name")]);
return oQVItem;
}});
oQV.addContent(oMQVC);
return oQV;
} | javascript | function(sServiceUrl,sConfigName,sThingKey,mFormatter) {
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl,false);
var oQV = new sap.ui.ux3.QuickView({firstTitle: "{title}", firstTitleHref: "{titleLinkURL}", type:"{Thing/text}", icon:"{imageURL}"});
oQV.setModel(oModel);
oQV.bindObject("/QuickviewConfigs(name='" + sConfigName + "',thingKey='" + sThingKey + "')",{expand:"Thing,QVAttributes/Attribute,QVActions/Action"});
var oMQVC = new QvContent();
oMQVC.bindAggregation("items",{path:"QVAttributes",factory: function(sId, oContext) {
var oQVItem = new QvItem(sId, {label:"{Attribute/label}",link: "{valueLinkURL}",order:"{order}"});
oQVItem.bindProperty("value","value",mFormatter && mFormatter[oContext.getProperty("Attribute/name")]);
return oQVItem;
}});
oQV.addContent(oMQVC);
return oQV;
} | [
"function",
"(",
"sServiceUrl",
",",
"sConfigName",
",",
"sThingKey",
",",
"mFormatter",
")",
"{",
"var",
"oModel",
"=",
"new",
"sap",
".",
"ui",
".",
"model",
".",
"odata",
".",
"ODataModel",
"(",
"sServiceUrl",
",",
"false",
")",
";",
"var",
"oQV",
"... | /* create a QV instance with content | [
"/",
"*",
"create",
"a",
"QV",
"instance",
"with",
"content"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.suite/src/sap/ui/suite/QuickViewUtils.js#L21-L36 | train | Creates a new QuickView with the given service url and config name and a formatter. | [
30522,
3853,
1006,
7020,
2121,
7903,
11236,
2140,
1010,
8040,
2239,
8873,
16989,
4168,
1010,
2358,
12053,
14839,
1010,
1049,
14192,
20097,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
2047,
20066,
1012,
21318,
1012,
2944,
1012,
1051,
2850,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jantimon/html-webpack-plugin | lib/compiler.js | isChildCompilerCacheOutdated | function isChildCompilerCacheOutdated (mainCompilation, childCompiler) {
// If the compilation was never run there is no invalid cache
if (!childCompiler.compilationStartedTimestamp) {
return false;
}
// Check if any dependent file was changed after the last compilation
const fileTimestamps = mainCompilation.fileTimestamps;
const isCacheOutOfDate = childCompiler.fileDependencies.some((fileDependency) => {
const timestamp = fileTimestamps.get(fileDependency);
// If the timestamp is not known the file is new
// If the timestamp is larger then the file has changed
// Otherwise the file is still the same
return !timestamp || timestamp > childCompiler.compilationStartedTimestamp;
});
return isCacheOutOfDate;
} | javascript | function isChildCompilerCacheOutdated (mainCompilation, childCompiler) {
// If the compilation was never run there is no invalid cache
if (!childCompiler.compilationStartedTimestamp) {
return false;
}
// Check if any dependent file was changed after the last compilation
const fileTimestamps = mainCompilation.fileTimestamps;
const isCacheOutOfDate = childCompiler.fileDependencies.some((fileDependency) => {
const timestamp = fileTimestamps.get(fileDependency);
// If the timestamp is not known the file is new
// If the timestamp is larger then the file has changed
// Otherwise the file is still the same
return !timestamp || timestamp > childCompiler.compilationStartedTimestamp;
});
return isCacheOutOfDate;
} | [
"function",
"isChildCompilerCacheOutdated",
"(",
"mainCompilation",
",",
"childCompiler",
")",
"{",
"// If the compilation was never run there is no invalid cache",
"if",
"(",
"!",
"childCompiler",
".",
"compilationStartedTimestamp",
")",
"{",
"return",
"false",
";",
"}",
"... | Returns `true` if the file dependencies of the given childCompiler are outdated.
@param {WebpackCompilation} mainCompilation
@param {HtmlWebpackChildCompiler} childCompiler
@returns {boolean} | [
"Returns",
"true",
"if",
"the",
"file",
"dependencies",
"of",
"the",
"given",
"childCompiler",
"are",
"outdated",
"."
] | 38db64ae8805de37d038e0ee0f6dfa2a26e2163a | https://github.com/jantimon/html-webpack-plugin/blob/38db64ae8805de37d038e0ee0f6dfa2a26e2163a/lib/compiler.js#L333-L348 | train | Checks if the childCompiler is outdated | [
30522,
3853,
2003,
19339,
9006,
22090,
18992,
5403,
5833,
13701,
2094,
1006,
2364,
9006,
8197,
13490,
1010,
2775,
9006,
22090,
2099,
1007,
1063,
1013,
1013,
2065,
1996,
6268,
2001,
2196,
2448,
2045,
2003,
2053,
19528,
17053,
2065,
1006,
999... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/utils/command.js | exec | function exec(command, options) {
var d = Promise.defer();
var child = childProcess.exec(command, options, function(err, stdout, stderr) {
if (!err) {
return d.resolve();
}
err.message = stdout.toString('utf8') + stderr.toString('utf8');
d.reject(err);
});
child.stdout.on('data', function (data) {
d.notify(data);
});
child.stderr.on('data', function (data) {
d.notify(data);
});
return d.promise;
} | javascript | function exec(command, options) {
var d = Promise.defer();
var child = childProcess.exec(command, options, function(err, stdout, stderr) {
if (!err) {
return d.resolve();
}
err.message = stdout.toString('utf8') + stderr.toString('utf8');
d.reject(err);
});
child.stdout.on('data', function (data) {
d.notify(data);
});
child.stderr.on('data', function (data) {
d.notify(data);
});
return d.promise;
} | [
"function",
"exec",
"(",
"command",
",",
"options",
")",
"{",
"var",
"d",
"=",
"Promise",
".",
"defer",
"(",
")",
";",
"var",
"child",
"=",
"childProcess",
".",
"exec",
"(",
"command",
",",
"options",
",",
"function",
"(",
"err",
",",
"stdout",
",",
... | Execute a command
@param {String} command
@param {Object} options
@return {Promise} | [
"Execute",
"a",
"command"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/command.js#L13-L34 | train | Exec a command | [
30522,
3853,
4654,
8586,
1006,
3094,
1010,
7047,
1007,
1063,
13075,
1040,
1027,
4872,
1012,
13366,
2121,
1006,
1007,
1025,
13075,
2775,
1027,
30524,
2358,
26797,
2102,
1010,
2358,
4063,
2099,
1007,
1063,
2065,
1006,
999,
9413,
2099,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function(oNodeList) {
var aNodeValues = [];
var xPath = AnnotationParser._oXPath;
for (var i = 0; i < oNodeList.length; i += 1) {
var oNode = xPath.nextNode(oNodeList, i);
var oValue = {};
var sText = xPath.getNodeText(oNode);
// TODO: Is nodeName correct or should we remove the namespace?
oValue[oNode.nodeName] = AnnotationParser._parserData.aliases ? AnnotationParser.replaceWithAlias(sText) : sText;
aNodeValues.push(oValue);
}
return aNodeValues;
} | javascript | function(oNodeList) {
var aNodeValues = [];
var xPath = AnnotationParser._oXPath;
for (var i = 0; i < oNodeList.length; i += 1) {
var oNode = xPath.nextNode(oNodeList, i);
var oValue = {};
var sText = xPath.getNodeText(oNode);
// TODO: Is nodeName correct or should we remove the namespace?
oValue[oNode.nodeName] = AnnotationParser._parserData.aliases ? AnnotationParser.replaceWithAlias(sText) : sText;
aNodeValues.push(oValue);
}
return aNodeValues;
} | [
"function",
"(",
"oNodeList",
")",
"{",
"var",
"aNodeValues",
"=",
"[",
"]",
";",
"var",
"xPath",
"=",
"AnnotationParser",
".",
"_oXPath",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"oNodeList",
".",
"length",
";",
"i",
"+=",
"1",
")",
... | /*
Extracts the text value from all nodes in the given NodeList and puts them into an array
@param {XPathResult} oNodeList - As many nodes as should be checked for Record values
@return {object[]} Array of values
@static
@private | [
"/",
"*",
"Extracts",
"the",
"text",
"value",
"from",
"all",
"nodes",
"in",
"the",
"given",
"NodeList",
"and",
"puts",
"them",
"into",
"an",
"array"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L883-L897 | train | Returns an array of values for the given DOM nodes | [
30522,
3853,
1006,
21058,
9247,
2923,
1007,
1063,
13075,
2019,
10244,
10175,
15808,
1027,
1031,
1033,
1025,
13075,
26726,
8988,
1027,
5754,
17287,
3508,
19362,
8043,
1012,
1035,
23060,
15069,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js | function (oThis) {
// jQuery Plugin "rect"
var sKey = "",
iVal = 0,
iZero = 0, // this is the 0 of the relative position between ToolPopup and Opener
iHalfArrow = oThis.iArrowHeight / 2,
isRTL = sap.ui.getCore().getConfiguration().getRTL(),
sArrowDir,
oPopRect = oThis.$().rect(),
oOpener = jQuery(document.getElementById(oThis.getOpener())),
oOpenerRect = oOpener.rect(),
popupBorder = 0,
$Arrow = oThis.$("arrow");
if (!oThis.getDomRef()) {
return;
}
oThis._sArrowDir = fnGetArrowDirection(oThis);
sArrowDir = oThis._sArrowDir;
if (isRTL) {
// in RTL mode arrow must be mirrowed here
if (oThis._sArrowDir === "Right") {
sArrowDir = "Left";
} else if (oThis._sArrowDir === "Left") {
sArrowDir = "Right";
}
}
if (!oOpenerRect) {
// if a proper opener isn't available
Log.warning("Opener wasn't set properly. Therefore arrow will be at a default position", "", "sap.ui.ux3.ToolPopup");
}
// get the corresponding my-property
if (!oThis._my && oThis.oPopup) {
oThis._my = oThis.oPopup._oPosition.my;
}
// calculate the horizontal/vertical value of the arrow
if (oThis._bHorizontalArrow) {
// left or right arrow
sKey = "top";
if (oOpenerRect) {
popupBorder = parseInt(oThis.$().css('border-top-width')) || 0;
iZero = parseInt(oOpenerRect.top - popupBorder - oPopRect.top);
iVal = Math.round(iZero + oOpenerRect.height / 2 - iHalfArrow);
// if the position would exceed the ToolPopup's height
iVal = iVal + iHalfArrow > oPopRect.height ? iVal - oThis.iArrowHeight : iVal;
}
} else {
// up/down arrow
sKey = "left";
if (oOpenerRect) {
if (isRTL) {
sKey = "right";
popupBorder = parseInt(oThis.$().css('border-right-width')) || 0;
iZero = parseInt(oPopRect.left + oPopRect.width - oOpenerRect.left - oOpenerRect.width - popupBorder);
} else {
popupBorder = parseInt(oThis.$().css('border-left-width')) || 0;
iZero = parseInt(oOpenerRect.left - oPopRect.left - popupBorder);
}
iVal = Math.round(iZero + oOpenerRect.width / 2 - iHalfArrow);
// if the position would exceed the ToolPopup's width
iVal = iVal + iHalfArrow > oPopRect.width ? iVal - oThis.iArrowHeight : iVal;
}
}
// This is very specific code that applies to HCB theme. This theme has a different logic
// for setting the arrow and so we have another logic
if (!oOpenerRect) {
iVal = oThis.iArrowHeight;
}
// set the corresponding classes
var sClassAttr = "";
if ($Arrow.hasClass("sapUiUx3TPNewArrow")) {
sClassAttr = "sapUiUx3TPNewArrow sapUiUx3TPNewArrow";
} else {
sClassAttr = oThis.isInverted() ? "sapUiUx3TPArrow sapUiTPInverted sapUiUx3TPArrow" : "sapUiUx3TPArrow sapUiUx3TPArrow";
}
$Arrow.attr("class", sClassAttr + sArrowDir);
if (sArrowDir === "Right") {
var iWidth = oPopRect.width;
// if the ToolPopup is invertable and it is being inverted use another
// value since in such a case the padding is different for the arrow
if (oThis.isInverted()) {
iWidth += oThis.iArrowPaddingInverted;
} else {
iWidth += oThis.iArrowPadding;
}
if (isRTL) {
$Arrow.css("right", iWidth + "px");
} else {
$Arrow.css("left", iWidth + "px");
}
} else {
$Arrow.css({
"left": "",
"right": ""
});
}
iVal = parseInt(iVal);
iVal = iVal < -popupBorder ? -popupBorder : iVal;
$Arrow.css(sKey, iVal + "px");
} | javascript | function (oThis) {
// jQuery Plugin "rect"
var sKey = "",
iVal = 0,
iZero = 0, // this is the 0 of the relative position between ToolPopup and Opener
iHalfArrow = oThis.iArrowHeight / 2,
isRTL = sap.ui.getCore().getConfiguration().getRTL(),
sArrowDir,
oPopRect = oThis.$().rect(),
oOpener = jQuery(document.getElementById(oThis.getOpener())),
oOpenerRect = oOpener.rect(),
popupBorder = 0,
$Arrow = oThis.$("arrow");
if (!oThis.getDomRef()) {
return;
}
oThis._sArrowDir = fnGetArrowDirection(oThis);
sArrowDir = oThis._sArrowDir;
if (isRTL) {
// in RTL mode arrow must be mirrowed here
if (oThis._sArrowDir === "Right") {
sArrowDir = "Left";
} else if (oThis._sArrowDir === "Left") {
sArrowDir = "Right";
}
}
if (!oOpenerRect) {
// if a proper opener isn't available
Log.warning("Opener wasn't set properly. Therefore arrow will be at a default position", "", "sap.ui.ux3.ToolPopup");
}
// get the corresponding my-property
if (!oThis._my && oThis.oPopup) {
oThis._my = oThis.oPopup._oPosition.my;
}
// calculate the horizontal/vertical value of the arrow
if (oThis._bHorizontalArrow) {
// left or right arrow
sKey = "top";
if (oOpenerRect) {
popupBorder = parseInt(oThis.$().css('border-top-width')) || 0;
iZero = parseInt(oOpenerRect.top - popupBorder - oPopRect.top);
iVal = Math.round(iZero + oOpenerRect.height / 2 - iHalfArrow);
// if the position would exceed the ToolPopup's height
iVal = iVal + iHalfArrow > oPopRect.height ? iVal - oThis.iArrowHeight : iVal;
}
} else {
// up/down arrow
sKey = "left";
if (oOpenerRect) {
if (isRTL) {
sKey = "right";
popupBorder = parseInt(oThis.$().css('border-right-width')) || 0;
iZero = parseInt(oPopRect.left + oPopRect.width - oOpenerRect.left - oOpenerRect.width - popupBorder);
} else {
popupBorder = parseInt(oThis.$().css('border-left-width')) || 0;
iZero = parseInt(oOpenerRect.left - oPopRect.left - popupBorder);
}
iVal = Math.round(iZero + oOpenerRect.width / 2 - iHalfArrow);
// if the position would exceed the ToolPopup's width
iVal = iVal + iHalfArrow > oPopRect.width ? iVal - oThis.iArrowHeight : iVal;
}
}
// This is very specific code that applies to HCB theme. This theme has a different logic
// for setting the arrow and so we have another logic
if (!oOpenerRect) {
iVal = oThis.iArrowHeight;
}
// set the corresponding classes
var sClassAttr = "";
if ($Arrow.hasClass("sapUiUx3TPNewArrow")) {
sClassAttr = "sapUiUx3TPNewArrow sapUiUx3TPNewArrow";
} else {
sClassAttr = oThis.isInverted() ? "sapUiUx3TPArrow sapUiTPInverted sapUiUx3TPArrow" : "sapUiUx3TPArrow sapUiUx3TPArrow";
}
$Arrow.attr("class", sClassAttr + sArrowDir);
if (sArrowDir === "Right") {
var iWidth = oPopRect.width;
// if the ToolPopup is invertable and it is being inverted use another
// value since in such a case the padding is different for the arrow
if (oThis.isInverted()) {
iWidth += oThis.iArrowPaddingInverted;
} else {
iWidth += oThis.iArrowPadding;
}
if (isRTL) {
$Arrow.css("right", iWidth + "px");
} else {
$Arrow.css("left", iWidth + "px");
}
} else {
$Arrow.css({
"left": "",
"right": ""
});
}
iVal = parseInt(iVal);
iVal = iVal < -popupBorder ? -popupBorder : iVal;
$Arrow.css(sKey, iVal + "px");
} | [
"function",
"(",
"oThis",
")",
"{",
"// jQuery Plugin \"rect\"",
"var",
"sKey",
"=",
"\"\"",
",",
"iVal",
"=",
"0",
",",
"iZero",
"=",
"0",
",",
"// this is the 0 of the relative position between ToolPopup and Opener",
"iHalfArrow",
"=",
"oThis",
".",
"iArrowHeight",... | Calculates the desired arrow position related to the set docking and to the size of the popup.
This only works when "my" and "at" both use the jQuery-based docking which means they
are strings like "begin top".
If there is no opener set properly an error is logged into the console and there will
be no arrow for the ToolPopup.
@param {sap.ui.ux3.ToolPopup} oThis
@private | [
"Calculates",
"the",
"desired",
"arrow",
"position",
"related",
"to",
"the",
"set",
"docking",
"and",
"to",
"the",
"size",
"of",
"the",
"popup",
".",
"This",
"only",
"works",
"when",
"my",
"and",
"at",
"both",
"use",
"the",
"jQuery",
"-",
"based",
"docki... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js#L873-L989 | train | Calculates the arrow position of the arrow | [
30522,
3853,
1006,
27178,
24158,
1007,
1063,
1013,
1013,
1046,
4226,
2854,
13354,
2378,
1000,
28667,
2102,
1000,
13075,
15315,
3240,
1027,
1000,
1000,
1010,
4921,
2389,
1027,
1014,
1010,
1045,
6290,
2080,
1027,
1014,
1010,
1013,
1013,
2023,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
googleapis/google-api-nodejs-client | samples/compute/listVMs.js | listVMs | async function listVMs() {
// [START auth]
const authClient = await google.auth.getClient({
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/compute',
'https://www.googleapis.com/auth/compute.readonly',
],
});
// [END auth]
// [START list]
const projectId = await google.auth.getProjectId();
const result = await compute.instances.aggregatedList({
auth: authClient,
project: projectId,
});
const vms = result.data;
console.log('VMs:', vms);
// [END list]
} | javascript | async function listVMs() {
// [START auth]
const authClient = await google.auth.getClient({
scopes: [
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/compute',
'https://www.googleapis.com/auth/compute.readonly',
],
});
// [END auth]
// [START list]
const projectId = await google.auth.getProjectId();
const result = await compute.instances.aggregatedList({
auth: authClient,
project: projectId,
});
const vms = result.data;
console.log('VMs:', vms);
// [END list]
} | [
"async",
"function",
"listVMs",
"(",
")",
"{",
"// [START auth]",
"const",
"authClient",
"=",
"await",
"google",
".",
"auth",
".",
"getClient",
"(",
"{",
"scopes",
":",
"[",
"'https://www.googleapis.com/auth/cloud-platform'",
",",
"'https://www.googleapis.com/auth/compu... | [END initialize] | [
"[",
"END",
"initialize",
"]"
] | e6e632a29d0b246d058e3067de3a5c3827e2b54e | https://github.com/googleapis/google-api-nodejs-client/blob/e6e632a29d0b246d058e3067de3a5c3827e2b54e/samples/compute/listVMs.js#L24-L44 | train | List all virtual machines in the cluster | [
30522,
2004,
6038,
2278,
3853,
2862,
2615,
5244,
1006,
1007,
1063,
1013,
1013,
1031,
2707,
8740,
2705,
1033,
9530,
3367,
8740,
2705,
20464,
11638,
1027,
26751,
8224,
1012,
8740,
2705,
1012,
2131,
20464,
11638,
1006,
1063,
9531,
2015,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js | mergeAnnotations | function mergeAnnotations(oSchema, mAnnotations, bPrivileged) {
var sTarget;
/*
* "PUT" semantics on term/qualifier level, only privileged sources may overwrite.
*
* @param {object} oTarget
* The target object (which is modified)
* @param {object} oSource
* The source object
*/
function extend(oTarget, oSource) {
var sName;
for (sName in oSource) {
if (bPrivileged || !(sName in oTarget)) {
oTarget[sName] = oSource[sName];
}
}
}
for (sTarget in oSchema.$Annotations) {
if (!(sTarget in mAnnotations)) {
mAnnotations[sTarget] = {};
}
extend(mAnnotations[sTarget], oSchema.$Annotations[sTarget]);
}
delete oSchema.$Annotations;
} | javascript | function mergeAnnotations(oSchema, mAnnotations, bPrivileged) {
var sTarget;
/*
* "PUT" semantics on term/qualifier level, only privileged sources may overwrite.
*
* @param {object} oTarget
* The target object (which is modified)
* @param {object} oSource
* The source object
*/
function extend(oTarget, oSource) {
var sName;
for (sName in oSource) {
if (bPrivileged || !(sName in oTarget)) {
oTarget[sName] = oSource[sName];
}
}
}
for (sTarget in oSchema.$Annotations) {
if (!(sTarget in mAnnotations)) {
mAnnotations[sTarget] = {};
}
extend(mAnnotations[sTarget], oSchema.$Annotations[sTarget]);
}
delete oSchema.$Annotations;
} | [
"function",
"mergeAnnotations",
"(",
"oSchema",
",",
"mAnnotations",
",",
"bPrivileged",
")",
"{",
"var",
"sTarget",
";",
"/*\n\t\t * \"PUT\" semantics on term/qualifier level, only privileged sources may overwrite.\n\t\t *\n\t\t * @param {object} oTarget\n\t\t * The target object (which... | Merges the given schema's annotations into the root scope's $Annotations.
@param {object} oSchema
a schema; schema children are ignored because they do not contain $Annotations
@param {object} mAnnotations
the root scope's $Annotations
@param {boolean} [bPrivileged=false]
whether the schema has been loaded from a privileged source and thus may overwrite
existing annotations | [
"Merges",
"the",
"given",
"schema",
"s",
"annotations",
"into",
"the",
"root",
"scope",
"s",
"$Annotations",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js#L275-L303 | train | Merge annotations from a schema to a target object. | [
30522,
3853,
13590,
11639,
17287,
9285,
1006,
9808,
5403,
2863,
1010,
10856,
17287,
9285,
1010,
17531,
3089,
14762,
24746,
2094,
1007,
1063,
13075,
2732,
18150,
1025,
1013,
1008,
1008,
1000,
2404,
1000,
28081,
2006,
2744,
1013,
10981,
2504,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/hello-mui/js/mui.js | function(scroller, options) {
this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
this.wrapperStyle = this.wrapper.style;
this.indicator = this.wrapper.children[0];
this.indicatorStyle = this.indicator.style;
this.scroller = scroller;
this.options = $.extend({
listenX: true,
listenY: true,
fade: false,
speedRatioX: 0,
speedRatioY: 0
}, options);
this.sizeRatioX = 1;
this.sizeRatioY = 1;
this.maxPosX = 0;
this.maxPosY = 0;
if (this.options.fade) {
this.wrapperStyle['webkitTransform'] = this.scroller.translateZ;
this.wrapperStyle['webkitTransitionDuration'] = this.options.fixedBadAndorid && $.os.isBadAndroid ? '0.001s' : '0ms';
this.wrapperStyle.opacity = '0';
}
} | javascript | function(scroller, options) {
this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
this.wrapperStyle = this.wrapper.style;
this.indicator = this.wrapper.children[0];
this.indicatorStyle = this.indicator.style;
this.scroller = scroller;
this.options = $.extend({
listenX: true,
listenY: true,
fade: false,
speedRatioX: 0,
speedRatioY: 0
}, options);
this.sizeRatioX = 1;
this.sizeRatioY = 1;
this.maxPosX = 0;
this.maxPosY = 0;
if (this.options.fade) {
this.wrapperStyle['webkitTransform'] = this.scroller.translateZ;
this.wrapperStyle['webkitTransitionDuration'] = this.options.fixedBadAndorid && $.os.isBadAndroid ? '0.001s' : '0ms';
this.wrapperStyle.opacity = '0';
}
} | [
"function",
"(",
"scroller",
",",
"options",
")",
"{",
"this",
".",
"wrapper",
"=",
"typeof",
"options",
".",
"el",
"==",
"'string'",
"?",
"document",
".",
"querySelector",
"(",
"options",
".",
"el",
")",
":",
"options",
".",
"el",
";",
"this",
".",
... | Indicator | [
"Indicator"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L4407-L4432 | train | Initialize the object | [
30522,
3853,
1006,
17186,
2121,
1010,
7047,
1007,
1063,
2023,
1012,
10236,
4842,
1027,
2828,
11253,
7047,
1012,
3449,
1027,
1027,
1005,
5164,
1005,
1029,
6254,
1012,
23032,
11246,
22471,
2953,
1006,
7047,
1012,
3449,
1007,
1024,
7047,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/HealthLogger.js | searchDone | function searchDone(searchType) {
var searchDetails = getHealthDataLog("searchDetails");
if (!searchDetails) {
searchDetails = {};
}
if (!searchDetails[searchType]) {
searchDetails[searchType] = 0;
}
searchDetails[searchType]++;
setHealthDataLog("searchDetails", searchDetails);
} | javascript | function searchDone(searchType) {
var searchDetails = getHealthDataLog("searchDetails");
if (!searchDetails) {
searchDetails = {};
}
if (!searchDetails[searchType]) {
searchDetails[searchType] = 0;
}
searchDetails[searchType]++;
setHealthDataLog("searchDetails", searchDetails);
} | [
"function",
"searchDone",
"(",
"searchType",
")",
"{",
"var",
"searchDetails",
"=",
"getHealthDataLog",
"(",
"\"searchDetails\"",
")",
";",
"if",
"(",
"!",
"searchDetails",
")",
"{",
"searchDetails",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"searchDetails",
... | Increments health log count for a particular kind of search done
@param {string} searchType The kind of search type that needs to be logged- should be a js var compatible string | [
"Increments",
"health",
"log",
"count",
"for",
"a",
"particular",
"kind",
"of",
"search",
"done"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L294-L304 | train | search done - set searchDetails to the current search type | [
30522,
3853,
3945,
5280,
2063,
1006,
3945,
13874,
1007,
1063,
13075,
3945,
3207,
22081,
1027,
2131,
20192,
24658,
2850,
9080,
8649,
1006,
1000,
3945,
3207,
22081,
1000,
1007,
1025,
2065,
1006,
999,
3945,
3207,
22081,
1007,
1063,
3945,
3207,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.uxap/src/sap/uxap/component/ObjectPageLayoutUXDrivenFactory.controller.js | function (sStaticHandlerName) {
var fnNameSpace = window, aNameSpaceParts = sStaticHandlerName.split('.');
try {
jQueryDOM.each(aNameSpaceParts, function (iIndex, sNameSpacePart) {
fnNameSpace = fnNameSpace[sNameSpacePart];
});
} catch (sError) {
Log.error("ObjectPageLayoutFactory :: undefined event handler: " + sStaticHandlerName + ". Did you forget to require its static class?");
fnNameSpace = undefined;
}
return fnNameSpace;
} | javascript | function (sStaticHandlerName) {
var fnNameSpace = window, aNameSpaceParts = sStaticHandlerName.split('.');
try {
jQueryDOM.each(aNameSpaceParts, function (iIndex, sNameSpacePart) {
fnNameSpace = fnNameSpace[sNameSpacePart];
});
} catch (sError) {
Log.error("ObjectPageLayoutFactory :: undefined event handler: " + sStaticHandlerName + ". Did you forget to require its static class?");
fnNameSpace = undefined;
}
return fnNameSpace;
} | [
"function",
"(",
"sStaticHandlerName",
")",
"{",
"var",
"fnNameSpace",
"=",
"window",
",",
"aNameSpaceParts",
"=",
"sStaticHandlerName",
".",
"split",
"(",
"'.'",
")",
";",
"try",
"{",
"jQueryDOM",
".",
"each",
"(",
"aNameSpaceParts",
",",
"function",
"(",
"... | determine the static function to use from its name
@param {string} sStaticHandlerName the name of the handler
@returns {*|window|window} function | [
"determine",
"the",
"static",
"function",
"to",
"use",
"from",
"its",
"name"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/ObjectPageLayoutUXDrivenFactory.controller.js#L112-L126 | train | Returns the static class name for the given static event handler name. | [
30522,
3853,
1006,
7020,
29336,
7033,
5685,
3917,
18442,
1007,
1063,
13075,
1042,
9516,
7834,
15327,
1027,
3332,
1010,
9617,
7834,
15327,
26950,
1027,
7020,
29336,
7033,
5685,
3917,
18442,
1012,
3975,
1006,
1005,
1012,
1005,
1007,
1025,
304... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
electron/electron | lib/browser/rpc-server.js | function (obj) {
return Object.getOwnPropertyNames(obj).map(function (name) {
return {
name: name,
value: obj[name]
}
})
} | javascript | function (obj) {
return Object.getOwnPropertyNames(obj).map(function (name) {
return {
name: name,
value: obj[name]
}
})
} | [
"function",
"(",
"obj",
")",
"{",
"return",
"Object",
".",
"getOwnPropertyNames",
"(",
"obj",
")",
".",
"map",
"(",
"function",
"(",
"name",
")",
"{",
"return",
"{",
"name",
":",
"name",
",",
"value",
":",
"obj",
"[",
"name",
"]",
"}",
"}",
")",
... | Convert object to meta by value. | [
"Convert",
"object",
"to",
"meta",
"by",
"value",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/rpc-server.js#L137-L144 | train | Returns an array of the chains of the given object | [
30522,
3853,
1006,
27885,
3501,
1007,
1063,
2709,
4874,
1012,
2131,
12384,
21572,
4842,
25680,
14074,
2015,
1006,
27885,
3501,
1007,
1012,
4949,
1006,
3853,
1006,
2171,
1007,
1063,
2709,
1063,
2171,
1024,
2171,
1010,
3643,
1024,
27885,
3501... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseExpression | function parseExpression() {
var expr, startToken = lookahead;
expr = parseAssignmentExpression();
if (match(',')) {
expr = delegate.createSequenceExpression([ expr ]);
while (index < length) {
if (!match(',')) {
break;
}
lex();
expr.expressions.push(parseAssignmentExpression());
}
delegate.markEnd(expr, startToken);
}
return expr;
} | javascript | function parseExpression() {
var expr, startToken = lookahead;
expr = parseAssignmentExpression();
if (match(',')) {
expr = delegate.createSequenceExpression([ expr ]);
while (index < length) {
if (!match(',')) {
break;
}
lex();
expr.expressions.push(parseAssignmentExpression());
}
delegate.markEnd(expr, startToken);
}
return expr;
} | [
"function",
"parseExpression",
"(",
")",
"{",
"var",
"expr",
",",
"startToken",
"=",
"lookahead",
";",
"expr",
"=",
"parseAssignmentExpression",
"(",
")",
";",
"if",
"(",
"match",
"(",
"','",
")",
")",
"{",
"expr",
"=",
"delegate",
".",
"createSequenceExpr... | 11.14 Comma Operator | [
"11",
".",
"14",
"Comma",
"Operator"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2586-L2606 | train | ECMA - 262 12. 2 Assignment Expressions | [
30522,
3853,
11968,
19763,
2595,
20110,
3258,
1006,
1007,
1063,
13075,
4654,
18098,
1010,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
1025,
4654,
18098,
1027,
11968,
17310,
18719,
16206,
3672,
10288,
20110,
3258,
1006,
1007,
1025,
2065,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-js/src/raven.js | function() {
var self = this;
var wrappedBuiltIns = self._wrappedBuiltIns;
function wrapTimeFn(orig) {
return function(fn, t) {
// preserve arity
// Make a copy of the arguments to prevent deoptimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
var args = new Array(arguments.length);
for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i];
}
var originalCallback = args[0];
if (isFunction(originalCallback)) {
args[0] = self.wrap(
{
mechanism: {
type: 'instrument',
data: {function: orig.name || '<anonymous>'}
}
},
originalCallback
);
}
// IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it
// also supports only two arguments and doesn't care what this is, so we
// can just call the original function directly.
if (orig.apply) {
return orig.apply(this, args);
} else {
return orig(args[0], args[1]);
}
};
}
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs;
function wrapEventTarget(global) {
var proto = _window[global] && _window[global].prototype;
if (proto && proto.hasOwnProperty && proto.hasOwnProperty('addEventListener')) {
fill(
proto,
'addEventListener',
function(orig) {
return function(evtName, fn, capture, secure) {
// preserve arity
try {
if (fn && fn.handleEvent) {
fn.handleEvent = self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'handleEvent',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn.handleEvent
);
}
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
// More breadcrumb DOM capture ... done here and not in `_instrumentBreadcrumbs`
// so that we don't have more than one wrapper function
var before, clickHandler, keypressHandler;
if (
autoBreadcrumbs &&
autoBreadcrumbs.dom &&
(global === 'EventTarget' || global === 'Node')
) {
// NOTE: generating multiple handlers per addEventListener invocation, should
// revisit and verify we can just use one (almost certainly)
clickHandler = self._breadcrumbEventHandler('click');
keypressHandler = self._keypressEventHandler();
before = function(evt) {
// need to intercept every DOM event in `before` argument, in case that
// same wrapped method is re-used for different events (e.g. mousemove THEN click)
// see #724
if (!evt) return;
var eventType;
try {
eventType = evt.type;
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
if (eventType === 'click') return clickHandler(evt);
else if (eventType === 'keypress') return keypressHandler(evt);
};
}
return orig.call(
this,
evtName,
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'addEventListener',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn,
before
),
capture,
secure
);
};
},
wrappedBuiltIns
);
fill(
proto,
'removeEventListener',
function(orig) {
return function(evt, fn, capture, secure) {
try {
fn = fn && (fn.__raven_wrapper__ ? fn.__raven_wrapper__ : fn);
} catch (e) {
// ignore, accessing __raven_wrapper__ will throw in some Selenium environments
}
return orig.call(this, evt, fn, capture, secure);
};
},
wrappedBuiltIns
);
}
}
fill(_window, 'setTimeout', wrapTimeFn, wrappedBuiltIns);
fill(_window, 'setInterval', wrapTimeFn, wrappedBuiltIns);
if (_window.requestAnimationFrame) {
fill(
_window,
'requestAnimationFrame',
function(orig) {
return function(cb) {
return orig(
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
function: 'requestAnimationFrame',
handler: (orig && orig.name) || '<anonymous>'
}
}
},
cb
)
);
};
},
wrappedBuiltIns
);
}
// event targets borrowed from bugsnag-js:
// https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L666
var eventTargets = [
'EventTarget',
'Window',
'Node',
'ApplicationCache',
'AudioTrackList',
'ChannelMergerNode',
'CryptoOperation',
'EventSource',
'FileReader',
'HTMLUnknownElement',
'IDBDatabase',
'IDBRequest',
'IDBTransaction',
'KeyOperation',
'MediaController',
'MessagePort',
'ModalWindow',
'Notification',
'SVGElementInstance',
'Screen',
'TextTrack',
'TextTrackCue',
'TextTrackList',
'WebSocket',
'WebSocketWorker',
'Worker',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload'
];
for (var i = 0; i < eventTargets.length; i++) {
wrapEventTarget(eventTargets[i]);
}
} | javascript | function() {
var self = this;
var wrappedBuiltIns = self._wrappedBuiltIns;
function wrapTimeFn(orig) {
return function(fn, t) {
// preserve arity
// Make a copy of the arguments to prevent deoptimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
var args = new Array(arguments.length);
for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i];
}
var originalCallback = args[0];
if (isFunction(originalCallback)) {
args[0] = self.wrap(
{
mechanism: {
type: 'instrument',
data: {function: orig.name || '<anonymous>'}
}
},
originalCallback
);
}
// IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it
// also supports only two arguments and doesn't care what this is, so we
// can just call the original function directly.
if (orig.apply) {
return orig.apply(this, args);
} else {
return orig(args[0], args[1]);
}
};
}
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs;
function wrapEventTarget(global) {
var proto = _window[global] && _window[global].prototype;
if (proto && proto.hasOwnProperty && proto.hasOwnProperty('addEventListener')) {
fill(
proto,
'addEventListener',
function(orig) {
return function(evtName, fn, capture, secure) {
// preserve arity
try {
if (fn && fn.handleEvent) {
fn.handleEvent = self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'handleEvent',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn.handleEvent
);
}
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
// More breadcrumb DOM capture ... done here and not in `_instrumentBreadcrumbs`
// so that we don't have more than one wrapper function
var before, clickHandler, keypressHandler;
if (
autoBreadcrumbs &&
autoBreadcrumbs.dom &&
(global === 'EventTarget' || global === 'Node')
) {
// NOTE: generating multiple handlers per addEventListener invocation, should
// revisit and verify we can just use one (almost certainly)
clickHandler = self._breadcrumbEventHandler('click');
keypressHandler = self._keypressEventHandler();
before = function(evt) {
// need to intercept every DOM event in `before` argument, in case that
// same wrapped method is re-used for different events (e.g. mousemove THEN click)
// see #724
if (!evt) return;
var eventType;
try {
eventType = evt.type;
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
if (eventType === 'click') return clickHandler(evt);
else if (eventType === 'keypress') return keypressHandler(evt);
};
}
return orig.call(
this,
evtName,
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'addEventListener',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn,
before
),
capture,
secure
);
};
},
wrappedBuiltIns
);
fill(
proto,
'removeEventListener',
function(orig) {
return function(evt, fn, capture, secure) {
try {
fn = fn && (fn.__raven_wrapper__ ? fn.__raven_wrapper__ : fn);
} catch (e) {
// ignore, accessing __raven_wrapper__ will throw in some Selenium environments
}
return orig.call(this, evt, fn, capture, secure);
};
},
wrappedBuiltIns
);
}
}
fill(_window, 'setTimeout', wrapTimeFn, wrappedBuiltIns);
fill(_window, 'setInterval', wrapTimeFn, wrappedBuiltIns);
if (_window.requestAnimationFrame) {
fill(
_window,
'requestAnimationFrame',
function(orig) {
return function(cb) {
return orig(
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
function: 'requestAnimationFrame',
handler: (orig && orig.name) || '<anonymous>'
}
}
},
cb
)
);
};
},
wrappedBuiltIns
);
}
// event targets borrowed from bugsnag-js:
// https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L666
var eventTargets = [
'EventTarget',
'Window',
'Node',
'ApplicationCache',
'AudioTrackList',
'ChannelMergerNode',
'CryptoOperation',
'EventSource',
'FileReader',
'HTMLUnknownElement',
'IDBDatabase',
'IDBRequest',
'IDBTransaction',
'KeyOperation',
'MediaController',
'MessagePort',
'ModalWindow',
'Notification',
'SVGElementInstance',
'Screen',
'TextTrack',
'TextTrackCue',
'TextTrackList',
'WebSocket',
'WebSocketWorker',
'Worker',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload'
];
for (var i = 0; i < eventTargets.length; i++) {
wrapEventTarget(eventTargets[i]);
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"wrappedBuiltIns",
"=",
"self",
".",
"_wrappedBuiltIns",
";",
"function",
"wrapTimeFn",
"(",
"orig",
")",
"{",
"return",
"function",
"(",
"fn",
",",
"t",
")",
"{",
"// preserve arity",
"/... | Wrap timer functions and event targets to catch errors and provide
better metadata. | [
"Wrap",
"timer",
"functions",
"and",
"event",
"targets",
"to",
"catch",
"errors",
"and",
"provide",
"better",
"metadata",
"."
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/src/raven.js#L1102-L1308 | train | This function is called by the constructor when the constructor is called. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
5058,
8569,
4014,
7629,
2015,
1027,
2969,
1012,
1035,
5058,
8569,
4014,
7629,
2015,
1025,
3853,
10236,
7292,
2546,
2078,
1006,
2030,
8004,
1007,
1063,
2709,
3853,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/Async.js | doSequentially | function doSequentially(items, beginProcessItem, failAndStopFast) {
var masterDeferred = new $.Deferred(),
hasFailed = false;
function doItem(i) {
if (i >= items.length) {
if (hasFailed) {
masterDeferred.reject();
} else {
masterDeferred.resolve();
}
return;
}
var itemPromise = beginProcessItem(items[i], i);
itemPromise.done(function () {
doItem(i + 1);
});
itemPromise.fail(function () {
if (failAndStopFast) {
masterDeferred.reject();
// note: we do NOT process any further items in this case
} else {
hasFailed = true;
doItem(i + 1);
}
});
}
doItem(0);
return masterDeferred.promise();
} | javascript | function doSequentially(items, beginProcessItem, failAndStopFast) {
var masterDeferred = new $.Deferred(),
hasFailed = false;
function doItem(i) {
if (i >= items.length) {
if (hasFailed) {
masterDeferred.reject();
} else {
masterDeferred.resolve();
}
return;
}
var itemPromise = beginProcessItem(items[i], i);
itemPromise.done(function () {
doItem(i + 1);
});
itemPromise.fail(function () {
if (failAndStopFast) {
masterDeferred.reject();
// note: we do NOT process any further items in this case
} else {
hasFailed = true;
doItem(i + 1);
}
});
}
doItem(0);
return masterDeferred.promise();
} | [
"function",
"doSequentially",
"(",
"items",
",",
"beginProcessItem",
",",
"failAndStopFast",
")",
"{",
"var",
"masterDeferred",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"hasFailed",
"=",
"false",
";",
"function",
"doItem",
"(",
"i",
")",
"{",
"if",... | Executes a series of tasks in serial (task N does not begin until task N-1 has completed).
Returns a "master" Promise that is resolved once all the tasks have resolved. If one or more
tasks fail, behavior depends on the failAndStopFast flag:
- If true, the master Promise is rejected as soon as the first task fails. The remaining
tasks are never started (the serial sequence is stopped).
- If false, the master Promise is rejected after all tasks have completed.
If nothing fails:
M ------------d
1 >---d .
2 >--d .
3 >--d .
4 >--d
With failAndStopFast = false:
M ------------F
1 >---d . .
2 >--d . .
3 >--F .
4 >--d
With failAndStopFast = true:
M ---------F
1 >---d .
2 >--d .
3 >--F
4 (#4 never runs)
To perform task-specific work after an individual task completes, attach handlers to each
Promise before beginProcessItem() returns it.
@param {!Array.<*>} items
@param {!function(*, number):Promise} beginProcessItem
@param {!boolean} failAndStopFast
@return {$.Promise} | [
"Executes",
"a",
"series",
"of",
"tasks",
"in",
"serial",
"(",
"task",
"N",
"does",
"not",
"begin",
"until",
"task",
"N",
"-",
"1",
"has",
"completed",
")",
".",
"Returns",
"a",
"master",
"Promise",
"that",
"is",
"resolved",
"once",
"all",
"the",
"task... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/Async.js#L162-L196 | train | doSequentially - processes an array of items in sequence | [
30522,
3853,
13004,
15417,
4818,
2135,
1006,
5167,
1010,
4088,
21572,
9623,
30524,
29560,
14399,
24333,
1007,
1063,
13075,
3040,
3207,
7512,
5596,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2038,
7011,
18450,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Configuration.js | function() {
var sName;
// lazy load of LocaleData to avoid cyclic dependencies
if ( !LocaleData ) {
LocaleData = sap.ui.requireSync("sap/ui/core/LocaleData");
}
if (this.calendarType) {
for (sName in CalendarType) {
if (sName.toLowerCase() === this.calendarType.toLowerCase()) {
this.calendarType = sName;
return this.calendarType;
}
}
Log.warning("Parameter 'calendarType' is set to " + this.calendarType + " which isn't a valid value and therefore ignored. The calendar type is determined from format setting and current locale");
}
var sLegacyDateFormat = this.oFormatSettings.getLegacyDateFormat();
switch (sLegacyDateFormat) {
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
return CalendarType.Gregorian;
case "7":
case "8":
case "9":
return CalendarType.Japanese;
case "A":
case "B":
return CalendarType.Islamic;
case "C":
return CalendarType.Persian;
}
return LocaleData.getInstance(this.getLocale()).getPreferredCalendarType();
} | javascript | function() {
var sName;
// lazy load of LocaleData to avoid cyclic dependencies
if ( !LocaleData ) {
LocaleData = sap.ui.requireSync("sap/ui/core/LocaleData");
}
if (this.calendarType) {
for (sName in CalendarType) {
if (sName.toLowerCase() === this.calendarType.toLowerCase()) {
this.calendarType = sName;
return this.calendarType;
}
}
Log.warning("Parameter 'calendarType' is set to " + this.calendarType + " which isn't a valid value and therefore ignored. The calendar type is determined from format setting and current locale");
}
var sLegacyDateFormat = this.oFormatSettings.getLegacyDateFormat();
switch (sLegacyDateFormat) {
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
return CalendarType.Gregorian;
case "7":
case "8":
case "9":
return CalendarType.Japanese;
case "A":
case "B":
return CalendarType.Islamic;
case "C":
return CalendarType.Persian;
}
return LocaleData.getInstance(this.getLocale()).getPreferredCalendarType();
} | [
"function",
"(",
")",
"{",
"var",
"sName",
";",
"// lazy load of LocaleData to avoid cyclic dependencies",
"if",
"(",
"!",
"LocaleData",
")",
"{",
"LocaleData",
"=",
"sap",
".",
"ui",
".",
"requireSync",
"(",
"\"sap/ui/core/LocaleData\"",
")",
";",
"}",
"if",
"(... | Returns the calendar type which is being used in locale dependent functionality.
When it's explicitly set by calling <code>setCalendar</code>, the set calendar type is returned.
Otherwise, the calendar type is determined by checking the format settings and current locale.
@return {sap.ui.core.CalendarType} the current calendar type
@since 1.28.6 | [
"Returns",
"the",
"calendar",
"type",
"which",
"is",
"being",
"used",
"in",
"locale",
"dependent",
"functionality",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Configuration.js#L820-L860 | train | Returns the calendar type of the current locale | [
30522,
3853,
1006,
1007,
1063,
13075,
1055,
18442,
1025,
1013,
1013,
13971,
7170,
1997,
2334,
11960,
2696,
2000,
4468,
23750,
12530,
15266,
2065,
1006,
999,
2334,
11960,
2696,
1007,
1063,
2334,
11960,
2696,
1027,
20066,
1012,
21318,
1012,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/search/FindReplace.js | _selectAndScrollTo | function _selectAndScrollTo(editor, selections, center, preferNoScroll) {
var primarySelection = _.find(selections, function (sel) { return sel.primary; }) || _.last(selections),
resultVisible = editor.isLineVisible(primarySelection.start.line),
centerOptions = Editor.BOUNDARY_CHECK_NORMAL;
if (preferNoScroll && resultVisible) {
// no need to scroll if the line with the match is in view
centerOptions = Editor.BOUNDARY_IGNORE_TOP;
}
// Make sure the primary selection is fully visible on screen.
var primary = _.find(selections, function (sel) {
return sel.primary;
});
if (!primary) {
primary = _.last(selections);
}
editor._codeMirror.scrollIntoView({from: primary.start, to: primary.end});
editor.setSelections(selections, center, centerOptions);
} | javascript | function _selectAndScrollTo(editor, selections, center, preferNoScroll) {
var primarySelection = _.find(selections, function (sel) { return sel.primary; }) || _.last(selections),
resultVisible = editor.isLineVisible(primarySelection.start.line),
centerOptions = Editor.BOUNDARY_CHECK_NORMAL;
if (preferNoScroll && resultVisible) {
// no need to scroll if the line with the match is in view
centerOptions = Editor.BOUNDARY_IGNORE_TOP;
}
// Make sure the primary selection is fully visible on screen.
var primary = _.find(selections, function (sel) {
return sel.primary;
});
if (!primary) {
primary = _.last(selections);
}
editor._codeMirror.scrollIntoView({from: primary.start, to: primary.end});
editor.setSelections(selections, center, centerOptions);
} | [
"function",
"_selectAndScrollTo",
"(",
"editor",
",",
"selections",
",",
"center",
",",
"preferNoScroll",
")",
"{",
"var",
"primarySelection",
"=",
"_",
".",
"find",
"(",
"selections",
",",
"function",
"(",
"sel",
")",
"{",
"return",
"sel",
".",
"primary",
... | @private
Sets the given selections in the editor and applies some heuristics to determine whether and how we should
center the primary selection.
@param {!Editor} editor The editor to search in
@param {!Array<{start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean}>} selections
The selections to set. Must not be empty.
@param {boolean} center Whether to try to center the primary selection vertically on the screen. If false, the selection will still be scrolled
into view if it's offscreen, but will not be centered.
@param {boolean=} preferNoScroll If center is true, whether to avoid scrolling if the hit is in the top half of the screen. Default false. | [
"@private",
"Sets",
"the",
"given",
"selections",
"in",
"the",
"editor",
"and",
"applies",
"some",
"heuristics",
"to",
"determine",
"whether",
"and",
"how",
"we",
"should",
"center",
"the",
"primary",
"selection",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L212-L232 | train | Scrolls the given selection to the given center. | [
30522,
3853,
1035,
7276,
29560,
26775,
14511,
3406,
1006,
3559,
1010,
16310,
1010,
2415,
1010,
9544,
15460,
26775,
14511,
1007,
1063,
13075,
3078,
11246,
18491,
1027,
1035,
1012,
2424,
1006,
16310,
1010,
3853,
1006,
7367,
2140,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | build/js/BoxRefresh.js | function (element, options) {
this.element = element;
this.options = options;
this.$overlay = $(options.overlayTemplate);
if (options.source === '') {
throw new Error('Source url was not defined. Please specify a url in your BoxRefresh source option.');
}
this._setUpListeners();
this.load();
} | javascript | function (element, options) {
this.element = element;
this.options = options;
this.$overlay = $(options.overlayTemplate);
if (options.source === '') {
throw new Error('Source url was not defined. Please specify a url in your BoxRefresh source option.');
}
this._setUpListeners();
this.load();
} | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"this",
".",
"element",
"=",
"element",
";",
"this",
".",
"options",
"=",
"options",
";",
"this",
".",
"$overlay",
"=",
"$",
"(",
"options",
".",
"overlayTemplate",
")",
";",
"if",
"(",
"options",
... | BoxRefresh Class Definition ========================= | [
"BoxRefresh",
"Class",
"Definition",
"========================="
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/build/js/BoxRefresh.js#L35-L46 | train | Constructor for the BoxRefresh class | [
30522,
3853,
1006,
5783,
1010,
7047,
1007,
1063,
2023,
1012,
5783,
1027,
5783,
1025,
2023,
1012,
7047,
1027,
7047,
1025,
2023,
1012,
1002,
2058,
8485,
1027,
1002,
1006,
7047,
1012,
2058,
8485,
18532,
15725,
1007,
1025,
2065,
1006,
7047,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
badges/shields | lib/logos.js | decodeDataUrlFromQueryParam | function decodeDataUrlFromQueryParam(value) {
if (typeof value !== 'string') {
return undefined
}
const maybeDataUrl = prependPrefix(value, 'data:')
.replace(/ /g, '+')
.replace(/\s/g, '')
return isDataUrl(maybeDataUrl) ? maybeDataUrl : undefined
} | javascript | function decodeDataUrlFromQueryParam(value) {
if (typeof value !== 'string') {
return undefined
}
const maybeDataUrl = prependPrefix(value, 'data:')
.replace(/ /g, '+')
.replace(/\s/g, '')
return isDataUrl(maybeDataUrl) ? maybeDataUrl : undefined
} | [
"function",
"decodeDataUrlFromQueryParam",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"undefined",
"}",
"const",
"maybeDataUrl",
"=",
"prependPrefix",
"(",
"value",
",",
"'data:'",
")",
".",
"replace",
"(",
"... | +'s are replaced with spaces when used in query params, this returns them to +'s, then removes remaining whitespace. https://github.com/badges/shields/pull/1546 | [
"+",
"s",
"are",
"replaced",
"with",
"spaces",
"when",
"used",
"in",
"query",
"params",
"this",
"returns",
"them",
"to",
"+",
"s",
"then",
"removes",
"remaining",
"whitespace",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"badges",
"/",
"shields",... | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/lib/logos.js#L40-L48 | train | Decode data url from query string | [
30522,
3853,
21933,
5732,
6790,
3126,
10270,
21716,
4226,
2854,
28689,
2213,
1006,
3643,
1007,
1063,
2065,
1006,
2828,
11253,
3643,
999,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
6151,
28344,
1065,
9530,
3367,
2672,
2850,
2696,
3126,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (mQueryOptions, sPath) {
sPath = sPath[0] === "("
? _Helper.getMetaPath(sPath).slice(1) // avoid leading "/"
: _Helper.getMetaPath(sPath);
if (sPath) {
sPath.split("/").some(function (sSegment) {
mQueryOptions = mQueryOptions && mQueryOptions.$expand
&& mQueryOptions.$expand[sSegment];
return !mQueryOptions;
});
}
return mQueryOptions && mQueryOptions.$select;
} | javascript | function (mQueryOptions, sPath) {
sPath = sPath[0] === "("
? _Helper.getMetaPath(sPath).slice(1) // avoid leading "/"
: _Helper.getMetaPath(sPath);
if (sPath) {
sPath.split("/").some(function (sSegment) {
mQueryOptions = mQueryOptions && mQueryOptions.$expand
&& mQueryOptions.$expand[sSegment];
return !mQueryOptions;
});
}
return mQueryOptions && mQueryOptions.$select;
} | [
"function",
"(",
"mQueryOptions",
",",
"sPath",
")",
"{",
"sPath",
"=",
"sPath",
"[",
"0",
"]",
"===",
"\"(\"",
"?",
"_Helper",
".",
"getMetaPath",
"(",
"sPath",
")",
".",
"slice",
"(",
"1",
")",
"// avoid leading \"/\"",
":",
"_Helper",
".",
"getMetaPat... | Returns the properties that have been selected for the given path.
@param {object} [mQueryOptions]
A map of query options as returned by
{@link sap.ui.model.odata.v4.ODataModel#buildQueryOptions}
@param {string} sPath
The path of the cache value in the cache
@returns {string[]} aSelect
The properties that have been selected for the given path or undefined otherwise | [
"Returns",
"the",
"properties",
"that",
"have",
"been",
"selected",
"for",
"the",
"given",
"path",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L650-L662 | train | Get the query options for the given path | [
30522,
3853,
1006,
1049,
4226,
2854,
7361,
9285,
1010,
14690,
2232,
1007,
1063,
14690,
2232,
1027,
14690,
2232,
1031,
1014,
1033,
1027,
1027,
1027,
1000,
1006,
1000,
1029,
1035,
2393,
2121,
1012,
2131,
11368,
22068,
2705,
1006,
14690,
2232,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/datepicker/js/calendarYearBody.js | mdCalendarYearDirective | function mdCalendarYearDirective() {
return {
require: ['^^mdCalendar', '^^mdCalendarYear', 'mdCalendarYearBody'],
scope: { offset: '=mdYearOffset' },
controller: CalendarYearBodyCtrl,
controllerAs: 'mdYearBodyCtrl',
bindToController: true,
link: function(scope, element, attrs, controllers) {
var calendarCtrl = controllers[0];
var yearCtrl = controllers[1];
var yearBodyCtrl = controllers[2];
yearBodyCtrl.calendarCtrl = calendarCtrl;
yearBodyCtrl.yearCtrl = yearCtrl;
scope.$watch(function() { return yearBodyCtrl.offset; }, function(offset) {
if (angular.isNumber(offset)) {
yearBodyCtrl.generateContent();
}
});
}
};
} | javascript | function mdCalendarYearDirective() {
return {
require: ['^^mdCalendar', '^^mdCalendarYear', 'mdCalendarYearBody'],
scope: { offset: '=mdYearOffset' },
controller: CalendarYearBodyCtrl,
controllerAs: 'mdYearBodyCtrl',
bindToController: true,
link: function(scope, element, attrs, controllers) {
var calendarCtrl = controllers[0];
var yearCtrl = controllers[1];
var yearBodyCtrl = controllers[2];
yearBodyCtrl.calendarCtrl = calendarCtrl;
yearBodyCtrl.yearCtrl = yearCtrl;
scope.$watch(function() { return yearBodyCtrl.offset; }, function(offset) {
if (angular.isNumber(offset)) {
yearBodyCtrl.generateContent();
}
});
}
};
} | [
"function",
"mdCalendarYearDirective",
"(",
")",
"{",
"return",
"{",
"require",
":",
"[",
"'^^mdCalendar'",
",",
"'^^mdCalendarYear'",
",",
"'mdCalendarYearBody'",
"]",
",",
"scope",
":",
"{",
"offset",
":",
"'=mdYearOffset'",
"}",
",",
"controller",
":",
"Calen... | Private component, consumed by the md-calendar-year, which separates the DOM construction logic
and allows for the year view to use md-virtual-repeat. | [
"Private",
"component",
"consumed",
"by",
"the",
"md",
"-",
"calendar",
"-",
"year",
"which",
"separates",
"the",
"DOM",
"construction",
"logic",
"and",
"allows",
"for",
"the",
"year",
"view",
"to",
"use",
"md",
"-",
"virtual",
"-",
"repeat",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarYearBody.js#L11-L33 | train | A directive that allows you to control the year of the calendar. | [
30522,
3853,
9108,
9289,
10497,
5649,
14644,
4305,
2890,
15277,
1006,
1007,
1063,
2709,
1063,
5478,
1024,
1031,
1005,
1034,
1034,
9108,
9289,
10497,
2906,
1005,
1010,
1005,
1034,
1034,
9108,
9289,
10497,
5649,
14644,
1005,
1010,
1005,
9108,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | src/components/container.js | flattenDeps | function flattenDeps(allDeps, factory) {
const addToDeps = allDeps.concat([factory]);
return Array.isArray(factory.deps) && factory.deps.length ?
factory.deps.reduce((accu, dep) => flattenDeps(accu, dep), addToDeps) :
addToDeps;
} | javascript | function flattenDeps(allDeps, factory) {
const addToDeps = allDeps.concat([factory]);
return Array.isArray(factory.deps) && factory.deps.length ?
factory.deps.reduce((accu, dep) => flattenDeps(accu, dep), addToDeps) :
addToDeps;
} | [
"function",
"flattenDeps",
"(",
"allDeps",
",",
"factory",
")",
"{",
"const",
"addToDeps",
"=",
"allDeps",
".",
"concat",
"(",
"[",
"factory",
"]",
")",
";",
"return",
"Array",
".",
"isArray",
"(",
"factory",
".",
"deps",
")",
"&&",
"factory",
".",
"de... | entryPoint | [
"entryPoint"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/components/container.js#L144-L149 | train | flatten deps array | [
30522,
3853,
4257,
6528,
3207,
4523,
1006,
2035,
3207,
4523,
1010,
4713,
1007,
1063,
9530,
3367,
5587,
3406,
3207,
4523,
1027,
2035,
3207,
4523,
1012,
9530,
11266,
1006,
1031,
4713,
1033,
1007,
1025,
2709,
9140,
1012,
18061,
11335,
2100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/core/component.js | function (value) {
var parsedValue;
if (typeof value !== 'string') { return value; }
if (this.isSingleProperty) {
parsedValue = this.schema.parse(value);
/**
* To avoid bogus double parsings. Cached values will be parsed when building
* component data. For instance when parsing a src id to its url, we want to cache
* original string and not the parsed one (#monster -> models/monster.dae)
* so when building data we parse the expected value.
*/
if (typeof parsedValue === 'string') { parsedValue = value; }
} else {
// Parse using the style parser to avoid double parsing of individual properties.
utils.objectPool.clearObject(this.parsingAttrValue);
parsedValue = styleParser.parse(value, this.parsingAttrValue);
}
return parsedValue;
} | javascript | function (value) {
var parsedValue;
if (typeof value !== 'string') { return value; }
if (this.isSingleProperty) {
parsedValue = this.schema.parse(value);
/**
* To avoid bogus double parsings. Cached values will be parsed when building
* component data. For instance when parsing a src id to its url, we want to cache
* original string and not the parsed one (#monster -> models/monster.dae)
* so when building data we parse the expected value.
*/
if (typeof parsedValue === 'string') { parsedValue = value; }
} else {
// Parse using the style parser to avoid double parsing of individual properties.
utils.objectPool.clearObject(this.parsingAttrValue);
parsedValue = styleParser.parse(value, this.parsingAttrValue);
}
return parsedValue;
} | [
"function",
"(",
"value",
")",
"{",
"var",
"parsedValue",
";",
"if",
"(",
"typeof",
"value",
"!==",
"'string'",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"this",
".",
"isSingleProperty",
")",
"{",
"parsedValue",
"=",
"this",
".",
"schema",
".",... | Given an HTML attribute value parses the string based on the component schema.
To avoid double parsings of strings into strings we store the original instead
of the parsed one
@param {string} value - HTML attribute value | [
"Given",
"an",
"HTML",
"attribute",
"value",
"parses",
"the",
"string",
"based",
"on",
"the",
"component",
"schema",
".",
"To",
"avoid",
"double",
"parsings",
"of",
"strings",
"into",
"strings",
"we",
"store",
"the",
"original",
"instead",
"of",
"the",
"pars... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/component.js#L236-L254 | train | Parses the given value. | [
30522,
3853,
1006,
3643,
1007,
1063,
13075,
11968,
6924,
10175,
5657,
1025,
2065,
1006,
2828,
11253,
3643,
999,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
3643,
1025,
1065,
2065,
1006,
2023,
1012,
26354,
2075,
2571,
21572,
4842,
3723,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mdx-js/mdx | packages/mdx/mdx-hast-to-jsx.js | toJSX | function toJSX(node, parentNode = {}, options = {}) {
const {
// Default options
skipExport = false,
preserveNewlines = false,
wrapExport
} = options
let children = ''
if (node.properties != null) {
// Turn style strings into JSX-friendly style object
if (typeof node.properties.style === 'string') {
node.properties.style = toStyleObject(node.properties.style, {
camelize: true
})
}
// Transform class property to JSX-friendly className
if (node.properties.class) {
node.properties.className = node.properties.class
delete node.properties.class
}
// AriaProperty => aria-property
// dataProperty => data-property
const paramCaseRe = /^(aria[A-Z])|(data[A-Z])/
node.properties = Object.entries(node.properties).reduce(
(properties, [key, value]) =>
Object.assign({}, properties, {
[paramCaseRe.test(key) ? paramCase(key) : key]: value
}),
{}
)
}
if (node.type === 'root') {
const importNodes = []
const exportNodes = []
const jsxNodes = []
let layout
for (const childNode of node.children) {
if (childNode.type === 'import') {
importNodes.push(childNode)
continue
}
if (childNode.type === 'export') {
if (childNode.default) {
layout = childNode.value
.replace(/^export\s+default\s+/, '')
.replace(/;\s*$/, '')
continue
}
exportNodes.push(childNode)
continue
}
jsxNodes.push(childNode)
}
const exportNames = exportNodes
.map(node =>
node.value.match(/export\s*(var|const|let|class|function)?\s*(\w+)/)
)
.map(match => (Array.isArray(match) ? match[2] : null))
.filter(Boolean)
const importStatements = importNodes
.map(childNode => toJSX(childNode, node))
.join('\n')
const exportStatements = exportNodes
.map(childNode => toJSX(childNode, node))
.join('\n')
const layoutProps = `const layoutProps = {
${exportNames.join(',\n')}
};`
const mdxLayout = `const MDXLayout = ${layout ? layout : '"wrapper"'}`
const fn = `function MDXContent({ components, ...props }) {
return (
<MDXLayout
{...layoutProps}
{...props}
components={components}>
${jsxNodes.map(childNode => toJSX(childNode, node)).join('')}
</MDXLayout>
)
}
MDXContent.isMDXComponent = true`
// Check JSX nodes against imports
const babelPluginExptractImportNamesInstance = new BabelPluginExtractImportNames()
transformSync(importStatements, {
configFile: false,
babelrc: false,
plugins: [
require('@babel/plugin-syntax-jsx'),
require('@babel/plugin-syntax-object-rest-spread'),
babelPluginExptractImportNamesInstance.plugin
]
})
const importNames = babelPluginExptractImportNamesInstance.state.names
const babelPluginExtractJsxNamesInstance = new BabelPluginExtractJsxNames()
const fnPostMdxTypeProp = transformSync(fn, {
configFile: false,
babelrc: false,
plugins: [
require('@babel/plugin-syntax-jsx'),
require('@babel/plugin-syntax-object-rest-spread'),
babelPluginExtractJsxNamesInstance.plugin
]
}).code
const jsxNames = babelPluginExtractJsxNamesInstance.state.names
.filter(name => STARTS_WITH_CAPITAL_LETTER.test(name))
.filter(name => name !== 'MDXLayout')
const importExportNames = importNames.concat(exportNames)
const fakedModulesForGlobalScope =
`const makeShortcode = name => function MDXDefaultShortcode(props) {
console.warn("Component " + name + " was not imported, exported, or provided by MDXProvider as global scope")
return <div {...props}/>
};
` +
uniq(jsxNames)
.filter(name => !importExportNames.includes(name))
.map(name => {
return `const ${name} = makeShortcode("${name}");`
})
.join('\n')
const moduleBase = `${importStatements}
${exportStatements}
${fakedModulesForGlobalScope}
${layoutProps}
${mdxLayout}`
if (skipExport) {
return `${moduleBase}
${fnPostMdxTypeProp}`
}
if (wrapExport) {
return `${moduleBase}
${fnPostMdxTypeProp}
export default ${wrapExport}(MDXContent)`
}
return `${moduleBase}
export default ${fnPostMdxTypeProp}`
}
// Recursively walk through children
if (node.children) {
children = node.children
.map(childNode => {
const childOptions = Object.assign({}, options, {
// Tell all children inside <pre> tags to preserve newlines as text nodes
preserveNewlines: preserveNewlines || node.tagName === 'pre'
})
return toJSX(childNode, node, childOptions)
})
.join('')
}
if (node.type === 'element') {
let props = ''
if (node.properties && Array.isArray(node.properties.className)) {
node.properties.className = node.properties.className.join(' ')
}
if (node.properties && Object.keys(node.properties).length > 0) {
props = JSON.stringify(node.properties)
}
return `<${node.tagName}${
parentNode.tagName ? ` parentName="${parentNode.tagName}"` : ''
}${props ? ` {...${props}}` : ''}>${children}</${node.tagName}>`
}
// Wraps text nodes inside template string, so that we don't run into escaping issues.
if (node.type === 'text') {
// Don't wrap newlines unless specifically instructed to by the flag,
// to avoid issues like React warnings caused by text nodes in tables.
const shouldPreserveNewlines =
preserveNewlines || parentNode.tagName === 'p'
if (node.value === '\n' && !shouldPreserveNewlines) {
return node.value
}
return toTemplateLiteral(node.value)
}
if (node.type === 'comment') {
return `{/*${node.value}*/}`
}
if (node.type === 'import' || node.type === 'export' || node.type === 'jsx') {
return node.value
}
} | javascript | function toJSX(node, parentNode = {}, options = {}) {
const {
// Default options
skipExport = false,
preserveNewlines = false,
wrapExport
} = options
let children = ''
if (node.properties != null) {
// Turn style strings into JSX-friendly style object
if (typeof node.properties.style === 'string') {
node.properties.style = toStyleObject(node.properties.style, {
camelize: true
})
}
// Transform class property to JSX-friendly className
if (node.properties.class) {
node.properties.className = node.properties.class
delete node.properties.class
}
// AriaProperty => aria-property
// dataProperty => data-property
const paramCaseRe = /^(aria[A-Z])|(data[A-Z])/
node.properties = Object.entries(node.properties).reduce(
(properties, [key, value]) =>
Object.assign({}, properties, {
[paramCaseRe.test(key) ? paramCase(key) : key]: value
}),
{}
)
}
if (node.type === 'root') {
const importNodes = []
const exportNodes = []
const jsxNodes = []
let layout
for (const childNode of node.children) {
if (childNode.type === 'import') {
importNodes.push(childNode)
continue
}
if (childNode.type === 'export') {
if (childNode.default) {
layout = childNode.value
.replace(/^export\s+default\s+/, '')
.replace(/;\s*$/, '')
continue
}
exportNodes.push(childNode)
continue
}
jsxNodes.push(childNode)
}
const exportNames = exportNodes
.map(node =>
node.value.match(/export\s*(var|const|let|class|function)?\s*(\w+)/)
)
.map(match => (Array.isArray(match) ? match[2] : null))
.filter(Boolean)
const importStatements = importNodes
.map(childNode => toJSX(childNode, node))
.join('\n')
const exportStatements = exportNodes
.map(childNode => toJSX(childNode, node))
.join('\n')
const layoutProps = `const layoutProps = {
${exportNames.join(',\n')}
};`
const mdxLayout = `const MDXLayout = ${layout ? layout : '"wrapper"'}`
const fn = `function MDXContent({ components, ...props }) {
return (
<MDXLayout
{...layoutProps}
{...props}
components={components}>
${jsxNodes.map(childNode => toJSX(childNode, node)).join('')}
</MDXLayout>
)
}
MDXContent.isMDXComponent = true`
// Check JSX nodes against imports
const babelPluginExptractImportNamesInstance = new BabelPluginExtractImportNames()
transformSync(importStatements, {
configFile: false,
babelrc: false,
plugins: [
require('@babel/plugin-syntax-jsx'),
require('@babel/plugin-syntax-object-rest-spread'),
babelPluginExptractImportNamesInstance.plugin
]
})
const importNames = babelPluginExptractImportNamesInstance.state.names
const babelPluginExtractJsxNamesInstance = new BabelPluginExtractJsxNames()
const fnPostMdxTypeProp = transformSync(fn, {
configFile: false,
babelrc: false,
plugins: [
require('@babel/plugin-syntax-jsx'),
require('@babel/plugin-syntax-object-rest-spread'),
babelPluginExtractJsxNamesInstance.plugin
]
}).code
const jsxNames = babelPluginExtractJsxNamesInstance.state.names
.filter(name => STARTS_WITH_CAPITAL_LETTER.test(name))
.filter(name => name !== 'MDXLayout')
const importExportNames = importNames.concat(exportNames)
const fakedModulesForGlobalScope =
`const makeShortcode = name => function MDXDefaultShortcode(props) {
console.warn("Component " + name + " was not imported, exported, or provided by MDXProvider as global scope")
return <div {...props}/>
};
` +
uniq(jsxNames)
.filter(name => !importExportNames.includes(name))
.map(name => {
return `const ${name} = makeShortcode("${name}");`
})
.join('\n')
const moduleBase = `${importStatements}
${exportStatements}
${fakedModulesForGlobalScope}
${layoutProps}
${mdxLayout}`
if (skipExport) {
return `${moduleBase}
${fnPostMdxTypeProp}`
}
if (wrapExport) {
return `${moduleBase}
${fnPostMdxTypeProp}
export default ${wrapExport}(MDXContent)`
}
return `${moduleBase}
export default ${fnPostMdxTypeProp}`
}
// Recursively walk through children
if (node.children) {
children = node.children
.map(childNode => {
const childOptions = Object.assign({}, options, {
// Tell all children inside <pre> tags to preserve newlines as text nodes
preserveNewlines: preserveNewlines || node.tagName === 'pre'
})
return toJSX(childNode, node, childOptions)
})
.join('')
}
if (node.type === 'element') {
let props = ''
if (node.properties && Array.isArray(node.properties.className)) {
node.properties.className = node.properties.className.join(' ')
}
if (node.properties && Object.keys(node.properties).length > 0) {
props = JSON.stringify(node.properties)
}
return `<${node.tagName}${
parentNode.tagName ? ` parentName="${parentNode.tagName}"` : ''
}${props ? ` {...${props}}` : ''}>${children}</${node.tagName}>`
}
// Wraps text nodes inside template string, so that we don't run into escaping issues.
if (node.type === 'text') {
// Don't wrap newlines unless specifically instructed to by the flag,
// to avoid issues like React warnings caused by text nodes in tables.
const shouldPreserveNewlines =
preserveNewlines || parentNode.tagName === 'p'
if (node.value === '\n' && !shouldPreserveNewlines) {
return node.value
}
return toTemplateLiteral(node.value)
}
if (node.type === 'comment') {
return `{/*${node.value}*/}`
}
if (node.type === 'import' || node.type === 'export' || node.type === 'jsx') {
return node.value
}
} | [
"function",
"toJSX",
"(",
"node",
",",
"parentNode",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"// Default options",
"skipExport",
"=",
"false",
",",
"preserveNewlines",
"=",
"false",
",",
"wrapExport",
"}",
"=",
"options",
"l... | eslint-disable-next-line complexity | [
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"complexity"
] | 7433324d209aca541ea72cb93fe570685b364b9f | https://github.com/mdx-js/mdx/blob/7433324d209aca541ea72cb93fe570685b364b9f/packages/mdx/mdx-hast-to-jsx.js#L65-L268 | train | Convert a node to JSX | [
30522,
3853,
2000,
22578,
2595,
1006,
13045,
1010,
6687,
3630,
3207,
1027,
1063,
1065,
1010,
7047,
1027,
1063,
1065,
1007,
1063,
9530,
3367,
1063,
1013,
1013,
12398,
7047,
13558,
10288,
6442,
1027,
6270,
1010,
7969,
2638,
13668,
10586,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mochajs/mocha | lib/runner.js | filterLeaks | function filterLeaks(ok, globals) {
return globals.filter(function(key) {
// Firefox and Chrome exposes iframes as index inside the window object
if (/^\d+/.test(key)) {
return false;
}
// in firefox
// if runner runs in an iframe, this iframe's window.getInterface method
// not init at first it is assigned in some seconds
if (global.navigator && /^getInterface/.test(key)) {
return false;
}
// an iframe could be approached by window[iframeIndex]
// in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
if (global.navigator && /^\d+/.test(key)) {
return false;
}
// Opera and IE expose global variables for HTML element IDs (issue #243)
if (/^mocha-/.test(key)) {
return false;
}
var matched = ok.filter(function(ok) {
if (~ok.indexOf('*')) {
return key.indexOf(ok.split('*')[0]) === 0;
}
return key === ok;
});
return !matched.length && (!global.navigator || key !== 'onerror');
});
} | javascript | function filterLeaks(ok, globals) {
return globals.filter(function(key) {
// Firefox and Chrome exposes iframes as index inside the window object
if (/^\d+/.test(key)) {
return false;
}
// in firefox
// if runner runs in an iframe, this iframe's window.getInterface method
// not init at first it is assigned in some seconds
if (global.navigator && /^getInterface/.test(key)) {
return false;
}
// an iframe could be approached by window[iframeIndex]
// in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
if (global.navigator && /^\d+/.test(key)) {
return false;
}
// Opera and IE expose global variables for HTML element IDs (issue #243)
if (/^mocha-/.test(key)) {
return false;
}
var matched = ok.filter(function(ok) {
if (~ok.indexOf('*')) {
return key.indexOf(ok.split('*')[0]) === 0;
}
return key === ok;
});
return !matched.length && (!global.navigator || key !== 'onerror');
});
} | [
"function",
"filterLeaks",
"(",
"ok",
",",
"globals",
")",
"{",
"return",
"globals",
".",
"filter",
"(",
"function",
"(",
"key",
")",
"{",
"// Firefox and Chrome exposes iframes as index inside the window object",
"if",
"(",
"/",
"^\\d+",
"/",
".",
"test",
"(",
... | Filter leaks with the given globals flagged as `ok`.
@private
@param {Array} ok
@param {Array} globals
@return {Array} | [
"Filter",
"leaks",
"with",
"the",
"given",
"globals",
"flagged",
"as",
"ok",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/runner.js#L958-L991 | train | filterLeaks returns true if any of the globals is not present in the ok array | [
30522,
3853,
11307,
19738,
5705,
1006,
7929,
1010,
3795,
2015,
1007,
1063,
2709,
3795,
2015,
1012,
11307,
1006,
3853,
1006,
3145,
1007,
1063,
1013,
1013,
2543,
14876,
2595,
1998,
18546,
14451,
2015,
2065,
6444,
2229,
2004,
5950,
2503,
1996,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableGrouping.js | function(oTable) {
var oBinding = oTable.getBinding("rows");
if (oBinding && oBinding._modified) {
TableGrouping.clearMode(oTable);
var oBindingInfo = oTable.getBindingInfo("rows");
oTable.unbindRows();
oTable.bindRows(oBindingInfo);
}
} | javascript | function(oTable) {
var oBinding = oTable.getBinding("rows");
if (oBinding && oBinding._modified) {
TableGrouping.clearMode(oTable);
var oBindingInfo = oTable.getBindingInfo("rows");
oTable.unbindRows();
oTable.bindRows(oBindingInfo);
}
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oBinding",
"=",
"oTable",
".",
"getBinding",
"(",
"\"rows\"",
")",
";",
"if",
"(",
"oBinding",
"&&",
"oBinding",
".",
"_modified",
")",
"{",
"TableGrouping",
".",
"clearMode",
"(",
"oTable",
")",
";",
"var",
... | Cleans up the experimental grouping for sap.ui.table.Table.
@param {sap.ui.table.Table} oTable Instance of the table. | [
"Cleans",
"up",
"the",
"experimental",
"grouping",
"for",
"sap",
".",
"ui",
".",
"table",
".",
"Table",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableGrouping.js#L681-L689 | train | Removes all rows bindings and sets the table to the default mode. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
27885,
22254,
2075,
1027,
27178,
3085,
1012,
2131,
8428,
4667,
1006,
1000,
10281,
1000,
1007,
1025,
2065,
1006,
27885,
22254,
2075,
1004,
1004,
27885,
22254,
2075,
1012,
1035,
6310,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/component/graphic.js | getCleanedElOption | function getCleanedElOption(elOption) {
elOption = zrUtil.extend({}, elOption);
zrUtil.each(
['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
function (name) {
delete elOption[name];
}
);
return elOption;
} | javascript | function getCleanedElOption(elOption) {
elOption = zrUtil.extend({}, elOption);
zrUtil.each(
['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
function (name) {
delete elOption[name];
}
);
return elOption;
} | [
"function",
"getCleanedElOption",
"(",
"elOption",
")",
"{",
"elOption",
"=",
"zrUtil",
".",
"extend",
"(",
"{",
"}",
",",
"elOption",
")",
";",
"zrUtil",
".",
"each",
"(",
"[",
"'id'",
",",
"'parentId'",
",",
"'$action'",
",",
"'hv'",
",",
"'bounding'",... | Remove unnecessary props to avoid potential problems. | [
"Remove",
"unnecessary",
"props",
"to",
"avoid",
"potential",
"problems",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/graphic.js#L439-L448 | train | Returns an object with the cleared parameters | [
30522,
3853,
2131,
14321,
7231,
9247,
7361,
3508,
1006,
3449,
7361,
3508,
1007,
1063,
3449,
7361,
3508,
1027,
1062,
22134,
4014,
1012,
7949,
1006,
1063,
1065,
1010,
3449,
7361,
3508,
1007,
1025,
1062,
22134,
4014,
1012,
2169,
1006,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (elem)
{
var nsMatch;
var from = null;
if (this.options.matchBare) {
from = Strophe.getBareJidFromJid(elem.getAttribute('from'));
} else {
from = elem.getAttribute('from');
}
nsMatch = false;
if (!this.ns) {
nsMatch = true;
} else {
var that = this;
Strophe.forEachChild(elem, null, function (elem) {
if (elem.getAttribute("xmlns") == that.ns) {
nsMatch = true;
}
});
nsMatch = nsMatch || elem.getAttribute("xmlns") == this.ns;
}
var elem_type = elem.getAttribute("type");
if (nsMatch &&
(!this.name || Strophe.isTagEqual(elem, this.name)) &&
(!this.type || (Array.isArray(this.type) ? this.type.indexOf(elem_type) != -1 : elem_type == this.type)) &&
(!this.id || elem.getAttribute("id") == this.id) &&
(!this.from || from == this.from)) {
return true;
}
return false;
} | javascript | function (elem)
{
var nsMatch;
var from = null;
if (this.options.matchBare) {
from = Strophe.getBareJidFromJid(elem.getAttribute('from'));
} else {
from = elem.getAttribute('from');
}
nsMatch = false;
if (!this.ns) {
nsMatch = true;
} else {
var that = this;
Strophe.forEachChild(elem, null, function (elem) {
if (elem.getAttribute("xmlns") == that.ns) {
nsMatch = true;
}
});
nsMatch = nsMatch || elem.getAttribute("xmlns") == this.ns;
}
var elem_type = elem.getAttribute("type");
if (nsMatch &&
(!this.name || Strophe.isTagEqual(elem, this.name)) &&
(!this.type || (Array.isArray(this.type) ? this.type.indexOf(elem_type) != -1 : elem_type == this.type)) &&
(!this.id || elem.getAttribute("id") == this.id) &&
(!this.from || from == this.from)) {
return true;
}
return false;
} | [
"function",
"(",
"elem",
")",
"{",
"var",
"nsMatch",
";",
"var",
"from",
"=",
"null",
";",
"if",
"(",
"this",
".",
"options",
".",
"matchBare",
")",
"{",
"from",
"=",
"Strophe",
".",
"getBareJidFromJid",
"(",
"elem",
".",
"getAttribute",
"(",
"'from'",... | PrivateFunction: isMatch
Tests if a stanza matches the Strophe.Handler.
Parameters:
(XMLElement) elem - The XML element to test.
Returns:
true if the stanza matches and false otherwise. | [
"PrivateFunction",
":",
"isMatch",
"Tests",
"if",
"a",
"stanza",
"matches",
"the",
"Strophe",
".",
"Handler",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L1838-L1873 | train | Returns true if the element is a child of the tag | [
30522,
3853,
1006,
3449,
6633,
1007,
1063,
13075,
24978,
18900,
2818,
1025,
13075,
2013,
1027,
19701,
1025,
2065,
1006,
2023,
1012,
7047,
1012,
2674,
8237,
2063,
1007,
1063,
2013,
1027,
2358,
18981,
5369,
1012,
2131,
8237,
20518,
3593,
1969... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/coord/parallel/Parallel.js | function (parallelModel, api) {
this._rect = layoutUtil.getLayoutRect(
parallelModel.getBoxLayoutParams(),
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._layoutAxes();
} | javascript | function (parallelModel, api) {
this._rect = layoutUtil.getLayoutRect(
parallelModel.getBoxLayoutParams(),
{
width: api.getWidth(),
height: api.getHeight()
}
);
this._layoutAxes();
} | [
"function",
"(",
"parallelModel",
",",
"api",
")",
"{",
"this",
".",
"_rect",
"=",
"layoutUtil",
".",
"getLayoutRect",
"(",
"parallelModel",
".",
"getBoxLayoutParams",
"(",
")",
",",
"{",
"width",
":",
"api",
".",
"getWidth",
"(",
")",
",",
"height",
":"... | Resize the parallel coordinate system.
@param {module:echarts/coord/parallel/ParallelModel} parallelModel
@param {module:echarts/ExtensionAPI} api | [
"Resize",
"the",
"parallel",
"coordinate",
"system",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L176-L186 | train | Initialize the layout | [
30522,
3853,
1006,
5903,
5302,
9247,
1010,
17928,
1007,
1063,
2023,
1012,
1035,
28667,
2102,
1027,
9621,
21823,
2140,
1012,
2131,
8485,
5833,
2890,
6593,
1006,
5903,
5302,
9247,
1012,
2131,
8758,
8485,
5833,
28689,
5244,
1006,
1007,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
firebase/firebaseui-web | javascript/widgets/handler/phonesigninfinish.js | function(userCredential) {
component.dismissDialog();
// Show code verified dialog.
component.showProgressDialog(
firebaseui.auth.ui.element.progressDialog.State.DONE,
firebaseui.auth.soy2.strings.dialogCodeVerified().toString());
// Keep on display for long enough to be seen.
var codeVerifiedTimer = setTimeout(function() {
// Dismiss dialog and dispose of component before completing sign-in.
component.dismissDialog();
component.dispose();
var authResult = /** @type {!firebaseui.auth.AuthResult} */ ({
// User already signed on external instance.
'user': app.getExternalAuth().currentUser,
// Phone Auth operations do not return a credential.
'credential': null,
'operationType': userCredential['operationType'],
'additionalUserInfo': userCredential['additionalUserInfo']
});
firebaseui.auth.widget.handler.common.setLoggedInWithAuthResult(
app, component, authResult, true);
}, firebaseui.auth.widget.handler.CODE_SUCCESS_DIALOG_DELAY);
// On reset, clear timeout.
app.registerPending(function() {
// Dismiss dialog if still visible.
if (component) {
component.dismissDialog();
}
clearTimeout(codeVerifiedTimer);
});
} | javascript | function(userCredential) {
component.dismissDialog();
// Show code verified dialog.
component.showProgressDialog(
firebaseui.auth.ui.element.progressDialog.State.DONE,
firebaseui.auth.soy2.strings.dialogCodeVerified().toString());
// Keep on display for long enough to be seen.
var codeVerifiedTimer = setTimeout(function() {
// Dismiss dialog and dispose of component before completing sign-in.
component.dismissDialog();
component.dispose();
var authResult = /** @type {!firebaseui.auth.AuthResult} */ ({
// User already signed on external instance.
'user': app.getExternalAuth().currentUser,
// Phone Auth operations do not return a credential.
'credential': null,
'operationType': userCredential['operationType'],
'additionalUserInfo': userCredential['additionalUserInfo']
});
firebaseui.auth.widget.handler.common.setLoggedInWithAuthResult(
app, component, authResult, true);
}, firebaseui.auth.widget.handler.CODE_SUCCESS_DIALOG_DELAY);
// On reset, clear timeout.
app.registerPending(function() {
// Dismiss dialog if still visible.
if (component) {
component.dismissDialog();
}
clearTimeout(codeVerifiedTimer);
});
} | [
"function",
"(",
"userCredential",
")",
"{",
"component",
".",
"dismissDialog",
"(",
")",
";",
"// Show code verified dialog.",
"component",
".",
"showProgressDialog",
"(",
"firebaseui",
".",
"auth",
".",
"ui",
".",
"element",
".",
"progressDialog",
".",
"State",
... | On success a user credential is returned. | [
"On",
"success",
"a",
"user",
"credential",
"is",
"returned",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/javascript/widgets/handler/phonesigninfinish.js#L141-L171 | train | Sign - in with a user credential. | [
30522,
3853,
1006,
5310,
16748,
16454,
4818,
1007,
1063,
6922,
1012,
19776,
27184,
8649,
1006,
1007,
1025,
1013,
1013,
2265,
3642,
20119,
13764,
8649,
1012,
6922,
1012,
2265,
21572,
17603,
4757,
27184,
8649,
1006,
2543,
15058,
10179,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/LanguageManager.js | _getLanguageForMode | function _getLanguageForMode(mode) {
var language = _modeToLanguageMap[mode];
if (language) {
return language;
}
// In case of unsupported languages
console.log("Called LanguageManager._getLanguageForMode with a mode for which no language has been registered:", mode);
return _fallbackLanguage;
} | javascript | function _getLanguageForMode(mode) {
var language = _modeToLanguageMap[mode];
if (language) {
return language;
}
// In case of unsupported languages
console.log("Called LanguageManager._getLanguageForMode with a mode for which no language has been registered:", mode);
return _fallbackLanguage;
} | [
"function",
"_getLanguageForMode",
"(",
"mode",
")",
"{",
"var",
"language",
"=",
"_modeToLanguageMap",
"[",
"mode",
"]",
";",
"if",
"(",
"language",
")",
"{",
"return",
"language",
";",
"}",
"// In case of unsupported languages",
"console",
".",
"log",
"(",
"... | Resolves a CodeMirror mode to a Language object.
@param {!string} mode CodeMirror mode
@return {Language} The language for the provided mode or the fallback language | [
"Resolves",
"a",
"CodeMirror",
"mode",
"to",
"a",
"Language",
"object",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L340-L349 | train | Returns the language for the given mode | [
30522,
3853,
1035,
2131,
25023,
6692,
3351,
14192,
10244,
1006,
5549,
1007,
1063,
13075,
2653,
1027,
1035,
5549,
3406,
25023,
6692,
3351,
2863,
2361,
1031,
5549,
1033,
1025,
2065,
1006,
2653,
1007,
1063,
2709,
2653,
1025,
1065,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
thomaspark/bootswatch | docs/_vendor/popper.js/dist/popper.js | getScrollParent | function getScrollParent(element) {
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
if (!element) {
return document.body;
}
switch (element.nodeName) {
case 'HTML':
case 'BODY':
return element.ownerDocument.body;
case '#document':
return element.body;
}
// Firefox want us to check `-x` and `-y` variations as well
const { overflow, overflowX, overflowY } = getStyleComputedProperty(element);
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
return element;
}
return getScrollParent(getParentNode(element));
} | javascript | function getScrollParent(element) {
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
if (!element) {
return document.body;
}
switch (element.nodeName) {
case 'HTML':
case 'BODY':
return element.ownerDocument.body;
case '#document':
return element.body;
}
// Firefox want us to check `-x` and `-y` variations as well
const { overflow, overflowX, overflowY } = getStyleComputedProperty(element);
if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
return element;
}
return getScrollParent(getParentNode(element));
} | [
"function",
"getScrollParent",
"(",
"element",
")",
"{",
"// Return body, `getScroll` will take care to get the correct `scrollTop` from it",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"document",
".",
"body",
";",
"}",
"switch",
"(",
"element",
".",
"nodeName",
"... | Returns the scrolling parent of the given element
@method
@memberof Popper.Utils
@argument {Element} element
@returns {Element} scroll parent | [
"Returns",
"the",
"scrolling",
"parent",
"of",
"the",
"given",
"element"
] | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/_vendor/popper.js/dist/popper.js#L126-L147 | train | Get the scroll parent of an element | [
30522,
3853,
4152,
26775,
14511,
19362,
4765,
1006,
5783,
1007,
1063,
1013,
1013,
2709,
2303,
1010,
1036,
4152,
26775,
14511,
1036,
2097,
2202,
2729,
2000,
2131,
1996,
6149,
1036,
17186,
14399,
1036,
2013,
2009,
2065,
1006,
999,
5783,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
zloirock/core-js | packages/core-js/internals/collection-strong.js | clear | function clear() {
var that = this;
var state = getInternalState(that);
var data = state.index;
var entry = state.first;
while (entry) {
entry.removed = true;
if (entry.previous) entry.previous = entry.previous.next = undefined;
delete data[entry.index];
entry = entry.next;
}
state.first = state.last = undefined;
if (DESCRIPTORS) state.size = 0;
else that.size = 0;
} | javascript | function clear() {
var that = this;
var state = getInternalState(that);
var data = state.index;
var entry = state.first;
while (entry) {
entry.removed = true;
if (entry.previous) entry.previous = entry.previous.next = undefined;
delete data[entry.index];
entry = entry.next;
}
state.first = state.last = undefined;
if (DESCRIPTORS) state.size = 0;
else that.size = 0;
} | [
"function",
"clear",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"state",
"=",
"getInternalState",
"(",
"that",
")",
";",
"var",
"data",
"=",
"state",
".",
"index",
";",
"var",
"entry",
"=",
"state",
".",
"first",
";",
"while",
"(",
"ent... | 23.1.3.1 Map.prototype.clear() 23.2.3.2 Set.prototype.clear() | [
"23",
".",
"1",
".",
"3",
".",
"1",
"Map",
".",
"prototype",
".",
"clear",
"()",
"23",
".",
"2",
".",
"3",
".",
"2",
"Set",
".",
"prototype",
".",
"clear",
"()"
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/internals/collection-strong.js#L74-L88 | train | Clear the cache | [
30522,
3853,
3154,
1006,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
13075,
2110,
1027,
2131,
18447,
11795,
9777,
12259,
1006,
2008,
1007,
1025,
13075,
2951,
1027,
2110,
1012,
5950,
1025,
13075,
4443,
1027,
2110,
1012,
2034,
1025,
2096,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moment/luxon | src/datetime.js | possiblyCachedWeekData | function possiblyCachedWeekData(dt) {
if (dt.weekData === null) {
dt.weekData = gregorianToWeek(dt.c);
}
return dt.weekData;
} | javascript | function possiblyCachedWeekData(dt) {
if (dt.weekData === null) {
dt.weekData = gregorianToWeek(dt.c);
}
return dt.weekData;
} | [
"function",
"possiblyCachedWeekData",
"(",
"dt",
")",
"{",
"if",
"(",
"dt",
".",
"weekData",
"===",
"null",
")",
"{",
"dt",
".",
"weekData",
"=",
"gregorianToWeek",
"(",
"dt",
".",
"c",
")",
";",
"}",
"return",
"dt",
".",
"weekData",
";",
"}"
] | we cache week data on the DT object and this intermediates the cache | [
"we",
"cache",
"week",
"data",
"on",
"the",
"DT",
"object",
"and",
"this",
"intermediates",
"the",
"cache"
] | 236f2badea297ee73421aa39a83e06177c1be6d0 | https://github.com/moment/luxon/blob/236f2badea297ee73421aa39a83e06177c1be6d0/src/datetime.js#L52-L57 | train | Returns week data from cache | [
30522,
3853,
4298,
3540,
7690,
28075,
2850,
2696,
1006,
26718,
1007,
1063,
2065,
1006,
26718,
1012,
2733,
2850,
2696,
1027,
1027,
1027,
19701,
1007,
1063,
26718,
1012,
2733,
2850,
2696,
1027,
25847,
18790,
4402,
2243,
1006,
26718,
1012,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/treemap/treemapLayout.js | sort | function sort(viewChildren, orderBy) {
if (orderBy) {
viewChildren.sort(function (a, b) {
var diff = orderBy === 'asc'
? a.getValue() - b.getValue() : b.getValue() - a.getValue();
return diff === 0
? (orderBy === 'asc'
? a.dataIndex - b.dataIndex : b.dataIndex - a.dataIndex
)
: diff;
});
}
return viewChildren;
} | javascript | function sort(viewChildren, orderBy) {
if (orderBy) {
viewChildren.sort(function (a, b) {
var diff = orderBy === 'asc'
? a.getValue() - b.getValue() : b.getValue() - a.getValue();
return diff === 0
? (orderBy === 'asc'
? a.dataIndex - b.dataIndex : b.dataIndex - a.dataIndex
)
: diff;
});
}
return viewChildren;
} | [
"function",
"sort",
"(",
"viewChildren",
",",
"orderBy",
")",
"{",
"if",
"(",
"orderBy",
")",
"{",
"viewChildren",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"diff",
"=",
"orderBy",
"===",
"'asc'",
"?",
"a",
".",
"getValue",
... | Sort | [
"Sort"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L344-L357 | train | sorts the viewChildren array | [
30522,
3853,
4066,
1006,
3193,
19339,
7389,
1010,
2344,
3762,
1007,
1063,
2065,
1006,
2344,
3762,
1007,
1063,
3193,
19339,
7389,
1012,
4066,
1006,
3853,
1006,
1037,
1010,
1038,
1007,
1063,
13075,
4487,
4246,
1027,
2344,
3762,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/ODataTreeBindingAdapter.js | function() {
// ensure only TreeBindings are enhanced which have not been enhanced yet
if (!(this instanceof TreeBinding) || this._bIsAdapted) {
return;
}
TreeBindingAdapter.apply(this);
// apply the methods of the adapters prototype to the TreeBinding instance
for (var fn in ODataTreeBindingAdapter.prototype) {
if (ODataTreeBindingAdapter.prototype.hasOwnProperty(fn)) {
this[fn] = ODataTreeBindingAdapter.prototype[fn];
}
}
// make sure we have a parameter object
this.mParameters = this.mParameters || {};
// initialize the contexts
this._aRowIndexMap = [];
//Store length and threshold for all requests
this._iThreshold = 0;
this._iPageSize = 0;
//set the default auto expand mode
this.setAutoExpandMode(this.mParameters.autoExpandMode || TreeAutoExpandMode.Sequential);
//default value for collapse recursive
if (this.mParameters.collapseRecursive === undefined) {
this.bCollapseRecursive = true;
} else {
this.bCollapseRecursive = !!this.mParameters.collapseRecursive;
}
//create general tree structure
this._createTreeState();
// restore old tree state if given AND if the binding is running in OperationMode.Client
// OperationMode.Auto is not supported, as the binding would behave fundamentally different in case the threshold is rejected.
if (this.mParameters.treeState && this.sOperationMode == OperationMode.Client) {
this.setTreeState(this.mParameters.treeState);
}
} | javascript | function() {
// ensure only TreeBindings are enhanced which have not been enhanced yet
if (!(this instanceof TreeBinding) || this._bIsAdapted) {
return;
}
TreeBindingAdapter.apply(this);
// apply the methods of the adapters prototype to the TreeBinding instance
for (var fn in ODataTreeBindingAdapter.prototype) {
if (ODataTreeBindingAdapter.prototype.hasOwnProperty(fn)) {
this[fn] = ODataTreeBindingAdapter.prototype[fn];
}
}
// make sure we have a parameter object
this.mParameters = this.mParameters || {};
// initialize the contexts
this._aRowIndexMap = [];
//Store length and threshold for all requests
this._iThreshold = 0;
this._iPageSize = 0;
//set the default auto expand mode
this.setAutoExpandMode(this.mParameters.autoExpandMode || TreeAutoExpandMode.Sequential);
//default value for collapse recursive
if (this.mParameters.collapseRecursive === undefined) {
this.bCollapseRecursive = true;
} else {
this.bCollapseRecursive = !!this.mParameters.collapseRecursive;
}
//create general tree structure
this._createTreeState();
// restore old tree state if given AND if the binding is running in OperationMode.Client
// OperationMode.Auto is not supported, as the binding would behave fundamentally different in case the threshold is rejected.
if (this.mParameters.treeState && this.sOperationMode == OperationMode.Client) {
this.setTreeState(this.mParameters.treeState);
}
} | [
"function",
"(",
")",
"{",
"// ensure only TreeBindings are enhanced which have not been enhanced yet",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"TreeBinding",
")",
"||",
"this",
".",
"_bIsAdapted",
")",
"{",
"return",
";",
"}",
"TreeBindingAdapter",
".",
"apply",
... | Adapter for TreeBindings to add the ListBinding functionality and use the
tree structure in list based controls.
Only usable with the sap.ui.table.TreeTable control.
The functions defined here are only available when you are using a TreeTable and an ODataModel.
@alias sap.ui.model.odata.ODataTreeBindingAdapter
@function
@experimental This module is only for experimental and internal use!
@public | [
"Adapter",
"for",
"TreeBindings",
"to",
"add",
"the",
"ListBinding",
"functionality",
"and",
"use",
"the",
"tree",
"structure",
"in",
"list",
"based",
"controls",
".",
"Only",
"usable",
"with",
"the",
"sap",
".",
"ui",
".",
"table",
".",
"TreeTable",
"contro... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/ODataTreeBindingAdapter.js#L22-L66 | train | Creates a new TreeBinding instance. | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
5676,
2069,
3392,
8428,
4667,
2015,
2024,
9412,
2029,
2031,
2025,
2042,
9412,
2664,
2065,
1006,
999,
1006,
2023,
6013,
11253,
3392,
8428,
4667,
1007,
1064,
1064,
2023,
1012,
1035,
20377,
8447,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/chart/heatmap/HeatmapLayer.js | function (data, width, height, normalize, colorFunc, isInRange) {
var brush = this._getBrush();
var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
var r = this.pointSize + this.blurSize;
var canvas = this.canvas;
var ctx = canvas.getContext('2d');
var len = data.length;
canvas.width = width;
canvas.height = height;
for (var i = 0; i < len; ++i) {
var p = data[i];
var x = p[0];
var y = p[1];
var value = p[2];
// calculate alpha using value
var alpha = normalize(value);
// draw with the circle brush with alpha
ctx.globalAlpha = alpha;
ctx.drawImage(brush, x - r, y - r);
}
if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}
// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
var minOpacity = this.minOpacity;
var maxOpacity = this.maxOpacity;
var diffOpacity = maxOpacity - minOpacity;
while (offset < pixelLen) {
var alpha = pixels[offset + 3] / 256;
var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
// Simple optimize to ignore the empty data
if (alpha > 0) {
var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
pixels[offset++] = gradient[gradientOffset];
pixels[offset++] = gradient[gradientOffset + 1];
pixels[offset++] = gradient[gradientOffset + 2];
pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
}
else {
offset += 4;
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
} | javascript | function (data, width, height, normalize, colorFunc, isInRange) {
var brush = this._getBrush();
var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
var r = this.pointSize + this.blurSize;
var canvas = this.canvas;
var ctx = canvas.getContext('2d');
var len = data.length;
canvas.width = width;
canvas.height = height;
for (var i = 0; i < len; ++i) {
var p = data[i];
var x = p[0];
var y = p[1];
var value = p[2];
// calculate alpha using value
var alpha = normalize(value);
// draw with the circle brush with alpha
ctx.globalAlpha = alpha;
ctx.drawImage(brush, x - r, y - r);
}
if (!canvas.width || !canvas.height) {
// Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
// 'CanvasRenderingContext2D': The source height is 0."
return canvas;
}
// colorize the canvas using alpha value and set with gradient
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var pixels = imageData.data;
var offset = 0;
var pixelLen = pixels.length;
var minOpacity = this.minOpacity;
var maxOpacity = this.maxOpacity;
var diffOpacity = maxOpacity - minOpacity;
while (offset < pixelLen) {
var alpha = pixels[offset + 3] / 256;
var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
// Simple optimize to ignore the empty data
if (alpha > 0) {
var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
// Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
pixels[offset++] = gradient[gradientOffset];
pixels[offset++] = gradient[gradientOffset + 1];
pixels[offset++] = gradient[gradientOffset + 2];
pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
}
else {
offset += 4;
}
}
ctx.putImageData(imageData, 0, 0);
return canvas;
} | [
"function",
"(",
"data",
",",
"width",
",",
"height",
",",
"normalize",
",",
"colorFunc",
",",
"isInRange",
")",
"{",
"var",
"brush",
"=",
"this",
".",
"_getBrush",
"(",
")",
";",
"var",
"gradientInRange",
"=",
"this",
".",
"_getGradient",
"(",
"data",
... | Renders Heatmap and returns the rendered canvas
@param {Array} data array of data, each has x, y, value
@param {number} width canvas width
@param {number} height canvas height | [
"Renders",
"Heatmap",
"and",
"returns",
"the",
"rendered",
"canvas"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/heatmap/HeatmapLayer.js#L59-L120 | train | Creates a canvas with the given data | [
30522,
3853,
1006,
2951,
1010,
9381,
1010,
4578,
1010,
3671,
4697,
1010,
3609,
11263,
12273,
1010,
2003,
2378,
24388,
2063,
1007,
1063,
13075,
8248,
1027,
2023,
1012,
1035,
2131,
18623,
1006,
1007,
1025,
13075,
17978,
2378,
24388,
2063,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
summernote/summernote | src/js/base/core/dom.js | commonAncestor | function commonAncestor(nodeA, nodeB) {
const ancestors = listAncestor(nodeA);
for (let n = nodeB; n; n = n.parentNode) {
if (ancestors.indexOf(n) > -1) return n;
}
return null; // difference document area
} | javascript | function commonAncestor(nodeA, nodeB) {
const ancestors = listAncestor(nodeA);
for (let n = nodeB; n; n = n.parentNode) {
if (ancestors.indexOf(n) > -1) return n;
}
return null; // difference document area
} | [
"function",
"commonAncestor",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"const",
"ancestors",
"=",
"listAncestor",
"(",
"nodeA",
")",
";",
"for",
"(",
"let",
"n",
"=",
"nodeB",
";",
"n",
";",
"n",
"=",
"n",
".",
"parentNode",
")",
"{",
"if",
"(",
"ance... | returns common ancestor node between two nodes.
@param {Node} nodeA
@param {Node} nodeB | [
"returns",
"common",
"ancestor",
"node",
"between",
"two",
"nodes",
"."
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L302-L308 | train | Returns the common ancestor of nodeA and nodeB | [
30522,
3853,
2691,
26755,
4263,
1006,
13045,
2050,
1010,
13045,
2497,
1007,
1063,
9530,
3367,
10748,
1027,
2862,
26755,
4263,
1006,
13045,
2050,
1007,
1025,
2005,
1006,
2292,
1050,
1027,
13045,
2497,
1025,
1050,
1025,
1050,
1027,
1050,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseAssignmentExpression | function parseAssignmentExpression() {
var token, left, right, node, startToken;
token = lookahead;
startToken = lookahead;
node = left = parseConditionalExpression();
if (matchAssign()) {
// LeftHandSideExpression
if (!isLeftHandSide(left)) {
throwErrorTolerant({}, Messages.InvalidLHSInAssignment);
}
// 11.13.1
if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) {
throwErrorTolerant(token, Messages.StrictLHSAssignment);
}
token = lex();
right = parseAssignmentExpression();
node = delegate.markEnd(delegate.createAssignmentExpression(token.value, left, right), startToken);
}
return node;
} | javascript | function parseAssignmentExpression() {
var token, left, right, node, startToken;
token = lookahead;
startToken = lookahead;
node = left = parseConditionalExpression();
if (matchAssign()) {
// LeftHandSideExpression
if (!isLeftHandSide(left)) {
throwErrorTolerant({}, Messages.InvalidLHSInAssignment);
}
// 11.13.1
if (strict && left.type === Syntax.Identifier && isRestrictedWord(left.name)) {
throwErrorTolerant(token, Messages.StrictLHSAssignment);
}
token = lex();
right = parseAssignmentExpression();
node = delegate.markEnd(delegate.createAssignmentExpression(token.value, left, right), startToken);
}
return node;
} | [
"function",
"parseAssignmentExpression",
"(",
")",
"{",
"var",
"token",
",",
"left",
",",
"right",
",",
"node",
",",
"startToken",
";",
"token",
"=",
"lookahead",
";",
"startToken",
"=",
"lookahead",
";",
"node",
"=",
"left",
"=",
"parseConditionalExpression",... | 11.13 Assignment Operators | [
"11",
".",
"13",
"Assignment",
"Operators"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2557-L2582 | train | ECMA - 262 12. 2 Assignment | [
30522,
3853,
11968,
17310,
18719,
16206,
3672,
10288,
20110,
3258,
1006,
1007,
1063,
13075,
19204,
1010,
2187,
1010,
2157,
1010,
13045,
1010,
2707,
18715,
2368,
1025,
19204,
1027,
2298,
4430,
13775,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js | handleChange | function handleChange(sType, oObject, sName, fnCreateChange) {
var sId = oObject.getId(),
oTargetConfig = mTargets[sId];
if (oTargetConfig) {
var oChange;
for (var i = 0; i < oTargetConfig.listeners.length; i++) {
if (isObserving(oTargetConfig.configurations[i], sType, sName)) {
if (!oChange) {
oChange = fnCreateChange();
oChange.name = sName;
oChange.object = oObject;
}
var oListener = oTargetConfig.listeners[i];
oListener._fnCallback(oChange);
}
}
}
} | javascript | function handleChange(sType, oObject, sName, fnCreateChange) {
var sId = oObject.getId(),
oTargetConfig = mTargets[sId];
if (oTargetConfig) {
var oChange;
for (var i = 0; i < oTargetConfig.listeners.length; i++) {
if (isObserving(oTargetConfig.configurations[i], sType, sName)) {
if (!oChange) {
oChange = fnCreateChange();
oChange.name = sName;
oChange.object = oObject;
}
var oListener = oTargetConfig.listeners[i];
oListener._fnCallback(oChange);
}
}
}
} | [
"function",
"handleChange",
"(",
"sType",
",",
"oObject",
",",
"sName",
",",
"fnCreateChange",
")",
"{",
"var",
"sId",
"=",
"oObject",
".",
"getId",
"(",
")",
",",
"oTargetConfig",
"=",
"mTargets",
"[",
"sId",
"]",
";",
"if",
"(",
"oTargetConfig",
")",
... | handles the change event and pipelines it to the ManagedObjectObservers that are attached as listeners | [
"handles",
"the",
"change",
"event",
"and",
"pipelines",
"it",
"to",
"the",
"ManagedObjectObservers",
"that",
"are",
"attached",
"as",
"listeners"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js#L421-L439 | train | Handles a change event from the target | [
30522,
3853,
5047,
22305,
2063,
1006,
2358,
18863,
1010,
1051,
16429,
20614,
1010,
1055,
18442,
1010,
1042,
12273,
29313,
22305,
2063,
1007,
1063,
13075,
15765,
1027,
1051,
16429,
20614,
1012,
2131,
3593,
1006,
1007,
1010,
27178,
2906,
18150,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/DragAndDrop.js | stopURIListPropagation | function stopURIListPropagation(files, event) {
var types = event.dataTransfer.types;
if ((!files || !files.length) && types) { // We only want to check if a string of text was dragged into the editor
types.forEach(function (value) {
//Dragging text externally (dragging text from another file): types has "text/plain" and "text/html"
//Dragging text internally (dragging text to another line): types has just "text/plain"
//Dragging a file: types has "Files"
//Dragging a url: types has "text/plain" and "text/uri-list" <-what we are interested in
if (value === "text/uri-list") {
event.stopPropagation();
event.preventDefault();
return;
}
});
}
} | javascript | function stopURIListPropagation(files, event) {
var types = event.dataTransfer.types;
if ((!files || !files.length) && types) { // We only want to check if a string of text was dragged into the editor
types.forEach(function (value) {
//Dragging text externally (dragging text from another file): types has "text/plain" and "text/html"
//Dragging text internally (dragging text to another line): types has just "text/plain"
//Dragging a file: types has "Files"
//Dragging a url: types has "text/plain" and "text/uri-list" <-what we are interested in
if (value === "text/uri-list") {
event.stopPropagation();
event.preventDefault();
return;
}
});
}
} | [
"function",
"stopURIListPropagation",
"(",
"files",
",",
"event",
")",
"{",
"var",
"types",
"=",
"event",
".",
"dataTransfer",
".",
"types",
";",
"if",
"(",
"(",
"!",
"files",
"||",
"!",
"files",
".",
"length",
")",
"&&",
"types",
")",
"{",
"// We only... | Determines if the event contains a type list that has a URI-list.
If it does and contains an empty file list, then what is being dropped is a URL.
If that is true then we stop the event propagation and default behavior to save Brackets editor from the browser taking over.
@param {Array.<File>} files Array of File objects from the event datastructure. URLs are the only drop item that would contain a URI-list.
@param {event} event The event datastucture containing datatransfer information about the drag/drop event. Contains a type list which may or may not hold a URI-list depending on what was dragged/dropped. Interested if it does. | [
"Determines",
"if",
"the",
"event",
"contains",
"a",
"type",
"list",
"that",
"has",
"a",
"URI",
"-",
"list",
".",
"If",
"it",
"does",
"and",
"contains",
"an",
"empty",
"file",
"list",
"then",
"what",
"is",
"being",
"dropped",
"is",
"a",
"URL",
".",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DragAndDrop.js#L72-L88 | train | Stop propagation of URI list | [
30522,
3853,
2644,
9496,
9863,
21572,
4502,
12540,
1006,
6764,
1010,
2724,
1007,
1063,
13075,
4127,
1027,
2724,
1012,
2951,
6494,
3619,
7512,
1012,
4127,
1025,
2065,
1006,
1006,
999,
6764,
1064,
1064,
999,
6764,
1012,
3091,
1007,
1004,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/sound.js | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer || !sound.isPlaying || sound.isPaused) {
continue;
}
sound.isPaused = true;
sound.pause();
}
} | javascript | function () {
var i;
var sound;
this.isPlaying = false;
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
if (!sound.source || !sound.source.buffer || !sound.isPlaying || sound.isPaused) {
continue;
}
sound.isPaused = true;
sound.pause();
}
} | [
"function",
"(",
")",
"{",
"var",
"i",
";",
"var",
"sound",
";",
"this",
".",
"isPlaying",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"pool",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"sound",
"=... | Pause all the sounds in the pool. | [
"Pause",
"all",
"the",
"sounds",
"in",
"the",
"pool",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L185-L198 | train | Pause all children of this group | [
30522,
3853,
1006,
1007,
1063,
13075,
1045,
1025,
13075,
2614,
1025,
2023,
1012,
2003,
13068,
2075,
1027,
6270,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
2023,
1012,
4770,
1012,
2336,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
BrainJS/brain.js | dist/recurrent/matrix/copy.js | copy | function copy(product, left) {
product.rows = parseInt(left.rows);
product.columns = parseInt(left.columns);
product.weights = left.weights.slice(0);
product.deltas = left.deltas.slice(0);
} | javascript | function copy(product, left) {
product.rows = parseInt(left.rows);
product.columns = parseInt(left.columns);
product.weights = left.weights.slice(0);
product.deltas = left.deltas.slice(0);
} | [
"function",
"copy",
"(",
"product",
",",
"left",
")",
"{",
"product",
".",
"rows",
"=",
"parseInt",
"(",
"left",
".",
"rows",
")",
";",
"product",
".",
"columns",
"=",
"parseInt",
"(",
"left",
".",
"columns",
")",
";",
"product",
".",
"weights",
"=",... | /*
@param {Matrix} product
@param {Matrix} left | [
"/",
"*"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/recurrent/matrix/copy.js#L12-L17 | train | Copy the values from the left to the product | [
30522,
3853,
6100,
1006,
4031,
1010,
2187,
1007,
1063,
4031,
1012,
10281,
1027,
11968,
20240,
3372,
1006,
2187,
1012,
10281,
1007,
1025,
4031,
1012,
7753,
1027,
11968,
20240,
3372,
1006,
2187,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
heyui/heyui | src/plugins/popper/index.js | clockwise | function clockwise(placement) {
var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var index = validPlacements.indexOf(placement);
var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
return counter ? arr.reverse() : arr;
} | javascript | function clockwise(placement) {
var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var index = validPlacements.indexOf(placement);
var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
return counter ? arr.reverse() : arr;
} | [
"function",
"clockwise",
"(",
"placement",
")",
"{",
"var",
"counter",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"false",
";",
"var",
"index",
"=",
"validPlace... | Given an initial placement, returns all the subsequent placements
clockwise (or counter-clockwise).
@method
@memberof Popper.Utils
@argument {String} placement - A valid placement (it accepts variations)
@argument {Boolean} counter - Set to true to walk the placements counterclockwise
@returns {Array} placements including their variations | [
"Given",
"an",
"initial",
"placement",
"returns",
"all",
"the",
"subsequent",
"placements",
"clockwise",
"(",
"or",
"counter",
"-",
"clockwise",
")",
"."
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1529-L1535 | train | Get the list of valid placements in clockwise order | [
30522,
3853,
22839,
1006,
11073,
1007,
1063,
13075,
4675,
1027,
9918,
1012,
3091,
1028,
1015,
1004,
1004,
9918,
1031,
1015,
1033,
999,
1027,
1027,
6151,
28344,
30524,
5950,
11253,
1006,
11073,
1007,
1025,
13075,
12098,
2099,
1027,
9398,
247... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mui-org/material-ui | packages/material-ui-icons/scripts/create-typings.js | run | async function run() {
console.log(`\u{1f52c} Searching for modules inside "${chalk.dim(SRC_DIR)}".`);
const files = glob.sync('!(index)*.js', { cwd: SRC_DIR });
const typings = files.map(file => createIconTyping(file));
await Promise.all([...typings, createIndexTyping(files)]);
console.log(`\u{1F5C4} Written typings to ${chalk.dim(TARGET_DIR)}.`);
} | javascript | async function run() {
console.log(`\u{1f52c} Searching for modules inside "${chalk.dim(SRC_DIR)}".`);
const files = glob.sync('!(index)*.js', { cwd: SRC_DIR });
const typings = files.map(file => createIconTyping(file));
await Promise.all([...typings, createIndexTyping(files)]);
console.log(`\u{1F5C4} Written typings to ${chalk.dim(TARGET_DIR)}.`);
} | [
"async",
"function",
"run",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"\\u{1f52c}",
"${",
"chalk",
".",
"dim",
"(",
"SRC_DIR",
")",
"}",
"`",
")",
";",
"const",
"files",
"=",
"glob",
".",
"sync",
"(",
"'!(index)*.js'",
",",
"{",
"cwd",
":",
... | Generate TypeScript. | [
"Generate",
"TypeScript",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-icons/scripts/create-typings.js#L33-L39 | train | Create index and index. js | [
30522,
2004,
6038,
2278,
3853,
2448,
1006,
1007,
1063,
10122,
1012,
8833,
1006,
1036,
1032,
1057,
1063,
1015,
2546,
25746,
2278,
1065,
6575,
2005,
14184,
2503,
1000,
1002,
1063,
16833,
1012,
11737,
1006,
5034,
2278,
1035,
16101,
1007,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | core/flyout_base.js | function() {
var topBlocks = this.workspace_.getTopBlocks(false);
for (var i = 0, block; block = topBlocks[i]; i++) {
block.removeSelect();
}
} | javascript | function() {
var topBlocks = this.workspace_.getTopBlocks(false);
for (var i = 0, block; block = topBlocks[i]; i++) {
block.removeSelect();
}
} | [
"function",
"(",
")",
"{",
"var",
"topBlocks",
"=",
"this",
".",
"workspace_",
".",
"getTopBlocks",
"(",
"false",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"block",
";",
"block",
"=",
"topBlocks",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
... | IE 11 is an incompetent browser that fails to fire mouseout events. When the mouse is over the background, deselect all blocks. | [
"IE",
"11",
"is",
"an",
"incompetent",
"browser",
"that",
"fails",
"to",
"fire",
"mouseout",
"events",
".",
"When",
"the",
"mouse",
"is",
"over",
"the",
"background",
"deselect",
"all",
"blocks",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/core/flyout_base.js#L563-L568 | train | Remove all the selected blocks | [
30522,
3853,
1006,
1007,
1063,
13075,
2327,
23467,
2015,
1027,
2023,
1012,
2573,
15327,
1035,
1012,
2131,
14399,
23467,
2015,
1006,
6270,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
3796,
1025,
3796,
1027,
2327,
23467,
2015,
1031... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function (rect, m, style, flipH, flipV)
{
var d = mxUtils.getValue(style, mxConstants.STYLE_DIRECTION, mxConstants.DIRECTION_EAST);
flipH = (flipH != null) ? flipH : mxUtils.getValue(style, mxConstants.STYLE_FLIPH, false);
flipV = (flipV != null) ? flipV : mxUtils.getValue(style, mxConstants.STYLE_FLIPV, false);
m.x = Math.round(Math.max(0, Math.min(rect.width, m.x)));
m.y = Math.round(Math.max(0, Math.min(rect.height, m.y)));
m.width = Math.round(Math.max(0, Math.min(rect.width, m.width)));
m.height = Math.round(Math.max(0, Math.min(rect.height, m.height)));
if ((flipV && (d == mxConstants.DIRECTION_SOUTH || d == mxConstants.DIRECTION_NORTH)) ||
(flipH && (d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)))
{
var tmp = m.x;
m.x = m.width;
m.width = tmp;
}
if ((flipH && (d == mxConstants.DIRECTION_SOUTH || d == mxConstants.DIRECTION_NORTH)) ||
(flipV && (d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)))
{
var tmp = m.y;
m.y = m.height;
m.height = tmp;
}
var m2 = mxRectangle.fromRectangle(m);
if (d == mxConstants.DIRECTION_SOUTH)
{
m2.y = m.x;
m2.x = m.height;
m2.width = m.y;
m2.height = m.width;
}
else if (d == mxConstants.DIRECTION_WEST)
{
m2.y = m.height;
m2.x = m.width;
m2.width = m.x;
m2.height = m.y;
}
else if (d == mxConstants.DIRECTION_NORTH)
{
m2.y = m.width;
m2.x = m.y;
m2.width = m.height;
m2.height = m.x;
}
return new mxRectangle(rect.x + m2.x, rect.y + m2.y, rect.width - m2.width - m2.x, rect.height - m2.height - m2.y);
} | javascript | function (rect, m, style, flipH, flipV)
{
var d = mxUtils.getValue(style, mxConstants.STYLE_DIRECTION, mxConstants.DIRECTION_EAST);
flipH = (flipH != null) ? flipH : mxUtils.getValue(style, mxConstants.STYLE_FLIPH, false);
flipV = (flipV != null) ? flipV : mxUtils.getValue(style, mxConstants.STYLE_FLIPV, false);
m.x = Math.round(Math.max(0, Math.min(rect.width, m.x)));
m.y = Math.round(Math.max(0, Math.min(rect.height, m.y)));
m.width = Math.round(Math.max(0, Math.min(rect.width, m.width)));
m.height = Math.round(Math.max(0, Math.min(rect.height, m.height)));
if ((flipV && (d == mxConstants.DIRECTION_SOUTH || d == mxConstants.DIRECTION_NORTH)) ||
(flipH && (d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)))
{
var tmp = m.x;
m.x = m.width;
m.width = tmp;
}
if ((flipH && (d == mxConstants.DIRECTION_SOUTH || d == mxConstants.DIRECTION_NORTH)) ||
(flipV && (d == mxConstants.DIRECTION_EAST || d == mxConstants.DIRECTION_WEST)))
{
var tmp = m.y;
m.y = m.height;
m.height = tmp;
}
var m2 = mxRectangle.fromRectangle(m);
if (d == mxConstants.DIRECTION_SOUTH)
{
m2.y = m.x;
m2.x = m.height;
m2.width = m.y;
m2.height = m.width;
}
else if (d == mxConstants.DIRECTION_WEST)
{
m2.y = m.height;
m2.x = m.width;
m2.width = m.x;
m2.height = m.y;
}
else if (d == mxConstants.DIRECTION_NORTH)
{
m2.y = m.width;
m2.x = m.y;
m2.width = m.height;
m2.height = m.x;
}
return new mxRectangle(rect.x + m2.x, rect.y + m2.y, rect.width - m2.width - m2.x, rect.height - m2.height - m2.y);
} | [
"function",
"(",
"rect",
",",
"m",
",",
"style",
",",
"flipH",
",",
"flipV",
")",
"{",
"var",
"d",
"=",
"mxUtils",
".",
"getValue",
"(",
"style",
",",
"mxConstants",
".",
"STYLE_DIRECTION",
",",
"mxConstants",
".",
"DIRECTION_EAST",
")",
";",
"flipH",
... | Function: getDirectedBounds
Adds the given margins to the given rectangle and rotates and flips the
rectangle according to the respective styles in style. | [
"Function",
":",
"getDirectedBounds"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4451-L4503 | train | Updates the bounds of the given rectangle with the given style | [
30522,
3853,
1006,
28667,
2102,
1010,
1049,
1010,
2806,
1010,
11238,
2232,
1010,
11238,
2615,
1007,
1063,
13075,
1040,
1027,
25630,
21823,
4877,
1012,
2131,
10175,
5657,
1006,
2806,
1010,
25630,
8663,
12693,
3215,
1012,
2806,
1035,
3257,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/sinon-server.js | FakeXMLHttpRequest | function FakeXMLHttpRequest() {
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new UploadProgress();
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
var xhr = this;
var events = ["loadstart", "load", "abort", "loadend"];
function addEventListener(eventName) {
xhr.addEventListener(eventName, function (event) {
var listener = xhr["on" + eventName];
if (listener && typeof listener == "function") {
listener.call(this, event);
}
});
}
for (var i = events.length - 1; i >= 0; i--) {
addEventListener(events[i]);
}
if (typeof FakeXMLHttpRequest.onCreate == "function") {
FakeXMLHttpRequest.onCreate(this);
}
} | javascript | function FakeXMLHttpRequest() {
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new UploadProgress();
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
var xhr = this;
var events = ["loadstart", "load", "abort", "loadend"];
function addEventListener(eventName) {
xhr.addEventListener(eventName, function (event) {
var listener = xhr["on" + eventName];
if (listener && typeof listener == "function") {
listener.call(this, event);
}
});
}
for (var i = events.length - 1; i >= 0; i--) {
addEventListener(events[i]);
}
if (typeof FakeXMLHttpRequest.onCreate == "function") {
FakeXMLHttpRequest.onCreate(this);
}
} | [
"function",
"FakeXMLHttpRequest",
"(",
")",
"{",
"this",
".",
"readyState",
"=",
"FakeXMLHttpRequest",
".",
"UNSENT",
";",
"this",
".",
"requestHeaders",
"=",
"{",
"}",
";",
"this",
".",
"requestBody",
"=",
"null",
";",
"this",
".",
"status",
"=",
"0",
"... | /*jsl:end | [
"/",
"*",
"jsl",
":",
"end"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/sinon-server.js#L1030-L1061 | train | FakeXMLHttpRequest - A FakeXMLHttpRequest | [
30522,
3853,
8275,
2595,
19968,
11039,
25856,
2890,
15500,
1006,
1007,
1063,
2023,
1012,
3201,
9153,
2618,
1027,
8275,
2595,
19968,
30524,
1012,
2039,
11066,
1027,
2047,
2039,
11066,
21572,
17603,
4757,
1006,
1007,
1025,
2065,
1006,
19432,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | services/php-version.js | compare | function compare(v1, v2) {
// Omit the starting `v`.
const rawv1 = omitv(v1)
const rawv2 = omitv(v2)
let v1data, v2data
try {
v1data = numberedVersionData(rawv1)
v2data = numberedVersionData(rawv2)
} catch (e) {
return asciiVersionCompare(rawv1, rawv2)
}
// Compare the numbered part (eg, 1.0.0 < 2.0.0).
const numbersCompare = listCompare(v1data.numbers, v2data.numbers)
if (numbersCompare !== 0) {
return numbersCompare
}
// Compare the modifiers (eg, alpha < beta).
if (v1data.modifier < v2data.modifier) {
return -1
} else if (v1data.modifier > v2data.modifier) {
return 1
}
// Compare the modifier counts (eg, alpha1 < alpha3).
if (v1data.modifierCount < v2data.modifierCount) {
return -1
} else if (v1data.modifierCount > v2data.modifierCount) {
return 1
}
return 0
} | javascript | function compare(v1, v2) {
// Omit the starting `v`.
const rawv1 = omitv(v1)
const rawv2 = omitv(v2)
let v1data, v2data
try {
v1data = numberedVersionData(rawv1)
v2data = numberedVersionData(rawv2)
} catch (e) {
return asciiVersionCompare(rawv1, rawv2)
}
// Compare the numbered part (eg, 1.0.0 < 2.0.0).
const numbersCompare = listCompare(v1data.numbers, v2data.numbers)
if (numbersCompare !== 0) {
return numbersCompare
}
// Compare the modifiers (eg, alpha < beta).
if (v1data.modifier < v2data.modifier) {
return -1
} else if (v1data.modifier > v2data.modifier) {
return 1
}
// Compare the modifier counts (eg, alpha1 < alpha3).
if (v1data.modifierCount < v2data.modifierCount) {
return -1
} else if (v1data.modifierCount > v2data.modifierCount) {
return 1
}
return 0
} | [
"function",
"compare",
"(",
"v1",
",",
"v2",
")",
"{",
"// Omit the starting `v`.",
"const",
"rawv1",
"=",
"omitv",
"(",
"v1",
")",
"const",
"rawv2",
"=",
"omitv",
"(",
"v2",
")",
"let",
"v1data",
",",
"v2data",
"try",
"{",
"v1data",
"=",
"numberedVersio... | Return a negative value if v1 < v2, zero if v1 = v2, a positive value otherwise. See https://getcomposer.org/doc/04-schema.md#version and https://github.com/badges/shields/issues/319#issuecomment-74411045 | [
"Return",
"a",
"negative",
"value",
"if",
"v1",
"<",
"v2",
"zero",
"if",
"v1",
"=",
"v2",
"a",
"positive",
"value",
"otherwise",
".",
"See",
"https",
":",
"//",
"getcomposer",
".",
"org",
"/",
"doc",
"/",
"04",
"-",
"schema",
".",
"md#version",
"and"... | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/php-version.js#L122-L155 | train | Compare two version strings. | [
30522,
3853,
12826,
1006,
1058,
2487,
1010,
1058,
2475,
1007,
1063,
1013,
1013,
18168,
4183,
1996,
3225,
1036,
1058,
1036,
1012,
9530,
3367,
6315,
2615,
2487,
1027,
18168,
4183,
2615,
1006,
1058,
2487,
1007,
9530,
3367,
6315,
2615,
2475,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/create-api-index.js | cleanTree | function cleanTree (oSymbol) {
delete oSymbol.treeName;
delete oSymbol.parent;
if (oSymbol.children) {
oSymbol.children.forEach(o => cleanTree(o));
}
} | javascript | function cleanTree (oSymbol) {
delete oSymbol.treeName;
delete oSymbol.parent;
if (oSymbol.children) {
oSymbol.children.forEach(o => cleanTree(o));
}
} | [
"function",
"cleanTree",
"(",
"oSymbol",
")",
"{",
"delete",
"oSymbol",
".",
"treeName",
";",
"delete",
"oSymbol",
".",
"parent",
";",
"if",
"(",
"oSymbol",
".",
"children",
")",
"{",
"oSymbol",
".",
"children",
".",
"forEach",
"(",
"o",
"=>",
"cleanTree... | Clean tree - keep file size down | [
"Clean",
"tree",
"-",
"keep",
"file",
"size",
"down"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/create-api-index.js#L329-L335 | train | clean up the tree | [
30522,
3853,
4550,
13334,
1006,
9808,
24335,
14956,
1007,
1063,
3972,
12870,
9808,
24335,
14956,
1012,
3392,
18442,
1025,
3972,
12870,
9808,
24335,
14956,
1012,
6687,
1025,
2065,
1006,
9808,
24335,
14956,
1012,
2336,
1007,
1063,
9808,
24335,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.uxap/src/sap/uxap/component/ObjectPageComponentContainer.js | function () {
var oObjectPageLayoutInstance = null;
if (this._oComponent && this._oComponent._oView) {
oObjectPageLayoutInstance = this._oComponent._oView.byId("ObjectPageLayout");
} else {
Log.error("ObjectPageComponentContainer :: cannot find children ObjectPageLayout, has it been rendered already?");
}
return oObjectPageLayoutInstance;
} | javascript | function () {
var oObjectPageLayoutInstance = null;
if (this._oComponent && this._oComponent._oView) {
oObjectPageLayoutInstance = this._oComponent._oView.byId("ObjectPageLayout");
} else {
Log.error("ObjectPageComponentContainer :: cannot find children ObjectPageLayout, has it been rendered already?");
}
return oObjectPageLayoutInstance;
} | [
"function",
"(",
")",
"{",
"var",
"oObjectPageLayoutInstance",
"=",
"null",
";",
"if",
"(",
"this",
".",
"_oComponent",
"&&",
"this",
".",
"_oComponent",
".",
"_oView",
")",
"{",
"oObjectPageLayoutInstance",
"=",
"this",
".",
"_oComponent",
".",
"_oView",
".... | Returns the instantiated objectPageLayout for further api manipulations or null if not not rendered already.
@returns {sap.uxap.ObjectPageLayout} Layout instanse | [
"Returns",
"the",
"instantiated",
"objectPageLayout",
"for",
"further",
"api",
"manipulations",
"or",
"null",
"if",
"not",
"not",
"rendered",
"already",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/ObjectPageComponentContainer.js#L59-L68 | train | Returns the ObjectPageLayout instance | [
30522,
3853,
1006,
1007,
1063,
13075,
1051,
16429,
20614,
13704,
8485,
5833,
7076,
26897,
1027,
19701,
1025,
2065,
1006,
2023,
1012,
1035,
1051,
9006,
29513,
3372,
1004,
1004,
2023,
1012,
1035,
1051,
9006,
29513,
3372,
1012,
1035,
1051,
858... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/cli-engine.js | validateFixTypes | function validateFixTypes(fixTypes) {
for (const fixType of fixTypes) {
if (!validFixTypes.has(fixType)) {
throw new Error(`Invalid fix type "${fixType}" found.`);
}
}
} | javascript | function validateFixTypes(fixTypes) {
for (const fixType of fixTypes) {
if (!validFixTypes.has(fixType)) {
throw new Error(`Invalid fix type "${fixType}" found.`);
}
}
} | [
"function",
"validateFixTypes",
"(",
"fixTypes",
")",
"{",
"for",
"(",
"const",
"fixType",
"of",
"fixTypes",
")",
"{",
"if",
"(",
"!",
"validFixTypes",
".",
"has",
"(",
"fixType",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"fixType",
"}",
... | ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------
Determines if each fix type in an array is supported by ESLint and throws
an error if not.
@param {string[]} fixTypes An array of fix types to check.
@returns {void}
@throws {Error} If an invalid fix type is found. | [
"------------------------------------------------------------------------------",
"Helpers",
"------------------------------------------------------------------------------",
"Determines",
"if",
"each",
"fix",
"type",
"in",
"an",
"array",
"is",
"supported",
"by",
"ESLint",
"and",
"th... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/cli-engine.js#L98-L104 | train | Validate fix types | [
30522,
3853,
9398,
3686,
8873,
18413,
18863,
2015,
1006,
8081,
13874,
2015,
1007,
1063,
2005,
1006,
9530,
3367,
8081,
13874,
1997,
8081,
13874,
2015,
1007,
1063,
2065,
1006,
999,
9398,
8873,
18413,
18863,
2015,
1012,
2038,
1006,
8081,
13874... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetView.js | postDropCleanup | function postDropCleanup(noRefresh) {
if (dragged) {
// re-enable stuff we turned off
_suppressSortRedrawForAllViews(false);
_suppressScrollShadowsOnAllViews(false);
}
// we don't need to refresh if the item
// was dragged but not enough to not change
// its order in the working set
if (!noRefresh) {
// rebuild the view
refresh(true);
}
// focus the editor
MainViewManager.focusActivePane();
} | javascript | function postDropCleanup(noRefresh) {
if (dragged) {
// re-enable stuff we turned off
_suppressSortRedrawForAllViews(false);
_suppressScrollShadowsOnAllViews(false);
}
// we don't need to refresh if the item
// was dragged but not enough to not change
// its order in the working set
if (!noRefresh) {
// rebuild the view
refresh(true);
}
// focus the editor
MainViewManager.focusActivePane();
} | [
"function",
"postDropCleanup",
"(",
"noRefresh",
")",
"{",
"if",
"(",
"dragged",
")",
"{",
"// re-enable stuff we turned off",
"_suppressSortRedrawForAllViews",
"(",
"false",
")",
";",
"_suppressScrollShadowsOnAllViews",
"(",
"false",
")",
";",
"}",
"// we don't need to... | Final Cleanup | [
"Final",
"Cleanup"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L742-L758 | train | This function is called after the drop event is fired. | [
30522,
3853,
2695,
25711,
14321,
24076,
2361,
1006,
4496,
12879,
21898,
1007,
1063,
2065,
1006,
7944,
1007,
1063,
1013,
1013,
2128,
1011,
9585,
4933,
2057,
2357,
2125,
1035,
16081,
21748,
7913,
7265,
2860,
29278,
8095,
8584,
2015,
1006,
627... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | getIfChildren | function getIfChildren(oIfElement) {
var oChild,
aChildren = Array.prototype.filter.call(oIfElement.childNodes, isElementNode),
i, n,
bFoundElse = false;
/*
* Tells whether the given XML DOM node is an element node.
*
* @param {Node} oNode - an XML DOM node
* @returns {boolean} whether the given node is an element node
*/
function isElementNode(oNode) {
return oNode.nodeType === 1;
}
/*
* Tells whether the given XML DOM element has the template namespace and the given
* local name.
*
* @param {Element} oElement - an XML DOM element
* @param {string} sLocalName - a local name
* @returns {boolean} whether the given element has the given name
*/
function isTemplateElement(oElement, sLocalName) {
return oElement.namespaceURI === sNAMESPACE
&& oElement.localName === sLocalName;
}
if (!aChildren.length || !isTemplateElement(aChildren[0], "then")) {
return null;
}
for (i = 1, n = aChildren.length; i < n; i += 1) {
oChild = aChildren[i];
if (bFoundElse) {
error("Expected </" + oIfElement.prefix + ":if>, but instead saw ", oChild);
}
if (isTemplateElement(oChild, "else")) {
bFoundElse = true;
} else if (!isTemplateElement(oChild, "elseif")) {
error("Expected <" + oIfElement.prefix + ":elseif> or <"
+ oIfElement.prefix + ":else>, but instead saw ", aChildren[i]);
}
}
return aChildren;
} | javascript | function getIfChildren(oIfElement) {
var oChild,
aChildren = Array.prototype.filter.call(oIfElement.childNodes, isElementNode),
i, n,
bFoundElse = false;
/*
* Tells whether the given XML DOM node is an element node.
*
* @param {Node} oNode - an XML DOM node
* @returns {boolean} whether the given node is an element node
*/
function isElementNode(oNode) {
return oNode.nodeType === 1;
}
/*
* Tells whether the given XML DOM element has the template namespace and the given
* local name.
*
* @param {Element} oElement - an XML DOM element
* @param {string} sLocalName - a local name
* @returns {boolean} whether the given element has the given name
*/
function isTemplateElement(oElement, sLocalName) {
return oElement.namespaceURI === sNAMESPACE
&& oElement.localName === sLocalName;
}
if (!aChildren.length || !isTemplateElement(aChildren[0], "then")) {
return null;
}
for (i = 1, n = aChildren.length; i < n; i += 1) {
oChild = aChildren[i];
if (bFoundElse) {
error("Expected </" + oIfElement.prefix + ":if>, but instead saw ", oChild);
}
if (isTemplateElement(oChild, "else")) {
bFoundElse = true;
} else if (!isTemplateElement(oChild, "elseif")) {
error("Expected <" + oIfElement.prefix + ":elseif> or <"
+ oIfElement.prefix + ":else>, but instead saw ", aChildren[i]);
}
}
return aChildren;
} | [
"function",
"getIfChildren",
"(",
"oIfElement",
")",
"{",
"var",
"oChild",
",",
"aChildren",
"=",
"Array",
".",
"prototype",
".",
"filter",
".",
"call",
"(",
"oIfElement",
".",
"childNodes",
",",
"isElementNode",
")",
",",
"i",
",",
"n",
",",
"bFoundElse",... | Determines the relevant children for the <template:if> element.
@param {Element} oIfElement
the <template:if> XML DOM element
@returns {Element[]}
the XML DOM element children (a <then>, zero or more <elseif> and possibly an
<else>) or null if there is no <then>
@throws {Error}
if there is an unexpected child element | [
"Determines",
"the",
"relevant",
"children",
"for",
"the",
"<template",
":",
"if",
">",
"element",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L986-L1031 | train | Returns an array of children of an If element | [
30522,
3853,
2131,
10128,
19339,
7389,
1006,
1051,
29323,
16930,
4765,
1007,
1063,
13075,
28166,
4014,
2094,
1010,
9353,
19466,
16200,
2078,
1027,
9140,
1012,
8773,
1012,
11307,
1012,
2655,
1006,
1051,
29323,
16930,
4765,
1012,
2775,
3630,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/text/index.js | pHandle | function pHandle(e) {
const $selectionElem = editor.selection.getSelectionContainerElem()
const $parentElem = $selectionElem.parent()
if ($parentElem.html() === '<code><br></code>') {
// 回车之前光标所在一个 <p><code>.....</code></p> ,忽然回车生成一个空的 <p><code><br></code></p>
// 而且继续回车跳不出去,因此只能特殊处理
insertEmptyP($selectionElem)
return
}
if (!$parentElem.equal($textElem)) {
// 不是顶级标签
return
}
const nodeName = $selectionElem.getNodeName()
if (nodeName === 'P') {
// 当前的标签是 P ,不用做处理
return
}
if ($selectionElem.text()) {
// 有内容,不做处理
return
}
// 插入 <p> ,并将选取定位到 <p>,删除当前标签
insertEmptyP($selectionElem)
} | javascript | function pHandle(e) {
const $selectionElem = editor.selection.getSelectionContainerElem()
const $parentElem = $selectionElem.parent()
if ($parentElem.html() === '<code><br></code>') {
// 回车之前光标所在一个 <p><code>.....</code></p> ,忽然回车生成一个空的 <p><code><br></code></p>
// 而且继续回车跳不出去,因此只能特殊处理
insertEmptyP($selectionElem)
return
}
if (!$parentElem.equal($textElem)) {
// 不是顶级标签
return
}
const nodeName = $selectionElem.getNodeName()
if (nodeName === 'P') {
// 当前的标签是 P ,不用做处理
return
}
if ($selectionElem.text()) {
// 有内容,不做处理
return
}
// 插入 <p> ,并将选取定位到 <p>,删除当前标签
insertEmptyP($selectionElem)
} | [
"function",
"pHandle",
"(",
"e",
")",
"{",
"const",
"$selectionElem",
"=",
"editor",
".",
"selection",
".",
"getSelectionContainerElem",
"(",
")",
"const",
"$parentElem",
"=",
"$selectionElem",
".",
"parent",
"(",
")",
"if",
"(",
"$parentElem",
".",
"html",
... | 将回车之后生成的非 <p> 的顶级标签,改为 <p> | [
"将回车之后生成的非",
"<p",
">",
"的顶级标签,改为",
"<p",
">"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/text/index.js#L186-L215 | train | Handle the p event | [
30522,
3853,
6887,
5685,
2571,
1006,
1041,
1007,
1063,
9530,
3367,
1002,
4989,
12260,
2213,
1027,
3559,
1012,
4989,
1012,
4152,
12260,
7542,
8663,
18249,
7869,
16930,
1006,
1007,
9530,
3367,
1002,
6687,
12260,
2213,
1027,
1002,
4989,
12260,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/object-curly-newline.js | areLineBreaksRequired | function areLineBreaksRequired(node, options, first, last) {
let objectProperties;
if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
objectProperties = node.properties;
} else {
// is ImportDeclaration or ExportNamedDeclaration
objectProperties = node.specifiers
.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
}
return objectProperties.length >= options.minProperties ||
(
options.multiline &&
objectProperties.length > 0 &&
first.loc.start.line !== last.loc.end.line
);
} | javascript | function areLineBreaksRequired(node, options, first, last) {
let objectProperties;
if (node.type === "ObjectExpression" || node.type === "ObjectPattern") {
objectProperties = node.properties;
} else {
// is ImportDeclaration or ExportNamedDeclaration
objectProperties = node.specifiers
.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
}
return objectProperties.length >= options.minProperties ||
(
options.multiline &&
objectProperties.length > 0 &&
first.loc.start.line !== last.loc.end.line
);
} | [
"function",
"areLineBreaksRequired",
"(",
"node",
",",
"options",
",",
"first",
",",
"last",
")",
"{",
"let",
"objectProperties",
";",
"if",
"(",
"node",
".",
"type",
"===",
"\"ObjectExpression\"",
"||",
"node",
".",
"type",
"===",
"\"ObjectPattern\"",
")",
... | Determines if ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration
node needs to be checked for missing line breaks
@param {ASTNode} node - Node under inspection
@param {Object} options - option specific to node type
@param {Token} first - First object property
@param {Token} last - Last object property
@returns {boolean} `true` if node needs to be checked for missing line breaks | [
"Determines",
"if",
"ObjectExpression",
"ObjectPattern",
"ImportDeclaration",
"or",
"ExportNamedDeclaration",
"node",
"needs",
"to",
"be",
"checked",
"for",
"missing",
"line",
"breaks"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-curly-newline.js#L111-L129 | train | Check if a node is a line break | [
30522,
3853,
2024,
4179,
23890,
21338,
2063,
15549,
5596,
1006,
13045,
1010,
7047,
1010,
2034,
1010,
2197,
1007,
1063,
2292,
4874,
21572,
4842,
7368,
1025,
2065,
1006,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
4874,
10288,
20110,
3258,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function () {
var oModel = this._oDialog.getModel("view"),
oTreeResults;
// early out if already open
if (this._oDebugPopover && this._oDebugPopover.isOpen()) {
return;
}
// fill and bind the tree structure from the currently loaded modules
oTreeResults = this._treeHelper.toTreeModel(this._oModuleSystemInfo);
oModel.setProperty("/DebugModules", [oTreeResults.tree]);
this._updateTreeInfos();
// create dialog lazily
if (!this._oDebugPopover) {
this._oDebugPopover = sap.ui.xmlfragment(this._DEBUG_MODULES_ID, "sap.ui.core.support.techinfo.TechnicalInfoDebugDialog", this);
this._oDialog.addDependent(this._oDebugPopover);
syncStyleClass(this._getContentDensityClass(), this._oDialog, this._oDebugPopover);
var oControl = this._getControl("customDebugValue", this._DEBUG_MODULES_ID);
try {
this._validateCustomDebugValue(oControl.getValue());
} catch (oException) {
this._showError(oControl, oException.message);
return;
}
}
// adopt tree depth to the deepest currently selected module
this._getControl("tree", this._DEBUG_MODULES_ID).expandToLevel(Math.max(this._MIN_EXPAND_LEVEL_DEBUG_MODULES, oTreeResults.depth));
// open dialog
this._oDebugPopover.open();
} | javascript | function () {
var oModel = this._oDialog.getModel("view"),
oTreeResults;
// early out if already open
if (this._oDebugPopover && this._oDebugPopover.isOpen()) {
return;
}
// fill and bind the tree structure from the currently loaded modules
oTreeResults = this._treeHelper.toTreeModel(this._oModuleSystemInfo);
oModel.setProperty("/DebugModules", [oTreeResults.tree]);
this._updateTreeInfos();
// create dialog lazily
if (!this._oDebugPopover) {
this._oDebugPopover = sap.ui.xmlfragment(this._DEBUG_MODULES_ID, "sap.ui.core.support.techinfo.TechnicalInfoDebugDialog", this);
this._oDialog.addDependent(this._oDebugPopover);
syncStyleClass(this._getContentDensityClass(), this._oDialog, this._oDebugPopover);
var oControl = this._getControl("customDebugValue", this._DEBUG_MODULES_ID);
try {
this._validateCustomDebugValue(oControl.getValue());
} catch (oException) {
this._showError(oControl, oException.message);
return;
}
}
// adopt tree depth to the deepest currently selected module
this._getControl("tree", this._DEBUG_MODULES_ID).expandToLevel(Math.max(this._MIN_EXPAND_LEVEL_DEBUG_MODULES, oTreeResults.depth));
// open dialog
this._oDebugPopover.open();
} | [
"function",
"(",
")",
"{",
"var",
"oModel",
"=",
"this",
".",
"_oDialog",
".",
"getModel",
"(",
"\"view\"",
")",
",",
"oTreeResults",
";",
"// early out if already open",
"if",
"(",
"this",
".",
"_oDebugPopover",
"&&",
"this",
".",
"_oDebugPopover",
".",
"is... | Opens a dialog with debug package selection options | [
"Opens",
"a",
"dialog",
"with",
"debug",
"package",
"selection",
"options"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L171-L204 | train | Creates a debug module dialog | [
30522,
3853,
1006,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
2023,
1012,
1035,
21045,
23067,
2290,
1012,
2131,
5302,
9247,
1006,
1000,
3193,
1000,
1007,
1010,
27178,
9910,
6072,
11314,
2015,
1025,
1013,
1013,
2220,
2041,
2065,
2525,
2330... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/editor/EditorCommandHandlers.js | _getLineCommentEdits | function _getLineCommentEdits(editor, selections, command) {
// We need to expand line selections in order to coalesce cursors on the same line, but we
// don't want to merge adjacent line selections.
var lineSelections = editor.convertToLineSelections(selections, { mergeAdjacent: false }),
edits = [];
_.each(lineSelections, function (lineSel) {
var sel = lineSel.selectionForEdit,
mode = editor.getModeForRange(sel.start, sel.end),
edit;
if (mode) {
var language = editor.document.getLanguage().getLanguageForMode(mode.name || mode);
if (language.hasLineCommentSyntax()) {
edit = _getLineCommentPrefixEdit(editor, language.getLineCommentPrefixes(), language.getBlockCommentPrefix(), language.getBlockCommentSuffix(), lineSel);
} else if (language.hasBlockCommentSyntax()) {
edit = _getLineCommentPrefixSuffixEdit(editor, language.getBlockCommentPrefix(), language.getBlockCommentSuffix(), lineSel, command);
}
}
if (!edit) {
// Even if we didn't want to do an edit, we still need to track the selection.
edit = {selection: lineSel.selectionsToTrack};
}
edits.push(edit);
});
return edits;
} | javascript | function _getLineCommentEdits(editor, selections, command) {
// We need to expand line selections in order to coalesce cursors on the same line, but we
// don't want to merge adjacent line selections.
var lineSelections = editor.convertToLineSelections(selections, { mergeAdjacent: false }),
edits = [];
_.each(lineSelections, function (lineSel) {
var sel = lineSel.selectionForEdit,
mode = editor.getModeForRange(sel.start, sel.end),
edit;
if (mode) {
var language = editor.document.getLanguage().getLanguageForMode(mode.name || mode);
if (language.hasLineCommentSyntax()) {
edit = _getLineCommentPrefixEdit(editor, language.getLineCommentPrefixes(), language.getBlockCommentPrefix(), language.getBlockCommentSuffix(), lineSel);
} else if (language.hasBlockCommentSyntax()) {
edit = _getLineCommentPrefixSuffixEdit(editor, language.getBlockCommentPrefix(), language.getBlockCommentSuffix(), lineSel, command);
}
}
if (!edit) {
// Even if we didn't want to do an edit, we still need to track the selection.
edit = {selection: lineSel.selectionsToTrack};
}
edits.push(edit);
});
return edits;
} | [
"function",
"_getLineCommentEdits",
"(",
"editor",
",",
"selections",
",",
"command",
")",
"{",
"// We need to expand line selections in order to coalesce cursors on the same line, but we",
"// don't want to merge adjacent line selections.",
"var",
"lineSelections",
"=",
"editor",
".... | @private
Generates an array of edits for toggling line comments on the given selections.
@param {!Editor} editor The editor to edit within.
@param {Array.<{start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean, isBeforeEdit: boolean}>}
selections The selections we want to line-comment.
@param {String} command The command callee. It cans be "line" or "block".
@return {Array.<{edit: {text: string, start:{line: number, ch: number}, end:?{line: number, ch: number}}|Array.<{text: string, start:{line: number, ch: number}, end:?{line: number, ch: number}}>,
selection: {start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean, isBeforeEdit: boolean}>}|
Array.<{start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean, isBeforeEdit: boolean}>}>}
An array of edit descriptions suitable for including in the edits array passed to `Document.doMultipleEdits()`. | [
"@private",
"Generates",
"an",
"array",
"of",
"edits",
"for",
"toggling",
"line",
"comments",
"on",
"the",
"given",
"selections",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L650-L675 | train | Get an array of edits for a line comment. | [
30522,
3853,
1035,
2131,
4179,
9006,
3672,
2098,
12762,
1006,
3559,
1010,
16310,
1010,
3094,
1007,
1063,
1013,
1013,
2057,
2342,
2000,
7818,
2240,
16310,
1999,
2344,
2000,
5317,
2229,
3401,
12731,
25301,
2869,
2006,
1996,
2168,
2240,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/xpath/xpath.js | push_ | function push_(array, position, element) {
if (!array[position]) {
array[position] = [];
}
array[position].push(element);
} | javascript | function push_(array, position, element) {
if (!array[position]) {
array[position] = [];
}
array[position].push(element);
} | [
"function",
"push_",
"(",
"array",
",",
"position",
",",
"element",
")",
"{",
"if",
"(",
"!",
"array",
"[",
"position",
"]",
")",
"{",
"array",
"[",
"position",
"]",
"=",
"[",
"]",
";",
"}",
"array",
"[",
"position",
"]",
".",
"push",
"(",
"eleme... | Another slight optimization: sort the rules into bins according to the last element (observing quantifiers), so we can restrict the match against the stack to the subest of rules that match the top of the stack. TODO(mesch): What we actually want is to compute states as in bison, so that we don't have to do any explicit and iterated match against the stack. | [
"Another",
"slight",
"optimization",
":",
"sort",
"the",
"rules",
"into",
"bins",
"according",
"to",
"the",
"last",
"element",
"(",
"observing",
"quantifiers",
")",
"so",
"we",
"can",
"restrict",
"the",
"match",
"against",
"the",
"stack",
"to",
"the",
"subes... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/xpath.js#L2320-L2325 | train | push element to array at given position | [
30522,
3853,
5245,
1035,
1006,
9140,
1010,
2597,
1010,
5783,
1007,
1063,
2065,
1006,
999,
9140,
1031,
2597,
1033,
1007,
1063,
9140,
1031,
2597,
1033,
1027,
1031,
1033,
1025,
1065,
9140,
1031,
2597,
1033,
1012,
5245,
1006,
5783,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/modifiers/highlightCode.js | getLanguageForClass | function getLanguageForClass(classNames) {
return Immutable.List(classNames)
.map(function(cl) {
// Markdown
if (cl.search('lang-') === 0) {
return cl.slice('lang-'.length);
}
// Asciidoc
if (cl.search('language-') === 0) {
return cl.slice('language-'.length);
}
return null;
})
.find(function(cl) {
return Boolean(cl);
});
} | javascript | function getLanguageForClass(classNames) {
return Immutable.List(classNames)
.map(function(cl) {
// Markdown
if (cl.search('lang-') === 0) {
return cl.slice('lang-'.length);
}
// Asciidoc
if (cl.search('language-') === 0) {
return cl.slice('language-'.length);
}
return null;
})
.find(function(cl) {
return Boolean(cl);
});
} | [
"function",
"getLanguageForClass",
"(",
"classNames",
")",
"{",
"return",
"Immutable",
".",
"List",
"(",
"classNames",
")",
".",
"map",
"(",
"function",
"(",
"cl",
")",
"{",
"// Markdown",
"if",
"(",
"cl",
".",
"search",
"(",
"'lang-'",
")",
"===",
"0",
... | Return language for a code blocks from a list of class names
@param {Array<String>}
@return {String} | [
"Return",
"language",
"for",
"a",
"code",
"blocks",
"from",
"a",
"list",
"of",
"class",
"names"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/highlightCode.js#L13-L31 | train | getLanguageForClass - Returns language code | [
30522,
3853,
2131,
25023,
6692,
3351,
29278,
26266,
1006,
2465,
18442,
2015,
1007,
1063,
2709,
10047,
28120,
3085,
1012,
2862,
1006,
2465,
18442,
2015,
1007,
1012,
4949,
1006,
3853,
1006,
18856,
1007,
1063,
1013,
1013,
2928,
7698,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/column.js | columnGroupWidths | function columnGroupWidths(groups, all) {
return {
left: columnTotalWidth(groups.left),
center: columnTotalWidth(groups.center),
right: columnTotalWidth(groups.right),
total: Math.floor(columnTotalWidth(all))
};
} | javascript | function columnGroupWidths(groups, all) {
return {
left: columnTotalWidth(groups.left),
center: columnTotalWidth(groups.center),
right: columnTotalWidth(groups.right),
total: Math.floor(columnTotalWidth(all))
};
} | [
"function",
"columnGroupWidths",
"(",
"groups",
",",
"all",
")",
"{",
"return",
"{",
"left",
":",
"columnTotalWidth",
"(",
"groups",
".",
"left",
")",
",",
"center",
":",
"columnTotalWidth",
"(",
"groups",
".",
"center",
")",
",",
"right",
":",
"columnTota... | Returns the widths of all group sets of a column | [
"Returns",
"the",
"widths",
"of",
"all",
"group",
"sets",
"of",
"a",
"column"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column.js#L32-L39 | train | Returns the widths of the given group of terms | [
30522,
3853,
5930,
17058,
9148,
11927,
7898,
1006,
2967,
1010,
2035,
1007,
1063,
2709,
1063,
2187,
1024,
5930,
3406,
9080,
9148,
11927,
2232,
1006,
2967,
1012,
2187,
1007,
1010,
2415,
1024,
5930,
3406,
9080,
9148,
11927,
2232,
1006,
2967,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | plugins/show-invisibles/prism-show-invisibles.js | addInvisibles | function addInvisibles(grammar) {
if (!grammar || grammar['tab']) {
return;
}
// assign invisibles here to "mark" the grammar in case of self references
for (var name in invisibles) {
if (invisibles.hasOwnProperty(name)) {
grammar[name] = invisibles[name];
}
}
for (var name in grammar) {
if (grammar.hasOwnProperty(name) && !invisibles[name]) {
if (name === 'rest') {
addInvisibles(grammar['rest']);
} else {
handleToken(grammar, name);
}
}
}
} | javascript | function addInvisibles(grammar) {
if (!grammar || grammar['tab']) {
return;
}
// assign invisibles here to "mark" the grammar in case of self references
for (var name in invisibles) {
if (invisibles.hasOwnProperty(name)) {
grammar[name] = invisibles[name];
}
}
for (var name in grammar) {
if (grammar.hasOwnProperty(name) && !invisibles[name]) {
if (name === 'rest') {
addInvisibles(grammar['rest']);
} else {
handleToken(grammar, name);
}
}
}
} | [
"function",
"addInvisibles",
"(",
"grammar",
")",
"{",
"if",
"(",
"!",
"grammar",
"||",
"grammar",
"[",
"'tab'",
"]",
")",
"{",
"return",
";",
"}",
"// assign invisibles here to \"mark\" the grammar in case of self references",
"for",
"(",
"var",
"name",
"in",
"in... | Recursively adds patterns to match invisible characters to the given grammar (if not added already).
@param {Object} grammar | [
"Recursively",
"adds",
"patterns",
"to",
"match",
"invisible",
"characters",
"to",
"the",
"given",
"grammar",
"(",
"if",
"not",
"added",
"already",
")",
"."
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/show-invisibles/prism-show-invisibles.js#L58-L79 | train | Add invisibles to the grammar | [
30522,
3853,
5587,
2378,
11365,
7028,
2015,
1006,
8035,
1007,
1063,
2065,
1006,
999,
8035,
1064,
1064,
8035,
1031,
1005,
21628,
1005,
1033,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
23911,
8841,
2015,
2182,
2000,
1000,
2928,
1000,
1996,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/report/resources/filter.js | updateIssuesGroups | function updateIssuesGroups() {
// Get all groups.
var groupHeaderElements = document.querySelectorAll('[data-groupName]');
for (var i = 0; i < groupHeaderElements.length; i++) {
var groupHeader = groupHeaderElements[i];
var issuesGroupId = groupHeader.getAttribute('data-expandableElement');
var groupName = groupHeader.getAttribute('data-groupName');
var groupNumber = groupHeader.getAttribute('data-groupNumber');
// Get all rules for the current group.
var rules = document.querySelectorAll('#' + issuesGroupId + ' > tr');
var numberOfUnfilteredIssues = 0;
var numberOfUnfilteredRules = 0;
// Hide the rule section if no issues. Otherwise update count.
for (var k = 0; k < rules.length; k++) {
var rule = rules[k];
var unfilteredIssuesForRule = rule.querySelectorAll('tr.filterable:not(.filtered)');
var numberOfUnfilteredIssuesForRule = unfilteredIssuesForRule.length;
if (numberOfUnfilteredIssuesForRule === 0) {
rule.classList.add('filtered');
} else {
numberOfUnfilteredRules++;
numberOfUnfilteredIssues += numberOfUnfilteredIssuesForRule;
rule.querySelector('span.rule-issue-number').innerText = '(' + numberOfUnfilteredIssuesForRule + ' issues)';
}
}
// Hide the group section if no issues. Otherwise update count.
if (numberOfUnfilteredRules === 0) {
groupHeader.classList.add('filtered');
} else {
groupHeader.classList.remove('filtered');
groupHeader.querySelector('span').innerText = ' ' + groupNumber + '. ' + groupName + ' (' + numberOfUnfilteredRules + ' rules, ' + numberOfUnfilteredIssues + ' issues)';
}
}
} | javascript | function updateIssuesGroups() {
// Get all groups.
var groupHeaderElements = document.querySelectorAll('[data-groupName]');
for (var i = 0; i < groupHeaderElements.length; i++) {
var groupHeader = groupHeaderElements[i];
var issuesGroupId = groupHeader.getAttribute('data-expandableElement');
var groupName = groupHeader.getAttribute('data-groupName');
var groupNumber = groupHeader.getAttribute('data-groupNumber');
// Get all rules for the current group.
var rules = document.querySelectorAll('#' + issuesGroupId + ' > tr');
var numberOfUnfilteredIssues = 0;
var numberOfUnfilteredRules = 0;
// Hide the rule section if no issues. Otherwise update count.
for (var k = 0; k < rules.length; k++) {
var rule = rules[k];
var unfilteredIssuesForRule = rule.querySelectorAll('tr.filterable:not(.filtered)');
var numberOfUnfilteredIssuesForRule = unfilteredIssuesForRule.length;
if (numberOfUnfilteredIssuesForRule === 0) {
rule.classList.add('filtered');
} else {
numberOfUnfilteredRules++;
numberOfUnfilteredIssues += numberOfUnfilteredIssuesForRule;
rule.querySelector('span.rule-issue-number').innerText = '(' + numberOfUnfilteredIssuesForRule + ' issues)';
}
}
// Hide the group section if no issues. Otherwise update count.
if (numberOfUnfilteredRules === 0) {
groupHeader.classList.add('filtered');
} else {
groupHeader.classList.remove('filtered');
groupHeader.querySelector('span').innerText = ' ' + groupNumber + '. ' + groupName + ' (' + numberOfUnfilteredRules + ' rules, ' + numberOfUnfilteredIssues + ' issues)';
}
}
} | [
"function",
"updateIssuesGroups",
"(",
")",
"{",
"// Get all groups.",
"var",
"groupHeaderElements",
"=",
"document",
".",
"querySelectorAll",
"(",
"'[data-groupName]'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"groupHeaderElements",
".",
"leng... | Used to update the groups counters and hide/show group headers if all of the elements are filtered. | [
"Used",
"to",
"update",
"the",
"groups",
"counters",
"and",
"hide",
"/",
"show",
"group",
"headers",
"if",
"all",
"of",
"the",
"elements",
"are",
"filtered",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/report/resources/filter.js#L11-L47 | train | Update the issues groups | [
30522,
3853,
10651,
14643,
15808,
17058,
2015,
1006,
1007,
1063,
1013,
1013,
2131,
2035,
2967,
1012,
13075,
2177,
4974,
7869,
16930,
11187,
1027,
6254,
1012,
23032,
11246,
22471,
6525,
3363,
1006,
1005,
1031,
2951,
1011,
2177,
18442,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/DraftEnabledMockServer.js | function(aRequests) {
var that = this;
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootActivationName),
response: function(oXhr) {
var oRequestBody = JSON.parse(oXhr.requestBody);
var aFilter = [];
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
if (oEntry.IsActiveEntity) {
// respond negative - trying to activate an already active entity
oXhr.respond(400);
}
if (oEntry.HasActiveEntity) {
// edit draft activiation --> delete active sibling
var oSiblingEntityUri = oEntry.SiblingEntity.__deferred.uri;
oResponse = jQuery.sap.sjax({
url: oSiblingEntityUri,
dataType: "json"
});
if (oResponse.success && oResponse.data && oResponse.data.d.__metadata) {
var oSibling = oResponse.data.d;
oResponse = jQuery.sap.sjax({
url: oSibling.__metadata.uri,
type: "DELETE"
});
}
}
oEntry = that._activate(oEntry);
oXhr.respondJSON(200, {}, JSON.stringify({
d: oEntry
}));
return true;
}
});
if (that._oDraftMetadata.draftRootEditName) {
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootEditName + "(\\?(.*))?"),
response: function(oXhr, sUrlParams) {
var aFilter = [];
var oRequestBody = JSON.parse(oXhr.requestBody);
if (oRequestBody && !jQuery.isEmptyObject(oRequestBody)) {
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
} else {
var aUrlParams = decodeURIComponent(sUrlParams).replace("?", "&").split("&");
for (var param in aUrlParams) {
var sParamValue = aUrlParams[param];
var rKeyValue = new RegExp("(.*)=(.*)");
var aRes;
if (sParamValue) {
aRes = rKeyValue.exec(sParamValue);
aFilter.push(aRes[1] + " eq " + aRes[2]);
}
}
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
if (!oEntry.IsActiveEntity || oEntry.HasDraftEntity) {
// respond negative - edit draft is only valid for an active document. If a business document already has an edit draft,
// the Edit action fails; there can be at most one edit draft per active business document.
oXhr.respond(400);
}
// creates a deep copy of the business document.
var oDraftEntry = jQuery.extend(true, {}, oEntry);
oDraftEntry.IsActiveEntity = false; // true for active documents
oDraftEntry.HasActiveEntity = true; // false for new drafts and active documents
oDraftEntry.HasDraftEntity = false;
oDraftEntry[that._oDraftMetadata.draftRootKey] = that._generatePropertyValue(that._oDraftMetadata.draftRootKey, "Guid");
// add the metadata for the entry
var sRootUri = that._getRootUri();
var oEntitySet = that._mEntitySets[that._oDraftMetadata.draftRootName];
oDraftEntry.__metadata = oDraftEntry.__metadata || {};
oDraftEntry.__metadata.uri = sRootUri + that._oDraftMetadata.draftRootName + "(" + that._createKeysString(oEntitySet,
oDraftEntry) + ")";
oDraftEntry.__metadata.type = oEntitySet.schema + "." + oEntitySet.type;
// add the navigation properties
jQuery.each(oEntitySet.navprops, function(sKey) {
oDraftEntry[sKey] = {
__deferred: {
uri: sRootUri + that._oDraftMetadata.draftRootName + "(" + that._createKeysString(oEntitySet, oDraftEntry) + ")/" + sKey
}
};
});
that._oMockdata[that._oDraftMetadata.draftRootName].push(oDraftEntry);
// update the active with HasDraftEntity = true
oResponse = jQuery.sap.sjax({
url: oEntry.__metadata.uri,
type: "PATCH",
data: JSON.stringify({
HasDraftEntity: true
})
});
oXhr.respondJSON(200, {}, JSON.stringify({
d: oDraftEntry
}));
return true;
}
});
}
if (that._oDraftMetadata.draftRootValidationName) {
aRequests.push({
method: "GET",
path: new RegExp(that._oDraftMetadata.draftRootValidationName + "(\\?(.*))?"),
response: function(oXhr, sUrlParams) {
var sValidation = that._oDraftMetadata.draftRootValidationName;
//trigger the before callback funtion
that.fireEvent(MockServer.HTTPMETHOD.GET + sValidation + ":before", {
oXhr: oXhr,
sUrlParams: sUrlParams
});
that.fireEvent(MockServer.HTTPMETHOD.GET + ":before", {
oXhr: oXhr,
sUrlParams: sUrlParams
});
var oResponse = {
d: {}
};
oResponse.d[sValidation] = {
"__metadata": {
"type": "ValidationResult"
},
"IsValid": true
};
//trigger the after callback funtion
that.fireEvent(MockServer.HTTPMETHOD.GET + sValidation + ":after", {
oXhr: oXhr,
oResult: oResponse
});
that.fireEvent(MockServer.HTTPMETHOD.GET + ":after", {
oXhr: oXhr,
oResult: oResponse
});
oXhr.respondJSON(200, {}, JSON.stringify(oResponse));
return true;
}
});
}
if (that._oDraftMetadata.draftRootPreparationtionName) {
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootPreparationtionName),
response: function(oXhr) {
//trigger the before callback funtion
that.fireEvent(MockServer.HTTPMETHOD.POST + that._oDraftMetadata.draftRootPreparationtionName + ":before", {
oXhr: oXhr
});
that.fireEvent(MockServer.HTTPMETHOD.POST + ":before", {
oXhr: oXhr
});
var oRequestBody = JSON.parse(oXhr.requestBody);
var aFilter = [];
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
//trigger the after callback funtion
that.fireEvent(MockServer.HTTPMETHOD.POST + that._oDraftMetadata.draftRootPreparationtionName + ":after", {
oXhr: oXhr,
oEntry: oEntry
});
that.fireEvent(MockServer.HTTPMETHOD.POST + ":after", {
oXhr: oXhr,
oEntry: oEntry
});
oXhr.respondJSON(200, {}, JSON.stringify({
d: oEntry
}));
return true;
}
});
}
MockServer.prototype.setRequests.apply(this, [aRequests]);
} | javascript | function(aRequests) {
var that = this;
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootActivationName),
response: function(oXhr) {
var oRequestBody = JSON.parse(oXhr.requestBody);
var aFilter = [];
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
if (oEntry.IsActiveEntity) {
// respond negative - trying to activate an already active entity
oXhr.respond(400);
}
if (oEntry.HasActiveEntity) {
// edit draft activiation --> delete active sibling
var oSiblingEntityUri = oEntry.SiblingEntity.__deferred.uri;
oResponse = jQuery.sap.sjax({
url: oSiblingEntityUri,
dataType: "json"
});
if (oResponse.success && oResponse.data && oResponse.data.d.__metadata) {
var oSibling = oResponse.data.d;
oResponse = jQuery.sap.sjax({
url: oSibling.__metadata.uri,
type: "DELETE"
});
}
}
oEntry = that._activate(oEntry);
oXhr.respondJSON(200, {}, JSON.stringify({
d: oEntry
}));
return true;
}
});
if (that._oDraftMetadata.draftRootEditName) {
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootEditName + "(\\?(.*))?"),
response: function(oXhr, sUrlParams) {
var aFilter = [];
var oRequestBody = JSON.parse(oXhr.requestBody);
if (oRequestBody && !jQuery.isEmptyObject(oRequestBody)) {
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
} else {
var aUrlParams = decodeURIComponent(sUrlParams).replace("?", "&").split("&");
for (var param in aUrlParams) {
var sParamValue = aUrlParams[param];
var rKeyValue = new RegExp("(.*)=(.*)");
var aRes;
if (sParamValue) {
aRes = rKeyValue.exec(sParamValue);
aFilter.push(aRes[1] + " eq " + aRes[2]);
}
}
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
if (!oEntry.IsActiveEntity || oEntry.HasDraftEntity) {
// respond negative - edit draft is only valid for an active document. If a business document already has an edit draft,
// the Edit action fails; there can be at most one edit draft per active business document.
oXhr.respond(400);
}
// creates a deep copy of the business document.
var oDraftEntry = jQuery.extend(true, {}, oEntry);
oDraftEntry.IsActiveEntity = false; // true for active documents
oDraftEntry.HasActiveEntity = true; // false for new drafts and active documents
oDraftEntry.HasDraftEntity = false;
oDraftEntry[that._oDraftMetadata.draftRootKey] = that._generatePropertyValue(that._oDraftMetadata.draftRootKey, "Guid");
// add the metadata for the entry
var sRootUri = that._getRootUri();
var oEntitySet = that._mEntitySets[that._oDraftMetadata.draftRootName];
oDraftEntry.__metadata = oDraftEntry.__metadata || {};
oDraftEntry.__metadata.uri = sRootUri + that._oDraftMetadata.draftRootName + "(" + that._createKeysString(oEntitySet,
oDraftEntry) + ")";
oDraftEntry.__metadata.type = oEntitySet.schema + "." + oEntitySet.type;
// add the navigation properties
jQuery.each(oEntitySet.navprops, function(sKey) {
oDraftEntry[sKey] = {
__deferred: {
uri: sRootUri + that._oDraftMetadata.draftRootName + "(" + that._createKeysString(oEntitySet, oDraftEntry) + ")/" + sKey
}
};
});
that._oMockdata[that._oDraftMetadata.draftRootName].push(oDraftEntry);
// update the active with HasDraftEntity = true
oResponse = jQuery.sap.sjax({
url: oEntry.__metadata.uri,
type: "PATCH",
data: JSON.stringify({
HasDraftEntity: true
})
});
oXhr.respondJSON(200, {}, JSON.stringify({
d: oDraftEntry
}));
return true;
}
});
}
if (that._oDraftMetadata.draftRootValidationName) {
aRequests.push({
method: "GET",
path: new RegExp(that._oDraftMetadata.draftRootValidationName + "(\\?(.*))?"),
response: function(oXhr, sUrlParams) {
var sValidation = that._oDraftMetadata.draftRootValidationName;
//trigger the before callback funtion
that.fireEvent(MockServer.HTTPMETHOD.GET + sValidation + ":before", {
oXhr: oXhr,
sUrlParams: sUrlParams
});
that.fireEvent(MockServer.HTTPMETHOD.GET + ":before", {
oXhr: oXhr,
sUrlParams: sUrlParams
});
var oResponse = {
d: {}
};
oResponse.d[sValidation] = {
"__metadata": {
"type": "ValidationResult"
},
"IsValid": true
};
//trigger the after callback funtion
that.fireEvent(MockServer.HTTPMETHOD.GET + sValidation + ":after", {
oXhr: oXhr,
oResult: oResponse
});
that.fireEvent(MockServer.HTTPMETHOD.GET + ":after", {
oXhr: oXhr,
oResult: oResponse
});
oXhr.respondJSON(200, {}, JSON.stringify(oResponse));
return true;
}
});
}
if (that._oDraftMetadata.draftRootPreparationtionName) {
aRequests.push({
method: "POST",
path: new RegExp(that._oDraftMetadata.draftRootPreparationtionName),
response: function(oXhr) {
//trigger the before callback funtion
that.fireEvent(MockServer.HTTPMETHOD.POST + that._oDraftMetadata.draftRootPreparationtionName + ":before", {
oXhr: oXhr
});
that.fireEvent(MockServer.HTTPMETHOD.POST + ":before", {
oXhr: oXhr
});
var oRequestBody = JSON.parse(oXhr.requestBody);
var aFilter = [];
for (var property in oRequestBody) {
aFilter.push(property + " eq " + oRequestBody[property]);
}
var oResponse = jQuery.sap.sjax({
url: that._oDraftMetadata.mockServerRootUri + that._oDraftMetadata.draftRootName + "?$filter=" + aFilter.join(" and "),
dataType: "json"
});
if (!oResponse.success || !oResponse.data.d.results[0]) {
// respond negative - no entity found
oXhr.respond(404);
}
var oEntry = oResponse.data.d.results[0];
//trigger the after callback funtion
that.fireEvent(MockServer.HTTPMETHOD.POST + that._oDraftMetadata.draftRootPreparationtionName + ":after", {
oXhr: oXhr,
oEntry: oEntry
});
that.fireEvent(MockServer.HTTPMETHOD.POST + ":after", {
oXhr: oXhr,
oEntry: oEntry
});
oXhr.respondJSON(200, {}, JSON.stringify({
d: oEntry
}));
return true;
}
});
}
MockServer.prototype.setRequests.apply(this, [aRequests]);
} | [
"function",
"(",
"aRequests",
")",
"{",
"var",
"that",
"=",
"this",
";",
"aRequests",
".",
"push",
"(",
"{",
"method",
":",
"\"POST\"",
",",
"path",
":",
"new",
"RegExp",
"(",
"that",
".",
"_oDraftMetadata",
".",
"draftRootActivationName",
")",
",",
"res... | ================================= overridden functions of MockServer ================================= | [
"=================================",
"overridden",
"functions",
"of",
"MockServer",
"================================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/DraftEnabledMockServer.js#L395-L603 | train | Adds a request to the server | [
30522,
3853,
1006,
2024,
15500,
2015,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
2024,
15500,
2015,
1012,
5245,
1006,
1063,
4118,
1024,
1000,
2695,
1000,
1010,
4130,
1024,
2047,
19723,
10288,
2361,
1006,
2008,
1012,
1035,
1051,
7265,
6199,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
pixijs/pixi.js | packages/prepare/src/Prepare.js | uploadGraphics | function uploadGraphics(renderer, item)
{
if (item instanceof Graphics)
{
// if the item is not dirty and already has webgl data, then it got prepared or rendered
// before now and we shouldn't waste time updating it again
if (item.dirty || item.clearDirty || !item._webGL[renderer.plugins.graphics.CONTEXT_UID])
{
renderer.plugins.graphics.updateGraphics(item);
}
return true;
}
return false;
} | javascript | function uploadGraphics(renderer, item)
{
if (item instanceof Graphics)
{
// if the item is not dirty and already has webgl data, then it got prepared or rendered
// before now and we shouldn't waste time updating it again
if (item.dirty || item.clearDirty || !item._webGL[renderer.plugins.graphics.CONTEXT_UID])
{
renderer.plugins.graphics.updateGraphics(item);
}
return true;
}
return false;
} | [
"function",
"uploadGraphics",
"(",
"renderer",
",",
"item",
")",
"{",
"if",
"(",
"item",
"instanceof",
"Graphics",
")",
"{",
"// if the item is not dirty and already has webgl data, then it got prepared or rendered",
"// before now and we shouldn't waste time updating it again",
"i... | Built-in hook to upload PIXI.Graphics to the GPU.
@private
@param {PIXI.Renderer} renderer - instance of the webgl renderer
@param {PIXI.DisplayObject} item - Item to check
@return {boolean} If item was uploaded. | [
"Built",
"-",
"in",
"hook",
"to",
"upload",
"PIXI",
".",
"Graphics",
"to",
"the",
"GPU",
"."
] | 99ae03b7565ae7ca5a6de633b0a277f7128fa4d0 | https://github.com/pixijs/pixi.js/blob/99ae03b7565ae7ca5a6de633b0a277f7128fa4d0/packages/prepare/src/Prepare.js#L65-L80 | train | upload Graphics to the image | [
30522,
3853,
2039,
11066,
14773,
2015,
1006,
17552,
2121,
1010,
8875,
1007,
30524,
1063,
1013,
1013,
2065,
1996,
8875,
2003,
2025,
6530,
1998,
2525,
2038,
4773,
23296,
2951,
1010,
2059,
2009,
2288,
4810,
2030,
10155,
1013,
1013,
2077,
2085,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableRendererUtils.js | function(rm, sName, oValue, bShouldAdd) {
if (sName && oValue && (!!bShouldAdd || arguments.length == 3)) {
rm.addStyle(sName, oValue);
if (TAGCONTEXT) {
TAGCONTEXT.writeStyles = true;
}
}
return TableRendererUtils;
} | javascript | function(rm, sName, oValue, bShouldAdd) {
if (sName && oValue && (!!bShouldAdd || arguments.length == 3)) {
rm.addStyle(sName, oValue);
if (TAGCONTEXT) {
TAGCONTEXT.writeStyles = true;
}
}
return TableRendererUtils;
} | [
"function",
"(",
"rm",
",",
"sName",
",",
"oValue",
",",
"bShouldAdd",
")",
"{",
"if",
"(",
"sName",
"&&",
"oValue",
"&&",
"(",
"!",
"!",
"bShouldAdd",
"||",
"arguments",
".",
"length",
"==",
"3",
")",
")",
"{",
"rm",
".",
"addStyle",
"(",
"sName",... | Adds the given style if no condition is given or the condition is truthy.
@param {sap.ui.core.RenderManager} rm Instance of the rendermanager
@param {string} sName The style name which should be written
@param {string} oValue The style value which should be written
@param {boolean} [bShouldAdd] optional condition
@returns TableRendererUtils to allow method chaining
@private | [
"Adds",
"the",
"given",
"style",
"if",
"no",
"condition",
"is",
"given",
"or",
"the",
"condition",
"is",
"truthy",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableRendererUtils.js#L54-L62 | train | Adds a style to the table renderer. | [
30522,
3853,
1006,
28549,
1010,
1055,
18442,
1010,
9242,
5657,
1010,
18667,
6806,
21285,
4215,
2094,
1007,
1063,
2065,
1006,
1055,
18442,
1004,
1004,
9242,
5657,
30524,
1064,
1064,
9918,
1012,
3091,
1027,
1027,
1017,
1007,
1007,
1063,
28549... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
vuejs/vue-devtools | src/util.js | internalSearchObject | function internalSearchObject (obj, searchTerm, seen, depth) {
if (depth > SEARCH_MAX_DEPTH) {
return false
}
let match = false
const keys = Object.keys(obj)
let key, value
for (let i = 0; i < keys.length; i++) {
key = keys[i]
value = obj[key]
match = internalSearchCheck(searchTerm, key, value, seen, depth + 1)
if (match) {
break
}
}
return match
} | javascript | function internalSearchObject (obj, searchTerm, seen, depth) {
if (depth > SEARCH_MAX_DEPTH) {
return false
}
let match = false
const keys = Object.keys(obj)
let key, value
for (let i = 0; i < keys.length; i++) {
key = keys[i]
value = obj[key]
match = internalSearchCheck(searchTerm, key, value, seen, depth + 1)
if (match) {
break
}
}
return match
} | [
"function",
"internalSearchObject",
"(",
"obj",
",",
"searchTerm",
",",
"seen",
",",
"depth",
")",
"{",
"if",
"(",
"depth",
">",
"SEARCH_MAX_DEPTH",
")",
"{",
"return",
"false",
"}",
"let",
"match",
"=",
"false",
"const",
"keys",
"=",
"Object",
".",
"key... | Executes a search on each field of the provided object
@param {*} obj Search target
@param {string} searchTerm Search string
@param {Map<any,boolean>} seen Map containing the search result to prevent stack overflow by walking on the same object multiple times
@param {number} depth Deep search depth level, which is capped to prevent performance issues
@returns {boolean} Search match | [
"Executes",
"a",
"search",
"on",
"each",
"field",
"of",
"the",
"provided",
"object"
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/util.js#L421-L437 | train | internalSearchObject - Search object for searchTerm | [
30522,
3853,
4722,
17310,
11140,
16429,
20614,
1006,
27885,
3501,
1010,
3945,
3334,
2213,
1010,
2464,
1010,
5995,
1007,
1063,
2065,
1006,
5995,
1028,
3945,
1035,
4098,
1035,
5995,
1007,
1063,
2709,
6270,
1065,
2292,
2674,
1027,
6270,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/radix.js | checkArguments | function checkArguments(node) {
const args = node.arguments;
switch (args.length) {
case 0:
context.report({
node,
message: "Missing parameters."
});
break;
case 1:
if (mode === MODE_ALWAYS) {
context.report({
node,
message: "Missing radix parameter."
});
}
break;
default:
if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
context.report({
node,
message: "Redundant radix parameter."
});
} else if (!isValidRadix(args[1])) {
context.report({
node,
message: "Invalid radix parameter."
});
}
break;
}
} | javascript | function checkArguments(node) {
const args = node.arguments;
switch (args.length) {
case 0:
context.report({
node,
message: "Missing parameters."
});
break;
case 1:
if (mode === MODE_ALWAYS) {
context.report({
node,
message: "Missing radix parameter."
});
}
break;
default:
if (mode === MODE_AS_NEEDED && isDefaultRadix(args[1])) {
context.report({
node,
message: "Redundant radix parameter."
});
} else if (!isValidRadix(args[1])) {
context.report({
node,
message: "Invalid radix parameter."
});
}
break;
}
} | [
"function",
"checkArguments",
"(",
"node",
")",
"{",
"const",
"args",
"=",
"node",
".",
"arguments",
";",
"switch",
"(",
"args",
".",
"length",
")",
"{",
"case",
"0",
":",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Missing para... | Checks the arguments of a given CallExpression node and reports it if it
offends this rule.
@param {ASTNode} node - A CallExpression node to check.
@returns {void} | [
"Checks",
"the",
"arguments",
"of",
"a",
"given",
"CallExpression",
"node",
"and",
"reports",
"it",
"if",
"it",
"offends",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/radix.js#L107-L141 | train | Check arguments for an error message. | [
30522,
3853,
4638,
2906,
22850,
11187,
1006,
13045,
1007,
1063,
9530,
3367,
12098,
5620,
1027,
13045,
1012,
9918,
1025,
6942,
1006,
12098,
5620,
1012,
3091,
1007,
1063,
2553,
1014,
1024,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
4471,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-extra-semi.js | report | function report(nodeOrToken) {
context.report({
node: nodeOrToken,
messageId: "unexpected",
fix(fixer) {
/*
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting with semi.
* https://github.com/eslint/eslint/issues/7928
*/
return new FixTracker(fixer, context.getSourceCode())
.retainSurroundingTokens(nodeOrToken)
.remove(nodeOrToken);
}
});
} | javascript | function report(nodeOrToken) {
context.report({
node: nodeOrToken,
messageId: "unexpected",
fix(fixer) {
/*
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting with semi.
* https://github.com/eslint/eslint/issues/7928
*/
return new FixTracker(fixer, context.getSourceCode())
.retainSurroundingTokens(nodeOrToken)
.remove(nodeOrToken);
}
});
} | [
"function",
"report",
"(",
"nodeOrToken",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nodeOrToken",
",",
"messageId",
":",
"\"unexpected\"",
",",
"fix",
"(",
"fixer",
")",
"{",
"/*\n * Expand the replacement range to include the sur... | Reports an unnecessary semicolon error.
@param {Node|Token} nodeOrToken - A node or a token to be reported.
@returns {void} | [
"Reports",
"an",
"unnecessary",
"semicolon",
"error",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-semi.js#L46-L62 | train | Reports an unexpected token. | [
30522,
3853,
3189,
1006,
13045,
11589,
11045,
2078,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1024,
13045,
11589,
11045,
2078,
1010,
4471,
3593,
1024,
1000,
9223,
1000,
1010,
8081,
1006,
8081,
2121,
1007,
1063,
1013,
1008,
1008,
7818... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/modifiers/svgToImg.js | svgToImg | function svgToImg(baseFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'svg', function($svg) {
var content = '<?xml version="1.0" encoding="UTF-8"?>' +
renderDOM($, $svg);
// We avoid generating twice the same PNG
var hash = crc.crc32(content).toString(16);
var fileName = hash + '.svg';
var filePath = path.join(baseFolder, fileName);
// Write the svg to the file
return fs.assertFile(filePath, function() {
return fs.writeFile(filePath, content, 'utf8');
})
// Return as image
.then(function() {
var src = LocationUtils.relative(currentDirectory, fileName);
$svg.replaceWith('<img src="' + src + '" />');
});
});
} | javascript | function svgToImg(baseFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'svg', function($svg) {
var content = '<?xml version="1.0" encoding="UTF-8"?>' +
renderDOM($, $svg);
// We avoid generating twice the same PNG
var hash = crc.crc32(content).toString(16);
var fileName = hash + '.svg';
var filePath = path.join(baseFolder, fileName);
// Write the svg to the file
return fs.assertFile(filePath, function() {
return fs.writeFile(filePath, content, 'utf8');
})
// Return as image
.then(function() {
var src = LocationUtils.relative(currentDirectory, fileName);
$svg.replaceWith('<img src="' + src + '" />');
});
});
} | [
"function",
"svgToImg",
"(",
"baseFolder",
",",
"currentFile",
",",
"$",
")",
"{",
"var",
"currentDirectory",
"=",
"path",
".",
"dirname",
"(",
"currentFile",
")",
";",
"return",
"editHTMLElement",
"(",
"$",
",",
"'svg'",
",",
"function",
"(",
"$svg",
")",... | Replace SVG tag by IMG
@param {String} baseFolder
@param {HTMLDom} $ | [
"Replace",
"SVG",
"tag",
"by",
"IMG"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/svgToImg.js#L31-L54 | train | Convert svg to img | [
30522,
3853,
17917,
13512,
10448,
24798,
1006,
2918,
10371,
2121,
1010,
2783,
8873,
2571,
1010,
1002,
1007,
1063,
13075,
2783,
4305,
2890,
16761,
2100,
1027,
4130,
1012,
16101,
18442,
1006,
2783,
8873,
2571,
1007,
1025,
2709,
13257,
21246,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/interimElement/interimElement.js | hide | function hide(reason, options) {
options = options || {};
if (options.closeAll) {
// We have to make a shallow copy of the array, because otherwise the map will break.
return $q.all(showingInterims.slice().reverse().map(closeElement));
} else if (options.closeTo !== undefined) {
return $q.all(showingInterims.slice(options.closeTo).map(closeElement));
}
// Hide the latest showing interim element.
return closeElement(showingInterims[showingInterims.length - 1]);
function closeElement(interim) {
if (!interim) {
return $q.when(reason);
}
var hideAction = interim
.remove(reason, false, options || { })
.catch(function(reason) { return reason; })
.finally(function() {
hidePromises.splice(hidePromises.indexOf(hideAction), 1);
});
showingInterims.splice(showingInterims.indexOf(interim), 1);
hidePromises.push(hideAction);
return interim.deferred.promise;
}
} | javascript | function hide(reason, options) {
options = options || {};
if (options.closeAll) {
// We have to make a shallow copy of the array, because otherwise the map will break.
return $q.all(showingInterims.slice().reverse().map(closeElement));
} else if (options.closeTo !== undefined) {
return $q.all(showingInterims.slice(options.closeTo).map(closeElement));
}
// Hide the latest showing interim element.
return closeElement(showingInterims[showingInterims.length - 1]);
function closeElement(interim) {
if (!interim) {
return $q.when(reason);
}
var hideAction = interim
.remove(reason, false, options || { })
.catch(function(reason) { return reason; })
.finally(function() {
hidePromises.splice(hidePromises.indexOf(hideAction), 1);
});
showingInterims.splice(showingInterims.indexOf(interim), 1);
hidePromises.push(hideAction);
return interim.deferred.promise;
}
} | [
"function",
"hide",
"(",
"reason",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"options",
".",
"closeAll",
")",
"{",
"// We have to make a shallow copy of the array, because otherwise the map will break.",
"return",
"$q",
"."... | /*
@ngdoc method
@name $$interimElement.$service#hide
@kind function
@description
Removes the `$interimElement` from the DOM and resolves the promise returned from `show`
@param {*} resolveParam Data to resolve the promise with
@returns a Promise that will be resolved after the element has been removed. | [
"/",
"*",
"@ngdoc",
"method",
"@name",
"$$interimElement",
".",
"$service#hide",
"@kind",
"function"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L354-L385 | train | Hide the last showing interim element | [
30522,
3853,
5342,
1006,
3114,
1010,
7047,
1007,
1063,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
7047,
1012,
2485,
8095,
1007,
1063,
1013,
1013,
2057,
2031,
2000,
2191,
1037,
8467,
6100,
1997,
1996,
9140,
1010,
2138,
472... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Component.js | getManifestEntry | function getManifestEntry(oMetadata, oManifest, sKey, bMerged) {
var oData = oManifest.getEntry(sKey);
// merge / extend should only be done for objects or when entry wasn't found
if (oData !== undefined && !isPlainObject(oData)) {
return oData;
}
// merge the configuration of the parent manifest with local manifest
// the configuration of the static component metadata will be ignored
var oParent, oParentData;
if (bMerged && (oParent = oMetadata.getParent()) instanceof ComponentMetadata) {
oParentData = oParent.getManifestEntry(sKey, bMerged);
}
// only extend / clone if there is data
// otherwise "null" will be converted into an empty object
if (oParentData || oData) {
oData = jQuery.extend(true, {}, oParentData, oData);
}
return oData;
} | javascript | function getManifestEntry(oMetadata, oManifest, sKey, bMerged) {
var oData = oManifest.getEntry(sKey);
// merge / extend should only be done for objects or when entry wasn't found
if (oData !== undefined && !isPlainObject(oData)) {
return oData;
}
// merge the configuration of the parent manifest with local manifest
// the configuration of the static component metadata will be ignored
var oParent, oParentData;
if (bMerged && (oParent = oMetadata.getParent()) instanceof ComponentMetadata) {
oParentData = oParent.getManifestEntry(sKey, bMerged);
}
// only extend / clone if there is data
// otherwise "null" will be converted into an empty object
if (oParentData || oData) {
oData = jQuery.extend(true, {}, oParentData, oData);
}
return oData;
} | [
"function",
"getManifestEntry",
"(",
"oMetadata",
",",
"oManifest",
",",
"sKey",
",",
"bMerged",
")",
"{",
"var",
"oData",
"=",
"oManifest",
".",
"getEntry",
"(",
"sKey",
")",
";",
"// merge / extend should only be done for objects or when entry wasn't found",
"if",
"... | Returns the configuration of a manifest section or the value for a
specific path. If no section or key is specified, the return value is null.
@param {sap.ui.core.ComponentMetadata} oMetadata the Component metadata
@param {sap.ui.core.Manifest} oManifest the manifest
@param {string} sKey Either the manifest section name (namespace) or a concrete path
@param {boolean} [bMerged] Indicates whether the manifest entry is merged with the manifest entries of the parent component.
@return {any|null} Value of the manifest section or the key (could be any kind of value)
@private
@see {@link sap.ui.core.Component#getManifestEntry} | [
"Returns",
"the",
"configuration",
"of",
"a",
"manifest",
"section",
"or",
"the",
"value",
"for",
"a",
"specific",
"path",
".",
"If",
"no",
"section",
"or",
"key",
"is",
"specified",
"the",
"return",
"value",
"is",
"null",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L102-L124 | train | Returns the manifest entry for the given key. | [
30522,
3853,
2131,
20799,
14081,
4765,
2854,
1006,
18168,
12928,
2850,
2696,
1010,
16640,
29323,
3367,
1010,
15315,
3240,
1010,
1038,
5017,
5999,
1007,
1063,
13075,
1051,
2850,
2696,
30524,
13590,
1013,
7949,
2323,
2069,
2022,
2589,
2005,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/get-selector.js | uncommonAttributes | function uncommonAttributes(node, selectorData) {
let retVal = [];
let attData = selectorData.attributes;
let tagData = selectorData.tags;
if (node.hasAttributes()) {
Array.from(axe.utils.getNodeAttributes(node))
.filter(filterAttributes)
.forEach(at => {
const atnv = getAttributeNameValue(node, at);
if (atnv && attData[atnv] < tagData[node.nodeName]) {
retVal.push({
name: atnv,
count: attData[atnv],
species: 'attribute'
});
}
});
}
return retVal.sort(countSort);
} | javascript | function uncommonAttributes(node, selectorData) {
let retVal = [];
let attData = selectorData.attributes;
let tagData = selectorData.tags;
if (node.hasAttributes()) {
Array.from(axe.utils.getNodeAttributes(node))
.filter(filterAttributes)
.forEach(at => {
const atnv = getAttributeNameValue(node, at);
if (atnv && attData[atnv] < tagData[node.nodeName]) {
retVal.push({
name: atnv,
count: attData[atnv],
species: 'attribute'
});
}
});
}
return retVal.sort(countSort);
} | [
"function",
"uncommonAttributes",
"(",
"node",
",",
"selectorData",
")",
"{",
"let",
"retVal",
"=",
"[",
"]",
";",
"let",
"attData",
"=",
"selectorData",
".",
"attributes",
";",
"let",
"tagData",
"=",
"selectorData",
".",
"tags",
";",
"if",
"(",
"node",
... | Given a node and the statistics on attribute frequency on the page,
return all its uncommon attribute data sorted in order of decreasing uniqueness
@param {Element} node The node
@param {Object} attData The map of attributes to counts
@return {Array} The sorted array of uncommon attribute data | [
"Given",
"a",
"node",
"and",
"the",
"statistics",
"on",
"attribute",
"frequency",
"on",
"the",
"page",
"return",
"all",
"its",
"uncommon",
"attribute",
"data",
"sorted",
"in",
"order",
"of",
"decreasing",
"uniqueness"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/get-selector.js#L236-L257 | train | Returns an array of uncommon attributes for a node | [
30522,
3853,
13191,
19321,
3089,
8569,
4570,
1006,
13045,
1010,
27000,
2850,
2696,
1007,
1063,
2292,
2128,
9189,
2389,
1027,
1031,
1033,
1025,
2292,
2012,
2102,
2850,
2696,
1027,
27000,
2850,
2696,
1012,
12332,
1025,
2292,
6415,
2850,
2696,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
juliangarnier/anime | lib/anime.js | getParentSvgEl | function getParentSvgEl(el) {
var parentEl = el.parentNode;
while (is.svg(parentEl)) {
parentEl = parentEl.parentNode;
if (!is.svg(parentEl.parentNode)) { break; }
}
return parentEl;
} | javascript | function getParentSvgEl(el) {
var parentEl = el.parentNode;
while (is.svg(parentEl)) {
parentEl = parentEl.parentNode;
if (!is.svg(parentEl.parentNode)) { break; }
}
return parentEl;
} | [
"function",
"getParentSvgEl",
"(",
"el",
")",
"{",
"var",
"parentEl",
"=",
"el",
".",
"parentNode",
";",
"while",
"(",
"is",
".",
"svg",
"(",
"parentEl",
")",
")",
"{",
"parentEl",
"=",
"parentEl",
".",
"parentNode",
";",
"if",
"(",
"!",
"is",
".",
... | Motion path | [
"Motion",
"path"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/lib/anime.js#L585-L592 | train | Get parent SVG element | [
30522,
3853,
2131,
19362,
11187,
2615,
12439,
1006,
3449,
1007,
1063,
13075,
6687,
2884,
1027,
3449,
1012,
6687,
3630,
3207,
1025,
2096,
1006,
2003,
1012,
17917,
2290,
1006,
6687,
2884,
1007,
1007,
1063,
6687,
2884,
1027,
6687,
2884,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/indent-legacy.js | checkIndentInArrayOrObjectBlock | function checkIndentInArrayOrObjectBlock(node) {
// Skip inline
if (isSingleLineNode(node)) {
return;
}
let elements = (node.type === "ArrayExpression") ? node.elements : node.properties;
// filter out empty elements example would be [ , 2] so remove first element as espree considers it as null
elements = elements.filter(elem => elem !== null);
let nodeIndent;
let elementsIndent;
const parentVarNode = getVariableDeclaratorNode(node);
// TODO - come up with a better strategy in future
if (isNodeFirstInLine(node)) {
const parent = node.parent;
nodeIndent = getNodeIndent(parent).goodChar;
if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) {
if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) {
if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) {
nodeIndent += (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]);
} else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") {
const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements;
if (parentElements[0] &&
parentElements[0].loc.start.line === parent.loc.start.line &&
parentElements[0].loc.end.line !== parent.loc.start.line) {
/*
* If the first element of the array spans multiple lines, don't increase the expected indentation of the rest.
* e.g. [{
* foo: 1
* },
* {
* bar: 1
* }]
* the second object is not indented.
*/
} else if (typeof options[parent.type] === "number") {
nodeIndent += options[parent.type] * indentSize;
} else {
nodeIndent = parentElements[0].loc.start.column;
}
} else if (parent.type === "CallExpression" || parent.type === "NewExpression") {
if (typeof options.CallExpression.arguments === "number") {
nodeIndent += options.CallExpression.arguments * indentSize;
} else if (options.CallExpression.arguments === "first") {
if (parent.arguments.indexOf(node) !== -1) {
nodeIndent = parent.arguments[0].loc.start.column;
}
} else {
nodeIndent += indentSize;
}
} else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") {
nodeIndent += indentSize;
}
}
} else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") {
nodeIndent += indentSize;
}
checkFirstNodeLineIndent(node, nodeIndent);
} else {
nodeIndent = getNodeIndent(node).goodChar;
}
if (options[node.type] === "first") {
elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter.
} else {
elementsIndent = nodeIndent + indentSize * options[node.type];
}
/*
* Check if the node is a multiple variable declaration; if so, then
* make sure indentation takes that into account.
*/
if (isNodeInVarOnTop(node, parentVarNode)) {
elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
}
checkNodesIndent(elements, elementsIndent);
if (elements.length > 0) {
// Skip last block line check if last item in same line
if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
return;
}
}
checkLastNodeLineIndent(node, nodeIndent +
(isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0));
} | javascript | function checkIndentInArrayOrObjectBlock(node) {
// Skip inline
if (isSingleLineNode(node)) {
return;
}
let elements = (node.type === "ArrayExpression") ? node.elements : node.properties;
// filter out empty elements example would be [ , 2] so remove first element as espree considers it as null
elements = elements.filter(elem => elem !== null);
let nodeIndent;
let elementsIndent;
const parentVarNode = getVariableDeclaratorNode(node);
// TODO - come up with a better strategy in future
if (isNodeFirstInLine(node)) {
const parent = node.parent;
nodeIndent = getNodeIndent(parent).goodChar;
if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) {
if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) {
if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) {
nodeIndent += (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]);
} else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") {
const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements;
if (parentElements[0] &&
parentElements[0].loc.start.line === parent.loc.start.line &&
parentElements[0].loc.end.line !== parent.loc.start.line) {
/*
* If the first element of the array spans multiple lines, don't increase the expected indentation of the rest.
* e.g. [{
* foo: 1
* },
* {
* bar: 1
* }]
* the second object is not indented.
*/
} else if (typeof options[parent.type] === "number") {
nodeIndent += options[parent.type] * indentSize;
} else {
nodeIndent = parentElements[0].loc.start.column;
}
} else if (parent.type === "CallExpression" || parent.type === "NewExpression") {
if (typeof options.CallExpression.arguments === "number") {
nodeIndent += options.CallExpression.arguments * indentSize;
} else if (options.CallExpression.arguments === "first") {
if (parent.arguments.indexOf(node) !== -1) {
nodeIndent = parent.arguments[0].loc.start.column;
}
} else {
nodeIndent += indentSize;
}
} else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") {
nodeIndent += indentSize;
}
}
} else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") {
nodeIndent += indentSize;
}
checkFirstNodeLineIndent(node, nodeIndent);
} else {
nodeIndent = getNodeIndent(node).goodChar;
}
if (options[node.type] === "first") {
elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter.
} else {
elementsIndent = nodeIndent + indentSize * options[node.type];
}
/*
* Check if the node is a multiple variable declaration; if so, then
* make sure indentation takes that into account.
*/
if (isNodeInVarOnTop(node, parentVarNode)) {
elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
}
checkNodesIndent(elements, elementsIndent);
if (elements.length > 0) {
// Skip last block line check if last item in same line
if (elements[elements.length - 1].loc.end.line === node.loc.end.line) {
return;
}
}
checkLastNodeLineIndent(node, nodeIndent +
(isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0));
} | [
"function",
"checkIndentInArrayOrObjectBlock",
"(",
"node",
")",
"{",
"// Skip inline",
"if",
"(",
"isSingleLineNode",
"(",
"node",
")",
")",
"{",
"return",
";",
"}",
"let",
"elements",
"=",
"(",
"node",
".",
"type",
"===",
"\"ArrayExpression\"",
")",
"?",
"... | Check indent for array block content or object block content
@param {ASTNode} node node to examine
@returns {void} | [
"Check",
"indent",
"for",
"array",
"block",
"content",
"or",
"object",
"block",
"content"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L718-L814 | train | Check indentation of array or object block | [
30522,
3853,
4638,
22254,
4765,
3981,
11335,
7677,
3217,
2497,
20614,
23467,
1006,
13045,
1007,
1063,
1013,
1013,
13558,
23881,
2065,
1006,
26354,
2075,
2571,
4179,
3630,
3207,
1006,
13045,
1007,
1007,
1063,
2709,
1025,
1065,
2292,
3787,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/chips/js/contactChipsDirective.js | MdContactChips | function MdContactChips($mdTheming, $mdUtil) {
return {
template: function(element, attrs) {
return MD_CONTACT_CHIPS_TEMPLATE;
},
restrict: 'E',
controller: 'MdContactChipsCtrl',
controllerAs: '$mdContactChipsCtrl',
bindToController: true,
compile: compile,
scope: {
contactQuery: '&mdContacts',
placeholder: '@?',
secondaryPlaceholder: '@?',
contactName: '@mdContactName',
contactImage: '@mdContactImage',
contactEmail: '@mdContactEmail',
contacts: '=ngModel',
ngChange: '&?',
requireMatch: '=?mdRequireMatch',
minLength: '=?mdMinLength',
highlightFlags: '@?mdHighlightFlags',
chipAppendDelay: '@?mdChipAppendDelay',
separatorKeys: '=?mdSeparatorKeys',
removedMessage: '@?mdRemovedMessage',
inputAriaDescribedBy: '@?inputAriaDescribedby',
inputAriaLabelledBy: '@?inputAriaLabelledby',
inputAriaLabel: '@?',
containerHint: '@?',
containerEmptyHint: '@?',
deleteHint: '@?'
}
};
function compile(element, attr) {
return function postLink(scope, element, attrs, controllers) {
var contactChipsController = controllers;
$mdUtil.initOptionalProperties(scope, attr);
$mdTheming(element);
element.attr('tabindex', '-1');
attrs.$observe('mdChipAppendDelay', function(newValue) {
contactChipsController.chipAppendDelay = newValue;
});
};
}
} | javascript | function MdContactChips($mdTheming, $mdUtil) {
return {
template: function(element, attrs) {
return MD_CONTACT_CHIPS_TEMPLATE;
},
restrict: 'E',
controller: 'MdContactChipsCtrl',
controllerAs: '$mdContactChipsCtrl',
bindToController: true,
compile: compile,
scope: {
contactQuery: '&mdContacts',
placeholder: '@?',
secondaryPlaceholder: '@?',
contactName: '@mdContactName',
contactImage: '@mdContactImage',
contactEmail: '@mdContactEmail',
contacts: '=ngModel',
ngChange: '&?',
requireMatch: '=?mdRequireMatch',
minLength: '=?mdMinLength',
highlightFlags: '@?mdHighlightFlags',
chipAppendDelay: '@?mdChipAppendDelay',
separatorKeys: '=?mdSeparatorKeys',
removedMessage: '@?mdRemovedMessage',
inputAriaDescribedBy: '@?inputAriaDescribedby',
inputAriaLabelledBy: '@?inputAriaLabelledby',
inputAriaLabel: '@?',
containerHint: '@?',
containerEmptyHint: '@?',
deleteHint: '@?'
}
};
function compile(element, attr) {
return function postLink(scope, element, attrs, controllers) {
var contactChipsController = controllers;
$mdUtil.initOptionalProperties(scope, attr);
$mdTheming(element);
element.attr('tabindex', '-1');
attrs.$observe('mdChipAppendDelay', function(newValue) {
contactChipsController.chipAppendDelay = newValue;
});
};
}
} | [
"function",
"MdContactChips",
"(",
"$mdTheming",
",",
"$mdUtil",
")",
"{",
"return",
"{",
"template",
":",
"function",
"(",
"element",
",",
"attrs",
")",
"{",
"return",
"MD_CONTACT_CHIPS_TEMPLATE",
";",
"}",
",",
"restrict",
":",
"'E'",
",",
"controller",
":... | MDContactChips Directive Definition
@param $mdTheming
@param $mdUtil
@returns {*}
@ngInject | [
"MDContactChips",
"Directive",
"Definition"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/js/contactChipsDirective.js#L133-L181 | train | A directive that can be used to link a chips to a contact. | [
30522,
3853,
9108,
8663,
2696,
6593,
5428,
4523,
1006,
1002,
9108,
10760,
6562,
1010,
1002,
9108,
21823,
2140,
1007,
1063,
2709,
1063,
23561,
1024,
3853,
1006,
5783,
1010,
2012,
16344,
2015,
1007,
1063,
2709,
9108,
1035,
3967,
1035,
11772,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.