repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
grpc/grpc-node | packages/grpc-native-core/src/server.js | waitForCancel | function waitForCancel() {
/* jshint validthis: true */
var self = this;
var cancel_batch = {};
cancel_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
self.call.startBatch(cancel_batch, function(err, result) {
if (err) {
self.emit('error', err);
}
if (result.cancelled) {
self.cancelled = true;
self.emit('cancelled');
}
});
} | javascript | function waitForCancel() {
/* jshint validthis: true */
var self = this;
var cancel_batch = {};
cancel_batch[grpc.opType.RECV_CLOSE_ON_SERVER] = true;
self.call.startBatch(cancel_batch, function(err, result) {
if (err) {
self.emit('error', err);
}
if (result.cancelled) {
self.cancelled = true;
self.emit('cancelled');
}
});
} | [
"function",
"waitForCancel",
"(",
")",
"{",
"/* jshint validthis: true */",
"var",
"self",
"=",
"this",
";",
"var",
"cancel_batch",
"=",
"{",
"}",
";",
"cancel_batch",
"[",
"grpc",
".",
"opType",
".",
"RECV_CLOSE_ON_SERVER",
"]",
"=",
"true",
";",
"self",
".... | Wait for the client to close, then emit a cancelled event if the client
cancelled.
@private | [
"Wait",
"for",
"the",
"client",
"to",
"close",
"then",
"emit",
"a",
"cancelled",
"event",
"if",
"the",
"client",
"cancelled",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L515-L529 | train | Wait for the client to close | [
30522,
30524,
24665,
15042,
1012,
23569,
18863,
1012,
28667,
2615,
1035,
2485,
1035,
2006,
1035,
8241,
1033,
1027,
2995,
1025,
2969,
1012,
2655,
1012,
2707,
14479,
2818,
1006,
17542,
1035,
14108,
1010,
3853,
1006,
9413,
2099,
1010,
2765,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/ControlTreeModifier.js | function (oControl, bStashed) {
var bOldValue;
var vControlId = oControl.getId();
if (oControl.getVisible){
bOldValue = !oControl.getVisible();
} else {
bOldValue = oControl.getStashed();
}
JsControlTreeModifier.setStashed.apply(this, arguments);
var oSetControl = sap.ui.getCore().byId(vControlId);
if (bOldValue !== bStashed) {
this._saveUndoOperation("setStashed", [oSetControl, !bStashed]);
}
} | javascript | function (oControl, bStashed) {
var bOldValue;
var vControlId = oControl.getId();
if (oControl.getVisible){
bOldValue = !oControl.getVisible();
} else {
bOldValue = oControl.getStashed();
}
JsControlTreeModifier.setStashed.apply(this, arguments);
var oSetControl = sap.ui.getCore().byId(vControlId);
if (bOldValue !== bStashed) {
this._saveUndoOperation("setStashed", [oSetControl, !bStashed]);
}
} | [
"function",
"(",
"oControl",
",",
"bStashed",
")",
"{",
"var",
"bOldValue",
";",
"var",
"vControlId",
"=",
"oControl",
".",
"getId",
"(",
")",
";",
"if",
"(",
"oControl",
".",
"getVisible",
")",
"{",
"bOldValue",
"=",
"!",
"oControl",
".",
"getVisible",
... | Execute the setStashed method and record the opposite value for the undo operation
The control can be a StashedControl ("placeholder") or a "real" control
After the setStashed operation, the placeholder can create a real control with same ID
Therefore we must save the previous ID in order to perform setStashed on this new control when executing the undo
Real controls have getVisible; placeholders have getStashed. For real controls, we only manipulate the visibility, since
once they are created, the stashing is not relevant anymore
@override | [
"Execute",
"the",
"setStashed",
"method",
"and",
"record",
"the",
"opposite",
"value",
"for",
"the",
"undo",
"operation",
"The",
"control",
"can",
"be",
"a",
"StashedControl",
"(",
"placeholder",
")",
"or",
"a",
"real",
"control",
"After",
"the",
"setStashed",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/ControlTreeModifier.js#L99-L115 | train | Sets the stashed state of the control. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1010,
18667,
10230,
9072,
1007,
1063,
13075,
7782,
10175,
5657,
1025,
13075,
18315,
12162,
13153,
3593,
1027,
1051,
8663,
13181,
2140,
1012,
2131,
3593,
1006,
1007,
1025,
2065,
1006,
1051,
8663,
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.core/src/sap/ui/core/util/XMLPreprocessor.js | warn | function warn(oElement) {
if (bWarning) {
if (!bCallerLoggedForWarnings) {
bCallerLoggedForWarnings = true;
Log.warning("Warning(s) during processing of " + sCaller, null,
sXMLPreprocessor);
}
Log.warning(
getNestingLevel() + Array.prototype.slice.call(arguments, 1).join(" "),
oElement && serializeSingleElement(oElement), sXMLPreprocessor);
}
} | javascript | function warn(oElement) {
if (bWarning) {
if (!bCallerLoggedForWarnings) {
bCallerLoggedForWarnings = true;
Log.warning("Warning(s) during processing of " + sCaller, null,
sXMLPreprocessor);
}
Log.warning(
getNestingLevel() + Array.prototype.slice.call(arguments, 1).join(" "),
oElement && serializeSingleElement(oElement), sXMLPreprocessor);
}
} | [
"function",
"warn",
"(",
"oElement",
")",
"{",
"if",
"(",
"bWarning",
")",
"{",
"if",
"(",
"!",
"bCallerLoggedForWarnings",
")",
"{",
"bCallerLoggedForWarnings",
"=",
"true",
";",
"Log",
".",
"warning",
"(",
"\"Warning(s) during processing of \"",
"+",
"sCaller"... | /*
Outputs a warning message with the current nesting level; takes care not to
construct the message or serialize XML in vain.
@param {Element} [oElement]
any XML DOM element which is serialized to the details
@param {...string} aTexts
the main text of the message is constructed from the rest of the arguments by
joining them separated by single spaces | [
"/",
"*",
"Outputs",
"a",
"warning",
"message",
"with",
"the",
"current",
"nesting",
"level",
";",
"takes",
"care",
"not",
"to",
"construct",
"the",
"message",
"or",
"serialize",
"XML",
"in",
"vain",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L1885-L1896 | train | Log warning for the given element | [
30522,
3853,
11582,
1006,
1051,
12260,
3672,
1007,
1063,
2065,
1006,
1038,
9028,
5582,
1007,
1063,
2065,
1006,
999,
4647,
24164,
12190,
8649,
5999,
29278,
9028,
5582,
2015,
1007,
1063,
4647,
24164,
12190,
8649,
5999,
29278,
9028,
5582,
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... |
laurent22/joplin | ReactNativeClient/lib/import-enex-md-gen.js | function(lines) {
let firstBracketIndex = 0;
let foundFirstNonWhite = false;
for (let i = lines.length - 1; i >= 0; i--) {
const l = lines[i];
if (!foundFirstNonWhite && (l === SPACE || l === ' ' || !l)) {
lines.pop();
} else {
foundFirstNonWhite = true;
}
if (l === '[') {
firstBracketIndex = i;
break;
}
}
for (let i = firstBracketIndex + 1; i < lines.length; i++) {
const l = lines[i];
if (l === SPACE || l === ' ' ||!l) {
lines.splice(i, 1);
} else {
break;
}
}
return lines;
} | javascript | function(lines) {
let firstBracketIndex = 0;
let foundFirstNonWhite = false;
for (let i = lines.length - 1; i >= 0; i--) {
const l = lines[i];
if (!foundFirstNonWhite && (l === SPACE || l === ' ' || !l)) {
lines.pop();
} else {
foundFirstNonWhite = true;
}
if (l === '[') {
firstBracketIndex = i;
break;
}
}
for (let i = firstBracketIndex + 1; i < lines.length; i++) {
const l = lines[i];
if (l === SPACE || l === ' ' ||!l) {
lines.splice(i, 1);
} else {
break;
}
}
return lines;
} | [
"function",
"(",
"lines",
")",
"{",
"let",
"firstBracketIndex",
"=",
"0",
";",
"let",
"foundFirstNonWhite",
"=",
"false",
";",
"for",
"(",
"let",
"i",
"=",
"lines",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"const",
... | Eg. converts: [ Sign in ](https://example.com) to: [Sign in](https://example.com) | [
"Eg",
".",
"converts",
":",
"[",
"Sign",
"in",
"]",
"(",
"https",
":",
"//",
"example",
".",
"com",
")",
"to",
":",
"[",
"Sign",
"in",
"]",
"(",
"https",
":",
"//",
"example",
".",
"com",
")"
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ReactNativeClient/lib/import-enex-md-gen.js#L788-L815 | train | Remove the last non - white space and whitespace characters from the lines | [
30522,
3853,
1006,
3210,
1007,
1063,
2292,
2034,
10024,
19869,
7629,
3207,
2595,
1027,
1014,
1025,
2292,
2179,
8873,
12096,
8540,
2860,
16584,
2063,
1027,
6270,
1025,
2005,
1006,
2292,
1045,
1027,
3210,
1012,
3091,
1011,
1015,
1025,
1045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/extensibility/node/package-validator.js | findCommonPrefix | function findCommonPrefix(extractDir, callback) {
fs.readdir(extractDir, function (err, files) {
ignoredFolders.forEach(function (folder) {
var index = files.indexOf(folder);
if (index !== -1) {
files.splice(index, 1);
}
});
if (err) {
callback(err);
} else if (files.length === 1) {
var name = files[0];
if (fs.statSync(path.join(extractDir, name)).isDirectory()) {
callback(null, name);
} else {
callback(null, "");
}
} else {
callback(null, "");
}
});
} | javascript | function findCommonPrefix(extractDir, callback) {
fs.readdir(extractDir, function (err, files) {
ignoredFolders.forEach(function (folder) {
var index = files.indexOf(folder);
if (index !== -1) {
files.splice(index, 1);
}
});
if (err) {
callback(err);
} else if (files.length === 1) {
var name = files[0];
if (fs.statSync(path.join(extractDir, name)).isDirectory()) {
callback(null, name);
} else {
callback(null, "");
}
} else {
callback(null, "");
}
});
} | [
"function",
"findCommonPrefix",
"(",
"extractDir",
",",
"callback",
")",
"{",
"fs",
".",
"readdir",
"(",
"extractDir",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"ignoredFolders",
".",
"forEach",
"(",
"function",
"(",
"folder",
")",
"{",
"var",
... | Finds the common prefix, if any, for the files in a package file.
In some package files, all of the files are contained in a subdirectory, and this function
will identify that directory if it exists.
@param {string} extractDir directory into which the package was extracted
@param {function(Error, string)} callback function to accept err, commonPrefix (which will be "" if there is none) | [
"Finds",
"the",
"common",
"prefix",
"if",
"any",
"for",
"the",
"files",
"in",
"a",
"package",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/package-validator.js#L152-L173 | train | find common prefix | [
30522,
3853,
2424,
9006,
8202,
28139,
8873,
2595,
1006,
14817,
4305,
2099,
1010,
2655,
5963,
1007,
1063,
1042,
2015,
1012,
3191,
4305,
2099,
1006,
14817,
4305,
2099,
1010,
3853,
1006,
9413,
2099,
1010,
6764,
1007,
1063,
6439,
10371,
2545,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-unused-labels.js | exitLabeledScope | function exitLabeledScope(node) {
if (!scopeInfo.used) {
context.report({
node: node.label,
messageId: "unused",
data: node.label,
fix(fixer) {
/*
* Only perform a fix if there are no comments between the label and the body. This will be the case
* when there is exactly one token/comment (the ":") between the label and the body.
*/
if (sourceCode.getTokenAfter(node.label, { includeComments: true }) ===
sourceCode.getTokenBefore(node.body, { includeComments: true })) {
return fixer.removeRange([node.range[0], node.body.range[0]]);
}
return null;
}
});
}
scopeInfo = scopeInfo.upper;
} | javascript | function exitLabeledScope(node) {
if (!scopeInfo.used) {
context.report({
node: node.label,
messageId: "unused",
data: node.label,
fix(fixer) {
/*
* Only perform a fix if there are no comments between the label and the body. This will be the case
* when there is exactly one token/comment (the ":") between the label and the body.
*/
if (sourceCode.getTokenAfter(node.label, { includeComments: true }) ===
sourceCode.getTokenBefore(node.body, { includeComments: true })) {
return fixer.removeRange([node.range[0], node.body.range[0]]);
}
return null;
}
});
}
scopeInfo = scopeInfo.upper;
} | [
"function",
"exitLabeledScope",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"scopeInfo",
".",
"used",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"node",
".",
"label",
",",
"messageId",
":",
"\"unused\"",
",",
"data",
":",
"node",
".",
"lab... | Removes the top of the stack.
At the same time, this reports the label if it's never used.
@param {ASTNode} node - A node to report. This is a LabeledStatement.
@returns {void} | [
"Removes",
"the",
"top",
"of",
"the",
"stack",
".",
"At",
"the",
"same",
"time",
"this",
"reports",
"the",
"label",
"if",
"it",
"s",
"never",
"used",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-labels.js#L57-L80 | train | Exit a labeled scope | [
30522,
3853,
6164,
20470,
12260,
5104,
16186,
1006,
13045,
1007,
1063,
2065,
1006,
999,
9531,
2378,
14876,
1012,
2109,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1024,
13045,
1012,
3830,
1010,
4471,
3593,
1024,
1000,
15171,
1000,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseUnaryExpression | function parseUnaryExpression() {
var token, expr, startToken;
if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
expr = parsePostfixExpression();
} else if (match('++') || match('--')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
// 11.4.4, 11.4.5
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
throwErrorTolerant({}, Messages.StrictLHSPrefix);
}
if (!isLeftHandSide(expr)) {
throwErrorTolerant({}, Messages.InvalidLHSInAssignment);
}
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
} else if (match('+') || match('-') || match('~') || match('!')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
} else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
throwErrorTolerant({}, Messages.StrictDelete);
}
} else {
expr = parsePostfixExpression();
}
return expr;
} | javascript | function parseUnaryExpression() {
var token, expr, startToken;
if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
expr = parsePostfixExpression();
} else if (match('++') || match('--')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
// 11.4.4, 11.4.5
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
throwErrorTolerant({}, Messages.StrictLHSPrefix);
}
if (!isLeftHandSide(expr)) {
throwErrorTolerant({}, Messages.InvalidLHSInAssignment);
}
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
} else if (match('+') || match('-') || match('~') || match('!')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
} else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
startToken = lookahead;
token = lex();
expr = parseUnaryExpression();
expr = delegate.createUnaryExpression(token.value, expr);
expr = delegate.markEnd(expr, startToken);
if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) {
throwErrorTolerant({}, Messages.StrictDelete);
}
} else {
expr = parsePostfixExpression();
}
return expr;
} | [
"function",
"parseUnaryExpression",
"(",
")",
"{",
"var",
"token",
",",
"expr",
",",
"startToken",
";",
"if",
"(",
"lookahead",
".",
"type",
"!==",
"Token",
".",
"Punctuator",
"&&",
"lookahead",
".",
"type",
"!==",
"Token",
".",
"Keyword",
")",
"{",
"exp... | 11.4 Unary Operators | [
"11",
".",
"4",
"Unary",
"Operators"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2352-L2392 | train | ECMA - 262 12. 2 Unary Operators | [
30522,
3853,
11968,
3366,
9521,
2854,
10288,
20110,
3258,
1006,
1007,
1063,
13075,
19204,
1010,
4654,
18098,
1010,
2707,
18715,
2368,
1025,
2065,
1006,
2298,
4430,
13775,
1012,
2828,
999,
1027,
1027,
19204,
1012,
26136,
6593,
6692,
4263,
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... |
adobe/brackets | src/extensions/default/RecentProjects/main.js | _handleListEvents | function _handleListEvents() {
$dropdown
.on("click", "a", function () {
var $link = $(this),
id = $link.attr("id"),
path = $link.data("path");
if (path) {
ProjectManager.openProject(path)
.fail(function () {
// Remove the project from the list only if it does not exist on disk
var recentProjects = getRecentProjects(),
index = recentProjects.indexOf(path);
if (index !== -1) {
FileSystem.resolve(path, function (err, item) {
if (err) {
recentProjects.splice(index, 1);
}
});
}
});
closeDropdown();
} else if (id === "open-folder-link") {
CommandManager.execute(Commands.FILE_OPEN_FOLDER);
}
})
.on("mouseenter", "a", function () {
if ($dropdownItem) {
$dropdownItem.removeClass("selected");
}
$dropdownItem = $(this).addClass("selected");
if ($dropdownItem.hasClass("recent-folder-link")) {
// Note: we can't depend on the event here because this can be triggered
// manually from checkHovers().
addDeleteButton($(this));
}
})
.on("mouseleave", "a", function () {
var $link = $(this).removeClass("selected");
if ($link.get(0) === $dropdownItem.get(0)) {
$dropdownItem = null;
}
if ($link.hasClass("recent-folder-link")) {
removeDeleteButton();
}
});
} | javascript | function _handleListEvents() {
$dropdown
.on("click", "a", function () {
var $link = $(this),
id = $link.attr("id"),
path = $link.data("path");
if (path) {
ProjectManager.openProject(path)
.fail(function () {
// Remove the project from the list only if it does not exist on disk
var recentProjects = getRecentProjects(),
index = recentProjects.indexOf(path);
if (index !== -1) {
FileSystem.resolve(path, function (err, item) {
if (err) {
recentProjects.splice(index, 1);
}
});
}
});
closeDropdown();
} else if (id === "open-folder-link") {
CommandManager.execute(Commands.FILE_OPEN_FOLDER);
}
})
.on("mouseenter", "a", function () {
if ($dropdownItem) {
$dropdownItem.removeClass("selected");
}
$dropdownItem = $(this).addClass("selected");
if ($dropdownItem.hasClass("recent-folder-link")) {
// Note: we can't depend on the event here because this can be triggered
// manually from checkHovers().
addDeleteButton($(this));
}
})
.on("mouseleave", "a", function () {
var $link = $(this).removeClass("selected");
if ($link.get(0) === $dropdownItem.get(0)) {
$dropdownItem = null;
}
if ($link.hasClass("recent-folder-link")) {
removeDeleteButton();
}
});
} | [
"function",
"_handleListEvents",
"(",
")",
"{",
"$dropdown",
".",
"on",
"(",
"\"click\"",
",",
"\"a\"",
",",
"function",
"(",
")",
"{",
"var",
"$link",
"=",
"$",
"(",
"this",
")",
",",
"id",
"=",
"$link",
".",
"attr",
"(",
"\"id\"",
")",
",",
"path... | Adds the click and mouse enter/leave events to the dropdown | [
"Adds",
"the",
"click",
"and",
"mouse",
"enter",
"/",
"leave",
"events",
"to",
"the",
"dropdown"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RecentProjects/main.js#L277-L327 | train | Handle list events | [
30522,
3853,
1035,
5047,
9863,
18697,
7666,
1006,
1007,
1063,
1002,
4530,
7698,
1012,
2006,
1006,
1000,
11562,
1000,
1010,
1000,
1037,
1000,
1010,
3853,
1006,
1007,
1063,
13075,
1002,
4957,
1027,
1002,
1006,
2023,
1007,
1010,
8909,
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/LiveDevelopment/Agents/DOMHelpers.js | _extractAttributes | function _extractAttributes(content) {
// remove the node name and the closing bracket and optional slash
content = content.replace(/^<\S+\s*/, "");
content = content.replace(/\s*\/?>$/, "");
if (content.length === 0) {
return;
}
// go through the items and identify key value pairs split by =
var index, key, value;
var attributes = {};
_findEach(content, [/\s/, 1], true, undefined, function each(item) {
index = item.search("=");
if (index < 0) {
return;
}
// get the key
key = item.substr(0, index).trim();
if (key.length === 0) {
return;
}
// get the value
value = item.substr(index + 1).trim();
value = _removeQuotes(value);
attributes[key] = value;
});
return attributes;
} | javascript | function _extractAttributes(content) {
// remove the node name and the closing bracket and optional slash
content = content.replace(/^<\S+\s*/, "");
content = content.replace(/\s*\/?>$/, "");
if (content.length === 0) {
return;
}
// go through the items and identify key value pairs split by =
var index, key, value;
var attributes = {};
_findEach(content, [/\s/, 1], true, undefined, function each(item) {
index = item.search("=");
if (index < 0) {
return;
}
// get the key
key = item.substr(0, index).trim();
if (key.length === 0) {
return;
}
// get the value
value = item.substr(index + 1).trim();
value = _removeQuotes(value);
attributes[key] = value;
});
return attributes;
} | [
"function",
"_extractAttributes",
"(",
"content",
")",
"{",
"// remove the node name and the closing bracket and optional slash",
"content",
"=",
"content",
".",
"replace",
"(",
"/",
"^<\\S+\\s*",
"/",
",",
"\"\"",
")",
";",
"content",
"=",
"content",
".",
"replace",
... | Extract tag attributes from the given source of a single tag
@param {string} source content | [
"Extract",
"tag",
"attributes",
"from",
"the",
"given",
"source",
"of",
"a",
"single",
"tag"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMHelpers.js#L147-L178 | train | Extract the attributes from the content | [
30522,
3853,
1035,
14817,
19321,
3089,
8569,
4570,
1006,
4180,
1007,
1063,
1013,
1013,
6366,
1996,
13045,
2171,
1998,
1996,
5494,
21605,
1998,
11887,
18296,
4180,
1027,
4180,
1012,
5672,
1006,
1013,
1034,
1026,
1032,
1055,
1009,
1032,
1055,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
postmanlabs/newman | lib/run/options.js | function (err, collection) {
if (err) {
return callback(err);
}
// ensure that the collection option is present before starting a run
if (!_.isObject(collection)) {
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
}
// ensure that the collection reference is an SDK instance
// @todo - should this be handled by config loaders?
collection = new Collection(Collection.isCollection(collection) ?
// if the option contain an instance of collection, we simply clone it for future use
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
// converted to a collection
collection.toJSON() : collection);
callback(null, collection);
} | javascript | function (err, collection) {
if (err) {
return callback(err);
}
// ensure that the collection option is present before starting a run
if (!_.isObject(collection)) {
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
}
// ensure that the collection reference is an SDK instance
// @todo - should this be handled by config loaders?
collection = new Collection(Collection.isCollection(collection) ?
// if the option contain an instance of collection, we simply clone it for future use
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
// converted to a collection
collection.toJSON() : collection);
callback(null, collection);
} | [
"function",
"(",
"err",
",",
"collection",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"// ensure that the collection option is present before starting a run",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"collection",
... | The post collection load handler.
@param {?Error} err - An Error instance / null, passed from the collection loader.
@param {Object} collection - The collection / raw JSON object, passed from the collection loader.
@returns {*} | [
"The",
"post",
"collection",
"load",
"handler",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L180-L199 | train | Load the cache | [
30522,
3853,
1006,
9413,
2099,
1010,
3074,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
1063,
2709,
2655,
5963,
1006,
9413,
2099,
1007,
30524,
1012,
11163,
2497,
20614,
1006,
3074,
1007,
1007,
1063,
2709,
2655,
5963,
1006,
2047,
7561,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | pollInterstitialPage | function pollInterstitialPage() {
if (keepPolling && Inspector.connected()) {
Inspector.Runtime.evaluate("window.isBracketsLiveDevelopmentInterstitialPageLoaded", function (response) {
var result = response.result;
if (result.type === "boolean" && result.value) {
window.clearTimeout(timer);
deferred.resolve();
} else {
window.setTimeout(pollInterstitialPage, 100);
}
});
} else {
deferred.reject();
}
} | javascript | function pollInterstitialPage() {
if (keepPolling && Inspector.connected()) {
Inspector.Runtime.evaluate("window.isBracketsLiveDevelopmentInterstitialPageLoaded", function (response) {
var result = response.result;
if (result.type === "boolean" && result.value) {
window.clearTimeout(timer);
deferred.resolve();
} else {
window.setTimeout(pollInterstitialPage, 100);
}
});
} else {
deferred.reject();
}
} | [
"function",
"pollInterstitialPage",
"(",
")",
"{",
"if",
"(",
"keepPolling",
"&&",
"Inspector",
".",
"connected",
"(",
")",
")",
"{",
"Inspector",
".",
"Runtime",
".",
"evaluate",
"(",
"\"window.isBracketsLiveDevelopmentInterstitialPageLoaded\"",
",",
"function",
"(... | 10 seconds /*
Asynchronously check to see if the interstitial page has
finished loading; if not, check again until timing out. | [
"10",
"seconds",
"/",
"*",
"Asynchronously",
"check",
"to",
"see",
"if",
"the",
"interstitial",
"page",
"has",
"finished",
"loading",
";",
"if",
"not",
"check",
"again",
"until",
"timing",
"out",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L1031-L1046 | train | pollInterstitialPage - Polls the Interstitial Page | [
30522,
3853,
8554,
18447,
2545,
3775,
20925,
13704,
1006,
1007,
1063,
2065,
1006,
2562,
18155,
2989,
1004,
1004,
7742,
1012,
4198,
1006,
1007,
1007,
1063,
7742,
1012,
2448,
7292,
1012,
16157,
1006,
1000,
3332,
1012,
2003,
10024,
19869,
3215... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
facebook/relay | packages/relay-compiler/core/RelayCompilerError.js | createCombinedError | function createCombinedError(
errors: $ReadOnlyArray<UserError>,
maybePrefix?: ?string,
): CombinedUserError {
const prefix = maybePrefix != null ? `${maybePrefix}: ` : '';
return new Error(
`${prefix}Encountered ${errors.length} error(s):\n` +
errors
.map(error =>
String(error)
.split('\n')
.map((line, index) => (index === 0 ? `- ${line}` : ` ${line}`))
.join('\n'),
)
.join('\n'),
);
} | javascript | function createCombinedError(
errors: $ReadOnlyArray<UserError>,
maybePrefix?: ?string,
): CombinedUserError {
const prefix = maybePrefix != null ? `${maybePrefix}: ` : '';
return new Error(
`${prefix}Encountered ${errors.length} error(s):\n` +
errors
.map(error =>
String(error)
.split('\n')
.map((line, index) => (index === 0 ? `- ${line}` : ` ${line}`))
.join('\n'),
)
.join('\n'),
);
} | [
"function",
"createCombinedError",
"(",
"errors",
":",
"$ReadOnlyArray",
"<",
"UserError",
">",
",",
"maybePrefix",
"?",
":",
"?",
"string",
",",
")",
":",
"CombinedUserError",
"{",
"const",
"prefix",
"=",
"maybePrefix",
"!=",
"null",
"?",
"`",
"${",
"maybeP... | Merges the results of multiple user errors into one so that they
can be reported in bulk. | [
"Merges",
"the",
"results",
"of",
"multiple",
"user",
"errors",
"into",
"one",
"so",
"that",
"they",
"can",
"be",
"reported",
"in",
"bulk",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/RelayCompilerError.js#L104-L120 | train | Creates a combined error from an array of user errors. | [
30522,
3853,
3443,
18274,
21280,
2121,
29165,
1006,
10697,
1024,
1002,
3191,
2239,
2135,
2906,
9447,
1026,
5310,
2121,
29165,
1028,
1010,
2672,
28139,
8873,
2595,
1029,
1024,
1029,
5164,
1010,
1007,
1024,
4117,
20330,
2121,
29165,
1063,
953... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | release.js | updateVersion | function updateVersion () {
start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`);
pkg.version = newVersion;
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
done();
abortCmds.push('git checkout package.json');
pushCmds.push('git add package.json');
} | javascript | function updateVersion () {
start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`);
pkg.version = newVersion;
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
done();
abortCmds.push('git checkout package.json');
pushCmds.push('git add package.json');
} | [
"function",
"updateVersion",
"(",
")",
"{",
"start",
"(",
"`",
"${",
"\"package.json\"",
".",
"cyan",
"}",
"${",
"oldVersion",
".",
"cyan",
"}",
"${",
"newVersion",
".",
"cyan",
"}",
"`",
")",
";",
"pkg",
".",
"version",
"=",
"newVersion",
";",
"fs",
... | writes the new version to package.json | [
"writes",
"the",
"new",
"version",
"to",
"package",
".",
"json"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L85-L92 | train | Updates the package. json version to the new version | [
30522,
3853,
10651,
27774,
1006,
1007,
1063,
2707,
1006,
1036,
2039,
16616,
1002,
1063,
1000,
7427,
1012,
1046,
3385,
1000,
1012,
22330,
2319,
1065,
2544,
2013,
1002,
1063,
2214,
27774,
1012,
22330,
2319,
1065,
2000,
1002,
1063,
2047,
27774... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | ElementTree | function ElementTree(id, instantiationOptions) {
var areInstantiationOptionsAnObject = _isObject(instantiationOptions);
var options;
/**
* Make sure that the options parameter is Object and
* that the ElementTree can be instantiate without initial options.
*/
if (areInstantiationOptionsAnObject) {
options = instantiationOptions;
} else {
options = {};
}
// Save DOM reference
this._ElementTreeContainer = document.getElementById(id);
/**
* Method fired when the number of issues against an element is clicked
*/
this.onIssueCountClicked = options.onIssueCountClicked ? options.onIssueCountClicked : function () {};
/**
* Method fired when the selected element in the ElementTree is changed.
* @param {string} selectedElementId - The selected element id
*/
this.onSelectionChanged = options.onSelectionChanged ? options.onSelectionChanged : function (selectedElementId) {};
/**
* Method fired when the hovered element in the ElementTree is changed.
* @param {string} hoveredElementId - The hovered element id
*/
this.onHoverChanged = options.onHoverChanged ? options.onHoverChanged : function (hoveredElementId) {};
/**
* Method fired when the mouse is out of the ElementTree.
*/
this.onMouseOut = options.onMouseOut ? options.onMouseOut : function () {};
/**
* Method fired when the initial ElementTree rendering is done.
*/
this.onInitialRendering = options.onInitialRendering ? options.onInitialRendering : function () {};
// Object with the tree model that will be visualized
this.setData(options.data);
} | javascript | function ElementTree(id, instantiationOptions) {
var areInstantiationOptionsAnObject = _isObject(instantiationOptions);
var options;
/**
* Make sure that the options parameter is Object and
* that the ElementTree can be instantiate without initial options.
*/
if (areInstantiationOptionsAnObject) {
options = instantiationOptions;
} else {
options = {};
}
// Save DOM reference
this._ElementTreeContainer = document.getElementById(id);
/**
* Method fired when the number of issues against an element is clicked
*/
this.onIssueCountClicked = options.onIssueCountClicked ? options.onIssueCountClicked : function () {};
/**
* Method fired when the selected element in the ElementTree is changed.
* @param {string} selectedElementId - The selected element id
*/
this.onSelectionChanged = options.onSelectionChanged ? options.onSelectionChanged : function (selectedElementId) {};
/**
* Method fired when the hovered element in the ElementTree is changed.
* @param {string} hoveredElementId - The hovered element id
*/
this.onHoverChanged = options.onHoverChanged ? options.onHoverChanged : function (hoveredElementId) {};
/**
* Method fired when the mouse is out of the ElementTree.
*/
this.onMouseOut = options.onMouseOut ? options.onMouseOut : function () {};
/**
* Method fired when the initial ElementTree rendering is done.
*/
this.onInitialRendering = options.onInitialRendering ? options.onInitialRendering : function () {};
// Object with the tree model that will be visualized
this.setData(options.data);
} | [
"function",
"ElementTree",
"(",
"id",
",",
"instantiationOptions",
")",
"{",
"var",
"areInstantiationOptionsAnObject",
"=",
"_isObject",
"(",
"instantiationOptions",
")",
";",
"var",
"options",
";",
"/**\n\t\t\t * Make sure that the options parameter is Object and\n\t\t\t * tha... | ElementTree constructor.
@param {string} id - The id of the DOM container
@param {ElementTree} instantiationOptions
@constructor | [
"ElementTree",
"constructor",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L119-L165 | train | The ElementTree constructor. | [
30522,
3853,
5783,
13334,
1006,
8909,
1010,
7107,
18963,
7361,
9285,
1007,
1063,
13075,
2024,
7076,
5794,
10711,
3508,
7361,
9285,
6761,
2497,
20614,
1027,
1035,
11163,
2497,
20614,
1006,
7107,
18963,
7361,
9285,
1007,
1025,
13075,
7047,
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... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onSignInWithEmailLink | function onSignInWithEmailLink() {
var email = $('#sign-in-with-email-link-email').val();
var link = $('#sign-in-with-email-link-link').val() || undefined;
if (auth.isSignInWithEmailLink(link)) {
auth.signInWithEmailLink(email, link).then(onAuthSuccess, onAuthError);
} else {
alertError('Sign in link is invalid');
}
} | javascript | function onSignInWithEmailLink() {
var email = $('#sign-in-with-email-link-email').val();
var link = $('#sign-in-with-email-link-link').val() || undefined;
if (auth.isSignInWithEmailLink(link)) {
auth.signInWithEmailLink(email, link).then(onAuthSuccess, onAuthError);
} else {
alertError('Sign in link is invalid');
}
} | [
"function",
"onSignInWithEmailLink",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#sign-in-with-email-link-email'",
")",
".",
"val",
"(",
")",
";",
"var",
"link",
"=",
"$",
"(",
"'#sign-in-with-email-link-link'",
")",
".",
"val",
"(",
")",
"||",
"undefine... | Signs in a user with an email link. | [
"Signs",
"in",
"a",
"user",
"with",
"an",
"email",
"link",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L329-L337 | train | Sign in with email link | [
30522,
3853,
2006,
5332,
29076,
2078,
24415,
14545,
8591,
19839,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
3696,
1011,
1999,
1011,
2007,
1011,
10373,
1011,
4957,
1011,
10373,
1005,
1007,
1012,
11748,
1006,
1007,
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/core/AppCacheBuster.js | function() {
// remove the function interceptions
ManagedObject.prototype.validateProperty = fnValidateProperty;
// only remove xhr interception if xhr#open was not modified meanwhile
if (XMLHttpRequest.prototype.open === fnEnhancedXhrOpen) {
XMLHttpRequest.prototype.open = fnXhrOpenOrig;
}
// remove the property descriptor interceptions (but only if not overridden again)
var descriptor;
if ((descriptor = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src")) && descriptor.set && descriptor.set._sapUiCoreACB === true) {
Object.defineProperty(HTMLScriptElement.prototype, "src", descScriptSrc);
}
if ((descriptor = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href")) && descriptor.set && descriptor.set._sapUiCoreACB === true) {
Object.defineProperty(HTMLLinkElement.prototype, "href", descLinkHref);
}
// clear the session (disables URL rewrite for session)
oSession.index = {};
oSession.active = false;
// create a new session for the next initialization
oSession = {
index: {},
active: false
};
} | javascript | function() {
// remove the function interceptions
ManagedObject.prototype.validateProperty = fnValidateProperty;
// only remove xhr interception if xhr#open was not modified meanwhile
if (XMLHttpRequest.prototype.open === fnEnhancedXhrOpen) {
XMLHttpRequest.prototype.open = fnXhrOpenOrig;
}
// remove the property descriptor interceptions (but only if not overridden again)
var descriptor;
if ((descriptor = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src")) && descriptor.set && descriptor.set._sapUiCoreACB === true) {
Object.defineProperty(HTMLScriptElement.prototype, "src", descScriptSrc);
}
if ((descriptor = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href")) && descriptor.set && descriptor.set._sapUiCoreACB === true) {
Object.defineProperty(HTMLLinkElement.prototype, "href", descLinkHref);
}
// clear the session (disables URL rewrite for session)
oSession.index = {};
oSession.active = false;
// create a new session for the next initialization
oSession = {
index: {},
active: false
};
} | [
"function",
"(",
")",
"{",
"// remove the function interceptions",
"ManagedObject",
".",
"prototype",
".",
"validateProperty",
"=",
"fnValidateProperty",
";",
"// only remove xhr interception if xhr#open was not modified meanwhile",
"if",
"(",
"XMLHttpRequest",
".",
"prototype",
... | Terminates the AppCacheBuster and removes the hooks from the URL
specific functions. This will also clear the index which is used
to prefix matching URLs.
@private | [
"Terminates",
"the",
"AppCacheBuster",
"and",
"removes",
"the",
"hooks",
"from",
"the",
"URL",
"specific",
"functions",
".",
"This",
"will",
"also",
"clear",
"the",
"index",
"which",
"is",
"used",
"to",
"prefix",
"matching",
"URLs",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/AppCacheBuster.js#L434-L463 | train | Removes the function interceptions from the object | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
6366,
1996,
3853,
18387,
3266,
16429,
20614,
1012,
8773,
1012,
9398,
3686,
21572,
4842,
3723,
1027,
1042,
2078,
10175,
8524,
2618,
21572,
4842,
3723,
1025,
1013,
1013,
2069,
6366,
1060,
8093,
17385... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js | createSearchConfig | function createSearchConfig(sFieldToSearch) {
var oConfig = {
fields: {},
expand: true
};
oConfig.fields[sFieldToSearch] = {};
return oConfig;
} | javascript | function createSearchConfig(sFieldToSearch) {
var oConfig = {
fields: {},
expand: true
};
oConfig.fields[sFieldToSearch] = {};
return oConfig;
} | [
"function",
"createSearchConfig",
"(",
"sFieldToSearch",
")",
"{",
"var",
"oConfig",
"=",
"{",
"fields",
":",
"{",
"}",
",",
"expand",
":",
"true",
"}",
";",
"oConfig",
".",
"fields",
"[",
"sFieldToSearch",
"]",
"=",
"{",
"}",
";",
"return",
"oConfig",
... | Create config for search of the lunr index
in the expected (by lunr lib) format
@param sFieldToSearch
@returns {{fields: {}, expand: boolean}} | [
"Create",
"config",
"for",
"search",
"of",
"the",
"lunr",
"index",
"in",
"the",
"expected",
"(",
"by",
"lunr",
"lib",
")",
"format"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L450-L458 | train | Creates a configuration object for a search query. | [
30522,
3853,
9005,
14644,
2818,
8663,
8873,
2290,
1006,
16420,
12891,
22282,
2906,
2818,
1007,
1063,
13075,
1051,
8663,
8873,
2290,
1027,
1063,
4249,
1024,
1063,
1065,
1010,
7818,
1024,
2995,
1065,
1025,
1051,
8663,
8873,
2290,
1012,
4249,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function () {
var data = this._conn._data;
// if no requests are in progress, poll
if (this._conn.authenticated && this._requests.length === 0 &&
data.length === 0 && !this._conn.disconnecting) {
Strophe.info("no requests during idle cycle, sending " +
"blank request");
data.push(null);
}
if (this._conn.paused) {
return;
}
if (this._requests.length < 2 && data.length > 0) {
var body = this._buildBody();
for (var i = 0; i < data.length; i++) {
if (data[i] !== null) {
if (data[i] === "restart") {
body.attrs({
to: this._conn.domain,
"xml:lang": "en",
"xmpp:restart": "true",
"xmlns:xmpp": Strophe.NS.BOSH
});
} else {
body.cnode(data[i]).up();
}
}
}
delete this._conn._data;
this._conn._data = [];
this._requests.push(
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, this._conn._dataRecv.bind(this._conn)),
body.tree().getAttribute("rid")));
this._throttledRequestHandler();
}
if (this._requests.length > 0) {
var time_elapsed = this._requests[0].age();
if (this._requests[0].dead !== null) {
if (this._requests[0].timeDead() >
Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
this._throttledRequestHandler();
}
}
if (time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)) {
Strophe.warn("Request " +
this._requests[0].id +
" timed out, over " + Math.floor(Strophe.TIMEOUT * this.wait) +
" seconds since last activity");
this._throttledRequestHandler();
}
}
} | javascript | function () {
var data = this._conn._data;
// if no requests are in progress, poll
if (this._conn.authenticated && this._requests.length === 0 &&
data.length === 0 && !this._conn.disconnecting) {
Strophe.info("no requests during idle cycle, sending " +
"blank request");
data.push(null);
}
if (this._conn.paused) {
return;
}
if (this._requests.length < 2 && data.length > 0) {
var body = this._buildBody();
for (var i = 0; i < data.length; i++) {
if (data[i] !== null) {
if (data[i] === "restart") {
body.attrs({
to: this._conn.domain,
"xml:lang": "en",
"xmpp:restart": "true",
"xmlns:xmpp": Strophe.NS.BOSH
});
} else {
body.cnode(data[i]).up();
}
}
}
delete this._conn._data;
this._conn._data = [];
this._requests.push(
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, this._conn._dataRecv.bind(this._conn)),
body.tree().getAttribute("rid")));
this._throttledRequestHandler();
}
if (this._requests.length > 0) {
var time_elapsed = this._requests[0].age();
if (this._requests[0].dead !== null) {
if (this._requests[0].timeDead() >
Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait)) {
this._throttledRequestHandler();
}
}
if (time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait)) {
Strophe.warn("Request " +
this._requests[0].id +
" timed out, over " + Math.floor(Strophe.TIMEOUT * this.wait) +
" seconds since last activity");
this._throttledRequestHandler();
}
}
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"_conn",
".",
"_data",
";",
"// if no requests are in progress, poll\r",
"if",
"(",
"this",
".",
"_conn",
".",
"authenticated",
"&&",
"this",
".",
"_requests",
".",
"length",
"===",
"0",
"&&",
"da... | PrivateFunction: _onIdle
_Private_ handler called by Strophe.Connection._onIdle
Sends all queued Requests or polls with empty Request if there are none. | [
"PrivateFunction",
":",
"_onIdle",
"_Private_",
"handler",
"called",
"by",
"Strophe",
".",
"Connection",
".",
"_onIdle"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4289-L4347 | train | End of method
| [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
1035,
9530,
2078,
1012,
1035,
2951,
1025,
1013,
1013,
2065,
2053,
11186,
2024,
1999,
5082,
1010,
8554,
2065,
1006,
2023,
1012,
1035,
9530,
2078,
1012,
14469,
4383,
1004,
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... | |
Dogfalo/materialize | dist/js/materialize.js | function (elements) {
for (var a = 0; a < elements.length; a++) {
var el = elements[a];
if (el.tagName.toLowerCase() === 'input') {
var parent = el.parentNode;
// If input already have parent just pass through
if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) {
continue;
}
// Put element class and style to the specified parent
var wrapper = document.createElement('i');
wrapper.className = el.className + ' waves-input-wrapper';
var elementStyle = el.getAttribute('style');
if (!elementStyle) {
elementStyle = '';
}
wrapper.setAttribute('style', elementStyle);
el.className = 'waves-button-input';
el.removeAttribute('style');
// Put element as child
parent.replaceChild(wrapper, el);
wrapper.appendChild(el);
}
}
} | javascript | function (elements) {
for (var a = 0; a < elements.length; a++) {
var el = elements[a];
if (el.tagName.toLowerCase() === 'input') {
var parent = el.parentNode;
// If input already have parent just pass through
if (parent.tagName.toLowerCase() === 'i' && parent.className.indexOf('waves-effect') !== -1) {
continue;
}
// Put element class and style to the specified parent
var wrapper = document.createElement('i');
wrapper.className = el.className + ' waves-input-wrapper';
var elementStyle = el.getAttribute('style');
if (!elementStyle) {
elementStyle = '';
}
wrapper.setAttribute('style', elementStyle);
el.className = 'waves-button-input';
el.removeAttribute('style');
// Put element as child
parent.replaceChild(wrapper, el);
wrapper.appendChild(el);
}
}
} | [
"function",
"(",
"elements",
")",
"{",
"for",
"(",
"var",
"a",
"=",
"0",
";",
"a",
"<",
"elements",
".",
"length",
";",
"a",
"++",
")",
"{",
"var",
"el",
"=",
"elements",
"[",
"a",
"]",
";",
"if",
"(",
"el",
".",
"tagName",
".",
"toLowerCase",
... | Little hack to make <input> can perform waves effect | [
"Little",
"hack",
"to",
"make",
"<input",
">",
"can",
"perform",
"waves",
"effect"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L4955-L4987 | train | This function is called by the waves - button - input. js | [
30522,
3853,
1006,
3787,
1007,
1063,
2005,
1006,
13075,
1037,
1027,
1014,
1025,
1037,
1026,
3787,
1012,
3091,
1025,
1037,
1009,
1009,
1007,
1063,
13075,
3449,
1027,
3787,
1031,
1037,
1033,
1025,
2065,
1006,
3449,
1012,
6415,
18442,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/ProjectManager.js | addWelcomeProjectPath | function addWelcomeProjectPath(path) {
var welcomeProjects = ProjectModel._addWelcomeProjectPath(path,
PreferencesManager.getViewState("welcomeProjects"));
PreferencesManager.setViewState("welcomeProjects", welcomeProjects);
} | javascript | function addWelcomeProjectPath(path) {
var welcomeProjects = ProjectModel._addWelcomeProjectPath(path,
PreferencesManager.getViewState("welcomeProjects"));
PreferencesManager.setViewState("welcomeProjects", welcomeProjects);
} | [
"function",
"addWelcomeProjectPath",
"(",
"path",
")",
"{",
"var",
"welcomeProjects",
"=",
"ProjectModel",
".",
"_addWelcomeProjectPath",
"(",
"path",
",",
"PreferencesManager",
".",
"getViewState",
"(",
"\"welcomeProjects\"",
")",
")",
";",
"PreferencesManager",
".",... | Adds the path to the list of welcome projects we've ever seen, if not on the list already.
@param {string} path Path to possibly add | [
"Adds",
"the",
"path",
"to",
"the",
"list",
"of",
"welcome",
"projects",
"we",
"ve",
"ever",
"seen",
"if",
"not",
"on",
"the",
"list",
"already",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L700-L704 | train | Add a path to the project model | [
30522,
3853,
5587,
8545,
22499,
4168,
21572,
20614,
15069,
1006,
4130,
1007,
1063,
13075,
6160,
21572,
20614,
2015,
1027,
2622,
5302,
9247,
1012,
1035,
5587,
8545,
22499,
4168,
21572,
20614,
15069,
1006,
4130,
1010,
18394,
24805,
4590,
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... |
necolas/react-native-web | packages/react-native-web/src/vendor/react-native/emitter/mixInEventEmitter.js | mixInEventEmitter | function mixInEventEmitter(cls: Function | Object, types: Object) {
invariant(types, 'Must supply set of valid event types');
// If this is a constructor, write to the prototype, otherwise write to the
// singleton object.
const target = cls.prototype || cls;
invariant(!target.__eventEmitter, 'An active emitter is already mixed in');
const ctor = cls.constructor;
if (ctor) {
invariant(
ctor === Object || ctor === Function,
'Mix EventEmitter into a class, not an instance'
);
}
// Keep track of the provided types, union the types if they already exist,
// which allows for prototype subclasses to provide more types.
if (target.hasOwnProperty(TYPES_KEY)) {
Object.assign(target.__types, types);
} else if (target.__types) {
target.__types = Object.assign({}, target.__types, types);
} else {
target.__types = types;
}
Object.assign(target, EventEmitterMixin);
} | javascript | function mixInEventEmitter(cls: Function | Object, types: Object) {
invariant(types, 'Must supply set of valid event types');
// If this is a constructor, write to the prototype, otherwise write to the
// singleton object.
const target = cls.prototype || cls;
invariant(!target.__eventEmitter, 'An active emitter is already mixed in');
const ctor = cls.constructor;
if (ctor) {
invariant(
ctor === Object || ctor === Function,
'Mix EventEmitter into a class, not an instance'
);
}
// Keep track of the provided types, union the types if they already exist,
// which allows for prototype subclasses to provide more types.
if (target.hasOwnProperty(TYPES_KEY)) {
Object.assign(target.__types, types);
} else if (target.__types) {
target.__types = Object.assign({}, target.__types, types);
} else {
target.__types = types;
}
Object.assign(target, EventEmitterMixin);
} | [
"function",
"mixInEventEmitter",
"(",
"cls",
":",
"Function",
"|",
"Object",
",",
"types",
":",
"Object",
")",
"{",
"invariant",
"(",
"types",
",",
"'Must supply set of valid event types'",
")",
";",
"// If this is a constructor, write to the prototype, otherwise write to t... | API to setup an object or constructor to be able to emit data events.
@example
function Dog() { ...dog stuff... }
mixInEventEmitter(Dog, {bark: true});
var puppy = new Dog();
puppy.addListener('bark', function (volume) {
console.log('Puppy', this, 'barked at volume:', volume);
});
puppy.emit('bark', 'quiet');
// Puppy <puppy> barked at volume: quiet
// A "singleton" object may also be commissioned:
var Singleton = {};
mixInEventEmitter(Singleton, {lonely: true});
Singleton.emit('lonely', true); | [
"API",
"to",
"setup",
"an",
"object",
"or",
"constructor",
"to",
"be",
"able",
"to",
"emit",
"data",
"events",
"."
] | 801937748b2f3c96284bee1881164ac0c62a9c6d | https://github.com/necolas/react-native-web/blob/801937748b2f3c96284bee1881164ac0c62a9c6d/packages/react-native-web/src/vendor/react-native/emitter/mixInEventEmitter.js#L49-L76 | train | Mix in an EventEmitter into a class. | [
30522,
3853,
4666,
3170,
15338,
23238,
12079,
1006,
18856,
2015,
1024,
3853,
1064,
4874,
1010,
4127,
1024,
4874,
1007,
1063,
23915,
1006,
4127,
1010,
1005,
2442,
4425,
2275,
1997,
9398,
2724,
4127,
1005,
1007,
1025,
1013,
1013,
2065,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | grunt/config/aliases.js | function(mode) {
if (!mode || (mode !== 'src' && mode !== 'target')) {
mode = 'src';
}
grunt.option('port', 0); // use random port
// listen to the connect server startup
grunt.event.on('connect.*.listening', function(hostname, port) {
// 0.0.0.0 does not work in windows
if (hostname === '0.0.0.0') {
hostname = 'localhost';
}
// set baseUrl (using hostname / port from connect task)
grunt.config(['selenium_qunit', 'options', 'baseUrl'], 'http://' + hostname + ':' + port);
// run selenium task
grunt.task.run(['selenium_qunit:run']);
});
// cleanup and start connect server
grunt.task.run([
'clean:surefire-reports',
'openui5_connect:' + mode
]);
} | javascript | function(mode) {
if (!mode || (mode !== 'src' && mode !== 'target')) {
mode = 'src';
}
grunt.option('port', 0); // use random port
// listen to the connect server startup
grunt.event.on('connect.*.listening', function(hostname, port) {
// 0.0.0.0 does not work in windows
if (hostname === '0.0.0.0') {
hostname = 'localhost';
}
// set baseUrl (using hostname / port from connect task)
grunt.config(['selenium_qunit', 'options', 'baseUrl'], 'http://' + hostname + ':' + port);
// run selenium task
grunt.task.run(['selenium_qunit:run']);
});
// cleanup and start connect server
grunt.task.run([
'clean:surefire-reports',
'openui5_connect:' + mode
]);
} | [
"function",
"(",
"mode",
")",
"{",
"if",
"(",
"!",
"mode",
"||",
"(",
"mode",
"!==",
"'src'",
"&&",
"mode",
"!==",
"'target'",
")",
")",
"{",
"mode",
"=",
"'src'",
";",
"}",
"grunt",
".",
"option",
"(",
"'port'",
",",
"0",
")",
";",
"// use rando... | QUnit test task | [
"QUnit",
"test",
"task"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/grunt/config/aliases.js#L41-L69 | train | set the mode of the connect server | [
30522,
3853,
1006,
5549,
1007,
1063,
2065,
1006,
999,
5549,
1064,
1064,
1006,
5549,
999,
1027,
1027,
30524,
999,
1027,
1027,
1005,
4539,
1005,
1007,
1007,
1063,
5549,
1027,
1005,
5034,
2278,
1005,
1025,
1065,
20696,
1012,
5724,
1006,
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... | |
jquery/jquery | build/release/cdn.js | makeReleaseCopies | function makeReleaseCopies( Release ) {
shell.mkdir( "-p", cdnFolder );
Object.keys( releaseFiles ).forEach( function( key ) {
var text,
builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, Release.newVersion ),
releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFile ) ) {
// Map files need to reference the new uncompressed name;
// assume that all files reside in the same directory.
// "file":"jquery.min.js" ... "sources":["jquery.js"]
text = fs.readFileSync( builtFile, "utf8" )
.replace( /"file":"([^"]+)"/,
"\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js\"" ) )
.replace( /"sources":\["([^"]+)"\]/,
"\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" );
fs.writeFileSync( releaseFile, text );
} else if ( builtFile !== releaseFile ) {
shell.cp( "-f", builtFile, releaseFile );
}
} );
} | javascript | function makeReleaseCopies( Release ) {
shell.mkdir( "-p", cdnFolder );
Object.keys( releaseFiles ).forEach( function( key ) {
var text,
builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, Release.newVersion ),
releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFile ) ) {
// Map files need to reference the new uncompressed name;
// assume that all files reside in the same directory.
// "file":"jquery.min.js" ... "sources":["jquery.js"]
text = fs.readFileSync( builtFile, "utf8" )
.replace( /"file":"([^"]+)"/,
"\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js\"" ) )
.replace( /"sources":\["([^"]+)"\]/,
"\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]" );
fs.writeFileSync( releaseFile, text );
} else if ( builtFile !== releaseFile ) {
shell.cp( "-f", builtFile, releaseFile );
}
} );
} | [
"function",
"makeReleaseCopies",
"(",
"Release",
")",
"{",
"shell",
".",
"mkdir",
"(",
"\"-p\"",
",",
"cdnFolder",
")",
";",
"Object",
".",
"keys",
"(",
"releaseFiles",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"text",
",",
"bu... | Generates copies for the CDNs | [
"Generates",
"copies",
"for",
"the",
"CDNs"
] | ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3 | https://github.com/jquery/jquery/blob/ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3/build/release/cdn.js#L30-L54 | train | Copies the files from the built file to the new release file | [
30522,
3853,
9338,
12260,
11022,
3597,
13046,
1006,
2713,
1007,
1063,
5806,
1012,
12395,
4305,
2099,
1006,
1000,
1011,
1052,
1000,
1010,
3729,
2078,
10371,
2121,
1007,
1025,
4874,
1012,
6309,
1006,
2713,
8873,
4244,
1007,
1012,
18921,
6776,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
google/material-design-lite | src/mdlComponentHandler.js | upgradeAllRegisteredInternal | function upgradeAllRegisteredInternal() {
for (var n = 0; n < registeredComponents_.length; n++) {
upgradeDomInternal(registeredComponents_[n].className);
}
} | javascript | function upgradeAllRegisteredInternal() {
for (var n = 0; n < registeredComponents_.length; n++) {
upgradeDomInternal(registeredComponents_[n].className);
}
} | [
"function",
"upgradeAllRegisteredInternal",
"(",
")",
"{",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"registeredComponents_",
".",
"length",
";",
"n",
"++",
")",
"{",
"upgradeDomInternal",
"(",
"registeredComponents_",
"[",
"n",
"]",
".",
"className",... | Upgrades all registered components found in the current DOM. This is
automatically called on window load. | [
"Upgrades",
"all",
"registered",
"components",
"found",
"in",
"the",
"current",
"DOM",
".",
"This",
"is",
"automatically",
"called",
"on",
"window",
"load",
"."
] | 60f441a22ed98ed2c03f6179adf460d888bf459f | https://github.com/google/material-design-lite/blob/60f441a22ed98ed2c03f6179adf460d888bf459f/src/mdlComponentHandler.js#L357-L361 | train | Upgrades all registered components | [
30522,
3853,
12200,
8095,
2890,
24063,
6850,
18447,
11795,
2389,
1006,
1007,
1063,
2005,
1006,
13075,
1050,
1027,
1014,
1025,
1050,
1026,
5068,
9006,
29513,
7666,
1035,
1012,
3091,
1025,
1050,
1009,
1009,
1007,
1063,
9725,
20936,
10111,
127... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | defineDagExtremity | function defineDagExtremity(params) {
return function dagExtremityImpl(selector) {
var eles = this;
var ret = [];
for (var i = 0; i < eles.length; i++) {
var ele = eles[i];
if (!ele.isNode()) {
continue;
}
var disqualified = false;
var edges = ele.connectedEdges();
for (var j = 0; j < edges.length; j++) {
var edge = edges[j];
var src = edge.source();
var tgt = edge.target();
if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) {
disqualified = true;
break;
}
}
if (!disqualified) {
ret.push(ele);
}
}
return this.spawn(ret, {
unique: true
}).filter(selector);
};
} | javascript | function defineDagExtremity(params) {
return function dagExtremityImpl(selector) {
var eles = this;
var ret = [];
for (var i = 0; i < eles.length; i++) {
var ele = eles[i];
if (!ele.isNode()) {
continue;
}
var disqualified = false;
var edges = ele.connectedEdges();
for (var j = 0; j < edges.length; j++) {
var edge = edges[j];
var src = edge.source();
var tgt = edge.target();
if (params.noIncomingEdges && tgt === ele && src !== ele || params.noOutgoingEdges && src === ele && tgt !== ele) {
disqualified = true;
break;
}
}
if (!disqualified) {
ret.push(ele);
}
}
return this.spawn(ret, {
unique: true
}).filter(selector);
};
} | [
"function",
"defineDagExtremity",
"(",
"params",
")",
"{",
"return",
"function",
"dagExtremityImpl",
"(",
"selector",
")",
"{",
"var",
"eles",
"=",
"this",
";",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles"... | DAG functions ////////////// | [
"DAG",
"functions",
"//////////////"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L11359-L11394 | train | defineDagExtremity - Returns a function that will return an array of nodes that are not connected to the nodes in the graph. | [
30522,
3853,
4225,
4270,
18413,
28578,
3012,
1006,
11498,
5244,
1007,
1063,
2709,
3853,
4830,
3351,
18413,
28578,
3012,
5714,
24759,
1006,
27000,
1007,
1063,
13075,
3449,
2229,
1027,
2023,
1025,
13075,
2128,
2102,
1027,
1031,
1033,
1025,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BrainJS/brain.js | dist/recurrent/matrix/multiply-b.js | multiplyB | function multiplyB(product, left, right) {
var leftRows = left.rows;
var leftColumns = left.columns;
var rightColumns = right.columns;
// loop over rows of left
for (var leftRow = 0; leftRow < leftRows; leftRow++) {
var leftRowBase = leftColumns * leftRow;
var rightRowBase = rightColumns * leftRow;
// loop over cols of right
for (var rightColumn = 0; rightColumn < rightColumns; rightColumn++) {
//loop over columns of left
for (var leftColumn = 0; leftColumn < leftColumns; leftColumn++) {
var rightColumnBase = rightColumns * leftColumn;
var _leftRow = leftRowBase + leftColumn;
var rightRow = rightColumnBase + rightColumn;
var backPropagateValue = product.deltas[rightRowBase + rightColumn];
left.deltas[_leftRow] += right.weights[rightRow] * backPropagateValue;
right.deltas[rightRow] += left.weights[_leftRow] * backPropagateValue;
}
}
}
} | javascript | function multiplyB(product, left, right) {
var leftRows = left.rows;
var leftColumns = left.columns;
var rightColumns = right.columns;
// loop over rows of left
for (var leftRow = 0; leftRow < leftRows; leftRow++) {
var leftRowBase = leftColumns * leftRow;
var rightRowBase = rightColumns * leftRow;
// loop over cols of right
for (var rightColumn = 0; rightColumn < rightColumns; rightColumn++) {
//loop over columns of left
for (var leftColumn = 0; leftColumn < leftColumns; leftColumn++) {
var rightColumnBase = rightColumns * leftColumn;
var _leftRow = leftRowBase + leftColumn;
var rightRow = rightColumnBase + rightColumn;
var backPropagateValue = product.deltas[rightRowBase + rightColumn];
left.deltas[_leftRow] += right.weights[rightRow] * backPropagateValue;
right.deltas[rightRow] += left.weights[_leftRow] * backPropagateValue;
}
}
}
} | [
"function",
"multiplyB",
"(",
"product",
",",
"left",
",",
"right",
")",
"{",
"var",
"leftRows",
"=",
"left",
".",
"rows",
";",
"var",
"leftColumns",
"=",
"left",
".",
"columns",
";",
"var",
"rightColumns",
"=",
"right",
".",
"columns",
";",
"// loop ove... | multiplies {from} deltas to {left} and {right}
@param {Matrix} product
@param {Matrix} left
@param {Matrix} right | [
"multiplies",
"{",
"from",
"}",
"deltas",
"to",
"{",
"left",
"}",
"and",
"{",
"right",
"}"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/recurrent/matrix/multiply-b.js#L13-L36 | train | multiply B product | [
30522,
3853,
4800,
22086,
2497,
1006,
4031,
1010,
2187,
1010,
2157,
1007,
1063,
13075,
2187,
10524,
2015,
1027,
2187,
1012,
10281,
1025,
13075,
2187,
25778,
2819,
3619,
1027,
2187,
1012,
7753,
1025,
13075,
2157,
25778,
2819,
3619,
1027,
215... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/array-element-newline.js | check | function check(node) {
const elements = node.elements;
const normalizedOptions = normalizeOptions(context.options[0]);
const options = normalizedOptions[node.type];
let elementBreak = false;
/*
* MULTILINE: true
* loop through every element and check
* if at least one element has linebreaks inside
* this ensures that following is not valid (due to elements are on the same line):
*
* [
* 1,
* 2,
* 3
* ]
*/
if (options.multiline) {
elementBreak = elements
.filter(element => element !== null)
.some(element => element.loc.start.line !== element.loc.end.line);
}
const linebreaksCount = node.elements.map((element, i) => {
const previousElement = elements[i - 1];
if (i === 0 || element === null || previousElement === null) {
return false;
}
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
return !astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement);
}).filter(isBreak => isBreak === true).length;
const needsLinebreaks = (
elements.length >= options.minItems ||
(
options.multiline &&
elementBreak
) ||
(
options.consistent &&
linebreaksCount > 0 &&
linebreaksCount < node.elements.length
)
);
elements.forEach((element, i) => {
const previousElement = elements[i - 1];
if (i === 0 || element === null || previousElement === null) {
return;
}
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
if (needsLinebreaks) {
if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
reportRequiredLineBreak(firstTokenOfCurrentElement);
}
} else {
if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
reportNoLineBreak(firstTokenOfCurrentElement);
}
}
});
} | javascript | function check(node) {
const elements = node.elements;
const normalizedOptions = normalizeOptions(context.options[0]);
const options = normalizedOptions[node.type];
let elementBreak = false;
/*
* MULTILINE: true
* loop through every element and check
* if at least one element has linebreaks inside
* this ensures that following is not valid (due to elements are on the same line):
*
* [
* 1,
* 2,
* 3
* ]
*/
if (options.multiline) {
elementBreak = elements
.filter(element => element !== null)
.some(element => element.loc.start.line !== element.loc.end.line);
}
const linebreaksCount = node.elements.map((element, i) => {
const previousElement = elements[i - 1];
if (i === 0 || element === null || previousElement === null) {
return false;
}
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
return !astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement);
}).filter(isBreak => isBreak === true).length;
const needsLinebreaks = (
elements.length >= options.minItems ||
(
options.multiline &&
elementBreak
) ||
(
options.consistent &&
linebreaksCount > 0 &&
linebreaksCount < node.elements.length
)
);
elements.forEach((element, i) => {
const previousElement = elements[i - 1];
if (i === 0 || element === null || previousElement === null) {
return;
}
const commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken);
const lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken);
const firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
if (needsLinebreaks) {
if (astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
reportRequiredLineBreak(firstTokenOfCurrentElement);
}
} else {
if (!astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement)) {
reportNoLineBreak(firstTokenOfCurrentElement);
}
}
});
} | [
"function",
"check",
"(",
"node",
")",
"{",
"const",
"elements",
"=",
"node",
".",
"elements",
";",
"const",
"normalizedOptions",
"=",
"normalizeOptions",
"(",
"context",
".",
"options",
"[",
"0",
"]",
")",
";",
"const",
"options",
"=",
"normalizedOptions",
... | Reports a given node if it violated this rule.
@param {ASTNode} node - A node to check. This is an ObjectExpression node or an ObjectPattern node.
@returns {void} | [
"Reports",
"a",
"given",
"node",
"if",
"it",
"violated",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/array-element-newline.js#L178-L251 | train | Check if node has linebreaks | [
30522,
3853,
4638,
1006,
13045,
1007,
1063,
9530,
3367,
3787,
1027,
13045,
1012,
3787,
1025,
9530,
3367,
3671,
3550,
7361,
9285,
1027,
3671,
4697,
7361,
9285,
1006,
6123,
1012,
7047,
1031,
1014,
1033,
1007,
1025,
9530,
3367,
7047,
1027,
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... |
openlayers/openlayers | src/ol/interaction/Modify.js | closestOnSegmentData | function closestOnSegmentData(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE &&
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
return geometry.getClosestPoint(pointCoordinates);
}
return closestOnSegment(pointCoordinates, segmentData.segment);
} | javascript | function closestOnSegmentData(pointCoordinates, segmentData) {
const geometry = segmentData.geometry;
if (geometry.getType() === GeometryType.CIRCLE &&
segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
return geometry.getClosestPoint(pointCoordinates);
}
return closestOnSegment(pointCoordinates, segmentData.segment);
} | [
"function",
"closestOnSegmentData",
"(",
"pointCoordinates",
",",
"segmentData",
")",
"{",
"const",
"geometry",
"=",
"segmentData",
".",
"geometry",
";",
"if",
"(",
"geometry",
".",
"getType",
"(",
")",
"===",
"GeometryType",
".",
"CIRCLE",
"&&",
"segmentData",
... | Returns the point closest to a given line segment.
@param {import("../coordinate.js").Coordinate} pointCoordinates The point to which a closest point
should be found.
@param {SegmentData} segmentData The object describing the line
segment which should contain the closest point.
@return {import("../coordinate.js").Coordinate} The point closest to the specified line segment. | [
"Returns",
"the",
"point",
"closest",
"to",
"a",
"given",
"line",
"segment",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/Modify.js#L1228-L1236 | train | Returns the closest point on the given segmentData | [
30522,
3853,
7541,
5644,
13910,
3672,
2850,
2696,
1006,
2391,
3597,
8551,
28184,
1010,
6903,
2850,
2696,
1007,
1063,
9530,
3367,
10988,
1027,
6903,
2850,
2696,
1012,
10988,
1025,
2065,
1006,
10988,
1012,
2131,
13874,
1006,
1007,
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... |
grpc/grpc-node | packages/grpc-native-core/src/client.js | Client | function Client(address, credentials, options) {
var self = this;
if (!options) {
options = {};
}
// Resolve interceptor options and assign interceptors to each method
if (Array.isArray(options.interceptor_providers) && Array.isArray(options.interceptors)) {
throw new client_interceptors.InterceptorConfigurationError(
'Both interceptors and interceptor_providers were passed as options ' +
'to the client constructor. Only one of these is allowed.');
}
self.$interceptors = options.interceptors || [];
self.$interceptor_providers = options.interceptor_providers || [];
if (self.$method_definitions) {
Object.keys(self.$method_definitions).forEach(method_name => {
const method_definition = self.$method_definitions[method_name];
self[method_name].interceptors = client_interceptors
.resolveInterceptorProviders(self.$interceptor_providers, method_definition)
.concat(self.$interceptors);
});
}
this.$callInvocationTransformer = options.callInvocationTransformer;
let channelOverride = options.channelOverride;
let channelFactoryOverride = options.channelFactoryOverride;
// Exclude channel options which have already been consumed
const ignoredKeys = [
'interceptors', 'interceptor_providers', 'channelOverride',
'channelFactoryOverride', 'callInvocationTransformer'
];
var channel_options = Object.getOwnPropertyNames(options)
.reduce((acc, key) => {
if (ignoredKeys.indexOf(key) === -1) {
acc[key] = options[key];
}
return acc;
}, {});
/* Private fields use $ as a prefix instead of _ because it is an invalid
* prefix of a method name */
if (channelOverride) {
this.$channel = options.channelOverride;
} else {
if (channelFactoryOverride) {
this.$channel = channelFactoryOverride(address, credentials, channel_options);
} else {
this.$channel = new grpc.Channel(address, credentials, channel_options);
}
}
} | javascript | function Client(address, credentials, options) {
var self = this;
if (!options) {
options = {};
}
// Resolve interceptor options and assign interceptors to each method
if (Array.isArray(options.interceptor_providers) && Array.isArray(options.interceptors)) {
throw new client_interceptors.InterceptorConfigurationError(
'Both interceptors and interceptor_providers were passed as options ' +
'to the client constructor. Only one of these is allowed.');
}
self.$interceptors = options.interceptors || [];
self.$interceptor_providers = options.interceptor_providers || [];
if (self.$method_definitions) {
Object.keys(self.$method_definitions).forEach(method_name => {
const method_definition = self.$method_definitions[method_name];
self[method_name].interceptors = client_interceptors
.resolveInterceptorProviders(self.$interceptor_providers, method_definition)
.concat(self.$interceptors);
});
}
this.$callInvocationTransformer = options.callInvocationTransformer;
let channelOverride = options.channelOverride;
let channelFactoryOverride = options.channelFactoryOverride;
// Exclude channel options which have already been consumed
const ignoredKeys = [
'interceptors', 'interceptor_providers', 'channelOverride',
'channelFactoryOverride', 'callInvocationTransformer'
];
var channel_options = Object.getOwnPropertyNames(options)
.reduce((acc, key) => {
if (ignoredKeys.indexOf(key) === -1) {
acc[key] = options[key];
}
return acc;
}, {});
/* Private fields use $ as a prefix instead of _ because it is an invalid
* prefix of a method name */
if (channelOverride) {
this.$channel = options.channelOverride;
} else {
if (channelFactoryOverride) {
this.$channel = channelFactoryOverride(address, credentials, channel_options);
} else {
this.$channel = new grpc.Channel(address, credentials, channel_options);
}
}
} | [
"function",
"Client",
"(",
"address",
",",
"credentials",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"// Resolve interceptor options and assign interceptors to each method",... | Options that can be set on a call.
@typedef {Object} grpc.Client~CallOptions
@property {grpc~Deadline} deadline The deadline for the entire call to
complete.
@property {string} host Server hostname to set on the call. Only meaningful
if different from the server address used to construct the client.
@property {grpc.Client~Call} parent Parent call. Used in servers when
making a call as part of the process of handling a call. Used to
propagate some information automatically, as specified by
propagate_flags.
@property {number} propagate_flags Indicates which properties of a parent
call should propagate to this call. Bitwise combination of flags in
{@link grpc.propagate}.
@property {grpc.credentials~CallCredentials} credentials The credentials that
should be used to make this particular call.
A generic gRPC client. Primarily useful as a base class for generated clients
@memberof grpc
@constructor
@param {string} address Server address to connect to
@param {grpc.credentials~ChannelCredentials} credentials Credentials to use
to connect to the server
@param {Object} options Options to apply to channel creation | [
"Options",
"that",
"can",
"be",
"set",
"on",
"a",
"call",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client.js#L365-L415 | train | Creates a new client | [
30522,
3853,
7396,
1006,
4769,
1010,
22496,
1010,
7047,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
999,
7047,
1007,
1063,
7047,
1027,
1063,
1065,
1025,
1065,
1013,
1013,
10663,
24727,
7047,
1998,
23911,
24727,
2015,
2000,
2169,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
facebook/relay | packages/relay-runtime/network/ConvertToExecuteFunction.js | convertSubscribe | function convertSubscribe(fn: SubscribeFunction): ExecuteFunction {
return function subscribe(operation, variables, cacheConfig) {
return RelayObservable.fromLegacy(observer =>
fn(operation, variables, cacheConfig, observer),
);
};
} | javascript | function convertSubscribe(fn: SubscribeFunction): ExecuteFunction {
return function subscribe(operation, variables, cacheConfig) {
return RelayObservable.fromLegacy(observer =>
fn(operation, variables, cacheConfig, observer),
);
};
} | [
"function",
"convertSubscribe",
"(",
"fn",
":",
"SubscribeFunction",
")",
":",
"ExecuteFunction",
"{",
"return",
"function",
"subscribe",
"(",
"operation",
",",
"variables",
",",
"cacheConfig",
")",
"{",
"return",
"RelayObservable",
".",
"fromLegacy",
"(",
"observ... | Converts a SubscribeFunction into an ExecuteFunction for use by RelayNetwork. | [
"Converts",
"a",
"SubscribeFunction",
"into",
"an",
"ExecuteFunction",
"for",
"use",
"by",
"RelayNetwork",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/network/ConvertToExecuteFunction.js#L40-L46 | train | Convert SubscribeFunction to RelayObservable | [
30522,
3853,
19884,
12083,
29234,
1006,
1042,
2078,
1024,
4942,
29234,
11263,
27989,
1007,
1024,
15389,
11263,
27989,
1063,
2709,
3853,
4942,
29234,
1006,
3169,
1010,
10857,
1010,
17053,
8663,
8873,
2290,
1007,
1063,
2709,
8846,
16429,
8043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/rule-should-run.js | matchTags | function matchTags(rule, runOnly) {
'use strict';
var include, exclude, matching;
var defaultExclude =
axe._audit && axe._audit.tagExclude ? axe._audit.tagExclude : [];
// normalize include/exclude
if (runOnly.hasOwnProperty('include') || runOnly.hasOwnProperty('exclude')) {
// Wrap include and exclude if it's not already an array
include = runOnly.include || [];
include = Array.isArray(include) ? include : [include];
exclude = runOnly.exclude || [];
exclude = Array.isArray(exclude) ? exclude : [exclude];
// add defaults, unless mentioned in include
exclude = exclude.concat(
defaultExclude.filter(function(tag) {
return include.indexOf(tag) === -1;
})
);
// Otherwise, only use the include value, ignore exclude
} else {
include = Array.isArray(runOnly) ? runOnly : [runOnly];
// exclude the defaults not included
exclude = defaultExclude.filter(function(tag) {
return include.indexOf(tag) === -1;
});
}
matching = include.some(function(tag) {
return rule.tags.indexOf(tag) !== -1;
});
if (matching || (include.length === 0 && rule.enabled !== false)) {
return exclude.every(function(tag) {
return rule.tags.indexOf(tag) === -1;
});
} else {
return false;
}
} | javascript | function matchTags(rule, runOnly) {
'use strict';
var include, exclude, matching;
var defaultExclude =
axe._audit && axe._audit.tagExclude ? axe._audit.tagExclude : [];
// normalize include/exclude
if (runOnly.hasOwnProperty('include') || runOnly.hasOwnProperty('exclude')) {
// Wrap include and exclude if it's not already an array
include = runOnly.include || [];
include = Array.isArray(include) ? include : [include];
exclude = runOnly.exclude || [];
exclude = Array.isArray(exclude) ? exclude : [exclude];
// add defaults, unless mentioned in include
exclude = exclude.concat(
defaultExclude.filter(function(tag) {
return include.indexOf(tag) === -1;
})
);
// Otherwise, only use the include value, ignore exclude
} else {
include = Array.isArray(runOnly) ? runOnly : [runOnly];
// exclude the defaults not included
exclude = defaultExclude.filter(function(tag) {
return include.indexOf(tag) === -1;
});
}
matching = include.some(function(tag) {
return rule.tags.indexOf(tag) !== -1;
});
if (matching || (include.length === 0 && rule.enabled !== false)) {
return exclude.every(function(tag) {
return rule.tags.indexOf(tag) === -1;
});
} else {
return false;
}
} | [
"function",
"matchTags",
"(",
"rule",
",",
"runOnly",
")",
"{",
"'use strict'",
";",
"var",
"include",
",",
"exclude",
",",
"matching",
";",
"var",
"defaultExclude",
"=",
"axe",
".",
"_audit",
"&&",
"axe",
".",
"_audit",
".",
"tagExclude",
"?",
"axe",
".... | Check if a rule matches the value of runOnly type=tag
@private
@param {object} rule
@param {object} runOnly Value of runOnly with type=tags
@return {bool} | [
"Check",
"if",
"a",
"rule",
"matches",
"the",
"value",
"of",
"runOnly",
"type",
"=",
"tag"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/rule-should-run.js#L8-L48 | train | Match the tags in the rule | [
30522,
3853,
2674,
15900,
2015,
1006,
3627,
1010,
2448,
2239,
2135,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
2421,
1010,
23329,
1010,
9844,
1025,
13075,
12398,
10288,
20464,
12672,
1027,
12946,
1012,
1035,
15727,
1004,
1004,
12946,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/preload-cssom.js | getCssomForAllRootNodes | function getCssomForAllRootNodes(rootNodes, convertDataToStylesheet, timeout) {
const q = axe.utils.queue();
rootNodes.forEach(({ rootNode, shadowId }, index) =>
q.defer((resolve, reject) =>
loadCssom({
rootNode,
shadowId,
timeout,
convertDataToStylesheet,
rootIndex: index + 1
})
.then(resolve)
.catch(reject)
)
);
return q;
} | javascript | function getCssomForAllRootNodes(rootNodes, convertDataToStylesheet, timeout) {
const q = axe.utils.queue();
rootNodes.forEach(({ rootNode, shadowId }, index) =>
q.defer((resolve, reject) =>
loadCssom({
rootNode,
shadowId,
timeout,
convertDataToStylesheet,
rootIndex: index + 1
})
.then(resolve)
.catch(reject)
)
);
return q;
} | [
"function",
"getCssomForAllRootNodes",
"(",
"rootNodes",
",",
"convertDataToStylesheet",
",",
"timeout",
")",
"{",
"const",
"q",
"=",
"axe",
".",
"utils",
".",
"queue",
"(",
")",
";",
"rootNodes",
".",
"forEach",
"(",
"(",
"{",
"rootNode",
",",
"shadowId",
... | Deferred function for CSSOM queue processing on all root nodes
@param {Array<Object>} rootNodes array of root nodes, where node is an enhanced `document` or `documentFragment` object returned from `getAllRootNodesInTree`
@param {Function} convertDataToStylesheet fn to convert given data to Stylesheet object
@returns {Object} `axe.utils.queue` | [
"Deferred",
"function",
"for",
"CSSOM",
"queue",
"processing",
"on",
"all",
"root",
"nodes"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/preload-cssom.js#L123-L141 | train | Get the cssom for all root nodes | [
30522,
3853,
2131,
6169,
25426,
29278,
8095,
3217,
4140,
3630,
6155,
1006,
7117,
3630,
6155,
1010,
10463,
2850,
29336,
14122,
26274,
21030,
2102,
1010,
2051,
5833,
1007,
1063,
9530,
3367,
1053,
1027,
12946,
1012,
21183,
12146,
1012,
24240,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/interfaces/interfaces.js | getJavaParameterListSimple | function getJavaParameterListSimple(parameters, returnType) {
var result = []
result.push("<span class='type'>Channel</span> <span class='parameterName'>channel</span>")
parameters.forEach(function(parameter){
if (parameter.out) return
result.push("<span class='type'>" + getJavaType(parameter.type) + " </span><span class='parameterName'>" + parameter.name + "</span>")
})
result.push("<span class='type'>String</span> <span class='parameterName'>callbackId</span>")
return result.join(", ")
} | javascript | function getJavaParameterListSimple(parameters, returnType) {
var result = []
result.push("<span class='type'>Channel</span> <span class='parameterName'>channel</span>")
parameters.forEach(function(parameter){
if (parameter.out) return
result.push("<span class='type'>" + getJavaType(parameter.type) + " </span><span class='parameterName'>" + parameter.name + "</span>")
})
result.push("<span class='type'>String</span> <span class='parameterName'>callbackId</span>")
return result.join(", ")
} | [
"function",
"getJavaParameterListSimple",
"(",
"parameters",
",",
"returnType",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"result",
".",
"push",
"(",
"\"<span class='type'>Channel</span> <span class='parameterName'>channel</span>\"",
")",
"parameters",
".",
"forEach",
"("... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/interfaces/interfaces.js#L390-L402 | train | getJavaParameterListSimple - returns a list of parameters | [
30522,
3853,
2131,
3900,
3567,
28689,
22828,
27103,
5714,
10814,
1006,
11709,
1010,
2709,
13874,
1007,
1063,
13075,
2765,
1027,
1031,
1033,
2765,
1012,
5245,
1006,
1000,
1026,
8487,
2465,
1027,
1005,
2828,
1005,
1028,
3149,
1026,
1013,
8487... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.unified/src/sap/ui/unified/CalendarRow.js | _calculateStartDate | function _calculateStartDate(oDate) {
var sIntervalType = this.getIntervalType();
var oUTCStartDate = CalendarUtils._createUniversalUTCDate(oDate, undefined, true);
switch (sIntervalType) {
case CalendarIntervalType.Hour:
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
case CalendarIntervalType.Day:
case CalendarIntervalType.Week:
case CalendarIntervalType.OneMonth:
oUTCStartDate.setUTCHours(0);
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
case CalendarIntervalType.Month:
oUTCStartDate.setUTCDate(1);
oUTCStartDate.setUTCHours(0);
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
default:
throw new Error("Unknown IntervalType: " + sIntervalType + "; " + this);
}
return oUTCStartDate;
} | javascript | function _calculateStartDate(oDate) {
var sIntervalType = this.getIntervalType();
var oUTCStartDate = CalendarUtils._createUniversalUTCDate(oDate, undefined, true);
switch (sIntervalType) {
case CalendarIntervalType.Hour:
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
case CalendarIntervalType.Day:
case CalendarIntervalType.Week:
case CalendarIntervalType.OneMonth:
oUTCStartDate.setUTCHours(0);
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
case CalendarIntervalType.Month:
oUTCStartDate.setUTCDate(1);
oUTCStartDate.setUTCHours(0);
oUTCStartDate.setUTCMinutes(0);
oUTCStartDate.setUTCSeconds(0);
oUTCStartDate.setUTCMilliseconds(0);
break;
default:
throw new Error("Unknown IntervalType: " + sIntervalType + "; " + this);
}
return oUTCStartDate;
} | [
"function",
"_calculateStartDate",
"(",
"oDate",
")",
"{",
"var",
"sIntervalType",
"=",
"this",
".",
"getIntervalType",
"(",
")",
";",
"var",
"oUTCStartDate",
"=",
"CalendarUtils",
".",
"_createUniversalUTCDate",
"(",
"oDate",
",",
"undefined",
",",
"true",
")",... | /*
@param {object} oDate JavaScript date object
@returns {UniversalDate} Start date for date object | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.unified/src/sap/ui/unified/CalendarRow.js#L1039-L1074 | train | Calculates the start date of the specified date. | [
30522,
3853,
1035,
18422,
14117,
2102,
13701,
1006,
1051,
13701,
1007,
1063,
13075,
8254,
3334,
10175,
13874,
1027,
2023,
1012,
2131,
18447,
2121,
10175,
13874,
1006,
1007,
1025,
13075,
2041,
6169,
7559,
2102,
13701,
1027,
8094,
21823,
4877,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Component.js | addSapParams | function addSapParams(oUri) {
['sap-client', 'sap-server'].forEach(function(sName) {
if (!oUri.hasSearch(sName)) {
var sValue = sap.ui.getCore().getConfiguration().getSAPParam(sName);
if (sValue) {
oUri.addSearch(sName, sValue);
}
}
});
} | javascript | function addSapParams(oUri) {
['sap-client', 'sap-server'].forEach(function(sName) {
if (!oUri.hasSearch(sName)) {
var sValue = sap.ui.getCore().getConfiguration().getSAPParam(sName);
if (sValue) {
oUri.addSearch(sName, sValue);
}
}
});
} | [
"function",
"addSapParams",
"(",
"oUri",
")",
"{",
"[",
"'sap-client'",
",",
"'sap-server'",
"]",
".",
"forEach",
"(",
"function",
"(",
"sName",
")",
"{",
"if",
"(",
"!",
"oUri",
".",
"hasSearch",
"(",
"sName",
")",
")",
"{",
"var",
"sValue",
"=",
"s... | Utility function which adds SAP-specific parameters to a URI instance
@param {URI} oUri URI.js instance
@private | [
"Utility",
"function",
"which",
"adds",
"SAP",
"-",
"specific",
"parameters",
"to",
"a",
"URI",
"instance"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L56-L65 | train | Adds the parameters of the sap - client sap - server to the URI | [
30522,
3853,
9909,
29098,
5400,
5244,
1006,
2256,
2072,
1007,
1063,
1031,
1005,
20066,
1011,
7396,
1005,
1010,
1005,
20066,
1011,
8241,
1005,
1033,
1012,
18921,
6776,
1006,
3853,
1006,
1055,
18442,
1007,
1063,
2065,
1006,
999,
2256,
2072,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/MDNDocs/main.js | inlineProvider | function inlineProvider(hostEditor, pos) {
var jsonFile, propInfo,
propQueue = [], // priority queue of propNames to try
langId = hostEditor.getLanguageForSelection().getId(),
supportedLangs = {
"css": true,
"scss": true,
"less": true,
"html": true
},
isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy
// Only provide docs when cursor is in supported language
if (!isQuickDocAvailable) {
return null;
}
// Send analytics data for Quick Doc open
HealthLogger.sendAnalyticsData(
"cssQuickDoc",
"usage",
"quickDoc",
"open"
);
// Only provide docs if the selection is within a single line
var sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
if (langId === "html") { // HTML
jsonFile = "html.json";
propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
// we're on an HTML attribute (and not on its value)
propQueue.push(propInfo.attr.name.toLowerCase());
}
if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
propInfo = propInfo.tagName.toLowerCase();
propQueue.push("<" + propInfo + ">");
}
} else { // CSS-like language
jsonFile = "css.json";
propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
if (propInfo.name) {
propQueue.push(propInfo.name);
// remove possible vendor prefixes
propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
}
}
// Are we on a supported property? (no matter if info is available for the property)
if (propQueue.length) {
var result = new $.Deferred();
// Load JSON file if not done yet
getDocs(jsonFile)
.done(function (docs) {
// Construct inline widget (if we have docs for this property)
var displayName, propDetails,
propName = _.find(propQueue, function (propName) { // find the first property where info is available
return docs.hasOwnProperty(propName);
});
if (propName) {
propDetails = docs[propName];
displayName = propName.substr(propName.lastIndexOf("/") + 1);
}
if (propDetails) {
var inlineWidget = new InlineDocsViewer(displayName, propDetails);
inlineWidget.load(hostEditor);
result.resolve(inlineWidget);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
return result.promise();
} else {
return null;
}
} | javascript | function inlineProvider(hostEditor, pos) {
var jsonFile, propInfo,
propQueue = [], // priority queue of propNames to try
langId = hostEditor.getLanguageForSelection().getId(),
supportedLangs = {
"css": true,
"scss": true,
"less": true,
"html": true
},
isQuickDocAvailable = langId ? supportedLangs[langId] : -1; // fail if langId is falsy
// Only provide docs when cursor is in supported language
if (!isQuickDocAvailable) {
return null;
}
// Send analytics data for Quick Doc open
HealthLogger.sendAnalyticsData(
"cssQuickDoc",
"usage",
"quickDoc",
"open"
);
// Only provide docs if the selection is within a single line
var sel = hostEditor.getSelection();
if (sel.start.line !== sel.end.line) {
return null;
}
if (langId === "html") { // HTML
jsonFile = "html.json";
propInfo = HTMLUtils.getTagInfo(hostEditor, sel.start);
if (propInfo.position.tokenType === HTMLUtils.ATTR_NAME && propInfo.attr && propInfo.attr.name) {
// we're on an HTML attribute (and not on its value)
propQueue.push(propInfo.attr.name.toLowerCase());
}
if (propInfo.tagName) { // we're somehow on an HTML tag (no matter where exactly)
propInfo = propInfo.tagName.toLowerCase();
propQueue.push("<" + propInfo + ">");
}
} else { // CSS-like language
jsonFile = "css.json";
propInfo = CSSUtils.getInfoAtPos(hostEditor, sel.start);
if (propInfo.name) {
propQueue.push(propInfo.name);
// remove possible vendor prefixes
propQueue.push(propInfo.name.replace(/^-(?:webkit|moz|ms|o)-/, ""));
}
}
// Are we on a supported property? (no matter if info is available for the property)
if (propQueue.length) {
var result = new $.Deferred();
// Load JSON file if not done yet
getDocs(jsonFile)
.done(function (docs) {
// Construct inline widget (if we have docs for this property)
var displayName, propDetails,
propName = _.find(propQueue, function (propName) { // find the first property where info is available
return docs.hasOwnProperty(propName);
});
if (propName) {
propDetails = docs[propName];
displayName = propName.substr(propName.lastIndexOf("/") + 1);
}
if (propDetails) {
var inlineWidget = new InlineDocsViewer(displayName, propDetails);
inlineWidget.load(hostEditor);
result.resolve(inlineWidget);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
return result.promise();
} else {
return null;
}
} | [
"function",
"inlineProvider",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"jsonFile",
",",
"propInfo",
",",
"propQueue",
"=",
"[",
"]",
",",
"// priority queue of propNames to try",
"langId",
"=",
"hostEditor",
".",
"getLanguageForSelection",
"(",
")",
".",
... | Inline docs provider.
@param {!Editor} editor
@param {!{line:Number, ch:Number}} pos
@return {?$.Promise} resolved with an InlineWidget; null if we're not going to provide anything | [
"Inline",
"docs",
"provider",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/MDNDocs/main.js#L89-L176 | train | inlineProvider - Function to provide inline docs | [
30522,
3853,
23881,
21572,
17258,
2121,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1063,
13075,
1046,
3385,
8873,
2571,
1010,
17678,
2378,
14876,
1010,
17678,
4226,
5657,
1027,
1031,
1033,
1010,
1013,
1013,
9470,
24240,
1997,
17678,
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... |
adobe/brackets | src/project/SidebarView.js | _updateWorkingSetState | function _updateWorkingSetState() {
if (MainViewManager.getPaneCount() === 1 &&
MainViewManager.getWorkingSetSize(MainViewManager.ACTIVE_PANE) === 0) {
$workingSetViewsContainer.hide();
$gearMenu.hide();
} else {
$workingSetViewsContainer.show();
$gearMenu.show();
}
} | javascript | function _updateWorkingSetState() {
if (MainViewManager.getPaneCount() === 1 &&
MainViewManager.getWorkingSetSize(MainViewManager.ACTIVE_PANE) === 0) {
$workingSetViewsContainer.hide();
$gearMenu.hide();
} else {
$workingSetViewsContainer.show();
$gearMenu.show();
}
} | [
"function",
"_updateWorkingSetState",
"(",
")",
"{",
"if",
"(",
"MainViewManager",
".",
"getPaneCount",
"(",
")",
"===",
"1",
"&&",
"MainViewManager",
".",
"getWorkingSetSize",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
"===",
"0",
")",
"{",
"$workingSetVi... | Update state of working set
@private | [
"Update",
"state",
"of",
"working",
"set"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/SidebarView.js#L115-L124 | train | update working set state | [
30522,
3853,
1035,
10651,
21398,
13462,
9153,
2618,
1006,
1007,
1063,
2065,
1006,
2364,
8584,
24805,
4590,
1012,
2131,
9739,
8586,
21723,
1006,
1007,
1027,
1027,
1027,
1015,
1004,
1004,
2364,
8584,
24805,
4590,
1012,
2131,
21398,
13462,
533... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
elastic/elasticsearch-js | api/api/cat.tasks.js | buildCatTasks | function buildCatTasks (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all.
* @param {boolean} detailed - Return detailed task information (default: false)
* @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all.
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const acceptedQuerystring = [
'format',
'node_id',
'actions',
'detailed',
'parent_task',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
nodeId: 'node_id',
parentTask: 'parent_task',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function catTasks (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_cat' + '/' + 'tasks'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildCatTasks (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request
*
* @param {string} format - a short version of the Accept header, e.g. json, yaml
* @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
* @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all.
* @param {boolean} detailed - Return detailed task information (default: false)
* @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all.
* @param {list} h - Comma-separated list of column names to display
* @param {boolean} help - Return help information
* @param {list} s - Comma-separated list of column names or column aliases to sort by
* @param {boolean} v - Verbose mode. Display column headers
*/
const acceptedQuerystring = [
'format',
'node_id',
'actions',
'detailed',
'parent_task',
'h',
'help',
's',
'v',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
nodeId: 'node_id',
parentTask: 'parent_task',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function catTasks (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params.body != null) {
const err = new ConfigurationError('This API does not require a body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'GET'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_cat' + '/' + 'tasks'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildCatTasks",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [cat.tasks](http://www.elastic.co/guide/en/... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/cat.tasks.js#L25-L118 | train | Build a function that can be used to get task information from the cluster | [
30522,
3853,
3857,
11266,
10230,
5705,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
15171,
1011,
13075,
2015,
9530,
3367,
1063,
9338,
2063,
15500,
1010,
9563,
2121,
2916... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
cypress-io/cypress | cli/lib/errors.js | formErrorText | function formErrorText (info, msg) {
const hr = '----------'
return addPlatformInformation(info)
.then((obj) => {
const formatted = []
function add (msg) {
formatted.push(
stripIndents(msg)
)
}
add(`
${obj.description}
${obj.solution}
`)
if (msg) {
add(`
${hr}
${msg}
`)
}
add(`
${hr}
${obj.platform}
`)
if (obj.footer) {
add(`
${hr}
${obj.footer}
`)
}
return formatted.join('\n\n')
})
} | javascript | function formErrorText (info, msg) {
const hr = '----------'
return addPlatformInformation(info)
.then((obj) => {
const formatted = []
function add (msg) {
formatted.push(
stripIndents(msg)
)
}
add(`
${obj.description}
${obj.solution}
`)
if (msg) {
add(`
${hr}
${msg}
`)
}
add(`
${hr}
${obj.platform}
`)
if (obj.footer) {
add(`
${hr}
${obj.footer}
`)
}
return formatted.join('\n\n')
})
} | [
"function",
"formErrorText",
"(",
"info",
",",
"msg",
")",
"{",
"const",
"hr",
"=",
"'----------'",
"return",
"addPlatformInformation",
"(",
"info",
")",
".",
"then",
"(",
"(",
"obj",
")",
"=>",
"{",
"const",
"formatted",
"=",
"[",
"]",
"function",
"add"... | Forms nice error message with error and platform information,
and if possible a way to solve it. Resolves with a string. | [
"Forms",
"nice",
"error",
"message",
"with",
"error",
"and",
"platform",
"information",
"and",
"if",
"possible",
"a",
"way",
"to",
"solve",
"it",
".",
"Resolves",
"with",
"a",
"string",
"."
] | bf1a942944f0e99684ff7fe0e18314332e46f83e | https://github.com/cypress-io/cypress/blob/bf1a942944f0e99684ff7fe0e18314332e46f83e/cli/lib/errors.js#L195-L241 | train | Form error text | [
30522,
3853,
2280,
29165,
18209,
1006,
18558,
1010,
5796,
2290,
1007,
1063,
9530,
3367,
17850,
1027,
1005,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1005,
2709,
5587,
24759,
4017,
14192,
2378,
14192,
3370,
1006,
18558,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/TimeOfDay.js | setConstraints | function setConstraints(oType, oConstraints) {
var vNullable,
vPrecision;
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
vPrecision = oConstraints.precision;
// "true" and "false" not allowed here, because in V4 they are never sent as string
if (vNullable === false) {
oType.oConstraints = {nullable : false};
} else if (vNullable !== undefined && vNullable !== true) {
Log.warning("Illegal nullable: " + vNullable, null, oType.getName());
}
if (vPrecision === Math.floor(vPrecision) && vPrecision > 0 && vPrecision <= 12) {
oType.oConstraints = oType.oConstraints || {};
oType.oConstraints.precision = vPrecision;
} else if (vPrecision !== undefined && vPrecision !== 0) {
Log.warning("Illegal precision: " + vPrecision, null, oType.getName());
}
}
} | javascript | function setConstraints(oType, oConstraints) {
var vNullable,
vPrecision;
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
vPrecision = oConstraints.precision;
// "true" and "false" not allowed here, because in V4 they are never sent as string
if (vNullable === false) {
oType.oConstraints = {nullable : false};
} else if (vNullable !== undefined && vNullable !== true) {
Log.warning("Illegal nullable: " + vNullable, null, oType.getName());
}
if (vPrecision === Math.floor(vPrecision) && vPrecision > 0 && vPrecision <= 12) {
oType.oConstraints = oType.oConstraints || {};
oType.oConstraints.precision = vPrecision;
} else if (vPrecision !== undefined && vPrecision !== 0) {
Log.warning("Illegal precision: " + vPrecision, null, oType.getName());
}
}
} | [
"function",
"setConstraints",
"(",
"oType",
",",
"oConstraints",
")",
"{",
"var",
"vNullable",
",",
"vPrecision",
";",
"oType",
".",
"oConstraints",
"=",
"undefined",
";",
"if",
"(",
"oConstraints",
")",
"{",
"vNullable",
"=",
"oConstraints",
".",
"nullable",
... | /*
Sets the constraints. Logs a warning and uses the constraint's default value, if an invalid
value is given.
@param {sap.ui.model.odata.type.TimeOfDay} oType
The type
@param {object} [oConstraints]
The constraints
@param {boolean} [oConstraints.nullable=true]
If <code>true</code>, the value <code>null</code> is valid for this type
@param {number} [oConstraints.precision=0]
The number of decimal places allowed in the seconds portion of a valid value; only
integer values between 0 and 12 are valid. | [
"/",
"*",
"Sets",
"the",
"constraints",
".",
"Logs",
"a",
"warning",
"and",
"uses",
"the",
"constraint",
"s",
"default",
"value",
"if",
"an",
"invalid",
"value",
"is",
"given",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/TimeOfDay.js#L86-L107 | train | Sets constraints for the given type | [
30522,
3853,
2275,
8663,
20528,
18447,
2015,
1006,
27178,
18863,
1010,
1051,
8663,
20528,
18447,
2015,
1007,
1063,
13075,
1058,
11231,
4571,
3468,
1010,
21210,
2890,
28472,
1025,
27178,
18863,
1012,
1051,
8663,
20528,
18447,
2015,
1027,
6151,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | setScope | function setScope (vnode) {
var i;
var ancestor = vnode;
while (ancestor) {
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
nodeOps.setAttribute(vnode.elm, i, '');
}
ancestor = ancestor.parent;
}
// for slot content they should also get the scopeId from the host instance.
if (isDef(i = activeInstance) &&
i !== vnode.context &&
isDef(i = i.$options._scopeId)) {
nodeOps.setAttribute(vnode.elm, i, '');
}
} | javascript | function setScope (vnode) {
var i;
var ancestor = vnode;
while (ancestor) {
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
nodeOps.setAttribute(vnode.elm, i, '');
}
ancestor = ancestor.parent;
}
// for slot content they should also get the scopeId from the host instance.
if (isDef(i = activeInstance) &&
i !== vnode.context &&
isDef(i = i.$options._scopeId)) {
nodeOps.setAttribute(vnode.elm, i, '');
}
} | [
"function",
"setScope",
"(",
"vnode",
")",
"{",
"var",
"i",
";",
"var",
"ancestor",
"=",
"vnode",
";",
"while",
"(",
"ancestor",
")",
"{",
"if",
"(",
"isDef",
"(",
"i",
"=",
"ancestor",
".",
"context",
")",
"&&",
"isDef",
"(",
"i",
"=",
"i",
".",... | set scope id attribute for scoped CSS. this is implemented as a special case to avoid the overhead of going through the normal attribute patching process. | [
"set",
"scope",
"id",
"attribute",
"for",
"scoped",
"CSS",
".",
"this",
"is",
"implemented",
"as",
"a",
"special",
"case",
"to",
"avoid",
"the",
"overhead",
"of",
"going",
"through",
"the",
"normal",
"attribute",
"patching",
"process",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L4519-L4534 | train | set the scope of the vnode | [
30522,
3853,
4520,
16186,
1006,
1058,
3630,
3207,
1007,
1063,
13075,
1045,
1025,
13075,
13032,
1027,
1058,
3630,
3207,
1025,
2096,
1006,
13032,
1007,
1063,
2065,
1006,
2003,
3207,
2546,
1006,
1045,
1027,
13032,
1012,
6123,
1007,
1004,
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... |
tgriesser/knex | src/query/builder.js | Builder | function Builder(client) {
this.client = client;
this.and = this;
this._single = {};
this._statements = [];
this._method = 'select';
if (client.config) {
saveAsyncStack(this, 5);
this._debug = client.config.debug;
}
// Internal flags used in the builder.
this._joinFlag = 'inner';
this._boolFlag = 'and';
this._notFlag = false;
this._asColumnFlag = false;
} | javascript | function Builder(client) {
this.client = client;
this.and = this;
this._single = {};
this._statements = [];
this._method = 'select';
if (client.config) {
saveAsyncStack(this, 5);
this._debug = client.config.debug;
}
// Internal flags used in the builder.
this._joinFlag = 'inner';
this._boolFlag = 'and';
this._notFlag = false;
this._asColumnFlag = false;
} | [
"function",
"Builder",
"(",
"client",
")",
"{",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"and",
"=",
"this",
";",
"this",
".",
"_single",
"=",
"{",
"}",
";",
"this",
".",
"_statements",
"=",
"[",
"]",
";",
"this",
".",
"_method",
"... | Typically called from `knex.builder`, start a new query building chain. | [
"Typically",
"called",
"from",
"knex",
".",
"builder",
"start",
"a",
"new",
"query",
"building",
"chain",
"."
] | 6a4fecfe7822442ee5c43d924958eadfe6e17a93 | https://github.com/tgriesser/knex/blob/6a4fecfe7822442ee5c43d924958eadfe6e17a93/src/query/builder.js#L30-L45 | train | A builder for a query. | [
30522,
3853,
12508,
1006,
7396,
1007,
1063,
2023,
1012,
7396,
1027,
7396,
1025,
2023,
1012,
1998,
1027,
2023,
1025,
2023,
1012,
1035,
2309,
1027,
1063,
1065,
1025,
2023,
1012,
1035,
8635,
1027,
1031,
1033,
1025,
2023,
1012,
1035,
4118,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js | function (oEvent) {
var oSelectedItem = oEvent.getParameters().selectedItem,
oListItem = oSelectedItem ? oSelectedItem : oEvent.getSource().getParent();
this._oDownloadButton.setBusy(true);
sap.ui.require([
"sap/ui/core/util/File",
"sap/ui/thirdparty/jszip"
], function (File, JSZip) {
var oZipFile = new JSZip();
// load the config file from the custom data attached to the list item
jQuery.getJSON(oListItem.data("config"), function (oConfig) {
var aFiles = oConfig.files,
aPromises = [],
aFails = [];
// add extra download files
aFiles.forEach(function(sFilePath) {
var oPromise = sourceFileDownloader(oConfig.cwd + sFilePath);
oPromise.then(function (oContent) {
if (oContent.errorMessage) {
// promise gets resolved in error case since Promise.all will not wait for all fails
aFails.push(oContent.errorMessage);
} else {
// exclude relative paths outside of the app root (e.g. common helpers, images, ...)
if (!sFilePath.startsWith("../")) {
oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
}
}
});
aPromises.push(oPromise);
});
// add generic license and notice file
var oLicensePromise = sourceFileDownloader(sap.ui.require.toUrl("sap/ui/documentation/sdk/tmpl/LICENSE.txt"));
oLicensePromise.then(function (oContent) {
oZipFile.file("LICENSE.txt", oContent, { base64: false, binary: true });
});
aPromises.push(oLicensePromise);
var oNoticePromise = sourceFileDownloader(sap.ui.require.toUrl("sap/ui/documentation/sdk/tmpl/NOTICE.txt"));
oNoticePromise.then(function (oContent) {
oZipFile.file("NOTICE.txt", oContent, { base64: false, binary: true });
});
aPromises.push(oNoticePromise);
Promise.all(aPromises).then(function () {
// collect errors and show them
if (aFails.length) {
var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
return sErrorMessage + sError + "\n";
}, "Could not locate the following download files:\n");
this._handleError(sCompleteErrorMessage);
}
// show success message
this._oDownloadButton.setBusy(false);
MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
// still make the available files ready for download
var oContent = oZipFile.generate({type:"blob"});
this._createArchive(File, oContent, oListItem.getLabel());
}.bind(this));
}.bind(this));
}.bind(this));
} | javascript | function (oEvent) {
var oSelectedItem = oEvent.getParameters().selectedItem,
oListItem = oSelectedItem ? oSelectedItem : oEvent.getSource().getParent();
this._oDownloadButton.setBusy(true);
sap.ui.require([
"sap/ui/core/util/File",
"sap/ui/thirdparty/jszip"
], function (File, JSZip) {
var oZipFile = new JSZip();
// load the config file from the custom data attached to the list item
jQuery.getJSON(oListItem.data("config"), function (oConfig) {
var aFiles = oConfig.files,
aPromises = [],
aFails = [];
// add extra download files
aFiles.forEach(function(sFilePath) {
var oPromise = sourceFileDownloader(oConfig.cwd + sFilePath);
oPromise.then(function (oContent) {
if (oContent.errorMessage) {
// promise gets resolved in error case since Promise.all will not wait for all fails
aFails.push(oContent.errorMessage);
} else {
// exclude relative paths outside of the app root (e.g. common helpers, images, ...)
if (!sFilePath.startsWith("../")) {
oZipFile.file(sFilePath, oContent, { base64: false, binary: true });
}
}
});
aPromises.push(oPromise);
});
// add generic license and notice file
var oLicensePromise = sourceFileDownloader(sap.ui.require.toUrl("sap/ui/documentation/sdk/tmpl/LICENSE.txt"));
oLicensePromise.then(function (oContent) {
oZipFile.file("LICENSE.txt", oContent, { base64: false, binary: true });
});
aPromises.push(oLicensePromise);
var oNoticePromise = sourceFileDownloader(sap.ui.require.toUrl("sap/ui/documentation/sdk/tmpl/NOTICE.txt"));
oNoticePromise.then(function (oContent) {
oZipFile.file("NOTICE.txt", oContent, { base64: false, binary: true });
});
aPromises.push(oNoticePromise);
Promise.all(aPromises).then(function () {
// collect errors and show them
if (aFails.length) {
var sCompleteErrorMessage = aFails.reduce(function (sErrorMessage, sError) {
return sErrorMessage + sError + "\n";
}, "Could not locate the following download files:\n");
this._handleError(sCompleteErrorMessage);
}
// show success message
this._oDownloadButton.setBusy(false);
MessageToast.show("Downloading for app \"" + oListItem.getLabel() + "\" has been started");
// still make the available files ready for download
var oContent = oZipFile.generate({type:"blob"});
this._createArchive(File, oContent, oListItem.getLabel());
}.bind(this));
}.bind(this));
}.bind(this));
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oSelectedItem",
"=",
"oEvent",
".",
"getParameters",
"(",
")",
".",
"selectedItem",
",",
"oListItem",
"=",
"oSelectedItem",
"?",
"oSelectedItem",
":",
"oEvent",
".",
"getSource",
"(",
")",
".",
"getParent",
"(",
... | Downloads a demo app
@param {sap.ui.base.Event} oEvent the Button press event
@public | [
"Downloads",
"a",
"demo",
"app"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js#L193-L259 | train | Downloads the file from the list item | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
9808,
12260,
10985,
4221,
2213,
1027,
1051,
18697,
3372,
1012,
2131,
28689,
22828,
2015,
1006,
1007,
1012,
3479,
4221,
2213,
1010,
19330,
2923,
4221,
2213,
1027,
9808,
12260,
10985,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
shipshapecode/shepherd | src/js/utils/bind.js | _setupAdvanceOnHandler | function _setupAdvanceOnHandler(selector) {
return (event) => {
if (this.isOpen()) {
const targetIsEl = this.el && event.target === this.el;
const targetIsSelector = !isUndefined(selector) && event.target.matches(selector);
if (targetIsSelector || targetIsEl) {
this.tour.next();
}
}
};
} | javascript | function _setupAdvanceOnHandler(selector) {
return (event) => {
if (this.isOpen()) {
const targetIsEl = this.el && event.target === this.el;
const targetIsSelector = !isUndefined(selector) && event.target.matches(selector);
if (targetIsSelector || targetIsEl) {
this.tour.next();
}
}
};
} | [
"function",
"_setupAdvanceOnHandler",
"(",
"selector",
")",
"{",
"return",
"(",
"event",
")",
"=>",
"{",
"if",
"(",
"this",
".",
"isOpen",
"(",
")",
")",
"{",
"const",
"targetIsEl",
"=",
"this",
".",
"el",
"&&",
"event",
".",
"target",
"===",
"this",
... | Sets up the handler to determine if we should advance the tour
@private | [
"Sets",
"up",
"the",
"handler",
"to",
"determine",
"if",
"we",
"should",
"advance",
"the",
"tour"
] | 0cb1c63fb07b58796358f6d33da5f6405e2b05f4 | https://github.com/shipshapecode/shepherd/blob/0cb1c63fb07b58796358f6d33da5f6405e2b05f4/src/js/utils/bind.js#L8-L19 | train | Setup the next event handler | [
30522,
3853,
1035,
16437,
4215,
21789,
2239,
11774,
3917,
1006,
27000,
1007,
1063,
2709,
1006,
2724,
1007,
1027,
1028,
1063,
2065,
1006,
2023,
1012,
11163,
11837,
1006,
1007,
1007,
1063,
9530,
3367,
4539,
5562,
2140,
1027,
2023,
1012,
3449,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/dot-location.js | checkDotLocation | function checkDotLocation(obj, prop, node) {
const dot = sourceCode.getTokenBefore(prop);
const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
if (dot.type === "Punctuator" && dot.value === ".") {
if (onObject) {
if (!astUtils.isTokenOnSameLine(obj, dot)) {
const neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : "";
context.report({
node,
loc: dot.loc.start,
messageId: "expectedDotAfterObject",
fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${neededTextAfterObj}.${textBeforeDot}${textAfterDot}`)
});
}
} else if (!astUtils.isTokenOnSameLine(dot, prop)) {
context.report({
node,
loc: dot.loc.start,
messageId: "expectedDotBeforeProperty",
fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`)
});
}
}
} | javascript | function checkDotLocation(obj, prop, node) {
const dot = sourceCode.getTokenBefore(prop);
const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);
if (dot.type === "Punctuator" && dot.value === ".") {
if (onObject) {
if (!astUtils.isTokenOnSameLine(obj, dot)) {
const neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : "";
context.report({
node,
loc: dot.loc.start,
messageId: "expectedDotAfterObject",
fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${neededTextAfterObj}.${textBeforeDot}${textAfterDot}`)
});
}
} else if (!astUtils.isTokenOnSameLine(dot, prop)) {
context.report({
node,
loc: dot.loc.start,
messageId: "expectedDotBeforeProperty",
fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`)
});
}
}
} | [
"function",
"checkDotLocation",
"(",
"obj",
",",
"prop",
",",
"node",
")",
"{",
"const",
"dot",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"prop",
")",
";",
"const",
"textBeforeDot",
"=",
"sourceCode",
".",
"getText",
"(",
")",
".",
"slice",
"(",
"ob... | Reports if the dot between object and property is on the correct loccation.
@param {ASTNode} obj The object owning the property.
@param {ASTNode} prop The property of the object.
@param {ASTNode} node The corresponding node of the token.
@returns {void} | [
"Reports",
"if",
"the",
"dot",
"between",
"object",
"and",
"property",
"is",
"on",
"the",
"correct",
"loccation",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/dot-location.js#L55-L81 | train | Check dot location | [
30522,
3853,
4638,
27364,
4135,
10719,
1006,
27885,
3501,
1010,
17678,
1010,
13045,
1007,
1063,
9530,
3367,
11089,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
17678,
1007,
1025,
9530,
3367,
3793,
4783,
29278,
26010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/FileTreeView.js | function () {
var result,
extensions = this.props.extensions;
if (extensions && extensions.get("icons")) {
var data = this.getDataForExtension();
result = extensions.get("icons").map(function (callback) {
try {
var result = callback(data);
if (result && !Preact.isValidElement(result)) {
result = Preact.DOM.span({
dangerouslySetInnerHTML: {
__html: $(result)[0].outerHTML
}
});
}
return result; // by this point, returns either undefined or a Preact object
} catch (e) {
console.error("Exception thrown in FileTreeView icon provider: " + e, e.stack);
}
}).filter(isDefined).toArray();
}
if (!result || result.length === 0) {
result = [DOM.ins({
className: "jstree-icon"
}, " ")];
}
return result;
} | javascript | function () {
var result,
extensions = this.props.extensions;
if (extensions && extensions.get("icons")) {
var data = this.getDataForExtension();
result = extensions.get("icons").map(function (callback) {
try {
var result = callback(data);
if (result && !Preact.isValidElement(result)) {
result = Preact.DOM.span({
dangerouslySetInnerHTML: {
__html: $(result)[0].outerHTML
}
});
}
return result; // by this point, returns either undefined or a Preact object
} catch (e) {
console.error("Exception thrown in FileTreeView icon provider: " + e, e.stack);
}
}).filter(isDefined).toArray();
}
if (!result || result.length === 0) {
result = [DOM.ins({
className: "jstree-icon"
}, " ")];
}
return result;
} | [
"function",
"(",
")",
"{",
"var",
"result",
",",
"extensions",
"=",
"this",
".",
"props",
".",
"extensions",
";",
"if",
"(",
"extensions",
"&&",
"extensions",
".",
"get",
"(",
"\"icons\"",
")",
")",
"{",
"var",
"data",
"=",
"this",
".",
"getDataForExte... | Calls the icon providers to get the collection of icons (most likely just one) for
the current file or directory.
@return {Array.<PreactComponent>} icon components to render | [
"Calls",
"the",
"icon",
"providers",
"to",
"get",
"the",
"collection",
"of",
"icons",
"(",
"most",
"likely",
"just",
"one",
")",
"for",
"the",
"current",
"file",
"or",
"directory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L407-L436 | train | Get the list of icons | [
30522,
3853,
1006,
1007,
1063,
13075,
2765,
1010,
14305,
1027,
2023,
1012,
24387,
1012,
14305,
1025,
2065,
1006,
14305,
1004,
1004,
14305,
1012,
2131,
1006,
1000,
18407,
1000,
1007,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2131,
2850,
269... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
TryGhost/Ghost | core/server/services/url/utils.js | getSubdir | function getSubdir() {
// Parse local path location
var localPath = url.parse(config.get('url')).path,
subdir;
// Remove trailing slash
if (localPath !== '/') {
localPath = localPath.replace(/\/$/, '');
}
subdir = localPath === '/' ? '' : localPath;
return subdir;
} | javascript | function getSubdir() {
// Parse local path location
var localPath = url.parse(config.get('url')).path,
subdir;
// Remove trailing slash
if (localPath !== '/') {
localPath = localPath.replace(/\/$/, '');
}
subdir = localPath === '/' ? '' : localPath;
return subdir;
} | [
"function",
"getSubdir",
"(",
")",
"{",
"// Parse local path location",
"var",
"localPath",
"=",
"url",
".",
"parse",
"(",
"config",
".",
"get",
"(",
"'url'",
")",
")",
".",
"path",
",",
"subdir",
";",
"// Remove trailing slash",
"if",
"(",
"localPath",
"!==... | Returns a subdirectory URL, if defined so in the config.
@return {string} URL a subdirectory if configured. | [
"Returns",
"a",
"subdirectory",
"URL",
"if",
"defined",
"so",
"in",
"the",
"config",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/url/utils.js#L71-L83 | train | Get the subdir of the current resource | [
30522,
3853,
4152,
12083,
4305,
2099,
1006,
1007,
1063,
1013,
1013,
11968,
3366,
2334,
4130,
3295,
13075,
2334,
15069,
1027,
24471,
2140,
1012,
11968,
3366,
1006,
9530,
8873,
2290,
1012,
2131,
1006,
1005,
24471,
2140,
1005,
1007,
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... |
vuejs/vue-devtools | shells/chrome/src/devtools-background.js | panelAction | function panelAction (cb, message = null) {
if (created && panelLoaded && panelShown) {
cb()
} else {
pendingAction = cb
message && toast(message)
}
} | javascript | function panelAction (cb, message = null) {
if (created && panelLoaded && panelShown) {
cb()
} else {
pendingAction = cb
message && toast(message)
}
} | [
"function",
"panelAction",
"(",
"cb",
",",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"created",
"&&",
"panelLoaded",
"&&",
"panelShown",
")",
"{",
"cb",
"(",
")",
"}",
"else",
"{",
"pendingAction",
"=",
"cb",
"message",
"&&",
"toast",
"(",
"message"... | Action that may execute immediatly or later when the Vue panel is ready | [
"Action",
"that",
"may",
"execute",
"immediatly",
"or",
"later",
"when",
"the",
"Vue",
"panel",
"is",
"ready"
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/shells/chrome/src/devtools-background.js#L79-L86 | train | panelAction - callback | [
30522,
3853,
5997,
18908,
3258,
1006,
17324,
1010,
4471,
1027,
19701,
1007,
1063,
2065,
1006,
2580,
1004,
1004,
5997,
17468,
1004,
1004,
9320,
14406,
2078,
1007,
1063,
17324,
1006,
1007,
1065,
2842,
1063,
14223,
18908,
3258,
1027,
17324,
44... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(nodeList, newTagName) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
this._setNodeTag(node, newTagName);
}
} | javascript | function(nodeList, newTagName) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
this._setNodeTag(node, newTagName);
}
} | [
"function",
"(",
"nodeList",
",",
"newTagName",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"nodeList",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"node",
"=",
"nodeList",
"[",
"i",
"]",
";",
"this",
".",
"_setNod... | Iterates over a NodeList, and calls _setNodeTag for each node.
@param NodeList nodeList The nodes to operate on
@param String newTagName the new tag name to use
@return void | [
"Iterates",
"over",
"a",
"NodeList",
"and",
"calls",
"_setNodeTag",
"for",
"each",
"node",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L194-L199 | train | Sets the tag name of the last node in the list | [
30522,
3853,
1006,
13045,
9863,
1010,
25597,
8490,
18442,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
13045,
9863,
1012,
3091,
1011,
1015,
1025,
1045,
1028,
1027,
1014,
1025,
1045,
1011,
1011,
1007,
1063,
13075,
13045,
1027,
13045,
9863,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Microsoft/vscode | build/lib/bundle.js | bundle | function bundle(entryPoints, config, callback) {
const entryPointsMap = {};
entryPoints.forEach((module) => {
entryPointsMap[module.name] = module;
});
const allMentionedModulesMap = {};
entryPoints.forEach((module) => {
allMentionedModulesMap[module.name] = true;
(module.include || []).forEach(function (includedModule) {
allMentionedModulesMap[includedModule] = true;
});
(module.exclude || []).forEach(function (excludedModule) {
allMentionedModulesMap[excludedModule] = true;
});
});
const code = require('fs').readFileSync(path.join(__dirname, '../../src/vs/loader.js'));
const r = vm.runInThisContext('(function(require, module, exports) { ' + code + '\n});');
const loaderModule = { exports: {} };
r.call({}, require, loaderModule, loaderModule.exports);
const loader = loaderModule.exports;
config.isBuild = true;
config.paths = config.paths || {};
if (!config.paths['vs/nls']) {
config.paths['vs/nls'] = 'out-build/vs/nls.build';
}
if (!config.paths['vs/css']) {
config.paths['vs/css'] = 'out-build/vs/css.build';
}
loader.config(config);
loader(['require'], (localRequire) => {
const resolvePath = (path) => {
const r = localRequire.toUrl(path);
if (!/\.js/.test(r)) {
return r + '.js';
}
return r;
};
for (const moduleId in entryPointsMap) {
const entryPoint = entryPointsMap[moduleId];
if (entryPoint.append) {
entryPoint.append = entryPoint.append.map(resolvePath);
}
if (entryPoint.prepend) {
entryPoint.prepend = entryPoint.prepend.map(resolvePath);
}
}
});
loader(Object.keys(allMentionedModulesMap), () => {
const modules = loader.getBuildInfo();
const partialResult = emitEntryPoints(modules, entryPointsMap);
const cssInlinedResources = loader('vs/css').getInlinedResources();
callback(null, {
files: partialResult.files,
cssInlinedResources: cssInlinedResources,
bundleData: partialResult.bundleData
});
}, (err) => callback(err, null));
} | javascript | function bundle(entryPoints, config, callback) {
const entryPointsMap = {};
entryPoints.forEach((module) => {
entryPointsMap[module.name] = module;
});
const allMentionedModulesMap = {};
entryPoints.forEach((module) => {
allMentionedModulesMap[module.name] = true;
(module.include || []).forEach(function (includedModule) {
allMentionedModulesMap[includedModule] = true;
});
(module.exclude || []).forEach(function (excludedModule) {
allMentionedModulesMap[excludedModule] = true;
});
});
const code = require('fs').readFileSync(path.join(__dirname, '../../src/vs/loader.js'));
const r = vm.runInThisContext('(function(require, module, exports) { ' + code + '\n});');
const loaderModule = { exports: {} };
r.call({}, require, loaderModule, loaderModule.exports);
const loader = loaderModule.exports;
config.isBuild = true;
config.paths = config.paths || {};
if (!config.paths['vs/nls']) {
config.paths['vs/nls'] = 'out-build/vs/nls.build';
}
if (!config.paths['vs/css']) {
config.paths['vs/css'] = 'out-build/vs/css.build';
}
loader.config(config);
loader(['require'], (localRequire) => {
const resolvePath = (path) => {
const r = localRequire.toUrl(path);
if (!/\.js/.test(r)) {
return r + '.js';
}
return r;
};
for (const moduleId in entryPointsMap) {
const entryPoint = entryPointsMap[moduleId];
if (entryPoint.append) {
entryPoint.append = entryPoint.append.map(resolvePath);
}
if (entryPoint.prepend) {
entryPoint.prepend = entryPoint.prepend.map(resolvePath);
}
}
});
loader(Object.keys(allMentionedModulesMap), () => {
const modules = loader.getBuildInfo();
const partialResult = emitEntryPoints(modules, entryPointsMap);
const cssInlinedResources = loader('vs/css').getInlinedResources();
callback(null, {
files: partialResult.files,
cssInlinedResources: cssInlinedResources,
bundleData: partialResult.bundleData
});
}, (err) => callback(err, null));
} | [
"function",
"bundle",
"(",
"entryPoints",
",",
"config",
",",
"callback",
")",
"{",
"const",
"entryPointsMap",
"=",
"{",
"}",
";",
"entryPoints",
".",
"forEach",
"(",
"(",
"module",
")",
"=>",
"{",
"entryPointsMap",
"[",
"module",
".",
"name",
"]",
"=",
... | Bundle `entryPoints` given config `config`. | [
"Bundle",
"entryPoints",
"given",
"config",
"config",
"."
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/bundle.js#L13-L70 | train | Bundle the modules | [
30522,
3853,
14012,
1006,
4443,
26521,
1010,
9530,
8873,
2290,
1010,
2655,
5963,
1007,
1063,
9530,
3367,
4443,
26521,
2863,
2361,
1027,
1063,
1065,
1025,
4443,
26521,
1012,
18921,
6776,
1006,
1006,
11336,
1007,
1027,
1028,
1063,
4443,
26521... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
google/material-design-icons | gulpfile.babel.js | getSvgSpriteConfig | function getSvgSpriteConfig(category) {
return {
shape: {
dimension: {
maxWidth: 24,
maxHeight: 24
},
},
mode: {
css : {
bust: false,
dest: './',
sprite: `./svg-sprite-${ category }.svg`,
example: {
dest: `./svg-sprite-${ category }.html`
},
render: {
css: {
dest: `./svg-sprite-${ category }.css`
}
}
},
symbol : {
bust: false,
dest: './',
sprite: `./svg-sprite-${ category }-symbol.svg`,
example: {
dest: `./svg-sprite-${ category }-symbol.html`
}
}
}
};
} | javascript | function getSvgSpriteConfig(category) {
return {
shape: {
dimension: {
maxWidth: 24,
maxHeight: 24
},
},
mode: {
css : {
bust: false,
dest: './',
sprite: `./svg-sprite-${ category }.svg`,
example: {
dest: `./svg-sprite-${ category }.html`
},
render: {
css: {
dest: `./svg-sprite-${ category }.css`
}
}
},
symbol : {
bust: false,
dest: './',
sprite: `./svg-sprite-${ category }-symbol.svg`,
example: {
dest: `./svg-sprite-${ category }-symbol.html`
}
}
}
};
} | [
"function",
"getSvgSpriteConfig",
"(",
"category",
")",
"{",
"return",
"{",
"shape",
":",
"{",
"dimension",
":",
"{",
"maxWidth",
":",
"24",
",",
"maxHeight",
":",
"24",
"}",
",",
"}",
",",
"mode",
":",
"{",
"css",
":",
"{",
"bust",
":",
"false",
"... | Returns the SVG sprite configuration for the specified category. | [
"Returns",
"the",
"SVG",
"sprite",
"configuration",
"for",
"the",
"specified",
"category",
"."
] | 224895a86501195e7a7ff3dde18e39f00b8e3d5a | https://github.com/google/material-design-icons/blob/224895a86501195e7a7ff3dde18e39f00b8e3d5a/gulpfile.babel.js#L122-L154 | train | Get the svg sprite config for a given category | [
30522,
3853,
4152,
2615,
5620,
18098,
4221,
8663,
8873,
2290,
1006,
4696,
1007,
1063,
2709,
1063,
4338,
1024,
1063,
9812,
1024,
1063,
4098,
9148,
11927,
2232,
1024,
2484,
1010,
4098,
26036,
13900,
1024,
2484,
1065,
1010,
1065,
1010,
5549,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-node | packages/grpc-native-core/src/server.js | handleClientStreaming | function handleClientStreaming(call, handler, metadata) {
var stream = new ServerReadableStream(call, metadata, handler.deserialize);
stream.on('error', function(error) {
handleError(call, error);
});
stream.waitForCancel();
handler.func(stream, function(err, value, trailer, flags) {
stream.terminate();
if (err) {
if (trailer) {
err.metadata = trailer;
}
handleError(call, err);
} else {
sendUnaryResponse(call, value, handler.serialize, trailer, flags);
}
});
} | javascript | function handleClientStreaming(call, handler, metadata) {
var stream = new ServerReadableStream(call, metadata, handler.deserialize);
stream.on('error', function(error) {
handleError(call, error);
});
stream.waitForCancel();
handler.func(stream, function(err, value, trailer, flags) {
stream.terminate();
if (err) {
if (trailer) {
err.metadata = trailer;
}
handleError(call, err);
} else {
sendUnaryResponse(call, value, handler.serialize, trailer, flags);
}
});
} | [
"function",
"handleClientStreaming",
"(",
"call",
",",
"handler",
",",
"metadata",
")",
"{",
"var",
"stream",
"=",
"new",
"ServerReadableStream",
"(",
"call",
",",
"metadata",
",",
"handler",
".",
"deserialize",
")",
";",
"stream",
".",
"on",
"(",
"'error'",... | User provided method to handle client streaming methods on the server.
@callback grpc.Server~handleClientStreamingCall
@param {grpc~ServerReadableStream} call The call object
@param {grpc.Server~sendUnaryData} callback The callback to call to respond
to the request
Fully handle a client streaming call
@access private
@param {grpc.internal~Call} call The call to handle
@param {Object} handler Request handler object for the method that was called
@param {grpc~Server.handleClientStreamingCall} handler.func The handler
function
@param {grpc~deserialize} handler.deserialize The deserialization function
for request data
@param {grpc~serialize} handler.serialize The serialization function for
response data
@param {grpc.Metadata} metadata Metadata from the client | [
"User",
"provided",
"method",
"to",
"handle",
"client",
"streaming",
"methods",
"on",
"the",
"server",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L664-L681 | train | Handle client streaming | [
30522,
3853,
5047,
20464,
11638,
21422,
2075,
1006,
2655,
1010,
28213,
1010,
27425,
1007,
1063,
13075,
5460,
1027,
2047,
8241,
16416,
20782,
21422,
1006,
2655,
1010,
27425,
1010,
28213,
1012,
4078,
11610,
3669,
4371,
1007,
1025,
5460,
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... |
keplergl/kepler.gl | src/schemas/vis-state-schema.js | geojsonSizeFieldV0ToV1 | function geojsonSizeFieldV0ToV1(config) {
const defaultRaiuds = 10;
const defaultRadiusRange = [0, 50];
// if extruded, sizeField is most likely used for height
if (config.visConfig.extruded) {
return 'heightField';
}
// if show stroke enabled, sizeField is most likely used for stroke
if (config.visConfig.stroked) {
return 'sizeField';
}
// if radius changed, or radius Range Changed, sizeField is most likely used for radius
// this is the most unreliable guess, that's why we put it in the end
if (
config.visConfig.radius !== defaultRaiuds ||
config.visConfig.radiusRange.some((d, i) => d !== defaultRadiusRange[i])
) {
return 'radiusField';
}
return 'sizeField';
} | javascript | function geojsonSizeFieldV0ToV1(config) {
const defaultRaiuds = 10;
const defaultRadiusRange = [0, 50];
// if extruded, sizeField is most likely used for height
if (config.visConfig.extruded) {
return 'heightField';
}
// if show stroke enabled, sizeField is most likely used for stroke
if (config.visConfig.stroked) {
return 'sizeField';
}
// if radius changed, or radius Range Changed, sizeField is most likely used for radius
// this is the most unreliable guess, that's why we put it in the end
if (
config.visConfig.radius !== defaultRaiuds ||
config.visConfig.radiusRange.some((d, i) => d !== defaultRadiusRange[i])
) {
return 'radiusField';
}
return 'sizeField';
} | [
"function",
"geojsonSizeFieldV0ToV1",
"(",
"config",
")",
"{",
"const",
"defaultRaiuds",
"=",
"10",
";",
"const",
"defaultRadiusRange",
"=",
"[",
"0",
",",
"50",
"]",
";",
"// if extruded, sizeField is most likely used for height",
"if",
"(",
"config",
".",
"visConf... | in v1 geojson stroke base on -> sizeField height based on -> heightField radius based on -> radiusField here we make our wiredst guess on which channel sizeField belongs to | [
"in",
"v1",
"geojson",
"stroke",
"base",
"on",
"-",
">",
"sizeField",
"height",
"based",
"on",
"-",
">",
"heightField",
"radius",
"based",
"on",
"-",
">",
"radiusField",
"here",
"we",
"make",
"our",
"wiredst",
"guess",
"on",
"which",
"channel",
"sizeField"... | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/schemas/vis-state-schema.js#L40-L64 | train | Convert sizeField from V0 to V1 | [
30522,
3853,
20248,
22578,
5644,
4697,
3790,
2615,
2692,
26525,
2487,
1006,
9530,
8873,
2290,
1007,
1063,
9530,
3367,
12398,
14995,
6784,
2015,
1027,
2184,
1025,
9530,
3367,
12398,
12173,
4173,
24388,
2063,
1027,
1031,
1014,
1010,
2753,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
askmike/gekko | strategies/indicators/LRC.js | linreg | function linreg(values_x, values_y) {
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var count = 0;
/*
* We'll use those variables for faster read/write access.
*/
var x = 0;
var y = 0;
var values_length = values_x.length;
if (values_length != values_y.length) {
throw new Error('The parameters values_x and values_y need to have same size!');
}
/*
* Nothing to do.
*/
if (values_length === 0) {
return [ [], [] ];
}
/*
* Calculate the sum for each of the parts necessary.
*/
for (var v = 0; v < values_length; v++) {
x = values_x[v];
y = values_y[v];
sum_x += x;
sum_y += y;
sum_xx += x*x;
sum_xy += x*y;
count++;
}
/*
* Calculate m and b for the formular:
* y = x * m + b
*/
var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x);
var b = (sum_y/count) - (m*sum_x)/count;
return [m, b];
} | javascript | function linreg(values_x, values_y) {
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var count = 0;
/*
* We'll use those variables for faster read/write access.
*/
var x = 0;
var y = 0;
var values_length = values_x.length;
if (values_length != values_y.length) {
throw new Error('The parameters values_x and values_y need to have same size!');
}
/*
* Nothing to do.
*/
if (values_length === 0) {
return [ [], [] ];
}
/*
* Calculate the sum for each of the parts necessary.
*/
for (var v = 0; v < values_length; v++) {
x = values_x[v];
y = values_y[v];
sum_x += x;
sum_y += y;
sum_xx += x*x;
sum_xy += x*y;
count++;
}
/*
* Calculate m and b for the formular:
* y = x * m + b
*/
var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x);
var b = (sum_y/count) - (m*sum_x)/count;
return [m, b];
} | [
"function",
"linreg",
"(",
"values_x",
",",
"values_y",
")",
"{",
"var",
"sum_x",
"=",
"0",
";",
"var",
"sum_y",
"=",
"0",
";",
"var",
"sum_xy",
"=",
"0",
";",
"var",
"sum_xx",
"=",
"0",
";",
"var",
"count",
"=",
"0",
";",
"/*\n * We'll use those... | /*
Least squares linear regression fitting. | [
"/",
"*",
"Least",
"squares",
"linear",
"regression",
"fitting",
"."
] | 0ce9ddd577fa8a22812c02331a494086758dfadf | https://github.com/askmike/gekko/blob/0ce9ddd577fa8a22812c02331a494086758dfadf/strategies/indicators/LRC.js#L54-L100 | train | Calculate the linreg | [
30522,
3853,
11409,
2890,
2290,
1006,
5300,
1035,
1060,
1010,
5300,
1035,
1061,
1007,
1063,
13075,
7680,
1035,
1060,
1027,
1014,
1025,
13075,
7680,
1035,
1061,
1027,
1014,
1025,
13075,
7680,
1035,
1060,
2100,
1027,
1014,
1025,
13075,
7680,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/BarInPageEnabler.js | function (sContext) {
var oOptions = this._getContextOptions(sContext);
if (!oOptions) {
return this;
}
if (!this.isContextSensitive) {
Log.error("The bar control you are using does not implement all the members of the IBar interface", this);
return this;
}
//If this class does not gets added by the renderer, add it here
if (!this.getRenderer().shouldAddIBarContext()) {
this.addStyleClass(IBAR_CSS_CLASS + "-CTX");
}
if (this.isContextSensitive()) {
this.addStyleClass(oOptions.contextClass);
}
return this;
} | javascript | function (sContext) {
var oOptions = this._getContextOptions(sContext);
if (!oOptions) {
return this;
}
if (!this.isContextSensitive) {
Log.error("The bar control you are using does not implement all the members of the IBar interface", this);
return this;
}
//If this class does not gets added by the renderer, add it here
if (!this.getRenderer().shouldAddIBarContext()) {
this.addStyleClass(IBAR_CSS_CLASS + "-CTX");
}
if (this.isContextSensitive()) {
this.addStyleClass(oOptions.contextClass);
}
return this;
} | [
"function",
"(",
"sContext",
")",
"{",
"var",
"oOptions",
"=",
"this",
".",
"_getContextOptions",
"(",
"sContext",
")",
";",
"if",
"(",
"!",
"oOptions",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"!",
"this",
".",
"isContextSensitive",
")",
"{",
... | Sets classes according to the context of the page.
Possible contexts are header, footer, subheader.
@param {string} sContext allowed values are header, footer, subheader.
@returns {sap.m.IBar} <code>this</code> for chaining
@sap-restricted
@private | [
"Sets",
"classes",
"according",
"to",
"the",
"context",
"of",
"the",
"page",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/BarInPageEnabler.js#L138-L160 | train | Adds the context class to the control | [
30522,
3853,
1006,
8040,
28040,
18413,
1007,
1063,
13075,
1051,
7361,
9285,
1027,
2023,
1012,
1035,
2131,
8663,
18209,
7361,
9285,
1006,
8040,
28040,
18413,
1007,
1025,
2065,
1006,
999,
1051,
7361,
9285,
1007,
1063,
2709,
2023,
1025,
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... | |
grpc/grpc-node | packages/grpc-native-core/src/server.js | setUpReadable | function setUpReadable(stream, deserialize) {
stream.deserialize = common.wrapIgnoreNull(deserialize);
stream.finished = false;
stream.reading = false;
stream.terminate = function() {
stream.finished = true;
stream.on('data', function() {});
};
stream.on('cancelled', function() {
stream.terminate();
});
} | javascript | function setUpReadable(stream, deserialize) {
stream.deserialize = common.wrapIgnoreNull(deserialize);
stream.finished = false;
stream.reading = false;
stream.terminate = function() {
stream.finished = true;
stream.on('data', function() {});
};
stream.on('cancelled', function() {
stream.terminate();
});
} | [
"function",
"setUpReadable",
"(",
"stream",
",",
"deserialize",
")",
"{",
"stream",
".",
"deserialize",
"=",
"common",
".",
"wrapIgnoreNull",
"(",
"deserialize",
")",
";",
"stream",
".",
"finished",
"=",
"false",
";",
"stream",
".",
"reading",
"=",
"false",
... | Initialize a readable stream. This is used for both the readable and duplex
stream constructors.
@private
@param {Readable} stream The stream to initialize
@param {grpc~deserialize} deserialize Deserialization function for
incoming data. | [
"Initialize",
"a",
"readable",
"stream",
".",
"This",
"is",
"used",
"for",
"both",
"the",
"readable",
"and",
"duplex",
"stream",
"constructors",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L200-L213 | train | Set up the readable stream | [
30522,
3853,
16437,
16416,
20782,
1006,
5460,
1010,
4078,
11610,
3669,
4371,
1007,
1063,
5460,
1012,
4078,
11610,
3669,
4371,
1027,
2691,
1012,
10236,
23773,
5686,
11231,
3363,
1006,
4078,
11610,
3669,
4371,
1007,
1025,
5460,
1012,
2736,
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... |
firebase/firebase-js-sdk | scripts/docgen/generate-docs.js | checkForMissingFilesAndFixFilenameCase | function checkForMissingFilesAndFixFilenameCase() {
// Get filenames from toc.yaml.
const filenames = tocText
.split('\n')
.filter(line => line.includes('path:'))
.map(line => line.split(devsitePath)[1]);
// Logs warning to console if a file from TOC is not found.
const fileCheckPromises = filenames.map(filename => {
// Warns if file does not exist, fixes filename case if it does.
// Preferred filename for devsite should be capitalized and taken from
// toc.yaml.
const tocFilePath = `${docPath}/${filename}.html`;
// Generated filename from Typedoc will be lowercase.
const generatedFilePath = `${docPath}/${filename.toLowerCase()}.html`;
return fs.exists(generatedFilePath).then(exists => {
if (exists) {
// Store in a lookup table for link fixing.
lowerToUpperLookup[
`${filename.toLowerCase()}.html`
] = `${filename}.html`;
return fs.rename(generatedFilePath, tocFilePath);
} else {
console.warn(
`Missing file: ${filename}.html requested ` +
`in toc.yaml but not found in ${docPath}`
);
}
});
});
return Promise.all(fileCheckPromises).then(() => filenames);
} | javascript | function checkForMissingFilesAndFixFilenameCase() {
// Get filenames from toc.yaml.
const filenames = tocText
.split('\n')
.filter(line => line.includes('path:'))
.map(line => line.split(devsitePath)[1]);
// Logs warning to console if a file from TOC is not found.
const fileCheckPromises = filenames.map(filename => {
// Warns if file does not exist, fixes filename case if it does.
// Preferred filename for devsite should be capitalized and taken from
// toc.yaml.
const tocFilePath = `${docPath}/${filename}.html`;
// Generated filename from Typedoc will be lowercase.
const generatedFilePath = `${docPath}/${filename.toLowerCase()}.html`;
return fs.exists(generatedFilePath).then(exists => {
if (exists) {
// Store in a lookup table for link fixing.
lowerToUpperLookup[
`${filename.toLowerCase()}.html`
] = `${filename}.html`;
return fs.rename(generatedFilePath, tocFilePath);
} else {
console.warn(
`Missing file: ${filename}.html requested ` +
`in toc.yaml but not found in ${docPath}`
);
}
});
});
return Promise.all(fileCheckPromises).then(() => filenames);
} | [
"function",
"checkForMissingFilesAndFixFilenameCase",
"(",
")",
"{",
"// Get filenames from toc.yaml.",
"const",
"filenames",
"=",
"tocText",
".",
"split",
"(",
"'\\n'",
")",
".",
"filter",
"(",
"line",
"=>",
"line",
".",
"includes",
"(",
"'path:'",
")",
")",
".... | Checks to see if any files listed in toc.yaml were not generated.
If files exist, fixes filename case to match toc.yaml version. | [
"Checks",
"to",
"see",
"if",
"any",
"files",
"listed",
"in",
"toc",
".",
"yaml",
"were",
"not",
"generated",
".",
"If",
"files",
"exist",
"fixes",
"filename",
"case",
"to",
"match",
"toc",
".",
"yaml",
"version",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/scripts/docgen/generate-docs.js#L135-L165 | train | Checks if a file from toc. yaml is missing and fixes filename case if it does. | [
30522,
3853,
4638,
14192,
14643,
2075,
8873,
4244,
5685,
8873,
2595,
8873,
20844,
4168,
18382,
1006,
1007,
1063,
1013,
1013,
2131,
5371,
18442,
2015,
2013,
2000,
2278,
1012,
8038,
19968,
1012,
9530,
3367,
5371,
18442,
2015,
1027,
2000,
6593... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
mescroll/mescroll | mescroll.js/html-demo/dotJump/option/mescroll-option.js | function(mescroll, downwarp) {
//初始化完毕的回调,可缓存dom
mescroll.downCircleDom = downwarp.getElementsByClassName("downwarp-circle")[0];
mescroll.downBallDom = downwarp.getElementsByClassName("downwarp-ball")[0];
} | javascript | function(mescroll, downwarp) {
//初始化完毕的回调,可缓存dom
mescroll.downCircleDom = downwarp.getElementsByClassName("downwarp-circle")[0];
mescroll.downBallDom = downwarp.getElementsByClassName("downwarp-ball")[0];
} | [
"function",
"(",
"mescroll",
",",
"downwarp",
")",
"{",
"//初始化完毕的回调,可缓存dom",
"mescroll",
".",
"downCircleDom",
"=",
"downwarp",
".",
"getElementsByClassName",
"(",
"\"downwarp-circle\"",
")",
"[",
"0",
"]",
";",
"mescroll",
".",
"downBallDom",
"=",
"downwarp",
"... | 布局内容 | [
"布局内容"
] | 43d3dcf3062da0fe95995ddcb5e93f5725792c98 | https://github.com/mescroll/mescroll/blob/43d3dcf3062da0fe95995ddcb5e93f5725792c98/mescroll.js/html-demo/dotJump/option/mescroll-option.js#L67-L71 | train | init downwarp dom | [
30522,
3853,
1006,
2033,
11020,
28402,
1010,
2091,
9028,
2361,
1007,
1063,
1013,
1013,
100,
100,
100,
100,
100,
1916,
100,
100,
1010,
100,
100,
100,
14383,
2033,
11020,
28402,
1012,
2091,
6895,
21769,
9527,
1027,
2091,
9028,
2361,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/ODataModel.js | _submit | function _submit(){
// execute the request and use the metadata if available
if (that.bUseBatch) {
that.updateSecurityToken();
// batch requests only need the path without the service URL
// extract query of url and combine it with the path...
var sUriQuery = URI.parse(oRequest.requestUri).query;
//var sRequestUrl = sPath.replace(/\/$/, ""); // remove trailing slash if any
//sRequestUrl += sUriQuery ? "?" + sUriQuery : "";
var sRequestUrl = that._createRequestUrl(sPath, null, sUriQuery, that.bUseBatch);
oRequest = that._createRequest(sRequestUrl, "GET", true);
var oBatchRequest = that._createBatchRequest([oRequest],true);
oRequestHandle = that._request(oBatchRequest, _handleSuccess, _handleError, OData.batchHandler, undefined, that.getServiceMetadata());
} else {
oRequestHandle = that._request(oRequest, _handleSuccess, _handleError, that.oHandler, undefined, that.getServiceMetadata());
}
if (fnHandleUpdate) {
// Create a wrapper for the request handle to be able to differentiate
// between intentionally aborted requests and failed requests
var oWrappedHandle = {
abort: function() {
oRequestHandle.bAborted = true;
oRequestHandle.abort();
}
};
fnHandleUpdate(oWrappedHandle);
}
} | javascript | function _submit(){
// execute the request and use the metadata if available
if (that.bUseBatch) {
that.updateSecurityToken();
// batch requests only need the path without the service URL
// extract query of url and combine it with the path...
var sUriQuery = URI.parse(oRequest.requestUri).query;
//var sRequestUrl = sPath.replace(/\/$/, ""); // remove trailing slash if any
//sRequestUrl += sUriQuery ? "?" + sUriQuery : "";
var sRequestUrl = that._createRequestUrl(sPath, null, sUriQuery, that.bUseBatch);
oRequest = that._createRequest(sRequestUrl, "GET", true);
var oBatchRequest = that._createBatchRequest([oRequest],true);
oRequestHandle = that._request(oBatchRequest, _handleSuccess, _handleError, OData.batchHandler, undefined, that.getServiceMetadata());
} else {
oRequestHandle = that._request(oRequest, _handleSuccess, _handleError, that.oHandler, undefined, that.getServiceMetadata());
}
if (fnHandleUpdate) {
// Create a wrapper for the request handle to be able to differentiate
// between intentionally aborted requests and failed requests
var oWrappedHandle = {
abort: function() {
oRequestHandle.bAborted = true;
oRequestHandle.abort();
}
};
fnHandleUpdate(oWrappedHandle);
}
} | [
"function",
"_submit",
"(",
")",
"{",
"// execute the request and use the metadata if available",
"if",
"(",
"that",
".",
"bUseBatch",
")",
"{",
"that",
".",
"updateSecurityToken",
"(",
")",
";",
"// batch requests only need the path without the service URL",
"// extract quer... | this method is used to retrieve all desired data. It triggers additional read requests if the server paging size
permits to return all the requested data. This could only happen for servers with support for oData > 2.0. | [
"this",
"method",
"is",
"used",
"to",
"retrieve",
"all",
"desired",
"data",
".",
"It",
"triggers",
"additional",
"read",
"requests",
"if",
"the",
"server",
"paging",
"size",
"permits",
"to",
"return",
"all",
"the",
"requested",
"data",
".",
"This",
"could",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/ODataModel.js#L831-L860 | train | submit the request | [
30522,
3853,
1035,
12040,
1006,
1007,
1063,
1013,
1013,
15389,
1996,
5227,
1998,
2224,
1996,
27425,
2065,
2800,
2065,
1006,
2008,
1012,
3902,
15878,
4017,
2818,
1007,
1063,
2008,
1012,
14409,
8586,
25137,
18715,
2368,
1006,
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... |
jhipster/generator-jhipster | generators/docker-cli.js | command | function command(cmd, cb, opts = {}) {
const options = {
silent: false,
maxBuffer: 10240000,
...opts
};
const command = exec(`${cmd}`, { maxBuffer: options.maxBuffer }, cb);
if (!options.silent) {
command.stdout.on('data', stdOut);
command.stderr.on('data', stdErr);
}
} | javascript | function command(cmd, cb, opts = {}) {
const options = {
silent: false,
maxBuffer: 10240000,
...opts
};
const command = exec(`${cmd}`, { maxBuffer: options.maxBuffer }, cb);
if (!options.silent) {
command.stdout.on('data', stdOut);
command.stderr.on('data', stdErr);
}
} | [
"function",
"command",
"(",
"cmd",
",",
"cb",
",",
"opts",
"=",
"{",
"}",
")",
"{",
"const",
"options",
"=",
"{",
"silent",
":",
"false",
",",
"maxBuffer",
":",
"10240000",
",",
"...",
"opts",
"}",
";",
"const",
"command",
"=",
"exec",
"(",
"`",
... | Execute the shell command given as a parameter and execute the callback at the end. Callback has profile:
`function(err, stdout, stderr)`
@param cmd the command to execute
@param cb the callback that will be called after the function is executed.
@param opts additional options
@attr silent flag to deactivate the live stderr and stdout. Default to false
@attr maxBuffer value of the buffer to store the live outputs. Default to 10240000 | [
"Execute",
"the",
"shell",
"command",
"given",
"as",
"a",
"parameter",
"and",
"execute",
"the",
"callback",
"at",
"the",
"end",
".",
"Callback",
"has",
"profile",
":",
"function",
"(",
"err",
"stdout",
"stderr",
")"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-cli.js#L51-L63 | train | Execute a command | [
30522,
3853,
3094,
1006,
4642,
2094,
1010,
17324,
1010,
23569,
2015,
1027,
1063,
1065,
1007,
1063,
9530,
3367,
7047,
1027,
1063,
4333,
1024,
6270,
1010,
4098,
8569,
12494,
1024,
9402,
29537,
8889,
1010,
1012,
1012,
1012,
23569,
2015,
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... |
eslint/eslint | lib/rules/indent-legacy.js | report | function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) {
if (gottenSpaces && gottenTabs) {
// To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs.
return;
}
const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed);
const textRange = isLastNodeCheck
? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs]
: [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs];
context.report({
node,
loc,
messageId: "expected",
data: createErrorMessageData(needed, gottenSpaces, gottenTabs),
fix: fixer => fixer.replaceTextRange(textRange, desiredIndent)
});
} | javascript | function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) {
if (gottenSpaces && gottenTabs) {
// To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs.
return;
}
const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed);
const textRange = isLastNodeCheck
? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs]
: [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs];
context.report({
node,
loc,
messageId: "expected",
data: createErrorMessageData(needed, gottenSpaces, gottenTabs),
fix: fixer => fixer.replaceTextRange(textRange, desiredIndent)
});
} | [
"function",
"report",
"(",
"node",
",",
"needed",
",",
"gottenSpaces",
",",
"gottenTabs",
",",
"loc",
",",
"isLastNodeCheck",
")",
"{",
"if",
"(",
"gottenSpaces",
"&&",
"gottenTabs",
")",
"{",
"// To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines th... | Reports a given indent violation
@param {ASTNode} node Node violating the indent rule
@param {int} needed Expected indentation character count
@param {int} gottenSpaces Indentation space count in the actual node/code
@param {int} gottenTabs Indentation tab count in the actual node/code
@param {Object=} loc Error line and column location
@param {boolean} isLastNodeCheck Is the error for last node check
@returns {void} | [
"Reports",
"a",
"given",
"indent",
"violation"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L310-L330 | train | Reports a node with the given number of spaces and tabs. | [
30522,
3853,
3189,
1006,
13045,
1010,
2734,
1010,
5407,
23058,
2015,
1010,
5407,
2696,
5910,
1010,
8840,
2278,
1010,
25340,
3367,
3630,
3207,
5403,
3600,
1007,
1063,
2065,
1006,
5407,
23058,
2015,
1004,
1004,
5407,
2696,
5910,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fengyuanchen/cropper | dist/cropper.common.js | getData | function getData(element, name) {
if (isObject(element[name])) {
return element[name];
} else if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute('data-' + hyphenate(name));
} | javascript | function getData(element, name) {
if (isObject(element[name])) {
return element[name];
} else if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute('data-' + hyphenate(name));
} | [
"function",
"getData",
"(",
"element",
",",
"name",
")",
"{",
"if",
"(",
"isObject",
"(",
"element",
"[",
"name",
"]",
")",
")",
"{",
"return",
"element",
"[",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"element",
".",
"dataset",
")",
"{",
"return",... | Get data from the given element.
@param {Element} element - The target element.
@param {string} name - The data key to get.
@returns {string} The data value. | [
"Get",
"data",
"from",
"the",
"given",
"element",
"."
] | 6677332a6a375b647f58808dfc24ea09f5804041 | https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L475-L483 | train | Get data from element | [
30522,
3853,
2131,
2850,
2696,
1006,
5783,
1010,
2171,
1007,
1063,
2065,
1006,
11163,
2497,
20614,
1006,
5783,
1031,
2171,
1033,
1007,
1007,
1063,
2709,
5783,
1031,
2171,
1033,
1025,
1065,
2842,
2065,
1006,
5783,
1012,
2951,
13462,
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... |
aframevr/aframe | src/utils/coordinates.js | stringify | function stringify (data) {
var str;
if (typeof data !== OBJECT) { return data; }
str = data.x + ' ' + data.y;
if (data.z != null) { str += ' ' + data.z; }
if (data.w != null) { str += ' ' + data.w; }
return str;
} | javascript | function stringify (data) {
var str;
if (typeof data !== OBJECT) { return data; }
str = data.x + ' ' + data.y;
if (data.z != null) { str += ' ' + data.z; }
if (data.w != null) { str += ' ' + data.w; }
return str;
} | [
"function",
"stringify",
"(",
"data",
")",
"{",
"var",
"str",
";",
"if",
"(",
"typeof",
"data",
"!==",
"OBJECT",
")",
"{",
"return",
"data",
";",
"}",
"str",
"=",
"data",
".",
"x",
"+",
"' '",
"+",
"data",
".",
"y",
";",
"if",
"(",
"data",
".",... | Stringify coordinates from an object with keys [x y z].
Example: {x: 3, y: 10, z: -5} to "3 10 -5".
@param {object|string} data - An object with keys [x y z].
@returns {string} An "x y z" string. | [
"Stringify",
"coordinates",
"from",
"an",
"object",
"with",
"keys",
"[",
"x",
"y",
"z",
"]",
".",
"Example",
":",
"{",
"x",
":",
"3",
"y",
":",
"10",
"z",
":",
"-",
"5",
"}",
"to",
"3",
"10",
"-",
"5",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/coordinates.js#L75-L82 | train | Stringify a data object | [
30522,
3853,
5164,
8757,
1006,
2951,
1007,
1063,
13075,
2358,
2099,
1025,
2065,
1006,
2828,
11253,
2951,
999,
1027,
1027,
4874,
1007,
1063,
2709,
2951,
1025,
1065,
2358,
2099,
1027,
2951,
1012,
1060,
1009,
1005,
1005,
1009,
2951,
1012,
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... |
adobe/brackets | src/filesystem/impls/appshell/node/FileWatcherManager.js | normalizeStats | function normalizeStats(nodeFsStats) {
// current shell's stat method floors the mtime to the nearest thousand
// which causes problems when comparing timestamps
// so we have to round mtime to the nearest thousand too
var mtime = Math.floor(nodeFsStats.mtime.getTime() / 1000) * 1000;
// from shell: If "filename" is a symlink,
// realPath should be the actual path to the linked object
// not implemented in shell yet
return {
isFile: nodeFsStats.isFile(),
isDirectory: nodeFsStats.isDirectory(),
mtime: mtime,
size: nodeFsStats.size,
realPath: null,
hash: mtime
};
} | javascript | function normalizeStats(nodeFsStats) {
// current shell's stat method floors the mtime to the nearest thousand
// which causes problems when comparing timestamps
// so we have to round mtime to the nearest thousand too
var mtime = Math.floor(nodeFsStats.mtime.getTime() / 1000) * 1000;
// from shell: If "filename" is a symlink,
// realPath should be the actual path to the linked object
// not implemented in shell yet
return {
isFile: nodeFsStats.isFile(),
isDirectory: nodeFsStats.isDirectory(),
mtime: mtime,
size: nodeFsStats.size,
realPath: null,
hash: mtime
};
} | [
"function",
"normalizeStats",
"(",
"nodeFsStats",
")",
"{",
"// current shell's stat method floors the mtime to the nearest thousand",
"// which causes problems when comparing timestamps",
"// so we have to round mtime to the nearest thousand too",
"var",
"mtime",
"=",
"Math",
".",
"floo... | Transform Node's native fs.stats to a format that can be sent through domain
@param {stats} nodeFsStats Node's fs.stats result
@return {object} Can be consumed by new FileSystemStats(object); in Brackets | [
"Transform",
"Node",
"s",
"native",
"fs",
".",
"stats",
"to",
"a",
"format",
"that",
"can",
"be",
"sent",
"through",
"domain"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/node/FileWatcherManager.js#L46-L63 | train | normalize stats from node fs | [
30522,
3853,
3671,
10057,
29336,
2015,
1006,
13045,
10343,
9153,
3215,
1007,
1063,
1013,
1013,
2783,
5806,
1005,
1055,
28093,
4118,
8158,
1996,
11047,
14428,
2000,
1996,
7205,
4595,
1013,
1013,
2029,
5320,
3471,
2043,
13599,
2335,
15464,
45... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | findNext | function findNext(editor, searchBackwards, preferNoScroll, pos) {
var cm = editor._codeMirror;
cm.operation(function () {
var state = getSearchState(cm);
clearCurrentMatchHighlight(cm, state);
var nextMatch = _getNextMatch(editor, searchBackwards, pos);
if (nextMatch) {
// Update match index indicators - only possible if we have resultSet saved (missing if FIND_MAX_FILE_SIZE threshold hit)
if (state.resultSet.length) {
_updateFindBarWithMatchInfo(state,
{from: nextMatch.start, to: nextMatch.end}, searchBackwards);
// Update current-tickmark indicator - only if highlighting enabled (disabled if FIND_HIGHLIGHT_MAX threshold hit)
if (state.marked.length) {
ScrollTrackMarkers.markCurrent(state.matchIndex); // _updateFindBarWithMatchInfo() has updated this index
}
}
_selectAndScrollTo(editor, [nextMatch], true, preferNoScroll);
// Only mark text with "current match" highlight if search bar still open
if (findBar && !findBar.isClosed()) {
// If highlighting disabled, apply both match AND current-match styles for correct appearance
var curentMatchClassName = state.marked.length ? "searching-current-match" : "CodeMirror-searching searching-current-match";
state.markedCurrent = cm.markText(nextMatch.start, nextMatch.end,
{ className: curentMatchClassName, startStyle: "searching-first", endStyle: "searching-last" });
}
} else {
cm.setCursor(editor.getCursorPos()); // collapses selection, keeping cursor in place to avoid scrolling
// (nothing more to do: previous highlights already cleared above)
}
});
} | javascript | function findNext(editor, searchBackwards, preferNoScroll, pos) {
var cm = editor._codeMirror;
cm.operation(function () {
var state = getSearchState(cm);
clearCurrentMatchHighlight(cm, state);
var nextMatch = _getNextMatch(editor, searchBackwards, pos);
if (nextMatch) {
// Update match index indicators - only possible if we have resultSet saved (missing if FIND_MAX_FILE_SIZE threshold hit)
if (state.resultSet.length) {
_updateFindBarWithMatchInfo(state,
{from: nextMatch.start, to: nextMatch.end}, searchBackwards);
// Update current-tickmark indicator - only if highlighting enabled (disabled if FIND_HIGHLIGHT_MAX threshold hit)
if (state.marked.length) {
ScrollTrackMarkers.markCurrent(state.matchIndex); // _updateFindBarWithMatchInfo() has updated this index
}
}
_selectAndScrollTo(editor, [nextMatch], true, preferNoScroll);
// Only mark text with "current match" highlight if search bar still open
if (findBar && !findBar.isClosed()) {
// If highlighting disabled, apply both match AND current-match styles for correct appearance
var curentMatchClassName = state.marked.length ? "searching-current-match" : "CodeMirror-searching searching-current-match";
state.markedCurrent = cm.markText(nextMatch.start, nextMatch.end,
{ className: curentMatchClassName, startStyle: "searching-first", endStyle: "searching-last" });
}
} else {
cm.setCursor(editor.getCursorPos()); // collapses selection, keeping cursor in place to avoid scrolling
// (nothing more to do: previous highlights already cleared above)
}
});
} | [
"function",
"findNext",
"(",
"editor",
",",
"searchBackwards",
",",
"preferNoScroll",
",",
"pos",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
";",
"cm",
".",
"operation",
"(",
"function",
"(",
")",
"{",
"var",
"state",
"=",
"getSearchState",
... | Selects the next match (or prev match, if searchBackwards==true) starting from either the current position
(if pos unspecified) or the given position (if pos specified explicitly). The starting position
need not be an existing match. If a new match is found, sets to state.lastMatch either the regex
match result, or simply true for a plain-string match. If no match found, sets state.lastMatch
to false.
@param {!Editor} editor
@param {?boolean} searchBackwards
@param {?boolean} preferNoScroll
@param {?Pos} pos | [
"Selects",
"the",
"next",
"match",
"(",
"or",
"prev",
"match",
"if",
"searchBackwards",
"==",
"true",
")",
"starting",
"from",
"either",
"the",
"current",
"position",
"(",
"if",
"pos",
"unspecified",
")",
"or",
"the",
"given",
"position",
"(",
"if",
"pos",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L416-L448 | train | Find next match in the search list | [
30522,
3853,
2424,
2638,
18413,
1006,
3559,
1010,
3945,
5963,
7652,
2015,
1010,
9544,
15460,
26775,
14511,
1010,
13433,
2015,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
1035,
3642,
14503,
29165,
1025,
4642,
1012,
3169,
1006,
3853,
1006,
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... |
angular/material | src/components/sidenav/sidenav.js | addLegacyAPI | function addLegacyAPI(service, handle) {
var falseFn = function() {
return false;
};
var rejectFn = function() {
return $q.when($mdUtil.supplant(errorMsg, [handle || ""]));
};
return angular.extend({
isLockedOpen: falseFn,
isOpen: falseFn,
toggle: rejectFn,
open: rejectFn,
close: rejectFn,
onClose: angular.noop,
then: function(callback) {
return waitForInstance(handle).then(callback || angular.noop);
}
}, service);
} | javascript | function addLegacyAPI(service, handle) {
var falseFn = function() {
return false;
};
var rejectFn = function() {
return $q.when($mdUtil.supplant(errorMsg, [handle || ""]));
};
return angular.extend({
isLockedOpen: falseFn,
isOpen: falseFn,
toggle: rejectFn,
open: rejectFn,
close: rejectFn,
onClose: angular.noop,
then: function(callback) {
return waitForInstance(handle).then(callback || angular.noop);
}
}, service);
} | [
"function",
"addLegacyAPI",
"(",
"service",
",",
"handle",
")",
"{",
"var",
"falseFn",
"=",
"function",
"(",
")",
"{",
"return",
"false",
";",
"}",
";",
"var",
"rejectFn",
"=",
"function",
"(",
")",
"{",
"return",
"$q",
".",
"when",
"(",
"$mdUtil",
"... | For failed instance/handle lookups, older-clients expect an response object with noops
that include `rejected promise APIs`
@param service
@param handle
@returns {Object} | [
"For",
"failed",
"instance",
"/",
"handle",
"lookups",
"older",
"-",
"clients",
"expect",
"an",
"response",
"object",
"with",
"noops",
"that",
"include",
"rejected",
"promise",
"APIs"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L106-L125 | train | Adds a legacy API to the specified service | [
30522,
3853,
5587,
23115,
15719,
9331,
2072,
1006,
2326,
1010,
5047,
1007,
1063,
13075,
6270,
2546,
2078,
1027,
3853,
1006,
1007,
1063,
2709,
6270,
1025,
1065,
1025,
13075,
15454,
2546,
2078,
1027,
3853,
1006,
1007,
1063,
2709,
1002,
1053,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
electron/electron | script/bump-version.js | main | async function main () {
const opts = parseCommandLine()
const currentVersion = await utils.getElectronVersion()
const version = await nextVersion(opts.bump, currentVersion)
const parsed = semver.parse(version)
const components = {
major: parsed.major,
minor: parsed.minor,
patch: parsed.patch,
pre: parsed.prerelease
}
// print would-be new version and exit early
if (opts.dryRun) {
console.log(`new version number would be: ${version}\n`)
return 0
}
// update all version-related files
await Promise.all([
updateVersion(version),
updateInfoPlist(version),
updatePackageJSON(version),
updateVersionH(components),
updateWinRC(components)
])
// commit all updated version-related files
await commitVersionBump(version)
console.log(`Bumped to version: ${version}`)
} | javascript | async function main () {
const opts = parseCommandLine()
const currentVersion = await utils.getElectronVersion()
const version = await nextVersion(opts.bump, currentVersion)
const parsed = semver.parse(version)
const components = {
major: parsed.major,
minor: parsed.minor,
patch: parsed.patch,
pre: parsed.prerelease
}
// print would-be new version and exit early
if (opts.dryRun) {
console.log(`new version number would be: ${version}\n`)
return 0
}
// update all version-related files
await Promise.all([
updateVersion(version),
updateInfoPlist(version),
updatePackageJSON(version),
updateVersionH(components),
updateWinRC(components)
])
// commit all updated version-related files
await commitVersionBump(version)
console.log(`Bumped to version: ${version}`)
} | [
"async",
"function",
"main",
"(",
")",
"{",
"const",
"opts",
"=",
"parseCommandLine",
"(",
")",
"const",
"currentVersion",
"=",
"await",
"utils",
".",
"getElectronVersion",
"(",
")",
"const",
"version",
"=",
"await",
"nextVersion",
"(",
"opts",
".",
"bump",
... | run the script | [
"run",
"the",
"script"
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/script/bump-version.js#L37-L69 | train | Main entry point | [
30522,
2004,
6038,
2278,
3853,
2364,
1006,
1007,
1063,
9530,
3367,
23569,
2015,
1027,
11968,
3366,
9006,
2386,
19422,
3170,
1006,
1007,
9530,
3367,
2783,
27774,
1027,
26751,
21183,
12146,
1012,
2131,
12260,
6593,
4948,
27774,
1006,
1007,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
tgriesser/knex | src/transaction.js | makeTransactor | function makeTransactor(trx, connection, trxClient) {
const transactor = makeKnex(trxClient);
transactor.withUserParams = () => {
throw new Error(
'Cannot set user params on a transaction - it can only inherit params from main knex instance'
);
};
transactor.isTransaction = true;
transactor.userParams = trx.userParams || {};
transactor.transaction = function(container, options) {
return trxClient.transaction(container, options, trx);
};
transactor.savepoint = function(container, options) {
return transactor.transaction(container, options);
};
if (trx.client.transacting) {
transactor.commit = (value) => trx.release(connection, value);
transactor.rollback = (error) => trx.rollbackTo(connection, error);
} else {
transactor.commit = (value) => trx.commit(connection, value);
transactor.rollback = (error) => trx.rollback(connection, error);
}
return transactor;
} | javascript | function makeTransactor(trx, connection, trxClient) {
const transactor = makeKnex(trxClient);
transactor.withUserParams = () => {
throw new Error(
'Cannot set user params on a transaction - it can only inherit params from main knex instance'
);
};
transactor.isTransaction = true;
transactor.userParams = trx.userParams || {};
transactor.transaction = function(container, options) {
return trxClient.transaction(container, options, trx);
};
transactor.savepoint = function(container, options) {
return transactor.transaction(container, options);
};
if (trx.client.transacting) {
transactor.commit = (value) => trx.release(connection, value);
transactor.rollback = (error) => trx.rollbackTo(connection, error);
} else {
transactor.commit = (value) => trx.commit(connection, value);
transactor.rollback = (error) => trx.rollback(connection, error);
}
return transactor;
} | [
"function",
"makeTransactor",
"(",
"trx",
",",
"connection",
",",
"trxClient",
")",
"{",
"const",
"transactor",
"=",
"makeKnex",
"(",
"trxClient",
")",
";",
"transactor",
".",
"withUserParams",
"=",
"(",
")",
"=>",
"{",
"throw",
"new",
"Error",
"(",
"'Cann... | The transactor is a full featured knex object, with a "commit", a "rollback" and a "savepoint" function. The "savepoint" is just sugar for creating a new transaction. If the rollback is run inside a savepoint, it rolls back to the last savepoint - otherwise it rolls back the transaction. | [
"The",
"transactor",
"is",
"a",
"full",
"featured",
"knex",
"object",
"with",
"a",
"commit",
"a",
"rollback",
"and",
"a",
"savepoint",
"function",
".",
"The",
"savepoint",
"is",
"just",
"sugar",
"for",
"creating",
"a",
"new",
"transaction",
".",
"If",
"the... | 6a4fecfe7822442ee5c43d924958eadfe6e17a93 | https://github.com/tgriesser/knex/blob/6a4fecfe7822442ee5c43d924958eadfe6e17a93/src/transaction.js#L187-L215 | train | Creates a transaction | [
30522,
3853,
2191,
6494,
3619,
18908,
2953,
1006,
19817,
2595,
1010,
4434,
1010,
19817,
2595,
20464,
11638,
1007,
1063,
9530,
3367,
9099,
18908,
2953,
1027,
2191,
2243,
2638,
2595,
1006,
19817,
2595,
20464,
11638,
1007,
1025,
9099,
18908,
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/thirdparty/zyngascroll.js | function(zoomLevel) {
var self = this;
if (zoomLevel == null) {
zoomLevel = self.__zoomLevel;
}
self.__maxScrollLeft = Math.max((self.__contentWidth * zoomLevel) - self.__clientWidth, 0);
self.__maxScrollTop = Math.max((self.__contentHeight * zoomLevel) - self.__clientHeight, 0);
} | javascript | function(zoomLevel) {
var self = this;
if (zoomLevel == null) {
zoomLevel = self.__zoomLevel;
}
self.__maxScrollLeft = Math.max((self.__contentWidth * zoomLevel) - self.__clientWidth, 0);
self.__maxScrollTop = Math.max((self.__contentHeight * zoomLevel) - self.__clientHeight, 0);
} | [
"function",
"(",
"zoomLevel",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"zoomLevel",
"==",
"null",
")",
"{",
"zoomLevel",
"=",
"self",
".",
"__zoomLevel",
";",
"}",
"self",
".",
"__maxScrollLeft",
"=",
"Math",
".",
"max",
"(",
"(",
"self"... | Recomputes scroll minimum values based on client dimensions and content dimensions. | [
"Recomputes",
"scroll",
"minimum",
"values",
"based",
"on",
"client",
"dimensions",
"and",
"content",
"dimensions",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/zyngascroll.js#L1375-L1386 | train | Sets the max scroll position to the specified zoom level | [
30522,
3853,
1006,
24095,
20414,
2884,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
24095,
20414,
2884,
1027,
1027,
19701,
1007,
1063,
24095,
20414,
2884,
1027,
2969,
1012,
1035,
1035,
24095,
20414,
2884,
1025,
1065,
2969,
1012,
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.core/src/sap/ui/core/support/debugReboot.js | function(oScript, rRegex) {
if (oScript && oScript.getAttribute("src") && rRegex.exec(oScript.getAttribute("src"))) {
return oScript;
}
} | javascript | function(oScript, rRegex) {
if (oScript && oScript.getAttribute("src") && rRegex.exec(oScript.getAttribute("src"))) {
return oScript;
}
} | [
"function",
"(",
"oScript",
",",
"rRegex",
")",
"{",
"if",
"(",
"oScript",
"&&",
"oScript",
".",
"getAttribute",
"(",
"\"src\"",
")",
"&&",
"rRegex",
".",
"exec",
"(",
"oScript",
".",
"getAttribute",
"(",
"\"src\"",
")",
")",
")",
"{",
"return",
"oScri... | replace the bootstrap tag with a newly created script tag to enable restarting the core from a different server | [
"replace",
"the",
"bootstrap",
"tag",
"with",
"a",
"newly",
"created",
"script",
"tag",
"to",
"enable",
"restarting",
"the",
"core",
"from",
"a",
"different",
"server"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/debugReboot.js#L56-L60 | train | Returns the script element if the src attribute is a regex | [
30522,
3853,
1006,
9808,
23235,
1010,
25269,
24746,
2595,
1007,
1063,
2065,
1006,
9808,
23235,
1004,
1004,
9808,
23235,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
1000,
5034,
2278,
1000,
1007,
1004,
1004,
25269,
24746,
2595,
1012,
4654,
858... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(oModelReference, mParameter) {
if (typeof mParameter == "string") {
throw "Deprecated second argument: Adjust your invocation by passing an object with a property sAnnotationJSONDoc as a second argument instead";
}
this._mParameter = mParameter;
var that = this;
/*
* get access to OData model
*/
this._oActivatedWorkarounds = {};
if (oModelReference && oModelReference.aWorkaroundID) {
for (var i = -1, sID; (sID = oModelReference.aWorkaroundID[++i]) !== undefined;) {
this._oActivatedWorkarounds[sID] = true;
}
oModelReference = oModelReference.oModelReference;
}
// check proper usage
if (!oModelReference || (!oModelReference.sServiceURI && !oModelReference.oModel)) {
throw "Usage with oModelReference being an instance of Model.ReferenceByURI or Model.ReferenceByModel";
}
//check if a model is given, or we need to create one from the service URI
if (oModelReference.oModel) {
this._oModel = oModelReference.oModel;
// find out which model version we are running
this._iVersion = AnalyticalVersionInfo.getVersion(this._oModel);
checkForMetadata();
} else if (mParameter && mParameter.modelVersion === AnalyticalVersionInfo.V2) {
// Check if the user wants a V2 model
var V2ODataModel = sap.ui.requireSync("sap/ui/model/odata/v2/ODataModel");
this._oModel = new V2ODataModel(oModelReference.sServiceURI);
this._iVersion = AnalyticalVersionInfo.V2;
checkForMetadata();
} else {
//default is V1 Model
var ODataModel = sap.ui.requireSync("sap/ui/model/odata/ODataModel");
this._oModel = new ODataModel(oModelReference.sServiceURI);
this._iVersion = AnalyticalVersionInfo.V1;
checkForMetadata();
}
if (this._oModel.getServiceMetadata()
&& this._oModel.getServiceMetadata().dataServices == undefined) {
throw "Model could not be loaded";
}
/**
* Check if the metadata is already available, if not defere the interpretation of the Metadata
*/
function checkForMetadata() {
// V2 supports asynchronous loading of metadata
// we have to register for the MetadataLoaded Event in case, the data is not loaded already
if (!that._oModel.getServiceMetadata()) {
that._oModel.attachMetadataLoaded(processMetadata);
} else {
// metadata already loaded
processMetadata();
}
}
/**
* Kickstart the interpretation of the metadata,
* either called directly if metadata is available, or deferred and then
* executed via callback by the model during the metadata loaded event.
*/
function processMetadata () {
//only interprete the metadata if the analytics model was not initialised yet
if (that.bIsInitialized) {
return;
}
//mark analytics model as initialized
that.bIsInitialized = true;
/*
* add extra annotations if provided
*/
if (mParameter && mParameter.sAnnotationJSONDoc) {
that.mergeV2Annotations(mParameter.sAnnotationJSONDoc);
}
that._interpreteMetadata(that._oModel.getServiceMetadata().dataServices);
}
} | javascript | function(oModelReference, mParameter) {
if (typeof mParameter == "string") {
throw "Deprecated second argument: Adjust your invocation by passing an object with a property sAnnotationJSONDoc as a second argument instead";
}
this._mParameter = mParameter;
var that = this;
/*
* get access to OData model
*/
this._oActivatedWorkarounds = {};
if (oModelReference && oModelReference.aWorkaroundID) {
for (var i = -1, sID; (sID = oModelReference.aWorkaroundID[++i]) !== undefined;) {
this._oActivatedWorkarounds[sID] = true;
}
oModelReference = oModelReference.oModelReference;
}
// check proper usage
if (!oModelReference || (!oModelReference.sServiceURI && !oModelReference.oModel)) {
throw "Usage with oModelReference being an instance of Model.ReferenceByURI or Model.ReferenceByModel";
}
//check if a model is given, or we need to create one from the service URI
if (oModelReference.oModel) {
this._oModel = oModelReference.oModel;
// find out which model version we are running
this._iVersion = AnalyticalVersionInfo.getVersion(this._oModel);
checkForMetadata();
} else if (mParameter && mParameter.modelVersion === AnalyticalVersionInfo.V2) {
// Check if the user wants a V2 model
var V2ODataModel = sap.ui.requireSync("sap/ui/model/odata/v2/ODataModel");
this._oModel = new V2ODataModel(oModelReference.sServiceURI);
this._iVersion = AnalyticalVersionInfo.V2;
checkForMetadata();
} else {
//default is V1 Model
var ODataModel = sap.ui.requireSync("sap/ui/model/odata/ODataModel");
this._oModel = new ODataModel(oModelReference.sServiceURI);
this._iVersion = AnalyticalVersionInfo.V1;
checkForMetadata();
}
if (this._oModel.getServiceMetadata()
&& this._oModel.getServiceMetadata().dataServices == undefined) {
throw "Model could not be loaded";
}
/**
* Check if the metadata is already available, if not defere the interpretation of the Metadata
*/
function checkForMetadata() {
// V2 supports asynchronous loading of metadata
// we have to register for the MetadataLoaded Event in case, the data is not loaded already
if (!that._oModel.getServiceMetadata()) {
that._oModel.attachMetadataLoaded(processMetadata);
} else {
// metadata already loaded
processMetadata();
}
}
/**
* Kickstart the interpretation of the metadata,
* either called directly if metadata is available, or deferred and then
* executed via callback by the model during the metadata loaded event.
*/
function processMetadata () {
//only interprete the metadata if the analytics model was not initialised yet
if (that.bIsInitialized) {
return;
}
//mark analytics model as initialized
that.bIsInitialized = true;
/*
* add extra annotations if provided
*/
if (mParameter && mParameter.sAnnotationJSONDoc) {
that.mergeV2Annotations(mParameter.sAnnotationJSONDoc);
}
that._interpreteMetadata(that._oModel.getServiceMetadata().dataServices);
}
} | [
"function",
"(",
"oModelReference",
",",
"mParameter",
")",
"{",
"if",
"(",
"typeof",
"mParameter",
"==",
"\"string\"",
")",
"{",
"throw",
"\"Deprecated second argument: Adjust your invocation by passing an object with a property sAnnotationJSONDoc as a second argument instead\"",
... | initialize a new object
@private | [
"initialize",
"a",
"new",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L245-L333 | train | Initializes the model | [
30522,
3853,
1006,
18168,
10244,
20974,
27235,
24413,
1010,
6131,
5400,
22828,
1007,
1063,
2065,
1006,
2828,
11253,
6131,
5400,
22828,
1027,
1027,
1000,
5164,
1000,
1007,
1063,
5466,
1000,
2139,
28139,
12921,
2117,
6685,
1024,
14171,
2115,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | examples/player/player.js | function() {
var self = this;
var display = (playlist.style.display === 'block') ? 'none' : 'block';
setTimeout(function() {
playlist.style.display = display;
}, (display === 'block') ? 0 : 500);
playlist.className = (display === 'block') ? 'fadein' : 'fadeout';
} | javascript | function() {
var self = this;
var display = (playlist.style.display === 'block') ? 'none' : 'block';
setTimeout(function() {
playlist.style.display = display;
}, (display === 'block') ? 0 : 500);
playlist.className = (display === 'block') ? 'fadein' : 'fadeout';
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"display",
"=",
"(",
"playlist",
".",
"style",
".",
"display",
"===",
"'block'",
")",
"?",
"'none'",
":",
"'block'",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"playlist",
"."... | Toggle the playlist display on/off. | [
"Toggle",
"the",
"playlist",
"display",
"on",
"/",
"off",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/player/player.js#L236-L244 | train | Set the display of the cubemap | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
4653,
1027,
1006,
2377,
9863,
1012,
2806,
1012,
4653,
1027,
1027,
1027,
1005,
3796,
1005,
1007,
1029,
1005,
3904,
1005,
1024,
1005,
3796,
1005,
1025,
2275,
7292,
5833,
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... | |
heyui/heyui | src/plugins/popper/index.js | removeEventListeners | function removeEventListeners(reference, state) {
// Remove resize event listener on window
getWindow(reference).removeEventListener('resize', state.updateBound);
// Remove scroll event listener on scroll parents
state.scrollParents.forEach(function (target) {
target.removeEventListener('scroll', state.updateBound);
});
// Reset state
state.updateBound = null;
state.scrollParents = [];
state.scrollElement = null;
state.eventsEnabled = false;
return state;
} | javascript | function removeEventListeners(reference, state) {
// Remove resize event listener on window
getWindow(reference).removeEventListener('resize', state.updateBound);
// Remove scroll event listener on scroll parents
state.scrollParents.forEach(function (target) {
target.removeEventListener('scroll', state.updateBound);
});
// Reset state
state.updateBound = null;
state.scrollParents = [];
state.scrollElement = null;
state.eventsEnabled = false;
return state;
} | [
"function",
"removeEventListeners",
"(",
"reference",
",",
"state",
")",
"{",
"// Remove resize event listener on window",
"getWindow",
"(",
"reference",
")",
".",
"removeEventListener",
"(",
"'resize'",
",",
"state",
".",
"updateBound",
")",
";",
"// Remove scroll even... | Remove event listeners used to update the popper position
@method
@memberof Popper.Utils
@private | [
"Remove",
"event",
"listeners",
"used",
"to",
"update",
"the",
"popper",
"position"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1121-L1136 | train | Remove event listeners on the window and scroll parents | [
30522,
3853,
6366,
18697,
3372,
9863,
24454,
2015,
1006,
4431,
1010,
2110,
1007,
1063,
1013,
1013,
6366,
24501,
4697,
2724,
19373,
2006,
3332,
2131,
11101,
5004,
1006,
4431,
1007,
1012,
6366,
18697,
3372,
9863,
24454,
1006,
1005,
24501,
469... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.uxap/src/sap/uxap/ThrottledTaskHelper.js | function(oOldOptions, oNewOptions) {
var oMergedOptions = jQuery.extend({}, oOldOptions, oNewOptions);
jQuery.each(oMergedOptions, function(key) {
oMergedOptions[key] = oOldOptions[key] || oNewOptions[key]; // default merge strategy is inclusive OR
});
return oMergedOptions;
} | javascript | function(oOldOptions, oNewOptions) {
var oMergedOptions = jQuery.extend({}, oOldOptions, oNewOptions);
jQuery.each(oMergedOptions, function(key) {
oMergedOptions[key] = oOldOptions[key] || oNewOptions[key]; // default merge strategy is inclusive OR
});
return oMergedOptions;
} | [
"function",
"(",
"oOldOptions",
",",
"oNewOptions",
")",
"{",
"var",
"oMergedOptions",
"=",
"jQuery",
".",
"extend",
"(",
"{",
"}",
",",
"oOldOptions",
",",
"oNewOptions",
")",
";",
"jQuery",
".",
"each",
"(",
"oMergedOptions",
",",
"function",
"(",
"key",... | Updates the task arguments
Default merge strategy is inclusive OR
@private | [
"Updates",
"the",
"task",
"arguments",
"Default",
"merge",
"strategy",
"is",
"inclusive",
"OR"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/ThrottledTaskHelper.js#L95-L103 | train | merges the given options with the old options | [
30522,
3853,
1006,
1051,
11614,
7361,
9285,
1010,
2028,
12155,
16790,
2015,
1007,
1063,
13075,
18168,
2121,
5999,
7361,
9285,
1027,
1046,
4226,
2854,
1012,
7949,
1006,
1063,
1065,
1010,
1051,
11614,
7361,
9285,
1010,
2028,
12155,
16790,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Component.js | loadComponent | function loadComponent(oConfig, mOptions) {
var sName = oConfig.name,
sUrl = oConfig.url,
oConfiguration = sap.ui.getCore().getConfiguration(),
bComponentPreload = /^(sync|async)$/.test(oConfiguration.getComponentPreload()),
vManifest = oConfig.manifest,
bManifestFirst,
sManifestUrl,
oManifest,
mModels,
mModelConfigs,
fnCallLoadComponentCallback;
function createSanitizedManifest( oRawManifestJSON, mOptions ) {
var oManifest = new Manifest( JSON.parse(JSON.stringify(oRawManifestJSON)), mOptions );
return oConfig.async ? Promise.resolve(oManifest) : oManifest;
}
// url must be a string, although registerModulePath would also accept an object
assert(!sUrl || typeof sUrl === 'string', "sUrl must be a string or undefined");
// if a component name and a URL is given, we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (sName && typeof sUrl === 'string') {
registerModulePath(sName, sUrl);
}
// set the name of this newly loaded component at the interaction measurement,
// as otherwise this would be the outer component from where it was called,
// which is not true - this component causes the load
Interaction.setStepComponent(sName);
if ( vManifest === undefined ) {
// no manifest property set, evaluate legacy properties
bManifestFirst = oConfig.manifestFirst === undefined ? oConfiguration.getManifestFirst() : !!oConfig.manifestFirst;
sManifestUrl = oConfig.manifestUrl;
// oManifest = undefined;
} else {
// in case of manifest property is set, by default we load async
if ( oConfig.async === undefined ) {
oConfig.async = true;
}
// determine the semantic of the manifest property
bManifestFirst = !!vManifest;
sManifestUrl = vManifest && typeof vManifest === 'string' ? vManifest : undefined;
oManifest = vManifest && typeof vManifest === 'object' ? createSanitizedManifest(vManifest, {url: oConfig && oConfig.altManifestUrl}) : undefined;
}
// if we find a manifest URL in the configuration
// we will load the manifest from the specified URL (sync or async)
if (!oManifest && sManifestUrl) {
oManifest = Manifest.load({
manifestUrl: sManifestUrl,
componentName: sName,
async: oConfig.async
});
}
// once the manifest is available we extract the controller name
if (oManifest && !oConfig.async) {
sName = oManifest.getComponentName();
// if a component name and a URL is given, we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (sName && typeof sUrl === 'string') {
registerModulePath(sName, sUrl);
}
}
// Only if loading a manifest is done asynchronously we will skip the
// name check because this will be done once the manifest is loaded!
if (!(oManifest && oConfig.async)) {
// check for an existing name
if (!sName) {
throw new Error("The name of the component is undefined.");
}
// check the type of the name
assert(typeof sName === 'string', "sName must be a string");
}
// in case of loading the manifest first by configuration we need to
// wait until the registration of the module path is done if needed and
// then we can use the standard capabilities of the framework to resolve
// the Components' modules namespace
if (bManifestFirst && !oManifest) {
oManifest = Manifest.load({
manifestUrl: getManifestUrl(sName),
componentName: sName,
async: oConfig.async,
failOnError: false
});
}
function getControllerModuleName() {
return (sName + ".Component").replace(/\./g, "/");
}
function prepareControllerClass(oClass) {
var sController = sName + '.Component';
if (!oClass) {
var sMsg = "The specified component controller '" + sController + "' could not be found!";
if (mOptions.failOnError) {
throw new Error(sMsg);
} else {
Log.warning(sMsg);
}
}
if (oManifest) {
// create the proxy metadata object
var oMetadataProxy = createMetadataProxy(oClass.getMetadata(), oManifest);
// create the proxy class for passing the manifest
var oClassProxy = function() {
// create a copy of arguments for local modification
// and later handover to Component constructor
var args = Array.prototype.slice.call(arguments);
// inject the manifest to the settings object
var mSettings;
if (args.length === 0 || typeof args[0] === "object") {
mSettings = args[0] = args[0] || {};
} else if (typeof args[0] === "string") {
mSettings = args[1] = args[1] || {};
}
mSettings._metadataProxy = oMetadataProxy;
// mixin created "models" into "mSettings"
if (mModels) {
mSettings._manifestModels = mModels;
}
// call the original constructor of the component class
var oInstance = Object.create(oClass.prototype);
oClass.apply(oInstance, args);
return oInstance;
};
// overload the getMetadata function
oClassProxy.getMetadata = function() {
return oMetadataProxy;
};
// overload the extend function
oClassProxy.extend = function() {
throw new Error("Extending Components created by Manifest is not supported!");
};
return oClassProxy;
} else {
return oClass;
}
}
/*
* Process .url and .lazy options.
* For preloadBundles, lazy will be ignored
*/
function processOptions(vObj, bIgnoreLazy) {
assert(
(typeof vObj === 'string' && vObj) ||
(typeof vObj === 'object' && typeof vObj.name === 'string' && vObj.name),
"reference either must be a non-empty string or an object with a non-empty 'name' and an optional 'url' property");
if ( typeof vObj === 'object' ) {
if ( vObj.url ) {
registerModulePath(vObj.name, vObj.url);
}
return (vObj.lazy && bIgnoreLazy !== true) ? undefined : vObj.name; // expl. check for true to allow usage in Array.prototype.map below
}
return vObj;
}
function preload(sComponentName, bAsync) {
var sController = sComponentName + '.Component',
http2 = sap.ui.getCore().getConfiguration().getDepCache(),
sPreloadName,
oTransitiveDependencies,
aLibs;
// only load the Component-preload file if the Component module is not yet available
if ( bComponentPreload && sComponentName != null && !sap.ui.loader._.getModuleState(sController.replace(/\./g, "/") + ".js") ) {
if ( bAsync ) {
// check whether component controller is included in a library preload
oTransitiveDependencies = VersionInfo._getTransitiveDependencyForComponent(sComponentName);
if (oTransitiveDependencies) {
aLibs = [oTransitiveDependencies.library];
// add all dependencies to aLibs
Array.prototype.push.apply(aLibs, oTransitiveDependencies.dependencies);
// load library preload for every transitive dependency
return sap.ui.getCore().loadLibraries( aLibs, { preloadOnly: true } );
} else {
sPreloadName = sController.replace(/\./g, "/") + (http2 ? '-h2-preload.js' : '-preload.js'); // URN
return sap.ui.loader._.loadJSResourceAsync(sPreloadName, true);
}
}
try {
sPreloadName = sController + '-preload'; // Module name
sap.ui.requireSync(sPreloadName.replace(/\./g, "/"));
} catch (e) {
Log.warning("couldn't preload component from " + sPreloadName + ": " + ((e && e.message) || e));
}
} else if (bAsync) {
return Promise.resolve();
}
}
function preloadDependencies(sComponentName, oManifest, bAsync) {
var aPromises = [];
var fnCollect = bAsync ? function(oPromise) {
aPromises.push(oPromise);
} : function() {};
// lookup the resource roots and call the register API
oManifest.defineResourceRoots();
// lookup the required libraries
var mLibs = oManifest.getEntry("/sap.ui5/dependencies/libs");
if (mLibs) {
var aLibs = [];
// filter the lazy libs
for (var sLibName in mLibs) {
if (!mLibs[sLibName].lazy) {
aLibs.push(sLibName);
}
}
if (aLibs.length > 0) {
Log.info("Component \"" + sComponentName + "\" is loading libraries: \"" + aLibs.join(", ") + "\"");
fnCollect(sap.ui.getCore().loadLibraries(aLibs, {
async: bAsync
}));
}
}
// lookup the extended component and preload it
var sExtendedComponent = oManifest.getEntry("/sap.ui5/extends/component");
if (sExtendedComponent) {
fnCollect(preload(sExtendedComponent, bAsync));
}
// lookup the non-lazy components from component dependencies
var aComponents = [];
var mComponents = oManifest.getEntry("/sap.ui5/dependencies/components");
if (mComponents) {
for (var sComponentName in mComponents) {
// filter the lazy components
if (!mComponents[sComponentName].lazy) {
aComponents.push(sComponentName);
}
}
}
// lookup the non-lazy components from component usages
var mUsages = oManifest.getEntry("/sap.ui5/componentUsages");
if (mUsages) {
// filter the lazy usages
for (var sUsage in mUsages) {
// default value is true, so explicit check for false
if (mUsages[sUsage].lazy === false && aComponents.indexOf(mUsages[sUsage].name) === -1) {
aComponents.push(mUsages[sUsage].name);
}
}
}
// preload the collected components
if (aComponents.length > 0) {
aComponents.forEach(function(sComponentName) {
fnCollect(preload(sComponentName, bAsync));
});
}
return bAsync ? Promise.all(aPromises) : undefined;
}
if ( oConfig.async ) {
// trigger loading of libraries and component preloads and collect the given promises
var hints = oConfig.asyncHints || {},
promises = [],
reflect = function(oPromise) {
// In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object.
oPromise = oPromise.then(
function(v) {
return {
result: v,
rejected: false
};
},
function(v) {
return {
result: v,
rejected: true
};
}
);
return oPromise;
},
collect = function(oPromise) {
if ( oPromise ) {
promises.push(reflect(oPromise));
}
},
identity = function($) { return $; },
phase1Preloads,
libs;
if (oManifest && mOptions.createModels) {
collect(oManifest.then(function(oManifest) {
// Calculate configurations of preloaded models once the manifest is available
mModelConfigs = getPreloadModelConfigsFromManifest(oManifest, oConfig.componentData, hints.cacheTokens);
return oManifest;
}).then(function(oManifest) {
// Create preloaded models directly after the manifest has been loaded
if (Object.keys(mModelConfigs.afterManifest).length > 0) {
mModels = Component._createManifestModels(mModelConfigs.afterManifest, oManifest.getComponentName());
}
return oManifest;
}));
}
phase1Preloads = [];
// load any required preload bundles
if ( Array.isArray(hints.preloadBundles) ) {
hints.preloadBundles.forEach(function(vBundle) {
//TODO: global jquery call found
phase1Preloads.push(
sap.ui.loader._.loadJSResourceAsync(processOptions(vBundle, /* ignoreLazy */ true), /* ignoreErrors */ true) );
});
}
// preload any libraries
if ( Array.isArray(hints.libs) ) {
libs = hints.libs.map(processOptions).filter(identity);
phase1Preloads.push(
sap.ui.getCore().loadLibraries( libs, { preloadOnly: true } )
);
}
// sync preloadBundles and preloads of libraries first before requiring the libs
// Note: component preloads are assumed to be always independent from libs
// therefore those requests are not synchronized with the require calls for the libs
phase1Preloads = Promise.all( phase1Preloads );
if ( libs && !mOptions.preloadOnly ) {
phase1Preloads = phase1Preloads.then( function() {
return sap.ui.getCore().loadLibraries( libs );
});
}
collect( phase1Preloads );
// preload the component itself
if (!oManifest) {
collect(preload(sName, true));
} else {
// in case of manifest first we need to load the manifest
// to know the component name and preload the component itself
collect(oManifest.then(function(oManifest) {
var sComponentName = oManifest.getComponentName();
// if a URL is given we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (typeof sUrl === 'string') {
registerModulePath(sComponentName, sUrl);
}
// preload the component
return preload(sComponentName, true).then(function() {
// after preload is finished, load the i18n resource
return oManifest._processI18n(true);
}).then(function() {
// after i18n resource is finished, the resource models from the manifest are loaded
if (!mOptions.createModels) {
return null;
}
var aResourceModelNames = Object.keys(mModelConfigs.afterPreload);
if (aResourceModelNames.length === 0) {
return null;
}
// if there are resource models to be loaded, load the resource bundle async first.
// a promise is returned which resolves after all resource models are loaded
return new Promise(function(resolve, reject) {
// load the sap.ui.model/resource/ResourceModel class async if it's not loaded yet
sap.ui.require(["sap/ui/model/resource/ResourceModel"], function(ResourceModel) {
// Directly resolve as otherwise uncaught exceptions can't be handled
resolve(ResourceModel);
}, reject);
}).then(function(ResourceModel) {
function loadResourceBundle(sModelName) {
var mModelConfig = mModelConfigs.afterPreload[sModelName];
if (Array.isArray(mModelConfig.settings) && mModelConfig.settings.length > 0) {
var mModelSettings = mModelConfig.settings[0]; // first argument is the config map
return ResourceModel.loadResourceBundle(mModelSettings, true).then(function(oResourceBundle) {
// Extend the model settings with the preloaded bundle so that no sync request
// is triggered once the model gets created
mModelSettings.bundle = oResourceBundle;
}, function(err) {
Log.error("Component Manifest: Could not preload ResourceBundle for ResourceModel. " +
"The model will be skipped here and tried to be created on Component initialization.",
"[\"sap.ui5\"][\"models\"][\"" + sModelName + "\"]", sComponentName);
Log.error(err);
// If the resource bundle can't be loaded, the resource model will be skipped.
// But once the component instance gets created, the model will be tried to created again.
delete mModelConfigs.afterPreload[sModelName];
});
} else {
// Can't load bundle as no settings are defined.
// Should not happen as those models won't be part of "mModelConfigs.afterPreload"
return Promise.resolve();
}
}
// Load all ResourceBundles for all models in parallel
return Promise.all(aResourceModelNames.map(loadResourceBundle)).then(function() {
if (Object.keys(mModelConfigs.afterPreload).length > 0) {
var mResourceModels = Component._createManifestModels(mModelConfigs.afterPreload, oManifest.getComponentName());
if (!mModels) {
mModels = {};
}
for (var sKey in mResourceModels) {
mModels[sKey] = mResourceModels[sKey];
}
}
});
});
});
}));
fnCallLoadComponentCallback = function(oLoadedManifest) {
// if a callback is registered to the component load, call it with the configuration
if (typeof Component._fnLoadComponentCallback === "function") {
// secure configuration and manifest from manipulation
var oConfigCopy = jQuery.extend(true, {}, oConfig);
var oManifestCopy = jQuery.extend(true, {}, oLoadedManifest);
// trigger the callback with a copy of its required data
// do not await any result from the callback nor stop component loading on an occurring error
try {
Component._fnLoadComponentCallback(oConfigCopy, oManifestCopy);
} catch (oError) {
Log.error("Callback for loading the component \"" + oManifest.getComponentName() +
"\" run into an error. The callback was skipped and the component loading resumed.",
oError, "sap.ui.core.Component");
}
}
};
}
// if a hint about "used" components is given, preload those components
if ( hints.components ) {
jQuery.each(hints.components, function(i, vComp) {
collect(preload(processOptions(vComp), true));
});
}
// combine given promises
return Promise.all(promises).then(function(v) {
// If any promise is rejected, a new rejected Promise is forwarded on the chain which leads to the catch clause
var aResults = [],
bErrorFound = false,
vError;
bErrorFound = v.some(function(oResult) {
if (oResult && oResult.rejected) {
vError = oResult.result;
return true;
}
aResults.push(oResult.result);
});
if (bErrorFound) {
return Promise.reject(vError);
}
return aResults;
}).then(function (v) {
// after all promises including the loading of dependent libs have been resolved
// pass the manifest to the callback function in case the manifest is present and a callback was set
if (oManifest && fnCallLoadComponentCallback) {
oManifest.then(fnCallLoadComponentCallback);
}
return v;
}).then(function(v) {
Log.debug("Component.load: all promises fulfilled, then " + v);
if (oManifest) {
return oManifest.then(function(oLoadedManifest) {
// store the loaded manifest in the oManifest variable
// which is used for the scope constructor function
oManifest = oLoadedManifest;
// read the component name from the manifest and
// preload the dependencies defined in the manifest
sName = oManifest.getComponentName();
return preloadDependencies(sName, oManifest, true);
});
} else {
return v;
}
}).then(function() {
if ( mOptions.preloadOnly ) {
return true;
}
return new Promise(function(resolve, reject) {
// asynchronously require component controller class
sap.ui.require( [ getControllerModuleName() ], function(oClass) {
// Directly resolve as otherwise uncaught exceptions can't be handled
resolve(oClass);
}, reject);
}).then(function(oClass) {
var oMetadata = oClass.getMetadata();
var sName = oMetadata.getComponentName();
var sDefaultManifestUrl = getManifestUrl(sName);
var pLoaded;
// Check if we loaded the manifest.json from the default location
// In this case it can be directly passed to its metadata class to prevent an additional request
if (oManifest && typeof vManifest !== "object" && (typeof sManifestUrl === "undefined" || sManifestUrl === sDefaultManifestUrl)) {
pLoaded = loadManifests(oMetadata, oManifest);
} else {
pLoaded = loadManifests(oMetadata);
}
return pLoaded.then(function() {
// prepare the loaded class and resolve with it
return prepareControllerClass(oClass);
});
});
}).then(function(oControllerClass) {
if (!oManifest) {
return oControllerClass;
}
// Load all modules derived from "/sap.ui5" manifest entries asynchronously (if underlaying loader supports it)
// Note: this does not load modules declared / derived from parent manifests (e.g. extension scenario)
var aModuleNames = [];
// lookup rootView class
var sRootViewType;
var oRootView = oManifest.getEntry("/sap.ui5/rootView");
if (typeof oRootView === "string") {
// String as rootView defaults to ViewType XML
// See: UIComponent#createContent and UIComponentMetadata#_convertLegacyMetadata
sRootViewType = "XML";
} else if (oRootView && typeof oRootView === "object" && oRootView.type) {
sRootViewType = oRootView.type;
}
if (sRootViewType && ViewType[sRootViewType]) {
var sViewClass = "sap/ui/core/mvc/" + ViewType[sRootViewType] + "View";
aModuleNames.push(sViewClass);
}
// lookup router class
var oRouting = oManifest.getEntry("/sap.ui5/routing");
if (oRouting && oRouting.routes) {
var sRouterClass = oManifest.getEntry("/sap.ui5/routing/config/routerClass") || "sap.ui.core.routing.Router";
var sRouterClassModule = sRouterClass.replace(/\./g, "/");
aModuleNames.push(sRouterClassModule);
}
// lookup model classes
var mManifestModels = jQuery.extend(true, {}, oManifest.getEntry("/sap.ui5/models"));
var mManifestDataSources = jQuery.extend(true, {}, oManifest.getEntry("/sap.app/dataSources"));
var mAllModelConfigurations = Component._createManifestModelConfigurations({
models: mManifestModels,
dataSources: mManifestDataSources,
manifest: oManifest,
cacheTokens: hints.cacheTokens
});
for (var mModelName in mAllModelConfigurations) {
if (!mAllModelConfigurations.hasOwnProperty(mModelName)) {
continue;
}
var oModelConfig = mAllModelConfigurations[mModelName];
if (!oModelConfig.type) {
continue;
}
var sModuleName = oModelConfig.type.replace(/\./g, "/");
if (aModuleNames.indexOf(sModuleName) === -1) {
aModuleNames.push(sModuleName);
}
}
if (aModuleNames.length > 0) {
return Promise.all(aModuleNames.map(function(sModuleName) {
// All modules are required separately to have a better error logging.
// This "preloading" is done for optimization to enable async loading
// in case the underlaying loader supports it. If loading fails, the component
// should still be created which might fail once the required module is actually used / loaded
return new Promise(function(resolve, reject) {
var bResolved = false;
function logErrorAndResolve(err) {
if (bResolved) {
return;
}
Log.warning("Can not preload module \"" + sModuleName + "\". " +
"This will most probably cause an error once the module is used later on.",
oManifest.getComponentName(), "sap.ui.core.Component");
Log.warning(err);
bResolved = true;
resolve();
}
sap.ui.require([sModuleName], resolve, logErrorAndResolve);
});
})).then(function() {
return oControllerClass;
});
} else {
return oControllerClass;
}
}).then(function(oControllerClass) {
var waitFor = mOptions.waitFor;
if (waitFor) {
// when waitFor Promises have been specified we also wait for
// them before we call the component constructor
var aPromises = Array.isArray(waitFor) ? waitFor : [ waitFor ];
return Promise.all(aPromises).then(function() {
return oControllerClass;
});
}
return oControllerClass;
}).catch(function(vError) {
// handle preload errors
// destroy "preloaded" models in case of any error to prevent memory leaks
if (mModels) {
for (var sName in mModels) {
var oModel = mModels[sName];
if (oModel && typeof oModel.destroy === "function") {
oModel.destroy();
}
}
}
// re-throw error to hand it over to the application
throw vError;
});
}
if (oManifest) {
preloadDependencies(sName, oManifest);
}
preload(sName);
// synchronously load the controller class, prepare and return it
return prepareControllerClass(
sap.ui.requireSync( getControllerModuleName() )
);
} | javascript | function loadComponent(oConfig, mOptions) {
var sName = oConfig.name,
sUrl = oConfig.url,
oConfiguration = sap.ui.getCore().getConfiguration(),
bComponentPreload = /^(sync|async)$/.test(oConfiguration.getComponentPreload()),
vManifest = oConfig.manifest,
bManifestFirst,
sManifestUrl,
oManifest,
mModels,
mModelConfigs,
fnCallLoadComponentCallback;
function createSanitizedManifest( oRawManifestJSON, mOptions ) {
var oManifest = new Manifest( JSON.parse(JSON.stringify(oRawManifestJSON)), mOptions );
return oConfig.async ? Promise.resolve(oManifest) : oManifest;
}
// url must be a string, although registerModulePath would also accept an object
assert(!sUrl || typeof sUrl === 'string', "sUrl must be a string or undefined");
// if a component name and a URL is given, we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (sName && typeof sUrl === 'string') {
registerModulePath(sName, sUrl);
}
// set the name of this newly loaded component at the interaction measurement,
// as otherwise this would be the outer component from where it was called,
// which is not true - this component causes the load
Interaction.setStepComponent(sName);
if ( vManifest === undefined ) {
// no manifest property set, evaluate legacy properties
bManifestFirst = oConfig.manifestFirst === undefined ? oConfiguration.getManifestFirst() : !!oConfig.manifestFirst;
sManifestUrl = oConfig.manifestUrl;
// oManifest = undefined;
} else {
// in case of manifest property is set, by default we load async
if ( oConfig.async === undefined ) {
oConfig.async = true;
}
// determine the semantic of the manifest property
bManifestFirst = !!vManifest;
sManifestUrl = vManifest && typeof vManifest === 'string' ? vManifest : undefined;
oManifest = vManifest && typeof vManifest === 'object' ? createSanitizedManifest(vManifest, {url: oConfig && oConfig.altManifestUrl}) : undefined;
}
// if we find a manifest URL in the configuration
// we will load the manifest from the specified URL (sync or async)
if (!oManifest && sManifestUrl) {
oManifest = Manifest.load({
manifestUrl: sManifestUrl,
componentName: sName,
async: oConfig.async
});
}
// once the manifest is available we extract the controller name
if (oManifest && !oConfig.async) {
sName = oManifest.getComponentName();
// if a component name and a URL is given, we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (sName && typeof sUrl === 'string') {
registerModulePath(sName, sUrl);
}
}
// Only if loading a manifest is done asynchronously we will skip the
// name check because this will be done once the manifest is loaded!
if (!(oManifest && oConfig.async)) {
// check for an existing name
if (!sName) {
throw new Error("The name of the component is undefined.");
}
// check the type of the name
assert(typeof sName === 'string', "sName must be a string");
}
// in case of loading the manifest first by configuration we need to
// wait until the registration of the module path is done if needed and
// then we can use the standard capabilities of the framework to resolve
// the Components' modules namespace
if (bManifestFirst && !oManifest) {
oManifest = Manifest.load({
manifestUrl: getManifestUrl(sName),
componentName: sName,
async: oConfig.async,
failOnError: false
});
}
function getControllerModuleName() {
return (sName + ".Component").replace(/\./g, "/");
}
function prepareControllerClass(oClass) {
var sController = sName + '.Component';
if (!oClass) {
var sMsg = "The specified component controller '" + sController + "' could not be found!";
if (mOptions.failOnError) {
throw new Error(sMsg);
} else {
Log.warning(sMsg);
}
}
if (oManifest) {
// create the proxy metadata object
var oMetadataProxy = createMetadataProxy(oClass.getMetadata(), oManifest);
// create the proxy class for passing the manifest
var oClassProxy = function() {
// create a copy of arguments for local modification
// and later handover to Component constructor
var args = Array.prototype.slice.call(arguments);
// inject the manifest to the settings object
var mSettings;
if (args.length === 0 || typeof args[0] === "object") {
mSettings = args[0] = args[0] || {};
} else if (typeof args[0] === "string") {
mSettings = args[1] = args[1] || {};
}
mSettings._metadataProxy = oMetadataProxy;
// mixin created "models" into "mSettings"
if (mModels) {
mSettings._manifestModels = mModels;
}
// call the original constructor of the component class
var oInstance = Object.create(oClass.prototype);
oClass.apply(oInstance, args);
return oInstance;
};
// overload the getMetadata function
oClassProxy.getMetadata = function() {
return oMetadataProxy;
};
// overload the extend function
oClassProxy.extend = function() {
throw new Error("Extending Components created by Manifest is not supported!");
};
return oClassProxy;
} else {
return oClass;
}
}
/*
* Process .url and .lazy options.
* For preloadBundles, lazy will be ignored
*/
function processOptions(vObj, bIgnoreLazy) {
assert(
(typeof vObj === 'string' && vObj) ||
(typeof vObj === 'object' && typeof vObj.name === 'string' && vObj.name),
"reference either must be a non-empty string or an object with a non-empty 'name' and an optional 'url' property");
if ( typeof vObj === 'object' ) {
if ( vObj.url ) {
registerModulePath(vObj.name, vObj.url);
}
return (vObj.lazy && bIgnoreLazy !== true) ? undefined : vObj.name; // expl. check for true to allow usage in Array.prototype.map below
}
return vObj;
}
function preload(sComponentName, bAsync) {
var sController = sComponentName + '.Component',
http2 = sap.ui.getCore().getConfiguration().getDepCache(),
sPreloadName,
oTransitiveDependencies,
aLibs;
// only load the Component-preload file if the Component module is not yet available
if ( bComponentPreload && sComponentName != null && !sap.ui.loader._.getModuleState(sController.replace(/\./g, "/") + ".js") ) {
if ( bAsync ) {
// check whether component controller is included in a library preload
oTransitiveDependencies = VersionInfo._getTransitiveDependencyForComponent(sComponentName);
if (oTransitiveDependencies) {
aLibs = [oTransitiveDependencies.library];
// add all dependencies to aLibs
Array.prototype.push.apply(aLibs, oTransitiveDependencies.dependencies);
// load library preload for every transitive dependency
return sap.ui.getCore().loadLibraries( aLibs, { preloadOnly: true } );
} else {
sPreloadName = sController.replace(/\./g, "/") + (http2 ? '-h2-preload.js' : '-preload.js'); // URN
return sap.ui.loader._.loadJSResourceAsync(sPreloadName, true);
}
}
try {
sPreloadName = sController + '-preload'; // Module name
sap.ui.requireSync(sPreloadName.replace(/\./g, "/"));
} catch (e) {
Log.warning("couldn't preload component from " + sPreloadName + ": " + ((e && e.message) || e));
}
} else if (bAsync) {
return Promise.resolve();
}
}
function preloadDependencies(sComponentName, oManifest, bAsync) {
var aPromises = [];
var fnCollect = bAsync ? function(oPromise) {
aPromises.push(oPromise);
} : function() {};
// lookup the resource roots and call the register API
oManifest.defineResourceRoots();
// lookup the required libraries
var mLibs = oManifest.getEntry("/sap.ui5/dependencies/libs");
if (mLibs) {
var aLibs = [];
// filter the lazy libs
for (var sLibName in mLibs) {
if (!mLibs[sLibName].lazy) {
aLibs.push(sLibName);
}
}
if (aLibs.length > 0) {
Log.info("Component \"" + sComponentName + "\" is loading libraries: \"" + aLibs.join(", ") + "\"");
fnCollect(sap.ui.getCore().loadLibraries(aLibs, {
async: bAsync
}));
}
}
// lookup the extended component and preload it
var sExtendedComponent = oManifest.getEntry("/sap.ui5/extends/component");
if (sExtendedComponent) {
fnCollect(preload(sExtendedComponent, bAsync));
}
// lookup the non-lazy components from component dependencies
var aComponents = [];
var mComponents = oManifest.getEntry("/sap.ui5/dependencies/components");
if (mComponents) {
for (var sComponentName in mComponents) {
// filter the lazy components
if (!mComponents[sComponentName].lazy) {
aComponents.push(sComponentName);
}
}
}
// lookup the non-lazy components from component usages
var mUsages = oManifest.getEntry("/sap.ui5/componentUsages");
if (mUsages) {
// filter the lazy usages
for (var sUsage in mUsages) {
// default value is true, so explicit check for false
if (mUsages[sUsage].lazy === false && aComponents.indexOf(mUsages[sUsage].name) === -1) {
aComponents.push(mUsages[sUsage].name);
}
}
}
// preload the collected components
if (aComponents.length > 0) {
aComponents.forEach(function(sComponentName) {
fnCollect(preload(sComponentName, bAsync));
});
}
return bAsync ? Promise.all(aPromises) : undefined;
}
if ( oConfig.async ) {
// trigger loading of libraries and component preloads and collect the given promises
var hints = oConfig.asyncHints || {},
promises = [],
reflect = function(oPromise) {
// In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object.
oPromise = oPromise.then(
function(v) {
return {
result: v,
rejected: false
};
},
function(v) {
return {
result: v,
rejected: true
};
}
);
return oPromise;
},
collect = function(oPromise) {
if ( oPromise ) {
promises.push(reflect(oPromise));
}
},
identity = function($) { return $; },
phase1Preloads,
libs;
if (oManifest && mOptions.createModels) {
collect(oManifest.then(function(oManifest) {
// Calculate configurations of preloaded models once the manifest is available
mModelConfigs = getPreloadModelConfigsFromManifest(oManifest, oConfig.componentData, hints.cacheTokens);
return oManifest;
}).then(function(oManifest) {
// Create preloaded models directly after the manifest has been loaded
if (Object.keys(mModelConfigs.afterManifest).length > 0) {
mModels = Component._createManifestModels(mModelConfigs.afterManifest, oManifest.getComponentName());
}
return oManifest;
}));
}
phase1Preloads = [];
// load any required preload bundles
if ( Array.isArray(hints.preloadBundles) ) {
hints.preloadBundles.forEach(function(vBundle) {
//TODO: global jquery call found
phase1Preloads.push(
sap.ui.loader._.loadJSResourceAsync(processOptions(vBundle, /* ignoreLazy */ true), /* ignoreErrors */ true) );
});
}
// preload any libraries
if ( Array.isArray(hints.libs) ) {
libs = hints.libs.map(processOptions).filter(identity);
phase1Preloads.push(
sap.ui.getCore().loadLibraries( libs, { preloadOnly: true } )
);
}
// sync preloadBundles and preloads of libraries first before requiring the libs
// Note: component preloads are assumed to be always independent from libs
// therefore those requests are not synchronized with the require calls for the libs
phase1Preloads = Promise.all( phase1Preloads );
if ( libs && !mOptions.preloadOnly ) {
phase1Preloads = phase1Preloads.then( function() {
return sap.ui.getCore().loadLibraries( libs );
});
}
collect( phase1Preloads );
// preload the component itself
if (!oManifest) {
collect(preload(sName, true));
} else {
// in case of manifest first we need to load the manifest
// to know the component name and preload the component itself
collect(oManifest.then(function(oManifest) {
var sComponentName = oManifest.getComponentName();
// if a URL is given we register this URL for the name of the component:
// the name is the package in which the component is located (dot separated)
if (typeof sUrl === 'string') {
registerModulePath(sComponentName, sUrl);
}
// preload the component
return preload(sComponentName, true).then(function() {
// after preload is finished, load the i18n resource
return oManifest._processI18n(true);
}).then(function() {
// after i18n resource is finished, the resource models from the manifest are loaded
if (!mOptions.createModels) {
return null;
}
var aResourceModelNames = Object.keys(mModelConfigs.afterPreload);
if (aResourceModelNames.length === 0) {
return null;
}
// if there are resource models to be loaded, load the resource bundle async first.
// a promise is returned which resolves after all resource models are loaded
return new Promise(function(resolve, reject) {
// load the sap.ui.model/resource/ResourceModel class async if it's not loaded yet
sap.ui.require(["sap/ui/model/resource/ResourceModel"], function(ResourceModel) {
// Directly resolve as otherwise uncaught exceptions can't be handled
resolve(ResourceModel);
}, reject);
}).then(function(ResourceModel) {
function loadResourceBundle(sModelName) {
var mModelConfig = mModelConfigs.afterPreload[sModelName];
if (Array.isArray(mModelConfig.settings) && mModelConfig.settings.length > 0) {
var mModelSettings = mModelConfig.settings[0]; // first argument is the config map
return ResourceModel.loadResourceBundle(mModelSettings, true).then(function(oResourceBundle) {
// Extend the model settings with the preloaded bundle so that no sync request
// is triggered once the model gets created
mModelSettings.bundle = oResourceBundle;
}, function(err) {
Log.error("Component Manifest: Could not preload ResourceBundle for ResourceModel. " +
"The model will be skipped here and tried to be created on Component initialization.",
"[\"sap.ui5\"][\"models\"][\"" + sModelName + "\"]", sComponentName);
Log.error(err);
// If the resource bundle can't be loaded, the resource model will be skipped.
// But once the component instance gets created, the model will be tried to created again.
delete mModelConfigs.afterPreload[sModelName];
});
} else {
// Can't load bundle as no settings are defined.
// Should not happen as those models won't be part of "mModelConfigs.afterPreload"
return Promise.resolve();
}
}
// Load all ResourceBundles for all models in parallel
return Promise.all(aResourceModelNames.map(loadResourceBundle)).then(function() {
if (Object.keys(mModelConfigs.afterPreload).length > 0) {
var mResourceModels = Component._createManifestModels(mModelConfigs.afterPreload, oManifest.getComponentName());
if (!mModels) {
mModels = {};
}
for (var sKey in mResourceModels) {
mModels[sKey] = mResourceModels[sKey];
}
}
});
});
});
}));
fnCallLoadComponentCallback = function(oLoadedManifest) {
// if a callback is registered to the component load, call it with the configuration
if (typeof Component._fnLoadComponentCallback === "function") {
// secure configuration and manifest from manipulation
var oConfigCopy = jQuery.extend(true, {}, oConfig);
var oManifestCopy = jQuery.extend(true, {}, oLoadedManifest);
// trigger the callback with a copy of its required data
// do not await any result from the callback nor stop component loading on an occurring error
try {
Component._fnLoadComponentCallback(oConfigCopy, oManifestCopy);
} catch (oError) {
Log.error("Callback for loading the component \"" + oManifest.getComponentName() +
"\" run into an error. The callback was skipped and the component loading resumed.",
oError, "sap.ui.core.Component");
}
}
};
}
// if a hint about "used" components is given, preload those components
if ( hints.components ) {
jQuery.each(hints.components, function(i, vComp) {
collect(preload(processOptions(vComp), true));
});
}
// combine given promises
return Promise.all(promises).then(function(v) {
// If any promise is rejected, a new rejected Promise is forwarded on the chain which leads to the catch clause
var aResults = [],
bErrorFound = false,
vError;
bErrorFound = v.some(function(oResult) {
if (oResult && oResult.rejected) {
vError = oResult.result;
return true;
}
aResults.push(oResult.result);
});
if (bErrorFound) {
return Promise.reject(vError);
}
return aResults;
}).then(function (v) {
// after all promises including the loading of dependent libs have been resolved
// pass the manifest to the callback function in case the manifest is present and a callback was set
if (oManifest && fnCallLoadComponentCallback) {
oManifest.then(fnCallLoadComponentCallback);
}
return v;
}).then(function(v) {
Log.debug("Component.load: all promises fulfilled, then " + v);
if (oManifest) {
return oManifest.then(function(oLoadedManifest) {
// store the loaded manifest in the oManifest variable
// which is used for the scope constructor function
oManifest = oLoadedManifest;
// read the component name from the manifest and
// preload the dependencies defined in the manifest
sName = oManifest.getComponentName();
return preloadDependencies(sName, oManifest, true);
});
} else {
return v;
}
}).then(function() {
if ( mOptions.preloadOnly ) {
return true;
}
return new Promise(function(resolve, reject) {
// asynchronously require component controller class
sap.ui.require( [ getControllerModuleName() ], function(oClass) {
// Directly resolve as otherwise uncaught exceptions can't be handled
resolve(oClass);
}, reject);
}).then(function(oClass) {
var oMetadata = oClass.getMetadata();
var sName = oMetadata.getComponentName();
var sDefaultManifestUrl = getManifestUrl(sName);
var pLoaded;
// Check if we loaded the manifest.json from the default location
// In this case it can be directly passed to its metadata class to prevent an additional request
if (oManifest && typeof vManifest !== "object" && (typeof sManifestUrl === "undefined" || sManifestUrl === sDefaultManifestUrl)) {
pLoaded = loadManifests(oMetadata, oManifest);
} else {
pLoaded = loadManifests(oMetadata);
}
return pLoaded.then(function() {
// prepare the loaded class and resolve with it
return prepareControllerClass(oClass);
});
});
}).then(function(oControllerClass) {
if (!oManifest) {
return oControllerClass;
}
// Load all modules derived from "/sap.ui5" manifest entries asynchronously (if underlaying loader supports it)
// Note: this does not load modules declared / derived from parent manifests (e.g. extension scenario)
var aModuleNames = [];
// lookup rootView class
var sRootViewType;
var oRootView = oManifest.getEntry("/sap.ui5/rootView");
if (typeof oRootView === "string") {
// String as rootView defaults to ViewType XML
// See: UIComponent#createContent and UIComponentMetadata#_convertLegacyMetadata
sRootViewType = "XML";
} else if (oRootView && typeof oRootView === "object" && oRootView.type) {
sRootViewType = oRootView.type;
}
if (sRootViewType && ViewType[sRootViewType]) {
var sViewClass = "sap/ui/core/mvc/" + ViewType[sRootViewType] + "View";
aModuleNames.push(sViewClass);
}
// lookup router class
var oRouting = oManifest.getEntry("/sap.ui5/routing");
if (oRouting && oRouting.routes) {
var sRouterClass = oManifest.getEntry("/sap.ui5/routing/config/routerClass") || "sap.ui.core.routing.Router";
var sRouterClassModule = sRouterClass.replace(/\./g, "/");
aModuleNames.push(sRouterClassModule);
}
// lookup model classes
var mManifestModels = jQuery.extend(true, {}, oManifest.getEntry("/sap.ui5/models"));
var mManifestDataSources = jQuery.extend(true, {}, oManifest.getEntry("/sap.app/dataSources"));
var mAllModelConfigurations = Component._createManifestModelConfigurations({
models: mManifestModels,
dataSources: mManifestDataSources,
manifest: oManifest,
cacheTokens: hints.cacheTokens
});
for (var mModelName in mAllModelConfigurations) {
if (!mAllModelConfigurations.hasOwnProperty(mModelName)) {
continue;
}
var oModelConfig = mAllModelConfigurations[mModelName];
if (!oModelConfig.type) {
continue;
}
var sModuleName = oModelConfig.type.replace(/\./g, "/");
if (aModuleNames.indexOf(sModuleName) === -1) {
aModuleNames.push(sModuleName);
}
}
if (aModuleNames.length > 0) {
return Promise.all(aModuleNames.map(function(sModuleName) {
// All modules are required separately to have a better error logging.
// This "preloading" is done for optimization to enable async loading
// in case the underlaying loader supports it. If loading fails, the component
// should still be created which might fail once the required module is actually used / loaded
return new Promise(function(resolve, reject) {
var bResolved = false;
function logErrorAndResolve(err) {
if (bResolved) {
return;
}
Log.warning("Can not preload module \"" + sModuleName + "\". " +
"This will most probably cause an error once the module is used later on.",
oManifest.getComponentName(), "sap.ui.core.Component");
Log.warning(err);
bResolved = true;
resolve();
}
sap.ui.require([sModuleName], resolve, logErrorAndResolve);
});
})).then(function() {
return oControllerClass;
});
} else {
return oControllerClass;
}
}).then(function(oControllerClass) {
var waitFor = mOptions.waitFor;
if (waitFor) {
// when waitFor Promises have been specified we also wait for
// them before we call the component constructor
var aPromises = Array.isArray(waitFor) ? waitFor : [ waitFor ];
return Promise.all(aPromises).then(function() {
return oControllerClass;
});
}
return oControllerClass;
}).catch(function(vError) {
// handle preload errors
// destroy "preloaded" models in case of any error to prevent memory leaks
if (mModels) {
for (var sName in mModels) {
var oModel = mModels[sName];
if (oModel && typeof oModel.destroy === "function") {
oModel.destroy();
}
}
}
// re-throw error to hand it over to the application
throw vError;
});
}
if (oManifest) {
preloadDependencies(sName, oManifest);
}
preload(sName);
// synchronously load the controller class, prepare and return it
return prepareControllerClass(
sap.ui.requireSync( getControllerModuleName() )
);
} | [
"function",
"loadComponent",
"(",
"oConfig",
",",
"mOptions",
")",
"{",
"var",
"sName",
"=",
"oConfig",
".",
"name",
",",
"sUrl",
"=",
"oConfig",
".",
"url",
",",
"oConfiguration",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getConfiguration",... | Internal loading method to decouple "sap.ui.component" / "sap.ui.component.load".
@param {object} oConfig see <code>sap.ui.component</code> / <code>sap.ui.component.load</code>
@param {object} mOptions internal loading configurations
@param {boolean} mOptions.failOnError see <code>sap.ui.component.load</code>
@param {boolean} mOptions.createModels whether models from manifest should be created during
component preload (should only be set via <code>sap.ui.component</code>)
@param {boolean} mOptions.preloadOnly see <code>sap.ui.component.load</code> (<code>vConfig.asyncHints.preloadOnly</code>)
@param {Promise|Promise[]} mOptions.waitFor see <code>sap.ui.component</code> (<code>vConfig.asyncHints.waitFor</code>)
@return {function|Promise} the constructor of the Component class or a Promise that will be fulfilled with the same
@private | [
"Internal",
"loading",
"method",
"to",
"decouple",
"sap",
".",
"ui",
".",
"component",
"/",
"sap",
".",
"ui",
".",
"component",
".",
"load",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L2378-L3046 | train | Loads a component from the given manifest | [
30522,
3853,
7170,
9006,
29513,
3372,
1006,
1051,
8663,
8873,
2290,
1010,
9587,
16790,
2015,
1007,
1063,
13075,
1055,
18442,
1027,
1051,
8663,
8873,
2290,
1012,
2171,
1010,
7505,
2140,
1027,
1051,
8663,
8873,
2290,
1012,
24471,
2140,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/parallel/ParallelSeries.js | function (activeState) {
var coordSys = this.coordinateSystem;
var data = this.getData();
var indices = [];
coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
if (activeState === theActiveState) {
indices.push(data.getRawIndex(dataIndex));
}
});
return indices;
} | javascript | function (activeState) {
var coordSys = this.coordinateSystem;
var data = this.getData();
var indices = [];
coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
if (activeState === theActiveState) {
indices.push(data.getRawIndex(dataIndex));
}
});
return indices;
} | [
"function",
"(",
"activeState",
")",
"{",
"var",
"coordSys",
"=",
"this",
".",
"coordinateSystem",
";",
"var",
"data",
"=",
"this",
".",
"getData",
"(",
")",
";",
"var",
"indices",
"=",
"[",
"]",
";",
"coordSys",
".",
"eachActiveState",
"(",
"data",
",... | User can get data raw indices on 'axisAreaSelected' event received.
@public
@param {string} activeState 'active' or 'inactive' or 'normal'
@return {Array.<number>} Raw indices | [
"User",
"can",
"get",
"data",
"raw",
"indices",
"on",
"axisAreaSelected",
"event",
"received",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/parallel/ParallelSeries.js#L47-L59 | train | Get the active index of the record | [
30522,
3853,
1006,
3161,
9153,
2618,
1007,
1063,
13075,
2522,
8551,
6508,
2015,
1027,
2023,
1012,
12093,
27268,
6633,
1025,
13075,
2951,
1027,
2023,
1012,
2131,
2850,
2696,
1006,
1007,
1025,
13075,
29299,
1027,
1031,
1033,
1025,
2522,
8551,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/util/ast-utils.js | hasJSDocThisTag | function hasJSDocThisTag(node, sourceCode) {
const jsdocComment = sourceCode.getJSDocComment(node);
if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
return true;
}
// Checks `@this` in its leading comments for callbacks,
// because callbacks don't have its JSDoc comment.
// e.g.
// sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value));
} | javascript | function hasJSDocThisTag(node, sourceCode) {
const jsdocComment = sourceCode.getJSDocComment(node);
if (jsdocComment && thisTagPattern.test(jsdocComment.value)) {
return true;
}
// Checks `@this` in its leading comments for callbacks,
// because callbacks don't have its JSDoc comment.
// e.g.
// sinon.test(/* @this sinon.Sandbox */function() { this.spy(); });
return sourceCode.getCommentsBefore(node).some(comment => thisTagPattern.test(comment.value));
} | [
"function",
"hasJSDocThisTag",
"(",
"node",
",",
"sourceCode",
")",
"{",
"const",
"jsdocComment",
"=",
"sourceCode",
".",
"getJSDocComment",
"(",
"node",
")",
";",
"if",
"(",
"jsdocComment",
"&&",
"thisTagPattern",
".",
"test",
"(",
"jsdocComment",
".",
"value... | Checks whether or not a node has a `@this` tag in its comments.
@param {ASTNode} node - A node to check.
@param {SourceCode} sourceCode - A SourceCode instance to get comments.
@returns {boolean} Whether or not the node has a `@this` tag in its comments. | [
"Checks",
"whether",
"or",
"not",
"a",
"node",
"has",
"a"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/ast-utils.js#L233-L245 | train | Checks if a node has a JSDoc This tag | [
30522,
3853,
2038,
22578,
3527,
6593,
24158,
15900,
1006,
13045,
1010,
3120,
16044,
1007,
1063,
9530,
3367,
1046,
16150,
10085,
9006,
3672,
1027,
3120,
16044,
1012,
2131,
22578,
3527,
21408,
20058,
3372,
1006,
13045,
1007,
30524,
1004,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
googleapis/google-api-nodejs-client | samples/jwt.js | runSample | async function runSample() {
// Create a new JWT client using the key file downloaded from the Google Developer Console
const client = await google.auth.getClient({
keyFile: path.join(__dirname, 'jwt.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.readonly',
});
// Obtain a new drive client, making sure you pass along the auth client
const drive = google.drive({
version: 'v2',
auth: client,
});
// Make an authorized request to list Drive files.
const res = await drive.files.list();
console.log(res.data);
return res.data;
} | javascript | async function runSample() {
// Create a new JWT client using the key file downloaded from the Google Developer Console
const client = await google.auth.getClient({
keyFile: path.join(__dirname, 'jwt.keys.json'),
scopes: 'https://www.googleapis.com/auth/drive.readonly',
});
// Obtain a new drive client, making sure you pass along the auth client
const drive = google.drive({
version: 'v2',
auth: client,
});
// Make an authorized request to list Drive files.
const res = await drive.files.list();
console.log(res.data);
return res.data;
} | [
"async",
"function",
"runSample",
"(",
")",
"{",
"// Create a new JWT client using the key file downloaded from the Google Developer Console",
"const",
"client",
"=",
"await",
"google",
".",
"auth",
".",
"getClient",
"(",
"{",
"keyFile",
":",
"path",
".",
"join",
"(",
... | The JWT authorization is ideal for performing server-to-server
communication without asking for user consent.
Suggested reading for Admin SDK users using service accounts:
https://developers.google.com/admin-sdk/directory/v1/guides/delegation
See the defaultauth.js sample for an alternate way of fetching compute credentials. | [
"The",
"JWT",
"authorization",
"is",
"ideal",
"for",
"performing",
"server",
"-",
"to",
"-",
"server",
"communication",
"without",
"asking",
"for",
"user",
"consent",
"."
] | e6e632a29d0b246d058e3067de3a5c3827e2b54e | https://github.com/googleapis/google-api-nodejs-client/blob/e6e632a29d0b246d058e3067de3a5c3827e2b54e/samples/jwt.js#L28-L46 | train | This sample is a sample of the sample code. | [
30522,
2004,
6038,
2278,
3853,
3216,
16613,
2571,
1006,
1007,
1063,
1013,
1013,
3443,
1037,
2047,
1046,
26677,
7396,
2478,
1996,
3145,
5371,
22817,
2013,
1996,
8224,
9722,
10122,
9530,
3367,
7396,
1027,
26751,
8224,
1012,
8740,
2705,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/transform-apijson-for-sdk.js | function ({name, type, className, text=name, local=false, hrefAppend=""}) {
let sLink;
// handling module's
if (className !== undefined && (/^module:/.test(name) || /^module:/.test(className))) {
name = name.replace(/^module:/, "");
}
name = encodeURIComponent(name);
className = encodeURIComponent(className);
// Build the link
sLink = type ? `${className}/${type}/${name}` : name;
if (hrefAppend) {
sLink += hrefAppend;
}
if (local) {
return `<a target="_self" class="jsdoclink scrollTo${type === `events` ? `Event` : `Method`}" data-sap-ui-target="${name}" href="#/api/${sLink}">${text}</a>`;
}
return `<a target="_self" class="jsdoclink" href="#/api/${sLink}">${text}</a>`;
} | javascript | function ({name, type, className, text=name, local=false, hrefAppend=""}) {
let sLink;
// handling module's
if (className !== undefined && (/^module:/.test(name) || /^module:/.test(className))) {
name = name.replace(/^module:/, "");
}
name = encodeURIComponent(name);
className = encodeURIComponent(className);
// Build the link
sLink = type ? `${className}/${type}/${name}` : name;
if (hrefAppend) {
sLink += hrefAppend;
}
if (local) {
return `<a target="_self" class="jsdoclink scrollTo${type === `events` ? `Event` : `Method`}" data-sap-ui-target="${name}" href="#/api/${sLink}">${text}</a>`;
}
return `<a target="_self" class="jsdoclink" href="#/api/${sLink}">${text}</a>`;
} | [
"function",
"(",
"{",
"name",
",",
"type",
",",
"className",
",",
"text",
"=",
"name",
",",
"local",
"=",
"false",
",",
"hrefAppend",
"=",
"\"\"",
"}",
")",
"{",
"let",
"sLink",
";",
"// handling module's",
"if",
"(",
"className",
"!==",
"undefined",
"... | Creates a html link
@param {string} name
@param {string} type
@param {string} className
@param {string} [text=name] by default if no text is provided the name will be used
@param {boolean} [local=false]
@param {string} [hrefAppend=""]
@returns {string} link | [
"Creates",
"a",
"html",
"link"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L1394-L1417 | train | Build the link to the api | [
30522,
30524,
2465,
18442,
999,
1027,
1027,
6151,
28344,
1004,
1004,
1006,
1013,
1034,
11336,
1024,
1013,
1012,
3231,
1006,
2171,
1007,
1064,
1064,
1013,
1034,
11336,
1024,
1013,
1012,
3231,
1006,
2465,
18442,
1007,
1007,
1007,
1063,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
facebook/relay | packages/babel-plugin-relay/createModernNode.js | createModernNode | function createModernNode(
t: $FlowFixMe,
graphqlDefinition: OperationDefinitionNode | FragmentDefinitionNode,
state: BabelState,
options: {
// If an output directory is specified when running relay-compiler this should point to that directory
artifactDirectory: ?string,
// The command to run to compile Relay files, used for error messages.
buildCommand: string,
// Generate extra validation, defaults to true.
isDevelopment: boolean,
// Wrap the validation code in a conditional checking this variable.
isDevVariable: ?string,
// Use haste style global requires, defaults to false.
isHasteMode: boolean,
},
): Object {
const definitionName = graphqlDefinition.name && graphqlDefinition.name.value;
if (!definitionName) {
throw new Error('GraphQL operations and fragments must contain names');
}
const requiredFile = definitionName + '.graphql';
const requiredPath = options.isHasteMode
? requiredFile
: options.artifactDirectory
? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
: GENERATED + requiredFile;
const hash = crypto
.createHash('md5')
.update(print(graphqlDefinition), 'utf8')
.digest('hex');
const requireGraphQLModule = t.callExpression(t.identifier('require'), [
t.stringLiteral(requiredPath),
]);
const bodyStatements = [t.returnStatement(requireGraphQLModule)];
if (options.isDevVariable != null || options.isDevelopment) {
const nodeVariable = t.identifier('node');
const nodeDotHash = t.memberExpression(nodeVariable, t.identifier('hash'));
let checkStatements = [
t.variableDeclaration('const', [
t.variableDeclarator(nodeVariable, requireGraphQLModule),
]),
t.ifStatement(
t.logicalExpression(
'&&',
nodeDotHash,
t.binaryExpression('!==', nodeDotHash, t.stringLiteral(hash)),
),
t.blockStatement([
t.expressionStatement(
warnNeedsRebuild(t, definitionName, options.buildCommand),
),
]),
),
];
if (options.isDevVariable != null) {
checkStatements = [
t.ifStatement(
t.identifier(options.isDevVariable),
t.blockStatement(checkStatements),
),
];
}
bodyStatements.unshift(...checkStatements);
}
return t.functionExpression(null, [], t.blockStatement(bodyStatements));
} | javascript | function createModernNode(
t: $FlowFixMe,
graphqlDefinition: OperationDefinitionNode | FragmentDefinitionNode,
state: BabelState,
options: {
// If an output directory is specified when running relay-compiler this should point to that directory
artifactDirectory: ?string,
// The command to run to compile Relay files, used for error messages.
buildCommand: string,
// Generate extra validation, defaults to true.
isDevelopment: boolean,
// Wrap the validation code in a conditional checking this variable.
isDevVariable: ?string,
// Use haste style global requires, defaults to false.
isHasteMode: boolean,
},
): Object {
const definitionName = graphqlDefinition.name && graphqlDefinition.name.value;
if (!definitionName) {
throw new Error('GraphQL operations and fragments must contain names');
}
const requiredFile = definitionName + '.graphql';
const requiredPath = options.isHasteMode
? requiredFile
: options.artifactDirectory
? getRelativeImportPath(state, options.artifactDirectory, requiredFile)
: GENERATED + requiredFile;
const hash = crypto
.createHash('md5')
.update(print(graphqlDefinition), 'utf8')
.digest('hex');
const requireGraphQLModule = t.callExpression(t.identifier('require'), [
t.stringLiteral(requiredPath),
]);
const bodyStatements = [t.returnStatement(requireGraphQLModule)];
if (options.isDevVariable != null || options.isDevelopment) {
const nodeVariable = t.identifier('node');
const nodeDotHash = t.memberExpression(nodeVariable, t.identifier('hash'));
let checkStatements = [
t.variableDeclaration('const', [
t.variableDeclarator(nodeVariable, requireGraphQLModule),
]),
t.ifStatement(
t.logicalExpression(
'&&',
nodeDotHash,
t.binaryExpression('!==', nodeDotHash, t.stringLiteral(hash)),
),
t.blockStatement([
t.expressionStatement(
warnNeedsRebuild(t, definitionName, options.buildCommand),
),
]),
),
];
if (options.isDevVariable != null) {
checkStatements = [
t.ifStatement(
t.identifier(options.isDevVariable),
t.blockStatement(checkStatements),
),
];
}
bodyStatements.unshift(...checkStatements);
}
return t.functionExpression(null, [], t.blockStatement(bodyStatements));
} | [
"function",
"createModernNode",
"(",
"t",
":",
"$FlowFixMe",
",",
"graphqlDefinition",
":",
"OperationDefinitionNode",
"|",
"FragmentDefinitionNode",
",",
"state",
":",
"BabelState",
",",
"options",
":",
"{",
"// If an output directory is specified when running relay-compiler... | Relay Modern creates separate generated files, so Babel transforms graphql
definitions to lazy require function calls. | [
"Relay",
"Modern",
"creates",
"separate",
"generated",
"files",
"so",
"Babel",
"transforms",
"graphql",
"definitions",
"to",
"lazy",
"require",
"function",
"calls",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/babel-plugin-relay/createModernNode.js#L28-L97 | train | Creates a node that can be used to compile the graphql. | [
30522,
3853,
3443,
5302,
25888,
3630,
3207,
1006,
1056,
1024,
1002,
4834,
8873,
2595,
4168,
1010,
10629,
4160,
17920,
16294,
22753,
1024,
3169,
3207,
16294,
22753,
3630,
3207,
1064,
15778,
3207,
16294,
22753,
3630,
3207,
1010,
2110,
1024,
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... |
GeekyAnts/vue-native-core | dist/react.vue.compiler.js | parseComponent | function parseComponent (
content,
options
) {
if ( options === void 0 ) options = {};
var sfc = {
template: null,
script: null,
styles: [],
customBlocks: []
};
var depth = 0;
var currentBlock = null;
function start (
tag,
attrs,
unary,
start,
end
) {
if (depth === 0) {
currentBlock = {
type: tag,
content: '',
start: end,
attrs: attrs.reduce(function (cumulated, ref) {
var name = ref.name;
var value = ref.value;
cumulated[name] = value || true;
return cumulated
}, Object.create(null))
};
if (isSpecialTag(tag)) {
checkAttrs(currentBlock, attrs);
if (tag === 'style') {
sfc.styles.push(currentBlock);
} else {
sfc[tag] = currentBlock;
}
} else { // custom blocks
sfc.customBlocks.push(currentBlock);
}
}
if (!unary) {
depth++;
}
}
function checkAttrs (block, attrs) {
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr.name === 'lang') {
block.lang = attr.value;
}
if (attr.name === 'scoped') {
block.scoped = true;
}
if (attr.name === 'module') {
block.module = attr.value || true;
}
if (attr.name === 'src') {
block.src = attr.value;
}
}
}
function end (tag, start, end) {
if (depth === 1 && currentBlock) {
currentBlock.end = start;
var text = deindent(content.slice(currentBlock.start, currentBlock.end));
// pad content so that linters and pre-processors can output correct
// line numbers in errors and warnings
if (currentBlock.type !== 'template' && options.pad) {
text = padContent(currentBlock, options.pad) + text;
}
currentBlock.content = text;
currentBlock = null;
}
depth--;
}
function padContent (block, pad) {
if (pad === 'space') {
return content.slice(0, block.start).replace(replaceRE, ' ')
} else {
var offset = content.slice(0, block.start).split(splitRE).length;
var padChar = block.type === 'script' && !block.lang
? '//\n'
: '\n';
return Array(offset).join(padChar)
}
}
parseHTML(content, {
start: start,
end: end
});
return sfc
} | javascript | function parseComponent (
content,
options
) {
if ( options === void 0 ) options = {};
var sfc = {
template: null,
script: null,
styles: [],
customBlocks: []
};
var depth = 0;
var currentBlock = null;
function start (
tag,
attrs,
unary,
start,
end
) {
if (depth === 0) {
currentBlock = {
type: tag,
content: '',
start: end,
attrs: attrs.reduce(function (cumulated, ref) {
var name = ref.name;
var value = ref.value;
cumulated[name] = value || true;
return cumulated
}, Object.create(null))
};
if (isSpecialTag(tag)) {
checkAttrs(currentBlock, attrs);
if (tag === 'style') {
sfc.styles.push(currentBlock);
} else {
sfc[tag] = currentBlock;
}
} else { // custom blocks
sfc.customBlocks.push(currentBlock);
}
}
if (!unary) {
depth++;
}
}
function checkAttrs (block, attrs) {
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr.name === 'lang') {
block.lang = attr.value;
}
if (attr.name === 'scoped') {
block.scoped = true;
}
if (attr.name === 'module') {
block.module = attr.value || true;
}
if (attr.name === 'src') {
block.src = attr.value;
}
}
}
function end (tag, start, end) {
if (depth === 1 && currentBlock) {
currentBlock.end = start;
var text = deindent(content.slice(currentBlock.start, currentBlock.end));
// pad content so that linters and pre-processors can output correct
// line numbers in errors and warnings
if (currentBlock.type !== 'template' && options.pad) {
text = padContent(currentBlock, options.pad) + text;
}
currentBlock.content = text;
currentBlock = null;
}
depth--;
}
function padContent (block, pad) {
if (pad === 'space') {
return content.slice(0, block.start).replace(replaceRE, ' ')
} else {
var offset = content.slice(0, block.start).split(splitRE).length;
var padChar = block.type === 'script' && !block.lang
? '//\n'
: '\n';
return Array(offset).join(padChar)
}
}
parseHTML(content, {
start: start,
end: end
});
return sfc
} | [
"function",
"parseComponent",
"(",
"content",
",",
"options",
")",
"{",
"if",
"(",
"options",
"===",
"void",
"0",
")",
"options",
"=",
"{",
"}",
";",
"var",
"sfc",
"=",
"{",
"template",
":",
"null",
",",
"script",
":",
"null",
",",
"styles",
":",
"... | Parse a single-file component (*.vue) file into an SFC Descriptor Object. | [
"Parse",
"a",
"single",
"-",
"file",
"component",
"(",
"*",
".",
"vue",
")",
"file",
"into",
"an",
"SFC",
"Descriptor",
"Object",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/react.vue.compiler.js#L509-L611 | train | Parse a component | [
30522,
3853,
11968,
3366,
9006,
29513,
3372,
1006,
4180,
1010,
7047,
1007,
1063,
2065,
1006,
7047,
1027,
1027,
1027,
11675,
1014,
1007,
7047,
1027,
1063,
1065,
1025,
13075,
16420,
2278,
1027,
1063,
23561,
1024,
19701,
1010,
5896,
1024,
1970... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/lib/handleUnknownCommand.js | registerUnknownCommands | function registerUnknownCommands (cli, options) {
cli.on('command:*', async () => {
const { args, options: commandoptions } = cli
logger.debug('global_options', options)
logger.debug('cli_options', commandoptions)
logger.debug('cli_args', args)
const [commandName] = args
const sourceDir = args[1] ? path.resolve(args[1]) : pwd
const inferredUserDocsDirectory = await inferUserDocsDirectory(pwd)
logger.developer('inferredUserDocsDirectory', inferredUserDocsDirectory)
logger.developer('sourceDir', sourceDir)
if (inferredUserDocsDirectory && sourceDir !== inferredUserDocsDirectory) {
logUnknownCommand(cli)
console.log()
logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)
console.log()
process.exit(1)
}
if (!inferredUserDocsDirectory) {
logUnknownCommand(cli)
process.exit(1)
}
logger.debug('Custom command', chalk.cyan(commandName))
CLI({
async beforeParse (subCli) {
const app = createApp({
sourceDir: sourceDir,
...options,
...commandoptions
})
await app.process()
app.pluginAPI.applySyncOption('extendCli', subCli, app)
console.log()
},
async afterParse (subCli) {
if (!subCli.matchedCommand) {
logUnknownCommand(subCli)
console.log()
}
}
})
})
} | javascript | function registerUnknownCommands (cli, options) {
cli.on('command:*', async () => {
const { args, options: commandoptions } = cli
logger.debug('global_options', options)
logger.debug('cli_options', commandoptions)
logger.debug('cli_args', args)
const [commandName] = args
const sourceDir = args[1] ? path.resolve(args[1]) : pwd
const inferredUserDocsDirectory = await inferUserDocsDirectory(pwd)
logger.developer('inferredUserDocsDirectory', inferredUserDocsDirectory)
logger.developer('sourceDir', sourceDir)
if (inferredUserDocsDirectory && sourceDir !== inferredUserDocsDirectory) {
logUnknownCommand(cli)
console.log()
logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)
console.log()
process.exit(1)
}
if (!inferredUserDocsDirectory) {
logUnknownCommand(cli)
process.exit(1)
}
logger.debug('Custom command', chalk.cyan(commandName))
CLI({
async beforeParse (subCli) {
const app = createApp({
sourceDir: sourceDir,
...options,
...commandoptions
})
await app.process()
app.pluginAPI.applySyncOption('extendCli', subCli, app)
console.log()
},
async afterParse (subCli) {
if (!subCli.matchedCommand) {
logUnknownCommand(subCli)
console.log()
}
}
})
})
} | [
"function",
"registerUnknownCommands",
"(",
"cli",
",",
"options",
")",
"{",
"cli",
".",
"on",
"(",
"'command:*'",
",",
"async",
"(",
")",
"=>",
"{",
"const",
"{",
"args",
",",
"options",
":",
"commandoptions",
"}",
"=",
"cli",
"logger",
".",
"debug",
... | Register a command to match all unmatched commands
@param {CAC} cli | [
"Register",
"a",
"command",
"to",
"match",
"all",
"unmatched",
"commands"
] | 15784acc0cf2e87de3c147895b2c3977b0195d78 | https://github.com/vuejs/vuepress/blob/15784acc0cf2e87de3c147895b2c3977b0195d78/packages/vuepress/lib/handleUnknownCommand.js#L76-L124 | train | Register unknown commands | [
30522,
3853,
4236,
16814,
19779,
15305,
14760,
18376,
1006,
18856,
2072,
1010,
7047,
1007,
1063,
18856,
2072,
1012,
2006,
1006,
1005,
3094,
1024,
1008,
1005,
1010,
2004,
6038,
2278,
1006,
1007,
1027,
1028,
1063,
9530,
3367,
1063,
12098,
562... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | postMessageToBrackets | function postMessageToBrackets(messageId, requester) {
if(!requesters[requester]) {
for (var key in requesters) {
requester = key;
break;
}
}
var msgObj = {
fn: messageId,
args: getFunctionArgs(arguments),
requester: requester.toString()
};
_domainManager.emitEvent('AutoUpdate', 'data', [msgObj]);
} | javascript | function postMessageToBrackets(messageId, requester) {
if(!requesters[requester]) {
for (var key in requesters) {
requester = key;
break;
}
}
var msgObj = {
fn: messageId,
args: getFunctionArgs(arguments),
requester: requester.toString()
};
_domainManager.emitEvent('AutoUpdate', 'data', [msgObj]);
} | [
"function",
"postMessageToBrackets",
"(",
"messageId",
",",
"requester",
")",
"{",
"if",
"(",
"!",
"requesters",
"[",
"requester",
"]",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"requesters",
")",
"{",
"requester",
"=",
"key",
";",
"break",
";",
"}",
"... | Posts messages to brackets
@param {string} messageId - Message to be passed | [
"Posts",
"messages",
"to",
"brackets"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L92-L106 | train | Post a message to brackets | [
30522,
3853,
2695,
7834,
3736,
18150,
16429,
22648,
3489,
3215,
1006,
4471,
3593,
1010,
5227,
2121,
1007,
1063,
2065,
1006,
999,
5227,
2545,
1031,
5227,
2121,
1033,
1007,
1063,
2005,
1006,
13075,
3145,
1999,
5227,
2545,
1007,
1063,
5227,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-unused-vars.js | hasRestSpreadSibling | function hasRestSpreadSibling(variable) {
if (config.ignoreRestSiblings) {
return variable.defs.some(def => {
const propertyNode = def.name.parent;
const patternNode = propertyNode.parent;
return (
propertyNode.type === "Property" &&
patternNode.type === "ObjectPattern" &&
REST_PROPERTY_TYPE.test(patternNode.properties[patternNode.properties.length - 1].type)
);
});
}
return false;
} | javascript | function hasRestSpreadSibling(variable) {
if (config.ignoreRestSiblings) {
return variable.defs.some(def => {
const propertyNode = def.name.parent;
const patternNode = propertyNode.parent;
return (
propertyNode.type === "Property" &&
patternNode.type === "ObjectPattern" &&
REST_PROPERTY_TYPE.test(patternNode.properties[patternNode.properties.length - 1].type)
);
});
}
return false;
} | [
"function",
"hasRestSpreadSibling",
"(",
"variable",
")",
"{",
"if",
"(",
"config",
".",
"ignoreRestSiblings",
")",
"{",
"return",
"variable",
".",
"defs",
".",
"some",
"(",
"def",
"=>",
"{",
"const",
"propertyNode",
"=",
"def",
".",
"name",
".",
"parent",... | Determines if a variable has a sibling rest property
@param {Variable} variable - eslint-scope variable object.
@returns {boolean} True if the variable is exported, false if not.
@private | [
"Determines",
"if",
"a",
"variable",
"has",
"a",
"sibling",
"rest",
"property"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L179-L194 | train | returns true if variable has a rest sibling | [
30522,
3853,
2038,
28533,
13102,
16416,
5104,
12322,
2989,
1006,
8023,
1007,
1063,
2065,
1006,
9530,
8873,
2290,
1012,
8568,
28533,
5332,
9709,
2015,
1007,
1063,
2709,
8023,
1012,
13366,
2015,
1012,
2070,
1006,
13366,
1027,
1028,
1063,
9530... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/gesture/gesture.js | makeStartPointer | function makeStartPointer(ev) {
var point = getEventPoint(ev);
var startPointer = {
startTime: +Date.now(),
target: ev.target,
// 'p' for pointer events, 'm' for mouse, 't' for touch
type: ev.type.charAt(0)
};
startPointer.startX = startPointer.x = point.pageX;
startPointer.startY = startPointer.y = point.pageY;
return startPointer;
} | javascript | function makeStartPointer(ev) {
var point = getEventPoint(ev);
var startPointer = {
startTime: +Date.now(),
target: ev.target,
// 'p' for pointer events, 'm' for mouse, 't' for touch
type: ev.type.charAt(0)
};
startPointer.startX = startPointer.x = point.pageX;
startPointer.startY = startPointer.y = point.pageY;
return startPointer;
} | [
"function",
"makeStartPointer",
"(",
"ev",
")",
"{",
"var",
"point",
"=",
"getEventPoint",
"(",
"ev",
")",
";",
"var",
"startPointer",
"=",
"{",
"startTime",
":",
"+",
"Date",
".",
"now",
"(",
")",
",",
"target",
":",
"ev",
".",
"target",
",",
"// 'p... | ******************** Module Functions ******************** /*
Initiate the pointer. x, y, and the pointer's type. | [
"********************",
"Module",
"Functions",
"********************",
"/",
"*",
"Initiate",
"the",
"pointer",
".",
"x",
"y",
"and",
"the",
"pointer",
"s",
"type",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L704-L715 | train | Creates a start pointer object | [
30522,
3853,
3084,
7559,
25856,
25785,
2121,
1006,
23408,
1007,
1063,
13075,
2391,
1027,
2131,
18697,
3372,
8400,
1006,
23408,
1007,
1025,
13075,
2707,
8400,
2121,
1027,
1063,
2707,
7292,
1024,
1009,
3058,
1012,
2085,
1006,
1007,
1010,
4539... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/semi.js | isOnSameLineWithNextToken | function isOnSameLineWithNextToken(node) {
const prevToken = sourceCode.getLastToken(node, 1);
const nextToken = sourceCode.getTokenAfter(node);
return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken);
} | javascript | function isOnSameLineWithNextToken(node) {
const prevToken = sourceCode.getLastToken(node, 1);
const nextToken = sourceCode.getTokenAfter(node);
return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken);
} | [
"function",
"isOnSameLineWithNextToken",
"(",
"node",
")",
"{",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"1",
")",
";",
"const",
"nextToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
")",
";",
"return",
"!"... | Check whether a given node is on the same line with the next token.
@param {Node} node A statement node to check.
@returns {boolean} `true` if the node is on the same line with the next token. | [
"Check",
"whether",
"a",
"given",
"node",
"is",
"on",
"the",
"same",
"line",
"with",
"the",
"next",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi.js#L166-L171 | train | Check if node is on same line with the next token | [
30522,
3853,
11163,
3619,
14074,
4179,
24415,
2638,
18413,
18715,
2368,
1006,
13045,
1007,
1063,
9530,
3367,
3653,
2615,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
1010,
1015,
1007,
1025,
9530,
3367,
2279,
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... |
aframevr/aframe | src/systems/material.js | fixVideoAttributes | function fixVideoAttributes (videoEl) {
videoEl.autoplay = videoEl.hasAttribute('autoplay') && videoEl.getAttribute('autoplay') !== 'false';
videoEl.controls = videoEl.hasAttribute('controls') && videoEl.getAttribute('controls') !== 'false';
if (videoEl.getAttribute('loop') === 'false') {
videoEl.removeAttribute('loop');
}
if (videoEl.getAttribute('preload') === 'false') {
videoEl.preload = 'none';
}
videoEl.crossOrigin = videoEl.crossOrigin || 'anonymous';
// To support inline videos in iOS webviews.
videoEl.setAttribute('playsinline', '');
videoEl.setAttribute('webkit-playsinline', '');
return videoEl;
} | javascript | function fixVideoAttributes (videoEl) {
videoEl.autoplay = videoEl.hasAttribute('autoplay') && videoEl.getAttribute('autoplay') !== 'false';
videoEl.controls = videoEl.hasAttribute('controls') && videoEl.getAttribute('controls') !== 'false';
if (videoEl.getAttribute('loop') === 'false') {
videoEl.removeAttribute('loop');
}
if (videoEl.getAttribute('preload') === 'false') {
videoEl.preload = 'none';
}
videoEl.crossOrigin = videoEl.crossOrigin || 'anonymous';
// To support inline videos in iOS webviews.
videoEl.setAttribute('playsinline', '');
videoEl.setAttribute('webkit-playsinline', '');
return videoEl;
} | [
"function",
"fixVideoAttributes",
"(",
"videoEl",
")",
"{",
"videoEl",
".",
"autoplay",
"=",
"videoEl",
".",
"hasAttribute",
"(",
"'autoplay'",
")",
"&&",
"videoEl",
".",
"getAttribute",
"(",
"'autoplay'",
")",
"!==",
"'false'",
";",
"videoEl",
".",
"controls"... | Fixes a video element's attributes to prevent developers from accidentally passing the
wrong attribute values to commonly misused video attributes.
<video> does not treat `autoplay`, `controls`, `crossorigin`, `loop`, and `preload` as
as booleans. Existence of those attributes will mean truthy.
For example, translates <video loop="false"> to <video>.
@see https://developer.mozilla.org/docs/Web/HTML/Element/video#Attributes
@param {Element} videoEl - Video element.
@returns {Element} Video element with the correct properties updated. | [
"Fixes",
"a",
"video",
"element",
"s",
"attributes",
"to",
"prevent",
"developers",
"from",
"accidentally",
"passing",
"the",
"wrong",
"attribute",
"values",
"to",
"commonly",
"misused",
"video",
"attributes",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L389-L403 | train | Fixes the video attributes | [
30522,
3853,
8081,
17258,
8780,
19321,
30524,
2618,
1006,
1005,
8285,
13068,
1005,
1007,
1004,
1004,
2678,
2884,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
1005,
8285,
13068,
1005,
1007,
999,
1027,
1027,
1005,
6270,
1005,
1025,
2678,
2884,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/node/selenium-webdriver/lib/logging.js | getLevel | function getLevel(nameOrValue) {
if (typeof nameOrValue === 'string') {
return LEVELS_BY_NAME.get(nameOrValue) || Level.ALL;
}
if (typeof nameOrValue !== 'number') {
throw new TypeError('not a string or number');
}
for (let level of ALL_LEVELS) {
if (nameOrValue >= level.value) {
return level;
}
}
return Level.ALL;
} | javascript | function getLevel(nameOrValue) {
if (typeof nameOrValue === 'string') {
return LEVELS_BY_NAME.get(nameOrValue) || Level.ALL;
}
if (typeof nameOrValue !== 'number') {
throw new TypeError('not a string or number');
}
for (let level of ALL_LEVELS) {
if (nameOrValue >= level.value) {
return level;
}
}
return Level.ALL;
} | [
"function",
"getLevel",
"(",
"nameOrValue",
")",
"{",
"if",
"(",
"typeof",
"nameOrValue",
"===",
"'string'",
")",
"{",
"return",
"LEVELS_BY_NAME",
".",
"get",
"(",
"nameOrValue",
")",
"||",
"Level",
".",
"ALL",
";",
"}",
"if",
"(",
"typeof",
"nameOrValue",... | Converts a level name or value to a {@link Level} value. If the name/value
is not recognized, {@link Level.ALL} will be returned.
@param {(number|string)} nameOrValue The log level name, or value, to
convert.
@return {!Level} The converted level. | [
"Converts",
"a",
"level",
"name",
"or",
"value",
"to",
"a",
"{",
"@link",
"Level",
"}",
"value",
".",
"If",
"the",
"name",
"/",
"value",
"is",
"not",
"recognized",
"{",
"@link",
"Level",
".",
"ALL",
"}",
"will",
"be",
"returned",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/lib/logging.js#L202-L215 | train | Get the level of a given name or value | [
30522,
3853,
2131,
20414,
2884,
1006,
2171,
2953,
10175,
5657,
1007,
1063,
2065,
1006,
2828,
11253,
2171,
2953,
10175,
5657,
1027,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
3798,
1035,
2011,
1035,
2171,
1012,
2131,
1006,
2171,
2953,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/lists.js | foldR | function foldR(fn, startValue, list) {
return list
? fn(foldR(fn, startValue, tail(list)), head(list))
: startValue
;
} | javascript | function foldR(fn, startValue, list) {
return list
? fn(foldR(fn, startValue, tail(list)), head(list))
: startValue
;
} | [
"function",
"foldR",
"(",
"fn",
",",
"startValue",
",",
"list",
")",
"{",
"return",
"list",
"?",
"fn",
"(",
"foldR",
"(",
"fn",
",",
"startValue",
",",
"tail",
"(",
"list",
")",
")",
",",
"head",
"(",
"list",
")",
")",
":",
"startValue",
";",
"}"... | foldR implementation. Reduce a list down to a single value.
@pram {Function} fn (rightEval, curVal) -> result | [
"foldR",
"implementation",
".",
"Reduce",
"a",
"list",
"down",
"to",
"a",
"single",
"value",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/lists.js#L102-L108 | train | Augmented function over the list of items in the list. | [
30522,
3853,
10671,
2099,
1006,
1042,
2078,
1010,
2707,
10175,
5657,
1010,
2862,
1007,
1063,
2709,
2862,
1029,
1042,
2078,
1006,
10671,
2099,
1006,
1042,
2078,
1010,
2707,
10175,
5657,
1010,
5725,
1006,
2862,
1007,
1007,
1010,
2132,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptCodeHints/main.js | getSessionHints | function getSessionHints(query, cursor, type, token, $deferredHints) {
var hintResults = session.getHints(query, getStringMatcher());
if (hintResults.needGuesses) {
var guessesResponse = ScopeManager.requestGuesses(session,
session.editor.document);
if (!$deferredHints) {
$deferredHints = $.Deferred();
}
guessesResponse.done(function () {
if (hintsArePending($deferredHints)) {
hintResults = session.getHints(query, getStringMatcher());
setCachedHintContext(hintResults.hints, cursor, type, token);
var hintResponse = getHintResponse(cachedHints, query, type);
$deferredHints.resolveWith(null, [hintResponse]);
}
}).fail(function () {
if (hintsArePending($deferredHints)) {
$deferredHints.reject();
}
});
return $deferredHints;
} else if (hintsArePending($deferredHints)) {
setCachedHintContext(hintResults.hints, cursor, type, token);
var hintResponse = getHintResponse(cachedHints, query, type);
$deferredHints.resolveWith(null, [hintResponse]);
return null;
} else {
setCachedHintContext(hintResults.hints, cursor, type, token);
return getHintResponse(cachedHints, query, type);
}
} | javascript | function getSessionHints(query, cursor, type, token, $deferredHints) {
var hintResults = session.getHints(query, getStringMatcher());
if (hintResults.needGuesses) {
var guessesResponse = ScopeManager.requestGuesses(session,
session.editor.document);
if (!$deferredHints) {
$deferredHints = $.Deferred();
}
guessesResponse.done(function () {
if (hintsArePending($deferredHints)) {
hintResults = session.getHints(query, getStringMatcher());
setCachedHintContext(hintResults.hints, cursor, type, token);
var hintResponse = getHintResponse(cachedHints, query, type);
$deferredHints.resolveWith(null, [hintResponse]);
}
}).fail(function () {
if (hintsArePending($deferredHints)) {
$deferredHints.reject();
}
});
return $deferredHints;
} else if (hintsArePending($deferredHints)) {
setCachedHintContext(hintResults.hints, cursor, type, token);
var hintResponse = getHintResponse(cachedHints, query, type);
$deferredHints.resolveWith(null, [hintResponse]);
return null;
} else {
setCachedHintContext(hintResults.hints, cursor, type, token);
return getHintResponse(cachedHints, query, type);
}
} | [
"function",
"getSessionHints",
"(",
"query",
",",
"cursor",
",",
"type",
",",
"token",
",",
"$deferredHints",
")",
"{",
"var",
"hintResults",
"=",
"session",
".",
"getHints",
"(",
"query",
",",
"getStringMatcher",
"(",
")",
")",
";",
"if",
"(",
"hintResult... | Common code to get the session hints. Will get guesses if there were
no completions for the query.
@param {string} query - user text to search hints with
@param {{line:number, ch:number}} cursor - the location where the hints
were created.
@param {{property: boolean,
showFunctionType:boolean,
context: string,
functionCallPos: {line:number, ch:number}}} type -
type information about the hints
@param {Object} token - CodeMirror token
@param {jQuery.Deferred=} $deferredHints - existing Deferred we need to
resolve (optional). If not supplied a new Deferred will be created if
needed.
@return {Object + jQuery.Deferred} - hint response (immediate or
deferred) as defined by the CodeHintManager API | [
"Common",
"code",
"to",
"get",
"the",
"session",
"hints",
".",
"Will",
"get",
"guesses",
"if",
"there",
"were",
"no",
"completions",
"for",
"the",
"query",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptCodeHints/main.js#L442-L476 | train | Get session hints | [
30522,
3853,
4152,
7971,
3258,
10606,
3215,
1006,
23032,
1010,
12731,
25301,
2099,
1010,
2828,
1010,
19204,
1010,
1002,
13366,
28849,
19114,
7666,
1007,
1063,
13075,
9374,
6072,
11314,
2015,
1027,
5219,
1012,
2131,
10606,
3215,
1006,
23032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
TryGhost/Ghost | core/server/ghost-server.js | GhostServer | function GhostServer(rootApp) {
this.rootApp = rootApp;
this.httpServer = null;
this.connections = {};
this.connectionId = 0;
// Expose config module for use externally.
this.config = config;
} | javascript | function GhostServer(rootApp) {
this.rootApp = rootApp;
this.httpServer = null;
this.connections = {};
this.connectionId = 0;
// Expose config module for use externally.
this.config = config;
} | [
"function",
"GhostServer",
"(",
"rootApp",
")",
"{",
"this",
".",
"rootApp",
"=",
"rootApp",
";",
"this",
".",
"httpServer",
"=",
"null",
";",
"this",
".",
"connections",
"=",
"{",
"}",
";",
"this",
".",
"connectionId",
"=",
"0",
";",
"// Expose config m... | ## GhostServer
@constructor
@param {Object} rootApp - parent express instance | [
"##",
"GhostServer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/ghost-server.js#L18-L26 | train | GhostServer constructor. | [
30522,
3853,
11277,
2121,
6299,
1006,
7117,
29098,
1007,
1063,
2023,
1012,
7117,
29098,
1027,
7117,
29098,
1025,
2023,
1012,
16770,
2121,
6299,
1027,
19701,
1025,
2023,
1012,
7264,
1027,
1063,
1065,
1025,
2023,
1012,
4434,
3593,
1027,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
elastic/elasticsearch-js | api/api/update_by_query.js | buildUpdateByQuery | function buildUpdateByQuery (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request
*
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {number} from - Starting offset (default: 0)
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} conflicts - What to do when the update by query hits version conflicts?
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {string} pipeline - Ingest pipeline to set on index requests made by this action. (default: none)
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {string} q - Query in the Lucene query string syntax
* @param {list} routing - A comma-separated list of specific routing values
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {enum} search_type - Search operation type
* @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {number} size - Number of hits to return (default: 10)
* @param {list} sort - A comma-separated list of <field>:<direction> pairs
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* @param {list} stats - Specific 'tag' of the request for logging and statistical purposes
* @param {boolean} version - Specify whether to return document version as part of a hit
* @param {boolean} version_type - Should the document increment the version number (internal) on hit or not (reindex)
* @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {boolean} refresh - Should the effected indexes be refreshed?
* @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable.
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {number} scroll_size - Size on the scroll request powering the update by query
* @param {boolean} wait_for_completion - Should the request should block until the update by query operation is complete.
* @param {number} requests_per_second - The throttle to set on this request in sub-requests per second. -1 means no throttle.
* @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
* @param {object} body - The search definition using the Query DSL
*/
const acceptedQuerystring = [
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'from',
'ignore_unavailable',
'allow_no_indices',
'conflicts',
'expand_wildcards',
'lenient',
'pipeline',
'preference',
'q',
'routing',
'scroll',
'search_type',
'search_timeout',
'size',
'sort',
'_source',
'_source_excludes',
'_source_includes',
'terminate_after',
'stats',
'version',
'version_type',
'request_cache',
'refresh',
'timeout',
'wait_for_active_shards',
'scroll_size',
'wait_for_completion',
'requests_per_second',
'slices',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
analyzeWildcard: 'analyze_wildcard',
defaultOperator: 'default_operator',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
searchTimeout: 'search_timeout',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
terminateAfter: 'terminate_after',
versionType: 'version_type',
requestCache: 'request_cache',
waitForActiveShards: 'wait_for_active_shards',
scrollSize: 'scroll_size',
waitForCompletion: 'wait_for_completion',
requestsPerSecond: 'requests_per_second',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function updateByQuery (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildUpdateByQuery (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request
*
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {number} from - Starting offset (default: 0)
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} conflicts - What to do when the update by query hits version conflicts?
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {string} pipeline - Ingest pipeline to set on index requests made by this action. (default: none)
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {string} q - Query in the Lucene query string syntax
* @param {list} routing - A comma-separated list of specific routing values
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {enum} search_type - Search operation type
* @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {number} size - Number of hits to return (default: 10)
* @param {list} sort - A comma-separated list of <field>:<direction> pairs
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* @param {list} stats - Specific 'tag' of the request for logging and statistical purposes
* @param {boolean} version - Specify whether to return document version as part of a hit
* @param {boolean} version_type - Should the document increment the version number (internal) on hit or not (reindex)
* @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {boolean} refresh - Should the effected indexes be refreshed?
* @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable.
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {number} scroll_size - Size on the scroll request powering the update by query
* @param {boolean} wait_for_completion - Should the request should block until the update by query operation is complete.
* @param {number} requests_per_second - The throttle to set on this request in sub-requests per second. -1 means no throttle.
* @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
* @param {object} body - The search definition using the Query DSL
*/
const acceptedQuerystring = [
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'from',
'ignore_unavailable',
'allow_no_indices',
'conflicts',
'expand_wildcards',
'lenient',
'pipeline',
'preference',
'q',
'routing',
'scroll',
'search_type',
'search_timeout',
'size',
'sort',
'_source',
'_source_excludes',
'_source_includes',
'terminate_after',
'stats',
'version',
'version_type',
'request_cache',
'refresh',
'timeout',
'wait_for_active_shards',
'scroll_size',
'wait_for_completion',
'requests_per_second',
'slices',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
analyzeWildcard: 'analyze_wildcard',
defaultOperator: 'default_operator',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
searchTimeout: 'search_timeout',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
terminateAfter: 'terminate_after',
versionType: 'version_type',
requestCache: 'request_cache',
waitForActiveShards: 'wait_for_active_shards',
scrollSize: 'scroll_size',
waitForCompletion: 'wait_for_completion',
requestsPerSecond: 'requests_per_second',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function updateByQuery (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildUpdateByQuery",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [update_by_query](https://www.elastic.... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/update_by_query.js#L25-L195 | train | Build an update by query | [
30522,
3853,
3857,
6279,
13701,
3762,
4226,
2854,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
15171,
1011,
13075,
2015,
9530,
3367,
1063,
9338,
2063,
15500,
1010,
9563,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | scripts/changelog/util.js | addVersionJSONToChangelog | function addVersionJSONToChangelog(version, changes) {
if (!changelog) readChangelog();
var entry = '\n\n## ' + version;
changes.forEach(function(change) {
entry += '\n* ' + change.type + ': ' + change.category + ': ' +
change.description;
});
var logParts = changelog.split(insertMarker);
logParts[0] = logParts[0]
.replace(versionMarkerReg, versionMarker.join(version)) + insertMarker;
changelog = logParts.join(entry);
} | javascript | function addVersionJSONToChangelog(version, changes) {
if (!changelog) readChangelog();
var entry = '\n\n## ' + version;
changes.forEach(function(change) {
entry += '\n* ' + change.type + ': ' + change.category + ': ' +
change.description;
});
var logParts = changelog.split(insertMarker);
logParts[0] = logParts[0]
.replace(versionMarkerReg, versionMarker.join(version)) + insertMarker;
changelog = logParts.join(entry);
} | [
"function",
"addVersionJSONToChangelog",
"(",
"version",
",",
"changes",
")",
"{",
"if",
"(",
"!",
"changelog",
")",
"readChangelog",
"(",
")",
";",
"var",
"entry",
"=",
"'\\n\\n## '",
"+",
"version",
";",
"changes",
".",
"forEach",
"(",
"function",
"(",
"... | This will not to write to file writeToChangelog must be called after | [
"This",
"will",
"not",
"to",
"write",
"to",
"file",
"writeToChangelog",
"must",
"be",
"called",
"after"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/scripts/changelog/util.js#L137-L150 | train | Add version to changelog | [
30522,
3853,
5587,
27774,
22578,
12162,
11663,
22043,
21197,
1006,
2544,
1010,
3431,
1007,
1063,
2065,
1006,
999,
2689,
21197,
1007,
3191,
22305,
18349,
2290,
1006,
1007,
1025,
13075,
4443,
1027,
1005,
1032,
1050,
1032,
1050,
1001,
1001,
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... |
jiahaog/nativefier | src/helpers/convertToIcns.js | convertToIcnsTmp | function convertToIcnsTmp(pngSrc, callback) {
const tempIconDirObj = tmp.dirSync({ unsafeCleanup: true });
const tempIconDirPath = tempIconDirObj.name;
convertToIcns(pngSrc, `${tempIconDirPath}/icon.icns`, callback);
} | javascript | function convertToIcnsTmp(pngSrc, callback) {
const tempIconDirObj = tmp.dirSync({ unsafeCleanup: true });
const tempIconDirPath = tempIconDirObj.name;
convertToIcns(pngSrc, `${tempIconDirPath}/icon.icns`, callback);
} | [
"function",
"convertToIcnsTmp",
"(",
"pngSrc",
",",
"callback",
")",
"{",
"const",
"tempIconDirObj",
"=",
"tmp",
".",
"dirSync",
"(",
"{",
"unsafeCleanup",
":",
"true",
"}",
")",
";",
"const",
"tempIconDirPath",
"=",
"tempIconDirObj",
".",
"name",
";",
"conv... | Converts the png to a temporary directory which will be cleaned up on process exit
@param {string} pngSrc
@param {pngToIcnsCallback} callback | [
"Converts",
"the",
"png",
"to",
"a",
"temporary",
"directory",
"which",
"will",
"be",
"cleaned",
"up",
"on",
"process",
"exit"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/src/helpers/convertToIcns.js#L59-L63 | train | Convert image to Icns | [
30522,
3853,
10463,
3406,
2594,
23808,
8737,
1006,
1052,
3070,
21338,
2278,
1010,
2655,
5963,
1007,
1063,
9530,
3367,
8915,
8737,
28524,
4305,
3217,
2497,
3501,
1027,
1056,
8737,
1012,
16101,
6508,
12273,
1006,
1063,
25135,
14321,
24076,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/geom/flat/closest.js | assignClosest | function assignClosest(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
const x1 = flatCoordinates[offset1];
const y1 = flatCoordinates[offset1 + 1];
const dx = flatCoordinates[offset2] - x1;
const dy = flatCoordinates[offset2 + 1] - y1;
let offset;
if (dx === 0 && dy === 0) {
offset = offset1;
} else {
const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
if (t > 1) {
offset = offset2;
} else if (t > 0) {
for (let i = 0; i < stride; ++i) {
closestPoint[i] = lerp(flatCoordinates[offset1 + i],
flatCoordinates[offset2 + i], t);
}
closestPoint.length = stride;
return;
} else {
offset = offset1;
}
}
for (let i = 0; i < stride; ++i) {
closestPoint[i] = flatCoordinates[offset + i];
}
closestPoint.length = stride;
} | javascript | function assignClosest(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
const x1 = flatCoordinates[offset1];
const y1 = flatCoordinates[offset1 + 1];
const dx = flatCoordinates[offset2] - x1;
const dy = flatCoordinates[offset2 + 1] - y1;
let offset;
if (dx === 0 && dy === 0) {
offset = offset1;
} else {
const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
if (t > 1) {
offset = offset2;
} else if (t > 0) {
for (let i = 0; i < stride; ++i) {
closestPoint[i] = lerp(flatCoordinates[offset1 + i],
flatCoordinates[offset2 + i], t);
}
closestPoint.length = stride;
return;
} else {
offset = offset1;
}
}
for (let i = 0; i < stride; ++i) {
closestPoint[i] = flatCoordinates[offset + i];
}
closestPoint.length = stride;
} | [
"function",
"assignClosest",
"(",
"flatCoordinates",
",",
"offset1",
",",
"offset2",
",",
"stride",
",",
"x",
",",
"y",
",",
"closestPoint",
")",
"{",
"const",
"x1",
"=",
"flatCoordinates",
"[",
"offset1",
"]",
";",
"const",
"y1",
"=",
"flatCoordinates",
"... | Returns the point on the 2D line segment flatCoordinates[offset1] to
flatCoordinates[offset2] that is closest to the point (x, y). Extra
dimensions are linearly interpolated.
@param {Array<number>} flatCoordinates Flat coordinates.
@param {number} offset1 Offset 1.
@param {number} offset2 Offset 2.
@param {number} stride Stride.
@param {number} x X.
@param {number} y Y.
@param {Array<number>} closestPoint Closest point. | [
"Returns",
"the",
"point",
"on",
"the",
"2D",
"line",
"segment",
"flatCoordinates",
"[",
"offset1",
"]",
"to",
"flatCoordinates",
"[",
"offset2",
"]",
"that",
"is",
"closest",
"to",
"the",
"point",
"(",
"x",
"y",
")",
".",
"Extra",
"dimensions",
"are",
"... | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/geom/flat/closest.js#L19-L46 | train | assigns the closest point to the given coordinates | [
30522,
3853,
23911,
20464,
27465,
2102,
1006,
4257,
3597,
8551,
28184,
1010,
16396,
2487,
1010,
16396,
2475,
1010,
18045,
1010,
1060,
1010,
1061,
1010,
7541,
8400,
1007,
1063,
9530,
3367,
1060,
2487,
1027,
4257,
3597,
8551,
28184,
1031,
163... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/credentials/cognito_identity_credentials.js | clearCache | function clearCache() {
this._identityId = null;
delete this.params.IdentityId;
var poolId = this.params.IdentityPoolId;
var loginId = this.params.LoginId || '';
delete this.storage[this.localStorageKey.id + poolId + loginId];
delete this.storage[this.localStorageKey.providers + poolId + loginId];
} | javascript | function clearCache() {
this._identityId = null;
delete this.params.IdentityId;
var poolId = this.params.IdentityPoolId;
var loginId = this.params.LoginId || '';
delete this.storage[this.localStorageKey.id + poolId + loginId];
delete this.storage[this.localStorageKey.providers + poolId + loginId];
} | [
"function",
"clearCache",
"(",
")",
"{",
"this",
".",
"_identityId",
"=",
"null",
";",
"delete",
"this",
".",
"params",
".",
"IdentityId",
";",
"var",
"poolId",
"=",
"this",
".",
"params",
".",
"IdentityPoolId",
";",
"var",
"loginId",
"=",
"this",
".",
... | Clears the cached Cognito ID associated with the currently configured
identity pool ID. Use this to manually invalidate your cache if
the identity pool ID was deleted. | [
"Clears",
"the",
"cached",
"Cognito",
"ID",
"associated",
"with",
"the",
"currently",
"configured",
"identity",
"pool",
"ID",
".",
"Use",
"this",
"to",
"manually",
"invalidate",
"your",
"cache",
"if",
"the",
"identity",
"pool",
"ID",
"was",
"deleted",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/cognito_identity_credentials.js#L191-L199 | train | Clear the cache | [
30522,
3853,
3154,
3540,
5403,
1006,
1007,
1063,
2023,
1012,
1035,
4767,
3593,
1027,
19701,
1025,
3972,
12870,
2023,
1012,
11498,
5244,
1012,
4767,
3593,
1025,
13075,
4770,
3593,
1027,
2023,
1012,
11498,
5244,
1012,
4767,
16869,
3593,
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... |
electron/electron | lib/browser/chrome-extension.js | function (srcDirectory) {
let manifest
let manifestContent
try {
manifestContent = fs.readFileSync(path.join(srcDirectory, 'manifest.json'))
} catch (readError) {
console.warn(`Reading ${path.join(srcDirectory, 'manifest.json')} failed.`)
console.warn(readError.stack || readError)
throw readError
}
try {
manifest = JSON.parse(manifestContent)
} catch (parseError) {
console.warn(`Parsing ${path.join(srcDirectory, 'manifest.json')} failed.`)
console.warn(parseError.stack || parseError)
throw parseError
}
if (!manifestNameMap[manifest.name]) {
const extensionId = generateExtensionIdFromName(manifest.name)
manifestMap[extensionId] = manifestNameMap[manifest.name] = manifest
Object.assign(manifest, {
srcDirectory: srcDirectory,
extensionId: extensionId,
// We can not use 'file://' directly because all resources in the extension
// will be treated as relative to the root in Chrome.
startPage: url.format({
protocol: 'chrome-extension',
slashes: true,
hostname: extensionId,
pathname: manifest.devtools_page
})
})
return manifest
} else if (manifest && manifest.name) {
console.warn(`Attempted to load extension "${manifest.name}" that has already been loaded.`)
return manifest
}
} | javascript | function (srcDirectory) {
let manifest
let manifestContent
try {
manifestContent = fs.readFileSync(path.join(srcDirectory, 'manifest.json'))
} catch (readError) {
console.warn(`Reading ${path.join(srcDirectory, 'manifest.json')} failed.`)
console.warn(readError.stack || readError)
throw readError
}
try {
manifest = JSON.parse(manifestContent)
} catch (parseError) {
console.warn(`Parsing ${path.join(srcDirectory, 'manifest.json')} failed.`)
console.warn(parseError.stack || parseError)
throw parseError
}
if (!manifestNameMap[manifest.name]) {
const extensionId = generateExtensionIdFromName(manifest.name)
manifestMap[extensionId] = manifestNameMap[manifest.name] = manifest
Object.assign(manifest, {
srcDirectory: srcDirectory,
extensionId: extensionId,
// We can not use 'file://' directly because all resources in the extension
// will be treated as relative to the root in Chrome.
startPage: url.format({
protocol: 'chrome-extension',
slashes: true,
hostname: extensionId,
pathname: manifest.devtools_page
})
})
return manifest
} else if (manifest && manifest.name) {
console.warn(`Attempted to load extension "${manifest.name}" that has already been loaded.`)
return manifest
}
} | [
"function",
"(",
"srcDirectory",
")",
"{",
"let",
"manifest",
"let",
"manifestContent",
"try",
"{",
"manifestContent",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"srcDirectory",
",",
"'manifest.json'",
")",
")",
"}",
"catch",
"(",
"readEr... | Create or get manifest object from |srcDirectory|. | [
"Create",
"or",
"get",
"manifest",
"object",
"from",
"|srcDirectory|",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/chrome-extension.js#L33-L73 | train | Load extension from a directory | [
30522,
3853,
1006,
5034,
19797,
7442,
16761,
2100,
1007,
1063,
2292,
19676,
2292,
19676,
8663,
6528,
2102,
3046,
1063,
19676,
8663,
6528,
2102,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
4130,
1012,
3693,
1006,
5034,
19797,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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(expr)
{
var result = null;
if (expr.indexOf('function') >= 0)
{
try
{
eval('var _mxJavaScriptExpression='+expr);
result = _mxJavaScriptExpression;
// TODO: Use delete here?
_mxJavaScriptExpression = null;
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
else
{
try
{
result = eval(expr);
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
return result;
} | javascript | function(expr)
{
var result = null;
if (expr.indexOf('function') >= 0)
{
try
{
eval('var _mxJavaScriptExpression='+expr);
result = _mxJavaScriptExpression;
// TODO: Use delete here?
_mxJavaScriptExpression = null;
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
else
{
try
{
result = eval(expr);
}
catch (e)
{
mxLog.warn(e.message + ' while evaluating ' + expr);
}
}
return result;
} | [
"function",
"(",
"expr",
")",
"{",
"var",
"result",
"=",
"null",
";",
"if",
"(",
"expr",
".",
"indexOf",
"(",
"'function'",
")",
">=",
"0",
")",
"{",
"try",
"{",
"eval",
"(",
"'var _mxJavaScriptExpression='",
"+",
"expr",
")",
";",
"result",
"=",
"_m... | Function: eval
Evaluates the given expression using eval and returns the JavaScript
object that represents the expression result. Supports evaluation of
expressions that define functions and returns the function object for
these expressions.
Parameters:
expr - A string that represents a JavaScript expression. | [
"Function",
":",
"eval"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L2358-L2389 | train | eval the expression | [
30522,
3853,
1006,
4654,
18098,
1007,
1063,
13075,
2765,
1027,
19701,
1025,
2065,
1006,
4654,
18098,
1012,
5950,
11253,
1006,
1005,
3853,
1005,
1007,
1028,
1027,
1014,
1007,
1063,
3046,
1063,
9345,
2140,
1006,
1005,
13075,
1035,
25630,
3900... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | FileStorage | function FileStorage(path, createIfMissing, recreateIfInvalid) {
this.path = path;
this.createIfMissing = createIfMissing;
this.recreateIfInvalid = recreateIfInvalid;
this._lineEndings = FileUtils.getPlatformLineEndings();
} | javascript | function FileStorage(path, createIfMissing, recreateIfInvalid) {
this.path = path;
this.createIfMissing = createIfMissing;
this.recreateIfInvalid = recreateIfInvalid;
this._lineEndings = FileUtils.getPlatformLineEndings();
} | [
"function",
"FileStorage",
"(",
"path",
",",
"createIfMissing",
",",
"recreateIfInvalid",
")",
"{",
"this",
".",
"path",
"=",
"path",
";",
"this",
".",
"createIfMissing",
"=",
"createIfMissing",
";",
"this",
".",
"recreateIfInvalid",
"=",
"recreateIfInvalid",
";... | Loads/saves preferences from a JSON file on disk.
@constructor
@param {string} path Path to the preferences file
@param {boolean} createIfMissing True if the file should be created if it doesn't exist.
If this is not true, an exception will be thrown if the
file does not exist.
@param {boolean} recreateIfInvalid True if the file needs to be recreated if it is invalid.
Invalid- Either unreadable or unparseable.
The invalid copy will be sent to trash in case the user wants to refer to it. | [
"Loads",
"/",
"saves",
"preferences",
"from",
"a",
"JSON",
"file",
"on",
"disk",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L155-L160 | train | FileStorage constructor. | [
30522,
3853,
6764,
4263,
4270,
1006,
4130,
1010,
3443,
10128,
15630,
7741,
1010,
28667,
29313,
10128,
2378,
10175,
3593,
1007,
1063,
2023,
1012,
4130,
1027,
4130,
1025,
2023,
1012,
3443,
10128,
15630,
7741,
1027,
3443,
10128,
15630,
7741,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_BoolErr | function parse_BoolErr(blob, length, opts) {
var cell = parse_XLSCell(blob, 6);
if(opts.biff == 2) ++blob.l;
var val = parse_Bes(blob, 2);
cell.val = val;
cell.t = (val === true || val === false) ? 'b' : 'e';
return cell;
} | javascript | function parse_BoolErr(blob, length, opts) {
var cell = parse_XLSCell(blob, 6);
if(opts.biff == 2) ++blob.l;
var val = parse_Bes(blob, 2);
cell.val = val;
cell.t = (val === true || val === false) ? 'b' : 'e';
return cell;
} | [
"function",
"parse_BoolErr",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"cell",
"=",
"parse_XLSCell",
"(",
"blob",
",",
"6",
")",
";",
"if",
"(",
"opts",
".",
"biff",
"==",
"2",
")",
"++",
"blob",
".",
"l",
";",
"var",
"val",
"=",
... | /* [MS-XLS] 2.4.24 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"24"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6151-L6158 | train | Parse bool error cell | [
30522,
3853,
11968,
3366,
1035,
22017,
3917,
2099,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
3526,
1027,
11968,
3366,
1035,
28712,
11020,
5349,
1006,
1038,
4135,
2497,
1010,
1020,
1007,
1025,
2065,
1006,
2356... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.