repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
markdown-it/markdown-it | lib/parser_block.js | ParserBlock | function ParserBlock() {
/**
* ParserBlock#ruler -> Ruler
*
* [[Ruler]] instance. Keep configuration of block rules.
**/
this.ruler = new Ruler();
for (var i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
}
} | javascript | function ParserBlock() {
/**
* ParserBlock#ruler -> Ruler
*
* [[Ruler]] instance. Keep configuration of block rules.
**/
this.ruler = new Ruler();
for (var i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
}
} | [
"function",
"ParserBlock",
"(",
")",
"{",
"/**\n * ParserBlock#ruler -> Ruler\n *\n * [[Ruler]] instance. Keep configuration of block rules.\n **/",
"this",
".",
"ruler",
"=",
"new",
"Ruler",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"_ru... | new ParserBlock() | [
"new",
"ParserBlock",
"()"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/parser_block.js#L32-L43 | train | ParserBlock constructor. | [
30522,
3853,
11968,
8043,
23467,
1006,
1007,
1063,
1013,
1008,
1008,
1008,
11968,
8043,
23467,
1001,
7786,
1011,
1028,
7786,
1008,
1008,
1031,
1031,
7786,
1033,
1033,
6013,
1012,
2562,
9563,
1997,
3796,
3513,
1012,
1008,
1008,
1013,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_PtgMemArea | function parse_PtgMemArea(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
blob.l += (opts && opts.biff == 2 ? 3 : 4);
var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
return [type, cce];
} | javascript | function parse_PtgMemArea(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
blob.l += (opts && opts.biff == 2 ? 3 : 4);
var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
return [type, cce];
} | [
"function",
"parse_PtgMemArea",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
".",
"read_shift",
"(",
"1",
")",
">>>",
"5",
")",
"&",
"0x03",
";",
"blob",
".",
"l",
"+=",
"(",
"opts",
"&&",
"opts",
".",
"biff... | /* [MS-XLS] 2.5.198.70 ; [MS-XLSB] 2.5.97.54 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"70",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"54"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10582-L10587 | train | Parse an PTG Mem area | [
30522,
3853,
11968,
3366,
1035,
13866,
21693,
14545,
16416,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1015,
1007,
1028,
1028,
1028,
1019,
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... |
adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | marker | function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
} | javascript | function marker(spec) {
var elt = window.document.createElement("div");
elt.className = spec;
return elt;
} | [
"function",
"marker",
"(",
"spec",
")",
"{",
"var",
"elt",
"=",
"window",
".",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"elt",
".",
"className",
"=",
"spec",
";",
"return",
"elt",
";",
"}"
] | Utility for creating fold markers in fold gutter
@param {string} spec the className for the marker
@return {HTMLElement} a htmlelement representing the fold marker | [
"Utility",
"for",
"creating",
"fold",
"markers",
"in",
"fold",
"gutter"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L29-L33 | train | Create a marker element | [
30522,
3853,
12115,
1006,
28699,
1007,
1063,
13075,
3449,
2102,
1027,
3332,
1012,
6254,
1012,
3443,
12260,
3672,
1006,
1000,
4487,
2615,
1000,
1007,
1025,
3449,
2102,
1012,
2465,
18442,
1027,
28699,
1025,
2709,
3449,
2102,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Component.js | activateServices | function activateServices(oComponent) {
var oServices = oComponent.getManifestEntry("/sap.ui5/services");
for (var sService in oServices) {
if (oServices[sService].lazy === false) {
oComponent.getService(sService);
}
}
} | javascript | function activateServices(oComponent) {
var oServices = oComponent.getManifestEntry("/sap.ui5/services");
for (var sService in oServices) {
if (oServices[sService].lazy === false) {
oComponent.getService(sService);
}
}
} | [
"function",
"activateServices",
"(",
"oComponent",
")",
"{",
"var",
"oServices",
"=",
"oComponent",
".",
"getManifestEntry",
"(",
"\"/sap.ui5/services\"",
")",
";",
"for",
"(",
"var",
"sService",
"in",
"oServices",
")",
"{",
"if",
"(",
"oServices",
"[",
"sServ... | Internal activation function for non lazy services which should be started immediately
@param {sap.ui.core.Component} oComponent The Component instance
@private | [
"Internal",
"activation",
"function",
"for",
"non",
"lazy",
"services",
"which",
"should",
"be",
"started",
"immediately"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L933-L940 | train | Activates all services in the component | [
30522,
3853,
20544,
8043,
7903,
2229,
1006,
1051,
9006,
29513,
3372,
1007,
1063,
13075,
9808,
2121,
7903,
2229,
1027,
1051,
9006,
29513,
3372,
1012,
2131,
20799,
14081,
4765,
2854,
1006,
1000,
1013,
20066,
1012,
21318,
2629,
1013,
2578,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/service/ControllerExtension.js | function(sCodeRef, sViewId) {
var oFlexSettings = oRta.getFlexSettings();
if (!oFlexSettings.developerMode) {
throw DtUtil.createError("service.ControllerExtension#add", "code extensions can only be created in developer mode", "sap.ui.rta");
}
if (!sCodeRef) {
throw DtUtil.createError("service.ControllerExtension#add", "can't create controller extension without codeRef", "sap.ui.rta");
}
if (!sCodeRef.endsWith(".js")) {
throw DtUtil.createError("service.ControllerExtension#add", "codeRef has to end with 'js'");
}
var oFlexController = oRta._getFlexController();
var oView = sap.ui.getCore().byId(sViewId);
var oAppComponent = FlexUtils.getAppComponentForControl(oView);
var sControllerName = oView.getControllerName && oView.getControllerName() || oView.getController() && oView.getController().getMetadata().getName();
var oChangeSpecificData = {
content: {
codeRef: sCodeRef
},
selector: {
controllerName: sControllerName
},
changeType: "codeExt",
namespace: oFlexSettings.namespace,
developerMode: oFlexSettings.developerMode,
scenario: oFlexSettings.scenario
};
var oPreparedChange = oFlexController.createBaseChange(oChangeSpecificData, oAppComponent);
oFlexController.addPreparedChange(oPreparedChange, oAppComponent);
return oPreparedChange.getDefinition();
} | javascript | function(sCodeRef, sViewId) {
var oFlexSettings = oRta.getFlexSettings();
if (!oFlexSettings.developerMode) {
throw DtUtil.createError("service.ControllerExtension#add", "code extensions can only be created in developer mode", "sap.ui.rta");
}
if (!sCodeRef) {
throw DtUtil.createError("service.ControllerExtension#add", "can't create controller extension without codeRef", "sap.ui.rta");
}
if (!sCodeRef.endsWith(".js")) {
throw DtUtil.createError("service.ControllerExtension#add", "codeRef has to end with 'js'");
}
var oFlexController = oRta._getFlexController();
var oView = sap.ui.getCore().byId(sViewId);
var oAppComponent = FlexUtils.getAppComponentForControl(oView);
var sControllerName = oView.getControllerName && oView.getControllerName() || oView.getController() && oView.getController().getMetadata().getName();
var oChangeSpecificData = {
content: {
codeRef: sCodeRef
},
selector: {
controllerName: sControllerName
},
changeType: "codeExt",
namespace: oFlexSettings.namespace,
developerMode: oFlexSettings.developerMode,
scenario: oFlexSettings.scenario
};
var oPreparedChange = oFlexController.createBaseChange(oChangeSpecificData, oAppComponent);
oFlexController.addPreparedChange(oPreparedChange, oAppComponent);
return oPreparedChange.getDefinition();
} | [
"function",
"(",
"sCodeRef",
",",
"sViewId",
")",
"{",
"var",
"oFlexSettings",
"=",
"oRta",
".",
"getFlexSettings",
"(",
")",
";",
"if",
"(",
"!",
"oFlexSettings",
".",
"developerMode",
")",
"{",
"throw",
"DtUtil",
".",
"createError",
"(",
"\"service.Control... | Creates a change that adds an extension to the controller associated with the given view.
Throws an error if the information is not complete.
As of now, this only creates the change with a reference to a file. The consumer has to take care of creating that file
and adding it to the backend.
@method sap.ui.rta.service.ControllerExtension.add
@param {object} sCodeRef Name of the file, without path, with the extension '.js'. Must comply to UI5 module naming convention.
Has to be unique and must not conflict with other already defined modules.
@param {string} sViewId ID of the view whose controller should be extended
@return {object} Returns the definition of the newly created change
@public | [
"Creates",
"a",
"change",
"that",
"adds",
"an",
"extension",
"to",
"the",
"controller",
"associated",
"with",
"the",
"given",
"view",
".",
"Throws",
"an",
"error",
"if",
"the",
"information",
"is",
"not",
"complete",
".",
"As",
"of",
"now",
"this",
"only",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/service/ControllerExtension.js#L69-L104 | train | Adds a code extension to the controller | [
30522,
3853,
1006,
8040,
27381,
12879,
1010,
17917,
2666,
9148,
2094,
1007,
1063,
13075,
1997,
2571,
2595,
21678,
8613,
1027,
2030,
2696,
1012,
2131,
21031,
2595,
21678,
8613,
1006,
1007,
1025,
2065,
1006,
999,
1997,
2571,
2595,
21678,
8613... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ODataUtils.js | function (sDateTimeOffset) {
var oDateTimeOffset,
aMatches = rDateTimeOffset.exec(sDateTimeOffset);
if (aMatches) {
if (aMatches[1] && aMatches[1].length > 4) {
// "round" to millis, BEWARE of the dot!
sDateTimeOffset
= sDateTimeOffset.replace(aMatches[1], aMatches[1].slice(0, 4));
}
oDateTimeOffset = DateFormat.getDateTimeInstance({
pattern : "yyyy-MM-dd'T'HH:mm:ss.SSSX",
strictParsing : true
}).parse(sDateTimeOffset.toUpperCase());
}
if (!oDateTimeOffset) {
throw new Error("Not a valid Edm.DateTimeOffset value: " + sDateTimeOffset);
}
return oDateTimeOffset;
} | javascript | function (sDateTimeOffset) {
var oDateTimeOffset,
aMatches = rDateTimeOffset.exec(sDateTimeOffset);
if (aMatches) {
if (aMatches[1] && aMatches[1].length > 4) {
// "round" to millis, BEWARE of the dot!
sDateTimeOffset
= sDateTimeOffset.replace(aMatches[1], aMatches[1].slice(0, 4));
}
oDateTimeOffset = DateFormat.getDateTimeInstance({
pattern : "yyyy-MM-dd'T'HH:mm:ss.SSSX",
strictParsing : true
}).parse(sDateTimeOffset.toUpperCase());
}
if (!oDateTimeOffset) {
throw new Error("Not a valid Edm.DateTimeOffset value: " + sDateTimeOffset);
}
return oDateTimeOffset;
} | [
"function",
"(",
"sDateTimeOffset",
")",
"{",
"var",
"oDateTimeOffset",
",",
"aMatches",
"=",
"rDateTimeOffset",
".",
"exec",
"(",
"sDateTimeOffset",
")",
";",
"if",
"(",
"aMatches",
")",
"{",
"if",
"(",
"aMatches",
"[",
"1",
"]",
"&&",
"aMatches",
"[",
... | Parses an "Edm.DateTimeOffset" value and returns the corresponding JavaScript
<code>Date</code> value.
@param {string} sDateTimeOffset
The "Edm.DateTimeOffset" value to parse
@returns {Date}
The JavaScript <code>Date</code> value
@throws {Error}
If the input cannot be parsed
@public
@since 1.43.0 | [
"Parses",
"an",
"Edm",
".",
"DateTimeOffset",
"value",
"and",
"returns",
"the",
"corresponding",
"JavaScript",
"<code",
">",
"Date<",
"/",
"code",
">",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataUtils.js#L138-L157 | train | Parses the given Edm. DateTimeOffset value. | [
30522,
3853,
1006,
17371,
3686,
7292,
27475,
3388,
1007,
1063,
13075,
1051,
13701,
7292,
27475,
3388,
1010,
25933,
10649,
2229,
1027,
16428,
3686,
7292,
27475,
3388,
1012,
4654,
8586,
1006,
17371,
3686,
7292,
27475,
3388,
1007,
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... | |
eslint/eslint | lib/code-path-analysis/code-path-analyzer.js | leaveFromCurrentSegment | function leaveFromCurrentSegment(analyzer, node) {
const state = CodePath.getState(analyzer.codePath);
const currentSegments = state.currentSegments;
for (let i = 0; i < currentSegments.length; ++i) {
const currentSegment = currentSegments[i];
debug.dump(`onCodePathSegmentEnd ${currentSegment.id}`);
if (currentSegment.reachable) {
analyzer.emitter.emit(
"onCodePathSegmentEnd",
currentSegment,
node
);
}
}
state.currentSegments = [];
} | javascript | function leaveFromCurrentSegment(analyzer, node) {
const state = CodePath.getState(analyzer.codePath);
const currentSegments = state.currentSegments;
for (let i = 0; i < currentSegments.length; ++i) {
const currentSegment = currentSegments[i];
debug.dump(`onCodePathSegmentEnd ${currentSegment.id}`);
if (currentSegment.reachable) {
analyzer.emitter.emit(
"onCodePathSegmentEnd",
currentSegment,
node
);
}
}
state.currentSegments = [];
} | [
"function",
"leaveFromCurrentSegment",
"(",
"analyzer",
",",
"node",
")",
"{",
"const",
"state",
"=",
"CodePath",
".",
"getState",
"(",
"analyzer",
".",
"codePath",
")",
";",
"const",
"currentSegments",
"=",
"state",
".",
"currentSegments",
";",
"for",
"(",
... | Updates the current segment with empty.
This is called at the last of functions or the program.
@param {CodePathAnalyzer} analyzer - The instance.
@param {ASTNode} node - The current AST node.
@returns {void} | [
"Updates",
"the",
"current",
"segment",
"with",
"empty",
".",
"This",
"is",
"called",
"at",
"the",
"last",
"of",
"functions",
"or",
"the",
"program",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-analyzer.js#L206-L224 | train | Leave from the current segment | [
30522,
3853,
2681,
19699,
5358,
10841,
14343,
7666,
13910,
3672,
1006,
17908,
2099,
1010,
13045,
1007,
1063,
9530,
3367,
2110,
1027,
3642,
15069,
1012,
4152,
12259,
1006,
17908,
2099,
1012,
3642,
15069,
1007,
1025,
9530,
3367,
14731,
13910,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/EditorStatusBar.js | _populateLanguageDropdown | function _populateLanguageDropdown() {
// Get all non-binary languages
var languages = _.values(LanguageManager.getLanguages()).filter(function (language) {
return !language.isBinary();
});
// sort dropdown alphabetically
languages.sort(function (a, b) {
return a.getName().toLowerCase().localeCompare(b.getName().toLowerCase());
});
languageSelect.items = languages;
// Add option to top of menu for persisting the override
languageSelect.items.unshift("---");
languageSelect.items.unshift(LANGUAGE_SET_AS_DEFAULT);
} | javascript | function _populateLanguageDropdown() {
// Get all non-binary languages
var languages = _.values(LanguageManager.getLanguages()).filter(function (language) {
return !language.isBinary();
});
// sort dropdown alphabetically
languages.sort(function (a, b) {
return a.getName().toLowerCase().localeCompare(b.getName().toLowerCase());
});
languageSelect.items = languages;
// Add option to top of menu for persisting the override
languageSelect.items.unshift("---");
languageSelect.items.unshift(LANGUAGE_SET_AS_DEFAULT);
} | [
"function",
"_populateLanguageDropdown",
"(",
")",
"{",
"// Get all non-binary languages",
"var",
"languages",
"=",
"_",
".",
"values",
"(",
"LanguageManager",
".",
"getLanguages",
"(",
")",
")",
".",
"filter",
"(",
"function",
"(",
"language",
")",
"{",
"return... | Populate the languageSelect DropdownButton's menu with all registered Languages | [
"Populate",
"the",
"languageSelect",
"DropdownButton",
"s",
"menu",
"with",
"all",
"registered",
"Languages"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorStatusBar.js#L325-L341 | train | Populate the language dropdown | [
30522,
3853,
1035,
3769,
9869,
25023,
6692,
5999,
18981,
7698,
1006,
1007,
1063,
1013,
1013,
2131,
2035,
2512,
1011,
12441,
4155,
13075,
4155,
1027,
1035,
1012,
5300,
1006,
2653,
24805,
30524,
15004,
4155,
1012,
4066,
1006,
3853,
1006,
1037... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/camel-case.js | deCamelCase | function deCamelCase(str) {
return str
.replace(/([A-Z])/g, function (match) { return " " + match; })
.replace(/^./, function (match) { return match.toUpperCase(); });
} | javascript | function deCamelCase(str) {
return str
.replace(/([A-Z])/g, function (match) { return " " + match; })
.replace(/^./, function (match) { return match.toUpperCase(); });
} | [
"function",
"deCamelCase",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"/",
"([A-Z])",
"/",
"g",
",",
"function",
"(",
"match",
")",
"{",
"return",
"\" \"",
"+",
"match",
";",
"}",
")",
".",
"replace",
"(",
"/",
"^.",
"/",
",",
"f... | Converts strings from camel case to words
http://stackoverflow.com/questions/7225407/convert-camelcasetext-to-camel-case-text | [
"Converts",
"strings",
"from",
"camel",
"case",
"to",
"words",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"7225407",
"/",
"convert",
"-",
"camelcasetext",
"-",
"to",
"-",
"camel",
"-",
"case",
"-",
"text"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/camel-case.js#L25-L29 | train | deCamelCase returns a string with all capital letters | [
30522,
3853,
11703,
14074,
15472,
11022,
1006,
2358,
2099,
1007,
1063,
2709,
2358,
2099,
1012,
5672,
1006,
1013,
1006,
1031,
1037,
1011,
1062,
1033,
1007,
1013,
1043,
1010,
3853,
1006,
2674,
1007,
1063,
2709,
1000,
1000,
1009,
2674,
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... |
nhn/tui.editor | src/js/wysiwygCommands/tableRemoveRow.js | getTrs | function getTrs(range, selectionMgr, $table) {
const $selectedCells = selectionMgr.getSelectedCells();
let rangeInformation, trs;
if ($selectedCells.length) {
rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0),
$selectedCells.last().get(0));
trs = getSelectedRows($selectedCells.first()[0], rangeInformation, $table);
} else {
const cell = $(range.startContainer).closest('td,th').get(0);
rangeInformation = selectionMgr.getSelectionRangeFromTable(cell, cell);
trs = getSelectedRows(cell, rangeInformation, $table);
}
return trs;
} | javascript | function getTrs(range, selectionMgr, $table) {
const $selectedCells = selectionMgr.getSelectedCells();
let rangeInformation, trs;
if ($selectedCells.length) {
rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0),
$selectedCells.last().get(0));
trs = getSelectedRows($selectedCells.first()[0], rangeInformation, $table);
} else {
const cell = $(range.startContainer).closest('td,th').get(0);
rangeInformation = selectionMgr.getSelectionRangeFromTable(cell, cell);
trs = getSelectedRows(cell, rangeInformation, $table);
}
return trs;
} | [
"function",
"getTrs",
"(",
"range",
",",
"selectionMgr",
",",
"$table",
")",
"{",
"const",
"$selectedCells",
"=",
"selectionMgr",
".",
"getSelectedCells",
"(",
")",
";",
"let",
"rangeInformation",
",",
"trs",
";",
"if",
"(",
"$selectedCells",
".",
"length",
... | Get TRs
@param {Range} range Range object
@param {object} selectionMgr Table selection manager
@param {jQuery} $table current table
@returns {jQuery} | [
"Get",
"TRs"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableRemoveRow.js#L95-L110 | train | Get selected rows from table | [
30522,
3853,
2131,
16344,
2015,
1006,
2846,
1010,
4989,
24798,
2099,
1010,
1002,
2795,
1007,
1063,
9530,
3367,
1002,
3479,
29109,
4877,
1027,
4989,
24798,
2099,
1012,
4152,
12260,
10985,
29109,
4877,
1006,
1007,
1025,
2292,
2846,
2378,
1419... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/input-mask/jquery.inputmask.date.extensions.js | function (chrs, buffer, pos, strict, opts) {
var frontValue = buffer.join('').substr(0, 3);
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
} | javascript | function (chrs, buffer, pos, strict, opts) {
var frontValue = buffer.join('').substr(0, 3);
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
} | [
"function",
"(",
"chrs",
",",
"buffer",
",",
"pos",
",",
"strict",
",",
"opts",
")",
"{",
"var",
"frontValue",
"=",
"buffer",
".",
"join",
"(",
"''",
")",
".",
"substr",
"(",
"0",
",",
"3",
")",
";",
"if",
"(",
"frontValue",
".",
"indexOf",
"(",
... | val2 ~ day or month | [
"val2",
"~",
"day",
"or",
"month"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/input-mask/jquery.inputmask.date.extensions.js#L116-L130 | train | check if the character is valid | [
30522,
3853,
1006,
10381,
2869,
1010,
17698,
1010,
13433,
2015,
1010,
9384,
1010,
23569,
2015,
1007,
1063,
13075,
2392,
10175,
5657,
1027,
17698,
1012,
3693,
1006,
1005,
1005,
1007,
1012,
4942,
3367,
2099,
1006,
1014,
1010,
1017,
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... | |
adobe/brackets | src/languageTools/LanguageClientWrapper.js | validateRequestParams | function validateRequestParams(type, params) {
var validatedParams = null;
params = params || {};
//Don't validate if the formatting is done by the caller
if (params.format === MESSAGE_FORMAT.LSP) {
return params;
}
switch (type) {
case ToolingInfo.LANGUAGE_SERVICE.START:
{
if (hasValidProp(params, "rootPaths") || hasValidProp(params, "rootPath")) {
validatedParams = params;
validatedParams.capabilities = validatedParams.capabilities || false;
}
break;
}
case ToolingInfo.FEATURES.CODE_HINTS:
case ToolingInfo.FEATURES.PARAMETER_HINTS:
case ToolingInfo.FEATURES.JUMP_TO_DECLARATION:
case ToolingInfo.FEATURES.JUMP_TO_DEFINITION:
case ToolingInfo.FEATURES.JUMP_TO_IMPL:
{
if (hasValidProps(params, ["filePath", "cursorPos"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.FEATURES.CODE_HINT_INFO:
{
validatedParams = params;
break;
}
case ToolingInfo.FEATURES.FIND_REFERENCES:
{
if (hasValidProps(params, ["filePath", "cursorPos"])) {
validatedParams = params;
validatedParams.includeDeclaration = validatedParams.includeDeclaration || false;
}
break;
}
case ToolingInfo.FEATURES.DOCUMENT_SYMBOLS:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.FEATURES.PROJECT_SYMBOLS:
{
if (hasValidProp(params, "query") && typeof params.query === "string") {
validatedParams = params;
}
break;
}
case ToolingInfo.LANGUAGE_SERVICE.CUSTOM_REQUEST:
{
validatedParams = params;
}
}
return validatedParams;
} | javascript | function validateRequestParams(type, params) {
var validatedParams = null;
params = params || {};
//Don't validate if the formatting is done by the caller
if (params.format === MESSAGE_FORMAT.LSP) {
return params;
}
switch (type) {
case ToolingInfo.LANGUAGE_SERVICE.START:
{
if (hasValidProp(params, "rootPaths") || hasValidProp(params, "rootPath")) {
validatedParams = params;
validatedParams.capabilities = validatedParams.capabilities || false;
}
break;
}
case ToolingInfo.FEATURES.CODE_HINTS:
case ToolingInfo.FEATURES.PARAMETER_HINTS:
case ToolingInfo.FEATURES.JUMP_TO_DECLARATION:
case ToolingInfo.FEATURES.JUMP_TO_DEFINITION:
case ToolingInfo.FEATURES.JUMP_TO_IMPL:
{
if (hasValidProps(params, ["filePath", "cursorPos"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.FEATURES.CODE_HINT_INFO:
{
validatedParams = params;
break;
}
case ToolingInfo.FEATURES.FIND_REFERENCES:
{
if (hasValidProps(params, ["filePath", "cursorPos"])) {
validatedParams = params;
validatedParams.includeDeclaration = validatedParams.includeDeclaration || false;
}
break;
}
case ToolingInfo.FEATURES.DOCUMENT_SYMBOLS:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.FEATURES.PROJECT_SYMBOLS:
{
if (hasValidProp(params, "query") && typeof params.query === "string") {
validatedParams = params;
}
break;
}
case ToolingInfo.LANGUAGE_SERVICE.CUSTOM_REQUEST:
{
validatedParams = params;
}
}
return validatedParams;
} | [
"function",
"validateRequestParams",
"(",
"type",
",",
"params",
")",
"{",
"var",
"validatedParams",
"=",
"null",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"//Don't validate if the formatting is done by the caller",
"if",
"(",
"params",
".",
"format",
"==... | /*
RequestParams creator - sendNotifications/request | [
"/",
"*",
"RequestParams",
"creator",
"-",
"sendNotifications",
"/",
"request"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/languageTools/LanguageClientWrapper.js#L61-L125 | train | Validates the parameters for a request | [
30522,
3853,
9398,
24932,
2063,
15500,
28689,
5244,
1006,
2828,
1010,
11498,
5244,
1007,
1063,
13075,
9398,
4383,
28689,
5244,
1027,
19701,
1025,
11498,
5244,
1027,
11498,
5244,
1064,
1064,
1063,
1065,
1025,
1013,
1013,
2123,
1005,
1056,
93... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
vuejs/vue-devtools | src/util.js | internalSearchCheck | function internalSearchCheck (searchTerm, key, value, seen, depth) {
let match = false
let result
if (key === '_custom') {
key = value.display
value = value.value
}
(result = specialTokenToString(value)) && (value = result)
if (key && compare(key, searchTerm)) {
match = true
seen.set(value, true)
} else if (seen.has(value)) {
match = seen.get(value)
} else if (Array.isArray(value)) {
seen.set(value, null)
match = internalSearchArray(value, searchTerm, seen, depth)
seen.set(value, match)
} else if (isPlainObject(value)) {
seen.set(value, null)
match = internalSearchObject(value, searchTerm, seen, depth)
seen.set(value, match)
} else if (compare(value, searchTerm)) {
match = true
seen.set(value, true)
}
return match
} | javascript | function internalSearchCheck (searchTerm, key, value, seen, depth) {
let match = false
let result
if (key === '_custom') {
key = value.display
value = value.value
}
(result = specialTokenToString(value)) && (value = result)
if (key && compare(key, searchTerm)) {
match = true
seen.set(value, true)
} else if (seen.has(value)) {
match = seen.get(value)
} else if (Array.isArray(value)) {
seen.set(value, null)
match = internalSearchArray(value, searchTerm, seen, depth)
seen.set(value, match)
} else if (isPlainObject(value)) {
seen.set(value, null)
match = internalSearchObject(value, searchTerm, seen, depth)
seen.set(value, match)
} else if (compare(value, searchTerm)) {
match = true
seen.set(value, true)
}
return match
} | [
"function",
"internalSearchCheck",
"(",
"searchTerm",
",",
"key",
",",
"value",
",",
"seen",
",",
"depth",
")",
"{",
"let",
"match",
"=",
"false",
"let",
"result",
"if",
"(",
"key",
"===",
"'_custom'",
")",
"{",
"key",
"=",
"value",
".",
"display",
"va... | Checks if the provided field matches the search terms
@param {string} searchTerm Search string
@param {string} key Field key (null if from array)
@param {*} value Field value
@param {Map<any,boolean>} seen Map containing the search result to prevent stack overflow by walking on the same object multiple times
@param {number} depth Deep search depth level, which is capped to prevent performance issues
@returns {boolean} Search match | [
"Checks",
"if",
"the",
"provided",
"field",
"matches",
"the",
"search",
"terms"
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/util.js#L472-L498 | train | internalSearchCheck - Search for a search term | [
30522,
3853,
4722,
17310,
11140,
5403,
3600,
1006,
3945,
3334,
2213,
1010,
3145,
1010,
3643,
1010,
2464,
1010,
5995,
1007,
1063,
2292,
2674,
1027,
6270,
2292,
2765,
2065,
1006,
3145,
1027,
1027,
1027,
1005,
1035,
7661,
1005,
1007,
1063,
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... |
dequelabs/axe-core | build/tasks/aria-supported.js | getDiff | function getDiff(base, subject, type) {
const diff = [];
const notes = [];
const sortedBase = Array.from(base.entries()).sort();
sortedBase.forEach(([key] = item) => {
switch (type) {
case 'supported':
if (
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
) {
diff.push([`${key}`, 'Yes']);
}
break;
case 'unsupported':
if (
(subject[key] && subject[key].unsupported === true) ||
!subject.hasOwnProperty(key)
) {
diff.push([`${key}`, 'No']);
} else if (
subject[key] &&
subject[key].unsupported &&
subject[key].unsupported.exceptions
) {
diff.push([`${key}`, `Mixed[^${notes.length + 1}]`]);
notes.push(
getSupportedElementsAsFootnote(
subject[key].unsupported.exceptions
)
);
}
break;
case 'all':
default:
diff.push([
`${key}`,
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
? 'Yes'
: 'No'
]);
break;
}
});
return {
diff,
notes
};
} | javascript | function getDiff(base, subject, type) {
const diff = [];
const notes = [];
const sortedBase = Array.from(base.entries()).sort();
sortedBase.forEach(([key] = item) => {
switch (type) {
case 'supported':
if (
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
) {
diff.push([`${key}`, 'Yes']);
}
break;
case 'unsupported':
if (
(subject[key] && subject[key].unsupported === true) ||
!subject.hasOwnProperty(key)
) {
diff.push([`${key}`, 'No']);
} else if (
subject[key] &&
subject[key].unsupported &&
subject[key].unsupported.exceptions
) {
diff.push([`${key}`, `Mixed[^${notes.length + 1}]`]);
notes.push(
getSupportedElementsAsFootnote(
subject[key].unsupported.exceptions
)
);
}
break;
case 'all':
default:
diff.push([
`${key}`,
subject.hasOwnProperty(key) &&
subject[key].unsupported === false
? 'Yes'
: 'No'
]);
break;
}
});
return {
diff,
notes
};
} | [
"function",
"getDiff",
"(",
"base",
",",
"subject",
",",
"type",
")",
"{",
"const",
"diff",
"=",
"[",
"]",
";",
"const",
"notes",
"=",
"[",
"]",
";",
"const",
"sortedBase",
"=",
"Array",
".",
"from",
"(",
"base",
".",
"entries",
"(",
")",
")",
".... | Given a `base` Map and `subject` Map object,
The function converts the `base` Map entries to an array which is sorted then enumerated to compare each entry against the `subject` Map
The function constructs a `string` to represent a `markdown table`, as well as returns notes to append to footnote
@param {Map} base Base Map Object
@param {Map} subject Subject Map Object
@param {String} type type to compare
@returns {Array<Object>[]}
@example Example Output: [ [ 'alert', 'No' ], [ 'figure', 'Yes' ] ] | [
"Given",
"a",
"base",
"Map",
"and",
"subject",
"Map",
"object",
"The",
"function",
"converts",
"the",
"base",
"Map",
"entries",
"to",
"an",
"array",
"which",
"is",
"sorted",
"then",
"enumerated",
"to",
"compare",
"each",
"entry",
"against",
"the",
"subject",... | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/build/tasks/aria-supported.js#L98-L150 | train | Get the diff of the base object and the subject object | [
30522,
3853,
2131,
4305,
4246,
1006,
2918,
1010,
3395,
1010,
2828,
1007,
1063,
9530,
3367,
4487,
4246,
1027,
1031,
1033,
1025,
9530,
3367,
3964,
1027,
1031,
1033,
1025,
9530,
3367,
19616,
15058,
1027,
9140,
1012,
2013,
1006,
2918,
1012,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/commons/text/label-text.js | getExplicitLabels | function getExplicitLabels({ actualNode }) {
if (!actualNode.id) {
return [];
}
return dom.findElmsInContext({
elm: 'label',
attr: 'for',
value: actualNode.id,
context: actualNode
});
} | javascript | function getExplicitLabels({ actualNode }) {
if (!actualNode.id) {
return [];
}
return dom.findElmsInContext({
elm: 'label',
attr: 'for',
value: actualNode.id,
context: actualNode
});
} | [
"function",
"getExplicitLabels",
"(",
"{",
"actualNode",
"}",
")",
"{",
"if",
"(",
"!",
"actualNode",
".",
"id",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"dom",
".",
"findElmsInContext",
"(",
"{",
"elm",
":",
"'label'",
",",
"attr",
":",
"'f... | Find a non-ARIA label for an element
@private
@param {VirtualNode} element The VirtualNode instance whose label we are seeking
@return {HTMLElement} The label element, or null if none is found | [
"Find",
"a",
"non",
"-",
"ARIA",
"label",
"for",
"an",
"element"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/text/label-text.js#L48-L58 | train | Get explicit labels | [
30522,
3853,
2131,
10288,
24759,
28775,
19646,
16336,
4877,
1006,
1063,
5025,
3630,
3207,
1065,
1007,
1063,
2065,
1006,
999,
5025,
3630,
3207,
1012,
8909,
1007,
1063,
2709,
1031,
1033,
1025,
1065,
2709,
14383,
1012,
2424,
2884,
5244,
2378,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | scripts/bundle.config.js | getExternals | function getExternals(packageInfo) {
let externals = {
// Hard coded externals
'h3-js': 'h3',
's2-geometry': 'S2'
};
const {peerDependencies = {}} = packageInfo;
for (const depName in peerDependencies) {
if (depName.startsWith('@deck.gl')) {
// Instead of bundling the dependency, import from the global `deck` object
externals[depName] = 'deck';
}
}
if (externals['@deck.gl/core']) {
// Do not bundle luma.gl if `core` is peer dependency
externals = [
externals,
(context, request, callback) => {
if (/^@?luma\.gl/.test(request)) {
return callback(null, 'luma');
}
return callback();
}
];
}
return externals;
} | javascript | function getExternals(packageInfo) {
let externals = {
// Hard coded externals
'h3-js': 'h3',
's2-geometry': 'S2'
};
const {peerDependencies = {}} = packageInfo;
for (const depName in peerDependencies) {
if (depName.startsWith('@deck.gl')) {
// Instead of bundling the dependency, import from the global `deck` object
externals[depName] = 'deck';
}
}
if (externals['@deck.gl/core']) {
// Do not bundle luma.gl if `core` is peer dependency
externals = [
externals,
(context, request, callback) => {
if (/^@?luma\.gl/.test(request)) {
return callback(null, 'luma');
}
return callback();
}
];
}
return externals;
} | [
"function",
"getExternals",
"(",
"packageInfo",
")",
"{",
"let",
"externals",
"=",
"{",
"// Hard coded externals",
"'h3-js'",
":",
"'h3'",
",",
"'s2-geometry'",
":",
"'S2'",
"}",
";",
"const",
"{",
"peerDependencies",
"=",
"{",
"}",
"}",
"=",
"packageInfo",
... | peerDependencies are excluded using `externals`
https://webpack.js.org/configuration/externals/
e.g. @deck.gl/core is not bundled with @deck.gl/geo-layers | [
"peerDependencies",
"are",
"excluded",
"using",
"externals",
"https",
":",
"//",
"webpack",
".",
"js",
".",
"org",
"/",
"configuration",
"/",
"externals",
"/",
"e",
".",
"g",
"."
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/scripts/bundle.config.js#L17-L46 | train | Get externals from a package. json | [
30522,
3853,
2131,
10288,
16451,
9777,
1006,
7427,
2378,
14876,
1007,
1063,
2292,
6327,
2015,
1027,
1063,
1013,
1013,
2524,
22402,
6327,
2015,
1005,
1044,
2509,
1011,
1046,
2015,
1005,
1024,
1005,
1044,
2509,
1005,
1010,
1005,
1055,
2475,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
sass/node-sass | scripts/install.js | download | function download(url, dest, cb) {
var reportError = function(err) {
var timeoutMessge;
if (err.code === 'ETIMEDOUT') {
if (err.connect === true) {
// timeout is hit while your client is attempting to establish a connection to a remote machine
timeoutMessge = 'Timed out attemping to establish a remote connection';
} else {
timeoutMessge = 'Timed out whilst downloading the prebuilt binary';
// occurs any time the server is too slow to send back a part of the response
}
}
cb(['Cannot download "', url, '": ', eol, eol,
typeof err.message === 'string' ? err.message : err, eol, eol,
timeoutMessge ? timeoutMessge + eol + eol : timeoutMessge,
'Hint: If github.com is not accessible in your location', eol,
' try setting a proxy via HTTP_PROXY, e.g. ', eol, eol,
' export HTTP_PROXY=http://example.com:1234',eol, eol,
'or configure npm proxy via', eol, eol,
' npm config set proxy http://example.com:8080'].join(''));
};
var successful = function(response) {
return response.statusCode >= 200 && response.statusCode < 300;
};
console.log('Downloading binary from', url);
try {
request(url, downloadOptions(), function(err, response, buffer) {
if (err) {
reportError(err);
} else if (!successful(response)) {
reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
} else {
console.log('Download complete');
if (successful(response)) {
fs.createWriteStream(dest)
.on('error', cb)
.end(buffer, cb);
} else {
cb();
}
}
})
.on('response', function(response) {
var length = parseInt(response.headers['content-length'], 10);
var progress = log.newItem('', length);
// The `progress` is true by default. However if it has not
// been explicitly set it's `undefined` which is considered
// as far as npm is concerned.
if (process.env.npm_config_progress === 'true') {
log.enableProgress();
response.on('data', function(chunk) {
progress.completeWork(chunk.length);
})
.on('end', progress.finish);
}
});
} catch (err) {
cb(err);
}
} | javascript | function download(url, dest, cb) {
var reportError = function(err) {
var timeoutMessge;
if (err.code === 'ETIMEDOUT') {
if (err.connect === true) {
// timeout is hit while your client is attempting to establish a connection to a remote machine
timeoutMessge = 'Timed out attemping to establish a remote connection';
} else {
timeoutMessge = 'Timed out whilst downloading the prebuilt binary';
// occurs any time the server is too slow to send back a part of the response
}
}
cb(['Cannot download "', url, '": ', eol, eol,
typeof err.message === 'string' ? err.message : err, eol, eol,
timeoutMessge ? timeoutMessge + eol + eol : timeoutMessge,
'Hint: If github.com is not accessible in your location', eol,
' try setting a proxy via HTTP_PROXY, e.g. ', eol, eol,
' export HTTP_PROXY=http://example.com:1234',eol, eol,
'or configure npm proxy via', eol, eol,
' npm config set proxy http://example.com:8080'].join(''));
};
var successful = function(response) {
return response.statusCode >= 200 && response.statusCode < 300;
};
console.log('Downloading binary from', url);
try {
request(url, downloadOptions(), function(err, response, buffer) {
if (err) {
reportError(err);
} else if (!successful(response)) {
reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
} else {
console.log('Download complete');
if (successful(response)) {
fs.createWriteStream(dest)
.on('error', cb)
.end(buffer, cb);
} else {
cb();
}
}
})
.on('response', function(response) {
var length = parseInt(response.headers['content-length'], 10);
var progress = log.newItem('', length);
// The `progress` is true by default. However if it has not
// been explicitly set it's `undefined` which is considered
// as far as npm is concerned.
if (process.env.npm_config_progress === 'true') {
log.enableProgress();
response.on('data', function(chunk) {
progress.completeWork(chunk.length);
})
.on('end', progress.finish);
}
});
} catch (err) {
cb(err);
}
} | [
"function",
"download",
"(",
"url",
",",
"dest",
",",
"cb",
")",
"{",
"var",
"reportError",
"=",
"function",
"(",
"err",
")",
"{",
"var",
"timeoutMessge",
";",
"if",
"(",
"err",
".",
"code",
"===",
"'ETIMEDOUT'",
")",
"{",
"if",
"(",
"err",
".",
"c... | Download file, if succeeds save, if not delete
@param {String} url
@param {String} dest
@param {Function} cb
@api private | [
"Download",
"file",
"if",
"succeeds",
"save",
"if",
"not",
"delete"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/scripts/install.js#L23-L90 | train | Downloads a binary from a remote URL to a local location. | [
30522,
3853,
8816,
1006,
24471,
2140,
1010,
4078,
2102,
1010,
17324,
1007,
1063,
13075,
6398,
29165,
1027,
3853,
1006,
9413,
2099,
1007,
1063,
13075,
2051,
5833,
7834,
28745,
2063,
1025,
2065,
1006,
9413,
2099,
1012,
3642,
1027,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/widgets/ModalBar.js | ModalBar | function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
} | javascript | function ModalBar(template, autoClose, animate) {
if (animate === undefined) {
animate = true;
}
this._handleKeydown = this._handleKeydown.bind(this);
this._handleFocusChange = this._handleFocusChange.bind(this);
this._$root = $("<div class='modal-bar'/>")
.html(template)
.insertBefore("#editor-holder");
if (animate) {
this._$root.addClass("popout offscreen");
// Forcing the renderer to do a layout, which will cause it to apply the transform for the "offscreen"
// class, so it will animate when you remove the class.
window.getComputedStyle(this._$root.get(0)).getPropertyValue("top");
this._$root.removeClass("popout offscreen");
}
// If something *other* than an editor (like another modal bar) has focus, set the focus
// to the editor here, before opening up the new modal bar. This ensures that the old
// focused item has time to react and close before the new modal bar is opened.
// See bugs #4287 and #3424
MainViewManager.focusActivePane();
if (autoClose) {
this._autoClose = true;
this._$root.on("keydown", this._handleKeydown);
window.document.body.addEventListener("focusin", this._handleFocusChange, true);
// Set focus to the first input field, or the first button if there is no input field.
// TODO: remove this logic?
var $firstInput = $("input[type='text']", this._$root).first();
if ($firstInput.length > 0) {
$firstInput.focus();
} else {
$("button", this._$root).first().focus();
}
}
// Preserve scroll position of the current full editor across the editor refresh, adjusting for the
// height of the modal bar so the code doesn't appear to shift if possible.
MainViewManager.cacheScrollState(MainViewManager.ALL_PANES);
WorkspaceManager.recomputeLayout(); // changes available ht for editor area
MainViewManager.restoreAdjustedScrollState(MainViewManager.ALL_PANES, this.height());
} | [
"function",
"ModalBar",
"(",
"template",
",",
"autoClose",
",",
"animate",
")",
"{",
"if",
"(",
"animate",
"===",
"undefined",
")",
"{",
"animate",
"=",
"true",
";",
"}",
"this",
".",
"_handleKeydown",
"=",
"this",
".",
"_handleKeydown",
".",
"bind",
"("... | Creates a modal bar whose contents are the given template.
Dispatches one event:
- close - When the bar is closed, either via close() or via autoClose. After this event, the
bar may remain visible and in the DOM while its closing animation is playing. However,
by the time "close" is fired, the bar has been "popped out" of the layout and the
editor scroll position has already been restored.
Second argument is the reason for closing (one of ModalBar.CLOSE_*).
Third argument is the Promise that close() will be returning.
@constructor
@param {string} template The HTML contents of the modal bar.
@param {boolean} autoClose If true, then close the dialog if the user hits Esc
or if the bar loses focus.
@param {boolean} animate If true (the default), animate the dialog closed, otherwise
close it immediately. | [
"Creates",
"a",
"modal",
"bar",
"whose",
"contents",
"are",
"the",
"given",
"template",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/ModalBar.js#L56-L102 | train | A ModalBar constructor. | [
30522,
3853,
16913,
2389,
8237,
1006,
23561,
1010,
8285,
20464,
9232,
1010,
2019,
21499,
1007,
1063,
2065,
1006,
2019,
21499,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
2019,
21499,
1027,
2995,
1025,
1065,
2023,
1012,
1035,
5047,
14839,
769... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/parallel/parallelPreprocessor.js | createParallelIfNeeded | function createParallelIfNeeded(option) {
if (option.parallel) {
return;
}
var hasParallelSeries = false;
zrUtil.each(option.series, function (seriesOpt) {
if (seriesOpt && seriesOpt.type === 'parallel') {
hasParallelSeries = true;
}
});
if (hasParallelSeries) {
option.parallel = [{}];
}
} | javascript | function createParallelIfNeeded(option) {
if (option.parallel) {
return;
}
var hasParallelSeries = false;
zrUtil.each(option.series, function (seriesOpt) {
if (seriesOpt && seriesOpt.type === 'parallel') {
hasParallelSeries = true;
}
});
if (hasParallelSeries) {
option.parallel = [{}];
}
} | [
"function",
"createParallelIfNeeded",
"(",
"option",
")",
"{",
"if",
"(",
"option",
".",
"parallel",
")",
"{",
"return",
";",
"}",
"var",
"hasParallelSeries",
"=",
"false",
";",
"zrUtil",
".",
"each",
"(",
"option",
".",
"series",
",",
"function",
"(",
"... | Create a parallel coordinate if not exists.
@inner | [
"Create",
"a",
"parallel",
"coordinate",
"if",
"not",
"exists",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/parallelPreprocessor.js#L32-L48 | train | Create parallel if not set | [
30522,
3853,
3443,
28689,
6216,
3669,
2546,
24045,
5732,
1006,
5724,
1007,
1063,
2065,
1006,
5724,
1012,
5903,
1007,
1063,
2709,
1025,
1065,
13075,
2038,
28689,
6216,
4877,
28077,
1027,
6270,
1025,
1062,
22134,
4014,
1012,
2169,
1006,
5724,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function ()
{
if (!this._requests) {
Strophe.debug("_throttledRequestHandler called with " +
"undefined requests");
} else {
Strophe.debug("_throttledRequestHandler called with " +
this._requests.length + " requests");
}
if (!this._requests || this._requests.length === 0) {
return;
}
if (this._requests.length > 0) {
this._processRequest(0);
}
if (this._requests.length > 1 &&
Math.abs(this._requests[0].rid -
this._requests[1].rid) < this.window) {
this._processRequest(1);
}
} | javascript | function ()
{
if (!this._requests) {
Strophe.debug("_throttledRequestHandler called with " +
"undefined requests");
} else {
Strophe.debug("_throttledRequestHandler called with " +
this._requests.length + " requests");
}
if (!this._requests || this._requests.length === 0) {
return;
}
if (this._requests.length > 0) {
this._processRequest(0);
}
if (this._requests.length > 1 &&
Math.abs(this._requests[0].rid -
this._requests[1].rid) < this.window) {
this._processRequest(1);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_requests",
")",
"{",
"Strophe",
".",
"debug",
"(",
"\"_throttledRequestHandler called with \"",
"+",
"\"undefined requests\"",
")",
";",
"}",
"else",
"{",
"Strophe",
".",
"debug",
"(",
"\"_throttledRequ... | PrivateFunction: _throttledRequestHandler
_Private_ function to throttle requests to the connection window.
This function makes sure we don't send requests so fast that the
request ids overflow the connection window in the case that one
request died. | [
"PrivateFunction",
":",
"_throttledRequestHandler",
"_Private_",
"function",
"to",
"throttle",
"requests",
"to",
"the",
"connection",
"window",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4684-L4707 | train | _processRequest is called by _processRequest to process the next request | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
1035,
11186,
1007,
1063,
2358,
18981,
5369,
1012,
2139,
8569,
2290,
1006,
1000,
1035,
24420,
16200,
15500,
11774,
3917,
2170,
2007,
1000,
1009,
1000,
6151,
28344,
11186,
1000,
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... | |
muaz-khan/RTCMultiConnection | dev/MediaStreamRecorder.js | MultiStreamRecorder | function MultiStreamRecorder(arrayOfMediaStreams, options) {
arrayOfMediaStreams = arrayOfMediaStreams || [];
if (arrayOfMediaStreams instanceof MediaStream) {
arrayOfMediaStreams = [arrayOfMediaStreams];
}
var self = this;
var mixer;
var mediaRecorder;
options = options || {
mimeType: 'video/webm',
video: {
width: 360,
height: 240
}
};
if (!options.frameInterval) {
options.frameInterval = 10;
}
if (!options.video) {
options.video = {};
}
if (!options.video.width) {
options.video.width = 360;
}
if (!options.video.height) {
options.video.height = 240;
}
this.start = function(timeSlice) {
// github/muaz-khan/MultiStreamsMixer
mixer = new MultiStreamsMixer(arrayOfMediaStreams);
if (getVideoTracks().length) {
mixer.frameInterval = options.frameInterval || 10;
mixer.width = options.video.width || 360;
mixer.height = options.video.height || 240;
mixer.startDrawingFrames();
}
if (typeof self.previewStream === 'function') {
self.previewStream(mixer.getMixedStream());
}
// record using MediaRecorder API
mediaRecorder = new MediaStreamRecorder(mixer.getMixedStream());
for (var prop in self) {
if (typeof self[prop] !== 'function') {
mediaRecorder[prop] = self[prop];
}
}
mediaRecorder.ondataavailable = function(blob) {
self.ondataavailable(blob);
};
mediaRecorder.onstop = self.onstop;
mediaRecorder.start(timeSlice);
};
function getVideoTracks() {
var tracks = [];
arrayOfMediaStreams.forEach(function(stream) {
stream.getVideoTracks().forEach(function(track) {
tracks.push(track);
});
});
return tracks;
}
this.stop = function(callback) {
if (!mediaRecorder) {
return;
}
mediaRecorder.stop(function(blob) {
callback(blob);
});
};
this.pause = function() {
if (mediaRecorder) {
mediaRecorder.pause();
}
};
this.resume = function() {
if (mediaRecorder) {
mediaRecorder.resume();
}
};
this.clearRecordedData = function() {
if (mediaRecorder) {
mediaRecorder.clearRecordedData();
mediaRecorder = null;
}
if (mixer) {
mixer.releaseStreams();
mixer = null;
}
};
this.addStreams = this.addStream = function(streams) {
if (!streams) {
throw 'First parameter is required.';
}
if (!(streams instanceof Array)) {
streams = [streams];
}
arrayOfMediaStreams.concat(streams);
if (!mediaRecorder || !mixer) {
return;
}
mixer.appendStreams(streams);
};
this.resetVideoStreams = function(streams) {
if (!mixer) {
return;
}
if (streams && !(streams instanceof Array)) {
streams = [streams];
}
mixer.resetVideoStreams(streams);
};
this.ondataavailable = function(blob) {
if (self.disableLogs) {
return;
}
console.log('ondataavailable', blob);
};
this.onstop = function() {};
// for debugging
this.name = 'MultiStreamRecorder';
this.toString = function() {
return this.name;
};
} | javascript | function MultiStreamRecorder(arrayOfMediaStreams, options) {
arrayOfMediaStreams = arrayOfMediaStreams || [];
if (arrayOfMediaStreams instanceof MediaStream) {
arrayOfMediaStreams = [arrayOfMediaStreams];
}
var self = this;
var mixer;
var mediaRecorder;
options = options || {
mimeType: 'video/webm',
video: {
width: 360,
height: 240
}
};
if (!options.frameInterval) {
options.frameInterval = 10;
}
if (!options.video) {
options.video = {};
}
if (!options.video.width) {
options.video.width = 360;
}
if (!options.video.height) {
options.video.height = 240;
}
this.start = function(timeSlice) {
// github/muaz-khan/MultiStreamsMixer
mixer = new MultiStreamsMixer(arrayOfMediaStreams);
if (getVideoTracks().length) {
mixer.frameInterval = options.frameInterval || 10;
mixer.width = options.video.width || 360;
mixer.height = options.video.height || 240;
mixer.startDrawingFrames();
}
if (typeof self.previewStream === 'function') {
self.previewStream(mixer.getMixedStream());
}
// record using MediaRecorder API
mediaRecorder = new MediaStreamRecorder(mixer.getMixedStream());
for (var prop in self) {
if (typeof self[prop] !== 'function') {
mediaRecorder[prop] = self[prop];
}
}
mediaRecorder.ondataavailable = function(blob) {
self.ondataavailable(blob);
};
mediaRecorder.onstop = self.onstop;
mediaRecorder.start(timeSlice);
};
function getVideoTracks() {
var tracks = [];
arrayOfMediaStreams.forEach(function(stream) {
stream.getVideoTracks().forEach(function(track) {
tracks.push(track);
});
});
return tracks;
}
this.stop = function(callback) {
if (!mediaRecorder) {
return;
}
mediaRecorder.stop(function(blob) {
callback(blob);
});
};
this.pause = function() {
if (mediaRecorder) {
mediaRecorder.pause();
}
};
this.resume = function() {
if (mediaRecorder) {
mediaRecorder.resume();
}
};
this.clearRecordedData = function() {
if (mediaRecorder) {
mediaRecorder.clearRecordedData();
mediaRecorder = null;
}
if (mixer) {
mixer.releaseStreams();
mixer = null;
}
};
this.addStreams = this.addStream = function(streams) {
if (!streams) {
throw 'First parameter is required.';
}
if (!(streams instanceof Array)) {
streams = [streams];
}
arrayOfMediaStreams.concat(streams);
if (!mediaRecorder || !mixer) {
return;
}
mixer.appendStreams(streams);
};
this.resetVideoStreams = function(streams) {
if (!mixer) {
return;
}
if (streams && !(streams instanceof Array)) {
streams = [streams];
}
mixer.resetVideoStreams(streams);
};
this.ondataavailable = function(blob) {
if (self.disableLogs) {
return;
}
console.log('ondataavailable', blob);
};
this.onstop = function() {};
// for debugging
this.name = 'MultiStreamRecorder';
this.toString = function() {
return this.name;
};
} | [
"function",
"MultiStreamRecorder",
"(",
"arrayOfMediaStreams",
",",
"options",
")",
"{",
"arrayOfMediaStreams",
"=",
"arrayOfMediaStreams",
"||",
"[",
"]",
";",
"if",
"(",
"arrayOfMediaStreams",
"instanceof",
"MediaStream",
")",
"{",
"arrayOfMediaStreams",
"=",
"[",
... | ______________________ MultiStreamRecorder.js | [
"______________________",
"MultiStreamRecorder",
".",
"js"
] | 2032ce949bde30b43a3d2666e0f1e5afbf337f3d | https://github.com/muaz-khan/RTCMultiConnection/blob/2032ce949bde30b43a3d2666e0f1e5afbf337f3d/dev/MediaStreamRecorder.js#L145-L303 | train | MultiStreamRecorder constructor. | [
30522,
3853,
4800,
21422,
2890,
27108,
4063,
1006,
9140,
11253,
16969,
21422,
2015,
1010,
7047,
1007,
1063,
9140,
11253,
16969,
21422,
2015,
1027,
9140,
11253,
16969,
21422,
2015,
1064,
1064,
1031,
1033,
1025,
2065,
1006,
9140,
11253,
16969,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_PtgAreaErr | function parse_PtgAreaErr(blob, length, opts) {
var type = (blob[blob.l++] & 0x60) >> 5;
blob.l += opts && (opts.biff > 8) ? 12 : (opts.biff < 8 ? 6 : 8);
return [type];
} | javascript | function parse_PtgAreaErr(blob, length, opts) {
var type = (blob[blob.l++] & 0x60) >> 5;
blob.l += opts && (opts.biff > 8) ? 12 : (opts.biff < 8 ? 6 : 8);
return [type];
} | [
"function",
"parse_PtgAreaErr",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
"[",
"blob",
".",
"l",
"++",
"]",
"&",
"0x60",
")",
">>",
"5",
";",
"blob",
".",
"l",
"+=",
"opts",
"&&",
"(",
"opts",
".",
"bif... | /* [MS-XLS] 2.5.198.29 ; [MS-XLSB] 2.5.97.20 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"29",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"20"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10325-L10329 | train | Parse an error in a PTG area. | [
30522,
3853,
11968,
3366,
1035,
13866,
6843,
5243,
2121,
2099,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1031,
1038,
4135,
2497,
1012,
1048,
1009,
1009,
1033,
1004,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | hasJavascriptHref | function hasJavascriptHref(element) {
if (getTagName(element) != 'a') {
return false;
}
if (element.getAttribute('onclick')) {
return false;
}
if (! element.href) {
return false;
}
if (! /\s*javascript:/i.test(element.href)) {
return false;
}
return true;
} | javascript | function hasJavascriptHref(element) {
if (getTagName(element) != 'a') {
return false;
}
if (element.getAttribute('onclick')) {
return false;
}
if (! element.href) {
return false;
}
if (! /\s*javascript:/i.test(element.href)) {
return false;
}
return true;
} | [
"function",
"hasJavascriptHref",
"(",
"element",
")",
"{",
"if",
"(",
"getTagName",
"(",
"element",
")",
"!=",
"'a'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"element",
".",
"getAttribute",
"(",
"'onclick'",
")",
")",
"{",
"return",
"false",
... | Returns true iff the given element represents a link with a javascript
href attribute, and does not have an onclick attribute defined.
@param element the element to test | [
"Returns",
"true",
"iff",
"the",
"given",
"element",
"represents",
"a",
"link",
"with",
"a",
"javascript",
"href",
"attribute",
"and",
"does",
"not",
"have",
"an",
"onclick",
"attribute",
"defined",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1004-L1018 | train | Checks if the element has a href attribute that is not a javascript attribute | [
30522,
3853,
2038,
3900,
12044,
23235,
28362,
2546,
1006,
5783,
1007,
1063,
2065,
1006,
2131,
15900,
18442,
1006,
5783,
1007,
999,
1027,
1005,
1037,
1005,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
5783,
1012,
2131,
19321,
3089,
8569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | makeBody | function makeBody(col, row, data) {
let body = '<tbody>';
let index = col;
for (let irow = 0; irow < row; irow += 1) {
body += '<tr>';
for (let icol = 0; icol < col; icol += 1) {
body += '<td>';
if (data) {
body += data[index];
index += 1;
}
body += '</td>';
}
body += '</tr>';
}
body += '</tbody>';
return body;
} | javascript | function makeBody(col, row, data) {
let body = '<tbody>';
let index = col;
for (let irow = 0; irow < row; irow += 1) {
body += '<tr>';
for (let icol = 0; icol < col; icol += 1) {
body += '<td>';
if (data) {
body += data[index];
index += 1;
}
body += '</td>';
}
body += '</tr>';
}
body += '</tbody>';
return body;
} | [
"function",
"makeBody",
"(",
"col",
",",
"row",
",",
"data",
")",
"{",
"let",
"body",
"=",
"'<tbody>'",
";",
"let",
"index",
"=",
"col",
";",
"for",
"(",
"let",
"irow",
"=",
"0",
";",
"irow",
"<",
"row",
";",
"irow",
"+=",
"1",
")",
"{",
"body"... | makeBody
make table body html string
@param {number} col column count
@param {number} row row count
@param {string} data cell data
@returns {string} html string | [
"makeBody",
"make",
"table",
"body",
"html",
"string"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/table.js#L98-L122 | train | Creates the body of a table | [
30522,
3853,
2191,
23684,
1006,
8902,
1010,
5216,
1010,
2951,
1007,
1063,
2292,
2303,
1027,
1005,
1026,
26419,
7716,
2100,
1028,
1005,
1025,
2292,
5950,
1027,
8902,
1025,
2005,
1006,
2292,
20868,
5004,
1027,
1014,
1025,
20868,
5004,
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... |
uber/deck.gl | modules/core/src/shaderlib/project/viewport-uniforms.js | calculateMatrixAndOffset | function calculateMatrixAndOffset({
// UNCHANGED
viewport,
// NEW PARAMS
coordinateSystem,
coordinateOrigin,
coordinateZoom
}) {
const {viewMatrixUncentered} = viewport;
let {viewMatrix} = viewport;
const {projectionMatrix} = viewport;
let {viewProjectionMatrix} = viewport;
let projectionCenter;
let cameraPosCommon = viewport.cameraPosition;
let shaderCoordinateSystem = getShaderCoordinateSystem(coordinateSystem);
let shaderCoordinateOrigin = coordinateOrigin;
if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET) {
if (coordinateZoom < LNGLAT_AUTO_OFFSET_ZOOM_THRESHOLD) {
// Use LNG_LAT projection if not zooming
shaderCoordinateSystem = PROJECT_COORDINATE_SYSTEM.LNG_LAT;
} else {
// Use LNGLAT_AUTO_OFFSET
const lng = Math.fround(viewport.longitude);
const lat = Math.fround(viewport.latitude);
shaderCoordinateOrigin = [lng, lat];
}
}
if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.IDENTITY) {
// We only support 64-bit precision in the X and Y components of positions for now
shaderCoordinateOrigin = [Math.fround(viewport.position[0]), Math.fround(viewport.position[1])];
}
switch (shaderCoordinateSystem) {
case PROJECT_COORDINATE_SYSTEM.LNG_LAT:
projectionCenter = ZERO_VECTOR;
break;
// TODO: make lighting work for meter offset mode
case PROJECT_COORDINATE_SYSTEM.LNGLAT_OFFSETS:
case PROJECT_COORDINATE_SYSTEM.METER_OFFSETS:
case PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET:
case PROJECT_COORDINATE_SYSTEM.IDENTITY:
// Calculate transformed projectionCenter (using 64 bit precision JS)
// This is the key to offset mode precision
// (avoids doing this addition in 32 bit precision in GLSL)
const positionCommonSpace = viewport.projectPosition(
shaderCoordinateOrigin,
Math.pow(2, coordinateZoom)
);
cameraPosCommon = [
cameraPosCommon[0] - positionCommonSpace[0],
cameraPosCommon[1] - positionCommonSpace[1],
cameraPosCommon[2]
];
positionCommonSpace[2] = 0;
positionCommonSpace[3] = 1;
// projectionCenter = new Matrix4(viewProjectionMatrix)
// .transformVector([positionPixels[0], positionPixels[1], 0.0, 1.0]);
projectionCenter = vec4.transformMat4([], positionCommonSpace, viewProjectionMatrix);
// Always apply uncentered projection matrix if available (shader adds center)
viewMatrix = viewMatrixUncentered || viewMatrix;
// Zero out 4th coordinate ("after" model matrix) - avoids further translations
// viewMatrix = new Matrix4(viewMatrixUncentered || viewMatrix)
// .multiplyRight(VECTOR_TO_POINT_MATRIX);
viewProjectionMatrix = mat4.multiply([], projectionMatrix, viewMatrix);
viewProjectionMatrix = mat4.multiply([], viewProjectionMatrix, VECTOR_TO_POINT_MATRIX);
break;
default:
throw new Error('Unknown projection mode');
}
return {
viewMatrix,
viewProjectionMatrix,
projectionCenter,
cameraPosCommon,
shaderCoordinateSystem,
shaderCoordinateOrigin
};
} | javascript | function calculateMatrixAndOffset({
// UNCHANGED
viewport,
// NEW PARAMS
coordinateSystem,
coordinateOrigin,
coordinateZoom
}) {
const {viewMatrixUncentered} = viewport;
let {viewMatrix} = viewport;
const {projectionMatrix} = viewport;
let {viewProjectionMatrix} = viewport;
let projectionCenter;
let cameraPosCommon = viewport.cameraPosition;
let shaderCoordinateSystem = getShaderCoordinateSystem(coordinateSystem);
let shaderCoordinateOrigin = coordinateOrigin;
if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET) {
if (coordinateZoom < LNGLAT_AUTO_OFFSET_ZOOM_THRESHOLD) {
// Use LNG_LAT projection if not zooming
shaderCoordinateSystem = PROJECT_COORDINATE_SYSTEM.LNG_LAT;
} else {
// Use LNGLAT_AUTO_OFFSET
const lng = Math.fround(viewport.longitude);
const lat = Math.fround(viewport.latitude);
shaderCoordinateOrigin = [lng, lat];
}
}
if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.IDENTITY) {
// We only support 64-bit precision in the X and Y components of positions for now
shaderCoordinateOrigin = [Math.fround(viewport.position[0]), Math.fround(viewport.position[1])];
}
switch (shaderCoordinateSystem) {
case PROJECT_COORDINATE_SYSTEM.LNG_LAT:
projectionCenter = ZERO_VECTOR;
break;
// TODO: make lighting work for meter offset mode
case PROJECT_COORDINATE_SYSTEM.LNGLAT_OFFSETS:
case PROJECT_COORDINATE_SYSTEM.METER_OFFSETS:
case PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET:
case PROJECT_COORDINATE_SYSTEM.IDENTITY:
// Calculate transformed projectionCenter (using 64 bit precision JS)
// This is the key to offset mode precision
// (avoids doing this addition in 32 bit precision in GLSL)
const positionCommonSpace = viewport.projectPosition(
shaderCoordinateOrigin,
Math.pow(2, coordinateZoom)
);
cameraPosCommon = [
cameraPosCommon[0] - positionCommonSpace[0],
cameraPosCommon[1] - positionCommonSpace[1],
cameraPosCommon[2]
];
positionCommonSpace[2] = 0;
positionCommonSpace[3] = 1;
// projectionCenter = new Matrix4(viewProjectionMatrix)
// .transformVector([positionPixels[0], positionPixels[1], 0.0, 1.0]);
projectionCenter = vec4.transformMat4([], positionCommonSpace, viewProjectionMatrix);
// Always apply uncentered projection matrix if available (shader adds center)
viewMatrix = viewMatrixUncentered || viewMatrix;
// Zero out 4th coordinate ("after" model matrix) - avoids further translations
// viewMatrix = new Matrix4(viewMatrixUncentered || viewMatrix)
// .multiplyRight(VECTOR_TO_POINT_MATRIX);
viewProjectionMatrix = mat4.multiply([], projectionMatrix, viewMatrix);
viewProjectionMatrix = mat4.multiply([], viewProjectionMatrix, VECTOR_TO_POINT_MATRIX);
break;
default:
throw new Error('Unknown projection mode');
}
return {
viewMatrix,
viewProjectionMatrix,
projectionCenter,
cameraPosCommon,
shaderCoordinateSystem,
shaderCoordinateOrigin
};
} | [
"function",
"calculateMatrixAndOffset",
"(",
"{",
"// UNCHANGED",
"viewport",
",",
"// NEW PARAMS",
"coordinateSystem",
",",
"coordinateOrigin",
",",
"coordinateZoom",
"}",
")",
"{",
"const",
"{",
"viewMatrixUncentered",
"}",
"=",
"viewport",
";",
"let",
"{",
"viewM... | The code that utilizes Matrix4 does the same calculation as their mat4 counterparts, has lower performance but provides error checking. Uncomment when debugging | [
"The",
"code",
"that",
"utilizes",
"Matrix4",
"does",
"the",
"same",
"calculation",
"as",
"their",
"mat4",
"counterparts",
"has",
"lower",
"performance",
"but",
"provides",
"error",
"checking",
".",
"Uncomment",
"when",
"debugging"
] | fbd09d33c84a9e6ed6e4c0ef5122a47463721970 | https://github.com/uber/deck.gl/blob/fbd09d33c84a9e6ed6e4c0ef5122a47463721970/modules/core/src/shaderlib/project/viewport-uniforms.js#L70-L157 | train | Calculate the matrix and offset of the view and projection of the viewport | [
30522,
3853,
18422,
18900,
17682,
28574,
21807,
3388,
1006,
1063,
1013,
1013,
15704,
3193,
6442,
1010,
1013,
1013,
2047,
11498,
5244,
12093,
27268,
6633,
1010,
13530,
10050,
11528,
1010,
13530,
23221,
2213,
1065,
1007,
1063,
9530,
3367,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/sinon-server.js | each | function each(collection, callback) {
if (!collection) {
return;
}
for (var i = 0, l = collection.length; i < l; i += 1) {
callback(collection[i]);
}
} | javascript | function each(collection, callback) {
if (!collection) {
return;
}
for (var i = 0, l = collection.length; i < l; i += 1) {
callback(collection[i]);
}
} | [
"function",
"each",
"(",
"collection",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"collection",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"collection",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"+=",
"1",... | filtering to enable a white-list version of Sinon FakeXhr, where whitelisted requests are passed through to real XHR | [
"filtering",
"to",
"enable",
"a",
"white",
"-",
"list",
"version",
"of",
"Sinon",
"FakeXhr",
"where",
"whitelisted",
"requests",
"are",
"passed",
"through",
"to",
"real",
"XHR"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/sinon-server.js#L1122-L1130 | train | Iterate over the elements of the collection | [
30522,
3853,
2169,
1006,
3074,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
999,
3074,
1007,
1063,
2709,
1025,
1065,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
1048,
1027,
3074,
1012,
3091,
1025,
1045,
1026,
1048,
1025,
1045,
1009,
1027,
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... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js | setTransport | function setTransport(transport) {
if (_transport) {
_transport.off(".livedev");
}
_transport = transport;
_transport
.on("connect.livedev", function (event, msg) {
_connect(msg[0], msg[1]);
})
.on("message.livedev", function (event, msg) {
_receive(msg[0], msg[1]);
})
.on("close.livedev", function (event, msg) {
_close(msg[0]);
});
_transport.start();
} | javascript | function setTransport(transport) {
if (_transport) {
_transport.off(".livedev");
}
_transport = transport;
_transport
.on("connect.livedev", function (event, msg) {
_connect(msg[0], msg[1]);
})
.on("message.livedev", function (event, msg) {
_receive(msg[0], msg[1]);
})
.on("close.livedev", function (event, msg) {
_close(msg[0]);
});
_transport.start();
} | [
"function",
"setTransport",
"(",
"transport",
")",
"{",
"if",
"(",
"_transport",
")",
"{",
"_transport",
".",
"off",
"(",
"\".livedev\"",
")",
";",
"}",
"_transport",
"=",
"transport",
";",
"_transport",
".",
"on",
"(",
"\"connect.livedev\"",
",",
"function"... | Sets the transport that should be used by the protocol. See `LiveDevelopment.setTransport()`
for more detail on the transport.
@param {{start: function(string), send: function(number|Array.<number>, string), close: function(number), getRemoteScript: function(): ?string}} transport | [
"Sets",
"the",
"transport",
"that",
"should",
"be",
"used",
"by",
"the",
"protocol",
".",
"See",
"LiveDevelopment",
".",
"setTransport",
"()",
"for",
"more",
"detail",
"on",
"the",
"transport",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js#L186-L203 | train | setTransport - Set transport | [
30522,
3853,
2275,
6494,
3619,
6442,
1006,
3665,
1007,
1063,
2065,
1006,
1035,
3665,
1007,
1063,
1035,
3665,
1012,
2125,
1006,
1000,
1012,
2973,
6777,
1000,
1007,
1025,
1065,
1035,
3665,
1027,
3665,
1025,
1035,
3665,
1012,
2006,
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... |
ColorlibHQ/AdminLTE | bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js | function(element, options) {
this.element = $(element).addClass('colorpicker-element');
this.options = $.extend(true, {}, defaults, this.element.data(), options);
this.component = this.options.component;
this.component = (this.component !== false) ? this.element.find(this.component) : false;
if (this.component && (this.component.length === 0)) {
this.component = false;
}
this.container = (this.options.container === true) ? this.element : this.options.container;
this.container = (this.container !== false) ? $(this.container) : false;
// Is the element an input? Should we search inside for any input?
this.input = this.element.is('input') ? this.element : (this.options.input ?
this.element.find(this.options.input) : false);
if (this.input && (this.input.length === 0)) {
this.input = false;
}
// Set HSB color
this.color = this.createColor(this.options.color !== false ? this.options.color : this.getValue());
this.format = this.options.format !== false ? this.options.format : this.color.origFormat;
if (this.options.color !== false) {
this.updateInput(this.color);
this.updateData(this.color);
}
this.disabled = false;
// Setup picker
var $picker = this.picker = $(this.options.template);
if (this.options.customClass) {
$picker.addClass(this.options.customClass);
}
if (this.options.inline) {
$picker.addClass('colorpicker-inline colorpicker-visible');
} else {
$picker.addClass('colorpicker-hidden');
}
if (this.options.horizontal) {
$picker.addClass('colorpicker-horizontal');
}
if (
(['rgba', 'hsla', 'alias'].indexOf(this.format) !== -1) ||
this.options.format === false ||
this.getValue() === 'transparent'
) {
$picker.addClass('colorpicker-with-alpha');
}
if (this.options.align === 'right') {
$picker.addClass('colorpicker-right');
}
if (this.options.inline === true) {
$picker.addClass('colorpicker-no-arrow');
}
if (this.options.colorSelectors) {
var colorpicker = this,
selectorsContainer = colorpicker.picker.find('.colorpicker-selectors');
if (selectorsContainer.length > 0) {
$.each(this.options.colorSelectors, function(name, color) {
var $btn = $('<i />')
.addClass('colorpicker-selectors-color')
.css('background-color', color)
.data('class', name).data('alias', name);
$btn.on('mousedown.colorpicker touchstart.colorpicker', function(event) {
event.preventDefault();
colorpicker.setValue(
colorpicker.format === 'alias' ? $(this).data('alias') : $(this).css('background-color')
);
});
selectorsContainer.append($btn);
});
selectorsContainer.show().addClass('colorpicker-visible');
}
}
// Prevent closing the colorpicker when clicking on itself
$picker.on('mousedown.colorpicker touchstart.colorpicker', $.proxy(function(e) {
if (e.target === e.currentTarget) {
e.preventDefault();
}
}, this));
// Bind click/tap events on the sliders
$picker.find('.colorpicker-saturation, .colorpicker-hue, .colorpicker-alpha')
.on('mousedown.colorpicker touchstart.colorpicker', $.proxy(this.mousedown, this));
$picker.appendTo(this.container ? this.container : $('body'));
// Bind other events
if (this.input !== false) {
this.input.on({
'keyup.colorpicker': $.proxy(this.keyup, this)
});
this.input.on({
'input.colorpicker': $.proxy(this.change, this)
});
if (this.component === false) {
this.element.on({
'focus.colorpicker': $.proxy(this.show, this)
});
}
if (this.options.inline === false) {
this.element.on({
'focusout.colorpicker': $.proxy(this.hide, this)
});
}
}
if (this.component !== false) {
this.component.on({
'click.colorpicker': $.proxy(this.show, this)
});
}
if ((this.input === false) && (this.component === false)) {
this.element.on({
'click.colorpicker': $.proxy(this.show, this)
});
}
// for HTML5 input[type='color']
if ((this.input !== false) && (this.component !== false) && (this.input.attr('type') === 'color')) {
this.input.on({
'click.colorpicker': $.proxy(this.show, this),
'focus.colorpicker': $.proxy(this.show, this)
});
}
this.update();
$($.proxy(function() {
this.element.trigger('create');
}, this));
} | javascript | function(element, options) {
this.element = $(element).addClass('colorpicker-element');
this.options = $.extend(true, {}, defaults, this.element.data(), options);
this.component = this.options.component;
this.component = (this.component !== false) ? this.element.find(this.component) : false;
if (this.component && (this.component.length === 0)) {
this.component = false;
}
this.container = (this.options.container === true) ? this.element : this.options.container;
this.container = (this.container !== false) ? $(this.container) : false;
// Is the element an input? Should we search inside for any input?
this.input = this.element.is('input') ? this.element : (this.options.input ?
this.element.find(this.options.input) : false);
if (this.input && (this.input.length === 0)) {
this.input = false;
}
// Set HSB color
this.color = this.createColor(this.options.color !== false ? this.options.color : this.getValue());
this.format = this.options.format !== false ? this.options.format : this.color.origFormat;
if (this.options.color !== false) {
this.updateInput(this.color);
this.updateData(this.color);
}
this.disabled = false;
// Setup picker
var $picker = this.picker = $(this.options.template);
if (this.options.customClass) {
$picker.addClass(this.options.customClass);
}
if (this.options.inline) {
$picker.addClass('colorpicker-inline colorpicker-visible');
} else {
$picker.addClass('colorpicker-hidden');
}
if (this.options.horizontal) {
$picker.addClass('colorpicker-horizontal');
}
if (
(['rgba', 'hsla', 'alias'].indexOf(this.format) !== -1) ||
this.options.format === false ||
this.getValue() === 'transparent'
) {
$picker.addClass('colorpicker-with-alpha');
}
if (this.options.align === 'right') {
$picker.addClass('colorpicker-right');
}
if (this.options.inline === true) {
$picker.addClass('colorpicker-no-arrow');
}
if (this.options.colorSelectors) {
var colorpicker = this,
selectorsContainer = colorpicker.picker.find('.colorpicker-selectors');
if (selectorsContainer.length > 0) {
$.each(this.options.colorSelectors, function(name, color) {
var $btn = $('<i />')
.addClass('colorpicker-selectors-color')
.css('background-color', color)
.data('class', name).data('alias', name);
$btn.on('mousedown.colorpicker touchstart.colorpicker', function(event) {
event.preventDefault();
colorpicker.setValue(
colorpicker.format === 'alias' ? $(this).data('alias') : $(this).css('background-color')
);
});
selectorsContainer.append($btn);
});
selectorsContainer.show().addClass('colorpicker-visible');
}
}
// Prevent closing the colorpicker when clicking on itself
$picker.on('mousedown.colorpicker touchstart.colorpicker', $.proxy(function(e) {
if (e.target === e.currentTarget) {
e.preventDefault();
}
}, this));
// Bind click/tap events on the sliders
$picker.find('.colorpicker-saturation, .colorpicker-hue, .colorpicker-alpha')
.on('mousedown.colorpicker touchstart.colorpicker', $.proxy(this.mousedown, this));
$picker.appendTo(this.container ? this.container : $('body'));
// Bind other events
if (this.input !== false) {
this.input.on({
'keyup.colorpicker': $.proxy(this.keyup, this)
});
this.input.on({
'input.colorpicker': $.proxy(this.change, this)
});
if (this.component === false) {
this.element.on({
'focus.colorpicker': $.proxy(this.show, this)
});
}
if (this.options.inline === false) {
this.element.on({
'focusout.colorpicker': $.proxy(this.hide, this)
});
}
}
if (this.component !== false) {
this.component.on({
'click.colorpicker': $.proxy(this.show, this)
});
}
if ((this.input === false) && (this.component === false)) {
this.element.on({
'click.colorpicker': $.proxy(this.show, this)
});
}
// for HTML5 input[type='color']
if ((this.input !== false) && (this.component !== false) && (this.input.attr('type') === 'color')) {
this.input.on({
'click.colorpicker': $.proxy(this.show, this),
'focus.colorpicker': $.proxy(this.show, this)
});
}
this.update();
$($.proxy(function() {
this.element.trigger('create');
}, this));
} | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"this",
".",
"element",
"=",
"$",
"(",
"element",
")",
".",
"addClass",
"(",
"'colorpicker-element'",
")",
";",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
... | Colorpicker component class
@param {Object|String} element
@param {Object} options
@constructor | [
"Colorpicker",
"component",
"class"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js#L767-L903 | train | Colorpicker constructor. | [
30522,
3853,
1006,
5783,
1010,
7047,
1007,
1063,
2023,
1012,
5783,
1027,
1002,
1006,
5783,
1007,
1012,
5587,
26266,
1006,
1005,
3609,
24330,
5484,
1011,
5783,
1005,
1007,
1025,
2023,
1012,
7047,
1027,
1002,
1012,
7949,
1006,
2995,
1010,
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 | _initialLayout | function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
} | javascript | function _initialLayout(forceRefresh) {
var panes = Object.keys(_panes),
size = 100 / panes.length;
_.forEach(_panes, function (pane) {
if (pane.id === FIRST_PANE) {
if (_orientation === VERTICAL) {
pane.$el.css({height: "100%",
width: size + "%",
float: "left"
});
} else {
pane.$el.css({ height: size + "%",
width: "100%"
});
}
} else {
if (_orientation === VERTICAL) {
pane.$el.css({ height: "100%",
width: "auto",
float: "none"
});
} else {
pane.$el.css({ width: "100%",
height: "50%"
});
}
}
_synchronizePaneSize(pane, forceRefresh);
});
} | [
"function",
"_initialLayout",
"(",
"forceRefresh",
")",
"{",
"var",
"panes",
"=",
"Object",
".",
"keys",
"(",
"_panes",
")",
",",
"size",
"=",
"100",
"/",
"panes",
".",
"length",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
... | Sets up the initial layout so panes are evenly distributed
This also sets css properties that aid in the layout when _updateLayout is called
@param {boolean} forceRefresh - true to force a resize and refresh of the entire view
@private | [
"Sets",
"up",
"the",
"initial",
"layout",
"so",
"panes",
"are",
"evenly",
"distributed",
"This",
"also",
"sets",
"css",
"properties",
"that",
"aid",
"in",
"the",
"layout",
"when",
"_updateLayout",
"is",
"called"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1049-L1080 | train | Layouts the initial pane | [
30522,
3853,
1035,
3988,
8485,
5833,
1006,
2486,
2890,
19699,
9953,
1007,
1063,
13075,
6090,
2229,
1027,
4874,
1012,
6309,
1006,
1035,
6090,
2229,
1007,
1010,
2946,
1027,
2531,
1013,
6090,
2229,
1012,
3091,
1025,
1035,
1012,
18921,
6776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/ui5loader.js | handleConfigObject | function handleConfigObject(oCfg, mHandlers) {
function processConfig(key, value) {
var handler = mHandlers[key];
if ( typeof handler === 'function' ) {
if ( handler.length === 1) {
handler(value);
} else if ( value != null ) {
forEach(value, handler);
}
} else {
log.warning("configuration option " + key + " not supported (ignored)");
}
}
// Make sure the 'baseUrl' handler is called first as
// other handlers (e.g. paths) depend on it
if (oCfg.baseUrl) {
processConfig("baseUrl", oCfg.baseUrl);
}
forEach(oCfg, function(key, value) {
// Ignore "baseUrl" here as it will be handled above
if (key !== "baseUrl") {
processConfig(key, value);
}
});
} | javascript | function handleConfigObject(oCfg, mHandlers) {
function processConfig(key, value) {
var handler = mHandlers[key];
if ( typeof handler === 'function' ) {
if ( handler.length === 1) {
handler(value);
} else if ( value != null ) {
forEach(value, handler);
}
} else {
log.warning("configuration option " + key + " not supported (ignored)");
}
}
// Make sure the 'baseUrl' handler is called first as
// other handlers (e.g. paths) depend on it
if (oCfg.baseUrl) {
processConfig("baseUrl", oCfg.baseUrl);
}
forEach(oCfg, function(key, value) {
// Ignore "baseUrl" here as it will be handled above
if (key !== "baseUrl") {
processConfig(key, value);
}
});
} | [
"function",
"handleConfigObject",
"(",
"oCfg",
",",
"mHandlers",
")",
"{",
"function",
"processConfig",
"(",
"key",
",",
"value",
")",
"{",
"var",
"handler",
"=",
"mHandlers",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"handler",
"===",
"'function'",
")",
... | Executes all available handlers which are defined in the config object
@param {object} oCfg config to handle
@param {map} mHandlers all available handlers | [
"Executes",
"all",
"available",
"handlers",
"which",
"are",
"defined",
"in",
"the",
"config",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L2200-L2227 | train | Handle configuration object | [
30522,
3853,
5047,
8663,
8873,
3995,
2497,
20614,
1006,
1051,
2278,
2546,
2290,
1010,
1049,
11774,
12910,
1007,
1063,
3853,
2832,
8663,
8873,
2290,
1006,
3145,
1010,
3643,
1007,
1063,
13075,
28213,
1027,
1049,
11774,
12910,
1031,
3145,
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... |
graphql/graphql-js | src/validation/rules/VariablesInAllowedPosition.js | allowedVariableUsage | function allowedVariableUsage(
schema: GraphQLSchema,
varType: GraphQLType,
varDefaultValue: ?ValueNode,
locationType: GraphQLType,
locationDefaultValue: ?mixed,
): boolean {
if (isNonNullType(locationType) && !isNonNullType(varType)) {
const hasNonNullVariableDefaultValue =
varDefaultValue && varDefaultValue.kind !== Kind.NULL;
const hasLocationDefaultValue = locationDefaultValue !== undefined;
if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
return false;
}
const nullableLocationType = locationType.ofType;
return isTypeSubTypeOf(schema, varType, nullableLocationType);
}
return isTypeSubTypeOf(schema, varType, locationType);
} | javascript | function allowedVariableUsage(
schema: GraphQLSchema,
varType: GraphQLType,
varDefaultValue: ?ValueNode,
locationType: GraphQLType,
locationDefaultValue: ?mixed,
): boolean {
if (isNonNullType(locationType) && !isNonNullType(varType)) {
const hasNonNullVariableDefaultValue =
varDefaultValue && varDefaultValue.kind !== Kind.NULL;
const hasLocationDefaultValue = locationDefaultValue !== undefined;
if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) {
return false;
}
const nullableLocationType = locationType.ofType;
return isTypeSubTypeOf(schema, varType, nullableLocationType);
}
return isTypeSubTypeOf(schema, varType, locationType);
} | [
"function",
"allowedVariableUsage",
"(",
"schema",
":",
"GraphQLSchema",
",",
"varType",
":",
"GraphQLType",
",",
"varDefaultValue",
":",
"?",
"ValueNode",
",",
"locationType",
":",
"GraphQLType",
",",
"locationDefaultValue",
":",
"?",
"mixed",
",",
")",
":",
"b... | Returns true if the variable is allowed in the location it was found,
which includes considering if default values exist for either the variable
or the location at which it is located. | [
"Returns",
"true",
"if",
"the",
"variable",
"is",
"allowed",
"in",
"the",
"location",
"it",
"was",
"found",
"which",
"includes",
"considering",
"if",
"default",
"values",
"exist",
"for",
"either",
"the",
"variable",
"or",
"the",
"location",
"at",
"which",
"i... | b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef | https://github.com/graphql/graphql-js/blob/b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef/src/validation/rules/VariablesInAllowedPosition.js#L91-L109 | train | Checks if a variable is allowed by a cluster | [
30522,
3853,
3039,
10755,
19210,
10383,
3351,
1006,
8040,
28433,
1024,
10629,
4160,
4877,
5403,
2863,
1010,
13075,
13874,
1024,
10629,
4160,
24228,
5051,
1010,
13075,
3207,
7011,
11314,
10175,
5657,
1024,
1029,
3643,
3630,
3207,
1010,
3295,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/commons/text/native-text-alternative.js | findTextMethods | function findTextMethods(virtualNode) {
const { nativeElementType, nativeTextMethods } = text;
const nativeType = nativeElementType.find(({ matches }) => {
return axe.commons.matches(virtualNode, matches);
});
// Use concat because namingMethods can be a string or an array of strings
const methods = nativeType ? [].concat(nativeType.namingMethods) : [];
return methods.map(methodName => nativeTextMethods[methodName]);
} | javascript | function findTextMethods(virtualNode) {
const { nativeElementType, nativeTextMethods } = text;
const nativeType = nativeElementType.find(({ matches }) => {
return axe.commons.matches(virtualNode, matches);
});
// Use concat because namingMethods can be a string or an array of strings
const methods = nativeType ? [].concat(nativeType.namingMethods) : [];
return methods.map(methodName => nativeTextMethods[methodName]);
} | [
"function",
"findTextMethods",
"(",
"virtualNode",
")",
"{",
"const",
"{",
"nativeElementType",
",",
"nativeTextMethods",
"}",
"=",
"text",
";",
"const",
"nativeType",
"=",
"nativeElementType",
".",
"find",
"(",
"(",
"{",
"matches",
"}",
")",
"=>",
"{",
"ret... | Get accessible text functions for a specific native HTML element
@private
@param {VirtualNode} element
@return {Function[]} Array of native accessible name computation methods | [
"Get",
"accessible",
"text",
"functions",
"for",
"a",
"specific",
"native",
"HTML",
"element"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/text/native-text-alternative.js#L40-L50 | train | Find text methods | [
30522,
3853,
2424,
18209,
11368,
6806,
5104,
1006,
7484,
3630,
3207,
1007,
1063,
9530,
3367,
1063,
3128,
12260,
3672,
13874,
1010,
3128,
18209,
11368,
6806,
5104,
1065,
1027,
3793,
1025,
9530,
3367,
3128,
13874,
1027,
3128,
12260,
3672,
138... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Manifest.js | function(oInstance) {
if (this._iInstanceCount === 0) {
// version check => only if minVersion is available a warning
// will be logged and the debug mode is turned on
this.checkUI5Version();
// define the resource roots
// => if not loaded via manifest first approach the resource roots
// will be registered too late for the AMD modules of the Component
// controller. This is a constraint for the resource roots config
// in the manifest!
this.defineResourceRoots();
// load the component dependencies (other UI5 libraries)
this.loadDependencies();
// load the custom scripts and CSS files
this.loadIncludes();
// activate the static customizing
this.activateCustomizing();
}
// activate the instance customizing
if (oInstance) {
this.activateCustomizing(oInstance);
}
this._iInstanceCount++;
} | javascript | function(oInstance) {
if (this._iInstanceCount === 0) {
// version check => only if minVersion is available a warning
// will be logged and the debug mode is turned on
this.checkUI5Version();
// define the resource roots
// => if not loaded via manifest first approach the resource roots
// will be registered too late for the AMD modules of the Component
// controller. This is a constraint for the resource roots config
// in the manifest!
this.defineResourceRoots();
// load the component dependencies (other UI5 libraries)
this.loadDependencies();
// load the custom scripts and CSS files
this.loadIncludes();
// activate the static customizing
this.activateCustomizing();
}
// activate the instance customizing
if (oInstance) {
this.activateCustomizing(oInstance);
}
this._iInstanceCount++;
} | [
"function",
"(",
"oInstance",
")",
"{",
"if",
"(",
"this",
".",
"_iInstanceCount",
"===",
"0",
")",
"{",
"// version check => only if minVersion is available a warning",
"// will be logged and the debug mode is turned on",
"this",
".",
"checkUI5Version",
"(",
")",
";",
"/... | Initializes the manifest which executes checks, define the resource
roots, load the dependencies and the includes.
@private | [
"Initializes",
"the",
"manifest",
"which",
"executes",
"checks",
"define",
"the",
"resource",
"roots",
"load",
"the",
"dependencies",
"and",
"the",
"includes",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Manifest.js#L625-L658 | train | Initializes the component customizing | [
30522,
3853,
1006,
1051,
7076,
26897,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
2462,
23808,
6651,
3597,
16671,
1027,
1027,
1027,
1014,
1007,
1063,
1013,
1013,
2544,
4638,
1027,
1028,
2069,
2065,
8117,
27774,
2003,
2800,
1037,
5432,
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... | |
SheetJS/js-xlsx | xlsx.js | parse_rpr | function parse_rpr(rpr, intro, outro) {
var font = {}, cp = 65001, align = "";
var pass = false;
var m = rpr.match(tagregex), i = 0;
if(m) for(;i!=m.length; ++i) {
var y = parsexmltag(m[i]);
switch(y[0].replace(/\w*:/g,"")) {
/* 18.8.12 condense CT_BooleanProperty */
/* ** not required . */
case '<condense': break;
/* 18.8.17 extend CT_BooleanProperty */
/* ** not required . */
case '<extend': break;
/* 18.8.36 shadow CT_BooleanProperty */
/* ** not required . */
case '<shadow':
if(!y.val) break;
/* falls through */
case '<shadow>':
case '<shadow/>': font.shadow = 1; break;
case '</shadow>': break;
/* 18.4.1 charset CT_IntProperty TODO */
case '<charset':
if(y.val == '1') break;
cp = CS2CP[parseInt(y.val, 10)];
break;
/* 18.4.2 outline CT_BooleanProperty TODO */
case '<outline':
if(!y.val) break;
/* falls through */
case '<outline>':
case '<outline/>': font.outline = 1; break;
case '</outline>': break;
/* 18.4.5 rFont CT_FontName */
case '<rFont': font.name = y.val; break;
/* 18.4.11 sz CT_FontSize */
case '<sz': font.sz = y.val; break;
/* 18.4.10 strike CT_BooleanProperty */
case '<strike':
if(!y.val) break;
/* falls through */
case '<strike>':
case '<strike/>': font.strike = 1; break;
case '</strike>': break;
/* 18.4.13 u CT_UnderlineProperty */
case '<u':
if(!y.val) break;
switch(y.val) {
case 'double': font.uval = "double"; break;
case 'singleAccounting': font.uval = "single-accounting"; break;
case 'doubleAccounting': font.uval = "double-accounting"; break;
}
/* falls through */
case '<u>':
case '<u/>': font.u = 1; break;
case '</u>': break;
/* 18.8.2 b */
case '<b':
if(y.val == '0') break;
/* falls through */
case '<b>':
case '<b/>': font.b = 1; break;
case '</b>': break;
/* 18.8.26 i */
case '<i':
if(y.val == '0') break;
/* falls through */
case '<i>':
case '<i/>': font.i = 1; break;
case '</i>': break;
/* 18.3.1.15 color CT_Color TODO: tint, theme, auto, indexed */
case '<color':
if(y.rgb) font.color = y.rgb.slice(2,8);
break;
/* 18.8.18 family ST_FontFamily */
case '<family': font.family = y.val; break;
/* 18.4.14 vertAlign CT_VerticalAlignFontProperty TODO */
case '<vertAlign': align = y.val; break;
/* 18.8.35 scheme CT_FontScheme TODO */
case '<scheme': break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '<extLst': case '<extLst>': case '</extLst>': break;
case '<ext': pass = true; break;
case '</ext>': pass = false; break;
default:
if(y[0].charCodeAt(1) !== 47 && !pass) throw new Error('Unrecognized rich format ' + y[0]);
}
}
var style = [];
if(font.u) style.push("text-decoration: underline;");
if(font.uval) style.push("text-underline-style:" + font.uval + ";");
if(font.sz) style.push("font-size:" + font.sz + "pt;");
if(font.outline) style.push("text-effect: outline;");
if(font.shadow) style.push("text-shadow: auto;");
intro.push('<span style="' + style.join("") + '">');
if(font.b) { intro.push("<b>"); outro.push("</b>"); }
if(font.i) { intro.push("<i>"); outro.push("</i>"); }
if(font.strike) { intro.push("<s>"); outro.push("</s>"); }
if(align == "superscript") align = "sup";
else if(align == "subscript") align = "sub";
if(align != "") { intro.push("<" + align + ">"); outro.push("</" + align + ">"); }
outro.push("</span>");
return cp;
} | javascript | function parse_rpr(rpr, intro, outro) {
var font = {}, cp = 65001, align = "";
var pass = false;
var m = rpr.match(tagregex), i = 0;
if(m) for(;i!=m.length; ++i) {
var y = parsexmltag(m[i]);
switch(y[0].replace(/\w*:/g,"")) {
/* 18.8.12 condense CT_BooleanProperty */
/* ** not required . */
case '<condense': break;
/* 18.8.17 extend CT_BooleanProperty */
/* ** not required . */
case '<extend': break;
/* 18.8.36 shadow CT_BooleanProperty */
/* ** not required . */
case '<shadow':
if(!y.val) break;
/* falls through */
case '<shadow>':
case '<shadow/>': font.shadow = 1; break;
case '</shadow>': break;
/* 18.4.1 charset CT_IntProperty TODO */
case '<charset':
if(y.val == '1') break;
cp = CS2CP[parseInt(y.val, 10)];
break;
/* 18.4.2 outline CT_BooleanProperty TODO */
case '<outline':
if(!y.val) break;
/* falls through */
case '<outline>':
case '<outline/>': font.outline = 1; break;
case '</outline>': break;
/* 18.4.5 rFont CT_FontName */
case '<rFont': font.name = y.val; break;
/* 18.4.11 sz CT_FontSize */
case '<sz': font.sz = y.val; break;
/* 18.4.10 strike CT_BooleanProperty */
case '<strike':
if(!y.val) break;
/* falls through */
case '<strike>':
case '<strike/>': font.strike = 1; break;
case '</strike>': break;
/* 18.4.13 u CT_UnderlineProperty */
case '<u':
if(!y.val) break;
switch(y.val) {
case 'double': font.uval = "double"; break;
case 'singleAccounting': font.uval = "single-accounting"; break;
case 'doubleAccounting': font.uval = "double-accounting"; break;
}
/* falls through */
case '<u>':
case '<u/>': font.u = 1; break;
case '</u>': break;
/* 18.8.2 b */
case '<b':
if(y.val == '0') break;
/* falls through */
case '<b>':
case '<b/>': font.b = 1; break;
case '</b>': break;
/* 18.8.26 i */
case '<i':
if(y.val == '0') break;
/* falls through */
case '<i>':
case '<i/>': font.i = 1; break;
case '</i>': break;
/* 18.3.1.15 color CT_Color TODO: tint, theme, auto, indexed */
case '<color':
if(y.rgb) font.color = y.rgb.slice(2,8);
break;
/* 18.8.18 family ST_FontFamily */
case '<family': font.family = y.val; break;
/* 18.4.14 vertAlign CT_VerticalAlignFontProperty TODO */
case '<vertAlign': align = y.val; break;
/* 18.8.35 scheme CT_FontScheme TODO */
case '<scheme': break;
/* 18.2.10 extLst CT_ExtensionList ? */
case '<extLst': case '<extLst>': case '</extLst>': break;
case '<ext': pass = true; break;
case '</ext>': pass = false; break;
default:
if(y[0].charCodeAt(1) !== 47 && !pass) throw new Error('Unrecognized rich format ' + y[0]);
}
}
var style = [];
if(font.u) style.push("text-decoration: underline;");
if(font.uval) style.push("text-underline-style:" + font.uval + ";");
if(font.sz) style.push("font-size:" + font.sz + "pt;");
if(font.outline) style.push("text-effect: outline;");
if(font.shadow) style.push("text-shadow: auto;");
intro.push('<span style="' + style.join("") + '">');
if(font.b) { intro.push("<b>"); outro.push("</b>"); }
if(font.i) { intro.push("<i>"); outro.push("</i>"); }
if(font.strike) { intro.push("<s>"); outro.push("</s>"); }
if(align == "superscript") align = "sup";
else if(align == "subscript") align = "sub";
if(align != "") { intro.push("<" + align + ">"); outro.push("</" + align + ">"); }
outro.push("</span>");
return cp;
} | [
"function",
"parse_rpr",
"(",
"rpr",
",",
"intro",
",",
"outro",
")",
"{",
"var",
"font",
"=",
"{",
"}",
",",
"cp",
"=",
"65001",
",",
"align",
"=",
"\"\"",
";",
"var",
"pass",
"=",
"false",
";",
"var",
"m",
"=",
"rpr",
".",
"match",
"(",
"tagr... | /* 18.4.7 rPr CT_RPrElt | [
"/",
"*",
"18",
".",
"4",
".",
"7",
"rPr",
"CT_RPrElt"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L7853-L7973 | train | Parse the RPR. | [
30522,
3853,
11968,
3366,
1035,
1054,
18098,
1006,
1054,
18098,
1010,
17174,
1010,
2041,
3217,
1007,
1063,
13075,
15489,
1027,
1063,
1065,
1010,
18133,
1027,
13757,
24096,
1010,
25705,
1027,
1000,
1000,
1025,
13075,
3413,
1027,
6270,
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... |
apache/incubator-echarts | src/coord/View.js | function (x, y, width, height) {
var rect = this.getBoundingRect();
var rawTransform = this._rawTransformable;
rawTransform.transform = rect.calculateTransform(
new BoundingRect(x, y, width, height)
);
rawTransform.decomposeTransform();
this._updateTransform();
} | javascript | function (x, y, width, height) {
var rect = this.getBoundingRect();
var rawTransform = this._rawTransformable;
rawTransform.transform = rect.calculateTransform(
new BoundingRect(x, y, width, height)
);
rawTransform.decomposeTransform();
this._updateTransform();
} | [
"function",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"var",
"rect",
"=",
"this",
".",
"getBoundingRect",
"(",
")",
";",
"var",
"rawTransform",
"=",
"this",
".",
"_rawTransformable",
";",
"rawTransform",
".",
"transform",
"=",
"rect",
... | Transformed to particular position and size
@param {number} x
@param {number} y
@param {number} width
@param {number} height | [
"Transformed",
"to",
"particular",
"position",
"and",
"size"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L112-L123 | train | Update the transform of the image | [
30522,
3853,
1006,
1060,
1010,
1061,
1010,
9381,
1010,
4578,
1007,
1063,
13075,
28667,
2102,
1027,
2023,
1012,
2131,
15494,
2075,
2890,
6593,
1006,
1007,
1025,
13075,
6315,
6494,
3619,
14192,
1027,
2023,
1012,
1035,
6315,
6494,
3619,
14192,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/chart/sankey/SankeyView.js | createGridClipShape | function createGridClipShape(rect, seriesModel, cb) {
var rectEl = new graphic.Rect({
shape: {
x: rect.x - 10,
y: rect.y - 10,
width: 0,
height: rect.height + 20
}
});
graphic.initProps(rectEl, {
shape: {
width: rect.width + 20,
height: rect.height + 20
}
}, seriesModel, cb);
return rectEl;
} | javascript | function createGridClipShape(rect, seriesModel, cb) {
var rectEl = new graphic.Rect({
shape: {
x: rect.x - 10,
y: rect.y - 10,
width: 0,
height: rect.height + 20
}
});
graphic.initProps(rectEl, {
shape: {
width: rect.width + 20,
height: rect.height + 20
}
}, seriesModel, cb);
return rectEl;
} | [
"function",
"createGridClipShape",
"(",
"rect",
",",
"seriesModel",
",",
"cb",
")",
"{",
"var",
"rectEl",
"=",
"new",
"graphic",
".",
"Rect",
"(",
"{",
"shape",
":",
"{",
"x",
":",
"rect",
".",
"x",
"-",
"10",
",",
"y",
":",
"rect",
".",
"y",
"-"... | Add animation to the view | [
"Add",
"animation",
"to",
"the",
"view"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/SankeyView.js#L409-L426 | train | Creates a grid clip shape | [
30522,
3853,
3443,
16523,
3593,
20464,
11514,
7377,
5051,
1006,
28667,
2102,
1010,
2186,
5302,
9247,
1010,
17324,
1007,
1063,
13075,
28667,
9834,
1027,
2047,
8425,
1012,
28667,
2102,
1006,
1063,
4338,
1024,
1063,
1060,
1024,
28667,
2102,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/trace/FESR.js | setClientDevice | function setClientDevice() {
var iClientId = 0;
if (Device.system.combi) {
iClientId = 1;
} else if (Device.system.desktop) {
iClientId = 2;
} else if (Device.system.tablet) {
iClientId = 4;
} else if (Device.system.phone) {
iClientId = 3;
}
return iClientId;
} | javascript | function setClientDevice() {
var iClientId = 0;
if (Device.system.combi) {
iClientId = 1;
} else if (Device.system.desktop) {
iClientId = 2;
} else if (Device.system.tablet) {
iClientId = 4;
} else if (Device.system.phone) {
iClientId = 3;
}
return iClientId;
} | [
"function",
"setClientDevice",
"(",
")",
"{",
"var",
"iClientId",
"=",
"0",
";",
"if",
"(",
"Device",
".",
"system",
".",
"combi",
")",
"{",
"iClientId",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"Device",
".",
"system",
".",
"desktop",
")",
"{",
"iCl... | current header string | [
"current",
"header",
"string"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/trace/FESR.js#L33-L45 | train | set client device | [
30522,
3853,
2275,
20464,
11638,
24844,
6610,
1006,
1007,
1063,
13075,
24582,
8751,
16778,
2094,
1027,
1014,
1025,
2065,
1006,
5080,
1012,
2291,
1012,
22863,
2072,
1007,
1063,
24582,
8751,
16778,
2094,
1027,
1015,
1025,
1065,
2842,
2065,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/graphic/helper/text.js | drawBackground | function drawBackground(hostEl, ctx, style, x, y, width, height) {
var textBackgroundColor = style.textBackgroundColor;
var textBorderWidth = style.textBorderWidth;
var textBorderColor = style.textBorderColor;
var isPlainBg = isString(textBackgroundColor);
setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
if (isPlainBg || (textBorderWidth && textBorderColor)) {
ctx.beginPath();
var textBorderRadius = style.textBorderRadius;
if (!textBorderRadius) {
ctx.rect(x, y, width, height);
}
else {
roundRectHelper.buildPath(ctx, {
x: x, y: y, width: width, height: height, r: textBorderRadius
});
}
ctx.closePath();
}
if (isPlainBg) {
setCtx(ctx, 'fillStyle', textBackgroundColor);
if (style.fillOpacity != null) {
var originalGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = style.fillOpacity * style.opacity;
ctx.fill();
ctx.globalAlpha = originalGlobalAlpha;
}
else {
ctx.fill();
}
}
else if (isObject(textBackgroundColor)) {
var image = textBackgroundColor.image;
image = imageHelper.createOrUpdateImage(
image, null, hostEl, onBgImageLoaded, textBackgroundColor
);
if (image && imageHelper.isImageReady(image)) {
ctx.drawImage(image, x, y, width, height);
}
}
if (textBorderWidth && textBorderColor) {
setCtx(ctx, 'lineWidth', textBorderWidth);
setCtx(ctx, 'strokeStyle', textBorderColor);
if (style.strokeOpacity != null) {
var originalGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = style.strokeOpacity * style.opacity;
ctx.stroke();
ctx.globalAlpha = originalGlobalAlpha;
}
else {
ctx.stroke();
}
}
} | javascript | function drawBackground(hostEl, ctx, style, x, y, width, height) {
var textBackgroundColor = style.textBackgroundColor;
var textBorderWidth = style.textBorderWidth;
var textBorderColor = style.textBorderColor;
var isPlainBg = isString(textBackgroundColor);
setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
if (isPlainBg || (textBorderWidth && textBorderColor)) {
ctx.beginPath();
var textBorderRadius = style.textBorderRadius;
if (!textBorderRadius) {
ctx.rect(x, y, width, height);
}
else {
roundRectHelper.buildPath(ctx, {
x: x, y: y, width: width, height: height, r: textBorderRadius
});
}
ctx.closePath();
}
if (isPlainBg) {
setCtx(ctx, 'fillStyle', textBackgroundColor);
if (style.fillOpacity != null) {
var originalGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = style.fillOpacity * style.opacity;
ctx.fill();
ctx.globalAlpha = originalGlobalAlpha;
}
else {
ctx.fill();
}
}
else if (isObject(textBackgroundColor)) {
var image = textBackgroundColor.image;
image = imageHelper.createOrUpdateImage(
image, null, hostEl, onBgImageLoaded, textBackgroundColor
);
if (image && imageHelper.isImageReady(image)) {
ctx.drawImage(image, x, y, width, height);
}
}
if (textBorderWidth && textBorderColor) {
setCtx(ctx, 'lineWidth', textBorderWidth);
setCtx(ctx, 'strokeStyle', textBorderColor);
if (style.strokeOpacity != null) {
var originalGlobalAlpha = ctx.globalAlpha;
ctx.globalAlpha = style.strokeOpacity * style.opacity;
ctx.stroke();
ctx.globalAlpha = originalGlobalAlpha;
}
else {
ctx.stroke();
}
}
} | [
"function",
"drawBackground",
"(",
"hostEl",
",",
"ctx",
",",
"style",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"var",
"textBackgroundColor",
"=",
"style",
".",
"textBackgroundColor",
";",
"var",
"textBorderWidth",
"=",
"style",
".",
"tex... | style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius, text} shape: {x, y, width, height} | [
"style",
":",
"{",
"textBackgroundColor",
"textBorderWidth",
"textBorderColor",
"textBorderRadius",
"text",
"}",
"shape",
":",
"{",
"x",
"y",
"width",
"height",
"}"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/graphic/helper/text.js#L420-L483 | train | draw background for a host element | [
30522,
3853,
4009,
5963,
16365,
1006,
21071,
1010,
14931,
2595,
1010,
2806,
1010,
1060,
1010,
1061,
1010,
9381,
1010,
4578,
1007,
1063,
13075,
3793,
5963,
16365,
18717,
1027,
2806,
1012,
3793,
5963,
16365,
18717,
1025,
13075,
3793,
12821,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | resolveCollisions | function resolveCollisions(nodesByBreadth, nodeGap, height, width, orient) {
var keyAttr = orient === 'vertical' ? 'x' : 'y';
zrUtil.each(nodesByBreadth, function (nodes) {
nodes.sort(function (a, b) {
return a.getLayout()[keyAttr] - b.getLayout()[keyAttr];
});
var nodeX;
var node;
var dy;
var y0 = 0;
var n = nodes.length;
var nodeDyAttr = orient === 'vertical' ? 'dx' : 'dy';
for (var i = 0; i < n; i++) {
node = nodes[i];
dy = y0 - node.getLayout()[keyAttr];
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] + dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
}
y0 = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap;
}
var viewWidth = orient === 'vertical' ? width : height;
// If the bottommost node goes outside the bounds, push it back up
dy = y0 - nodeGap - viewWidth;
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] - dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
y0 = nodeX;
for (i = n - 2; i >= 0; --i) {
node = nodes[i];
dy = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap - y0;
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] - dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
}
y0 = node.getLayout()[keyAttr];
}
}
});
} | javascript | function resolveCollisions(nodesByBreadth, nodeGap, height, width, orient) {
var keyAttr = orient === 'vertical' ? 'x' : 'y';
zrUtil.each(nodesByBreadth, function (nodes) {
nodes.sort(function (a, b) {
return a.getLayout()[keyAttr] - b.getLayout()[keyAttr];
});
var nodeX;
var node;
var dy;
var y0 = 0;
var n = nodes.length;
var nodeDyAttr = orient === 'vertical' ? 'dx' : 'dy';
for (var i = 0; i < n; i++) {
node = nodes[i];
dy = y0 - node.getLayout()[keyAttr];
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] + dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
}
y0 = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap;
}
var viewWidth = orient === 'vertical' ? width : height;
// If the bottommost node goes outside the bounds, push it back up
dy = y0 - nodeGap - viewWidth;
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] - dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
y0 = nodeX;
for (i = n - 2; i >= 0; --i) {
node = nodes[i];
dy = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap - y0;
if (dy > 0) {
nodeX = node.getLayout()[keyAttr] - dy;
orient === 'vertical'
? node.setLayout({x: nodeX}, true)
: node.setLayout({y: nodeX}, true);
}
y0 = node.getLayout()[keyAttr];
}
}
});
} | [
"function",
"resolveCollisions",
"(",
"nodesByBreadth",
",",
"nodeGap",
",",
"height",
",",
"width",
",",
"orient",
")",
"{",
"var",
"keyAttr",
"=",
"orient",
"===",
"'vertical'",
"?",
"'x'",
":",
"'y'",
";",
"zrUtil",
".",
"each",
"(",
"nodesByBreadth",
"... | Resolve the collision of initialized depth (y-position)
@param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
group by the array of all sankey nodes based on the nodes x-position.
@param {number} nodeGap the vertical distance between two nodes
@param {number} height the whole height of the area to draw the view | [
"Resolve",
"the",
"collision",
"of",
"initialized",
"depth",
"(",
"y",
"-",
"position",
")"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L347-L393 | train | Resolve collision between nodes | [
30522,
3853,
10663,
26895,
19969,
2015,
1006,
14164,
3762,
27035,
2705,
1010,
13045,
3654,
2361,
1010,
4578,
1010,
9381,
1010,
16865,
1007,
1063,
13075,
3145,
19321,
2099,
1027,
16865,
1027,
1027,
1027,
1005,
7471,
1005,
1029,
1005,
1060,
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... |
aws/aws-sdk-js | lib/discover_endpoint.js | requiredDiscoverEndpoint | function requiredDiscoverEndpoint(request, done) {
var service = request.service;
var api = service.api;
var operationModel = api.operations ? api.operations[request.operation] : undefined;
var inputShape = operationModel ? operationModel.input : undefined;
var identifiers = marshallCustomIdentifiers(request, inputShape);
var cacheKey = getCacheKey(request);
if (Object.keys(identifiers).length > 0) {
cacheKey = util.update(cacheKey, identifiers);
if (operationModel) cacheKey.operation = operationModel.name;
}
var cacheKeyStr = AWS.EndpointCache.getKeyString(cacheKey);
var endpoints = AWS.endpointCache.get(cacheKeyStr); //endpoint cache also accepts string keys
if (endpoints && endpoints.length === 1 && endpoints[0].Address === '') {
//endpoint operation is being made but response not yet received
//push request object to a pending queue
if (!requestQueue[cacheKeyStr]) requestQueue[cacheKeyStr] = [];
requestQueue[cacheKeyStr].push({request: request, callback: done});
return;
} else if (endpoints && endpoints.length > 0) {
request.httpRequest.updateEndpoint(endpoints[0].Address);
done();
} else {
var endpointRequest = service.makeRequest(api.endpointOperation, {
Operation: operationModel.name,
Identifiers: identifiers,
});
endpointRequest.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS);
addApiVersionHeader(endpointRequest);
//put in a placeholder for endpoints already requested, prevent
//too much in-flight calls
AWS.endpointCache.put(cacheKeyStr, [{
Address: '',
CachePeriodInMinutes: 60 //long-live cache
}]);
endpointRequest.send(function(err, data) {
if (err) {
var errorParams = {
code: 'EndpointDiscoveryException',
message: 'Request cannot be fulfilled without specifying an endpoint',
retryable: false
};
request.response.error = util.error(err, errorParams);
AWS.endpointCache.remove(cacheKey);
//fail all the pending requests in batch
if (requestQueue[cacheKeyStr]) {
var pendingRequests = requestQueue[cacheKeyStr];
util.arrayEach(pendingRequests, function(requestContext) {
requestContext.request.response.error = util.error(err, errorParams);
requestContext.callback();
});
delete requestQueue[cacheKeyStr];
}
} else if (data) {
AWS.endpointCache.put(cacheKeyStr, data.Endpoints);
request.httpRequest.updateEndpoint(data.Endpoints[0].Address);
//update the endpoint for all the pending requests in batch
if (requestQueue[cacheKeyStr]) {
var pendingRequests = requestQueue[cacheKeyStr];
util.arrayEach(pendingRequests, function(requestContext) {
requestContext.request.httpRequest.updateEndpoint(data.Endpoints[0].Address);
requestContext.callback();
});
delete requestQueue[cacheKeyStr];
}
}
done();
});
}
} | javascript | function requiredDiscoverEndpoint(request, done) {
var service = request.service;
var api = service.api;
var operationModel = api.operations ? api.operations[request.operation] : undefined;
var inputShape = operationModel ? operationModel.input : undefined;
var identifiers = marshallCustomIdentifiers(request, inputShape);
var cacheKey = getCacheKey(request);
if (Object.keys(identifiers).length > 0) {
cacheKey = util.update(cacheKey, identifiers);
if (operationModel) cacheKey.operation = operationModel.name;
}
var cacheKeyStr = AWS.EndpointCache.getKeyString(cacheKey);
var endpoints = AWS.endpointCache.get(cacheKeyStr); //endpoint cache also accepts string keys
if (endpoints && endpoints.length === 1 && endpoints[0].Address === '') {
//endpoint operation is being made but response not yet received
//push request object to a pending queue
if (!requestQueue[cacheKeyStr]) requestQueue[cacheKeyStr] = [];
requestQueue[cacheKeyStr].push({request: request, callback: done});
return;
} else if (endpoints && endpoints.length > 0) {
request.httpRequest.updateEndpoint(endpoints[0].Address);
done();
} else {
var endpointRequest = service.makeRequest(api.endpointOperation, {
Operation: operationModel.name,
Identifiers: identifiers,
});
endpointRequest.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS);
addApiVersionHeader(endpointRequest);
//put in a placeholder for endpoints already requested, prevent
//too much in-flight calls
AWS.endpointCache.put(cacheKeyStr, [{
Address: '',
CachePeriodInMinutes: 60 //long-live cache
}]);
endpointRequest.send(function(err, data) {
if (err) {
var errorParams = {
code: 'EndpointDiscoveryException',
message: 'Request cannot be fulfilled without specifying an endpoint',
retryable: false
};
request.response.error = util.error(err, errorParams);
AWS.endpointCache.remove(cacheKey);
//fail all the pending requests in batch
if (requestQueue[cacheKeyStr]) {
var pendingRequests = requestQueue[cacheKeyStr];
util.arrayEach(pendingRequests, function(requestContext) {
requestContext.request.response.error = util.error(err, errorParams);
requestContext.callback();
});
delete requestQueue[cacheKeyStr];
}
} else if (data) {
AWS.endpointCache.put(cacheKeyStr, data.Endpoints);
request.httpRequest.updateEndpoint(data.Endpoints[0].Address);
//update the endpoint for all the pending requests in batch
if (requestQueue[cacheKeyStr]) {
var pendingRequests = requestQueue[cacheKeyStr];
util.arrayEach(pendingRequests, function(requestContext) {
requestContext.request.httpRequest.updateEndpoint(data.Endpoints[0].Address);
requestContext.callback();
});
delete requestQueue[cacheKeyStr];
}
}
done();
});
}
} | [
"function",
"requiredDiscoverEndpoint",
"(",
"request",
",",
"done",
")",
"{",
"var",
"service",
"=",
"request",
".",
"service",
";",
"var",
"api",
"=",
"service",
".",
"api",
";",
"var",
"operationModel",
"=",
"api",
".",
"operations",
"?",
"api",
".",
... | Call endpoint discovery operation when it's required.
When endpoint is available in cache then use cached ones. If endpoints are
unavailable then SDK should call endpoint operation then use returned new
endpoint for the api call. SDK will automatically attempt to do endpoint
discovery. This is turned off by default
@param [object] request object
@api private | [
"Call",
"endpoint",
"discovery",
"operation",
"when",
"it",
"s",
"required",
".",
"When",
"endpoint",
"is",
"available",
"in",
"cache",
"then",
"use",
"cached",
"ones",
".",
"If",
"endpoints",
"are",
"unavailable",
"then",
"SDK",
"should",
"call",
"endpoint",
... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L131-L204 | train | This function is called when an endpoint is discovered | [
30522,
3853,
3223,
10521,
3597,
28943,
4859,
8400,
1006,
5227,
1010,
2589,
1007,
1063,
13075,
2326,
1027,
5227,
1012,
2326,
1025,
13075,
17928,
1027,
2326,
1012,
17928,
1025,
13075,
3169,
5302,
9247,
1027,
17928,
1012,
3136,
1029,
17928,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | bits/44_offcrypto.js | parse_CRYPTOVersion | function parse_CRYPTOVersion(blob, length/*:?number*/) {
var o/*:any*/ = {};
o.Major = blob.read_shift(2);
o.Minor = blob.read_shift(2);
/*:: if(length == null) return o; */
if(length >= 4) blob.l += length - 4;
return o;
} | javascript | function parse_CRYPTOVersion(blob, length/*:?number*/) {
var o/*:any*/ = {};
o.Major = blob.read_shift(2);
o.Minor = blob.read_shift(2);
/*:: if(length == null) return o; */
if(length >= 4) blob.l += length - 4;
return o;
} | [
"function",
"parse_CRYPTOVersion",
"(",
"blob",
",",
"length",
"/*:?number*/",
")",
"{",
"var",
"o",
"/*:any*/",
"=",
"{",
"}",
";",
"o",
".",
"Major",
"=",
"blob",
".",
"read_shift",
"(",
"2",
")",
";",
"o",
".",
"Minor",
"=",
"blob",
".",
"read_shi... | /* [MS-OFFCRYPTO] 2.1.4 Version | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"1",
".",
"4",
"Version"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/44_offcrypto.js#L9-L16 | train | Parse the version number | [
30522,
3853,
11968,
3366,
1035,
19888,
24302,
3258,
1006,
1038,
4135,
2497,
1010,
3091,
1013,
1008,
1024,
1029,
2193,
1008,
1013,
1007,
1063,
13075,
1051,
1013,
1008,
1024,
2151,
1008,
1013,
1027,
1063,
1065,
1025,
1051,
1012,
2350,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sType, sStyle) {
assert(sType == "second" || sType == "minute" || sType == "hour" || sType == "zone" || sType == "day"
|| sType == "weekday" || sType == "week" || sType == "month" || sType == "quarter" || sType == "year" || sType == "era",
"sType must be second, minute, hour, zone, day, weekday, week, month, quarter, year, era");
if (sStyle === undefined) {
sStyle = "wide";
}
assert(sStyle === "wide" || sStyle === "short" || sStyle === "narrow", "sStyle is only allowed to be set with 'wide', 'short' or 'narrow'");
var aSingleFormFields = ["era", "weekday", "zone"],
sKey = aSingleFormFields.indexOf(sType) === -1 ? sType + "-" + sStyle : sType;
return this._get("dateFields", sKey, "displayName");
} | javascript | function(sType, sStyle) {
assert(sType == "second" || sType == "minute" || sType == "hour" || sType == "zone" || sType == "day"
|| sType == "weekday" || sType == "week" || sType == "month" || sType == "quarter" || sType == "year" || sType == "era",
"sType must be second, minute, hour, zone, day, weekday, week, month, quarter, year, era");
if (sStyle === undefined) {
sStyle = "wide";
}
assert(sStyle === "wide" || sStyle === "short" || sStyle === "narrow", "sStyle is only allowed to be set with 'wide', 'short' or 'narrow'");
var aSingleFormFields = ["era", "weekday", "zone"],
sKey = aSingleFormFields.indexOf(sType) === -1 ? sType + "-" + sStyle : sType;
return this._get("dateFields", sKey, "displayName");
} | [
"function",
"(",
"sType",
",",
"sStyle",
")",
"{",
"assert",
"(",
"sType",
"==",
"\"second\"",
"||",
"sType",
"==",
"\"minute\"",
"||",
"sType",
"==",
"\"hour\"",
"||",
"sType",
"==",
"\"zone\"",
"||",
"sType",
"==",
"\"day\"",
"||",
"sType",
"==",
"\"we... | Returns the display name for a time unit (second, minute, hour, day, week, month, year).
@param {string} sType Type (second, minute, hour, day, week, month, year)
@param {string} [sStyle="wide"] @since 1.32.10, 1.34.4 the style of the pattern. The valid values are "wide", "short" and "narrow"
returns {string} display name
@public
@since 1.34.0 | [
"Returns",
"the",
"display",
"name",
"for",
"a",
"time",
"unit",
"(",
"second",
"minute",
"hour",
"day",
"week",
"month",
"year",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L1278-L1293 | train | Returns the display name of a date field | [
30522,
3853,
1006,
2358,
18863,
1010,
7020,
27983,
1007,
1063,
20865,
1006,
2358,
18863,
1027,
1027,
1000,
2117,
1000,
1064,
1064,
2358,
18863,
1027,
1027,
1000,
3371,
1000,
1064,
1064,
2358,
18863,
1027,
1027,
1000,
3178,
1000,
1064,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _close | function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
} | javascript | function _close(paneId, file, optionsIn) {
var options = optionsIn || {};
_forEachPaneOrPanes(paneId, function (pane) {
if (pane.removeView(file, options.noOpenNextFile) && (paneId === ACTIVE_PANE || pane.id === paneId)) {
_removeFileFromMRU(pane.id, file);
exports.trigger("workingSetRemove", file, false, pane.id);
return false;
}
});
} | [
"function",
"_close",
"(",
"paneId",
",",
"file",
",",
"optionsIn",
")",
"{",
"var",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"if",
"(",
"pane",
".",
"removeView",
"... | Closes a file in the specified pane or panes
@param {!string} paneId - id of the pane in which to open the document
@param {!File} file - file to close
@param {Object={noOpenNextFile:boolean}} optionsIn - options
This function does not fail if the file is not open | [
"Closes",
"a",
"file",
"in",
"the",
"specified",
"pane",
"or",
"panes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1351-L1360 | train | Close a file | [
30522,
3853,
1035,
2485,
1006,
6090,
7416,
2094,
1010,
5371,
1010,
7047,
2378,
1007,
1063,
13075,
7047,
1027,
7047,
2378,
1064,
1064,
1063,
1065,
1025,
1035,
18921,
6776,
9739,
8780,
14536,
7231,
2015,
1006,
6090,
7416,
2094,
1010,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/util/dedupeJSONStringify.js | collectDuplicates | function collectDuplicates(value) {
if (value == null || typeof value !== 'object') {
return;
}
const metadata = metadataForVal.get(value);
// Only consider duplicates with hashes longer than 2 (excludes [] and {}).
if (metadata && metadata.value !== value && metadata.hash.length > 2) {
metadata.isDuplicate = true;
return;
}
if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
collectDuplicates(value[i]);
}
} else {
for (const k in value) {
if (value.hasOwnProperty(k) && value[k] !== undefined) {
collectDuplicates(value[k]);
}
}
}
} | javascript | function collectDuplicates(value) {
if (value == null || typeof value !== 'object') {
return;
}
const metadata = metadataForVal.get(value);
// Only consider duplicates with hashes longer than 2 (excludes [] and {}).
if (metadata && metadata.value !== value && metadata.hash.length > 2) {
metadata.isDuplicate = true;
return;
}
if (Array.isArray(value)) {
for (let i = 0; i < value.length; i++) {
collectDuplicates(value[i]);
}
} else {
for (const k in value) {
if (value.hasOwnProperty(k) && value[k] !== undefined) {
collectDuplicates(value[k]);
}
}
}
} | [
"function",
"collectDuplicates",
"(",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
"||",
"typeof",
"value",
"!==",
"'object'",
")",
"{",
"return",
";",
"}",
"const",
"metadata",
"=",
"metadataForVal",
".",
"get",
"(",
"value",
")",
";",
"// Only ... | Using top-down recursion, linearly scan the JSON tree to determine which values should be deduplicated. | [
"Using",
"top",
"-",
"down",
"recursion",
"linearly",
"scan",
"the",
"JSON",
"tree",
"to",
"determine",
"which",
"values",
"should",
"be",
"deduplicated",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/util/dedupeJSONStringify.js#L66-L87 | train | Collect duplicates from an object | [
30522,
3853,
8145,
8566,
24759,
24695,
2015,
1006,
3643,
1007,
1063,
2065,
1006,
3643,
1027,
1027,
19701,
1064,
1064,
2828,
11253,
3643,
999,
1027,
1027,
1005,
4874,
1005,
1007,
1063,
2709,
1025,
1065,
9530,
3367,
27425,
1027,
27425,
29278,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | requestJumptoDef | function requestJumptoDef(session, document, offset) {
var path = document.file.fullPath,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: filterText(session.getJavascriptText())
};
var ternPromise = getJumptoDef(fileInfo, offset);
return {promise: ternPromise};
} | javascript | function requestJumptoDef(session, document, offset) {
var path = document.file.fullPath,
fileInfo = {
type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
offsetLines: 0,
text: filterText(session.getJavascriptText())
};
var ternPromise = getJumptoDef(fileInfo, offset);
return {promise: ternPromise};
} | [
"function",
"requestJumptoDef",
"(",
"session",
",",
"document",
",",
"offset",
")",
"{",
"var",
"path",
"=",
"document",
".",
"file",
".",
"fullPath",
",",
"fileInfo",
"=",
"{",
"type",
":",
"MessageIds",
".",
"TERN_FILE_INFO_TYPE_FULL",
",",
"name",
":",
... | Request Jump-To-Definition from Tern.
@param {session} session - the session
@param {Document} document - the document
@param {{line: number, ch: number}} offset - the offset into the document
@return {jQuery.Promise} - The promise will not complete until tern
has completed. | [
"Request",
"Jump",
"-",
"To",
"-",
"Definition",
"from",
"Tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L412-L424 | train | Request a tern definition for a file | [
30522,
3853,
5227,
9103,
27718,
10244,
2546,
1006,
5219,
1010,
6254,
1010,
16396,
1007,
1063,
13075,
4130,
1027,
6254,
1012,
5371,
1012,
2440,
15069,
1010,
5371,
2378,
14876,
1027,
1063,
2828,
1024,
4471,
9821,
1012,
28774,
2078,
1035,
5371... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/api/v0.1/users.js | handlePermissions | function handlePermissions(options) {
return canThis(options.context).destroy.user(options.id).then(() => {
options.status = 'all';
return options;
}).catch((err) => {
return Promise.reject(new common.errors.NoPermissionError({
err: err,
context: common.i18n.t('errors.api.users.noPermissionToDestroyUser')
}));
});
} | javascript | function handlePermissions(options) {
return canThis(options.context).destroy.user(options.id).then(() => {
options.status = 'all';
return options;
}).catch((err) => {
return Promise.reject(new common.errors.NoPermissionError({
err: err,
context: common.i18n.t('errors.api.users.noPermissionToDestroyUser')
}));
});
} | [
"function",
"handlePermissions",
"(",
"options",
")",
"{",
"return",
"canThis",
"(",
"options",
".",
"context",
")",
".",
"destroy",
".",
"user",
"(",
"options",
".",
"id",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"options",
".",
"status",
"=",
"'... | ### Handle Permissions
We need to be an authorised user to perform this action
@param {Object} options
@returns {Object} options | [
"###",
"Handle",
"Permissions",
"We",
"need",
"to",
"be",
"an",
"authorised",
"user",
"to",
"perform",
"this",
"action"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/users.js#L184-L194 | train | Check if user has permissions to destroy | [
30522,
3853,
5047,
4842,
25481,
2015,
1006,
7047,
1007,
1063,
2709,
2064,
15222,
2015,
1006,
7047,
1012,
6123,
1007,
1012,
6033,
1012,
5310,
1006,
7047,
1012,
8909,
1007,
1012,
2059,
1006,
1006,
1007,
1027,
1028,
1063,
7047,
1012,
3570,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/localization.js | checkAccessKeysResults | function checkAccessKeysResults(controller, accessKeysSet) {
// Sort the access keys to have them in a A->Z order
var accessKeysList = accessKeysSet.sort();
// List of access keys
var aKeysList = [];
// List of values to identify the access keys
var valueList = [];
// List of rectangles of nodes containing access keys
var rects = [];
// List of rectangles of nodes with broken access keys
var badRects = [];
// Makes lists of all access keys and the values the access keys are in
for (var i = 0; i < accessKeysList.length; i++) {
var accessKey = accessKeysList[i][0];
var node = accessKeysList[i][1];
// Set the id and label to be shown in the console
var id = node.id || "(id is undefined)";
var label = node.label || "(label is undefined)";
var box = node.boxObject;
var innerIds = [];
var innerRects = [];
// if the access key is already in our list, take it out to replace it
// later
if (accessKey == aKeysList[aKeysList.length-1]) {
innerIds = valueList.pop();
innerRects = rects.pop();
} else {
aKeysList.push([accessKey]);
}
innerIds.push("[id: " + id + ", label: " + label + "]");
valueList.push(innerIds);
innerRects.push([box.x, box.y, box.width, box.height]);
rects.push(innerRects);
}
// Go through all access keys and find the duplicated ones
for (var i = 0; i < valueList.length; i++) {
// Only access keys contained in more than one node are the ones we are
// looking for
if (valueList[i].length > 1) {
for (var j = 0; j < rects[i].length; j++) {
badRects.push(rects[i][j]);
}
jumlib.assert(false, 'accessKey: ' + aKeysList[i] +
' found in string\'s: ' + valueList[i].join(", "));
}
}
// If we have found broken access keys, make a screenshot
if (badRects.length > 0) {
screenshot.create(controller, badRects);
}
} | javascript | function checkAccessKeysResults(controller, accessKeysSet) {
// Sort the access keys to have them in a A->Z order
var accessKeysList = accessKeysSet.sort();
// List of access keys
var aKeysList = [];
// List of values to identify the access keys
var valueList = [];
// List of rectangles of nodes containing access keys
var rects = [];
// List of rectangles of nodes with broken access keys
var badRects = [];
// Makes lists of all access keys and the values the access keys are in
for (var i = 0; i < accessKeysList.length; i++) {
var accessKey = accessKeysList[i][0];
var node = accessKeysList[i][1];
// Set the id and label to be shown in the console
var id = node.id || "(id is undefined)";
var label = node.label || "(label is undefined)";
var box = node.boxObject;
var innerIds = [];
var innerRects = [];
// if the access key is already in our list, take it out to replace it
// later
if (accessKey == aKeysList[aKeysList.length-1]) {
innerIds = valueList.pop();
innerRects = rects.pop();
} else {
aKeysList.push([accessKey]);
}
innerIds.push("[id: " + id + ", label: " + label + "]");
valueList.push(innerIds);
innerRects.push([box.x, box.y, box.width, box.height]);
rects.push(innerRects);
}
// Go through all access keys and find the duplicated ones
for (var i = 0; i < valueList.length; i++) {
// Only access keys contained in more than one node are the ones we are
// looking for
if (valueList[i].length > 1) {
for (var j = 0; j < rects[i].length; j++) {
badRects.push(rects[i][j]);
}
jumlib.assert(false, 'accessKey: ' + aKeysList[i] +
' found in string\'s: ' + valueList[i].join(", "));
}
}
// If we have found broken access keys, make a screenshot
if (badRects.length > 0) {
screenshot.create(controller, badRects);
}
} | [
"function",
"checkAccessKeysResults",
"(",
"controller",
",",
"accessKeysSet",
")",
"{",
"// Sort the access keys to have them in a A->Z order",
"var",
"accessKeysList",
"=",
"accessKeysSet",
".",
"sort",
"(",
")",
";",
"// List of access keys",
"var",
"aKeysList",
"=",
"... | Callback function for parsing the results of testing for duplicated
access keys.
This function processes the access keys found in one access keys scope
looking for access keys that are listed more than one time.
At the end, it calls the screenshot.create to create a screenshot with the
elements containing the broken access keys highlighted.
@param {array of array of object} accessKeysSet
@param {MozmillController} controller | [
"Callback",
"function",
"for",
"parsing",
"the",
"results",
"of",
"testing",
"for",
"duplicated",
"access",
"keys",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L57-L118 | train | This function is called by the accessKeysSet function to get the results of the search | [
30522,
3853,
4638,
6305,
9623,
17140,
7274,
6072,
11314,
2015,
1006,
11486,
1010,
3229,
14839,
11393,
2102,
1007,
1063,
1013,
1013,
4066,
1996,
3229,
6309,
2000,
2031,
2068,
1999,
1037,
1037,
1011,
1028,
1062,
2344,
13075,
3229,
14839,
1454... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js | function(oList) {
if (oList._bCollapsed) {
var iWidth = oList.$("cntnt").height() - 50/*Space for Header Action Buttons - Maybe provide theme parameter in future*/;
var $txt = oList.$("head-txt");
$txt.css("width", iWidth + "px");
}
var aSubLists = oList.getSubLists();
for (var i = 0; i < aSubLists.length; i++) {
refreshCollapseHeaderTextWidth(aSubLists[i]);
}
} | javascript | function(oList) {
if (oList._bCollapsed) {
var iWidth = oList.$("cntnt").height() - 50/*Space for Header Action Buttons - Maybe provide theme parameter in future*/;
var $txt = oList.$("head-txt");
$txt.css("width", iWidth + "px");
}
var aSubLists = oList.getSubLists();
for (var i = 0; i < aSubLists.length; i++) {
refreshCollapseHeaderTextWidth(aSubLists[i]);
}
} | [
"function",
"(",
"oList",
")",
"{",
"if",
"(",
"oList",
".",
"_bCollapsed",
")",
"{",
"var",
"iWidth",
"=",
"oList",
".",
"$",
"(",
"\"cntnt\"",
")",
".",
"height",
"(",
")",
"-",
"50",
"/*Space for Header Action Buttons - Maybe provide theme parameter in future... | Refreshs the header text width of all collapsed lists | [
"Refreshs",
"the",
"header",
"text",
"width",
"of",
"all",
"collapsed",
"lists"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L1348-L1358 | train | Refreshes the header text width of the list | [
30522,
3853,
1006,
19330,
2923,
1007,
1063,
2065,
1006,
19330,
2923,
1012,
1035,
4647,
14511,
9331,
6924,
1007,
1063,
13075,
1045,
9148,
11927,
2232,
1027,
19330,
2923,
1012,
1002,
1006,
1000,
27166,
2102,
3372,
1000,
1007,
1012,
4578,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/LanguageManager.js | _validateNonEmptyString | function _validateNonEmptyString(value, description, deferred) {
var reportError = deferred ? deferred.reject : console.error;
// http://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript
if (Object.prototype.toString.call(value) !== "[object String]") {
reportError(description + " must be a string");
return false;
}
if (value === "") {
reportError(description + " must not be empty");
return false;
}
return true;
} | javascript | function _validateNonEmptyString(value, description, deferred) {
var reportError = deferred ? deferred.reject : console.error;
// http://stackoverflow.com/questions/1303646/check-whether-variable-is-number-or-string-in-javascript
if (Object.prototype.toString.call(value) !== "[object String]") {
reportError(description + " must be a string");
return false;
}
if (value === "") {
reportError(description + " must not be empty");
return false;
}
return true;
} | [
"function",
"_validateNonEmptyString",
"(",
"value",
",",
"description",
",",
"deferred",
")",
"{",
"var",
"reportError",
"=",
"deferred",
"?",
"deferred",
".",
"reject",
":",
"console",
".",
"error",
";",
"// http://stackoverflow.com/questions/1303646/check-whether-var... | Helper functions
Checks whether value is a non-empty string. Reports an error otherwise.
If no deferred is passed, console.error is called.
Otherwise the deferred is rejected with the error message.
@param {*} value The value to validate
@param {!string} description A helpful identifier for value
@param {?jQuery.Deferred} deferred A deferred to reject with the error message in case of an error
@return {boolean} True if the value is a non-empty string, false otherwise | [
"Helper",
"functions",
"Checks",
"whether",
"value",
"is",
"a",
"non",
"-",
"empty",
"string",
".",
"Reports",
"an",
"error",
"otherwise",
".",
"If",
"no",
"deferred",
"is",
"passed",
"console",
".",
"error",
"is",
"called",
".",
"Otherwise",
"the",
"defer... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L189-L202 | train | Validate a string | [
30522,
3853,
1035,
9398,
3686,
8540,
6633,
13876,
27268,
4892,
1006,
3643,
1010,
6412,
1010,
13366,
28849,
2094,
1007,
1063,
13075,
6398,
29165,
1027,
13366,
28849,
2094,
1029,
13366,
28849,
2094,
1012,
15454,
1024,
10122,
1012,
7561,
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... |
eslint/eslint | lib/rules/newline-before-return.js | canFix | function canFix(node) {
const leadingComments = sourceCode.getCommentsBefore(node);
const lastLeadingComment = leadingComments[leadingComments.length - 1];
const tokenBefore = sourceCode.getTokenBefore(node);
if (leadingComments.length === 0) {
return true;
}
/*
* if the last leading comment ends in the same line as the previous token and
* does not share a line with the `return` node, we can consider it safe to fix.
* Example:
* function a() {
* var b; //comment
* return;
* }
*/
if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &&
lastLeadingComment.loc.end.line !== node.loc.start.line) {
return true;
}
return false;
} | javascript | function canFix(node) {
const leadingComments = sourceCode.getCommentsBefore(node);
const lastLeadingComment = leadingComments[leadingComments.length - 1];
const tokenBefore = sourceCode.getTokenBefore(node);
if (leadingComments.length === 0) {
return true;
}
/*
* if the last leading comment ends in the same line as the previous token and
* does not share a line with the `return` node, we can consider it safe to fix.
* Example:
* function a() {
* var b; //comment
* return;
* }
*/
if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &&
lastLeadingComment.loc.end.line !== node.loc.start.line) {
return true;
}
return false;
} | [
"function",
"canFix",
"(",
"node",
")",
"{",
"const",
"leadingComments",
"=",
"sourceCode",
".",
"getCommentsBefore",
"(",
"node",
")",
";",
"const",
"lastLeadingComment",
"=",
"leadingComments",
"[",
"leadingComments",
".",
"length",
"-",
"1",
"]",
";",
"cons... | Checks whether it is safe to apply a fix to a given return statement.
The fix is not considered safe if the given return statement has leading comments,
as we cannot safely determine if the newline should be added before or after the comments.
For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211
@param {ASTNode} node - The return statement node to check.
@returns {boolean} `true` if it can fix the node.
@private | [
"Checks",
"whether",
"it",
"is",
"safe",
"to",
"apply",
"a",
"fix",
"to",
"a",
"given",
"return",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/newline-before-return.js#L168-L192 | train | Check if node can be fixed | [
30522,
3853,
2064,
8873,
2595,
1006,
13045,
1007,
1063,
9530,
3367,
2877,
9006,
8163,
1027,
3120,
16044,
1012,
2131,
9006,
8163,
4783,
29278,
2063,
1006,
13045,
1007,
1025,
9530,
3367,
2197,
19738,
4667,
9006,
3672,
1027,
2877,
9006,
8163,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AnnotationHelper.js | function (oContext) {
var sFunctionImport = oContext.getProperty("String"),
oResult = oContext.getModel().getODataFunctionImport(sFunctionImport, true);
if (!oResult) {
Log.warning(oContext.getPath() + ": found '" + sFunctionImport
+ "' which is not a name of a function import", undefined,
"sap.ui.model.odata.AnnotationHelper");
}
return oResult;
} | javascript | function (oContext) {
var sFunctionImport = oContext.getProperty("String"),
oResult = oContext.getModel().getODataFunctionImport(sFunctionImport, true);
if (!oResult) {
Log.warning(oContext.getPath() + ": found '" + sFunctionImport
+ "' which is not a name of a function import", undefined,
"sap.ui.model.odata.AnnotationHelper");
}
return oResult;
} | [
"function",
"(",
"oContext",
")",
"{",
"var",
"sFunctionImport",
"=",
"oContext",
".",
"getProperty",
"(",
"\"String\"",
")",
",",
"oResult",
"=",
"oContext",
".",
"getModel",
"(",
")",
".",
"getODataFunctionImport",
"(",
"sFunctionImport",
",",
"true",
")",
... | Helper function for a <code>template:with</code> instruction that goes to the
function import with the name which <code>oContext</code> points at.
Example: Assume that "dataField" refers to a DataFieldForAction within an
OData meta model;
the helper function is then called on the "Action" property of that data field
(which holds an object with the qualified name of the function import in the
<code>String</code> property) and in turn the path of that function import
is assigned to the variable "function".
<pre>
<template:with path="dataField>Action"
helper="sap.ui.model.odata.AnnotationHelper.gotoFunctionImport" var="function">
</pre>
@param {sap.ui.model.Context} oContext
a context which must point to an object with a <code>String</code> property, which
holds the qualified name of the function import;
the context's model must be an {@link sap.ui.model.odata.ODataMetaModel}
@returns {string}
the path to the function import with the given qualified name,
or <code>undefined</code> if no function import is found. In this case, a warning
is logged to the console.
@since 1.29.1
@public | [
"Helper",
"function",
"for",
"a",
"<code",
">",
"template",
":",
"with<",
"/",
"code",
">",
"instruction",
"that",
"goes",
"to",
"the",
"function",
"import",
"with",
"the",
"name",
"which",
"<code",
">",
"oContext<",
"/",
"code",
">",
"points",
"at",
"."... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js#L456-L467 | train | Returns the data function import if found | [
30522,
3853,
1006,
1051,
8663,
18209,
1007,
1063,
13075,
16420,
4609,
7542,
5714,
6442,
1027,
1051,
8663,
18209,
1012,
2131,
21572,
4842,
3723,
1006,
1000,
5164,
1000,
1007,
1010,
10848,
23722,
2102,
1027,
1051,
8663,
18209,
1012,
2131,
530... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/models/base/index.js | initialize | function initialize() {
var self = this;
// NOTE: triggered before `creating`/`updating`
this.on('saving', function onSaving(newObj, attrs, options) {
if (options.method === 'insert') {
// id = 0 is still a valid value for external usage
if (_.isUndefined(newObj.id) || _.isNull(newObj.id)) {
newObj.setId();
}
}
});
[
'fetching',
'fetching:collection',
'fetched',
'fetched:collection',
'creating',
'created',
'updating',
'updated',
'destroying',
'destroyed',
'saving',
'saved'
].forEach(function (eventName) {
var functionName = 'on' + eventName[0].toUpperCase() + eventName.slice(1);
if (functionName.indexOf(':') !== -1) {
functionName = functionName.slice(0, functionName.indexOf(':'))
+ functionName[functionName.indexOf(':') + 1].toUpperCase()
+ functionName.slice(functionName.indexOf(':') + 2);
functionName = functionName.replace(':', '');
}
if (!self[functionName]) {
return;
}
self.on(eventName, self[functionName]);
});
// @NOTE: Please keep here. If we don't initialize the parent, bookshelf-relations won't work.
proto.initialize.call(this);
} | javascript | function initialize() {
var self = this;
// NOTE: triggered before `creating`/`updating`
this.on('saving', function onSaving(newObj, attrs, options) {
if (options.method === 'insert') {
// id = 0 is still a valid value for external usage
if (_.isUndefined(newObj.id) || _.isNull(newObj.id)) {
newObj.setId();
}
}
});
[
'fetching',
'fetching:collection',
'fetched',
'fetched:collection',
'creating',
'created',
'updating',
'updated',
'destroying',
'destroyed',
'saving',
'saved'
].forEach(function (eventName) {
var functionName = 'on' + eventName[0].toUpperCase() + eventName.slice(1);
if (functionName.indexOf(':') !== -1) {
functionName = functionName.slice(0, functionName.indexOf(':'))
+ functionName[functionName.indexOf(':') + 1].toUpperCase()
+ functionName.slice(functionName.indexOf(':') + 2);
functionName = functionName.replace(':', '');
}
if (!self[functionName]) {
return;
}
self.on(eventName, self[functionName]);
});
// @NOTE: Please keep here. If we don't initialize the parent, bookshelf-relations won't work.
proto.initialize.call(this);
} | [
"function",
"initialize",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// NOTE: triggered before `creating`/`updating`",
"this",
".",
"on",
"(",
"'saving'",
",",
"function",
"onSaving",
"(",
"newObj",
",",
"attrs",
",",
"options",
")",
"{",
"if",
"(",
"o... | Bookshelf `initialize` - declare a constructor-like method for model creation | [
"Bookshelf",
"initialize",
"-",
"declare",
"a",
"constructor",
"-",
"like",
"method",
"for",
"model",
"creation"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L223-L268 | train | Initialize the bookshelf - relations | [
30522,
3853,
3988,
4697,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
3602,
1024,
13330,
2077,
1036,
4526,
1036,
1013,
1036,
2039,
16616,
1036,
2023,
1012,
2006,
1006,
1005,
7494,
1005,
1010,
3853,
2006,
3736,
6455,
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... |
catapult-project/catapult | tracing/third_party/oboe/src/instanceApi.js | instanceApi | function instanceApi(oboeBus, contentSource){
var oboeApi,
fullyQualifiedNamePattern = /^(node|path):./,
rootNodeFinishedEvent = oboeBus(ROOT_NODE_FOUND),
emitNodeDrop = oboeBus(NODE_DROP).emit,
emitNodeSwap = oboeBus(NODE_SWAP).emit,
/**
* Add any kind of listener that the instance api exposes
*/
addListener = varArgs(function( eventId, parameters ){
if( oboeApi[eventId] ) {
// for events added as .on(event, callback), if there is a
// .event() equivalent with special behaviour , pass through
// to that:
apply(parameters, oboeApi[eventId]);
} else {
// we have a standard Node.js EventEmitter 2-argument call.
// The first parameter is the listener.
var event = oboeBus(eventId),
listener = parameters[0];
if( fullyQualifiedNamePattern.test(eventId) ) {
// allow fully-qualified node/path listeners
// to be added
addForgettableCallback(event, listener);
} else {
// the event has no special handling, pass through
// directly onto the event bus:
event.on( listener);
}
}
return oboeApi; // chaining
}),
/**
* Remove any kind of listener that the instance api exposes
*/
removeListener = function( eventId, p2, p3 ){
if( eventId == 'done' ) {
rootNodeFinishedEvent.un(p2);
} else if( eventId == 'node' || eventId == 'path' ) {
// allow removal of node and path
oboeBus.un(eventId + ':' + p2, p3);
} else {
// we have a standard Node.js EventEmitter 2-argument call.
// The second parameter is the listener. This may be a call
// to remove a fully-qualified node/path listener but requires
// no special handling
var listener = p2;
oboeBus(eventId).un(listener);
}
return oboeApi; // chaining
};
/**
* Add a callback, wrapped in a try/catch so as to not break the
* execution of Oboe if an exception is thrown (fail events are
* fired instead)
*
* The callback is used as the listener id so that it can later be
* removed using .un(callback)
*/
function addProtectedCallback(eventName, callback) {
oboeBus(eventName).on(protectedCallback(callback), callback);
return oboeApi; // chaining
}
/**
* Add a callback where, if .forget() is called during the callback's
* execution, the callback will be de-registered
*/
function addForgettableCallback(event, callback, listenerId) {
// listenerId is optional and if not given, the original
// callback will be used
listenerId = listenerId || callback;
var safeCallback = protectedCallback(callback);
event.on( function() {
var discard = false;
oboeApi.forget = function(){
discard = true;
};
apply( arguments, safeCallback );
delete oboeApi.forget;
if( discard ) {
event.un(listenerId);
}
}, listenerId);
return oboeApi; // chaining
}
/**
* wrap a callback so that if it throws, Oboe.js doesn't crash but instead
* throw the error in another event loop
*/
function protectedCallback( callback ) {
return function() {
try{
return callback.apply(oboeApi, arguments);
}catch(e) {
setTimeout(function() {
throw new Error(e.message);
});
}
}
}
/**
* Return the fully qualified event for when a pattern matches
* either a node or a path
*
* @param type {String} either 'node' or 'path'
*/
function fullyQualifiedPatternMatchEvent(type, pattern) {
return oboeBus(type + ':' + pattern);
}
function wrapCallbackToSwapNodeIfSomethingReturned( callback ) {
return function() {
var returnValueFromCallback = callback.apply(this, arguments);
if( defined(returnValueFromCallback) ) {
if( returnValueFromCallback == oboe.drop ) {
emitNodeDrop();
} else {
emitNodeSwap(returnValueFromCallback);
}
}
}
}
function addSingleNodeOrPathListener(eventId, pattern, callback) {
var effectiveCallback;
if( eventId == 'node' ) {
effectiveCallback = wrapCallbackToSwapNodeIfSomethingReturned(callback);
} else {
effectiveCallback = callback;
}
addForgettableCallback(
fullyQualifiedPatternMatchEvent(eventId, pattern),
effectiveCallback,
callback
);
}
/**
* Add several listeners at a time, from a map
*/
function addMultipleNodeOrPathListeners(eventId, listenerMap) {
for( var pattern in listenerMap ) {
addSingleNodeOrPathListener(eventId, pattern, listenerMap[pattern]);
}
}
/**
* implementation behind .onPath() and .onNode()
*/
function addNodeOrPathListenerApi( eventId, jsonPathOrListenerMap, callback ){
if( isString(jsonPathOrListenerMap) ) {
addSingleNodeOrPathListener(eventId, jsonPathOrListenerMap, callback);
} else {
addMultipleNodeOrPathListeners(eventId, jsonPathOrListenerMap);
}
return oboeApi; // chaining
}
// some interface methods are only filled in after we receive
// values and are noops before that:
oboeBus(ROOT_PATH_FOUND).on( function(rootNode) {
oboeApi.root = functor(rootNode);
});
/**
* When content starts make the headers readable through the
* instance API
*/
oboeBus(HTTP_START).on( function(_statusCode, headers) {
oboeApi.header = function(name) {
return name ? headers[name]
: headers
;
}
});
/**
* Construct and return the public API of the Oboe instance to be
* returned to the calling application
*/
return oboeApi = {
on : addListener,
addListener : addListener,
removeListener : removeListener,
emit : oboeBus.emit,
node : partialComplete(addNodeOrPathListenerApi, 'node'),
path : partialComplete(addNodeOrPathListenerApi, 'path'),
done : partialComplete(addForgettableCallback, rootNodeFinishedEvent),
start : partialComplete(addProtectedCallback, HTTP_START ),
// fail doesn't use protectedCallback because
// could lead to non-terminating loops
fail : oboeBus(FAIL_EVENT).on,
// public api calling abort fires the ABORTING event
abort : oboeBus(ABORTING).emit,
// initially return nothing for header and root
header : noop,
root : noop,
source : contentSource
};
} | javascript | function instanceApi(oboeBus, contentSource){
var oboeApi,
fullyQualifiedNamePattern = /^(node|path):./,
rootNodeFinishedEvent = oboeBus(ROOT_NODE_FOUND),
emitNodeDrop = oboeBus(NODE_DROP).emit,
emitNodeSwap = oboeBus(NODE_SWAP).emit,
/**
* Add any kind of listener that the instance api exposes
*/
addListener = varArgs(function( eventId, parameters ){
if( oboeApi[eventId] ) {
// for events added as .on(event, callback), if there is a
// .event() equivalent with special behaviour , pass through
// to that:
apply(parameters, oboeApi[eventId]);
} else {
// we have a standard Node.js EventEmitter 2-argument call.
// The first parameter is the listener.
var event = oboeBus(eventId),
listener = parameters[0];
if( fullyQualifiedNamePattern.test(eventId) ) {
// allow fully-qualified node/path listeners
// to be added
addForgettableCallback(event, listener);
} else {
// the event has no special handling, pass through
// directly onto the event bus:
event.on( listener);
}
}
return oboeApi; // chaining
}),
/**
* Remove any kind of listener that the instance api exposes
*/
removeListener = function( eventId, p2, p3 ){
if( eventId == 'done' ) {
rootNodeFinishedEvent.un(p2);
} else if( eventId == 'node' || eventId == 'path' ) {
// allow removal of node and path
oboeBus.un(eventId + ':' + p2, p3);
} else {
// we have a standard Node.js EventEmitter 2-argument call.
// The second parameter is the listener. This may be a call
// to remove a fully-qualified node/path listener but requires
// no special handling
var listener = p2;
oboeBus(eventId).un(listener);
}
return oboeApi; // chaining
};
/**
* Add a callback, wrapped in a try/catch so as to not break the
* execution of Oboe if an exception is thrown (fail events are
* fired instead)
*
* The callback is used as the listener id so that it can later be
* removed using .un(callback)
*/
function addProtectedCallback(eventName, callback) {
oboeBus(eventName).on(protectedCallback(callback), callback);
return oboeApi; // chaining
}
/**
* Add a callback where, if .forget() is called during the callback's
* execution, the callback will be de-registered
*/
function addForgettableCallback(event, callback, listenerId) {
// listenerId is optional and if not given, the original
// callback will be used
listenerId = listenerId || callback;
var safeCallback = protectedCallback(callback);
event.on( function() {
var discard = false;
oboeApi.forget = function(){
discard = true;
};
apply( arguments, safeCallback );
delete oboeApi.forget;
if( discard ) {
event.un(listenerId);
}
}, listenerId);
return oboeApi; // chaining
}
/**
* wrap a callback so that if it throws, Oboe.js doesn't crash but instead
* throw the error in another event loop
*/
function protectedCallback( callback ) {
return function() {
try{
return callback.apply(oboeApi, arguments);
}catch(e) {
setTimeout(function() {
throw new Error(e.message);
});
}
}
}
/**
* Return the fully qualified event for when a pattern matches
* either a node or a path
*
* @param type {String} either 'node' or 'path'
*/
function fullyQualifiedPatternMatchEvent(type, pattern) {
return oboeBus(type + ':' + pattern);
}
function wrapCallbackToSwapNodeIfSomethingReturned( callback ) {
return function() {
var returnValueFromCallback = callback.apply(this, arguments);
if( defined(returnValueFromCallback) ) {
if( returnValueFromCallback == oboe.drop ) {
emitNodeDrop();
} else {
emitNodeSwap(returnValueFromCallback);
}
}
}
}
function addSingleNodeOrPathListener(eventId, pattern, callback) {
var effectiveCallback;
if( eventId == 'node' ) {
effectiveCallback = wrapCallbackToSwapNodeIfSomethingReturned(callback);
} else {
effectiveCallback = callback;
}
addForgettableCallback(
fullyQualifiedPatternMatchEvent(eventId, pattern),
effectiveCallback,
callback
);
}
/**
* Add several listeners at a time, from a map
*/
function addMultipleNodeOrPathListeners(eventId, listenerMap) {
for( var pattern in listenerMap ) {
addSingleNodeOrPathListener(eventId, pattern, listenerMap[pattern]);
}
}
/**
* implementation behind .onPath() and .onNode()
*/
function addNodeOrPathListenerApi( eventId, jsonPathOrListenerMap, callback ){
if( isString(jsonPathOrListenerMap) ) {
addSingleNodeOrPathListener(eventId, jsonPathOrListenerMap, callback);
} else {
addMultipleNodeOrPathListeners(eventId, jsonPathOrListenerMap);
}
return oboeApi; // chaining
}
// some interface methods are only filled in after we receive
// values and are noops before that:
oboeBus(ROOT_PATH_FOUND).on( function(rootNode) {
oboeApi.root = functor(rootNode);
});
/**
* When content starts make the headers readable through the
* instance API
*/
oboeBus(HTTP_START).on( function(_statusCode, headers) {
oboeApi.header = function(name) {
return name ? headers[name]
: headers
;
}
});
/**
* Construct and return the public API of the Oboe instance to be
* returned to the calling application
*/
return oboeApi = {
on : addListener,
addListener : addListener,
removeListener : removeListener,
emit : oboeBus.emit,
node : partialComplete(addNodeOrPathListenerApi, 'node'),
path : partialComplete(addNodeOrPathListenerApi, 'path'),
done : partialComplete(addForgettableCallback, rootNodeFinishedEvent),
start : partialComplete(addProtectedCallback, HTTP_START ),
// fail doesn't use protectedCallback because
// could lead to non-terminating loops
fail : oboeBus(FAIL_EVENT).on,
// public api calling abort fires the ABORTING event
abort : oboeBus(ABORTING).emit,
// initially return nothing for header and root
header : noop,
root : noop,
source : contentSource
};
} | [
"function",
"instanceApi",
"(",
"oboeBus",
",",
"contentSource",
")",
"{",
"var",
"oboeApi",
",",
"fullyQualifiedNamePattern",
"=",
"/",
"^(node|path):.",
"/",
",",
"rootNodeFinishedEvent",
"=",
"oboeBus",
"(",
"ROOT_NODE_FOUND",
")",
",",
"emitNodeDrop",
"=",
"ob... | The instance API is the thing that is returned when oboe() is called.
it allows:
- listeners for various events to be added and removed
- the http response header/headers to be read | [
"The",
"instance",
"API",
"is",
"the",
"thing",
"that",
"is",
"returned",
"when",
"oboe",
"()",
"is",
"called",
".",
"it",
"allows",
":"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/instanceApi.js#L8-L254 | train | The instance api is the base implementation of the instance api. | [
30522,
3853,
6013,
9331,
2072,
1006,
22523,
8286,
1010,
8417,
8162,
3401,
1007,
1063,
13075,
22523,
9331,
2072,
1010,
3929,
26426,
7810,
18442,
4502,
12079,
2078,
1027,
1013,
1034,
1006,
13045,
1064,
4130,
1007,
1024,
1012,
1013,
1010,
7117... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
archriss/react-native-snap-carousel | example/src/utils/animations.js | scrollInterpolator3 | function scrollInterpolator3 (index, carouselProps) {
const range = [2, 1, 0, -1];
const inputRange = getInputRangeFromIndexes(range, index, carouselProps);
const outputRange = range;
return { inputRange, outputRange };
} | javascript | function scrollInterpolator3 (index, carouselProps) {
const range = [2, 1, 0, -1];
const inputRange = getInputRangeFromIndexes(range, index, carouselProps);
const outputRange = range;
return { inputRange, outputRange };
} | [
"function",
"scrollInterpolator3",
"(",
"index",
",",
"carouselProps",
")",
"{",
"const",
"range",
"=",
"[",
"2",
",",
"1",
",",
"0",
",",
"-",
"1",
"]",
";",
"const",
"inputRange",
"=",
"getInputRangeFromIndexes",
"(",
"range",
",",
"index",
",",
"carou... | Left/right translate effect | [
"Left",
"/",
"right",
"translate",
"effect"
] | 85980e5177a75d393a1b38480800753282148c50 | https://github.com/archriss/react-native-snap-carousel/blob/85980e5177a75d393a1b38480800753282148c50/example/src/utils/animations.js#L89-L95 | train | scrollInterpolator3 - returns an object with input range and output range | [
30522,
3853,
17186,
18447,
2121,
18155,
8844,
2509,
1006,
5950,
1010,
27628,
21572,
4523,
1007,
1063,
9530,
3367,
2846,
1027,
1031,
1016,
1010,
1015,
1010,
1014,
1010,
1011,
1015,
1033,
1025,
9530,
3367,
7953,
24388,
2063,
1027,
2131,
2378,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | src/components/common/item-selector/item-selector.js | _toArray | function _toArray(item) {
if (Array.isArray(item)) {
return item;
}
if (typeof item === 'undefined' || item === null) {
return [];
}
return [item];
} | javascript | function _toArray(item) {
if (Array.isArray(item)) {
return item;
}
if (typeof item === 'undefined' || item === null) {
return [];
}
return [item];
} | [
"function",
"_toArray",
"(",
"item",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"if",
"(",
"typeof",
"item",
"===",
"'undefined'",
"||",
"item",
"===",
"null",
")",
"{",
"return",
"[",
"]",... | Converts non-arrays to arrays. Leaves arrays alone. Converts
undefined values to empty arrays ([] instead of [undefined]).
Otherwise, just returns [item] for non-array items.
@param {*} item
@returns {array} boom! much array. very indexed. so useful. | [
"Converts",
"non",
"-",
"arrays",
"to",
"arrays",
".",
"Leaves",
"arrays",
"alone",
".",
"Converts",
"undefined",
"values",
"to",
"empty",
"arrays",
"(",
"[]",
"instead",
"of",
"[",
"undefined",
"]",
")",
".",
"Otherwise",
"just",
"returns",
"[",
"item",
... | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/components/common/item-selector/item-selector.js#L42-L52 | train | Convert an item to an array | [
30522,
3853,
1035,
2000,
2906,
9447,
1006,
8875,
1007,
1063,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
8875,
1007,
1007,
1063,
2709,
8875,
1025,
1065,
2065,
1006,
2828,
11253,
8875,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-loop-func.js | isSafeReference | function isSafeReference(upperRef) {
const id = upperRef.identifier;
return (
!upperRef.isWrite() ||
variable.scope.variableScope === upperRef.from.variableScope &&
id.range[0] < border
);
} | javascript | function isSafeReference(upperRef) {
const id = upperRef.identifier;
return (
!upperRef.isWrite() ||
variable.scope.variableScope === upperRef.from.variableScope &&
id.range[0] < border
);
} | [
"function",
"isSafeReference",
"(",
"upperRef",
")",
"{",
"const",
"id",
"=",
"upperRef",
".",
"identifier",
";",
"return",
"(",
"!",
"upperRef",
".",
"isWrite",
"(",
")",
"||",
"variable",
".",
"scope",
".",
"variableScope",
"===",
"upperRef",
".",
"from"... | Checks whether a given reference is safe or not.
The reference is every reference of the upper scope's variable we are
looking now.
It's safeafe if the reference matches one of the following condition.
- is readonly.
- doesn't exist inside a local function and after the border.
@param {eslint-scope.Reference} upperRef - A reference to check.
@returns {boolean} `true` if the reference is safe. | [
"Checks",
"whether",
"a",
"given",
"reference",
"is",
"safe",
"or",
"not",
".",
"The",
"reference",
"is",
"every",
"reference",
"of",
"the",
"upper",
"scope",
"s",
"variable",
"we",
"are",
"looking",
"now",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-loop-func.js#L138-L146 | train | Check if the reference is safe | [
30522,
3853,
26354,
10354,
7869,
25523,
1006,
3356,
2890,
2546,
1007,
1063,
9530,
3367,
8909,
1027,
3356,
2890,
2546,
1012,
8909,
4765,
18095,
1025,
2709,
1006,
999,
3356,
2890,
2546,
1012,
2003,
26373,
1006,
1007,
1064,
1064,
8023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | openNewFile | function openNewFile() {
var fileOpenPromise;
if (FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER) {
// If selection is in the tree, leave workingset unchanged - even if orig file is in the list
fileOpenPromise = FileViewController
.openAndSelectDocument(path, FileViewController.PROJECT_MANAGER);
} else {
// If selection is in workingset, replace orig item in place with the new file
var info = MainViewManager.findInAllWorkingSets(doc.file.fullPath).shift();
// Remove old file from workingset; no redraw yet since there's a pause before the new file is opened
MainViewManager._removeView(info.paneId, doc.file, true);
// Add new file to workingset, and ensure we now redraw (even if index hasn't changed)
fileOpenPromise = handleFileAddToWorkingSetAndOpen({fullPath: path, paneId: info.paneId, index: info.index, forceRedraw: true});
}
// always configure editor after file is opened
fileOpenPromise.always(function () {
_configureEditorAndResolve();
});
} | javascript | function openNewFile() {
var fileOpenPromise;
if (FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER) {
// If selection is in the tree, leave workingset unchanged - even if orig file is in the list
fileOpenPromise = FileViewController
.openAndSelectDocument(path, FileViewController.PROJECT_MANAGER);
} else {
// If selection is in workingset, replace orig item in place with the new file
var info = MainViewManager.findInAllWorkingSets(doc.file.fullPath).shift();
// Remove old file from workingset; no redraw yet since there's a pause before the new file is opened
MainViewManager._removeView(info.paneId, doc.file, true);
// Add new file to workingset, and ensure we now redraw (even if index hasn't changed)
fileOpenPromise = handleFileAddToWorkingSetAndOpen({fullPath: path, paneId: info.paneId, index: info.index, forceRedraw: true});
}
// always configure editor after file is opened
fileOpenPromise.always(function () {
_configureEditorAndResolve();
});
} | [
"function",
"openNewFile",
"(",
")",
"{",
"var",
"fileOpenPromise",
";",
"if",
"(",
"FileViewController",
".",
"getFileSelectionFocus",
"(",
")",
"===",
"FileViewController",
".",
"PROJECT_MANAGER",
")",
"{",
"// If selection is in the tree, leave workingset unchanged - eve... | Replace old document with new one in open editor & workingset | [
"Replace",
"old",
"document",
"with",
"new",
"one",
"in",
"open",
"editor",
"&",
"workingset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L914-L936 | train | Open a new file | [
30522,
3853,
2330,
2638,
2860,
8873,
2571,
1006,
1007,
1063,
13075,
5371,
26915,
21572,
28732,
1025,
2065,
1006,
5371,
8584,
8663,
13181,
10820,
1012,
2131,
8873,
24527,
2571,
7542,
14876,
7874,
1006,
1007,
1027,
1027,
1027,
5371,
8584,
866... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/HintUtils.js | maybeIdentifier | function maybeIdentifier(key) {
var result = false,
i;
for (i = 0; i < key.length; i++) {
result = Acorn.isIdentifierChar(key.charCodeAt(i));
if (!result) {
break;
}
}
return result;
} | javascript | function maybeIdentifier(key) {
var result = false,
i;
for (i = 0; i < key.length; i++) {
result = Acorn.isIdentifierChar(key.charCodeAt(i));
if (!result) {
break;
}
}
return result;
} | [
"function",
"maybeIdentifier",
"(",
"key",
")",
"{",
"var",
"result",
"=",
"false",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"key",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"=",
"Acorn",
".",
"isIdentifierChar",
"(",
"ke... | Is the string key perhaps a valid JavaScript identifier?
@param {string} key - string to test.
@return {boolean} - could key be a valid identifier? | [
"Is",
"the",
"string",
"key",
"perhaps",
"a",
"valid",
"JavaScript",
"identifier?"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/HintUtils.js#L63-L75 | train | Check if a string is an identifier | [
30522,
3853,
2672,
5178,
16778,
8873,
2121,
1006,
3145,
1007,
1063,
13075,
2765,
1027,
6270,
1010,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
3145,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2765,
1027,
9353,
9691,
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.table/src/sap/ui/table/rules/TableHelper.support.js | function(oRuleDef, oRuleset) {
oRuleDef = TableSupportHelper.normalizeRule(oRuleDef);
var sResult = oRuleset.addRule(oRuleDef);
if (sResult != "success") {
Log.warning("Support Rule '" + oRuleDef.id + "' for library sap.ui.table not applied: " + sResult);
}
} | javascript | function(oRuleDef, oRuleset) {
oRuleDef = TableSupportHelper.normalizeRule(oRuleDef);
var sResult = oRuleset.addRule(oRuleDef);
if (sResult != "success") {
Log.warning("Support Rule '" + oRuleDef.id + "' for library sap.ui.table not applied: " + sResult);
}
} | [
"function",
"(",
"oRuleDef",
",",
"oRuleset",
")",
"{",
"oRuleDef",
"=",
"TableSupportHelper",
".",
"normalizeRule",
"(",
"oRuleDef",
")",
";",
"var",
"sResult",
"=",
"oRuleset",
".",
"addRule",
"(",
"oRuleDef",
")",
";",
"if",
"(",
"sResult",
"!=",
"\"suc... | Normalizes the given rule definition and adds it to the given Ruleset.
@see #normalizeRule
@param {object} oRuleDef The rule definition
@param {sap.ui.support.supportRules.RuleSet} oRuleset The ruleset | [
"Normalizes",
"the",
"given",
"rule",
"definition",
"and",
"adds",
"it",
"to",
"the",
"given",
"Ruleset",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/rules/TableHelper.support.js#L65-L71 | train | Adds a rule to the given RuleSet | [
30522,
3853,
1006,
2030,
18696,
12879,
1010,
2030,
16308,
3388,
1007,
1063,
2030,
18696,
12879,
1027,
7251,
6279,
6442,
16001,
4842,
1012,
3671,
17629,
9307,
1006,
2030,
18696,
12879,
1007,
1025,
13075,
5034,
2229,
11314,
1027,
2030,
16308,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | drawImage | function drawImage(editor) {
var cm = editor.codemirror;
var stat = getState(cm);
var options = editor.options;
var url = "http://";
if(options.promptURLs) {
url = prompt(options.promptTexts.image);
if(!url) {
return false;
}
}
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
} | javascript | function drawImage(editor) {
var cm = editor.codemirror;
var stat = getState(cm);
var options = editor.options;
var url = "http://";
if(options.promptURLs) {
url = prompt(options.promptTexts.image);
if(!url) {
return false;
}
}
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
} | [
"function",
"drawImage",
"(",
"editor",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"codemirror",
";",
"var",
"stat",
"=",
"getState",
"(",
"cm",
")",
";",
"var",
"options",
"=",
"editor",
".",
"options",
";",
"var",
"url",
"=",
"\"http://\"",
";",
"i... | Action for drawing an img. | [
"Action",
"for",
"drawing",
"an",
"img",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L633-L645 | train | Draw an image | [
30522,
3853,
4009,
9581,
3351,
1006,
3559,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
3642,
14503,
29165,
1025,
13075,
28093,
1027,
4152,
12259,
1006,
4642,
1007,
1025,
13075,
7047,
1027,
3559,
1012,
7047,
1025,
13075,
24471,
2140,
1027,
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... |
benweet/stackedit | src/libs/pagedown.js | Pagedown | function Pagedown(options) {
options = options || {};
if (typeof options.handler === "function") { //backwards compatible behavior
options = {
helpButton: options
};
}
options.strings = options.strings || {};
var getString = function (identifier) {
return options.strings[identifier] || defaultsStrings[identifier];
};
function identity(x) {
return x;
}
function returnFalse() {
return false;
}
function HookCollection() { }
HookCollection.prototype = {
chain: function (hookname, func) {
var original = this[hookname];
if (!original) {
throw new Error("unknown hook " + hookname);
}
if (original === identity) {
this[hookname] = func;
} else {
this[hookname] = function () {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = original.apply(null, args);
return func.apply(null, args);
};
}
},
set: function (hookname, func) {
if (!this[hookname]) {
throw new Error("unknown hook " + hookname);
}
this[hookname] = func;
},
addNoop: function (hookname) {
this[hookname] = identity;
},
addFalse: function (hookname) {
this[hookname] = returnFalse;
}
};
var hooks = this.hooks = new HookCollection();
hooks.addNoop("onPreviewRefresh"); // called with no arguments after the preview has been refreshed
hooks.addNoop("postBlockquoteCreation"); // called with the user's selection *after* the blockquote was created; should return the actual to-be-inserted text
hooks.addFalse("insertImageDialog");
/* called with one parameter: a callback to be called with the URL of the image. If the application creates
* its own image insertion dialog, this hook should return true, and the callback should be called with the chosen
* image url (or null if the user cancelled). If this hook returns false, the default dialog will be used.
*/
hooks.addFalse("insertLinkDialog");
var that = this,
input;
this.run = function () {
if (input)
return; // already initialized
input = options.input;
var commandManager = new CommandManager(hooks, getString);
var uiManager;
uiManager = new UIManager(input, commandManager);
that.uiManager = uiManager;
};
} | javascript | function Pagedown(options) {
options = options || {};
if (typeof options.handler === "function") { //backwards compatible behavior
options = {
helpButton: options
};
}
options.strings = options.strings || {};
var getString = function (identifier) {
return options.strings[identifier] || defaultsStrings[identifier];
};
function identity(x) {
return x;
}
function returnFalse() {
return false;
}
function HookCollection() { }
HookCollection.prototype = {
chain: function (hookname, func) {
var original = this[hookname];
if (!original) {
throw new Error("unknown hook " + hookname);
}
if (original === identity) {
this[hookname] = func;
} else {
this[hookname] = function () {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = original.apply(null, args);
return func.apply(null, args);
};
}
},
set: function (hookname, func) {
if (!this[hookname]) {
throw new Error("unknown hook " + hookname);
}
this[hookname] = func;
},
addNoop: function (hookname) {
this[hookname] = identity;
},
addFalse: function (hookname) {
this[hookname] = returnFalse;
}
};
var hooks = this.hooks = new HookCollection();
hooks.addNoop("onPreviewRefresh"); // called with no arguments after the preview has been refreshed
hooks.addNoop("postBlockquoteCreation"); // called with the user's selection *after* the blockquote was created; should return the actual to-be-inserted text
hooks.addFalse("insertImageDialog");
/* called with one parameter: a callback to be called with the URL of the image. If the application creates
* its own image insertion dialog, this hook should return true, and the callback should be called with the chosen
* image url (or null if the user cancelled). If this hook returns false, the default dialog will be used.
*/
hooks.addFalse("insertLinkDialog");
var that = this,
input;
this.run = function () {
if (input)
return; // already initialized
input = options.input;
var commandManager = new CommandManager(hooks, getString);
var uiManager;
uiManager = new UIManager(input, commandManager);
that.uiManager = uiManager;
};
} | [
"function",
"Pagedown",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
".",
"handler",
"===",
"\"function\"",
")",
"{",
"//backwards compatible behavior",
"options",
"=",
"{",
"helpButton",
":",
"opt... | options, if given, can have the following properties: options.helpButton = { handler: yourEventHandler } options.strings = { italicexample: "slanted text" } `yourEventHandler` is the click handler for the help button. If `options.helpButton` isn't given, not help button is created. `options.strings` can have any or all of the same properties as `defaultStrings` above, so you can just override some string displayed to the user on a case-by-case basis, or translate all strings to a different language. For backwards compatibility reasons, the `options` argument can also be just the `helpButton` object, and `strings.help` can also be set via `helpButton.title`. This should be considered legacy. The constructed editor object has the methods: - getConverter() returns the markdown converter object that was passed to the constructor - run() actually starts the editor; should be called after all necessary plugins are registered. Calling this more than once is a no-op. - refreshPreview() forces the preview to be updated. This method is only available after run() was called. | [
"options",
"if",
"given",
"can",
"have",
"the",
"following",
"properties",
":",
"options",
".",
"helpButton",
"=",
"{",
"handler",
":",
"yourEventHandler",
"}",
"options",
".",
"strings",
"=",
"{",
"italicexample",
":",
"slanted",
"text",
"}",
"yourEventHandle... | 91f8cf3c10b75df65b69f9181cee8151d65a788d | https://github.com/benweet/stackedit/blob/91f8cf3c10b75df65b69f9181cee8151d65a788d/src/libs/pagedown.js#L64-L145 | train | Pagedown is a wrapper around the page - related functionality. | [
30522,
3853,
3931,
7698,
1006,
7047,
1007,
1063,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
2828,
11253,
7047,
1012,
28213,
1027,
1027,
1027,
1000,
3853,
1000,
1007,
1063,
1013,
1013,
11043,
11892,
5248,
7047,
1027,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | getWorkingSetSize | function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
} | javascript | function getWorkingSetSize(paneId) {
var result = 0;
_forEachPaneOrPanes(paneId, function (pane) {
result += pane.getViewListSize();
});
return result;
} | [
"function",
"getWorkingSetSize",
"(",
"paneId",
")",
"{",
"var",
"result",
"=",
"0",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"result",
"+=",
"pane",
".",
"getViewListSize",
"(",
")",
";",
"}",
")",
";",
"return"... | Retrieves the size of the selected pane's view list
@param {!string} paneId - id of the pane in which to get the workingset size.
Can use `ALL_PANES` or `ACTIVE_PANE`
@return {!number} the number of items in the specified pane | [
"Retrieves",
"the",
"size",
"of",
"the",
"selected",
"pane",
"s",
"view",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L571-L577 | train | Get the size of the working set | [
30522,
3853,
2131,
21398,
13462,
5332,
4371,
1006,
6090,
7416,
2094,
1007,
1063,
13075,
2765,
1027,
1014,
1025,
1035,
18921,
6776,
9739,
8780,
14536,
7231,
2015,
1006,
6090,
7416,
2094,
1010,
3853,
1006,
6090,
2063,
1007,
1063,
2765,
1009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(target) {
if (!target) {
return false;
}
for (var i = 0; i < this._disabledInputs.length; i++) {
if (this._disabledInputs[i] === target) {
return true;
}
}
return false;
} | javascript | function(target) {
if (!target) {
return false;
}
for (var i = 0; i < this._disabledInputs.length; i++) {
if (this._disabledInputs[i] === target) {
return true;
}
}
return false;
} | [
"function",
"(",
"target",
")",
"{",
"if",
"(",
"!",
"target",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_disabledInputs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
... | /* Is the first field in a jQuery collection disabled as a datepicker?
@param target element - the target input field or division or span
@return boolean - true if disabled, false if enabled | [
"/",
"*",
"Is",
"the",
"first",
"field",
"in",
"a",
"jQuery",
"collection",
"disabled",
"as",
"a",
"datepicker?"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8037-L8047 | train | Returns true if the target is not a disabled input | [
30522,
3853,
1006,
4539,
1007,
1063,
2065,
1006,
999,
4539,
1007,
1063,
2709,
6270,
1025,
1065,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2023,
1012,
1035,
9776,
2378,
18780,
2015,
1012,
3091,
1025,
1045,
1009,
1009,
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... | |
adobe/brackets | src/view/ViewCommandHandlers.js | setFontSize | function setFontSize(fontSize) {
if (currFontSize === fontSize) {
return;
}
_removeDynamicFontSize();
if (fontSize) {
_addDynamicFontSize(fontSize);
}
// Update scroll metrics in viewed editors
_.forEach(MainViewManager.getPaneIdList(), function (paneId) {
var currentPath = MainViewManager.getCurrentlyViewedPath(paneId),
doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath);
if (doc && doc._masterEditor) {
_updateScroll(doc._masterEditor, fontSize);
}
});
exports.trigger("fontSizeChange", fontSize, currFontSize);
currFontSize = fontSize;
prefs.set("fontSize", fontSize);
} | javascript | function setFontSize(fontSize) {
if (currFontSize === fontSize) {
return;
}
_removeDynamicFontSize();
if (fontSize) {
_addDynamicFontSize(fontSize);
}
// Update scroll metrics in viewed editors
_.forEach(MainViewManager.getPaneIdList(), function (paneId) {
var currentPath = MainViewManager.getCurrentlyViewedPath(paneId),
doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath);
if (doc && doc._masterEditor) {
_updateScroll(doc._masterEditor, fontSize);
}
});
exports.trigger("fontSizeChange", fontSize, currFontSize);
currFontSize = fontSize;
prefs.set("fontSize", fontSize);
} | [
"function",
"setFontSize",
"(",
"fontSize",
")",
"{",
"if",
"(",
"currFontSize",
"===",
"fontSize",
")",
"{",
"return",
";",
"}",
"_removeDynamicFontSize",
"(",
")",
";",
"if",
"(",
"fontSize",
")",
"{",
"_addDynamicFontSize",
"(",
"fontSize",
")",
";",
"}... | Font size setter to set the font size for the document editor
@param {string} fontSize The font size with size unit as 'px' or 'em' | [
"Font",
"size",
"setter",
"to",
"set",
"the",
"font",
"size",
"for",
"the",
"document",
"editor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/ViewCommandHandlers.js#L236-L258 | train | set fontSize to the current fontSize | [
30522,
3853,
2275,
14876,
7666,
4697,
1006,
15489,
5332,
4371,
1007,
1063,
2065,
1006,
12731,
12171,
14876,
7666,
4697,
1027,
1027,
1027,
15489,
5332,
4371,
1007,
1063,
2709,
1025,
1065,
1035,
3718,
18279,
7712,
14876,
7666,
4697,
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... |
SAP/openui5 | src/sap.ui.core/src/jquery.sap.global.js | function(key, type, callback) {
return function(value) {
try {
if ( value != null || type === 'string' ) {
if (value) {
localStorage.setItem(key, type === 'boolean' ? 'X' : value);
} else {
localStorage.removeItem(key);
}
callback(value);
}
value = localStorage.getItem(key);
return type === 'boolean' ? value === 'X' : value;
} catch (e) {
Log.warning("Could not access localStorage while accessing '" + key + "' (value: '" + value + "', are cookies disabled?): " + e.message);
}
};
} | javascript | function(key, type, callback) {
return function(value) {
try {
if ( value != null || type === 'string' ) {
if (value) {
localStorage.setItem(key, type === 'boolean' ? 'X' : value);
} else {
localStorage.removeItem(key);
}
callback(value);
}
value = localStorage.getItem(key);
return type === 'boolean' ? value === 'X' : value;
} catch (e) {
Log.warning("Could not access localStorage while accessing '" + key + "' (value: '" + value + "', are cookies disabled?): " + e.message);
}
};
} | [
"function",
"(",
"key",
",",
"type",
",",
"callback",
")",
"{",
"return",
"function",
"(",
"value",
")",
"{",
"try",
"{",
"if",
"(",
"value",
"!=",
"null",
"||",
"type",
"===",
"'string'",
")",
"{",
"if",
"(",
"value",
")",
"{",
"localStorage",
"."... | Reads the value for the given key from the localStorage or writes a new value to it. | [
"Reads",
"the",
"value",
"for",
"the",
"given",
"key",
"from",
"the",
"localStorage",
"or",
"writes",
"a",
"new",
"value",
"to",
"it",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/jquery.sap.global.js#L563-L580 | train | set localStorage value | [
30522,
3853,
1006,
3145,
1010,
2828,
1010,
2655,
5963,
1007,
1063,
2709,
3853,
1006,
3643,
1007,
1063,
3046,
1063,
2065,
1006,
3643,
999,
1027,
19701,
1064,
1064,
2828,
1027,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2065,
1006,
3643,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/ThemeCheck.js | checkCustom | function checkCustom (oThemeCheck, lib){
var cssFile = window.document.getElementById("sap-ui-theme-" + lib);
if (!cssFile) {
return false;
}
/*
Check if custom.css indication rule is applied to <link> element
The rule looks like this:
link[id^="sap-ui-theme-"]::after,
.sapUiThemeDesignerCustomCss {
content: '{"customcss" : true}';
}
First selector is to apply it to the <link> elements,
the second one for the Safari workaround (see below).
*/
var style = window.getComputedStyle(cssFile, ':after');
var content = style ? style.getPropertyValue('content') : null;
if (!content && Device.browser.safari) {
// Safari has a bug which prevents reading properties of hidden pseudo elements
// As a workaround: Add "sapUiThemeDesignerCustomCss" class on html element
// in order to get the computed "content" value and remove it again.
var html = document.documentElement;
html.classList.add("sapUiThemeDesignerCustomCss");
content = window.getComputedStyle(html, ":after").getPropertyValue("content");
html.classList.remove("sapUiThemeDesignerCustomCss");
}
if (content && content !== "none") {
try {
// Strip surrounding quotes (single or double depending on browser)
if (content[0] === "'" || content[0] === '"') {
content = content.substring(1, content.length - 1);
}
// Cast to boolean (returns true if string equals "true", otherwise false)
return content === "true";
} catch (e) {
// parsing error
Log.error("Custom check: Error parsing JSON string for custom.css indication.", e);
}
}
//***********************************
// Fallback legacy customcss check
//***********************************
/*
* checks if a particular class is available at the beginning of the stylesheet
*/
var aRules = cssFile.sheet ? safeAccessSheetCssRules(cssFile.sheet) : null;
if (!aRules || aRules.length === 0) {
Log.warning("Custom check: Failed retrieving a CSS rule from stylesheet " + lib);
return false;
}
// we should now have some rule name ==> try to match against custom check
for (var i = 0; (i < 2 && i < aRules.length) ; i++) {
if (oThemeCheck._CUSTOMCSSCHECK.test(aRules[i].selectorText)) {
return true;
}
}
return false;
} | javascript | function checkCustom (oThemeCheck, lib){
var cssFile = window.document.getElementById("sap-ui-theme-" + lib);
if (!cssFile) {
return false;
}
/*
Check if custom.css indication rule is applied to <link> element
The rule looks like this:
link[id^="sap-ui-theme-"]::after,
.sapUiThemeDesignerCustomCss {
content: '{"customcss" : true}';
}
First selector is to apply it to the <link> elements,
the second one for the Safari workaround (see below).
*/
var style = window.getComputedStyle(cssFile, ':after');
var content = style ? style.getPropertyValue('content') : null;
if (!content && Device.browser.safari) {
// Safari has a bug which prevents reading properties of hidden pseudo elements
// As a workaround: Add "sapUiThemeDesignerCustomCss" class on html element
// in order to get the computed "content" value and remove it again.
var html = document.documentElement;
html.classList.add("sapUiThemeDesignerCustomCss");
content = window.getComputedStyle(html, ":after").getPropertyValue("content");
html.classList.remove("sapUiThemeDesignerCustomCss");
}
if (content && content !== "none") {
try {
// Strip surrounding quotes (single or double depending on browser)
if (content[0] === "'" || content[0] === '"') {
content = content.substring(1, content.length - 1);
}
// Cast to boolean (returns true if string equals "true", otherwise false)
return content === "true";
} catch (e) {
// parsing error
Log.error("Custom check: Error parsing JSON string for custom.css indication.", e);
}
}
//***********************************
// Fallback legacy customcss check
//***********************************
/*
* checks if a particular class is available at the beginning of the stylesheet
*/
var aRules = cssFile.sheet ? safeAccessSheetCssRules(cssFile.sheet) : null;
if (!aRules || aRules.length === 0) {
Log.warning("Custom check: Failed retrieving a CSS rule from stylesheet " + lib);
return false;
}
// we should now have some rule name ==> try to match against custom check
for (var i = 0; (i < 2 && i < aRules.length) ; i++) {
if (oThemeCheck._CUSTOMCSSCHECK.test(aRules[i].selectorText)) {
return true;
}
}
return false;
} | [
"function",
"checkCustom",
"(",
"oThemeCheck",
",",
"lib",
")",
"{",
"var",
"cssFile",
"=",
"window",
".",
"document",
".",
"getElementById",
"(",
"\"sap-ui-theme-\"",
"+",
"lib",
")",
";",
"if",
"(",
"!",
"cssFile",
")",
"{",
"return",
"false",
";",
"}"... | /* checks if a particular class is available | [
"/",
"*",
"checks",
"if",
"a",
"particular",
"class",
"is",
"available"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/ThemeCheck.js#L318-L393 | train | Checks if custom. css is applied to the element | [
30522,
3853,
4638,
7874,
20389,
1006,
27178,
29122,
27635,
3600,
1010,
5622,
2497,
1007,
1063,
13075,
20116,
22747,
9463,
1027,
3332,
1012,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1000,
20066,
1011,
21318,
1011,
4323,
1011,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(urls, onload, onerror)
{
var remain = urls.length;
var result = [];
var errors = 0;
var err = function()
{
if (errors == 0 && onerror != null)
{
onerror();
}
errors++;
};
for (var i = 0; i < urls.length; i++)
{
(function(url, index)
{
mxUtils.get(url, function(req)
{
var status = req.getStatus();
if (status < 200 || status > 299)
{
err();
}
else
{
result[index] = req;
remain--;
if (remain == 0)
{
onload(result);
}
}
}, err);
})(urls[i], i);
}
if (remain == 0)
{
onload(result);
}
} | javascript | function(urls, onload, onerror)
{
var remain = urls.length;
var result = [];
var errors = 0;
var err = function()
{
if (errors == 0 && onerror != null)
{
onerror();
}
errors++;
};
for (var i = 0; i < urls.length; i++)
{
(function(url, index)
{
mxUtils.get(url, function(req)
{
var status = req.getStatus();
if (status < 200 || status > 299)
{
err();
}
else
{
result[index] = req;
remain--;
if (remain == 0)
{
onload(result);
}
}
}, err);
})(urls[i], i);
}
if (remain == 0)
{
onload(result);
}
} | [
"function",
"(",
"urls",
",",
"onload",
",",
"onerror",
")",
"{",
"var",
"remain",
"=",
"urls",
".",
"length",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"errors",
"=",
"0",
";",
"var",
"err",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"e... | Function: getAll
Loads the URLs in the given array *asynchronously* and invokes the given function
if all requests returned with a valid 2xx status. The error handler is invoked
once on the first error or invalid response.
Parameters:
urls - Array of URLs to be loaded.
onload - Callback with array of <mxXmlRequests>.
onerror - Optional function to execute on error. | [
"Function",
":",
"getAll"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3630-L3675 | train | This function is called by the load function on the server | [
30522,
3853,
1006,
24471,
4877,
1010,
2006,
11066,
1010,
2028,
18933,
2099,
1007,
1063,
13075,
3961,
1027,
24471,
4877,
1012,
3091,
1025,
13075,
2765,
1027,
1031,
1033,
1025,
13075,
10697,
1027,
1014,
1025,
13075,
9413,
2099,
1027,
3853,
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 | grunt/config/aliases.js | function() {
var sapUiBuildtime = config.buildtime;
var version = config.package && config.package.version;
var useDefaultTemplate = grunt.option('default-template');
if (!useDefaultTemplate) {
var sapUiVersionJson = {
name: "openui5",
version: version,
buildTimestamp: sapUiBuildtime,
scmRevision: '',
gav: 'com.sap.openui5:openui5:' + version,
libraries: config.allLibraries.map(function(library) {
return {
name: library.name,
version: version,
buildTimestamp: sapUiBuildtime,
scmRevision: ''
};
})
};
grunt.file.write("target/openui5-sdk/resources/sap-ui-version.json", JSON.stringify(sapUiVersionJson, null, '\t'));
}
var aTasks = [];
config.libraries.forEach(function(library) {
// ignore theme libs
if ( library.type === 'theme' ) {
return;
}
aTasks.push('jsdoc:library-' + library.name);
if (!useDefaultTemplate) {
aTasks.push('ui5docs-preprocess:library-' + library.name);
}
});
if (!useDefaultTemplate) {
aTasks.push('ui5docs-api-index:openui5-sdk');
}
grunt.task.run(aTasks);
} | javascript | function() {
var sapUiBuildtime = config.buildtime;
var version = config.package && config.package.version;
var useDefaultTemplate = grunt.option('default-template');
if (!useDefaultTemplate) {
var sapUiVersionJson = {
name: "openui5",
version: version,
buildTimestamp: sapUiBuildtime,
scmRevision: '',
gav: 'com.sap.openui5:openui5:' + version,
libraries: config.allLibraries.map(function(library) {
return {
name: library.name,
version: version,
buildTimestamp: sapUiBuildtime,
scmRevision: ''
};
})
};
grunt.file.write("target/openui5-sdk/resources/sap-ui-version.json", JSON.stringify(sapUiVersionJson, null, '\t'));
}
var aTasks = [];
config.libraries.forEach(function(library) {
// ignore theme libs
if ( library.type === 'theme' ) {
return;
}
aTasks.push('jsdoc:library-' + library.name);
if (!useDefaultTemplate) {
aTasks.push('ui5docs-preprocess:library-' + library.name);
}
});
if (!useDefaultTemplate) {
aTasks.push('ui5docs-api-index:openui5-sdk');
}
grunt.task.run(aTasks);
} | [
"function",
"(",
")",
"{",
"var",
"sapUiBuildtime",
"=",
"config",
".",
"buildtime",
";",
"var",
"version",
"=",
"config",
".",
"package",
"&&",
"config",
".",
"package",
".",
"version",
";",
"var",
"useDefaultTemplate",
"=",
"grunt",
".",
"option",
"(",
... | Build task | [
"Build",
"task"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/grunt/config/aliases.js#L266-L308 | train | write sap - ui - version. json | [
30522,
3853,
1006,
1007,
1063,
13075,
20066,
10179,
8569,
4014,
11927,
14428,
1027,
9530,
8873,
2290,
1012,
3857,
7292,
1025,
13075,
2544,
1027,
9530,
8873,
2290,
1012,
7427,
1004,
1004,
9530,
8873,
2290,
1012,
7427,
1012,
2544,
1025,
13075... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mochajs/mocha | lib/reporters/html.js | text | function text(el, contents) {
if (el.textContent) {
el.textContent = contents;
} else {
el.innerText = contents;
}
} | javascript | function text(el, contents) {
if (el.textContent) {
el.textContent = contents;
} else {
el.innerText = contents;
}
} | [
"function",
"text",
"(",
"el",
",",
"contents",
")",
"{",
"if",
"(",
"el",
".",
"textContent",
")",
"{",
"el",
".",
"textContent",
"=",
"contents",
";",
"}",
"else",
"{",
"el",
".",
"innerText",
"=",
"contents",
";",
"}",
"}"
] | Set an element's text contents.
@param {HTMLElement} el
@param {string} contents | [
"Set",
"an",
"element",
"s",
"text",
"contents",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/html.js#L371-L377 | train | Set text content | [
30522,
3853,
3793,
1006,
3449,
1010,
8417,
1007,
1063,
2065,
1006,
3449,
1012,
3793,
8663,
6528,
2102,
1007,
1063,
3449,
1012,
3793,
8663,
6528,
2102,
1027,
8417,
1025,
1065,
2842,
1063,
3449,
1012,
5110,
18209,
1027,
8417,
1025,
1065,
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... |
lynckia/licode | erizo_controller/erizoClient/src/utils/L.Resizer.js | forEachElement | function forEachElement(elements, callback = () => {}) {
const elementsType = Object.prototype.toString.call(elements);
const isCollectionTyped = (elementsType === '[object Array]' ||
(elementsType === '[object NodeList]') ||
(elementsType === '[object HTMLCollection]') ||
(typeof jQuery !== 'undefined' && elements instanceof jQuery) || // jquery
(typeof Elements !== 'undefined' && elements instanceof Elements) // mootools
);
let i = 0;
const j = elements.length;
if (isCollectionTyped) {
for (; i < j; i += 1) {
callback(elements[i]);
}
} else {
callback(elements);
}
} | javascript | function forEachElement(elements, callback = () => {}) {
const elementsType = Object.prototype.toString.call(elements);
const isCollectionTyped = (elementsType === '[object Array]' ||
(elementsType === '[object NodeList]') ||
(elementsType === '[object HTMLCollection]') ||
(typeof jQuery !== 'undefined' && elements instanceof jQuery) || // jquery
(typeof Elements !== 'undefined' && elements instanceof Elements) // mootools
);
let i = 0;
const j = elements.length;
if (isCollectionTyped) {
for (; i < j; i += 1) {
callback(elements[i]);
}
} else {
callback(elements);
}
} | [
"function",
"forEachElement",
"(",
"elements",
",",
"callback",
"=",
"(",
")",
"=>",
"{",
"}",
")",
"{",
"const",
"elementsType",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"elements",
")",
";",
"const",
"isCollectionTyped",
"=",
... | Iterate over each of the provided element(s).
@param {HTMLElement|HTMLElement[]} elements
@param {Function} callback | [
"Iterate",
"over",
"each",
"of",
"the",
"provided",
"element",
"(",
"s",
")",
"."
] | ce1f09ae30054f677fc25f2011b0e5072fa6f71f | https://github.com/lynckia/licode/blob/ce1f09ae30054f677fc25f2011b0e5072fa6f71f/erizo_controller/erizoClient/src/utils/L.Resizer.js#L280-L297 | train | Iterate over an array of elements | [
30522,
3853,
18921,
15395,
16930,
4765,
1006,
3787,
1010,
2655,
5963,
1027,
1006,
1007,
1027,
1028,
1063,
1065,
1007,
1063,
9530,
3367,
3787,
13874,
1027,
4874,
1012,
8773,
1012,
2000,
3367,
4892,
1012,
2655,
1006,
3787,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | mmult | function mmult(A, B, n) {
var C = new Array(n * n);
for (var i = 0; i < n; i++) {
for (var j = 0; j < n; j++) {
C[i * n + j] = 0;
}
for (var k = 0; k < n; k++) {
for (var _j = 0; _j < n; _j++) {
C[i * n + _j] += A[i * n + k] * B[k * n + _j];
}
}
}
return C;
} | javascript | function mmult(A, B, n) {
var C = new Array(n * n);
for (var i = 0; i < n; i++) {
for (var j = 0; j < n; j++) {
C[i * n + j] = 0;
}
for (var k = 0; k < n; k++) {
for (var _j = 0; _j < n; _j++) {
C[i * n + _j] += A[i * n + k] * B[k * n + _j];
}
}
}
return C;
} | [
"function",
"mmult",
"(",
"A",
",",
"B",
",",
"n",
")",
"{",
"var",
"C",
"=",
"new",
"Array",
"(",
"n",
"*",
"n",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"... | TODO: blocked matrix multiplication? | [
"TODO",
":",
"blocked",
"matrix",
"multiplication?"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L3842-L3858 | train | A = A * B | [
30522,
3853,
3461,
11314,
1006,
1037,
1010,
1038,
1010,
1050,
1007,
1063,
13075,
1039,
1027,
2047,
9140,
1006,
1050,
1008,
1050,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
1050,
1025,
1045,
1009,
1009,
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... |
SeleniumHQ/selenium | third_party/closure/goog/labs/format/csv.js | readRecord | function readRecord() {
if (index >= text.length) {
return EOF;
}
var record = [];
for (var field = readField(); field != EOR; field = readField()) {
record.push(field);
}
return record;
} | javascript | function readRecord() {
if (index >= text.length) {
return EOF;
}
var record = [];
for (var field = readField(); field != EOR; field = readField()) {
record.push(field);
}
return record;
} | [
"function",
"readRecord",
"(",
")",
"{",
"if",
"(",
"index",
">=",
"text",
".",
"length",
")",
"{",
"return",
"EOF",
";",
"}",
"var",
"record",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"field",
"=",
"readField",
"(",
")",
";",
"field",
"!=",
"EOR",... | Read the next record.
@return {!Array<string>|!goog.labs.format.csv.Sentinels_} A single record
with multiple fields. | [
"Read",
"the",
"next",
"record",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/labs/format/csv.js#L344-L353 | train | Read a record from the stream | [
30522,
3853,
3191,
2890,
27108,
2094,
1006,
1007,
1063,
2065,
1006,
5950,
1028,
1027,
3793,
1012,
3091,
1007,
1063,
2709,
1041,
11253,
1025,
1065,
13075,
2501,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
2492,
1027,
3191,
3790,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/key-spacing.js | report | function report(property, side, whitespace, expected, mode) {
const diff = whitespace.length - expected,
nextColon = getNextColon(property.key),
tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true }),
tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true }),
isKeySide = side === "key",
locStart = isKeySide ? tokenBeforeColon.loc.start : tokenAfterColon.loc.start,
isExtra = diff > 0,
diffAbs = Math.abs(diff),
spaces = Array(diffAbs + 1).join(" ");
if ((
diff && mode === "strict" ||
diff < 0 && mode === "minimum" ||
diff > 0 && !expected && mode === "minimum") &&
!(expected && containsLineTerminator(whitespace))
) {
let fix;
if (isExtra) {
let range;
// Remove whitespace
if (isKeySide) {
range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
} else {
range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
}
fix = function(fixer) {
return fixer.removeRange(range);
};
} else {
// Add whitespace
if (isKeySide) {
fix = function(fixer) {
return fixer.insertTextAfter(tokenBeforeColon, spaces);
};
} else {
fix = function(fixer) {
return fixer.insertTextBefore(tokenAfterColon, spaces);
};
}
}
let messageId = "";
if (isExtra) {
messageId = side === "key" ? "extraKey" : "extraValue";
} else {
messageId = side === "key" ? "missingKey" : "missingValue";
}
context.report({
node: property[side],
loc: locStart,
messageId,
data: {
computed: property.computed ? "computed " : "",
key: getKey(property)
},
fix
});
}
} | javascript | function report(property, side, whitespace, expected, mode) {
const diff = whitespace.length - expected,
nextColon = getNextColon(property.key),
tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: true }),
tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: true }),
isKeySide = side === "key",
locStart = isKeySide ? tokenBeforeColon.loc.start : tokenAfterColon.loc.start,
isExtra = diff > 0,
diffAbs = Math.abs(diff),
spaces = Array(diffAbs + 1).join(" ");
if ((
diff && mode === "strict" ||
diff < 0 && mode === "minimum" ||
diff > 0 && !expected && mode === "minimum") &&
!(expected && containsLineTerminator(whitespace))
) {
let fix;
if (isExtra) {
let range;
// Remove whitespace
if (isKeySide) {
range = [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs];
} else {
range = [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]];
}
fix = function(fixer) {
return fixer.removeRange(range);
};
} else {
// Add whitespace
if (isKeySide) {
fix = function(fixer) {
return fixer.insertTextAfter(tokenBeforeColon, spaces);
};
} else {
fix = function(fixer) {
return fixer.insertTextBefore(tokenAfterColon, spaces);
};
}
}
let messageId = "";
if (isExtra) {
messageId = side === "key" ? "extraKey" : "extraValue";
} else {
messageId = side === "key" ? "missingKey" : "missingValue";
}
context.report({
node: property[side],
loc: locStart,
messageId,
data: {
computed: property.computed ? "computed " : "",
key: getKey(property)
},
fix
});
}
} | [
"function",
"report",
"(",
"property",
",",
"side",
",",
"whitespace",
",",
"expected",
",",
"mode",
")",
"{",
"const",
"diff",
"=",
"whitespace",
".",
"length",
"-",
"expected",
",",
"nextColon",
"=",
"getNextColon",
"(",
"property",
".",
"key",
")",
",... | Reports an appropriately-formatted error if spacing is incorrect on one
side of the colon.
@param {ASTNode} property Key-value pair in an object literal.
@param {string} side Side being verified - either "key" or "value".
@param {string} whitespace Actual whitespace string.
@param {int} expected Expected whitespace length.
@param {string} mode Value of the mode as "strict" or "minimum"
@returns {void} | [
"Reports",
"an",
"appropriately",
"-",
"formatted",
"error",
"if",
"spacing",
"is",
"incorrect",
"on",
"one",
"side",
"of",
"the",
"colon",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/key-spacing.js#L419-L483 | train | Reports a property with a given side of whitespace. | [
30522,
3853,
3189,
1006,
3200,
1010,
2217,
1010,
12461,
15327,
1010,
3517,
1010,
5549,
1007,
1063,
9530,
3367,
4487,
4246,
1027,
12461,
15327,
1012,
3091,
1011,
3517,
1010,
2279,
25778,
2239,
1027,
2131,
2638,
18413,
25778,
2239,
1006,
3200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js | function(bForce) {
if (oPendingInteraction) {
// set provisionary processing time from start to end and calculate later
if (!bForce) {
oPendingInteraction.processing = now() - oPendingInteraction.start;
} else {
finalizeInteraction(now());
}
}
} | javascript | function(bForce) {
if (oPendingInteraction) {
// set provisionary processing time from start to end and calculate later
if (!bForce) {
oPendingInteraction.processing = now() - oPendingInteraction.start;
} else {
finalizeInteraction(now());
}
}
} | [
"function",
"(",
"bForce",
")",
"{",
"if",
"(",
"oPendingInteraction",
")",
"{",
"// set provisionary processing time from start to end and calculate later",
"if",
"(",
"!",
"bForce",
")",
"{",
"oPendingInteraction",
".",
"processing",
"=",
"now",
"(",
")",
"-",
"oP... | End an interaction measurements.
@param {boolean} bForce forces end of interaction now and ignores further re-renderings
@static
@private | [
"End",
"an",
"interaction",
"measurements",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js#L385-L394 | train | set the processing time of the pending interaction | [
30522,
3853,
1006,
28939,
2953,
3401,
1007,
1063,
2065,
1006,
2330,
4667,
18447,
6906,
7542,
1007,
1063,
1013,
1013,
2275,
9347,
5649,
6364,
2051,
2013,
2707,
2000,
2203,
1998,
18422,
2101,
2065,
1006,
999,
28939,
2953,
3401,
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... | |
caolan/async | lib/every.js | every | function every(coll, iteratee, callback) {
return createTester(bool => !bool, res => !res)(eachOf, coll, iteratee, callback)
} | javascript | function every(coll, iteratee, callback) {
return createTester(bool => !bool, res => !res)(eachOf, coll, iteratee, callback)
} | [
"function",
"every",
"(",
"coll",
",",
"iteratee",
",",
"callback",
")",
"{",
"return",
"createTester",
"(",
"bool",
"=>",
"!",
"bool",
",",
"res",
"=>",
"!",
"res",
")",
"(",
"eachOf",
",",
"coll",
",",
"iteratee",
",",
"callback",
")",
"}"
] | Returns `true` if every element in `coll` satisfies an async test. If any
iteratee call returns `false`, the main `callback` is immediately called.
@name every
@static
@memberOf module:Collections
@method
@alias all
@category Collection
@param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
@param {AsyncFunction} iteratee - An async truth test to apply to each item
in the collection in parallel.
The iteratee must complete with a boolean result value.
Invoked with (item, callback).
@param {Function} [callback] - A callback which is called after all the
`iteratee` functions have finished. Result will be either `true` or `false`
depending on the values of the async tests. Invoked with (err, result).
@returns {Promise} a promise, if no callback provided
@example
async.every(['file1','file2','file3'], function(filePath, callback) {
fs.access(filePath, function(err) {
callback(null, !err)
});
}, function(err, result) {
// if result is true then every file exists
}); | [
"Returns",
"true",
"if",
"every",
"element",
"in",
"coll",
"satisfies",
"an",
"async",
"test",
".",
"If",
"any",
"iteratee",
"call",
"returns",
"false",
"the",
"main",
"callback",
"is",
"immediately",
"called",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/every.js#L34-L36 | train | Returns true if every element in coll is false | [
30522,
3853,
2296,
1006,
8902,
2140,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
2709,
3443,
22199,
2121,
1006,
22017,
2140,
1027,
1028,
999,
22017,
2140,
1010,
24501,
1027,
1028,
999,
24501,
1007,
1006,
2169,
11253,
1010,
8902,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/path-utils.js | getRelativePath | function getRelativePath(filepath, baseDir) {
const absolutePath = path.isAbsolute(filepath)
? filepath
: path.resolve(filepath);
if (baseDir) {
if (!path.isAbsolute(baseDir)) {
throw new Error(`baseDir should be an absolute path: ${baseDir}`);
}
return path.relative(baseDir, absolutePath);
}
return absolutePath.replace(/^\//u, "");
} | javascript | function getRelativePath(filepath, baseDir) {
const absolutePath = path.isAbsolute(filepath)
? filepath
: path.resolve(filepath);
if (baseDir) {
if (!path.isAbsolute(baseDir)) {
throw new Error(`baseDir should be an absolute path: ${baseDir}`);
}
return path.relative(baseDir, absolutePath);
}
return absolutePath.replace(/^\//u, "");
} | [
"function",
"getRelativePath",
"(",
"filepath",
",",
"baseDir",
")",
"{",
"const",
"absolutePath",
"=",
"path",
".",
"isAbsolute",
"(",
"filepath",
")",
"?",
"filepath",
":",
"path",
".",
"resolve",
"(",
"filepath",
")",
";",
"if",
"(",
"baseDir",
")",
"... | Converts an absolute filepath to a relative path from a given base path
For example, if the filepath is `/my/awesome/project/foo.bar`,
and the base directory is `/my/awesome/project/`,
then this function should return `foo.bar`.
path.relative() does something similar, but it requires a baseDir (`from` argument).
This function makes it optional and just removes a leading slash if the baseDir is not given.
It does not take into account symlinks (for now).
@param {string} filepath Path to convert to relative path. If already relative,
it will be assumed to be relative to process.cwd(),
converted to absolute, and then processed.
@param {string} [baseDir] Absolute base directory to resolve the filepath from.
If not provided, all this function will do is remove
a leading slash.
@returns {string} Relative filepath | [
"Converts",
"an",
"absolute",
"filepath",
"to",
"a",
"relative",
"path",
"from",
"a",
"given",
"base",
"path"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/path-utils.js#L50-L63 | train | Get the relative path of a file | [
30522,
3853,
2131,
16570,
8082,
15069,
1006,
5371,
15069,
1010,
2241,
4313,
1007,
1063,
9530,
3367,
7619,
15069,
1027,
4130,
1012,
18061,
5910,
4747,
10421,
1006,
5371,
15069,
1007,
1029,
5371,
15069,
1024,
4130,
1012,
10663,
1006,
5371,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(string, t0)
{
if (mxLog.TRACE)
{
var dt = (t0 != 0) ? ' ('+(new Date().getTime() - t0)+' ms)' : '';
mxLog.writeln('Leaving '+string+dt);
}
} | javascript | function(string, t0)
{
if (mxLog.TRACE)
{
var dt = (t0 != 0) ? ' ('+(new Date().getTime() - t0)+' ms)' : '';
mxLog.writeln('Leaving '+string+dt);
}
} | [
"function",
"(",
"string",
",",
"t0",
")",
"{",
"if",
"(",
"mxLog",
".",
"TRACE",
")",
"{",
"var",
"dt",
"=",
"(",
"t0",
"!=",
"0",
")",
"?",
"' ('",
"+",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"-",
"t0",
")",
"+",
"' ms)'"... | Function: leave
Writes the specified string to the console
if <TRACE> is true and computes the difference
between the current time and t0 in milliseconds.
See <enter> for an example. | [
"Function",
":",
"leave"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L928-L935 | train | Helper function to log a message | [
30522,
3853,
1006,
5164,
1010,
1056,
2692,
1007,
1063,
2065,
1006,
25630,
21197,
1012,
7637,
1007,
1063,
13075,
26718,
1027,
1006,
1056,
2692,
999,
1027,
1014,
1007,
1029,
1005,
1006,
1005,
1009,
1006,
2047,
3058,
1006,
1007,
1012,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/getModifiers.js | getModifiers | function getModifiers(output, page) {
var book = output.getBook();
var plugins = output.getPlugins();
var glossary = book.getGlossary();
var file = page.getFile();
// Glossary entries
var entries = glossary.getEntries();
var glossaryFile = glossary.getFile();
var glossaryFilename = fileToOutput(output, glossaryFile.getPath());
// Current file path
var currentFilePath = file.getPath();
// Get TemplateBlock for highlighting
var blocks = Plugins.listBlocks(plugins);
var code = blocks.get(CODEBLOCK) || defaultBlocks.get(CODEBLOCK);
// Current context
var context = Api.encodeGlobal(output);
return [
// Normalize IDs on headings
Modifiers.addHeadingId,
// Annotate text with glossary entries
Modifiers.annotateText.bind(null, entries, glossaryFilename),
// Resolve images
Modifiers.resolveImages.bind(null, currentFilePath),
// Resolve links (.md -> .html)
Modifiers.resolveLinks.bind(null,
currentFilePath,
resolveFileToURL.bind(null, output)
),
// Highlight code blocks using "code" block
Modifiers.highlightCode.bind(null, function(lang, source) {
return Promise(code.applyBlock({
body: source,
kwargs: {
language: lang
}
}, context))
.then(function(result) {
if (result.html === false) {
return { text: result.body };
} else {
return { html: result.body };
}
});
})
];
} | javascript | function getModifiers(output, page) {
var book = output.getBook();
var plugins = output.getPlugins();
var glossary = book.getGlossary();
var file = page.getFile();
// Glossary entries
var entries = glossary.getEntries();
var glossaryFile = glossary.getFile();
var glossaryFilename = fileToOutput(output, glossaryFile.getPath());
// Current file path
var currentFilePath = file.getPath();
// Get TemplateBlock for highlighting
var blocks = Plugins.listBlocks(plugins);
var code = blocks.get(CODEBLOCK) || defaultBlocks.get(CODEBLOCK);
// Current context
var context = Api.encodeGlobal(output);
return [
// Normalize IDs on headings
Modifiers.addHeadingId,
// Annotate text with glossary entries
Modifiers.annotateText.bind(null, entries, glossaryFilename),
// Resolve images
Modifiers.resolveImages.bind(null, currentFilePath),
// Resolve links (.md -> .html)
Modifiers.resolveLinks.bind(null,
currentFilePath,
resolveFileToURL.bind(null, output)
),
// Highlight code blocks using "code" block
Modifiers.highlightCode.bind(null, function(lang, source) {
return Promise(code.applyBlock({
body: source,
kwargs: {
language: lang
}
}, context))
.then(function(result) {
if (result.html === false) {
return { text: result.body };
} else {
return { html: result.body };
}
});
})
];
} | [
"function",
"getModifiers",
"(",
"output",
",",
"page",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"plugins",
"=",
"output",
".",
"getPlugins",
"(",
")",
";",
"var",
"glossary",
"=",
"book",
".",
"getGlossary",
"(",
... | Return default modifier to prepare a page for
rendering.
@return {Array<Modifier>} | [
"Return",
"default",
"modifier",
"to",
"prepare",
"a",
"page",
"for",
"rendering",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/getModifiers.js#L17-L71 | train | Get the modifiers of a page | [
30522,
3853,
2131,
5302,
4305,
8873,
2545,
1006,
6434,
1010,
3931,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
13354,
7076,
1027,
6434,
1012,
2131,
24759,
15916,
7076,
1006,
1007,
1025,
13075,
27068,
5649... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/UpdateInfoBar.js | generateJsonForMustache | function generateJsonForMustache(msgObj) {
var msgJsonObj = {};
if (msgObj.type) {
msgJsonObj.type = "'" + msgObj.type + "'";
}
msgJsonObj.title = msgObj.title;
msgJsonObj.description = msgObj.description;
if (msgObj.needButtons) {
msgJsonObj.buttons = [{
"id": "restart",
"value": Strings.RESTART_BUTTON,
"tIndex": "'0'"
}, {
"id": "later",
"value": Strings.LATER_BUTTON,
"tIndex": "'0'"
}];
msgJsonObj.needButtons = msgObj.needButtons;
}
return msgJsonObj;
} | javascript | function generateJsonForMustache(msgObj) {
var msgJsonObj = {};
if (msgObj.type) {
msgJsonObj.type = "'" + msgObj.type + "'";
}
msgJsonObj.title = msgObj.title;
msgJsonObj.description = msgObj.description;
if (msgObj.needButtons) {
msgJsonObj.buttons = [{
"id": "restart",
"value": Strings.RESTART_BUTTON,
"tIndex": "'0'"
}, {
"id": "later",
"value": Strings.LATER_BUTTON,
"tIndex": "'0'"
}];
msgJsonObj.needButtons = msgObj.needButtons;
}
return msgJsonObj;
} | [
"function",
"generateJsonForMustache",
"(",
"msgObj",
")",
"{",
"var",
"msgJsonObj",
"=",
"{",
"}",
";",
"if",
"(",
"msgObj",
".",
"type",
")",
"{",
"msgJsonObj",
".",
"type",
"=",
"\"'\"",
"+",
"msgObj",
".",
"type",
"+",
"\"'\"",
";",
"}",
"msgJsonOb... | keycode for escape key
Generates the json to be used by Mustache for rendering
@param {object} msgObj - json object containing message information to be displayed
@returns {object} - the generated json object | [
"keycode",
"for",
"escape",
"key",
"Generates",
"the",
"json",
"to",
"be",
"used",
"by",
"Mustache",
"for",
"rendering"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/UpdateInfoBar.js#L53-L73 | train | Generate JSON for Mustache | [
30522,
3853,
9699,
22578,
2239,
14192,
19966,
15395,
1006,
5796,
3995,
2497,
3501,
1007,
1063,
13075,
5796,
2290,
22578,
17175,
2497,
3501,
1027,
1063,
1065,
1025,
2065,
1006,
5796,
3995,
2497,
3501,
1012,
2828,
1007,
1063,
5796,
2290,
2257... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MultiBrowserImpl/language/HTMLSimpleDOM.js | _dumpDOM | function _dumpDOM(root) {
var result = "",
indent = "";
function walk(node) {
if (node.tag) {
result += indent + "TAG " + node.tagID + " " + node.tag + " " + JSON.stringify(node.attributes) + "\n";
} else {
result += indent + "TEXT " + (node.tagID || "- ") + node.content + "\n";
}
if (node.isElement()) {
indent += " ";
node.children.forEach(walk);
indent = indent.slice(2);
}
}
walk(root);
return result;
} | javascript | function _dumpDOM(root) {
var result = "",
indent = "";
function walk(node) {
if (node.tag) {
result += indent + "TAG " + node.tagID + " " + node.tag + " " + JSON.stringify(node.attributes) + "\n";
} else {
result += indent + "TEXT " + (node.tagID || "- ") + node.content + "\n";
}
if (node.isElement()) {
indent += " ";
node.children.forEach(walk);
indent = indent.slice(2);
}
}
walk(root);
return result;
} | [
"function",
"_dumpDOM",
"(",
"root",
")",
"{",
"var",
"result",
"=",
"\"\"",
",",
"indent",
"=",
"\"\"",
";",
"function",
"walk",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"tag",
")",
"{",
"result",
"+=",
"indent",
"+",
"\"TAG \"",
"+",
"node"... | @private
Generates a string version of a SimpleDOM for debugging purposes.
@param {SimpleNode} root root of the tree
@return {string} Text version of the tree. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js#L522-L541 | train | Dump DOM | [
30522,
3853,
1035,
15653,
9527,
1006,
7117,
1007,
1063,
13075,
2765,
1027,
1000,
1000,
1010,
27427,
4765,
1027,
1000,
1000,
1025,
3853,
3328,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
6415,
1007,
1063,
2765,
1009,
1027,
27427,
4765,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | src/ol/pointer/MsSource.js | msPointerCancel | function msPointerCancel(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.cancel(e, inEvent);
this.cleanup(inEvent.pointerId);
} | javascript | function msPointerCancel(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.cancel(e, inEvent);
this.cleanup(inEvent.pointerId);
} | [
"function",
"msPointerCancel",
"(",
"inEvent",
")",
"{",
"const",
"e",
"=",
"this",
".",
"prepareEvent_",
"(",
"inEvent",
")",
";",
"this",
".",
"dispatcher",
".",
"cancel",
"(",
"e",
",",
"inEvent",
")",
";",
"this",
".",
"cleanup",
"(",
"inEvent",
".... | Handler for `msPointerCancel`.
@this {MsSource}
@param {MSPointerEvent} inEvent The in event. | [
"Handler",
"for",
"msPointerCancel",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L112-L116 | train | Cancels pointer event. | [
30522,
3853,
5796,
8400,
2121,
9336,
29109,
1006,
1999,
18697,
3372,
1007,
1063,
9530,
3367,
1041,
1027,
2023,
1012,
7374,
18697,
3372,
1035,
1006,
1999,
18697,
3372,
1007,
1025,
2023,
1012,
18365,
2121,
1012,
17542,
1006,
1041,
1010,
1999,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/utils/debounce.js | leadingEdge | function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// 为 trailing edge 触发函数调用设定定时器
timerId = setTimeout(timerExpired, wait);
// leading = true 执行函数
return leading ? invokeFunc(time) : result;
} | javascript | function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// 为 trailing edge 触发函数调用设定定时器
timerId = setTimeout(timerExpired, wait);
// leading = true 执行函数
return leading ? invokeFunc(time) : result;
} | [
"function",
"leadingEdge",
"(",
"time",
")",
"{",
"// Reset any `maxWait` timer.",
"lastInvokeTime",
"=",
"time",
";",
"// 为 trailing edge 触发函数调用设定定时器",
"timerId",
"=",
"setTimeout",
"(",
"timerExpired",
",",
"wait",
")",
";",
"// leading = true 执行函数",
"return",
"leadin... | 在leading edge阶段执行函数 | [
"在leading",
"edge阶段执行函数"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/utils/debounce.js#L54-L61 | train | This function is called when a node is being added to a node | [
30522,
3853,
2877,
24225,
1006,
2051,
1007,
1063,
1013,
1013,
25141,
2151,
1036,
4098,
21547,
2102,
1036,
25309,
1012,
2197,
2378,
6767,
3489,
7292,
1027,
2051,
1025,
1013,
1013,
100,
12542,
3341,
100,
100,
100,
100,
100,
100,
100,
1822,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
caolan/async | lib/eachOfLimit.js | eachOfLimit | function eachOfLimit(coll, limit, iteratee, callback) {
return _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
} | javascript | function eachOfLimit(coll, limit, iteratee, callback) {
return _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
} | [
"function",
"eachOfLimit",
"(",
"coll",
",",
"limit",
",",
"iteratee",
",",
"callback",
")",
"{",
"return",
"_eachOfLimit",
"(",
"limit",
")",
"(",
"coll",
",",
"wrapAsync",
"(",
"iteratee",
")",
",",
"callback",
")",
";",
"}"
] | The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
time.
@name eachOfLimit
@static
@memberOf module:Collections
@method
@see [async.eachOf]{@link module:Collections.eachOf}
@alias forEachOfLimit
@category Collection
@param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
@param {number} limit - The maximum number of async operations at a time.
@param {AsyncFunction} iteratee - An async function to apply to each
item in `coll`. The `key` is the item's key, or index in the case of an
array.
Invoked with (item, key, callback).
@param {Function} [callback] - A callback which is called when all
`iteratee` functions have finished, or an error occurs. Invoked with (err).
@returns {Promise} a promise, if a callback is omitted | [
"The",
"same",
"as",
"[",
"eachOf",
"]",
"{",
"@link",
"module",
":",
"Collections",
".",
"eachOf",
"}",
"but",
"runs",
"a",
"maximum",
"of",
"limit",
"async",
"operations",
"at",
"a",
"time",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/eachOfLimit.js#L26-L28 | train | Iterates over a collection and invokes iteratee on each item. | [
30522,
3853,
2169,
11253,
17960,
4183,
1006,
8902,
2140,
1010,
5787,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
2709,
1035,
2169,
11253,
17960,
4183,
1006,
5787,
1007,
1006,
8902,
2140,
1010,
10236,
3022,
6038,
2278,
1006,
2009,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | bower_components/ion.rangeSlider/js/ion.rangeSlider.js | function (e) {
if (this.current_plugin !== this.plugin_count) {
return;
}
if (this.is_active) {
this.is_active = false;
} else {
return;
}
this.$cache.cont.find(".state_hover").removeClass("state_hover");
this.force_redraw = true;
if (is_old_ie) {
$("*").prop("unselectable", false);
}
this.updateScene();
this.restoreOriginalMinInterval();
// callbacks call
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
this.callOnFinish();
}
this.dragging = false;
} | javascript | function (e) {
if (this.current_plugin !== this.plugin_count) {
return;
}
if (this.is_active) {
this.is_active = false;
} else {
return;
}
this.$cache.cont.find(".state_hover").removeClass("state_hover");
this.force_redraw = true;
if (is_old_ie) {
$("*").prop("unselectable", false);
}
this.updateScene();
this.restoreOriginalMinInterval();
// callbacks call
if ($.contains(this.$cache.cont[0], e.target) || this.dragging) {
this.callOnFinish();
}
this.dragging = false;
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"this",
".",
"current_plugin",
"!==",
"this",
".",
"plugin_count",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"is_active",
")",
"{",
"this",
".",
"is_active",
"=",
"false",
";",
"}",
"else",
"{"... | Mouseup or touchend
only for handlers
@param e {Object} event object | [
"Mouseup",
"or",
"touchend",
"only",
"for",
"handlers"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L783-L811 | train | onmouseout event | [
30522,
3853,
1006,
1041,
1007,
1063,
2065,
1006,
2023,
1012,
2783,
1035,
13354,
2378,
999,
1027,
1027,
2023,
1012,
13354,
2378,
1035,
4175,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2023,
1012,
2003,
1035,
3161,
1007,
1063,
2023,
1012,
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... | |
angular/material | src/components/slider/slider.js | setDisable | function setDisable(value) {
element.children().attr('disabled', value);
element.find('input').attr('disabled', value);
} | javascript | function setDisable(value) {
element.children().attr('disabled', value);
element.find('input').attr('disabled', value);
} | [
"function",
"setDisable",
"(",
"value",
")",
"{",
"element",
".",
"children",
"(",
")",
".",
"attr",
"(",
"'disabled'",
",",
"value",
")",
";",
"element",
".",
"find",
"(",
"'input'",
")",
".",
"attr",
"(",
"'disabled'",
",",
"value",
")",
";",
"}"
] | We have to manually stop the $watch on ngDisabled because it exists on the parent scope, and won't be automatically destroyed when the component is destroyed. | [
"We",
"have",
"to",
"manually",
"stop",
"the",
"$watch",
"on",
"ngDisabled",
"because",
"it",
"exists",
"on",
"the",
"parent",
"scope",
"and",
"won",
"t",
"be",
"automatically",
"destroyed",
"when",
"the",
"component",
"is",
"destroyed",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/slider/slider.js#L69-L72 | train | Set the disabled attribute of the node | [
30522,
3853,
2275,
10521,
3085,
1006,
3643,
1007,
1063,
5783,
1012,
2336,
1006,
1007,
1012,
2012,
16344,
1006,
1005,
9776,
1005,
1010,
3643,
1007,
1025,
5783,
1012,
2424,
1006,
1005,
7953,
1005,
1007,
1012,
2012,
16344,
1006,
1005,
9776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _markStart | function _markStart(id, time) {
if (activeTests[id.id]) {
console.error("Recursive tests with the same id are not supported. Timer id: " + id.id);
}
activeTests[id.id] = { startTime: time };
} | javascript | function _markStart(id, time) {
if (activeTests[id.id]) {
console.error("Recursive tests with the same id are not supported. Timer id: " + id.id);
}
activeTests[id.id] = { startTime: time };
} | [
"function",
"_markStart",
"(",
"id",
",",
"time",
")",
"{",
"if",
"(",
"activeTests",
"[",
"id",
".",
"id",
"]",
")",
"{",
"console",
".",
"error",
"(",
"\"Recursive tests with the same id are not supported. Timer id: \"",
"+",
"id",
".",
"id",
")",
";",
"}"... | @private
Helper function for markStart()
@param {Object} id Timer id.
@param {number} time Timer start time. | [
"@private",
"Helper",
"function",
"for",
"markStart",
"()"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L139-L145 | train | Mark a timer as started | [
30522,
3853,
1035,
6017,
7559,
2102,
1006,
8909,
1010,
2051,
1007,
1063,
2065,
1006,
3161,
22199,
2015,
1031,
8909,
1012,
8909,
1033,
1007,
1063,
30524,
8909,
1024,
1000,
1009,
8909,
1012,
8909,
1007,
1025,
1065,
3161,
22199,
2015,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | _draft/music/webuploader.js | function() {
var me = this,
widgets = me._widgets = [];
$.each( widgetClass, function( _, klass ) {
widgets.push( new klass( me ) );
});
return _init.apply( me, arguments );
} | javascript | function() {
var me = this,
widgets = me._widgets = [];
$.each( widgetClass, function( _, klass ) {
widgets.push( new klass( me ) );
});
return _init.apply( me, arguments );
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
",",
"widgets",
"=",
"me",
".",
"_widgets",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"widgetClass",
",",
"function",
"(",
"_",
",",
"klass",
")",
"{",
"widgets",
".",
"push",
"(",
"new",
"k... | 覆写_init用来初始化widgets | [
"覆写_init用来初始化widgets"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/_draft/music/webuploader.js#L1317-L1326 | train | Initializes the widget class | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1010,
15536,
28682,
1027,
2033,
1012,
1035,
15536,
28682,
1027,
1031,
1033,
1025,
1002,
1012,
2169,
1006,
15536,
24291,
26266,
1010,
3853,
1006,
1035,
1010,
1047,
27102,
1007,
1063,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
benweet/stackedit | src/libs/pagedown.js | doClick | function doClick(buttonName) {
var button = buttons[buttonName];
if (!button) {
return;
}
inputBox.focus();
var linkOrImage = button === buttons.link || button.id === buttons.image;
var state = new TextareaState(input);
if (!state) {
return;
}
var chunks = state.getChunks();
// Some commands launch a "modal" prompt dialog. Javascript
// can't really make a modal dialog box and the WMD code
// will continue to execute while the dialog is displayed.
// This prevents the dialog pattern I'm used to and means
// I can't do something like this:
//
// var link = CreateLinkDialog();
// makeMarkdownLink(link);
//
// Instead of this straightforward method of handling a
// dialog I have to pass any code which would execute
// after the dialog is dismissed (e.g. link creation)
// in a function parameter.
//
// Yes this is awkward and I think it sucks, but there's
// no real workaround. Only the image and link code
// create dialogs and require the function pointers.
var fixupInputArea = function () {
inputBox.focus();
if (chunks) {
state.setChunks(chunks);
}
state.restore();
};
var noCleanup = button(chunks, fixupInputArea);
if (!noCleanup) {
fixupInputArea();
if (!linkOrImage) {
inputBox.adjustCursorPosition();
}
}
} | javascript | function doClick(buttonName) {
var button = buttons[buttonName];
if (!button) {
return;
}
inputBox.focus();
var linkOrImage = button === buttons.link || button.id === buttons.image;
var state = new TextareaState(input);
if (!state) {
return;
}
var chunks = state.getChunks();
// Some commands launch a "modal" prompt dialog. Javascript
// can't really make a modal dialog box and the WMD code
// will continue to execute while the dialog is displayed.
// This prevents the dialog pattern I'm used to and means
// I can't do something like this:
//
// var link = CreateLinkDialog();
// makeMarkdownLink(link);
//
// Instead of this straightforward method of handling a
// dialog I have to pass any code which would execute
// after the dialog is dismissed (e.g. link creation)
// in a function parameter.
//
// Yes this is awkward and I think it sucks, but there's
// no real workaround. Only the image and link code
// create dialogs and require the function pointers.
var fixupInputArea = function () {
inputBox.focus();
if (chunks) {
state.setChunks(chunks);
}
state.restore();
};
var noCleanup = button(chunks, fixupInputArea);
if (!noCleanup) {
fixupInputArea();
if (!linkOrImage) {
inputBox.adjustCursorPosition();
}
}
} | [
"function",
"doClick",
"(",
"buttonName",
")",
"{",
"var",
"button",
"=",
"buttons",
"[",
"buttonName",
"]",
";",
"if",
"(",
"!",
"button",
")",
"{",
"return",
";",
"}",
"inputBox",
".",
"focus",
"(",
")",
";",
"var",
"linkOrImage",
"=",
"button",
"=... | Perform the button's action. | [
"Perform",
"the",
"button",
"s",
"action",
"."
] | 91f8cf3c10b75df65b69f9181cee8151d65a788d | https://github.com/benweet/stackedit/blob/91f8cf3c10b75df65b69f9181cee8151d65a788d/src/libs/pagedown.js#L398-L451 | train | Clicks a button on the input box. | [
30522,
3853,
9986,
25230,
1006,
6462,
18442,
1007,
1063,
13075,
6462,
1027,
11287,
1031,
6462,
18442,
1033,
1025,
2065,
1006,
999,
6462,
1007,
1063,
2709,
1025,
1065,
7953,
8758,
1012,
3579,
1006,
1007,
1025,
13075,
4957,
10050,
26860,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/RecentProjects/main.js | getRecentProjects | function getRecentProjects() {
var recentProjects = PreferencesManager.getViewState("recentProjects") || [],
i;
for (i = 0; i < recentProjects.length; i++) {
// We have to canonicalize & then de-canonicalize the path here, since our pref format uses no trailing "/"
recentProjects[i] = FileUtils.stripTrailingSlash(ProjectManager.updateWelcomeProjectPath(recentProjects[i] + "/"));
}
return recentProjects;
} | javascript | function getRecentProjects() {
var recentProjects = PreferencesManager.getViewState("recentProjects") || [],
i;
for (i = 0; i < recentProjects.length; i++) {
// We have to canonicalize & then de-canonicalize the path here, since our pref format uses no trailing "/"
recentProjects[i] = FileUtils.stripTrailingSlash(ProjectManager.updateWelcomeProjectPath(recentProjects[i] + "/"));
}
return recentProjects;
} | [
"function",
"getRecentProjects",
"(",
")",
"{",
"var",
"recentProjects",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"\"recentProjects\"",
")",
"||",
"[",
"]",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"recentProjects",
".",
"length... | Get the stored list of recent projects, fixing up paths as appropriate.
Warning: unlike most paths in Brackets, these lack a trailing "/" | [
"Get",
"the",
"stored",
"list",
"of",
"recent",
"projects",
"fixing",
"up",
"paths",
"as",
"appropriate",
".",
"Warning",
":",
"unlike",
"most",
"paths",
"in",
"Brackets",
"these",
"lack",
"a",
"trailing",
"/"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RecentProjects/main.js#L64-L73 | train | Get the list of recent projects | [
30522,
3853,
30524,
20614,
2015,
1006,
1007,
1063,
13075,
3522,
21572,
20614,
2015,
1027,
18394,
24805,
4590,
1012,
2131,
8584,
9153,
2618,
1006,
1000,
3522,
21572,
20614,
2015,
1000,
1007,
1064,
1064,
1031,
1033,
1010,
1045,
1025,
2005,
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... |
getsentry/sentry-javascript | packages/raven-node/lib/utils.js | snipLine | function snipLine(line, colno) {
var ll = line.length;
if (ll <= 150) return line;
if (colno > ll) colno = ll;
var start = Math.max(colno - 60, 0);
if (start < 5) start = 0;
var end = Math.min(start + 140, ll);
if (end > ll - 5) end = ll;
if (end === ll) start = Math.max(end - 140, 0);
line = line.slice(start, end);
if (start > 0) line = '{snip} ' + line;
if (end < ll) line += ' {snip}';
return line;
} | javascript | function snipLine(line, colno) {
var ll = line.length;
if (ll <= 150) return line;
if (colno > ll) colno = ll;
var start = Math.max(colno - 60, 0);
if (start < 5) start = 0;
var end = Math.min(start + 140, ll);
if (end > ll - 5) end = ll;
if (end === ll) start = Math.max(end - 140, 0);
line = line.slice(start, end);
if (start > 0) line = '{snip} ' + line;
if (end < ll) line += ' {snip}';
return line;
} | [
"function",
"snipLine",
"(",
"line",
",",
"colno",
")",
"{",
"var",
"ll",
"=",
"line",
".",
"length",
";",
"if",
"(",
"ll",
"<=",
"150",
")",
"return",
"line",
";",
"if",
"(",
"colno",
">",
"ll",
")",
"colno",
"=",
"ll",
";",
"var",
"start",
"=... | This is basically just `trim_line` from https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67 | [
"This",
"is",
"basically",
"just",
"trim_line",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"getsentry",
"/",
"sentry",
"/",
"blob",
"/",
"master",
"/",
"src",
"/",
"sentry",
"/",
"lang",
"/",
"javascript",
"/",
"processor",
".",
"py#L67"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-node/lib/utils.js#L297-L314 | train | snip line | [
30522,
3853,
1055,
3490,
28296,
2063,
1006,
2240,
1010,
8902,
3630,
1007,
1063,
13075,
2222,
1027,
2240,
1012,
3091,
1025,
2065,
1006,
2222,
1026,
1027,
5018,
1007,
2709,
2240,
1025,
2065,
1006,
8902,
3630,
1028,
2222,
1007,
8902,
3630,
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/blanket.js | parseArguments | function parseArguments() {
var args = [];
expect('(');
if (!match(')')) {
while (index < length) {
args.push(parseAssignmentExpression());
if (match(')')) {
break;
}
expect(',');
}
}
expect(')');
return args;
} | javascript | function parseArguments() {
var args = [];
expect('(');
if (!match(')')) {
while (index < length) {
args.push(parseAssignmentExpression());
if (match(')')) {
break;
}
expect(',');
}
}
expect(')');
return args;
} | [
"function",
"parseArguments",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"expect",
"(",
"'('",
")",
";",
"if",
"(",
"!",
"match",
"(",
"')'",
")",
")",
"{",
"while",
"(",
"index",
"<",
"length",
")",
"{",
"args",
".",
"push",
"(",
"parse... | 11.2 Left-Hand-Side Expressions | [
"11",
".",
"2",
"Left",
"-",
"Hand",
"-",
"Side",
"Expressions"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2210-L2228 | train | Parses the arguments of an operation. | [
30522,
3853,
11968,
17310,
10623,
27417,
3215,
1006,
1007,
1063,
13075,
12098,
5620,
1027,
1031,
1033,
1025,
5987,
1006,
1005,
1006,
1005,
1007,
1025,
2065,
1006,
999,
2674,
1006,
1005,
1007,
1005,
1007,
1007,
1063,
2096,
1006,
5950,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/software-update.js | softwareUpdate_closeDialog | function softwareUpdate_closeDialog() {
if (this._controller) {
this._controller.keypress(null, "VK_ESCAPE", {});
this._controller.sleep(500);
this._controller = null;
this._wizard = null;
}
} | javascript | function softwareUpdate_closeDialog() {
if (this._controller) {
this._controller.keypress(null, "VK_ESCAPE", {});
this._controller.sleep(500);
this._controller = null;
this._wizard = null;
}
} | [
"function",
"softwareUpdate_closeDialog",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_controller",
")",
"{",
"this",
".",
"_controller",
".",
"keypress",
"(",
"null",
",",
"\"VK_ESCAPE\"",
",",
"{",
"}",
")",
";",
"this",
".",
"_controller",
".",
"sleep",
"... | Close the software update dialog | [
"Close",
"the",
"software",
"update",
"dialog"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/software-update.js#L267-L274 | train | Close software update dialog | [
30522,
3853,
4007,
6279,
13701,
1035,
2701,
4818,
8649,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
11486,
1007,
1063,
2023,
1012,
1035,
11486,
1012,
3145,
20110,
1006,
19701,
1010,
1000,
1058,
2243,
1035,
4019,
1000,
1010,
1063,
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/search/ScrollTrackMarkers.js | addTickmarks | function addTickmarks(curEditor, posArray) {
console.assert(editor === curEditor);
marks = marks.concat(posArray);
_renderMarks(posArray);
} | javascript | function addTickmarks(curEditor, posArray) {
console.assert(editor === curEditor);
marks = marks.concat(posArray);
_renderMarks(posArray);
} | [
"function",
"addTickmarks",
"(",
"curEditor",
",",
"posArray",
")",
"{",
"console",
".",
"assert",
"(",
"editor",
"===",
"curEditor",
")",
";",
"marks",
"=",
"marks",
".",
"concat",
"(",
"posArray",
")",
";",
"_renderMarks",
"(",
"posArray",
")",
";",
"}... | Add tickmarks to the editor's tickmark track, if it's visible
@param curEditor {!Editor}
@param posArray {!Array.<{line:Number, ch:Number}>} | [
"Add",
"tickmarks",
"to",
"the",
"editor",
"s",
"tickmark",
"track",
"if",
"it",
"s",
"visible"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/ScrollTrackMarkers.js#L217-L222 | train | Add tickmarks to the current language | [
30522,
3853,
5587,
26348,
27373,
1006,
21391,
15660,
1010,
13433,
10286,
9447,
1007,
1063,
10122,
1012,
20865,
1006,
3559,
1027,
1027,
1027,
21391,
15660,
1007,
1025,
6017,
1027,
6017,
1012,
9530,
11266,
1006,
13433,
10286,
9447,
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... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js | function () {
var tempRules = Storage.getRules(),
loadingFromAdditionalRuleSets = this.model.getProperty("/loadingAdditionalRuleSets");
if (tempRules && !loadingFromAdditionalRuleSets && !this.tempRulesLoaded) {
this.tempRulesFromStorage = tempRules;
this.tempRulesLoaded = true;
tempRules.forEach(function (tempRule) {
CommunicationBus.publish(channelNames.VERIFY_CREATE_RULE, RuleSerializer.serialize(tempRule));
});
this.persistedTempRulesCount = tempRules.length;
}
} | javascript | function () {
var tempRules = Storage.getRules(),
loadingFromAdditionalRuleSets = this.model.getProperty("/loadingAdditionalRuleSets");
if (tempRules && !loadingFromAdditionalRuleSets && !this.tempRulesLoaded) {
this.tempRulesFromStorage = tempRules;
this.tempRulesLoaded = true;
tempRules.forEach(function (tempRule) {
CommunicationBus.publish(channelNames.VERIFY_CREATE_RULE, RuleSerializer.serialize(tempRule));
});
this.persistedTempRulesCount = tempRules.length;
}
} | [
"function",
"(",
")",
"{",
"var",
"tempRules",
"=",
"Storage",
".",
"getRules",
"(",
")",
",",
"loadingFromAdditionalRuleSets",
"=",
"this",
".",
"model",
".",
"getProperty",
"(",
"\"/loadingAdditionalRuleSets\"",
")",
";",
"if",
"(",
"tempRules",
"&&",
"!",
... | Loads temporary rules from the local storage | [
"Loads",
"temporary",
"rules",
"from",
"the",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L725-L739 | train | This function is called when the model is loaded | [
30522,
3853,
1006,
1007,
1063,
13075,
8915,
8737,
6820,
4244,
1027,
5527,
1012,
2131,
6820,
4244,
1006,
1007,
1010,
10578,
19699,
9626,
14141,
22753,
2389,
6820,
24527,
3215,
1027,
2023,
1012,
2944,
1012,
2131,
21572,
4842,
3723,
1006,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/tabs/js/tabsController.js | fixOffset | function fixOffset (value) {
var elements = getElements();
if (!elements.tabs.length || !ctrl.shouldPaginate) return 0;
var lastTab = elements.tabs[ elements.tabs.length - 1 ],
totalWidth = lastTab.offsetLeft + lastTab.offsetWidth;
if (isRtl()) {
value = Math.min(elements.paging.offsetWidth - elements.canvas.clientWidth, value);
value = Math.max(0, value);
} else {
value = Math.max(0, value);
value = Math.min(totalWidth - elements.canvas.clientWidth, value);
}
return value;
} | javascript | function fixOffset (value) {
var elements = getElements();
if (!elements.tabs.length || !ctrl.shouldPaginate) return 0;
var lastTab = elements.tabs[ elements.tabs.length - 1 ],
totalWidth = lastTab.offsetLeft + lastTab.offsetWidth;
if (isRtl()) {
value = Math.min(elements.paging.offsetWidth - elements.canvas.clientWidth, value);
value = Math.max(0, value);
} else {
value = Math.max(0, value);
value = Math.min(totalWidth - elements.canvas.clientWidth, value);
}
return value;
} | [
"function",
"fixOffset",
"(",
"value",
")",
"{",
"var",
"elements",
"=",
"getElements",
"(",
")",
";",
"if",
"(",
"!",
"elements",
".",
"tabs",
".",
"length",
"||",
"!",
"ctrl",
".",
"shouldPaginate",
")",
"return",
"0",
";",
"var",
"lastTab",
"=",
"... | Takes an offset value and makes sure that it is within the min/max allowed values.
@param {number} value
@returns {number} | [
"Takes",
"an",
"offset",
"value",
"and",
"makes",
"sure",
"that",
"it",
"is",
"within",
"the",
"min",
"/",
"max",
"allowed",
"values",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L923-L940 | train | fix offset for the last tab | [
30522,
3853,
8081,
27475,
3388,
1006,
3643,
1007,
1063,
13075,
3787,
1027,
2131,
12260,
8163,
1006,
1007,
1025,
2065,
1006,
999,
3787,
1012,
21628,
2015,
1012,
3091,
1064,
1064,
999,
14931,
12190,
1012,
2323,
4502,
20876,
2618,
1007,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js | onSubmit | function onSubmit(vRequest) {
if (Array.isArray(vRequest)) {
vRequest.forEach(onSubmit);
} else if (vRequest.$submit) {
vRequest.$submit();
}
} | javascript | function onSubmit(vRequest) {
if (Array.isArray(vRequest)) {
vRequest.forEach(onSubmit);
} else if (vRequest.$submit) {
vRequest.$submit();
}
} | [
"function",
"onSubmit",
"(",
"vRequest",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"vRequest",
")",
")",
"{",
"vRequest",
".",
"forEach",
"(",
"onSubmit",
")",
";",
"}",
"else",
"if",
"(",
"vRequest",
".",
"$submit",
")",
"{",
"vRequest",
".... | /*
(Recursively) calls $submit on the request(s)
@param {object|object[]} vRequest | [
"/",
"*",
"(",
"Recursively",
")",
"calls",
"$submit",
"on",
"the",
"request",
"(",
"s",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L1371-L1377 | train | Submit the request | [
30522,
3853,
2006,
6342,
25526,
4183,
1006,
27830,
2063,
15500,
1007,
1063,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
27830,
2063,
15500,
1007,
1007,
1063,
27830,
2063,
15500,
1012,
18921,
6776,
1006,
2006,
6342,
25526,
4183,
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/core/routing/TargetCache.js | function (oOptions, sType) {
var oObject;
try {
if (sType === "Component" && !this.async) {
Log.error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async");
throw new Error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async");
}
if (!oOptions) {
Log.error("the oOptions parameter of getObject is mandatory", this);
throw new Error("the oOptions parameter of getObject is mandatory");
}
oObject = this._get(oOptions, sType);
} catch (e) {
return Promise.reject(e);
}
if (oObject instanceof Promise) {
return oObject;
} else if (oObject.isA("sap.ui.core.mvc.View")) {
return oObject.loaded();
} else {
return Promise.resolve(oObject);
}
} | javascript | function (oOptions, sType) {
var oObject;
try {
if (sType === "Component" && !this.async) {
Log.error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async");
throw new Error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async");
}
if (!oOptions) {
Log.error("the oOptions parameter of getObject is mandatory", this);
throw new Error("the oOptions parameter of getObject is mandatory");
}
oObject = this._get(oOptions, sType);
} catch (e) {
return Promise.reject(e);
}
if (oObject instanceof Promise) {
return oObject;
} else if (oObject.isA("sap.ui.core.mvc.View")) {
return oObject.loaded();
} else {
return Promise.resolve(oObject);
}
} | [
"function",
"(",
"oOptions",
",",
"sType",
")",
"{",
"var",
"oObject",
";",
"try",
"{",
"if",
"(",
"sType",
"===",
"\"Component\"",
"&&",
"!",
"this",
".",
"async",
")",
"{",
"Log",
".",
"error",
"(",
"\"sap.ui.core.routing.Target doesn't support loading compo... | Returns a cached view or component, for a given name. If it does not exist yet, it will create the view or component with the provided options.
If you provide a "id" in the "oOptions", it will be prefixed with the id of the component.
@param {object} oOptions see {@link sap.ui.core.mvc.View.create} or {@link sap.ui.core.Component.create} for the documentation.
@param {string} oOptions.name If you do not use setView please see {@link sap.ui.core.mvc.View.create} or {@link sap.ui.core.Component.create} for the documentation.
This is used as a key in the cache of the view or component instance. If you want to retrieve a view or a component that has been given an alternative name in {@link #set},
you need to provide the same name here and you can skip all the other options.
@param {string} [oOptions.id] The id you pass into the options will be prefixed with the id of the component you pass into the constructor.
So you can retrieve the view later by calling the {@link sap.ui.core.UIComponent#byId} function of the UIComponent.
@param {string} sType whether the object is a "View" or "Component". Views and components are stored separately in the cache. This means that a view and a component instance
could be stored under the same name.
@return {Promise} A promise that is resolved when the view or component is loaded. The view or component instance will be passed to the resolve function.
@private | [
"Returns",
"a",
"cached",
"view",
"or",
"component",
"for",
"a",
"given",
"name",
".",
"If",
"it",
"does",
"not",
"exist",
"yet",
"it",
"will",
"create",
"the",
"view",
"or",
"component",
"with",
"the",
"provided",
"options",
".",
"If",
"you",
"provide",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/TargetCache.js#L91-L117 | train | Returns the object of the given type | [
30522,
3853,
1006,
1051,
7361,
9285,
1010,
2358,
18863,
1007,
1063,
13075,
1051,
16429,
20614,
1025,
3046,
1063,
2065,
1006,
2358,
18863,
1027,
1027,
1027,
1000,
6922,
1000,
1004,
1004,
999,
2023,
1012,
2004,
6038,
2278,
1007,
1063,
8833,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(sPropertyName, aValues) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot add filter condition for unknown property name " + sPropertyName; // TODO
}
var aFilterablePropertyNames = this._oEntityType.getFilterablePropertyNames();
if (((aFilterablePropertyNames ? Array.prototype.indexOf.call(aFilterablePropertyNames, sPropertyName) : -1)) === -1) {
throw "Cannot add filter condition for not filterable property name " + sPropertyName; // TODO
}
for ( var i = -1, oValue; (oValue = aValues[++i]) !== undefined;) {
this._addCondition(sPropertyName, FilterOperator.EQ, oValue);
}
return this;
} | javascript | function(sPropertyName, aValues) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot add filter condition for unknown property name " + sPropertyName; // TODO
}
var aFilterablePropertyNames = this._oEntityType.getFilterablePropertyNames();
if (((aFilterablePropertyNames ? Array.prototype.indexOf.call(aFilterablePropertyNames, sPropertyName) : -1)) === -1) {
throw "Cannot add filter condition for not filterable property name " + sPropertyName; // TODO
}
for ( var i = -1, oValue; (oValue = aValues[++i]) !== undefined;) {
this._addCondition(sPropertyName, FilterOperator.EQ, oValue);
}
return this;
} | [
"function",
"(",
"sPropertyName",
",",
"aValues",
")",
"{",
"var",
"oProperty",
"=",
"this",
".",
"_oEntityType",
".",
"findPropertyByName",
"(",
"sPropertyName",
")",
";",
"if",
"(",
"oProperty",
"==",
"null",
")",
"{",
"throw",
"\"Cannot add filter condition f... | Add a set condition to the filter expression.
A set condition tests if the value of a property is included in a set of given values. It is a convenience method for
this particular use case eliminating the need for multiple API calls.
@param {string}
sPropertyName The name of the property bound in the condition
@param {array}
aValues values defining the set
@throws Exception
if the property is unknown or not filterable
@returns {sap.ui.model.analytics.odata4analytics.FilterExpression} This object for method chaining
@public
@function
@name sap.ui.model.analytics.odata4analytics.FilterExpression#addSetCondition | [
"Add",
"a",
"set",
"condition",
"to",
"the",
"filter",
"expression",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3211-L3224 | train | Adds a condition to the filter expression. | [
30522,
3853,
1006,
11867,
18981,
15010,
18442,
1010,
10927,
7630,
2229,
1007,
1063,
13075,
6728,
18981,
15010,
1027,
2023,
1012,
1035,
1051,
4765,
3012,
13874,
1012,
2424,
21572,
4842,
3723,
3762,
18442,
1006,
11867,
18981,
15010,
18442,
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... | |
airyland/vux | src/components/orientation/orientation.js | function (fn, after) {
if (typeof fn === FUNCTION) {
this._subs[after ? AFTER : ON].push(fn)
}
return this
} | javascript | function (fn, after) {
if (typeof fn === FUNCTION) {
this._subs[after ? AFTER : ON].push(fn)
}
return this
} | [
"function",
"(",
"fn",
",",
"after",
")",
"{",
"if",
"(",
"typeof",
"fn",
"===",
"FUNCTION",
")",
"{",
"this",
".",
"_subs",
"[",
"after",
"?",
"AFTER",
":",
"ON",
"]",
".",
"push",
"(",
"fn",
")",
"}",
"return",
"this",
"}"
] | 添加change事件
@method change
@param {Function} fn 回调函数
@param {Boolean} after 时候绑定after事件
@chainable | [
"添加change事件"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/orientation/orientation.js#L166-L172 | train | Add a function to the sequence | [
30522,
3853,
1006,
1042,
2078,
1010,
2044,
1007,
1063,
2065,
1006,
2828,
11253,
1042,
2078,
1027,
1027,
1027,
3853,
1007,
1063,
2023,
1012,
1035,
4942,
2015,
1031,
2044,
1029,
2044,
1024,
2006,
1033,
1012,
5245,
1006,
1042,
2078,
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... | |
adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | updateInViewport | function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
} | javascript | function updateInViewport(cm, from, to) {
var vp = cm.getViewport(), state = cm.state.foldGutter;
from = isNaN(from) ? vp.from : from;
to = isNaN(to) ? vp.to : to;
if (!state) { return; }
cm.operation(function () {
updateFoldInfo(cm, from, to);
});
state.from = from;
state.to = to;
} | [
"function",
"updateInViewport",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
",",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"from",
"=",
"isNaN",
"(",
"from",
")",
"?",
"vp",
"... | Updates the fold information in the viewport for the specified range
@param {CodeMirror} cm the instance of the CodeMirror object
@param {?number} from the starting line number for the update
@param {?number} to the end line number for the update | [
"Updates",
"the",
"fold",
"information",
"in",
"the",
"viewport",
"for",
"the",
"specified",
"range"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L130-L141 | train | Update the fold gutter in the viewport | [
30522,
3853,
10651,
2378,
8584,
6442,
1006,
4642,
1010,
2013,
1010,
2000,
1007,
1063,
13075,
21210,
1027,
4642,
1012,
2131,
8584,
6442,
1006,
1007,
1010,
2110,
1027,
4642,
1012,
2110,
1012,
10671,
27920,
3334,
1025,
2013,
1027,
3475,
2319,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.