repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function() {
var clonedTestElement = testElement.cloneNode(false),
returnValue,
innerHTML;
clonedTestElement.innerHTML = "<p><div></div>";
innerHTML = clonedTestElement.innerHTML.toLowerCase();
returnValue = innerHTML === "<p></p><div></div>" || innerHTML === "<p><div></div></p>";
// Cache result by overwriting current function
this.autoClosesUnclosedTags = function() { return returnValue; };
return returnValue;
} | javascript | function() {
var clonedTestElement = testElement.cloneNode(false),
returnValue,
innerHTML;
clonedTestElement.innerHTML = "<p><div></div>";
innerHTML = clonedTestElement.innerHTML.toLowerCase();
returnValue = innerHTML === "<p></p><div></div>" || innerHTML === "<p><div></div></p>";
// Cache result by overwriting current function
this.autoClosesUnclosedTags = function() { return returnValue; };
return returnValue;
} | [
"function",
"(",
")",
"{",
"var",
"clonedTestElement",
"=",
"testElement",
".",
"cloneNode",
"(",
"false",
")",
",",
"returnValue",
",",
"innerHTML",
";",
"clonedTestElement",
".",
"innerHTML",
"=",
"\"<p><div></div>\"",
";",
"innerHTML",
"=",
"clonedTestElement",... | Check whether the browser automatically closes tags that don't need to be opened | [
"Check",
"whether",
"the",
"browser",
"automatically",
"closes",
"tags",
"that",
"don",
"t",
"need",
"to",
"be",
"opened"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L4455-L4468 | train | Returns the result of the test | [
30522,
3853,
1006,
1007,
30524,
11039,
19968,
1027,
1000,
1026,
1052,
1028,
1026,
4487,
2615,
1028,
1026,
1013,
4487,
2615,
1028,
1000,
1025,
5110,
11039,
19968,
1027,
17598,
11927,
4355,
12260,
3672,
1012,
5110,
11039,
19968,
1012,
2000,
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... | |
Project-OSRM/osrm-backend | scripts/osrm-runner.js | ServerDetails | function ServerDetails(x) {
if (!(this instanceof ServerDetails)) return new ServerDetails(x);
const v = x.split(':');
this.hostname = (v[0].length > 0) ? v[0] : '';
this.port = (v.length > 1) ? Number(v[1]) : 80;
} | javascript | function ServerDetails(x) {
if (!(this instanceof ServerDetails)) return new ServerDetails(x);
const v = x.split(':');
this.hostname = (v[0].length > 0) ? v[0] : '';
this.port = (v.length > 1) ? Number(v[1]) : 80;
} | [
"function",
"ServerDetails",
"(",
"x",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ServerDetails",
")",
")",
"return",
"new",
"ServerDetails",
"(",
"x",
")",
";",
"const",
"v",
"=",
"x",
".",
"split",
"(",
"':'",
")",
";",
"this",
".",
"h... | Command line arguments | [
"Command",
"line",
"arguments"
] | e86d93760f51304940d55d62c0d47f15094d6712 | https://github.com/Project-OSRM/osrm-backend/blob/e86d93760f51304940d55d62c0d47f15094d6712/scripts/osrm-runner.js#L86-L91 | train | Server details | [
30522,
3853,
8241,
3207,
22081,
1006,
1060,
1007,
1063,
2065,
1006,
999,
1006,
2023,
6013,
11253,
8241,
3207,
22081,
1007,
1007,
2709,
2047,
8241,
3207,
22081,
1006,
1060,
1007,
1025,
9530,
3367,
1058,
1027,
1060,
1012,
3975,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function (oEvent) {
var oModel = this._oDialog.getModel("view"),
oListItem = oEvent.getParameter("listItem"),
oContext = oListItem.getItemNodeContext(),
oNodePath = oContext.context.getPath(),
oSubTreeData = oModel.getProperty(oNodePath),
oControl = this._getControl("customDebugValue", this._DEBUG_MODULES_ID);
this._resetValueState(oControl);
this._treeHelper.recursiveSelect(oSubTreeData, oListItem.getSelected());
this._updateTreeInfos();
} | javascript | function (oEvent) {
var oModel = this._oDialog.getModel("view"),
oListItem = oEvent.getParameter("listItem"),
oContext = oListItem.getItemNodeContext(),
oNodePath = oContext.context.getPath(),
oSubTreeData = oModel.getProperty(oNodePath),
oControl = this._getControl("customDebugValue", this._DEBUG_MODULES_ID);
this._resetValueState(oControl);
this._treeHelper.recursiveSelect(oSubTreeData, oListItem.getSelected());
this._updateTreeInfos();
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oModel",
"=",
"this",
".",
"_oDialog",
".",
"getModel",
"(",
"\"view\"",
")",
",",
"oListItem",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"listItem\"",
")",
",",
"oContext",
"=",
"oListItem",
".",
"getItemNodeC... | Selects/Deselects a node including its tree branch
@param {sap.ui.base.Event} oEvent The tree select event | [
"Selects",
"/",
"Deselects",
"a",
"node",
"including",
"its",
"tree",
"branch"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L229-L240 | train | Handles the selection of the selected item | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
2023,
1012,
1035,
21045,
23067,
2290,
1012,
2131,
5302,
9247,
1006,
1000,
3193,
1000,
1007,
1010,
19330,
2923,
4221,
2213,
1027,
1051,
18697,
3372,
1012,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/tracked-controls-webvr.js | function () {
var changed = false;
var controllerAxes = this.controller.axes;
var i;
var previousAxis = this.axis;
var changedAxes = this.changedAxes;
// Check if axis changed.
this.changedAxes.length = 0;
for (i = 0; i < controllerAxes.length; ++i) {
changedAxes.push(previousAxis[i] !== controllerAxes[i]);
if (changedAxes[i]) { changed = true; }
}
if (!changed) { return false; }
this.axis.length = 0;
for (i = 0; i < controllerAxes.length; i++) {
this.axis.push(controllerAxes[i]);
}
this.el.emit(EVENTS.AXISMOVE, this.axisMoveEventDetail, false);
return true;
} | javascript | function () {
var changed = false;
var controllerAxes = this.controller.axes;
var i;
var previousAxis = this.axis;
var changedAxes = this.changedAxes;
// Check if axis changed.
this.changedAxes.length = 0;
for (i = 0; i < controllerAxes.length; ++i) {
changedAxes.push(previousAxis[i] !== controllerAxes[i]);
if (changedAxes[i]) { changed = true; }
}
if (!changed) { return false; }
this.axis.length = 0;
for (i = 0; i < controllerAxes.length; i++) {
this.axis.push(controllerAxes[i]);
}
this.el.emit(EVENTS.AXISMOVE, this.axisMoveEventDetail, false);
return true;
} | [
"function",
"(",
")",
"{",
"var",
"changed",
"=",
"false",
";",
"var",
"controllerAxes",
"=",
"this",
".",
"controller",
".",
"axes",
";",
"var",
"i",
";",
"var",
"previousAxis",
"=",
"this",
".",
"axis",
";",
"var",
"changedAxes",
"=",
"this",
".",
... | An axis is an array of values from -1 (up, left) to 1 (down, right).
Compare each component of the axis to the previous value to determine change.
@returns {boolean} Whether axes changed. | [
"An",
"axis",
"is",
"an",
"array",
"of",
"values",
"from",
"-",
"1",
"(",
"up",
"left",
")",
"to",
"1",
"(",
"down",
"right",
")",
".",
"Compare",
"each",
"component",
"of",
"the",
"axis",
"to",
"the",
"previous",
"value",
"to",
"determine",
"change"... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webvr.js#L256-L277 | train | Check if axis has changed | [
30522,
3853,
1006,
1007,
1063,
13075,
2904,
1027,
6270,
1025,
13075,
11486,
8528,
2229,
1027,
2023,
1012,
11486,
1012,
19589,
1025,
13075,
1045,
1025,
13075,
3025,
8528,
2483,
1027,
2023,
1012,
8123,
1025,
13075,
2904,
8528,
2229,
1027,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( dataTransfer, callback ) {
var results = [],
promises = [],
items, files, file, item, i, len, canAccessFolder;
items = dataTransfer.items;
files = dataTransfer.files;
canAccessFolder = !!(items && items[ 0 ].webkitGetAsEntry);
for ( i = 0, len = files.length; i < len; i++ ) {
file = files[ i ];
item = items && items[ i ];
if ( canAccessFolder && item.webkitGetAsEntry().isDirectory ) {
promises.push( this._traverseDirectoryTree(
item.webkitGetAsEntry(), results ) );
} else {
results.push( file );
}
}
Base.when.apply( Base, promises ).done(function() {
if ( !results.length ) {
return;
}
callback( results );
});
} | javascript | function( dataTransfer, callback ) {
var results = [],
promises = [],
items, files, file, item, i, len, canAccessFolder;
items = dataTransfer.items;
files = dataTransfer.files;
canAccessFolder = !!(items && items[ 0 ].webkitGetAsEntry);
for ( i = 0, len = files.length; i < len; i++ ) {
file = files[ i ];
item = items && items[ i ];
if ( canAccessFolder && item.webkitGetAsEntry().isDirectory ) {
promises.push( this._traverseDirectoryTree(
item.webkitGetAsEntry(), results ) );
} else {
results.push( file );
}
}
Base.when.apply( Base, promises ).done(function() {
if ( !results.length ) {
return;
}
callback( results );
});
} | [
"function",
"(",
"dataTransfer",
",",
"callback",
")",
"{",
"var",
"results",
"=",
"[",
"]",
",",
"promises",
"=",
"[",
"]",
",",
"items",
",",
"files",
",",
"file",
",",
"item",
",",
"i",
",",
"len",
",",
"canAccessFolder",
";",
"items",
"=",
"dat... | 如果传入 callback 则去查看文件夹,否则只管当前文件夹。 | [
"如果传入",
"callback",
"则去查看文件夹,否则只管当前文件夹。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L4177-L4208 | train | Returns a list of files in the dataTransfer that contains a directory. | [
30522,
3853,
1006,
2951,
6494,
3619,
7512,
1010,
2655,
5963,
1007,
1063,
13075,
3463,
1027,
1031,
1033,
1010,
10659,
1027,
1031,
1033,
1010,
5167,
1010,
6764,
1010,
5371,
1010,
8875,
1010,
1045,
1010,
18798,
1010,
2064,
6305,
9623,
22747,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableUtils.js | function() {
// Converting the row height CSS parameters (e.g. _sap_ui_table_RowHeight) is too complex (CSS calc()).
// Therefore, the base sizes are used and calculation is done in JavaScript.
function getPixelValue(sThemeParameterName) {
return TableUtils.convertCSSSizeToPixel(ThemeParameters.get(sThemeParameterName));
}
mBaseSize.undefined = getPixelValue("_sap_ui_table_BaseSize");
mBaseSize.sapUiSizeCozy = getPixelValue("_sap_ui_table_BaseSizeCozy");
mBaseSize.sapUiSizeCompact = getPixelValue("_sap_ui_table_BaseSizeCompact");
mBaseSize.sapUiSizeCondensed = getPixelValue("_sap_ui_table_BaseSizeCondensed");
iBaseBorderWidth = getPixelValue("_sap_ui_table_BaseBorderWidth");
iRowHorizontalFrameSize = iBaseBorderWidth;
mDefaultRowHeight.undefined = mBaseSize.undefined + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCozy = mBaseSize.sapUiSizeCozy + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCompact = mBaseSize.sapUiSizeCompact + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCondensed = mBaseSize.sapUiSizeCondensed + iRowHorizontalFrameSize;
mThemeParameters.navigationIcon = ThemeParameters.get("_sap_ui_table_NavigationIcon");
mThemeParameters.deleteIcon = ThemeParameters.get("_sap_ui_table_DeleteIcon");
mThemeParameters.resetIcon = ThemeParameters.get("_sap_ui_table_ResetIcon");
} | javascript | function() {
// Converting the row height CSS parameters (e.g. _sap_ui_table_RowHeight) is too complex (CSS calc()).
// Therefore, the base sizes are used and calculation is done in JavaScript.
function getPixelValue(sThemeParameterName) {
return TableUtils.convertCSSSizeToPixel(ThemeParameters.get(sThemeParameterName));
}
mBaseSize.undefined = getPixelValue("_sap_ui_table_BaseSize");
mBaseSize.sapUiSizeCozy = getPixelValue("_sap_ui_table_BaseSizeCozy");
mBaseSize.sapUiSizeCompact = getPixelValue("_sap_ui_table_BaseSizeCompact");
mBaseSize.sapUiSizeCondensed = getPixelValue("_sap_ui_table_BaseSizeCondensed");
iBaseBorderWidth = getPixelValue("_sap_ui_table_BaseBorderWidth");
iRowHorizontalFrameSize = iBaseBorderWidth;
mDefaultRowHeight.undefined = mBaseSize.undefined + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCozy = mBaseSize.sapUiSizeCozy + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCompact = mBaseSize.sapUiSizeCompact + iRowHorizontalFrameSize;
mDefaultRowHeight.sapUiSizeCondensed = mBaseSize.sapUiSizeCondensed + iRowHorizontalFrameSize;
mThemeParameters.navigationIcon = ThemeParameters.get("_sap_ui_table_NavigationIcon");
mThemeParameters.deleteIcon = ThemeParameters.get("_sap_ui_table_DeleteIcon");
mThemeParameters.resetIcon = ThemeParameters.get("_sap_ui_table_ResetIcon");
} | [
"function",
"(",
")",
"{",
"// Converting the row height CSS parameters (e.g. _sap_ui_table_RowHeight) is too complex (CSS calc()).",
"// Therefore, the base sizes are used and calculation is done in JavaScript.",
"function",
"getPixelValue",
"(",
"sThemeParameterName",
")",
"{",
"return",
... | Reads the theme parameters and updates the corresponding variables used and provided by the utilities, e.g. row height values. | [
"Reads",
"the",
"theme",
"parameters",
"and",
"updates",
"the",
"corresponding",
"variables",
"used",
"and",
"provided",
"by",
"the",
"utilities",
"e",
".",
"g",
".",
"row",
"height",
"values",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L1498-L1521 | train | This function is called by the sap. ui. table. Table to calculate the row height in pixels. | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
16401,
1996,
5216,
4578,
20116,
2015,
11709,
1006,
1041,
1012,
1043,
1012,
1035,
20066,
1035,
21318,
1035,
2795,
1035,
5216,
26036,
13900,
1007,
2003,
2205,
3375,
1006,
20116,
2015,
10250,
2278,
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... | |
react-bootstrap/react-bootstrap | www/src/components/SideNav.js | attachSearch | function attachSearch(ref) {
if (ref && window)
import('docsearch.js').then(({ default: docsearch }) => {
docsearch({
apiKey: '00f98b765b687b91399288e7c4c68ce1',
indexName: 'react_bootstrap_v4',
inputSelector: `#${ref.id}`,
debug: process.env.NODE_ENV !== 'production', // Set debug to true if you want to inspect the dropdown
});
});
} | javascript | function attachSearch(ref) {
if (ref && window)
import('docsearch.js').then(({ default: docsearch }) => {
docsearch({
apiKey: '00f98b765b687b91399288e7c4c68ce1',
indexName: 'react_bootstrap_v4',
inputSelector: `#${ref.id}`,
debug: process.env.NODE_ENV !== 'production', // Set debug to true if you want to inspect the dropdown
});
});
} | [
"function",
"attachSearch",
"(",
"ref",
")",
"{",
"if",
"(",
"ref",
"&&",
"window",
")",
"import",
"(",
"'docsearch.js'",
")",
".",
"then",
"(",
"(",
"{",
"default",
":",
"docsearch",
"}",
")",
"=>",
"{",
"docsearch",
"(",
"{",
"apiKey",
":",
"'00f98... | We need to configure this | [
"We",
"need",
"to",
"configure",
"this"
] | f0dc81f91ae90eb54bd1e4c04fa9419872d347dc | https://github.com/react-bootstrap/react-bootstrap/blob/f0dc81f91ae90eb54bd1e4c04fa9419872d347dc/www/src/components/SideNav.js#L141-L151 | train | Attaches a search function to the window | [
30522,
3853,
22476,
17310,
11140,
1006,
25416,
1007,
1063,
2065,
1006,
25416,
1004,
1004,
3332,
1007,
12324,
1006,
1005,
9986,
17310,
11140,
1012,
1046,
2015,
1005,
1007,
1012,
2059,
1006,
1006,
1063,
12398,
1024,
9986,
17310,
11140,
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... |
adobe/brackets | src/preferences/PreferencesBase.js | function (context) {
if (context) {
if (this.contextBuilder) {
context = this.contextBuilder(context);
}
if (!context.scopeOrder) {
context.scopeOrder = this._defaults.scopeOrder;
}
return context;
}
return { scopeOrder: this._defaults.scopeOrder };
} | javascript | function (context) {
if (context) {
if (this.contextBuilder) {
context = this.contextBuilder(context);
}
if (!context.scopeOrder) {
context.scopeOrder = this._defaults.scopeOrder;
}
return context;
}
return { scopeOrder: this._defaults.scopeOrder };
} | [
"function",
"(",
"context",
")",
"{",
"if",
"(",
"context",
")",
"{",
"if",
"(",
"this",
".",
"contextBuilder",
")",
"{",
"context",
"=",
"this",
".",
"contextBuilder",
"(",
"context",
")",
";",
"}",
"if",
"(",
"!",
"context",
".",
"scopeOrder",
")",... | @private
Normalizes the context to be one of:
1. a context object that was passed in
2. the default context
@param {Object} context Context that was passed in
@return {{scopeOrder: string, filename: ?string}} context object | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1559-L1570 | train | Returns a context object | [
30522,
3853,
1006,
6123,
1007,
1063,
2065,
1006,
6123,
1007,
1063,
2065,
1006,
2023,
1012,
6123,
8569,
23891,
2099,
1007,
1063,
6123,
1027,
2023,
1012,
6123,
8569,
23891,
2099,
1006,
6123,
1007,
1025,
1065,
2065,
1006,
999,
6123,
1012,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | js/mui.ajax.js | function(status, xhr, settings) {
settings.complete.call(settings.context, xhr, status);
} | javascript | function(status, xhr, settings) {
settings.complete.call(settings.context, xhr, status);
} | [
"function",
"(",
"status",
",",
"xhr",
",",
"settings",
")",
"{",
"settings",
".",
"complete",
".",
"call",
"(",
"settings",
".",
"context",
",",
"xhr",
",",
"status",
")",
";",
"}"
] | status: "success", "notmodified", "error", "timeout", "abort", "parsererror" | [
"status",
":",
"success",
"notmodified",
"error",
"timeout",
"abort",
"parsererror"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/js/mui.ajax.js#L52-L54 | train | Called when the request is complete | [
30522,
3853,
1006,
3570,
1010,
1060,
8093,
1010,
10906,
1007,
1063,
10906,
1012,
3143,
1012,
2655,
1006,
10906,
1012,
6123,
1010,
1060,
8093,
1010,
3570,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/linter.js | runRules | function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parserName, settings, filename) {
const emitter = createEmitter();
const nodeQueue = [];
let currentNode = sourceCode.ast;
Traverser.traverse(sourceCode.ast, {
enter(node, parent) {
node.parent = parent;
nodeQueue.push({ isEntering: true, node });
},
leave(node) {
nodeQueue.push({ isEntering: false, node });
},
visitorKeys: sourceCode.visitorKeys
});
/*
* Create a frozen object with the ruleContext properties and methods that are shared by all rules.
* All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
* properties once for each rule.
*/
const sharedTraversalContext = Object.freeze(
Object.assign(
Object.create(BASE_TRAVERSAL_CONTEXT),
{
getAncestors: () => getAncestors(currentNode),
getDeclaredVariables: sourceCode.scopeManager.getDeclaredVariables.bind(sourceCode.scopeManager),
getFilename: () => filename,
getScope: () => getScope(sourceCode.scopeManager, currentNode),
getSourceCode: () => sourceCode,
markVariableAsUsed: name => markVariableAsUsed(sourceCode.scopeManager, currentNode, parserOptions, name),
parserOptions,
parserPath: parserName,
parserServices: sourceCode.parserServices,
settings
}
)
);
const lintingProblems = [];
Object.keys(configuredRules).forEach(ruleId => {
const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);
if (severity === 0) {
return;
}
const rule = ruleMapper(ruleId);
const messageIds = rule.meta && rule.meta.messages;
let reportTranslator = null;
const ruleContext = Object.freeze(
Object.assign(
Object.create(sharedTraversalContext),
{
id: ruleId,
options: getRuleOptions(configuredRules[ruleId]),
report(...args) {
/*
* Create a report translator lazily.
* In a vast majority of cases, any given rule reports zero errors on a given
* piece of code. Creating a translator lazily avoids the performance cost of
* creating a new translator function for each rule that usually doesn't get
* called.
*
* Using lazy report translators improves end-to-end performance by about 3%
* with Node 8.4.0.
*/
if (reportTranslator === null) {
reportTranslator = createReportTranslator({ ruleId, severity, sourceCode, messageIds });
}
const problem = reportTranslator(...args);
if (problem.fix && rule.meta && !rule.meta.fixable) {
throw new Error("Fixable rules should export a `meta.fixable` property.");
}
lintingProblems.push(problem);
}
}
)
);
const ruleListeners = createRuleListeners(rule, ruleContext);
// add all the selectors from the rule as listeners
Object.keys(ruleListeners).forEach(selector => {
emitter.on(
selector,
timing.enabled
? timing.time(ruleId, ruleListeners[selector])
: ruleListeners[selector]
);
});
});
const eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter));
nodeQueue.forEach(traversalInfo => {
currentNode = traversalInfo.node;
try {
if (traversalInfo.isEntering) {
eventGenerator.enterNode(currentNode);
} else {
eventGenerator.leaveNode(currentNode);
}
} catch (err) {
err.currentNode = currentNode;
throw err;
}
});
return lintingProblems;
} | javascript | function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parserName, settings, filename) {
const emitter = createEmitter();
const nodeQueue = [];
let currentNode = sourceCode.ast;
Traverser.traverse(sourceCode.ast, {
enter(node, parent) {
node.parent = parent;
nodeQueue.push({ isEntering: true, node });
},
leave(node) {
nodeQueue.push({ isEntering: false, node });
},
visitorKeys: sourceCode.visitorKeys
});
/*
* Create a frozen object with the ruleContext properties and methods that are shared by all rules.
* All rule contexts will inherit from this object. This avoids the performance penalty of copying all the
* properties once for each rule.
*/
const sharedTraversalContext = Object.freeze(
Object.assign(
Object.create(BASE_TRAVERSAL_CONTEXT),
{
getAncestors: () => getAncestors(currentNode),
getDeclaredVariables: sourceCode.scopeManager.getDeclaredVariables.bind(sourceCode.scopeManager),
getFilename: () => filename,
getScope: () => getScope(sourceCode.scopeManager, currentNode),
getSourceCode: () => sourceCode,
markVariableAsUsed: name => markVariableAsUsed(sourceCode.scopeManager, currentNode, parserOptions, name),
parserOptions,
parserPath: parserName,
parserServices: sourceCode.parserServices,
settings
}
)
);
const lintingProblems = [];
Object.keys(configuredRules).forEach(ruleId => {
const severity = ConfigOps.getRuleSeverity(configuredRules[ruleId]);
if (severity === 0) {
return;
}
const rule = ruleMapper(ruleId);
const messageIds = rule.meta && rule.meta.messages;
let reportTranslator = null;
const ruleContext = Object.freeze(
Object.assign(
Object.create(sharedTraversalContext),
{
id: ruleId,
options: getRuleOptions(configuredRules[ruleId]),
report(...args) {
/*
* Create a report translator lazily.
* In a vast majority of cases, any given rule reports zero errors on a given
* piece of code. Creating a translator lazily avoids the performance cost of
* creating a new translator function for each rule that usually doesn't get
* called.
*
* Using lazy report translators improves end-to-end performance by about 3%
* with Node 8.4.0.
*/
if (reportTranslator === null) {
reportTranslator = createReportTranslator({ ruleId, severity, sourceCode, messageIds });
}
const problem = reportTranslator(...args);
if (problem.fix && rule.meta && !rule.meta.fixable) {
throw new Error("Fixable rules should export a `meta.fixable` property.");
}
lintingProblems.push(problem);
}
}
)
);
const ruleListeners = createRuleListeners(rule, ruleContext);
// add all the selectors from the rule as listeners
Object.keys(ruleListeners).forEach(selector => {
emitter.on(
selector,
timing.enabled
? timing.time(ruleId, ruleListeners[selector])
: ruleListeners[selector]
);
});
});
const eventGenerator = new CodePathAnalyzer(new NodeEventGenerator(emitter));
nodeQueue.forEach(traversalInfo => {
currentNode = traversalInfo.node;
try {
if (traversalInfo.isEntering) {
eventGenerator.enterNode(currentNode);
} else {
eventGenerator.leaveNode(currentNode);
}
} catch (err) {
err.currentNode = currentNode;
throw err;
}
});
return lintingProblems;
} | [
"function",
"runRules",
"(",
"sourceCode",
",",
"configuredRules",
",",
"ruleMapper",
",",
"parserOptions",
",",
"parserName",
",",
"settings",
",",
"filename",
")",
"{",
"const",
"emitter",
"=",
"createEmitter",
"(",
")",
";",
"const",
"nodeQueue",
"=",
"[",
... | Runs the given rules on the given SourceCode object
@param {SourceCode} sourceCode A SourceCode object for the given text
@param {Object} configuredRules The rules configuration
@param {function(string): Rule} ruleMapper A mapper function from rule names to rules
@param {Object} parserOptions The options that were passed to the parser
@param {string} parserName The name of the parser in the config
@param {Object} settings The settings that were enabled in the config
@param {string} filename The reported filename of the code
@returns {Problem[]} An array of reported problems | [
"Runs",
"the",
"given",
"rules",
"on",
"the",
"given",
"SourceCode",
"object"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/linter.js#L671-L786 | train | Runs the given rules on the source code. | [
30522,
3853,
2448,
6820,
4244,
1006,
3120,
16044,
1010,
26928,
6820,
4244,
1010,
3627,
2863,
18620,
1010,
11968,
8043,
7361,
9285,
1010,
11968,
8043,
18442,
1010,
10906,
1010,
5371,
18442,
1007,
1063,
9530,
3367,
12495,
12079,
1027,
3443,
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/core/Core.js | registerPreloadedModules | function registerPreloadedModules(oData, sURL) {
var modules = oData.modules,
fnUI5ToRJS = function(sName) {
return /^jquery\.sap\./.test(sName) ? sName : sName.replace(/\./g, "/");
};
if ( Version(oData.version || "1.0").compareTo("2.0") < 0 ) {
modules = {};
for ( var sName in oData.modules ) {
modules[fnUI5ToRJS(sName) + ".js"] = oData.modules[sName];
}
}
sap.ui.require.preload(modules, oData.name, sURL);
} | javascript | function registerPreloadedModules(oData, sURL) {
var modules = oData.modules,
fnUI5ToRJS = function(sName) {
return /^jquery\.sap\./.test(sName) ? sName : sName.replace(/\./g, "/");
};
if ( Version(oData.version || "1.0").compareTo("2.0") < 0 ) {
modules = {};
for ( var sName in oData.modules ) {
modules[fnUI5ToRJS(sName) + ".js"] = oData.modules[sName];
}
}
sap.ui.require.preload(modules, oData.name, sURL);
} | [
"function",
"registerPreloadedModules",
"(",
"oData",
",",
"sURL",
")",
"{",
"var",
"modules",
"=",
"oData",
".",
"modules",
",",
"fnUI5ToRJS",
"=",
"function",
"(",
"sName",
")",
"{",
"return",
"/",
"^jquery\\.sap\\.",
"/",
".",
"test",
"(",
"sName",
")",... | Adds all resources from a preload bundle to the preload cache.
When a resource exists already in the cache, the new content is ignored.
@param {object} oData Preload bundle
@param {string} [oData.url] URL from which the bundle has been loaded
@param {string} [oData.name] Unique name of the bundle
@param {string} [oData.version='1.0'] Format version of the preload bundle
@param {object} oData.modules Map of resources keyed by their resource name; each resource must be a string or a function
@private | [
"Adds",
"all",
"resources",
"from",
"a",
"preload",
"bundle",
"to",
"the",
"preload",
"cache",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Core.js#L1716-L1728 | train | Register the preloaded modules | [
30522,
3853,
4236,
28139,
17468,
5302,
8566,
4244,
1006,
1051,
2850,
2696,
1010,
7505,
2140,
1007,
1063,
13075,
14184,
1027,
1051,
2850,
2696,
1012,
14184,
1010,
1042,
11231,
2072,
2629,
4263,
30524,
1055,
18442,
1024,
1055,
18442,
1012,
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... |
facebook/relay | packages/relay-compiler/transforms/RelaySkipHandleFieldTransform.js | relaySkipHandleFieldTransform | function relaySkipHandleFieldTransform(
context: CompilerContext,
): CompilerContext {
return IRTransformer.transform(context, {
LinkedField: visitField,
ScalarField: visitField,
});
} | javascript | function relaySkipHandleFieldTransform(
context: CompilerContext,
): CompilerContext {
return IRTransformer.transform(context, {
LinkedField: visitField,
ScalarField: visitField,
});
} | [
"function",
"relaySkipHandleFieldTransform",
"(",
"context",
":",
"CompilerContext",
",",
")",
":",
"CompilerContext",
"{",
"return",
"IRTransformer",
".",
"transform",
"(",
"context",
",",
"{",
"LinkedField",
":",
"visitField",
",",
"ScalarField",
":",
"visitField"... | A transform that removes field `handles`. Intended for use when e.g.
printing queries to send to a GraphQL server. | [
"A",
"transform",
"that",
"removes",
"field",
"handles",
".",
"Intended",
"for",
"use",
"when",
"e",
".",
"g",
".",
"printing",
"queries",
"to",
"send",
"to",
"a",
"GraphQL",
"server",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/transforms/RelaySkipHandleFieldTransform.js#L22-L29 | train | Transform a field to be skipped by the next block | [
30522,
3853,
8846,
5488,
21890,
4859,
2571,
3790,
6494,
3619,
14192,
1006,
6123,
1024,
21624,
8663,
18209,
1010,
1007,
1024,
21624,
8663,
18209,
1063,
2709,
20868,
6494,
3619,
14192,
2121,
1012,
10938,
1006,
6123,
1010,
1063,
5799,
3790,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.layout/src/sap/ui/layout/form/SimpleForm.js | _createRFLayoutData | function _createRFLayoutData(iWeight, bLinebreak, bLinebreakable, iMinWidth) {
var oLayout = new ResponsiveFlowLayoutData({weight:iWeight,linebreak:bLinebreak === true,linebreakable: bLinebreakable === true});
if (iMinWidth) {
oLayout.setMinWidth(iMinWidth);
}
this._aLayouts.push(oLayout.getId());
return oLayout;
} | javascript | function _createRFLayoutData(iWeight, bLinebreak, bLinebreakable, iMinWidth) {
var oLayout = new ResponsiveFlowLayoutData({weight:iWeight,linebreak:bLinebreak === true,linebreakable: bLinebreakable === true});
if (iMinWidth) {
oLayout.setMinWidth(iMinWidth);
}
this._aLayouts.push(oLayout.getId());
return oLayout;
} | [
"function",
"_createRFLayoutData",
"(",
"iWeight",
",",
"bLinebreak",
",",
"bLinebreakable",
",",
"iMinWidth",
")",
"{",
"var",
"oLayout",
"=",
"new",
"ResponsiveFlowLayoutData",
"(",
"{",
"weight",
":",
"iWeight",
",",
"linebreak",
":",
"bLinebreak",
"===",
"tr... | /*
Creates new sap.ui.layout.ResponsiveFlowLayoutData with the given parameters
@param {int} iWeight the weight for the layout data
@param {boolean} bLinebreak Whether the layout data has a linebreak
@param {boolean} bLinebreakable Whether the layout data is linebreakable
@returns {sap.ui.layout.ResponsiveFlowLayoutData} The newly created ResponsiveFlowLayoutData
@private | [
"/",
"*",
"Creates",
"new",
"sap",
".",
"ui",
".",
"layout",
".",
"ResponsiveFlowLayoutData",
"with",
"the",
"given",
"parameters"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.layout/src/sap/ui/layout/form/SimpleForm.js#L1444-L1453 | train | Creates a layout object and adds it to the internal list of layouts | [
30522,
3853,
1035,
3443,
12881,
8485,
5833,
2850,
2696,
1006,
1045,
11179,
1010,
1038,
4179,
23890,
1010,
1038,
4179,
23890,
3085,
1010,
10047,
2378,
9148,
11927,
2232,
1007,
1063,
13075,
19330,
28852,
4904,
1027,
2047,
26651,
12314,
8485,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/text.js | function () {
var data = this.data;
var hasChangedShader;
var material = this.material;
var NewShader;
var shaderData = this.shaderData;
var shaderName;
// Infer shader if using a stock font (or from `-msdf` filename convention).
shaderName = data.shader;
if (MSDF_FONTS.indexOf(data.font) !== -1 || data.font.indexOf('-msdf.') >= 0) {
shaderName = 'msdf';
} else if (data.font in FONTS && MSDF_FONTS.indexOf(data.font) === -1) {
shaderName = 'sdf';
}
hasChangedShader = (this.shaderObject && this.shaderObject.name) !== shaderName;
shaderData.alphaTest = data.alphaTest;
shaderData.color = data.color;
shaderData.map = this.texture;
shaderData.opacity = data.opacity;
shaderData.side = parseSide(data.side);
shaderData.transparent = data.transparent;
shaderData.negate = data.negate;
// Shader has not changed, do an update.
if (!hasChangedShader) {
// Update shader material.
this.shaderObject.update(shaderData);
// Apparently, was not set on `init` nor `update`.
material.transparent = shaderData.transparent;
material.side = shaderData.side;
return;
}
// Shader has changed. Create a shader material.
NewShader = createShader(this.el, shaderName, shaderData);
this.material = NewShader.material;
this.shaderObject = NewShader.shader;
// Set new shader material.
this.material.side = shaderData.side;
if (this.mesh) { this.mesh.material = this.material; }
} | javascript | function () {
var data = this.data;
var hasChangedShader;
var material = this.material;
var NewShader;
var shaderData = this.shaderData;
var shaderName;
// Infer shader if using a stock font (or from `-msdf` filename convention).
shaderName = data.shader;
if (MSDF_FONTS.indexOf(data.font) !== -1 || data.font.indexOf('-msdf.') >= 0) {
shaderName = 'msdf';
} else if (data.font in FONTS && MSDF_FONTS.indexOf(data.font) === -1) {
shaderName = 'sdf';
}
hasChangedShader = (this.shaderObject && this.shaderObject.name) !== shaderName;
shaderData.alphaTest = data.alphaTest;
shaderData.color = data.color;
shaderData.map = this.texture;
shaderData.opacity = data.opacity;
shaderData.side = parseSide(data.side);
shaderData.transparent = data.transparent;
shaderData.negate = data.negate;
// Shader has not changed, do an update.
if (!hasChangedShader) {
// Update shader material.
this.shaderObject.update(shaderData);
// Apparently, was not set on `init` nor `update`.
material.transparent = shaderData.transparent;
material.side = shaderData.side;
return;
}
// Shader has changed. Create a shader material.
NewShader = createShader(this.el, shaderName, shaderData);
this.material = NewShader.material;
this.shaderObject = NewShader.shader;
// Set new shader material.
this.material.side = shaderData.side;
if (this.mesh) { this.mesh.material = this.material; }
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"hasChangedShader",
";",
"var",
"material",
"=",
"this",
".",
"material",
";",
"var",
"NewShader",
";",
"var",
"shaderData",
"=",
"this",
".",
"shaderData",
";",
"var",
"sh... | Update the shader of the material. | [
"Update",
"the",
"shader",
"of",
"the",
"material",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L145-L189 | train | Update the shader object | [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
2038,
22305,
2098,
7377,
4063,
1025,
13075,
3430,
1027,
2023,
1012,
3430,
1025,
13075,
2739,
16102,
2121,
1025,
13075,
8703,
13639,
2696,
1027,
2023,
1012,
870... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function () {
var name, params = [], match, ruleset, cond, variadic = false;
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
peek(/^[^{]*\}/)) {
return;
}
save();
match = $re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/);
if (match) {
name = match[1];
var argInfo = this.args(false);
params = argInfo.args;
variadic = argInfo.variadic;
// .mixincall("@{a}");
// looks a bit like a mixin definition.. so we have to be nice and restore
if (!$char(')')) {
furthest = i;
restore();
}
parsers.comments();
if ($re(/^when/)) { // Guard
cond = expect(parsers.conditions, 'expected condition');
}
ruleset = parsers.block();
if (ruleset) {
return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
} else {
restore();
}
}
} | javascript | function () {
var name, params = [], match, ruleset, cond, variadic = false;
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
peek(/^[^{]*\}/)) {
return;
}
save();
match = $re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/);
if (match) {
name = match[1];
var argInfo = this.args(false);
params = argInfo.args;
variadic = argInfo.variadic;
// .mixincall("@{a}");
// looks a bit like a mixin definition.. so we have to be nice and restore
if (!$char(')')) {
furthest = i;
restore();
}
parsers.comments();
if ($re(/^when/)) { // Guard
cond = expect(parsers.conditions, 'expected condition');
}
ruleset = parsers.block();
if (ruleset) {
return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
} else {
restore();
}
}
} | [
"function",
"(",
")",
"{",
"var",
"name",
",",
"params",
"=",
"[",
"]",
",",
"match",
",",
"ruleset",
",",
"cond",
",",
"variadic",
"=",
"false",
";",
"if",
"(",
"(",
"input",
".",
"charAt",
"(",
"i",
")",
"!==",
"'.'",
"&&",
"input",
".",
"cha... | A Mixin definition, with a list of parameters .rounded (@radius: 2px, @color) { ... } Until we have a finer grained state-machine, we have to do a look-ahead, to make sure we don't have a mixin call. See the `rule` function for more information. We start by matching `.rounded (`, and then proceed on to the argument list, which has optional default values. We store the parameters in `params`, with a `value` key, if there is a value, such as in the case of `@radius`. Once we've got our params list, and a closing `)`, we parse the `{...}` block. | [
"A",
"Mixin",
"definition",
"with",
"a",
"list",
"of",
"parameters",
".",
"rounded",
"("
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1266-L1304 | train | parse mixin definition | [
30522,
3853,
1006,
1007,
1063,
13075,
2171,
1010,
11498,
5244,
1027,
1031,
1033,
1010,
2674,
1010,
3513,
3388,
1010,
9530,
2094,
1010,
13075,
28665,
2594,
1027,
6270,
1025,
2065,
1006,
1006,
7953,
1012,
25869,
4017,
1006,
1045,
1007,
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... | |
nhn/tui.editor | src/js/wysiwygCommands/table.js | makeHeader | function makeHeader(col, data) {
let header = '<thead><tr>';
let index = 0;
while (col) {
header += '<th>';
if (data) {
header += data[index];
index += 1;
}
header += '</th>';
col -= 1;
}
header += '</tr></thead>';
return header;
} | javascript | function makeHeader(col, data) {
let header = '<thead><tr>';
let index = 0;
while (col) {
header += '<th>';
if (data) {
header += data[index];
index += 1;
}
header += '</th>';
col -= 1;
}
header += '</tr></thead>';
return header;
} | [
"function",
"makeHeader",
"(",
"col",
",",
"data",
")",
"{",
"let",
"header",
"=",
"'<thead><tr>'",
";",
"let",
"index",
"=",
"0",
";",
"while",
"(",
"col",
")",
"{",
"header",
"+=",
"'<th>'",
";",
"if",
"(",
"data",
")",
"{",
"header",
"+=",
"data... | makeHeader
make table header html string
@param {number} col column count
@param {string} data cell data
@returns {string} html string | [
"makeHeader",
"make",
"table",
"header",
"html",
"string"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/table.js#L69-L88 | train | Creates a header string for the table | [
30522,
3853,
2191,
4974,
2121,
1006,
8902,
1010,
2951,
1007,
1063,
2292,
20346,
1027,
1005,
1026,
1996,
4215,
1028,
1026,
19817,
1028,
1005,
1025,
2292,
5950,
1027,
1014,
1025,
2096,
1006,
8902,
1007,
1063,
20346,
1009,
1027,
1005,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/services/s3.js | computeContentMd5 | function computeContentMd5(req) {
if (req.service.willComputeChecksums(req)) {
var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64');
req.httpRequest.headers['Content-MD5'] = md5;
}
} | javascript | function computeContentMd5(req) {
if (req.service.willComputeChecksums(req)) {
var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64');
req.httpRequest.headers['Content-MD5'] = md5;
}
} | [
"function",
"computeContentMd5",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"service",
".",
"willComputeChecksums",
"(",
"req",
")",
")",
"{",
"var",
"md5",
"=",
"AWS",
".",
"util",
".",
"crypto",
".",
"md5",
"(",
"req",
".",
"httpRequest",
".",
"b... | A listener that computes the Content-MD5 and sets it in the header.
@see AWS.S3.willComputeChecksums
@api private | [
"A",
"listener",
"that",
"computes",
"the",
"Content",
"-",
"MD5",
"and",
"sets",
"it",
"in",
"the",
"header",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L357-L362 | train | Compute the Content - MD5 header if the request will use the same algorithm as the original | [
30522,
3853,
24134,
8663,
6528,
21246,
2094,
2629,
1006,
2128,
4160,
1007,
1063,
2065,
1006,
2128,
4160,
1012,
2326,
1012,
2097,
9006,
18780,
27635,
10603,
18163,
1006,
2128,
4160,
1007,
1007,
1063,
13075,
9108,
2629,
1027,
22091,
2015,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/chips/demoContactChips/script.js | delayedQuerySearch | function delayedQuerySearch(criteria) {
if (!pendingSearch || !debounceSearch()) {
cancelSearch();
return pendingSearch = $q(function(resolve, reject) {
// Simulate async search... (after debouncing)
cancelSearch = reject;
$timeout(function() {
resolve(self.querySearch(criteria));
refreshDebounce();
}, Math.random() * 500, true);
});
}
return pendingSearch;
} | javascript | function delayedQuerySearch(criteria) {
if (!pendingSearch || !debounceSearch()) {
cancelSearch();
return pendingSearch = $q(function(resolve, reject) {
// Simulate async search... (after debouncing)
cancelSearch = reject;
$timeout(function() {
resolve(self.querySearch(criteria));
refreshDebounce();
}, Math.random() * 500, true);
});
}
return pendingSearch;
} | [
"function",
"delayedQuerySearch",
"(",
"criteria",
")",
"{",
"if",
"(",
"!",
"pendingSearch",
"||",
"!",
"debounceSearch",
"(",
")",
")",
"{",
"cancelSearch",
"(",
")",
";",
"return",
"pendingSearch",
"=",
"$q",
"(",
"function",
"(",
"resolve",
",",
"rejec... | Async search for contacts
Also debounce the queries; since the md-contact-chips does not support this | [
"Async",
"search",
"for",
"contacts",
"Also",
"debounce",
"the",
"queries",
";",
"since",
"the",
"md",
"-",
"contact",
"-",
"chips",
"does",
"not",
"support",
"this"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/demoContactChips/script.js#L41-L58 | train | Debounce the search | [
30522,
3853,
8394,
4226,
24769,
14644,
2818,
1006,
9181,
1007,
1063,
2065,
1006,
999,
14223,
17310,
11140,
1064,
1064,
999,
2139,
5092,
17457,
17310,
11140,
1006,
1007,
1007,
1063,
17542,
17310,
11140,
1006,
30524,
17310,
11140,
1027,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/functional.js | varArgs | function varArgs(fn){
var numberOfFixedArguments = fn.length -1,
slice = Array.prototype.slice;
if( numberOfFixedArguments == 0 ) {
// an optimised case for when there are no fixed args:
return function(){
return fn.call(this, slice.call(arguments));
}
} else if( numberOfFixedArguments == 1 ) {
// an optimised case for when there are is one fixed args:
return function(){
return fn.call(this, arguments[0], slice.call(arguments, 1));
}
}
// general case
// we know how many arguments fn will always take. Create a
// fixed-size array to hold that many, to be re-used on
// every call to the returned function
var argsHolder = Array(fn.length);
return function(){
for (var i = 0; i < numberOfFixedArguments; i++) {
argsHolder[i] = arguments[i];
}
argsHolder[numberOfFixedArguments] =
slice.call(arguments, numberOfFixedArguments);
return fn.apply( this, argsHolder);
}
} | javascript | function varArgs(fn){
var numberOfFixedArguments = fn.length -1,
slice = Array.prototype.slice;
if( numberOfFixedArguments == 0 ) {
// an optimised case for when there are no fixed args:
return function(){
return fn.call(this, slice.call(arguments));
}
} else if( numberOfFixedArguments == 1 ) {
// an optimised case for when there are is one fixed args:
return function(){
return fn.call(this, arguments[0], slice.call(arguments, 1));
}
}
// general case
// we know how many arguments fn will always take. Create a
// fixed-size array to hold that many, to be re-used on
// every call to the returned function
var argsHolder = Array(fn.length);
return function(){
for (var i = 0; i < numberOfFixedArguments; i++) {
argsHolder[i] = arguments[i];
}
argsHolder[numberOfFixedArguments] =
slice.call(arguments, numberOfFixedArguments);
return fn.apply( this, argsHolder);
}
} | [
"function",
"varArgs",
"(",
"fn",
")",
"{",
"var",
"numberOfFixedArguments",
"=",
"fn",
".",
"length",
"-",
"1",
",",
"slice",
"=",
"Array",
".",
"prototype",
".",
"slice",
";",
"if",
"(",
"numberOfFixedArguments",
"==",
"0",
")",
"{",
"// an optimised cas... | Define variable argument functions but cut out all that tedious messing about
with the arguments object. Delivers the variable-length part of the arguments
list as an array.
Eg:
var myFunction = varArgs(
function( fixedArgument, otherFixedArgument, variableNumberOfArguments ){
console.log( variableNumberOfArguments );
}
)
myFunction('a', 'b', 1, 2, 3); // logs [1,2,3]
var myOtherFunction = varArgs(function( variableNumberOfArguments ){
console.log( variableNumberOfArguments );
})
myFunction(1, 2, 3); // logs [1,2,3] | [
"Define",
"variable",
"argument",
"functions",
"but",
"cut",
"out",
"all",
"that",
"tedious",
"messing",
"about",
"with",
"the",
"arguments",
"object",
".",
"Delivers",
"the",
"variable",
"-",
"length",
"part",
"of",
"the",
"arguments",
"list",
"as",
"an",
"... | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/functional.js#L158-L197 | train | This function is a function that takes a number of arguments and returns a function that will return a new object with the arguments as the first argument. | [
30522,
3853,
13075,
2906,
5620,
1006,
1042,
2078,
1007,
1063,
13075,
2193,
7245,
7646,
11960,
10623,
27417,
3215,
1027,
1042,
2078,
1012,
3091,
1011,
1015,
1010,
14704,
1027,
9140,
1012,
8773,
1012,
14704,
1025,
2065,
1006,
2193,
7245,
7646... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.unified/src/sap/ui/unified/calendar/CalendarDate.js | createUTCDate | function createUTCDate(oDate) {
var oUTCDate = new Date(Date.UTC(0, 0, 1));
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
return oUTCDate;
} | javascript | function createUTCDate(oDate) {
var oUTCDate = new Date(Date.UTC(0, 0, 1));
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
return oUTCDate;
} | [
"function",
"createUTCDate",
"(",
"oDate",
")",
"{",
"var",
"oUTCDate",
"=",
"new",
"Date",
"(",
"Date",
".",
"UTC",
"(",
"0",
",",
"0",
",",
"1",
")",
")",
";",
"oUTCDate",
".",
"setUTCFullYear",
"(",
"oDate",
".",
"getFullYear",
"(",
")",
",",
"o... | Creates a JavaScript UTC Date corresponding to the given JavaScript Date.
@param {Date} oDate JavaScript date object. Time related information is cut.
@returns {Date} JavaScript date created from the date object, but this time considered as UTC date information. | [
"Creates",
"a",
"JavaScript",
"UTC",
"Date",
"corresponding",
"to",
"the",
"given",
"JavaScript",
"Date",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.unified/src/sap/ui/unified/calendar/CalendarDate.js#L341-L347 | train | Creates a new Date instance with the correct UTC date | [
30522,
3853,
3443,
4904,
19797,
3686,
1006,
1051,
13701,
1007,
1063,
13075,
2041,
19797,
3686,
1027,
2047,
3058,
1006,
3058,
1012,
11396,
1006,
1014,
1010,
1014,
1010,
1015,
1007,
1007,
1025,
2041,
19797,
3686,
1012,
2275,
4904,
2278,
7699,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/preferences/PreferencesBase.js | function (oldContext, newContext) {
var changes = [];
_.each(this._scopes, function (scope) {
var changedInScope = scope.contextChanged(oldContext, newContext);
if (changedInScope) {
changes.push(changedInScope);
}
});
changes = _.union.apply(null, changes);
if (changes.length > 0) {
this._triggerChange({
ids: changes
});
}
} | javascript | function (oldContext, newContext) {
var changes = [];
_.each(this._scopes, function (scope) {
var changedInScope = scope.contextChanged(oldContext, newContext);
if (changedInScope) {
changes.push(changedInScope);
}
});
changes = _.union.apply(null, changes);
if (changes.length > 0) {
this._triggerChange({
ids: changes
});
}
} | [
"function",
"(",
"oldContext",
",",
"newContext",
")",
"{",
"var",
"changes",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"this",
".",
"_scopes",
",",
"function",
"(",
"scope",
")",
"{",
"var",
"changedInScope",
"=",
"scope",
".",
"contextChanged",
"(",... | Signals the context change to all the scopes within the preferences
layer. PreferencesManager is in charge of computing the context and
signaling the changes to PreferencesSystem.
@param {{path: string, language: string}} oldContext Old context
@param {{path: string, language: string}} newContext New context | [
"Signals",
"the",
"context",
"change",
"to",
"all",
"the",
"scopes",
"within",
"the",
"preferences",
"layer",
".",
"PreferencesManager",
"is",
"in",
"charge",
"of",
"computing",
"the",
"context",
"and",
"signaling",
"the",
"changes",
"to",
"PreferencesSystem",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1815-L1831 | train | trigger contextChanged event | [
30522,
3853,
1006,
2214,
8663,
18209,
1010,
2047,
8663,
18209,
1007,
1063,
13075,
3431,
1027,
1031,
1033,
1025,
1035,
1012,
2169,
1006,
2023,
1012,
1035,
9531,
2015,
1010,
3853,
1006,
9531,
1007,
1063,
13075,
2904,
7076,
16186,
1027,
9531,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(inst, name) {
return inst.settings[name] !== undefined ?
inst.settings[name] : this._defaults[name];
} | javascript | function(inst, name) {
return inst.settings[name] !== undefined ?
inst.settings[name] : this._defaults[name];
} | [
"function",
"(",
"inst",
",",
"name",
")",
"{",
"return",
"inst",
".",
"settings",
"[",
"name",
"]",
"!==",
"undefined",
"?",
"inst",
".",
"settings",
"[",
"name",
"]",
":",
"this",
".",
"_defaults",
"[",
"name",
"]",
";",
"}"
] | /* Get a setting value, defaulting if necessary. | [
"/",
"*",
"Get",
"a",
"setting",
"value",
"defaulting",
"if",
"necessary",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L9024-L9027 | train | Get the value of a configuration option. | [
30522,
3853,
1006,
16021,
2102,
1010,
2171,
1007,
1063,
2709,
16021,
2102,
1012,
10906,
1031,
2171,
1033,
999,
1027,
1027,
6151,
28344,
1029,
16021,
2102,
1012,
10906,
1031,
2171,
1033,
1024,
2023,
1012,
1035,
12398,
2015,
1031,
2171,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ksky521/nodeppt | packages/nodeppt-parser/lib/markdown/plus-list.js | applyClass | function applyClass(token) {
// init attributes
token.attrs = token.attrs || [];
// get index of class attribute
let keys = token.attrs.map(arr => arr[0]);
let idx = keys.indexOf('class');
if (idx === -1) {
// Add class attribute if not defined
token.attrs.push(['class', className]);
} else {
// Get the current class list to append.
// Watch out for duplicates
let classStr = token.attrs[idx][1] || '';
let classList = classStr.split(' ');
// Add the class if we don't already have it
if (classList.indexOf(className) === -1) {
token.attrs[idx][1] = classStr += ' ' + className;
}
}
} | javascript | function applyClass(token) {
// init attributes
token.attrs = token.attrs || [];
// get index of class attribute
let keys = token.attrs.map(arr => arr[0]);
let idx = keys.indexOf('class');
if (idx === -1) {
// Add class attribute if not defined
token.attrs.push(['class', className]);
} else {
// Get the current class list to append.
// Watch out for duplicates
let classStr = token.attrs[idx][1] || '';
let classList = classStr.split(' ');
// Add the class if we don't already have it
if (classList.indexOf(className) === -1) {
token.attrs[idx][1] = classStr += ' ' + className;
}
}
} | [
"function",
"applyClass",
"(",
"token",
")",
"{",
"// init attributes",
"token",
".",
"attrs",
"=",
"token",
".",
"attrs",
"||",
"[",
"]",
";",
"// get index of class attribute",
"let",
"keys",
"=",
"token",
".",
"attrs",
".",
"map",
"(",
"arr",
"=>",
"arr... | Adds class to token
@param {any} token
@param {string} className | [
"Adds",
"class",
"to",
"token"
] | ca77e29ef818c08b0522b31e3925b073cf159b9c | https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-parser/lib/markdown/plus-list.js#L17-L39 | train | Apply a class to a token | [
30522,
3853,
6611,
26266,
1006,
19204,
1007,
1063,
1013,
1013,
1999,
4183,
12332,
19204,
1012,
2012,
16344,
2015,
1027,
19204,
1012,
2012,
16344,
2015,
1064,
1064,
1031,
1033,
1025,
1013,
1013,
2131,
5950,
1997,
2465,
17961,
2292,
6309,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | kargerStein | function kargerStein() {
var _this$byGroup = this.byGroup(),
nodes = _this$byGroup.nodes,
edges = _this$byGroup.edges;
edges.unmergeBy(function (edge) {
return edge.isLoop();
});
var numNodes = nodes.length;
var numEdges = edges.length;
var numIter = Math.ceil(Math.pow(Math.log(numNodes) / Math.LN2, 2));
var stopSize = Math.floor(numNodes / sqrt2);
if (numNodes < 2) {
error('At least 2 nodes are required for Karger-Stein algorithm');
return undefined;
} // Now store edge destination as indexes
// Format for each edge (edge index, source node index, target node index)
var edgeIndexes = [];
for (var i = 0; i < numEdges; i++) {
var e = edges[i];
edgeIndexes.push([i, nodes.indexOf(e.source()), nodes.indexOf(e.target())]);
} // We will store the best cut found here
var minCutSize = Infinity;
var minCutEdgeIndexes = [];
var minCutNodeMap = new Array(numNodes); // Initial meta node partition
var metaNodeMap = new Array(numNodes);
var metaNodeMap2 = new Array(numNodes);
var copyNodesMap = function copyNodesMap(from, to) {
for (var _i3 = 0; _i3 < numNodes; _i3++) {
to[_i3] = from[_i3];
}
}; // Main loop
for (var iter = 0; iter <= numIter; iter++) {
// Reset meta node partition
for (var _i4 = 0; _i4 < numNodes; _i4++) {
metaNodeMap[_i4] = _i4;
} // Contract until stop point (stopSize nodes)
var edgesState = contractUntil(metaNodeMap, edgeIndexes.slice(), numNodes, stopSize);
var edgesState2 = edgesState.slice(); // copy
// Create a copy of the colapsed nodes state
copyNodesMap(metaNodeMap, metaNodeMap2); // Run 2 iterations starting in the stop state
var res1 = contractUntil(metaNodeMap, edgesState, stopSize, 2);
var res2 = contractUntil(metaNodeMap2, edgesState2, stopSize, 2); // Is any of the 2 results the best cut so far?
if (res1.length <= res2.length && res1.length < minCutSize) {
minCutSize = res1.length;
minCutEdgeIndexes = res1;
copyNodesMap(metaNodeMap, minCutNodeMap);
} else if (res2.length <= res1.length && res2.length < minCutSize) {
minCutSize = res2.length;
minCutEdgeIndexes = res2;
copyNodesMap(metaNodeMap2, minCutNodeMap);
}
} // end of main loop
// Construct result
var cut = this.spawn(minCutEdgeIndexes.map(function (e) {
return edges[e[0]];
}));
var partition1 = this.spawn();
var partition2 = this.spawn(); // traverse metaNodeMap for best cut
var witnessNodePartition = minCutNodeMap[0];
for (var _i5 = 0; _i5 < minCutNodeMap.length; _i5++) {
var partitionId = minCutNodeMap[_i5];
var node = nodes[_i5];
if (partitionId === witnessNodePartition) {
partition1.merge(node);
} else {
partition2.merge(node);
}
}
var ret = {
cut: cut,
partition1: partition1,
partition2: partition2
};
return ret;
} | javascript | function kargerStein() {
var _this$byGroup = this.byGroup(),
nodes = _this$byGroup.nodes,
edges = _this$byGroup.edges;
edges.unmergeBy(function (edge) {
return edge.isLoop();
});
var numNodes = nodes.length;
var numEdges = edges.length;
var numIter = Math.ceil(Math.pow(Math.log(numNodes) / Math.LN2, 2));
var stopSize = Math.floor(numNodes / sqrt2);
if (numNodes < 2) {
error('At least 2 nodes are required for Karger-Stein algorithm');
return undefined;
} // Now store edge destination as indexes
// Format for each edge (edge index, source node index, target node index)
var edgeIndexes = [];
for (var i = 0; i < numEdges; i++) {
var e = edges[i];
edgeIndexes.push([i, nodes.indexOf(e.source()), nodes.indexOf(e.target())]);
} // We will store the best cut found here
var minCutSize = Infinity;
var minCutEdgeIndexes = [];
var minCutNodeMap = new Array(numNodes); // Initial meta node partition
var metaNodeMap = new Array(numNodes);
var metaNodeMap2 = new Array(numNodes);
var copyNodesMap = function copyNodesMap(from, to) {
for (var _i3 = 0; _i3 < numNodes; _i3++) {
to[_i3] = from[_i3];
}
}; // Main loop
for (var iter = 0; iter <= numIter; iter++) {
// Reset meta node partition
for (var _i4 = 0; _i4 < numNodes; _i4++) {
metaNodeMap[_i4] = _i4;
} // Contract until stop point (stopSize nodes)
var edgesState = contractUntil(metaNodeMap, edgeIndexes.slice(), numNodes, stopSize);
var edgesState2 = edgesState.slice(); // copy
// Create a copy of the colapsed nodes state
copyNodesMap(metaNodeMap, metaNodeMap2); // Run 2 iterations starting in the stop state
var res1 = contractUntil(metaNodeMap, edgesState, stopSize, 2);
var res2 = contractUntil(metaNodeMap2, edgesState2, stopSize, 2); // Is any of the 2 results the best cut so far?
if (res1.length <= res2.length && res1.length < minCutSize) {
minCutSize = res1.length;
minCutEdgeIndexes = res1;
copyNodesMap(metaNodeMap, minCutNodeMap);
} else if (res2.length <= res1.length && res2.length < minCutSize) {
minCutSize = res2.length;
minCutEdgeIndexes = res2;
copyNodesMap(metaNodeMap2, minCutNodeMap);
}
} // end of main loop
// Construct result
var cut = this.spawn(minCutEdgeIndexes.map(function (e) {
return edges[e[0]];
}));
var partition1 = this.spawn();
var partition2 = this.spawn(); // traverse metaNodeMap for best cut
var witnessNodePartition = minCutNodeMap[0];
for (var _i5 = 0; _i5 < minCutNodeMap.length; _i5++) {
var partitionId = minCutNodeMap[_i5];
var node = nodes[_i5];
if (partitionId === witnessNodePartition) {
partition1.merge(node);
} else {
partition2.merge(node);
}
}
var ret = {
cut: cut,
partition1: partition1,
partition2: partition2
};
return ret;
} | [
"function",
"kargerStein",
"(",
")",
"{",
"var",
"_this$byGroup",
"=",
"this",
".",
"byGroup",
"(",
")",
",",
"nodes",
"=",
"_this$byGroup",
".",
"nodes",
",",
"edges",
"=",
"_this$byGroup",
".",
"edges",
";",
"edges",
".",
"unmergeBy",
"(",
"function",
... | Computes the minimum cut of an undirected graph Returns the correct answer with high probability | [
"Computes",
"the",
"minimum",
"cut",
"of",
"an",
"undirected",
"graph",
"Returns",
"the",
"correct",
"answer",
"with",
"high",
"probability"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L2102-L2198 | train | Karger - Stein algorithm | [
30522,
3853,
10556,
25858,
8602,
1006,
1007,
1063,
13075,
1035,
2023,
1002,
2011,
17058,
1027,
2023,
1012,
2011,
17058,
1006,
1007,
1010,
14164,
1027,
1035,
2023,
1002,
2011,
17058,
1012,
14164,
1010,
7926,
1027,
1035,
2023,
1002,
2011,
170... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | expect | function expect(value) {
var token = lex();
if (token.type !== Token.Punctuator || token.value !== value) {
throwUnexpected(token);
}
} | javascript | function expect(value) {
var token = lex();
if (token.type !== Token.Punctuator || token.value !== value) {
throwUnexpected(token);
}
} | [
"function",
"expect",
"(",
"value",
")",
"{",
"var",
"token",
"=",
"lex",
"(",
")",
";",
"if",
"(",
"token",
".",
"type",
"!==",
"Token",
".",
"Punctuator",
"||",
"token",
".",
"value",
"!==",
"value",
")",
"{",
"throwUnexpected",
"(",
"token",
")",
... | Expect the next token to match the specified punctuator. If not, an exception will be thrown. | [
"Expect",
"the",
"next",
"token",
"to",
"match",
"the",
"specified",
"punctuator",
".",
"If",
"not",
"an",
"exception",
"will",
"be",
"thrown",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L1899-L1904 | train | Expects a punctuation or phrase | [
30522,
3853,
5987,
1006,
3643,
1007,
1063,
13075,
19204,
1027,
17244,
1006,
1007,
1025,
2065,
1006,
19204,
1012,
2828,
999,
1027,
1027,
19204,
1012,
26136,
6593,
6692,
4263,
1064,
1064,
19204,
1012,
3643,
999,
1027,
1027,
3643,
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.documentation/src/sap/ui/documentation/sdk/controller/BaseController.js | function(oEvent) {
var oImage = this.byId("phoneImage");
if (Device.system.phone && oImage) {
oImage.toggleStyleClass("phoneHeaderImageLandscape", oEvent.landscape);
}
} | javascript | function(oEvent) {
var oImage = this.byId("phoneImage");
if (Device.system.phone && oImage) {
oImage.toggleStyleClass("phoneHeaderImageLandscape", oEvent.landscape);
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oImage",
"=",
"this",
".",
"byId",
"(",
"\"phoneImage\"",
")",
";",
"if",
"(",
"Device",
".",
"system",
".",
"phone",
"&&",
"oImage",
")",
"{",
"oImage",
".",
"toggleStyleClass",
"(",
"\"phoneHeaderImageLandscap... | Switches the maximum height of the phone image for optimal display in landscape mode
@param {sap.ui.base.Event} oEvent Device orientation change event
@private | [
"Switches",
"the",
"maximum",
"height",
"of",
"the",
"phone",
"image",
"for",
"optimal",
"display",
"in",
"landscape",
"mode"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/BaseController.js#L170-L176 | train | Toggle the landscape style class of the phone image | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
1051,
9581,
3351,
1027,
2023,
1012,
2011,
3593,
1006,
1000,
3042,
9581,
3351,
1000,
1007,
1025,
2065,
1006,
5080,
1012,
2291,
1012,
3042,
1004,
1004,
1051,
9581,
3351,
1007,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.uxap/src/sap/uxap/component/Component.js | function () {
var oController;
//step3: create view
this._oView = sap.ui.view(this._oViewConfig);
//step4: bind the view with the model
if (this._oModel) {
oController = this._oView.getController();
//some factory requires pre-processing once the view and model are created
if (oController && oController.connectToComponent) {
oController.connectToComponent(this._oModel);
}
//can now apply the model and rely on the underlying factory logic
this._oView.setModel(this._oModel, "objectPageLayoutMetadata");
}
return this._oView;
} | javascript | function () {
var oController;
//step3: create view
this._oView = sap.ui.view(this._oViewConfig);
//step4: bind the view with the model
if (this._oModel) {
oController = this._oView.getController();
//some factory requires pre-processing once the view and model are created
if (oController && oController.connectToComponent) {
oController.connectToComponent(this._oModel);
}
//can now apply the model and rely on the underlying factory logic
this._oView.setModel(this._oModel, "objectPageLayoutMetadata");
}
return this._oView;
} | [
"function",
"(",
")",
"{",
"var",
"oController",
";",
"//step3: create view",
"this",
".",
"_oView",
"=",
"sap",
".",
"ui",
".",
"view",
"(",
"this",
".",
"_oViewConfig",
")",
";",
"//step4: bind the view with the model",
"if",
"(",
"this",
".",
"_oModel",
"... | Create view corresponding to the chosen config
@returns {sap.ui.view} Created view | [
"Create",
"view",
"corresponding",
"to",
"the",
"chosen",
"config"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/Component.js#L63-L83 | train | create the view and bind the model | [
30522,
3853,
1006,
1007,
1063,
13075,
1051,
8663,
13181,
10820,
1025,
1013,
1013,
3357,
2509,
1024,
3443,
3193,
2023,
1012,
1035,
1051,
8584,
1027,
20066,
1012,
21318,
1012,
3193,
1006,
2023,
1012,
1035,
1051,
8584,
8663,
8873,
2290,
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... | |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/JSDOMParser.js | function (str) {
var strlen = str.length;
if (this.html.substr(this.currentChar, strlen).toLowerCase() === str.toLowerCase()) {
this.currentChar += strlen;
return true;
}
return false;
} | javascript | function (str) {
var strlen = str.length;
if (this.html.substr(this.currentChar, strlen).toLowerCase() === str.toLowerCase()) {
this.currentChar += strlen;
return true;
}
return false;
} | [
"function",
"(",
"str",
")",
"{",
"var",
"strlen",
"=",
"str",
".",
"length",
";",
"if",
"(",
"this",
".",
"html",
".",
"substr",
"(",
"this",
".",
"currentChar",
",",
"strlen",
")",
".",
"toLowerCase",
"(",
")",
"===",
"str",
".",
"toLowerCase",
"... | If the current input matches this string, advance the input index;
otherwise, do nothing.
@returns whether input matched string | [
"If",
"the",
"current",
"input",
"matches",
"this",
"string",
"advance",
"the",
"input",
"index",
";",
"otherwise",
"do",
"nothing",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L995-L1002 | train | Check if the current char is in the string | [
30522,
3853,
1006,
2358,
2099,
1007,
1063,
13075,
2358,
20927,
2078,
1027,
2358,
30524,
7507,
2099,
1010,
2358,
20927,
2078,
1007,
1012,
2000,
27663,
18992,
3366,
1006,
1007,
1027,
1027,
1027,
2358,
2099,
1012,
2000,
27663,
18992,
3366,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/scene/pool.js | function () {
var el;
el = document.createElement('a-entity');
el.play = this.wrapPlay(el.play);
el.setAttribute('mixin', this.data.mixin);
el.object3D.visible = false;
el.pause();
this.container.appendChild(el);
this.availableEls.push(el);
} | javascript | function () {
var el;
el = document.createElement('a-entity');
el.play = this.wrapPlay(el.play);
el.setAttribute('mixin', this.data.mixin);
el.object3D.visible = false;
el.pause();
this.container.appendChild(el);
this.availableEls.push(el);
} | [
"function",
"(",
")",
"{",
"var",
"el",
";",
"el",
"=",
"document",
".",
"createElement",
"(",
"'a-entity'",
")",
";",
"el",
".",
"play",
"=",
"this",
".",
"wrapPlay",
"(",
"el",
".",
"play",
")",
";",
"el",
".",
"setAttribute",
"(",
"'mixin'",
","... | Add a new entity to the list of available entities. | [
"Add",
"a",
"new",
"entity",
"to",
"the",
"list",
"of",
"available",
"entities",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/pool.js#L57-L66 | train | Creates an entity and adds it to the container | [
30522,
3853,
1006,
1007,
1063,
13075,
3449,
1025,
3449,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
1037,
1011,
9178,
1005,
1007,
1025,
3449,
1012,
2377,
1027,
2023,
1012,
10236,
13068,
1006,
3449,
1012,
2377,
1007,
1025,
3449,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
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... | |
facebook/relay | packages/relay-runtime/util/getRequestParametersIdentifier.js | getRequestParametersIdentifier | function getRequestParametersIdentifier(
parameters: RequestParameters,
variables: Variables,
): Identifier {
const requestID = parameters.id != null ? parameters.id : parameters.text;
invariant(
requestID != null,
'getRequestParametersIdentifier: Expected request `%s` to have either a ' +
'valid `id` or `text` property',
parameters.name,
);
return requestID + JSON.stringify(stableCopy(variables));
} | javascript | function getRequestParametersIdentifier(
parameters: RequestParameters,
variables: Variables,
): Identifier {
const requestID = parameters.id != null ? parameters.id : parameters.text;
invariant(
requestID != null,
'getRequestParametersIdentifier: Expected request `%s` to have either a ' +
'valid `id` or `text` property',
parameters.name,
);
return requestID + JSON.stringify(stableCopy(variables));
} | [
"function",
"getRequestParametersIdentifier",
"(",
"parameters",
":",
"RequestParameters",
",",
"variables",
":",
"Variables",
",",
")",
":",
"Identifier",
"{",
"const",
"requestID",
"=",
"parameters",
".",
"id",
"!=",
"null",
"?",
"parameters",
".",
"id",
":",
... | Returns a stable identifier for the given pair of `RequestParameters` +
variables. | [
"Returns",
"a",
"stable",
"identifier",
"for",
"the",
"given",
"pair",
"of",
"RequestParameters",
"+",
"variables",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/util/getRequestParametersIdentifier.js#L25-L37 | train | Returns an identifier for the parameters | [
30522,
3853,
2131,
2890,
15500,
28689,
22828,
7363,
16778,
8873,
2121,
1006,
11709,
1024,
5227,
28689,
22828,
2015,
1010,
10857,
1024,
10857,
1010,
1007,
1024,
8909,
4765,
18095,
1063,
9530,
3367,
5227,
3593,
1027,
11709,
1012,
8909,
999,
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... |
moment/luxon | src/datetime.js | clone | function clone(inst, alts) {
const current = {
ts: inst.ts,
zone: inst.zone,
c: inst.c,
o: inst.o,
loc: inst.loc,
invalid: inst.invalid
};
return new DateTime(Object.assign({}, current, alts, { old: current }));
} | javascript | function clone(inst, alts) {
const current = {
ts: inst.ts,
zone: inst.zone,
c: inst.c,
o: inst.o,
loc: inst.loc,
invalid: inst.invalid
};
return new DateTime(Object.assign({}, current, alts, { old: current }));
} | [
"function",
"clone",
"(",
"inst",
",",
"alts",
")",
"{",
"const",
"current",
"=",
"{",
"ts",
":",
"inst",
".",
"ts",
",",
"zone",
":",
"inst",
".",
"zone",
",",
"c",
":",
"inst",
".",
"c",
",",
"o",
":",
"inst",
".",
"o",
",",
"loc",
":",
"... | clone really means, "make a new object with these modifications". all "setters" really use this to create a new object while only changing some of the properties | [
"clone",
"really",
"means",
"make",
"a",
"new",
"object",
"with",
"these",
"modifications",
".",
"all",
"setters",
"really",
"use",
"this",
"to",
"create",
"a",
"new",
"object",
"while",
"only",
"changing",
"some",
"of",
"the",
"properties"
] | 236f2badea297ee73421aa39a83e06177c1be6d0 | https://github.com/moment/luxon/blob/236f2badea297ee73421aa39a83e06177c1be6d0/src/datetime.js#L61-L71 | train | Clone an object | [
30522,
3853,
17598,
1006,
16021,
2102,
1010,
12456,
2015,
1007,
1063,
9530,
3367,
2783,
1027,
1063,
24529,
1024,
16021,
2102,
1012,
24529,
1010,
4224,
1024,
16021,
2102,
1012,
4224,
1010,
1039,
1024,
16021,
2102,
1012,
1039,
1010,
1051,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/aws-containers/prompts.js | askTypeOfApplication | function askTypeOfApplication() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'applicationType',
message: 'Which *type* of application would you like to deploy?',
choices: [
{
value: 'monolith',
name: 'Monolithic application'
},
{
value: 'microservice',
name: 'Microservice application'
}
],
default: 'monolith'
}
];
return this.prompt(prompts).then(props => {
const applicationType = props.applicationType;
this.deploymentApplicationType = props.applicationType;
if (applicationType) {
this.log(applicationType);
done();
} else {
this.abort = true;
done();
}
});
} | javascript | function askTypeOfApplication() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'applicationType',
message: 'Which *type* of application would you like to deploy?',
choices: [
{
value: 'monolith',
name: 'Monolithic application'
},
{
value: 'microservice',
name: 'Microservice application'
}
],
default: 'monolith'
}
];
return this.prompt(prompts).then(props => {
const applicationType = props.applicationType;
this.deploymentApplicationType = props.applicationType;
if (applicationType) {
this.log(applicationType);
done();
} else {
this.abort = true;
done();
}
});
} | [
"function",
"askTypeOfApplication",
"(",
")",
"{",
"if",
"(",
"this",
".",
"abort",
")",
"return",
"null",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'list'",
",",
"name",
":",
"... | Ask user what type of application is to be created? | [
"Ask",
"user",
"what",
"type",
"of",
"application",
"is",
"to",
"be",
"created?"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/prompts.js#L116-L150 | train | Ask user what type of application to deploy? | [
30522,
3853,
3198,
13874,
11253,
29098,
19341,
3508,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
11113,
11589,
1007,
2709,
19701,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
25732,
2015,
1027,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | scripts/utopia.js | function(target, event, callback, traditional) {
if(_.type(target) === 'string' || _.type(target) === 'array') {
var elements = _.type(target) === 'string'? $$(target) : target;
elements.forEach(function(element) {
_.event.bind(element, event, callback, traditional);
});
}
else if(_.type(event) === 'string') {
if(traditional) {
target['on' + event] = callback;
}
else {
target.addEventListener(event, callback, false);
}
}
else if(_.type(event) === 'array') {
for (var i=0; i<event.length; i++) {
_.event.bind(target, event[i], callback, arguments[2]);
}
}
else {
for (var name in event) {
_.event.bind(target, name, event[name], arguments[2]);
}
}
} | javascript | function(target, event, callback, traditional) {
if(_.type(target) === 'string' || _.type(target) === 'array') {
var elements = _.type(target) === 'string'? $$(target) : target;
elements.forEach(function(element) {
_.event.bind(element, event, callback, traditional);
});
}
else if(_.type(event) === 'string') {
if(traditional) {
target['on' + event] = callback;
}
else {
target.addEventListener(event, callback, false);
}
}
else if(_.type(event) === 'array') {
for (var i=0; i<event.length; i++) {
_.event.bind(target, event[i], callback, arguments[2]);
}
}
else {
for (var name in event) {
_.event.bind(target, name, event[name], arguments[2]);
}
}
} | [
"function",
"(",
"target",
",",
"event",
",",
"callback",
",",
"traditional",
")",
"{",
"if",
"(",
"_",
".",
"type",
"(",
"target",
")",
"===",
"'string'",
"||",
"_",
".",
"type",
"(",
"target",
")",
"===",
"'array'",
")",
"{",
"var",
"elements",
"... | Binds one or more events to one or more elements | [
"Binds",
"one",
"or",
"more",
"events",
"to",
"one",
"or",
"more",
"elements"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L310-L336 | train | Binds an event listener to an element or array of elements | [
30522,
3853,
1006,
4539,
1010,
2724,
1010,
2655,
5963,
1010,
3151,
1007,
1063,
2065,
1006,
1035,
1012,
2828,
1006,
4539,
1007,
1027,
1027,
1027,
1005,
5164,
1005,
1064,
1064,
1035,
1012,
2828,
1006,
4539,
1007,
1027,
1027,
1027,
1005,
914... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
chartjs/Chart.js | src/helpers/helpers.core.js | function(value, index, defaultValue) {
return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
} | javascript | function(value, index, defaultValue) {
return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
} | [
"function",
"(",
"value",
",",
"index",
",",
"defaultValue",
")",
"{",
"return",
"helpers",
".",
"valueOrDefault",
"(",
"helpers",
".",
"isArray",
"(",
"value",
")",
"?",
"value",
"[",
"index",
"]",
":",
"value",
",",
"defaultValue",
")",
";",
"}"
] | Returns value at the given `index` in array if defined, else returns `defaultValue`.
@param {Array} value - The array to lookup for value at `index`.
@param {number} index - The index in `value` to lookup for value.
@param {*} defaultValue - The value to return if `value[index]` is undefined.
@returns {*} | [
"Returns",
"value",
"at",
"the",
"given",
"index",
"in",
"array",
"if",
"defined",
"else",
"returns",
"defaultValue",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/helpers/helpers.core.js#L87-L89 | train | Returns the value at index in array | [
30522,
3853,
1006,
3643,
1010,
5950,
1010,
12398,
10175,
5657,
1007,
1063,
2709,
2393,
2545,
1012,
3643,
8551,
12879,
23505,
1006,
2393,
2545,
1012,
18061,
11335,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-file.js | loadJSConfigFile | function loadJSConfigFile(filePath) {
debug(`Loading JS config file: ${filePath}`);
try {
return importFresh(filePath);
} catch (e) {
debug(`Error reading JavaScript file: ${filePath}`);
e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
throw e;
}
} | javascript | function loadJSConfigFile(filePath) {
debug(`Loading JS config file: ${filePath}`);
try {
return importFresh(filePath);
} catch (e) {
debug(`Error reading JavaScript file: ${filePath}`);
e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
throw e;
}
} | [
"function",
"loadJSConfigFile",
"(",
"filePath",
")",
"{",
"debug",
"(",
"`",
"${",
"filePath",
"}",
"`",
")",
";",
"try",
"{",
"return",
"importFresh",
"(",
"filePath",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"debug",
"(",
"`",
"${",
"filePath",... | Loads a JavaScript configuration from a file.
@param {string} filePath The filename to load.
@returns {Object} The configuration object from the file.
@throws {Error} If the file cannot be read.
@private | [
"Loads",
"a",
"JavaScript",
"configuration",
"from",
"a",
"file",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-file.js#L154-L163 | train | Load a JS config file | [
30522,
3853,
7170,
22578,
8663,
8873,
25708,
9463,
1006,
5371,
15069,
1007,
1063,
2139,
8569,
2290,
1006,
1036,
10578,
1046,
2015,
9530,
8873,
2290,
5371,
1024,
1002,
1063,
5371,
15069,
1065,
1036,
1007,
1025,
3046,
1063,
2709,
12324,
19699... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/parse/parseGlossary.js | parseGlossary | function parseGlossary(book) {
var logger = book.getLogger();
return parseStructureFile(book, 'glossary')
.spread(function(file, entries) {
if (!file) {
return book;
}
logger.debug.ln('glossary index file found at', file.getPath());
var glossary = Glossary.createFromEntries(file, entries);
return book.set('glossary', glossary);
});
} | javascript | function parseGlossary(book) {
var logger = book.getLogger();
return parseStructureFile(book, 'glossary')
.spread(function(file, entries) {
if (!file) {
return book;
}
logger.debug.ln('glossary index file found at', file.getPath());
var glossary = Glossary.createFromEntries(file, entries);
return book.set('glossary', glossary);
});
} | [
"function",
"parseGlossary",
"(",
"book",
")",
"{",
"var",
"logger",
"=",
"book",
".",
"getLogger",
"(",
")",
";",
"return",
"parseStructureFile",
"(",
"book",
",",
"'glossary'",
")",
".",
"spread",
"(",
"function",
"(",
"file",
",",
"entries",
")",
"{",... | Parse glossary
@param {Book} book
@return {Promise<Book>} | [
"Parse",
"glossary"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseGlossary.js#L10-L24 | train | Parse glossary index file | [
30522,
3853,
11968,
3366,
23296,
21842,
2854,
1006,
2338,
1007,
1063,
13075,
8833,
4590,
1027,
2338,
1012,
2131,
21197,
4590,
1006,
1007,
1025,
2709,
11968,
8583,
18300,
5397,
8873,
2571,
1006,
2338,
1010,
1005,
27068,
5649,
1005,
1007,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( status, text ) {
var prevStatus = statusMap[ this.id ];
typeof text !== 'undefined' && (this.statusText = text);
if ( status !== prevStatus ) {
statusMap[ this.id ] = status;
/**
* 文件状态变化
* @event statuschange
*/
this.trigger( 'statuschange', status, prevStatus );
}
} | javascript | function( status, text ) {
var prevStatus = statusMap[ this.id ];
typeof text !== 'undefined' && (this.statusText = text);
if ( status !== prevStatus ) {
statusMap[ this.id ] = status;
/**
* 文件状态变化
* @event statuschange
*/
this.trigger( 'statuschange', status, prevStatus );
}
} | [
"function",
"(",
"status",
",",
"text",
")",
"{",
"var",
"prevStatus",
"=",
"statusMap",
"[",
"this",
".",
"id",
"]",
";",
"typeof",
"text",
"!==",
"'undefined'",
"&&",
"(",
"this",
".",
"statusText",
"=",
"text",
")",
";",
"if",
"(",
"status",
"!=="... | 设置状态,状态变化时会触发`change`事件。
@method setStatus
@grammar setStatus( status[, statusText] );
@param {File.Status|String} status [文件状态值](#WebUploader:File:File.Status)
@param {String} [statusText=''] 状态说明,常在error时使用,用http, abort,server等来标记是由于什么原因导致文件错误。 | [
"设置状态,状态变化时会触发",
"change",
"事件。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L2053-L2068 | train | set status | [
30522,
3853,
1006,
3570,
1010,
3793,
1007,
1063,
13075,
3653,
15088,
29336,
2271,
1027,
3570,
2863,
2361,
1031,
2023,
1012,
8909,
1033,
1025,
2828,
11253,
3793,
999,
1027,
1027,
1005,
6151,
28344,
1005,
1004,
1004,
1006,
2023,
1012,
3570,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
zloirock/core-js | packages/core-js/internals/object-create.js | function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = documentCreateElement('iframe');
var length = enumBugKeys.length;
var lt = '<';
var script = 'script';
var gt = '>';
var js = 'java' + script + ':';
var iframeDocument;
iframe.style.display = 'none';
html.appendChild(iframe);
iframe.src = String(js);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
return createDict();
} | javascript | function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = documentCreateElement('iframe');
var length = enumBugKeys.length;
var lt = '<';
var script = 'script';
var gt = '>';
var js = 'java' + script + ':';
var iframeDocument;
iframe.style.display = 'none';
html.appendChild(iframe);
iframe.src = String(js);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
return createDict();
} | [
"function",
"(",
")",
"{",
"// Thrash, waste and sodomy: IE GC bug",
"var",
"iframe",
"=",
"documentCreateElement",
"(",
"'iframe'",
")",
";",
"var",
"length",
"=",
"enumBugKeys",
".",
"length",
";",
"var",
"lt",
"=",
"'<'",
";",
"var",
"script",
"=",
"'script... | Create object with fake `null` prototype: use iframe Object with cleared prototype | [
"Create",
"object",
"with",
"fake",
"null",
"prototype",
":",
"use",
"iframe",
"Object",
"with",
"cleared",
"prototype"
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/internals/object-create.js#L12-L31 | train | This function is used to create a new object | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
27042,
1010,
5949,
1998,
2061,
9527,
2100,
1024,
29464,
1043,
2278,
11829,
13075,
2065,
6444,
2063,
1027,
6254,
16748,
3686,
12260,
3672,
1006,
1005,
2065,
6444,
2063,
1005,
1007,
1025,
13075,
3091... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/appVariant/Feature.js | processArray | function processArray(aPromises) {
return aPromises.reduce(function(pacc, fn) {
return pacc.then(fn);
}, Promise.resolve())
.catch(function() {
return Promise.resolve(false);
});
} | javascript | function processArray(aPromises) {
return aPromises.reduce(function(pacc, fn) {
return pacc.then(fn);
}, Promise.resolve())
.catch(function() {
return Promise.resolve(false);
});
} | [
"function",
"processArray",
"(",
"aPromises",
")",
"{",
"return",
"aPromises",
".",
"reduce",
"(",
"function",
"(",
"pacc",
",",
"fn",
")",
"{",
"return",
"pacc",
".",
"then",
"(",
"fn",
")",
";",
"}",
",",
"Promise",
".",
"resolve",
"(",
")",
")",
... | Execute a list of Promises | [
"Execute",
"a",
"list",
"of",
"Promises"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/appVariant/Feature.js#L263-L270 | train | Process an array of promises | [
30522,
3853,
2832,
2906,
9447,
1006,
19804,
20936,
8583,
1007,
1063,
2709,
19804,
20936,
8583,
1012,
5547,
1006,
3853,
1006,
14397,
2278,
1010,
1042,
2078,
1007,
1063,
2709,
14397,
2278,
1012,
2059,
1006,
1042,
2078,
1007,
1025,
1065,
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... |
GitbookIO/gitbook | lib/output/modifiers/inlineAssets.js | inlineAssets | function inlineAssets(rootFolder, currentFile) {
return function($) {
return Promise()
// Resolving images and fetching external images should be
// done before svg conversion
.then(resolveImages.bind(null, currentFile, $))
.then(fetchRemoteImages.bind(null, rootFolder, currentFile, $))
.then(svgToImg.bind(null, rootFolder, currentFile, $))
.then(svgToPng.bind(null, rootFolder, currentFile, $))
.then(inlinePng.bind(null, rootFolder, currentFile, $));
};
} | javascript | function inlineAssets(rootFolder, currentFile) {
return function($) {
return Promise()
// Resolving images and fetching external images should be
// done before svg conversion
.then(resolveImages.bind(null, currentFile, $))
.then(fetchRemoteImages.bind(null, rootFolder, currentFile, $))
.then(svgToImg.bind(null, rootFolder, currentFile, $))
.then(svgToPng.bind(null, rootFolder, currentFile, $))
.then(inlinePng.bind(null, rootFolder, currentFile, $));
};
} | [
"function",
"inlineAssets",
"(",
"rootFolder",
",",
"currentFile",
")",
"{",
"return",
"function",
"(",
"$",
")",
"{",
"return",
"Promise",
"(",
")",
"// Resolving images and fetching external images should be",
"// done before svg conversion",
".",
"then",
"(",
"resolv... | Inline all assets in a page
@param {String} rootFolder | [
"Inline",
"all",
"assets",
"in",
"a",
"page"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/inlineAssets.js#L14-L27 | train | inlineAssets - inline assets | [
30522,
3853,
23881,
27241,
3215,
1006,
7117,
10371,
2121,
1010,
2783,
8873,
2571,
1007,
1063,
2709,
3853,
1006,
1002,
1007,
1063,
2709,
4872,
1006,
1007,
1013,
1013,
29304,
4871,
1998,
18584,
2075,
6327,
4871,
2323,
2022,
1013,
1013,
2589,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | build/tasks/aria-supported.js | getAriaQueryAttributes | function getAriaQueryAttributes() {
const ariaKeys = Array.from(props).map(([key]) => key);
const roleAriaKeys = Array.from(roles).reduce((out, [name, rule]) => {
return [...out, ...Object.keys(rule.props)];
}, []);
return new Set(axe.utils.uniqueArray(roleAriaKeys, ariaKeys));
} | javascript | function getAriaQueryAttributes() {
const ariaKeys = Array.from(props).map(([key]) => key);
const roleAriaKeys = Array.from(roles).reduce((out, [name, rule]) => {
return [...out, ...Object.keys(rule.props)];
}, []);
return new Set(axe.utils.uniqueArray(roleAriaKeys, ariaKeys));
} | [
"function",
"getAriaQueryAttributes",
"(",
")",
"{",
"const",
"ariaKeys",
"=",
"Array",
".",
"from",
"(",
"props",
")",
".",
"map",
"(",
"(",
"[",
"key",
"]",
")",
"=>",
"key",
")",
";",
"const",
"roleAriaKeys",
"=",
"Array",
".",
"from",
"(",
"roles... | Get list of aria attributes, from `aria-query`
@returns {Set|Object} collection of aria attributes from `aria-query` module | [
"Get",
"list",
"of",
"aria",
"attributes",
"from",
"aria",
"-",
"query"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/build/tasks/aria-supported.js#L80-L86 | train | Get the aria query attributes | [
30522,
3853,
2131,
10980,
4226,
20444,
4779,
3089,
8569,
4570,
1006,
1007,
1063,
9530,
3367,
9342,
14839,
2015,
1027,
9140,
1012,
2013,
1006,
24387,
1007,
1012,
4949,
1006,
1006,
1031,
3145,
1033,
1007,
1027,
1028,
3145,
1007,
1025,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Agents/DOMAgent.js | _onChildNodeInserted | function _onChildNodeInserted(event, res) {
// res = {parentNodeId, previousNodeId, node}
if (res.node.nodeId > 0) {
var parent = nodeWithId(res.parentNodeId);
var previousNode = nodeWithId(res.previousNodeId);
var node = new DOMNode(exports, res.node);
parent.insertChildAfter(node, previousNode);
}
} | javascript | function _onChildNodeInserted(event, res) {
// res = {parentNodeId, previousNodeId, node}
if (res.node.nodeId > 0) {
var parent = nodeWithId(res.parentNodeId);
var previousNode = nodeWithId(res.previousNodeId);
var node = new DOMNode(exports, res.node);
parent.insertChildAfter(node, previousNode);
}
} | [
"function",
"_onChildNodeInserted",
"(",
"event",
",",
"res",
")",
"{",
"// res = {parentNodeId, previousNodeId, node}",
"if",
"(",
"res",
".",
"node",
".",
"nodeId",
">",
"0",
")",
"{",
"var",
"parent",
"=",
"nodeWithId",
"(",
"res",
".",
"parentNodeId",
")",... | WebInspector Event: DOM.childNodeInserted | [
"WebInspector",
"Event",
":",
"DOM",
".",
"childNodeInserted"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L227-L235 | train | onChildNodeInserted - Inserts a child node after a previous node | [
30522,
3853,
1035,
2006,
19339,
3630,
3207,
7076,
28728,
1006,
2724,
1010,
24501,
1007,
1063,
1013,
1013,
24501,
1027,
1063,
6687,
3630,
3207,
3593,
1010,
3025,
3630,
3207,
3593,
1010,
13045,
1065,
2065,
1006,
24501,
1012,
13045,
1012,
1304... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/DragAndDrop.js | attachHandlers | function attachHandlers() {
function handleDragOver(event) {
event = event.originalEvent || event;
var files = event.dataTransfer.files;
stopURIListPropagation(files, event);
if (files && files.length) {
event.stopPropagation();
event.preventDefault();
var dropEffect = "none";
// Don't allow drag-and-drop of files/folders when a modal dialog is showing.
if ($(".modal.instance").length === 0 && isValidDrop(event.dataTransfer.items)) {
dropEffect = "copy";
}
event.dataTransfer.dropEffect = dropEffect;
}
}
function handleDrop(event) {
event = event.originalEvent || event;
var files = event.dataTransfer.files;
stopURIListPropagation(files, event);
if (files && files.length) {
event.stopPropagation();
event.preventDefault();
brackets.app.getDroppedFiles(function (err, paths) {
if (!err) {
openDroppedFiles(paths);
}
});
}
}
// For most of the window, only respond if nothing more specific in the UI has already grabbed the event (e.g.
// the Extension Manager drop-to-install zone, or an extension with a drop-to-upload zone in its panel)
$(window.document.body)
.on("dragover", handleDragOver)
.on("drop", handleDrop);
// Over CodeMirror specifically, always pre-empt CodeMirror's drag event handling if files are being dragged - CM stops
// propagation on any drag event it sees, even when it's not a text drag/drop. But allow CM to handle all non-file drag
// events. See bug #10617.
window.document.body.addEventListener("dragover", function (event) {
if ($(event.target).closest(".CodeMirror").length) {
handleDragOver(event);
}
}, true);
window.document.body.addEventListener("drop", function (event) {
if ($(event.target).closest(".CodeMirror").length) {
handleDrop(event);
}
}, true);
} | javascript | function attachHandlers() {
function handleDragOver(event) {
event = event.originalEvent || event;
var files = event.dataTransfer.files;
stopURIListPropagation(files, event);
if (files && files.length) {
event.stopPropagation();
event.preventDefault();
var dropEffect = "none";
// Don't allow drag-and-drop of files/folders when a modal dialog is showing.
if ($(".modal.instance").length === 0 && isValidDrop(event.dataTransfer.items)) {
dropEffect = "copy";
}
event.dataTransfer.dropEffect = dropEffect;
}
}
function handleDrop(event) {
event = event.originalEvent || event;
var files = event.dataTransfer.files;
stopURIListPropagation(files, event);
if (files && files.length) {
event.stopPropagation();
event.preventDefault();
brackets.app.getDroppedFiles(function (err, paths) {
if (!err) {
openDroppedFiles(paths);
}
});
}
}
// For most of the window, only respond if nothing more specific in the UI has already grabbed the event (e.g.
// the Extension Manager drop-to-install zone, or an extension with a drop-to-upload zone in its panel)
$(window.document.body)
.on("dragover", handleDragOver)
.on("drop", handleDrop);
// Over CodeMirror specifically, always pre-empt CodeMirror's drag event handling if files are being dragged - CM stops
// propagation on any drag event it sees, even when it's not a text drag/drop. But allow CM to handle all non-file drag
// events. See bug #10617.
window.document.body.addEventListener("dragover", function (event) {
if ($(event.target).closest(".CodeMirror").length) {
handleDragOver(event);
}
}, true);
window.document.body.addEventListener("drop", function (event) {
if ($(event.target).closest(".CodeMirror").length) {
handleDrop(event);
}
}, true);
} | [
"function",
"attachHandlers",
"(",
")",
"{",
"function",
"handleDragOver",
"(",
"event",
")",
"{",
"event",
"=",
"event",
".",
"originalEvent",
"||",
"event",
";",
"var",
"files",
"=",
"event",
".",
"dataTransfer",
".",
"files",
";",
"stopURIListPropagation",
... | Attaches global drag & drop handlers to this window. This enables dropping files/folders to open them, and also
protects the Brackets app from being replaced by the browser trying to load the dropped file in its place. | [
"Attaches",
"global",
"drag",
"&",
"drop",
"handlers",
"to",
"this",
"window",
".",
"This",
"enables",
"dropping",
"files",
"/",
"folders",
"to",
"open",
"them",
"and",
"also",
"protects",
"the",
"Brackets",
"app",
"from",
"being",
"replaced",
"by",
"the",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DragAndDrop.js#L178-L239 | train | Attach event handlers to the window | [
30522,
3853,
22476,
11774,
12910,
1006,
1007,
1063,
3853,
8971,
29181,
7840,
1006,
2724,
1007,
1063,
2724,
1027,
2724,
1012,
2434,
18697,
3372,
1064,
1064,
2724,
1025,
13075,
6764,
1027,
2724,
1012,
2951,
6494,
3619,
7512,
1012,
6764,
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... |
heyui/heyui | src/plugins/popper/index.js | setupEventListeners | function setupEventListeners(reference, options, state, updateBound) {
// Resize event listener on window
state.updateBound = updateBound;
getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
// Scroll event listener on scroll parents
var scrollElement = getScrollParent(reference);
attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
state.scrollElement = scrollElement;
state.eventsEnabled = true;
return state;
} | javascript | function setupEventListeners(reference, options, state, updateBound) {
// Resize event listener on window
state.updateBound = updateBound;
getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
// Scroll event listener on scroll parents
var scrollElement = getScrollParent(reference);
attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
state.scrollElement = scrollElement;
state.eventsEnabled = true;
return state;
} | [
"function",
"setupEventListeners",
"(",
"reference",
",",
"options",
",",
"state",
",",
"updateBound",
")",
"{",
"// Resize event listener on window",
"state",
".",
"updateBound",
"=",
"updateBound",
";",
"getWindow",
"(",
"reference",
")",
".",
"addEventListener",
... | Setup needed event listeners used to update the popper position
@method
@memberof Popper.Utils
@private | [
"Setup",
"needed",
"event",
"listeners",
"used",
"to",
"update",
"the",
"popper",
"position"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1089-L1101 | train | Setup event listeners on the window and scroll parents | [
30522,
3853,
16437,
18697,
3372,
9863,
24454,
2015,
1006,
4431,
1010,
7047,
1010,
2110,
1010,
10651,
15494,
1007,
1063,
1013,
1013,
24501,
4697,
2724,
19373,
2006,
30524,
1007,
1025,
1013,
1013,
17186,
2724,
19373,
2006,
17186,
3008,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/service/ControllerExtension.js | function(sViewId) {
var oViewOverlay = OverlayRegistry.getOverlay(sViewId);
if (!oViewOverlay) {
throw DtUtil.createError("service.ControllerExtension#getTemplate", "no overlay found for the given view ID", "sap.ui.rta");
}
var sControllerExtensionTemplatePath = oViewOverlay.getDesignTimeMetadata().getControllerExtensionTemplate();
return makeAjaxCall(sControllerExtensionTemplatePath + "-dbg")
.catch(function() {
return makeAjaxCall(sControllerExtensionTemplatePath);
});
} | javascript | function(sViewId) {
var oViewOverlay = OverlayRegistry.getOverlay(sViewId);
if (!oViewOverlay) {
throw DtUtil.createError("service.ControllerExtension#getTemplate", "no overlay found for the given view ID", "sap.ui.rta");
}
var sControllerExtensionTemplatePath = oViewOverlay.getDesignTimeMetadata().getControllerExtensionTemplate();
return makeAjaxCall(sControllerExtensionTemplatePath + "-dbg")
.catch(function() {
return makeAjaxCall(sControllerExtensionTemplatePath);
});
} | [
"function",
"(",
"sViewId",
")",
"{",
"var",
"oViewOverlay",
"=",
"OverlayRegistry",
".",
"getOverlay",
"(",
"sViewId",
")",
";",
"if",
"(",
"!",
"oViewOverlay",
")",
"{",
"throw",
"DtUtil",
".",
"createError",
"(",
"\"service.ControllerExtension#getTemplate\"",
... | Gets the Controller Extension template from the DesignTimeMetadata of the given view and returns it as a string wrapped in a promise.
If there is no template specified, a default template will be returned.
@method sap.ui.rta.service.ControllerExtension.getTemplate
@param {string} sViewId ID of the view whose template should be retrieved
@return {Promise} Returns a promise that resolves with the template as string or rejects when the file was not found
@public | [
"Gets",
"the",
"Controller",
"Extension",
"template",
"from",
"the",
"DesignTimeMetadata",
"of",
"the",
"given",
"view",
"and",
"returns",
"it",
"as",
"a",
"string",
"wrapped",
"in",
"a",
"promise",
".",
"If",
"there",
"is",
"no",
"template",
"specified",
"a... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/service/ControllerExtension.js#L115-L126 | train | Returns the template for the given view | [
30522,
3853,
1006,
17917,
2666,
9148,
2094,
1007,
1063,
13075,
1051,
8584,
7840,
8485,
1027,
2058,
8485,
2890,
24063,
2854,
1012,
2131,
7840,
8485,
1006,
17917,
2666,
9148,
2094,
1007,
1025,
2065,
1006,
999,
1051,
8584,
7840,
8485,
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... | |
eslint/eslint | lib/rules/no-useless-return.js | isInFinally | function isInFinally(node) {
for (
let currentNode = node;
currentNode && currentNode.parent && !astUtils.isFunction(currentNode);
currentNode = currentNode.parent
) {
if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
return true;
}
}
return false;
} | javascript | function isInFinally(node) {
for (
let currentNode = node;
currentNode && currentNode.parent && !astUtils.isFunction(currentNode);
currentNode = currentNode.parent
) {
if (currentNode.parent.type === "TryStatement" && currentNode.parent.finalizer === currentNode) {
return true;
}
}
return false;
} | [
"function",
"isInFinally",
"(",
"node",
")",
"{",
"for",
"(",
"let",
"currentNode",
"=",
"node",
";",
"currentNode",
"&&",
"currentNode",
".",
"parent",
"&&",
"!",
"astUtils",
".",
"isFunction",
"(",
"currentNode",
")",
";",
"currentNode",
"=",
"currentNode"... | Checks whether the given return statement is in a `finally` block or not.
@param {ASTNode} node - The return statement node to check.
@returns {boolean} `true` if the node is in a `finally` block. | [
"Checks",
"whether",
"the",
"given",
"return",
"statement",
"is",
"in",
"a",
"finally",
"block",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-return.js#L49-L61 | train | Check if the given node is in a finally block | [
30522,
3853,
2003,
2378,
16294,
3973,
1006,
13045,
1007,
1063,
2005,
1006,
2292,
2783,
3630,
3207,
1027,
13045,
1025,
2783,
3630,
3207,
1004,
1004,
2783,
3630,
3207,
1012,
6687,
1004,
1004,
999,
2004,
8525,
3775,
4877,
1012,
2003,
11263,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_vertical/vertical_extensions.js | function(menuOptions) {
// Add the edit option at the end.
menuOptions.push(Blockly.Procedures.makeEditOption(this));
// Find the delete option and update its callback to be specific to
// functions.
for (var i = 0, option; option = menuOptions[i]; i++) {
if (option.text == Blockly.Msg.DELETE_BLOCK) {
var input = this.getInput('custom_block');
// this is the root block, not the shadow block.
if (input && input.connection && input.connection.targetBlock()) {
var procCode = input.connection.targetBlock().getProcCode();
} else {
return;
}
var rootBlock = this;
option.callback = function() {
var didDelete = Blockly.Procedures.deleteProcedureDefCallback(
procCode, rootBlock);
if (!didDelete) {
// TODO:(#1151)
alert('To delete a block definition, first remove all uses of the block');
}
};
}
}
// Find and remove the duplicate option
for (var i = 0, option; option = menuOptions[i]; i++) {
if (option.text == Blockly.Msg.DUPLICATE) {
menuOptions.splice(i, 1);
break;
}
}
} | javascript | function(menuOptions) {
// Add the edit option at the end.
menuOptions.push(Blockly.Procedures.makeEditOption(this));
// Find the delete option and update its callback to be specific to
// functions.
for (var i = 0, option; option = menuOptions[i]; i++) {
if (option.text == Blockly.Msg.DELETE_BLOCK) {
var input = this.getInput('custom_block');
// this is the root block, not the shadow block.
if (input && input.connection && input.connection.targetBlock()) {
var procCode = input.connection.targetBlock().getProcCode();
} else {
return;
}
var rootBlock = this;
option.callback = function() {
var didDelete = Blockly.Procedures.deleteProcedureDefCallback(
procCode, rootBlock);
if (!didDelete) {
// TODO:(#1151)
alert('To delete a block definition, first remove all uses of the block');
}
};
}
}
// Find and remove the duplicate option
for (var i = 0, option; option = menuOptions[i]; i++) {
if (option.text == Blockly.Msg.DUPLICATE) {
menuOptions.splice(i, 1);
break;
}
}
} | [
"function",
"(",
"menuOptions",
")",
"{",
"// Add the edit option at the end.",
"menuOptions",
".",
"push",
"(",
"Blockly",
".",
"Procedures",
".",
"makeEditOption",
"(",
"this",
")",
")",
";",
"// Find the delete option and update its callback to be specific to",
"// funct... | Add the "edit" option and removes the "duplicate" option from the context
menu.
@param {!Array.<!Object>} menuOptions List of menu options to edit.
@this Blockly.Block | [
"Add",
"the",
"edit",
"option",
"and",
"removes",
"the",
"duplicate",
"option",
"from",
"the",
"context",
"menu",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/vertical_extensions.js#L159-L192 | train | Add the edit option to the menu. | [
30522,
3853,
1006,
12183,
7361,
9285,
1007,
1063,
1013,
1013,
5587,
1996,
10086,
5724,
2012,
1996,
2203,
1012,
12183,
7361,
9285,
1012,
5245,
1006,
3796,
2135,
1012,
8853,
1012,
2191,
2098,
9956,
16790,
1006,
2023,
1007,
1007,
1025,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/tabs/js/tabsController.js | canPageForward | function canPageForward () {
var elements = getElements();
var lastTab = elements.tabs[ elements.tabs.length - 1 ];
if (isRtl()) {
return ctrl.offsetLeft < elements.paging.offsetWidth - elements.canvas.offsetWidth;
}
return lastTab && lastTab.offsetLeft + lastTab.offsetWidth > elements.canvas.clientWidth +
ctrl.offsetLeft;
} | javascript | function canPageForward () {
var elements = getElements();
var lastTab = elements.tabs[ elements.tabs.length - 1 ];
if (isRtl()) {
return ctrl.offsetLeft < elements.paging.offsetWidth - elements.canvas.offsetWidth;
}
return lastTab && lastTab.offsetLeft + lastTab.offsetWidth > elements.canvas.clientWidth +
ctrl.offsetLeft;
} | [
"function",
"canPageForward",
"(",
")",
"{",
"var",
"elements",
"=",
"getElements",
"(",
")",
";",
"var",
"lastTab",
"=",
"elements",
".",
"tabs",
"[",
"elements",
".",
"tabs",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"isRtl",
"(",
")",
")",
"... | Determines whether or not the right pagination arrow should be enabled.
@returns {*|boolean} | [
"Determines",
"whether",
"or",
"not",
"the",
"right",
"pagination",
"arrow",
"should",
"be",
"enabled",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L521-L531 | train | Check if the current page can be forward | [
30522,
3853,
2064,
13704,
29278,
7652,
1006,
1007,
1063,
13075,
3787,
1027,
2131,
12260,
8163,
1006,
1007,
1025,
13075,
2197,
2696,
2497,
1027,
3787,
1012,
21628,
2015,
1031,
3787,
1012,
21628,
2015,
1012,
3091,
1011,
1015,
1033,
1025,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _configureEditorAndResolve | function _configureEditorAndResolve() {
var editor = EditorManager.getActiveEditor();
if (editor) {
if (settings) {
editor.setSelections(settings.selections);
editor.setScrollPos(settings.scrollPos.x, settings.scrollPos.y);
}
}
result.resolve(newFile);
} | javascript | function _configureEditorAndResolve() {
var editor = EditorManager.getActiveEditor();
if (editor) {
if (settings) {
editor.setSelections(settings.selections);
editor.setScrollPos(settings.scrollPos.x, settings.scrollPos.y);
}
}
result.resolve(newFile);
} | [
"function",
"_configureEditorAndResolve",
"(",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
"(",
"editor",
")",
"{",
"if",
"(",
"settings",
")",
"{",
"editor",
".",
"setSelections",
"(",
"settings",
".",
"se... | Reconstruct old doc's editor's view state, & finally resolve overall promise | [
"Reconstruct",
"old",
"doc",
"s",
"editor",
"s",
"view",
"state",
"&",
"finally",
"resolve",
"overall",
"promise"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L902-L911 | train | Configure editor and resolve promise | [
30522,
3853,
1035,
9530,
8873,
27390,
13089,
15660,
5685,
6072,
4747,
3726,
1006,
1007,
1063,
13075,
3559,
1027,
3559,
24805,
4590,
1012,
2131,
19620,
2098,
15660,
1006,
1007,
1025,
2065,
1006,
3559,
1007,
1063,
2065,
1006,
10906,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/chips/demoContactChips/script.js | createFilterFor | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(contact) {
return (contact._lowername.indexOf(lowercaseQuery) !== -1);
};
} | javascript | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(contact) {
return (contact._lowername.indexOf(lowercaseQuery) !== -1);
};
} | [
"function",
"createFilterFor",
"(",
"query",
")",
"{",
"var",
"lowercaseQuery",
"=",
"query",
".",
"toLowerCase",
"(",
")",
";",
"return",
"function",
"filterFn",
"(",
"contact",
")",
"{",
"return",
"(",
"contact",
".",
"_lowername",
".",
"indexOf",
"(",
"... | Create filter function for a query string | [
"Create",
"filter",
"function",
"for",
"a",
"query",
"string"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/demoContactChips/script.js#L79-L86 | train | Create a filter function for a given query | [
30522,
3853,
3443,
8873,
21928,
29278,
1006,
23032,
1007,
1063,
13075,
2896,
18382,
4226,
2854,
1027,
23032,
1012,
2000,
27663,
18992,
3366,
1006,
1007,
1025,
2709,
3853,
11307,
2546,
2078,
1006,
3967,
1007,
1063,
2709,
1006,
3967,
1012,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | tracing/third_party/oboe/src/lists.js | map | function map(fn, list) {
return list
? cons(fn(head(list)), map(fn,tail(list)))
: emptyList
;
} | javascript | function map(fn, list) {
return list
? cons(fn(head(list)), map(fn,tail(list)))
: emptyList
;
} | [
"function",
"map",
"(",
"fn",
",",
"list",
")",
"{",
"return",
"list",
"?",
"cons",
"(",
"fn",
"(",
"head",
"(",
"list",
")",
")",
",",
"map",
"(",
"fn",
",",
"tail",
"(",
"list",
")",
")",
")",
":",
"emptyList",
";",
"}"
] | Map a function over a list | [
"Map",
"a",
"function",
"over",
"a",
"list"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/lists.js#L89-L95 | train | Map a function to a list of items | [
30522,
3853,
4949,
1006,
1042,
2078,
1010,
2862,
1007,
1063,
2709,
2862,
1029,
9530,
2015,
1006,
1042,
2078,
1006,
2132,
1006,
2862,
1007,
1007,
1010,
4949,
1006,
1042,
2078,
1010,
5725,
1006,
2862,
1007,
1007,
1007,
1024,
4064,
9863,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/tabs.js | tabBrowser_openInNewTab | function tabBrowser_openInNewTab(aEvent) {
var event = aEvent || { };
var type = (event.type == undefined) ? "middleClick" : event.type;
// Disable tab closing animation for default behavior
prefs.preferences.setPref(PREF_TABS_ANIMATE, false);
// Add event listener to wait until the tab has been opened
var self = { opened: false };
function checkTabOpened() { self.opened = true; }
this._controller.window.addEventListener("TabOpen", checkTabOpened, false);
switch (type) {
case "contextMenu":
var contextMenuItem = new elementslib.ID(this._controller.window.document,
"context-openlinkintab");
this._controller.rightClick(event.target);
this._controller.click(contextMenuItem);
utils.closeContentAreaContextMenu(this._controller);
break;
case "middleClick":
this._controller.middleClick(event.target);
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " + type);
}
try {
this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
{tab: self});
} finally {
this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
}
} | javascript | function tabBrowser_openInNewTab(aEvent) {
var event = aEvent || { };
var type = (event.type == undefined) ? "middleClick" : event.type;
// Disable tab closing animation for default behavior
prefs.preferences.setPref(PREF_TABS_ANIMATE, false);
// Add event listener to wait until the tab has been opened
var self = { opened: false };
function checkTabOpened() { self.opened = true; }
this._controller.window.addEventListener("TabOpen", checkTabOpened, false);
switch (type) {
case "contextMenu":
var contextMenuItem = new elementslib.ID(this._controller.window.document,
"context-openlinkintab");
this._controller.rightClick(event.target);
this._controller.click(contextMenuItem);
utils.closeContentAreaContextMenu(this._controller);
break;
case "middleClick":
this._controller.middleClick(event.target);
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " + type);
}
try {
this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
{tab: self});
} finally {
this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
}
} | [
"function",
"tabBrowser_openInNewTab",
"(",
"aEvent",
")",
"{",
"var",
"event",
"=",
"aEvent",
"||",
"{",
"}",
";",
"var",
"type",
"=",
"(",
"event",
".",
"type",
"==",
"undefined",
")",
"?",
"\"middleClick\"",
":",
"event",
".",
"type",
";",
"// Disable... | Open element (link) in a new tab
@param {object} aEvent
The event specifies how to open the element in a new tab
Elements: type - Type of event (contextMenu, middleClick)
[optional - default: middleClick] | [
"Open",
"element",
"(",
"link",
")",
"in",
"a",
"new",
"tab"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabs.js#L372-L406 | train | Open in new tab | [
30522,
3853,
21628,
12618,
9333,
2121,
1035,
2330,
23111,
7974,
2696,
2497,
1006,
29347,
15338,
1007,
1063,
13075,
2724,
1027,
29347,
15338,
1064,
1064,
1063,
1065,
1025,
13075,
2828,
1027,
1006,
2724,
1012,
2828,
1027,
1027,
6151,
28344,
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/prefer-rest-params.js | isNotNormalMemberAccess | function isNotNormalMemberAccess(reference) {
const id = reference.identifier;
const parent = id.parent;
return !(
parent.type === "MemberExpression" &&
parent.object === id &&
!parent.computed
);
} | javascript | function isNotNormalMemberAccess(reference) {
const id = reference.identifier;
const parent = id.parent;
return !(
parent.type === "MemberExpression" &&
parent.object === id &&
!parent.computed
);
} | [
"function",
"isNotNormalMemberAccess",
"(",
"reference",
")",
"{",
"const",
"id",
"=",
"reference",
".",
"identifier",
";",
"const",
"parent",
"=",
"id",
".",
"parent",
";",
"return",
"!",
"(",
"parent",
".",
"type",
"===",
"\"MemberExpression\"",
"&&",
"par... | Checks if the given reference is not normal member access.
- arguments .... true // not member access
- arguments[i] .... true // computed member access
- arguments[0] .... true // computed member access
- arguments.length .... false // normal member access
@param {eslint-scope.Reference} reference - The reference to check.
@returns {boolean} `true` if the reference is not normal member access. | [
"Checks",
"if",
"the",
"given",
"reference",
"is",
"not",
"normal",
"member",
"access",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-rest-params.js#L48-L57 | train | Check if a reference is not a normal member access | [
30522,
3853,
3475,
4140,
12131,
9067,
4168,
21784,
6305,
9623,
2015,
1006,
4431,
1007,
1063,
9530,
3367,
8909,
1027,
4431,
1012,
8909,
4765,
18095,
1025,
9530,
3367,
6687,
1027,
8909,
1012,
6687,
1025,
2709,
999,
1006,
6687,
1012,
2828,
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... |
angular/material | src/components/dialog/dialog.js | MdDialogController | function MdDialogController($mdDialog, $mdConstant) {
// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in
// interimElements. The $mdCompiler simulates the $onInit hook for all versions.
this.$onInit = function() {
var isPrompt = this.$type == 'prompt';
if (isPrompt && this.initialValue) {
this.result = this.initialValue;
}
this.hide = function() {
$mdDialog.hide(isPrompt ? this.result : true);
};
this.abort = function() {
$mdDialog.cancel();
};
this.keypress = function($event) {
var invalidPrompt = isPrompt && this.required && !angular.isDefined(this.result);
if ($event.keyCode === $mdConstant.KEY_CODE.ENTER && !invalidPrompt) {
$mdDialog.hide(this.result);
}
};
};
} | javascript | function MdDialogController($mdDialog, $mdConstant) {
// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in
// interimElements. The $mdCompiler simulates the $onInit hook for all versions.
this.$onInit = function() {
var isPrompt = this.$type == 'prompt';
if (isPrompt && this.initialValue) {
this.result = this.initialValue;
}
this.hide = function() {
$mdDialog.hide(isPrompt ? this.result : true);
};
this.abort = function() {
$mdDialog.cancel();
};
this.keypress = function($event) {
var invalidPrompt = isPrompt && this.required && !angular.isDefined(this.result);
if ($event.keyCode === $mdConstant.KEY_CODE.ENTER && !invalidPrompt) {
$mdDialog.hide(this.result);
}
};
};
} | [
"function",
"MdDialogController",
"(",
"$mdDialog",
",",
"$mdConstant",
")",
"{",
"// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in",
"// interimElements. The $mdCompiler simulates the $onInit hook for all versions.",
"this",
".",
"$onInit",
"=",
"functi... | Controller for the md-dialog interim elements
@ngInject | [
"Controller",
"for",
"the",
"md",
"-",
"dialog",
"interim",
"elements"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L647-L671 | train | Controller for the md - dialog - controller. | [
30522,
3853,
9108,
27184,
8649,
8663,
13181,
10820,
1006,
1002,
9108,
27184,
8649,
1010,
1002,
9108,
8663,
12693,
2102,
1007,
1063,
1013,
1013,
2005,
21778,
2007,
16108,
22578,
1015,
1012,
1020,
1009,
1010,
2057,
2323,
2467,
2224,
1996,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | dist/js/materialize.js | destroy | function destroy() {
this._removeEventHandlers();
this.el.M_Materialbox = undefined;
// Unwrap image
$(this.placeholder).after(this.el).remove();
this.$el.removeAttr('style');
} | javascript | function destroy() {
this._removeEventHandlers();
this.el.M_Materialbox = undefined;
// Unwrap image
$(this.placeholder).after(this.el).remove();
this.$el.removeAttr('style');
} | [
"function",
"destroy",
"(",
")",
"{",
"this",
".",
"_removeEventHandlers",
"(",
")",
";",
"this",
".",
"el",
".",
"M_Materialbox",
"=",
"undefined",
";",
"// Unwrap image",
"$",
"(",
"this",
".",
"placeholder",
")",
".",
"after",
"(",
"this",
".",
"el",
... | Teardown component | [
"Teardown",
"component"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3369-L3377 | train | Destroys the materialbox | [
30522,
3853,
6033,
1006,
1007,
1063,
2023,
1012,
1035,
6366,
18697,
3372,
11774,
12910,
1006,
1007,
1025,
2023,
1012,
3449,
1012,
1049,
1035,
3430,
8758,
1027,
6151,
28344,
1025,
1013,
1013,
4895,
13088,
9331,
3746,
1002,
1006,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(elems)
{
// Known block elements for handling linefeeds (list is not complete)
var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
var ret = [];
function doExtract(elts)
{
// Single break should be ignored
if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
elts[0].innerHTML == '\n'))
{
return;
}
for (var i = 0; i < elts.length; i++)
{
var elem = elts[i];
// DIV with a br or linefeed forces a linefeed
if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
elem.innerHTML.toLowerCase() == '<br>')))
{
ret.push('\n');
}
else
{
if (elem.nodeType === 3 || elem.nodeType === 4)
{
if (elem.nodeValue.length > 0)
{
ret.push(elem.nodeValue);
}
}
else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
{
doExtract(elem.childNodes);
}
if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
{
ret.push('\n');
}
}
}
};
doExtract(elems);
return ret.join('');
} | javascript | function(elems)
{
// Known block elements for handling linefeeds (list is not complete)
var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
var ret = [];
function doExtract(elts)
{
// Single break should be ignored
if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
elts[0].innerHTML == '\n'))
{
return;
}
for (var i = 0; i < elts.length; i++)
{
var elem = elts[i];
// DIV with a br or linefeed forces a linefeed
if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
elem.innerHTML.toLowerCase() == '<br>')))
{
ret.push('\n');
}
else
{
if (elem.nodeType === 3 || elem.nodeType === 4)
{
if (elem.nodeValue.length > 0)
{
ret.push(elem.nodeValue);
}
}
else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
{
doExtract(elem.childNodes);
}
if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
{
ret.push('\n');
}
}
}
};
doExtract(elems);
return ret.join('');
} | [
"function",
"(",
"elems",
")",
"{",
"// Known block elements for handling linefeeds (list is not complete)",
"var",
"blocks",
"=",
"[",
"'BLOCKQUOTE'",
",",
"'DIV'",
",",
"'H1'",
",",
"'H2'",
",",
"'H3'",
",",
"'H4'",
",",
"'H5'",
",",
"'H6'",
",",
"'OL'",
",",
... | Function: extractTextWithWhitespace
Returns the text content of the specified node.
Parameters:
elems - DOM nodes to return the text for. | [
"Function",
":",
"extractTextWithWhitespace"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3006-L3057 | train | Returns an array of elements that are not part of a block | [
30522,
3853,
1006,
3449,
6633,
2015,
1007,
1063,
1013,
1013,
2124,
3796,
3787,
2005,
8304,
2240,
7959,
2098,
2015,
1006,
2862,
2003,
2025,
3143,
1007,
13075,
5991,
1027,
1031,
1005,
3796,
28940,
12184,
1005,
1010,
1005,
4487,
2615,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Controls.controller.js | function(oEvent) {
var sFilter = oEvent.oSource.getFilter(),
oSearchField = this.getOwnerComponent().byId("controlsMaster").byId("searchField");
// Apply the value and fire a live change event so the list will be filtered
oSearchField.setValue(sFilter).fireLiveChange({
newValue: sFilter
});
// Show master page: this call will show the master page only on small screen sizes but not on phone
setTimeout(function () {
this.getSplitApp().showMaster();
}.bind(this), 0);
} | javascript | function(oEvent) {
var sFilter = oEvent.oSource.getFilter(),
oSearchField = this.getOwnerComponent().byId("controlsMaster").byId("searchField");
// Apply the value and fire a live change event so the list will be filtered
oSearchField.setValue(sFilter).fireLiveChange({
newValue: sFilter
});
// Show master page: this call will show the master page only on small screen sizes but not on phone
setTimeout(function () {
this.getSplitApp().showMaster();
}.bind(this), 0);
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"sFilter",
"=",
"oEvent",
".",
"oSource",
".",
"getFilter",
"(",
")",
",",
"oSearchField",
"=",
"this",
".",
"getOwnerComponent",
"(",
")",
".",
"byId",
"(",
"\"controlsMaster\"",
")",
".",
"byId",
"(",
"\"sear... | Filter for controls in the master search field when the title of a control section was pressed | [
"Filter",
"for",
"controls",
"in",
"the",
"master",
"search",
"field",
"when",
"the",
"title",
"of",
"a",
"control",
"section",
"was",
"pressed"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Controls.controller.js#L51-L63 | train | Filter the list | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
16420,
4014,
3334,
1027,
1051,
18697,
3372,
1012,
9808,
8162,
3401,
1012,
2131,
8873,
21928,
1006,
1007,
1010,
9808,
14644,
22693,
1027,
2023,
1012,
2131,
12384,
2121,
9006,
29513,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/preferences/PreferencesBase.js | function (layer) {
this._layers.push(layer);
this._layerMap[layer.key] = layer;
this._exclusions.push(layer.key);
this.trigger(PREFERENCE_CHANGE, {
ids: layer.getKeys(this.data[layer.key], {})
});
} | javascript | function (layer) {
this._layers.push(layer);
this._layerMap[layer.key] = layer;
this._exclusions.push(layer.key);
this.trigger(PREFERENCE_CHANGE, {
ids: layer.getKeys(this.data[layer.key], {})
});
} | [
"function",
"(",
"layer",
")",
"{",
"this",
".",
"_layers",
".",
"push",
"(",
"layer",
")",
";",
"this",
".",
"_layerMap",
"[",
"layer",
".",
"key",
"]",
"=",
"layer",
";",
"this",
".",
"_exclusions",
".",
"push",
"(",
"layer",
".",
"key",
")",
"... | Adds a Layer to this Scope. The Layer object should define a `key`, which
represents the subset of the preference data that the Layer works with.
Layers should also define `get` and `getKeys` operations that are like their
counterparts in Scope but take "data" as the first argument.
Listeners are notified of potential changes in preferences with the addition of
this layer.
@param {Layer} layer Layer object to add to this Scope | [
"Adds",
"a",
"Layer",
"to",
"this",
"Scope",
".",
"The",
"Layer",
"object",
"should",
"define",
"a",
"key",
"which",
"represents",
"the",
"subset",
"of",
"the",
"preference",
"data",
"that",
"the",
"Layer",
"works",
"with",
".",
"Layers",
"should",
"also",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L514-L521 | train | add layer to the list of layers | [
30522,
3853,
1006,
6741,
1007,
1063,
2023,
1012,
1035,
9014,
1012,
5245,
1006,
6741,
1007,
1025,
2023,
1012,
1035,
6741,
2863,
2361,
1031,
6741,
1012,
3145,
1033,
1027,
6741,
1025,
2023,
1012,
1035,
15945,
2015,
1012,
5245,
1006,
6741,
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... | |
google/closure-library | doc/js/article.js | function(prefix, string) {
return string.substring(0, prefix.length) == prefix ?
string.substring(prefix.length) :
'';
} | javascript | function(prefix, string) {
return string.substring(0, prefix.length) == prefix ?
string.substring(prefix.length) :
'';
} | [
"function",
"(",
"prefix",
",",
"string",
")",
"{",
"return",
"string",
".",
"substring",
"(",
"0",
",",
"prefix",
".",
"length",
")",
"==",
"prefix",
"?",
"string",
".",
"substring",
"(",
"prefix",
".",
"length",
")",
":",
"''",
";",
"}"
] | Checks for a prefix, returns everything after it if it exists | [
"Checks",
"for",
"a",
"prefix",
"returns",
"everything",
"after",
"it",
"if",
"it",
"exists"
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/doc/js/article.js#L292-L296 | train | Returns the phrase of the given phrase | [
30522,
3853,
1006,
17576,
1010,
5164,
1007,
1063,
2709,
5164,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
17576,
1012,
3091,
1007,
1027,
1027,
17576,
1029,
5164,
1012,
4942,
3367,
4892,
1006,
17576,
1012,
3091,
1007,
1024,
1005,
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/JavaScriptCodeHints/main.js | handleActiveEditorChange | function handleActiveEditorChange(event, current, previous) {
// Uninstall "languageChanged" event listeners on previous editor's document & put them on current editor's doc
if (previous) {
previous.document
.off(HintUtils.eventName("languageChanged"));
}
if (current) {
current.document
.on(HintUtils.eventName("languageChanged"), function () {
// If current doc's language changed, reset our state by treating it as if the user switched to a
// different document altogether
uninstallEditorListeners(current);
installEditorListeners(current);
});
}
uninstallEditorListeners(previous);
installEditorListeners(current, previous);
} | javascript | function handleActiveEditorChange(event, current, previous) {
// Uninstall "languageChanged" event listeners on previous editor's document & put them on current editor's doc
if (previous) {
previous.document
.off(HintUtils.eventName("languageChanged"));
}
if (current) {
current.document
.on(HintUtils.eventName("languageChanged"), function () {
// If current doc's language changed, reset our state by treating it as if the user switched to a
// different document altogether
uninstallEditorListeners(current);
installEditorListeners(current);
});
}
uninstallEditorListeners(previous);
installEditorListeners(current, previous);
} | [
"function",
"handleActiveEditorChange",
"(",
"event",
",",
"current",
",",
"previous",
")",
"{",
"// Uninstall \"languageChanged\" event listeners on previous editor's document & put them on current editor's doc",
"if",
"(",
"previous",
")",
"{",
"previous",
".",
"document",
".... | /*
Handle the activeEditorChange event fired by EditorManager.
Uninstalls the change listener on the previous editor
and installs a change listener on the new editor.
@param {Event} event - editor change event (ignored)
@param {Editor} current - the new current editor context
@param {Editor} previous - the previous editor context | [
"/",
"*",
"Handle",
"the",
"activeEditorChange",
"event",
"fired",
"by",
"EditorManager",
".",
"Uninstalls",
"the",
"change",
"listener",
"on",
"the",
"previous",
"editor",
"and",
"installs",
"a",
"change",
"listener",
"on",
"the",
"new",
"editor",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptCodeHints/main.js#L702-L720 | train | Handle active editor change | [
30522,
3853,
5047,
19620,
2098,
15660,
22305,
2063,
1006,
2724,
1010,
2783,
1010,
3025,
1007,
1063,
1013,
1013,
4895,
7076,
9080,
2140,
1000,
2653,
22305,
2098,
1000,
2724,
13810,
2006,
3025,
3559,
1005,
1055,
6254,
1004,
2404,
2068,
2006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/fontawesome-free/js/fontawesome.js | bindInternal4 | function bindInternal4(func, thisContext) {
return function (a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
} | javascript | function bindInternal4(func, thisContext) {
return function (a, b, c, d) {
return func.call(thisContext, a, b, c, d);
};
} | [
"function",
"bindInternal4",
"(",
"func",
",",
"thisContext",
")",
"{",
"return",
"function",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
"{",
"return",
"func",
".",
"call",
"(",
"thisContext",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
";",
... | Internal helper to bind a function known to have 4 arguments
to a given context. | [
"Internal",
"helper",
"to",
"bind",
"a",
"function",
"known",
"to",
"have",
"4",
"arguments",
"to",
"a",
"given",
"context",
"."
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/fontawesome-free/js/fontawesome.js#L1095-L1099 | train | Internal 4. 4 bind function | [
30522,
3853,
14187,
18447,
11795,
2389,
2549,
1006,
4569,
2278,
1010,
2023,
8663,
18209,
1007,
1063,
2709,
3853,
1006,
1037,
1010,
1038,
1010,
1039,
1010,
1040,
1007,
1063,
2709,
4569,
2278,
1012,
2655,
1006,
2023,
8663,
18209,
1010,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/services/s3.js | extractRequestIds | function extractRequestIds(resp) {
var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null;
var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null;
resp.extendedRequestId = extendedRequestId;
resp.cfId = cfId;
if (resp.error) {
resp.error.requestId = resp.requestId || null;
resp.error.extendedRequestId = extendedRequestId;
resp.error.cfId = cfId;
}
} | javascript | function extractRequestIds(resp) {
var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null;
var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null;
resp.extendedRequestId = extendedRequestId;
resp.cfId = cfId;
if (resp.error) {
resp.error.requestId = resp.requestId || null;
resp.error.extendedRequestId = extendedRequestId;
resp.error.cfId = cfId;
}
} | [
"function",
"extractRequestIds",
"(",
"resp",
")",
"{",
"var",
"extendedRequestId",
"=",
"resp",
".",
"httpResponse",
".",
"headers",
"?",
"resp",
".",
"httpResponse",
".",
"headers",
"[",
"'x-amz-id-2'",
"]",
":",
"null",
";",
"var",
"cfId",
"=",
"resp",
... | Extracts S3 specific request ids from the http response.
@api private | [
"Extracts",
"S3",
"specific",
"request",
"ids",
"from",
"the",
"http",
"response",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L720-L731 | train | Extract request ids from the response | [
30522,
3853,
14817,
2890,
15500,
9821,
1006,
24501,
2361,
1007,
1063,
13075,
3668,
2890,
15500,
3593,
1027,
24501,
2361,
1012,
8299,
6072,
26029,
3366,
1012,
20346,
2015,
1029,
24501,
2361,
1012,
8299,
6072,
26029,
3366,
1012,
20346,
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... |
uber/deck.gl | showcases/ascii/components/constants.js | getWebcamStream | function getWebcamStream(callback) {
window.navigator.mediaDevices
.getUserMedia({video: true})
.then(stream => callback(stream))
.catch(console.error); // eslint-disable-line
} | javascript | function getWebcamStream(callback) {
window.navigator.mediaDevices
.getUserMedia({video: true})
.then(stream => callback(stream))
.catch(console.error); // eslint-disable-line
} | [
"function",
"getWebcamStream",
"(",
"callback",
")",
"{",
"window",
".",
"navigator",
".",
"mediaDevices",
".",
"getUserMedia",
"(",
"{",
"video",
":",
"true",
"}",
")",
".",
"then",
"(",
"stream",
"=>",
"callback",
"(",
"stream",
")",
")",
".",
"catch",... | /* global window | [
"/",
"*",
"global",
"window"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/showcases/ascii/components/constants.js#L6-L11 | train | Get the current video stream | [
30522,
3853,
2131,
8545,
9818,
13596,
25379,
1006,
2655,
5963,
1007,
1063,
3332,
1012,
20532,
1012,
2865,
24844,
23522,
1012,
2131,
20330,
16969,
1006,
1063,
2678,
1024,
2995,
1065,
1007,
1012,
2059,
1006,
5460,
1027,
1028,
2655,
5963,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/PerfUtils.js | getValueAsString | function getValueAsString(entry, aggregateStats) {
if (!Array.isArray(entry)) {
return entry;
}
if (aggregateStats) {
var sum = 0,
avg,
min = _.min(entry),
max = _.max(entry),
sd,
variationSum = 0;
entry.forEach(function (value) {
sum += value;
});
avg = Math.round(sum / entry.length);
entry.forEach(function (value) {
variationSum += Math.pow(value - avg, 2);
});
sd = Math.round(Math.sqrt(variationSum / entry.length));
return min + "(" + avg + ")" + max + "[" + sd + "]";
} else {
return entry.join(", ");
}
} | javascript | function getValueAsString(entry, aggregateStats) {
if (!Array.isArray(entry)) {
return entry;
}
if (aggregateStats) {
var sum = 0,
avg,
min = _.min(entry),
max = _.max(entry),
sd,
variationSum = 0;
entry.forEach(function (value) {
sum += value;
});
avg = Math.round(sum / entry.length);
entry.forEach(function (value) {
variationSum += Math.pow(value - avg, 2);
});
sd = Math.round(Math.sqrt(variationSum / entry.length));
return min + "(" + avg + ")" + max + "[" + sd + "]";
} else {
return entry.join(", ");
}
} | [
"function",
"getValueAsString",
"(",
"entry",
",",
"aggregateStats",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"entry",
")",
")",
"{",
"return",
"entry",
";",
"}",
"if",
"(",
"aggregateStats",
")",
"{",
"var",
"sum",
"=",
"0",
",",
"avg... | return single value, or comma separated values for an array or return aggregated values with
<min value, average, max value, standard deviation>
@param {Array} entry An array or a single value
@param {Boolean} aggregateStats If set, the returned value will be aggregated in the form -
<min(avg)max[standard deviation]>
@return {String} a single value, or comma separated values in an array or
<min(avg)max[standard deviation]> if aggregateStats is set | [
"return",
"single",
"value",
"or",
"comma",
"separated",
"values",
"for",
"an",
"array",
"or",
"return",
"aggregated",
"values",
"with",
"<min",
"value",
"average",
"max",
"value",
"standard",
"deviation",
">"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L312-L337 | train | Get value as string | [
30522,
3853,
2131,
10175,
5657,
12054,
18886,
3070,
1006,
4443,
1010,
9572,
9153,
3215,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
4443,
1007,
1007,
1063,
2709,
4443,
1025,
1065,
2065,
1006,
9572,
9153,
3215,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js | function() {
if (!this.metaPath) {
this.oMetaContext = this.oMetaModel.getMetaContext(this.path);
this.metaPath = this.oMetaContext.getPath();
} else {
this.oMetaContext = this.oMetaModel.createBindingContext(this.metaPath);
}
} | javascript | function() {
if (!this.metaPath) {
this.oMetaContext = this.oMetaModel.getMetaContext(this.path);
this.metaPath = this.oMetaContext.getPath();
} else {
this.oMetaContext = this.oMetaModel.createBindingContext(this.metaPath);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"metaPath",
")",
"{",
"this",
".",
"oMetaContext",
"=",
"this",
".",
"oMetaModel",
".",
"getMetaContext",
"(",
"this",
".",
"path",
")",
";",
"this",
".",
"metaPath",
"=",
"this",
".",
"oMetaCon... | Individual init method for Adapters
@protected | [
"Individual",
"init",
"method",
"for",
"Adapters"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js#L76-L83 | train | This method is called when the model is initialized | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
18804,
15069,
1007,
1063,
2023,
1012,
18168,
12928,
8663,
18209,
1027,
2023,
1012,
18168,
12928,
5302,
9247,
1012,
2131,
11368,
22684,
10111,
18413,
1006,
2023,
1012,
4130,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/view/MainViewManager.js | addToWorkingSet | function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
} | javascript | function addToWorkingSet(paneId, file, index, force) {
// look for the file to have already been added to another pane
var pane = _getPane(paneId);
if (!pane) {
throw new Error("invalid pane id: " + paneId);
}
var result = pane.reorderItem(file, index, force),
entry = _makeMRUListEntry(file, pane.id);
// handles the case of save as so that the file remains in the
// the same location in the working set as the file that was renamed
if (result === pane.ITEM_FOUND_NEEDS_SORT) {
console.warn("pane.reorderItem returned pane.ITEM_FOUND_NEEDS_SORT which shouldn't happen " + file);
exports.trigger("workingSetSort", pane.id);
} else if (result === pane.ITEM_NOT_FOUND) {
index = pane.addToViewList(file, index);
if (_findFileInMRUList(pane.id, file) === -1) {
// Add to or update the position in MRU
if (pane.getCurrentlyViewedFile() === file) {
_mruList.unshift(entry);
} else {
_mruList.push(entry);
}
}
exports.trigger("workingSetAdd", file, index, pane.id);
}
} | [
"function",
"addToWorkingSet",
"(",
"paneId",
",",
"file",
",",
"index",
",",
"force",
")",
"{",
"// look for the file to have already been added to another pane",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"!",
"pane",
")",
"{",
"throw"... | Adds the given file to the end of the workingset, if it is not already there.
This API does not create a view of the file, it just adds it to the working set
Views of files in the working set are persisted and are not destroyed until the user
closes the file using FILE_CLOSE; Views are created using FILE_OPEN and, when opened, are
made the current view. If a File is already opened then the file is just made current
and its view is shown.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!File} file - The File object to add to the workingset
@param {number=} index - Position to add to list (defaults to last); -1 is ignored
@param {boolean=} forceRedraw - If true, a workingset change notification is always sent
(useful if suppressRedraw was used with removeView() earlier) | [
"Adds",
"the",
"given",
"file",
"to",
"the",
"end",
"of",
"the",
"workingset",
"if",
"it",
"is",
"not",
"already",
"there",
".",
"This",
"API",
"does",
"not",
"create",
"a",
"view",
"of",
"the",
"file",
"it",
"just",
"adds",
"it",
"to",
"the",
"worki... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L709-L739 | train | Add a file to the working set | [
30522,
3853,
5587,
18790,
2953,
6834,
13462,
1006,
6090,
7416,
2094,
1010,
5371,
1010,
5950,
1010,
2486,
1007,
1063,
1013,
1013,
2298,
2005,
1996,
5371,
2000,
2031,
2525,
2042,
2794,
2000,
2178,
6090,
2063,
13075,
6090,
2063,
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... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onLinkWithEmailLink | function onLinkWithEmailLink() {
var email = $('#link-with-email-link-email').val();
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().linkWithCredential(credential)
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | function onLinkWithEmailLink() {
var email = $('#link-with-email-link-email').val();
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().linkWithCredential(credential)
.then(onAuthUserCredentialSuccess, onAuthError);
} | [
"function",
"onLinkWithEmailLink",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#link-with-email-link-email'",
")",
".",
"val",
"(",
")",
";",
"var",
"link",
"=",
"$",
"(",
"'#link-with-email-link-link'",
")",
".",
"val",
"(",
")",
"||",
"undefined",
";... | Links a user with an email link. | [
"Links",
"a",
"user",
"with",
"an",
"email",
"link",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L342-L349 | train | Link with email link | [
30522,
3853,
2006,
13767,
24415,
14545,
8591,
19839,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
4957,
1011,
2007,
1011,
10373,
1011,
4957,
1011,
10373,
1005,
1007,
1012,
11748,
1006,
1007,
1025,
13075,
4957,
1027,
1002,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js | function(bDeleteRecordings) {
// Check for the filename or ask for it (if configured)
var sFilename = (this.sFilename || this.sDefaultFilename);
if (this.bPromptForDownloadFilename) {
sFilename = window.prompt("Enter file name", sFilename + ".har");
} else {
sFilename = sFilename + ".har";
}
// The content skeleton
var mHarContent = {
log: {
version: "1.2",
creator: {
name: "RequestRecorder",
version: "1.0"
},
entries: this.aRequests
}
};
// Check if recorded entries should be cleared.
if (bDeleteRecordings) {
this.deleteRecordedEntries();
}
// Inject the data into the dom and download it (if configured).
if (!this.bIsDownloadDisabled) {
var sString = JSON.stringify(mHarContent, null, 4);
var a = document.createElement("a");
document.body.appendChild(a);
var oBlob = new window.Blob([sString], { type: "octet/stream" });
var sUrl = window.URL.createObjectURL(oBlob);
a.href = sUrl;
a.download = sFilename;
a.click();
window.URL.revokeObjectURL(sUrl);
}
return mHarContent;
} | javascript | function(bDeleteRecordings) {
// Check for the filename or ask for it (if configured)
var sFilename = (this.sFilename || this.sDefaultFilename);
if (this.bPromptForDownloadFilename) {
sFilename = window.prompt("Enter file name", sFilename + ".har");
} else {
sFilename = sFilename + ".har";
}
// The content skeleton
var mHarContent = {
log: {
version: "1.2",
creator: {
name: "RequestRecorder",
version: "1.0"
},
entries: this.aRequests
}
};
// Check if recorded entries should be cleared.
if (bDeleteRecordings) {
this.deleteRecordedEntries();
}
// Inject the data into the dom and download it (if configured).
if (!this.bIsDownloadDisabled) {
var sString = JSON.stringify(mHarContent, null, 4);
var a = document.createElement("a");
document.body.appendChild(a);
var oBlob = new window.Blob([sString], { type: "octet/stream" });
var sUrl = window.URL.createObjectURL(oBlob);
a.href = sUrl;
a.download = sFilename;
a.click();
window.URL.revokeObjectURL(sUrl);
}
return mHarContent;
} | [
"function",
"(",
"bDeleteRecordings",
")",
"{",
"// Check for the filename or ask for it (if configured)",
"var",
"sFilename",
"=",
"(",
"this",
".",
"sFilename",
"||",
"this",
".",
"sDefaultFilename",
")",
";",
"if",
"(",
"this",
".",
"bPromptForDownloadFilename",
")... | Transforms and delivers the recorded data for the har file.
If the downloading is not disabled the file will be downloaded automatically or with an optional prompt for a filename.
@param {boolean} bDeleteRecordings True if the existing entries should be deleted.
@returns {Object} The recorded har file content | [
"Transforms",
"and",
"delivers",
"the",
"recorded",
"data",
"for",
"the",
"har",
"file",
".",
"If",
"the",
"downloading",
"is",
"not",
"disabled",
"the",
"file",
"will",
"be",
"downloaded",
"automatically",
"or",
"with",
"an",
"optional",
"prompt",
"for",
"a... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L289-L328 | train | Download the file | [
30522,
3853,
1006,
1038,
9247,
15141,
8586,
8551,
8613,
1007,
1063,
1013,
1013,
4638,
2005,
1996,
5371,
18442,
2030,
3198,
2005,
2009,
1006,
2065,
26928,
1007,
13075,
16420,
9463,
18442,
1027,
1006,
2023,
1012,
16420,
9463,
18442,
1064,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
grpc/grpc | examples/node/static_codegen/route_guide/route_guide_client.js | runRouteChat | function runRouteChat(callback) {
var call = client.routeChat();
call.on('data', function(note) {
console.log('Got message "' + note.getMessage() + '" at ' +
note.getLocation().getLatitude() + ', ' +
note.getLocation().getLongitude());
});
call.on('end', callback);
var notes = [{
location: {
latitude: 0,
longitude: 0
},
message: 'First message'
}, {
location: {
latitude: 0,
longitude: 1
},
message: 'Second message'
}, {
location: {
latitude: 1,
longitude: 0
},
message: 'Third message'
}, {
location: {
latitude: 0,
longitude: 0
},
message: 'Fourth message'
}];
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
console.log('Sending message "' + note.message + '" at ' +
note.location.latitude + ', ' + note.location.longitude);
var noteMsg = new messages.RouteNote();
noteMsg.setMessage(note.message);
var location = new messages.Point();
location.setLatitude(note.location.latitude);
location.setLongitude(note.location.longitude);
noteMsg.setLocation(location);
call.write(noteMsg);
}
call.end();
} | javascript | function runRouteChat(callback) {
var call = client.routeChat();
call.on('data', function(note) {
console.log('Got message "' + note.getMessage() + '" at ' +
note.getLocation().getLatitude() + ', ' +
note.getLocation().getLongitude());
});
call.on('end', callback);
var notes = [{
location: {
latitude: 0,
longitude: 0
},
message: 'First message'
}, {
location: {
latitude: 0,
longitude: 1
},
message: 'Second message'
}, {
location: {
latitude: 1,
longitude: 0
},
message: 'Third message'
}, {
location: {
latitude: 0,
longitude: 0
},
message: 'Fourth message'
}];
for (var i = 0; i < notes.length; i++) {
var note = notes[i];
console.log('Sending message "' + note.message + '" at ' +
note.location.latitude + ', ' + note.location.longitude);
var noteMsg = new messages.RouteNote();
noteMsg.setMessage(note.message);
var location = new messages.Point();
location.setLatitude(note.location.latitude);
location.setLongitude(note.location.longitude);
noteMsg.setLocation(location);
call.write(noteMsg);
}
call.end();
} | [
"function",
"runRouteChat",
"(",
"callback",
")",
"{",
"var",
"call",
"=",
"client",
".",
"routeChat",
"(",
")",
";",
"call",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"note",
")",
"{",
"console",
".",
"log",
"(",
"'Got message \"'",
"+",
"note",... | Run the routeChat demo. Send some chat messages, and print any chat messages
that are sent from the server.
@param {function} callback Called when the demo is complete | [
"Run",
"the",
"routeChat",
"demo",
".",
"Send",
"some",
"chat",
"messages",
"and",
"print",
"any",
"chat",
"messages",
"that",
"are",
"sent",
"from",
"the",
"server",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/static_codegen/route_guide/route_guide_client.js#L165-L213 | train | Run the route chat | [
30522,
3853,
2448,
22494,
15007,
4017,
1006,
2655,
5963,
1007,
1063,
13075,
2655,
1027,
7396,
1012,
2799,
7507,
2102,
1006,
1007,
1025,
2655,
1012,
2006,
1006,
1005,
2951,
1005,
1010,
3853,
1006,
3602,
1007,
1063,
10122,
1012,
8833,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_setCategory | function addonsManager_setCategory(aSpec) {
var spec = aSpec || { };
var category = spec.category;
var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
this._controller.click(category);
if (waitFor)
this.waitForCategory({category: category});
} | javascript | function addonsManager_setCategory(aSpec) {
var spec = aSpec || { };
var category = spec.category;
var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
this._controller.click(category);
if (waitFor)
this.waitForCategory({category: category});
} | [
"function",
"addonsManager_setCategory",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"category",
"=",
"spec",
".",
"category",
";",
"var",
"waitFor",
"=",
"(",
"spec",
".",
"waitFor",
"==",
"undefined",
")",
"?",
"t... | Select the given category
@param {object} aSpec
Information for selecting a category
Elements: category - Category element
waitFor - Wait until the category has been selected
[optional - default: true] | [
"Select",
"the",
"given",
"category"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L698-L710 | train | Sets the category of the add - ons | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2275,
16280,
20255,
2100,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
4696,
1027,
28699,
1012,
4696,
1025,
13075,
3524,
29278,
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... |
goldfire/howler.js | examples/player/player.js | function(val) {
var self = this;
// Update the global volume (affecting all Howls).
Howler.volume(val);
// Update the display on the slider.
var barWidth = (val * 90) / 100;
barFull.style.width = (barWidth * 100) + '%';
sliderBtn.style.left = (window.innerWidth * barWidth + window.innerWidth * 0.05 - 25) + 'px';
} | javascript | function(val) {
var self = this;
// Update the global volume (affecting all Howls).
Howler.volume(val);
// Update the display on the slider.
var barWidth = (val * 90) / 100;
barFull.style.width = (barWidth * 100) + '%';
sliderBtn.style.left = (window.innerWidth * barWidth + window.innerWidth * 0.05 - 25) + 'px';
} | [
"function",
"(",
"val",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Update the global volume (affecting all Howls).",
"Howler",
".",
"volume",
"(",
"val",
")",
";",
"// Update the display on the slider.",
"var",
"barWidth",
"=",
"(",
"val",
"*",
"90",
")",
"/... | Set the volume and update the volume slider display.
@param {Number} val Volume between 0 and 1. | [
"Set",
"the",
"volume",
"and",
"update",
"the",
"volume",
"slider",
"display",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/player/player.js#L185-L195 | train | Update the volume of the cluster | [
30522,
3853,
1006,
11748,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
10651,
1996,
3795,
3872,
1006,
12473,
2035,
22912,
2015,
1007,
1012,
22912,
2121,
1012,
3872,
1006,
11748,
1007,
1025,
1013,
1013,
10651,
1996,
4653,
2006,
199... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/FileTreeViewModel.js | _moveMarker | function _moveMarker(treeData, markerName, oldPath, newPath) {
var objectPath;
if (newPath) {
objectPath = _filePathToObjectPath(treeData, newPath);
}
var newTreeData = treeData;
if (oldPath && oldPath !== newPath) {
var lastObjectPath = _filePathToObjectPath(treeData, oldPath);
if (lastObjectPath) {
newTreeData = newTreeData.updateIn(lastObjectPath, function (entry) {
return entry.delete(markerName);
});
}
}
if (newPath && objectPath && objectPath.length !== 0) {
newTreeData = newTreeData.updateIn(objectPath, function (entry) {
return entry.set(markerName, true);
});
}
return newTreeData;
} | javascript | function _moveMarker(treeData, markerName, oldPath, newPath) {
var objectPath;
if (newPath) {
objectPath = _filePathToObjectPath(treeData, newPath);
}
var newTreeData = treeData;
if (oldPath && oldPath !== newPath) {
var lastObjectPath = _filePathToObjectPath(treeData, oldPath);
if (lastObjectPath) {
newTreeData = newTreeData.updateIn(lastObjectPath, function (entry) {
return entry.delete(markerName);
});
}
}
if (newPath && objectPath && objectPath.length !== 0) {
newTreeData = newTreeData.updateIn(objectPath, function (entry) {
return entry.set(markerName, true);
});
}
return newTreeData;
} | [
"function",
"_moveMarker",
"(",
"treeData",
",",
"markerName",
",",
"oldPath",
",",
"newPath",
")",
"{",
"var",
"objectPath",
";",
"if",
"(",
"newPath",
")",
"{",
"objectPath",
"=",
"_filePathToObjectPath",
"(",
"treeData",
",",
"newPath",
")",
";",
"}",
"... | @private
See `FileTreeViewModel.moveMarker` | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeViewModel.js#L417-L442 | train | Move marker in treeData | [
30522,
3853,
1035,
2693,
10665,
2121,
1006,
3392,
2850,
2696,
1010,
12115,
18442,
1010,
2214,
15069,
1010,
2047,
15069,
1007,
1063,
13075,
4874,
15069,
1025,
2065,
1006,
2047,
15069,
1007,
1063,
4874,
15069,
1027,
1035,
5371,
15069,
3406,
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... |
openlayers/openlayers | src/ol/pointer/MsSource.js | msGotPointerCapture | function msGotPointerCapture(inEvent) {
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
} | javascript | function msGotPointerCapture(inEvent) {
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
} | [
"function",
"msGotPointerCapture",
"(",
"inEvent",
")",
"{",
"const",
"e",
"=",
"this",
".",
"dispatcher",
".",
"makeEvent",
"(",
"'gotpointercapture'",
",",
"inEvent",
",",
"inEvent",
")",
";",
"this",
".",
"dispatcher",
".",
"dispatchEvent",
"(",
"e",
")",... | Handler for `msGotPointerCapture`.
@this {MsSource}
@param {MSPointerEvent} inEvent The in event. | [
"Handler",
"for",
"msGotPointerCapture",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L135-L138 | train | The msGotPointerCapture function is called when the pointer is captured. | [
30522,
3853,
5796,
3995,
25856,
25785,
2121,
17695,
11244,
1006,
1999,
18697,
3372,
1007,
1063,
9530,
3367,
1041,
1027,
2023,
1012,
18365,
2121,
1012,
2191,
18697,
3372,
1006,
1005,
2288,
8400,
2121,
17695,
11244,
1005,
1010,
1999,
18697,
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... |
adobe/brackets | src/preferences/PreferencesBase.js | function (id, context) {
var scopeCounter,
scopeName;
context = this._getContext(context);
var scopeOrder = this._getScopeOrder(context);
for (scopeCounter = 0; scopeCounter < scopeOrder.length; scopeCounter++) {
scopeName = scopeOrder[scopeCounter];
var scope = this._scopes[scopeName];
if (scope) {
var result = scope.getPreferenceLocation(id, context);
if (result !== undefined) {
result.scope = scopeName;
return result;
}
}
}
} | javascript | function (id, context) {
var scopeCounter,
scopeName;
context = this._getContext(context);
var scopeOrder = this._getScopeOrder(context);
for (scopeCounter = 0; scopeCounter < scopeOrder.length; scopeCounter++) {
scopeName = scopeOrder[scopeCounter];
var scope = this._scopes[scopeName];
if (scope) {
var result = scope.getPreferenceLocation(id, context);
if (result !== undefined) {
result.scope = scopeName;
return result;
}
}
}
} | [
"function",
"(",
"id",
",",
"context",
")",
"{",
"var",
"scopeCounter",
",",
"scopeName",
";",
"context",
"=",
"this",
".",
"_getContext",
"(",
"context",
")",
";",
"var",
"scopeOrder",
"=",
"this",
".",
"_getScopeOrder",
"(",
"context",
")",
";",
"for",... | Gets the location in which the value of a preference has been set.
@param {string} id Name of the preference for which the value should be retrieved
@param {Object=} context Optional context object to change the preference lookup
@return {{scope: string, layer: ?string, layerID: ?object}} Object describing where the preferences came from | [
"Gets",
"the",
"location",
"in",
"which",
"the",
"value",
"of",
"a",
"preference",
"has",
"been",
"set",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1686-L1705 | train | Returns the preference location for the given preference id and context | [
30522,
3853,
1006,
8909,
1010,
6123,
1007,
1063,
13075,
9531,
3597,
16671,
2121,
1010,
9531,
18442,
1025,
6123,
1027,
2023,
1012,
1035,
2131,
8663,
18209,
1006,
6123,
1007,
1025,
13075,
9531,
8551,
2121,
1027,
2023,
1012,
1035,
4152,
16186,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | src/ol/interaction/KeyboardPan.js | handleEvent | function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
const keyCode = keyEvent.keyCode;
if (this.condition_(mapBrowserEvent) &&
(keyCode == KeyCode.DOWN ||
keyCode == KeyCode.LEFT ||
keyCode == KeyCode.RIGHT ||
keyCode == KeyCode.UP)) {
const map = mapBrowserEvent.map;
const view = map.getView();
const mapUnitsDelta = view.getResolution() * this.pixelDelta_;
let deltaX = 0, deltaY = 0;
if (keyCode == KeyCode.DOWN) {
deltaY = -mapUnitsDelta;
} else if (keyCode == KeyCode.LEFT) {
deltaX = -mapUnitsDelta;
} else if (keyCode == KeyCode.RIGHT) {
deltaX = mapUnitsDelta;
} else {
deltaY = mapUnitsDelta;
}
const delta = [deltaX, deltaY];
rotateCoordinate(delta, view.getRotation());
pan(view, delta, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
}
return !stopEvent;
} | javascript | function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = /** @type {KeyboardEvent} */ (mapBrowserEvent.originalEvent);
const keyCode = keyEvent.keyCode;
if (this.condition_(mapBrowserEvent) &&
(keyCode == KeyCode.DOWN ||
keyCode == KeyCode.LEFT ||
keyCode == KeyCode.RIGHT ||
keyCode == KeyCode.UP)) {
const map = mapBrowserEvent.map;
const view = map.getView();
const mapUnitsDelta = view.getResolution() * this.pixelDelta_;
let deltaX = 0, deltaY = 0;
if (keyCode == KeyCode.DOWN) {
deltaY = -mapUnitsDelta;
} else if (keyCode == KeyCode.LEFT) {
deltaX = -mapUnitsDelta;
} else if (keyCode == KeyCode.RIGHT) {
deltaX = mapUnitsDelta;
} else {
deltaY = mapUnitsDelta;
}
const delta = [deltaX, deltaY];
rotateCoordinate(delta, view.getRotation());
pan(view, delta, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
}
return !stopEvent;
} | [
"function",
"handleEvent",
"(",
"mapBrowserEvent",
")",
"{",
"let",
"stopEvent",
"=",
"false",
";",
"if",
"(",
"mapBrowserEvent",
".",
"type",
"==",
"EventType",
".",
"KEYDOWN",
")",
"{",
"const",
"keyEvent",
"=",
"/** @type {KeyboardEvent} */",
"(",
"mapBrowser... | Handles the {@link module:ol/MapBrowserEvent map browser event} if it was a
`KeyEvent`, and decides the direction to pan to (if an arrow key was
pressed).
@param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
@return {boolean} `false` to stop event propagation.
@this {KeyboardPan} | [
"Handles",
"the",
"{"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/KeyboardPan.js#L92-L123 | train | Handle a mapBrowserEvent | [
30522,
3853,
5047,
18697,
3372,
1006,
4949,
12618,
9333,
7869,
15338,
1007,
1063,
2292,
2644,
18697,
3372,
1027,
6270,
1025,
2065,
1006,
4949,
12618,
9333,
7869,
15338,
1012,
2828,
1027,
1027,
2724,
13874,
1012,
3145,
7698,
1007,
1063,
9530... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/P13nDimMeasurePanel.js | function(sId, oBindingContext) {
var oAvailableRoleType = oBindingContext.getObject();
return new Item({
key: oAvailableRoleType.key,
text: oAvailableRoleType.text
});
} | javascript | function(sId, oBindingContext) {
var oAvailableRoleType = oBindingContext.getObject();
return new Item({
key: oAvailableRoleType.key,
text: oAvailableRoleType.text
});
} | [
"function",
"(",
"sId",
",",
"oBindingContext",
")",
"{",
"var",
"oAvailableRoleType",
"=",
"oBindingContext",
".",
"getObject",
"(",
")",
";",
"return",
"new",
"Item",
"(",
"{",
"key",
":",
"oAvailableRoleType",
".",
"key",
",",
"text",
":",
"oAvailableRole... | sorter: [ new sap.ui.model.Sorter("/text", false) ], | [
"sorter",
":",
"[",
"new",
"sap",
".",
"ui",
".",
"model",
".",
"Sorter",
"(",
"/",
"text",
"false",
")",
"]"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/P13nDimMeasurePanel.js#L601-L607 | train | Creates an Item object for the given ID. | [
30522,
3853,
1006,
15765,
1010,
27885,
22254,
2075,
8663,
18209,
1007,
1063,
13075,
1051,
12462,
11733,
16213,
9890,
13874,
1027,
27885,
22254,
2075,
8663,
18209,
1012,
2131,
16429,
20614,
1006,
1007,
1025,
2709,
2047,
8875,
1006,
1063,
3145,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
feathericons/feather | bin/process-svg.js | processSvg | function processSvg(svg) {
return (
optimize(svg)
.then(setAttrs)
.then(format)
// remove semicolon inserted by prettier
// because prettier thinks it's formatting JSX not HTML
.then(svg => svg.replace(/;/g, ''))
);
} | javascript | function processSvg(svg) {
return (
optimize(svg)
.then(setAttrs)
.then(format)
// remove semicolon inserted by prettier
// because prettier thinks it's formatting JSX not HTML
.then(svg => svg.replace(/;/g, ''))
);
} | [
"function",
"processSvg",
"(",
"svg",
")",
"{",
"return",
"(",
"optimize",
"(",
"svg",
")",
".",
"then",
"(",
"setAttrs",
")",
".",
"then",
"(",
"format",
")",
"// remove semicolon inserted by prettier",
"// because prettier thinks it's formatting JSX not HTML",
".",
... | Process SVG string.
@param {string} svg - An SVG string.
@param {Promise<string>} | [
"Process",
"SVG",
"string",
"."
] | 8f658193d25e943b196a2367319b5d9e85ee9f9f | https://github.com/feathericons/feather/blob/8f658193d25e943b196a2367319b5d9e85ee9f9f/bin/process-svg.js#L12-L21 | train | process SVG | [
30522,
3853,
2832,
2015,
2615,
2290,
1006,
17917,
2290,
1007,
1063,
2709,
1006,
23569,
27605,
4371,
1006,
17917,
2290,
1007,
1012,
2059,
1006,
2275,
19321,
2869,
1007,
1012,
2059,
1006,
4289,
1007,
1013,
1013,
6366,
4100,
25778,
2239,
12889... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jszip.js | arrayLikeToString | function arrayLikeToString(array) {
// Performances notes :
// --------------------
// String.fromCharCode.apply(null, array) is the fastest, see
// see http://jsperf.com/converting-a-uint8array-to-a-string/2
// but the stack is limited (and we can get huge arrays !).
//
// result += String.fromCharCode(array[i]); generate too many strings !
//
// This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
var chunk = 65536;
var result = [],
len = array.length,
type = exports.getTypeOf(array),
k = 0,
canUseApply = true;
try {
switch(type) {
case "uint8array":
String.fromCharCode.apply(null, new Uint8Array(0));
break;
case "nodebuffer":
String.fromCharCode.apply(null, nodeBuffer(0));
break;
}
} catch(e) {
canUseApply = false;
}
// no apply : slow and painful algorithm
// default browser on android 4.*
if (!canUseApply) {
var resultStr = "";
for(var i = 0; i < array.length;i++) {
resultStr += String.fromCharCode(array[i]);
}
return resultStr;
}
while (k < len && chunk > 1) {
try {
if (type === "array" || type === "nodebuffer") {
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
}
else {
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
}
k += chunk;
}
catch (e) {
chunk = Math.floor(chunk / 2);
}
}
return result.join("");
} | javascript | function arrayLikeToString(array) {
// Performances notes :
// --------------------
// String.fromCharCode.apply(null, array) is the fastest, see
// see http://jsperf.com/converting-a-uint8array-to-a-string/2
// but the stack is limited (and we can get huge arrays !).
//
// result += String.fromCharCode(array[i]); generate too many strings !
//
// This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
var chunk = 65536;
var result = [],
len = array.length,
type = exports.getTypeOf(array),
k = 0,
canUseApply = true;
try {
switch(type) {
case "uint8array":
String.fromCharCode.apply(null, new Uint8Array(0));
break;
case "nodebuffer":
String.fromCharCode.apply(null, nodeBuffer(0));
break;
}
} catch(e) {
canUseApply = false;
}
// no apply : slow and painful algorithm
// default browser on android 4.*
if (!canUseApply) {
var resultStr = "";
for(var i = 0; i < array.length;i++) {
resultStr += String.fromCharCode(array[i]);
}
return resultStr;
}
while (k < len && chunk > 1) {
try {
if (type === "array" || type === "nodebuffer") {
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
}
else {
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
}
k += chunk;
}
catch (e) {
chunk = Math.floor(chunk / 2);
}
}
return result.join("");
} | [
"function",
"arrayLikeToString",
"(",
"array",
")",
"{",
"// Performances notes :",
"// --------------------",
"// String.fromCharCode.apply(null, array) is the fastest, see",
"// see http://jsperf.com/converting-a-uint8array-to-a-string/2",
"// but the stack is limited (and we can get huge arra... | Transform an array-like object to a string.
@param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
@return {String} the result. | [
"Transform",
"an",
"array",
"-",
"like",
"object",
"to",
"a",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1431-L1484 | train | Convert an array - like object to a string | [
30522,
3853,
9140,
10359,
13122,
18886,
3070,
1006,
9140,
1007,
1063,
1013,
1013,
4616,
3964,
1024,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
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... |
postmanlabs/newman | lib/reporters/cli/cli-utils.js | function () {
var tty,
width,
height;
try { tty = require('tty'); }
catch (e) { tty = null; }
if (tty && tty.isatty(1) && tty.isatty(2)) {
if (process.stdout.getWindowSize) {
width = process.stdout.getWindowSize(1)[0];
height = process.stdout.getWindowSize(1)[1];
}
else if (tty.getWindowSize) {
width = tty.getWindowSize()[1];
height = tty.getWindowSize()[0];
}
else if (process.stdout.columns && process.stdout.rows) {
height = process.stdout.rows;
width = process.stdout.columns;
}
}
return {
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
width: width,
height: height
};
} | javascript | function () {
var tty,
width,
height;
try { tty = require('tty'); }
catch (e) { tty = null; }
if (tty && tty.isatty(1) && tty.isatty(2)) {
if (process.stdout.getWindowSize) {
width = process.stdout.getWindowSize(1)[0];
height = process.stdout.getWindowSize(1)[1];
}
else if (tty.getWindowSize) {
width = tty.getWindowSize()[1];
height = tty.getWindowSize()[0];
}
else if (process.stdout.columns && process.stdout.rows) {
height = process.stdout.rows;
width = process.stdout.columns;
}
}
return {
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
width: width,
height: height
};
} | [
"function",
"(",
")",
"{",
"var",
"tty",
",",
"width",
",",
"height",
";",
"try",
"{",
"tty",
"=",
"require",
"(",
"'tty'",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"tty",
"=",
"null",
";",
"}",
"if",
"(",
"tty",
"&&",
"tty",
".",
"isatty"... | A CLI utility helper method to compute and scae the size of the CLI table to be displayed.
@returns {Object} - A set of properties: width, height, and TTY existance. | [
"A",
"CLI",
"utility",
"helper",
"method",
"to",
"compute",
"and",
"scae",
"the",
"size",
"of",
"the",
"CLI",
"table",
"to",
"be",
"displayed",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L155-L183 | train | Returns an object containing information about the current term size | [
30522,
3853,
1006,
1007,
1063,
13075,
23746,
2100,
1010,
9381,
1010,
4578,
1025,
3046,
1063,
23746,
2100,
1027,
5478,
1006,
1005,
23746,
2100,
1005,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
23746,
2100,
1027,
19701,
1025,
1065,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/output/modifiers/fetchRemoteImages.js | fetchRemoteImages | function fetchRemoteImages(rootFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
var extension = path.extname(src);
if (!LocationUtils.isExternal(src)) {
return;
}
// We avoid generating twice the same PNG
var hash = crc.crc32(src).toString(16);
var fileName = hash + extension;
var filePath = path.join(rootFolder, fileName);
return fs.assertFile(filePath, function() {
return fs.download(src, filePath);
})
.then(function() {
// Convert to relative
src = LocationUtils.relative(currentDirectory, fileName);
$img.replaceWith('<img src="' + src + '" />');
});
});
} | javascript | function fetchRemoteImages(rootFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
var extension = path.extname(src);
if (!LocationUtils.isExternal(src)) {
return;
}
// We avoid generating twice the same PNG
var hash = crc.crc32(src).toString(16);
var fileName = hash + extension;
var filePath = path.join(rootFolder, fileName);
return fs.assertFile(filePath, function() {
return fs.download(src, filePath);
})
.then(function() {
// Convert to relative
src = LocationUtils.relative(currentDirectory, fileName);
$img.replaceWith('<img src="' + src + '" />');
});
});
} | [
"function",
"fetchRemoteImages",
"(",
"rootFolder",
",",
"currentFile",
",",
"$",
")",
"{",
"var",
"currentDirectory",
"=",
"path",
".",
"dirname",
"(",
"currentFile",
")",
";",
"return",
"editHTMLElement",
"(",
"$",
",",
"'img'",
",",
"function",
"(",
"$img... | Fetch all remote images
@param {String} rootFolder
@param {String} currentFile
@param {HTMLDom} $
@return {Promise} | [
"Fetch",
"all",
"remote",
"images"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/fetchRemoteImages.js#L16-L42 | train | Fetch remote images | [
30522,
3853,
18584,
28578,
12184,
9581,
8449,
1006,
7117,
10371,
2121,
1010,
2783,
8873,
2571,
1010,
1002,
1007,
1063,
13075,
2783,
4305,
2890,
16761,
2100,
1027,
4130,
1012,
16101,
18442,
1006,
2783,
8873,
2571,
1007,
1025,
2709,
13257,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js | function (sPath) {
sPath = AnnotationHelper.getNavigationPath(sPath);
if (rBadChars.test(sPath)) {
throw new Error("Invalid OData identifier: " + sPath);
}
return sPath ? "{" + sPath + "}" : sPath;
} | javascript | function (sPath) {
sPath = AnnotationHelper.getNavigationPath(sPath);
if (rBadChars.test(sPath)) {
throw new Error("Invalid OData identifier: " + sPath);
}
return sPath ? "{" + sPath + "}" : sPath;
} | [
"function",
"(",
"sPath",
")",
"{",
"sPath",
"=",
"AnnotationHelper",
".",
"getNavigationPath",
"(",
"sPath",
")",
";",
"if",
"(",
"rBadChars",
".",
"test",
"(",
"sPath",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid OData identifier: \"",
"+",
"... | Returns a data binding according to the result of
{@link sap.ui.model.odata.v4.AnnotationHelper.getNavigationPath}.
@param {string} sPath
The path value from the meta model, for example
"ToSupplier/@com.sap.vocabularies.Communication.v1.Address" or
"@com.sap.vocabularies.UI.v1.FieldGroup#Dimensions"
@returns {string}
A data binding according to the result of
{@link sap.ui.model.odata.v4.AnnotationHelper.getNavigationPath}, for example
"{ToSupplier}" or ""
@throws {Error}
If the result of {@link sap.ui.model.odata.v4.AnnotationHelper.getNavigationPath}
contains segments which are not valid OData identifiers and violate the data
binding syntax
@public
@since 1.43.0 | [
"Returns",
"a",
"data",
"binding",
"according",
"to",
"the",
"result",
"of",
"{",
"@link",
"sap",
".",
"ui",
".",
"model",
".",
"odata",
".",
"v4",
".",
"AnnotationHelper",
".",
"getNavigationPath",
"}",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L243-L249 | train | Returns the navigation path for the given OData identifier. | [
30522,
3853,
1006,
14690,
2232,
1007,
1063,
14690,
2232,
1027,
5754,
17287,
3508,
16001,
4842,
1012,
2131,
2532,
5737,
12540,
15069,
1006,
14690,
2232,
1007,
1025,
2065,
1006,
21144,
4215,
7507,
2869,
1012,
3231,
1006,
14690,
2232,
1007,
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... | |
apache/incubator-echarts | src/component/helper/BrushController.js | BrushController | function BrushController(zr) {
if (__DEV__) {
zrUtil.assert(zr);
}
Eventful.call(this);
/**
* @type {module:zrender/zrender~ZRender}
* @private
*/
this._zr = zr;
/**
* @type {module:zrender/container/Group}
* @readOnly
*/
this.group = new graphic.Group();
/**
* Only for drawing (after enabledBrush).
* 'line', 'rect', 'polygon' or false
* If passing false/null/undefined, disable brush.
* If passing 'auto', determined by panel.defaultBrushType
* @private
* @type {string}
*/
this._brushType;
/**
* Only for drawing (after enabledBrush).
*
* @private
* @type {Object}
*/
this._brushOption;
/**
* @private
* @type {Object}
*/
this._panels;
/**
* @private
* @type {Array.<nubmer>}
*/
this._track = [];
/**
* @private
* @type {boolean}
*/
this._dragging;
/**
* @private
* @type {Array}
*/
this._covers = [];
/**
* @private
* @type {moudule:zrender/container/Group}
*/
this._creatingCover;
/**
* `true` means global panel
* @private
* @type {module:zrender/container/Group|boolean}
*/
this._creatingPanel;
/**
* @private
* @type {boolean}
*/
this._enableGlobalPan;
/**
* @private
* @type {boolean}
*/
if (__DEV__) {
this._mounted;
}
/**
* @private
* @type {string}
*/
this._uid = 'brushController_' + baseUID++;
/**
* @private
* @type {Object}
*/
this._handlers = {};
each(mouseHandlers, function (handler, eventName) {
this._handlers[eventName] = zrUtil.bind(handler, this);
}, this);
} | javascript | function BrushController(zr) {
if (__DEV__) {
zrUtil.assert(zr);
}
Eventful.call(this);
/**
* @type {module:zrender/zrender~ZRender}
* @private
*/
this._zr = zr;
/**
* @type {module:zrender/container/Group}
* @readOnly
*/
this.group = new graphic.Group();
/**
* Only for drawing (after enabledBrush).
* 'line', 'rect', 'polygon' or false
* If passing false/null/undefined, disable brush.
* If passing 'auto', determined by panel.defaultBrushType
* @private
* @type {string}
*/
this._brushType;
/**
* Only for drawing (after enabledBrush).
*
* @private
* @type {Object}
*/
this._brushOption;
/**
* @private
* @type {Object}
*/
this._panels;
/**
* @private
* @type {Array.<nubmer>}
*/
this._track = [];
/**
* @private
* @type {boolean}
*/
this._dragging;
/**
* @private
* @type {Array}
*/
this._covers = [];
/**
* @private
* @type {moudule:zrender/container/Group}
*/
this._creatingCover;
/**
* `true` means global panel
* @private
* @type {module:zrender/container/Group|boolean}
*/
this._creatingPanel;
/**
* @private
* @type {boolean}
*/
this._enableGlobalPan;
/**
* @private
* @type {boolean}
*/
if (__DEV__) {
this._mounted;
}
/**
* @private
* @type {string}
*/
this._uid = 'brushController_' + baseUID++;
/**
* @private
* @type {Object}
*/
this._handlers = {};
each(mouseHandlers, function (handler, eventName) {
this._handlers[eventName] = zrUtil.bind(handler, this);
}, this);
} | [
"function",
"BrushController",
"(",
"zr",
")",
"{",
"if",
"(",
"__DEV__",
")",
"{",
"zrUtil",
".",
"assert",
"(",
"zr",
")",
";",
"}",
"Eventful",
".",
"call",
"(",
"this",
")",
";",
"/**\n * @type {module:zrender/zrender~ZRender}\n * @private\n */",
... | @alias module:echarts/component/helper/BrushController
@constructor
@mixin {module:zrender/mixin/Eventful}
@event module:echarts/component/helper/BrushController#brush
params:
areas: Array.<Array>, coord relates to container group,
If no container specified, to global.
opt {
isEnd: boolean,
removeOnClick: boolean
}
@param {module:zrender/zrender~ZRender} zr | [
"@alias",
"module",
":",
"echarts",
"/",
"component",
"/",
"helper",
"/",
"BrushController",
"@constructor",
"@mixin",
"{",
"module",
":",
"zrender",
"/",
"mixin",
"/",
"Eventful",
"}",
"@event",
"module",
":",
"echarts",
"/",
"component",
"/",
"helper",
"/"... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/helper/BrushController.js#L83-L186 | train | The controller for the brush. | [
30522,
3853,
8248,
8663,
13181,
10820,
1006,
1062,
2099,
1007,
1063,
2065,
1006,
1035,
1035,
16475,
1035,
1035,
1007,
1063,
1062,
22134,
4014,
1012,
20865,
1006,
1062,
2099,
1007,
1025,
1065,
2724,
3993,
1012,
2655,
1006,
2023,
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... |
angular/material | src/core/services/gesture/gesture.js | addHandler | function addHandler(name, definition) {
var handler = new $$MdGestureHandler(name);
angular.extend(handler, definition);
HANDLERS[name] = handler;
return self;
} | javascript | function addHandler(name, definition) {
var handler = new $$MdGestureHandler(name);
angular.extend(handler, definition);
HANDLERS[name] = handler;
return self;
} | [
"function",
"addHandler",
"(",
"name",
",",
"definition",
")",
"{",
"var",
"handler",
"=",
"new",
"$$MdGestureHandler",
"(",
"name",
")",
";",
"angular",
".",
"extend",
"(",
"handler",
",",
"definition",
")",
";",
"HANDLERS",
"[",
"name",
"]",
"=",
"hand... | /*
add a handler to $mdGesture. see below. | [
"/",
"*",
"add",
"a",
"handler",
"to",
"$mdGesture",
".",
"see",
"below",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L191-L197 | train | Adds a new gesture handler to the current container. | [
30522,
3853,
5587,
11774,
3917,
1006,
2171,
1010,
6210,
1007,
1063,
13075,
28213,
1027,
2047,
1002,
1002,
9108,
8449,
11244,
11774,
3917,
1006,
2171,
1007,
1025,
16108,
1012,
7949,
1006,
28213,
1010,
6210,
1007,
1025,
28213,
2015,
1031,
217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cypress-io/cypress | cli/lib/util.js | printNodeOptions | function printNodeOptions (log = debug) {
if (!log.enabled) {
return
}
if (process.env.NODE_OPTIONS) {
log('NODE_OPTIONS=%s', process.env.NODE_OPTIONS)
} else {
log('NODE_OPTIONS is not set')
}
} | javascript | function printNodeOptions (log = debug) {
if (!log.enabled) {
return
}
if (process.env.NODE_OPTIONS) {
log('NODE_OPTIONS=%s', process.env.NODE_OPTIONS)
} else {
log('NODE_OPTIONS is not set')
}
} | [
"function",
"printNodeOptions",
"(",
"log",
"=",
"debug",
")",
"{",
"if",
"(",
"!",
"log",
".",
"enabled",
")",
"{",
"return",
"}",
"if",
"(",
"process",
".",
"env",
".",
"NODE_OPTIONS",
")",
"{",
"log",
"(",
"'NODE_OPTIONS=%s'",
",",
"process",
".",
... | Prints NODE_OPTIONS using debug() module, but only
if DEBUG=cypress... is set | [
"Prints",
"NODE_OPTIONS",
"using",
"debug",
"()",
"module",
"but",
"only",
"if",
"DEBUG",
"=",
"cypress",
"...",
"is",
"set"
] | bf1a942944f0e99684ff7fe0e18314332e46f83e | https://github.com/cypress-io/cypress/blob/bf1a942944f0e99684ff7fe0e18314332e46f83e/cli/lib/util.js#L40-L50 | train | Print node options | [
30522,
3853,
6140,
3630,
3207,
7361,
9285,
1006,
8833,
1027,
2139,
8569,
2290,
1007,
1063,
2065,
1006,
999,
8833,
1012,
9124,
1007,
1063,
2709,
1065,
2065,
1006,
2832,
1012,
4372,
2615,
1012,
13045,
1035,
7047,
1007,
1063,
8833,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moleculerjs/moleculer | src/middlewares/circuit-breaker.js | checkThreshold | function checkThreshold(item, ctx) {
if (item.count >= item.opts.minRequestCount) {
const rate = item.failures / item.count;
if (rate >= item.opts.threshold)
trip(item, ctx);
}
} | javascript | function checkThreshold(item, ctx) {
if (item.count >= item.opts.minRequestCount) {
const rate = item.failures / item.count;
if (rate >= item.opts.threshold)
trip(item, ctx);
}
} | [
"function",
"checkThreshold",
"(",
"item",
",",
"ctx",
")",
"{",
"if",
"(",
"item",
".",
"count",
">=",
"item",
".",
"opts",
".",
"minRequestCount",
")",
"{",
"const",
"rate",
"=",
"item",
".",
"failures",
"/",
"item",
".",
"count",
";",
"if",
"(",
... | Check circuit-breaker failure threshold of Endpoint
@param {Object} item
@param {Context} ctx | [
"Check",
"circuit",
"-",
"breaker",
"failure",
"threshold",
"of",
"Endpoint"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L108-L114 | train | Check threshold for a request | [
30522,
3853,
4638,
2705,
21898,
11614,
1006,
8875,
1010,
14931,
2595,
1007,
1063,
2065,
1006,
8875,
1012,
4175,
1028,
1027,
8875,
1012,
23569,
2015,
1012,
8117,
2890,
15500,
3597,
16671,
1007,
1063,
9530,
3367,
3446,
1027,
8875,
1012,
15428... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PrefsCodeHints/main.js | formatHints | function formatHints(hints, query) {
var hasMetadata = hints.some(function (token) {
return token.type || token.description;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintItem = $("<span>").addClass("brackets-pref-hints"),
$hintObj = $("<span>").addClass("hint-obj");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
$hintItem.append($hintObj);
if (hasMetadata) {
$hintItem.data("type", token.type);
if (token.description) {
$hintItem.append($("<span>")
.addClass("hint-description")
.text(token.description));
}
}
return $hintItem;
});
} | javascript | function formatHints(hints, query) {
var hasMetadata = hints.some(function (token) {
return token.type || token.description;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintItem = $("<span>").addClass("brackets-pref-hints"),
$hintObj = $("<span>").addClass("hint-obj");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
$hintItem.append($hintObj);
if (hasMetadata) {
$hintItem.data("type", token.type);
if (token.description) {
$hintItem.append($("<span>")
.addClass("hint-description")
.text(token.description));
}
}
return $hintItem;
});
} | [
"function",
"formatHints",
"(",
"hints",
",",
"query",
")",
"{",
"var",
"hasMetadata",
"=",
"hints",
".",
"some",
"(",
"function",
"(",
"token",
")",
"{",
"return",
"token",
".",
"type",
"||",
"token",
".",
"description",
";",
"}",
")",
";",
"StringMat... | /*
Returns a sorted and formatted list of hints with the query substring
highlighted.
@param {Array.<Object>} hints - the list of hints to format
@param {string} query - querystring used for highlighting matched
portions of each hint
@return {Array.jQuery} sorted Array of jQuery DOM elements to insert | [
"/",
"*",
"Returns",
"a",
"sorted",
"and",
"formatted",
"list",
"of",
"hints",
"with",
"the",
"query",
"substring",
"highlighted",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/PrefsCodeHints/main.js#L124-L162 | train | Format hints for the given query | [
30522,
3853,
4289,
10606,
3215,
1006,
20385,
1010,
23032,
1007,
1063,
13075,
2038,
11368,
8447,
2696,
1027,
20385,
1012,
2070,
1006,
3853,
1006,
19204,
1007,
1063,
2709,
19204,
1012,
2828,
1064,
1064,
19204,
1012,
6412,
1025,
1065,
1007,
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... |
electron/electron | lib/renderer/api/remote.js | setObjectPrototype | function setObjectPrototype (ref, object, metaId, descriptor) {
if (descriptor === null) return
const proto = {}
setObjectMembers(ref, proto, metaId, descriptor.members)
setObjectPrototype(ref, proto, metaId, descriptor.proto)
Object.setPrototypeOf(object, proto)
} | javascript | function setObjectPrototype (ref, object, metaId, descriptor) {
if (descriptor === null) return
const proto = {}
setObjectMembers(ref, proto, metaId, descriptor.members)
setObjectPrototype(ref, proto, metaId, descriptor.proto)
Object.setPrototypeOf(object, proto)
} | [
"function",
"setObjectPrototype",
"(",
"ref",
",",
"object",
",",
"metaId",
",",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
"===",
"null",
")",
"return",
"const",
"proto",
"=",
"{",
"}",
"setObjectMembers",
"(",
"ref",
",",
"proto",
",",
"metaId",
... | Populate object's prototype from descriptor. This matches |getObjectPrototype| in rpc-server. | [
"Populate",
"object",
"s",
"prototype",
"from",
"descriptor",
".",
"This",
"matches",
"|getObjectPrototype|",
"in",
"rpc",
"-",
"server",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/renderer/api/remote.js#L165-L171 | train | set object prototype | [
30522,
3853,
2275,
16429,
20614,
21572,
3406,
13874,
1006,
25416,
1010,
4874,
1010,
18804,
3593,
1010,
4078,
23235,
2953,
1007,
1063,
2065,
1006,
4078,
23235,
2953,
1027,
1027,
1027,
19701,
1007,
2709,
9530,
3367,
15053,
1027,
1063,
1065,
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... |
aframevr/aframe | src/components/text.js | function () {
this.geometry.dispose();
this.geometry = null;
this.el.removeObject3D(this.attrName);
this.material.dispose();
this.material = null;
this.texture.dispose();
this.texture = null;
if (this.shaderObject) {
delete this.shaderObject;
}
} | javascript | function () {
this.geometry.dispose();
this.geometry = null;
this.el.removeObject3D(this.attrName);
this.material.dispose();
this.material = null;
this.texture.dispose();
this.texture = null;
if (this.shaderObject) {
delete this.shaderObject;
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"geometry",
".",
"dispose",
"(",
")",
";",
"this",
".",
"geometry",
"=",
"null",
";",
"this",
".",
"el",
".",
"removeObject3D",
"(",
"this",
".",
"attrName",
")",
";",
"this",
".",
"material",
".",
"dispose",
... | Clean up geometry, material, texture, mesh, objects. | [
"Clean",
"up",
"geometry",
"material",
"texture",
"mesh",
"objects",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L129-L140 | train | This method is called when the object is being disposed | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
10988,
1012,
27764,
1006,
1007,
1025,
2023,
1012,
10988,
1027,
19701,
1025,
2023,
1012,
3449,
1012,
6366,
16429,
20614,
29097,
1006,
2023,
1012,
2012,
16344,
18442,
1007,
1025,
2023,
1012,
3430,
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... | |
TryGhost/Ghost | core/server/services/auth/auth-strategies.js | ghostStrategy | function ghostStrategy(req, ghostAuthAccessToken, ghostAuthRefreshToken, profile, done) {
var inviteToken = req.body.inviteToken,
options = {context: {internal: true}},
handleInviteToken, handleSetup, handleSignIn;
// CASE: socket hangs up for example
if (!ghostAuthAccessToken || !profile) {
return done(new common.errors.NoPermissionError({
help: 'Please try again.'
}));
}
handleInviteToken = function handleInviteToken() {
var user, invite;
inviteToken = security.url.decodeBase64(inviteToken);
return models.Invite.findOne({token: inviteToken}, options)
.then(function addInviteUser(_invite) {
invite = _invite;
if (!invite) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.invites.inviteNotFound')
});
}
if (invite.get('expires') < Date.now()) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.invites.inviteExpired')
});
}
return models.User.add({
email: profile.email,
name: profile.name,
password: security.identifier.uid(50),
roles: [invite.toJSON().role_id],
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, options);
})
.then(function destroyInvite(_user) {
user = _user;
return invite.destroy(options);
})
.then(function () {
return user;
});
};
handleSetup = function handleSetup() {
return models.User.findOne({slug: 'ghost-owner', status: 'inactive'}, options)
.then(function fetchedOwner(owner) {
if (!owner) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.models.user.userNotFound')
});
}
// CASE: slug null forces regenerating the slug (ghost-owner is default and needs to be overridden)
return models.User.edit({
email: profile.email,
name: profile.name,
slug: null,
status: 'active',
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, _.merge({id: owner.id}, options));
});
};
handleSignIn = function handleSignIn() {
var user;
return models.User.findOne({ghost_auth_id: profile.id}, options)
.then(function (_user) {
user = _user;
if (!user) {
throw new common.errors.NotFoundError();
}
if (!user.isActive()) {
throw new common.errors.NoPermissionError({
message: common.i18n.t('errors.models.user.accountSuspended')
});
}
return models.User.edit({
email: profile.email,
name: profile.name,
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, _.merge({id: user.id}, options));
})
.then(function () {
return user;
});
};
if (inviteToken) {
return handleInviteToken()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
done(err);
});
}
handleSignIn()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
if (!(err instanceof common.errors.NotFoundError)) {
return done(err);
}
handleSetup()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
done(err);
});
});
} | javascript | function ghostStrategy(req, ghostAuthAccessToken, ghostAuthRefreshToken, profile, done) {
var inviteToken = req.body.inviteToken,
options = {context: {internal: true}},
handleInviteToken, handleSetup, handleSignIn;
// CASE: socket hangs up for example
if (!ghostAuthAccessToken || !profile) {
return done(new common.errors.NoPermissionError({
help: 'Please try again.'
}));
}
handleInviteToken = function handleInviteToken() {
var user, invite;
inviteToken = security.url.decodeBase64(inviteToken);
return models.Invite.findOne({token: inviteToken}, options)
.then(function addInviteUser(_invite) {
invite = _invite;
if (!invite) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.invites.inviteNotFound')
});
}
if (invite.get('expires') < Date.now()) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.invites.inviteExpired')
});
}
return models.User.add({
email: profile.email,
name: profile.name,
password: security.identifier.uid(50),
roles: [invite.toJSON().role_id],
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, options);
})
.then(function destroyInvite(_user) {
user = _user;
return invite.destroy(options);
})
.then(function () {
return user;
});
};
handleSetup = function handleSetup() {
return models.User.findOne({slug: 'ghost-owner', status: 'inactive'}, options)
.then(function fetchedOwner(owner) {
if (!owner) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.models.user.userNotFound')
});
}
// CASE: slug null forces regenerating the slug (ghost-owner is default and needs to be overridden)
return models.User.edit({
email: profile.email,
name: profile.name,
slug: null,
status: 'active',
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, _.merge({id: owner.id}, options));
});
};
handleSignIn = function handleSignIn() {
var user;
return models.User.findOne({ghost_auth_id: profile.id}, options)
.then(function (_user) {
user = _user;
if (!user) {
throw new common.errors.NotFoundError();
}
if (!user.isActive()) {
throw new common.errors.NoPermissionError({
message: common.i18n.t('errors.models.user.accountSuspended')
});
}
return models.User.edit({
email: profile.email,
name: profile.name,
ghost_auth_id: profile.id,
ghost_auth_access_token: ghostAuthAccessToken
}, _.merge({id: user.id}, options));
})
.then(function () {
return user;
});
};
if (inviteToken) {
return handleInviteToken()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
done(err);
});
}
handleSignIn()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
if (!(err instanceof common.errors.NotFoundError)) {
return done(err);
}
handleSetup()
.then(function (user) {
done(null, user, profile);
})
.catch(function (err) {
done(err);
});
});
} | [
"function",
"ghostStrategy",
"(",
"req",
",",
"ghostAuthAccessToken",
",",
"ghostAuthRefreshToken",
",",
"profile",
",",
"done",
")",
"{",
"var",
"inviteToken",
"=",
"req",
".",
"body",
".",
"inviteToken",
",",
"options",
"=",
"{",
"context",
":",
"{",
"inte... | Ghost Strategy
ghostAuthRefreshToken: will be null for now, because we don't need it right now
CASES:
- via invite token
- via normal sign in
- via setup | [
"Ghost",
"Strategy",
"ghostAuthRefreshToken",
":",
"will",
"be",
"null",
"for",
"now",
"because",
"we",
"don",
"t",
"need",
"it",
"right",
"now"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/auth/auth-strategies.js#L83-L210 | train | ghostStrategy - The ghost strategy | [
30522,
3853,
11277,
6494,
2618,
6292,
1006,
2128,
4160,
1010,
5745,
4887,
8322,
9468,
7971,
18715,
2368,
1010,
5745,
4887,
2705,
2890,
19699,
9953,
18715,
2368,
1010,
6337,
1010,
2589,
1007,
1063,
13075,
13260,
18715,
2368,
1027,
2128,
4160... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jquery-mobile-custom.js | function( ypos ) {
if ( $.type( ypos ) !== "number" ) {
ypos = $.mobile.defaultHomeScroll;
}
// prevent scrollstart and scrollstop events
$.event.special.scrollstart.enabled = false;
setTimeout( function() {
window.scrollTo( 0, ypos );
$.mobile.document.trigger( "silentscroll", { x: 0, y: ypos });
}, 20 );
setTimeout( function() {
$.event.special.scrollstart.enabled = true;
}, 150 );
} | javascript | function( ypos ) {
if ( $.type( ypos ) !== "number" ) {
ypos = $.mobile.defaultHomeScroll;
}
// prevent scrollstart and scrollstop events
$.event.special.scrollstart.enabled = false;
setTimeout( function() {
window.scrollTo( 0, ypos );
$.mobile.document.trigger( "silentscroll", { x: 0, y: ypos });
}, 20 );
setTimeout( function() {
$.event.special.scrollstart.enabled = true;
}, 150 );
} | [
"function",
"(",
"ypos",
")",
"{",
"if",
"(",
"$",
".",
"type",
"(",
"ypos",
")",
"!==",
"\"number\"",
")",
"{",
"ypos",
"=",
"$",
".",
"mobile",
".",
"defaultHomeScroll",
";",
"}",
"// prevent scrollstart and scrollstop events",
"$",
".",
"event",
".",
... | Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value | [
"Scroll",
"page",
"vertically",
":",
"scroll",
"to",
"0",
"to",
"hide",
"iOS",
"address",
"bar",
"or",
"pass",
"a",
"Y",
"value"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jquery-mobile-custom.js#L438-L454 | train | scroll to the home page | [
30522,
3853,
1006,
1061,
6873,
2015,
1007,
1063,
2065,
1006,
1002,
1012,
2828,
1006,
1061,
6873,
2015,
1007,
999,
1027,
1027,
1000,
2193,
1000,
1007,
1063,
1061,
6873,
2015,
1027,
1002,
1012,
4684,
1012,
12398,
23393,
2229,
26775,
14511,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableColumnUtils.js | function(oTable, sColumnId) {
TableColumnUtils.initColumnUtils(oTable);
var oSourceColumnMapItem = oTable._oColumnInfo.columnMap[sColumnId];
if (!oSourceColumnMapItem) {
Log.error("Column with ID '" + sColumnId + "' not found", oTable);
} else {
return oSourceColumnMapItem;
}
} | javascript | function(oTable, sColumnId) {
TableColumnUtils.initColumnUtils(oTable);
var oSourceColumnMapItem = oTable._oColumnInfo.columnMap[sColumnId];
if (!oSourceColumnMapItem) {
Log.error("Column with ID '" + sColumnId + "' not found", oTable);
} else {
return oSourceColumnMapItem;
}
} | [
"function",
"(",
"oTable",
",",
"sColumnId",
")",
"{",
"TableColumnUtils",
".",
"initColumnUtils",
"(",
"oTable",
")",
";",
"var",
"oSourceColumnMapItem",
"=",
"oTable",
".",
"_oColumnInfo",
".",
"columnMap",
"[",
"sColumnId",
"]",
";",
"if",
"(",
"!",
"oSou... | Get the column map item for the column identified by <code>sColumnId</code>.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {string} sColumnId ID of the column.
@returns {ColumnMapItem | undefined} Column map item with detailed column information.
@private | [
"Get",
"the",
"column",
"map",
"item",
"for",
"the",
"column",
"identified",
"by",
"<code",
">",
"sColumnId<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js#L164-L172 | train | Returns the column map item for the given column ID. | [
30522,
3853,
1006,
27178,
3085,
1010,
8040,
4747,
2819,
3490,
2094,
1007,
1063,
2795,
25778,
2819,
24072,
12146,
1012,
1999,
4183,
25778,
2819,
24072,
12146,
1006,
27178,
3085,
1007,
1025,
13075,
9808,
8162,
3401,
25778,
2819,
2078,
2863,
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... | |
summernote/summernote | src/js/base/core/dom.js | html | function html($node, isNewlineOnBlock) {
let markup = value($node);
if (isNewlineOnBlock) {
const regexTag = /<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;
markup = markup.replace(regexTag, function(match, endSlash, name) {
name = name.toUpperCase();
const isEndOfInlineContainer = /^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(name) &&
!!endSlash;
const isBlockNode = /^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(name);
return match + ((isEndOfInlineContainer || isBlockNode) ? '\n' : '');
});
markup = markup.trim();
}
return markup;
} | javascript | function html($node, isNewlineOnBlock) {
let markup = value($node);
if (isNewlineOnBlock) {
const regexTag = /<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;
markup = markup.replace(regexTag, function(match, endSlash, name) {
name = name.toUpperCase();
const isEndOfInlineContainer = /^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(name) &&
!!endSlash;
const isBlockNode = /^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(name);
return match + ((isEndOfInlineContainer || isBlockNode) ? '\n' : '');
});
markup = markup.trim();
}
return markup;
} | [
"function",
"html",
"(",
"$node",
",",
"isNewlineOnBlock",
")",
"{",
"let",
"markup",
"=",
"value",
"(",
"$node",
")",
";",
"if",
"(",
"isNewlineOnBlock",
")",
"{",
"const",
"regexTag",
"=",
"/",
"<(\\/?)(\\b(?!!)[^>\\s]*)(.*?)(\\s*\\/?>)",
"/",
"g",
";",
"m... | @method html
get the HTML contents of node
@param {jQuery} $node
@param {Boolean} [isNewlineOnBlock] | [
"@method",
"html"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L961-L978 | train | HTML markup | [
30522,
3853,
16129,
1006,
1002,
13045,
1010,
3475,
7974,
4179,
2239,
23467,
1007,
1063,
2292,
2928,
6279,
1027,
3643,
1006,
1002,
13045,
1007,
1025,
2065,
1006,
3475,
7974,
4179,
2239,
23467,
1007,
1063,
9530,
3367,
19723,
10288,
15900,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/hand-controls.js | function (button, evt) {
var lastGesture;
var isPressed = evt === 'down';
var isTouched = evt === 'touchstart';
// Update objects.
if (evt.indexOf('touch') === 0) {
// Update touch object.
if (isTouched === this.touchedButtons[button]) { return; }
this.touchedButtons[button] = isTouched;
} else {
// Update button object.
if (isPressed === this.pressedButtons[button]) { return; }
this.pressedButtons[button] = isPressed;
}
// Determine the gesture.
lastGesture = this.gesture;
this.gesture = this.determineGesture();
// Same gesture.
if (this.gesture === lastGesture) { return; }
// Animate gesture.
this.animateGesture(this.gesture, lastGesture);
// Emit events.
this.emitGestureEvents(this.gesture, lastGesture);
} | javascript | function (button, evt) {
var lastGesture;
var isPressed = evt === 'down';
var isTouched = evt === 'touchstart';
// Update objects.
if (evt.indexOf('touch') === 0) {
// Update touch object.
if (isTouched === this.touchedButtons[button]) { return; }
this.touchedButtons[button] = isTouched;
} else {
// Update button object.
if (isPressed === this.pressedButtons[button]) { return; }
this.pressedButtons[button] = isPressed;
}
// Determine the gesture.
lastGesture = this.gesture;
this.gesture = this.determineGesture();
// Same gesture.
if (this.gesture === lastGesture) { return; }
// Animate gesture.
this.animateGesture(this.gesture, lastGesture);
// Emit events.
this.emitGestureEvents(this.gesture, lastGesture);
} | [
"function",
"(",
"button",
",",
"evt",
")",
"{",
"var",
"lastGesture",
";",
"var",
"isPressed",
"=",
"evt",
"===",
"'down'",
";",
"var",
"isTouched",
"=",
"evt",
"===",
"'touchstart'",
";",
"// Update objects.",
"if",
"(",
"evt",
".",
"indexOf",
"(",
"'t... | Play model animation, based on which button was pressed and which kind of event.
1. Process buttons.
2. Determine gesture (this.determineGesture()).
3. Animation gesture (this.animationGesture()).
4. Emit gesture events (this.emitGestureEvents()).
@param {string} button - Name of the button.
@param {string} evt - Type of event for the button (i.e., down/up/touchstart/touchend). | [
"Play",
"model",
"animation",
"based",
"on",
"which",
"button",
"was",
"pressed",
"and",
"which",
"kind",
"of",
"event",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/hand-controls.js#L209-L236 | train | Update the state of the gesture. | [
30522,
3853,
1006,
6462,
1010,
23408,
2102,
1007,
1063,
13075,
2197,
8449,
11244,
1025,
13075,
2003,
19811,
1027,
23408,
2102,
1027,
1027,
1027,
1005,
2091,
1005,
1025,
13075,
21541,
7140,
7690,
1027,
23408,
2102,
1027,
1027,
1027,
1005,
35... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | amdDefine | function amdDefine(sModuleName, aDependencies, vFactory) {
var oArgs = arguments;
var bExportIsSet = typeof oArgs[oArgs.length - 1] === "boolean";
// bExport parameter is proprietary and should not be used for an AMD compliant define()
if (bExportIsSet) {
oArgs = Array.prototype.slice.call(oArgs, 0, oArgs.length - 1);
}
ui5Define.apply(this, oArgs);
} | javascript | function amdDefine(sModuleName, aDependencies, vFactory) {
var oArgs = arguments;
var bExportIsSet = typeof oArgs[oArgs.length - 1] === "boolean";
// bExport parameter is proprietary and should not be used for an AMD compliant define()
if (bExportIsSet) {
oArgs = Array.prototype.slice.call(oArgs, 0, oArgs.length - 1);
}
ui5Define.apply(this, oArgs);
} | [
"function",
"amdDefine",
"(",
"sModuleName",
",",
"aDependencies",
",",
"vFactory",
")",
"{",
"var",
"oArgs",
"=",
"arguments",
";",
"var",
"bExportIsSet",
"=",
"typeof",
"oArgs",
"[",
"oArgs",
".",
"length",
"-",
"1",
"]",
"===",
"\"boolean\"",
";",
"// b... | The amdDefine() function is closer to the AMD spec, as opposed to sap.ui.define.
It's later assigned as the global define() if the loader is running in amd=true
mode (has to be configured explicitly). | [
"The",
"amdDefine",
"()",
"function",
"is",
"closer",
"to",
"the",
"AMD",
"spec",
"as",
"opposed",
"to",
"sap",
".",
"ui",
".",
"define",
".",
"It",
"s",
"later",
"assigned",
"as",
"the",
"global",
"define",
"()",
"if",
"the",
"loader",
"is",
"running"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L1807-L1817 | train | Define a module with a list of dependencies | [
30522,
3853,
2572,
14141,
12879,
3170,
1006,
15488,
7716,
9307,
18442,
1010,
4748,
13699,
10497,
15266,
1010,
1058,
21450,
1007,
1063,
13075,
1051,
2906,
5620,
1027,
9918,
1025,
13075,
2022,
2595,
6442,
23491,
2102,
1027,
2828,
11253,
1051,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Locale.js | function() {
var sLanguage = this.sLanguage || "",
m;
// cut off any ext. language sub tags
if ( sLanguage.indexOf("-") >= 0 ) {
sLanguage = sLanguage.slice(0, sLanguage.indexOf("-"));
}
// convert to new ISO codes
sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
// handle special cases for Chinese: map 'Traditional Chinese' (or region TW which implies Traditional) to 'zf'
if ( sLanguage === "zh" ) {
if ( this.sScript === "Hant" || (!this.sScript && this.sRegion === "TW") ) {
sLanguage = "zf";
}
}
// recognize SAP supportability pseudo languages
if ( this.sPrivateUse && (m = /-(saptrc|sappsd)(?:-|$)/i.exec(this.sPrivateUse)) ) {
sLanguage = (m[1].toLowerCase() === "saptrc") ? "1Q" : "2Q";
}
// by convention, SAP systems seem to use uppercase letters
return sLanguage.toUpperCase();
} | javascript | function() {
var sLanguage = this.sLanguage || "",
m;
// cut off any ext. language sub tags
if ( sLanguage.indexOf("-") >= 0 ) {
sLanguage = sLanguage.slice(0, sLanguage.indexOf("-"));
}
// convert to new ISO codes
sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
// handle special cases for Chinese: map 'Traditional Chinese' (or region TW which implies Traditional) to 'zf'
if ( sLanguage === "zh" ) {
if ( this.sScript === "Hant" || (!this.sScript && this.sRegion === "TW") ) {
sLanguage = "zf";
}
}
// recognize SAP supportability pseudo languages
if ( this.sPrivateUse && (m = /-(saptrc|sappsd)(?:-|$)/i.exec(this.sPrivateUse)) ) {
sLanguage = (m[1].toLowerCase() === "saptrc") ? "1Q" : "2Q";
}
// by convention, SAP systems seem to use uppercase letters
return sLanguage.toUpperCase();
} | [
"function",
"(",
")",
"{",
"var",
"sLanguage",
"=",
"this",
".",
"sLanguage",
"||",
"\"\"",
",",
"m",
";",
"// cut off any ext. language sub tags",
"if",
"(",
"sLanguage",
".",
"indexOf",
"(",
"\"-\"",
")",
">=",
"0",
")",
"{",
"sLanguage",
"=",
"sLanguage... | Best guess to get a proper SAP Logon Language for this locale.
Conversions taken into account:
<ul>
<li>use the language part only</li>
<li>convert old ISO639 codes to newer ones (e.g. 'iw' to 'he')</li>
<li>for Chinese, map 'Traditional Chinese' to SAP proprietary code 'zf'</li>
<li>map private extensions x-sap1q and x-sap2q to SAP pseudo languages '1Q' and '2Q'</li>
<li>remove ext. language sub tags</li>
<li>convert to uppercase</li>
</ul>
Note that the conversion also returns a result for languages that are not
supported by the default set of SAP languages. This method has no knowledge
about the concrete languages of any given backend system.
@return {string} a language code that should
@public
@since 1.17.0
@deprecated As of 1.44, use {@link sap.ui.core.Configuration#getSAPLogonLanguage} instead
as that class allows to configure an SAP Logon language. | [
"Best",
"guess",
"to",
"get",
"a",
"proper",
"SAP",
"Logon",
"Language",
"for",
"this",
"locale",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Locale.js#L241-L268 | train | Returns the language code for the current language. | [
30522,
3853,
1006,
1007,
1063,
13075,
21435,
6692,
3351,
1027,
2023,
1012,
21435,
6692,
3351,
1064,
1064,
1000,
1000,
1010,
1049,
1025,
1013,
1013,
3013,
2125,
2151,
4654,
2102,
1012,
2653,
4942,
22073,
2065,
1006,
21435,
6692,
3351,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | tasks/generate-index.js | formatSymbolExport | function formatSymbolExport(symbol, namespaces, imports) {
const name = symbol.name;
const parts = name.split('~');
const isNamed = parts[0].indexOf('.') !== -1;
const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
const last = nsParts.length - 1;
const importName = isNamed ?
'_' + nsParts.slice(0, last).join('_') + '$' + nsParts[last] :
'$' + nsParts.join('$');
let line = nsParts[0];
for (let i = 1, ii = nsParts.length; i < ii; ++i) {
line += `.${nsParts[i]}`;
namespaces[line] = (line in namespaces ? namespaces[line] : true) && i < ii - 1;
}
line += ` = ${importName};`;
imports[getImport(symbol, nsParts.pop())] = true;
return line;
} | javascript | function formatSymbolExport(symbol, namespaces, imports) {
const name = symbol.name;
const parts = name.split('~');
const isNamed = parts[0].indexOf('.') !== -1;
const nsParts = parts[0].replace(/^module\:/, '').split(/[\/\.]/);
const last = nsParts.length - 1;
const importName = isNamed ?
'_' + nsParts.slice(0, last).join('_') + '$' + nsParts[last] :
'$' + nsParts.join('$');
let line = nsParts[0];
for (let i = 1, ii = nsParts.length; i < ii; ++i) {
line += `.${nsParts[i]}`;
namespaces[line] = (line in namespaces ? namespaces[line] : true) && i < ii - 1;
}
line += ` = ${importName};`;
imports[getImport(symbol, nsParts.pop())] = true;
return line;
} | [
"function",
"formatSymbolExport",
"(",
"symbol",
",",
"namespaces",
",",
"imports",
")",
"{",
"const",
"name",
"=",
"symbol",
".",
"name",
";",
"const",
"parts",
"=",
"name",
".",
"split",
"(",
"'~'",
")",
";",
"const",
"isNamed",
"=",
"parts",
"[",
"0... | Generate code to export a named symbol.
@param {Object} symbol Symbol.
@param {Object<string, string>} namespaces Already defined namespaces.
@param {Object} imports Imports.
@return {string} Export code. | [
"Generate",
"code",
"to",
"export",
"a",
"named",
"symbol",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L43-L60 | train | Format symbol export | [
30522,
3853,
11630,
24335,
14956,
10288,
6442,
1006,
6454,
1010,
3415,
15327,
2015,
1010,
17589,
1007,
1063,
9530,
3367,
2171,
1027,
6454,
1012,
2171,
1025,
9530,
3367,
3033,
1027,
2171,
1012,
3975,
1006,
1005,
1066,
1005,
1007,
1025,
9530,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-self-compare.js | hasSameTokens | function hasSameTokens(nodeA, nodeB) {
const tokensA = sourceCode.getTokens(nodeA);
const tokensB = sourceCode.getTokens(nodeB);
return tokensA.length === tokensB.length &&
tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value);
} | javascript | function hasSameTokens(nodeA, nodeB) {
const tokensA = sourceCode.getTokens(nodeA);
const tokensB = sourceCode.getTokens(nodeB);
return tokensA.length === tokensB.length &&
tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value);
} | [
"function",
"hasSameTokens",
"(",
"nodeA",
",",
"nodeB",
")",
"{",
"const",
"tokensA",
"=",
"sourceCode",
".",
"getTokens",
"(",
"nodeA",
")",
";",
"const",
"tokensB",
"=",
"sourceCode",
".",
"getTokens",
"(",
"nodeB",
")",
";",
"return",
"tokensA",
".",
... | Determines whether two nodes are composed of the same tokens.
@param {ASTNode} nodeA The first node
@param {ASTNode} nodeB The second node
@returns {boolean} true if the nodes have identical token representations | [
"Determines",
"whether",
"two",
"nodes",
"are",
"composed",
"of",
"the",
"same",
"tokens",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-compare.js#L36-L42 | train | Check if two nodes have the same tokens | [
30522,
3853,
2038,
21559,
18903,
7520,
2015,
1006,
13045,
2050,
1010,
13045,
2497,
1007,
1063,
9530,
3367,
19204,
3736,
1027,
30524,
1004,
1004,
19204,
3736,
1012,
2296,
1006,
1006,
19204,
1010,
5950,
1007,
1027,
1028,
19204,
1012,
2828,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableAccExtension.js | function(oExtension, sType, mParams) {
var mAttributes = {},
oTable = oExtension.getTable(),
sTableId = oTable.getId();
function addAriaForOverlayOrNoData(oTable, mAttr, bOverlay, bNoData) {
var sMarker = "";
if (bOverlay && bNoData) {
sMarker = "overlay,nodata";
} else if (bOverlay && !bNoData) {
sMarker = "overlay";
} else if (!bOverlay && bNoData) {
sMarker = "nodata";
}
var bHidden = false;
if (bOverlay && oTable.getShowOverlay() || bNoData && TableUtils.isNoDataVisible(oTable)) {
bHidden = true;
}
if (bHidden) {
mAttributes["aria-hidden"] = "true";
}
if (sMarker) {
mAttributes["data-sap-ui-table-acc-covered"] = sMarker;
}
}
switch (sType) {
case TableAccExtension.ELEMENTTYPES.COLUMNROWHEADER:
mAttributes["aria-labelledby"] = [sTableId + "-ariacolrowheaderlabel"];
mAttributes["role"] = ["button"];
if (mParams && mParams.enabled) {
mAttributes["aria-pressed"] = mParams.checked ? "true" : "false";
} else {
mAttributes["aria-disabled"] = "true";
mAttributes["aria-pressed"] = "false";
}
if (!oTable._getShowStandardTooltips() && oTable._oSelectionPlugin.getRenderConfig().headerSelector.type === "toggle") {
mAttributes["aria-labelledby"].push(sTableId + "-ariaselectall");
}
break;
case TableAccExtension.ELEMENTTYPES.ROWHEADER:
mAttributes["role"] = "rowheader";
if (Device.browser.msie) {
mAttributes["aria-labelledby"] = [sTableId + "-ariarowheaderlabel"];
}
if (oTable.getSelectionMode() !== SelectionMode.None && (!mParams || !mParams.rowHidden)) {
var bSelected = mParams && mParams.rowSelected;
mAttributes["aria-selected"] = "" + bSelected;
var mTooltipTexts = oExtension.getAriaTextsForSelectionMode(true);
mAttributes["title"] = mTooltipTexts.mouse[bSelected ? "rowDeselect" : "rowSelect"];
}
break;
case TableAccExtension.ELEMENTTYPES.ROWACTION:
mAttributes["role"] = "gridcell";
mAttributes["aria-labelledby"] = [sTableId + "-rowacthdr"];
if (oTable.getSelectionMode() !== SelectionMode.None && (!mParams || !mParams.rowHidden)) {
var bSelected = mParams && mParams.rowSelected;
mAttributes["aria-selected"] = "" + bSelected;
}
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER:
var oColumn = mParams && mParams.column;
var bHasColSpan = mParams && mParams.colspan;
mAttributes["role"] = "columnheader";
var aLabels = [];
if (mParams && mParams.headerId) {
var aHeaders = ExtensionHelper.getRelevantColumnHeaders(oTable, oColumn);
var iIdx = aHeaders.indexOf(mParams.headerId);
aLabels = iIdx > 0 ? aHeaders.slice(0, iIdx + 1) : [mParams.headerId];
}
for (var i = 0; i < aLabels.length; i++) {
aLabels[i] = aLabels[i] + "-inner";
}
mAttributes["aria-labelledby"] = aLabels;
if (mParams && (mParams.index < oTable.getComputedFixedColumnCount())) {
mAttributes["aria-labelledby"].push(sTableId + "-ariafixedcolumn");
}
if (!bHasColSpan && oColumn && oColumn.getSorted()) {
mAttributes["aria-sort"] = oColumn.getSortOrder() === "Ascending" ? "ascending" : "descending";
}
if (!bHasColSpan && oColumn && oColumn._menuHasItems()) {
mAttributes["aria-haspopup"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.DATACELL:
mAttributes["role"] = "gridcell";
var aLabels = [],
oColumn = mParams && mParams.column ? mParams.column : null;
if (oColumn) {
aLabels = ExtensionHelper.getRelevantColumnHeaders(oTable, oColumn);
mAttributes["headers"] = aLabels.join(" ");
for (var i = 0; i < aLabels.length; i++) {
aLabels[i] = aLabels[i] + "-inner";
}
if (mParams && mParams.fixed) {
aLabels.push(sTableId + "-ariafixedcolumn");
}
}
mAttributes["aria-labelledby"] = aLabels;
if (oTable.getSelectionMode() !== SelectionMode.None && mParams && mParams.rowSelected) {
mAttributes["aria-selected"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.ROOT: //The tables root dom element
break;
case TableAccExtension.ELEMENTTYPES.TABLE: //The "real" table element(s)
mAttributes["role"] = "presentation";
addAriaForOverlayOrNoData(oTable, mAttributes, true, true);
break;
case TableAccExtension.ELEMENTTYPES.CONTENT: //The content area of the table which contains all the table elements, rowheaders, columnheaders, etc
mAttributes["role"] = TableUtils.Grouping.isGroupMode(oTable) || TableUtils.Grouping.isTreeMode(oTable) ? "treegrid" : "grid";
mAttributes["aria-labelledby"] = [].concat(oTable.getAriaLabelledBy());
if (oTable.getTitle()) {
mAttributes["aria-labelledby"].push(oTable.getTitle().getId());
}
if (oTable.getSelectionMode() === SelectionMode.MultiToggle) {
mAttributes["aria-multiselectable"] = "true";
}
var bHasFixedColumns = TableUtils.hasFixedColumns(oTable);
var bHasFixedTopRows = oTable.getFixedRowCount() > 0;
var bHasFixedBottomRows = oTable.getFixedBottomRowCount() > 0;
var bHasRowHeader = TableUtils.hasRowHeader(oTable);
var bHasRowActions = TableUtils.hasRowActions(oTable);
mAttributes["aria-owns"] = [sTableId + "-table"];
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed");
}
if (bHasFixedTopRows) {
mAttributes["aria-owns"].push(sTableId + "-table-fixrow");
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed-fixrow");
}
}
if (bHasFixedBottomRows) {
mAttributes["aria-owns"].push(sTableId + "-table-fixrow-bottom");
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed-fixrow-bottom");
}
}
if (bHasRowHeader) {
mAttributes["aria-owns"].push(sTableId + "-sapUiTableRowHdrScr");
}
if (bHasRowActions) {
mAttributes["aria-owns"].push(sTableId + "-sapUiTableRowActionScr");
}
break;
case TableAccExtension.ELEMENTTYPES.TABLEHEADER: //The table header area
mAttributes["role"] = "heading";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER_TBL: //Table of column headers
mAttributes["role"] = "presentation";
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER_ROW: //The area which contains the column headers
mAttributes["role"] = "row";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.CREATIONROW_TBL: // Table of the creation row
mAttributes["role"] = "presentation";
break;
case TableAccExtension.ELEMENTTYPES.CREATIONROW: // Root of the creation row
mAttributes["role"] = "form";
mAttributes["aria-labelledby"] = mParams.creationRow.getId() + "-label";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.ROWHEADER_COL: //The area which contains the row headers
addAriaForOverlayOrNoData(oTable, mAttributes, true, true);
break;
case TableAccExtension.ELEMENTTYPES.TH: //The "technical" column headers
var bHasFixedColumns = oTable.getComputedFixedColumnCount() > 0;
if (!bHasFixedColumns) {
mAttributes["role"] = "presentation";
}
mAttributes["scope"] = "col";
if (bHasFixedColumns) {
if (mParams && mParams.column) {
mAttributes["aria-owns"] = mParams.column.getId();
mAttributes["aria-labelledby"] = [mParams.column.getId()];
}
} else {
mAttributes["aria-hidden"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.TR: //The rows
mAttributes["role"] = "row";
var bSelected = false;
if (mParams && typeof mParams.index === "number" && oTable.getSelectionMode() !== SelectionMode.None
&& oTable.isIndexSelected(mParams.index)) {
mAttributes["aria-selected"] = "true";
bSelected = true;
}
if (TableUtils.isRowSelectionAllowed(oTable) && oTable.getContextByIndex(mParams.index)) {
var mTooltipTexts = oExtension.getAriaTextsForSelectionMode(true);
mAttributes["title"] = mTooltipTexts.mouse[bSelected ? "rowDeselect" : "rowSelect"];
}
break;
case TableAccExtension.ELEMENTTYPES.TREEICON: //The expand/collapse icon in the TreeTable
if (TableUtils.Grouping.isTreeMode(oTable)) {
mAttributes = {
"aria-label": "",
"title": "",
"role": ""
};
if (oTable.getBinding("rows")) {
if (mParams && mParams.row) {
if (mParams.row._bHasChildren) {
var sText = TableUtils.getResourceText(mParams.row._bIsExpanded ? "TBL_COLLAPSE" : "TBL_EXPAND");
if (oTable._getShowStandardTooltips()) {
mAttributes["title"] = sText;
} else {
mAttributes["aria-label"] = sText;
}
mAttributes["aria-expanded"] = "" + (!!mParams.row._bIsExpanded);
mAttributes["aria-hidden"] = "false";
mAttributes["role"] = "button";
} else {
mAttributes["aria-label"] = TableUtils.getResourceText("TBL_LEAF");
mAttributes["aria-hidden"] = "true";
}
}
}
}
break;
case TableAccExtension.ELEMENTTYPES.NODATA: //The no data container
mAttributes["role"] = "gridcell";
var oNoData = oTable.getNoData();
mAttributes["aria-labelledby"] = [oNoData instanceof Control ? oNoData.getId() : (sTableId + "-noDataMsg")];
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.OVERLAY: //The overlay container
mAttributes["role"] = "region";
mAttributes["aria-labelledby"] = [].concat(oTable.getAriaLabelledBy());
if (oTable.getTitle()) {
mAttributes["aria-labelledby"].push(oTable.getTitle().getId());
}
mAttributes["aria-labelledby"].push(sTableId + "-ariainvalid");
break;
case TableAccExtension.ELEMENTTYPES.TABLEFOOTER: //The table footer area
case TableAccExtension.ELEMENTTYPES.TABLESUBHEADER: //The table toolbar and extension areas
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.ROWACTIONHEADER: // The header of the row action column
mAttributes["aria-hidden"] = "true";
break;
case "PRESENTATION":
mAttributes["role"] = "presentation";
break;
}
return mAttributes;
} | javascript | function(oExtension, sType, mParams) {
var mAttributes = {},
oTable = oExtension.getTable(),
sTableId = oTable.getId();
function addAriaForOverlayOrNoData(oTable, mAttr, bOverlay, bNoData) {
var sMarker = "";
if (bOverlay && bNoData) {
sMarker = "overlay,nodata";
} else if (bOverlay && !bNoData) {
sMarker = "overlay";
} else if (!bOverlay && bNoData) {
sMarker = "nodata";
}
var bHidden = false;
if (bOverlay && oTable.getShowOverlay() || bNoData && TableUtils.isNoDataVisible(oTable)) {
bHidden = true;
}
if (bHidden) {
mAttributes["aria-hidden"] = "true";
}
if (sMarker) {
mAttributes["data-sap-ui-table-acc-covered"] = sMarker;
}
}
switch (sType) {
case TableAccExtension.ELEMENTTYPES.COLUMNROWHEADER:
mAttributes["aria-labelledby"] = [sTableId + "-ariacolrowheaderlabel"];
mAttributes["role"] = ["button"];
if (mParams && mParams.enabled) {
mAttributes["aria-pressed"] = mParams.checked ? "true" : "false";
} else {
mAttributes["aria-disabled"] = "true";
mAttributes["aria-pressed"] = "false";
}
if (!oTable._getShowStandardTooltips() && oTable._oSelectionPlugin.getRenderConfig().headerSelector.type === "toggle") {
mAttributes["aria-labelledby"].push(sTableId + "-ariaselectall");
}
break;
case TableAccExtension.ELEMENTTYPES.ROWHEADER:
mAttributes["role"] = "rowheader";
if (Device.browser.msie) {
mAttributes["aria-labelledby"] = [sTableId + "-ariarowheaderlabel"];
}
if (oTable.getSelectionMode() !== SelectionMode.None && (!mParams || !mParams.rowHidden)) {
var bSelected = mParams && mParams.rowSelected;
mAttributes["aria-selected"] = "" + bSelected;
var mTooltipTexts = oExtension.getAriaTextsForSelectionMode(true);
mAttributes["title"] = mTooltipTexts.mouse[bSelected ? "rowDeselect" : "rowSelect"];
}
break;
case TableAccExtension.ELEMENTTYPES.ROWACTION:
mAttributes["role"] = "gridcell";
mAttributes["aria-labelledby"] = [sTableId + "-rowacthdr"];
if (oTable.getSelectionMode() !== SelectionMode.None && (!mParams || !mParams.rowHidden)) {
var bSelected = mParams && mParams.rowSelected;
mAttributes["aria-selected"] = "" + bSelected;
}
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER:
var oColumn = mParams && mParams.column;
var bHasColSpan = mParams && mParams.colspan;
mAttributes["role"] = "columnheader";
var aLabels = [];
if (mParams && mParams.headerId) {
var aHeaders = ExtensionHelper.getRelevantColumnHeaders(oTable, oColumn);
var iIdx = aHeaders.indexOf(mParams.headerId);
aLabels = iIdx > 0 ? aHeaders.slice(0, iIdx + 1) : [mParams.headerId];
}
for (var i = 0; i < aLabels.length; i++) {
aLabels[i] = aLabels[i] + "-inner";
}
mAttributes["aria-labelledby"] = aLabels;
if (mParams && (mParams.index < oTable.getComputedFixedColumnCount())) {
mAttributes["aria-labelledby"].push(sTableId + "-ariafixedcolumn");
}
if (!bHasColSpan && oColumn && oColumn.getSorted()) {
mAttributes["aria-sort"] = oColumn.getSortOrder() === "Ascending" ? "ascending" : "descending";
}
if (!bHasColSpan && oColumn && oColumn._menuHasItems()) {
mAttributes["aria-haspopup"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.DATACELL:
mAttributes["role"] = "gridcell";
var aLabels = [],
oColumn = mParams && mParams.column ? mParams.column : null;
if (oColumn) {
aLabels = ExtensionHelper.getRelevantColumnHeaders(oTable, oColumn);
mAttributes["headers"] = aLabels.join(" ");
for (var i = 0; i < aLabels.length; i++) {
aLabels[i] = aLabels[i] + "-inner";
}
if (mParams && mParams.fixed) {
aLabels.push(sTableId + "-ariafixedcolumn");
}
}
mAttributes["aria-labelledby"] = aLabels;
if (oTable.getSelectionMode() !== SelectionMode.None && mParams && mParams.rowSelected) {
mAttributes["aria-selected"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.ROOT: //The tables root dom element
break;
case TableAccExtension.ELEMENTTYPES.TABLE: //The "real" table element(s)
mAttributes["role"] = "presentation";
addAriaForOverlayOrNoData(oTable, mAttributes, true, true);
break;
case TableAccExtension.ELEMENTTYPES.CONTENT: //The content area of the table which contains all the table elements, rowheaders, columnheaders, etc
mAttributes["role"] = TableUtils.Grouping.isGroupMode(oTable) || TableUtils.Grouping.isTreeMode(oTable) ? "treegrid" : "grid";
mAttributes["aria-labelledby"] = [].concat(oTable.getAriaLabelledBy());
if (oTable.getTitle()) {
mAttributes["aria-labelledby"].push(oTable.getTitle().getId());
}
if (oTable.getSelectionMode() === SelectionMode.MultiToggle) {
mAttributes["aria-multiselectable"] = "true";
}
var bHasFixedColumns = TableUtils.hasFixedColumns(oTable);
var bHasFixedTopRows = oTable.getFixedRowCount() > 0;
var bHasFixedBottomRows = oTable.getFixedBottomRowCount() > 0;
var bHasRowHeader = TableUtils.hasRowHeader(oTable);
var bHasRowActions = TableUtils.hasRowActions(oTable);
mAttributes["aria-owns"] = [sTableId + "-table"];
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed");
}
if (bHasFixedTopRows) {
mAttributes["aria-owns"].push(sTableId + "-table-fixrow");
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed-fixrow");
}
}
if (bHasFixedBottomRows) {
mAttributes["aria-owns"].push(sTableId + "-table-fixrow-bottom");
if (bHasFixedColumns) {
mAttributes["aria-owns"].push(sTableId + "-table-fixed-fixrow-bottom");
}
}
if (bHasRowHeader) {
mAttributes["aria-owns"].push(sTableId + "-sapUiTableRowHdrScr");
}
if (bHasRowActions) {
mAttributes["aria-owns"].push(sTableId + "-sapUiTableRowActionScr");
}
break;
case TableAccExtension.ELEMENTTYPES.TABLEHEADER: //The table header area
mAttributes["role"] = "heading";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER_TBL: //Table of column headers
mAttributes["role"] = "presentation";
break;
case TableAccExtension.ELEMENTTYPES.COLUMNHEADER_ROW: //The area which contains the column headers
mAttributes["role"] = "row";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.CREATIONROW_TBL: // Table of the creation row
mAttributes["role"] = "presentation";
break;
case TableAccExtension.ELEMENTTYPES.CREATIONROW: // Root of the creation row
mAttributes["role"] = "form";
mAttributes["aria-labelledby"] = mParams.creationRow.getId() + "-label";
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.ROWHEADER_COL: //The area which contains the row headers
addAriaForOverlayOrNoData(oTable, mAttributes, true, true);
break;
case TableAccExtension.ELEMENTTYPES.TH: //The "technical" column headers
var bHasFixedColumns = oTable.getComputedFixedColumnCount() > 0;
if (!bHasFixedColumns) {
mAttributes["role"] = "presentation";
}
mAttributes["scope"] = "col";
if (bHasFixedColumns) {
if (mParams && mParams.column) {
mAttributes["aria-owns"] = mParams.column.getId();
mAttributes["aria-labelledby"] = [mParams.column.getId()];
}
} else {
mAttributes["aria-hidden"] = "true";
}
break;
case TableAccExtension.ELEMENTTYPES.TR: //The rows
mAttributes["role"] = "row";
var bSelected = false;
if (mParams && typeof mParams.index === "number" && oTable.getSelectionMode() !== SelectionMode.None
&& oTable.isIndexSelected(mParams.index)) {
mAttributes["aria-selected"] = "true";
bSelected = true;
}
if (TableUtils.isRowSelectionAllowed(oTable) && oTable.getContextByIndex(mParams.index)) {
var mTooltipTexts = oExtension.getAriaTextsForSelectionMode(true);
mAttributes["title"] = mTooltipTexts.mouse[bSelected ? "rowDeselect" : "rowSelect"];
}
break;
case TableAccExtension.ELEMENTTYPES.TREEICON: //The expand/collapse icon in the TreeTable
if (TableUtils.Grouping.isTreeMode(oTable)) {
mAttributes = {
"aria-label": "",
"title": "",
"role": ""
};
if (oTable.getBinding("rows")) {
if (mParams && mParams.row) {
if (mParams.row._bHasChildren) {
var sText = TableUtils.getResourceText(mParams.row._bIsExpanded ? "TBL_COLLAPSE" : "TBL_EXPAND");
if (oTable._getShowStandardTooltips()) {
mAttributes["title"] = sText;
} else {
mAttributes["aria-label"] = sText;
}
mAttributes["aria-expanded"] = "" + (!!mParams.row._bIsExpanded);
mAttributes["aria-hidden"] = "false";
mAttributes["role"] = "button";
} else {
mAttributes["aria-label"] = TableUtils.getResourceText("TBL_LEAF");
mAttributes["aria-hidden"] = "true";
}
}
}
}
break;
case TableAccExtension.ELEMENTTYPES.NODATA: //The no data container
mAttributes["role"] = "gridcell";
var oNoData = oTable.getNoData();
mAttributes["aria-labelledby"] = [oNoData instanceof Control ? oNoData.getId() : (sTableId + "-noDataMsg")];
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.OVERLAY: //The overlay container
mAttributes["role"] = "region";
mAttributes["aria-labelledby"] = [].concat(oTable.getAriaLabelledBy());
if (oTable.getTitle()) {
mAttributes["aria-labelledby"].push(oTable.getTitle().getId());
}
mAttributes["aria-labelledby"].push(sTableId + "-ariainvalid");
break;
case TableAccExtension.ELEMENTTYPES.TABLEFOOTER: //The table footer area
case TableAccExtension.ELEMENTTYPES.TABLESUBHEADER: //The table toolbar and extension areas
addAriaForOverlayOrNoData(oTable, mAttributes, true, false);
break;
case TableAccExtension.ELEMENTTYPES.ROWACTIONHEADER: // The header of the row action column
mAttributes["aria-hidden"] = "true";
break;
case "PRESENTATION":
mAttributes["role"] = "presentation";
break;
}
return mAttributes;
} | [
"function",
"(",
"oExtension",
",",
"sType",
",",
"mParams",
")",
"{",
"var",
"mAttributes",
"=",
"{",
"}",
",",
"oTable",
"=",
"oExtension",
".",
"getTable",
"(",
")",
",",
"sTableId",
"=",
"oTable",
".",
"getId",
"(",
")",
";",
"function",
"addAriaFo... | /*
Returns the default aria attibutes for the given element type with the given settings.
@see TableAccExtension.ELEMENTTYPES | [
"/",
"*",
"Returns",
"the",
"default",
"aria",
"attibutes",
"for",
"the",
"given",
"element",
"type",
"with",
"the",
"given",
"settings",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccExtension.js#L592-L883 | train | Adds an ARIA attribute to the table. | [
30522,
3853,
1006,
1051,
10288,
29048,
1010,
2358,
18863,
1010,
6131,
5400,
5244,
1007,
1063,
13075,
4717,
3089,
8569,
4570,
1027,
1063,
1065,
1010,
27178,
3085,
1027,
1051,
10288,
29048,
1012,
2131,
10880,
1006,
1007,
1010,
6540,
30524,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/config/config-file.js | writeJSConfigFile | function writeJSConfigFile(config, filePath) {
debug(`Writing JS config file: ${filePath}`);
let contentToWrite;
const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`;
try {
const CLIEngine = require("../cli-engine");
const linter = new CLIEngine({
baseConfig: config,
fix: true,
useEslintrc: false
});
const report = linter.executeOnText(stringifiedContent);
contentToWrite = report.results[0].output || stringifiedContent;
} catch (e) {
debug("Error linting JavaScript config file, writing unlinted version");
const errorMessage = e.message;
contentToWrite = stringifiedContent;
e.message = "An error occurred while generating your JavaScript config file. ";
e.message += "A config file was still generated, but the config file itself may not follow your linting rules.";
e.message += `\nError: ${errorMessage}`;
throw e;
} finally {
fs.writeFileSync(filePath, contentToWrite, "utf8");
}
} | javascript | function writeJSConfigFile(config, filePath) {
debug(`Writing JS config file: ${filePath}`);
let contentToWrite;
const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`;
try {
const CLIEngine = require("../cli-engine");
const linter = new CLIEngine({
baseConfig: config,
fix: true,
useEslintrc: false
});
const report = linter.executeOnText(stringifiedContent);
contentToWrite = report.results[0].output || stringifiedContent;
} catch (e) {
debug("Error linting JavaScript config file, writing unlinted version");
const errorMessage = e.message;
contentToWrite = stringifiedContent;
e.message = "An error occurred while generating your JavaScript config file. ";
e.message += "A config file was still generated, but the config file itself may not follow your linting rules.";
e.message += `\nError: ${errorMessage}`;
throw e;
} finally {
fs.writeFileSync(filePath, contentToWrite, "utf8");
}
} | [
"function",
"writeJSConfigFile",
"(",
"config",
",",
"filePath",
")",
"{",
"debug",
"(",
"`",
"${",
"filePath",
"}",
"`",
")",
";",
"let",
"contentToWrite",
";",
"const",
"stringifiedContent",
"=",
"`",
"${",
"stringify",
"(",
"config",
",",
"{",
"cmp",
... | Writes a configuration file in JavaScript format.
@param {Object} config The configuration object to write.
@param {string} filePath The filename to write to.
@throws {Error} If an error occurs linting the config file contents.
@returns {void}
@private | [
"Writes",
"a",
"configuration",
"file",
"in",
"JavaScript",
"format",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-file.js#L285-L313 | train | Writes a JavaScript config file to a file at the given path. | [
30522,
3853,
4339,
22578,
8663,
8873,
25708,
9463,
1006,
9530,
8873,
2290,
1010,
5371,
15069,
1007,
1063,
2139,
8569,
2290,
1006,
1036,
3015,
1046,
2015,
9530,
8873,
2290,
5371,
1024,
1002,
1063,
5371,
15069,
1065,
1036,
1007,
1025,
2292,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.