repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
adobe/brackets | src/document/DocumentManager.js | addToWorkingSet | function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
} | javascript | function addToWorkingSet(file, index, forceRedraw) {
DeprecationWarning.deprecationWarning("Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()", true);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, file, index, forceRedraw);
} | [
"function",
"addToWorkingSet",
"(",
"file",
",",
"index",
",",
"forceRedraw",
")",
"{",
"DeprecationWarning",
".",
"deprecationWarning",
"(",
"\"Use MainViewManager.addToWorkingSet() instead of DocumentManager.addToWorkingSet()\"",
",",
"true",
")",
";",
"MainViewManager",
".... | Adds the given file to the end of the working set list.
@deprecated Use MainViewManager.addToWorkingSet() instead
@param {!File} file
@param {number=} index Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw If true, a working set change notification is always sent
(useful if suppressRedraw was used with removeFromWorkingSet() earlier) | [
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"working",
"set",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L202-L205 | train | Add a file to the working set | [
30522,
3853,
5587,
18790,
2953,
6834,
13462,
1006,
5371,
1010,
5950,
1010,
2486,
5596,
2527,
2860,
1007,
1063,
2139,
28139,
10719,
9028,
5582,
1012,
2139,
28139,
10719,
9028,
5582,
1006,
1000,
2224,
2364,
8584,
24805,
4590,
1012,
5587,
1879... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/FakeLrepConnector.js | handleGetTransports | function handleGetTransports(sUri, sMethod, oData, mOptions, resolve, reject){
if (sUri.match(/^\/sap\/bc\/lrep\/actions\/gettransports\//)){
resolve({
response: {
"transports": [
{
"transportId": "U31K008488",
"description": "The Ultimate Transport",
"owner": "Fantasy Owner",
"locked": true
}
],
"localonly": false,
"errorCode": ""
}
});
}
} | javascript | function handleGetTransports(sUri, sMethod, oData, mOptions, resolve, reject){
if (sUri.match(/^\/sap\/bc\/lrep\/actions\/gettransports\//)){
resolve({
response: {
"transports": [
{
"transportId": "U31K008488",
"description": "The Ultimate Transport",
"owner": "Fantasy Owner",
"locked": true
}
],
"localonly": false,
"errorCode": ""
}
});
}
} | [
"function",
"handleGetTransports",
"(",
"sUri",
",",
"sMethod",
",",
"oData",
",",
"mOptions",
",",
"resolve",
",",
"reject",
")",
"{",
"if",
"(",
"sUri",
".",
"match",
"(",
"/",
"^\\/sap\\/bc\\/lrep\\/actions\\/gettransports\\/",
"/",
")",
")",
"{",
"resolve"... | REVISE Make response configurable | [
"REVISE",
"Make",
"response",
"configurable"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/FakeLrepConnector.js#L216-L233 | train | Handle the get transports request | [
30522,
3853,
5047,
18150,
6494,
3619,
25378,
1006,
7505,
2072,
1010,
15488,
11031,
7716,
1010,
1051,
2850,
2696,
1010,
9587,
16790,
2015,
1010,
10663,
1010,
15454,
1007,
1063,
2065,
1006,
7505,
2072,
1012,
2674,
1006,
1013,
1034,
1032,
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... |
NetEase/pomelo | lib/server/server.js | function(id, crons) {
for(var i=0, l=crons.length; i<l; i++) {
if(id === crons[i].id) {
return true;
}
}
return false;
} | javascript | function(id, crons) {
for(var i=0, l=crons.length; i<l; i++) {
if(id === crons[i].id) {
return true;
}
}
return false;
} | [
"function",
"(",
"id",
",",
"crons",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"crons",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"id",
"===",
"crons",
"[",
"i",
"]",
".",
"id",
")",
"{",
"... | Check if cron is in crons. | [
"Check",
"if",
"cron",
"is",
"in",
"crons",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/server/server.js#L445-L452 | train | Check if the id is in the list of crons | [
30522,
3853,
1006,
8909,
1010,
13675,
5644,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
30524,
8909,
1027,
1027,
1027,
13675,
5644,
1031,
1045,
1033,
1012,
8909,
1007,
1063,
2709,
2995,
1025,
1065,
1065,
2709,
6270,
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... | |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(sel, range) {
var ranges = sel.getAllRanges();
sel.removeAllRanges();
for (var i = 0, len = ranges.length; i < len; ++i) {
if (!rangesEqual(range, ranges[i])) {
sel.addRange(ranges[i]);
}
}
if (!sel.rangeCount) {
updateEmptySelection(sel);
}
} | javascript | function(sel, range) {
var ranges = sel.getAllRanges();
sel.removeAllRanges();
for (var i = 0, len = ranges.length; i < len; ++i) {
if (!rangesEqual(range, ranges[i])) {
sel.addRange(ranges[i]);
}
}
if (!sel.rangeCount) {
updateEmptySelection(sel);
}
} | [
"function",
"(",
"sel",
",",
"range",
")",
"{",
"var",
"ranges",
"=",
"sel",
".",
"getAllRanges",
"(",
")",
";",
"sel",
".",
"removeAllRanges",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"ranges",
".",
"length",
";",
"i",
... | Removal of a single range | [
"Removal",
"of",
"a",
"single",
"range"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L3480-L3491 | train | update the selection | [
30522,
3853,
1006,
7367,
2140,
1010,
2846,
1007,
1063,
13075,
8483,
1027,
7367,
2140,
1012,
2131,
8095,
24388,
2229,
1006,
1007,
1025,
7367,
2140,
1012,
6366,
8095,
24388,
2229,
1006,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
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... | |
websockets/ws | lib/websocket.js | abortHandshake | function abortHandshake(websocket, stream, message) {
websocket.readyState = WebSocket.CLOSING;
const err = new Error(message);
Error.captureStackTrace(err, abortHandshake);
if (stream.setHeader) {
stream.abort();
stream.once('abort', websocket.emitClose.bind(websocket));
websocket.emit('error', err);
} else {
stream.destroy(err);
stream.once('error', websocket.emit.bind(websocket, 'error'));
stream.once('close', websocket.emitClose.bind(websocket));
}
} | javascript | function abortHandshake(websocket, stream, message) {
websocket.readyState = WebSocket.CLOSING;
const err = new Error(message);
Error.captureStackTrace(err, abortHandshake);
if (stream.setHeader) {
stream.abort();
stream.once('abort', websocket.emitClose.bind(websocket));
websocket.emit('error', err);
} else {
stream.destroy(err);
stream.once('error', websocket.emit.bind(websocket, 'error'));
stream.once('close', websocket.emitClose.bind(websocket));
}
} | [
"function",
"abortHandshake",
"(",
"websocket",
",",
"stream",
",",
"message",
")",
"{",
"websocket",
".",
"readyState",
"=",
"WebSocket",
".",
"CLOSING",
";",
"const",
"err",
"=",
"new",
"Error",
"(",
"message",
")",
";",
"Error",
".",
"captureStackTrace",
... | Abort the handshake and emit an error.
@param {WebSocket} websocket The WebSocket instance
@param {(http.ClientRequest|net.Socket)} stream The request to abort or the
socket to destroy
@param {String} message The error message
@private | [
"Abort",
"the",
"handshake",
"and",
"emit",
"an",
"error",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket.js#L684-L699 | train | Aborts the connection | [
30522,
3853,
11113,
28610,
29560,
20459,
2063,
1006,
4773,
6499,
19869,
2102,
1010,
5460,
1010,
4471,
1007,
1063,
4773,
6499,
19869,
2102,
1012,
3201,
9153,
2618,
1027,
4773,
6499,
19869,
2102,
1012,
5494,
1025,
9530,
3367,
9413,
2099,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mochajs/mocha | lib/browser/growl.js | function() {
// If user hasn't responded yet... "No notification for you!" (Seinfeld)
Promise.race([promise, Promise.resolve(undefined)])
.then(canNotify)
.then(function() {
display(runner);
})
.catch(notPermitted);
} | javascript | function() {
// If user hasn't responded yet... "No notification for you!" (Seinfeld)
Promise.race([promise, Promise.resolve(undefined)])
.then(canNotify)
.then(function() {
display(runner);
})
.catch(notPermitted);
} | [
"function",
"(",
")",
"{",
"// If user hasn't responded yet... \"No notification for you!\" (Seinfeld)",
"Promise",
".",
"race",
"(",
"[",
"promise",
",",
"Promise",
".",
"resolve",
"(",
"undefined",
")",
"]",
")",
".",
"then",
"(",
"canNotify",
")",
".",
"then",
... | Attempt notification. | [
"Attempt",
"notification",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/browser/growl.js#L47-L55 | train | If user has responded yet then notify user | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
2065,
5310,
8440,
1005,
1056,
5838,
2664,
1012,
1012,
1012,
1000,
2053,
26828,
2005,
2017,
999,
1000,
1006,
7367,
2378,
8151,
1007,
4872,
1012,
2679,
1006,
1031,
4872,
1010,
4872,
1012,
10663,
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/utils/BuildInfoUtils.js | _loadSHA | function _loadSHA(path, callback) {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.reject();
} else {
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
// to a file in /refs which in turn contains the SHA
var file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file).done(function (text) {
if (text.indexOf("ref: ") === 0) {
// e.g. "ref: refs/heads/branchname"
var basePath = path.substr(0, path.lastIndexOf("/")),
refRelPath = text.substr(5).trim(),
branch = text.substr(16).trim();
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
result.resolve({ branch: branch, sha: data.sha.trim() });
}).fail(function () {
result.resolve({ branch: branch });
});
} else {
result.resolve({ sha: text });
}
}).fail(function () {
result.reject();
});
}
return result.promise();
} | javascript | function _loadSHA(path, callback) {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.reject();
} else {
// HEAD contains a SHA in detached-head mode; otherwise it contains a relative path
// to a file in /refs which in turn contains the SHA
var file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file).done(function (text) {
if (text.indexOf("ref: ") === 0) {
// e.g. "ref: refs/heads/branchname"
var basePath = path.substr(0, path.lastIndexOf("/")),
refRelPath = text.substr(5).trim(),
branch = text.substr(16).trim();
_loadSHA(basePath + "/" + refRelPath, callback).done(function (data) {
result.resolve({ branch: branch, sha: data.sha.trim() });
}).fail(function () {
result.resolve({ branch: branch });
});
} else {
result.resolve({ sha: text });
}
}).fail(function () {
result.reject();
});
}
return result.promise();
} | [
"function",
"_loadSHA",
"(",
"path",
",",
"callback",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"brackets",
".",
"inBrowser",
")",
"{",
"result",
".",
"reject",
"(",
")",
";",
"}",
"else",
"{",
"// HEAD ... | Loads a SHA from Git metadata file. If the file contains a symbolic ref name, follows the ref
and loads the SHA from that file in turn. | [
"Loads",
"a",
"SHA",
"from",
"Git",
"metadata",
"file",
".",
"If",
"the",
"file",
"contains",
"a",
"symbolic",
"ref",
"name",
"follows",
"the",
"ref",
"and",
"loads",
"the",
"SHA",
"from",
"that",
"file",
"in",
"turn",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/BuildInfoUtils.js#L41-L71 | train | Load SHA from file | [
30522,
3853,
1035,
15665,
3270,
1006,
4130,
1010,
2655,
5963,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
2065,
1006,
19719,
1012,
1999,
12618,
9333,
2121,
1007,
1063,
2765,
1012,
15454,
1006,
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... |
statsd/statsd | lib/logger.js | function (config) {
this.config = config;
this.backend = this.config.backend || 'stdout';
this.level = this.config.level || "LOG_INFO";
if (this.backend == 'stdout') {
this.util = require('util');
} else {
if (this.backend == 'syslog') {
this.util = require('modern-syslog');
this.util.init(config.application || 'statsd', this.util.LOG_PID | this.util.LOG_ODELAY, this.util.LOG_LOCAL0);
} else {
throw "Logger: Should be 'stdout' or 'syslog'.";
}
}
} | javascript | function (config) {
this.config = config;
this.backend = this.config.backend || 'stdout';
this.level = this.config.level || "LOG_INFO";
if (this.backend == 'stdout') {
this.util = require('util');
} else {
if (this.backend == 'syslog') {
this.util = require('modern-syslog');
this.util.init(config.application || 'statsd', this.util.LOG_PID | this.util.LOG_ODELAY, this.util.LOG_LOCAL0);
} else {
throw "Logger: Should be 'stdout' or 'syslog'.";
}
}
} | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"backend",
"=",
"this",
".",
"config",
".",
"backend",
"||",
"'stdout'",
";",
"this",
".",
"level",
"=",
"this",
".",
"config",
".",
"level",
"||",
"\"LOG_IN... | /*jshint node:true, laxcomma:true | [
"/",
"*",
"jshint",
"node",
":",
"true",
"laxcomma",
":",
"true"
] | ef8e4d76d76c3a0cf771e3724cf79ea22f3c50d9 | https://github.com/statsd/statsd/blob/ef8e4d76d76c3a0cf771e3724cf79ea22f3c50d9/lib/logger.js#L3-L17 | train | Logger constructor. | [
30522,
3853,
1006,
9530,
8873,
2290,
1007,
1063,
2023,
1012,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1025,
2023,
1012,
2067,
10497,
1027,
2023,
1012,
9530,
8873,
2290,
1012,
2067,
10497,
1064,
1064,
1005,
2358,
26797,
2102,
1005,
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... | |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js | function (settings) {
var xy = this.bezier.coordinates,
ctx = this.canvas.getContext("2d"),
setting;
var defaultSettings = {
handleTimingFunction: "#2893ef",
handleThickness: 0.008,
vBorderThickness: 0.02,
hBorderThickness: 0.01,
bezierTimingFunction: "#2893ef",
bezierThickness: 0.03
};
settings = settings || {};
for (setting in defaultSettings) {
if (defaultSettings.hasOwnProperty(setting)) {
if (!settings.hasOwnProperty(setting)) {
settings[setting] = defaultSettings[setting];
}
}
}
ctx.clearRect(-0.5, -0.5, 2, 2);
// Draw control handles
ctx.beginPath();
ctx.fillStyle = settings.handleTimingFunction;
ctx.lineWidth = settings.handleThickness;
ctx.strokeStyle = settings.handleTimingFunction;
ctx.moveTo(0, 0);
ctx.lineTo(xy[0], xy[1]);
ctx.moveTo(1, 1);
ctx.lineTo(xy[2], xy[3]);
ctx.stroke();
ctx.closePath();
ctx.beginPath();
ctx.arc(xy[0], xy[1], 1.5 * settings.handleThickness, 0, 2 * Math.PI, false);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.arc(xy[2], xy[3], 1.5 * settings.handleThickness, 0, 2 * Math.PI, false);
ctx.closePath();
ctx.fill();
// Draw bezier curve
ctx.beginPath();
ctx.lineWidth = settings.bezierThickness;
ctx.strokeStyle = settings.bezierColor;
ctx.moveTo(0, 0);
ctx.bezierCurveTo(xy[0], xy[1], xy[2], xy[3], 1, 1);
ctx.stroke();
ctx.closePath();
} | javascript | function (settings) {
var xy = this.bezier.coordinates,
ctx = this.canvas.getContext("2d"),
setting;
var defaultSettings = {
handleTimingFunction: "#2893ef",
handleThickness: 0.008,
vBorderThickness: 0.02,
hBorderThickness: 0.01,
bezierTimingFunction: "#2893ef",
bezierThickness: 0.03
};
settings = settings || {};
for (setting in defaultSettings) {
if (defaultSettings.hasOwnProperty(setting)) {
if (!settings.hasOwnProperty(setting)) {
settings[setting] = defaultSettings[setting];
}
}
}
ctx.clearRect(-0.5, -0.5, 2, 2);
// Draw control handles
ctx.beginPath();
ctx.fillStyle = settings.handleTimingFunction;
ctx.lineWidth = settings.handleThickness;
ctx.strokeStyle = settings.handleTimingFunction;
ctx.moveTo(0, 0);
ctx.lineTo(xy[0], xy[1]);
ctx.moveTo(1, 1);
ctx.lineTo(xy[2], xy[3]);
ctx.stroke();
ctx.closePath();
ctx.beginPath();
ctx.arc(xy[0], xy[1], 1.5 * settings.handleThickness, 0, 2 * Math.PI, false);
ctx.closePath();
ctx.fill();
ctx.beginPath();
ctx.arc(xy[2], xy[3], 1.5 * settings.handleThickness, 0, 2 * Math.PI, false);
ctx.closePath();
ctx.fill();
// Draw bezier curve
ctx.beginPath();
ctx.lineWidth = settings.bezierThickness;
ctx.strokeStyle = settings.bezierColor;
ctx.moveTo(0, 0);
ctx.bezierCurveTo(xy[0], xy[1], xy[2], xy[3], 1, 1);
ctx.stroke();
ctx.closePath();
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"xy",
"=",
"this",
".",
"bezier",
".",
"coordinates",
",",
"ctx",
"=",
"this",
".",
"canvas",
".",
"getContext",
"(",
"\"2d\"",
")",
",",
"setting",
";",
"var",
"defaultSettings",
"=",
"{",
"handleTimingFunct... | Paint canvas
@param {Object} settings Paint settings | [
"Paint",
"canvas"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js#L150-L210 | train | Draw bezier curve | [
30522,
3853,
1006,
10906,
1007,
1063,
13075,
1060,
2100,
1027,
2023,
1012,
2022,
21548,
1012,
12093,
1010,
14931,
2595,
1027,
2023,
1012,
10683,
1012,
2131,
8663,
18209,
1006,
1000,
14134,
1000,
1007,
1010,
4292,
1025,
13075,
12398,
21678,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
lovell/sharp | lib/output.js | toFormat | function toFormat (format, options) {
if (is.object(format) && is.string(format.id)) {
format = format.id;
}
if (format === 'jpg') format = 'jpeg';
if (!is.inArray(format, ['jpeg', 'png', 'webp', 'tiff', 'raw'])) {
throw new Error('Unsupported output format ' + format);
}
return this[format](options);
} | javascript | function toFormat (format, options) {
if (is.object(format) && is.string(format.id)) {
format = format.id;
}
if (format === 'jpg') format = 'jpeg';
if (!is.inArray(format, ['jpeg', 'png', 'webp', 'tiff', 'raw'])) {
throw new Error('Unsupported output format ' + format);
}
return this[format](options);
} | [
"function",
"toFormat",
"(",
"format",
",",
"options",
")",
"{",
"if",
"(",
"is",
".",
"object",
"(",
"format",
")",
"&&",
"is",
".",
"string",
"(",
"format",
".",
"id",
")",
")",
"{",
"format",
"=",
"format",
".",
"id",
";",
"}",
"if",
"(",
"f... | Force output to a given format.
@example
// Convert any input to PNG output
const data = await sharp(input)
.toFormat('png')
.toBuffer();
@param {(String|Object)} format - as a String or an Object with an 'id' attribute
@param {Object} options - output options
@returns {Sharp}
@throws {Error} unsupported format or options | [
"Force",
"output",
"to",
"a",
"given",
"format",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/output.js#L461-L470 | train | Convert image to specified format | [
30522,
3853,
2000,
14192,
4017,
1006,
4289,
1010,
7047,
1007,
1063,
2065,
1006,
2003,
1012,
4874,
1006,
4289,
1007,
1004,
1004,
2003,
1012,
5164,
1006,
4289,
1012,
8909,
1007,
1007,
1063,
4289,
1027,
4289,
1012,
8909,
1025,
1065,
2065,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | stop | function stop() {
return function stopImpl(clearQueue, jumpToEnd) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
if (!cy.styleEnabled()) {
return this;
}
for (var i = 0; i < all.length; i++) {
var ele = all[i];
var _p = ele._private;
var anis = _p.animation.current;
for (var j = 0; j < anis.length; j++) {
var ani = anis[j];
var ani_p = ani._private;
if (jumpToEnd) {
// next iteration of the animation loop, the animation
// will go straight to the end and be removed
ani_p.duration = 0;
}
} // clear the queue of future animations
if (clearQueue) {
_p.animation.queue = [];
}
if (!jumpToEnd) {
_p.animation.current = [];
}
} // we have to notify (the animation loop doesn't do it for us on `stop`)
cy.notify('draw');
return this;
};
} | javascript | function stop() {
return function stopImpl(clearQueue, jumpToEnd) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
if (!cy.styleEnabled()) {
return this;
}
for (var i = 0; i < all.length; i++) {
var ele = all[i];
var _p = ele._private;
var anis = _p.animation.current;
for (var j = 0; j < anis.length; j++) {
var ani = anis[j];
var ani_p = ani._private;
if (jumpToEnd) {
// next iteration of the animation loop, the animation
// will go straight to the end and be removed
ani_p.duration = 0;
}
} // clear the queue of future animations
if (clearQueue) {
_p.animation.queue = [];
}
if (!jumpToEnd) {
_p.animation.current = [];
}
} // we have to notify (the animation loop doesn't do it for us on `stop`)
cy.notify('draw');
return this;
};
} | [
"function",
"stop",
"(",
")",
"{",
"return",
"function",
"stopImpl",
"(",
"clearQueue",
",",
"jumpToEnd",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"selfIsArrayLike",
"=",
"self",
".",
"length",
"!==",
"undefined",
";",
"var",
"all",
"=",
"selfIs... | animate | [
"animate"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L5929-L5971 | train | stop returns a function that will stop the current iteration of the animation loop | [
30522,
3853,
2644,
1006,
1007,
1063,
2709,
3853,
2644,
5714,
24759,
1006,
3154,
4226,
5657,
1010,
5376,
3406,
10497,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
2969,
14268,
11335,
8516,
17339,
1027,
2969,
1012,
3091,
999,
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... |
showdownjs/showdown | dist/showdown.js | createEvent | function createEvent (rgx, evtName, wholeMatch, text, id, url, title, options, globals) {
return globals.converter._dispatch(evtName, wholeMatch, options, globals, {
regexp: rgx,
matches: {
wholeMatch: wholeMatch,
text: text,
id: id,
url: url,
title: title
}
});
} | javascript | function createEvent (rgx, evtName, wholeMatch, text, id, url, title, options, globals) {
return globals.converter._dispatch(evtName, wholeMatch, options, globals, {
regexp: rgx,
matches: {
wholeMatch: wholeMatch,
text: text,
id: id,
url: url,
title: title
}
});
} | [
"function",
"createEvent",
"(",
"rgx",
",",
"evtName",
",",
"wholeMatch",
",",
"text",
",",
"id",
",",
"url",
",",
"title",
",",
"options",
",",
"globals",
")",
"{",
"return",
"globals",
".",
"converter",
".",
"_dispatch",
"(",
"evtName",
",",
"wholeMatc... | TODO Normalize this
Helper function: Create a capture event
@param {RegExp} rgx
@param {String} evtName Event name
@param {String} wholeMatch
@param {String} text
@param {String} id
@param {String} url
@param {String} title
@param {{}} options
@param {{}} globals
@returns {showdown.helper.Event|*} | [
"TODO",
"Normalize",
"this",
"Helper",
"function",
":",
"Create",
"a",
"capture",
"event"
] | 33bba54535d6fcdde5c82d2ec4d7a3bd951b5bb9 | https://github.com/showdownjs/showdown/blob/33bba54535d6fcdde5c82d2ec4d7a3bd951b5bb9/dist/showdown.js#L3299-L3310 | train | Creates a new event | [
30522,
3853,
3443,
18697,
3372,
1006,
1054,
2290,
2595,
1010,
23408,
2102,
18442,
1010,
2878,
18900,
2818,
1010,
3793,
1010,
8909,
1010,
24471,
2140,
1010,
2516,
1010,
7047,
1010,
3795,
2015,
1007,
1063,
2709,
3795,
2015,
1012,
10463,
2121,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/api/encodeProgress.js | encodeProgress | function encodeProgress(output, page) {
var current = page.getPath();
var navigation = encodeNavigation(output);
navigation = Immutable.Map(navigation);
var n = navigation.size;
var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = navigation
.map(function(nav, chapterPath) {
nav.path = chapterPath;
return nav;
})
.valueSeq()
.sortBy(function(nav) {
return nav.index;
})
.map(function(nav, i) {
// Calcul percent
nav.percent = (i * 100) / Math.max((n - 1), 1);
// Is it done
nav.done = done;
if (nav.path == current) {
currentChapter = nav;
percent = nav.percent;
done = false;
} else if (done) {
prevPercent = nav.percent;
}
return nav;
})
.toJS();
return {
// Previous percent
prevPercent: prevPercent,
// Current percent
percent: percent,
// List of chapter with progress
chapters: chapters,
// Current chapter
current: currentChapter
};
} | javascript | function encodeProgress(output, page) {
var current = page.getPath();
var navigation = encodeNavigation(output);
navigation = Immutable.Map(navigation);
var n = navigation.size;
var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = navigation
.map(function(nav, chapterPath) {
nav.path = chapterPath;
return nav;
})
.valueSeq()
.sortBy(function(nav) {
return nav.index;
})
.map(function(nav, i) {
// Calcul percent
nav.percent = (i * 100) / Math.max((n - 1), 1);
// Is it done
nav.done = done;
if (nav.path == current) {
currentChapter = nav;
percent = nav.percent;
done = false;
} else if (done) {
prevPercent = nav.percent;
}
return nav;
})
.toJS();
return {
// Previous percent
prevPercent: prevPercent,
// Current percent
percent: percent,
// List of chapter with progress
chapters: chapters,
// Current chapter
current: currentChapter
};
} | [
"function",
"encodeProgress",
"(",
"output",
",",
"page",
")",
"{",
"var",
"current",
"=",
"page",
".",
"getPath",
"(",
")",
";",
"var",
"navigation",
"=",
"encodeNavigation",
"(",
"output",
")",
";",
"navigation",
"=",
"Immutable",
".",
"Map",
"(",
"nav... | page.progress is a deprecated property from GitBook v2
@param {Output}
@param {Page}
@return {Object} | [
"page",
".",
"progress",
"is",
"a",
"deprecated",
"property",
"from",
"GitBook",
"v2"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeProgress.js#L11-L60 | train | Encode progress of a page | [
30522,
3853,
4372,
16044,
21572,
17603,
4757,
1006,
6434,
1010,
3931,
1007,
1063,
13075,
2783,
1027,
3931,
1012,
2131,
15069,
1006,
1007,
1025,
13075,
9163,
1027,
4372,
16044,
2532,
5737,
12540,
1006,
6434,
1007,
1025,
9163,
1027,
10047,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/InlineTimingFunctionEditor/main.js | inlineTimingFunctionEditorProvider | function inlineTimingFunctionEditorProvider(hostEditor, pos) {
var context = prepareEditorForProvider(hostEditor, pos),
inlineTimingFunctionEditor,
result;
if (!context.timingFunction) {
return context.reason || null;
} else {
inlineTimingFunctionEditor = new InlineTimingFunctionEditor(context.timingFunction, context.start, context.end);
inlineTimingFunctionEditor.load(hostEditor);
result = new $.Deferred();
result.resolve(inlineTimingFunctionEditor);
return result.promise();
}
} | javascript | function inlineTimingFunctionEditorProvider(hostEditor, pos) {
var context = prepareEditorForProvider(hostEditor, pos),
inlineTimingFunctionEditor,
result;
if (!context.timingFunction) {
return context.reason || null;
} else {
inlineTimingFunctionEditor = new InlineTimingFunctionEditor(context.timingFunction, context.start, context.end);
inlineTimingFunctionEditor.load(hostEditor);
result = new $.Deferred();
result.resolve(inlineTimingFunctionEditor);
return result.promise();
}
} | [
"function",
"inlineTimingFunctionEditorProvider",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"context",
"=",
"prepareEditorForProvider",
"(",
"hostEditor",
",",
"pos",
")",
",",
"inlineTimingFunctionEditor",
",",
"result",
";",
"if",
"(",
"!",
"context",
".",... | Registered as an inline editor provider: creates an InlineTimingFunctionEditor
when the cursor is on a timing function value.
@param {!Editor} hostEditor
@param {!{line:Number, ch:Number}} pos
@return {?$.Promise} synchronously resolved with an InlineWidget, or
{string} if timing function with invalid syntax is detected at pos, or
null if there's no timing function at pos. | [
"Registered",
"as",
"an",
"inline",
"editor",
"provider",
":",
"creates",
"an",
"InlineTimingFunctionEditor",
"when",
"the",
"cursor",
"is",
"on",
"a",
"timing",
"function",
"value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/main.js#L134-L149 | train | inlineTimingFunctionEditorProvider - Provider for inlineTimingFunctionEditor | [
30522,
3853,
23881,
3775,
6562,
11263,
27989,
2098,
15660,
21572,
17258,
2121,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1063,
13075,
6123,
1027,
7374,
2098,
15660,
29278,
21572,
17258,
2121,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js | function(oTable, iLocationX) {
var oHeaderDomRef, $HeaderDomRef, oRect, iWidth, oPos, bBefore, bAfter;
for (var i = 0; i < oTable._aTableHeaders.length; i++) {
oHeaderDomRef = oTable._aTableHeaders[i];
$HeaderDomRef = jQuery(oHeaderDomRef);
oRect = oHeaderDomRef.getBoundingClientRect();
iWidth = $HeaderDomRef.outerWidth();
oPos = {
left: oRect.left,
center: oRect.left + iWidth / 2,
right: oRect.left + iWidth,
width: iWidth,
index: parseInt($HeaderDomRef.attr("data-sap-ui-headcolindex")),
id: $HeaderDomRef.attr("data-sap-ui-colid")
};
bBefore = iLocationX >= oPos.left && iLocationX <= oPos.center;
bAfter = iLocationX >= oPos.center && iLocationX <= oPos.right;
if (bBefore || bAfter) {
oPos.before = oTable._bRtlMode ? bAfter : bBefore;
oPos.after = oTable._bRtlMode ? bBefore : bAfter;
return oPos;
}
}
return null;
} | javascript | function(oTable, iLocationX) {
var oHeaderDomRef, $HeaderDomRef, oRect, iWidth, oPos, bBefore, bAfter;
for (var i = 0; i < oTable._aTableHeaders.length; i++) {
oHeaderDomRef = oTable._aTableHeaders[i];
$HeaderDomRef = jQuery(oHeaderDomRef);
oRect = oHeaderDomRef.getBoundingClientRect();
iWidth = $HeaderDomRef.outerWidth();
oPos = {
left: oRect.left,
center: oRect.left + iWidth / 2,
right: oRect.left + iWidth,
width: iWidth,
index: parseInt($HeaderDomRef.attr("data-sap-ui-headcolindex")),
id: $HeaderDomRef.attr("data-sap-ui-colid")
};
bBefore = iLocationX >= oPos.left && iLocationX <= oPos.center;
bAfter = iLocationX >= oPos.center && iLocationX <= oPos.right;
if (bBefore || bAfter) {
oPos.before = oTable._bRtlMode ? bAfter : bBefore;
oPos.after = oTable._bRtlMode ? bBefore : bAfter;
return oPos;
}
}
return null;
} | [
"function",
"(",
"oTable",
",",
"iLocationX",
")",
"{",
"var",
"oHeaderDomRef",
",",
"$HeaderDomRef",
",",
"oRect",
",",
"iWidth",
",",
"oPos",
",",
"bBefore",
",",
"bAfter",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"oTable",
".",
"_aTab... | /*
Finds the column which belongs to the current x position and returns information about this column. | [
"/",
"*",
"Finds",
"the",
"column",
"which",
"belongs",
"to",
"the",
"current",
"x",
"position",
"and",
"returns",
"information",
"about",
"this",
"column",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L612-L640 | train | Returns the position of the header that contains the given location. | [
30522,
3853,
1006,
27178,
3085,
1010,
6335,
23909,
2595,
1007,
1063,
13075,
2821,
13775,
2121,
9527,
2890,
2546,
1010,
1002,
20346,
9527,
2890,
2546,
1010,
10848,
6593,
1010,
1045,
9148,
11927,
2232,
1010,
6728,
2891,
1010,
22861,
12879,
56... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | docs/js/toc.js | maketoc | function maketoc(element, enableSections)
{
enableSections = (enableSections != null) ? enableSections : true;
var tmp = crawlDom(document.body, 2, 4, [], 30, enableSections);
if (tmp.childNodes.length > 0)
{
element.appendChild(tmp);
}
} | javascript | function maketoc(element, enableSections)
{
enableSections = (enableSections != null) ? enableSections : true;
var tmp = crawlDom(document.body, 2, 4, [], 30, enableSections);
if (tmp.childNodes.length > 0)
{
element.appendChild(tmp);
}
} | [
"function",
"maketoc",
"(",
"element",
",",
"enableSections",
")",
"{",
"enableSections",
"=",
"(",
"enableSections",
"!=",
"null",
")",
"?",
"enableSections",
":",
"true",
";",
"var",
"tmp",
"=",
"crawlDom",
"(",
"document",
".",
"body",
",",
"2",
",",
... | Creates a table of contents inside the given element. | [
"Creates",
"a",
"table",
"of",
"contents",
"inside",
"the",
"given",
"element",
"."
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/docs/js/toc.js#L4-L13 | train | Crawls the document and adds it to the DOM | [
30522,
3853,
2191,
3406,
2278,
1006,
5783,
1010,
12939,
18491,
2015,
1007,
1063,
12939,
18491,
2015,
1027,
1006,
12939,
18491,
2015,
999,
1027,
19701,
1007,
1029,
12939,
18491,
2015,
1024,
2995,
1025,
13075,
1056,
8737,
1027,
13529,
9527,
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... |
google/closure-library | closure/goog/html/sanitizer/noclobber.js | getElementStyle | function getElementStyle(element) {
assertHTMLElement(element);
return genericPropertyGet(
Methods.STYLE_GETTER, element, 'style', function(style) {
return style instanceof CSSStyleDeclaration;
});
} | javascript | function getElementStyle(element) {
assertHTMLElement(element);
return genericPropertyGet(
Methods.STYLE_GETTER, element, 'style', function(style) {
return style instanceof CSSStyleDeclaration;
});
} | [
"function",
"getElementStyle",
"(",
"element",
")",
"{",
"assertHTMLElement",
"(",
"element",
")",
";",
"return",
"genericPropertyGet",
"(",
"Methods",
".",
"STYLE_GETTER",
",",
"element",
",",
"'style'",
",",
"function",
"(",
"style",
")",
"{",
"return",
"sty... | Returns an element's style without falling prey to things like
<form><input name="style"></form>.
@param {!Element} element
@return {!CSSStyleDeclaration} | [
"Returns",
"an",
"element",
"s",
"style",
"without",
"falling",
"prey",
"to",
"things",
"like",
"<form",
">",
"<input",
"name",
"=",
"style",
">",
"<",
"/",
"form",
">",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/sanitizer/noclobber.js#L258-L264 | train | Get the style of an HTMLElement | [
30522,
3853,
2131,
12260,
8163,
27983,
1006,
5783,
1007,
1063,
20865,
11039,
19968,
12260,
3672,
1006,
5783,
1007,
1025,
2709,
12391,
21572,
4842,
3723,
18150,
1006,
4725,
1012,
2806,
1035,
2131,
3334,
1010,
30524,
25879,
3258,
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... |
swimlane/ngx-datatable | release/utils/sort.js | nextSortDir | function nextSortDir(sortType, current) {
if (sortType === types_1.SortType.single) {
if (current === types_1.SortDirection.asc) {
return types_1.SortDirection.desc;
}
else {
return types_1.SortDirection.asc;
}
}
else {
if (!current) {
return types_1.SortDirection.asc;
}
else if (current === types_1.SortDirection.asc) {
return types_1.SortDirection.desc;
}
else if (current === types_1.SortDirection.desc) {
return undefined;
}
// avoid TS7030: Not all code paths return a value.
return undefined;
}
} | javascript | function nextSortDir(sortType, current) {
if (sortType === types_1.SortType.single) {
if (current === types_1.SortDirection.asc) {
return types_1.SortDirection.desc;
}
else {
return types_1.SortDirection.asc;
}
}
else {
if (!current) {
return types_1.SortDirection.asc;
}
else if (current === types_1.SortDirection.asc) {
return types_1.SortDirection.desc;
}
else if (current === types_1.SortDirection.desc) {
return undefined;
}
// avoid TS7030: Not all code paths return a value.
return undefined;
}
} | [
"function",
"nextSortDir",
"(",
"sortType",
",",
"current",
")",
"{",
"if",
"(",
"sortType",
"===",
"types_1",
".",
"SortType",
".",
"single",
")",
"{",
"if",
"(",
"current",
"===",
"types_1",
".",
"SortDirection",
".",
"asc",
")",
"{",
"return",
"types_... | Gets the next sort direction | [
"Gets",
"the",
"next",
"sort",
"direction"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/sort.js#L8-L30 | train | Return the next sort direction | [
30522,
3853,
2279,
21748,
2102,
4305,
2099,
1006,
4066,
13874,
1010,
2783,
1007,
1063,
2065,
1006,
4066,
13874,
1027,
1027,
1027,
4127,
1035,
1015,
1012,
4066,
13874,
1012,
2309,
1007,
1063,
2065,
1006,
2783,
1027,
1027,
1027,
4127,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | _doLaunchAfterServerReady | function _doLaunchAfterServerReady(initialDoc) {
// update status
_setStatus(STATUS_CONNECTING);
_createLiveDocumentForFrame(initialDoc);
// start listening for requests
_server.start();
// Install a one-time event handler when connected to the launcher page
Inspector.one("connect", _onConnect);
// open browser to the interstitial page to prepare for loading agents
_openInterstitialPage();
// Once all agents loaded (see _onInterstitialPageLoad()), begin Live Highlighting for preprocessor documents
_openDeferred.done(function () {
// Setup activeEditorChange event listener so that we can track cursor positions in
// CSS preprocessor files and perform live preview highlighting on all elements with
// the current selector in the preprocessor file.
EditorManager.on("activeEditorChange", onActiveEditorChange);
// Explicitly trigger onActiveEditorChange so that live preview highlighting
// can be set up for the preprocessor files.
onActiveEditorChange(null, EditorManager.getActiveEditor(), null);
});
} | javascript | function _doLaunchAfterServerReady(initialDoc) {
// update status
_setStatus(STATUS_CONNECTING);
_createLiveDocumentForFrame(initialDoc);
// start listening for requests
_server.start();
// Install a one-time event handler when connected to the launcher page
Inspector.one("connect", _onConnect);
// open browser to the interstitial page to prepare for loading agents
_openInterstitialPage();
// Once all agents loaded (see _onInterstitialPageLoad()), begin Live Highlighting for preprocessor documents
_openDeferred.done(function () {
// Setup activeEditorChange event listener so that we can track cursor positions in
// CSS preprocessor files and perform live preview highlighting on all elements with
// the current selector in the preprocessor file.
EditorManager.on("activeEditorChange", onActiveEditorChange);
// Explicitly trigger onActiveEditorChange so that live preview highlighting
// can be set up for the preprocessor files.
onActiveEditorChange(null, EditorManager.getActiveEditor(), null);
});
} | [
"function",
"_doLaunchAfterServerReady",
"(",
"initialDoc",
")",
"{",
"// update status",
"_setStatus",
"(",
"STATUS_CONNECTING",
")",
";",
"_createLiveDocumentForFrame",
"(",
"initialDoc",
")",
";",
"// start listening for requests",
"_server",
".",
"start",
"(",
")",
... | helper function that actually does the launch once we are sure we have a doc and the server for that doc is up and running. | [
"helper",
"function",
"that",
"actually",
"does",
"the",
"launch",
"once",
"we",
"are",
"sure",
"we",
"have",
"a",
"doc",
"and",
"the",
"server",
"for",
"that",
"doc",
"is",
"up",
"and",
"running",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L1244-L1269 | train | Called after the server is ready | [
30522,
3853,
1035,
2079,
17298,
12680,
10354,
7747,
2121,
6299,
16416,
5149,
1006,
3988,
3527,
2278,
1007,
1063,
1013,
1013,
10651,
3570,
1035,
4520,
29336,
2271,
1006,
3570,
1035,
7176,
1007,
1025,
1035,
3443,
3669,
7178,
10085,
27417,
244... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | isModifierRequired | function isModifierRequired(modifiers, requestingName, requestedName) {
var requesting = find(modifiers, function (_ref) {
var name = _ref.name;
return name === requestingName;
});
var isRequired = !!requesting && modifiers.some(function (modifier) {
return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
});
if (!isRequired) {
var _requesting = '`' + requestingName + '`';
var requested = '`' + requestedName + '`';
console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
}
return isRequired;
} | javascript | function isModifierRequired(modifiers, requestingName, requestedName) {
var requesting = find(modifiers, function (_ref) {
var name = _ref.name;
return name === requestingName;
});
var isRequired = !!requesting && modifiers.some(function (modifier) {
return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
});
if (!isRequired) {
var _requesting = '`' + requestingName + '`';
var requested = '`' + requestedName + '`';
console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
}
return isRequired;
} | [
"function",
"isModifierRequired",
"(",
"modifiers",
",",
"requestingName",
",",
"requestedName",
")",
"{",
"var",
"requesting",
"=",
"find",
"(",
"modifiers",
",",
"function",
"(",
"_ref",
")",
"{",
"var",
"name",
"=",
"_ref",
".",
"name",
";",
"return",
"... | Helper used to know if the given modifier depends from another one.<br />
It checks if the needed modifier is listed and enabled.
@method
@memberof Popper.Utils
@param {Array} modifiers - list of modifiers
@param {String} requestingName - name of requesting modifier
@param {String} requestedName - name of requested modifier
@returns {Boolean} | [
"Helper",
"used",
"to",
"know",
"if",
"the",
"given",
"modifier",
"depends",
"from",
"another",
"one",
".",
"<br",
"/",
">",
"It",
"checks",
"if",
"the",
"needed",
"modifier",
"is",
"listed",
"and",
"enabled",
"."
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1365-L1381 | train | Checks if a modifier is required by a particular specification | [
30522,
3853,
2003,
5302,
4305,
8873,
28849,
15549,
5596,
1006,
16913,
28295,
1010,
17942,
18442,
1010,
7303,
18442,
1007,
1063,
13075,
17942,
1027,
2424,
1006,
16913,
28295,
1010,
3853,
1006,
1035,
25416,
1007,
1063,
13075,
2171,
1027,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | tracing/third_party/oboe/src/instanceApi.js | addProtectedCallback | function addProtectedCallback(eventName, callback) {
oboeBus(eventName).on(protectedCallback(callback), callback);
return oboeApi; // chaining
} | javascript | function addProtectedCallback(eventName, callback) {
oboeBus(eventName).on(protectedCallback(callback), callback);
return oboeApi; // chaining
} | [
"function",
"addProtectedCallback",
"(",
"eventName",
",",
"callback",
")",
"{",
"oboeBus",
"(",
"eventName",
")",
".",
"on",
"(",
"protectedCallback",
"(",
"callback",
")",
",",
"callback",
")",
";",
"return",
"oboeApi",
";",
"// chaining",
"}"
] | Add a callback, wrapped in a try/catch so as to not break the
execution of Oboe if an exception is thrown (fail events are
fired instead)
The callback is used as the listener id so that it can later be
removed using .un(callback) | [
"Add",
"a",
"callback",
"wrapped",
"in",
"a",
"try",
"/",
"catch",
"so",
"as",
"to",
"not",
"break",
"the",
"execution",
"of",
"Oboe",
"if",
"an",
"exception",
"is",
"thrown",
"(",
"fail",
"events",
"are",
"fired",
"instead",
")"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/instanceApi.js#L85-L88 | train | Adds a protected event to the oboe bus | [
30522,
3853,
5587,
21572,
26557,
3064,
9289,
20850,
8684,
1006,
2724,
18442,
1010,
2655,
5963,
1007,
1063,
22523,
8286,
1006,
2724,
18442,
1007,
1012,
2006,
1006,
5123,
9289,
20850,
8684,
1006,
2655,
5963,
1007,
1010,
2655,
5963,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | initProvide | function initProvide (vm) {
var provide = vm.$options.provide;
if (provide) {
vm._provided = typeof provide === 'function'
? provide.call(vm)
: provide;
}
} | javascript | function initProvide (vm) {
var provide = vm.$options.provide;
if (provide) {
vm._provided = typeof provide === 'function'
? provide.call(vm)
: provide;
}
} | [
"function",
"initProvide",
"(",
"vm",
")",
"{",
"var",
"provide",
"=",
"vm",
".",
"$options",
".",
"provide",
";",
"if",
"(",
"provide",
")",
"{",
"vm",
".",
"_provided",
"=",
"typeof",
"provide",
"===",
"'function'",
"?",
"provide",
".",
"call",
"(",
... | /* | [
"/",
"*"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L2997-L3004 | train | Initialize the provide function | [
30522,
30524,
13075,
3073,
1027,
1058,
2213,
1012,
1002,
7047,
1012,
3073,
1025,
2065,
1006,
3073,
1007,
1063,
1058,
2213,
1012,
1035,
3024,
1027,
2828,
11253,
3073,
1027,
1027,
1027,
1005,
3853,
1005,
1029,
3073,
1012,
2655,
1006,
1058,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | handleFileNew | function handleFileNew() {
//var defaultExtension = PreferencesManager.get("defaultExtension");
//if (defaultExtension) {
// defaultExtension = "." + defaultExtension;
//}
var defaultExtension = ""; // disable preference setting for now
var doc = DocumentManager.createUntitledDocument(_nextUntitledIndexToUse++, defaultExtension);
MainViewManager._edit(MainViewManager.ACTIVE_PANE, doc);
HealthLogger.sendAnalyticsData(
HealthLogger.commonStrings.USAGE +
HealthLogger.commonStrings.FILE_OPEN +
HealthLogger.commonStrings.FILE_NEW,
HealthLogger.commonStrings.USAGE,
HealthLogger.commonStrings.FILE_OPEN,
HealthLogger.commonStrings.FILE_NEW
);
return new $.Deferred().resolve(doc).promise();
} | javascript | function handleFileNew() {
//var defaultExtension = PreferencesManager.get("defaultExtension");
//if (defaultExtension) {
// defaultExtension = "." + defaultExtension;
//}
var defaultExtension = ""; // disable preference setting for now
var doc = DocumentManager.createUntitledDocument(_nextUntitledIndexToUse++, defaultExtension);
MainViewManager._edit(MainViewManager.ACTIVE_PANE, doc);
HealthLogger.sendAnalyticsData(
HealthLogger.commonStrings.USAGE +
HealthLogger.commonStrings.FILE_OPEN +
HealthLogger.commonStrings.FILE_NEW,
HealthLogger.commonStrings.USAGE,
HealthLogger.commonStrings.FILE_OPEN,
HealthLogger.commonStrings.FILE_NEW
);
return new $.Deferred().resolve(doc).promise();
} | [
"function",
"handleFileNew",
"(",
")",
"{",
"//var defaultExtension = PreferencesManager.get(\"defaultExtension\");",
"//if (defaultExtension) {",
"// defaultExtension = \".\" + defaultExtension;",
"//}",
"var",
"defaultExtension",
"=",
"\"\"",
";",
"// disable preference setting for ... | Create a new untitled document in the workingset, and make it the current document.
Promise is resolved (synchronously) with the newly-created Document. | [
"Create",
"a",
"new",
"untitled",
"document",
"in",
"the",
"workingset",
"and",
"make",
"it",
"the",
"current",
"document",
".",
"Promise",
"is",
"resolved",
"(",
"synchronously",
")",
"with",
"the",
"newly",
"-",
"created",
"Document",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L682-L702 | train | Handle file new | [
30522,
3853,
5047,
8873,
11474,
2860,
1006,
1007,
1063,
1013,
1013,
13075,
12398,
10288,
29048,
1027,
18394,
24805,
4590,
1012,
2131,
1006,
1000,
12398,
10288,
29048,
1000,
1007,
1025,
1013,
1013,
2065,
1006,
12398,
10288,
29048,
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... |
mui-org/material-ui | packages/material-ui/src/Slide/Slide.js | getTranslateValue | function getTranslateValue(direction, node) {
const rect = node.getBoundingClientRect();
let transform;
if (node.fakeTransform) {
transform = node.fakeTransform;
} else {
const computedStyle = window.getComputedStyle(node);
transform =
computedStyle.getPropertyValue('-webkit-transform') ||
computedStyle.getPropertyValue('transform');
}
let offsetX = 0;
let offsetY = 0;
if (transform && transform !== 'none' && typeof transform === 'string') {
const transformValues = transform
.split('(')[1]
.split(')')[0]
.split(',');
offsetX = parseInt(transformValues[4], 10);
offsetY = parseInt(transformValues[5], 10);
}
if (direction === 'left') {
return `translateX(100vw) translateX(-${rect.left - offsetX}px)`;
}
if (direction === 'right') {
return `translateX(-${rect.left + rect.width + GUTTER - offsetX}px)`;
}
if (direction === 'up') {
return `translateY(100vh) translateY(-${rect.top - offsetY}px)`;
}
// direction === 'down'
return `translateY(-${rect.top + rect.height + GUTTER - offsetY}px)`;
} | javascript | function getTranslateValue(direction, node) {
const rect = node.getBoundingClientRect();
let transform;
if (node.fakeTransform) {
transform = node.fakeTransform;
} else {
const computedStyle = window.getComputedStyle(node);
transform =
computedStyle.getPropertyValue('-webkit-transform') ||
computedStyle.getPropertyValue('transform');
}
let offsetX = 0;
let offsetY = 0;
if (transform && transform !== 'none' && typeof transform === 'string') {
const transformValues = transform
.split('(')[1]
.split(')')[0]
.split(',');
offsetX = parseInt(transformValues[4], 10);
offsetY = parseInt(transformValues[5], 10);
}
if (direction === 'left') {
return `translateX(100vw) translateX(-${rect.left - offsetX}px)`;
}
if (direction === 'right') {
return `translateX(-${rect.left + rect.width + GUTTER - offsetX}px)`;
}
if (direction === 'up') {
return `translateY(100vh) translateY(-${rect.top - offsetY}px)`;
}
// direction === 'down'
return `translateY(-${rect.top + rect.height + GUTTER - offsetY}px)`;
} | [
"function",
"getTranslateValue",
"(",
"direction",
",",
"node",
")",
"{",
"const",
"rect",
"=",
"node",
".",
"getBoundingClientRect",
"(",
")",
";",
"let",
"transform",
";",
"if",
"(",
"node",
".",
"fakeTransform",
")",
"{",
"transform",
"=",
"node",
".",
... | Translate the node so he can't be seen on the screen. Later, we gonna translate back the node to his original location with `translate3d(0, 0, 0)`.` | [
"Translate",
"the",
"node",
"so",
"he",
"can",
"t",
"be",
"seen",
"on",
"the",
"screen",
".",
"Later",
"we",
"gonna",
"translate",
"back",
"the",
"node",
"to",
"his",
"original",
"location",
"with",
"translate3d",
"(",
"0",
"0",
"0",
")",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/Slide/Slide.js#L17-L57 | train | Get translate value for node | [
30522,
3853,
2131,
6494,
3619,
13806,
10175,
5657,
1006,
3257,
1010,
13045,
1007,
1063,
9530,
3367,
28667,
2102,
1027,
13045,
1012,
2131,
15494,
2075,
20464,
11638,
2890,
6593,
1006,
1007,
1025,
2292,
10938,
1025,
2065,
1006,
13045,
1012,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/node/selenium-webdriver/chrome.js | configureExecutor | function configureExecutor(executor) {
executor.defineCommand(
Command.LAUNCH_APP,
'POST',
'/session/:sessionId/chromium/launch_app');
executor.defineCommand(
Command.GET_NETWORK_CONDITIONS,
'GET',
'/session/:sessionId/chromium/network_conditions');
executor.defineCommand(
Command.SET_NETWORK_CONDITIONS,
'POST',
'/session/:sessionId/chromium/network_conditions');
executor.defineCommand(
Command.SEND_DEVTOOLS_COMMAND,
'POST',
'/session/:sessionId/chromium/send_command');
} | javascript | function configureExecutor(executor) {
executor.defineCommand(
Command.LAUNCH_APP,
'POST',
'/session/:sessionId/chromium/launch_app');
executor.defineCommand(
Command.GET_NETWORK_CONDITIONS,
'GET',
'/session/:sessionId/chromium/network_conditions');
executor.defineCommand(
Command.SET_NETWORK_CONDITIONS,
'POST',
'/session/:sessionId/chromium/network_conditions');
executor.defineCommand(
Command.SEND_DEVTOOLS_COMMAND,
'POST',
'/session/:sessionId/chromium/send_command');
} | [
"function",
"configureExecutor",
"(",
"executor",
")",
"{",
"executor",
".",
"defineCommand",
"(",
"Command",
".",
"LAUNCH_APP",
",",
"'POST'",
",",
"'/session/:sessionId/chromium/launch_app'",
")",
";",
"executor",
".",
"defineCommand",
"(",
"Command",
".",
"GET_NE... | Configures the given executor with Chrome-specific commands.
@param {!http.Executor} executor the executor to configure. | [
"Configures",
"the",
"given",
"executor",
"with",
"Chrome",
"-",
"specific",
"commands",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/chrome.js#L185-L202 | train | Configure the specified executor. | [
30522,
3853,
9530,
8873,
27390,
4402,
2595,
8586,
16161,
2099,
1006,
4654,
8586,
16161,
2099,
1007,
1063,
4654,
8586,
16161,
2099,
1012,
9375,
9006,
2386,
2094,
1006,
3094,
1012,
4888,
1035,
10439,
1010,
1005,
2695,
1005,
1010,
1005,
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... |
eslint/eslint | lib/config/config-initializer.js | getLocalESLintVersion | function getLocalESLintVersion() {
try {
const eslintPath = relativeModuleResolver("eslint", path.join(process.cwd(), "__placeholder__.js"));
const eslint = require(eslintPath);
return eslint.linter.version || null;
} catch (_err) {
return null;
}
} | javascript | function getLocalESLintVersion() {
try {
const eslintPath = relativeModuleResolver("eslint", path.join(process.cwd(), "__placeholder__.js"));
const eslint = require(eslintPath);
return eslint.linter.version || null;
} catch (_err) {
return null;
}
} | [
"function",
"getLocalESLintVersion",
"(",
")",
"{",
"try",
"{",
"const",
"eslintPath",
"=",
"relativeModuleResolver",
"(",
"\"eslint\"",
",",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"\"__placeholder__.js\"",
")",
")",
";",
"const",
"e... | Get the version of the local ESLint.
@returns {string|null} The version. If the local ESLint was not found, returns null. | [
"Get",
"the",
"version",
"of",
"the",
"local",
"ESLint",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-initializer.js#L335-L344 | train | Get the local version of the eslint module | [
30522,
3853,
2131,
4135,
9289,
2229,
4115,
9189,
2545,
3258,
1006,
1007,
1063,
3046,
1063,
9530,
3367,
9686,
4115,
25856,
8988,
1027,
5816,
5302,
8566,
3917,
2229,
4747,
6299,
1006,
1000,
9686,
4115,
2102,
1000,
1010,
4130,
1012,
3693,
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... |
SheetJS/js-xlsx | xlsx.js | parse_DataSpaceDefinition | function parse_DataSpaceDefinition(blob) {
var o = [];
blob.l += 4; // must be 0x8
var cnt = blob.read_shift(4);
while(cnt-- > 0) o.push(blob.read_shift(0, 'lpp4'));
return o;
} | javascript | function parse_DataSpaceDefinition(blob) {
var o = [];
blob.l += 4; // must be 0x8
var cnt = blob.read_shift(4);
while(cnt-- > 0) o.push(blob.read_shift(0, 'lpp4'));
return o;
} | [
"function",
"parse_DataSpaceDefinition",
"(",
"blob",
")",
"{",
"var",
"o",
"=",
"[",
"]",
";",
"blob",
".",
"l",
"+=",
"4",
";",
"// must be 0x8",
"var",
"cnt",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"while",
"(",
"cnt",
"--",
">",
"0... | /* [MS-OFFCRYPTO] 2.1.7 DataSpaceDefinition | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"1",
".",
"7",
"DataSpaceDefinition"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L8165-L8171 | train | Parse DataSpace Definition | [
30522,
3853,
11968,
3366,
1035,
2951,
23058,
3207,
16294,
22753,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
1051,
1027,
1031,
1033,
1025,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1018,
1025,
1013,
1013,
2442,
2022,
1014,
2595,
2620,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
babel/babel | packages/babel-helpers/src/index.js | permuteHelperAST | function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
if (localBindings && !id) {
throw new Error("Unexpected local bindings for module-based helpers.");
}
if (!id) return;
const {
localBindingNames,
dependencies,
exportBindingAssignments,
exportPath,
exportName,
importBindingsReferences,
importPaths,
} = metadata;
const dependenciesRefs = {};
dependencies.forEach((name, id) => {
dependenciesRefs[id.name] =
(typeof getDependency === "function" && getDependency(name)) || id;
});
const toRename = {};
const bindings = new Set(localBindings || []);
localBindingNames.forEach(name => {
let newName = name;
while (bindings.has(newName)) newName = "_" + newName;
if (newName !== name) toRename[name] = newName;
});
if (id.type === "Identifier" && exportName !== id.name) {
toRename[exportName] = id.name;
}
traverse(file, {
Program(path) {
// We need to compute these in advance because removing nodes would
// invalidate the paths.
const exp = path.get(exportPath);
const imps = importPaths.map(p => path.get(p));
const impsBindingRefs = importBindingsReferences.map(p => path.get(p));
const decl = exp.get("declaration");
if (id.type === "Identifier") {
if (decl.isFunctionDeclaration()) {
exp.replaceWith(decl);
} else {
exp.replaceWith(
t.variableDeclaration("var", [t.variableDeclarator(id, decl.node)]),
);
}
} else if (id.type === "MemberExpression") {
if (decl.isFunctionDeclaration()) {
exportBindingAssignments.forEach(assignPath => {
const assign = path.get(assignPath);
assign.replaceWith(t.assignmentExpression("=", id, assign.node));
});
exp.replaceWith(decl);
path.pushContainer(
"body",
t.expressionStatement(
t.assignmentExpression("=", id, t.identifier(exportName)),
),
);
} else {
exp.replaceWith(
t.expressionStatement(t.assignmentExpression("=", id, decl.node)),
);
}
} else {
throw new Error("Unexpected helper format.");
}
Object.keys(toRename).forEach(name => {
path.scope.rename(name, toRename[name]);
});
for (const path of imps) path.remove();
for (const path of impsBindingRefs) {
const node = t.cloneNode(dependenciesRefs[path.node.name]);
path.replaceWith(node);
}
// We only use "traverse" for all the handy scoping helpers, so we can stop immediately without
// actually doing the traversal.
path.stop();
},
});
} | javascript | function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
if (localBindings && !id) {
throw new Error("Unexpected local bindings for module-based helpers.");
}
if (!id) return;
const {
localBindingNames,
dependencies,
exportBindingAssignments,
exportPath,
exportName,
importBindingsReferences,
importPaths,
} = metadata;
const dependenciesRefs = {};
dependencies.forEach((name, id) => {
dependenciesRefs[id.name] =
(typeof getDependency === "function" && getDependency(name)) || id;
});
const toRename = {};
const bindings = new Set(localBindings || []);
localBindingNames.forEach(name => {
let newName = name;
while (bindings.has(newName)) newName = "_" + newName;
if (newName !== name) toRename[name] = newName;
});
if (id.type === "Identifier" && exportName !== id.name) {
toRename[exportName] = id.name;
}
traverse(file, {
Program(path) {
// We need to compute these in advance because removing nodes would
// invalidate the paths.
const exp = path.get(exportPath);
const imps = importPaths.map(p => path.get(p));
const impsBindingRefs = importBindingsReferences.map(p => path.get(p));
const decl = exp.get("declaration");
if (id.type === "Identifier") {
if (decl.isFunctionDeclaration()) {
exp.replaceWith(decl);
} else {
exp.replaceWith(
t.variableDeclaration("var", [t.variableDeclarator(id, decl.node)]),
);
}
} else if (id.type === "MemberExpression") {
if (decl.isFunctionDeclaration()) {
exportBindingAssignments.forEach(assignPath => {
const assign = path.get(assignPath);
assign.replaceWith(t.assignmentExpression("=", id, assign.node));
});
exp.replaceWith(decl);
path.pushContainer(
"body",
t.expressionStatement(
t.assignmentExpression("=", id, t.identifier(exportName)),
),
);
} else {
exp.replaceWith(
t.expressionStatement(t.assignmentExpression("=", id, decl.node)),
);
}
} else {
throw new Error("Unexpected helper format.");
}
Object.keys(toRename).forEach(name => {
path.scope.rename(name, toRename[name]);
});
for (const path of imps) path.remove();
for (const path of impsBindingRefs) {
const node = t.cloneNode(dependenciesRefs[path.node.name]);
path.replaceWith(node);
}
// We only use "traverse" for all the handy scoping helpers, so we can stop immediately without
// actually doing the traversal.
path.stop();
},
});
} | [
"function",
"permuteHelperAST",
"(",
"file",
",",
"metadata",
",",
"id",
",",
"localBindings",
",",
"getDependency",
")",
"{",
"if",
"(",
"localBindings",
"&&",
"!",
"id",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unexpected local bindings for module-based helper... | Given a helper AST and information about how it will be used, update the AST to match the usage. | [
"Given",
"a",
"helper",
"AST",
"and",
"information",
"about",
"how",
"it",
"will",
"be",
"used",
"update",
"the",
"AST",
"to",
"match",
"the",
"usage",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-helpers/src/index.js#L137-L227 | train | Permute helper AST | [
30522,
3853,
2566,
26746,
16001,
4842,
14083,
1006,
5371,
1010,
27425,
1010,
8909,
1010,
2334,
8428,
4667,
2015,
1010,
2131,
3207,
11837,
4181,
5666,
1007,
1063,
2065,
1006,
2334,
8428,
4667,
2015,
1004,
1004,
999,
8909,
1007,
1063,
5466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | modules/layers/src/solid-polygon-layer/polygon.js | validate | function validate(polygon) {
polygon = (polygon && polygon.positions) || polygon;
if (!Array.isArray(polygon) && !ArrayBuffer.isView(polygon)) {
throw new Error('invalid polygon');
}
} | javascript | function validate(polygon) {
polygon = (polygon && polygon.positions) || polygon;
if (!Array.isArray(polygon) && !ArrayBuffer.isView(polygon)) {
throw new Error('invalid polygon');
}
} | [
"function",
"validate",
"(",
"polygon",
")",
"{",
"polygon",
"=",
"(",
"polygon",
"&&",
"polygon",
".",
"positions",
")",
"||",
"polygon",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"polygon",
")",
"&&",
"!",
"ArrayBuffer",
".",
"isView",
"(",
... | 4 data formats are supported: Simple Polygon: an array of points Complex Polygon: an array of array of points (array of rings) with the first ring representing the outer hull and other rings representing holes Simple Flat: an array of numbers (flattened "simple polygon") Complex Flat: {position: array<number>, holeIndices: array<number>} (flattened "complex polygon")
Ensure a polygon is valid format
@param {Array|Object} polygon | [
"4",
"data",
"formats",
"are",
"supported",
":",
"Simple",
"Polygon",
":",
"an",
"array",
"of",
"points",
"Complex",
"Polygon",
":",
"an",
"array",
"of",
"array",
"of",
"points",
"(",
"array",
"of",
"rings",
")",
"with",
"the",
"first",
"ring",
"represen... | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/layers/src/solid-polygon-layer/polygon.js#L36-L41 | train | Validate polygon | [
30522,
3853,
9398,
3686,
1006,
26572,
7446,
1007,
1063,
26572,
7446,
1027,
1006,
26572,
7446,
1004,
1004,
26572,
7446,
1012,
4460,
1007,
1064,
1064,
26572,
7446,
1025,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
26572,
7446,
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... |
caolan/async | lib/sortBy.js | sortBy | function sortBy (coll, iteratee, callback) {
var _iteratee = wrapAsync(iteratee);
return map(coll, (x, iterCb) => {
_iteratee(x, (err, criteria) => {
if (err) return iterCb(err);
iterCb(err, {value: x, criteria});
});
}, (err, results) => {
if (err) return callback(err);
callback(null, results.sort(comparator).map(v => v.value));
});
function comparator(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}
} | javascript | function sortBy (coll, iteratee, callback) {
var _iteratee = wrapAsync(iteratee);
return map(coll, (x, iterCb) => {
_iteratee(x, (err, criteria) => {
if (err) return iterCb(err);
iterCb(err, {value: x, criteria});
});
}, (err, results) => {
if (err) return callback(err);
callback(null, results.sort(comparator).map(v => v.value));
});
function comparator(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
}
} | [
"function",
"sortBy",
"(",
"coll",
",",
"iteratee",
",",
"callback",
")",
"{",
"var",
"_iteratee",
"=",
"wrapAsync",
"(",
"iteratee",
")",
";",
"return",
"map",
"(",
"coll",
",",
"(",
"x",
",",
"iterCb",
")",
"=>",
"{",
"_iteratee",
"(",
"x",
",",
... | Sorts a list by the results of running each `coll` value through an async
`iteratee`.
@name sortBy
@static
@memberOf module:Collections
@method
@category Collection
@param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
@param {AsyncFunction} iteratee - An async function to apply to each item in
`coll`.
The iteratee should complete with a value to use as the sort criteria as
its `result`.
Invoked with (item, callback).
@param {Function} callback - A callback which is called after all the
`iteratee` functions have finished, or an error occurs. Results is the items
from the original `coll` sorted by the values returned by the `iteratee`
calls. Invoked with (err, results).
@returns {Promise} a promise, if no callback passed
@example
async.sortBy(['file1','file2','file3'], function(file, callback) {
fs.stat(file, function(err, stats) {
callback(err, stats.mtime);
});
}, function(err, results) {
// results is now the original array of files sorted by
// modified date
});
// By modifying the callback parameter the
// sorting order can be influenced:
// ascending order
async.sortBy([1,9,3,5], function(x, callback) {
callback(null, x);
}, function(err,result) {
// result callback
});
// descending order
async.sortBy([1,9,3,5], function(x, callback) {
callback(null, x*-1); //<- x*-1 instead of x, turns the order around
}, function(err,result) {
// result callback
}); | [
"Sorts",
"a",
"list",
"by",
"the",
"results",
"of",
"running",
"each",
"coll",
"value",
"through",
"an",
"async",
"iteratee",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/sortBy.js#L53-L69 | train | Sorts the elements of a collection using a async iteratee. | [
30522,
3853,
4066,
3762,
1006,
8902,
2140,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
13075,
1035,
2009,
22139,
2063,
1027,
10236,
3022,
6038,
2278,
1006,
2009,
22139,
2063,
1007,
1025,
2709,
4949,
1006,
8902,
2140,
1010,
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... |
SheetJS/js-xlsx | xlsx.js | parse_ws_xml_sheetpr | function parse_ws_xml_sheetpr(sheetPr, s, wb, idx) {
var data = parsexmltag(sheetPr);
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(data.codeName) wb.Sheets[idx].CodeName = data.codeName;
} | javascript | function parse_ws_xml_sheetpr(sheetPr, s, wb, idx) {
var data = parsexmltag(sheetPr);
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(data.codeName) wb.Sheets[idx].CodeName = data.codeName;
} | [
"function",
"parse_ws_xml_sheetpr",
"(",
"sheetPr",
",",
"s",
",",
"wb",
",",
"idx",
")",
"{",
"var",
"data",
"=",
"parsexmltag",
"(",
"sheetPr",
")",
";",
"if",
"(",
"!",
"wb",
".",
"Sheets",
"[",
"idx",
"]",
")",
"wb",
".",
"Sheets",
"[",
"idx",
... | /* 18.3.1.82-3 sheetPr CT_ChartsheetPr / CT_SheetPr | [
"/",
"*",
"18",
".",
"3",
".",
"1",
".",
"82",
"-",
"3",
"sheetPr",
"CT_ChartsheetPr",
"/",
"CT_SheetPr"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L12884-L12888 | train | Parse xml sheetPr | [
30522,
3853,
11968,
3366,
1035,
1059,
2015,
1035,
20950,
1035,
7123,
18098,
1006,
7123,
18098,
1010,
1055,
1010,
25610,
1010,
8909,
2595,
1007,
1063,
13075,
2951,
1027,
11968,
3366,
2595,
19968,
15900,
1006,
7123,
18098,
1007,
1025,
2065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/computed-property-spacing.js | reportRequiredEndingSpace | function reportRequiredEndingSpace(node, token) {
context.report({
node,
loc: token.loc.start,
messageId: "missingSpaceBefore",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextBefore(token, " ");
}
});
} | javascript | function reportRequiredEndingSpace(node, token) {
context.report({
node,
loc: token.loc.start,
messageId: "missingSpaceBefore",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextBefore(token, " ");
}
});
} | [
"function",
"reportRequiredEndingSpace",
"(",
"node",
",",
"token",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"token",
".",
"loc",
".",
"start",
",",
"messageId",
":",
"\"missingSpaceBefore\"",
",",
"data",
":",
"{",
"tokenValu... | Reports that there should be a space before the last token
@param {ASTNode} node - The node to report in the event of an error.
@param {Token} token - The token to use for the report.
@returns {void} | [
"Reports",
"that",
"there",
"should",
"be",
"a",
"space",
"before",
"the",
"last",
"token"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/computed-property-spacing.js#L117-L129 | train | Reports a node with a space that is not required to end with a space. | [
30522,
3853,
3189,
2890,
15549,
5596,
18537,
23058,
1006,
13045,
1010,
19204,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
8840,
2278,
1024,
19204,
1012,
8840,
2278,
1012,
2707,
1010,
4471,
3593,
1024,
1000,
4394,
23058,
4783,
292... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | packages/weex-vue-framework/index.js | createInstance | function createInstance (
instanceId,
appCode,
config,
data,
env
) {
if ( appCode === void 0 ) appCode = '';
if ( config === void 0 ) config = {};
if ( env === void 0 ) env = {};
// Virtual-DOM object.
var document = new renderer.Document(instanceId, config.bundleUrl);
// All function/callback of parameters before sent to native
// will be converted as an id. So `callbacks` is used to store
// these real functions. When a callback invoked and won't be
// called again, it should be removed from here automatically.
var callbacks = [];
// The latest callback id, incremental.
var callbackId = 1;
var instance = instances[instanceId] = {
instanceId: instanceId, config: config, data: data,
document: document, callbacks: callbacks, callbackId: callbackId
};
// Prepare native module getter and HTML5 Timer APIs.
var moduleGetter = genModuleGetter(instanceId);
var timerAPIs = getInstanceTimer(instanceId, moduleGetter);
// Prepare `weex` instance variable.
var weexInstanceVar = {
config: config,
document: document,
requireModule: moduleGetter
};
Object.freeze(weexInstanceVar);
// Each instance has a independent `Vue` module instance
var Vue = instance.Vue = createVueModuleInstance(instanceId, moduleGetter);
// The function which create a closure the JS Bundle will run in.
// It will declare some instance variables like `Vue`, HTML5 Timer APIs etc.
var instanceVars = Object.assign({
Vue: Vue,
weex: weexInstanceVar,
// deprecated
__weex_require_module__: weexInstanceVar.requireModule // eslint-disable-line
}, timerAPIs);
callFunction(instanceVars, appCode);
// Send `createFinish` signal to native.
renderer.sendTasks(instanceId + '', [{ module: 'dom', method: 'createFinish', args: [] }], -1);
} | javascript | function createInstance (
instanceId,
appCode,
config,
data,
env
) {
if ( appCode === void 0 ) appCode = '';
if ( config === void 0 ) config = {};
if ( env === void 0 ) env = {};
// Virtual-DOM object.
var document = new renderer.Document(instanceId, config.bundleUrl);
// All function/callback of parameters before sent to native
// will be converted as an id. So `callbacks` is used to store
// these real functions. When a callback invoked and won't be
// called again, it should be removed from here automatically.
var callbacks = [];
// The latest callback id, incremental.
var callbackId = 1;
var instance = instances[instanceId] = {
instanceId: instanceId, config: config, data: data,
document: document, callbacks: callbacks, callbackId: callbackId
};
// Prepare native module getter and HTML5 Timer APIs.
var moduleGetter = genModuleGetter(instanceId);
var timerAPIs = getInstanceTimer(instanceId, moduleGetter);
// Prepare `weex` instance variable.
var weexInstanceVar = {
config: config,
document: document,
requireModule: moduleGetter
};
Object.freeze(weexInstanceVar);
// Each instance has a independent `Vue` module instance
var Vue = instance.Vue = createVueModuleInstance(instanceId, moduleGetter);
// The function which create a closure the JS Bundle will run in.
// It will declare some instance variables like `Vue`, HTML5 Timer APIs etc.
var instanceVars = Object.assign({
Vue: Vue,
weex: weexInstanceVar,
// deprecated
__weex_require_module__: weexInstanceVar.requireModule // eslint-disable-line
}, timerAPIs);
callFunction(instanceVars, appCode);
// Send `createFinish` signal to native.
renderer.sendTasks(instanceId + '', [{ module: 'dom', method: 'createFinish', args: [] }], -1);
} | [
"function",
"createInstance",
"(",
"instanceId",
",",
"appCode",
",",
"config",
",",
"data",
",",
"env",
")",
"{",
"if",
"(",
"appCode",
"===",
"void",
"0",
")",
"appCode",
"=",
"''",
";",
"if",
"(",
"config",
"===",
"void",
"0",
")",
"config",
"=",
... | Create an instance with id, code, config and external data.
@param {string} instanceId
@param {string} appCode
@param {object} config
@param {object} data
@param {object} env { info, config, services } | [
"Create",
"an",
"instance",
"with",
"id",
"code",
"config",
"and",
"external",
"data",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/weex-vue-framework/index.js#L71-L126 | train | Creates a new instance of the specified type. | [
30522,
3853,
3443,
7076,
26897,
1006,
6013,
3593,
1010,
10439,
16044,
1010,
9530,
8873,
2290,
1010,
2951,
1010,
4372,
2615,
1007,
1063,
2065,
1006,
10439,
16044,
1027,
1027,
1027,
11675,
1014,
1007,
10439,
16044,
1027,
1005,
1005,
1025,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/object-curly-newline.js | check | function check(node) {
const options = normalizedOptions[node.type];
if (
(node.type === "ImportDeclaration" &&
!node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) ||
(node.type === "ExportNamedDeclaration" &&
!node.specifiers.some(specifier => specifier.type === "ExportSpecifier"))
) {
return;
}
const openBrace = sourceCode.getFirstToken(node, token => token.value === "{");
let closeBrace;
if (node.typeAnnotation) {
closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
} else {
closeBrace = sourceCode.getLastToken(node, token => token.value === "}");
}
let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
const hasCommentsFirstToken = astUtils.isCommentToken(first);
const hasCommentsLastToken = astUtils.isCommentToken(last);
/*
* Use tokens or comments to check multiline or not.
* But use only tokens to check whether line breaks are needed.
* This allows:
* var obj = { // eslint-disable-line foo
* a: 1
* }
*/
first = sourceCode.getTokenAfter(openBrace);
last = sourceCode.getTokenBefore(closeBrace);
if (needsLineBreaks) {
if (astUtils.isTokenOnSameLine(openBrace, first)) {
context.report({
message: "Expected a line break after this opening brace.",
node,
loc: openBrace.loc.start,
fix(fixer) {
if (hasCommentsFirstToken) {
return null;
}
return fixer.insertTextAfter(openBrace, "\n");
}
});
}
if (astUtils.isTokenOnSameLine(last, closeBrace)) {
context.report({
message: "Expected a line break before this closing brace.",
node,
loc: closeBrace.loc.start,
fix(fixer) {
if (hasCommentsLastToken) {
return null;
}
return fixer.insertTextBefore(closeBrace, "\n");
}
});
}
} else {
const consistent = options.consistent;
const hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first);
const hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace);
if (
(!consistent && hasLineBreakBetweenOpenBraceAndFirst) ||
(consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast)
) {
context.report({
message: "Unexpected line break after this opening brace.",
node,
loc: openBrace.loc.start,
fix(fixer) {
if (hasCommentsFirstToken) {
return null;
}
return fixer.removeRange([
openBrace.range[1],
first.range[0]
]);
}
});
}
if (
(!consistent && hasLineBreakBetweenCloseBraceAndLast) ||
(consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast)
) {
context.report({
message: "Unexpected line break before this closing brace.",
node,
loc: closeBrace.loc.start,
fix(fixer) {
if (hasCommentsLastToken) {
return null;
}
return fixer.removeRange([
last.range[1],
closeBrace.range[0]
]);
}
});
}
}
} | javascript | function check(node) {
const options = normalizedOptions[node.type];
if (
(node.type === "ImportDeclaration" &&
!node.specifiers.some(specifier => specifier.type === "ImportSpecifier")) ||
(node.type === "ExportNamedDeclaration" &&
!node.specifiers.some(specifier => specifier.type === "ExportSpecifier"))
) {
return;
}
const openBrace = sourceCode.getFirstToken(node, token => token.value === "{");
let closeBrace;
if (node.typeAnnotation) {
closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
} else {
closeBrace = sourceCode.getLastToken(node, token => token.value === "}");
}
let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
const needsLineBreaks = areLineBreaksRequired(node, options, first, last);
const hasCommentsFirstToken = astUtils.isCommentToken(first);
const hasCommentsLastToken = astUtils.isCommentToken(last);
/*
* Use tokens or comments to check multiline or not.
* But use only tokens to check whether line breaks are needed.
* This allows:
* var obj = { // eslint-disable-line foo
* a: 1
* }
*/
first = sourceCode.getTokenAfter(openBrace);
last = sourceCode.getTokenBefore(closeBrace);
if (needsLineBreaks) {
if (astUtils.isTokenOnSameLine(openBrace, first)) {
context.report({
message: "Expected a line break after this opening brace.",
node,
loc: openBrace.loc.start,
fix(fixer) {
if (hasCommentsFirstToken) {
return null;
}
return fixer.insertTextAfter(openBrace, "\n");
}
});
}
if (astUtils.isTokenOnSameLine(last, closeBrace)) {
context.report({
message: "Expected a line break before this closing brace.",
node,
loc: closeBrace.loc.start,
fix(fixer) {
if (hasCommentsLastToken) {
return null;
}
return fixer.insertTextBefore(closeBrace, "\n");
}
});
}
} else {
const consistent = options.consistent;
const hasLineBreakBetweenOpenBraceAndFirst = !astUtils.isTokenOnSameLine(openBrace, first);
const hasLineBreakBetweenCloseBraceAndLast = !astUtils.isTokenOnSameLine(last, closeBrace);
if (
(!consistent && hasLineBreakBetweenOpenBraceAndFirst) ||
(consistent && hasLineBreakBetweenOpenBraceAndFirst && !hasLineBreakBetweenCloseBraceAndLast)
) {
context.report({
message: "Unexpected line break after this opening brace.",
node,
loc: openBrace.loc.start,
fix(fixer) {
if (hasCommentsFirstToken) {
return null;
}
return fixer.removeRange([
openBrace.range[1],
first.range[0]
]);
}
});
}
if (
(!consistent && hasLineBreakBetweenCloseBraceAndLast) ||
(consistent && !hasLineBreakBetweenOpenBraceAndFirst && hasLineBreakBetweenCloseBraceAndLast)
) {
context.report({
message: "Unexpected line break before this closing brace.",
node,
loc: closeBrace.loc.start,
fix(fixer) {
if (hasCommentsLastToken) {
return null;
}
return fixer.removeRange([
last.range[1],
closeBrace.range[0]
]);
}
});
}
}
} | [
"function",
"check",
"(",
"node",
")",
"{",
"const",
"options",
"=",
"normalizedOptions",
"[",
"node",
".",
"type",
"]",
";",
"if",
"(",
"(",
"node",
".",
"type",
"===",
"\"ImportDeclaration\"",
"&&",
"!",
"node",
".",
"specifiers",
".",
"some",
"(",
"... | Reports a given node if it violated this rule.
@param {ASTNode} node - A node to check. This is an ObjectExpression, ObjectPattern, ImportDeclaration or ExportNamedDeclaration node.
@returns {void} | [
"Reports",
"a",
"given",
"node",
"if",
"it",
"violated",
"this",
"rule",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-curly-newline.js#L177-L293 | train | Check if a node needs line breaks | [
30522,
3853,
4638,
1006,
13045,
1007,
1063,
9530,
3367,
7047,
1027,
3671,
3550,
7361,
9285,
1031,
13045,
1012,
2828,
1033,
1025,
2065,
1006,
1006,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
12324,
3207,
20464,
25879,
3258,
1000,
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... |
eslint/eslint | lib/util/source-code.js | looksLikeExport | function looksLikeExport(astNode) {
return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" ||
astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
} | javascript | function looksLikeExport(astNode) {
return astNode.type === "ExportDefaultDeclaration" || astNode.type === "ExportNamedDeclaration" ||
astNode.type === "ExportAllDeclaration" || astNode.type === "ExportSpecifier";
} | [
"function",
"looksLikeExport",
"(",
"astNode",
")",
"{",
"return",
"astNode",
".",
"type",
"===",
"\"ExportDefaultDeclaration\"",
"||",
"astNode",
".",
"type",
"===",
"\"ExportNamedDeclaration\"",
"||",
"astNode",
".",
"type",
"===",
"\"ExportAllDeclaration\"",
"||",
... | Check to see if its a ES6 export declaration.
@param {ASTNode} astNode An AST node.
@returns {boolean} whether the given node represents an export declaration.
@private | [
"Check",
"to",
"see",
"if",
"its",
"a",
"ES6",
"export",
"declaration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code.js#L51-L54 | train | Check if the given node is a export declaration | [
30522,
3853,
3504,
10359,
10288,
6442,
1006,
2004,
2102,
3630,
3207,
1007,
1063,
2709,
2004,
2102,
3630,
3207,
1012,
2828,
1027,
1027,
1027,
1000,
9167,
3207,
7011,
11314,
3207,
20464,
25879,
3258,
1000,
1064,
1064,
2004,
2102,
3630,
3207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | packages/weex-vue-framework/index.js | getRoot | function getRoot (instanceId) {
var instance = instances[instanceId];
if (!instance || !(instance.app instanceof instance.Vue)) {
return new Error(("getRoot: instance " + instanceId + " not found!"))
}
return instance.app.$el.toJSON()
} | javascript | function getRoot (instanceId) {
var instance = instances[instanceId];
if (!instance || !(instance.app instanceof instance.Vue)) {
return new Error(("getRoot: instance " + instanceId + " not found!"))
}
return instance.app.$el.toJSON()
} | [
"function",
"getRoot",
"(",
"instanceId",
")",
"{",
"var",
"instance",
"=",
"instances",
"[",
"instanceId",
"]",
";",
"if",
"(",
"!",
"instance",
"||",
"!",
"(",
"instance",
".",
"app",
"instanceof",
"instance",
".",
"Vue",
")",
")",
"{",
"return",
"ne... | Get the JSON object of the root element.
@param {string} instanceId | [
"Get",
"the",
"JSON",
"object",
"of",
"the",
"root",
"element",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/weex-vue-framework/index.js#L164-L170 | train | Get root element of a node | [
30522,
3853,
2131,
3217,
4140,
1006,
6013,
3593,
1007,
1063,
13075,
6013,
1027,
12107,
1031,
6013,
3593,
1033,
1025,
2065,
1006,
999,
6013,
1064,
1064,
999,
1006,
6013,
1012,
10439,
6013,
11253,
6013,
1012,
24728,
2063,
1007,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js | function(sViewName, vObject) {
var oResultConfig;
// TODO: checking order of components?
findConfig(CONFIG_VIEW_REPLACEMENTS, vObject, function(oConfig) {
oResultConfig = oConfig[sViewName];
return !!oResultConfig;
});
return oResultConfig;
} | javascript | function(sViewName, vObject) {
var oResultConfig;
// TODO: checking order of components?
findConfig(CONFIG_VIEW_REPLACEMENTS, vObject, function(oConfig) {
oResultConfig = oConfig[sViewName];
return !!oResultConfig;
});
return oResultConfig;
} | [
"function",
"(",
"sViewName",
",",
"vObject",
")",
"{",
"var",
"oResultConfig",
";",
"// TODO: checking order of components?",
"findConfig",
"(",
"CONFIG_VIEW_REPLACEMENTS",
",",
"vObject",
",",
"function",
"(",
"oConfig",
")",
"{",
"oResultConfig",
"=",
"oConfig",
... | returns the configuration of the replacement View or undefined
@private | [
"returns",
"the",
"configuration",
"of",
"the",
"replacement",
"View",
"or",
"undefined"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js#L156-L164 | train | Returns the configuration for a given view. | [
30522,
3853,
1006,
17917,
2666,
7962,
14074,
1010,
29536,
2497,
20614,
1007,
1063,
13075,
10848,
23722,
13535,
2239,
8873,
2290,
1025,
1013,
1013,
28681,
2080,
1024,
9361,
2344,
1997,
6177,
1029,
2424,
8663,
8873,
2290,
1006,
9530,
8873,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(root, path)
{
var parent = root;
if (path != null)
{
var tokens = path.split(mxCellPath.PATH_SEPARATOR);
for (var i=0; i<tokens.length; i++)
{
parent = parent.getChildAt(parseInt(tokens[i]));
}
}
return parent;
} | javascript | function(root, path)
{
var parent = root;
if (path != null)
{
var tokens = path.split(mxCellPath.PATH_SEPARATOR);
for (var i=0; i<tokens.length; i++)
{
parent = parent.getChildAt(parseInt(tokens[i]));
}
}
return parent;
} | [
"function",
"(",
"root",
",",
"path",
")",
"{",
"var",
"parent",
"=",
"root",
";",
"if",
"(",
"path",
"!=",
"null",
")",
"{",
"var",
"tokens",
"=",
"path",
".",
"split",
"(",
"mxCellPath",
".",
"PATH_SEPARATOR",
")",
";",
"for",
"(",
"var",
"i",
... | Function: resolve
Returns the cell for the specified cell path using the given root as the
root of the path.
Parameters:
root - Root cell of the path to be resolved.
path - String that defines the path. | [
"Function",
":",
"resolve"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L43304-L43319 | train | Returns the parent of the given path | [
30522,
3853,
1006,
7117,
1010,
4130,
1007,
1063,
13075,
6687,
1027,
7117,
1025,
2065,
1006,
4130,
999,
1027,
19701,
1007,
1063,
13075,
19204,
2015,
1027,
4130,
1012,
3975,
1006,
25630,
29109,
14277,
8988,
1012,
4130,
1035,
19802,
25879,
295... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
graphql/graphiql | src/utility/fillLeafs.js | buildSelectionSet | function buildSelectionSet(type, getDefaultFieldNames) {
// Unwrap any non-null or list types.
const namedType = getNamedType(type);
// Unknown types and leaf types do not have selection sets.
if (!type || isLeafType(type)) {
return;
}
// Get an array of field names to use.
const fieldNames = getDefaultFieldNames(namedType);
// If there are no field names to use, return no selection set.
if (!Array.isArray(fieldNames) || fieldNames.length === 0) {
return;
}
// Build a selection set of each field, calling buildSelectionSet recursively.
return {
kind: 'SelectionSet',
selections: fieldNames.map(fieldName => {
const fieldDef = namedType.getFields()[fieldName];
const fieldType = fieldDef ? fieldDef.type : null;
return {
kind: 'Field',
name: {
kind: 'Name',
value: fieldName,
},
selectionSet: buildSelectionSet(fieldType, getDefaultFieldNames),
};
}),
};
} | javascript | function buildSelectionSet(type, getDefaultFieldNames) {
// Unwrap any non-null or list types.
const namedType = getNamedType(type);
// Unknown types and leaf types do not have selection sets.
if (!type || isLeafType(type)) {
return;
}
// Get an array of field names to use.
const fieldNames = getDefaultFieldNames(namedType);
// If there are no field names to use, return no selection set.
if (!Array.isArray(fieldNames) || fieldNames.length === 0) {
return;
}
// Build a selection set of each field, calling buildSelectionSet recursively.
return {
kind: 'SelectionSet',
selections: fieldNames.map(fieldName => {
const fieldDef = namedType.getFields()[fieldName];
const fieldType = fieldDef ? fieldDef.type : null;
return {
kind: 'Field',
name: {
kind: 'Name',
value: fieldName,
},
selectionSet: buildSelectionSet(fieldType, getDefaultFieldNames),
};
}),
};
} | [
"function",
"buildSelectionSet",
"(",
"type",
",",
"getDefaultFieldNames",
")",
"{",
"// Unwrap any non-null or list types.",
"const",
"namedType",
"=",
"getNamedType",
"(",
"type",
")",
";",
"// Unknown types and leaf types do not have selection sets.",
"if",
"(",
"!",
"ty... | Given a GraphQL type, and a function which produces field names, recursively generate a SelectionSet which includes default fields. | [
"Given",
"a",
"GraphQL",
"type",
"and",
"a",
"function",
"which",
"produces",
"field",
"names",
"recursively",
"generate",
"a",
"SelectionSet",
"which",
"includes",
"default",
"fields",
"."
] | 5d0f31d6059edc5f816edba3962c3b57fdabd478 | https://github.com/graphql/graphiql/blob/5d0f31d6059edc5f816edba3962c3b57fdabd478/src/utility/fillLeafs.js#L108-L141 | train | Build a selection set for a given type | [
30522,
3853,
16473,
12260,
22014,
3388,
1006,
2828,
1010,
2131,
3207,
7011,
11314,
3790,
18442,
2015,
1007,
1063,
1013,
1013,
4895,
13088,
9331,
2151,
2512,
1011,
19701,
2030,
2862,
4127,
1012,
9530,
3367,
2315,
13874,
1027,
2131,
18442,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
shipshapecode/shepherd | src/js/utils/modal.js | _createMaskRect | function _createMaskRect() {
const element = document.createElementNS(svgNS, 'rect');
_setAttributes(element, {
fill: '#FFFFFF',
height: '100%',
id: elementIds.modalOverlayMaskRect,
width: '100%',
x: '0',
y: '0'
});
return element;
} | javascript | function _createMaskRect() {
const element = document.createElementNS(svgNS, 'rect');
_setAttributes(element, {
fill: '#FFFFFF',
height: '100%',
id: elementIds.modalOverlayMaskRect,
width: '100%',
x: '0',
y: '0'
});
return element;
} | [
"function",
"_createMaskRect",
"(",
")",
"{",
"const",
"element",
"=",
"document",
".",
"createElementNS",
"(",
"svgNS",
",",
"'rect'",
")",
";",
"_setAttributes",
"(",
"element",
",",
"{",
"fill",
":",
"'#FFFFFF'",
",",
"height",
":",
"'100%'",
",",
"id",... | <rect id="modalOverlayMaskRect" x="0" y="0" width="100%" height="100%" fill="#FFFFFF"/> | [
"<rect",
"id",
"=",
"modalOverlayMaskRect",
"x",
"=",
"0",
"y",
"=",
"0",
"width",
"=",
"100%",
"height",
"=",
"100%",
"fill",
"=",
"#FFFFFF",
"/",
">"
] | 0cb1c63fb07b58796358f6d33da5f6405e2b05f4 | https://github.com/shipshapecode/shepherd/blob/0cb1c63fb07b58796358f6d33da5f6405e2b05f4/src/js/utils/modal.js#L46-L59 | train | Creates mask rect | [
30522,
3853,
1035,
3443,
9335,
21638,
22471,
1006,
1007,
1063,
9530,
3367,
5783,
1027,
6254,
1012,
3443,
12260,
3672,
3619,
1006,
17917,
16206,
2015,
1010,
1005,
28667,
2102,
1005,
1007,
1025,
1035,
2275,
19321,
3089,
8569,
4570,
1006,
5783... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mui-org/material-ui | packages/material-ui-styles/src/styled/styled.js | styled | function styled(Component) {
const componentCreator = (style, options = {}) => {
const { name, ...stylesOptions } = options;
if (process.env.NODE_ENV !== 'production' && Component === undefined) {
throw new Error(
[
'You are calling styled(Component)(style) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production' && !name) {
// Provide a better DX outside production.
classNamePrefix = getDisplayName(Component);
warning(
typeof classNamePrefix === 'string',
[
'Material-UI: the component displayName is invalid. It needs to be a string.',
`Please fix the following component: ${Component}.`,
].join('\n'),
);
}
const stylesOrCreator =
typeof style === 'function'
? theme => ({ root: props => style({ theme, ...props }) })
: { root: style };
const useStyles = makeStyles(stylesOrCreator, {
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
});
let filterProps;
let propTypes = {};
if (style.filterProps) {
filterProps = style.filterProps;
delete style.filterProps;
}
/* eslint-disable react/forbid-foreign-prop-types */
if (style.propTypes) {
propTypes = style.propTypes;
delete style.propTypes;
}
/* eslint-enable react/forbid-foreign-prop-types */
const StyledComponent = React.forwardRef(function StyledComponent(props, ref) {
const {
children,
className: classNameProp,
clone,
component: ComponentProp,
...other
} = props;
const classes = useStyles(props);
const className = clsx(classes.root, classNameProp);
if (clone) {
return React.cloneElement(children, {
className: clsx(children.props.className, className),
});
}
let spread = other;
if (filterProps) {
spread = omit(spread, filterProps);
}
if (typeof children === 'function') {
return children({ className, ...spread });
}
const FinalComponent = ComponentProp || Component;
return (
<FinalComponent ref={ref} className={className} {...spread}>
{children}
</FinalComponent>
);
});
StyledComponent.propTypes = {
/**
* A render function or node.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component will recycle it's children DOM element.
* It's using `React.cloneElement` internally.
*/
clone: chainPropTypes(PropTypes.bool, props => {
if (props.clone && props.component) {
return new Error('You can not use the clone and component properties at the same time.');
}
return null;
}),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
...propTypes,
};
if (process.env.NODE_ENV !== 'production') {
StyledComponent.displayName = `Styled(${classNamePrefix})`;
}
hoistNonReactStatics(StyledComponent, Component);
return StyledComponent;
};
return componentCreator;
} | javascript | function styled(Component) {
const componentCreator = (style, options = {}) => {
const { name, ...stylesOptions } = options;
if (process.env.NODE_ENV !== 'production' && Component === undefined) {
throw new Error(
[
'You are calling styled(Component)(style) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production' && !name) {
// Provide a better DX outside production.
classNamePrefix = getDisplayName(Component);
warning(
typeof classNamePrefix === 'string',
[
'Material-UI: the component displayName is invalid. It needs to be a string.',
`Please fix the following component: ${Component}.`,
].join('\n'),
);
}
const stylesOrCreator =
typeof style === 'function'
? theme => ({ root: props => style({ theme, ...props }) })
: { root: style };
const useStyles = makeStyles(stylesOrCreator, {
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
});
let filterProps;
let propTypes = {};
if (style.filterProps) {
filterProps = style.filterProps;
delete style.filterProps;
}
/* eslint-disable react/forbid-foreign-prop-types */
if (style.propTypes) {
propTypes = style.propTypes;
delete style.propTypes;
}
/* eslint-enable react/forbid-foreign-prop-types */
const StyledComponent = React.forwardRef(function StyledComponent(props, ref) {
const {
children,
className: classNameProp,
clone,
component: ComponentProp,
...other
} = props;
const classes = useStyles(props);
const className = clsx(classes.root, classNameProp);
if (clone) {
return React.cloneElement(children, {
className: clsx(children.props.className, className),
});
}
let spread = other;
if (filterProps) {
spread = omit(spread, filterProps);
}
if (typeof children === 'function') {
return children({ className, ...spread });
}
const FinalComponent = ComponentProp || Component;
return (
<FinalComponent ref={ref} className={className} {...spread}>
{children}
</FinalComponent>
);
});
StyledComponent.propTypes = {
/**
* A render function or node.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component will recycle it's children DOM element.
* It's using `React.cloneElement` internally.
*/
clone: chainPropTypes(PropTypes.bool, props => {
if (props.clone && props.component) {
return new Error('You can not use the clone and component properties at the same time.');
}
return null;
}),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
...propTypes,
};
if (process.env.NODE_ENV !== 'production') {
StyledComponent.displayName = `Styled(${classNamePrefix})`;
}
hoistNonReactStatics(StyledComponent, Component);
return StyledComponent;
};
return componentCreator;
} | [
"function",
"styled",
"(",
"Component",
")",
"{",
"const",
"componentCreator",
"=",
"(",
"style",
",",
"options",
"=",
"{",
"}",
")",
"=>",
"{",
"const",
"{",
"name",
",",
"...",
"stylesOptions",
"}",
"=",
"options",
";",
"if",
"(",
"process",
".",
"... | styled-components's API removes the mapping between components and styles. Using components as a low-level styling construct can be simpler. | [
"styled",
"-",
"components",
"s",
"API",
"removes",
"the",
"mapping",
"between",
"components",
"and",
"styles",
".",
"Using",
"components",
"as",
"a",
"low",
"-",
"level",
"styling",
"construct",
"can",
"be",
"simpler",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-styles/src/styled/styled.js#L23-L149 | train | Creates a styled component. | [
30522,
3853,
13650,
1006,
6922,
1007,
1063,
9530,
3367,
6922,
16748,
8844,
1027,
1006,
2806,
1010,
7047,
1027,
1063,
1065,
1007,
1027,
1028,
1063,
9530,
3367,
1063,
2171,
1010,
1012,
1012,
1012,
6782,
7361,
9285,
1065,
1027,
7047,
1025,
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/events/jquery/EventTriggerHook.js | _applyTriggerHook | function _applyTriggerHook(sEventType) {
if (!jQuery.event.special[sEventType]) {
jQuery.event.special[sEventType] = {};
}
var oSpecialEvent = jQuery.event.special[sEventType],
originalTriggerHook = oSpecialEvent.trigger;
oSpecialEvent.trigger = fnTriggerHook;
return originalTriggerHook;
} | javascript | function _applyTriggerHook(sEventType) {
if (!jQuery.event.special[sEventType]) {
jQuery.event.special[sEventType] = {};
}
var oSpecialEvent = jQuery.event.special[sEventType],
originalTriggerHook = oSpecialEvent.trigger;
oSpecialEvent.trigger = fnTriggerHook;
return originalTriggerHook;
} | [
"function",
"_applyTriggerHook",
"(",
"sEventType",
")",
"{",
"if",
"(",
"!",
"jQuery",
".",
"event",
".",
"special",
"[",
"sEventType",
"]",
")",
"{",
"jQuery",
".",
"event",
".",
"special",
"[",
"sEventType",
"]",
"=",
"{",
"}",
";",
"}",
"var",
"o... | Register special jQuery.trigger event hook | [
"Register",
"special",
"jQuery",
".",
"trigger",
"event",
"hook"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/jquery/EventTriggerHook.js#L52-L62 | train | Apply a trigger hook to a special event | [
30522,
3853,
1035,
6611,
18886,
13327,
6806,
6559,
1006,
2698,
15353,
5051,
1007,
1063,
2065,
1006,
999,
1046,
4226,
2854,
1012,
2724,
1012,
2569,
1031,
2698,
15353,
5051,
1033,
1007,
1063,
1046,
4226,
2854,
1012,
2724,
1012,
2569,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | build/js/ControlSidebar.js | Plugin | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DataKey);
if (!data) {
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new ControlSidebar($this, options)));
}
if (typeof option == 'string') data.toggle();
});
} | javascript | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DataKey);
if (!data) {
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new ControlSidebar($this, options)));
}
if (typeof option == 'string') data.toggle();
});
} | [
"function",
"Plugin",
"(",
"option",
")",
"{",
"return",
"this",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"$this",
".",
"data",
"(",
"DataKey",
")",
";",
"if",
"(",
"!",
"... | Plugin Definition ================= | [
"Plugin",
"Definition",
"================="
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/build/js/ControlSidebar.js#L105-L117 | train | Plugin constructor. | [
30522,
3853,
13354,
2378,
1006,
5724,
1007,
1063,
2709,
30524,
1012,
2951,
1006,
2951,
14839,
1007,
1025,
2065,
1006,
999,
2951,
1007,
1063,
13075,
7047,
1027,
1002,
1012,
7949,
1006,
1063,
1065,
1010,
12398,
1010,
1002,
2023,
1012,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/reporters/cli/cli-utils.js | function (runOptions) {
var dimension = cliUtils.dimension(),
options = {
depth: 25,
maxArrayLength: 100, // only supported in Node v6.1.0 and up: https://github.com/nodejs/node/pull/6334
colors: !cliUtils.noTTY(runOptions.color),
// note that similar dimension calculation is in utils.wrapper
// only supported in Node v6.3.0 and above: https://github.com/nodejs/node/pull/7499
breakLength: ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 16
};
return function (item) {
return inspect(item, options);
};
} | javascript | function (runOptions) {
var dimension = cliUtils.dimension(),
options = {
depth: 25,
maxArrayLength: 100, // only supported in Node v6.1.0 and up: https://github.com/nodejs/node/pull/6334
colors: !cliUtils.noTTY(runOptions.color),
// note that similar dimension calculation is in utils.wrapper
// only supported in Node v6.3.0 and above: https://github.com/nodejs/node/pull/7499
breakLength: ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 16
};
return function (item) {
return inspect(item, options);
};
} | [
"function",
"(",
"runOptions",
")",
"{",
"var",
"dimension",
"=",
"cliUtils",
".",
"dimension",
"(",
")",
",",
"options",
"=",
"{",
"depth",
":",
"25",
",",
"maxArrayLength",
":",
"100",
",",
"// only supported in Node v6.1.0 and up: https://github.com/nodejs/node/p... | A CLI utility helper method that generates a color inspector function for CLI reports.
@param {Object} runOptions - The set of run options acquired via the runner.
@returns {Function} - A function to perform utils.inspect, given a sample item, under pre-existing options. | [
"A",
"CLI",
"utility",
"helper",
"method",
"that",
"generates",
"a",
"color",
"inspector",
"function",
"for",
"CLI",
"reports",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L112-L129 | train | Returns a function that returns a function that will return a string that represents the current language. | [
30522,
3853,
1006,
2448,
7361,
9285,
1007,
1063,
13075,
9812,
1027,
18856,
17922,
3775,
4877,
1012,
9812,
1006,
1007,
1010,
7047,
1027,
1063,
5995,
1024,
2423,
1010,
4098,
2906,
9447,
7770,
13512,
2232,
1024,
2531,
1010,
1013,
1013,
2069,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
twbs/bootstrap | dist/js/bootstrap.esm.js | normalizeData | function normalizeData(val) {
if (val === 'true') {
return true;
}
if (val === 'false') {
return false;
}
if (val === Number(val).toString()) {
return Number(val);
}
if (val === '' || val === 'null') {
return null;
}
return val;
} | javascript | function normalizeData(val) {
if (val === 'true') {
return true;
}
if (val === 'false') {
return false;
}
if (val === Number(val).toString()) {
return Number(val);
}
if (val === '' || val === 'null') {
return null;
}
return val;
} | [
"function",
"normalizeData",
"(",
"val",
")",
"{",
"if",
"(",
"val",
"===",
"'true'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"val",
"===",
"'false'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"val",
"===",
"Number",
"(",
"val",
... | --------------------------------------------------------------------------
Bootstrap (v4.3.1): dom/manipulator.js
Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
-------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------",
"Bootstrap",
"(",
"v4",
".",
"3",
".",
"1",
")",
":",
"dom",
"/",
"manipulator",
".",
"js",
"Licensed",
"under",
"MIT",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"twbs",
"/",... | d806e874b4b9c4a3bb2d0715415aebbad78466a2 | https://github.com/twbs/bootstrap/blob/d806e874b4b9c4a3bb2d0715415aebbad78466a2/dist/js/bootstrap.esm.js#L1181-L1199 | train | Normalize the data value | [
30522,
3853,
3671,
3550,
6790,
1006,
11748,
1007,
1063,
2065,
1006,
11748,
1027,
1027,
1027,
1005,
2995,
1005,
1007,
1063,
2709,
2995,
1025,
1065,
2065,
1006,
11748,
1027,
1027,
1027,
1005,
6270,
1005,
1007,
1063,
2709,
6270,
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... |
Shopify/draggable | src/Draggable/Plugins/Mirror/Mirror.js | addMirrorClasses | function addMirrorClasses({mirror, mirrorClass, ...args}) {
return withPromise((resolve) => {
mirror.classList.add(mirrorClass);
resolve({mirror, mirrorClass, ...args});
});
} | javascript | function addMirrorClasses({mirror, mirrorClass, ...args}) {
return withPromise((resolve) => {
mirror.classList.add(mirrorClass);
resolve({mirror, mirrorClass, ...args});
});
} | [
"function",
"addMirrorClasses",
"(",
"{",
"mirror",
",",
"mirrorClass",
",",
"...",
"args",
"}",
")",
"{",
"return",
"withPromise",
"(",
"(",
"resolve",
")",
"=>",
"{",
"mirror",
".",
"classList",
".",
"add",
"(",
"mirrorClass",
")",
";",
"resolve",
"(",... | Applys mirror class on mirror element
@param {Object} state
@param {HTMLElement} state.mirror
@param {String} state.mirrorClass
@return {Promise}
@private | [
"Applys",
"mirror",
"class",
"on",
"mirror",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Draggable/Plugins/Mirror/Mirror.js#L400-L405 | train | Adds a class to the specified mirror class list | [
30522,
3853,
5587,
14503,
29165,
26266,
2229,
1006,
1063,
5259,
1010,
5259,
26266,
1010,
1012,
1012,
1012,
12098,
5620,
1065,
1007,
1063,
2709,
2007,
21572,
28732,
1006,
1006,
10663,
1007,
1027,
1028,
1063,
5259,
1012,
2465,
9863,
1012,
558... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DOMNode.js | DOMNode | function DOMNode(agent, payload) {
this.agent = agent;
this.children = [];
this.attributes = {};
// set the payload
if (typeof payload === "string") {
payload = DOMHelpers.extractPayload(payload);
}
if (payload) {
this.setPayload(payload);
}
this.agent.addNode(this);
} | javascript | function DOMNode(agent, payload) {
this.agent = agent;
this.children = [];
this.attributes = {};
// set the payload
if (typeof payload === "string") {
payload = DOMHelpers.extractPayload(payload);
}
if (payload) {
this.setPayload(payload);
}
this.agent.addNode(this);
} | [
"function",
"DOMNode",
"(",
"agent",
",",
"payload",
")",
"{",
"this",
".",
"agent",
"=",
"agent",
";",
"this",
".",
"children",
"=",
"[",
"]",
";",
"this",
".",
"attributes",
"=",
"{",
"}",
";",
"// set the payload",
"if",
"(",
"typeof",
"payload",
... | Constructor
@param {DOMAgent} the agent is passed to avoid circular relationships
@param {DOM.Node} node payload | [
"Constructor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMNode.js#L79-L92 | train | DOM Node constructor | [
30522,
3853,
14383,
3630,
3207,
1006,
4005,
1010,
18093,
1007,
1063,
2023,
1012,
4005,
1027,
4005,
1025,
2023,
1012,
2336,
1027,
1031,
1033,
1025,
2023,
1012,
12332,
1027,
1063,
1065,
1025,
1013,
1013,
2275,
1996,
18093,
2065,
1006,
2828,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Microsoft/vscode | src/main.js | stripComments | function stripComments(content) {
const regexp = /("(?:[^\\"]*(?:\\.)?)*")|('(?:[^\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
return content.replace(regexp, function (match, m1, m2, m3, m4) {
// Only one of m1, m2, m3, m4 matches
if (m3) {
// A block comment. Replace with nothing
return '';
} else if (m4) {
// A line comment. If it ends in \r?\n then keep it.
const length_1 = m4.length;
if (length_1 > 2 && m4[length_1 - 1] === '\n') {
return m4[length_1 - 2] === '\r' ? '\r\n' : '\n';
}
else {
return '';
}
} else {
// We match a string
return match;
}
});
} | javascript | function stripComments(content) {
const regexp = /("(?:[^\\"]*(?:\\.)?)*")|('(?:[^\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
return content.replace(regexp, function (match, m1, m2, m3, m4) {
// Only one of m1, m2, m3, m4 matches
if (m3) {
// A block comment. Replace with nothing
return '';
} else if (m4) {
// A line comment. If it ends in \r?\n then keep it.
const length_1 = m4.length;
if (length_1 > 2 && m4[length_1 - 1] === '\n') {
return m4[length_1 - 2] === '\r' ? '\r\n' : '\n';
}
else {
return '';
}
} else {
// We match a string
return match;
}
});
} | [
"function",
"stripComments",
"(",
"content",
")",
"{",
"const",
"regexp",
"=",
"/",
"(\"(?:[^\\\\\"]*(?:\\\\.)?)*\")|('(?:[^\\\\']*(?:\\\\.)?)*')|(\\/\\*(?:\\r?\\n|.)*?\\*\\/)|(\\/{2,}.*?(?:(?:\\r?\\n)|$))",
"/",
"g",
";",
"return",
"content",
".",
"replace",
"(",
"regexp",
"... | #region NLS Support
@param {string} content
@returns {string} | [
"#region",
"NLS",
"Support"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/src/main.js#L300-L322 | train | Strip comments from a string | [
30522,
3853,
6167,
9006,
8163,
1006,
4180,
1007,
1063,
9530,
3367,
19723,
10288,
2361,
1027,
1013,
1006,
1000,
1006,
1029,
1024,
1031,
1034,
1032,
1032,
1000,
1033,
1008,
1006,
1029,
1024,
1032,
1032,
1012,
1007,
1029,
1007,
1008,
1000,
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... |
TryGhost/Ghost | core/server/services/routing/helpers/format-response.js | formatPageResponse | function formatPageResponse(result) {
var response = {};
if (result.posts) {
response.posts = result.posts;
}
if (result.meta && result.meta.pagination) {
response.pagination = result.meta.pagination;
}
_.each(result.data, function (data, name) {
if (data.meta) {
// Move pagination to be a top level key
response[name] = data;
response[name].pagination = data.meta.pagination;
delete response[name].meta;
} else {
// This is a single object, don't wrap it in an array
response[name] = data[0];
}
});
return response;
} | javascript | function formatPageResponse(result) {
var response = {};
if (result.posts) {
response.posts = result.posts;
}
if (result.meta && result.meta.pagination) {
response.pagination = result.meta.pagination;
}
_.each(result.data, function (data, name) {
if (data.meta) {
// Move pagination to be a top level key
response[name] = data;
response[name].pagination = data.meta.pagination;
delete response[name].meta;
} else {
// This is a single object, don't wrap it in an array
response[name] = data[0];
}
});
return response;
} | [
"function",
"formatPageResponse",
"(",
"result",
")",
"{",
"var",
"response",
"=",
"{",
"}",
";",
"if",
"(",
"result",
".",
"posts",
")",
"{",
"response",
".",
"posts",
"=",
"result",
".",
"posts",
";",
"}",
"if",
"(",
"result",
".",
"meta",
"&&",
... | @description Formats API response into handlebars/theme format.
@return {Object} containing page variables | [
"@description",
"Formats",
"API",
"response",
"into",
"handlebars",
"/",
"theme",
"format",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/routing/helpers/format-response.js#L8-L32 | train | Format a page response | [
30522,
3853,
4289,
13704,
6072,
26029,
3366,
1006,
2765,
1007,
1063,
13075,
3433,
1027,
1063,
1065,
1025,
2065,
1006,
2765,
1012,
8466,
1007,
1063,
3433,
1012,
8466,
1027,
2765,
1012,
8466,
1025,
1065,
2065,
1006,
2765,
1012,
18804,
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... |
socketio/socket.io | lib/index.js | Server | function Server(srv, opts){
if (!(this instanceof Server)) return new Server(srv, opts);
if ('object' == typeof srv && srv instanceof Object && !srv.listen) {
opts = srv;
srv = null;
}
opts = opts || {};
this.nsps = {};
this.parentNsps = new Map();
this.path(opts.path || '/socket.io');
this.serveClient(false !== opts.serveClient);
this.parser = opts.parser || parser;
this.encoder = new this.parser.Encoder();
this.adapter(opts.adapter || Adapter);
this.origins(opts.origins || '*:*');
this.sockets = this.of('/');
if (srv) this.attach(srv, opts);
} | javascript | function Server(srv, opts){
if (!(this instanceof Server)) return new Server(srv, opts);
if ('object' == typeof srv && srv instanceof Object && !srv.listen) {
opts = srv;
srv = null;
}
opts = opts || {};
this.nsps = {};
this.parentNsps = new Map();
this.path(opts.path || '/socket.io');
this.serveClient(false !== opts.serveClient);
this.parser = opts.parser || parser;
this.encoder = new this.parser.Encoder();
this.adapter(opts.adapter || Adapter);
this.origins(opts.origins || '*:*');
this.sockets = this.of('/');
if (srv) this.attach(srv, opts);
} | [
"function",
"Server",
"(",
"srv",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Server",
")",
")",
"return",
"new",
"Server",
"(",
"srv",
",",
"opts",
")",
";",
"if",
"(",
"'object'",
"==",
"typeof",
"srv",
"&&",
"srv",
"instan... | Server constructor.
@param {http.Server|Number|Object} srv http server, port or options
@param {Object} [opts]
@api public | [
"Server",
"constructor",
"."
] | 9c1e73c752aec63f48b511330a506d037783d897 | https://github.com/socketio/socket.io/blob/9c1e73c752aec63f48b511330a506d037783d897/lib/index.js#L43-L60 | train | Server constructor. | [
30522,
3853,
8241,
1006,
5034,
2615,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
999,
1006,
2023,
6013,
11253,
8241,
1007,
1007,
2709,
2047,
8241,
1006,
5034,
2615,
1010,
23569,
2015,
1007,
1025,
2065,
1006,
1005,
4874,
1005,
1027,
1027,
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... |
adobe/brackets | src/utils/TokenUtils.js | moveSkippingWhitespace | function moveSkippingWhitespace(moveFxn, ctx) {
if (!moveFxn(ctx)) {
return false;
}
while (!ctx.token.type && !/\S/.test(ctx.token.string)) {
if (!moveFxn(ctx)) {
return false;
}
}
return true;
} | javascript | function moveSkippingWhitespace(moveFxn, ctx) {
if (!moveFxn(ctx)) {
return false;
}
while (!ctx.token.type && !/\S/.test(ctx.token.string)) {
if (!moveFxn(ctx)) {
return false;
}
}
return true;
} | [
"function",
"moveSkippingWhitespace",
"(",
"moveFxn",
",",
"ctx",
")",
"{",
"if",
"(",
"!",
"moveFxn",
"(",
"ctx",
")",
")",
"{",
"return",
"false",
";",
"}",
"while",
"(",
"!",
"ctx",
".",
"token",
".",
"type",
"&&",
"!",
"/",
"\\S",
"/",
".",
"... | Moves the given context in the given direction, skipping any whitespace it hits.
@param {function} moveFxn the function to move the context
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@return {boolean} whether the context changed | [
"Moves",
"the",
"given",
"context",
"in",
"the",
"given",
"direction",
"skipping",
"any",
"whitespace",
"it",
"hits",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L178-L188 | train | Move the tokens skipping whitespace | [
30522,
3853,
5829,
3211,
14853,
2860,
16584,
2229,
15327,
1006,
2693,
2546,
2595,
2078,
1010,
14931,
2595,
1007,
1063,
2065,
1006,
999,
2693,
2546,
2595,
2078,
1006,
14931,
2595,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
2096,
1006,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-return-await.js | hasErrorHandler | function hasErrorHandler(node) {
let ancestor = node;
while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") {
if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) {
return true;
}
ancestor = ancestor.parent;
}
return false;
} | javascript | function hasErrorHandler(node) {
let ancestor = node;
while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") {
if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) {
return true;
}
ancestor = ancestor.parent;
}
return false;
} | [
"function",
"hasErrorHandler",
"(",
"node",
")",
"{",
"let",
"ancestor",
"=",
"node",
";",
"while",
"(",
"!",
"astUtils",
".",
"isFunction",
"(",
"ancestor",
")",
"&&",
"ancestor",
".",
"type",
"!==",
"\"Program\"",
")",
"{",
"if",
"(",
"ancestor",
".",
... | Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
this function. For example, a statement in a `try` block will always have an error handler. A statement in
a `catch` block will only have an error handler if there is also a `finally` block.
@param {ASTNode} node A node representing a location where an could be thrown
@returns {boolean} `true` if a thrown error will be caught/handled in this function | [
"Determines",
"whether",
"a",
"thrown",
"error",
"from",
"this",
"node",
"will",
"be",
"caught",
"/",
"handled",
"within",
"this",
"function",
"rather",
"than",
"immediately",
"halting",
"this",
"function",
".",
"For",
"example",
"a",
"statement",
"in",
"a",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-return-await.js#L56-L66 | train | Check if a node has an error handler | [
30522,
3853,
2038,
2121,
29165,
11774,
3917,
1006,
13045,
1007,
1063,
2292,
13032,
1027,
13045,
1025,
2096,
1006,
999,
2004,
8525,
3775,
4877,
1012,
2003,
11263,
27989,
1006,
13032,
1007,
1004,
1004,
13032,
1012,
2828,
999,
1027,
1027,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/api/deprecate.js | logNotice | function logNotice(book, key, message) {
if (logged[key] || disabled[key]) return;
logged[key] = true;
var logger = book.getLogger();
logger.warn.ln(message);
} | javascript | function logNotice(book, key, message) {
if (logged[key] || disabled[key]) return;
logged[key] = true;
var logger = book.getLogger();
logger.warn.ln(message);
} | [
"function",
"logNotice",
"(",
"book",
",",
"key",
",",
"message",
")",
"{",
"if",
"(",
"logged",
"[",
"key",
"]",
"||",
"disabled",
"[",
"key",
"]",
")",
"return",
";",
"logged",
"[",
"key",
"]",
"=",
"true",
";",
"var",
"logger",
"=",
"book",
".... | Log a deprecated notice
@param {Book|Output} book
@param {String} key
@param {String} message | [
"Log",
"a",
"deprecated",
"notice"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L14-L21 | train | Log a notice to the log | [
30522,
3853,
8833,
17048,
6610,
1006,
2338,
1010,
3145,
1010,
4471,
1007,
1063,
2065,
1006,
26618,
1031,
3145,
1033,
1064,
1064,
9776,
1031,
3145,
1033,
1007,
2709,
1025,
26618,
1031,
3145,
1033,
1027,
2995,
1025,
13075,
8833,
4590,
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... |
eslint/eslint | lib/rules/func-name-matching.js | isModuleExports | function isModuleExports(pattern) {
if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") {
// module.exports
if (pattern.property.type === "Identifier" && pattern.property.name === "exports") {
return true;
}
// module["exports"]
if (pattern.property.type === "Literal" && pattern.property.value === "exports") {
return true;
}
}
return false;
} | javascript | function isModuleExports(pattern) {
if (pattern.type === "MemberExpression" && pattern.object.type === "Identifier" && pattern.object.name === "module") {
// module.exports
if (pattern.property.type === "Identifier" && pattern.property.name === "exports") {
return true;
}
// module["exports"]
if (pattern.property.type === "Literal" && pattern.property.value === "exports") {
return true;
}
}
return false;
} | [
"function",
"isModuleExports",
"(",
"pattern",
")",
"{",
"if",
"(",
"pattern",
".",
"type",
"===",
"\"MemberExpression\"",
"&&",
"pattern",
".",
"object",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"pattern",
".",
"object",
".",
"name",
"===",
"\"module\"",
... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Determines if a pattern is `module.exports` or `module["exports"]`
@param {ASTNode} pattern The left side of the AssignmentExpression
@returns {boolean} True if the pattern is `module.exports` or `module["exports"]` | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Determines",
"if",
"a",
"pattern",
"is",
"module",
".",
"exports",
"or",
"module",
"[",
"exports",
"]"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/func-name-matching.js#L24-L38 | train | Check if pattern is a module exports | [
30522,
3853,
2003,
5302,
8566,
10559,
2595,
25378,
1006,
5418,
1007,
1063,
2065,
1006,
5418,
1012,
2828,
1027,
1027,
1027,
1000,
2266,
10288,
20110,
3258,
1000,
1004,
1004,
5418,
1012,
4874,
1012,
2828,
1027,
1027,
1027,
1000,
8909,
4765,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function (sAnnotationTarget, oAnnotationNode, oAnnotationTarget) {
var sQualifier = getQualifier(oAnnotationNode);
var sTerm = AnnotationParser.replaceWithAlias(oAnnotationNode.getAttribute("Term"));
if (sQualifier) {
sTerm += "#" + sQualifier;
}
var vValue = AnnotationParser.getPropertyValue(oAnnotationNode, sAnnotationTarget);
vValue = AnnotationParser.setEdmTypes(vValue, AnnotationParser._parserData.metadataProperties.types, sAnnotationTarget, AnnotationParser._parserData.schema);
oAnnotationTarget[sTerm] = vValue;
if (Array.isArray(oAnnotationTarget)) {
AnnotationParser._parserData.annotationsAtArrays.push(oAnnotationNode);
}
} | javascript | function (sAnnotationTarget, oAnnotationNode, oAnnotationTarget) {
var sQualifier = getQualifier(oAnnotationNode);
var sTerm = AnnotationParser.replaceWithAlias(oAnnotationNode.getAttribute("Term"));
if (sQualifier) {
sTerm += "#" + sQualifier;
}
var vValue = AnnotationParser.getPropertyValue(oAnnotationNode, sAnnotationTarget);
vValue = AnnotationParser.setEdmTypes(vValue, AnnotationParser._parserData.metadataProperties.types, sAnnotationTarget, AnnotationParser._parserData.schema);
oAnnotationTarget[sTerm] = vValue;
if (Array.isArray(oAnnotationTarget)) {
AnnotationParser._parserData.annotationsAtArrays.push(oAnnotationNode);
}
} | [
"function",
"(",
"sAnnotationTarget",
",",
"oAnnotationNode",
",",
"oAnnotationTarget",
")",
"{",
"var",
"sQualifier",
"=",
"getQualifier",
"(",
"oAnnotationNode",
")",
";",
"var",
"sTerm",
"=",
"AnnotationParser",
".",
"replaceWithAlias",
"(",
"oAnnotationNode",
".... | /*
Sets the parsed annotation term at the given oAnnotationTarget object.
@param {string} sAnnotationTarget
The target path used to determine EDM types
@param {Element} oAnnotationNode
The <Annotation> node to parse
@param {object|object[]} oAnnotationTarget
The target at which the annotation value is added
@static
@private | [
"/",
"*",
"Sets",
"the",
"parsed",
"annotation",
"term",
"at",
"the",
"given",
"oAnnotationTarget",
"object",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L563-L577 | train | Adds an annotation to the annotation target | [
30522,
3853,
1006,
2624,
17048,
3370,
7559,
18150,
1010,
1051,
11639,
17287,
3508,
3630,
3207,
1010,
1051,
11639,
17287,
3508,
7559,
18150,
1007,
1063,
13075,
5490,
8787,
18095,
1027,
2131,
26426,
18095,
1006,
1051,
11639,
17287,
3508,
3630,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/NodeDomain.js | NodeDomain | function NodeDomain(domainName, domainPath) {
var connection = new NodeConnection();
this.connection = connection;
this._domainName = domainName;
this._domainPath = domainPath;
this._domainLoaded = false;
this._load = this._load.bind(this);
this._connectionPromise = connection.connect(true)
.then(this._load);
connection.on("close", function (event, promise) {
this.connection.off(EVENT_NAMESPACE);
this._domainLoaded = false;
this._connectionPromise = promise.then(this._load);
}.bind(this));
} | javascript | function NodeDomain(domainName, domainPath) {
var connection = new NodeConnection();
this.connection = connection;
this._domainName = domainName;
this._domainPath = domainPath;
this._domainLoaded = false;
this._load = this._load.bind(this);
this._connectionPromise = connection.connect(true)
.then(this._load);
connection.on("close", function (event, promise) {
this.connection.off(EVENT_NAMESPACE);
this._domainLoaded = false;
this._connectionPromise = promise.then(this._load);
}.bind(this));
} | [
"function",
"NodeDomain",
"(",
"domainName",
",",
"domainPath",
")",
"{",
"var",
"connection",
"=",
"new",
"NodeConnection",
"(",
")",
";",
"this",
".",
"connection",
"=",
"connection",
";",
"this",
".",
"_domainName",
"=",
"domainName",
";",
"this",
".",
... | Provides a simple abstraction for executing the commands of a single
domain loaded via a NodeConnection. Automatically handles connection
management and domain loading, and exposes each command in the domain as
a promise-returning method that can safely be called regardless of the
current status of the underlying connection. Example usage:
var myDomain = new NodeDomain("someDomain", "/path/to/SomeDomainDef.js"),
$result = myDomain.exec("someCommand", arg1, arg2);
$result.done(function (value) {
// the command succeeded!
});
$result.fail(function (err) {
// the command failed; act accordingly!
});
To handle domain events, just listen for the event on the domain:
myDomain.on("someEvent", someHandler);
@constructor
@param {string} domainName Name of the registered Node Domain
@param {string} domainPath Full path of the JavaScript Node domain specification | [
"Provides",
"a",
"simple",
"abstraction",
"for",
"executing",
"the",
"commands",
"of",
"a",
"single",
"domain",
"loaded",
"via",
"a",
"NodeConnection",
".",
"Automatically",
"handles",
"connection",
"management",
"and",
"domain",
"loading",
"and",
"exposes",
"each... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/NodeDomain.js#L59-L75 | train | NodeDomain constructor. | [
30522,
3853,
13045,
9527,
8113,
1006,
5884,
18442,
1010,
5884,
15069,
1007,
1063,
13075,
4434,
1027,
2047,
13045,
8663,
2638,
7542,
1006,
1007,
1025,
2023,
1012,
4434,
1027,
4434,
1025,
2023,
1012,
1035,
5884,
18442,
1027,
5884,
18442,
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... |
angular/protractor | website/docgen/processors/tag-fixer.js | buildName | function buildName(obj) {
if (!obj) {
return parts.join('.');
}
if (obj.property && obj.property.name) {
parts.unshift(obj.property.name);
}
if (obj.object && obj.object.name) {
parts.unshift(obj.object.name);
}
return buildName(obj.object);
} | javascript | function buildName(obj) {
if (!obj) {
return parts.join('.');
}
if (obj.property && obj.property.name) {
parts.unshift(obj.property.name);
}
if (obj.object && obj.object.name) {
parts.unshift(obj.object.name);
}
return buildName(obj.object);
} | [
"function",
"buildName",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
"parts",
".",
"join",
"(",
"'.'",
")",
";",
"}",
"if",
"(",
"obj",
".",
"property",
"&&",
"obj",
".",
"property",
".",
"name",
")",
"{",
"parts",
".",
"un... | Recursively create the function name by examining the object property.
@param obj Parsed object.
@return {string} The name of the function. | [
"Recursively",
"create",
"the",
"function",
"name",
"by",
"examining",
"the",
"object",
"property",
"."
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/website/docgen/processors/tag-fixer.js#L39-L53 | train | Build the name of the object | [
30522,
3853,
3857,
18442,
1006,
27885,
3501,
1007,
1063,
2065,
1006,
999,
27885,
3501,
1007,
1063,
2709,
3033,
1012,
3693,
1006,
1005,
1012,
1005,
1007,
1025,
1065,
2065,
1006,
27885,
3501,
1012,
3200,
1004,
1004,
27885,
3501,
1012,
3200,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oEntitySet, oEntityType) {
if (oEntityType.property) {
oEntityType.property.forEach(function (oProperty) {
if (oProperty["sap:filterable"] === "false") {
Utils.addPropertyToAnnotation("sap:filterable", oEntitySet, oProperty);
}
if (oProperty["sap:required-in-filter"] === "true") {
Utils.addPropertyToAnnotation("sap:required-in-filter", oEntitySet,
oProperty);
}
if (oProperty["sap:sortable"] === "false") {
Utils.addPropertyToAnnotation("sap:sortable", oEntitySet, oProperty);
}
if (oProperty["sap:filter-restriction"]) {
Utils.addFilterRestriction(oProperty, oEntitySet);
}
});
}
if (oEntityType.navigationProperty) {
oEntityType.navigationProperty.forEach(function (oNavigationProperty) {
if (oNavigationProperty["sap:filterable"] === "false") {
Utils.addNavigationFilterRestriction(oNavigationProperty, oEntitySet);
// keep deprecated conversion for compatibility reasons
Utils.addPropertyToAnnotation("sap:filterable", oEntitySet,
oNavigationProperty);
}
Utils.handleCreatableNavigationProperty(oEntitySet, oNavigationProperty);
});
}
} | javascript | function (oEntitySet, oEntityType) {
if (oEntityType.property) {
oEntityType.property.forEach(function (oProperty) {
if (oProperty["sap:filterable"] === "false") {
Utils.addPropertyToAnnotation("sap:filterable", oEntitySet, oProperty);
}
if (oProperty["sap:required-in-filter"] === "true") {
Utils.addPropertyToAnnotation("sap:required-in-filter", oEntitySet,
oProperty);
}
if (oProperty["sap:sortable"] === "false") {
Utils.addPropertyToAnnotation("sap:sortable", oEntitySet, oProperty);
}
if (oProperty["sap:filter-restriction"]) {
Utils.addFilterRestriction(oProperty, oEntitySet);
}
});
}
if (oEntityType.navigationProperty) {
oEntityType.navigationProperty.forEach(function (oNavigationProperty) {
if (oNavigationProperty["sap:filterable"] === "false") {
Utils.addNavigationFilterRestriction(oNavigationProperty, oEntitySet);
// keep deprecated conversion for compatibility reasons
Utils.addPropertyToAnnotation("sap:filterable", oEntitySet,
oNavigationProperty);
}
Utils.handleCreatableNavigationProperty(oEntitySet, oNavigationProperty);
});
}
} | [
"function",
"(",
"oEntitySet",
",",
"oEntityType",
")",
"{",
"if",
"(",
"oEntityType",
".",
"property",
")",
"{",
"oEntityType",
".",
"property",
".",
"forEach",
"(",
"function",
"(",
"oProperty",
")",
"{",
"if",
"(",
"oProperty",
"[",
"\"sap:filterable\"",
... | Iterate over all properties of the associated entity type for given entity
set and check whether the property needs to be added to an annotation at the
entity set.
For example all properties with "sap:sortable=false" are collected in
annotation Org.OData.Capabilities.V1.SortRestrictions/NonSortableProperties.
@param {object} oEntitySet
the entity set
@param {object} oEntityType
the corresponding entity type | [
"Iterate",
"over",
"all",
"properties",
"of",
"the",
"associated",
"entity",
"type",
"for",
"given",
"entity",
"set",
"and",
"check",
"whether",
"the",
"property",
"needs",
"to",
"be",
"added",
"to",
"an",
"annotation",
"at",
"the",
"entity",
"set",
".",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L542-L571 | train | Adds the sap : filterable and sap : required - in - filter annotations to the entity set. | [
30522,
3853,
1006,
1051,
4765,
3012,
13462,
1010,
1051,
4765,
3012,
13874,
1007,
1063,
2065,
1006,
1051,
4765,
3012,
13874,
1012,
3200,
1007,
1063,
1051,
4765,
3012,
13874,
1012,
3200,
1012,
18921,
6776,
1006,
3853,
1006,
6728,
18981,
15010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableScrollExtension.js | function(oTable) {
var oScrollExtension = oTable._getScrollExtension();
var oHSb = oScrollExtension.getHorizontalScrollbar();
if (oHSb && internal(oTable).iHorizontalScrollPosition !== null) {
var aScrollTargets = HorizontalScrollingHelper.getScrollAreas(oTable);
for (var i = 0; i < aScrollTargets.length; i++) {
var oScrollTarget = aScrollTargets[i];
delete oScrollTarget._scrollLeft;
}
if (oHSb.scrollLeft !== internal(oTable).iHorizontalScrollPosition) {
oHSb.scrollLeft = internal(oTable).iHorizontalScrollPosition;
} else {
var oEvent = jQuery.Event("scroll");
oEvent.target = oHSb;
HorizontalScrollingHelper.onScroll.call(oTable, oEvent);
}
}
} | javascript | function(oTable) {
var oScrollExtension = oTable._getScrollExtension();
var oHSb = oScrollExtension.getHorizontalScrollbar();
if (oHSb && internal(oTable).iHorizontalScrollPosition !== null) {
var aScrollTargets = HorizontalScrollingHelper.getScrollAreas(oTable);
for (var i = 0; i < aScrollTargets.length; i++) {
var oScrollTarget = aScrollTargets[i];
delete oScrollTarget._scrollLeft;
}
if (oHSb.scrollLeft !== internal(oTable).iHorizontalScrollPosition) {
oHSb.scrollLeft = internal(oTable).iHorizontalScrollPosition;
} else {
var oEvent = jQuery.Event("scroll");
oEvent.target = oHSb;
HorizontalScrollingHelper.onScroll.call(oTable, oEvent);
}
}
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oScrollExtension",
"=",
"oTable",
".",
"_getScrollExtension",
"(",
")",
";",
"var",
"oHSb",
"=",
"oScrollExtension",
".",
"getHorizontalScrollbar",
"(",
")",
";",
"if",
"(",
"oHSb",
"&&",
"internal",
"(",
"oTable"... | This function can be used to restore the last horizontal scroll position which has been stored.
In case there is no stored scroll position nothing happens.
@param {sap.ui.table.Table} oTable Instance of the table.
@see HorizontalScrollingHelper#onScroll | [
"This",
"function",
"can",
"be",
"used",
"to",
"restore",
"the",
"last",
"horizontal",
"scroll",
"position",
"which",
"has",
"been",
"stored",
".",
"In",
"case",
"there",
"is",
"no",
"stored",
"scroll",
"position",
"nothing",
"happens",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableScrollExtension.js#L182-L202 | train | Updates the horizontal scroll position of the table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
9808,
26775,
14511,
10288,
29048,
1027,
27178,
3085,
1012,
1035,
4152,
26775,
14511,
10288,
29048,
1006,
1007,
1025,
13075,
2821,
19022,
1027,
9808,
26775,
14511,
10288,
29048,
1012,
2131,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RelayFindGraphQLTags.js | invariant | function invariant(condition, msg, ...args) {
if (!condition) {
throw new Error(util.format(msg, ...args));
}
} | javascript | function invariant(condition, msg, ...args) {
if (!condition) {
throw new Error(util.format(msg, ...args));
}
} | [
"function",
"invariant",
"(",
"condition",
",",
"msg",
",",
"...",
"args",
")",
"{",
"if",
"(",
"!",
"condition",
")",
"{",
"throw",
"new",
"Error",
"(",
"util",
".",
"format",
"(",
"msg",
",",
"...",
"args",
")",
")",
";",
"}",
"}"
] | TODO: Not sure why this is defined here rather than imported, is it so that it doesn’t get stripped in prod? | [
"TODO",
":",
"Not",
"sure",
"why",
"this",
"is",
"defined",
"here",
"rather",
"than",
"imported",
"is",
"it",
"so",
"that",
"it",
"doesn’t",
"get",
"stripped",
"in",
"prod?"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/RelayFindGraphQLTags.js#L108-L112 | train | Assert that a condition is true. | [
30522,
3853,
23915,
1006,
4650,
1010,
5796,
2290,
1010,
1012,
1012,
1012,
12098,
5620,
1007,
1063,
2065,
1006,
999,
4650,
1007,
1063,
5466,
2047,
7561,
1006,
21183,
4014,
1012,
4289,
1006,
5796,
2290,
1010,
1012,
1012,
1012,
12098,
5620,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tensorflow/tfjs-models | posenet/demos/coco.js | drawResults | function drawResults(canvas, poses, minPartConfidence, minPoseConfidence) {
renderImageToCanvas(image, [513, 513], canvas);
poses.forEach((pose) => {
if (pose.score >= minPoseConfidence) {
if (guiState.showKeypoints) {
drawKeypoints(
pose.keypoints, minPartConfidence, canvas.getContext('2d'));
}
if (guiState.showSkeleton) {
drawSkeleton(
pose.keypoints, minPartConfidence, canvas.getContext('2d'));
}
if (guiState.showBoundingBox) {
drawBoundingBox(pose.keypoints, canvas.getContext('2d'));
}
}
});
} | javascript | function drawResults(canvas, poses, minPartConfidence, minPoseConfidence) {
renderImageToCanvas(image, [513, 513], canvas);
poses.forEach((pose) => {
if (pose.score >= minPoseConfidence) {
if (guiState.showKeypoints) {
drawKeypoints(
pose.keypoints, minPartConfidence, canvas.getContext('2d'));
}
if (guiState.showSkeleton) {
drawSkeleton(
pose.keypoints, minPartConfidence, canvas.getContext('2d'));
}
if (guiState.showBoundingBox) {
drawBoundingBox(pose.keypoints, canvas.getContext('2d'));
}
}
});
} | [
"function",
"drawResults",
"(",
"canvas",
",",
"poses",
",",
"minPartConfidence",
",",
"minPoseConfidence",
")",
"{",
"renderImageToCanvas",
"(",
"image",
",",
"[",
"513",
",",
"513",
"]",
",",
"canvas",
")",
";",
"poses",
".",
"forEach",
"(",
"(",
"pose",... | Draws a pose if it passes a minimum confidence onto a canvas.
Only the pose's keypoints that pass a minPartConfidence are drawn. | [
"Draws",
"a",
"pose",
"if",
"it",
"passes",
"a",
"minimum",
"confidence",
"onto",
"a",
"canvas",
".",
"Only",
"the",
"pose",
"s",
"keypoints",
"that",
"pass",
"a",
"minPartConfidence",
"are",
"drawn",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/posenet/demos/coco.js#L67-L86 | train | draw results | [
30522,
3853,
4009,
6072,
11314,
2015,
1006,
10683,
1010,
22382,
1010,
8117,
19362,
13535,
2239,
20740,
5897,
1010,
8117,
20688,
8663,
20740,
5897,
1007,
1063,
17552,
9581,
18150,
24755,
2078,
12044,
1006,
3746,
1010,
1031,
4868,
2509,
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... |
adobe/brackets | src/JSUtils/ScopeManager.js | isFileExcluded | function isFileExcluded(file) {
if (file.name[0] === ".") {
return true;
}
var languageID = LanguageManager.getLanguageForPath(file.fullPath).getId();
if (languageID !== HintUtils.LANGUAGE_ID) {
return true;
}
var excludes = preferences.getExcludedFiles();
if (excludes && excludes.test(file.name)) {
return true;
}
if (isFileExcludedInternal(file.fullPath)) {
return true;
}
return false;
} | javascript | function isFileExcluded(file) {
if (file.name[0] === ".") {
return true;
}
var languageID = LanguageManager.getLanguageForPath(file.fullPath).getId();
if (languageID !== HintUtils.LANGUAGE_ID) {
return true;
}
var excludes = preferences.getExcludedFiles();
if (excludes && excludes.test(file.name)) {
return true;
}
if (isFileExcludedInternal(file.fullPath)) {
return true;
}
return false;
} | [
"function",
"isFileExcluded",
"(",
"file",
")",
"{",
"if",
"(",
"file",
".",
"name",
"[",
"0",
"]",
"===",
"\".\"",
")",
"{",
"return",
"true",
";",
"}",
"var",
"languageID",
"=",
"LanguageManager",
".",
"getLanguageForPath",
"(",
"file",
".",
"fullPath"... | Test if the file should be excluded from analysis.
@param {!File} file - file to test for exclusion.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"file",
"should",
"be",
"excluded",
"from",
"analysis",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L247-L267 | train | Check if a file is excluded | [
30522,
3853,
2003,
8873,
10559,
2595,
20464,
13936,
1006,
5371,
1007,
1063,
2065,
1006,
5371,
1012,
2171,
1031,
1014,
1033,
1027,
1027,
1027,
1000,
1012,
1000,
1007,
1063,
2709,
2995,
1025,
1065,
13075,
2653,
3593,
1027,
2653,
24805,
4590,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | write_binary_type | function write_binary_type(out, opts) {
switch(opts.type) {
case "string":
case "base64":
case "binary":
var bstr = "";
// $FlowIgnore
for(var i = 0; i < out.length; ++i) bstr += String.fromCharCode(out[i]);
return opts.type == 'base64' ? Base64.encode(bstr) : opts.type == 'string' ? utf8read(bstr) : bstr;
case "file": return write_dl(opts.file, out);
case "buffer": return out;
default: throw new Error("Unrecognized type " + opts.type);
}
} | javascript | function write_binary_type(out, opts) {
switch(opts.type) {
case "string":
case "base64":
case "binary":
var bstr = "";
// $FlowIgnore
for(var i = 0; i < out.length; ++i) bstr += String.fromCharCode(out[i]);
return opts.type == 'base64' ? Base64.encode(bstr) : opts.type == 'string' ? utf8read(bstr) : bstr;
case "file": return write_dl(opts.file, out);
case "buffer": return out;
default: throw new Error("Unrecognized type " + opts.type);
}
} | [
"function",
"write_binary_type",
"(",
"out",
",",
"opts",
")",
"{",
"switch",
"(",
"opts",
".",
"type",
")",
"{",
"case",
"\"string\"",
":",
"case",
"\"base64\"",
":",
"case",
"\"binary\"",
":",
"var",
"bstr",
"=",
"\"\"",
";",
"// $FlowIgnore",
"for",
"... | /* TODO: test consistency | [
"/",
"*",
"TODO",
":",
"test",
"consistency"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L20422-L20435 | train | Write a binary file or buffer | [
30522,
3853,
4339,
1035,
12441,
1035,
2828,
1006,
2041,
1010,
23569,
2015,
1007,
1063,
6942,
1006,
23569,
2015,
1012,
2828,
1007,
1063,
2553,
1000,
5164,
1000,
1024,
2553,
1000,
2918,
21084,
1000,
1024,
2553,
1000,
12441,
1000,
1024,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | initialize | function initialize ( target, originalOptions ) {
if ( !target.nodeName ) {
throw new Error('noUiSlider.create requires a single element.');
}
if (originalOptions.tooltips === undefined) {
originalOptions.tooltips = true;
}
// Test the options and create the slider environment;
var options = testOptions( originalOptions, target );
var api = closure( target, options, originalOptions );
target.noUiSlider = api;
return api;
} | javascript | function initialize ( target, originalOptions ) {
if ( !target.nodeName ) {
throw new Error('noUiSlider.create requires a single element.');
}
if (originalOptions.tooltips === undefined) {
originalOptions.tooltips = true;
}
// Test the options and create the slider environment;
var options = testOptions( originalOptions, target );
var api = closure( target, options, originalOptions );
target.noUiSlider = api;
return api;
} | [
"function",
"initialize",
"(",
"target",
",",
"originalOptions",
")",
"{",
"if",
"(",
"!",
"target",
".",
"nodeName",
")",
"{",
"throw",
"new",
"Error",
"(",
"'noUiSlider.create requires a single element.'",
")",
";",
"}",
"if",
"(",
"originalOptions",
".",
"t... | Run the standard initializer | [
"Run",
"the",
"standard",
"initializer"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L2123-L2140 | train | Initialize the noUiSlider environment | [
30522,
3853,
3988,
4697,
1006,
4539,
1010,
2434,
7361,
9285,
1007,
1063,
2065,
1006,
999,
4539,
1012,
13045,
18442,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
2053,
27020,
24198,
2099,
1012,
3443,
5942,
1037,
2309,
5783,
1012,
1005,
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... |
radare/radare2 | shlr/www/graph/js-graph-it.js | Canvas | function Canvas(htmlElement) {
/*
* initialization
*/
this.id = htmlElement.id;
this.htmlElement = htmlElement;
this.blocks = new Array();
this.connectors = new Array();
this.offsetLeft = calculateOffsetLeft(this.htmlElement);
this.offsetTop = calculateOffsetTop(this.htmlElement);
this.width;
this.height;
// create the inner div element
this.innerDiv = document.createElement ("div");
this.initCanvas = function() {
// setup the inner div
var children = this.htmlElement.childNodes;
var el;
var n = children.length;
for(var i = 0; i < n; i++) {
el = children[0];
this.htmlElement.removeChild(el);
this.innerDiv.appendChild(el);
if(el.style)
el.style.zIndex = "2";
}
this.htmlElement.appendChild(this.innerDiv);
this.htmlElement.style.overflow = "auto";
this.htmlElement.style.position = "relative";
this.innerDiv.id = this.id + "_innerDiv";
this.innerDiv.style.border = "none";
this.innerDiv.style.padding = "0px";
this.innerDiv.style.margin = "0px";
this.innerDiv.style.position = "absolute";
this.innerDiv.style.top = "0px";
this.innerDiv.style.left = "0px";
this.width = 0;
this.height = 0;
this.offsetLeft = calculateOffsetLeft(this.innerDiv);
this.offsetTop = calculateOffsetTop(this.innerDiv);
// inspect canvas children to identify first level blocks
new DocumentScanner(this, true).scan(this.htmlElement);
// now this.width and this.height are populated with minimum values needed for the inner
// blocks to fit, add 2 to avoid border overlap;
this.height += 2;
this.width += 2;
var visibleWidth = this.htmlElement.offsetWidth - 2; // - 2 is to avoid border overlap
var visibleHeight = this.htmlElement.offsetHeight - 2; // - 2 is to avoid border overlap
// consider the scrollbars width calculating the inner div size
if(this.height > visibleHeight)
visibleWidth -= SCROLLBARS_WIDTH;
if(this.width > visibleWidth)
visibleHeight -= SCROLLBARS_WIDTH;
this.height = Math.max(this.height, visibleHeight);
this.width = Math.max(this.width, visibleWidth);
this.innerDiv.style.width = this.width + "px";
this.innerDiv.style.height = this.height + "px";
// init connectors
for(i = 0; i < this.connectors.length; i++) {
this.connectors[i].initConnector();
}
}
this.visit = function(element) {
if (element == this.htmlElement)
return true;
// check the element dimensions against the acutal size of the canvas
this.width = Math.max(this.width, calculateOffsetLeft(element) - this.offsetLeft + element.offsetWidth);
this.height = Math.max(this.height, calculateOffsetTop(element) - this.offsetTop + element.offsetHeight);
if(isBlock(element)) {
// block found initialize it
var newBlock = new Block(element, this);
newBlock.initBlock();
this.blocks.push(newBlock);
return false;
} else if(isConnector(element)) {
// connector found, just create it, source or destination blocks may not
// have been initialized yet
var newConnector = new Connector(element, this);
this.connectors.push(newConnector);
return false;
} else {
// continue searching nested elements
return true;
}
}
/*
* methods
*/
this.print = function()
{
var output = '<ul><legend>canvas: ' + this.id + '</legend>';
var i;
for(i = 0; i < this.blocks.length; i++)
{
output += '<li>';
output += this.blocks[i].print();
output += '</li>';
}
output += '</ul>';
return output;
}
this.alignBlocks = function() {
var i;
var roof = 0;
// TODO: implement proper layout
for (i = 0; i < this.blocks.length ; i++) {
var b = this.blocks[i]; //.findBlock(blockId);
b.onMove();
b.htmlElement.style.top =roof;
roof += b.htmlElement.style.height+20;
// TODO: alert ("align "+b);
}
for (i = 0; i < this.connectors.length; i++) {
this.connectors[i].repaint();
console.log( this.connectors[i]);
}
}
this.fitBlocks = function() {
for (var i = 0; i < this.blocks.length ; i++) {
var b = this.blocks[i]; //.findBlock(blockId);
this.blocks[i].fit ();
}
}
/*
* This function searches for a nested block with a given id
*/
this.findBlock = function(blockId) {
var result;
for(var i = 0; i < this.blocks.length && !result; i++)
result = this.blocks[i].findBlock(blockId);
return result;
}
this.toString = function() {
return 'canvas: ' + this.id;
}
} | javascript | function Canvas(htmlElement) {
/*
* initialization
*/
this.id = htmlElement.id;
this.htmlElement = htmlElement;
this.blocks = new Array();
this.connectors = new Array();
this.offsetLeft = calculateOffsetLeft(this.htmlElement);
this.offsetTop = calculateOffsetTop(this.htmlElement);
this.width;
this.height;
// create the inner div element
this.innerDiv = document.createElement ("div");
this.initCanvas = function() {
// setup the inner div
var children = this.htmlElement.childNodes;
var el;
var n = children.length;
for(var i = 0; i < n; i++) {
el = children[0];
this.htmlElement.removeChild(el);
this.innerDiv.appendChild(el);
if(el.style)
el.style.zIndex = "2";
}
this.htmlElement.appendChild(this.innerDiv);
this.htmlElement.style.overflow = "auto";
this.htmlElement.style.position = "relative";
this.innerDiv.id = this.id + "_innerDiv";
this.innerDiv.style.border = "none";
this.innerDiv.style.padding = "0px";
this.innerDiv.style.margin = "0px";
this.innerDiv.style.position = "absolute";
this.innerDiv.style.top = "0px";
this.innerDiv.style.left = "0px";
this.width = 0;
this.height = 0;
this.offsetLeft = calculateOffsetLeft(this.innerDiv);
this.offsetTop = calculateOffsetTop(this.innerDiv);
// inspect canvas children to identify first level blocks
new DocumentScanner(this, true).scan(this.htmlElement);
// now this.width and this.height are populated with minimum values needed for the inner
// blocks to fit, add 2 to avoid border overlap;
this.height += 2;
this.width += 2;
var visibleWidth = this.htmlElement.offsetWidth - 2; // - 2 is to avoid border overlap
var visibleHeight = this.htmlElement.offsetHeight - 2; // - 2 is to avoid border overlap
// consider the scrollbars width calculating the inner div size
if(this.height > visibleHeight)
visibleWidth -= SCROLLBARS_WIDTH;
if(this.width > visibleWidth)
visibleHeight -= SCROLLBARS_WIDTH;
this.height = Math.max(this.height, visibleHeight);
this.width = Math.max(this.width, visibleWidth);
this.innerDiv.style.width = this.width + "px";
this.innerDiv.style.height = this.height + "px";
// init connectors
for(i = 0; i < this.connectors.length; i++) {
this.connectors[i].initConnector();
}
}
this.visit = function(element) {
if (element == this.htmlElement)
return true;
// check the element dimensions against the acutal size of the canvas
this.width = Math.max(this.width, calculateOffsetLeft(element) - this.offsetLeft + element.offsetWidth);
this.height = Math.max(this.height, calculateOffsetTop(element) - this.offsetTop + element.offsetHeight);
if(isBlock(element)) {
// block found initialize it
var newBlock = new Block(element, this);
newBlock.initBlock();
this.blocks.push(newBlock);
return false;
} else if(isConnector(element)) {
// connector found, just create it, source or destination blocks may not
// have been initialized yet
var newConnector = new Connector(element, this);
this.connectors.push(newConnector);
return false;
} else {
// continue searching nested elements
return true;
}
}
/*
* methods
*/
this.print = function()
{
var output = '<ul><legend>canvas: ' + this.id + '</legend>';
var i;
for(i = 0; i < this.blocks.length; i++)
{
output += '<li>';
output += this.blocks[i].print();
output += '</li>';
}
output += '</ul>';
return output;
}
this.alignBlocks = function() {
var i;
var roof = 0;
// TODO: implement proper layout
for (i = 0; i < this.blocks.length ; i++) {
var b = this.blocks[i]; //.findBlock(blockId);
b.onMove();
b.htmlElement.style.top =roof;
roof += b.htmlElement.style.height+20;
// TODO: alert ("align "+b);
}
for (i = 0; i < this.connectors.length; i++) {
this.connectors[i].repaint();
console.log( this.connectors[i]);
}
}
this.fitBlocks = function() {
for (var i = 0; i < this.blocks.length ; i++) {
var b = this.blocks[i]; //.findBlock(blockId);
this.blocks[i].fit ();
}
}
/*
* This function searches for a nested block with a given id
*/
this.findBlock = function(blockId) {
var result;
for(var i = 0; i < this.blocks.length && !result; i++)
result = this.blocks[i].findBlock(blockId);
return result;
}
this.toString = function() {
return 'canvas: ' + this.id;
}
} | [
"function",
"Canvas",
"(",
"htmlElement",
")",
"{",
"/*\n\t * initialization\n\t */",
"this",
".",
"id",
"=",
"htmlElement",
".",
"id",
";",
"this",
".",
"htmlElement",
"=",
"htmlElement",
";",
"this",
".",
"blocks",
"=",
"new",
"Array",
"(",
")",
";",
"th... | The canvas class.
This class is built on a div html element. | [
"The",
"canvas",
"class",
".",
"This",
"class",
"is",
"built",
"on",
"a",
"div",
"html",
"element",
"."
] | bf5e3028810a0ec7c267c6fe4bfad639b4819e35 | https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L229-L382 | train | Canvas constructor. | [
30522,
3853,
10683,
1006,
16129,
12260,
3672,
1007,
1063,
1013,
1008,
1008,
3988,
3989,
1008,
1013,
2023,
1012,
8909,
1027,
16129,
12260,
3672,
1012,
8909,
1025,
2023,
1012,
16129,
12260,
3672,
1027,
16129,
12260,
3672,
1025,
2023,
1012,
59... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-unreachable.js | reportIfUnreachable | function reportIfUnreachable(node) {
let nextNode = null;
if (node && currentCodePath.currentSegments.every(isUnreachable)) {
// Store this statement to distinguish consecutive statements.
if (range.isEmpty) {
range.reset(node);
return;
}
// Skip if this statement is inside of the current range.
if (range.contains(node)) {
return;
}
// Merge if this statement is consecutive to the current range.
if (range.isConsecutive(node)) {
range.merge(node);
return;
}
nextNode = node;
}
/*
* Report the current range since this statement is reachable or is
* not consecutive to the current range.
*/
if (!range.isEmpty) {
context.report({
message: "Unreachable code.",
loc: range.location,
node: range.startNode
});
}
// Update the current range.
range.reset(nextNode);
} | javascript | function reportIfUnreachable(node) {
let nextNode = null;
if (node && currentCodePath.currentSegments.every(isUnreachable)) {
// Store this statement to distinguish consecutive statements.
if (range.isEmpty) {
range.reset(node);
return;
}
// Skip if this statement is inside of the current range.
if (range.contains(node)) {
return;
}
// Merge if this statement is consecutive to the current range.
if (range.isConsecutive(node)) {
range.merge(node);
return;
}
nextNode = node;
}
/*
* Report the current range since this statement is reachable or is
* not consecutive to the current range.
*/
if (!range.isEmpty) {
context.report({
message: "Unreachable code.",
loc: range.location,
node: range.startNode
});
}
// Update the current range.
range.reset(nextNode);
} | [
"function",
"reportIfUnreachable",
"(",
"node",
")",
"{",
"let",
"nextNode",
"=",
"null",
";",
"if",
"(",
"node",
"&&",
"currentCodePath",
".",
"currentSegments",
".",
"every",
"(",
"isUnreachable",
")",
")",
"{",
"// Store this statement to distinguish consecutive ... | Reports a given node if it's unreachable.
@param {ASTNode} node - A statement node to report.
@returns {void} | [
"Reports",
"a",
"given",
"node",
"if",
"it",
"s",
"unreachable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unreachable.js#L126-L165 | train | Report if the current code path is reachable or is consecutive to the current range. | [
30522,
3853,
3189,
10128,
4609,
16416,
7507,
3468,
1006,
13045,
1007,
1063,
2292,
2279,
3630,
3207,
1027,
19701,
1025,
2065,
1006,
13045,
1004,
1004,
2783,
16044,
15069,
1012,
14731,
13910,
8163,
1012,
2296,
1006,
2003,
4609,
16416,
7507,
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... |
jhipster/generator-jhipster | generators/aws-containers/aws-client.js | initAwsStuff | function initAwsStuff(region = DEFAULT_REGION) {
ec2 = new AWS.EC2({ region });
// ecr = new AWS.ECR({ region });
s3 = new AWS.S3();
sts = new AWS.STS();
SSM = new AwsSSM(region);
ECR = new AwsECR(region);
CF = new AwsCF(region);
} | javascript | function initAwsStuff(region = DEFAULT_REGION) {
ec2 = new AWS.EC2({ region });
// ecr = new AWS.ECR({ region });
s3 = new AWS.S3();
sts = new AWS.STS();
SSM = new AwsSSM(region);
ECR = new AwsECR(region);
CF = new AwsCF(region);
} | [
"function",
"initAwsStuff",
"(",
"region",
"=",
"DEFAULT_REGION",
")",
"{",
"ec2",
"=",
"new",
"AWS",
".",
"EC2",
"(",
"{",
"region",
"}",
")",
";",
"// ecr = new AWS.ECR({ region });",
"s3",
"=",
"new",
"AWS",
".",
"S3",
"(",
")",
";",
"sts",
"=",
"ne... | Init AWS stuff like ECR and whatnot.
@param ecrConfig The config used to instanciate ECR | [
"Init",
"AWS",
"stuff",
"like",
"ECR",
"and",
"whatnot",
"."
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/aws-client.js#L104-L113 | train | Initialize the AWS stuff | [
30522,
3853,
1999,
6590,
9333,
3367,
16093,
2546,
1006,
2555,
1027,
12398,
1035,
2555,
1007,
1063,
14925,
2475,
1027,
2047,
22091,
2015,
1012,
14925,
2475,
1006,
1063,
2555,
1065,
1007,
1025,
1013,
1013,
14925,
2099,
1027,
2047,
22091,
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... |
eslint/eslint | Makefile.js | generatePrerelease | function generatePrerelease(prereleaseId) {
ReleaseOps.generateRelease(prereleaseId);
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
const nextMajor = semver.inc(releaseInfo.version, "major");
echo("Generating site");
// always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
target.gensite(nextMajor);
/*
* Premajor release should have identical "next major version".
* Preminor and prepatch release will not.
* 5.0.0-alpha.0 --> next major = 5, current major = 5
* 4.4.0-alpha.0 --> next major = 5, current major = 4
* 4.0.1-alpha.0 --> next major = 5, current major = 4
*/
if (semver.major(releaseInfo.version) === semver.major(nextMajor)) {
/*
* This prerelease is for a major release (not preminor/prepatch).
* Blog post generation logic needs to be aware of this (as well as
* know what the next major version is actually supposed to be).
*/
generateBlogPost(releaseInfo, nextMajor);
} else {
generateBlogPost(releaseInfo);
}
commitSiteToGit(`v${releaseInfo.version}`);
} | javascript | function generatePrerelease(prereleaseId) {
ReleaseOps.generateRelease(prereleaseId);
const releaseInfo = JSON.parse(cat(".eslint-release-info.json"));
const nextMajor = semver.inc(releaseInfo.version, "major");
echo("Generating site");
// always write docs into the next major directory (so 2.0.0-alpha.0 writes to 2.0.0)
target.gensite(nextMajor);
/*
* Premajor release should have identical "next major version".
* Preminor and prepatch release will not.
* 5.0.0-alpha.0 --> next major = 5, current major = 5
* 4.4.0-alpha.0 --> next major = 5, current major = 4
* 4.0.1-alpha.0 --> next major = 5, current major = 4
*/
if (semver.major(releaseInfo.version) === semver.major(nextMajor)) {
/*
* This prerelease is for a major release (not preminor/prepatch).
* Blog post generation logic needs to be aware of this (as well as
* know what the next major version is actually supposed to be).
*/
generateBlogPost(releaseInfo, nextMajor);
} else {
generateBlogPost(releaseInfo);
}
commitSiteToGit(`v${releaseInfo.version}`);
} | [
"function",
"generatePrerelease",
"(",
"prereleaseId",
")",
"{",
"ReleaseOps",
".",
"generateRelease",
"(",
"prereleaseId",
")",
";",
"const",
"releaseInfo",
"=",
"JSON",
".",
"parse",
"(",
"cat",
"(",
"\".eslint-release-info.json\"",
")",
")",
";",
"const",
"ne... | Updates the changelog, bumps the version number in package.json, creates a local git commit and tag,
and generates the site in an adjacent `eslint.github.io` folder.
@param {string} prereleaseId The prerelease identifier (alpha, beta, etc.)
@returns {void} | [
"Updates",
"the",
"changelog",
"bumps",
"the",
"version",
"number",
"in",
"package",
".",
"json",
"creates",
"a",
"local",
"git",
"commit",
"and",
"tag",
"and",
"generates",
"the",
"site",
"in",
"an",
"adjacent",
"eslint",
".",
"github",
".",
"io",
"folder... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L272-L302 | train | Generates a prerelease | [
30522,
3853,
9699,
28139,
16570,
19500,
1006,
3653,
16570,
19500,
3593,
1007,
1063,
2713,
11923,
1012,
9699,
16570,
19500,
1006,
3653,
16570,
19500,
3593,
1007,
1025,
9530,
3367,
2713,
2378,
14876,
1027,
1046,
3385,
1012,
11968,
3366,
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/language/JSUtils.js | function (node) {
if (node.body && node.body.type === "FunctionDeclaration") {
if (node.label) {
_addResult(node.label);
}
}
} | javascript | function (node) {
if (node.body && node.body.type === "FunctionDeclaration") {
if (node.label) {
_addResult(node.label);
}
}
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"body",
"&&",
"node",
".",
"body",
".",
"type",
"===",
"\"FunctionDeclaration\"",
")",
"{",
"if",
"(",
"node",
".",
"label",
")",
"{",
"_addResult",
"(",
"node",
".",
"label",
")",
";",
"}"... | /*
<functionName>: function() {} | [
"/",
"*",
"<functionName",
">",
":",
"function",
"()",
"{}"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L157-L163 | train | Add a result to the result list | [
30522,
3853,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
2303,
1004,
1004,
13045,
1012,
2303,
1012,
2828,
1027,
1027,
1027,
1000,
3853,
3207,
20464,
25879,
3258,
1000,
1007,
1063,
2065,
1006,
13045,
1012,
3830,
1007,
1063,
1035,
5587,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/look-controls.js | function () {
this.mouseDown = false;
this.pitchObject = new THREE.Object3D();
this.yawObject = new THREE.Object3D();
this.yawObject.position.y = 10;
this.yawObject.add(this.pitchObject);
} | javascript | function () {
this.mouseDown = false;
this.pitchObject = new THREE.Object3D();
this.yawObject = new THREE.Object3D();
this.yawObject.position.y = 10;
this.yawObject.add(this.pitchObject);
} | [
"function",
"(",
")",
"{",
"this",
".",
"mouseDown",
"=",
"false",
";",
"this",
".",
"pitchObject",
"=",
"new",
"THREE",
".",
"Object3D",
"(",
")",
";",
"this",
".",
"yawObject",
"=",
"new",
"THREE",
".",
"Object3D",
"(",
")",
";",
"this",
".",
"ya... | Set up states and Object3Ds needed to store rotation data. | [
"Set",
"up",
"states",
"and",
"Object3Ds",
"needed",
"to",
"store",
"rotation",
"data",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L110-L116 | train | Initialize the object | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
8000,
7698,
1027,
6270,
1025,
2023,
1012,
6510,
16429,
20614,
1027,
2047,
2093,
1012,
4874,
29097,
1006,
1007,
1025,
2023,
1012,
8038,
12155,
2497,
20614,
1027,
2047,
2093,
1012,
4874,
29097,
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... | |
facebook/relay | packages/relay-compiler/core/GraphQLDerivedFromMetadata.js | getReaderSourceDefinitionName | function getReaderSourceDefinitionName(node: GeneratedNode): string {
const [name, derivedFrom] =
node.kind === 'Request'
? [node.params.name, node.params.metadata?.derivedFrom]
: node.kind === 'SplitOperation'
? [node.name, node.metadata?.derivedFrom]
: [node.name, null];
return typeof derivedFrom === 'string' ? derivedFrom : name;
} | javascript | function getReaderSourceDefinitionName(node: GeneratedNode): string {
const [name, derivedFrom] =
node.kind === 'Request'
? [node.params.name, node.params.metadata?.derivedFrom]
: node.kind === 'SplitOperation'
? [node.name, node.metadata?.derivedFrom]
: [node.name, null];
return typeof derivedFrom === 'string' ? derivedFrom : name;
} | [
"function",
"getReaderSourceDefinitionName",
"(",
"node",
":",
"GeneratedNode",
")",
":",
"string",
"{",
"const",
"[",
"name",
",",
"derivedFrom",
"]",
"=",
"node",
".",
"kind",
"===",
"'Request'",
"?",
"[",
"node",
".",
"params",
".",
"name",
",",
"node",... | Helpers to retieve the name of the document from which the input derives:
this is either the name of the input itself (if it is not a derived node)
or the metadata.derivedFrom property for derived nodes.
Version for generated nodes | [
"Helpers",
"to",
"retieve",
"the",
"name",
"of",
"the",
"document",
"from",
"which",
"the",
"input",
"derives",
":",
"this",
"is",
"either",
"the",
"name",
"of",
"the",
"input",
"itself",
"(",
"if",
"it",
"is",
"not",
"a",
"derived",
"node",
")",
"or",... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/GraphQLDerivedFromMetadata.js#L23-L31 | train | Returns the name of the reader source definition | [
30522,
3853,
2131,
16416,
13375,
8162,
22119,
16294,
22753,
18442,
1006,
13045,
1024,
7013,
3630,
3207,
1007,
1024,
5164,
1063,
9530,
3367,
1031,
2171,
1010,
5173,
19699,
5358,
1033,
1027,
13045,
1012,
2785,
1027,
1027,
1027,
1005,
5227,
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... |
eslint/eslint | lib/util/report-translator.js | assertValidNodeInfo | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | javascript | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | [
"function",
"assertValidNodeInfo",
"(",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
".",
"node",
")",
"{",
"assert",
"(",
"typeof",
"descriptor",
".",
"node",
"===",
"\"object\"",
",",
"\"Node must be an object\"",
")",
";",
"}",
"else",
"{",
"assert",
... | Asserts that either a loc or a node was provided, and the node is valid if it was provided.
@param {MessageDescriptor} descriptor A descriptor to validate
@returns {void}
@throws AssertionError if neither a node nor a loc was provided, or if the node is not an object | [
"Asserts",
"that",
"either",
"a",
"loc",
"or",
"a",
"node",
"was",
"provided",
"and",
"the",
"node",
"is",
"valid",
"if",
"it",
"was",
"provided",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L92-L98 | train | Assert that the node is valid | [
30522,
3853,
20865,
10175,
3593,
3630,
3207,
2378,
14876,
1006,
4078,
23235,
2953,
1007,
1063,
2065,
1006,
4078,
23235,
2953,
1012,
13045,
1007,
1063,
20865,
1006,
2828,
11253,
4078,
23235,
2953,
1012,
13045,
1027,
1027,
1027,
1000,
4874,
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... |
uber/deck.gl | modules/geo-layers/src/tile-layer/utils/viewport-util.js | getAdjustedTileIndex | function getAdjustedTileIndex({x, y, z}, adjustedZ) {
const m = Math.pow(2, z - adjustedZ);
return {
x: Math.floor(x / m),
y: Math.floor(y / m),
z: adjustedZ
};
} | javascript | function getAdjustedTileIndex({x, y, z}, adjustedZ) {
const m = Math.pow(2, z - adjustedZ);
return {
x: Math.floor(x / m),
y: Math.floor(y / m),
z: adjustedZ
};
} | [
"function",
"getAdjustedTileIndex",
"(",
"{",
"x",
",",
"y",
",",
"z",
"}",
",",
"adjustedZ",
")",
"{",
"const",
"m",
"=",
"Math",
".",
"pow",
"(",
"2",
",",
"z",
"-",
"adjustedZ",
")",
";",
"return",
"{",
"x",
":",
"Math",
".",
"floor",
"(",
"... | Calculates and returns a new tile index {x, y, z}, with z being the given adjustedZ. | [
"Calculates",
"and",
"returns",
"a",
"new",
"tile",
"index",
"{",
"x",
"y",
"z",
"}",
"with",
"z",
"being",
"the",
"given",
"adjustedZ",
"."
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/geo-layers/src/tile-layer/utils/viewport-util.js#L64-L71 | train | Get the adjusted tile index | [
30522,
3853,
2131,
4215,
29427,
2098,
15286,
22254,
10288,
1006,
1063,
1060,
1010,
1061,
1010,
1062,
1065,
1010,
10426,
2480,
1007,
1063,
9530,
3367,
1049,
1027,
8785,
1012,
23776,
1006,
1016,
1010,
1062,
1011,
10426,
2480,
1007,
1025,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/ODataMessageParser.js | getAllElements | function getAllElements(oDocument, aElementNames) {
var aElements = [];
var mElementNames = {};
for (var i = 0; i < aElementNames.length; ++i) {
mElementNames[aElementNames[i]] = true;
}
var oElement = oDocument;
while (oElement) {
if (mElementNames[oElement.tagName]) {
aElements.push(oElement);
}
if (oElement.hasChildNodes()) {
oElement = oElement.firstChild;
} else {
while (!oElement.nextSibling) {
oElement = oElement.parentNode;
if (!oElement || oElement === oDocument) {
oElement = null;
break;
}
}
if (oElement) {
oElement = oElement.nextSibling;
}
}
}
return aElements;
} | javascript | function getAllElements(oDocument, aElementNames) {
var aElements = [];
var mElementNames = {};
for (var i = 0; i < aElementNames.length; ++i) {
mElementNames[aElementNames[i]] = true;
}
var oElement = oDocument;
while (oElement) {
if (mElementNames[oElement.tagName]) {
aElements.push(oElement);
}
if (oElement.hasChildNodes()) {
oElement = oElement.firstChild;
} else {
while (!oElement.nextSibling) {
oElement = oElement.parentNode;
if (!oElement || oElement === oDocument) {
oElement = null;
break;
}
}
if (oElement) {
oElement = oElement.nextSibling;
}
}
}
return aElements;
} | [
"function",
"getAllElements",
"(",
"oDocument",
",",
"aElementNames",
")",
"{",
"var",
"aElements",
"=",
"[",
"]",
";",
"var",
"mElementNames",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aElementNames",
".",
"length",
";",
... | Returns all elements in the given document (or node) that match the given elementnames
@param {Node} oDocument - The start node from where to search for elements
@param {string[]} aElementNames - The names of the elements to search for
@returns {HTMLElement[]} The matching elements
@private | [
"Returns",
"all",
"elements",
"in",
"the",
"given",
"document",
"(",
"or",
"node",
")",
"that",
"match",
"the",
"given",
"elementnames"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/ODataMessageParser.js#L836-L868 | train | Returns an array of all elements in the given DOM | [
30522,
3853,
2131,
24164,
16930,
11187,
1006,
1051,
3527,
24894,
4765,
1010,
29347,
16930,
4765,
18442,
2015,
1007,
1063,
13075,
29347,
16930,
11187,
1027,
1031,
1033,
1025,
13075,
11463,
13665,
18442,
2015,
1027,
1063,
1065,
1025,
2005,
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... |
eslint/eslint | lib/rules/no-constant-condition.js | trackConstantConditionLoop | function trackConstantConditionLoop(node) {
if (node.test && isConstant(node.test, true)) {
loopsInCurrentScope.add(node);
}
} | javascript | function trackConstantConditionLoop(node) {
if (node.test && isConstant(node.test, true)) {
loopsInCurrentScope.add(node);
}
} | [
"function",
"trackConstantConditionLoop",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"test",
"&&",
"isConstant",
"(",
"node",
".",
"test",
",",
"true",
")",
")",
"{",
"loopsInCurrentScope",
".",
"add",
"(",
"node",
")",
";",
"}",
"}"
] | Tracks when the given node contains a constant condition.
@param {ASTNode} node The AST node to check.
@returns {void}
@private | [
"Tracks",
"when",
"the",
"given",
"node",
"contains",
"a",
"constant",
"condition",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-constant-condition.js#L154-L158 | train | trackConstantConditionLoop - Tracks a constant condition loop. | [
30522,
3853,
2650,
8663,
12693,
13535,
15422,
22753,
4135,
7361,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
3231,
1004,
1004,
2003,
8663,
12693,
2102,
1006,
13045,
1012,
3231,
1010,
2995,
1007,
1007,
1063,
15932,
2378,
10841,
14343,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/beibei/option/mescroll-option.js | function(mescroll, downwarp) {
//初始化完毕的回调,可缓存dom
mescroll.downProgressDom = downwarp.getElementsByClassName("downwarp-progress")[0];
mescroll.downLoadingDom = downwarp.getElementsByClassName("downwarp-loading")[0];
} | javascript | function(mescroll, downwarp) {
//初始化完毕的回调,可缓存dom
mescroll.downProgressDom = downwarp.getElementsByClassName("downwarp-progress")[0];
mescroll.downLoadingDom = downwarp.getElementsByClassName("downwarp-loading")[0];
} | [
"function",
"(",
"mescroll",
",",
"downwarp",
")",
"{",
"//初始化完毕的回调,可缓存dom",
"mescroll",
".",
"downProgressDom",
"=",
"downwarp",
".",
"getElementsByClassName",
"(",
"\"downwarp-progress\"",
")",
"[",
"0",
"]",
";",
"mescroll",
".",
"downLoadingDom",
"=",
"downwar... | 布局内容 | [
"布局内容"
] | 43d3dcf3062da0fe95995ddcb5e93f5725792c98 | https://github.com/mescroll/mescroll/blob/43d3dcf3062da0fe95995ddcb5e93f5725792c98/mescroll.js/html-demo/beibei/option/mescroll-option.js#L68-L72 | 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,
21572,
17603,
4757,
9527,
1027,
2091,
9028,
2361,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _findMatchingGlob | function _findMatchingGlob(pathData, filename) {
var globs = Object.keys(pathData),
globCounter;
if (!filename) {
return;
}
for (globCounter = 0; globCounter < globs.length; globCounter++) {
var glob = globs[globCounter];
if (globmatch(filename, glob)) {
return glob;
}
}
} | javascript | function _findMatchingGlob(pathData, filename) {
var globs = Object.keys(pathData),
globCounter;
if (!filename) {
return;
}
for (globCounter = 0; globCounter < globs.length; globCounter++) {
var glob = globs[globCounter];
if (globmatch(filename, glob)) {
return glob;
}
}
} | [
"function",
"_findMatchingGlob",
"(",
"pathData",
",",
"filename",
")",
"{",
"var",
"globs",
"=",
"Object",
".",
"keys",
"(",
"pathData",
")",
",",
"globCounter",
";",
"if",
"(",
"!",
"filename",
")",
"{",
"return",
";",
"}",
"for",
"(",
"globCounter",
... | Utility functions for the PathLayer
@private
Look for a matching file glob among the collection of paths.
@param {Object} pathData The keys are globs and the values are the preferences for that glob
@param {string} filename relative filename to match against the globs
@return {?string} glob pattern that matched, if any | [
"Utility",
"functions",
"for",
"the",
"PathLayer",
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L573-L588 | train | Find a glob in the pathData | [
30522,
3853,
1035,
2424,
18900,
8450,
23296,
16429,
1006,
4130,
2850,
2696,
1010,
5371,
18442,
1007,
1063,
13075,
1043,
4135,
5910,
1027,
4874,
1012,
6309,
1006,
4130,
2850,
2696,
1007,
1010,
1043,
4135,
9818,
21723,
2121,
1025,
2065,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/token-store/index.js | createCursorWithSkip | function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
let includeComments = false;
let skip = 0;
let filter = null;
if (typeof opts === "number") {
skip = opts | 0;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
skip = opts.skip | 0;
filter = opts.filter || null;
}
assert(skip >= 0, "options.skip should be zero or a positive integer.");
assert(!filter || typeof filter === "function", "options.filter should be a function.");
return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
} | javascript | function createCursorWithSkip(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
let includeComments = false;
let skip = 0;
let filter = null;
if (typeof opts === "number") {
skip = opts | 0;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
skip = opts.skip | 0;
filter = opts.filter || null;
}
assert(skip >= 0, "options.skip should be zero or a positive integer.");
assert(!filter || typeof filter === "function", "options.filter should be a function.");
return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, skip, -1);
} | [
"function",
"createCursorWithSkip",
"(",
"factory",
",",
"tokens",
",",
"comments",
",",
"indexMap",
",",
"startLoc",
",",
"endLoc",
",",
"opts",
")",
"{",
"let",
"includeComments",
"=",
"false",
";",
"let",
"skip",
"=",
"0",
";",
"let",
"filter",
"=",
"... | Creates the cursor iterates tokens with options.
@param {CursorFactory} factory - The cursor factory to initialize cursor.
@param {Token[]} tokens - The array of tokens.
@param {Comment[]} comments - The array of comments.
@param {Object} indexMap - The map from locations to indices in `tokens`.
@param {number} startLoc - The start location of the iteration range.
@param {number} endLoc - The end location of the iteration range.
@param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.skip`. If this is a function then it's `opts.filter`.
@param {boolean} [opts.includeComments=false] - The flag to iterate comments as well.
@param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
@param {number} [opts.skip=0] - The count of tokens the cursor skips.
@returns {Cursor} The created cursor.
@private | [
"Creates",
"the",
"cursor",
"iterates",
"tokens",
"with",
"options",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/token-store/index.js#L79-L97 | train | Creates a new cursor with skip option. | [
30522,
3853,
3443,
10841,
25301,
2099,
24415,
5488,
2361,
1006,
4713,
1010,
19204,
2015,
1010,
7928,
1010,
5950,
2863,
2361,
1010,
2707,
4135,
2278,
1010,
2203,
4135,
2278,
1010,
23569,
2015,
1007,
1063,
2292,
2421,
9006,
8163,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/menus/img/index.js | function (e) {
const editor = this.editor
const $elem = this.$elem
if (editor._selectedImg) {
this._active = true
$elem.addClass('w-e-active')
} else {
this._active = false
$elem.removeClass('w-e-active')
}
} | javascript | function (e) {
const editor = this.editor
const $elem = this.$elem
if (editor._selectedImg) {
this._active = true
$elem.addClass('w-e-active')
} else {
this._active = false
$elem.removeClass('w-e-active')
}
} | [
"function",
"(",
"e",
")",
"{",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"$elem",
"=",
"this",
".",
"$elem",
"if",
"(",
"editor",
".",
"_selectedImg",
")",
"{",
"this",
".",
"_active",
"=",
"true",
"$elem",
".",
"addClass",
"(",
"'w-e-... | 试图改变 active 状态 | [
"试图改变",
"active",
"状态"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/img/index.js#L239-L249 | train | onSelectonSelect | [
30522,
3853,
1006,
1041,
1007,
1063,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
1002,
3449,
6633,
1027,
2023,
1012,
1002,
3449,
6633,
2065,
1006,
3559,
1012,
1035,
3479,
5714,
2290,
1007,
1063,
2023,
1012,
1035,
3161,
1027,
299... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
transloadit/uppy | packages/@uppy/companion/src/server/controllers/s3.js | createMultipartUpload | function createMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const key = config.getKey(req, req.body.filename)
const { type } = req.body
if (typeof key !== 'string') {
return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
}
if (typeof type !== 'string') {
return res.status(400).json({ error: 's3: content type must be a string' })
}
client.createMultipartUpload({
Bucket: config.bucket,
Key: key,
ACL: config.acl,
ContentType: type,
Expires: ms('5 minutes') / 1000
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
key: data.Key,
uploadId: data.UploadId
})
})
} | javascript | function createMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const key = config.getKey(req, req.body.filename)
const { type } = req.body
if (typeof key !== 'string') {
return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
}
if (typeof type !== 'string') {
return res.status(400).json({ error: 's3: content type must be a string' })
}
client.createMultipartUpload({
Bucket: config.bucket,
Key: key,
ACL: config.acl,
ContentType: type,
Expires: ms('5 minutes') / 1000
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
key: data.Key,
uploadId: data.UploadId
})
})
} | [
"function",
"createMultipartUpload",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// @ts-ignore The `uppy` property is added by middleware before reaching here.",
"const",
"client",
"=",
"req",
".",
"uppy",
".",
"s3Client",
"const",
"key",
"=",
"config",
".",
"getK... | Create an S3 multipart upload. With this, files can be uploaded in chunks of 5MB+ each.
Expected JSON body:
- filename - The name of the file, given to the `config.getKey`
option to determine the object key name in the S3 bucket.
- type - The MIME type of the file.
Response JSON:
- key - The object key in the S3 bucket.
- uploadId - The ID of this multipart upload, to be used in later requests. | [
"Create",
"an",
"S3",
"multipart",
"upload",
".",
"With",
"this",
"files",
"can",
"be",
"uploaded",
"in",
"chunks",
"of",
"5MB",
"+",
"each",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L70-L98 | train | Create a multipart upload | [
30522,
3853,
3443,
12274,
7096,
11514,
8445,
6279,
11066,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
1030,
24529,
1011,
8568,
1996,
30524,
7685,
1012,
1055,
2509,
20464,
11638,
9530,
3367,
3145,
1027,
9530,
8873,
229... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | function() {
// 1. "sap-language" must be part of the annotation URI
if (!oAnnotationUri.hasQuery("sap-language")) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"Missing \"sap-language\" URI parameter",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// 2. "sap-client" must be set as URI param
if (!oAnnotationUri.hasQuery("sap-client")) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"Missing \"sap-client\" URI parameter",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// 3. "sap-client" must equal to the value of "sap.ui.getCore().getConfiguration().getSAPParam("sap-client")"
if (!oAnnotationUri.hasQuery("sap-client", oConfig.getSAPParam("sap-client"))) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"URI parameter \"sap-client=" + oAnnotationUri.query(true)["sap-client"] + "\" must be identical with configuration \"sap-client=" + oConfig.getSAPParam("sap-client") + "\"",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// Overriding the parameter is fine as the given one should be the most up-to-date
if (oAnnotationUri.hasQuery("sap-context-token") && !oAnnotationUri.hasQuery("sap-context-token", sCacheToken)) {
var existingContextToken = oAnnotationUri.query(true)["sap-context-token"];
Log.warning("Component Manifest: Overriding existing \"sap-context-token=" + existingContextToken + "\" with provided value \"" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + ").",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
}
// Finally, set the sap-context-token
oAnnotationUri.setQuery("sap-context-token", sCacheToken);
} | javascript | function() {
// 1. "sap-language" must be part of the annotation URI
if (!oAnnotationUri.hasQuery("sap-language")) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"Missing \"sap-language\" URI parameter",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// 2. "sap-client" must be set as URI param
if (!oAnnotationUri.hasQuery("sap-client")) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"Missing \"sap-client\" URI parameter",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// 3. "sap-client" must equal to the value of "sap.ui.getCore().getConfiguration().getSAPParam("sap-client")"
if (!oAnnotationUri.hasQuery("sap-client", oConfig.getSAPParam("sap-client"))) {
Log.warning("Component Manifest: Ignoring provided \"sap-context-token=" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + "). " +
"URI parameter \"sap-client=" + oAnnotationUri.query(true)["sap-client"] + "\" must be identical with configuration \"sap-client=" + oConfig.getSAPParam("sap-client") + "\"",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
return;
}
// Overriding the parameter is fine as the given one should be the most up-to-date
if (oAnnotationUri.hasQuery("sap-context-token") && !oAnnotationUri.hasQuery("sap-context-token", sCacheToken)) {
var existingContextToken = oAnnotationUri.query(true)["sap-context-token"];
Log.warning("Component Manifest: Overriding existing \"sap-context-token=" + existingContextToken + "\" with provided value \"" + sCacheToken + "\" for ODataAnnotation \"" + aAnnotations[i] + "\" (" + oAnnotationUri.toString() + ").",
"[\"sap.app\"][\"dataSources\"][\"" + aAnnotations[i] + "\"]", sLogComponentName);
}
// Finally, set the sap-context-token
oAnnotationUri.setQuery("sap-context-token", sCacheToken);
} | [
"function",
"(",
")",
"{",
"// 1. \"sap-language\" must be part of the annotation URI",
"if",
"(",
"!",
"oAnnotationUri",
".",
"hasQuery",
"(",
"\"sap-language\"",
")",
")",
"{",
"Log",
".",
"warning",
"(",
"\"Component Manifest: Ignoring provided \\\"sap-context-token=\"",
... | /* eslint-disable no-loop-func | [
"/",
"*",
"eslint",
"-",
"disable",
"no",
"-",
"loop",
"-",
"func"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L1349-L1385 | train | Validates the annotation URI | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
1015,
1012,
1000,
20066,
1011,
2653,
1000,
2442,
2022,
2112,
1997,
1996,
5754,
17287,
3508,
24471,
2072,
2065,
1006,
999,
1051,
11639,
17287,
3508,
9496,
1012,
2038,
4226,
2854,
1006,
1000,
20066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/selenium-core/scripts/selenium-remoterunner.js | getSeleniumWindowNameURLparameters | function getSeleniumWindowNameURLparameters() {
var w = (proxyInjectionMode ? selenium.browserbot.getCurrentWindow() : window).top;
var s = "&seleniumWindowName=";
if (w.opener == null) {
return s;
}
if (w["seleniumWindowName"] == null) {
if (w.name) {
w["seleniumWindowName"] = w.name;
} else {
w["seleniumWindowName"] = 'generatedSeleniumWindowName_' + Math.round(100000 * Math.random());
}
}
s += w["seleniumWindowName"];
var windowOpener = w.opener;
for (key in windowOpener) {
var val = null;
try {
val = windowOpener[key];
}
catch(e) {
}
if (val==w) {
s += "&jsWindowNameVar=" + key; // found a js variable in the opener referring to this window
}
}
return s;
} | javascript | function getSeleniumWindowNameURLparameters() {
var w = (proxyInjectionMode ? selenium.browserbot.getCurrentWindow() : window).top;
var s = "&seleniumWindowName=";
if (w.opener == null) {
return s;
}
if (w["seleniumWindowName"] == null) {
if (w.name) {
w["seleniumWindowName"] = w.name;
} else {
w["seleniumWindowName"] = 'generatedSeleniumWindowName_' + Math.round(100000 * Math.random());
}
}
s += w["seleniumWindowName"];
var windowOpener = w.opener;
for (key in windowOpener) {
var val = null;
try {
val = windowOpener[key];
}
catch(e) {
}
if (val==w) {
s += "&jsWindowNameVar=" + key; // found a js variable in the opener referring to this window
}
}
return s;
} | [
"function",
"getSeleniumWindowNameURLparameters",
"(",
")",
"{",
"var",
"w",
"=",
"(",
"proxyInjectionMode",
"?",
"selenium",
".",
"browserbot",
".",
"getCurrentWindow",
"(",
")",
":",
"window",
")",
".",
"top",
";",
"var",
"s",
"=",
"\"&seleniumWindowName=\"",
... | Return URL parameters pertaining to the name(s?) of the current window In selenium, the main (i.e., first) window's name is a blank string. Additional pop-ups are associated with either 1.) the name given by the 2nd parameter to window.open, or 2.) the name of a property on the opening window which points at the window. An example of #2: if window X contains JavaScript as follows: var windowABC = window.open(...) Note that the example JavaScript above is equivalent to window["windowABC"] = window.open(...) | [
"Return",
"URL",
"parameters",
"pertaining",
"to",
"the",
"name",
"(",
"s?",
")",
"of",
"the",
"current",
"window",
"In",
"selenium",
"the",
"main",
"(",
"i",
".",
"e",
".",
"first",
")",
"window",
"s",
"name",
"is",
"a",
"blank",
"string",
".",
"Add... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/selenium-remoterunner.js#L495-L522 | train | Get the URL parameters for the current window | [
30522,
3853,
4152,
12260,
14907,
11101,
12384,
14074,
3126,
14277,
5400,
22828,
2015,
1006,
1007,
1063,
13075,
1059,
1027,
1006,
24540,
2378,
20614,
3258,
5302,
3207,
1029,
7367,
7770,
5007,
1012,
16602,
18384,
1012,
2131,
10841,
14343,
3372,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/controllers/Analysis.controller.js | function (tempLib, treeTable) {
var library,
rule,
oTempLibCopy,
bSelected,
aRules,
iIndex,
fnFilter = function (oRule) {
return oRule.id === rule.id;
};
for (var i in treeTable) {
library = treeTable[i];
oTempLibCopy = treeTable[i].nodes;
if (library.name !== Constants.TEMP_RULESETS_NAME) {
continue;
}
//reset the model to add the temp rules
treeTable[i].nodes = [];
for (var ruleIndex in tempLib.rules) {
rule = tempLib.rules[ruleIndex];
bSelected = oTempLibCopy[ruleIndex] !== undefined ? oTempLibCopy[ruleIndex].selected : true;
// syncs selection of temporary rules from local storage
if (this.tempRulesFromStorage) {
aRules = this.tempRulesFromStorage.filter(fnFilter);
if (aRules.length > 0) {
bSelected = aRules[0].selected;
iIndex = this.tempRulesFromStorage.indexOf(aRules[0]);
this.tempRulesFromStorage.splice(iIndex, 1);
if (bSelected === false) {
library.selected = false;
}
}
if (this.tempRulesFromStorage.length === 0) {
this.tempRulesFromStorage.length = null;
}
}
library.nodes.push({
name: rule.title,
description: rule.description,
id: rule.id,
audiences: rule.audiences.toString(),
categories: rule.categories.toString(),
minversion: rule.minversion,
resolution: rule.resolution,
title: rule.title,
selected: bSelected,
libName: library.name,
check: rule.check
});
}
this.model.setProperty("/treeModel", treeTable);
return library;
}
} | javascript | function (tempLib, treeTable) {
var library,
rule,
oTempLibCopy,
bSelected,
aRules,
iIndex,
fnFilter = function (oRule) {
return oRule.id === rule.id;
};
for (var i in treeTable) {
library = treeTable[i];
oTempLibCopy = treeTable[i].nodes;
if (library.name !== Constants.TEMP_RULESETS_NAME) {
continue;
}
//reset the model to add the temp rules
treeTable[i].nodes = [];
for (var ruleIndex in tempLib.rules) {
rule = tempLib.rules[ruleIndex];
bSelected = oTempLibCopy[ruleIndex] !== undefined ? oTempLibCopy[ruleIndex].selected : true;
// syncs selection of temporary rules from local storage
if (this.tempRulesFromStorage) {
aRules = this.tempRulesFromStorage.filter(fnFilter);
if (aRules.length > 0) {
bSelected = aRules[0].selected;
iIndex = this.tempRulesFromStorage.indexOf(aRules[0]);
this.tempRulesFromStorage.splice(iIndex, 1);
if (bSelected === false) {
library.selected = false;
}
}
if (this.tempRulesFromStorage.length === 0) {
this.tempRulesFromStorage.length = null;
}
}
library.nodes.push({
name: rule.title,
description: rule.description,
id: rule.id,
audiences: rule.audiences.toString(),
categories: rule.categories.toString(),
minversion: rule.minversion,
resolution: rule.resolution,
title: rule.title,
selected: bSelected,
libName: library.name,
check: rule.check
});
}
this.model.setProperty("/treeModel", treeTable);
return library;
}
} | [
"function",
"(",
"tempLib",
",",
"treeTable",
")",
"{",
"var",
"library",
",",
"rule",
",",
"oTempLibCopy",
",",
"bSelected",
",",
"aRules",
",",
"iIndex",
",",
"fnFilter",
"=",
"function",
"(",
"oRule",
")",
"{",
"return",
"oRule",
".",
"id",
"===",
"... | Keeps in sync the TreeViewModel for temporary library that we use for visualisation of sap.m.TreeTable and the model that we use in the Suppport Assistant
@param {Object} tempLib temporary library model from Support Assistant
@param {Object} treeTable Model for sap.m.TreeTable visualization
@returns {Object} The temp library | [
"Keeps",
"in",
"sync",
"the",
"TreeViewModel",
"for",
"temporary",
"library",
"that",
"we",
"use",
"for",
"visualisation",
"of",
"sap",
".",
"m",
".",
"TreeTable",
"and",
"the",
"model",
"that",
"we",
"use",
"in",
"the",
"Suppport",
"Assistant"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L451-L514 | train | Synchronizes the selected temporary rules from local storage | [
30522,
3853,
1006,
8915,
8737,
29521,
1010,
3392,
10880,
1007,
1063,
13075,
3075,
1010,
3627,
1010,
27178,
6633,
24759,
12322,
3597,
7685,
1010,
18667,
12260,
10985,
1010,
12098,
16308,
1010,
2462,
13629,
2595,
1010,
1042,
2078,
8873,
21928,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
goldfire/howler.js | dist/howler.js | function() {
var self = this;
var args = arguments;
var vol, id;
// Determine the values based on arguments.
if (args.length === 0) {
// Return the value of the groups' volume.
return self._volume;
} else if (args.length === 1 || args.length === 2 && typeof args[1] === 'undefined') {
// First check if this is an ID, and if not, assume it is a new volume.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else {
vol = parseFloat(args[0]);
}
} else if (args.length >= 2) {
vol = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// Update the volume or return the current volume.
var sound;
if (typeof vol !== 'undefined' && vol >= 0 && vol <= 1) {
// If the sound hasn't loaded, add it to the load queue to change volume when capable.
if (self._state !== 'loaded'|| self._playLock) {
self._queue.push({
event: 'volume',
action: function() {
self.volume.apply(self, args);
}
});
return self;
}
// Set the group volume.
if (typeof id === 'undefined') {
self._volume = vol;
}
// Update one or all volumes.
id = self._getSoundIds(id);
for (var i=0; i<id.length; i++) {
// Get the sound.
sound = self._soundById(id[i]);
if (sound) {
sound._volume = vol;
// Stop currently running fades.
if (!args[2]) {
self._stopFade(id[i]);
}
if (self._webAudio && sound._node && !sound._muted) {
sound._node.gain.setValueAtTime(vol, Howler.ctx.currentTime);
} else if (sound._node && !sound._muted) {
sound._node.volume = vol * Howler.volume();
}
self._emit('volume', sound._id);
}
}
} else {
sound = id ? self._soundById(id) : self._sounds[0];
return sound ? sound._volume : 0;
}
return self;
} | javascript | function() {
var self = this;
var args = arguments;
var vol, id;
// Determine the values based on arguments.
if (args.length === 0) {
// Return the value of the groups' volume.
return self._volume;
} else if (args.length === 1 || args.length === 2 && typeof args[1] === 'undefined') {
// First check if this is an ID, and if not, assume it is a new volume.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else {
vol = parseFloat(args[0]);
}
} else if (args.length >= 2) {
vol = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// Update the volume or return the current volume.
var sound;
if (typeof vol !== 'undefined' && vol >= 0 && vol <= 1) {
// If the sound hasn't loaded, add it to the load queue to change volume when capable.
if (self._state !== 'loaded'|| self._playLock) {
self._queue.push({
event: 'volume',
action: function() {
self.volume.apply(self, args);
}
});
return self;
}
// Set the group volume.
if (typeof id === 'undefined') {
self._volume = vol;
}
// Update one or all volumes.
id = self._getSoundIds(id);
for (var i=0; i<id.length; i++) {
// Get the sound.
sound = self._soundById(id[i]);
if (sound) {
sound._volume = vol;
// Stop currently running fades.
if (!args[2]) {
self._stopFade(id[i]);
}
if (self._webAudio && sound._node && !sound._muted) {
sound._node.gain.setValueAtTime(vol, Howler.ctx.currentTime);
} else if (sound._node && !sound._muted) {
sound._node.volume = vol * Howler.volume();
}
self._emit('volume', sound._id);
}
}
} else {
sound = id ? self._soundById(id) : self._sounds[0];
return sound ? sound._volume : 0;
}
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"args",
"=",
"arguments",
";",
"var",
"vol",
",",
"id",
";",
"// Determine the values based on arguments.",
"if",
"(",
"args",
".",
"length",
"===",
"0",
")",
"{",
"// Return the value of the... | Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments.
volume() -> Returns the group's volume value.
volume(id) -> Returns the sound id's current volume.
volume(vol) -> Sets the volume of all sounds in this Howl group.
volume(vol, id) -> Sets the volume of passed sound id.
@return {Howl/Number} Returns self or current volume. | [
"Get",
"/",
"set",
"the",
"volume",
"of",
"this",
"sound",
"or",
"of",
"the",
"Howl",
"group",
".",
"This",
"method",
"can",
"optionally",
"take",
"0",
"1",
"or",
"2",
"arguments",
".",
"volume",
"()",
"-",
">",
"Returns",
"the",
"group",
"s",
"volum... | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1179-L1251 | train | Update the volume of the group. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
12098,
5620,
1027,
9918,
1025,
13075,
5285,
1010,
8909,
1025,
1013,
1013,
5646,
1996,
5300,
2241,
2006,
9918,
1012,
2065,
1006,
12098,
5620,
1012,
3091,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/HealthData/main.js | addCommand | function addCommand() {
CommandManager.register(Strings.CMD_HEALTH_DATA_STATISTICS, healthDataCmdId, handleHealthDataStatistics);
menu.addMenuItem(healthDataCmdId, "", Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER);
menu.addMenuDivider(Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER);
} | javascript | function addCommand() {
CommandManager.register(Strings.CMD_HEALTH_DATA_STATISTICS, healthDataCmdId, handleHealthDataStatistics);
menu.addMenuItem(healthDataCmdId, "", Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER);
menu.addMenuDivider(Menus.AFTER, Commands.HELP_SHOW_EXT_FOLDER);
} | [
"function",
"addCommand",
"(",
")",
"{",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_HEALTH_DATA_STATISTICS",
",",
"healthDataCmdId",
",",
"handleHealthDataStatistics",
")",
";",
"menu",
".",
"addMenuItem",
"(",
"healthDataCmdId",
",",
"\"\"",
",",
... | Register the command and add the menu item for the Health Data Statistics | [
"Register",
"the",
"command",
"and",
"add",
"the",
"menu",
"item",
"for",
"the",
"Health",
"Data",
"Statistics"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/main.js#L48-L53 | train | Register the command | [
30522,
3853,
5587,
9006,
2386,
2094,
1006,
1007,
1063,
3094,
24805,
4590,
1012,
4236,
1006,
7817,
1012,
4642,
2094,
1035,
2740,
1035,
2951,
1035,
6747,
1010,
2740,
2850,
2696,
27487,
4305,
2094,
1010,
5047,
20192,
24658,
2850,
10230,
29336,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/JavaScriptRefactoring/RefactoringUtils.js | RefactoringSession | function RefactoringSession(editor) {
this.editor = editor;
this.document = editor.document;
this.selection = editor.getSelection();
this.text = this.document.getText();
this.selectedText = editor.getSelectedText();
this.cm = editor._codeMirror;
this.startIndex = editor.indexFromPos(this.selection.start);
this.endIndex = editor.indexFromPos(this.selection.end);
this.startPos = this.selection.start;
this.endPos = this.selection.end;
this.ast = this.createAstOfCurrentDoc();
} | javascript | function RefactoringSession(editor) {
this.editor = editor;
this.document = editor.document;
this.selection = editor.getSelection();
this.text = this.document.getText();
this.selectedText = editor.getSelectedText();
this.cm = editor._codeMirror;
this.startIndex = editor.indexFromPos(this.selection.start);
this.endIndex = editor.indexFromPos(this.selection.end);
this.startPos = this.selection.start;
this.endPos = this.selection.end;
this.ast = this.createAstOfCurrentDoc();
} | [
"function",
"RefactoringSession",
"(",
"editor",
")",
"{",
"this",
".",
"editor",
"=",
"editor",
";",
"this",
".",
"document",
"=",
"editor",
".",
"document",
";",
"this",
".",
"selection",
"=",
"editor",
".",
"getSelection",
"(",
")",
";",
"this",
".",
... | Note - To use these state defined in Refactoring Session,
Please reinitialize this RefactoringSession after performing any of the below operations
(i.e. replaceRange, setSelection or indentLine)
RefactoringSession objects encapsulate state associated with a refactoring session
and This will help finding information around documents, selection,
position, ast, and queries around AST nodes
@constructor
@param {Editor} editor - the editor context for the session | [
"Note",
"-",
"To",
"use",
"these",
"state",
"defined",
"in",
"Refactoring",
"Session",
"Please",
"reinitialize",
"this",
"RefactoringSession",
"after",
"performing",
"any",
"of",
"the",
"below",
"operations",
"(",
"i",
".",
"e",
".",
"replaceRange",
"setSelectio... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L435-L447 | train | Creates a new RefactoringSession | [
30522,
3853,
25416,
18908,
28741,
5620,
7971,
3258,
1006,
3559,
1007,
1063,
2023,
1012,
3559,
1027,
3559,
1025,
2023,
1012,
6254,
1027,
3559,
1012,
6254,
1025,
2023,
1012,
4989,
1027,
3559,
1012,
4152,
12260,
7542,
1006,
1007,
1025,
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... |
adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | _cmdRemove | function _cmdRemove(extensionDir, callback, pCallback) {
fs.remove(extensionDir, function (err) {
if (err) {
callback(err);
} else {
callback(null);
}
});
} | javascript | function _cmdRemove(extensionDir, callback, pCallback) {
fs.remove(extensionDir, function (err) {
if (err) {
callback(err);
} else {
callback(null);
}
});
} | [
"function",
"_cmdRemove",
"(",
"extensionDir",
",",
"callback",
",",
"pCallback",
")",
"{",
"fs",
".",
"remove",
"(",
"extensionDir",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{... | Implements the remove extension command. | [
"Implements",
"the",
"remove",
"extension",
"command",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L447-L455 | train | Remove the extension directory | [
30522,
3853,
1035,
4642,
16200,
5302,
3726,
1006,
5331,
4305,
2099,
1010,
2655,
5963,
30524,
1063,
2655,
5963,
1006,
9413,
2099,
1007,
1025,
1065,
2842,
1063,
2655,
5963,
1006,
19701,
1007,
1025,
1065,
1065,
1007,
1025,
1065,
102,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | onLinkWithEmailAndPassword | function onLinkWithEmailAndPassword() {
var email = $('#link-email').val();
var password = $('#link-password').val();
activeUser().linkWithCredential(
firebase.auth.EmailAuthProvider.credential(email, password))
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | function onLinkWithEmailAndPassword() {
var email = $('#link-email').val();
var password = $('#link-password').val();
activeUser().linkWithCredential(
firebase.auth.EmailAuthProvider.credential(email, password))
.then(onAuthUserCredentialSuccess, onAuthError);
} | [
"function",
"onLinkWithEmailAndPassword",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#link-email'",
")",
".",
"val",
"(",
")",
";",
"var",
"password",
"=",
"$",
"(",
"'#link-password'",
")",
".",
"val",
"(",
")",
";",
"activeUser",
"(",
")",
".",
... | Links a signed in user with an email and password account. | [
"Links",
"a",
"signed",
"in",
"user",
"with",
"an",
"email",
"and",
"password",
"account",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L748-L754 | train | Link with email and password | [
30522,
3853,
2006,
13767,
24415,
14545,
11733,
4859,
15194,
18351,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
4957,
1011,
10373,
1005,
1007,
1012,
11748,
1006,
1007,
1025,
13075,
20786,
1027,
1002,
1006,
1005,
1001,
4957,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ipfs/js-ipfs | examples/traverse-ipld-graphs/create-node.js | createNode | function createNode (options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
options.path = options.path || '/tmp/ipfs' + Math.random()
const node = new IPFS({
repo: options.path
})
node.on('start', () => callback(null, node))
} | javascript | function createNode (options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
options.path = options.path || '/tmp/ipfs' + Math.random()
const node = new IPFS({
repo: options.path
})
node.on('start', () => callback(null, node))
} | [
"function",
"createNode",
"(",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
"options",
"=",
"{",
"}",
"}",
"options",
".",
"path",
"=",
"options",
".",
"path",
"||",
"'... | In your project, replace by the following line and install IPFS as a dep const IPFS = require('ipfs') | [
"In",
"your",
"project",
"replace",
"by",
"the",
"following",
"line",
"and",
"install",
"IPFS",
"as",
"a",
"dep",
"const",
"IPFS",
"=",
"require",
"(",
"ipfs",
")"
] | 97e67601094acda3906549ecb0248fd09f1a8cc3 | https://github.com/ipfs/js-ipfs/blob/97e67601094acda3906549ecb0248fd09f1a8cc3/examples/traverse-ipld-graphs/create-node.js#L7-L20 | train | Create a new node | [
30522,
3853,
3443,
3630,
3207,
1006,
7047,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
2828,
11253,
7047,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
1063,
2655,
5963,
1027,
7047,
7047,
1027,
1063,
1065,
1065,
7047,
1012,
4130,
1027,
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... |
GitbookIO/gitbook | lib/utils/path.js | resolveInRoot | function resolveInRoot(root) {
var input, result;
var args = Array.prototype.slice.call(arguments, 1);
input = args
.reduce(function(current, p) {
// Handle path relative to book root ("/README.md")
if (p[0] == '/' || p[0] == '\\') return p.slice(1);
return current? path.join(current, p) : path.normalize(p);
}, '');
result = path.resolve(root, input);
if (!isInRoot(root, result)) {
throw new error.FileOutOfScopeError({
filename: result,
root: root
});
}
return result;
} | javascript | function resolveInRoot(root) {
var input, result;
var args = Array.prototype.slice.call(arguments, 1);
input = args
.reduce(function(current, p) {
// Handle path relative to book root ("/README.md")
if (p[0] == '/' || p[0] == '\\') return p.slice(1);
return current? path.join(current, p) : path.normalize(p);
}, '');
result = path.resolve(root, input);
if (!isInRoot(root, result)) {
throw new error.FileOutOfScopeError({
filename: result,
root: root
});
}
return result;
} | [
"function",
"resolveInRoot",
"(",
"root",
")",
"{",
"var",
"input",
",",
"result",
";",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"input",
"=",
"args",
".",
"reduce",
"(",
"functio... | Resolve paths in a specific folder Throw error if file is outside this folder | [
"Resolve",
"paths",
"in",
"a",
"specific",
"folder",
"Throw",
"error",
"if",
"file",
"is",
"outside",
"this",
"folder"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/path.js#L26-L48 | train | Resolves the given path in the root | [
30522,
3853,
10663,
2378,
3217,
4140,
1006,
7117,
1007,
1063,
13075,
7953,
1010,
2765,
1025,
13075,
12098,
5620,
1027,
9140,
1012,
8773,
1012,
14704,
1012,
2655,
1006,
9918,
1010,
1015,
1007,
1025,
7953,
1027,
12098,
5620,
1012,
5547,
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/widgets/Dialogs.js | setDialogMaxSize | function setDialogMaxSize() {
var maxWidth, maxHeight,
$dlgs = $(".modal-inner-wrapper > .instance");
// Verify 1 or more modal dialogs are showing
if ($dlgs.length > 0) {
maxWidth = $("body").width();
maxHeight = $("body").height();
$dlgs.css({
"max-width": maxWidth,
"max-height": maxHeight,
"overflow": "auto"
});
}
} | javascript | function setDialogMaxSize() {
var maxWidth, maxHeight,
$dlgs = $(".modal-inner-wrapper > .instance");
// Verify 1 or more modal dialogs are showing
if ($dlgs.length > 0) {
maxWidth = $("body").width();
maxHeight = $("body").height();
$dlgs.css({
"max-width": maxWidth,
"max-height": maxHeight,
"overflow": "auto"
});
}
} | [
"function",
"setDialogMaxSize",
"(",
")",
"{",
"var",
"maxWidth",
",",
"maxHeight",
",",
"$dlgs",
"=",
"$",
"(",
"\".modal-inner-wrapper > .instance\"",
")",
";",
"// Verify 1 or more modal dialogs are showing",
"if",
"(",
"$dlgs",
".",
"length",
">",
"0",
")",
"{... | Don't allow dialog to exceed viewport size | [
"Don",
"t",
"allow",
"dialog",
"to",
"exceed",
"viewport",
"size"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/Dialogs.js#L260-L275 | train | Set max size of the modal dialog | [
30522,
3853,
2275,
27184,
8649,
17848,
5332,
4371,
1006,
1007,
1063,
13075,
4098,
9148,
11927,
2232,
1010,
4098,
26036,
13900,
1010,
1002,
21469,
5620,
1027,
1002,
1006,
1000,
1012,
16913,
2389,
1011,
5110,
1011,
10236,
4842,
1028,
1012,
60... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Package.js | installFromURL | function installFromURL(url) {
var STATE_DOWNLOADING = 1,
STATE_INSTALLING = 2,
STATE_SUCCEEDED = 3,
STATE_FAILED = 4;
var d = new $.Deferred();
var state = STATE_DOWNLOADING;
var downloadId = (_uniqueId++);
download(url, downloadId)
.done(function (downloadResult) {
state = STATE_INSTALLING;
installFromPath(downloadResult.localPath, downloadResult.filenameHint)
.done(function (result) {
var installationStatus = result.installationStatus;
state = STATE_SUCCEEDED;
result.localPath = downloadResult.localPath;
result.keepFile = false;
if (installationStatus === InstallationStatuses.INSTALLED) {
// Delete temp file
FileSystem.getFileForPath(downloadResult.localPath).unlink();
}
d.resolve(result);
})
.fail(function (err) {
// File IO errors, internal error in install()/validate(), or extension startup crashed
state = STATE_FAILED;
FileSystem.getFileForPath(downloadResult.localPath).unlink();
d.reject(err); // TODO: needs to be err.message ?
});
})
.fail(function (err) {
// Download error (the Node-side download code cleans up any partial ZIP file)
state = STATE_FAILED;
d.reject(err);
});
return {
promise: d.promise(),
cancel: function () {
if (state === STATE_DOWNLOADING) {
// This will trigger download()'s fail() handler with CANCELED as the err code
cancelDownload(downloadId);
}
// Else it's too late to cancel; we'll continue on through the done() chain and emit
// a success result (calling done() handlers) if all else goes well.
}
};
} | javascript | function installFromURL(url) {
var STATE_DOWNLOADING = 1,
STATE_INSTALLING = 2,
STATE_SUCCEEDED = 3,
STATE_FAILED = 4;
var d = new $.Deferred();
var state = STATE_DOWNLOADING;
var downloadId = (_uniqueId++);
download(url, downloadId)
.done(function (downloadResult) {
state = STATE_INSTALLING;
installFromPath(downloadResult.localPath, downloadResult.filenameHint)
.done(function (result) {
var installationStatus = result.installationStatus;
state = STATE_SUCCEEDED;
result.localPath = downloadResult.localPath;
result.keepFile = false;
if (installationStatus === InstallationStatuses.INSTALLED) {
// Delete temp file
FileSystem.getFileForPath(downloadResult.localPath).unlink();
}
d.resolve(result);
})
.fail(function (err) {
// File IO errors, internal error in install()/validate(), or extension startup crashed
state = STATE_FAILED;
FileSystem.getFileForPath(downloadResult.localPath).unlink();
d.reject(err); // TODO: needs to be err.message ?
});
})
.fail(function (err) {
// Download error (the Node-side download code cleans up any partial ZIP file)
state = STATE_FAILED;
d.reject(err);
});
return {
promise: d.promise(),
cancel: function () {
if (state === STATE_DOWNLOADING) {
// This will trigger download()'s fail() handler with CANCELED as the err code
cancelDownload(downloadId);
}
// Else it's too late to cancel; we'll continue on through the done() chain and emit
// a success result (calling done() handlers) if all else goes well.
}
};
} | [
"function",
"installFromURL",
"(",
"url",
")",
"{",
"var",
"STATE_DOWNLOADING",
"=",
"1",
",",
"STATE_INSTALLING",
"=",
"2",
",",
"STATE_SUCCEEDED",
"=",
"3",
",",
"STATE_FAILED",
"=",
"4",
";",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
"... | On success, resolves with an extension metadata object; at that point, the extension has already
started running in Brackets. On failure (including validation errors), rejects with an error object.
An error object consists of either a string error code OR an array where the first entry is the error
code and the remaining entries are further info. The error code string is one of either
ExtensionsDomain.Errors or Package.Errors. Use formatError() to convert an error object to a friendly,
localized error message.
The returned cancel() function will *attempt* to cancel installation, but it is not guaranteed to
succeed. If cancel() succeeds, the Promise is rejected with a CANCELED error code. If we're unable
to cancel, the Promise is resolved or rejected normally, as if cancel() had never been called.
@return {{promise: $.Promise, cancel: function():boolean}} | [
"On",
"success",
"resolves",
"with",
"an",
"extension",
"metadata",
"object",
";",
"at",
"that",
"point",
"the",
"extension",
"has",
"already",
"started",
"running",
"in",
"Brackets",
".",
"On",
"failure",
"(",
"including",
"validation",
"errors",
")",
"reject... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/Package.js#L352-L405 | train | Installs a file from a URL | [
30522,
3853,
16500,
19699,
5358,
3126,
2140,
1006,
24471,
2140,
1007,
1063,
13075,
2110,
1035,
8816,
2075,
1027,
1015,
1010,
2110,
1035,
23658,
1027,
1016,
1010,
2110,
1035,
4594,
1027,
1017,
1010,
2110,
1035,
3478,
1027,
1018,
1025,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
postcss/autoprefixer | lib/hacks/grid-utils.js | warnTemplateSelectorNotFound | function warnTemplateSelectorNotFound (decl, result) {
let rule = decl.parent
let root = decl.root()
let duplicatesFound = false
// slice selector array. Remove the last part (for comparison)
let slicedSelectorArr = list
.space(rule.selector)
.filter(str => str !== '>')
.slice(0, -1)
// we need to compare only if selector is complex.
// e.g '.grid-cell' is simple, but '.parent > .grid-cell' is complex
if (slicedSelectorArr.length > 0) {
let gridTemplateFound = false
let foundAreaSelector = null
root.walkDecls(/grid-template(-areas)?$/, d => {
let parent = d.parent
let templateSelectors = parent.selectors
let { areas } = parseTemplate({ decl: d, gap: getGridGap(d) })
let hasArea = areas[decl.value]
// find the the matching selectors
for (let tplSelector of templateSelectors) {
if (gridTemplateFound) {
break
}
let tplSelectorArr = list
.space(tplSelector)
.filter(str => str !== '>')
gridTemplateFound = tplSelectorArr.every(
(item, idx) => item === slicedSelectorArr[idx]
)
}
if (gridTemplateFound || !hasArea) {
return true
}
if (!foundAreaSelector) {
foundAreaSelector = parent.selector
}
// if we found the duplicate area with different selector
if (foundAreaSelector && foundAreaSelector !== parent.selector) {
duplicatesFound = true
}
return undefined
})
// warn user if we didn't find template
if (!gridTemplateFound && duplicatesFound) {
decl.warn(
result,
`Autoprefixer cannot find a grid-template ` +
`containing the duplicate grid-area "${ decl.value }" ` +
`with full selector matching: ${ slicedSelectorArr.join(' ') }`
)
}
}
} | javascript | function warnTemplateSelectorNotFound (decl, result) {
let rule = decl.parent
let root = decl.root()
let duplicatesFound = false
// slice selector array. Remove the last part (for comparison)
let slicedSelectorArr = list
.space(rule.selector)
.filter(str => str !== '>')
.slice(0, -1)
// we need to compare only if selector is complex.
// e.g '.grid-cell' is simple, but '.parent > .grid-cell' is complex
if (slicedSelectorArr.length > 0) {
let gridTemplateFound = false
let foundAreaSelector = null
root.walkDecls(/grid-template(-areas)?$/, d => {
let parent = d.parent
let templateSelectors = parent.selectors
let { areas } = parseTemplate({ decl: d, gap: getGridGap(d) })
let hasArea = areas[decl.value]
// find the the matching selectors
for (let tplSelector of templateSelectors) {
if (gridTemplateFound) {
break
}
let tplSelectorArr = list
.space(tplSelector)
.filter(str => str !== '>')
gridTemplateFound = tplSelectorArr.every(
(item, idx) => item === slicedSelectorArr[idx]
)
}
if (gridTemplateFound || !hasArea) {
return true
}
if (!foundAreaSelector) {
foundAreaSelector = parent.selector
}
// if we found the duplicate area with different selector
if (foundAreaSelector && foundAreaSelector !== parent.selector) {
duplicatesFound = true
}
return undefined
})
// warn user if we didn't find template
if (!gridTemplateFound && duplicatesFound) {
decl.warn(
result,
`Autoprefixer cannot find a grid-template ` +
`containing the duplicate grid-area "${ decl.value }" ` +
`with full selector matching: ${ slicedSelectorArr.join(' ') }`
)
}
}
} | [
"function",
"warnTemplateSelectorNotFound",
"(",
"decl",
",",
"result",
")",
"{",
"let",
"rule",
"=",
"decl",
".",
"parent",
"let",
"root",
"=",
"decl",
".",
"root",
"(",
")",
"let",
"duplicatesFound",
"=",
"false",
"// slice selector array. Remove the last part (... | compare selectors with grid-area rule and grid-template rule
show warning if grid-template selector is not found
(this function used for grid-area rule)
@param {Declaration} decl
@param {Result} result
@return {void} | [
"compare",
"selectors",
"with",
"grid",
"-",
"area",
"rule",
"and",
"grid",
"-",
"template",
"rule",
"show",
"warning",
"if",
"grid",
"-",
"template",
"selector",
"is",
"not",
"found",
"(",
"this",
"function",
"used",
"for",
"grid",
"-",
"area",
"rule",
... | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/lib/hacks/grid-utils.js#L675-L739 | train | Warn user if no grid - template selector is found | [
30522,
3853,
11582,
18532,
15725,
11246,
22471,
26295,
24475,
28819,
1006,
11703,
2140,
1010,
2765,
1007,
1063,
2292,
3627,
1027,
11703,
2140,
1012,
6687,
2292,
7117,
1027,
11703,
2140,
1012,
7117,
1006,
1007,
2292,
24473,
22747,
28819,
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... |
facebook/relay | packages/relay-compiler/core/GraphQLDerivedFromMetadata.js | getSourceDefinitionName | function getSourceDefinitionName(
node: Fragment | Request | Root | SplitOperation,
): string {
const derivedFrom =
node.kind === 'Request' ||
node.kind === 'Root' ||
node.kind === 'SplitOperation'
? node.metadata?.derivedFrom
: null;
return typeof derivedFrom === 'string' ? derivedFrom : node.name;
} | javascript | function getSourceDefinitionName(
node: Fragment | Request | Root | SplitOperation,
): string {
const derivedFrom =
node.kind === 'Request' ||
node.kind === 'Root' ||
node.kind === 'SplitOperation'
? node.metadata?.derivedFrom
: null;
return typeof derivedFrom === 'string' ? derivedFrom : node.name;
} | [
"function",
"getSourceDefinitionName",
"(",
"node",
":",
"Fragment",
"|",
"Request",
"|",
"Root",
"|",
"SplitOperation",
",",
")",
":",
"string",
"{",
"const",
"derivedFrom",
"=",
"node",
".",
"kind",
"===",
"'Request'",
"||",
"node",
".",
"kind",
"===",
"... | Version for IR | [
"Version",
"for",
"IR"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/GraphQLDerivedFromMetadata.js#L34-L44 | train | Get source definition name | [
30522,
3853,
4152,
8162,
22119,
16294,
22753,
18442,
1006,
13045,
1024,
15778,
1064,
5227,
1064,
7117,
1064,
3975,
25918,
3370,
1010,
1007,
1024,
5164,
1063,
9530,
3367,
5173,
19699,
5358,
1027,
13045,
1012,
2785,
1027,
1027,
1027,
1005,
52... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/cursor.js | function (evt) {
var currentIntersection;
var cursorEl = this.el;
var index;
var intersectedEl;
var intersection;
// Select closest object, excluding the cursor.
index = evt.detail.els[0] === cursorEl ? 1 : 0;
intersection = evt.detail.intersections[index];
intersectedEl = evt.detail.els[index];
// If cursor is the only intersected object, ignore the event.
if (!intersectedEl) { return; }
// Already intersecting this entity.
if (this.intersectedEl === intersectedEl) { return; }
// Ignore events further away than active intersection.
if (this.intersectedEl) {
currentIntersection = this.el.components.raycaster.getIntersection(this.intersectedEl);
if (currentIntersection && currentIntersection.distance <= intersection.distance) { return; }
}
// Unset current intersection.
this.clearCurrentIntersection(true);
this.setIntersection(intersectedEl, intersection);
} | javascript | function (evt) {
var currentIntersection;
var cursorEl = this.el;
var index;
var intersectedEl;
var intersection;
// Select closest object, excluding the cursor.
index = evt.detail.els[0] === cursorEl ? 1 : 0;
intersection = evt.detail.intersections[index];
intersectedEl = evt.detail.els[index];
// If cursor is the only intersected object, ignore the event.
if (!intersectedEl) { return; }
// Already intersecting this entity.
if (this.intersectedEl === intersectedEl) { return; }
// Ignore events further away than active intersection.
if (this.intersectedEl) {
currentIntersection = this.el.components.raycaster.getIntersection(this.intersectedEl);
if (currentIntersection && currentIntersection.distance <= intersection.distance) { return; }
}
// Unset current intersection.
this.clearCurrentIntersection(true);
this.setIntersection(intersectedEl, intersection);
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"currentIntersection",
";",
"var",
"cursorEl",
"=",
"this",
".",
"el",
";",
"var",
"index",
";",
"var",
"intersectedEl",
";",
"var",
"intersection",
";",
"// Select closest object, excluding the cursor.",
"index",
"=",
"e... | Handle intersection. | [
"Handle",
"intersection",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/cursor.js#L267-L295 | train | Handles event on the intersecting object. | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
13075,
2783,
18447,
2545,
18491,
1025,
13075,
12731,
25301,
16570,
1027,
2023,
1012,
3449,
1025,
13075,
5950,
1025,
13075,
29261,
14728,
2140,
1025,
13075,
6840,
1025,
1013,
1013,
7276,
7541,
4874,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/api/encodeNavigation.js | encodeNavigation | function encodeNavigation(output) {
var book = output.getBook();
var pages = output.getPages();
var summary = book.getSummary();
var articles = summary.getArticlesAsList();
var navigation = articles
.map(function(article, i) {
var ref = article.getRef();
if (!ref) {
return undefined;
}
var prev = articles.get(i - 1);
var next = articles.get(i + 1);
return [
ref,
{
index: i,
title: article.getTitle(),
introduction: (i === 0),
prev: prev? encodeArticle(pages, prev) : undefined,
next: next? encodeArticle(pages, next) : undefined,
level: article.getLevel()
}
];
})
.filter(function(e) {
return Boolean(e);
});
return Immutable.Map(navigation).toJS();
} | javascript | function encodeNavigation(output) {
var book = output.getBook();
var pages = output.getPages();
var summary = book.getSummary();
var articles = summary.getArticlesAsList();
var navigation = articles
.map(function(article, i) {
var ref = article.getRef();
if (!ref) {
return undefined;
}
var prev = articles.get(i - 1);
var next = articles.get(i + 1);
return [
ref,
{
index: i,
title: article.getTitle(),
introduction: (i === 0),
prev: prev? encodeArticle(pages, prev) : undefined,
next: next? encodeArticle(pages, next) : undefined,
level: article.getLevel()
}
];
})
.filter(function(e) {
return Boolean(e);
});
return Immutable.Map(navigation).toJS();
} | [
"function",
"encodeNavigation",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"pages",
"=",
"output",
".",
"getPages",
"(",
")",
";",
"var",
"summary",
"=",
"book",
".",
"getSummary",
"(",
")",
";",
"var... | this.navigation is a deprecated property from GitBook v2
@param {Output}
@return {Object} | [
"this",
".",
"navigation",
"is",
"a",
"deprecated",
"property",
"from",
"GitBook",
"v2"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeNavigation.js#L28-L62 | train | Encode navigation | [
30522,
3853,
4372,
16044,
2532,
5737,
12540,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
5530,
1027,
6434,
1012,
2131,
13704,
2015,
1006,
1007,
1025,
13075,
12654,
1027,
2338,
1012,
4152,
2819... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function (sString, sConfirmTextPrefix) {
var $temp = jQuery("<textarea>");
try {
jQuery("body").append($temp);
$temp.val(sString).select();
document.execCommand("copy");
$temp.remove();
MessageToast.show(this._getText(sConfirmTextPrefix + ".Success"));
} catch (oException) {
MessageToast.show(this._getText(sConfirmTextPrefix + ".Error"));
}
} | javascript | function (sString, sConfirmTextPrefix) {
var $temp = jQuery("<textarea>");
try {
jQuery("body").append($temp);
$temp.val(sString).select();
document.execCommand("copy");
$temp.remove();
MessageToast.show(this._getText(sConfirmTextPrefix + ".Success"));
} catch (oException) {
MessageToast.show(this._getText(sConfirmTextPrefix + ".Error"));
}
} | [
"function",
"(",
"sString",
",",
"sConfirmTextPrefix",
")",
"{",
"var",
"$temp",
"=",
"jQuery",
"(",
"\"<textarea>\"",
")",
";",
"try",
"{",
"jQuery",
"(",
"\"body\"",
")",
".",
"append",
"(",
"$temp",
")",
";",
"$temp",
".",
"val",
"(",
"sString",
")"... | Copies the technical information shown in the dialog to the clipboard
@param {string} sString The string to be copied
@param {string} sConfirmTextPrefix The prefix for the i18n texts to be displayed on success/error
@private | [
"Copies",
"the",
"technical",
"information",
"shown",
"in",
"the",
"dialog",
"to",
"the",
"clipboard"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L903-L915 | train | Copy the given string to the clipboard | [
30522,
3853,
1006,
7020,
18886,
3070,
1010,
8040,
2239,
27972,
18209,
28139,
8873,
2595,
1007,
1063,
13075,
1002,
8915,
8737,
1027,
1046,
4226,
2854,
1006,
1000,
1026,
3793,
12069,
2050,
1028,
1000,
1007,
1025,
3046,
1063,
1046,
4226,
2854,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mui-org/material-ui | packages/material-ui/src/ClickAwayListener/ClickAwayListener.js | ClickAwayListener | function ClickAwayListener(props) {
const { children, mouseEvent = 'onMouseUp', touchEvent = 'onTouchEnd', onClickAway } = props;
const mountedRef = useMountedRef();
const movedRef = React.useRef(false);
const nodeRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
const handleOwnRef = React.useCallback(instance => {
// #StrictMode ready
nodeRef.current = ReactDOM.findDOMNode(instance);
}, []);
const handleRef = useForkRef(children.ref, handleOwnRef);
const handleClickAway = React.useCallback(
event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE 11 support, which trigger the handleClickAway even after the unbind
if (!mountedRef.current) {
return;
}
// Do not act if user performed touchmove
if (movedRef.current) {
movedRef.current = false;
return;
}
const { current: node } = nodeRef;
// The child might render null.
if (!node) {
return;
}
const doc = ownerDocument(node);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!node.contains(event.target)
) {
onClickAway(event);
}
},
[mountedRef, onClickAway],
);
const handleTouchMove = React.useCallback(() => {
movedRef.current = true;
}, []);
const listenerProps = {};
if (mouseEvent !== false) {
listenerProps[mouseEvent] = handleClickAway;
}
if (touchEvent !== false) {
listenerProps[touchEvent] = handleClickAway;
listenerProps.onTouchMove = handleTouchMove;
}
return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef })}
<EventListener target="document" {...listenerProps} />
</React.Fragment>
);
} | javascript | function ClickAwayListener(props) {
const { children, mouseEvent = 'onMouseUp', touchEvent = 'onTouchEnd', onClickAway } = props;
const mountedRef = useMountedRef();
const movedRef = React.useRef(false);
const nodeRef = React.useRef(null);
// can be removed once we drop support for non ref forwarding class components
const handleOwnRef = React.useCallback(instance => {
// #StrictMode ready
nodeRef.current = ReactDOM.findDOMNode(instance);
}, []);
const handleRef = useForkRef(children.ref, handleOwnRef);
const handleClickAway = React.useCallback(
event => {
// Ignore events that have been `event.preventDefault()` marked.
if (event.defaultPrevented) {
return;
}
// IE 11 support, which trigger the handleClickAway even after the unbind
if (!mountedRef.current) {
return;
}
// Do not act if user performed touchmove
if (movedRef.current) {
movedRef.current = false;
return;
}
const { current: node } = nodeRef;
// The child might render null.
if (!node) {
return;
}
const doc = ownerDocument(node);
if (
doc.documentElement &&
doc.documentElement.contains(event.target) &&
!node.contains(event.target)
) {
onClickAway(event);
}
},
[mountedRef, onClickAway],
);
const handleTouchMove = React.useCallback(() => {
movedRef.current = true;
}, []);
const listenerProps = {};
if (mouseEvent !== false) {
listenerProps[mouseEvent] = handleClickAway;
}
if (touchEvent !== false) {
listenerProps[touchEvent] = handleClickAway;
listenerProps.onTouchMove = handleTouchMove;
}
return (
<React.Fragment>
{React.cloneElement(children, { ref: handleRef })}
<EventListener target="document" {...listenerProps} />
</React.Fragment>
);
} | [
"function",
"ClickAwayListener",
"(",
"props",
")",
"{",
"const",
"{",
"children",
",",
"mouseEvent",
"=",
"'onMouseUp'",
",",
"touchEvent",
"=",
"'onTouchEnd'",
",",
"onClickAway",
"}",
"=",
"props",
";",
"const",
"mountedRef",
"=",
"useMountedRef",
"(",
")",... | Listen for click events that occur somewhere in the document, outside of the element itself.
For instance, if you need to hide a menu when people click anywhere else on your page. | [
"Listen",
"for",
"click",
"events",
"that",
"occur",
"somewhere",
"in",
"the",
"document",
"outside",
"of",
"the",
"element",
"itself",
".",
"For",
"instance",
"if",
"you",
"need",
"to",
"hide",
"a",
"menu",
"when",
"people",
"click",
"anywhere",
"else",
"... | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/ClickAwayListener/ClickAwayListener.js#L25-L94 | train | The ClickAwayListener is a function that will be called when a child of a container is clicked. | [
30522,
3853,
11562,
9497,
9863,
24454,
1006,
24387,
1007,
1063,
9530,
3367,
1063,
2336,
1010,
8000,
18697,
3372,
1027,
1005,
2006,
27711,
13765,
2361,
1005,
1010,
3543,
18697,
3372,
1027,
1005,
3031,
19140,
4859,
1005,
1010,
2006,
20464,
67... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/model/Global.js | function (mainType, cb, context) {
var componentsMap = this._componentsMap;
if (typeof mainType === 'function') {
context = cb;
cb = mainType;
componentsMap.each(function (components, componentType) {
each(components, function (component, index) {
cb.call(context, componentType, component, index);
});
});
}
else if (isString(mainType)) {
each(componentsMap.get(mainType), cb, context);
}
else if (isObject(mainType)) {
var queryResult = this.findComponents(mainType);
each(queryResult, cb, context);
}
} | javascript | function (mainType, cb, context) {
var componentsMap = this._componentsMap;
if (typeof mainType === 'function') {
context = cb;
cb = mainType;
componentsMap.each(function (components, componentType) {
each(components, function (component, index) {
cb.call(context, componentType, component, index);
});
});
}
else if (isString(mainType)) {
each(componentsMap.get(mainType), cb, context);
}
else if (isObject(mainType)) {
var queryResult = this.findComponents(mainType);
each(queryResult, cb, context);
}
} | [
"function",
"(",
"mainType",
",",
"cb",
",",
"context",
")",
"{",
"var",
"componentsMap",
"=",
"this",
".",
"_componentsMap",
";",
"if",
"(",
"typeof",
"mainType",
"===",
"'function'",
")",
"{",
"context",
"=",
"cb",
";",
"cb",
"=",
"mainType",
";",
"c... | @usage
eachComponent('legend', function (legendModel, index) {
...
});
eachComponent(function (componentType, model, index) {
// componentType does not include subType
// (componentType is 'xxx' but not 'xxx.aa')
});
eachComponent(
{mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
function (model, index) {...}
);
eachComponent(
{mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
function (model, index) {...}
);
@param {string|Object=} mainType When mainType is object, the definition
is the same as the method 'findComponents'.
@param {Function} cb
@param {*} context | [
"@usage",
"eachComponent",
"(",
"legend",
"function",
"(",
"legendModel",
"index",
")",
"{",
"...",
"}",
")",
";",
"eachComponent",
"(",
"function",
"(",
"componentType",
"model",
"index",
")",
"{",
"//",
"componentType",
"does",
"not",
"include",
"subType",
... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Global.js#L452-L471 | train | find all the components | [
30522,
3853,
1006,
2364,
13874,
1010,
17324,
1010,
6123,
1007,
1063,
13075,
6177,
2863,
2361,
1027,
2023,
1012,
1035,
6177,
2863,
2361,
1025,
2065,
1006,
2828,
11253,
2364,
13874,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
1063,
6123,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/ui5loader.js | unloadResources | function unloadResources(sName, bPreloadGroup, bUnloadAll, bDeleteExports) {
var aModules = [],
sURN, oModule;
if ( bPreloadGroup == null ) {
bPreloadGroup = true;
}
if ( bPreloadGroup ) {
// collect modules that belong to the given group
for ( sURN in mModules ) {
oModule = mModules[sURN];
if ( oModule && oModule.group === sName ) {
aModules.push(sURN);
}
}
} else {
// single module
if ( mModules[sName] ) {
aModules.push(sName);
}
}
aModules.forEach(function(sURN) {
var oModule = mModules[sURN];
if ( oModule && bDeleteExports && sURN.match(/\.js$/) ) {
// @evo-todo move to compat layer?
setGlobalProperty(urnToUI5(sURN), undefined);
}
if ( oModule && (bUnloadAll || oModule.state === PRELOADED) ) {
delete mModules[sURN];
}
});
} | javascript | function unloadResources(sName, bPreloadGroup, bUnloadAll, bDeleteExports) {
var aModules = [],
sURN, oModule;
if ( bPreloadGroup == null ) {
bPreloadGroup = true;
}
if ( bPreloadGroup ) {
// collect modules that belong to the given group
for ( sURN in mModules ) {
oModule = mModules[sURN];
if ( oModule && oModule.group === sName ) {
aModules.push(sURN);
}
}
} else {
// single module
if ( mModules[sName] ) {
aModules.push(sName);
}
}
aModules.forEach(function(sURN) {
var oModule = mModules[sURN];
if ( oModule && bDeleteExports && sURN.match(/\.js$/) ) {
// @evo-todo move to compat layer?
setGlobalProperty(urnToUI5(sURN), undefined);
}
if ( oModule && (bUnloadAll || oModule.state === PRELOADED) ) {
delete mModules[sURN];
}
});
} | [
"function",
"unloadResources",
"(",
"sName",
",",
"bPreloadGroup",
",",
"bUnloadAll",
",",
"bDeleteExports",
")",
"{",
"var",
"aModules",
"=",
"[",
"]",
",",
"sURN",
",",
"oModule",
";",
"if",
"(",
"bPreloadGroup",
"==",
"null",
")",
"{",
"bPreloadGroup",
... | Removes a set of resources from the resource cache.
@param {string} sName unified resource name of a resource or the name of a preload group to be removed
@param {boolean} [bPreloadGroup=true] whether the name specifies a preload group, defaults to true
@param {boolean} [bUnloadAll] Whether all matching resources should be unloaded, even if they have been executed already.
@param {boolean} [bDeleteExports] Whether exports (global variables) should be destroyed as well. Will be done for UI5 module names only.
@experimental Since 1.16.3 API might change completely, apps must not develop against it.
@private | [
"Removes",
"a",
"set",
"of",
"resources",
"from",
"the",
"resource",
"cache",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L2025-L2060 | train | Unload resources from the given module | [
30522,
3853,
4895,
11066,
6072,
8162,
9623,
1006,
1055,
18442,
1010,
17531,
16570,
10441,
2094,
17058,
1010,
21122,
11066,
8095,
1010,
1038,
9247,
12870,
10288,
25378,
1007,
1063,
13075,
2572,
7716,
16308,
1027,
1031,
1033,
1010,
7505,
2078,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.