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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
jhipster/generator-jhipster | generators/aws-containers/prompts.js | askDeployNow | function askDeployNow() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'confirm',
name: 'deployNow',
message: 'Would you like to deploy now?.',
default: true
}
];
return this.prompt(prompts).then(props => {
this.deployNow = props.deployNow;
done();
});
} | javascript | function askDeployNow() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'confirm',
name: 'deployNow',
message: 'Would you like to deploy now?.',
default: true
}
];
return this.prompt(prompts).then(props => {
this.deployNow = props.deployNow;
done();
});
} | [
"function",
"askDeployNow",
"(",
")",
"{",
"if",
"(",
"this",
".",
"abort",
")",
"return",
"null",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'confirm'",
",",
"name",
":",
"'depl... | Ask user if they would like to deploy now? | [
"Ask",
"user",
"if",
"they",
"would",
"like",
"to",
"deploy",
"now?"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/prompts.js#L495-L511 | train | Ask user if they want to deploy now? | [
30522,
3853,
3198,
3207,
24759,
6977,
19779,
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,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | checkNodeIndent | function checkNodeIndent(node, neededIndent) {
const actualIndent = getNodeIndent(node, false);
if (
node.type !== "ArrayExpression" &&
node.type !== "ObjectExpression" &&
(actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
isNodeFirstInLine(node)
) {
report(node, neededIndent, actualIndent.space, actualIndent.tab);
}
if (node.type === "IfStatement" && node.alternate) {
const elseToken = sourceCode.getTokenBefore(node.alternate);
checkNodeIndent(elseToken, neededIndent);
if (!isNodeFirstInLine(node.alternate)) {
checkNodeIndent(node.alternate, neededIndent);
}
}
if (node.type === "TryStatement" && node.handler) {
const catchToken = sourceCode.getFirstToken(node.handler);
checkNodeIndent(catchToken, neededIndent);
}
if (node.type === "TryStatement" && node.finalizer) {
const finallyToken = sourceCode.getTokenBefore(node.finalizer);
checkNodeIndent(finallyToken, neededIndent);
}
if (node.type === "DoWhileStatement") {
const whileToken = sourceCode.getTokenAfter(node.body);
checkNodeIndent(whileToken, neededIndent);
}
} | javascript | function checkNodeIndent(node, neededIndent) {
const actualIndent = getNodeIndent(node, false);
if (
node.type !== "ArrayExpression" &&
node.type !== "ObjectExpression" &&
(actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
isNodeFirstInLine(node)
) {
report(node, neededIndent, actualIndent.space, actualIndent.tab);
}
if (node.type === "IfStatement" && node.alternate) {
const elseToken = sourceCode.getTokenBefore(node.alternate);
checkNodeIndent(elseToken, neededIndent);
if (!isNodeFirstInLine(node.alternate)) {
checkNodeIndent(node.alternate, neededIndent);
}
}
if (node.type === "TryStatement" && node.handler) {
const catchToken = sourceCode.getFirstToken(node.handler);
checkNodeIndent(catchToken, neededIndent);
}
if (node.type === "TryStatement" && node.finalizer) {
const finallyToken = sourceCode.getTokenBefore(node.finalizer);
checkNodeIndent(finallyToken, neededIndent);
}
if (node.type === "DoWhileStatement") {
const whileToken = sourceCode.getTokenAfter(node.body);
checkNodeIndent(whileToken, neededIndent);
}
} | [
"function",
"checkNodeIndent",
"(",
"node",
",",
"neededIndent",
")",
"{",
"const",
"actualIndent",
"=",
"getNodeIndent",
"(",
"node",
",",
"false",
")",
";",
"if",
"(",
"node",
".",
"type",
"!==",
"\"ArrayExpression\"",
"&&",
"node",
".",
"type",
"!==",
"... | Check indent for node
@param {ASTNode} node Node to check
@param {int} neededIndent needed indent
@returns {void} | [
"Check",
"indent",
"for",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L375-L414 | train | Check indent of node | [
30522,
3853,
4638,
3630,
3207,
22254,
4765,
1006,
13045,
1010,
2734,
22254,
4765,
1007,
1063,
9530,
3367,
5025,
22254,
4765,
1027,
2131,
3630,
3207,
22254,
4765,
1006,
13045,
1010,
6270,
1007,
1025,
2065,
1006,
13045,
1012,
2828,
999,
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... |
aframevr/aframe | src/components/animation.js | toRadians | function toRadians (obj) {
obj.x = THREE.Math.degToRad(obj.x);
obj.y = THREE.Math.degToRad(obj.y);
obj.z = THREE.Math.degToRad(obj.z);
} | javascript | function toRadians (obj) {
obj.x = THREE.Math.degToRad(obj.x);
obj.y = THREE.Math.degToRad(obj.y);
obj.z = THREE.Math.degToRad(obj.z);
} | [
"function",
"toRadians",
"(",
"obj",
")",
"{",
"obj",
".",
"x",
"=",
"THREE",
".",
"Math",
".",
"degToRad",
"(",
"obj",
".",
"x",
")",
";",
"obj",
".",
"y",
"=",
"THREE",
".",
"Math",
".",
"degToRad",
"(",
"obj",
".",
"y",
")",
";",
"obj",
".... | Convert object to radians. | [
"Convert",
"object",
"to",
"radians",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L542-L546 | train | Converts an object to an angle | [
30522,
3853,
17153,
25205,
3619,
1006,
27885,
3501,
1007,
1063,
27885,
3501,
1012,
1060,
1027,
2093,
1012,
8785,
1012,
2139,
13512,
6525,
2094,
1006,
27885,
3501,
1012,
1060,
1007,
1025,
27885,
3501,
1012,
1061,
1027,
2093,
1012,
8785,
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... |
GitbookIO/gitbook | lib/parse/parseBook.js | parseBook | function parseBook(book) {
return timing.measure(
'parse.book',
Promise(book)
.then(parseIgnore)
.then(parseConfig)
.then(parseLanguages)
.then(function(resultBook) {
if (resultBook.isMultilingual()) {
return parseMultilingualBook(resultBook);
} else {
return parseBookContent(resultBook);
}
})
);
} | javascript | function parseBook(book) {
return timing.measure(
'parse.book',
Promise(book)
.then(parseIgnore)
.then(parseConfig)
.then(parseLanguages)
.then(function(resultBook) {
if (resultBook.isMultilingual()) {
return parseMultilingualBook(resultBook);
} else {
return parseBookContent(resultBook);
}
})
);
} | [
"function",
"parseBook",
"(",
"book",
")",
"{",
"return",
"timing",
".",
"measure",
"(",
"'parse.book'",
",",
"Promise",
"(",
"book",
")",
".",
"then",
"(",
"parseIgnore",
")",
".",
"then",
"(",
"parseConfig",
")",
".",
"then",
"(",
"parseLanguages",
")"... | Parse a whole book from a filesystem
@param {Book} book
@return {Promise<Book>} | [
"Parse",
"a",
"whole",
"book",
"from",
"a",
"filesystem"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseBook.js#L60-L75 | train | Parse a book | [
30522,
3853,
11968,
3366,
8654,
1006,
2338,
1007,
1063,
2709,
10984,
1012,
5468,
1006,
1005,
11968,
3366,
1012,
2338,
1005,
1010,
4872,
1006,
2338,
1007,
1012,
2059,
1006,
11968,
20240,
26745,
2890,
1007,
1012,
2059,
1006,
11968,
3366,
8663... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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(sPath, oProperties, sTarget, oSchema) {
var iPos = sPath.indexOf("/");
if (iPos > -1) {
var sPropertyName = sPath.substr(0, iPos);
var mNavProperty = AnnotationParser.findNavProperty(sTarget, sPropertyName);
if (mNavProperty) {
var mToEntityType = AnnotationParser._parserData.metadataInstance._getEntityTypeByNavPropertyObject(mNavProperty);
if (mToEntityType) {
sTarget = mToEntityType.entityType;
sPath = sPath.substr(iPos + 1);
}
}
}
if ((sPath.charAt(0) === "@") && (sPath.indexOf(oSchema.Alias) === 1)) {
sPath = sPath.slice(oSchema.Alias.length + 2);
}
if (sPath.indexOf("/") >= 0) {
if (oProperties[sPath.slice(0, sPath.indexOf("/"))]) {
sTarget = sPath.slice(0, sPath.indexOf("/"));
sPath = sPath.slice(sPath.indexOf("/") + 1);
}
}
return oProperties[sTarget] && oProperties[sTarget][sPath];
} | javascript | function(sPath, oProperties, sTarget, oSchema) {
var iPos = sPath.indexOf("/");
if (iPos > -1) {
var sPropertyName = sPath.substr(0, iPos);
var mNavProperty = AnnotationParser.findNavProperty(sTarget, sPropertyName);
if (mNavProperty) {
var mToEntityType = AnnotationParser._parserData.metadataInstance._getEntityTypeByNavPropertyObject(mNavProperty);
if (mToEntityType) {
sTarget = mToEntityType.entityType;
sPath = sPath.substr(iPos + 1);
}
}
}
if ((sPath.charAt(0) === "@") && (sPath.indexOf(oSchema.Alias) === 1)) {
sPath = sPath.slice(oSchema.Alias.length + 2);
}
if (sPath.indexOf("/") >= 0) {
if (oProperties[sPath.slice(0, sPath.indexOf("/"))]) {
sTarget = sPath.slice(0, sPath.indexOf("/"));
sPath = sPath.slice(sPath.indexOf("/") + 1);
}
}
return oProperties[sTarget] && oProperties[sTarget][sPath];
} | [
"function",
"(",
"sPath",
",",
"oProperties",
",",
"sTarget",
",",
"oSchema",
")",
"{",
"var",
"iPos",
"=",
"sPath",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"iPos",
">",
"-",
"1",
")",
"{",
"var",
"sPropertyName",
"=",
"sPath",
".",
"sub... | /*
@static
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L782-L808 | train | Returns the target entity type and path of the property | [
30522,
3853,
1006,
14690,
2232,
1010,
6728,
18981,
8743,
3111,
1010,
2732,
18150,
1010,
9808,
5403,
2863,
1007,
1063,
13075,
12997,
2891,
1027,
14690,
2232,
1012,
5950,
11253,
1006,
1000,
1013,
1000,
1007,
1025,
2065,
1006,
12997,
2891,
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... | |
markdown-it/markdown-it | lib/common/utils.js | arrayReplaceAt | function arrayReplaceAt(src, pos, newElements) {
return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
} | javascript | function arrayReplaceAt(src, pos, newElements) {
return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
} | [
"function",
"arrayReplaceAt",
"(",
"src",
",",
"pos",
",",
"newElements",
")",
"{",
"return",
"[",
"]",
".",
"concat",
"(",
"src",
".",
"slice",
"(",
"0",
",",
"pos",
")",
",",
"newElements",
",",
"src",
".",
"slice",
"(",
"pos",
"+",
"1",
")",
"... | Remove element from array and put another array at those position. Useful for some operations with tokens | [
"Remove",
"element",
"from",
"array",
"and",
"put",
"another",
"array",
"at",
"those",
"position",
".",
"Useful",
"for",
"some",
"operations",
"with",
"tokens"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/common/utils.js#L38-L40 | train | Replace elements in array at pos with newElements | [
30522,
3853,
9140,
2890,
24759,
10732,
4017,
1006,
5034,
2278,
1010,
13433,
2015,
1010,
2047,
12260,
8163,
1007,
1063,
2709,
1031,
1033,
1012,
9530,
11266,
1006,
5034,
2278,
1012,
14704,
1006,
1014,
1010,
13433,
2015,
1007,
1010,
2047,
1226... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/_ODataMetaModelUtils.js | function (aArray, vExpectedPropertyValue, sPropertyName) {
var i, n;
sPropertyName = sPropertyName || "name";
if (aArray) {
for (i = 0, n = aArray.length; i < n; i += 1) {
if (aArray[i][sPropertyName] === vExpectedPropertyValue) {
return i;
}
}
}
return -1;
} | javascript | function (aArray, vExpectedPropertyValue, sPropertyName) {
var i, n;
sPropertyName = sPropertyName || "name";
if (aArray) {
for (i = 0, n = aArray.length; i < n; i += 1) {
if (aArray[i][sPropertyName] === vExpectedPropertyValue) {
return i;
}
}
}
return -1;
} | [
"function",
"(",
"aArray",
",",
"vExpectedPropertyValue",
",",
"sPropertyName",
")",
"{",
"var",
"i",
",",
"n",
";",
"sPropertyName",
"=",
"sPropertyName",
"||",
"\"name\"",
";",
"if",
"(",
"aArray",
")",
"{",
"for",
"(",
"i",
"=",
"0",
",",
"n",
"=",
... | Returns the index of the first object inside the given array, where the property with the
given name has the given expected value.
@param {object[]} [aArray]
some array
@param {any} vExpectedPropertyValue
expected value of the property with given name
@param {string} [sPropertyName="name"]
some property name
@returns {number}
the index of the first object found or <code>-1</code> if no such object is found | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"object",
"inside",
"the",
"given",
"array",
"where",
"the",
"property",
"with",
"the",
"given",
"name",
"has",
"the",
"given",
"expected",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L586-L598 | train | Returns the index of the property in the array that matches the expected value | [
30522,
3853,
1006,
9779,
11335,
2100,
1010,
2310,
2595,
5051,
10985,
21572,
4842,
3723,
10175,
5657,
1010,
11867,
18981,
15010,
18442,
1007,
1063,
13075,
1045,
1010,
1050,
1025,
11867,
18981,
15010,
18442,
1027,
11867,
18981,
15010,
18442,
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... | |
mdn/browser-compat-data | scripts/render.js | getData | function getData(queryString, obj) {
return queryString.split('.').reduce(function(prev, curr) {
return prev ? prev[curr] : undefined
}, obj);
} | javascript | function getData(queryString, obj) {
return queryString.split('.').reduce(function(prev, curr) {
return prev ? prev[curr] : undefined
}, obj);
} | [
"function",
"getData",
"(",
"queryString",
",",
"obj",
")",
"{",
"return",
"queryString",
".",
"split",
"(",
"'.'",
")",
".",
"reduce",
"(",
"function",
"(",
"prev",
",",
"curr",
")",
"{",
"return",
"prev",
"?",
"prev",
"[",
"curr",
"]",
":",
"undefi... | /*
Get compat data using a query string like "webextensions.api.alarms" | [
"/",
"*",
"Get",
"compat",
"data",
"using",
"a",
"query",
"string",
"like",
"webextensions",
".",
"api",
".",
"alarms"
] | 6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b | https://github.com/mdn/browser-compat-data/blob/6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b/scripts/render.js#L402-L406 | train | Get data from query string | [
30522,
3853,
2131,
2850,
2696,
1006,
23032,
3367,
4892,
1010,
27885,
3501,
1007,
1063,
2709,
23032,
3367,
4892,
1012,
3975,
1006,
1005,
1012,
1005,
1007,
1012,
5547,
1006,
3853,
1006,
3653,
2615,
1010,
12731,
12171,
1007,
1063,
2709,
3653,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | CalendarYearBodyCtrl | function CalendarYearBodyCtrl($element, $$mdDateUtil, $mdDateLocale) {
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.dateLocale = $mdDateLocale;
/** @type {Object} Reference to the calendar. */
this.calendarCtrl = null;
/** @type {Object} Reference to the year view. */
this.yearCtrl = null;
/**
* Number of months from the start of the month "items" that the currently rendered month
* occurs. Set via angular data binding.
* @type {number}
*/
this.offset = null;
/**
* Date cell to focus after appending the month to the document.
* @type {HTMLElement}
*/
this.focusAfterAppend = null;
} | javascript | function CalendarYearBodyCtrl($element, $$mdDateUtil, $mdDateLocale) {
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.dateLocale = $mdDateLocale;
/** @type {Object} Reference to the calendar. */
this.calendarCtrl = null;
/** @type {Object} Reference to the year view. */
this.yearCtrl = null;
/**
* Number of months from the start of the month "items" that the currently rendered month
* occurs. Set via angular data binding.
* @type {number}
*/
this.offset = null;
/**
* Date cell to focus after appending the month to the document.
* @type {HTMLElement}
*/
this.focusAfterAppend = null;
} | [
"function",
"CalendarYearBodyCtrl",
"(",
"$element",
",",
"$$mdDateUtil",
",",
"$mdDateLocale",
")",
"{",
"/** @final {!angular.JQLite} */",
"this",
".",
"$element",
"=",
"$element",
";",
"/** @final */",
"this",
".",
"dateUtil",
"=",
"$$mdDateUtil",
";",
"/** @final ... | Controller for a single year.
@ngInject @constructor | [
"Controller",
"for",
"a",
"single",
"year",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendarYearBody.js#L39-L67 | train | The calendar year body controller. | [
30522,
3853,
8094,
29100,
23684,
6593,
12190,
1006,
1002,
5783,
1010,
1002,
1002,
9108,
13701,
21823,
2140,
1010,
1002,
9108,
13701,
4135,
9289,
2063,
1007,
1063,
1013,
1008,
1008,
1030,
2345,
1063,
999,
16108,
1012,
1046,
4160,
22779,
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... |
spencermountain/compromise | src/terms/index.js | function(arr, world, refText, refTerms) {
this.terms = arr;
this.world = world || w;
this.refText = refText;
this._refTerms = refTerms;
this.get = n => {
return this.terms[n];
};
//apply getters
let keys = Object.keys(getters);
for (let i = 0; i < keys.length; i++) {
Object.defineProperty(this, keys[i], getters[keys[i]]);
}
} | javascript | function(arr, world, refText, refTerms) {
this.terms = arr;
this.world = world || w;
this.refText = refText;
this._refTerms = refTerms;
this.get = n => {
return this.terms[n];
};
//apply getters
let keys = Object.keys(getters);
for (let i = 0; i < keys.length; i++) {
Object.defineProperty(this, keys[i], getters[keys[i]]);
}
} | [
"function",
"(",
"arr",
",",
"world",
",",
"refText",
",",
"refTerms",
")",
"{",
"this",
".",
"terms",
"=",
"arr",
";",
"this",
".",
"world",
"=",
"world",
"||",
"w",
";",
"this",
".",
"refText",
"=",
"refText",
";",
"this",
".",
"_refTerms",
"=",
... | Terms is an array of Term objects, and methods that wrap around them | [
"Terms",
"is",
"an",
"array",
"of",
"Term",
"objects",
"and",
"methods",
"that",
"wrap",
"around",
"them"
] | 526b1cab28a45ccbb430fbf2824db420acd587cf | https://github.com/spencermountain/compromise/blob/526b1cab28a45ccbb430fbf2824db420acd587cf/src/terms/index.js#L7-L20 | train | A kludge for the terms in the formula | [
30522,
3853,
1006,
12098,
2099,
1010,
2088,
1010,
25416,
18209,
1010,
25416,
3334,
5244,
1007,
1063,
2023,
1012,
3408,
1027,
12098,
2099,
1025,
2023,
1012,
2088,
1027,
2088,
1064,
1064,
1059,
1025,
2023,
1012,
25416,
18209,
1027,
25416,
182... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
nhn/tui.editor | src/js/extensions/table/tableRenderer.js | _createTheadOrTbodyHtml | function _createTheadOrTbodyHtml(trs, wrapperNodeName) {
let html = '';
if (trs.length) {
html = trs.map(tr => {
const tdHtml = tr.map(_createCellHtml).join('');
return `<tr>${tdHtml}</tr>`;
}).join('');
html = `<${wrapperNodeName}>${html}</${wrapperNodeName}>`;
}
return html;
} | javascript | function _createTheadOrTbodyHtml(trs, wrapperNodeName) {
let html = '';
if (trs.length) {
html = trs.map(tr => {
const tdHtml = tr.map(_createCellHtml).join('');
return `<tr>${tdHtml}</tr>`;
}).join('');
html = `<${wrapperNodeName}>${html}</${wrapperNodeName}>`;
}
return html;
} | [
"function",
"_createTheadOrTbodyHtml",
"(",
"trs",
",",
"wrapperNodeName",
")",
"{",
"let",
"html",
"=",
"''",
";",
"if",
"(",
"trs",
".",
"length",
")",
"{",
"html",
"=",
"trs",
".",
"map",
"(",
"tr",
"=>",
"{",
"const",
"tdHtml",
"=",
"tr",
".",
... | Create html for thead or tbody.
@param {Array.<Array.<object>>} trs - tr list
@param {string} wrapperNodeName - wrapper node name like THEAD, TBODY
@returns {string}
@private | [
"Create",
"html",
"for",
"thead",
"or",
"tbody",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/tableRenderer.js#L30-L43 | train | Create html for the table head or tbody | [
30522,
3853,
1035,
3443,
10760,
26467,
2102,
23684,
11039,
19968,
1006,
19817,
2015,
1010,
10236,
4842,
3630,
4181,
14074,
1007,
1063,
2292,
16129,
1027,
1005,
1005,
1025,
2065,
1006,
19817,
2015,
1012,
3091,
1007,
1063,
16129,
1027,
19817,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
jakesgordon/javascript-state-machine | src/jsm.js | JSM | function JSM(context, config) {
this.context = context;
this.config = config;
this.state = config.init.from;
this.observers = [context];
} | javascript | function JSM(context, config) {
this.context = context;
this.config = config;
this.state = config.init.from;
this.observers = [context];
} | [
"function",
"JSM",
"(",
"context",
",",
"config",
")",
"{",
"this",
".",
"context",
"=",
"context",
";",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"state",
"=",
"config",
".",
"init",
".",
"from",
";",
"this",
".",
"observers",
"=",
"... | ------------------------------------------------------------------------------------------------- | [
"-------------------------------------------------------------------------------------------------"
] | 0d603577423244228cebcd62e60dbbfff27c6ea3 | https://github.com/jakesgordon/javascript-state-machine/blob/0d603577423244228cebcd62e60dbbfff27c6ea3/src/jsm.js#L9-L14 | train | JSM constructor. | [
30522,
3853,
1046,
6491,
1006,
6123,
1010,
9530,
8873,
2290,
1007,
1063,
2023,
1012,
6123,
1027,
6123,
1025,
2023,
1012,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1025,
2023,
1012,
2110,
1027,
9530,
8873,
2290,
1012,
1999,
4183,
1012,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ScopeManager.js | updateTernFile | function updateTernFile(document) {
var path = document.file.fullPath;
_postMessageByPass({
type : MessageIds.TERN_UPDATE_FILE_MSG,
path : path,
text : getTextFromDocument(document)
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_UPDATE_FILE_MSG);
} | javascript | function updateTernFile(document) {
var path = document.file.fullPath;
_postMessageByPass({
type : MessageIds.TERN_UPDATE_FILE_MSG,
path : path,
text : getTextFromDocument(document)
});
return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_UPDATE_FILE_MSG);
} | [
"function",
"updateTernFile",
"(",
"document",
")",
"{",
"var",
"path",
"=",
"document",
".",
"file",
".",
"fullPath",
";",
"_postMessageByPass",
"(",
"{",
"type",
":",
"MessageIds",
".",
"TERN_UPDATE_FILE_MSG",
",",
"path",
":",
"path",
",",
"text",
":",
... | Update tern with the new contents of a given file.
@param {Document} document - the document to update
@return {jQuery.Promise} - the promise for the request | [
"Update",
"tern",
"with",
"the",
"new",
"contents",
"of",
"a",
"given",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L885-L895 | train | update Tern file | [
30522,
3853,
10651,
16451,
8873,
2571,
1006,
6254,
1007,
1063,
13075,
4130,
1027,
6254,
1012,
5371,
1012,
2440,
15069,
1025,
1035,
2695,
7834,
3736,
3351,
3762,
15194,
1006,
1063,
2828,
1024,
4471,
9821,
1012,
28774,
2078,
1035,
10651,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | moveLine | function moveLine(editor, direction) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
var doc = editor.document,
lineSelections = editor.convertToLineSelections(editor.getSelections()),
isInlineWidget = !!EditorManager.getFocusedInlineWidget(),
firstLine = editor.getFirstVisibleLine(),
lastLine = editor.getLastVisibleLine(),
totalLines = editor.lineCount(),
lineLength = 0,
edits = [],
newSels = [],
pos = {};
_.each(lineSelections, function (lineSel) {
var sel = lineSel.selectionForEdit,
editGroup = [];
// Make the move
switch (direction) {
case DIRECTION_UP:
if (sel.start.line !== firstLine) {
var prevText = doc.getRange({ line: sel.start.line - 1, ch: 0 }, sel.start);
if (sel.end.line === lastLine + 1) {
if (isInlineWidget) {
prevText = prevText.substring(0, prevText.length - 1);
lineLength = doc.getLine(sel.end.line - 1).length;
editGroup.push({text: "\n", start: { line: sel.end.line - 1, ch: lineLength }});
} else {
prevText = "\n" + prevText.substring(0, prevText.length - 1);
}
}
editGroup.push({text: "", start: { line: sel.start.line - 1, ch: 0 }, end: sel.start});
editGroup.push({text: prevText, start: { line: sel.end.line - 1, ch: 0 }});
// Make sure CodeMirror hasn't expanded the selection to include
// the line we inserted below.
_.each(lineSel.selectionsToTrack, function (originalSel) {
originalSel.start.line--;
originalSel.end.line--;
});
edits.push({edit: editGroup, selection: lineSel.selectionsToTrack});
}
break;
case DIRECTION_DOWN:
if (sel.end.line <= lastLine) {
var nextText = doc.getRange(sel.end, { line: sel.end.line + 1, ch: 0 }),
deletionStart = sel.end;
if (sel.end.line === lastLine) {
if (isInlineWidget) {
if (sel.end.line === totalLines - 1) {
nextText += "\n";
}
lineLength = doc.getLine(sel.end.line - 1).length;
editGroup.push({text: "\n", start: { line: sel.end.line, ch: doc.getLine(sel.end.line).length }});
} else {
nextText += "\n";
deletionStart = { line: sel.end.line - 1, ch: doc.getLine(sel.end.line - 1).length };
}
}
editGroup.push({text: "", start: deletionStart, end: { line: sel.end.line + 1, ch: 0 }});
if (lineLength) {
editGroup.push({text: "", start: { line: sel.end.line - 1, ch: lineLength }, end: { line: sel.end.line, ch: 0 }});
}
editGroup.push({text: nextText, start: { line: sel.start.line, ch: 0 }});
// In this case, we don't need to track selections, because the edits are done in such a way that
// the existing selections will automatically be updated properly by CodeMirror as it does the edits.
edits.push({edit: editGroup});
}
break;
}
});
// Make sure selections are correct and primary selection is scrolled into view
if (edits.length) {
newSels = doc.doMultipleEdits(edits);
pos.ch = 0;
if (direction === DIRECTION_UP) {
editor.setSelections(newSels);
pos.line = editor.getSelection().start.line;
} else if (direction === DIRECTION_DOWN) {
pos.line = editor.getSelection().end.line;
} else {
console.error("EditorCommandHandler.moveLine() called with invalid argument 'direction' = %d", direction);
pos = null;
}
editor._codeMirror.scrollIntoView(pos);
}
} | javascript | function moveLine(editor, direction) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
var doc = editor.document,
lineSelections = editor.convertToLineSelections(editor.getSelections()),
isInlineWidget = !!EditorManager.getFocusedInlineWidget(),
firstLine = editor.getFirstVisibleLine(),
lastLine = editor.getLastVisibleLine(),
totalLines = editor.lineCount(),
lineLength = 0,
edits = [],
newSels = [],
pos = {};
_.each(lineSelections, function (lineSel) {
var sel = lineSel.selectionForEdit,
editGroup = [];
// Make the move
switch (direction) {
case DIRECTION_UP:
if (sel.start.line !== firstLine) {
var prevText = doc.getRange({ line: sel.start.line - 1, ch: 0 }, sel.start);
if (sel.end.line === lastLine + 1) {
if (isInlineWidget) {
prevText = prevText.substring(0, prevText.length - 1);
lineLength = doc.getLine(sel.end.line - 1).length;
editGroup.push({text: "\n", start: { line: sel.end.line - 1, ch: lineLength }});
} else {
prevText = "\n" + prevText.substring(0, prevText.length - 1);
}
}
editGroup.push({text: "", start: { line: sel.start.line - 1, ch: 0 }, end: sel.start});
editGroup.push({text: prevText, start: { line: sel.end.line - 1, ch: 0 }});
// Make sure CodeMirror hasn't expanded the selection to include
// the line we inserted below.
_.each(lineSel.selectionsToTrack, function (originalSel) {
originalSel.start.line--;
originalSel.end.line--;
});
edits.push({edit: editGroup, selection: lineSel.selectionsToTrack});
}
break;
case DIRECTION_DOWN:
if (sel.end.line <= lastLine) {
var nextText = doc.getRange(sel.end, { line: sel.end.line + 1, ch: 0 }),
deletionStart = sel.end;
if (sel.end.line === lastLine) {
if (isInlineWidget) {
if (sel.end.line === totalLines - 1) {
nextText += "\n";
}
lineLength = doc.getLine(sel.end.line - 1).length;
editGroup.push({text: "\n", start: { line: sel.end.line, ch: doc.getLine(sel.end.line).length }});
} else {
nextText += "\n";
deletionStart = { line: sel.end.line - 1, ch: doc.getLine(sel.end.line - 1).length };
}
}
editGroup.push({text: "", start: deletionStart, end: { line: sel.end.line + 1, ch: 0 }});
if (lineLength) {
editGroup.push({text: "", start: { line: sel.end.line - 1, ch: lineLength }, end: { line: sel.end.line, ch: 0 }});
}
editGroup.push({text: nextText, start: { line: sel.start.line, ch: 0 }});
// In this case, we don't need to track selections, because the edits are done in such a way that
// the existing selections will automatically be updated properly by CodeMirror as it does the edits.
edits.push({edit: editGroup});
}
break;
}
});
// Make sure selections are correct and primary selection is scrolled into view
if (edits.length) {
newSels = doc.doMultipleEdits(edits);
pos.ch = 0;
if (direction === DIRECTION_UP) {
editor.setSelections(newSels);
pos.line = editor.getSelection().start.line;
} else if (direction === DIRECTION_DOWN) {
pos.line = editor.getSelection().end.line;
} else {
console.error("EditorCommandHandler.moveLine() called with invalid argument 'direction' = %d", direction);
pos = null;
}
editor._codeMirror.scrollIntoView(pos);
}
} | [
"function",
"moveLine",
"(",
"editor",
",",
"direction",
")",
"{",
"editor",
"=",
"editor",
"||",
"EditorManager",
".",
"getFocusedEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"var",
"doc",
"=",
"editor",
".",
"docume... | Moves the selected text, or current line if no selection. The cursor/selection
moves with the line/lines.
@param {Editor} editor - target editor
@param {Number} direction - direction of the move (-1,+1) => (Up,Down) | [
"Moves",
"the",
"selected",
"text",
"or",
"current",
"line",
"if",
"no",
"selection",
".",
"The",
"cursor",
"/",
"selection",
"moves",
"with",
"the",
"line",
"/",
"lines",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L826-L926 | train | Move a line in the editor | [
30522,
3853,
2693,
4179,
1006,
3559,
1010,
3257,
1007,
1063,
3559,
1027,
3559,
1064,
1064,
3559,
24805,
4590,
1012,
2131,
14876,
7874,
19082,
15660,
1006,
1007,
1025,
2065,
1006,
999,
3559,
1007,
1063,
2709,
1025,
1065,
13075,
9986,
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... |
vuejs/vuepress | packages/@vuepress/markdown/lib/tableOfContents.js | vBindEscape | function vBindEscape (strs, ...args) {
return strs.reduce((prev, curr, index) => {
return prev + curr + (index >= args.length
? ''
: `"${JSON.stringify(args[index])
.replace(/"/g, "'")
.replace(/([^\\])(\\\\)*\\'/g, (_, char) => char + '\\u0022')}"`)
}, '')
} | javascript | function vBindEscape (strs, ...args) {
return strs.reduce((prev, curr, index) => {
return prev + curr + (index >= args.length
? ''
: `"${JSON.stringify(args[index])
.replace(/"/g, "'")
.replace(/([^\\])(\\\\)*\\'/g, (_, char) => char + '\\u0022')}"`)
}, '')
} | [
"function",
"vBindEscape",
"(",
"strs",
",",
"...",
"args",
")",
"{",
"return",
"strs",
".",
"reduce",
"(",
"(",
"prev",
",",
"curr",
",",
"index",
")",
"=>",
"{",
"return",
"prev",
"+",
"curr",
"+",
"(",
"index",
">=",
"args",
".",
"length",
"?",
... | escape double quotes in v-bind derivatives | [
"escape",
"double",
"quotes",
"in",
"v",
"-",
"bind",
"derivatives"
] | 15784acc0cf2e87de3c147895b2c3977b0195d78 | https://github.com/vuejs/vuepress/blob/15784acc0cf2e87de3c147895b2c3977b0195d78/packages/@vuepress/markdown/lib/tableOfContents.js#L75-L83 | train | vBindEscape - escape a string | [
30522,
3853,
1058,
8428,
6155,
19464,
1006,
2358,
2869,
1010,
1012,
1012,
1012,
12098,
5620,
1007,
1063,
2709,
2358,
2869,
1012,
5547,
1006,
1006,
3653,
2615,
1010,
12731,
12171,
1010,
5950,
1007,
1027,
1028,
1063,
2709,
3653,
2615,
1009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
benweet/stackedit | server/pdf.js | waitForJavaScript | function waitForJavaScript() {
if (window.MathJax) {
// Amazon EC2: fix TeX font detection
MathJax.Hub.Register.StartupHook('HTML-CSS Jax Startup', function () {
var htmlCss = MathJax.OutputJax['HTML-CSS'];
htmlCss.Font.checkWebFont = function (check, font, callback) {
if (check.time(callback)) {
return;
}
if (check.total === 0) {
htmlCss.Font.testFont(font);
setTimeout(check, 200);
} else {
callback(check.STATUS.OK);
}
};
});
MathJax.Hub.Queue(function () {
window.status = 'done';
});
} else {
setTimeout(function () {
window.status = 'done';
}, 2000);
}
} | javascript | function waitForJavaScript() {
if (window.MathJax) {
// Amazon EC2: fix TeX font detection
MathJax.Hub.Register.StartupHook('HTML-CSS Jax Startup', function () {
var htmlCss = MathJax.OutputJax['HTML-CSS'];
htmlCss.Font.checkWebFont = function (check, font, callback) {
if (check.time(callback)) {
return;
}
if (check.total === 0) {
htmlCss.Font.testFont(font);
setTimeout(check, 200);
} else {
callback(check.STATUS.OK);
}
};
});
MathJax.Hub.Queue(function () {
window.status = 'done';
});
} else {
setTimeout(function () {
window.status = 'done';
}, 2000);
}
} | [
"function",
"waitForJavaScript",
"(",
")",
"{",
"if",
"(",
"window",
".",
"MathJax",
")",
"{",
"// Amazon EC2: fix TeX font detection",
"MathJax",
".",
"Hub",
".",
"Register",
".",
"StartupHook",
"(",
"'HTML-CSS Jax Startup'",
",",
"function",
"(",
")",
"{",
"va... | /* eslint-disable no-var, prefer-arrow-callback, func-names | [
"/",
"*",
"eslint",
"-",
"disable",
"no",
"-",
"var",
"prefer",
"-",
"arrow",
"-",
"callback",
"func",
"-",
"names"
] | 91f8cf3c10b75df65b69f9181cee8151d65a788d | https://github.com/benweet/stackedit/blob/91f8cf3c10b75df65b69f9181cee8151d65a788d/server/pdf.js#L8-L33 | train | Wait for JavaScript to be loaded | [
30522,
3853,
3524,
29278,
3900,
12044,
23235,
1006,
1007,
1063,
2065,
1006,
3332,
1012,
8785,
3900,
2595,
1007,
1063,
1013,
1013,
9733,
14925,
2475,
1024,
8081,
16060,
15489,
10788,
8785,
3900,
2595,
1012,
9594,
1012,
4236,
1012,
22752,
680... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-else-return.js | checkIfWithoutElse | function checkIfWithoutElse(node) {
const parent = node.parent;
/*
* Fixing this would require splitting one statement into two, so no error should
* be reported if this node is in a position where only one statement is allowed.
*/
if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
return;
}
const consequents = [];
let alternate;
for (let currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) {
if (!currentNode.alternate) {
return;
}
consequents.push(currentNode.consequent);
alternate = currentNode.alternate;
}
if (consequents.every(alwaysReturns)) {
displayReport(alternate);
}
} | javascript | function checkIfWithoutElse(node) {
const parent = node.parent;
/*
* Fixing this would require splitting one statement into two, so no error should
* be reported if this node is in a position where only one statement is allowed.
*/
if (!astUtils.STATEMENT_LIST_PARENTS.has(parent.type)) {
return;
}
const consequents = [];
let alternate;
for (let currentNode = node; currentNode.type === "IfStatement"; currentNode = currentNode.alternate) {
if (!currentNode.alternate) {
return;
}
consequents.push(currentNode.consequent);
alternate = currentNode.alternate;
}
if (consequents.every(alwaysReturns)) {
displayReport(alternate);
}
} | [
"function",
"checkIfWithoutElse",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"/*\n * Fixing this would require splitting one statement into two, so no error should\n * be reported if this node is in a position where only one statement... | Check the if statement, but don't catch else-if blocks.
@returns {void}
@param {Node} node The node for the if statement to check
@private | [
"Check",
"the",
"if",
"statement",
"but",
"don",
"t",
"catch",
"else",
"-",
"if",
"blocks",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-else-return.js#L220-L245 | train | Check if node is not a if statement | [
30522,
3853,
4638,
10128,
24415,
5833,
9050,
2063,
1006,
13045,
1007,
1063,
9530,
3367,
6687,
1027,
13045,
1012,
6687,
1025,
1013,
1008,
1008,
15887,
2023,
2052,
5478,
14541,
2028,
4861,
2046,
2048,
1010,
2061,
2053,
7561,
2323,
1008,
2022,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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(elems)
{
// Known block elements for handling linefeeds (list is not complete)
var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
var ret = [];
function doExtract(elts)
{
// Single break should be ignored
if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
elts[0].innerHTML == '\n'))
{
return;
}
for (var i = 0; i < elts.length; i++)
{
var elem = elts[i];
// DIV with a br or linefeed forces a linefeed
if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
elem.innerHTML.toLowerCase() == '<br>')))
{
ret.push('\n');
}
else
{
if (elem.nodeType === 3 || elem.nodeType === 4)
{
if (elem.nodeValue.length > 0)
{
ret.push(elem.nodeValue);
}
}
else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
{
doExtract(elem.childNodes);
}
if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
{
ret.push('\n');
}
}
}
};
doExtract(elems);
return ret.join('');
} | javascript | function(elems)
{
// Known block elements for handling linefeeds (list is not complete)
var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
var ret = [];
function doExtract(elts)
{
// Single break should be ignored
if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
elts[0].innerHTML == '\n'))
{
return;
}
for (var i = 0; i < elts.length; i++)
{
var elem = elts[i];
// DIV with a br or linefeed forces a linefeed
if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
elem.innerHTML.toLowerCase() == '<br>')))
{
ret.push('\n');
}
else
{
if (elem.nodeType === 3 || elem.nodeType === 4)
{
if (elem.nodeValue.length > 0)
{
ret.push(elem.nodeValue);
}
}
else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
{
doExtract(elem.childNodes);
}
if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
{
ret.push('\n');
}
}
}
};
doExtract(elems);
return ret.join('');
} | [
"function",
"(",
"elems",
")",
"{",
"// Known block elements for handling linefeeds (list is not complete)",
"var",
"blocks",
"=",
"[",
"'BLOCKQUOTE'",
",",
"'DIV'",
",",
"'H1'",
",",
"'H2'",
",",
"'H3'",
",",
"'H4'",
",",
"'H5'",
",",
"'H6'",
",",
"'OL'",
",",
... | Function: extractTextWithWhitespace
Returns the text content of the specified node.
Parameters:
elems - DOM nodes to return the text for. | [
"Function",
":",
"extractTextWithWhitespace"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3006-L3057 | train | Returns an array of elements that are not part of a block | [
30522,
3853,
1006,
3449,
6633,
2015,
1007,
1063,
1013,
1013,
2124,
3796,
3787,
2005,
8304,
2240,
7959,
2098,
2015,
1006,
2862,
2003,
2025,
3143,
1007,
13075,
5991,
1027,
1031,
1005,
3796,
28940,
12184,
1005,
1010,
1005,
4487,
2615,
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... | |
GitbookIO/gitbook | lib/output/generatePages.js | generatePages | function generatePages(generator, output) {
var pages = output.getPages();
var logger = output.getLogger();
// Is generator ignoring assets?
if (!generator.onPage) {
return Promise(output);
}
return Promise.reduce(pages, function(out, page) {
var file = page.getFile();
logger.debug.ln('generate page "' + file.getPath() + '"');
return generatePage(out, page)
.then(function(resultPage) {
return generator.onPage(out, resultPage);
})
.fail(function(err) {
logger.error.ln('error while generating page "' + file.getPath() + '":');
throw err;
});
}, output);
} | javascript | function generatePages(generator, output) {
var pages = output.getPages();
var logger = output.getLogger();
// Is generator ignoring assets?
if (!generator.onPage) {
return Promise(output);
}
return Promise.reduce(pages, function(out, page) {
var file = page.getFile();
logger.debug.ln('generate page "' + file.getPath() + '"');
return generatePage(out, page)
.then(function(resultPage) {
return generator.onPage(out, resultPage);
})
.fail(function(err) {
logger.error.ln('error while generating page "' + file.getPath() + '":');
throw err;
});
}, output);
} | [
"function",
"generatePages",
"(",
"generator",
",",
"output",
")",
"{",
"var",
"pages",
"=",
"output",
".",
"getPages",
"(",
")",
";",
"var",
"logger",
"=",
"output",
".",
"getLogger",
"(",
")",
";",
"// Is generator ignoring assets?",
"if",
"(",
"!",
"gen... | Output all pages using a generator
@param {Generator} generator
@param {Output} output
@return {Promise<Output>} | [
"Output",
"all",
"pages",
"using",
"a",
"generator"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/generatePages.js#L11-L34 | train | Generate pages from generator | [
30522,
3853,
9699,
13704,
2015,
1006,
13103,
1010,
6434,
1007,
1063,
13075,
5530,
1027,
6434,
1012,
2131,
13704,
2015,
1006,
1007,
1025,
13075,
8833,
4590,
1027,
6434,
1012,
2131,
21197,
4590,
1006,
1007,
1025,
1013,
1013,
2003,
13103,
9217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
feathericons/feather | src/to-svg.js | toSvg | function toSvg(name, attrs = {}) {
console.warn(
'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',
);
if (!name) {
throw new Error('The required `key` (icon name) parameter is missing.');
}
if (!icons[name]) {
throw new Error(
`No icon matching '${
name
}'. See the complete list of icons at https://feathericons.com`,
);
}
return icons[name].toSvg(attrs);
} | javascript | function toSvg(name, attrs = {}) {
console.warn(
'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.',
);
if (!name) {
throw new Error('The required `key` (icon name) parameter is missing.');
}
if (!icons[name]) {
throw new Error(
`No icon matching '${
name
}'. See the complete list of icons at https://feathericons.com`,
);
}
return icons[name].toSvg(attrs);
} | [
"function",
"toSvg",
"(",
"name",
",",
"attrs",
"=",
"{",
"}",
")",
"{",
"console",
".",
"warn",
"(",
"'feather.toSvg() is deprecated. Please use feather.icons[name].toSvg() instead.'",
",",
")",
";",
"if",
"(",
"!",
"name",
")",
"{",
"throw",
"new",
"Error",
... | Create an SVG string.
@deprecated
@param {string} name
@param {Object} attrs
@returns {string} | [
"Create",
"an",
"SVG",
"string",
"."
] | 8f658193d25e943b196a2367319b5d9e85ee9f9f | https://github.com/feathericons/feather/blob/8f658193d25e943b196a2367319b5d9e85ee9f9f/src/to-svg.js#L10-L28 | train | Returns an svg string for the specified icon | [
30522,
3853,
2000,
2015,
2615,
2290,
1006,
2171,
1010,
2012,
16344,
2015,
1027,
30524,
2290,
1006,
1007,
2003,
2139,
28139,
12921,
1012,
3531,
2224,
15550,
1012,
18407,
1031,
2171,
1033,
1012,
2000,
2015,
2615,
2290,
1006,
1007,
2612,
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... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/ui-element.js | UIArgument | function UIArgument(uiArgumentShorthand, localVars)
{
/**
* @param uiArgumentShorthand
*
* @throws UIArgumentException
*/
this.validate = function(uiArgumentShorthand)
{
var msg = "UIArgument validation error:\n"
+ print_r(uiArgumentShorthand);
// try really hard to throw an exception!
if (!uiArgumentShorthand.name) {
throw new UIArgumentException(msg + 'no name specified!');
}
if (!uiArgumentShorthand.description) {
throw new UIArgumentException(msg + 'no description specified!');
}
if (!uiArgumentShorthand.defaultValues &&
!uiArgumentShorthand.getDefaultValues) {
throw new UIArgumentException(msg + 'no default values specified!');
}
};
/**
* @param uiArgumentShorthand
* @param localVars a list of local variables
*/
this.init = function(uiArgumentShorthand, localVars)
{
this.validate(uiArgumentShorthand);
this.name = uiArgumentShorthand.name;
this.description = uiArgumentShorthand.description;
this.required = uiArgumentShorthand.required || false;
if (uiArgumentShorthand.defaultValues) {
var defaultValues = uiArgumentShorthand.defaultValues;
this.getDefaultValues =
function() { return defaultValues; }
}
else {
this.getDefaultValues = uiArgumentShorthand.getDefaultValues;
}
for (var name in localVars) {
this[name] = localVars[name];
}
}
this.init(uiArgumentShorthand, localVars);
} | javascript | function UIArgument(uiArgumentShorthand, localVars)
{
/**
* @param uiArgumentShorthand
*
* @throws UIArgumentException
*/
this.validate = function(uiArgumentShorthand)
{
var msg = "UIArgument validation error:\n"
+ print_r(uiArgumentShorthand);
// try really hard to throw an exception!
if (!uiArgumentShorthand.name) {
throw new UIArgumentException(msg + 'no name specified!');
}
if (!uiArgumentShorthand.description) {
throw new UIArgumentException(msg + 'no description specified!');
}
if (!uiArgumentShorthand.defaultValues &&
!uiArgumentShorthand.getDefaultValues) {
throw new UIArgumentException(msg + 'no default values specified!');
}
};
/**
* @param uiArgumentShorthand
* @param localVars a list of local variables
*/
this.init = function(uiArgumentShorthand, localVars)
{
this.validate(uiArgumentShorthand);
this.name = uiArgumentShorthand.name;
this.description = uiArgumentShorthand.description;
this.required = uiArgumentShorthand.required || false;
if (uiArgumentShorthand.defaultValues) {
var defaultValues = uiArgumentShorthand.defaultValues;
this.getDefaultValues =
function() { return defaultValues; }
}
else {
this.getDefaultValues = uiArgumentShorthand.getDefaultValues;
}
for (var name in localVars) {
this[name] = localVars[name];
}
}
this.init(uiArgumentShorthand, localVars);
} | [
"function",
"UIArgument",
"(",
"uiArgumentShorthand",
",",
"localVars",
")",
"{",
"/**\n * @param uiArgumentShorthand\n *\n * @throws UIArgumentException\n */",
"this",
".",
"validate",
"=",
"function",
"(",
"uiArgumentShorthand",
")",
"{",
"var",
"msg",
"=",... | Constructs a UIArgument. This is mostly for checking that the values are
valid.
@param uiArgumentShorthand
@param localVars
@throws UIArgumentException | [
"Constructs",
"a",
"UIArgument",
".",
"This",
"is",
"mostly",
"for",
"checking",
"that",
"the",
"values",
"are",
"valid",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L530-L586 | train | UIArgument constructor. | [
30522,
3853,
21318,
2906,
22850,
4765,
1006,
21318,
2906,
22850,
11187,
27794,
11774,
1010,
2334,
10755,
2015,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
11498,
2213,
21318,
2906,
22850,
11187,
27794,
11774,
1008,
1008,
1030,
11618,
21318,
290... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/StringUtils.js | breakableUrl | function breakableUrl(url) {
// This is for displaying in UI, so always want it escaped
var escUrl = _.escape(url);
// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
return escUrl.replace(
new RegExp(regexEscape("/"), "g"),
"/" + "​"
);
} | javascript | function breakableUrl(url) {
// This is for displaying in UI, so always want it escaped
var escUrl = _.escape(url);
// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there
return escUrl.replace(
new RegExp(regexEscape("/"), "g"),
"/" + "​"
);
} | [
"function",
"breakableUrl",
"(",
"url",
")",
"{",
"// This is for displaying in UI, so always want it escaped",
"var",
"escUrl",
"=",
"_",
".",
"escape",
"(",
"url",
")",
";",
"// Inject zero-width space character (U+200B) near path separators (/) to allow line breaking there",
"... | Return an escaped path or URL string that can be broken near path separators.
@param {string} url the path or URL to format
@return {string} the formatted path or URL | [
"Return",
"an",
"escaped",
"path",
"or",
"URL",
"string",
"that",
"can",
"be",
"broken",
"near",
"path",
"separators",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L166-L175 | train | Break a URL into a line breakable | [
30522,
3853,
3338,
3085,
3126,
2140,
1006,
24471,
2140,
1007,
1063,
1013,
1013,
2023,
2003,
2005,
14962,
1999,
21318,
1010,
2061,
2467,
2215,
2009,
6376,
13075,
9686,
10841,
12190,
1027,
1035,
1012,
4019,
1006,
24471,
2140,
1007,
1025,
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... |
grpc/grpc | examples/node/static_codegen/route_guide/route_guide_server.js | recordRoute | function recordRoute(call, callback) {
var point_count = 0;
var feature_count = 0;
var distance = 0;
var previous = null;
// Start a timer
var start_time = process.hrtime();
call.on('data', function(point) {
point_count += 1;
if (checkFeature(point).name !== '') {
feature_count += 1;
}
/* For each point after the first, add the incremental distance from the
* previous point to the total distance value */
if (previous != null) {
distance += getDistance(previous, point);
}
previous = point;
});
call.on('end', function() {
var summary = new messages.RouteSummary();
summary.setPointCount(point_count);
summary.setFeatureCount(feature_count);
// Cast the distance to an integer
summary.setDistance(distance|0);
// End the timer
summary.setElapsedTime(process.hrtime(start_time)[0]);
callback(null, summary);
});
} | javascript | function recordRoute(call, callback) {
var point_count = 0;
var feature_count = 0;
var distance = 0;
var previous = null;
// Start a timer
var start_time = process.hrtime();
call.on('data', function(point) {
point_count += 1;
if (checkFeature(point).name !== '') {
feature_count += 1;
}
/* For each point after the first, add the incremental distance from the
* previous point to the total distance value */
if (previous != null) {
distance += getDistance(previous, point);
}
previous = point;
});
call.on('end', function() {
var summary = new messages.RouteSummary();
summary.setPointCount(point_count);
summary.setFeatureCount(feature_count);
// Cast the distance to an integer
summary.setDistance(distance|0);
// End the timer
summary.setElapsedTime(process.hrtime(start_time)[0]);
callback(null, summary);
});
} | [
"function",
"recordRoute",
"(",
"call",
",",
"callback",
")",
"{",
"var",
"point_count",
"=",
"0",
";",
"var",
"feature_count",
"=",
"0",
";",
"var",
"distance",
"=",
"0",
";",
"var",
"previous",
"=",
"null",
";",
"// Start a timer",
"var",
"start_time",
... | recordRoute handler. Gets a stream of points, and responds with statistics
about the "trip": number of points, number of known features visited, total
distance traveled, and total time spent.
@param {Readable} call The request point stream.
@param {function(Error, routeSummary)} callback The callback to pass the
response to | [
"recordRoute",
"handler",
".",
"Gets",
"a",
"stream",
"of",
"points",
"and",
"responds",
"with",
"statistics",
"about",
"the",
"trip",
":",
"number",
"of",
"points",
"number",
"of",
"known",
"features",
"visited",
"total",
"distance",
"traveled",
"and",
"total... | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/static_codegen/route_guide/route_guide_server.js#L137-L166 | train | Record a route | [
30522,
3853,
2501,
22494,
2618,
1006,
2655,
1010,
2655,
5963,
1007,
1063,
13075,
2391,
1035,
4175,
1027,
1014,
1025,
13075,
3444,
1035,
4175,
1027,
1014,
1025,
13075,
3292,
1027,
30524,
4017,
5397,
1006,
2391,
1007,
1012,
2171,
999,
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/extensions/default/AutoUpdate/main.js | checkInstallationStatus | function checkInstallationStatus() {
var searchParams = {
"updateDir": updateDir,
"installErrorStr": ["ERROR:"],
"bracketsErrorStr": ["ERROR:"],
"encoding": "utf8"
},
// Below are the possible Windows Installer error strings, which will be searched for in the installer logs to track failures.
winInstallErrorStrArr = [
"Installation success or error status",
"Reconfiguration success or error status"
];
if (brackets.platform === "win") {
searchParams.installErrorStr = winInstallErrorStrArr;
searchParams.encoding = "utf16le";
}
postMessageToNode(MessageIds.CHECK_INSTALLER_STATUS, searchParams);
} | javascript | function checkInstallationStatus() {
var searchParams = {
"updateDir": updateDir,
"installErrorStr": ["ERROR:"],
"bracketsErrorStr": ["ERROR:"],
"encoding": "utf8"
},
// Below are the possible Windows Installer error strings, which will be searched for in the installer logs to track failures.
winInstallErrorStrArr = [
"Installation success or error status",
"Reconfiguration success or error status"
];
if (brackets.platform === "win") {
searchParams.installErrorStr = winInstallErrorStrArr;
searchParams.encoding = "utf16le";
}
postMessageToNode(MessageIds.CHECK_INSTALLER_STATUS, searchParams);
} | [
"function",
"checkInstallationStatus",
"(",
")",
"{",
"var",
"searchParams",
"=",
"{",
"\"updateDir\"",
":",
"updateDir",
",",
"\"installErrorStr\"",
":",
"[",
"\"ERROR:\"",
"]",
",",
"\"bracketsErrorStr\"",
":",
"[",
"\"ERROR:\"",
"]",
",",
"\"encoding\"",
":",
... | Checks Install failure scenarios | [
"Checks",
"Install",
"failure",
"scenarios"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L197-L214 | train | Check installation status | [
30522,
3853,
4638,
7076,
9080,
13490,
9153,
5809,
1006,
1007,
1063,
13075,
3945,
28689,
5244,
1027,
1063,
1000,
7172,
4313,
1000,
1024,
7172,
4313,
1010,
1000,
16500,
2121,
29165,
3367,
2099,
1000,
1024,
1031,
1000,
7561,
1024,
1000,
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... |
expressjs/express | examples/error/index.js | error | function error(err, req, res, next) {
// log it
if (!test) console.error(err.stack);
// respond with 500 "Internal Server Error".
res.status(500);
res.send('Internal Server Error');
} | javascript | function error(err, req, res, next) {
// log it
if (!test) console.error(err.stack);
// respond with 500 "Internal Server Error".
res.status(500);
res.send('Internal Server Error');
} | [
"function",
"error",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"// log it",
"if",
"(",
"!",
"test",
")",
"console",
".",
"error",
"(",
"err",
".",
"stack",
")",
";",
"// respond with 500 \"Internal Server Error\".",
"res",
".",
"status",
... | error handling middleware have an arity of 4 instead of the typical (req, res, next), otherwise they behave exactly like regular middleware, you may have several of them, in different orders etc. | [
"error",
"handling",
"middleware",
"have",
"an",
"arity",
"of",
"4",
"instead",
"of",
"the",
"typical",
"(",
"req",
"res",
"next",
")",
"otherwise",
"they",
"behave",
"exactly",
"like",
"regular",
"middleware",
"you",
"may",
"have",
"several",
"of",
"them",
... | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/examples/error/index.js#L18-L25 | train | error handler for the request | [
30522,
3853,
7561,
1006,
9413,
2099,
1010,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
8833,
2009,
2065,
1006,
999,
3231,
1007,
10122,
1012,
7561,
1006,
9413,
2099,
1012,
9991,
1007,
1025,
1013,
1013,
6869,
2007,
3156,
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... |
NetEase/pomelo | lib/connectors/hybrid/tcpsocket.js | function(socket, opts) {
if(!(this instanceof Socket)) {
return new Socket(socket, opts);
}
if(!socket || !opts) {
throw new Error('invalid socket or opts');
}
if(!opts.headSize || typeof opts.headHandler !== 'function') {
throw new Error('invalid opts.headSize or opts.headHandler');
}
// stream style interfaces.
// TODO: need to port to stream2 after node 0.9
Stream.call(this);
this.readable = true;
this.writeable = true;
this._socket = socket;
this.headSize = opts.headSize;
this.closeMethod = opts.closeMethod;
this.headBuffer = new Buffer(opts.headSize);
this.headHandler = opts.headHandler;
this.headOffset = 0;
this.packageOffset = 0;
this.packageSize = 0;
this.packageBuffer = null;
// bind event form the origin socket
this._socket.on('data', ondata.bind(null, this));
this._socket.on('end', onend.bind(null, this));
this._socket.on('error', this.emit.bind(this, 'error'));
this._socket.on('close', this.emit.bind(this, 'close'));
this.state = ST_HEAD;
} | javascript | function(socket, opts) {
if(!(this instanceof Socket)) {
return new Socket(socket, opts);
}
if(!socket || !opts) {
throw new Error('invalid socket or opts');
}
if(!opts.headSize || typeof opts.headHandler !== 'function') {
throw new Error('invalid opts.headSize or opts.headHandler');
}
// stream style interfaces.
// TODO: need to port to stream2 after node 0.9
Stream.call(this);
this.readable = true;
this.writeable = true;
this._socket = socket;
this.headSize = opts.headSize;
this.closeMethod = opts.closeMethod;
this.headBuffer = new Buffer(opts.headSize);
this.headHandler = opts.headHandler;
this.headOffset = 0;
this.packageOffset = 0;
this.packageSize = 0;
this.packageBuffer = null;
// bind event form the origin socket
this._socket.on('data', ondata.bind(null, this));
this._socket.on('end', onend.bind(null, this));
this._socket.on('error', this.emit.bind(this, 'error'));
this._socket.on('close', this.emit.bind(this, 'close'));
this.state = ST_HEAD;
} | [
"function",
"(",
"socket",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Socket",
")",
")",
"{",
"return",
"new",
"Socket",
"(",
"socket",
",",
"opts",
")",
";",
"}",
"if",
"(",
"!",
"socket",
"||",
"!",
"opts",
")",
"{",
"... | closed
Tcp socket wrapper with package compositing.
Collect the package from socket and emit a completed package with 'data' event.
Uniform with ws.WebSocket interfaces.
@param {Object} socket origin socket from node.js net module
@param {Object} opts options parameter.
opts.headSize size of package head
opts.headHandler(headBuffer) handler for package head. caculate and return body size from head data. | [
"closed",
"Tcp",
"socket",
"wrapper",
"with",
"package",
"compositing",
".",
"Collect",
"the",
"package",
"from",
"socket",
"and",
"emit",
"a",
"completed",
"package",
"with",
"data",
"event",
".",
"Uniform",
"with",
"ws",
".",
"WebSocket",
"interfaces",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/connectors/hybrid/tcpsocket.js#L24-L61 | train | A stream that can be used to send a message to the remote node. | [
30522,
3853,
1006,
22278,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
999,
1006,
2023,
6013,
11253,
22278,
1007,
1007,
1063,
2709,
2047,
22278,
1006,
22278,
1010,
23569,
2015,
1007,
1025,
1065,
2065,
1006,
999,
22278,
1064,
1064,
999,
23569,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
aws/aws-sdk-js | lib/publisher/configuration.js | fromEnvironment | function fromEnvironment(config) {
config.port = config.port || process.env.AWS_CSM_PORT;
config.enabled = config.enabled || process.env.AWS_CSM_ENABLED;
config.clientId = config.clientId || process.env.AWS_CSM_CLIENT_ID;
return config.port && config.enabled && config.clientId ||
['false', '0'].indexOf(config.enabled) >= 0; //no need to read shared config file if explicitely disabled
} | javascript | function fromEnvironment(config) {
config.port = config.port || process.env.AWS_CSM_PORT;
config.enabled = config.enabled || process.env.AWS_CSM_ENABLED;
config.clientId = config.clientId || process.env.AWS_CSM_CLIENT_ID;
return config.port && config.enabled && config.clientId ||
['false', '0'].indexOf(config.enabled) >= 0; //no need to read shared config file if explicitely disabled
} | [
"function",
"fromEnvironment",
"(",
"config",
")",
"{",
"config",
".",
"port",
"=",
"config",
".",
"port",
"||",
"process",
".",
"env",
".",
"AWS_CSM_PORT",
";",
"config",
".",
"enabled",
"=",
"config",
".",
"enabled",
"||",
"process",
".",
"env",
".",
... | Resolve configurations from environmental variables.
@param {object} client side monitoring config object needs to be resolved
@returns {boolean} whether resolving configurations is done
@api private | [
"Resolve",
"configurations",
"from",
"environmental",
"variables",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L26-L32 | train | Get the configuration from the environment | [
30522,
3853,
2013,
2368,
21663,
2239,
3672,
1006,
9530,
8873,
2290,
1007,
1063,
9530,
8873,
2290,
1012,
3417,
1027,
9530,
8873,
2290,
1012,
3417,
1064,
1064,
2832,
1012,
4372,
2615,
1012,
22091,
2015,
1035,
20116,
2213,
1035,
3417,
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... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | XPathEvaluator | function XPathEvaluator(newDefaultEngineName) {
// private
var nativeEngine = new NativeEngine();
var defaultEngineName = newDefaultEngineName || 'ajaxslt';
var engines = {
'ajaxslt' : new AjaxsltEngine(),
'javascript-xpath' : new JavascriptXPathEngine(),
'rpc-optimizing-ajaxslt': new MultiWindowRPCOptimizingEngine('test-doc-frame', new AjaxsltEngine()),
'rpc-optimizing-jsxpath': new MultiWindowRPCOptimizingEngine('test-doc-frame', new JavascriptXPathEngine()),
'native' : nativeEngine
};
var currentEngineName = defaultEngineName;
var allowNativeXPath = true;
var ignoreAttributesWithoutValue = true;
function preprocess(xpath) {
// Trim any trailing "/": not valid xpath, and remains from attribute
// locator.
if (xpath.charAt(xpath.length - 1) == '/') {
xpath = xpath.slice(0, -1);
}
// HUGE hack - remove namespace from xpath for IE
if (browserVersion && browserVersion.isIE) {
xpath = xpath.replace(/x:/g, '')
}
return xpath;
}
/**
* Returns the most sensible engine given the settings and the document
* object.
*/
function getEngineFor(inDocument) {
if (allowNativeXPath &&
nativeEngine.setDocument(inDocument).isAvailable()) {
return nativeEngine;
}
var currentEngine = engines[currentEngineName];
if (currentEngine &&
currentEngine.setDocument(inDocument).isAvailable()) {
return currentEngine;
}
return engines[defaultEngineName].setDocument(inDocument);
}
/**
* Dispatches an XPath evaluation method on the relevant engine for the
* given document, and returns the result
*/
function dispatch(methodName, inDocument, xpath, contextNode, namespaceResolver) {
xpath = preprocess(xpath);
if (! contextNode) {
contextNode = inDocument;
}
var result = getEngineFor(inDocument)
.setIgnoreAttributesWithoutValue(ignoreAttributesWithoutValue)
[methodName](xpath, contextNode, namespaceResolver);
return result;
}
// public
/**
* Registers a new engine by name, and returns whether the registration was
* successful. Each registered engine must be an instance of XPathEngine.
* The engines registered by default - "ajaxslt", "javascript-xpath",
* "native", and "default" - can't be overwritten.
*/
this.registerEngine = function(name, engine) {
// can't overwrite one of these
if (name == 'ajaxslt' ||
name == 'javascript-xpath' ||
name == 'native' ||
name == 'default') {
return false;
}
if (! (engine instanceof XPathEngine)) {
return false;
}
engines[name] = engine;
return true;
};
this.getRegisteredEngine = function(name) {
return engines[name];
};
this.setCurrentEngine = function(name) {
if (name == 'default') {
currentEngineName = defaultEngineName;
}
else if (! engines[name]) {
return;
}
else {
currentEngineName = name;
}
};
this.getCurrentEngine = function() {
return currentEngineName || defaultEngineName;
};
this.setAllowNativeXPath = function(allow) {
allowNativeXPath = allow;
};
this.isAllowNativeXPath = function() {
return allowNativeXPath;
};
this.setIgnoreAttributesWithoutValue = function(ignore) {
ignoreAttributesWithoutValue = ignore;
};
this.isIgnoreAttributesWithoutValue = function() {
return ignoreAttributesWithoutValue;
};
this.selectNodes = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('selectNodes', inDocument, xpath, contextNode,
namespaceResolver);
};
this.selectSingleNode = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('selectSingleNode', inDocument, xpath, contextNode,
namespaceResolver);
};
this.countNodes = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('countNodes', inDocument, xpath, contextNode,
namespaceResolver);
};
// initialization
this.init();
} | javascript | function XPathEvaluator(newDefaultEngineName) {
// private
var nativeEngine = new NativeEngine();
var defaultEngineName = newDefaultEngineName || 'ajaxslt';
var engines = {
'ajaxslt' : new AjaxsltEngine(),
'javascript-xpath' : new JavascriptXPathEngine(),
'rpc-optimizing-ajaxslt': new MultiWindowRPCOptimizingEngine('test-doc-frame', new AjaxsltEngine()),
'rpc-optimizing-jsxpath': new MultiWindowRPCOptimizingEngine('test-doc-frame', new JavascriptXPathEngine()),
'native' : nativeEngine
};
var currentEngineName = defaultEngineName;
var allowNativeXPath = true;
var ignoreAttributesWithoutValue = true;
function preprocess(xpath) {
// Trim any trailing "/": not valid xpath, and remains from attribute
// locator.
if (xpath.charAt(xpath.length - 1) == '/') {
xpath = xpath.slice(0, -1);
}
// HUGE hack - remove namespace from xpath for IE
if (browserVersion && browserVersion.isIE) {
xpath = xpath.replace(/x:/g, '')
}
return xpath;
}
/**
* Returns the most sensible engine given the settings and the document
* object.
*/
function getEngineFor(inDocument) {
if (allowNativeXPath &&
nativeEngine.setDocument(inDocument).isAvailable()) {
return nativeEngine;
}
var currentEngine = engines[currentEngineName];
if (currentEngine &&
currentEngine.setDocument(inDocument).isAvailable()) {
return currentEngine;
}
return engines[defaultEngineName].setDocument(inDocument);
}
/**
* Dispatches an XPath evaluation method on the relevant engine for the
* given document, and returns the result
*/
function dispatch(methodName, inDocument, xpath, contextNode, namespaceResolver) {
xpath = preprocess(xpath);
if (! contextNode) {
contextNode = inDocument;
}
var result = getEngineFor(inDocument)
.setIgnoreAttributesWithoutValue(ignoreAttributesWithoutValue)
[methodName](xpath, contextNode, namespaceResolver);
return result;
}
// public
/**
* Registers a new engine by name, and returns whether the registration was
* successful. Each registered engine must be an instance of XPathEngine.
* The engines registered by default - "ajaxslt", "javascript-xpath",
* "native", and "default" - can't be overwritten.
*/
this.registerEngine = function(name, engine) {
// can't overwrite one of these
if (name == 'ajaxslt' ||
name == 'javascript-xpath' ||
name == 'native' ||
name == 'default') {
return false;
}
if (! (engine instanceof XPathEngine)) {
return false;
}
engines[name] = engine;
return true;
};
this.getRegisteredEngine = function(name) {
return engines[name];
};
this.setCurrentEngine = function(name) {
if (name == 'default') {
currentEngineName = defaultEngineName;
}
else if (! engines[name]) {
return;
}
else {
currentEngineName = name;
}
};
this.getCurrentEngine = function() {
return currentEngineName || defaultEngineName;
};
this.setAllowNativeXPath = function(allow) {
allowNativeXPath = allow;
};
this.isAllowNativeXPath = function() {
return allowNativeXPath;
};
this.setIgnoreAttributesWithoutValue = function(ignore) {
ignoreAttributesWithoutValue = ignore;
};
this.isIgnoreAttributesWithoutValue = function() {
return ignoreAttributesWithoutValue;
};
this.selectNodes = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('selectNodes', inDocument, xpath, contextNode,
namespaceResolver);
};
this.selectSingleNode = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('selectSingleNode', inDocument, xpath, contextNode,
namespaceResolver);
};
this.countNodes = function(inDocument, xpath, contextNode, namespaceResolver) {
return dispatch('countNodes', inDocument, xpath, contextNode,
namespaceResolver);
};
// initialization
this.init();
} | [
"function",
"XPathEvaluator",
"(",
"newDefaultEngineName",
")",
"{",
"// private",
"var",
"nativeEngine",
"=",
"new",
"NativeEngine",
"(",
")",
";",
"var",
"defaultEngineName",
"=",
"newDefaultEngineName",
"||",
"'ajaxslt'",
";",
"var",
"engines",
"=",
"{",
"'ajax... | An object responsible for handling XPath logic. New XPath engines can be
registered to this evaluator on the fly.
@param newDefaultEngineName the name of the default XPath engine. Must be
a non-native engine that is always available.
Defaults to 'ajaxslt'. | [
"An",
"object",
"responsible",
"for",
"handling",
"XPath",
"logic",
".",
"New",
"XPath",
"engines",
"can",
"be",
"registered",
"to",
"this",
"evaluator",
"on",
"the",
"fly",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1947-L2092 | train | XPathEvaluator - Augmenter for XPath evaluation. | [
30522,
3853,
26726,
8988,
13331,
7630,
8844,
1006,
2047,
3207,
7011,
11314,
13159,
21820,
14074,
1007,
1063,
1013,
1013,
2797,
13075,
3128,
13159,
3170,
1027,
2047,
3128,
13159,
3170,
1006,
1007,
1025,
13075,
12398,
13159,
21820,
14074,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_categories | function addonsManager_categories(aSpec) {
var spec = aSpec || { };
var categories = this.getElements({
type: "categories",
subtype: spec.attribute,
value: spec.value
});
if (categories.length == 0)
throw new Error(arguments.callee.name + ": Categories could not be found.");
return categories;
} | javascript | function addonsManager_categories(aSpec) {
var spec = aSpec || { };
var categories = this.getElements({
type: "categories",
subtype: spec.attribute,
value: spec.value
});
if (categories.length == 0)
throw new Error(arguments.callee.name + ": Categories could not be found.");
return categories;
} | [
"function",
"addonsManager_categories",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"categories",
"=",
"this",
".",
"getElements",
"(",
"{",
"type",
":",
"\"categories\"",
",",
"subtype",
":",
"spec",
".",
"attribute",
... | Returns the categories which match the filter criteria
@param {object} aSpec
Information about the filter to apply
Elements: attribute - DOM attribute of the wanted category
[optional - default: ""]
value - Value of the DOM attribute
[optional - default: ""]
@returns List of categories
@type {array of ElemBase} | [
"Returns",
"the",
"categories",
"which",
"match",
"the",
"filter",
"criteria"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L629-L642 | train | Returns the categories of the addons manager | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
7236,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
7236,
1027,
2023,
1012,
2131,
12260,
8163,
1006,
1063,
2828,
1024,
1000,
7236,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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_PtgAttrSemi | function parse_PtgAttrSemi(blob, length, opts) {
var bitSemi = (blob[blob.l+1] & 0xFF) ? 1 : 0;
blob.l += opts && opts.biff == 2 ? 3 : 4;
return [bitSemi];
} | javascript | function parse_PtgAttrSemi(blob, length, opts) {
var bitSemi = (blob[blob.l+1] & 0xFF) ? 1 : 0;
blob.l += opts && opts.biff == 2 ? 3 : 4;
return [bitSemi];
} | [
"function",
"parse_PtgAttrSemi",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"bitSemi",
"=",
"(",
"blob",
"[",
"blob",
".",
"l",
"+",
"1",
"]",
"&",
"0xFF",
")",
"?",
"1",
":",
"0",
";",
"blob",
".",
"l",
"+=",
"opts",
"&&",
"opts... | /* [MS-XLS] 2.5.198.37 ; [MS-XLSB] 2.5.97.29 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"37",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"29"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10397-L10401 | train | Parse an PTG attribute | [
30522,
3853,
11968,
3366,
1035,
13866,
20697,
16344,
3366,
4328,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
9017,
23238,
1027,
1006,
1038,
4135,
2497,
1031,
1038,
4135,
2497,
1012,
1048,
1009,
1015,
1033,
1004... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
uber/deck.gl | examples/experimental/bezier/src/bezier-graph-layer.js | computeControlPoint | function computeControlPoint(source, target, direction, offset) {
const midPoint = [(source[0] + target[0]) / 2, (source[1] + target[1]) / 2];
const dx = target[0] - source[0];
const dy = target[1] - source[1];
const normal = [dy, -dx];
const length = Math.sqrt(Math.pow(normal[0], 2.0) + Math.pow(normal[1], 2.0));
const normalized = [normal[0] / length, normal[1] / length];
return [
midPoint[0] + normalized[0] * offset * direction,
midPoint[1] + normalized[1] * offset * direction
];
} | javascript | function computeControlPoint(source, target, direction, offset) {
const midPoint = [(source[0] + target[0]) / 2, (source[1] + target[1]) / 2];
const dx = target[0] - source[0];
const dy = target[1] - source[1];
const normal = [dy, -dx];
const length = Math.sqrt(Math.pow(normal[0], 2.0) + Math.pow(normal[1], 2.0));
const normalized = [normal[0] / length, normal[1] / length];
return [
midPoint[0] + normalized[0] * offset * direction,
midPoint[1] + normalized[1] * offset * direction
];
} | [
"function",
"computeControlPoint",
"(",
"source",
",",
"target",
",",
"direction",
",",
"offset",
")",
"{",
"const",
"midPoint",
"=",
"[",
"(",
"source",
"[",
"0",
"]",
"+",
"target",
"[",
"0",
"]",
")",
"/",
"2",
",",
"(",
"source",
"[",
"1",
"]",... | A helper function to compute the control point of a quadratic bezier curve
@param {number[]} source - the coordinates of source point, ex: [x, y, z]
@param {number[]} target - the coordinates of target point, ex: [x, y, z]
@param {number} direction - the direction of the curve, 1 or -1
@param {number} offset - offset from the midpoint
@return {number[]} - the coordinates of the control point | [
"A",
"helper",
"function",
"to",
"compute",
"the",
"control",
"point",
"of",
"a",
"quadratic",
"bezier",
"curve"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/examples/experimental/bezier/src/bezier-graph-layer.js#L54-L65 | train | Compute control point | [
30522,
3853,
24134,
8663,
13181,
14277,
25785,
1006,
3120,
1010,
4539,
1010,
3257,
1010,
16396,
1007,
1063,
9530,
3367,
3054,
8400,
1027,
1031,
1006,
3120,
1031,
1014,
1033,
1009,
4539,
1031,
1014,
1033,
1007,
1013,
1016,
1010,
1006,
3120,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | third_party/js/mozmill/shared-modules/utils.js | formatUrlPref | function formatUrlPref(prefName) {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Ci.nsIURLFormatter);
return formatter.formatURLPref(prefName);
} | javascript | function formatUrlPref(prefName) {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Ci.nsIURLFormatter);
return formatter.formatURLPref(prefName);
} | [
"function",
"formatUrlPref",
"(",
"prefName",
")",
"{",
"var",
"formatter",
"=",
"Cc",
"[",
"\"@mozilla.org/toolkit/URLFormatterService;1\"",
"]",
".",
"getService",
"(",
"Ci",
".",
"nsIURLFormatter",
")",
";",
"return",
"formatter",
".",
"formatURLPref",
"(",
"pr... | Format a URL by replacing all placeholders
@param {string} prefName
The preference name which contains the URL
@return The formatted URL
@type string | [
"Format",
"a",
"URL",
"by",
"replacing",
"all",
"placeholders"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L281-L286 | train | Format a URL pref | [
30522,
3853,
4289,
3126,
14277,
2890,
2546,
1006,
3653,
2546,
18442,
1007,
1063,
13075,
4289,
3334,
1027,
10507,
1031,
1000,
1030,
9587,
5831,
4571,
1012,
8917,
1013,
6994,
23615,
1013,
24471,
10270,
2953,
18900,
7747,
2121,
7903,
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... |
catapult-project/catapult | tracing/third_party/oboe/src/ascentManager.js | ascentManager | function ascentManager(oboeBus, handlers){
"use strict";
var listenerId = {},
ascent;
function stateAfter(handler) {
return function(param){
ascent = handler( ascent, param);
}
}
for( var eventName in handlers ) {
oboeBus(eventName).on(stateAfter(handlers[eventName]), listenerId);
}
oboeBus(NODE_SWAP).on(function(newNode) {
var oldHead = head(ascent),
key = keyOf(oldHead),
ancestors = tail(ascent),
parentNode;
if( ancestors ) {
parentNode = nodeOf(head(ancestors));
parentNode[key] = newNode;
}
});
oboeBus(NODE_DROP).on(function() {
var oldHead = head(ascent),
key = keyOf(oldHead),
ancestors = tail(ascent),
parentNode;
if( ancestors ) {
parentNode = nodeOf(head(ancestors));
delete parentNode[key];
}
});
oboeBus(ABORTING).on(function(){
for( var eventName in handlers ) {
oboeBus(eventName).un(listenerId);
}
});
} | javascript | function ascentManager(oboeBus, handlers){
"use strict";
var listenerId = {},
ascent;
function stateAfter(handler) {
return function(param){
ascent = handler( ascent, param);
}
}
for( var eventName in handlers ) {
oboeBus(eventName).on(stateAfter(handlers[eventName]), listenerId);
}
oboeBus(NODE_SWAP).on(function(newNode) {
var oldHead = head(ascent),
key = keyOf(oldHead),
ancestors = tail(ascent),
parentNode;
if( ancestors ) {
parentNode = nodeOf(head(ancestors));
parentNode[key] = newNode;
}
});
oboeBus(NODE_DROP).on(function() {
var oldHead = head(ascent),
key = keyOf(oldHead),
ancestors = tail(ascent),
parentNode;
if( ancestors ) {
parentNode = nodeOf(head(ancestors));
delete parentNode[key];
}
});
oboeBus(ABORTING).on(function(){
for( var eventName in handlers ) {
oboeBus(eventName).un(listenerId);
}
});
} | [
"function",
"ascentManager",
"(",
"oboeBus",
",",
"handlers",
")",
"{",
"\"use strict\"",
";",
"var",
"listenerId",
"=",
"{",
"}",
",",
"ascent",
";",
"function",
"stateAfter",
"(",
"handler",
")",
"{",
"return",
"function",
"(",
"param",
")",
"{",
"ascent... | A bridge used to assign stateless functions to listen to clarinet.
As well as the parameter from clarinet, each callback will also be passed
the result of the last callback.
This may also be used to clear all listeners by assigning zero handlers:
ascentManager( clarinet, {} ) | [
"A",
"bridge",
"used",
"to",
"assign",
"stateless",
"functions",
"to",
"listen",
"to",
"clarinet",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/ascentManager.js#L12-L62 | train | A function that handles ascent events. | [
30522,
3853,
16354,
24805,
4590,
1006,
22523,
8286,
1010,
28213,
2015,
1007,
1063,
1000,
2224,
9384,
1000,
1025,
13075,
19373,
3593,
1027,
1063,
1065,
1010,
16354,
1025,
3853,
2110,
10354,
3334,
1006,
28213,
1007,
1063,
2709,
3853,
1006,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ui/external/ElementTree.js | _getElementTreeLeftColumnOfListItem | function _getElementTreeLeftColumnOfListItem(controls, paddingLeft) {
var html = "<offset style=\"padding-left:" + paddingLeft + "px\" >";
if (controls.content.length > 0) {
html += "<arrow down=\"true\"></arrow>";
} else {
html += "<place-holder></place-holder>";
}
html += "</offset>";
return html;
} | javascript | function _getElementTreeLeftColumnOfListItem(controls, paddingLeft) {
var html = "<offset style=\"padding-left:" + paddingLeft + "px\" >";
if (controls.content.length > 0) {
html += "<arrow down=\"true\"></arrow>";
} else {
html += "<place-holder></place-holder>";
}
html += "</offset>";
return html;
} | [
"function",
"_getElementTreeLeftColumnOfListItem",
"(",
"controls",
",",
"paddingLeft",
")",
"{",
"var",
"html",
"=",
"\"<offset style=\\\"padding-left:\"",
"+",
"paddingLeft",
"+",
"\"px\\\" >\"",
";",
"if",
"(",
"controls",
".",
"content",
".",
"length",
">",
"0",... | Create HTML for the left part of the ElementTree list item.
@param {ElementTreeOptions.controls} controls
@param {number} paddingLeft
@returns {string}
@private | [
"Create",
"HTML",
"for",
"the",
"left",
"part",
"of",
"the",
"ElementTree",
"list",
"item",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L60-L72 | train | Returns the HTML markup of the left column of the list item | [
30522,
3853,
1035,
2131,
12260,
3672,
13334,
2571,
6199,
25778,
2819,
3630,
10258,
2923,
4221,
2213,
1006,
7711,
1010,
11687,
4667,
2571,
6199,
1007,
1063,
13075,
16129,
1027,
1000,
1026,
16396,
2806,
1027,
1032,
1000,
11687,
4667,
1011,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/autocomplete/js/autocompleteController.js | getAngularElements | function getAngularElements (elements) {
var obj = {};
for (var key in elements) {
if (elements.hasOwnProperty(key)) obj[ key ] = angular.element(elements[ key ]);
}
return obj;
} | javascript | function getAngularElements (elements) {
var obj = {};
for (var key in elements) {
if (elements.hasOwnProperty(key)) obj[ key ] = angular.element(elements[ key ]);
}
return obj;
} | [
"function",
"getAngularElements",
"(",
"elements",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"elements",
")",
"{",
"if",
"(",
"elements",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"obj",
"[",
"key",
"]",
"=",
"a... | Gathers angular-wrapped versions of each element
@param elements
@returns {{}} | [
"Gathers",
"angular",
"-",
"wrapped",
"versions",
"of",
"each",
"element"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L333-L339 | train | Get angular elements from an object | [
30522,
3853,
2131,
5654,
7934,
12260,
8163,
1006,
3787,
1007,
1063,
13075,
27885,
3501,
1027,
1063,
1065,
1025,
2005,
1006,
13075,
3145,
1999,
3787,
1007,
1063,
2065,
1006,
3787,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
3145,
1007,
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... |
Shopify/draggable | src/Swappable/Swappable.js | onSwappableSwappedDefaultAnnouncement | function onSwappableSwappedDefaultAnnouncement({dragEvent, swappedElement}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'swappable element';
const overText = swappedElement.textContent.trim() || swappedElement.id || 'swappable element';
return `Swapped ${sourceText} with ${overText}`;
} | javascript | function onSwappableSwappedDefaultAnnouncement({dragEvent, swappedElement}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'swappable element';
const overText = swappedElement.textContent.trim() || swappedElement.id || 'swappable element';
return `Swapped ${sourceText} with ${overText}`;
} | [
"function",
"onSwappableSwappedDefaultAnnouncement",
"(",
"{",
"dragEvent",
",",
"swappedElement",
"}",
")",
"{",
"const",
"sourceText",
"=",
"dragEvent",
".",
"source",
".",
"textContent",
".",
"trim",
"(",
")",
"||",
"dragEvent",
".",
"source",
".",
"id",
"|... | Returns an announcement message when the Draggable element is swapped with another draggable element
@param {SwappableSwappedEvent} swappableEvent
@return {String} | [
"Returns",
"an",
"announcement",
"message",
"when",
"the",
"Draggable",
"element",
"is",
"swapped",
"with",
"another",
"draggable",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Swappable/Swappable.js#L13-L18 | train | This function is called when the user clicks on a swappable element. | [
30522,
3853,
2006,
26760,
29098,
3085,
26760,
29098,
22367,
12879,
23505,
11639,
23709,
3401,
3672,
1006,
1063,
8011,
18697,
3372,
1010,
29176,
12260,
3672,
1065,
1007,
1063,
9530,
3367,
3120,
18209,
1027,
8011,
18697,
3372,
1012,
3120,
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... |
uber/deck.gl | modules/layers/src/icon-layer/icon-manager.js | resizeImage | function resizeImage(ctx, imageData, width, height) {
const {naturalWidth, naturalHeight} = imageData;
if (width === naturalWidth && height === naturalHeight) {
return imageData;
}
ctx.canvas.height = height;
ctx.canvas.width = width;
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
// image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight
ctx.drawImage(imageData, 0, 0, naturalWidth, naturalHeight, 0, 0, width, height);
return ctx.canvas;
} | javascript | function resizeImage(ctx, imageData, width, height) {
const {naturalWidth, naturalHeight} = imageData;
if (width === naturalWidth && height === naturalHeight) {
return imageData;
}
ctx.canvas.height = height;
ctx.canvas.width = width;
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
// image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight
ctx.drawImage(imageData, 0, 0, naturalWidth, naturalHeight, 0, 0, width, height);
return ctx.canvas;
} | [
"function",
"resizeImage",
"(",
"ctx",
",",
"imageData",
",",
"width",
",",
"height",
")",
"{",
"const",
"{",
"naturalWidth",
",",
"naturalHeight",
"}",
"=",
"imageData",
";",
"if",
"(",
"width",
"===",
"naturalWidth",
"&&",
"height",
"===",
"naturalHeight",... | resize image to given width and height | [
"resize",
"image",
"to",
"given",
"width",
"and",
"height"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/layers/src/icon-layer/icon-manager.js#L23-L38 | train | Resize image to the specified size | [
30522,
3853,
24501,
4697,
9581,
3351,
1006,
14931,
2595,
1010,
30524,
1027,
3019,
9148,
11927,
2232,
1004,
1004,
4578,
1027,
1027,
1027,
3019,
26036,
13900,
1007,
1063,
2709,
3746,
2850,
2696,
1025,
1065,
14931,
2595,
1012,
10683,
1012,
457... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | third_party/js/mozmill/shared-modules/downloads.js | downloadManager_getAllDownloads | function downloadManager_getAllDownloads() {
var dbConn = this._dms.DBConnection;
var stmt = null;
if (dbConn.schemaVersion < 3)
return new Array();
// Run a SQL query and iterate through all results which have been found
var downloads = [];
stmt = dbConn.createStatement("SELECT * FROM moz_downloads");
while (stmt.executeStep()) {
downloads.push({
id: stmt.row.id, name: stmt.row.name, target: stmt.row.target,
tempPath: stmt.row.tempPath, startTime: stmt.row.startTime,
endTime: stmt.row.endTime, state: stmt.row.state,
referrer: stmt.row.referrer, entityID: stmt.row.entityID,
currBytes: stmt.row.currBytes, maxBytes: stmt.row.maxBytes,
mimeType : stmt.row.mimeType, autoResume: stmt.row.autoResume,
preferredApplication: stmt.row.preferredApplication,
preferredAction: stmt.row.preferredAction
});
};
stmt.reset();
return downloads;
} | javascript | function downloadManager_getAllDownloads() {
var dbConn = this._dms.DBConnection;
var stmt = null;
if (dbConn.schemaVersion < 3)
return new Array();
// Run a SQL query and iterate through all results which have been found
var downloads = [];
stmt = dbConn.createStatement("SELECT * FROM moz_downloads");
while (stmt.executeStep()) {
downloads.push({
id: stmt.row.id, name: stmt.row.name, target: stmt.row.target,
tempPath: stmt.row.tempPath, startTime: stmt.row.startTime,
endTime: stmt.row.endTime, state: stmt.row.state,
referrer: stmt.row.referrer, entityID: stmt.row.entityID,
currBytes: stmt.row.currBytes, maxBytes: stmt.row.maxBytes,
mimeType : stmt.row.mimeType, autoResume: stmt.row.autoResume,
preferredApplication: stmt.row.preferredApplication,
preferredAction: stmt.row.preferredAction
});
};
stmt.reset();
return downloads;
} | [
"function",
"downloadManager_getAllDownloads",
"(",
")",
"{",
"var",
"dbConn",
"=",
"this",
".",
"_dms",
".",
"DBConnection",
";",
"var",
"stmt",
"=",
"null",
";",
"if",
"(",
"dbConn",
".",
"schemaVersion",
"<",
"3",
")",
"return",
"new",
"Array",
"(",
"... | Get the list of all downloaded files in the database
@returns List of downloads
@type {Array of download} | [
"Get",
"the",
"list",
"of",
"all",
"downloaded",
"files",
"in",
"the",
"database"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L195-L220 | train | Get all the downloads | [
30522,
3853,
8816,
24805,
4590,
1035,
2131,
8095,
7698,
11066,
2015,
1006,
1007,
1063,
13075,
16962,
8663,
2078,
1027,
2023,
1012,
1035,
1040,
5244,
1012,
16962,
8663,
2638,
7542,
1025,
13075,
2358,
20492,
1027,
19701,
1025,
2065,
1006,
169... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/routing/Router.js | function (sName, oParameters) {
if (oParameters === undefined) {
//even if there are only optional parameters crossroads cannot navigate with undefined
oParameters = {};
}
var oRoute = this.getRoute(sName);
if (!oRoute) {
Log.warning("Route with name " + sName + " does not exist", this);
return;
}
return oRoute.getURL(oParameters);
} | javascript | function (sName, oParameters) {
if (oParameters === undefined) {
//even if there are only optional parameters crossroads cannot navigate with undefined
oParameters = {};
}
var oRoute = this.getRoute(sName);
if (!oRoute) {
Log.warning("Route with name " + sName + " does not exist", this);
return;
}
return oRoute.getURL(oParameters);
} | [
"function",
"(",
"sName",
",",
"oParameters",
")",
"{",
"if",
"(",
"oParameters",
"===",
"undefined",
")",
"{",
"//even if there are only optional parameters crossroads cannot navigate with undefined",
"oParameters",
"=",
"{",
"}",
";",
"}",
"var",
"oRoute",
"=",
"thi... | Returns the URL for the route and replaces the placeholders with the values in oParameters
@param {string} sName Name of the route
@param {object} [oParameters] Parameters for the route
@return {string} the unencoded pattern with interpolated arguments
@public | [
"Returns",
"the",
"URL",
"for",
"the",
"route",
"and",
"replaces",
"the",
"placeholders",
"with",
"the",
"values",
"in",
"oParameters"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L513-L525 | train | Navigates to a route | [
30522,
3853,
1006,
1055,
18442,
1010,
6728,
5400,
22828,
2015,
1007,
1063,
2065,
1006,
6728,
5400,
22828,
2015,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
1013,
1013,
2130,
30524,
1065,
1025,
1065,
13075,
20298,
10421,
1027,
2023,
1012,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | insertFragment | function insertFragment(sFragmentName, oElement, oWithControl) {
var oFragmentPromise,
fnLoad = oViewInfo.sync
? XMLTemplateProcessor.loadTemplate
: XMLTemplateProcessor.loadTemplatePromise,
sPreviousName = sCurrentName;
// Note: It is perfectly valid to include the very same fragment again, as long as
// the context is changed. So we check for cycles at the current "with" control.
// A context change will create a new one.
oWithControl.$mFragmentContexts = oWithControl.$mFragmentContexts || {};
if (oWithControl.$mFragmentContexts[sFragmentName]) {
error("Cyclic reference to fragment '" + sFragmentName + "' ", oElement);
}
iNestingLevel++;
debug(oElement, "fragmentName =", sFragmentName);
oWithControl.$mFragmentContexts[sFragmentName] = true;
sCurrentName = sFragmentName;
Measurement.average(sPerformanceInsertFragment, "", aPerformanceCategories);
// take fragment promise from cache, then import fragment
oFragmentPromise = mFragmentCache[sFragmentName];
if (!oFragmentPromise) {
mFragmentCache[sFragmentName] = oFragmentPromise
= SyncPromise.resolve(fnLoad(sFragmentName, "fragment"));
}
return oFragmentPromise.then(function (oFragmentElement) {
oFragmentElement = oElement.ownerDocument.importNode(oFragmentElement, true);
Measurement.end(sPerformanceInsertFragment);
return requireFor(oFragmentElement).then(function () {
if (oFragmentElement.namespaceURI === "sap.ui.core"
&& oFragmentElement.localName === "FragmentDefinition") {
return liftChildNodes(oFragmentElement, oWithControl, oElement);
}
oElement.parentNode.insertBefore(oFragmentElement, oElement);
return visitNode(oFragmentElement, oWithControl);
});
}).then(function () {
oElement.parentNode.removeChild(oElement);
sCurrentName = sPreviousName;
oWithControl.$mFragmentContexts[sFragmentName] = false;
debugFinished(oElement);
iNestingLevel -= 1;
});
} | javascript | function insertFragment(sFragmentName, oElement, oWithControl) {
var oFragmentPromise,
fnLoad = oViewInfo.sync
? XMLTemplateProcessor.loadTemplate
: XMLTemplateProcessor.loadTemplatePromise,
sPreviousName = sCurrentName;
// Note: It is perfectly valid to include the very same fragment again, as long as
// the context is changed. So we check for cycles at the current "with" control.
// A context change will create a new one.
oWithControl.$mFragmentContexts = oWithControl.$mFragmentContexts || {};
if (oWithControl.$mFragmentContexts[sFragmentName]) {
error("Cyclic reference to fragment '" + sFragmentName + "' ", oElement);
}
iNestingLevel++;
debug(oElement, "fragmentName =", sFragmentName);
oWithControl.$mFragmentContexts[sFragmentName] = true;
sCurrentName = sFragmentName;
Measurement.average(sPerformanceInsertFragment, "", aPerformanceCategories);
// take fragment promise from cache, then import fragment
oFragmentPromise = mFragmentCache[sFragmentName];
if (!oFragmentPromise) {
mFragmentCache[sFragmentName] = oFragmentPromise
= SyncPromise.resolve(fnLoad(sFragmentName, "fragment"));
}
return oFragmentPromise.then(function (oFragmentElement) {
oFragmentElement = oElement.ownerDocument.importNode(oFragmentElement, true);
Measurement.end(sPerformanceInsertFragment);
return requireFor(oFragmentElement).then(function () {
if (oFragmentElement.namespaceURI === "sap.ui.core"
&& oFragmentElement.localName === "FragmentDefinition") {
return liftChildNodes(oFragmentElement, oWithControl, oElement);
}
oElement.parentNode.insertBefore(oFragmentElement, oElement);
return visitNode(oFragmentElement, oWithControl);
});
}).then(function () {
oElement.parentNode.removeChild(oElement);
sCurrentName = sPreviousName;
oWithControl.$mFragmentContexts[sFragmentName] = false;
debugFinished(oElement);
iNestingLevel -= 1;
});
} | [
"function",
"insertFragment",
"(",
"sFragmentName",
",",
"oElement",
",",
"oWithControl",
")",
"{",
"var",
"oFragmentPromise",
",",
"fnLoad",
"=",
"oViewInfo",
".",
"sync",
"?",
"XMLTemplateProcessor",
".",
"loadTemplate",
":",
"XMLTemplateProcessor",
".",
"loadTemp... | Inserts the fragment with the given name in place of the given element. Loads the
fragment, takes care of caching (for the current pre-processor run) and visits the
fragment's content once it has been imported into the element's owner document and
put into place. Loading of fragments is asynchronous if the template view is
asynchronous.
@param {string} sFragmentName
the fragment's resolved name
@param {Element} oElement
the XML DOM element, e.g. <sap.ui.core:Fragment> or <core:ExtensionPoint>
@param {sap.ui.core.util._with} oWithControl
the parent's "with" control
@returns {sap.ui.base.SyncPromise}
A sync promise which resolves with <code>undefined</code> as soon as the fragment
has been inserted, or is rejected with a corresponding error if loading or visiting
fails.
@throws {Error}
If a cycle is detected (same <code>sFragmentName</code> and
<code>oWithControl</code>) | [
"Inserts",
"the",
"fragment",
"with",
"the",
"given",
"name",
"in",
"place",
"of",
"the",
"given",
"element",
".",
"Loads",
"the",
"fragment",
"takes",
"care",
"of",
"caching",
"(",
"for",
"the",
"current",
"pre",
"-",
"processor",
"run",
")",
"and",
"vi... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L1148-L1194 | train | Inserts a fragment into the DOM. | [
30522,
3853,
19274,
27843,
21693,
4765,
1006,
16420,
29181,
3672,
18442,
1010,
1051,
12260,
3672,
1010,
27593,
8939,
8663,
13181,
2140,
1007,
1063,
13075,
1997,
29181,
3672,
21572,
28732,
1010,
1042,
20554,
10441,
2094,
1027,
1051,
8584,
2378... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/tooltip/TooltipView.js | function (dataByCoordSys) {
var lastCoordSys = this._lastDataByCoordSys;
var contentNotChanged = !!lastCoordSys
&& lastCoordSys.length === dataByCoordSys.length;
contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
var thisItem = thisDataByAxis[indexAxis] || {};
var lastIndices = lastItem.seriesDataIndices || [];
var newIndices = thisItem.seriesDataIndices || [];
contentNotChanged
&= lastItem.value === thisItem.value
&& lastItem.axisType === thisItem.axisType
&& lastItem.axisId === thisItem.axisId
&& lastIndices.length === newIndices.length;
contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
var newIdxItem = newIndices[j];
contentNotChanged
&= lastIdxItem.seriesIndex === newIdxItem.seriesIndex
&& lastIdxItem.dataIndex === newIdxItem.dataIndex;
});
});
});
this._lastDataByCoordSys = dataByCoordSys;
return !!contentNotChanged;
} | javascript | function (dataByCoordSys) {
var lastCoordSys = this._lastDataByCoordSys;
var contentNotChanged = !!lastCoordSys
&& lastCoordSys.length === dataByCoordSys.length;
contentNotChanged && each(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
var lastDataByAxis = lastItemCoordSys.dataByAxis || {};
var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
contentNotChanged &= lastDataByAxis.length === thisDataByAxis.length;
contentNotChanged && each(lastDataByAxis, function (lastItem, indexAxis) {
var thisItem = thisDataByAxis[indexAxis] || {};
var lastIndices = lastItem.seriesDataIndices || [];
var newIndices = thisItem.seriesDataIndices || [];
contentNotChanged
&= lastItem.value === thisItem.value
&& lastItem.axisType === thisItem.axisType
&& lastItem.axisId === thisItem.axisId
&& lastIndices.length === newIndices.length;
contentNotChanged && each(lastIndices, function (lastIdxItem, j) {
var newIdxItem = newIndices[j];
contentNotChanged
&= lastIdxItem.seriesIndex === newIdxItem.seriesIndex
&& lastIdxItem.dataIndex === newIdxItem.dataIndex;
});
});
});
this._lastDataByCoordSys = dataByCoordSys;
return !!contentNotChanged;
} | [
"function",
"(",
"dataByCoordSys",
")",
"{",
"var",
"lastCoordSys",
"=",
"this",
".",
"_lastDataByCoordSys",
";",
"var",
"contentNotChanged",
"=",
"!",
"!",
"lastCoordSys",
"&&",
"lastCoordSys",
".",
"length",
"===",
"dataByCoordSys",
".",
"length",
";",
"conten... | FIXME Should we remove this but leave this to user? | [
"FIXME",
"Should",
"we",
"remove",
"this",
"but",
"leave",
"this",
"to",
"user?"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/tooltip/TooltipView.js#L677-L711 | train | returns true if the data is not changed | [
30522,
3853,
1006,
2951,
3762,
3597,
8551,
6508,
2015,
1007,
1063,
13075,
2197,
3597,
8551,
6508,
2015,
1027,
2023,
1012,
1035,
2197,
2850,
2696,
3762,
3597,
8551,
6508,
2015,
1025,
13075,
4180,
17048,
22305,
2098,
1027,
999,
999,
2197,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/html-tags.js | htmlTagObjectToString | function htmlTagObjectToString (tagDefinition, xhtml) {
const attributes = Object.keys(tagDefinition.attributes || {})
.filter(function (attributeName) {
return tagDefinition.attributes[attributeName] !== false;
})
.map(function (attributeName) {
if (tagDefinition.attributes[attributeName] === true) {
return xhtml ? attributeName + '="' + attributeName + '"' : attributeName;
}
return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
});
return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (tagDefinition.voidTag && xhtml ? '/' : '') + '>' +
(tagDefinition.innerHTML || '') +
(tagDefinition.voidTag ? '' : '</' + tagDefinition.tagName + '>');
} | javascript | function htmlTagObjectToString (tagDefinition, xhtml) {
const attributes = Object.keys(tagDefinition.attributes || {})
.filter(function (attributeName) {
return tagDefinition.attributes[attributeName] !== false;
})
.map(function (attributeName) {
if (tagDefinition.attributes[attributeName] === true) {
return xhtml ? attributeName + '="' + attributeName + '"' : attributeName;
}
return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
});
return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (tagDefinition.voidTag && xhtml ? '/' : '') + '>' +
(tagDefinition.innerHTML || '') +
(tagDefinition.voidTag ? '' : '</' + tagDefinition.tagName + '>');
} | [
"function",
"htmlTagObjectToString",
"(",
"tagDefinition",
",",
"xhtml",
")",
"{",
"const",
"attributes",
"=",
"Object",
".",
"keys",
"(",
"tagDefinition",
".",
"attributes",
"||",
"{",
"}",
")",
".",
"filter",
"(",
"function",
"(",
"attributeName",
")",
"{"... | Turn a tag definition into a html string
@param {HtmlTagObject} tagDefinition
A tag element according to the htmlWebpackPlugin object notation
@param xhtml {boolean}
Wether the generated html should add closing slashes to be xhtml compliant | [
"Turn",
"a",
"tag",
"definition",
"into",
"a",
"html",
"string",
"@param",
"{",
"HtmlTagObject",
"}",
"tagDefinition",
"A",
"tag",
"element",
"according",
"to",
"the",
"htmlWebpackPlugin",
"object",
"notation"
] | 38db64ae8805de37d038e0ee0f6dfa2a26e2163a | https://github.com/jantimon/html-webpack-plugin/blob/38db64ae8805de37d038e0ee0f6dfa2a26e2163a/lib/html-tags.js#L30-L44 | train | Converts an HTML tag object to a string | [
30522,
3853,
16129,
15900,
16429,
20614,
13122,
18886,
3070,
1006,
6415,
3207,
16294,
22753,
1010,
1060,
11039,
19968,
1007,
1063,
9530,
3367,
12332,
1027,
4874,
1012,
6309,
30524,
1063,
2065,
1006,
6415,
3207,
16294,
22753,
1012,
12332,
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... |
aws/aws-sdk-js | features/extra/helpers.js | unexpectedError | function unexpectedError(resp, next) {
var svc = resp.request.service.api.serviceName;
var op = resp.request.operation;
var code = resp.error.code;
var msg = resp.error.message;
var err = 'Received unexpected error from ' + svc + '.' + op + ', ' + code + ': ' + msg;
next.fail(new Error(err));
} | javascript | function unexpectedError(resp, next) {
var svc = resp.request.service.api.serviceName;
var op = resp.request.operation;
var code = resp.error.code;
var msg = resp.error.message;
var err = 'Received unexpected error from ' + svc + '.' + op + ', ' + code + ': ' + msg;
next.fail(new Error(err));
} | [
"function",
"unexpectedError",
"(",
"resp",
",",
"next",
")",
"{",
"var",
"svc",
"=",
"resp",
".",
"request",
".",
"service",
".",
"api",
".",
"serviceName",
";",
"var",
"op",
"=",
"resp",
".",
"request",
".",
"operation",
";",
"var",
"code",
"=",
"r... | Given a response that contains an error, this fails the current
step with a formatted error message that indicates which service and
operation failed. | [
"Given",
"a",
"response",
"that",
"contains",
"an",
"error",
"this",
"fails",
"the",
"current",
"step",
"with",
"a",
"formatted",
"error",
"message",
"that",
"indicates",
"which",
"service",
"and",
"operation",
"failed",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L105-L112 | train | Unexpected error from the cluster | [
30522,
3853,
9223,
2121,
29165,
1006,
24501,
2361,
1010,
2279,
1007,
1063,
13075,
17917,
2278,
1027,
24501,
2361,
1012,
5227,
1012,
2326,
1012,
17928,
1012,
2326,
18442,
1025,
13075,
6728,
1027,
24501,
2361,
1012,
5227,
1012,
3169,
1025,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
if (this._aQueryResultNames) {
return this._aQueryResultNames;
}
this._aQueryResultNames = new Array(0);
for ( var sName in this._oQueryResultSet) {
this._aQueryResultNames.push(this._oQueryResultSet[sName].getName());
}
return this._aQueryResultNames;
} | javascript | function() {
if (this._aQueryResultNames) {
return this._aQueryResultNames;
}
this._aQueryResultNames = new Array(0);
for ( var sName in this._oQueryResultSet) {
this._aQueryResultNames.push(this._oQueryResultSet[sName].getName());
}
return this._aQueryResultNames;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_aQueryResultNames",
")",
"{",
"return",
"this",
".",
"_aQueryResultNames",
";",
"}",
"this",
".",
"_aQueryResultNames",
"=",
"new",
"Array",
"(",
"0",
")",
";",
"for",
"(",
"var",
"sName",
"in",
"thi... | Get the names of all query results (entity sets) offered by the model
@returns {string[]} List of all query result names
@public
@function
@name sap.ui.model.analytics.odata4analytics.Model#getAllQueryResultNames | [
"Get",
"the",
"names",
"of",
"all",
"query",
"results",
"(",
"entity",
"sets",
")",
"offered",
"by",
"the",
"model"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L765-L777 | train | Returns an array of the names of the query results. | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
1037,
4226,
2854,
6072,
11314,
18442,
2015,
1007,
1063,
2709,
2023,
1012,
1035,
1037,
4226,
2854,
6072,
11314,
18442,
2015,
1025,
1065,
2023,
1012,
1035,
1037,
4226,
2854,
6072,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | Collision | function Collision(el, colliders, options)
{
this.options = $.extend(defaults, options);
this.$element = el;
this.last_colliders = [];
this.last_colliders_coords = [];
if(typeof colliders === 'string' || colliders instanceof jQuery)
{
this.$colliders = $(colliders, this.options.colliders_context).not(this.$element);
}
else
{
this.colliders = $(colliders);
}
this.init();
} | javascript | function Collision(el, colliders, options)
{
this.options = $.extend(defaults, options);
this.$element = el;
this.last_colliders = [];
this.last_colliders_coords = [];
if(typeof colliders === 'string' || colliders instanceof jQuery)
{
this.$colliders = $(colliders, this.options.colliders_context).not(this.$element);
}
else
{
this.colliders = $(colliders);
}
this.init();
} | [
"function",
"Collision",
"(",
"el",
",",
"colliders",
",",
"options",
")",
"{",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"defaults",
",",
"options",
")",
";",
"this",
".",
"$element",
"=",
"el",
";",
"this",
".",
"last_colliders",
"=",
"... | Detects collisions between a DOM element against other DOM elements or
Coords objects.
@class Collision
@uses Coords
@param {HTMLElement} el The jQuery wrapped HTMLElement.
@param {HTMLElement|Array} colliders Can be a jQuery collection
of HTMLElements or an Array of Coords instances.
@param {Object} [options] An Object with all options you want to
overwrite:
@param {Function} [options.on_overlap_start] Executes a function the first
time each `collider ` is overlapped.
@param {Function} [options.on_overlap_stop] Executes a function when a
`collider` is no longer collided.
@param {Function} [options.on_overlap] Executes a function when the
mouse is moved during the collision.
@return {Object} Collision instance.
@constructor | [
"Detects",
"collisions",
"between",
"a",
"DOM",
"element",
"against",
"other",
"DOM",
"elements",
"or",
"Coords",
"objects",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L15273-L15289 | train | collision constructor | [
30522,
3853,
12365,
1006,
3449,
1010,
8902,
24198,
2869,
1010,
7047,
1007,
1063,
2023,
1012,
7047,
1027,
1002,
1012,
7949,
1006,
12398,
2015,
1010,
7047,
1007,
1025,
2023,
1012,
1002,
5783,
1027,
3449,
1025,
2023,
1012,
2197,
1035,
8902,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
grpc/grpc | examples/node/dynamic_codegen/route_guide/route_guide_server.js | getServer | function getServer() {
var server = new grpc.Server();
server.addProtoService(routeguide.RouteGuide.service, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
} | javascript | function getServer() {
var server = new grpc.Server();
server.addProtoService(routeguide.RouteGuide.service, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
} | [
"function",
"getServer",
"(",
")",
"{",
"var",
"server",
"=",
"new",
"grpc",
".",
"Server",
"(",
")",
";",
"server",
".",
"addProtoService",
"(",
"routeguide",
".",
"RouteGuide",
".",
"service",
",",
"{",
"getFeature",
":",
"getFeature",
",",
"listFeatures... | Get a new server with the handler functions in this file bound to the methods
it serves.
@return {Server} The new server object | [
"Get",
"a",
"new",
"server",
"with",
"the",
"handler",
"functions",
"in",
"this",
"file",
"bound",
"to",
"the",
"methods",
"it",
"serves",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/dynamic_codegen/route_guide/route_guide_server.js#L219-L228 | train | Returns a grpc server | [
30522,
3853,
4152,
2121,
6299,
1006,
1007,
1063,
13075,
8241,
1027,
2047,
24665,
15042,
1012,
8241,
1006,
1007,
1025,
8241,
1012,
5587,
21572,
22282,
30524,
22494,
2618,
1010,
2799,
7507,
2102,
1024,
2799,
7507,
2102,
1065,
1007,
1025,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/analytics/odata4analytics.js | function(aDimensionName) {
if (!aDimensionName) {
return;
}
this._oSelectedPropertyNames = null; // reset previously compiled list of selected properties
for (var i = -1, sDimName; (sDimName = aDimensionName[++i]) !== undefined;) {
if (!this._oQueryResult.findDimensionByName(sDimName)) {
throw sDimName + " is not a valid dimension name"; // TODO
}
this._oAggregationLevel[sDimName] = {
key : true,
text : false,
attributes : null
};
}
} | javascript | function(aDimensionName) {
if (!aDimensionName) {
return;
}
this._oSelectedPropertyNames = null; // reset previously compiled list of selected properties
for (var i = -1, sDimName; (sDimName = aDimensionName[++i]) !== undefined;) {
if (!this._oQueryResult.findDimensionByName(sDimName)) {
throw sDimName + " is not a valid dimension name"; // TODO
}
this._oAggregationLevel[sDimName] = {
key : true,
text : false,
attributes : null
};
}
} | [
"function",
"(",
"aDimensionName",
")",
"{",
"if",
"(",
"!",
"aDimensionName",
")",
"{",
"return",
";",
"}",
"this",
".",
"_oSelectedPropertyNames",
"=",
"null",
";",
"// reset previously compiled list of selected properties",
"for",
"(",
"var",
"i",
"=",
"-",
"... | Add one or more dimensions to the aggregation level
@param aDimensionName
Array of dimension names to be added to the already defined
aggregation level.
@public
@function
@name sap.ui.model.analytics.odata4analytics.QueryResultRequest#addToAggregationLevel | [
"Add",
"one",
"or",
"more",
"dimensions",
"to",
"the",
"aggregation",
"level"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L4200-L4217 | train | Sets the aggregation level for the given dimension name. | [
30522,
3853,
1006,
27133,
3549,
10992,
18442,
1007,
1063,
2065,
1006,
999,
27133,
3549,
10992,
18442,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
1035,
9808,
12260,
10985,
21572,
4842,
25680,
14074,
2015,
1027,
19701,
1025,
1013,
1013,
25141,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
codemirror/CodeMirror | src/edit/key_events.js | handleCharBinding | function handleCharBinding(cm, e, ch) {
return dispatchKey(cm, "'" + ch + "'", e, b => doHandleBinding(cm, b, true))
} | javascript | function handleCharBinding(cm, e, ch) {
return dispatchKey(cm, "'" + ch + "'", e, b => doHandleBinding(cm, b, true))
} | [
"function",
"handleCharBinding",
"(",
"cm",
",",
"e",
",",
"ch",
")",
"{",
"return",
"dispatchKey",
"(",
"cm",
",",
"\"'\"",
"+",
"ch",
"+",
"\"'\"",
",",
"e",
",",
"b",
"=>",
"doHandleBinding",
"(",
"cm",
",",
"b",
",",
"true",
")",
")",
"}"
] | Handle a key from the keypress event | [
"Handle",
"a",
"key",
"from",
"the",
"keypress",
"event"
] | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/edit/key_events.js#L102-L104 | train | Handle a character binding. | [
30522,
3853,
5047,
7507,
27366,
4667,
1006,
4642,
1010,
1041,
1010,
10381,
1007,
1063,
2709,
18365,
14839,
1006,
4642,
1010,
1000,
1005,
1000,
1009,
10381,
1009,
1000,
1005,
1000,
30524,
2995,
1007,
1007,
1065,
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,
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/ScopeManager.js | isDirectoryExcluded | function isDirectoryExcluded(path) {
var excludes = preferences.getExcludedDirectories();
if (!excludes) {
return false;
}
var testPath = ProjectManager.makeProjectRelativeIfPossible(path);
testPath = FileUtils.stripTrailingSlash(testPath);
return excludes.test(testPath);
} | javascript | function isDirectoryExcluded(path) {
var excludes = preferences.getExcludedDirectories();
if (!excludes) {
return false;
}
var testPath = ProjectManager.makeProjectRelativeIfPossible(path);
testPath = FileUtils.stripTrailingSlash(testPath);
return excludes.test(testPath);
} | [
"function",
"isDirectoryExcluded",
"(",
"path",
")",
"{",
"var",
"excludes",
"=",
"preferences",
".",
"getExcludedDirectories",
"(",
")",
";",
"if",
"(",
"!",
"excludes",
")",
"{",
"return",
"false",
";",
"}",
"var",
"testPath",
"=",
"ProjectManager",
".",
... | Test if the directory should be excluded from analysis.
@param {!string} path - full directory path.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"directory",
"should",
"be",
"excluded",
"from",
"analysis",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L198-L209 | train | Check if a directory is excluded | [
30522,
3853,
2003,
4305,
2890,
16761,
6672,
2595,
20464,
13936,
1006,
4130,
1007,
1063,
13075,
23329,
2015,
1027,
18394,
1012,
2131,
10288,
20464,
13936,
4305,
2890,
16761,
3111,
1006,
1007,
1025,
2065,
1006,
999,
23329,
2015,
1007,
1063,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/_Requestor.js | function (oPayload) {
var oResult = oPayload;
if (oResult) {
Object.keys(oResult).forEach(function (sKey) {
if (sKey.indexOf("@$ui5.") === 0) {
if (oResult === oPayload) {
oResult = jQuery.extend({}, oPayload);
}
delete oResult[sKey];
}
});
}
return oResult;
} | javascript | function (oPayload) {
var oResult = oPayload;
if (oResult) {
Object.keys(oResult).forEach(function (sKey) {
if (sKey.indexOf("@$ui5.") === 0) {
if (oResult === oPayload) {
oResult = jQuery.extend({}, oPayload);
}
delete oResult[sKey];
}
});
}
return oResult;
} | [
"function",
"(",
"oPayload",
")",
"{",
"var",
"oResult",
"=",
"oPayload",
";",
"if",
"(",
"oResult",
")",
"{",
"Object",
".",
"keys",
"(",
"oResult",
")",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"if",
"(",
"sKey",
".",
"indexOf",
"(... | Creates a duplicate of the payload where all properties starting with "@$ui5." are
removed.
@param {object} [oPayload]
The request payload
@returns {object}
The payload without the unwanted properties (only copied if necessary)
@private | [
"Creates",
"a",
"duplicate",
"of",
"the",
"payload",
"where",
"all",
"properties",
"starting",
"with",
"@$ui5",
".",
"are",
"removed",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L1470-L1483 | train | returns the object that is a hash of the payload | [
30522,
3853,
1006,
6728,
4710,
11066,
1007,
1063,
13075,
10848,
23722,
2102,
1027,
6728,
4710,
11066,
1025,
2065,
1006,
10848,
23722,
2102,
1007,
1063,
4874,
1012,
6309,
1006,
10848,
23722,
2102,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
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... | |
adobe/brackets | src/project/ProjectManager.js | _setProjectRoot | function _setProjectRoot(rootEntry) {
var d = new $.Deferred();
model.setProjectRoot(rootEntry).then(function () {
d.resolve();
model.reopenNodes(PreferencesManager.getViewState("project.treeState", _getProjectViewStateContext()));
});
return d.promise();
} | javascript | function _setProjectRoot(rootEntry) {
var d = new $.Deferred();
model.setProjectRoot(rootEntry).then(function () {
d.resolve();
model.reopenNodes(PreferencesManager.getViewState("project.treeState", _getProjectViewStateContext()));
});
return d.promise();
} | [
"function",
"_setProjectRoot",
"(",
"rootEntry",
")",
"{",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"model",
".",
"setProjectRoot",
"(",
"rootEntry",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"d",
".",
"resolve",
"(",
")",... | @private
Sets the project root to the given directory, resetting the ProjectModel and file tree in the process.
@param {Directory} rootEntry directory object for the project root
@return {$.Promise} resolved when the project is done setting up | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L560-L567 | train | Set the project root | [
30522,
3853,
1035,
2275,
21572,
20614,
3217,
4140,
1006,
7117,
4765,
2854,
1007,
1063,
13075,
1040,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
2944,
1012,
2275,
21572,
20614,
3217,
4140,
1006,
7117,
4765,
2854,
1007,
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... |
dcloudio/mui | js/sliders.js | function() {
slider.style['-webkit-transition-duration'] = '0';
slider.style.webkitTransform = 'translate3d(' + (slideNumber * slider.offsetWidth) + 'px,0,0)';
slider.removeEventListener('webkitTransitionEnd', fixedLoop);
} | javascript | function() {
slider.style['-webkit-transition-duration'] = '0';
slider.style.webkitTransform = 'translate3d(' + (slideNumber * slider.offsetWidth) + 'px,0,0)';
slider.removeEventListener('webkitTransitionEnd', fixedLoop);
} | [
"function",
"(",
")",
"{",
"slider",
".",
"style",
"[",
"'-webkit-transition-duration'",
"]",
"=",
"'0'",
";",
"slider",
".",
"style",
".",
"webkitTransform",
"=",
"'translate3d('",
"+",
"(",
"slideNumber",
"*",
"slider",
".",
"offsetWidth",
")",
"+",
"'px,0... | slider.style.webkitTransform = 'translate3d(' + offsetX + 'px,0,0)'; self.updateProcess(offsetX); | [
"slider",
".",
"style",
".",
"webkitTransform",
"=",
"translate3d",
"(",
"+",
"offsetX",
"+",
"px",
"0",
"0",
")",
";",
"self",
".",
"updateProcess",
"(",
"offsetX",
")",
";"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/js/sliders.js#L264-L268 | train | This function is called when the user clicks on the slider | [
30522,
3853,
1006,
1007,
1063,
7358,
2099,
1012,
2806,
1031,
1005,
1011,
4773,
23615,
1011,
6653,
1011,
9367,
1005,
1033,
1027,
1005,
1014,
1005,
1025,
7358,
2099,
1012,
2806,
1012,
4773,
23615,
6494,
3619,
14192,
1027,
1005,
17637,
29097,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/UglifyJS/parse-js.js | curry | function curry(f) {
var args = slice(arguments, 1);
return function() { return f.apply(this, args.concat(slice(arguments))); };
} | javascript | function curry(f) {
var args = slice(arguments, 1);
return function() { return f.apply(this, args.concat(slice(arguments))); };
} | [
"function",
"curry",
"(",
"f",
")",
"{",
"var",
"args",
"=",
"slice",
"(",
"arguments",
",",
"1",
")",
";",
"return",
"function",
"(",
")",
"{",
"return",
"f",
".",
"apply",
"(",
"this",
",",
"args",
".",
"concat",
"(",
"slice",
"(",
"arguments",
... | /* -----[ Utilities ]----- | [
"/",
"*",
"-----",
"[",
"Utilities",
"]",
"-----"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/UglifyJS/parse-js.js#L1193-L1196 | train | Curry function f. | [
30522,
3853,
15478,
1006,
1042,
1007,
1063,
13075,
12098,
5620,
1027,
14704,
1006,
9918,
1010,
1015,
1007,
1025,
2709,
3853,
1006,
1007,
1063,
2709,
1042,
1012,
6611,
1006,
2023,
1010,
12098,
5620,
1012,
9530,
11266,
1006,
14704,
1006,
9918... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DeprecationWarning.js | deprecateEvent | function deprecateEvent(outbound, inbound, oldEventName, newEventName, canonicalOutboundName, canonicalInboundName) {
// Mark deprecated so EventDispatcher.on() will emit warnings
EventDispatcher.markDeprecated(outbound, oldEventName, canonicalInboundName);
// create an event handler for the new event to listen for
inbound.on(newEventName, function () {
// Dispatch the event in case anyone is still listening
EventDispatcher.triggerWithArray(outbound, oldEventName, Array.prototype.slice.call(arguments, 1));
});
} | javascript | function deprecateEvent(outbound, inbound, oldEventName, newEventName, canonicalOutboundName, canonicalInboundName) {
// Mark deprecated so EventDispatcher.on() will emit warnings
EventDispatcher.markDeprecated(outbound, oldEventName, canonicalInboundName);
// create an event handler for the new event to listen for
inbound.on(newEventName, function () {
// Dispatch the event in case anyone is still listening
EventDispatcher.triggerWithArray(outbound, oldEventName, Array.prototype.slice.call(arguments, 1));
});
} | [
"function",
"deprecateEvent",
"(",
"outbound",
",",
"inbound",
",",
"oldEventName",
",",
"newEventName",
",",
"canonicalOutboundName",
",",
"canonicalInboundName",
")",
"{",
"// Mark deprecated so EventDispatcher.on() will emit warnings",
"EventDispatcher",
".",
"markDeprecated... | Show a deprecation warning if there are listeners for the event
```
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
"workingSetAdd",
"workingSetAdd",
"DocumentManager.workingSetAdd",
"MainViewManager.workingSetAdd");
```
@param {Object} outbound - the object with the old event to dispatch
@param {Object} inbound - the object with the new event to map to the old event
@param {string} oldEventName - the name of the old event
@param {string} newEventName - the name of the new event
@param {string=} canonicalOutboundName - the canonical name of the old event
@param {string=} canonicalInboundName - the canonical name of the new event | [
"Show",
"a",
"deprecation",
"warning",
"if",
"there",
"are",
"listeners",
"for",
"the",
"event"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L115-L124 | train | Deprecate an event | [
30522,
3853,
2139,
28139,
16280,
18697,
3372,
1006,
2041,
15494,
1010,
1999,
15494,
1010,
2214,
18697,
3372,
18442,
1010,
2047,
18697,
3372,
18442,
1010,
18562,
5833,
15494,
18442,
1010,
18562,
2378,
15494,
18442,
1007,
1063,
1013,
1013,
2928... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
chartjs/Chart.js | src/scales/scale.time.js | buildLookupTable | function buildLookupTable(timestamps, min, max, distribution) {
if (distribution === 'linear' || !timestamps.length) {
return [
{time: min, pos: 0},
{time: max, pos: 1}
];
}
var table = [];
var items = [min];
var i, ilen, prev, curr, next;
for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
curr = timestamps[i];
if (curr > min && curr < max) {
items.push(curr);
}
}
items.push(max);
for (i = 0, ilen = items.length; i < ilen; ++i) {
next = items[i + 1];
prev = items[i - 1];
curr = items[i];
// only add points that breaks the scale linearity
if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) {
table.push({time: curr, pos: i / (ilen - 1)});
}
}
return table;
} | javascript | function buildLookupTable(timestamps, min, max, distribution) {
if (distribution === 'linear' || !timestamps.length) {
return [
{time: min, pos: 0},
{time: max, pos: 1}
];
}
var table = [];
var items = [min];
var i, ilen, prev, curr, next;
for (i = 0, ilen = timestamps.length; i < ilen; ++i) {
curr = timestamps[i];
if (curr > min && curr < max) {
items.push(curr);
}
}
items.push(max);
for (i = 0, ilen = items.length; i < ilen; ++i) {
next = items[i + 1];
prev = items[i - 1];
curr = items[i];
// only add points that breaks the scale linearity
if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) {
table.push({time: curr, pos: i / (ilen - 1)});
}
}
return table;
} | [
"function",
"buildLookupTable",
"(",
"timestamps",
",",
"min",
",",
"max",
",",
"distribution",
")",
"{",
"if",
"(",
"distribution",
"===",
"'linear'",
"||",
"!",
"timestamps",
".",
"length",
")",
"{",
"return",
"[",
"{",
"time",
":",
"min",
",",
"pos",
... | Returns an array of {time, pos} objects used to interpolate a specific `time` or position
(`pos`) on the scale, by searching entries before and after the requested value. `pos` is
a decimal between 0 and 1: 0 being the start of the scale (left or top) and 1 the other
extremity (left + width or top + height). Note that it would be more optimized to directly
store pre-computed pixels, but the scale dimensions are not guaranteed at the time we need
to create the lookup table. The table ALWAYS contains at least two items: min and max.
@param {number[]} timestamps - timestamps sorted from lowest to highest.
@param {string} distribution - If 'linear', timestamps will be spread linearly along the min
and max range, so basically, the table will contains only two items: {min, 0} and {max, 1}.
If 'series', timestamps will be positioned at the same distance from each other. In this
case, only timestamps that break the time linearity are registered, meaning that in the
best case, all timestamps are linear, the table contains only min and max. | [
"Returns",
"an",
"array",
"of",
"{",
"time",
"pos",
"}",
"objects",
"used",
"to",
"interpolate",
"a",
"specific",
"time",
"or",
"position",
"(",
"pos",
")",
"on",
"the",
"scale",
"by",
"searching",
"entries",
"before",
"and",
"after",
"the",
"requested",
... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/scales/scale.time.js#L114-L147 | train | Build lookup table | [
30522,
3853,
3857,
4135,
21940,
22799,
3468,
1006,
2335,
15464,
4523,
1010,
8117,
1010,
4098,
1010,
4353,
1007,
1063,
2065,
1006,
4353,
1027,
1027,
1027,
1005,
7399,
1005,
1064,
1064,
999,
2335,
15464,
4523,
1012,
3091,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 (mChangeListeners, sPath, oOldValue, oNewValue, aSelect) {
var sPredicate;
/*
* Take over the property value from source to target and fires an event if the property
* is changed
* @param {string} sPath The path of oOldValue in mChangeListeners
* @param {string} sProperty The property
* @param {object} oOldValue The old value
* @param {object} oNewValue The new value
*/
function copyPathValue(sPath, sProperty, oOldValue , oNewValue) {
var aSegments = sProperty.split("/");
aSegments.every(function (sSegment, iIndex) {
if (oNewValue[sSegment] === null) {
oOldValue[sSegment] = null;
if (iIndex < aSegments.length - 1) {
return false;
}
_Helper.fireChange(mChangeListeners, _Helper.buildPath(sPath, sProperty),
oOldValue[sSegment]);
} else if (typeof oNewValue[sSegment] === "object") {
oOldValue[sSegment] = oOldValue[sSegment] || {};
} else {
if (oOldValue[sSegment] !== oNewValue[sSegment]) {
oOldValue[sSegment] = oNewValue[sSegment];
_Helper.fireChange(mChangeListeners,
_Helper.buildPath(sPath, sProperty), oOldValue[sSegment]);
}
return false;
}
oOldValue = oOldValue[sSegment];
oNewValue = oNewValue[sSegment];
return true;
});
}
/*
* Creates an array of all property paths for a given object
* @param {object} oObject
* @param {object} [sObjectName] The name of the complex property
*/
function buildPropertyPaths(oObject, sObjectName) {
Object.keys(oObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sObjectName, sProperty),
vPropertyValue = oObject[sProperty];
if (sProperty === "@$ui5._") {
return; // ignore private namespace
}
if (vPropertyValue !== null && typeof vPropertyValue === "object") {
buildPropertyPaths(vPropertyValue, sPropertyPath);
} else {
aSelect.push(sPropertyPath);
}
});
}
if (!aSelect || aSelect.indexOf("*") >= 0) {
// no individual properties selected, fetch all properties of the new value
aSelect = [];
buildPropertyPaths(oNewValue);
} else {
// fetch the selected properties plus the ETag;
// _Cache#visitResponse is called with the response data before updateSelected
// copies the selected values to the cache. visitResponse computes
// - $count values for collections, which are not relevant for POST (deep create is
// not yet supported);
// - key predicates, which are relevant only for the top level element as no deep
// create is supported
// and reports bound messages. Messages need to be copied only if they are selected.
aSelect = aSelect.concat("@odata.etag");
}
// take over properties from the new value and fire change events
aSelect.forEach(function (sProperty) {
copyPathValue(sPath, sProperty, oOldValue, oNewValue);
});
// copy key predicate, but do not fire change event
sPredicate = _Helper.getPrivateAnnotation(oNewValue, "predicate");
if (sPredicate) {
_Helper.setPrivateAnnotation(oOldValue, "predicate", sPredicate);
}
} | javascript | function (mChangeListeners, sPath, oOldValue, oNewValue, aSelect) {
var sPredicate;
/*
* Take over the property value from source to target and fires an event if the property
* is changed
* @param {string} sPath The path of oOldValue in mChangeListeners
* @param {string} sProperty The property
* @param {object} oOldValue The old value
* @param {object} oNewValue The new value
*/
function copyPathValue(sPath, sProperty, oOldValue , oNewValue) {
var aSegments = sProperty.split("/");
aSegments.every(function (sSegment, iIndex) {
if (oNewValue[sSegment] === null) {
oOldValue[sSegment] = null;
if (iIndex < aSegments.length - 1) {
return false;
}
_Helper.fireChange(mChangeListeners, _Helper.buildPath(sPath, sProperty),
oOldValue[sSegment]);
} else if (typeof oNewValue[sSegment] === "object") {
oOldValue[sSegment] = oOldValue[sSegment] || {};
} else {
if (oOldValue[sSegment] !== oNewValue[sSegment]) {
oOldValue[sSegment] = oNewValue[sSegment];
_Helper.fireChange(mChangeListeners,
_Helper.buildPath(sPath, sProperty), oOldValue[sSegment]);
}
return false;
}
oOldValue = oOldValue[sSegment];
oNewValue = oNewValue[sSegment];
return true;
});
}
/*
* Creates an array of all property paths for a given object
* @param {object} oObject
* @param {object} [sObjectName] The name of the complex property
*/
function buildPropertyPaths(oObject, sObjectName) {
Object.keys(oObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sObjectName, sProperty),
vPropertyValue = oObject[sProperty];
if (sProperty === "@$ui5._") {
return; // ignore private namespace
}
if (vPropertyValue !== null && typeof vPropertyValue === "object") {
buildPropertyPaths(vPropertyValue, sPropertyPath);
} else {
aSelect.push(sPropertyPath);
}
});
}
if (!aSelect || aSelect.indexOf("*") >= 0) {
// no individual properties selected, fetch all properties of the new value
aSelect = [];
buildPropertyPaths(oNewValue);
} else {
// fetch the selected properties plus the ETag;
// _Cache#visitResponse is called with the response data before updateSelected
// copies the selected values to the cache. visitResponse computes
// - $count values for collections, which are not relevant for POST (deep create is
// not yet supported);
// - key predicates, which are relevant only for the top level element as no deep
// create is supported
// and reports bound messages. Messages need to be copied only if they are selected.
aSelect = aSelect.concat("@odata.etag");
}
// take over properties from the new value and fire change events
aSelect.forEach(function (sProperty) {
copyPathValue(sPath, sProperty, oOldValue, oNewValue);
});
// copy key predicate, but do not fire change event
sPredicate = _Helper.getPrivateAnnotation(oNewValue, "predicate");
if (sPredicate) {
_Helper.setPrivateAnnotation(oOldValue, "predicate", sPredicate);
}
} | [
"function",
"(",
"mChangeListeners",
",",
"sPath",
",",
"oOldValue",
",",
"oNewValue",
",",
"aSelect",
")",
"{",
"var",
"sPredicate",
";",
"/*\n\t\t\t * Take over the property value from source to target and fires an event if the property\n\t\t\t * is changed\n\t\t\t * @param {string... | Updates the old value with the given new value for the selected properties (see
{@link #updateExisting}). If no selected properties are given or if "*" is contained in
the selected properties, then all properties are selected. <code>@odata.etag</code> is
always selected. Fires change events for all changed properties.
@param {object} mChangeListeners
A map of change listeners by path
@param {string} sPath
The path of oOldValue in mChangeListeners
@param {object} oOldValue
The old value
@param {object} oNewValue
The new value
@param {string[]} [aSelect]
The properties to be updated in oOldValue; default is all properties from oNewValue | [
"Updates",
"the",
"old",
"value",
"with",
"the",
"given",
"new",
"value",
"for",
"the",
"selected",
"properties",
"(",
"see",
"{",
"@link",
"#updateExisting",
"}",
")",
".",
"If",
"no",
"selected",
"properties",
"are",
"given",
"or",
"if",
"*",
"is",
"co... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L1193-L1278 | train | Creates a property path from source to target. | [
30522,
3853,
1006,
11338,
18003,
29282,
6528,
2545,
1010,
14690,
2232,
1010,
1051,
11614,
10175,
5657,
1010,
2028,
2860,
10175,
5657,
1010,
2004,
12260,
6593,
1007,
1063,
13075,
11867,
5596,
24695,
1025,
1013,
1008,
1008,
2202,
2058,
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.m/src/sap/m/ViewSettingsDialog.js | findViewSettingsItemByKey | function findViewSettingsItemByKey(vItemOrKey, aViewSettingsItems, sErrorMessage) {
var oItem;
// convenience, also allow strings
if (typeof vItemOrKey === "string") {
// find item with this key
oItem = getViewSettingsItemByKey(aViewSettingsItems, vItemOrKey);
if (!oItem) {
Log.error(sErrorMessage);
}
} else {
oItem = vItemOrKey;
}
return oItem;
} | javascript | function findViewSettingsItemByKey(vItemOrKey, aViewSettingsItems, sErrorMessage) {
var oItem;
// convenience, also allow strings
if (typeof vItemOrKey === "string") {
// find item with this key
oItem = getViewSettingsItemByKey(aViewSettingsItems, vItemOrKey);
if (!oItem) {
Log.error(sErrorMessage);
}
} else {
oItem = vItemOrKey;
}
return oItem;
} | [
"function",
"findViewSettingsItemByKey",
"(",
"vItemOrKey",
",",
"aViewSettingsItems",
",",
"sErrorMessage",
")",
"{",
"var",
"oItem",
";",
"// convenience, also allow strings",
"if",
"(",
"typeof",
"vItemOrKey",
"===",
"\"string\"",
")",
"{",
"// find item with this key"... | Finds an sap.m.ViewSettingsItem from a list of items by a given key.
If it does not succeed logs an error.
@param {sap.m.ViewSettingsItem|string} vItemOrKey The searched item or its key
@param {array} aViewSettingsItems The list of sap.m.ViewSettingsItem objects to be searched
@param {string} sErrorMessage The error message that will be logged if the item is not found
@returns {*} The sap.m.ViewSettingsItem found in the list of items
@private | [
"Finds",
"an",
"sap",
".",
"m",
".",
"ViewSettingsItem",
"from",
"a",
"list",
"of",
"items",
"by",
"a",
"given",
"key",
".",
"If",
"it",
"does",
"not",
"succeed",
"logs",
"an",
"error",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/ViewSettingsDialog.js#L2967-L2983 | train | Returns the view settings item by key | [
30522,
3853,
2424,
8584,
21678,
8613,
4221,
14905,
15922,
3240,
1006,
6819,
18532,
2953,
14839,
1010,
20704,
2666,
9333,
18319,
3070,
28032,
6633,
2015,
1010,
14262,
29165,
7834,
3736,
3351,
1007,
1063,
13075,
1051,
4221,
2213,
1025,
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... |
apache/incubator-echarts | src/data/helper/sourceHelper.js | doGuessOrdinal | function doGuessOrdinal(
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
var result;
// Experience value.
var maxLoop = 5;
if (isTypedArray(data)) {
return false;
}
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
// always exists in source.
var dimName;
if (dimensionsDefine) {
dimName = dimensionsDefine[dimIndex];
dimName = isObject(dimName) ? dimName.name : dimName;
}
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
var sample = data[dimIndex];
for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
if ((result = detectValue(sample[startIndex + i])) != null) {
return result;
}
}
}
else {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var row = data[startIndex + i];
if (row && (result = detectValue(row[dimIndex])) != null) {
return result;
}
}
}
}
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
if (!dimName) {
return;
}
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
if (item && (result = detectValue(item[dimName])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
if (!dimName) {
return;
}
var sample = data[dimName];
if (!sample || isTypedArray(sample)) {
return false;
}
for (var i = 0; i < sample.length && i < maxLoop; i++) {
if ((result = detectValue(sample[i])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
var val = getDataItemValue(item);
if (!isArray(val)) {
return false;
}
if ((result = detectValue(val[dimIndex])) != null) {
return result;
}
}
}
function detectValue(val) {
// Consider usage convenience, '1', '2' will be treated as "number".
// `isFinit('')` get `true`.
if (val != null && isFinite(val) && val !== '') {
return false;
}
else if (isString(val) && val !== '-') {
return true;
}
}
return false;
} | javascript | function doGuessOrdinal(
data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex
) {
var result;
// Experience value.
var maxLoop = 5;
if (isTypedArray(data)) {
return false;
}
// When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
// always exists in source.
var dimName;
if (dimensionsDefine) {
dimName = dimensionsDefine[dimIndex];
dimName = isObject(dimName) ? dimName.name : dimName;
}
if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
var sample = data[dimIndex];
for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
if ((result = detectValue(sample[startIndex + i])) != null) {
return result;
}
}
}
else {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var row = data[startIndex + i];
if (row && (result = detectValue(row[dimIndex])) != null) {
return result;
}
}
}
}
else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
if (!dimName) {
return;
}
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
if (item && (result = detectValue(item[dimName])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
if (!dimName) {
return;
}
var sample = data[dimName];
if (!sample || isTypedArray(sample)) {
return false;
}
for (var i = 0; i < sample.length && i < maxLoop; i++) {
if ((result = detectValue(sample[i])) != null) {
return result;
}
}
}
else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
for (var i = 0; i < data.length && i < maxLoop; i++) {
var item = data[i];
var val = getDataItemValue(item);
if (!isArray(val)) {
return false;
}
if ((result = detectValue(val[dimIndex])) != null) {
return result;
}
}
}
function detectValue(val) {
// Consider usage convenience, '1', '2' will be treated as "number".
// `isFinit('')` get `true`.
if (val != null && isFinite(val) && val !== '') {
return false;
}
else if (isString(val) && val !== '-') {
return true;
}
}
return false;
} | [
"function",
"doGuessOrdinal",
"(",
"data",
",",
"sourceFormat",
",",
"seriesLayoutBy",
",",
"dimensionsDefine",
",",
"startIndex",
",",
"dimIndex",
")",
"{",
"var",
"result",
";",
"// Experience value.",
"var",
"maxLoop",
"=",
"5",
";",
"if",
"(",
"isTypedArray"... | dimIndex may be overflow source data. | [
"dimIndex",
"may",
"be",
"overflow",
"source",
"data",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/sourceHelper.js#L500-L587 | train | Guess ordinal value from data | [
30522,
3853,
3899,
15808,
21748,
18979,
2140,
1006,
2951,
1010,
3120,
14192,
4017,
1010,
2186,
8485,
5833,
3762,
1010,
9646,
3207,
23460,
1010,
2707,
22254,
10288,
1010,
11737,
22254,
10288,
1007,
1063,
13075,
2765,
1025,
1013,
1013,
3325,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | third_party/js/mozmill/shared-modules/downloads.js | downloadManager_cancelActiveDownloads | function downloadManager_cancelActiveDownloads() {
// Get a list of all active downloads (nsISimpleEnumerator)
var downloads = this._dms.activeDownloads;
// Iterate through each active download and cancel it
while (downloads.hasMoreElements()) {
var download = downloads.getNext().QueryInterface(Ci.nsIDownload);
this._dms.cancelDownload(download.id);
}
} | javascript | function downloadManager_cancelActiveDownloads() {
// Get a list of all active downloads (nsISimpleEnumerator)
var downloads = this._dms.activeDownloads;
// Iterate through each active download and cancel it
while (downloads.hasMoreElements()) {
var download = downloads.getNext().QueryInterface(Ci.nsIDownload);
this._dms.cancelDownload(download.id);
}
} | [
"function",
"downloadManager_cancelActiveDownloads",
"(",
")",
"{",
"// Get a list of all active downloads (nsISimpleEnumerator)",
"var",
"downloads",
"=",
"this",
".",
"_dms",
".",
"activeDownloads",
";",
"// Iterate through each active download and cancel it",
"while",
"(",
"do... | Cancel all active downloads | [
"Cancel",
"all",
"active",
"downloads"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L106-L115 | train | Cancel all active downloads | [
30522,
3853,
8816,
24805,
4590,
1035,
17542,
19620,
7698,
11066,
2015,
1006,
1007,
1063,
1013,
1013,
2131,
1037,
2862,
1997,
2035,
3161,
22956,
1006,
24978,
17417,
23344,
2368,
17897,
16259,
1007,
13075,
22956,
1027,
2023,
1012,
1035,
1040,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
chartjs/Chart.js | src/helpers/helpers.core.js | function(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
return fn.apply(thisArg, args);
}
} | javascript | function(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
return fn.apply(thisArg, args);
}
} | [
"function",
"(",
"fn",
",",
"args",
",",
"thisArg",
")",
"{",
"if",
"(",
"fn",
"&&",
"typeof",
"fn",
".",
"call",
"===",
"'function'",
")",
"{",
"return",
"fn",
".",
"apply",
"(",
"thisArg",
",",
"args",
")",
";",
"}",
"}"
] | Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
value returned by `fn`. If `fn` is not a function, this method returns undefined.
@param {function} fn - The function to call.
@param {Array|undefined|null} args - The arguments with which `fn` should be called.
@param {object} [thisArg] - The value of `this` provided for the call to `fn`.
@returns {*} | [
"Calls",
"fn",
"with",
"the",
"given",
"args",
"in",
"the",
"scope",
"defined",
"by",
"thisArg",
"and",
"returns",
"the",
"value",
"returned",
"by",
"fn",
".",
"If",
"fn",
"is",
"not",
"a",
"function",
"this",
"method",
"returns",
"undefined",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/helpers/helpers.core.js#L99-L103 | train | This function is a bit of a hack to avoid the race condition of calling a function in the same way as the function. | [
30522,
3853,
1006,
1042,
2078,
1010,
12098,
5620,
1010,
2023,
2906,
2290,
1007,
1063,
2065,
1006,
1042,
2078,
1004,
1004,
2828,
11253,
1042,
2078,
1012,
2655,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
1063,
2709,
1042,
2078,
1012,
6611,
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... | |
ccxt/ccxt | build/transpile.js | createPHPClass | function createPHPClass (className, baseClass, body, methods) {
const baseFolder = (baseClass == 'Exchange') ? 'base/' : ''
const baseFile = baseFolder + baseClass + '.php'
const header = [
"<?php\n",
"namespace ccxt;\n",
"// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:",
"// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code\n",
"use \Exception as Exception; // a common import\n",
'class ' + className + ' extends ' + baseClass + ' {' ,
]
let bodyAsString = body.join ("\n")
for (let method of methods) {
const regex = new RegExp ('this->(' + method + ')\\s*\\(', 'g')
bodyAsString = bodyAsString.replace (regex,
(match, p1) => ('this->' + unCamelCase (p1) + ' ('))
}
const footer =[
"}\n",
]
const result = header.join ("\n") + "\n" + bodyAsString + "\n" + footer.join ('\n')
return result
} | javascript | function createPHPClass (className, baseClass, body, methods) {
const baseFolder = (baseClass == 'Exchange') ? 'base/' : ''
const baseFile = baseFolder + baseClass + '.php'
const header = [
"<?php\n",
"namespace ccxt;\n",
"// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:",
"// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code\n",
"use \Exception as Exception; // a common import\n",
'class ' + className + ' extends ' + baseClass + ' {' ,
]
let bodyAsString = body.join ("\n")
for (let method of methods) {
const regex = new RegExp ('this->(' + method + ')\\s*\\(', 'g')
bodyAsString = bodyAsString.replace (regex,
(match, p1) => ('this->' + unCamelCase (p1) + ' ('))
}
const footer =[
"}\n",
]
const result = header.join ("\n") + "\n" + bodyAsString + "\n" + footer.join ('\n')
return result
} | [
"function",
"createPHPClass",
"(",
"className",
",",
"baseClass",
",",
"body",
",",
"methods",
")",
"{",
"const",
"baseFolder",
"=",
"(",
"baseClass",
"==",
"'Exchange'",
")",
"?",
"'base/'",
":",
"''",
"const",
"baseFile",
"=",
"baseFolder",
"+",
"baseClass... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/build/transpile.js#L449-L477 | train | Creates a class with the given name baseClass and body. | [
30522,
3853,
3443,
8458,
15042,
27102,
1006,
2465,
18442,
1010,
2918,
26266,
1010,
2303,
1010,
4725,
1007,
1063,
9530,
3367,
2918,
10371,
2121,
1027,
1006,
2918,
26266,
1027,
1027,
1005,
3863,
1005,
1007,
1029,
1005,
2918,
1013,
1005,
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... |
aframevr/aframe | src/components/rotation.js | function () {
var data = this.data;
var object3D = this.el.object3D;
object3D.rotation.set(degToRad(data.x), degToRad(data.y), degToRad(data.z));
object3D.rotation.order = 'YXZ';
} | javascript | function () {
var data = this.data;
var object3D = this.el.object3D;
object3D.rotation.set(degToRad(data.x), degToRad(data.y), degToRad(data.z));
object3D.rotation.order = 'YXZ';
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"object3D",
"=",
"this",
".",
"el",
".",
"object3D",
";",
"object3D",
".",
"rotation",
".",
"set",
"(",
"degToRad",
"(",
"data",
".",
"x",
")",
",",
"degToRad",
"(",
... | Updates object3D rotation. | [
"Updates",
"object3D",
"rotation",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/rotation.js#L10-L15 | train | Update the rotation of the object3D | [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
4874,
29097,
1027,
2023,
1012,
3449,
1012,
4874,
29097,
1025,
4874,
29097,
1012,
9963,
1012,
2275,
1006,
2139,
13512,
6525,
2094,
1006,
2951,
1012,
1060,
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... | |
SeleniumHQ/selenium | javascript/selenium-core/xpath/xpath.js | xpathSortByKey | function xpathSortByKey(v1, v2) {
// NOTE: Sort key vectors of different length never occur in
// xsltSort.
for (var i = 0; i < v1.key.length; ++i) {
var o = v1.key[i].order == 'descending' ? -1 : 1;
if (v1.key[i].value > v2.key[i].value) {
return +1 * o;
} else if (v1.key[i].value < v2.key[i].value) {
return -1 * o;
}
}
return 0;
} | javascript | function xpathSortByKey(v1, v2) {
// NOTE: Sort key vectors of different length never occur in
// xsltSort.
for (var i = 0; i < v1.key.length; ++i) {
var o = v1.key[i].order == 'descending' ? -1 : 1;
if (v1.key[i].value > v2.key[i].value) {
return +1 * o;
} else if (v1.key[i].value < v2.key[i].value) {
return -1 * o;
}
}
return 0;
} | [
"function",
"xpathSortByKey",
"(",
"v1",
",",
"v2",
")",
"{",
"// NOTE: Sort key vectors of different length never occur in",
"// xsltSort.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"v1",
".",
"key",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
... | Sorts by all order criteria defined. According to the JavaScript spec ([ECMA] Section 11.8.5), the compare operators compare strings as strings and numbers as numbers. NOTE: In browsers which do not follow the spec, this breaks only in the case that numbers should be sorted as strings, which is very uncommon. | [
"Sorts",
"by",
"all",
"order",
"criteria",
"defined",
".",
"According",
"to",
"the",
"JavaScript",
"spec",
"(",
"[",
"ECMA",
"]",
"Section",
"11",
".",
"8",
".",
"5",
")",
"the",
"compare",
"operators",
"compare",
"strings",
"as",
"strings",
"and",
"numb... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/xpath.js#L2461-L2475 | train | Sort by key vector | [
30522,
3853,
26726,
8988,
21748,
2102,
3762,
14839,
1006,
1058,
2487,
1010,
1058,
2475,
1007,
1063,
1013,
1013,
3602,
1024,
4066,
3145,
19019,
1997,
2367,
3091,
2196,
5258,
1999,
1013,
1013,
1060,
14540,
3215,
11589,
1012,
2005,
1006,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function(mTargetAnnotations, mSourceAnnotations) {
// Merge must be done on Term level, this is why the original line does not suffice any more:
// jQuery.extend(true, this.oAnnotations, mAnnotations);
// Terms are defined on different levels, the main one is below the target level, which is directly
// added as property to the annotations object and then in the same way inside two special properties
// named "propertyAnnotations" and "EntityContainer"
var sTarget, sTerm;
var aSpecialCases = ["annotationsAtArrays", "propertyAnnotations", "EntityContainer", "annotationReferences"];
// First merge standard annotations
for (sTarget in mSourceAnnotations) {
if (aSpecialCases.indexOf(sTarget) !== -1) {
// Skip these as they are special properties that contain Target level definitions
continue;
}
// ...all others contain Term level definitions
AnnotationParser._mergeAnnotation(sTarget, mSourceAnnotations, mTargetAnnotations);
}
// Now merge special cases except "annotationsAtArrays"
for (var i = 1; i < aSpecialCases.length; ++i) {
var sSpecialCase = aSpecialCases[i];
mTargetAnnotations[sSpecialCase] = mTargetAnnotations[sSpecialCase] || {}; // Make sure the target namespace exists
for (sTarget in mSourceAnnotations[sSpecialCase]) {
for (sTerm in mSourceAnnotations[sSpecialCase][sTarget]) {
// Now merge every term
mTargetAnnotations[sSpecialCase][sTarget] = mTargetAnnotations[sSpecialCase][sTarget] || {};
AnnotationParser._mergeAnnotation(sTerm, mSourceAnnotations[sSpecialCase][sTarget], mTargetAnnotations[sSpecialCase][sTarget]);
}
}
}
if (mSourceAnnotations.annotationsAtArrays) {
mTargetAnnotations.annotationsAtArrays = (mTargetAnnotations.annotationsAtArrays || [])
.concat(mSourceAnnotations.annotationsAtArrays);
}
} | javascript | function(mTargetAnnotations, mSourceAnnotations) {
// Merge must be done on Term level, this is why the original line does not suffice any more:
// jQuery.extend(true, this.oAnnotations, mAnnotations);
// Terms are defined on different levels, the main one is below the target level, which is directly
// added as property to the annotations object and then in the same way inside two special properties
// named "propertyAnnotations" and "EntityContainer"
var sTarget, sTerm;
var aSpecialCases = ["annotationsAtArrays", "propertyAnnotations", "EntityContainer", "annotationReferences"];
// First merge standard annotations
for (sTarget in mSourceAnnotations) {
if (aSpecialCases.indexOf(sTarget) !== -1) {
// Skip these as they are special properties that contain Target level definitions
continue;
}
// ...all others contain Term level definitions
AnnotationParser._mergeAnnotation(sTarget, mSourceAnnotations, mTargetAnnotations);
}
// Now merge special cases except "annotationsAtArrays"
for (var i = 1; i < aSpecialCases.length; ++i) {
var sSpecialCase = aSpecialCases[i];
mTargetAnnotations[sSpecialCase] = mTargetAnnotations[sSpecialCase] || {}; // Make sure the target namespace exists
for (sTarget in mSourceAnnotations[sSpecialCase]) {
for (sTerm in mSourceAnnotations[sSpecialCase][sTarget]) {
// Now merge every term
mTargetAnnotations[sSpecialCase][sTarget] = mTargetAnnotations[sSpecialCase][sTarget] || {};
AnnotationParser._mergeAnnotation(sTerm, mSourceAnnotations[sSpecialCase][sTarget], mTargetAnnotations[sSpecialCase][sTarget]);
}
}
}
if (mSourceAnnotations.annotationsAtArrays) {
mTargetAnnotations.annotationsAtArrays = (mTargetAnnotations.annotationsAtArrays || [])
.concat(mSourceAnnotations.annotationsAtArrays);
}
} | [
"function",
"(",
"mTargetAnnotations",
",",
"mSourceAnnotations",
")",
"{",
"// Merge must be done on Term level, this is why the original line does not suffice any more:",
"// jQuery.extend(true, this.oAnnotations, mAnnotations);",
"// Terms are defined on different levels, the main one is be... | Merges the given parsed annotation map into the given target annotation map.
@param {map} mTargetAnnotations The target annotation map into which the source annotations should be merged
@param {map} mSourceAnnotations The source annotation map that should be merged into the target annotation map
@static
@protected | [
"Merges",
"the",
"given",
"parsed",
"annotation",
"map",
"into",
"the",
"given",
"target",
"annotation",
"map",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L92-L133 | train | Merge the annotations from the source annotations to the target annotations | [
30522,
3853,
1006,
11047,
2906,
18150,
11639,
17287,
9285,
1010,
5796,
8162,
21456,
10695,
17287,
9285,
1007,
1063,
1013,
1013,
13590,
2442,
2022,
2589,
2006,
2744,
2504,
1010,
2023,
2003,
2339,
1996,
2434,
2240,
2515,
2025,
10514,
26989,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/analytics/odata4analytics.js | function(sPropertyName, sOperator, oValue, oValue2) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot add filter condition for unknown property name " + sPropertyName; // TODO
}
var aFilterablePropertyNames = this._oEntityType.getFilterablePropertyNames();
if (((aFilterablePropertyNames ? Array.prototype.indexOf.call(aFilterablePropertyNames, sPropertyName) : -1)) === -1) {
throw "Cannot add filter condition for not filterable property name " + sPropertyName; // TODO
}
this._addCondition(sPropertyName, sOperator, oValue, oValue2);
return this;
} | javascript | function(sPropertyName, sOperator, oValue, oValue2) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot add filter condition for unknown property name " + sPropertyName; // TODO
}
var aFilterablePropertyNames = this._oEntityType.getFilterablePropertyNames();
if (((aFilterablePropertyNames ? Array.prototype.indexOf.call(aFilterablePropertyNames, sPropertyName) : -1)) === -1) {
throw "Cannot add filter condition for not filterable property name " + sPropertyName; // TODO
}
this._addCondition(sPropertyName, sOperator, oValue, oValue2);
return this;
} | [
"function",
"(",
"sPropertyName",
",",
"sOperator",
",",
"oValue",
",",
"oValue2",
")",
"{",
"var",
"oProperty",
"=",
"this",
".",
"_oEntityType",
".",
"findPropertyByName",
"(",
"sPropertyName",
")",
";",
"if",
"(",
"oProperty",
"==",
"null",
")",
"{",
"t... | Add a condition to the filter expression.
Multiple conditions on the same property are combined with a logical OR first, and in a second step conditions for
different properties are combined with a logical AND.
@param {string}
sPropertyName The name of the property bound in the condition
@param {sap.ui.model.FilterOperator}
sOperator operator used for the condition
@param {object}
oValue value to be used for this condition
@param {object}
oValue2 (optional) as second value to be used for this condition
@throws Exception
if the property is unknown or not filterable
@returns {sap.ui.model.analytics.odata4analytics.FilterExpression} This object for method chaining
@public
@function
@name sap.ui.model.analytics.odata4analytics.FilterExpression#addCondition | [
"Add",
"a",
"condition",
"to",
"the",
"filter",
"expression",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3153-L3164 | train | Adds a filter condition to the filter expression. | [
30522,
3853,
1006,
11867,
18981,
15010,
18442,
1010,
2061,
4842,
8844,
1010,
9242,
5657,
1010,
9242,
5657,
2475,
1007,
1063,
13075,
6728,
18981,
15010,
1027,
2023,
1012,
1035,
1051,
4765,
3012,
13874,
1012,
2424,
21572,
4842,
3723,
3762,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/preferences/PreferencesBase.js | function (id, addBefore) {
var shadowScopeOrder = this._defaults._shadowScopeOrder,
index = _.findIndex(shadowScopeOrder, function (entry) {
return entry.id === id;
}),
entry;
if (index > -1) {
entry = shadowScopeOrder[index];
this._addToScopeOrder(entry.id, entry.scope, entry.promise, addBefore);
}
} | javascript | function (id, addBefore) {
var shadowScopeOrder = this._defaults._shadowScopeOrder,
index = _.findIndex(shadowScopeOrder, function (entry) {
return entry.id === id;
}),
entry;
if (index > -1) {
entry = shadowScopeOrder[index];
this._addToScopeOrder(entry.id, entry.scope, entry.promise, addBefore);
}
} | [
"function",
"(",
"id",
",",
"addBefore",
")",
"{",
"var",
"shadowScopeOrder",
"=",
"this",
".",
"_defaults",
".",
"_shadowScopeOrder",
",",
"index",
"=",
"_",
".",
"findIndex",
"(",
"shadowScopeOrder",
",",
"function",
"(",
"entry",
")",
"{",
"return",
"en... | Adds scope to the scope order by its id. The scope should be previously added to the preference system.
@param {string} id the scope id
@param {string} before the id of the scope to add before | [
"Adds",
"scope",
"to",
"the",
"scope",
"order",
"by",
"its",
"id",
".",
"The",
"scope",
"should",
"be",
"previously",
"added",
"to",
"the",
"preference",
"system",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1516-L1526 | train | Add a new record to the scope order | [
30522,
3853,
30524,
2121,
1010,
3853,
1006,
4443,
1007,
1063,
2709,
4443,
1012,
8909,
1027,
1027,
1027,
8909,
1025,
1065,
1007,
1010,
4443,
1025,
2065,
1006,
5950,
1028,
1011,
1015,
1007,
1063,
4443,
1027,
6281,
16186,
8551,
2121,
1031,
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... | |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function (sVersion) {
// remove all whitespaces
sVersion = sVersion.replace(/\s/g, "");
// get version without snapshot
// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will result in version 1.
var oRegexp1 = /\b\d{1,5}(.\d{1,5}){0,2}/g;
var oRegexp2 = /\b\d{1,5}(\.\d{1,5}){0,2}/g;
var nLength = sVersion.match(oRegexp1) ? sVersion.match(oRegexp1)[0].length : 0;
var nLenghtWithDot = sVersion.match(oRegexp2) ? sVersion.match(oRegexp2)[0].length : 0;
if (nLenghtWithDot < 1 || nLenghtWithDot != nLength){
return false;
}
//if the character after the version is also a number or a dot, it should also be a format error
if (nLenghtWithDot && sVersion != sVersion.substr(0,nLenghtWithDot)){
var cNextCharacter = sVersion.substr(nLenghtWithDot, 1);
var oRegexp = /^[0-9.]$/;
if (oRegexp.test(cNextCharacter)){
return false;
}
}
// split into number-parts and check if there are max. three parts
var aVersionParts = sVersion.substr(0,nLenghtWithDot).split(".");
if (aVersionParts.length > 3){
return false;
}
// 5 digits maximum per part
if (!aVersionParts.every(function(sPart){return sPart.length <= 5;})){
return false;
}
return true;
} | javascript | function (sVersion) {
// remove all whitespaces
sVersion = sVersion.replace(/\s/g, "");
// get version without snapshot
// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will result in version 1.
var oRegexp1 = /\b\d{1,5}(.\d{1,5}){0,2}/g;
var oRegexp2 = /\b\d{1,5}(\.\d{1,5}){0,2}/g;
var nLength = sVersion.match(oRegexp1) ? sVersion.match(oRegexp1)[0].length : 0;
var nLenghtWithDot = sVersion.match(oRegexp2) ? sVersion.match(oRegexp2)[0].length : 0;
if (nLenghtWithDot < 1 || nLenghtWithDot != nLength){
return false;
}
//if the character after the version is also a number or a dot, it should also be a format error
if (nLenghtWithDot && sVersion != sVersion.substr(0,nLenghtWithDot)){
var cNextCharacter = sVersion.substr(nLenghtWithDot, 1);
var oRegexp = /^[0-9.]$/;
if (oRegexp.test(cNextCharacter)){
return false;
}
}
// split into number-parts and check if there are max. three parts
var aVersionParts = sVersion.substr(0,nLenghtWithDot).split(".");
if (aVersionParts.length > 3){
return false;
}
// 5 digits maximum per part
if (!aVersionParts.every(function(sPart){return sPart.length <= 5;})){
return false;
}
return true;
} | [
"function",
"(",
"sVersion",
")",
"{",
"// remove all whitespaces",
"sVersion",
"=",
"sVersion",
".",
"replace",
"(",
"/",
"\\s",
"/",
"g",
",",
"\"\"",
")",
";",
"// get version without snapshot",
"// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will... | Checks if the application version has the correct format: "major.minor.patch".
@param {string} sVersion - Version of application
@returns {boolean} true if the format is correct, otherwise false
@public | [
"Checks",
"if",
"the",
"application",
"version",
"has",
"the",
"correct",
"format",
":",
"major",
".",
"minor",
".",
"patch",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L1192-L1227 | train | returns true if the version is a valid version | [
30522,
3853,
1006,
17917,
2545,
3258,
1007,
1063,
1013,
1013,
6366,
2035,
12461,
15327,
2015,
17917,
2545,
3258,
1027,
17917,
2545,
3258,
1012,
5672,
1006,
1013,
1032,
1055,
1013,
1043,
1010,
1000,
1000,
1007,
1025,
1013,
1013,
2131,
2544,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/routing/TargetCache.js | function () {
EventProvider.prototype.destroy.apply(this);
if (this.bIsDestroyed) {
return this;
}
function destroyObject(oObject) {
if (oObject && oObject.destroy) {
oObject.destroy();
}
}
Object.keys(this._oCache).forEach(function (sType) {
var oTypeCache = this._oCache[sType];
Object.keys(oTypeCache).forEach(function (sKey) {
var oInstanceCache = oTypeCache[sKey];
Object.keys(oInstanceCache).forEach(function(sId) {
var vObject = oInstanceCache[sId];
if (vObject instanceof Promise) { // if the promise isn't replaced by the real object yet
// wait until the promise resolves to destroy the object
vObject.then(destroyObject);
} else {
destroyObject(vObject);
}
});
});
}.bind(this));
this._oCache = undefined;
this.bIsDestroyed = true;
return this;
} | javascript | function () {
EventProvider.prototype.destroy.apply(this);
if (this.bIsDestroyed) {
return this;
}
function destroyObject(oObject) {
if (oObject && oObject.destroy) {
oObject.destroy();
}
}
Object.keys(this._oCache).forEach(function (sType) {
var oTypeCache = this._oCache[sType];
Object.keys(oTypeCache).forEach(function (sKey) {
var oInstanceCache = oTypeCache[sKey];
Object.keys(oInstanceCache).forEach(function(sId) {
var vObject = oInstanceCache[sId];
if (vObject instanceof Promise) { // if the promise isn't replaced by the real object yet
// wait until the promise resolves to destroy the object
vObject.then(destroyObject);
} else {
destroyObject(vObject);
}
});
});
}.bind(this));
this._oCache = undefined;
this.bIsDestroyed = true;
return this;
} | [
"function",
"(",
")",
"{",
"EventProvider",
".",
"prototype",
".",
"destroy",
".",
"apply",
"(",
"this",
")",
";",
"if",
"(",
"this",
".",
"bIsDestroyed",
")",
"{",
"return",
"this",
";",
"}",
"function",
"destroyObject",
"(",
"oObject",
")",
"{",
"if"... | Destroys all the views and components created by this instance.
@returns {sap.ui.core.routing.TargetCache} this for chaining. | [
"Destroys",
"all",
"the",
"views",
"and",
"components",
"created",
"by",
"this",
"instance",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/TargetCache.js#L155-L188 | train | Destroys the object cache | [
30522,
3853,
1006,
1007,
1063,
2724,
21572,
17258,
2121,
1012,
8773,
1012,
6033,
1012,
6611,
1006,
2023,
1007,
1025,
2065,
1006,
2023,
1012,
20377,
6155,
13181,
20821,
1007,
1063,
2709,
2023,
1025,
1065,
3853,
6033,
16429,
20614,
1006,
1051... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/scripts/htmlutils.js | function( elem, types, handler ) {
// don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
var events = jQuery.data( elem, "events" ), ret, type, fn;
if ( events ) {
// Unbind all events for the element
if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
for ( type in events ) {
this.remove( elem, type + (types || "") );
}
} else {
// types is actually an event object here
if ( types.type ) {
handler = types.handler;
types = types.type;
}
// Handle multiple events separated by a space
// jQuery(...).unbind("mouseover mouseout", fn);
types = types.split(/\s+/);
var i = 0;
while ( (type = types[ i++ ]) ) {
// Namespaced event handlers
var namespaces = type.split(".");
type = namespaces.shift();
var all = !namespaces.length,
cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
special = this.special[ type ] || {};
if ( events[ type ] ) {
// remove the given handler for the given type
if ( handler ) {
fn = events[ type ][ handler.guid ];
delete events[ type ][ handler.guid ];
// remove all handlers for the given type
} else {
for ( var handle in events[ type ] ) {
// Handle the removal of namespaced events
if ( all || namespace.test( events[ type ][ handle ].type ) ) {
delete events[ type ][ handle ];
}
}
}
if ( special.remove ) {
special.remove.call( elem, namespaces, fn);
}
// remove generic event handler if no more handlers exist
for ( ret in events[ type ] ) {
break;
}
if ( !ret ) {
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
if ( elem.removeEventListener ) {
elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
} else if ( elem.detachEvent ) {
elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
}
}
ret = null;
delete events[ type ];
}
}
}
}
// Remove the expando if it's no longer used
for ( ret in events ) {
break;
}
if ( !ret ) {
var handle = jQuery.data( elem, "handle" );
if ( handle ) {
handle.elem = null;
}
jQuery.removeData( elem, "events" );
jQuery.removeData( elem, "handle" );
}
}
} | javascript | function( elem, types, handler ) {
// don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
var events = jQuery.data( elem, "events" ), ret, type, fn;
if ( events ) {
// Unbind all events for the element
if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
for ( type in events ) {
this.remove( elem, type + (types || "") );
}
} else {
// types is actually an event object here
if ( types.type ) {
handler = types.handler;
types = types.type;
}
// Handle multiple events separated by a space
// jQuery(...).unbind("mouseover mouseout", fn);
types = types.split(/\s+/);
var i = 0;
while ( (type = types[ i++ ]) ) {
// Namespaced event handlers
var namespaces = type.split(".");
type = namespaces.shift();
var all = !namespaces.length,
cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
special = this.special[ type ] || {};
if ( events[ type ] ) {
// remove the given handler for the given type
if ( handler ) {
fn = events[ type ][ handler.guid ];
delete events[ type ][ handler.guid ];
// remove all handlers for the given type
} else {
for ( var handle in events[ type ] ) {
// Handle the removal of namespaced events
if ( all || namespace.test( events[ type ][ handle ].type ) ) {
delete events[ type ][ handle ];
}
}
}
if ( special.remove ) {
special.remove.call( elem, namespaces, fn);
}
// remove generic event handler if no more handlers exist
for ( ret in events[ type ] ) {
break;
}
if ( !ret ) {
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
if ( elem.removeEventListener ) {
elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
} else if ( elem.detachEvent ) {
elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
}
}
ret = null;
delete events[ type ];
}
}
}
}
// Remove the expando if it's no longer used
for ( ret in events ) {
break;
}
if ( !ret ) {
var handle = jQuery.data( elem, "handle" );
if ( handle ) {
handle.elem = null;
}
jQuery.removeData( elem, "events" );
jQuery.removeData( elem, "handle" );
}
}
} | [
"function",
"(",
"elem",
",",
"types",
",",
"handler",
")",
"{",
"// don't do events on text and comment nodes",
"if",
"(",
"elem",
".",
"nodeType",
"===",
"3",
"||",
"elem",
".",
"nodeType",
"===",
"8",
")",
"{",
"return",
";",
"}",
"var",
"events",
"=",
... | Detach an event or set of events from an element | [
"Detach",
"an",
"event",
"or",
"set",
"of",
"events",
"from",
"an",
"element"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L4266-L4352 | train | Remove event handlers for an element | [
30522,
3853,
1006,
3449,
6633,
1010,
4127,
1010,
28213,
1007,
1063,
1013,
1013,
2123,
1005,
1056,
2079,
2824,
2006,
3793,
1998,
7615,
14164,
2065,
1006,
3449,
6633,
1012,
13045,
13874,
1027,
1027,
1027,
1017,
1064,
1064,
3449,
6633,
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... | |
jgraph/mxgraph | javascript/mxClient.js | function(terminal, edge, source, defaultValue)
{
var value = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT,
mxUtils.getValue(edge.style, (source) ? mxConstants.STYLE_SOURCE_PORT_CONSTRAINT :
mxConstants.STYLE_TARGET_PORT_CONSTRAINT, null));
if (value == null)
{
return defaultValue;
}
else
{
var directions = value.toString();
var returnValue = mxConstants.DIRECTION_MASK_NONE;
var constraintRotationEnabled = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT_ROTATION, 0);
var rotation = 0;
if (constraintRotationEnabled == 1)
{
rotation = mxUtils.getValue(terminal.style, mxConstants.STYLE_ROTATION, 0);
}
var quad = 0;
if (rotation > 45)
{
quad = 1;
if (rotation >= 135)
{
quad = 2;
}
}
else if (rotation < -45)
{
quad = 3;
if (rotation <= -135)
{
quad = 2;
}
}
if (directions.indexOf(mxConstants.DIRECTION_NORTH) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_WEST) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_SOUTH) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_EAST) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
}
}
return returnValue;
}
} | javascript | function(terminal, edge, source, defaultValue)
{
var value = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT,
mxUtils.getValue(edge.style, (source) ? mxConstants.STYLE_SOURCE_PORT_CONSTRAINT :
mxConstants.STYLE_TARGET_PORT_CONSTRAINT, null));
if (value == null)
{
return defaultValue;
}
else
{
var directions = value.toString();
var returnValue = mxConstants.DIRECTION_MASK_NONE;
var constraintRotationEnabled = mxUtils.getValue(terminal.style, mxConstants.STYLE_PORT_CONSTRAINT_ROTATION, 0);
var rotation = 0;
if (constraintRotationEnabled == 1)
{
rotation = mxUtils.getValue(terminal.style, mxConstants.STYLE_ROTATION, 0);
}
var quad = 0;
if (rotation > 45)
{
quad = 1;
if (rotation >= 135)
{
quad = 2;
}
}
else if (rotation < -45)
{
quad = 3;
if (rotation <= -135)
{
quad = 2;
}
}
if (directions.indexOf(mxConstants.DIRECTION_NORTH) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_WEST) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_SOUTH) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
}
}
if (directions.indexOf(mxConstants.DIRECTION_EAST) >= 0)
{
switch (quad)
{
case 0:
returnValue |= mxConstants.DIRECTION_MASK_EAST;
break;
case 1:
returnValue |= mxConstants.DIRECTION_MASK_SOUTH;
break;
case 2:
returnValue |= mxConstants.DIRECTION_MASK_WEST;
break;
case 3:
returnValue |= mxConstants.DIRECTION_MASK_NORTH;
break;
}
}
return returnValue;
}
} | [
"function",
"(",
"terminal",
",",
"edge",
",",
"source",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"mxUtils",
".",
"getValue",
"(",
"terminal",
".",
"style",
",",
"mxConstants",
".",
"STYLE_PORT_CONSTRAINT",
",",
"mxUtils",
".",
"getValue",
"(",
... | Returns an integer mask of the port constraints of the given map
@param dict the style map to determine the port constraints for
@param defaultValue Default value to return if the key is undefined.
@return the mask of port constraint directions
Parameters:
terminal - <mxCelState> that represents the terminal.
edge - <mxCellState> that represents the edge.
source - Boolean that specifies if the terminal is the source terminal.
defaultValue - Default value to be returned. | [
"Returns",
"an",
"integer",
"mask",
"of",
"the",
"port",
"constraints",
"of",
"the",
"given",
"map",
"@param",
"dict",
"the",
"style",
"map",
"to",
"determine",
"the",
"port",
"constraints",
"for",
"@param",
"defaultValue",
"Default",
"value",
"to",
"return",
... | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4273-L4391 | train | Returns the direction mask of the given edge | [
30522,
3853,
1006,
5536,
1010,
3341,
1010,
3120,
1010,
12398,
10175,
5657,
1007,
1063,
13075,
3643,
1027,
25630,
21823,
4877,
1012,
2131,
10175,
5657,
1006,
5536,
1012,
2806,
1010,
25630,
8663,
12693,
3215,
1012,
2806,
1035,
3417,
1035,
271... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
ecomfe/zrender | build/babel-plugin-transform-modules-commonjs-ec.js | getLocalExportMetadata | function getLocalExportMetadata(programPath){
const bindingKindLookup = new Map();
programPath.get('body').forEach(child => {
let kind;
if (child.isImportDeclaration()) {
kind = 'import';
}
else {
if (child.isExportDefaultDeclaration()) {
child = child.get('declaration');
}
if (child.isExportNamedDeclaration() && child.node.declaration) {
child = child.get('declaration');
}
if (child.isFunctionDeclaration()) {
kind = 'hoisted';
}
else if (child.isClassDeclaration()) {
kind = 'block';
}
else if (child.isVariableDeclaration({ kind: 'var' })) {
kind = 'var';
}
else if (child.isVariableDeclaration()) {
kind = 'block';
}
else {
return;
}
}
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {
bindingKindLookup.set(name, kind);
});
});
const localMetadata = new Map();
const getLocalMetadata = idPath => {
const localName = idPath.node.name;
let metadata = localMetadata.get(localName);
if (!metadata) {
const kind = bindingKindLookup.get(localName);
if (kind === undefined) {
throw idPath.buildCodeFrameError(`Exporting local "${localName}", which is not declared.`);
}
metadata = {
names: [],
kind,
};
localMetadata.set(localName, metadata);
}
return metadata;
};
programPath.get('body').forEach(child => {
if (child.isExportNamedDeclaration() && !child.node.source) {
if (child.node.declaration) {
const declaration = child.get('declaration');
const ids = declaration.getOuterBindingIdentifierPaths();
Object.keys(ids).forEach(name => {
if (name === '__esModule') {
throw declaration.buildCodeFrameError('Illegal export "__esModule".');
}
getLocalMetadata(ids[name]).names.push(name);
});
}
else {
child.get('specifiers').forEach(spec => {
const local = spec.get('local');
const exported = spec.get('exported');
if (exported.node.name === '__esModule') {
throw exported.buildCodeFrameError('Illegal export "__esModule".');
}
getLocalMetadata(local).names.push(exported.node.name);
});
}
}
else if (child.isExportDefaultDeclaration()) {
const declaration = child.get('declaration');
if (
declaration.isFunctionDeclaration() ||
declaration.isClassDeclaration()
) {
getLocalMetadata(declaration.get('id')).names.push('default');
}
else {
// These should have been removed by the nameAnonymousExports() call.
throw declaration.buildCodeFrameError('Unexpected default expression export.');
}
}
});
return localMetadata;
} | javascript | function getLocalExportMetadata(programPath){
const bindingKindLookup = new Map();
programPath.get('body').forEach(child => {
let kind;
if (child.isImportDeclaration()) {
kind = 'import';
}
else {
if (child.isExportDefaultDeclaration()) {
child = child.get('declaration');
}
if (child.isExportNamedDeclaration() && child.node.declaration) {
child = child.get('declaration');
}
if (child.isFunctionDeclaration()) {
kind = 'hoisted';
}
else if (child.isClassDeclaration()) {
kind = 'block';
}
else if (child.isVariableDeclaration({ kind: 'var' })) {
kind = 'var';
}
else if (child.isVariableDeclaration()) {
kind = 'block';
}
else {
return;
}
}
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {
bindingKindLookup.set(name, kind);
});
});
const localMetadata = new Map();
const getLocalMetadata = idPath => {
const localName = idPath.node.name;
let metadata = localMetadata.get(localName);
if (!metadata) {
const kind = bindingKindLookup.get(localName);
if (kind === undefined) {
throw idPath.buildCodeFrameError(`Exporting local "${localName}", which is not declared.`);
}
metadata = {
names: [],
kind,
};
localMetadata.set(localName, metadata);
}
return metadata;
};
programPath.get('body').forEach(child => {
if (child.isExportNamedDeclaration() && !child.node.source) {
if (child.node.declaration) {
const declaration = child.get('declaration');
const ids = declaration.getOuterBindingIdentifierPaths();
Object.keys(ids).forEach(name => {
if (name === '__esModule') {
throw declaration.buildCodeFrameError('Illegal export "__esModule".');
}
getLocalMetadata(ids[name]).names.push(name);
});
}
else {
child.get('specifiers').forEach(spec => {
const local = spec.get('local');
const exported = spec.get('exported');
if (exported.node.name === '__esModule') {
throw exported.buildCodeFrameError('Illegal export "__esModule".');
}
getLocalMetadata(local).names.push(exported.node.name);
});
}
}
else if (child.isExportDefaultDeclaration()) {
const declaration = child.get('declaration');
if (
declaration.isFunctionDeclaration() ||
declaration.isClassDeclaration()
) {
getLocalMetadata(declaration.get('id')).names.push('default');
}
else {
// These should have been removed by the nameAnonymousExports() call.
throw declaration.buildCodeFrameError('Unexpected default expression export.');
}
}
});
return localMetadata;
} | [
"function",
"getLocalExportMetadata",
"(",
"programPath",
")",
"{",
"const",
"bindingKindLookup",
"=",
"new",
"Map",
"(",
")",
";",
"programPath",
".",
"get",
"(",
"'body'",
")",
".",
"forEach",
"(",
"child",
"=>",
"{",
"let",
"kind",
";",
"if",
"(",
"ch... | Get metadata about local variables that are exported.
@return {Map<string, LocalExportMetadata>} | [
"Get",
"metadata",
"about",
"local",
"variables",
"that",
"are",
"exported",
"."
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/build/babel-plugin-transform-modules-commonjs-ec.js#L263-L363 | train | Get local export metadata | [
30522,
3853,
2131,
4135,
9289,
10288,
6442,
11368,
8447,
2696,
1006,
2565,
15069,
1007,
1063,
9530,
3367,
8031,
18824,
4135,
21940,
2361,
1027,
2047,
4949,
1006,
1007,
1025,
2565,
15069,
1012,
2131,
1006,
1005,
2303,
1005,
1007,
1012,
18921... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
tensorflow/tfjs-models | knn-classifier/demo/camera.js | animate | async function animate() {
stats.begin();
// Get image data from video element
const image = tf.browser.fromPixels(video);
let logits;
// 'conv_preds' is the logits activation of MobileNet.
const infer = () => mobilenet.infer(image, 'conv_preds');
// Train class if one of the buttons is held down
if (training != -1) {
logits = infer();
// Add current image to classifier
classifier.addExample(logits, training);
}
// If the classifier has examples for any classes, make a prediction!
const numClasses = classifier.getNumClasses();
if (numClasses > 0) {
logits = infer();
const res = await classifier.predictClass(logits, TOPK);
for (let i = 0; i < NUM_CLASSES; i++) {
// Make the predicted class bold
if (res.classIndex == i) {
infoTexts[i].style.fontWeight = 'bold';
} else {
infoTexts[i].style.fontWeight = 'normal';
}
const classExampleCount = classifier.getClassExampleCount();
// Update info text
if (classExampleCount[i] > 0) {
const conf = res.confidences[i] * 100;
infoTexts[i].innerText = ` ${classExampleCount[i]} examples - ${conf}%`;
}
}
}
image.dispose();
if (logits != null) {
logits.dispose();
}
stats.end();
requestAnimationFrame(animate);
} | javascript | async function animate() {
stats.begin();
// Get image data from video element
const image = tf.browser.fromPixels(video);
let logits;
// 'conv_preds' is the logits activation of MobileNet.
const infer = () => mobilenet.infer(image, 'conv_preds');
// Train class if one of the buttons is held down
if (training != -1) {
logits = infer();
// Add current image to classifier
classifier.addExample(logits, training);
}
// If the classifier has examples for any classes, make a prediction!
const numClasses = classifier.getNumClasses();
if (numClasses > 0) {
logits = infer();
const res = await classifier.predictClass(logits, TOPK);
for (let i = 0; i < NUM_CLASSES; i++) {
// Make the predicted class bold
if (res.classIndex == i) {
infoTexts[i].style.fontWeight = 'bold';
} else {
infoTexts[i].style.fontWeight = 'normal';
}
const classExampleCount = classifier.getClassExampleCount();
// Update info text
if (classExampleCount[i] > 0) {
const conf = res.confidences[i] * 100;
infoTexts[i].innerText = ` ${classExampleCount[i]} examples - ${conf}%`;
}
}
}
image.dispose();
if (logits != null) {
logits.dispose();
}
stats.end();
requestAnimationFrame(animate);
} | [
"async",
"function",
"animate",
"(",
")",
"{",
"stats",
".",
"begin",
"(",
")",
";",
"// Get image data from video element",
"const",
"image",
"=",
"tf",
".",
"browser",
".",
"fromPixels",
"(",
"video",
")",
";",
"let",
"logits",
";",
"// 'conv_preds' is the l... | Animation function called on each frame, running prediction | [
"Animation",
"function",
"called",
"on",
"each",
"frame",
"running",
"prediction"
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/knn-classifier/demo/camera.js#L124-L171 | train | Animate the image | [
30522,
2004,
6038,
2278,
3853,
2019,
21499,
1006,
1007,
1063,
26319,
1012,
4088,
1006,
1007,
1025,
1013,
1013,
2131,
3746,
2951,
2013,
2678,
5783,
9530,
3367,
3746,
1027,
1056,
2546,
1012,
16602,
1012,
2013,
8197,
2595,
9050,
1006,
2678,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | bower_components/chart.js/Chart.js | function(){
// First we need the width of the yLabels, assuming the xLabels aren't rotated
// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
this.startPoint = (this.display) ? this.fontSize : 0;
this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
// Apply padding settings to the start and end point.
this.startPoint += this.padding;
this.endPoint -= this.padding;
// Cache the starting height, so can determine if we need to recalculate the scale yAxis
var cachedHeight = this.endPoint - this.startPoint,
cachedYLabelWidth;
// Build the current yLabels so we have an idea of what size they'll be to start
/*
* This sets what is returned from calculateScaleRange as static properties of this class:
*
this.steps;
this.stepValue;
this.min;
this.max;
*
*/
this.calculateYRange(cachedHeight);
// With these properties set we can now build the array of yLabels
// and also the width of the largest yLabel
this.buildYLabels();
this.calculateXLabelRotation();
while((cachedHeight > this.endPoint - this.startPoint)){
cachedHeight = this.endPoint - this.startPoint;
cachedYLabelWidth = this.yLabelWidth;
this.calculateYRange(cachedHeight);
this.buildYLabels();
// Only go through the xLabel loop again if the yLabel width has changed
if (cachedYLabelWidth < this.yLabelWidth){
this.calculateXLabelRotation();
}
}
} | javascript | function(){
// First we need the width of the yLabels, assuming the xLabels aren't rotated
// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation
this.startPoint = (this.display) ? this.fontSize : 0;
this.endPoint = (this.display) ? this.height - (this.fontSize * 1.5) - 5 : this.height; // -5 to pad labels
// Apply padding settings to the start and end point.
this.startPoint += this.padding;
this.endPoint -= this.padding;
// Cache the starting height, so can determine if we need to recalculate the scale yAxis
var cachedHeight = this.endPoint - this.startPoint,
cachedYLabelWidth;
// Build the current yLabels so we have an idea of what size they'll be to start
/*
* This sets what is returned from calculateScaleRange as static properties of this class:
*
this.steps;
this.stepValue;
this.min;
this.max;
*
*/
this.calculateYRange(cachedHeight);
// With these properties set we can now build the array of yLabels
// and also the width of the largest yLabel
this.buildYLabels();
this.calculateXLabelRotation();
while((cachedHeight > this.endPoint - this.startPoint)){
cachedHeight = this.endPoint - this.startPoint;
cachedYLabelWidth = this.yLabelWidth;
this.calculateYRange(cachedHeight);
this.buildYLabels();
// Only go through the xLabel loop again if the yLabel width has changed
if (cachedYLabelWidth < this.yLabelWidth){
this.calculateXLabelRotation();
}
}
} | [
"function",
"(",
")",
"{",
"// First we need the width of the yLabels, assuming the xLabels aren't rotated",
"// To do that we need the base line at the top and base of the chart, assuming there is no x label rotation",
"this",
".",
"startPoint",
"=",
"(",
"this",
".",
"display",
")",
... | Fitting loop to rotate x Labels and figure out what fits there, and also calculate how many Y steps to use | [
"Fitting",
"loop",
"to",
"rotate",
"x",
"Labels",
"and",
"figure",
"out",
"what",
"fits",
"there",
"and",
"also",
"calculate",
"how",
"many",
"Y",
"steps",
"to",
"use"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/chart.js/Chart.js#L1482-L1528 | train | Calculate the y range of the y labels | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
2034,
2057,
2342,
1996,
9381,
1997,
1996,
1061,
20470,
9050,
1010,
10262,
1996,
28712,
16336,
4877,
4995,
1005,
1056,
20931,
1013,
1013,
2000,
2079,
2008,
2057,
2342,
1996,
2918,
2240,
2012,
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... | |
SheetJS/js-xlsx | bits/44_offcrypto.js | parse_RC4CryptoHeader | function parse_RC4CryptoHeader(blob, length/*:number*/) {
var o = {};
var vers = o.EncryptionVersionInfo = parse_CRYPTOVersion(blob, 4); length -= 4;
if(vers.Minor != 2) throw new Error('unrecognized minor version code: ' + vers.Minor);
if(vers.Major > 4 || vers.Major < 2) throw new Error('unrecognized major version code: ' + vers.Major);
o.Flags = blob.read_shift(4); length -= 4;
var sz = blob.read_shift(4); length -= 4;
o.EncryptionHeader = parse_EncryptionHeader(blob, sz); length -= sz;
o.EncryptionVerifier = parse_EncryptionVerifier(blob, length);
return o;
} | javascript | function parse_RC4CryptoHeader(blob, length/*:number*/) {
var o = {};
var vers = o.EncryptionVersionInfo = parse_CRYPTOVersion(blob, 4); length -= 4;
if(vers.Minor != 2) throw new Error('unrecognized minor version code: ' + vers.Minor);
if(vers.Major > 4 || vers.Major < 2) throw new Error('unrecognized major version code: ' + vers.Major);
o.Flags = blob.read_shift(4); length -= 4;
var sz = blob.read_shift(4); length -= 4;
o.EncryptionHeader = parse_EncryptionHeader(blob, sz); length -= sz;
o.EncryptionVerifier = parse_EncryptionVerifier(blob, length);
return o;
} | [
"function",
"parse_RC4CryptoHeader",
"(",
"blob",
",",
"length",
"/*:number*/",
")",
"{",
"var",
"o",
"=",
"{",
"}",
";",
"var",
"vers",
"=",
"o",
".",
"EncryptionVersionInfo",
"=",
"parse_CRYPTOVersion",
"(",
"blob",
",",
"4",
")",
";",
"length",
"-=",
... | /* [MS-OFFCRYPTO] 2.3.5.1 RC4 CryptoAPI Encryption Header | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"3",
".",
"5",
".",
"1",
"RC4",
"CryptoAPI",
"Encryption",
"Header"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/44_offcrypto.js#L169-L179 | train | Parse the RC4 Crypto Header | [
30522,
3853,
11968,
3366,
1035,
22110,
2549,
26775,
22571,
3406,
4974,
2121,
1006,
1038,
4135,
2497,
1010,
3091,
1013,
1008,
1024,
2193,
1008,
1013,
1007,
1063,
13075,
1051,
1027,
1063,
1065,
1025,
13075,
2310,
2869,
1027,
1051,
1012,
21999... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | mxText | function mxText(value, bounds, align, valign, color,
family, size, fontStyle, spacing, spacingTop, spacingRight,
spacingBottom, spacingLeft, horizontal, background, border,
wrap, clipped, overflow, labelPadding, textDirection)
{
mxShape.call(this);
this.value = value;
this.bounds = bounds;
this.color = (color != null) ? color : 'black';
this.align = (align != null) ? align : mxConstants.ALIGN_CENTER;
this.valign = (valign != null) ? valign : mxConstants.ALIGN_MIDDLE;
this.family = (family != null) ? family : mxConstants.DEFAULT_FONTFAMILY;
this.size = (size != null) ? size : mxConstants.DEFAULT_FONTSIZE;
this.fontStyle = (fontStyle != null) ? fontStyle : mxConstants.DEFAULT_FONTSTYLE;
this.spacing = parseInt(spacing || 2);
this.spacingTop = this.spacing + parseInt(spacingTop || 0);
this.spacingRight = this.spacing + parseInt(spacingRight || 0);
this.spacingBottom = this.spacing + parseInt(spacingBottom || 0);
this.spacingLeft = this.spacing + parseInt(spacingLeft || 0);
this.horizontal = (horizontal != null) ? horizontal : true;
this.background = background;
this.border = border;
this.wrap = (wrap != null) ? wrap : false;
this.clipped = (clipped != null) ? clipped : false;
this.overflow = (overflow != null) ? overflow : 'visible';
this.labelPadding = (labelPadding != null) ? labelPadding : 0;
this.textDirection = textDirection;
this.rotation = 0;
this.updateMargin();
} | javascript | function mxText(value, bounds, align, valign, color,
family, size, fontStyle, spacing, spacingTop, spacingRight,
spacingBottom, spacingLeft, horizontal, background, border,
wrap, clipped, overflow, labelPadding, textDirection)
{
mxShape.call(this);
this.value = value;
this.bounds = bounds;
this.color = (color != null) ? color : 'black';
this.align = (align != null) ? align : mxConstants.ALIGN_CENTER;
this.valign = (valign != null) ? valign : mxConstants.ALIGN_MIDDLE;
this.family = (family != null) ? family : mxConstants.DEFAULT_FONTFAMILY;
this.size = (size != null) ? size : mxConstants.DEFAULT_FONTSIZE;
this.fontStyle = (fontStyle != null) ? fontStyle : mxConstants.DEFAULT_FONTSTYLE;
this.spacing = parseInt(spacing || 2);
this.spacingTop = this.spacing + parseInt(spacingTop || 0);
this.spacingRight = this.spacing + parseInt(spacingRight || 0);
this.spacingBottom = this.spacing + parseInt(spacingBottom || 0);
this.spacingLeft = this.spacing + parseInt(spacingLeft || 0);
this.horizontal = (horizontal != null) ? horizontal : true;
this.background = background;
this.border = border;
this.wrap = (wrap != null) ? wrap : false;
this.clipped = (clipped != null) ? clipped : false;
this.overflow = (overflow != null) ? overflow : 'visible';
this.labelPadding = (labelPadding != null) ? labelPadding : 0;
this.textDirection = textDirection;
this.rotation = 0;
this.updateMargin();
} | [
"function",
"mxText",
"(",
"value",
",",
"bounds",
",",
"align",
",",
"valign",
",",
"color",
",",
"family",
",",
"size",
",",
"fontStyle",
",",
"spacing",
",",
"spacingTop",
",",
"spacingRight",
",",
"spacingBottom",
",",
"spacingLeft",
",",
"horizontal",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxText
Extends <mxShape> to implement a text shape. To change vertical text from
bottom to top to top to bottom, the following code can be used:
(code)
mxText.prototype.verticalTextRotation = 90;
(end)
Constructor: mxText
Constructs a new text shape.
Parameters:
value - String that represents the text to be displayed. This is stored in
<value>.
bounds - <mxRectangle> that defines the bounds. This is stored in
<mxShape.bounds>.
align - Specifies the horizontal alignment. Default is ''. This is stored in
<align>.
valign - Specifies the vertical alignment. Default is ''. This is stored in
<valign>.
color - String that specifies the text color. Default is 'black'. This is
stored in <color>.
family - String that specifies the font family. Default is
<mxConstants.DEFAULT_FONTFAMILY>. This is stored in <family>.
size - Integer that specifies the font size. Default is
<mxConstants.DEFAULT_FONTSIZE>. This is stored in <size>.
fontStyle - Specifies the font style. Default is 0. This is stored in
<fontStyle>.
spacing - Integer that specifies the global spacing. Default is 2. This is
stored in <spacing>.
spacingTop - Integer that specifies the top spacing. Default is 0. The
sum of the spacing and this is stored in <spacingTop>.
spacingRight - Integer that specifies the right spacing. Default is 0. The
sum of the spacing and this is stored in <spacingRight>.
spacingBottom - Integer that specifies the bottom spacing. Default is 0.The
sum of the spacing and this is stored in <spacingBottom>.
spacingLeft - Integer that specifies the left spacing. Default is 0. The
sum of the spacing and this is stored in <spacingLeft>.
horizontal - Boolean that specifies if the label is horizontal. Default is
true. This is stored in <horizontal>.
background - String that specifies the background color. Default is null.
This is stored in <background>.
border - String that specifies the label border color. Default is null.
This is stored in <border>.
wrap - Specifies if word-wrapping should be enabled. Default is false.
This is stored in <wrap>.
clipped - Specifies if the label should be clipped. Default is false.
This is stored in <clipped>.
overflow - Value of the overflow style. Default is 'visible'. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxText"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L26096-L26125 | train | A text shape | [
30522,
3853,
25630,
18209,
1006,
3643,
1010,
19202,
1010,
25705,
1010,
11748,
23773,
1010,
3609,
1010,
2155,
1010,
2946,
1010,
15489,
21756,
2571,
1010,
12403,
6129,
1010,
12403,
6129,
14399,
1010,
12403,
6129,
15950,
1010,
12403,
6129,
18384... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | gatsby-browser.js | scrollToElementId | function scrollToElementId(id) {
const el = document.querySelector(id)
if (el) {
return window.scrollTo(0, el.offsetTop - 20)
} else {
return false
}
} | javascript | function scrollToElementId(id) {
const el = document.querySelector(id)
if (el) {
return window.scrollTo(0, el.offsetTop - 20)
} else {
return false
}
} | [
"function",
"scrollToElementId",
"(",
"id",
")",
"{",
"const",
"el",
"=",
"document",
".",
"querySelector",
"(",
"id",
")",
"if",
"(",
"el",
")",
"{",
"return",
"window",
".",
"scrollTo",
"(",
"0",
",",
"el",
".",
"offsetTop",
"-",
"20",
")",
"}",
... | Adapted from https://github.com/gatsbyjs/gatsby/issues/8413 | [
"Adapted",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"gatsbyjs",
"/",
"gatsby",
"/",
"issues",
"/",
"8413"
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/gatsby-browser.js#L4-L11 | train | scrollToElementId - scroll to element id | [
30522,
3853,
17186,
3406,
12260,
3672,
3593,
1006,
8909,
1007,
1063,
9530,
3367,
3449,
1027,
6254,
1012,
23032,
11246,
22471,
2953,
1006,
8909,
1007,
2065,
1006,
3449,
1007,
1063,
2709,
3332,
1012,
17186,
3406,
1006,
1014,
1010,
3449,
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... |
babel/babel | packages/babel-standalone/src/index.js | processOptions | function processOptions(options) {
// Parse preset names
const presets = (options.presets || []).map(presetName => {
const preset = loadBuiltin(availablePresets, presetName);
if (preset) {
// workaround for babel issue
// at some point, babel copies the preset, losing the non-enumerable
// buildPreset key; convert it into an enumerable key.
if (
isArray(preset) &&
typeof preset[0] === "object" &&
preset[0].hasOwnProperty("buildPreset")
) {
preset[0] = { ...preset[0], buildPreset: preset[0].buildPreset };
}
} else {
throw new Error(
`Invalid preset specified in Babel options: "${presetName}"`,
);
}
return preset;
});
// Parse plugin names
const plugins = (options.plugins || []).map(pluginName => {
const plugin = loadBuiltin(availablePlugins, pluginName);
if (!plugin) {
throw new Error(
`Invalid plugin specified in Babel options: "${pluginName}"`,
);
}
return plugin;
});
return {
babelrc: false,
...options,
presets,
plugins,
};
} | javascript | function processOptions(options) {
// Parse preset names
const presets = (options.presets || []).map(presetName => {
const preset = loadBuiltin(availablePresets, presetName);
if (preset) {
// workaround for babel issue
// at some point, babel copies the preset, losing the non-enumerable
// buildPreset key; convert it into an enumerable key.
if (
isArray(preset) &&
typeof preset[0] === "object" &&
preset[0].hasOwnProperty("buildPreset")
) {
preset[0] = { ...preset[0], buildPreset: preset[0].buildPreset };
}
} else {
throw new Error(
`Invalid preset specified in Babel options: "${presetName}"`,
);
}
return preset;
});
// Parse plugin names
const plugins = (options.plugins || []).map(pluginName => {
const plugin = loadBuiltin(availablePlugins, pluginName);
if (!plugin) {
throw new Error(
`Invalid plugin specified in Babel options: "${pluginName}"`,
);
}
return plugin;
});
return {
babelrc: false,
...options,
presets,
plugins,
};
} | [
"function",
"processOptions",
"(",
"options",
")",
"{",
"// Parse preset names",
"const",
"presets",
"=",
"(",
"options",
".",
"presets",
"||",
"[",
"]",
")",
".",
"map",
"(",
"presetName",
"=>",
"{",
"const",
"preset",
"=",
"loadBuiltin",
"(",
"availablePre... | Parses plugin names and presets from the specified options. | [
"Parses",
"plugin",
"names",
"and",
"presets",
"from",
"the",
"specified",
"options",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-standalone/src/index.js#L57-L99 | train | Process Babel options | [
30522,
3853,
2832,
7361,
9285,
1006,
7047,
1007,
1063,
1013,
1013,
11968,
3366,
3653,
13462,
3415,
9530,
3367,
3653,
13462,
2015,
1027,
1006,
7047,
1012,
3653,
13462,
2015,
1064,
1064,
1031,
1033,
1007,
1012,
4949,
1006,
3653,
13462,
18442,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | third_party/polymer3/bower_components/polymer/lib/utils/gestures.js | function(mouseEvent) {
// Check for sourceCapabilities, used to distinguish synthetic events
// if mouseEvent did not come from a device that fires touch events,
// it was made by a real mouse and should be counted
// http://wicg.github.io/InputDeviceCapabilities/#dom-inputdevicecapabilities-firestouchevents
let sc = mouseEvent.sourceCapabilities;
if (sc && !sc.firesTouchEvents) {
return;
}
// skip synthetic mouse events
mouseEvent[HANDLED_OBJ] = {skip: true};
// disable "ghost clicks"
if (mouseEvent.type === 'click') {
let clickFromLabel = false;
let path = mouseEvent.composedPath && mouseEvent.composedPath();
if (path) {
for (let i = 0; i < path.length; i++) {
if (path[i].nodeType === Node.ELEMENT_NODE) {
if (path[i].localName === 'label') {
clickedLabels.push(path[i]);
} else if (canBeLabelled(path[i])) {
let ownerLabels = matchingLabels(path[i]);
// check if one of the clicked labels is labelling this element
for (let j = 0; j < ownerLabels.length; j++) {
clickFromLabel = clickFromLabel || clickedLabels.indexOf(ownerLabels[j]) > -1;
}
}
}
if (path[i] === POINTERSTATE.mouse.target) {
return;
}
}
}
// if one of the clicked labels was labelling the target element,
// this is not a ghost click
if (clickFromLabel) {
return;
}
mouseEvent.preventDefault();
mouseEvent.stopPropagation();
}
} | javascript | function(mouseEvent) {
// Check for sourceCapabilities, used to distinguish synthetic events
// if mouseEvent did not come from a device that fires touch events,
// it was made by a real mouse and should be counted
// http://wicg.github.io/InputDeviceCapabilities/#dom-inputdevicecapabilities-firestouchevents
let sc = mouseEvent.sourceCapabilities;
if (sc && !sc.firesTouchEvents) {
return;
}
// skip synthetic mouse events
mouseEvent[HANDLED_OBJ] = {skip: true};
// disable "ghost clicks"
if (mouseEvent.type === 'click') {
let clickFromLabel = false;
let path = mouseEvent.composedPath && mouseEvent.composedPath();
if (path) {
for (let i = 0; i < path.length; i++) {
if (path[i].nodeType === Node.ELEMENT_NODE) {
if (path[i].localName === 'label') {
clickedLabels.push(path[i]);
} else if (canBeLabelled(path[i])) {
let ownerLabels = matchingLabels(path[i]);
// check if one of the clicked labels is labelling this element
for (let j = 0; j < ownerLabels.length; j++) {
clickFromLabel = clickFromLabel || clickedLabels.indexOf(ownerLabels[j]) > -1;
}
}
}
if (path[i] === POINTERSTATE.mouse.target) {
return;
}
}
}
// if one of the clicked labels was labelling the target element,
// this is not a ghost click
if (clickFromLabel) {
return;
}
mouseEvent.preventDefault();
mouseEvent.stopPropagation();
}
} | [
"function",
"(",
"mouseEvent",
")",
"{",
"// Check for sourceCapabilities, used to distinguish synthetic events",
"// if mouseEvent did not come from a device that fires touch events,",
"// it was made by a real mouse and should be counted",
"// http://wicg.github.io/InputDeviceCapabilities/#dom-inp... | touch will make synthetic mouse events `preventDefault` on touchend will cancel them, but this breaks `<input>` focus and link clicks disable mouse handlers for MOUSE_TIMEOUT ms after a touchend to ignore synthetic mouse events | [
"touch",
"will",
"make",
"synthetic",
"mouse",
"events",
"preventDefault",
"on",
"touchend",
"will",
"cancel",
"them",
"but",
"this",
"breaks",
"<input",
">",
"focus",
"and",
"link",
"clicks",
"disable",
"mouse",
"handlers",
"for",
"MOUSE_TIMEOUT",
"ms",
"after"... | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/polymer3/bower_components/polymer/lib/utils/gestures.js#L152-L193 | train | Check for synthetic mouse events | [
30522,
3853,
1006,
8000,
18697,
3372,
1007,
1063,
1013,
1013,
4638,
2005,
3120,
17695,
28518,
15909,
3111,
1010,
2109,
2000,
10782,
12553,
2824,
1013,
1013,
2065,
8000,
18697,
3372,
2106,
2025,
2272,
2013,
1037,
5080,
2008,
8769,
3543,
2824... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/HTMLDOMDiff.js | domdiff | function domdiff(oldNode, newNode) {
var queue = [],
edits = [],
moves = [],
newElement,
oldElement,
oldNodeMap = oldNode ? oldNode.nodeMap : {},
newNodeMap = newNode.nodeMap;
/**
* Adds elements to the queue for generateChildEdits.
* Only elements (and not text nodes) are added. New nodes (ones that aren't in the
* old nodeMap), are not added here because they will be added when generateChildEdits
* creates the elementInsert edit.
*/
var queuePush = function (node) {
if (node.children && oldNodeMap[node.tagID]) {
queue.push(node);
}
};
/**
* Aggregates the child edits in the proper data structures.
*
* @param {Object} delta edits, moves and newElements to add
*/
var addEdits = function (delta) {
edits.push.apply(edits, delta.edits);
moves.push.apply(moves, delta.moves);
queue.push.apply(queue, delta.newElements);
};
// Start at the root of the current tree.
queue.push(newNode);
do {
newElement = queue.pop();
oldElement = oldNodeMap[newElement.tagID];
// Do we need to compare elements?
if (oldElement) {
// Are attributes different?
if (newElement.attributeSignature !== oldElement.attributeSignature) {
// generate attribute edits
edits.push.apply(edits, generateAttributeEdits(oldElement, newElement));
}
// Has there been a change to this node's immediate children?
if (newElement.childSignature !== oldElement.childSignature) {
addEdits(generateChildEdits(oldElement, oldNodeMap, newElement, newNodeMap));
}
// If there's a change farther down in the tree, add the children to the queue.
// If not, we can skip that whole subtree.
if (newElement.subtreeSignature !== oldElement.subtreeSignature) {
newElement.children.forEach(queuePush);
}
// This is a new element, so go straight to generating child edits (which will
// create the appropriate Insert edits).
} else {
// If this is the root (html) tag, we need to manufacture an insert for it here,
// because it isn't the child of any other node. The browser-side code doesn't
// care about parentage/positioning in this case, and will handle just setting the
// ID on the existing implied HTML tag in the browser without actually creating it.
if (!newElement.parent) {
edits.push({
type: "elementInsert",
tag: newElement.tag,
tagID: newElement.tagID,
parentID: null,
attributes: newElement.attributes
});
}
addEdits(generateChildEdits(null, oldNodeMap, newElement, newNodeMap));
}
} while (queue.length);
// Special handling for moves: add edits to the beginning of the list so that
// moved nodes are set aside to ensure that they remain available at the time of their
// move.
if (moves.length > 0) {
edits.unshift({
type: "rememberNodes",
tagIDs: moves
});
}
return edits;
} | javascript | function domdiff(oldNode, newNode) {
var queue = [],
edits = [],
moves = [],
newElement,
oldElement,
oldNodeMap = oldNode ? oldNode.nodeMap : {},
newNodeMap = newNode.nodeMap;
/**
* Adds elements to the queue for generateChildEdits.
* Only elements (and not text nodes) are added. New nodes (ones that aren't in the
* old nodeMap), are not added here because they will be added when generateChildEdits
* creates the elementInsert edit.
*/
var queuePush = function (node) {
if (node.children && oldNodeMap[node.tagID]) {
queue.push(node);
}
};
/**
* Aggregates the child edits in the proper data structures.
*
* @param {Object} delta edits, moves and newElements to add
*/
var addEdits = function (delta) {
edits.push.apply(edits, delta.edits);
moves.push.apply(moves, delta.moves);
queue.push.apply(queue, delta.newElements);
};
// Start at the root of the current tree.
queue.push(newNode);
do {
newElement = queue.pop();
oldElement = oldNodeMap[newElement.tagID];
// Do we need to compare elements?
if (oldElement) {
// Are attributes different?
if (newElement.attributeSignature !== oldElement.attributeSignature) {
// generate attribute edits
edits.push.apply(edits, generateAttributeEdits(oldElement, newElement));
}
// Has there been a change to this node's immediate children?
if (newElement.childSignature !== oldElement.childSignature) {
addEdits(generateChildEdits(oldElement, oldNodeMap, newElement, newNodeMap));
}
// If there's a change farther down in the tree, add the children to the queue.
// If not, we can skip that whole subtree.
if (newElement.subtreeSignature !== oldElement.subtreeSignature) {
newElement.children.forEach(queuePush);
}
// This is a new element, so go straight to generating child edits (which will
// create the appropriate Insert edits).
} else {
// If this is the root (html) tag, we need to manufacture an insert for it here,
// because it isn't the child of any other node. The browser-side code doesn't
// care about parentage/positioning in this case, and will handle just setting the
// ID on the existing implied HTML tag in the browser without actually creating it.
if (!newElement.parent) {
edits.push({
type: "elementInsert",
tag: newElement.tag,
tagID: newElement.tagID,
parentID: null,
attributes: newElement.attributes
});
}
addEdits(generateChildEdits(null, oldNodeMap, newElement, newNodeMap));
}
} while (queue.length);
// Special handling for moves: add edits to the beginning of the list so that
// moved nodes are set aside to ensure that they remain available at the time of their
// move.
if (moves.length > 0) {
edits.unshift({
type: "rememberNodes",
tagIDs: moves
});
}
return edits;
} | [
"function",
"domdiff",
"(",
"oldNode",
",",
"newNode",
")",
"{",
"var",
"queue",
"=",
"[",
"]",
",",
"edits",
"=",
"[",
"]",
",",
"moves",
"=",
"[",
"]",
",",
"newElement",
",",
"oldElement",
",",
"oldNodeMap",
"=",
"oldNode",
"?",
"oldNode",
".",
... | Generate a list of edits that will mutate oldNode to look like newNode.
Currently, there are the following possible edit operations:
* elementInsert
* elementDelete
* elementMove
* textInsert
* textDelete
* textReplace
* attrDelete
* attrChange
* attrAdd
* rememberNodes (a special instruction that reflects the need to hang on to moved nodes)
@param {Object} oldNode SimpleDOM node with the original content
@param {Object} newNode SimpleDOM node with the new content
@return {Array.{Object}} list of edit operations | [
"Generate",
"a",
"list",
"of",
"edits",
"that",
"will",
"mutate",
"oldNode",
"to",
"look",
"like",
"newNode",
".",
"Currently",
"there",
"are",
"the",
"following",
"possible",
"edit",
"operations",
":"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L535-L626 | train | diff function for domdiff | [
30522,
3853,
14383,
4305,
4246,
1006,
2214,
3630,
3207,
1010,
2047,
3630,
3207,
1007,
1063,
13075,
24240,
1027,
1031,
1033,
1010,
10086,
2015,
1027,
1031,
1033,
1010,
5829,
1027,
1031,
1033,
1010,
2047,
12260,
3672,
1010,
2214,
12260,
3672,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/qunit/utils/ControlIterator.js | _run | function _run(fnCallback, mOptions) {
if (!mOptions) {
mOptions = {};
}
var fnDone = mOptions.done || function(){};
var aLibrariesToTest = mOptions.librariesToTest || undefined;
var aExcludedLibraries = mOptions.excludedLibraries || [];
var aControlsToTest = mOptions.controlsToTest || [];
var aExcludedControls = mOptions.excludedControls || [];
var bIncludeDistLayer = (mOptions.includeDistLayer !== undefined) ? mOptions.includeDistLayer : false;
var bIncludeElements = (mOptions.includeElements !== undefined) ? mOptions.includeElements : false;
var bIncludeNonRenderable = (mOptions.includeNonRenderable !== undefined) ? mOptions.includeNonRenderable : true;
var bIncludeNonInstantiable = (mOptions.includeNonInstantiable !== undefined) ? mOptions.includeNonInstantiable : false;
var QUnit = mOptions.qunit;
if (QUnit) { // verify it's good
QUnit.test("Checking the given QUnit object", function(assert) {
assert.ok(true, "The given QUnit should be able to assert");
});
} else { // otherwise create a mock QUnit that can be used for assert.ok() only
var nop = function(){};
var assert = {
ok: function(bCondition, sText) {
if (!bCondition) {
throw new Error(sText);
}
},
expect: nop
};
QUnit = {
module: nop,
test: function (text, fnCallback) {
fnCallback(assert);
}
};
}
// check given parameters
QUnit.test("Checking the given options", function(assert) {
assert.ok(mOptions.librariesToTest === undefined || jQuery.isArray(mOptions.librariesToTest), "The given librariesToTest must be undefined or an array, but is: " + mOptions.librariesToTest);
assert.ok(mOptions.excludedLibraries === undefined || jQuery.isArray(mOptions.excludedLibraries), "The given excludedLibraries must be undefined or an array, but is: " + mOptions.excludedLibraries);
assert.ok(mOptions.excludedControls === undefined || jQuery.isArray(mOptions.excludedControls), "The given excludedControls must be undefined or an array, but is: " + mOptions.excludedControls);
assert.ok(mOptions.includeDistLayer === undefined || typeof mOptions.includeDistLayer === "boolean", "The given includeDistLayer must be undefined or a boolean, but is: " + mOptions.includeDistLayer);
assert.ok(mOptions.includeElements === undefined || typeof mOptions.includeElements === "boolean", "The given includeElements must be undefined or a boolean, but is: " + mOptions.includeElements);
assert.ok(mOptions.includeNonRenderable === undefined || typeof mOptions.includeNonRenderable === "boolean", "The given includeNonRenderable must be undefined or a boolean, but is: " + mOptions.includeNonRenderable);
assert.ok(mOptions.includeNonInstantiable === undefined || typeof mOptions.includeNonInstantiable === "boolean", "The given includeNonInstantiable must be undefined or a boolean, but is: " + mOptions.includeNonInstantiable);
assert.ok(fnDone === undefined || typeof fnDone === "function", "The given done callback must be undefined or a function, but is: " + fnDone);
});
// get the libraries we are interested in
var mLibraries = getLibraries(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit);
loopLibraries(mLibraries, bIncludeElements, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(aResults){
fnDone({
testedControlCount: aResults[0],
testedLibraryCount: aResults[1]
});
});
} | javascript | function _run(fnCallback, mOptions) {
if (!mOptions) {
mOptions = {};
}
var fnDone = mOptions.done || function(){};
var aLibrariesToTest = mOptions.librariesToTest || undefined;
var aExcludedLibraries = mOptions.excludedLibraries || [];
var aControlsToTest = mOptions.controlsToTest || [];
var aExcludedControls = mOptions.excludedControls || [];
var bIncludeDistLayer = (mOptions.includeDistLayer !== undefined) ? mOptions.includeDistLayer : false;
var bIncludeElements = (mOptions.includeElements !== undefined) ? mOptions.includeElements : false;
var bIncludeNonRenderable = (mOptions.includeNonRenderable !== undefined) ? mOptions.includeNonRenderable : true;
var bIncludeNonInstantiable = (mOptions.includeNonInstantiable !== undefined) ? mOptions.includeNonInstantiable : false;
var QUnit = mOptions.qunit;
if (QUnit) { // verify it's good
QUnit.test("Checking the given QUnit object", function(assert) {
assert.ok(true, "The given QUnit should be able to assert");
});
} else { // otherwise create a mock QUnit that can be used for assert.ok() only
var nop = function(){};
var assert = {
ok: function(bCondition, sText) {
if (!bCondition) {
throw new Error(sText);
}
},
expect: nop
};
QUnit = {
module: nop,
test: function (text, fnCallback) {
fnCallback(assert);
}
};
}
// check given parameters
QUnit.test("Checking the given options", function(assert) {
assert.ok(mOptions.librariesToTest === undefined || jQuery.isArray(mOptions.librariesToTest), "The given librariesToTest must be undefined or an array, but is: " + mOptions.librariesToTest);
assert.ok(mOptions.excludedLibraries === undefined || jQuery.isArray(mOptions.excludedLibraries), "The given excludedLibraries must be undefined or an array, but is: " + mOptions.excludedLibraries);
assert.ok(mOptions.excludedControls === undefined || jQuery.isArray(mOptions.excludedControls), "The given excludedControls must be undefined or an array, but is: " + mOptions.excludedControls);
assert.ok(mOptions.includeDistLayer === undefined || typeof mOptions.includeDistLayer === "boolean", "The given includeDistLayer must be undefined or a boolean, but is: " + mOptions.includeDistLayer);
assert.ok(mOptions.includeElements === undefined || typeof mOptions.includeElements === "boolean", "The given includeElements must be undefined or a boolean, but is: " + mOptions.includeElements);
assert.ok(mOptions.includeNonRenderable === undefined || typeof mOptions.includeNonRenderable === "boolean", "The given includeNonRenderable must be undefined or a boolean, but is: " + mOptions.includeNonRenderable);
assert.ok(mOptions.includeNonInstantiable === undefined || typeof mOptions.includeNonInstantiable === "boolean", "The given includeNonInstantiable must be undefined or a boolean, but is: " + mOptions.includeNonInstantiable);
assert.ok(fnDone === undefined || typeof fnDone === "function", "The given done callback must be undefined or a function, but is: " + fnDone);
});
// get the libraries we are interested in
var mLibraries = getLibraries(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit);
loopLibraries(mLibraries, bIncludeElements, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(aResults){
fnDone({
testedControlCount: aResults[0],
testedLibraryCount: aResults[1]
});
});
} | [
"function",
"_run",
"(",
"fnCallback",
",",
"mOptions",
")",
"{",
"if",
"(",
"!",
"mOptions",
")",
"{",
"mOptions",
"=",
"{",
"}",
";",
"}",
"var",
"fnDone",
"=",
"mOptions",
".",
"done",
"||",
"function",
"(",
")",
"{",
"}",
";",
"var",
"aLibrarie... | Called by run() with a 1:1 parameter forwarding | [
"Called",
"by",
"run",
"()",
"with",
"a",
"1",
":",
"1",
"parameter",
"forwarding"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L479-L539 | train | Run the test | [
30522,
3853,
1035,
2448,
1006,
1042,
20909,
3363,
5963,
1010,
9587,
16790,
2015,
1007,
1063,
2065,
1006,
999,
9587,
16790,
2015,
1007,
1063,
9587,
16790,
2015,
1027,
1063,
1065,
1025,
1065,
13075,
1042,
19333,
2063,
1027,
9587,
16790,
2015,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | doSearch | function doSearch(editor, searchBackwards) {
var state = getSearchState(editor._codeMirror);
if (state.parsedQuery) {
findNext(editor, searchBackwards);
} else {
openSearchBar(editor, false);
}
} | javascript | function doSearch(editor, searchBackwards) {
var state = getSearchState(editor._codeMirror);
if (state.parsedQuery) {
findNext(editor, searchBackwards);
} else {
openSearchBar(editor, false);
}
} | [
"function",
"doSearch",
"(",
"editor",
",",
"searchBackwards",
")",
"{",
"var",
"state",
"=",
"getSearchState",
"(",
"editor",
".",
"_codeMirror",
")",
";",
"if",
"(",
"state",
".",
"parsedQuery",
")",
"{",
"findNext",
"(",
"editor",
",",
"searchBackwards",
... | If no search pending, opens the Find dialog. If search bar already open, moves to
next/prev result (depending on 'searchBackwards') | [
"If",
"no",
"search",
"pending",
"opens",
"the",
"Find",
"dialog",
".",
"If",
"search",
"bar",
"already",
"open",
"moves",
"to",
"next",
"/",
"prev",
"result",
"(",
"depending",
"on",
"searchBackwards",
")"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L655-L663 | train | doSearch - Search for a search term | [
30522,
3853,
13004,
2906,
2818,
1006,
3559,
1010,
3945,
5963,
7652,
2015,
1007,
1063,
13075,
2110,
1027,
4152,
14644,
18069,
12259,
1006,
3559,
1012,
1035,
3642,
14503,
29165,
1007,
1025,
2065,
1006,
2110,
1012,
11968,
6924,
4226,
2854,
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... |
openlayers/openlayers | src/ol/pointer/MouseSource.js | mousedown | function mousedown(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091
if (POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
const e = prepareEvent(inEvent, this.dispatcher);
this.pointerMap[POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent);
}
} | javascript | function mousedown(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091
if (POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
const e = prepareEvent(inEvent, this.dispatcher);
this.pointerMap[POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent);
}
} | [
"function",
"mousedown",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"// TODO(dfreedman) workaround for some elements not sending mouseup",
"// http://crbug/149091",
"if",
"(",
"POINTER_ID",
".",
"t... | Handler for `mousedown`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mousedown",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L63-L74 | train | mouse down event handler | [
30522,
3853,
8000,
7698,
1006,
1999,
18697,
3372,
1007,
1063,
2065,
1006,
999,
2023,
1012,
2003,
18697,
7666,
5714,
8898,
19699,
5358,
24826,
2818,
1035,
1006,
1999,
18697,
3372,
1007,
1007,
1063,
1013,
1013,
28681,
2080,
1006,
1040,
23301,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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(obj, array)
{
var result = null;
if (typeof(array) == 'object')
{
var index = mxUtils.indexOf(array, obj);
while (index >= 0)
{
array.splice(index, 1);
result = obj;
index = mxUtils.indexOf(array, obj);
}
}
for (var key in array)
{
if (array[key] == obj)
{
delete array[key];
result = obj;
}
}
return result;
} | javascript | function(obj, array)
{
var result = null;
if (typeof(array) == 'object')
{
var index = mxUtils.indexOf(array, obj);
while (index >= 0)
{
array.splice(index, 1);
result = obj;
index = mxUtils.indexOf(array, obj);
}
}
for (var key in array)
{
if (array[key] == obj)
{
delete array[key];
result = obj;
}
}
return result;
} | [
"function",
"(",
"obj",
",",
"array",
")",
"{",
"var",
"result",
"=",
"null",
";",
"if",
"(",
"typeof",
"(",
"array",
")",
"==",
"'object'",
")",
"{",
"var",
"index",
"=",
"mxUtils",
".",
"indexOf",
"(",
"array",
",",
"obj",
")",
";",
"while",
"(... | Function: remove
Removes all occurrences of the given object in the given array or
object. If there are multiple occurrences of the object, be they
associative or as an array entry, all occurrences are removed from
the array or deleted from the object. By removing the object from
the array, all elements following the removed element are shifted
by one step towards the beginning of the array.
The length of arrays is not modified inside this function.
Parameters:
obj - Object to find in the given array.
array - Array to check for the given obj. | [
"Function",
":",
"remove"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L2533-L2559 | train | Removes an object from an array | [
30522,
3853,
1006,
27885,
3501,
1010,
9140,
1007,
1063,
13075,
2765,
1027,
19701,
1025,
2065,
1006,
2828,
11253,
1006,
9140,
1007,
1027,
1027,
1005,
4874,
1005,
1007,
1063,
13075,
5950,
1027,
25630,
21823,
4877,
1012,
5950,
11253,
1006,
914... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ripple/ripple.js | getElementColor | function getElementColor () {
var items = self.options && self.options.colorElement ? self.options.colorElement : [];
var elem = items.length ? items[ 0 ] : self.$element[ 0 ];
return elem ? self.$window.getComputedStyle(elem).color : 'rgb(0,0,0)';
} | javascript | function getElementColor () {
var items = self.options && self.options.colorElement ? self.options.colorElement : [];
var elem = items.length ? items[ 0 ] : self.$element[ 0 ];
return elem ? self.$window.getComputedStyle(elem).color : 'rgb(0,0,0)';
} | [
"function",
"getElementColor",
"(",
")",
"{",
"var",
"items",
"=",
"self",
".",
"options",
"&&",
"self",
".",
"options",
".",
"colorElement",
"?",
"self",
".",
"options",
".",
"colorElement",
":",
"[",
"]",
";",
"var",
"elem",
"=",
"items",
".",
"lengt... | Finds the color element and returns its text color for use as default ripple color
@returns {string} | [
"Finds",
"the",
"color",
"element",
"and",
"returns",
"its",
"text",
"color",
"for",
"use",
"as",
"default",
"ripple",
"color"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/ripple/ripple.js#L214-L219 | train | Get the color of the element | [
30522,
3853,
2131,
12260,
3672,
18717,
1006,
1007,
1063,
13075,
5167,
1027,
2969,
1012,
7047,
1004,
1004,
2969,
1012,
7047,
1012,
3609,
12260,
3672,
1029,
2969,
1012,
7047,
1012,
3609,
12260,
3672,
1024,
1031,
1033,
1025,
13075,
3449,
6633,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/crossroads.js | Route | function Route(pattern, callback, priority, router) {
var isRegexPattern = isRegExp(pattern),
patternLexer = router.patternLexer;
this._router = router;
this._pattern = pattern;
this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(pattern);
this._optionalParamsIds = isRegexPattern? null : patternLexer.getOptionalParamsIds(pattern);
this._matchRegexp = isRegexPattern? pattern : patternLexer.compilePattern(pattern, router.ignoreCase);
this.matched = new signals.Signal();
this.switched = new signals.Signal();
if (callback) {
this.matched.add(callback);
}
this._priority = priority || 0;
} | javascript | function Route(pattern, callback, priority, router) {
var isRegexPattern = isRegExp(pattern),
patternLexer = router.patternLexer;
this._router = router;
this._pattern = pattern;
this._paramsIds = isRegexPattern? null : patternLexer.getParamIds(pattern);
this._optionalParamsIds = isRegexPattern? null : patternLexer.getOptionalParamsIds(pattern);
this._matchRegexp = isRegexPattern? pattern : patternLexer.compilePattern(pattern, router.ignoreCase);
this.matched = new signals.Signal();
this.switched = new signals.Signal();
if (callback) {
this.matched.add(callback);
}
this._priority = priority || 0;
} | [
"function",
"Route",
"(",
"pattern",
",",
"callback",
",",
"priority",
",",
"router",
")",
"{",
"var",
"isRegexPattern",
"=",
"isRegExp",
"(",
"pattern",
")",
",",
"patternLexer",
"=",
"router",
".",
"patternLexer",
";",
"this",
".",
"_router",
"=",
"route... | Route -------------- =====================
@constructor | [
"Route",
"--------------",
"====================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/crossroads.js#L292-L306 | train | Constructor for Route | [
30522,
3853,
2799,
1006,
5418,
1010,
2655,
5963,
1010,
9470,
1010,
2799,
2099,
1007,
1063,
13075,
2003,
2890,
3351,
2595,
4502,
12079,
2078,
1027,
2003,
2890,
3351,
2595,
2361,
1006,
5418,
1007,
1010,
5418,
2571,
2595,
2121,
1027,
2799,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | examples/demo-app/src/utils/cloud-providers/dropbox.js | getAccessToken | function getAccessToken() {
let token = dropbox.getAccessToken();
if (!token && window.localStorage) {
const jsonString = window.localStorage.getItem('dropbox');
token = jsonString && JSON.parse(jsonString).token;
if (token) {
dropbox.setAccessToken(token);
}
}
return (token || '') !== '' ? token : null;
} | javascript | function getAccessToken() {
let token = dropbox.getAccessToken();
if (!token && window.localStorage) {
const jsonString = window.localStorage.getItem('dropbox');
token = jsonString && JSON.parse(jsonString).token;
if (token) {
dropbox.setAccessToken(token);
}
}
return (token || '') !== '' ? token : null;
} | [
"function",
"getAccessToken",
"(",
")",
"{",
"let",
"token",
"=",
"dropbox",
".",
"getAccessToken",
"(",
")",
";",
"if",
"(",
"!",
"token",
"&&",
"window",
".",
"localStorage",
")",
"{",
"const",
"jsonString",
"=",
"window",
".",
"localStorage",
".",
"ge... | Provides the current dropbox auth token. If stored in localStorage is set onto dropbox handler and returned
@returns {any} | [
"Provides",
"the",
"current",
"dropbox",
"auth",
"token",
".",
"If",
"stored",
"in",
"localStorage",
"is",
"set",
"onto",
"dropbox",
"handler",
"and",
"returned"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/utils/cloud-providers/dropbox.js#L150-L161 | train | Get the token from the local storage | [
30522,
3853,
2131,
6305,
9623,
16033,
7520,
1006,
1007,
1063,
2292,
19204,
1027,
4530,
8758,
1012,
2131,
6305,
9623,
16033,
7520,
1006,
1007,
1025,
2065,
1006,
999,
19204,
1004,
1004,
3332,
1012,
10575,
4263,
4270,
1007,
1063,
9530,
3367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/light.js | function () {
var el = this.el;
var data = this.data;
var light = this.light;
light.castShadow = data.castShadow;
// Shadow camera helper.
var cameraHelper = el.getObject3D('cameraHelper');
if (data.shadowCameraVisible && !cameraHelper) {
el.setObject3D('cameraHelper', new THREE.CameraHelper(light.shadow.camera));
} else if (!data.shadowCameraVisible && cameraHelper) {
el.removeObject3D('cameraHelper');
}
if (!data.castShadow) { return light; }
// Shadow appearance.
light.shadow.bias = data.shadowBias;
light.shadow.radius = data.shadowRadius;
light.shadow.mapSize.height = data.shadowMapHeight;
light.shadow.mapSize.width = data.shadowMapWidth;
// Shadow camera.
light.shadow.camera.near = data.shadowCameraNear;
light.shadow.camera.far = data.shadowCameraFar;
if (light.shadow.camera instanceof THREE.OrthographicCamera) {
light.shadow.camera.top = data.shadowCameraTop;
light.shadow.camera.right = data.shadowCameraRight;
light.shadow.camera.bottom = data.shadowCameraBottom;
light.shadow.camera.left = data.shadowCameraLeft;
} else {
light.shadow.camera.fov = data.shadowCameraFov;
}
light.shadow.camera.updateProjectionMatrix();
if (cameraHelper) { cameraHelper.update(); }
} | javascript | function () {
var el = this.el;
var data = this.data;
var light = this.light;
light.castShadow = data.castShadow;
// Shadow camera helper.
var cameraHelper = el.getObject3D('cameraHelper');
if (data.shadowCameraVisible && !cameraHelper) {
el.setObject3D('cameraHelper', new THREE.CameraHelper(light.shadow.camera));
} else if (!data.shadowCameraVisible && cameraHelper) {
el.removeObject3D('cameraHelper');
}
if (!data.castShadow) { return light; }
// Shadow appearance.
light.shadow.bias = data.shadowBias;
light.shadow.radius = data.shadowRadius;
light.shadow.mapSize.height = data.shadowMapHeight;
light.shadow.mapSize.width = data.shadowMapWidth;
// Shadow camera.
light.shadow.camera.near = data.shadowCameraNear;
light.shadow.camera.far = data.shadowCameraFar;
if (light.shadow.camera instanceof THREE.OrthographicCamera) {
light.shadow.camera.top = data.shadowCameraTop;
light.shadow.camera.right = data.shadowCameraRight;
light.shadow.camera.bottom = data.shadowCameraBottom;
light.shadow.camera.left = data.shadowCameraLeft;
} else {
light.shadow.camera.fov = data.shadowCameraFov;
}
light.shadow.camera.updateProjectionMatrix();
if (cameraHelper) { cameraHelper.update(); }
} | [
"function",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"light",
"=",
"this",
".",
"light",
";",
"light",
".",
"castShadow",
"=",
"data",
".",
"castShadow",
";",
"// Shadow camera help... | Updates shadow-related properties on the current light. | [
"Updates",
"shadow",
"-",
"related",
"properties",
"on",
"the",
"current",
"light",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/light.js#L168-L205 | train | Update shadow properties | [
30522,
3853,
1006,
1007,
1063,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
2422,
1027,
2023,
1012,
2422,
1025,
2422,
1012,
23942,
16102,
5004,
1027,
2951,
1012,
23942,
16102,
5004,
1025,
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... | |
nhn/tui.editor | src/js/wysiwygCommands/tableRemoveCol.js | focusToCell | function focusToCell(sq, $cell, tableMgr) {
const nextFocusCell = $cell.get(0);
if ($cell.length && $.contains(document, $cell)) {
const range = sq.getSelection();
range.selectNodeContents($cell[0]);
range.collapse(true);
sq.setSelection(range);
tableMgr.setLastCellNode(nextFocusCell);
}
} | javascript | function focusToCell(sq, $cell, tableMgr) {
const nextFocusCell = $cell.get(0);
if ($cell.length && $.contains(document, $cell)) {
const range = sq.getSelection();
range.selectNodeContents($cell[0]);
range.collapse(true);
sq.setSelection(range);
tableMgr.setLastCellNode(nextFocusCell);
}
} | [
"function",
"focusToCell",
"(",
"sq",
",",
"$cell",
",",
"tableMgr",
")",
"{",
"const",
"nextFocusCell",
"=",
"$cell",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"$cell",
".",
"length",
"&&",
"$",
".",
"contains",
"(",
"document",
",",
"$cell",
")",
... | Focus to given cell
@param {Squire} sq - Squire instance
@param {jQuery} $cell - jQuery wrapped table cell
@param {object} tableMgr - Table manager instance | [
"Focus",
"to",
"given",
"cell"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableRemoveCol.js#L112-L123 | train | Focus to cell | [
30522,
3853,
3579,
3406,
29109,
2140,
1006,
5490,
1010,
1002,
3526,
1010,
2795,
24798,
2099,
1007,
1063,
9530,
3367,
2279,
14876,
7874,
29109,
2140,
1027,
1002,
3526,
1012,
2131,
1006,
1014,
1007,
1025,
2065,
1006,
1002,
3526,
1012,
3091,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
testing-library/dom-testing-library | src/query-helpers.js | makeGetAllQuery | function makeGetAllQuery(allQuery, getMissingError) {
return (container, ...args) => {
const els = allQuery(container, ...args)
if (!els.length) {
throw getElementError(getMissingError(container, ...args), container)
}
return els
}
} | javascript | function makeGetAllQuery(allQuery, getMissingError) {
return (container, ...args) => {
const els = allQuery(container, ...args)
if (!els.length) {
throw getElementError(getMissingError(container, ...args), container)
}
return els
}
} | [
"function",
"makeGetAllQuery",
"(",
"allQuery",
",",
"getMissingError",
")",
"{",
"return",
"(",
"container",
",",
"...",
"args",
")",
"=>",
"{",
"const",
"els",
"=",
"allQuery",
"(",
"container",
",",
"...",
"args",
")",
"if",
"(",
"!",
"els",
".",
"l... | this accepts a query function and returns a function which throws an error if an empty list of elements is returned | [
"this",
"accepts",
"a",
"query",
"function",
"and",
"returns",
"a",
"function",
"which",
"throws",
"an",
"error",
"if",
"an",
"empty",
"list",
"of",
"elements",
"is",
"returned"
] | fcb2cbcffb7aff6ecff3be8731168c86eee82ce1 | https://github.com/testing-library/dom-testing-library/blob/fcb2cbcffb7aff6ecff3be8731168c86eee82ce1/src/query-helpers.js#L83-L91 | train | Returns a function that will return an array of elements that match the query. | [
30522,
3853,
2191,
18150,
8095,
4226,
2854,
1006,
2035,
4226,
2854,
1010,
2131,
15630,
7741,
2121,
29165,
1007,
1063,
2709,
1006,
11661,
1010,
1012,
1012,
1012,
30524,
5466,
2131,
12260,
3672,
2121,
29165,
1006,
2131,
15630,
7741,
2121,
291... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/events/F6Navigation.js | findFirstTabbableOfPreviousGroup | function findFirstTabbableOfPreviousGroup($FirstTabbableInScope, $Tabbables, oSouceGroup, bFindPreviousGroup) {
var oGroup, $Target;
for (var i = $Tabbables.length - 1; i >= 0; i--) {
oGroup = findClosestGroup($Tabbables[i]);
if (oGroup != oSouceGroup) {
if (bFindPreviousGroup) {
//First find last tabbable of previous group and remember this new group (named "X" in the following comments)
oSouceGroup = oGroup;
bFindPreviousGroup = false;
} else {
//Then starting from group X and try to find again the last tabbable of previous group (named "Y")
//-> Jump one tabbable back to get the first tabbable of X
$Target = jQuery($Tabbables[i + 1]);
break;
}
}
}
if (!$Target && !bFindPreviousGroup) {
//Group X found but not group Y -> X is the first group -> Focus the first tabbable scope (e.g. page) element
$Target = $FirstTabbableInScope;
}
return $Target;
} | javascript | function findFirstTabbableOfPreviousGroup($FirstTabbableInScope, $Tabbables, oSouceGroup, bFindPreviousGroup) {
var oGroup, $Target;
for (var i = $Tabbables.length - 1; i >= 0; i--) {
oGroup = findClosestGroup($Tabbables[i]);
if (oGroup != oSouceGroup) {
if (bFindPreviousGroup) {
//First find last tabbable of previous group and remember this new group (named "X" in the following comments)
oSouceGroup = oGroup;
bFindPreviousGroup = false;
} else {
//Then starting from group X and try to find again the last tabbable of previous group (named "Y")
//-> Jump one tabbable back to get the first tabbable of X
$Target = jQuery($Tabbables[i + 1]);
break;
}
}
}
if (!$Target && !bFindPreviousGroup) {
//Group X found but not group Y -> X is the first group -> Focus the first tabbable scope (e.g. page) element
$Target = $FirstTabbableInScope;
}
return $Target;
} | [
"function",
"findFirstTabbableOfPreviousGroup",
"(",
"$FirstTabbableInScope",
",",
"$Tabbables",
",",
"oSouceGroup",
",",
"bFindPreviousGroup",
")",
"{",
"var",
"oGroup",
",",
"$Target",
";",
"for",
"(",
"var",
"i",
"=",
"$Tabbables",
".",
"length",
"-",
"1",
";... | see navigate() (bForward = false) | [
"see",
"navigate",
"()",
"(",
"bForward",
"=",
"false",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/F6Navigation.js#L124-L149 | train | Find the first tabbable of the previous group | [
30522,
3853,
2424,
8873,
12096,
2696,
22414,
3468,
11253,
28139,
24918,
17058,
1006,
1002,
2034,
2696,
22414,
3468,
7076,
16186,
1010,
1002,
21628,
3676,
13510,
1010,
9808,
7140,
3401,
17058,
1010,
28939,
22254,
28139,
24918,
17058,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | examples/nextjs-next/src/Link.js | Link | function Link(props) {
const { activeClassName, router, className: classNameProps, naked, ...other } = props;
const className = clsx(classNameProps, {
[activeClassName]: router.pathname === props.href && activeClassName,
});
if (naked) {
return <NextComposed className={className} {...other} />;
}
return <MuiLink component={NextComposed} className={className} {...other} />;
} | javascript | function Link(props) {
const { activeClassName, router, className: classNameProps, naked, ...other } = props;
const className = clsx(classNameProps, {
[activeClassName]: router.pathname === props.href && activeClassName,
});
if (naked) {
return <NextComposed className={className} {...other} />;
}
return <MuiLink component={NextComposed} className={className} {...other} />;
} | [
"function",
"Link",
"(",
"props",
")",
"{",
"const",
"{",
"activeClassName",
",",
"router",
",",
"className",
":",
"classNameProps",
",",
"naked",
",",
"...",
"other",
"}",
"=",
"props",
";",
"const",
"className",
"=",
"clsx",
"(",
"classNameProps",
",",
... | A styled version of the Next.js Link component: https://nextjs.org/docs/#with-link | [
"A",
"styled",
"version",
"of",
"the",
"Next",
".",
"js",
"Link",
"component",
":",
"https",
":",
"//",
"nextjs",
".",
"org",
"/",
"docs",
"/",
"#with",
"-",
"link"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/examples/nextjs-next/src/Link.js#L27-L39 | train | Link component | [
30522,
3853,
4957,
1006,
24387,
1007,
1063,
9530,
3367,
1063,
3161,
26266,
18442,
1010,
2799,
2099,
1010,
2465,
18442,
1024,
2465,
18442,
21572,
4523,
1010,
6248,
1010,
1012,
1012,
1012,
2060,
1065,
1027,
24387,
1025,
9530,
3367,
2465,
1844... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/caja-html-sanitizer.js | makeTagPolicy | function makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy) {
return function(tagName, attribs) {
if (!(html4.ELEMENTS[tagName] & html4.eflags.UNSAFE)) {
return sanitizeAttribs(
tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy);
}
};
} | javascript | function makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy) {
return function(tagName, attribs) {
if (!(html4.ELEMENTS[tagName] & html4.eflags.UNSAFE)) {
return sanitizeAttribs(
tagName, attribs, opt_naiveUriRewriter, opt_nmTokenPolicy);
}
};
} | [
"function",
"makeTagPolicy",
"(",
"opt_naiveUriRewriter",
",",
"opt_nmTokenPolicy",
")",
"{",
"return",
"function",
"(",
"tagName",
",",
"attribs",
")",
"{",
"if",
"(",
"!",
"(",
"html4",
".",
"ELEMENTS",
"[",
"tagName",
"]",
"&",
"html4",
".",
"eflags",
"... | Creates a tag policy that omits all tags marked UNSAFE in html4-defs.js
and applies the default attribute sanitizer with the supplied policy for
URI attributes and NMTOKEN attributes.
@param {?function(?string): ?string} opt_naiveUriRewriter A transform to
apply to URI attributes. If not given, URI attributes are deleted.
@param {function(?string): ?string} opt_nmTokenPolicy A transform to apply
to attributes containing HTML names, element IDs, and space-separated
lists of classes. If not given, such attributes are left unchanged.
@return {function(string, Array.<?string>)} A tagPolicy suitable for
passing to html.sanitize. | [
"Creates",
"a",
"tag",
"policy",
"that",
"omits",
"all",
"tags",
"marked",
"UNSAFE",
"in",
"html4",
"-",
"defs",
".",
"js",
"and",
"applies",
"the",
"default",
"attribute",
"sanitizer",
"with",
"the",
"supplied",
"policy",
"for",
"URI",
"attributes",
"and",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js#L3520-L3527 | train | Creates a tag policy function that checks if the tag is safe | [
30522,
3853,
2191,
15900,
18155,
2594,
2100,
1006,
23569,
1035,
15743,
9496,
15603,
17625,
2099,
1010,
23569,
1035,
13221,
18715,
2368,
18155,
2594,
2100,
1007,
1063,
2709,
3853,
1006,
6415,
18442,
1010,
2012,
18886,
5910,
1007,
1063,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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... |
goldfire/howler.js | dist/howler.js | function() {
var self = this;
var args = arguments;
var rate, id;
// Determine the values based on arguments.
if (args.length === 0) {
// We will simply return the current rate of the first node.
id = self._sounds[0]._id;
} else if (args.length === 1) {
// First check if this is an ID, and if not, assume it is a new rate value.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else {
rate = parseFloat(args[0]);
}
} else if (args.length === 2) {
rate = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// Update the playback rate or return the current value.
var sound;
if (typeof rate === 'number') {
// If the sound hasn't loaded, add it to the load queue to change playback rate when capable.
if (self._state !== 'loaded' || self._playLock) {
self._queue.push({
event: 'rate',
action: function() {
self.rate.apply(self, args);
}
});
return self;
}
// Set the group rate.
if (typeof id === 'undefined') {
self._rate = rate;
}
// Update one or all volumes.
id = self._getSoundIds(id);
for (var i=0; i<id.length; i++) {
// Get the sound.
sound = self._soundById(id[i]);
if (sound) {
// Keep track of our position when the rate changed and update the playback
// start position so we can properly adjust the seek position for time elapsed.
if (self.playing(id[i])) {
sound._rateSeek = self.seek(id[i]);
sound._playStart = self._webAudio ? Howler.ctx.currentTime : sound._playStart;
}
sound._rate = rate;
// Change the playback rate.
if (self._webAudio && sound._node && sound._node.bufferSource) {
sound._node.bufferSource.playbackRate.setValueAtTime(rate, Howler.ctx.currentTime);
} else if (sound._node) {
sound._node.playbackRate = rate;
}
// Reset the timers.
var seek = self.seek(id[i]);
var duration = ((self._sprite[sound._sprite][0] + self._sprite[sound._sprite][1]) / 1000) - seek;
var timeout = (duration * 1000) / Math.abs(sound._rate);
// Start a new end timer if sound is already playing.
if (self._endTimers[id[i]] || !sound._paused) {
self._clearTimer(id[i]);
self._endTimers[id[i]] = setTimeout(self._ended.bind(self, sound), timeout);
}
self._emit('rate', sound._id);
}
}
} else {
sound = self._soundById(id);
return sound ? sound._rate : self._rate;
}
return self;
} | javascript | function() {
var self = this;
var args = arguments;
var rate, id;
// Determine the values based on arguments.
if (args.length === 0) {
// We will simply return the current rate of the first node.
id = self._sounds[0]._id;
} else if (args.length === 1) {
// First check if this is an ID, and if not, assume it is a new rate value.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else {
rate = parseFloat(args[0]);
}
} else if (args.length === 2) {
rate = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// Update the playback rate or return the current value.
var sound;
if (typeof rate === 'number') {
// If the sound hasn't loaded, add it to the load queue to change playback rate when capable.
if (self._state !== 'loaded' || self._playLock) {
self._queue.push({
event: 'rate',
action: function() {
self.rate.apply(self, args);
}
});
return self;
}
// Set the group rate.
if (typeof id === 'undefined') {
self._rate = rate;
}
// Update one or all volumes.
id = self._getSoundIds(id);
for (var i=0; i<id.length; i++) {
// Get the sound.
sound = self._soundById(id[i]);
if (sound) {
// Keep track of our position when the rate changed and update the playback
// start position so we can properly adjust the seek position for time elapsed.
if (self.playing(id[i])) {
sound._rateSeek = self.seek(id[i]);
sound._playStart = self._webAudio ? Howler.ctx.currentTime : sound._playStart;
}
sound._rate = rate;
// Change the playback rate.
if (self._webAudio && sound._node && sound._node.bufferSource) {
sound._node.bufferSource.playbackRate.setValueAtTime(rate, Howler.ctx.currentTime);
} else if (sound._node) {
sound._node.playbackRate = rate;
}
// Reset the timers.
var seek = self.seek(id[i]);
var duration = ((self._sprite[sound._sprite][0] + self._sprite[sound._sprite][1]) / 1000) - seek;
var timeout = (duration * 1000) / Math.abs(sound._rate);
// Start a new end timer if sound is already playing.
if (self._endTimers[id[i]] || !sound._paused) {
self._clearTimer(id[i]);
self._endTimers[id[i]] = setTimeout(self._ended.bind(self, sound), timeout);
}
self._emit('rate', sound._id);
}
}
} else {
sound = self._soundById(id);
return sound ? sound._rate : self._rate;
}
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"args",
"=",
"arguments",
";",
"var",
"rate",
",",
"id",
";",
"// Determine the values based on arguments.",
"if",
"(",
"args",
".",
"length",
"===",
"0",
")",
"{",
"// We will simply return ... | Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments.
rate() -> Returns the first sound node's current playback rate.
rate(id) -> Returns the sound id's current playback rate.
rate(rate) -> Sets the playback rate of all sounds in this Howl group.
rate(rate, id) -> Sets the playback rate of passed sound id.
@return {Howl/Number} Returns self or the current playback rate. | [
"Get",
"/",
"set",
"the",
"playback",
"rate",
"of",
"a",
"sound",
".",
"This",
"method",
"can",
"optionally",
"take",
"0",
"1",
"or",
"2",
"arguments",
".",
"rate",
"()",
"-",
">",
"Returns",
"the",
"first",
"sound",
"node",
"s",
"current",
"playback",... | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1454-L1539 | train | Update the rate of the sound | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
12098,
5620,
1027,
9918,
1025,
13075,
3446,
1010,
8909,
1025,
1013,
1013,
5646,
1996,
5300,
2241,
2006,
9918,
1012,
2065,
1006,
12098,
5620,
1012,
3091,
1027,
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... | |
apache/incubator-echarts | src/chart/funnel/FunnelView.js | FunnelPiece | function FunnelPiece(data, idx) {
graphic.Group.call(this);
var polygon = new graphic.Polygon();
var labelLine = new graphic.Polyline();
var text = new graphic.Text();
this.add(polygon);
this.add(labelLine);
this.add(text);
this.highDownOnUpdate = function (fromState, toState) {
if (toState === 'emphasis') {
labelLine.ignore = labelLine.hoverIgnore;
text.ignore = text.hoverIgnore;
}
else {
labelLine.ignore = labelLine.normalIgnore;
text.ignore = text.normalIgnore;
}
};
this.updateData(data, idx, true);
} | javascript | function FunnelPiece(data, idx) {
graphic.Group.call(this);
var polygon = new graphic.Polygon();
var labelLine = new graphic.Polyline();
var text = new graphic.Text();
this.add(polygon);
this.add(labelLine);
this.add(text);
this.highDownOnUpdate = function (fromState, toState) {
if (toState === 'emphasis') {
labelLine.ignore = labelLine.hoverIgnore;
text.ignore = text.hoverIgnore;
}
else {
labelLine.ignore = labelLine.normalIgnore;
text.ignore = text.normalIgnore;
}
};
this.updateData(data, idx, true);
} | [
"function",
"FunnelPiece",
"(",
"data",
",",
"idx",
")",
"{",
"graphic",
".",
"Group",
".",
"call",
"(",
"this",
")",
";",
"var",
"polygon",
"=",
"new",
"graphic",
".",
"Polygon",
"(",
")",
";",
"var",
"labelLine",
"=",
"new",
"graphic",
".",
"Polyli... | Piece of pie including Sector, Label, LabelLine
@constructor
@extends {module:zrender/graphic/Group} | [
"Piece",
"of",
"pie",
"including",
"Sector",
"Label",
"LabelLine"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/funnel/FunnelView.js#L29-L52 | train | FunnelPiece constructor. | [
30522,
3853,
25102,
11198,
1006,
2951,
1010,
8909,
2595,
1007,
1063,
8425,
1012,
2177,
1012,
2655,
1006,
2023,
1007,
1025,
13075,
26572,
7446,
1027,
2047,
8425,
1012,
26572,
7446,
1006,
1007,
1025,
13075,
3830,
4179,
1027,
2047,
8425,
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... |
nhn/tui.editor | src/js/extensions/table/mergedTableCreator.js | _findIndex | function _findIndex(arr, onFind) {
let foundIndex = -1;
util.forEach(arr, (item, index) => {
let nextFind = true;
if (onFind(item, index)) {
foundIndex = index;
nextFind = false;
}
return nextFind;
});
return foundIndex;
} | javascript | function _findIndex(arr, onFind) {
let foundIndex = -1;
util.forEach(arr, (item, index) => {
let nextFind = true;
if (onFind(item, index)) {
foundIndex = index;
nextFind = false;
}
return nextFind;
});
return foundIndex;
} | [
"function",
"_findIndex",
"(",
"arr",
",",
"onFind",
")",
"{",
"let",
"foundIndex",
"=",
"-",
"1",
";",
"util",
".",
"forEach",
"(",
"arr",
",",
"(",
"item",
",",
"index",
")",
"=>",
"{",
"let",
"nextFind",
"=",
"true",
";",
"if",
"(",
"onFind",
... | Find index by onFind function.
@param {Array} arr - target array
@param {function} onFind - find function
@returns {number}
@private | [
"Find",
"index",
"by",
"onFind",
"function",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/mergedTableCreator.js#L80-L94 | train | Find index of an item in an array | [
30522,
3853,
1035,
2424,
22254,
10288,
1006,
12098,
2099,
1010,
2006,
16294,
2094,
1007,
1063,
2292,
2179,
22254,
10288,
1027,
1011,
1015,
1025,
21183,
30524,
1027,
6270,
1025,
1065,
2709,
2279,
16294,
2094,
1025,
1065,
1007,
1025,
2709,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
modood/Administrative-divisions-of-China | lib/sqlite.js | init | async function init () {
try {
await sequelize.sync()
} catch (err) {
console.log(err)
process.exit(-1)
}
} | javascript | async function init () {
try {
await sequelize.sync()
} catch (err) {
console.log(err)
process.exit(-1)
}
} | [
"async",
"function",
"init",
"(",
")",
"{",
"try",
"{",
"await",
"sequelize",
".",
"sync",
"(",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"err",
")",
"process",
".",
"exit",
"(",
"-",
"1",
")",
"}",
"}"
] | /* Connect database | [
"/",
"*",
"Connect",
"database"
] | 31aaa3c31dc767a01f8f5e724c795f02f4540437 | https://github.com/modood/Administrative-divisions-of-China/blob/31aaa3c31dc767a01f8f5e724c795f02f4540437/lib/sqlite.js#L62-L69 | train | init
| [
30522,
2004,
6038,
2278,
3853,
1999,
4183,
1006,
1007,
1063,
3046,
1063,
26751,
8297,
4697,
1012,
26351,
1006,
1007,
1065,
4608,
1006,
9413,
2099,
1007,
1063,
10122,
1012,
8833,
1006,
9413,
2099,
1007,
2832,
1012,
6164,
1006,
1011,
1015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | build_tree | function build_tree(clens, cmap, MAX) {
var maxlen = 1, w = 0, i = 0, j = 0, ccode = 0, L = clens.length;
var bl_count = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);
for(i = 0; i < 32; ++i) bl_count[i] = 0;
for(i = L; i < MAX; ++i) clens[i] = 0;
L = clens.length;
var ctree = use_typed_arrays ? new Uint16Array(L) : zero_fill_array(L); // []
/* build code tree */
for(i = 0; i < L; ++i) {
bl_count[(w = clens[i])]++;
if(maxlen < w) maxlen = w;
ctree[i] = 0;
}
bl_count[0] = 0;
for(i = 1; i <= maxlen; ++i) bl_count[i+16] = (ccode = (ccode + bl_count[i-1])<<1);
for(i = 0; i < L; ++i) {
ccode = clens[i];
if(ccode != 0) ctree[i] = bl_count[ccode+16]++;
}
/* cmap[maxlen + 4 bits] = (off&15) + (lit<<4) reverse mapping */
var cleni = 0;
for(i = 0; i < L; ++i) {
cleni = clens[i];
if(cleni != 0) {
ccode = bit_swap_n(ctree[i], maxlen)>>(maxlen-cleni);
for(j = (1<<(maxlen + 4 - cleni)) - 1; j>=0; --j)
cmap[ccode|(j<<cleni)] = (cleni&15) | (i<<4);
}
}
return maxlen;
} | javascript | function build_tree(clens, cmap, MAX) {
var maxlen = 1, w = 0, i = 0, j = 0, ccode = 0, L = clens.length;
var bl_count = use_typed_arrays ? new Uint16Array(32) : zero_fill_array(32);
for(i = 0; i < 32; ++i) bl_count[i] = 0;
for(i = L; i < MAX; ++i) clens[i] = 0;
L = clens.length;
var ctree = use_typed_arrays ? new Uint16Array(L) : zero_fill_array(L); // []
/* build code tree */
for(i = 0; i < L; ++i) {
bl_count[(w = clens[i])]++;
if(maxlen < w) maxlen = w;
ctree[i] = 0;
}
bl_count[0] = 0;
for(i = 1; i <= maxlen; ++i) bl_count[i+16] = (ccode = (ccode + bl_count[i-1])<<1);
for(i = 0; i < L; ++i) {
ccode = clens[i];
if(ccode != 0) ctree[i] = bl_count[ccode+16]++;
}
/* cmap[maxlen + 4 bits] = (off&15) + (lit<<4) reverse mapping */
var cleni = 0;
for(i = 0; i < L; ++i) {
cleni = clens[i];
if(cleni != 0) {
ccode = bit_swap_n(ctree[i], maxlen)>>(maxlen-cleni);
for(j = (1<<(maxlen + 4 - cleni)) - 1; j>=0; --j)
cmap[ccode|(j<<cleni)] = (cleni&15) | (i<<4);
}
}
return maxlen;
} | [
"function",
"build_tree",
"(",
"clens",
",",
"cmap",
",",
"MAX",
")",
"{",
"var",
"maxlen",
"=",
"1",
",",
"w",
"=",
"0",
",",
"i",
"=",
"0",
",",
"j",
"=",
"0",
",",
"ccode",
"=",
"0",
",",
"L",
"=",
"clens",
".",
"length",
";",
"var",
"bl... | /* modified inflate function also moves original read head /* build tree (used for literals and lengths) | [
"/",
"*",
"modified",
"inflate",
"function",
"also",
"moves",
"original",
"read",
"head",
"/",
"*",
"build",
"tree",
"(",
"used",
"for",
"literals",
"and",
"lengths",
")"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L2069-L2104 | train | build tree | [
30522,
3853,
3857,
1035,
3392,
1006,
18856,
6132,
1010,
4642,
9331,
1010,
4098,
1007,
1063,
13075,
4098,
7770,
1027,
1015,
1010,
1059,
1027,
1014,
1010,
1045,
1027,
1014,
1010,
1046,
1027,
1014,
1010,
10507,
10244,
1027,
1014,
1010,
1048,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
lovell/sharp | lib/operation.js | linear | function linear (a, b) {
if (!is.defined(a)) {
this.options.linearA = 1.0;
} else if (is.number(a)) {
this.options.linearA = a;
} else {
throw new Error('Invalid linear transform multiplier ' + a);
}
if (!is.defined(b)) {
this.options.linearB = 0.0;
} else if (is.number(b)) {
this.options.linearB = b;
} else {
throw new Error('Invalid linear transform offset ' + b);
}
return this;
} | javascript | function linear (a, b) {
if (!is.defined(a)) {
this.options.linearA = 1.0;
} else if (is.number(a)) {
this.options.linearA = a;
} else {
throw new Error('Invalid linear transform multiplier ' + a);
}
if (!is.defined(b)) {
this.options.linearB = 0.0;
} else if (is.number(b)) {
this.options.linearB = b;
} else {
throw new Error('Invalid linear transform offset ' + b);
}
return this;
} | [
"function",
"linear",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"!",
"is",
".",
"defined",
"(",
"a",
")",
")",
"{",
"this",
".",
"options",
".",
"linearA",
"=",
"1.0",
";",
"}",
"else",
"if",
"(",
"is",
".",
"number",
"(",
"a",
")",
")",
"{"... | Apply the linear formula a * input + b to the image (levels adjustment)
@param {Number} [a=1.0] multiplier
@param {Number} [b=0.0] offset
@returns {Sharp}
@throws {Error} Invalid parameters | [
"Apply",
"the",
"linear",
"formula",
"a",
"*",
"input",
"+",
"b",
"to",
"the",
"image",
"(",
"levels",
"adjustment",
")"
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/operation.js#L361-L379 | train | Linear transform | [
30522,
3853,
7399,
1006,
1037,
1010,
1038,
1007,
1063,
2065,
1006,
999,
2003,
1012,
4225,
1006,
1037,
1007,
1007,
1063,
2023,
1012,
7047,
1012,
7399,
2050,
1027,
1015,
1012,
1014,
1025,
1065,
2842,
2065,
1006,
2003,
1012,
2193,
1006,
1037... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/scripts/htmlutils.js | getFunctionName | function getFunctionName(aFunction) {
var regexpResult = aFunction.toString().match(/function (\w*)/);
if (regexpResult && regexpResult[1]) {
return regexpResult[1];
}
return 'anonymous';
} | javascript | function getFunctionName(aFunction) {
var regexpResult = aFunction.toString().match(/function (\w*)/);
if (regexpResult && regexpResult[1]) {
return regexpResult[1];
}
return 'anonymous';
} | [
"function",
"getFunctionName",
"(",
"aFunction",
")",
"{",
"var",
"regexpResult",
"=",
"aFunction",
".",
"toString",
"(",
")",
".",
"match",
"(",
"/",
"function (\\w*)",
"/",
")",
";",
"if",
"(",
"regexpResult",
"&&",
"regexpResult",
"[",
"1",
"]",
")",
... | Override the broken getFunctionName() method from JsUnit
This file must be loaded _after_ the jsunitCore.js | [
"Override",
"the",
"broken",
"getFunctionName",
"()",
"method",
"from",
"JsUnit",
"This",
"file",
"must",
"be",
"loaded",
"_after_",
"the",
"jsunitCore",
".",
"js"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L365-L371 | train | Get the name of a function | [
30522,
3853,
2131,
11263,
27989,
18442,
1006,
21358,
4609,
7542,
1007,
1063,
13075,
19723,
10288,
28994,
11314,
1027,
21358,
4609,
7542,
1012,
2000,
3367,
4892,
1006,
1007,
1012,
2674,
1006,
1013,
3853,
1006,
1032,
1059,
1008,
1007,
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... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js | _fnGetFocusControlById | function _fnGetFocusControlById(oToolPopup, id) {
var oControl,
parent;
if (!id) {
return null;
}
oControl = sap.ui.getCore().byId(id);
while (!oControl && oControl !== oToolPopup) {
if (!id || !document.getElementById(id)) {
return null;
}
parent = document.getElementById(id).parentNode;
id = parent.id;
oControl = sap.ui.getCore().byId(id);
}
return oControl;
} | javascript | function _fnGetFocusControlById(oToolPopup, id) {
var oControl,
parent;
if (!id) {
return null;
}
oControl = sap.ui.getCore().byId(id);
while (!oControl && oControl !== oToolPopup) {
if (!id || !document.getElementById(id)) {
return null;
}
parent = document.getElementById(id).parentNode;
id = parent.id;
oControl = sap.ui.getCore().byId(id);
}
return oControl;
} | [
"function",
"_fnGetFocusControlById",
"(",
"oToolPopup",
",",
"id",
")",
"{",
"var",
"oControl",
",",
"parent",
";",
"if",
"(",
"!",
"id",
")",
"{",
"return",
"null",
";",
"}",
"oControl",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"byId",... | Returns a DOM element by its Id.
@param {Number} id
@returns {Element|sap.ui.core.Element|Object|sap.ui.core.tmpl.Template}
@private | [
"Returns",
"a",
"DOM",
"element",
"by",
"its",
"Id",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js#L371-L390 | train | Returns the control with the given id | [
30522,
3853,
1035,
1042,
15465,
24475,
10085,
2271,
8663,
13181,
14510,
3593,
1006,
27178,
13669,
16340,
6279,
1010,
8909,
1007,
1063,
13075,
1051,
8663,
13181,
2140,
1010,
6687,
1025,
2065,
1006,
999,
8909,
1007,
1063,
2709,
19701,
1025,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.