repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SAP/openui5 | src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js | process | function process (oObject, oTranslator, iCurrentLevel, iMaxLevel, oParams) {
if (iCurrentLevel === iMaxLevel) {
return;
}
if (Array.isArray(oObject)) {
oObject.forEach(function (vItem, iIndex, aArray) {
if (typeof vItem === "object") {
process(vItem, oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(vItem, oObject, oParams)) {
aArray[iIndex] = processPlaceholder(vItem, oParams);
} else if (isTranslatable(vItem) && oTranslator) {
aArray[iIndex] = oTranslator.getText(vItem.substring(2, vItem.length - 2));
}
}, this);
} else {
for (var sProp in oObject) {
if (typeof oObject[sProp] === "object") {
process(oObject[sProp], oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(oObject[sProp], oObject, oParams)) {
oObject[sProp] = processPlaceholder(oObject[sProp], oParams);
} else if (isTranslatable(oObject[sProp]) && oTranslator) {
oObject[sProp] = oTranslator.getText(oObject[sProp].substring(2, oObject[sProp].length - 2));
}
}
}
} | javascript | function process (oObject, oTranslator, iCurrentLevel, iMaxLevel, oParams) {
if (iCurrentLevel === iMaxLevel) {
return;
}
if (Array.isArray(oObject)) {
oObject.forEach(function (vItem, iIndex, aArray) {
if (typeof vItem === "object") {
process(vItem, oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(vItem, oObject, oParams)) {
aArray[iIndex] = processPlaceholder(vItem, oParams);
} else if (isTranslatable(vItem) && oTranslator) {
aArray[iIndex] = oTranslator.getText(vItem.substring(2, vItem.length - 2));
}
}, this);
} else {
for (var sProp in oObject) {
if (typeof oObject[sProp] === "object") {
process(oObject[sProp], oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(oObject[sProp], oObject, oParams)) {
oObject[sProp] = processPlaceholder(oObject[sProp], oParams);
} else if (isTranslatable(oObject[sProp]) && oTranslator) {
oObject[sProp] = oTranslator.getText(oObject[sProp].substring(2, oObject[sProp].length - 2));
}
}
}
} | [
"function",
"process",
"(",
"oObject",
",",
"oTranslator",
",",
"iCurrentLevel",
",",
"iMaxLevel",
",",
"oParams",
")",
"{",
"if",
"(",
"iCurrentLevel",
"===",
"iMaxLevel",
")",
"{",
"return",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"oObject",
... | Process a manifest.
@private
@param {Object} oObject The Manifest to process.
@param {Object} oTranslator The translator.
@param {number} iCurrentLevel The current level of recursion.
@param {number} iMaxLevel The maximum level of recursion.
@param {Object} oParams The parameters to be replaced in the manifest. | [
"Process",
"a",
"manifest",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js#L235-L261 | train | Process an object | [
30522,
3853,
2832,
1006,
1051,
16429,
20614,
1010,
27178,
5521,
14540,
8844,
1010,
24582,
29264,
20414,
2884,
1010,
10047,
8528,
20414,
2884,
1010,
6728,
5400,
5244,
1007,
1063,
2065,
1006,
24582,
29264,
20414,
2884,
1027,
1027,
1027,
10047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/sound.js | function () {
var el = this.el;
var i;
var sceneEl = el.sceneEl;
var self = this;
var sound;
if (this.pool.children.length > 0) {
this.stopSound();
el.removeObject3D('sound');
}
// Only want one AudioListener. Cache it on the scene.
var listener = this.listener = sceneEl.audioListener || new THREE.AudioListener();
sceneEl.audioListener = listener;
if (sceneEl.camera) {
sceneEl.camera.add(listener);
}
// Wait for camera if necessary.
sceneEl.addEventListener('camera-set-active', function (evt) {
evt.detail.cameraEl.getObject3D('camera').add(listener);
});
// Create [poolSize] audio instances and attach them to pool
this.pool = new THREE.Group();
for (i = 0; i < this.data.poolSize; i++) {
sound = this.data.positional
? new THREE.PositionalAudio(listener)
: new THREE.Audio(listener);
this.pool.add(sound);
}
el.setObject3D(this.attrName, this.pool);
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
sound.onEnded = function () {
this.isPlaying = false;
self.el.emit('sound-ended', self.evtDetail, false);
};
}
} | javascript | function () {
var el = this.el;
var i;
var sceneEl = el.sceneEl;
var self = this;
var sound;
if (this.pool.children.length > 0) {
this.stopSound();
el.removeObject3D('sound');
}
// Only want one AudioListener. Cache it on the scene.
var listener = this.listener = sceneEl.audioListener || new THREE.AudioListener();
sceneEl.audioListener = listener;
if (sceneEl.camera) {
sceneEl.camera.add(listener);
}
// Wait for camera if necessary.
sceneEl.addEventListener('camera-set-active', function (evt) {
evt.detail.cameraEl.getObject3D('camera').add(listener);
});
// Create [poolSize] audio instances and attach them to pool
this.pool = new THREE.Group();
for (i = 0; i < this.data.poolSize; i++) {
sound = this.data.positional
? new THREE.PositionalAudio(listener)
: new THREE.Audio(listener);
this.pool.add(sound);
}
el.setObject3D(this.attrName, this.pool);
for (i = 0; i < this.pool.children.length; i++) {
sound = this.pool.children[i];
sound.onEnded = function () {
this.isPlaying = false;
self.el.emit('sound-ended', self.evtDetail, false);
};
}
} | [
"function",
"(",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"i",
";",
"var",
"sceneEl",
"=",
"el",
".",
"sceneEl",
";",
"var",
"self",
"=",
"this",
";",
"var",
"sound",
";",
"if",
"(",
"this",
".",
"pool",
".",
"children",
".",
... | Removes current sound object, creates new sound object, adds to entity.
@returns {object} sound | [
"Removes",
"current",
"sound",
"object",
"creates",
"new",
"sound",
"object",
"adds",
"to",
"entity",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/sound.js#L138-L180 | train | Creates the sound and attaches it to the scene | [
30522,
3853,
1006,
1007,
1063,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
1045,
1025,
13075,
3496,
2884,
1027,
3449,
1012,
3496,
2884,
1025,
13075,
2969,
1027,
2023,
1025,
13075,
2614,
1025,
2065,
1006,
2023,
1012,
4770,
1012,
2336,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(sStyle, sCalendarType) {
assert(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
return this._get(getCLDRCalendarName(sCalendarType), "dateFormats", sStyle);
} | javascript | function(sStyle, sCalendarType) {
assert(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
return this._get(getCLDRCalendarName(sCalendarType), "dateFormats", sStyle);
} | [
"function",
"(",
"sStyle",
",",
"sCalendarType",
")",
"{",
"assert",
"(",
"sStyle",
"==",
"\"short\"",
"||",
"sStyle",
"==",
"\"medium\"",
"||",
"sStyle",
"==",
"\"long\"",
"||",
"sStyle",
"==",
"\"full\"",
",",
"\"sStyle must be short, medium, long or full\"",
")... | Get date pattern in format "short", "medium", "long" or "full".
@param {string} sStyle the required style for the date pattern
@param {sap.ui.core.CalendarType} [sCalendarType] the type of calendar. If it's not set, it falls back to the calendar type either set in configuration or calculated from locale.
@returns {string} the selected date pattern
@public | [
"Get",
"date",
"pattern",
"in",
"format",
"short",
"medium",
"long",
"or",
"full",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L207-L210 | train | Get the date format for the specified calendar type | [
30522,
3853,
1006,
7020,
27983,
1010,
4094,
8943,
5339,
18863,
1007,
1063,
20865,
1006,
7020,
27983,
1027,
1027,
1000,
2460,
1000,
30524,
5396,
1000,
1064,
1064,
7020,
27983,
1027,
1027,
1000,
2146,
1000,
1064,
1064,
7020,
27983,
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... | |
naptha/tesseract.js | src/common/dump.js | deindent | function deindent(html){
var lines = html.split('\n')
if(lines[0].substring(0, 2) === " "){
for (var i = 0; i < lines.length; i++) {
if (lines[i].substring(0,2) === " ") {
lines[i] = lines[i].slice(2)
}
};
}
return lines.join('\n')
} | javascript | function deindent(html){
var lines = html.split('\n')
if(lines[0].substring(0, 2) === " "){
for (var i = 0; i < lines.length; i++) {
if (lines[i].substring(0,2) === " ") {
lines[i] = lines[i].slice(2)
}
};
}
return lines.join('\n')
} | [
"function",
"deindent",
"(",
"html",
")",
"{",
"var",
"lines",
"=",
"html",
".",
"split",
"(",
"'\\n'",
")",
"if",
"(",
"lines",
"[",
"0",
"]",
".",
"substring",
"(",
"0",
",",
"2",
")",
"===",
"\" \"",
")",
"{",
"for",
"(",
"var",
"i",
"=",
... | the generated HOCR is excessively indented, so we get rid of that indentation | [
"the",
"generated",
"HOCR",
"is",
"excessively",
"indented",
"so",
"we",
"get",
"rid",
"of",
"that",
"indentation"
] | 613a19c7e1b61f26014dd3310fca5391423dd65d | https://github.com/naptha/tesseract.js/blob/613a19c7e1b61f26014dd3310fca5391423dd65d/src/common/dump.js#L154-L164 | train | Deindent the given HTML | [
30522,
3853,
14866,
25915,
2102,
1006,
16129,
1007,
1063,
13075,
3210,
1027,
16129,
1012,
3975,
1006,
1005,
1032,
1050,
1005,
1007,
2065,
1006,
3210,
1031,
1014,
1033,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
1016,
1007,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataModel.js | addMessage | function addMessage(oMessage) {
var oReportMessage = {
code : oMessage.code,
message : oMessage.message,
technical : oMessage.technical
};
Object.keys(oMessage).forEach(function (sProperty) {
if (sProperty[0] === '@') {
if (sProperty.endsWith(".numericSeverity")) {
oReportMessage.numericSeverity = oMessage[sProperty];
} else if (sProperty.endsWith(".longtextUrl") && oError.requestUrl
&& sResourcePath) {
oReportMessage.longtextUrl =
_Helper.makeAbsolute(oMessage[sProperty], oError.requestUrl);
}
}
});
if (typeof oMessage.target !== "string") {
aUnboundMessages.push(oReportMessage);
} else if (oMessage.target[0] === "$" || !sResourcePath) {
// target for the bound message cannot be resolved -> report as unbound message
oReportMessage.message = oMessage.target + ": " + oReportMessage.message;
aUnboundMessages.push(oReportMessage);
} else {
oReportMessage.target = oMessage.target;
oReportMessage.transition = true;
aBoundMessages.push(oReportMessage);
}
} | javascript | function addMessage(oMessage) {
var oReportMessage = {
code : oMessage.code,
message : oMessage.message,
technical : oMessage.technical
};
Object.keys(oMessage).forEach(function (sProperty) {
if (sProperty[0] === '@') {
if (sProperty.endsWith(".numericSeverity")) {
oReportMessage.numericSeverity = oMessage[sProperty];
} else if (sProperty.endsWith(".longtextUrl") && oError.requestUrl
&& sResourcePath) {
oReportMessage.longtextUrl =
_Helper.makeAbsolute(oMessage[sProperty], oError.requestUrl);
}
}
});
if (typeof oMessage.target !== "string") {
aUnboundMessages.push(oReportMessage);
} else if (oMessage.target[0] === "$" || !sResourcePath) {
// target for the bound message cannot be resolved -> report as unbound message
oReportMessage.message = oMessage.target + ": " + oReportMessage.message;
aUnboundMessages.push(oReportMessage);
} else {
oReportMessage.target = oMessage.target;
oReportMessage.transition = true;
aBoundMessages.push(oReportMessage);
}
} | [
"function",
"addMessage",
"(",
"oMessage",
")",
"{",
"var",
"oReportMessage",
"=",
"{",
"code",
":",
"oMessage",
".",
"code",
",",
"message",
":",
"oMessage",
".",
"message",
",",
"technical",
":",
"oMessage",
".",
"technical",
"}",
";",
"Object",
".",
"... | /*
Clones the message object taking all relevant properties, converts the annotations for
numeric severity and longtext to the corresponding properties and adds it to one of the
arrays to be reported later.
@param {object} oMessage The message | [
"/",
"*",
"Clones",
"the",
"message",
"object",
"taking",
"all",
"relevant",
"properties",
"converts",
"the",
"annotations",
"for",
"numeric",
"severity",
"and",
"longtext",
"to",
"the",
"corresponding",
"properties",
"and",
"adds",
"it",
"to",
"one",
"of",
"t... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataModel.js#L1410-L1440 | train | Adds a message to the report | [
30522,
3853,
5587,
7834,
3736,
3351,
1006,
18168,
7971,
4270,
1007,
1063,
13075,
10848,
6442,
7834,
3736,
3351,
1027,
1063,
3642,
1024,
18168,
7971,
4270,
1012,
3642,
1010,
4471,
1024,
18168,
7971,
4270,
1012,
4471,
1010,
4087,
1024,
18168,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/utils/path.js | isInRoot | function isInRoot(root, filename) {
root = path.normalize(root);
filename = path.normalize(filename);
if (root === '.') {
return true;
}
if (root[root.length - 1] != path.sep) {
root = root + path.sep;
}
return (filename.substr(0, root.length) === root);
} | javascript | function isInRoot(root, filename) {
root = path.normalize(root);
filename = path.normalize(filename);
if (root === '.') {
return true;
}
if (root[root.length - 1] != path.sep) {
root = root + path.sep;
}
return (filename.substr(0, root.length) === root);
} | [
"function",
"isInRoot",
"(",
"root",
",",
"filename",
")",
"{",
"root",
"=",
"path",
".",
"normalize",
"(",
"root",
")",
";",
"filename",
"=",
"path",
".",
"normalize",
"(",
"filename",
")",
";",
"if",
"(",
"root",
"===",
"'.'",
")",
"{",
"return",
... | Return true if file path is inside a folder | [
"Return",
"true",
"if",
"file",
"path",
"is",
"inside",
"a",
"folder"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/path.js#L10-L22 | train | Check if the filename is in the root directory | [
30522,
3853,
2003,
2378,
3217,
4140,
1006,
7117,
1010,
5371,
18442,
1007,
1063,
7117,
1027,
4130,
1012,
3671,
4697,
1006,
7117,
1007,
1025,
5371,
18442,
1027,
4130,
1012,
3671,
4697,
1006,
5371,
18442,
1007,
1025,
2065,
1006,
7117,
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... |
angular/material | src/core/services/layout/layout.js | validateAttributeValue | function validateAttributeValue(className, value, updateFn) {
var origValue;
if (!needsInterpolation(value)) {
switch (className.replace(SUFFIXES,"")) {
case 'layout' :
if (!findIn(value, LAYOUT_OPTIONS)) {
value = LAYOUT_OPTIONS[0]; // 'row';
}
break;
case 'flex' :
if (!findIn(value, FLEX_OPTIONS)) {
if (isNaN(value)) {
value = '';
}
}
break;
case 'flex-offset' :
case 'flex-order' :
if (!value || isNaN(+value)) {
value = '0';
}
break;
case 'layout-align' :
var axis = extractAlignAxis(value);
value = $mdUtil.supplant("{main}-{cross}",axis);
break;
case 'layout-padding' :
case 'layout-margin' :
case 'layout-fill' :
case 'layout-wrap' :
case 'layout-nowrap' :
value = '';
break;
}
if (value != origValue) {
(updateFn || angular.noop)(value);
}
}
return value ? value.trim() : "";
} | javascript | function validateAttributeValue(className, value, updateFn) {
var origValue;
if (!needsInterpolation(value)) {
switch (className.replace(SUFFIXES,"")) {
case 'layout' :
if (!findIn(value, LAYOUT_OPTIONS)) {
value = LAYOUT_OPTIONS[0]; // 'row';
}
break;
case 'flex' :
if (!findIn(value, FLEX_OPTIONS)) {
if (isNaN(value)) {
value = '';
}
}
break;
case 'flex-offset' :
case 'flex-order' :
if (!value || isNaN(+value)) {
value = '0';
}
break;
case 'layout-align' :
var axis = extractAlignAxis(value);
value = $mdUtil.supplant("{main}-{cross}",axis);
break;
case 'layout-padding' :
case 'layout-margin' :
case 'layout-fill' :
case 'layout-wrap' :
case 'layout-nowrap' :
value = '';
break;
}
if (value != origValue) {
(updateFn || angular.noop)(value);
}
}
return value ? value.trim() : "";
} | [
"function",
"validateAttributeValue",
"(",
"className",
",",
"value",
",",
"updateFn",
")",
"{",
"var",
"origValue",
";",
"if",
"(",
"!",
"needsInterpolation",
"(",
"value",
")",
")",
"{",
"switch",
"(",
"className",
".",
"replace",
"(",
"SUFFIXES",
",",
"... | For the Layout attribute value, validate or replace with default
fallback value | [
"For",
"the",
"Layout",
"attribute",
"value",
"validate",
"or",
"replace",
"with",
"default",
"fallback",
"value"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/layout/layout.js#L409-L455 | train | Validate attribute value | [
30522,
3853,
9398,
3686,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
2465,
18442,
1010,
3643,
1010,
10651,
2546,
2078,
1007,
1063,
13075,
2030,
8004,
10175,
5657,
1025,
2065,
1006,
999,
3791,
18447,
2121,
18155,
3370,
1006,
3643,
1007,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable) {
var sSelectionMode = oTable ? oTable.getSelectionMode() : SelectionMode.None;
return sSelectionMode === SelectionMode.MultiToggle && oTable.getEnableSelectAll();
} | javascript | function(oTable) {
var sSelectionMode = oTable ? oTable.getSelectionMode() : SelectionMode.None;
return sSelectionMode === SelectionMode.MultiToggle && oTable.getEnableSelectAll();
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"sSelectionMode",
"=",
"oTable",
"?",
"oTable",
".",
"getSelectionMode",
"(",
")",
":",
"SelectionMode",
".",
"None",
";",
"return",
"sSelectionMode",
"===",
"SelectionMode",
".",
"MultiToggle",
"&&",
"oTable",
".",
... | Returns whether the table has a SelectAll checkbox.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {boolean} Whether the table has a SelectAll checkbox. | [
"Returns",
"whether",
"the",
"table",
"has",
"a",
"SelectAll",
"checkbox",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L246-L249 | train | Returns true if the table has a multi - toggle selection mode. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
7020,
12260,
7542,
5302,
3207,
1027,
27178,
3085,
1029,
27178,
3085,
1012,
4152,
12260,
7542,
5302,
3207,
1006,
1007,
1024,
4989,
5302,
3207,
1012,
3904,
1025,
2709,
7020,
12260,
7542,
5302... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jszip.js | function(reader, from, length, compression, uncompressedSize) {
return function() {
var compressedFileData = utils.transformTo(compression.uncompressInputType, this.getCompressedContent());
var uncompressedFileData = compression.uncompress(compressedFileData);
if (uncompressedFileData.length !== uncompressedSize) {
throw new Error("Bug : uncompressed data size mismatch");
}
return uncompressedFileData;
};
} | javascript | function(reader, from, length, compression, uncompressedSize) {
return function() {
var compressedFileData = utils.transformTo(compression.uncompressInputType, this.getCompressedContent());
var uncompressedFileData = compression.uncompress(compressedFileData);
if (uncompressedFileData.length !== uncompressedSize) {
throw new Error("Bug : uncompressed data size mismatch");
}
return uncompressedFileData;
};
} | [
"function",
"(",
"reader",
",",
"from",
",",
"length",
",",
"compression",
",",
"uncompressedSize",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"compressedFileData",
"=",
"utils",
".",
"transformTo",
"(",
"compression",
".",
"uncompressInputType",
",... | Prepare the function used to generate the uncompressed content from this ZipFile.
@param {DataReader} reader the reader to use.
@param {number} from the offset from where we should read the data.
@param {number} length the length of the data to read.
@param {JSZip.compression} compression the compression used on this file.
@param {number} uncompressedSize the uncompressed size to expect.
@return {Function} the callback to get the uncompressed content (the type depends of the DataReader class). | [
"Prepare",
"the",
"function",
"used",
"to",
"generate",
"the",
"uncompressed",
"content",
"from",
"this",
"ZipFile",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1942-L1954 | train | uncompress the file | [
30522,
3853,
1006,
8068,
1010,
2013,
1010,
3091,
1010,
13379,
1010,
4895,
9006,
19811,
5332,
4371,
1007,
1063,
2709,
3853,
1006,
1007,
1063,
13075,
16620,
8873,
3709,
6790,
1027,
21183,
12146,
1012,
10938,
3406,
1006,
13379,
1012,
4895,
900... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
summernote/summernote | src/js/base/core/dom.js | removeWhile | function removeWhile(node, pred) {
while (node) {
if (isEditable(node) || !pred(node)) {
break;
}
const parent = node.parentNode;
remove(node);
node = parent;
}
} | javascript | function removeWhile(node, pred) {
while (node) {
if (isEditable(node) || !pred(node)) {
break;
}
const parent = node.parentNode;
remove(node);
node = parent;
}
} | [
"function",
"removeWhile",
"(",
"node",
",",
"pred",
")",
"{",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"isEditable",
"(",
"node",
")",
"||",
"!",
"pred",
"(",
"node",
")",
")",
"{",
"break",
";",
"}",
"const",
"parent",
"=",
"node",
".",
"pare... | @method removeWhile
@param {Node} node
@param {Function} pred | [
"@method",
"removeWhile"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L900-L910 | train | Remove nodes from the tree while predicate returns true | [
30522,
3853,
6366,
19927,
1006,
13045,
1010,
3653,
2094,
1007,
1063,
2096,
1006,
13045,
1007,
1063,
2065,
1006,
2003,
2098,
6590,
3468,
1006,
13045,
1007,
1064,
1064,
999,
3653,
2094,
1006,
13045,
1007,
1007,
1063,
3338,
1025,
1065,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js | function (oTree) {
var oResult = {};
oTree.selected = this.isNodeSelected(oTree);
this.setHierarchyNode(oResult, oTree);
return oResult;
} | javascript | function (oTree) {
var oResult = {};
oTree.selected = this.isNodeSelected(oTree);
this.setHierarchyNode(oResult, oTree);
return oResult;
} | [
"function",
"(",
"oTree",
")",
"{",
"var",
"oResult",
"=",
"{",
"}",
";",
"oTree",
".",
"selected",
"=",
"this",
".",
"isNodeSelected",
"(",
"oTree",
")",
";",
"this",
".",
"setHierarchyNode",
"(",
"oResult",
",",
"oTree",
")",
";",
"return",
"oResult"... | Converts a bindable tree back to the module hierarchy structure
@param {object} oTree The tree to be converted
@return {object} The module hierarchy with the current selection state of the UI | [
"Converts",
"a",
"bindable",
"tree",
"back",
"to",
"the",
"module",
"hierarchy",
"structure"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js#L181-L186 | train | Returns an object with the selected state of the hierarchy node | [
30522,
3853,
1006,
27178,
9910,
1007,
1063,
13075,
10848,
23722,
2102,
1027,
1063,
1065,
1025,
27178,
9910,
1012,
3479,
1027,
2023,
1012,
3475,
19847,
12260,
10985,
1006,
27178,
9910,
1007,
1025,
2023,
1012,
6662,
3771,
2906,
11714,
3630,
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... | |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | function( elems, name, selector ) {
// Build a new jQuery matched element set
var ret = this.constructor();
if ( jQuery.isArray( elems ) ) {
push.apply( ret, elems );
} else {
jQuery.merge( ret, elems );
}
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
if ( name === "find" ) {
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
} else if ( name ) {
ret.selector = this.selector + "." + name + "(" + selector + ")";
}
// Return the newly-formed element set
return ret;
} | javascript | function( elems, name, selector ) {
// Build a new jQuery matched element set
var ret = this.constructor();
if ( jQuery.isArray( elems ) ) {
push.apply( ret, elems );
} else {
jQuery.merge( ret, elems );
}
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
if ( name === "find" ) {
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
} else if ( name ) {
ret.selector = this.selector + "." + name + "(" + selector + ")";
}
// Return the newly-formed element set
return ret;
} | [
"function",
"(",
"elems",
",",
"name",
",",
"selector",
")",
"{",
"// Build a new jQuery matched element set",
"var",
"ret",
"=",
"this",
".",
"constructor",
"(",
")",
";",
"if",
"(",
"jQuery",
".",
"isArray",
"(",
"elems",
")",
")",
"{",
"push",
".",
"a... | Take an array of elements and push it onto the stack (returning the new matched element set) | [
"Take",
"an",
"array",
"of",
"elements",
"and",
"push",
"it",
"onto",
"the",
"stack",
"(",
"returning",
"the",
"new",
"matched",
"element",
"set",
")"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L241-L265 | train | Creates a new jQuery matched element | [
30522,
3853,
1006,
3449,
6633,
2015,
1010,
2171,
1010,
27000,
1007,
1063,
1013,
1013,
3857,
1037,
2047,
1046,
4226,
2854,
10349,
5783,
2275,
13075,
2128,
2102,
1027,
2023,
1012,
9570,
2953,
1006,
1007,
1025,
2065,
1006,
1046,
4226,
2854,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
wangfupeng1988/wangEditor | src/js/editor/upload/upload-img.js | function (link) {
if (!link) {
return
}
const editor = this.editor
const config = editor.config
// 校验格式
const linkImgCheck = config.linkImgCheck
let checkResult
if (linkImgCheck && typeof linkImgCheck === 'function') {
checkResult = linkImgCheck(link)
if (typeof checkResult === 'string') {
// 校验失败,提示信息
alert(checkResult)
return
}
}
editor.cmd.do('insertHTML', `<img src="${link}" style="max-width:100%;"/>`)
// 验证图片 url 是否有效,无效的话给出提示
let img = document.createElement('img')
img.onload = () => {
const callback = config.linkImgCallback
if (callback && typeof callback === 'function') {
callback(link)
}
img = null
}
img.onerror = () => {
img = null
// 无法成功下载图片
this._alert('插入图片错误', `wangEditor: 插入图片出错,图片链接是 "${link}",下载该链接失败`)
return
}
img.onabort = () => {
img = null
}
img.src = link
} | javascript | function (link) {
if (!link) {
return
}
const editor = this.editor
const config = editor.config
// 校验格式
const linkImgCheck = config.linkImgCheck
let checkResult
if (linkImgCheck && typeof linkImgCheck === 'function') {
checkResult = linkImgCheck(link)
if (typeof checkResult === 'string') {
// 校验失败,提示信息
alert(checkResult)
return
}
}
editor.cmd.do('insertHTML', `<img src="${link}" style="max-width:100%;"/>`)
// 验证图片 url 是否有效,无效的话给出提示
let img = document.createElement('img')
img.onload = () => {
const callback = config.linkImgCallback
if (callback && typeof callback === 'function') {
callback(link)
}
img = null
}
img.onerror = () => {
img = null
// 无法成功下载图片
this._alert('插入图片错误', `wangEditor: 插入图片出错,图片链接是 "${link}",下载该链接失败`)
return
}
img.onabort = () => {
img = null
}
img.src = link
} | [
"function",
"(",
"link",
")",
"{",
"if",
"(",
"!",
"link",
")",
"{",
"return",
"}",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"config",
"=",
"editor",
".",
"config",
"// 校验格式",
"const",
"linkImgCheck",
"=",
"config",
".",
"linkImgCheck",
... | 根据链接插入图片 | [
"根据链接插入图片"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/editor/upload/upload-img.js#L36-L77 | train | link 是否有效,无法成功下载图片 | [
30522,
3853,
1006,
4957,
1007,
1063,
2065,
1006,
999,
4957,
1007,
1063,
2709,
1065,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
9530,
8873,
2290,
1027,
3559,
1012,
9530,
8873,
2290,
1013,
1013,
100,
100,
100,
100,
9530,
3367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/api/v0.1/users.js | doQuery | function doQuery(options) {
return models.User.findPage(options)
.then(({data, meta}) => {
return {
users: data.map(model => urlsForUser(model.id, model.toJSON(options), options)),
meta: meta
};
});
} | javascript | function doQuery(options) {
return models.User.findPage(options)
.then(({data, meta}) => {
return {
users: data.map(model => urlsForUser(model.id, model.toJSON(options), options)),
meta: meta
};
});
} | [
"function",
"doQuery",
"(",
"options",
")",
"{",
"return",
"models",
".",
"User",
".",
"findPage",
"(",
"options",
")",
".",
"then",
"(",
"(",
"{",
"data",
",",
"meta",
"}",
")",
"=>",
"{",
"return",
"{",
"users",
":",
"data",
".",
"map",
"(",
"m... | ### Model Query
Make the call to the Model layer
@param {Object} options
@returns {Object} options | [
"###",
"Model",
"Query",
"Make",
"the",
"call",
"to",
"the",
"Model",
"layer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/users.js#L39-L47 | train | Query for users | [
30522,
3853,
2079,
4226,
2854,
1006,
7047,
1007,
1063,
2709,
4275,
1012,
5310,
1012,
2424,
13704,
1006,
7047,
1007,
1012,
2059,
1006,
1006,
1063,
30524,
20330,
1006,
2944,
1012,
8909,
1010,
2944,
1012,
2000,
22578,
2239,
1006,
7047,
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... |
thomaspark/bootswatch | docs/_vendor/popper.js/dist/popper.js | applyStyleOnLoad | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
// compute reference element offsets
const referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
// compute auto placement, store placement inside the data object,
// modifiers will be able to edit `placement` if needed
// and refer to originalPlacement to know the original value
const placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
popper.setAttribute('x-placement', placement);
// Apply `position` to popper before anything else because
// without the position applied we can't guarantee correct computations
setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
return options;
} | javascript | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
// compute reference element offsets
const referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
// compute auto placement, store placement inside the data object,
// modifiers will be able to edit `placement` if needed
// and refer to originalPlacement to know the original value
const placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
popper.setAttribute('x-placement', placement);
// Apply `position` to popper before anything else because
// without the position applied we can't guarantee correct computations
setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
return options;
} | [
"function",
"applyStyleOnLoad",
"(",
"reference",
",",
"popper",
",",
"options",
",",
"modifierOptions",
",",
"state",
")",
"{",
"// compute reference element offsets",
"const",
"referenceOffsets",
"=",
"getReferenceOffsets",
"(",
"state",
",",
"popper",
",",
"referen... | Set the x-placement attribute before everything else because it could be used
to add margins to the popper margins needs to be calculated to get the
correct popper offsets.
@method
@memberof Popper.modifiers
@param {HTMLElement} reference - The reference element used to position the popper
@param {HTMLElement} popper - The HTML element used as popper
@param {Object} options - Popper.js options | [
"Set",
"the",
"x",
"-",
"placement",
"attribute",
"before",
"everything",
"else",
"because",
"it",
"could",
"be",
"used",
"to",
"add",
"margins",
"to",
"the",
"popper",
"margins",
"needs",
"to",
"be",
"calculated",
"to",
"get",
"the",
"correct",
"popper",
... | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/_vendor/popper.js/dist/popper.js#L1102-L1118 | train | Apply the style on load to the popper element | [
30522,
3853,
6611,
21756,
2571,
2239,
11066,
1006,
4431,
1010,
3769,
4842,
1010,
7047,
1010,
16913,
18095,
7361,
9285,
1010,
2110,
1007,
1063,
1013,
1013,
24134,
4431,
5783,
16396,
2015,
9530,
3367,
4431,
27475,
8454,
1027,
2131,
2890,
2552... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/IconPool.js | getInfo | function getInfo() {
var collection = mRegistry[collectionName];
var info = collection && collection[iconName];
// convert raw data lazily to the icon info
if (typeof info === 'number') {
mRegistry[collectionName][iconName] = undefined; // avoid duplicate icon warning
info = IconPool.addIcon(iconName, collectionName, {
fontFamily: mFontRegistry[collectionName].config.fontFamily,
content: info & 0xFFFF,
suppressMirroring: !!(info & 0x10000),
resourceBundle: getCoreResourceBundle()
});
}
return info;
} | javascript | function getInfo() {
var collection = mRegistry[collectionName];
var info = collection && collection[iconName];
// convert raw data lazily to the icon info
if (typeof info === 'number') {
mRegistry[collectionName][iconName] = undefined; // avoid duplicate icon warning
info = IconPool.addIcon(iconName, collectionName, {
fontFamily: mFontRegistry[collectionName].config.fontFamily,
content: info & 0xFFFF,
suppressMirroring: !!(info & 0x10000),
resourceBundle: getCoreResourceBundle()
});
}
return info;
} | [
"function",
"getInfo",
"(",
")",
"{",
"var",
"collection",
"=",
"mRegistry",
"[",
"collectionName",
"]",
";",
"var",
"info",
"=",
"collection",
"&&",
"collection",
"[",
"iconName",
"]",
";",
"// convert raw data lazily to the icon info",
"if",
"(",
"typeof",
"in... | retrieves the icon info from the internal registry | [
"retrieves",
"the",
"icon",
"info",
"from",
"the",
"internal",
"registry"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/IconPool.js#L931-L947 | train | Get the icon info from the registry | [
30522,
3853,
2131,
2378,
14876,
1006,
1007,
1063,
13075,
3074,
1027,
2720,
13910,
2923,
2854,
1031,
3074,
18442,
1033,
1025,
13075,
18558,
1027,
3074,
1004,
1004,
3074,
1031,
12696,
18442,
1033,
1025,
1013,
1013,
10463,
6315,
2951,
2474,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/PerfUtils.js | addMeasurement | function addMeasurement(id) {
if (!enabled) {
return;
}
if (!(id instanceof PerfMeasurement)) {
id = new PerfMeasurement(id, id);
}
var elapsedTime = brackets.app.getElapsedMilliseconds();
if (activeTests[id.id]) {
elapsedTime -= activeTests[id.id].startTime;
delete activeTests[id.id];
}
if (perfData[id]) {
// We have existing data, add to it
if (Array.isArray(perfData[id])) {
perfData[id].push(elapsedTime);
} else {
// Current data is a number, convert to Array
perfData[id] = [perfData[id], elapsedTime];
}
} else {
perfData[id] = elapsedTime;
}
if (id.reent !== undefined) {
if (_reentTests[id] === 0) {
delete _reentTests[id];
} else {
_reentTests[id]--;
}
}
} | javascript | function addMeasurement(id) {
if (!enabled) {
return;
}
if (!(id instanceof PerfMeasurement)) {
id = new PerfMeasurement(id, id);
}
var elapsedTime = brackets.app.getElapsedMilliseconds();
if (activeTests[id.id]) {
elapsedTime -= activeTests[id.id].startTime;
delete activeTests[id.id];
}
if (perfData[id]) {
// We have existing data, add to it
if (Array.isArray(perfData[id])) {
perfData[id].push(elapsedTime);
} else {
// Current data is a number, convert to Array
perfData[id] = [perfData[id], elapsedTime];
}
} else {
perfData[id] = elapsedTime;
}
if (id.reent !== undefined) {
if (_reentTests[id] === 0) {
delete _reentTests[id];
} else {
_reentTests[id]--;
}
}
} | [
"function",
"addMeasurement",
"(",
"id",
")",
"{",
"if",
"(",
"!",
"enabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"(",
"id",
"instanceof",
"PerfMeasurement",
")",
")",
"{",
"id",
"=",
"new",
"PerfMeasurement",
"(",
"id",
",",
"id",
")",
"... | Stop a timer and add its measurements to the performance data.
Multiple measurements can be stored for any given name. If there are
multiple values for a name, they are stored in an Array.
If markStart() was not called for the specified timer, the
measured time is relative to app startup.
@param {Object} id Timer id. | [
"Stop",
"a",
"timer",
"and",
"add",
"its",
"measurements",
"to",
"the",
"performance",
"data",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L187-L223 | train | Add a measurement to the log | [
30522,
3853,
5587,
4168,
3022,
5397,
3672,
1006,
8909,
1007,
1063,
2065,
1006,
999,
9124,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
999,
1006,
8909,
6013,
11253,
2566,
16715,
5243,
28632,
3672,
1007,
1007,
1063,
8909,
1027,
2047,
2566,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ErrorHandler.js | function (sDetails) {
if (this._bMessageOpen) {
return;
}
this._bMessageOpen = true;
MessageBox.error(
this._sErrorText,
{
id : "serviceErrorMessageBox",
details : sDetails,
styleClass : this._oComponent.getContentDensityClass(),
actions : [MessageBox.Action.CLOSE],
onClose : function () {
this._bMessageOpen = false;
}.bind(this)
}
);
} | javascript | function (sDetails) {
if (this._bMessageOpen) {
return;
}
this._bMessageOpen = true;
MessageBox.error(
this._sErrorText,
{
id : "serviceErrorMessageBox",
details : sDetails,
styleClass : this._oComponent.getContentDensityClass(),
actions : [MessageBox.Action.CLOSE],
onClose : function () {
this._bMessageOpen = false;
}.bind(this)
}
);
} | [
"function",
"(",
"sDetails",
")",
"{",
"if",
"(",
"this",
".",
"_bMessageOpen",
")",
"{",
"return",
";",
"}",
"this",
".",
"_bMessageOpen",
"=",
"true",
";",
"MessageBox",
".",
"error",
"(",
"this",
".",
"_sErrorText",
",",
"{",
"id",
":",
"\"serviceEr... | Shows a {@link sap.m.MessageBox} when a service call has failed.
Only the first error message will be display.
@param {string} sDetails a technical error to be displayed on request
@private | [
"Shows",
"a",
"{"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ErrorHandler.js#L56-L73 | train | Show error message box | [
30522,
3853,
1006,
17371,
12928,
12146,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
1038,
7834,
3736,
3351,
26915,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
1035,
1038,
7834,
3736,
3351,
26915,
1027,
2995,
1025,
4471,
8758,
1012,
7561,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.m/src/sap/m/MenuButton.js | isForbiddenType | function isForbiddenType(sType) {
var aTypes = [ButtonType.Up, ButtonType.Back, ButtonType.Unstyled];
return aTypes.indexOf(sType) !== -1;
} | javascript | function isForbiddenType(sType) {
var aTypes = [ButtonType.Up, ButtonType.Back, ButtonType.Unstyled];
return aTypes.indexOf(sType) !== -1;
} | [
"function",
"isForbiddenType",
"(",
"sType",
")",
"{",
"var",
"aTypes",
"=",
"[",
"ButtonType",
".",
"Up",
",",
"ButtonType",
".",
"Back",
",",
"ButtonType",
".",
"Unstyled",
"]",
";",
"return",
"aTypes",
".",
"indexOf",
"(",
"sType",
")",
"!==",
"-",
... | Several button type property values are not allowed | [
"Several",
"button",
"type",
"property",
"values",
"are",
"not",
"allowed"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/MenuButton.js#L528-L531 | train | Checks if the given type is forbidden | [
30522,
3853,
2003,
29278,
17062,
16454,
18863,
1006,
2358,
18863,
1007,
1063,
13075,
2012,
18863,
2015,
30524,
1006,
2358,
18863,
1007,
999,
1027,
1027,
1011,
1015,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/interimElement/interimElement.js | transitionOutAndRemove | function transitionOutAndRemove(response, isCancelled, opts) {
// abort if the show() and compile failed
if (!element) return $q.when(false);
options = angular.extend(options || {}, opts || {});
options.cancelAutoHide && options.cancelAutoHide();
options.element.triggerHandler('$mdInterimElementRemove');
if (options.$destroy === true) {
return hideElement(options.element, options).then(function(){
(isCancelled && rejectAll(response)) || resolveAll(response);
});
} else {
$q.when(showAction).finally(function() {
hideElement(options.element, options).then(function() {
isCancelled ? rejectAll(response) : resolveAll(response);
}, rejectAll);
});
return self.deferred.promise;
}
/**
* The `show()` returns a promise that will be resolved when the interim
* element is hidden or cancelled...
*/
function resolveAll(response) {
self.deferred.resolve(response);
}
/**
* Force the '$md<xxx>.show()' promise to reject
*/
function rejectAll(fault) {
self.deferred.reject(fault);
}
} | javascript | function transitionOutAndRemove(response, isCancelled, opts) {
// abort if the show() and compile failed
if (!element) return $q.when(false);
options = angular.extend(options || {}, opts || {});
options.cancelAutoHide && options.cancelAutoHide();
options.element.triggerHandler('$mdInterimElementRemove');
if (options.$destroy === true) {
return hideElement(options.element, options).then(function(){
(isCancelled && rejectAll(response)) || resolveAll(response);
});
} else {
$q.when(showAction).finally(function() {
hideElement(options.element, options).then(function() {
isCancelled ? rejectAll(response) : resolveAll(response);
}, rejectAll);
});
return self.deferred.promise;
}
/**
* The `show()` returns a promise that will be resolved when the interim
* element is hidden or cancelled...
*/
function resolveAll(response) {
self.deferred.resolve(response);
}
/**
* Force the '$md<xxx>.show()' promise to reject
*/
function rejectAll(fault) {
self.deferred.reject(fault);
}
} | [
"function",
"transitionOutAndRemove",
"(",
"response",
",",
"isCancelled",
",",
"opts",
")",
"{",
"// abort if the show() and compile failed",
"if",
"(",
"!",
"element",
")",
"return",
"$q",
".",
"when",
"(",
"false",
")",
";",
"options",
"=",
"angular",
".",
... | After the show process has finished/rejected:
- announce 'removing',
- perform the transition-out, and
- perform optional clean up scope. | [
"After",
"the",
"show",
"process",
"has",
"finished",
"/",
"rejected",
":",
"-",
"announce",
"removing",
"-",
"perform",
"the",
"transition",
"-",
"out",
"and",
"-",
"perform",
"optional",
"clean",
"up",
"scope",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L526-L566 | train | transition out and remove | [
30522,
3853,
6653,
5833,
5685,
28578,
21818,
1006,
3433,
1010,
2003,
9336,
29109,
3709,
1010,
23569,
2015,
1007,
1063,
1013,
1013,
11113,
11589,
2065,
1996,
2265,
1006,
1007,
1998,
4012,
22090,
3478,
2065,
1006,
999,
5783,
1007,
2709,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeViewModel.js | _markAsChanged | function _markAsChanged(treeData, changed) {
changed.forEach(function (filePath) {
var objectPath = _filePathToObjectPath(treeData, filePath);
if (objectPath) {
treeData = treeData.updateIn(objectPath, _addTimestamp);
}
});
return treeData;
} | javascript | function _markAsChanged(treeData, changed) {
changed.forEach(function (filePath) {
var objectPath = _filePathToObjectPath(treeData, filePath);
if (objectPath) {
treeData = treeData.updateIn(objectPath, _addTimestamp);
}
});
return treeData;
} | [
"function",
"_markAsChanged",
"(",
"treeData",
",",
"changed",
")",
"{",
"changed",
".",
"forEach",
"(",
"function",
"(",
"filePath",
")",
"{",
"var",
"objectPath",
"=",
"_filePathToObjectPath",
"(",
"treeData",
",",
"filePath",
")",
";",
"if",
"(",
"objectP... | @private
Sets/updates the timestamp on the file paths listed in the `changed` array.
@param {Immutable.Map} treeData
@param {Array.<string>} changed list of changed project-relative file paths
@return {Immutable.Map} revised treeData | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeViewModel.js#L987-L995 | train | Mark as changed | [
30522,
3853,
1035,
2928,
3022,
22305,
2098,
1006,
3392,
2850,
2696,
30524,
3392,
2850,
2696,
1010,
5371,
15069,
1007,
1025,
2065,
1006,
4874,
15069,
1007,
1063,
3392,
2850,
2696,
1027,
3392,
2850,
2696,
1012,
10651,
2378,
1006,
4874,
15069,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | components/prism-jsx.js | function (token) {
if (!token) {
return '';
}
if (typeof token === 'string') {
return token;
}
if (typeof token.content === 'string') {
return token.content;
}
return token.content.map(stringifyToken).join('');
} | javascript | function (token) {
if (!token) {
return '';
}
if (typeof token === 'string') {
return token;
}
if (typeof token.content === 'string') {
return token.content;
}
return token.content.map(stringifyToken).join('');
} | [
"function",
"(",
"token",
")",
"{",
"if",
"(",
"!",
"token",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"typeof",
"token",
"===",
"'string'",
")",
"{",
"return",
"token",
";",
"}",
"if",
"(",
"typeof",
"token",
".",
"content",
"===",
"'string'"... | The following will handle plain text inside tags | [
"The",
"following",
"will",
"handle",
"plain",
"text",
"inside",
"tags"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-jsx.js#L38-L49 | train | Returns a string representation of a token | [
30522,
3853,
1006,
19204,
1007,
1063,
2065,
1006,
999,
19204,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
2065,
1006,
2828,
11253,
19204,
1027,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
19204,
1025,
1065,
2065,
1006,
2828,
11253,
19204,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(url, doc, onload)
{
if (mxClient.IS_IE)
{
doc.onreadystatechange = function ()
{
if (doc.readyState == 4)
{
onload();
}
};
}
else
{
doc.addEventListener('load', onload, false);
}
doc.load(url);
} | javascript | function(url, doc, onload)
{
if (mxClient.IS_IE)
{
doc.onreadystatechange = function ()
{
if (doc.readyState == 4)
{
onload();
}
};
}
else
{
doc.addEventListener('load', onload, false);
}
doc.load(url);
} | [
"function",
"(",
"url",
",",
"doc",
",",
"onload",
")",
"{",
"if",
"(",
"mxClient",
".",
"IS_IE",
")",
"{",
"doc",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"doc",
".",
"readyState",
"==",
"4",
")",
"{",
"onload",
"(",
... | Function: loadInto
Loads the specified URL *asynchronously* into the specified document,
invoking onload after the document has been loaded. This implementation
does not use <mxXmlRequest>, but the document.load method.
Parameters:
url - URL to get the data from.
doc - The document to load the URL into.
onload - Function to execute when the URL has been loaded. | [
"Function",
":",
"loadInto"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3741-L3759 | train | Load a file | [
30522,
3853,
1006,
24471,
2140,
1010,
9986,
1010,
2006,
11066,
1007,
1063,
2065,
1006,
25630,
20464,
11638,
1012,
2003,
1035,
29464,
1007,
1063,
9986,
1012,
2006,
16416,
5149,
9153,
15007,
22043,
1027,
3853,
1006,
1007,
1063,
2065,
1006,
99... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | getDist | function getDist(type, node, centroid, attributes, mode) {
var getP = mode === 'kMedoids' ? function (i) {
return attributes[i](centroid);
} : function (i) {
return centroid[i];
};
var getQ = function getQ(i) {
return attributes[i](node);
};
return clusteringDistance(type, attributes.length, getP, getQ);
} | javascript | function getDist(type, node, centroid, attributes, mode) {
var getP = mode === 'kMedoids' ? function (i) {
return attributes[i](centroid);
} : function (i) {
return centroid[i];
};
var getQ = function getQ(i) {
return attributes[i](node);
};
return clusteringDistance(type, attributes.length, getP, getQ);
} | [
"function",
"getDist",
"(",
"type",
",",
"node",
",",
"centroid",
",",
"attributes",
",",
"mode",
")",
"{",
"var",
"getP",
"=",
"mode",
"===",
"'kMedoids'",
"?",
"function",
"(",
"i",
")",
"{",
"return",
"attributes",
"[",
"i",
"]",
"(",
"centroid",
... | /* eslint-enable | [
"/",
"*",
"eslint",
"-",
"enable"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L4107-L4119 | train | get dist of node | [
30522,
3853,
2131,
10521,
2102,
1006,
2828,
1010,
13045,
1010,
18120,
3593,
1010,
12332,
1010,
5549,
1007,
1063,
13075,
2131,
2361,
1027,
5549,
1027,
1027,
1027,
1005,
2463,
26010,
9821,
1005,
1029,
3853,
1006,
1045,
1007,
1063,
2709,
12332... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable, oElement, bIncludePseudoCells) {
bIncludePseudoCells = bIncludePseudoCells === true;
var $Element = jQuery(oElement);
var $Cell = TableUtils.getCell(oTable, oElement, bIncludePseudoCells);
if (!$Cell || $Cell[0] === $Element[0]) {
return null; // The element is not inside a table cell.
} else {
return $Cell;
}
} | javascript | function(oTable, oElement, bIncludePseudoCells) {
bIncludePseudoCells = bIncludePseudoCells === true;
var $Element = jQuery(oElement);
var $Cell = TableUtils.getCell(oTable, oElement, bIncludePseudoCells);
if (!$Cell || $Cell[0] === $Element[0]) {
return null; // The element is not inside a table cell.
} else {
return $Cell;
}
} | [
"function",
"(",
"oTable",
",",
"oElement",
",",
"bIncludePseudoCells",
")",
"{",
"bIncludePseudoCells",
"=",
"bIncludePseudoCells",
"===",
"true",
";",
"var",
"$Element",
"=",
"jQuery",
"(",
"oElement",
")",
";",
"var",
"$Cell",
"=",
"TableUtils",
".",
"getCe... | Returns the table cell which is the parent of an element.
@param {sap.ui.table.Table} oTable Instance of the table used as the context within which to search for the parent cell.
@param {jQuery | HTMLElement} oElement An element inside a table cell.
@param {jQuery | HTMLElement} [bIncludePseudoCells=false] Whether to include pseudo cells.
@returns {jQuery | null} Returns <code>null</code>, if the element is not inside a table cell. | [
"Returns",
"the",
"table",
"cell",
"which",
"is",
"the",
"parent",
"of",
"an",
"element",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L893-L904 | train | Returns the cell of the given element. | [
30522,
3853,
1006,
27178,
3085,
1010,
1051,
12260,
3672,
1010,
8026,
20464,
12672,
29251,
6784,
10085,
5349,
2015,
1007,
1063,
8026,
20464,
12672,
29251,
6784,
10085,
5349,
2015,
1027,
8026,
20464,
12672,
29251,
6784,
10085,
5349,
2015,
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... | |
thomaspark/bootswatch | docs/3/bower_components/html5shiv/dist/html5shiv-printshiv.js | createElement | function createElement(nodeName, ownerDocument, data){
if (!ownerDocument) {
ownerDocument = document;
}
if(supportsUnknownElements){
return ownerDocument.createElement(nodeName);
}
if (!data) {
data = getExpandoData(ownerDocument);
}
var node;
if (data.cache[nodeName]) {
node = data.cache[nodeName].cloneNode();
} else if (saveClones.test(nodeName)) {
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
} else {
node = data.createElem(nodeName);
}
// Avoid adding some elements to fragments in IE < 9 because
// * Attributes like `name` or `type` cannot be set/changed once an element
// is inserted into a document/fragment
// * Link elements with `src` attributes that are inaccessible, as with
// a 403 response, will cause the tab/window to crash
// * Script elements appended to fragments will execute when their `src`
// or `text` property is set
return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
} | javascript | function createElement(nodeName, ownerDocument, data){
if (!ownerDocument) {
ownerDocument = document;
}
if(supportsUnknownElements){
return ownerDocument.createElement(nodeName);
}
if (!data) {
data = getExpandoData(ownerDocument);
}
var node;
if (data.cache[nodeName]) {
node = data.cache[nodeName].cloneNode();
} else if (saveClones.test(nodeName)) {
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
} else {
node = data.createElem(nodeName);
}
// Avoid adding some elements to fragments in IE < 9 because
// * Attributes like `name` or `type` cannot be set/changed once an element
// is inserted into a document/fragment
// * Link elements with `src` attributes that are inaccessible, as with
// a 403 response, will cause the tab/window to crash
// * Script elements appended to fragments will execute when their `src`
// or `text` property is set
return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
} | [
"function",
"createElement",
"(",
"nodeName",
",",
"ownerDocument",
",",
"data",
")",
"{",
"if",
"(",
"!",
"ownerDocument",
")",
"{",
"ownerDocument",
"=",
"document",
";",
"}",
"if",
"(",
"supportsUnknownElements",
")",
"{",
"return",
"ownerDocument",
".",
... | returns a shived element for the given nodeName and document
@memberOf html5
@param {String} nodeName name of the element
@param {Document} ownerDocument The context document.
@returns {Object} The shived element. | [
"returns",
"a",
"shived",
"element",
"for",
"the",
"given",
"nodeName",
"and",
"document"
] | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/3/bower_components/html5shiv/dist/html5shiv-printshiv.js#L127-L155 | train | Creates a new element | [
30522,
3853,
3443,
12260,
3672,
1006,
13045,
18442,
1010,
3954,
3527,
24894,
4765,
1010,
2951,
1007,
1063,
2065,
1006,
999,
3954,
3527,
24894,
4765,
1007,
1063,
3954,
3527,
24894,
4765,
1027,
6254,
1025,
1065,
2065,
1006,
6753,
16814,
19779... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(ctor, superCtor)
{
var f = function() {};
f.prototype = superCtor.prototype;
ctor.prototype = new f();
ctor.prototype.constructor = ctor;
} | javascript | function(ctor, superCtor)
{
var f = function() {};
f.prototype = superCtor.prototype;
ctor.prototype = new f();
ctor.prototype.constructor = ctor;
} | [
"function",
"(",
"ctor",
",",
"superCtor",
")",
"{",
"var",
"f",
"=",
"function",
"(",
")",
"{",
"}",
";",
"f",
".",
"prototype",
"=",
"superCtor",
".",
"prototype",
";",
"ctor",
".",
"prototype",
"=",
"new",
"f",
"(",
")",
";",
"ctor",
".",
"pro... | Function: extend
Assigns a copy of the superclass prototype to the subclass prototype.
Note that this does not call the constructor of the superclass at this
point, the superclass constructor should be called explicitely in the
subclass constructor. Below is an example.
(code)
MyGraph = function(container, model, renderHint, stylesheet)
{
mxGraph.call(this, container, model, renderHint, stylesheet);
}
mxUtils.extend(MyGraph, mxGraph);
(end)
Parameters:
ctor - Constructor of the subclass.
superCtor - Constructor of the superclass. | [
"Function",
":",
"extend"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4015-L4022 | train | A function that creates a new object that inherits from another object. | [
30522,
3853,
1006,
14931,
2953,
1010,
3565,
16761,
1007,
1063,
13075,
1042,
1027,
3853,
1006,
1007,
1063,
1065,
1025,
1042,
1012,
8773,
1027,
3565,
16761,
1012,
8773,
1025,
14931,
2953,
1012,
8773,
1027,
2047,
1042,
1006,
1007,
1025,
14931,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js | function(oTable, iColumnIndex, iWidth, bFireEvent, iColumnSpan) {
if (!oTable ||
iColumnIndex == null || iColumnIndex < 0 ||
iWidth == null || iWidth <= 0) {
return false;
}
if (iColumnSpan == null || iColumnSpan <= 0) {
iColumnSpan = 1;
}
if (bFireEvent == null) {
bFireEvent = true;
}
var aColumns = oTable.getColumns();
if (iColumnIndex >= aColumns.length || !aColumns[iColumnIndex].getVisible()) {
return false;
}
var aVisibleColumns = [];
for (var i = iColumnIndex; i < aColumns.length; i++) {
var oColumn = aColumns[i];
if (oColumn.getVisible()) {
aVisibleColumns.push(oColumn);
// Consider only the required amount of visible columns.
if (aVisibleColumns.length === iColumnSpan) {
break;
}
}
}
var aResizableColumns = [];
for (var i = 0; i < aVisibleColumns.length; i++) {
var oVisibleColumn = aVisibleColumns[i];
if (oVisibleColumn.getResizable()) {
aResizableColumns.push(oVisibleColumn);
}
}
if (aResizableColumns.length === 0) {
return false;
}
var iSpanWidth = 0;
for (var i = 0; i < aVisibleColumns.length; i++) {
var oVisibleColumn = aVisibleColumns[i];
iSpanWidth += TableColumnUtils.getColumnWidth(oTable, oVisibleColumn.getIndex());
}
var iPixelDelta = iWidth - iSpanWidth;
var iSharedPixelDelta = Math.round(iPixelDelta / aResizableColumns.length);
var bResizeWasPerformed = false;
var oTableElement = oTable.getDomRef();
// Fix Auto Columns if a column in the scrollable area was resized:
// Set minimum widths of all columns with variable width except those in aResizableColumns.
// As a result, flexible columns cannot shrink smaller as their current width after the resize
// (see setMinColWidths in Table.js).
if (!TableColumnUtils.TableUtils.isFixedColumn(oTable, iColumnIndex)) {
oTable._getVisibleColumns().forEach(function(col) {
var width = col.getWidth(),
colElement;
if (oTableElement && aResizableColumns.indexOf(col) < 0 && TableColumnUtils.TableUtils.isVariableWidth(width)) {
colElement = oTableElement.querySelector("th[data-sap-ui-colid=\"" + col.getId() + "\"]");
if (colElement) {
col._minWidth = Math.max(colElement.offsetWidth, TableColumnUtils.getMinColumnWidth());
}
}
});
}
// Resize all resizable columns. Share the width change (pixel delta) between them.
for (var i = 0; i < aResizableColumns.length; i++) {
var oResizableColumn = aResizableColumns[i];
var iColumnWidth = TableColumnUtils.getColumnWidth(oTable, oResizableColumn.getIndex());
var iNewWidth = iColumnWidth + iSharedPixelDelta;
var iColMinWidth = TableColumnUtils.getMinColumnWidth();
if (iNewWidth < iColMinWidth) {
iNewWidth = iColMinWidth;
}
var iWidthChange = iNewWidth - iColumnWidth;
// Distribute any remaining delta to the remaining columns.
if (Math.abs(iWidthChange) < Math.abs(iSharedPixelDelta)) {
var iRemainingColumnCount = aResizableColumns.length - (i + 1);
iPixelDelta -= iWidthChange;
iSharedPixelDelta = Math.round(iPixelDelta / iRemainingColumnCount);
}
if (iWidthChange !== 0) {
var bExecuteDefault = true;
var sWidth = iNewWidth + "px";
if (bFireEvent) {
bExecuteDefault = oTable.fireColumnResize({
column: oResizableColumn,
width: sWidth
});
}
if (bExecuteDefault) {
oResizableColumn.setWidth(sWidth);
bResizeWasPerformed = true;
}
}
}
return bResizeWasPerformed;
} | javascript | function(oTable, iColumnIndex, iWidth, bFireEvent, iColumnSpan) {
if (!oTable ||
iColumnIndex == null || iColumnIndex < 0 ||
iWidth == null || iWidth <= 0) {
return false;
}
if (iColumnSpan == null || iColumnSpan <= 0) {
iColumnSpan = 1;
}
if (bFireEvent == null) {
bFireEvent = true;
}
var aColumns = oTable.getColumns();
if (iColumnIndex >= aColumns.length || !aColumns[iColumnIndex].getVisible()) {
return false;
}
var aVisibleColumns = [];
for (var i = iColumnIndex; i < aColumns.length; i++) {
var oColumn = aColumns[i];
if (oColumn.getVisible()) {
aVisibleColumns.push(oColumn);
// Consider only the required amount of visible columns.
if (aVisibleColumns.length === iColumnSpan) {
break;
}
}
}
var aResizableColumns = [];
for (var i = 0; i < aVisibleColumns.length; i++) {
var oVisibleColumn = aVisibleColumns[i];
if (oVisibleColumn.getResizable()) {
aResizableColumns.push(oVisibleColumn);
}
}
if (aResizableColumns.length === 0) {
return false;
}
var iSpanWidth = 0;
for (var i = 0; i < aVisibleColumns.length; i++) {
var oVisibleColumn = aVisibleColumns[i];
iSpanWidth += TableColumnUtils.getColumnWidth(oTable, oVisibleColumn.getIndex());
}
var iPixelDelta = iWidth - iSpanWidth;
var iSharedPixelDelta = Math.round(iPixelDelta / aResizableColumns.length);
var bResizeWasPerformed = false;
var oTableElement = oTable.getDomRef();
// Fix Auto Columns if a column in the scrollable area was resized:
// Set minimum widths of all columns with variable width except those in aResizableColumns.
// As a result, flexible columns cannot shrink smaller as their current width after the resize
// (see setMinColWidths in Table.js).
if (!TableColumnUtils.TableUtils.isFixedColumn(oTable, iColumnIndex)) {
oTable._getVisibleColumns().forEach(function(col) {
var width = col.getWidth(),
colElement;
if (oTableElement && aResizableColumns.indexOf(col) < 0 && TableColumnUtils.TableUtils.isVariableWidth(width)) {
colElement = oTableElement.querySelector("th[data-sap-ui-colid=\"" + col.getId() + "\"]");
if (colElement) {
col._minWidth = Math.max(colElement.offsetWidth, TableColumnUtils.getMinColumnWidth());
}
}
});
}
// Resize all resizable columns. Share the width change (pixel delta) between them.
for (var i = 0; i < aResizableColumns.length; i++) {
var oResizableColumn = aResizableColumns[i];
var iColumnWidth = TableColumnUtils.getColumnWidth(oTable, oResizableColumn.getIndex());
var iNewWidth = iColumnWidth + iSharedPixelDelta;
var iColMinWidth = TableColumnUtils.getMinColumnWidth();
if (iNewWidth < iColMinWidth) {
iNewWidth = iColMinWidth;
}
var iWidthChange = iNewWidth - iColumnWidth;
// Distribute any remaining delta to the remaining columns.
if (Math.abs(iWidthChange) < Math.abs(iSharedPixelDelta)) {
var iRemainingColumnCount = aResizableColumns.length - (i + 1);
iPixelDelta -= iWidthChange;
iSharedPixelDelta = Math.round(iPixelDelta / iRemainingColumnCount);
}
if (iWidthChange !== 0) {
var bExecuteDefault = true;
var sWidth = iNewWidth + "px";
if (bFireEvent) {
bExecuteDefault = oTable.fireColumnResize({
column: oResizableColumn,
width: sWidth
});
}
if (bExecuteDefault) {
oResizableColumn.setWidth(sWidth);
bResizeWasPerformed = true;
}
}
}
return bResizeWasPerformed;
} | [
"function",
"(",
"oTable",
",",
"iColumnIndex",
",",
"iWidth",
",",
"bFireEvent",
",",
"iColumnSpan",
")",
"{",
"if",
"(",
"!",
"oTable",
"||",
"iColumnIndex",
"==",
"null",
"||",
"iColumnIndex",
"<",
"0",
"||",
"iWidth",
"==",
"null",
"||",
"iWidth",
"<... | Resizes one or more visible columns to the specified amount of pixels.
In case a column span is specified:
The span covers only visible columns. If columns directly after the column with index <code>iColumnIndex</code> are invisible they
will be skipped and not be considered for resizing.
The new width <code>iWidth</code> will be equally applied among all resizable columns in the span of visible columns,
considering the minimum column width. The actual resulting width might differ due to rounding errors and the minimum column width.
Resizing of a column won't be performed if the ColumnResize event is fired
and execution of the default action is prevented in the event handler.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {int} iColumnIndex The index of a column. Must the index of a visible column.
@param {int} iWidth The width in pixel to set the column or column span to. Must be greater than 0.
@param {boolean} [bFireEvent=true] Whether the ColumnResize event should be fired. The event will be fired for every resized column.
@param {int} [iColumnSpan=1] The span of columns to resize beginning from <code>iColumnIndex</code>.
@returns {boolean} Returns <code>true</code>, if at least one column has been resized. | [
"Resizes",
"one",
"or",
"more",
"visible",
"columns",
"to",
"the",
"specified",
"amount",
"of",
"pixels",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js#L569-L680 | train | Returns true if the column is visible and the width of the column is at least the specified amount of visible. | [
30522,
3853,
1006,
27178,
3085,
1010,
24582,
4747,
2819,
11483,
3207,
2595,
1010,
1045,
9148,
11927,
2232,
1010,
28939,
7442,
18697,
3372,
1010,
24582,
4747,
2819,
3619,
9739,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1064,
1064,
24582,
474... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
electron/electron | lib/browser/guest-window-manager.js | function (sender, target) {
return (target.getLastWebPreferences().openerId === sender.id) ||
(sender.getLastWebPreferences().nodeIntegration === true) ||
isSameOrigin(sender.getURL(), target.getURL())
} | javascript | function (sender, target) {
return (target.getLastWebPreferences().openerId === sender.id) ||
(sender.getLastWebPreferences().nodeIntegration === true) ||
isSameOrigin(sender.getURL(), target.getURL())
} | [
"function",
"(",
"sender",
",",
"target",
")",
"{",
"return",
"(",
"target",
".",
"getLastWebPreferences",
"(",
")",
".",
"openerId",
"===",
"sender",
".",
"id",
")",
"||",
"(",
"sender",
".",
"getLastWebPreferences",
"(",
")",
".",
"nodeIntegration",
"===... | Checks whether |sender| can access the |target|: 1. Check whether |sender| is the parent of |target|. 2. Check whether |sender| has node integration, if so it is allowed to do anything it wants. 3. Check whether the origins match. However it allows a child window without node integration but with same origin to do anything it wants, when its opener window has node integration. The W3C does not have anything on this, but from my understanding of the security model of |window.opener|, this should be fine. | [
"Checks",
"whether",
"|sender|",
"can",
"access",
"the",
"|target|",
":",
"1",
".",
"Check",
"whether",
"|sender|",
"is",
"the",
"parent",
"of",
"|target|",
".",
"2",
".",
"Check",
"whether",
"|sender|",
"has",
"node",
"integration",
"if",
"so",
"it",
"is"... | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/guest-window-manager.js#L169-L173 | train | Returns true if the target is the same origin as the sender | [
30522,
3853,
1006,
4604,
2121,
1010,
4539,
1007,
1063,
2709,
1006,
4539,
1012,
2131,
8523,
2102,
8545,
2497,
28139,
25523,
2015,
1006,
1007,
1012,
16181,
3593,
1027,
1027,
1027,
4604,
2121,
1012,
8909,
1007,
1064,
1064,
1006,
4604,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/helpers/get.js | isBrowse | function isBrowse(options) {
var browse = true;
if (options.id || options.slug) {
browse = false;
}
return browse;
} | javascript | function isBrowse(options) {
var browse = true;
if (options.id || options.slug) {
browse = false;
}
return browse;
} | [
"function",
"isBrowse",
"(",
"options",
")",
"{",
"var",
"browse",
"=",
"true",
";",
"if",
"(",
"options",
".",
"id",
"||",
"options",
".",
"slug",
")",
"{",
"browse",
"=",
"false",
";",
"}",
"return",
"browse",
";",
"}"
] | ## Is Browse
Is this a Browse request or a Read request?
@param {Object} resource
@param {Object} options
@returns {boolean} | [
"##",
"Is",
"Browse",
"Is",
"this",
"a",
"Browse",
"request",
"or",
"a",
"Read",
"request?"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/helpers/get.js#L59-L67 | train | Returns true if the user is browse | [
30522,
3853,
2003,
12618,
9333,
2063,
1006,
7047,
1007,
1063,
13075,
11347,
2063,
1027,
2995,
1025,
2065,
1006,
7047,
1012,
8909,
1064,
1064,
7047,
1012,
23667,
1007,
1063,
11347,
2063,
1027,
6270,
1025,
1065,
2709,
11347,
2063,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/block-spacing.js | isValid | function isValid(left, right) {
return (
!util.isTokenOnSameLine(left, right) ||
sourceCode.isSpaceBetweenTokens(left, right) === always
);
} | javascript | function isValid(left, right) {
return (
!util.isTokenOnSameLine(left, right) ||
sourceCode.isSpaceBetweenTokens(left, right) === always
);
} | [
"function",
"isValid",
"(",
"left",
",",
"right",
")",
"{",
"return",
"(",
"!",
"util",
".",
"isTokenOnSameLine",
"(",
"left",
",",
"right",
")",
"||",
"sourceCode",
".",
"isSpaceBetweenTokens",
"(",
"left",
",",
"right",
")",
"===",
"always",
")",
";",
... | Checks whether or not:
- given tokens are on same line.
- there is/isn't a space between given tokens.
@param {Token} left - A token to check.
@param {Token} right - The token which is next to `left`.
@returns {boolean}
When the option is `"always"`, `true` if there are one or more spaces between given tokens.
When the option is `"never"`, `true` if there are not any spaces between given tokens.
If given tokens are not on same line, it's always `true`. | [
"Checks",
"whether",
"or",
"not",
":",
"-",
"given",
"tokens",
"are",
"on",
"same",
"line",
".",
"-",
"there",
"is",
"/",
"isn",
"t",
"a",
"space",
"between",
"given",
"tokens",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/block-spacing.js#L68-L73 | train | Check if the given two tokens are valid | [
30522,
3853,
2003,
10175,
3593,
1006,
2187,
1010,
2157,
1007,
1063,
2709,
1006,
999,
21183,
4014,
1012,
21541,
11045,
8540,
21559,
18809,
2063,
1006,
2187,
1010,
2157,
1007,
1064,
1064,
3120,
16044,
1012,
26354,
15327,
20915,
28394,
13663,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | dist/js/materialize.js | Datepicker | function Datepicker(el, options) {
_classCallCheck(this, Datepicker);
var _this53 = _possibleConstructorReturn(this, (Datepicker.__proto__ || Object.getPrototypeOf(Datepicker)).call(this, Datepicker, el, options));
_this53.el.M_Datepicker = _this53;
_this53.options = $.extend({}, Datepicker.defaults, options);
// make sure i18n defaults are not lost when only few i18n option properties are passed
if (!!options && options.hasOwnProperty('i18n') && typeof options.i18n === 'object') {
_this53.options.i18n = $.extend({}, Datepicker.defaults.i18n, options.i18n);
}
// Remove time component from minDate and maxDate options
if (_this53.options.minDate) _this53.options.minDate.setHours(0, 0, 0, 0);
if (_this53.options.maxDate) _this53.options.maxDate.setHours(0, 0, 0, 0);
_this53.id = M.guid();
_this53._setupVariables();
_this53._insertHTMLIntoDOM();
_this53._setupModal();
_this53._setupEventHandlers();
if (!_this53.options.defaultDate) {
_this53.options.defaultDate = new Date(Date.parse(_this53.el.value));
}
var defDate = _this53.options.defaultDate;
if (Datepicker._isDate(defDate)) {
if (_this53.options.setDefaultDate) {
_this53.setDate(defDate, true);
_this53.setInputValue();
} else {
_this53.gotoDate(defDate);
}
} else {
_this53.gotoDate(new Date());
}
/**
* Describes open/close state of datepicker
* @type {Boolean}
*/
_this53.isOpen = false;
return _this53;
} | javascript | function Datepicker(el, options) {
_classCallCheck(this, Datepicker);
var _this53 = _possibleConstructorReturn(this, (Datepicker.__proto__ || Object.getPrototypeOf(Datepicker)).call(this, Datepicker, el, options));
_this53.el.M_Datepicker = _this53;
_this53.options = $.extend({}, Datepicker.defaults, options);
// make sure i18n defaults are not lost when only few i18n option properties are passed
if (!!options && options.hasOwnProperty('i18n') && typeof options.i18n === 'object') {
_this53.options.i18n = $.extend({}, Datepicker.defaults.i18n, options.i18n);
}
// Remove time component from minDate and maxDate options
if (_this53.options.minDate) _this53.options.minDate.setHours(0, 0, 0, 0);
if (_this53.options.maxDate) _this53.options.maxDate.setHours(0, 0, 0, 0);
_this53.id = M.guid();
_this53._setupVariables();
_this53._insertHTMLIntoDOM();
_this53._setupModal();
_this53._setupEventHandlers();
if (!_this53.options.defaultDate) {
_this53.options.defaultDate = new Date(Date.parse(_this53.el.value));
}
var defDate = _this53.options.defaultDate;
if (Datepicker._isDate(defDate)) {
if (_this53.options.setDefaultDate) {
_this53.setDate(defDate, true);
_this53.setInputValue();
} else {
_this53.gotoDate(defDate);
}
} else {
_this53.gotoDate(new Date());
}
/**
* Describes open/close state of datepicker
* @type {Boolean}
*/
_this53.isOpen = false;
return _this53;
} | [
"function",
"Datepicker",
"(",
"el",
",",
"options",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"Datepicker",
")",
";",
"var",
"_this53",
"=",
"_possibleConstructorReturn",
"(",
"this",
",",
"(",
"Datepicker",
".",
"__proto__",
"||",
"Object",
".",
"getP... | Construct Datepicker instance and set up overlay
@constructor
@param {Element} el
@param {Object} options | [
"Construct",
"Datepicker",
"instance",
"and",
"set",
"up",
"overlay"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L8821-L8869 | train | Construct Datepicker instance | [
30522,
3853,
3058,
24330,
5484,
1006,
3449,
1010,
7047,
1007,
1063,
1035,
2465,
9289,
29358,
11012,
1006,
2023,
1010,
3058,
24330,
5484,
1007,
1025,
13075,
1035,
2023,
22275,
1027,
1035,
2825,
8663,
3367,
6820,
16761,
13465,
14287,
1006,
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... |
nhn/tui.editor | src/js/codemirror/fixOrderedListNumber.js | findFirstListItem | function findFirstListItem(lineNumber, cm) {
let nextLineNumber = lineNumber;
let lineText = cm.getLine(lineNumber);
while (listRE.test(lineText)) {
nextLineNumber -= 1;
lineText = cm.getLine(nextLineNumber);
}
if (lineNumber === nextLineNumber) {
nextLineNumber = -1;
} else {
nextLineNumber += 1;
}
return nextLineNumber;
} | javascript | function findFirstListItem(lineNumber, cm) {
let nextLineNumber = lineNumber;
let lineText = cm.getLine(lineNumber);
while (listRE.test(lineText)) {
nextLineNumber -= 1;
lineText = cm.getLine(nextLineNumber);
}
if (lineNumber === nextLineNumber) {
nextLineNumber = -1;
} else {
nextLineNumber += 1;
}
return nextLineNumber;
} | [
"function",
"findFirstListItem",
"(",
"lineNumber",
",",
"cm",
")",
"{",
"let",
"nextLineNumber",
"=",
"lineNumber",
";",
"let",
"lineText",
"=",
"cm",
".",
"getLine",
"(",
"lineNumber",
")",
";",
"while",
"(",
"listRE",
".",
"test",
"(",
"lineText",
")",
... | find line number of list item which contains given lineNumber
@param {number} lineNumber - line number of list item
@param {CodeMirror} cm - CodeMirror instance
@returns {number} - line number of first list item
@ignore | [
"find",
"line",
"number",
"of",
"list",
"item",
"which",
"contains",
"given",
"lineNumber"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/codemirror/fixOrderedListNumber.js#L103-L119 | train | Find the next list item | [
30522,
3853,
2424,
8873,
12096,
9863,
4221,
2213,
1006,
17517,
29440,
1010,
4642,
1007,
1063,
2292,
2279,
4179,
19172,
5677,
1027,
17517,
29440,
1025,
2292,
2240,
18209,
1027,
4642,
1012,
2131,
4179,
1006,
17517,
29440,
1007,
1025,
2096,
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... |
jgraph/mxgraph | javascript/mxClient.js | function(cell)
{
var result = '';
if (cell != null)
{
var parent = cell.getParent();
while (parent != null)
{
var index = parent.getIndex(cell);
result = index + mxCellPath.PATH_SEPARATOR + result;
cell = parent;
parent = cell.getParent();
}
}
// Removes trailing separator
var n = result.length;
if (n > 1)
{
result = result.substring(0, n - 1);
}
return result;
} | javascript | function(cell)
{
var result = '';
if (cell != null)
{
var parent = cell.getParent();
while (parent != null)
{
var index = parent.getIndex(cell);
result = index + mxCellPath.PATH_SEPARATOR + result;
cell = parent;
parent = cell.getParent();
}
}
// Removes trailing separator
var n = result.length;
if (n > 1)
{
result = result.substring(0, n - 1);
}
return result;
} | [
"function",
"(",
"cell",
")",
"{",
"var",
"result",
"=",
"''",
";",
"if",
"(",
"cell",
"!=",
"null",
")",
"{",
"var",
"parent",
"=",
"cell",
".",
"getParent",
"(",
")",
";",
"while",
"(",
"parent",
"!=",
"null",
")",
"{",
"var",
"index",
"=",
"... | Function: create
Creates the cell path for the given cell. The cell path is a
concatenation of the indices of all ancestors on the (finite) path to
the root, eg. "0.0.0.1".
Parameters:
cell - Cell whose path should be returned. | [
"Function",
":",
"create"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L43235-L43262 | train | Returns the path of the cell | [
30522,
3853,
1006,
3526,
1007,
1063,
13075,
2765,
1027,
1005,
1005,
1025,
2065,
1006,
3526,
999,
1027,
19701,
1007,
1063,
13075,
6687,
1027,
3526,
1012,
2131,
19362,
4765,
1006,
1007,
30524,
1027,
6687,
1012,
2131,
22254,
10288,
1006,
3526,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-state.js | getThrowContext | function getThrowContext(state) {
let context = state.tryContext;
while (context) {
if (context.position === "try" ||
(context.hasFinalizer && context.position === "catch")
) {
return context;
}
context = context.upper;
}
return state;
} | javascript | function getThrowContext(state) {
let context = state.tryContext;
while (context) {
if (context.position === "try" ||
(context.hasFinalizer && context.position === "catch")
) {
return context;
}
context = context.upper;
}
return state;
} | [
"function",
"getThrowContext",
"(",
"state",
")",
"{",
"let",
"context",
"=",
"state",
".",
"tryContext",
";",
"while",
"(",
"context",
")",
"{",
"if",
"(",
"context",
".",
"position",
"===",
"\"try\"",
"||",
"(",
"context",
".",
"hasFinalizer",
"&&",
"c... | Gets a context for a `throw` statement.
@param {CodePathState} state - A state to get.
@returns {TryContext|CodePathState} A context for a `throw` statement. | [
"Gets",
"a",
"context",
"for",
"a",
"throw",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-state.js#L114-L127 | train | Get the next try or catch context | [
30522,
3853,
2131,
2705,
10524,
8663,
18209,
1006,
2110,
1007,
1063,
2292,
6123,
1027,
2110,
1012,
3046,
8663,
18209,
1025,
2096,
1006,
6123,
1007,
1063,
2065,
1006,
6123,
1012,
2597,
1027,
1027,
1027,
1000,
3046,
1000,
1064,
1064,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/events/F6Navigation.js | isContained | function isContained(aContainers, oRef) {
for (var i = 0; i < aContainers.length; i++) {
if (aContainers[i] === oRef || jQuery.contains(aContainers[i], oRef)) {
return true;
}
}
return false;
} | javascript | function isContained(aContainers, oRef) {
for (var i = 0; i < aContainers.length; i++) {
if (aContainers[i] === oRef || jQuery.contains(aContainers[i], oRef)) {
return true;
}
}
return false;
} | [
"function",
"isContained",
"(",
"aContainers",
",",
"oRef",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aContainers",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"aContainers",
"[",
"i",
"]",
"===",
"oRef",
"||",
"jQuery",
... | Checks whether the given DomRef is contained or equals (in) one of the given container | [
"Checks",
"whether",
"the",
"given",
"DomRef",
"is",
"contained",
"or",
"equals",
"(",
"in",
")",
"one",
"of",
"the",
"given",
"container"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/F6Navigation.js#L114-L121 | train | Returns true if the given container is contained in the given container | [
30522,
3853,
2003,
8663,
28055,
1006,
9353,
12162,
18175,
2869,
30524,
2869,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2065,
1006,
9353,
12162,
18175,
2869,
1031,
1045,
1033,
1027,
1027,
1027,
10848,
2546,
1064,
1064,
1046,
4226,
2854... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/parse/parseBook.js | parseMultilingualBook | function parseMultilingualBook(book) {
var languages = book.getLanguages();
var langList = languages.getList();
return Promise.reduce(langList, function(currentBook, lang) {
var langID = lang.getID();
var child = Book.createFromParent(currentBook, langID);
var ignore = currentBook.getIgnore();
return Promise(child)
.then(parseConfig)
.then(parseBookContent)
.then(function(result) {
// Ignore content of this book when generating parent book
ignore = ignore.add(langID + '/**');
currentBook = currentBook.set('ignore', ignore);
return currentBook.addLanguageBook(langID, result);
});
}, book);
} | javascript | function parseMultilingualBook(book) {
var languages = book.getLanguages();
var langList = languages.getList();
return Promise.reduce(langList, function(currentBook, lang) {
var langID = lang.getID();
var child = Book.createFromParent(currentBook, langID);
var ignore = currentBook.getIgnore();
return Promise(child)
.then(parseConfig)
.then(parseBookContent)
.then(function(result) {
// Ignore content of this book when generating parent book
ignore = ignore.add(langID + '/**');
currentBook = currentBook.set('ignore', ignore);
return currentBook.addLanguageBook(langID, result);
});
}, book);
} | [
"function",
"parseMultilingualBook",
"(",
"book",
")",
"{",
"var",
"languages",
"=",
"book",
".",
"getLanguages",
"(",
")",
";",
"var",
"langList",
"=",
"languages",
".",
"getList",
"(",
")",
";",
"return",
"Promise",
".",
"reduce",
"(",
"langList",
",",
... | Parse a multilingual book
@param {Book} book
@return {Promise<Book>} | [
"Parse",
"a",
"multilingual",
"book"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseBook.js#L31-L51 | train | Parse multilingual book | [
30522,
3853,
11968,
3366,
12274,
7096,
16281,
8787,
8654,
1006,
2338,
1007,
1063,
13075,
4155,
1027,
2338,
1012,
2131,
25023,
6692,
8449,
1006,
1007,
1025,
13075,
11374,
9863,
1027,
4155,
1012,
2131,
9863,
1006,
1007,
1025,
2709,
4872,
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... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | normalizeChildren | function normalizeChildren (children) {
return isPrimitive(children)
? [createTextVNode(children)]
: Array.isArray(children)
? normalizeArrayChildren(children)
: undefined
} | javascript | function normalizeChildren (children) {
return isPrimitive(children)
? [createTextVNode(children)]
: Array.isArray(children)
? normalizeArrayChildren(children)
: undefined
} | [
"function",
"normalizeChildren",
"(",
"children",
")",
"{",
"return",
"isPrimitive",
"(",
"children",
")",
"?",
"[",
"createTextVNode",
"(",
"children",
")",
"]",
":",
"Array",
".",
"isArray",
"(",
"children",
")",
"?",
"normalizeArrayChildren",
"(",
"children... | 2. When the children contains constructs that always generated nested Arrays, e.g. <template>, <slot>, v-for, or when the children is provided by user with hand-written render functions / JSX. In such cases a full normalization is needed to cater to all possible types of children values. | [
"2",
".",
"When",
"the",
"children",
"contains",
"constructs",
"that",
"always",
"generated",
"nested",
"Arrays",
"e",
".",
"g",
".",
"<template",
">",
"<slot",
">",
"v",
"-",
"for",
"or",
"when",
"the",
"children",
"is",
"provided",
"by",
"user",
"with"... | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L1784-L1790 | train | Normalizes children to a single node array | [
30522,
3853,
3671,
4697,
19339,
7389,
1006,
2336,
1007,
1063,
2709,
2003,
18098,
27605,
6024,
1006,
2336,
1007,
1029,
1031,
3443,
18209,
16022,
10244,
1006,
2336,
1007,
1033,
1024,
9140,
1012,
18061,
11335,
2100,
1006,
2336,
1007,
1029,
367... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/scene/vr-mode-ui.js | createEnterVRButton | function createEnterVRButton (onClick) {
var vrButton;
var wrapper;
// Create elements.
wrapper = document.createElement('div');
wrapper.classList.add(ENTER_VR_CLASS);
wrapper.setAttribute(constants.AFRAME_INJECTED, '');
vrButton = document.createElement('button');
vrButton.className = ENTER_VR_BTN_CLASS;
vrButton.setAttribute('title',
'Enter VR mode with a headset or fullscreen mode on a desktop. ' +
'Visit https://webvr.rocks or https://webvr.info for more information.');
vrButton.setAttribute(constants.AFRAME_INJECTED, '');
// Insert elements.
wrapper.appendChild(vrButton);
vrButton.addEventListener('click', function (evt) {
onClick();
evt.stopPropagation();
});
return wrapper;
} | javascript | function createEnterVRButton (onClick) {
var vrButton;
var wrapper;
// Create elements.
wrapper = document.createElement('div');
wrapper.classList.add(ENTER_VR_CLASS);
wrapper.setAttribute(constants.AFRAME_INJECTED, '');
vrButton = document.createElement('button');
vrButton.className = ENTER_VR_BTN_CLASS;
vrButton.setAttribute('title',
'Enter VR mode with a headset or fullscreen mode on a desktop. ' +
'Visit https://webvr.rocks or https://webvr.info for more information.');
vrButton.setAttribute(constants.AFRAME_INJECTED, '');
// Insert elements.
wrapper.appendChild(vrButton);
vrButton.addEventListener('click', function (evt) {
onClick();
evt.stopPropagation();
});
return wrapper;
} | [
"function",
"createEnterVRButton",
"(",
"onClick",
")",
"{",
"var",
"vrButton",
";",
"var",
"wrapper",
";",
"// Create elements.",
"wrapper",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"wrapper",
".",
"classList",
".",
"add",
"(",
"ENTER_VR... | Create a button that when clicked will enter into stereo-rendering mode for VR.
Structure: <div><button></div>
@param {function} onClick - click event handler
@returns {Element} Wrapper <div>. | [
"Create",
"a",
"button",
"that",
"when",
"clicked",
"will",
"enter",
"into",
"stereo",
"-",
"rendering",
"mode",
"for",
"VR",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/vr-mode-ui.js#L138-L160 | train | Creates a button that will enter the VR mode. | [
30522,
3853,
3443,
29110,
19716,
8569,
15474,
1006,
2006,
20464,
6799,
1007,
1063,
13075,
27830,
8569,
15474,
1025,
13075,
10236,
4842,
1025,
1013,
1013,
3443,
3787,
1012,
10236,
4842,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/core/core.scale.js | function() {
var me = this;
if (me.margins) {
me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, 0);
}
} | javascript | function() {
var me = this;
if (me.margins) {
me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, 0);
}
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"me",
".",
"margins",
")",
"{",
"me",
".",
"paddingLeft",
"=",
"Math",
".",
"max",
"(",
"me",
".",
"paddingLeft",
"-",
"me",
".",
"margins",
".",
"left",
",",
"0",
")",
";",
... | Handle margins and padding interactions
@private | [
"Handle",
"margins",
"and",
"padding",
"interactions"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.scale.js#L556-L564 | train | Set the padding to the right or bottom of the rectangle | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
2065,
1006,
2033,
1012,
17034,
1007,
1063,
2033,
1012,
11687,
4667,
2571,
6199,
1027,
8785,
1012,
4098,
1006,
2033,
1012,
11687,
4667,
2571,
6199,
1011,
2033,
1012,
17034,
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... | |
aws/aws-sdk-js | lib/response.js | nextPage | function nextPage(callback) {
var config;
var service = this.request.service;
var operation = this.request.operation;
try {
config = service.paginationConfig(operation, true);
} catch (e) { this.error = e; }
if (!this.hasNextPage()) {
if (callback) callback(this.error, null);
else if (this.error) throw this.error;
return null;
}
var params = AWS.util.copy(this.request.params);
if (!this.nextPageTokens) {
return callback ? callback(null, null) : null;
} else {
var inputTokens = config.inputToken;
if (typeof inputTokens === 'string') inputTokens = [inputTokens];
for (var i = 0; i < inputTokens.length; i++) {
params[inputTokens[i]] = this.nextPageTokens[i];
}
return service.makeRequest(this.request.operation, params, callback);
}
} | javascript | function nextPage(callback) {
var config;
var service = this.request.service;
var operation = this.request.operation;
try {
config = service.paginationConfig(operation, true);
} catch (e) { this.error = e; }
if (!this.hasNextPage()) {
if (callback) callback(this.error, null);
else if (this.error) throw this.error;
return null;
}
var params = AWS.util.copy(this.request.params);
if (!this.nextPageTokens) {
return callback ? callback(null, null) : null;
} else {
var inputTokens = config.inputToken;
if (typeof inputTokens === 'string') inputTokens = [inputTokens];
for (var i = 0; i < inputTokens.length; i++) {
params[inputTokens[i]] = this.nextPageTokens[i];
}
return service.makeRequest(this.request.operation, params, callback);
}
} | [
"function",
"nextPage",
"(",
"callback",
")",
"{",
"var",
"config",
";",
"var",
"service",
"=",
"this",
".",
"request",
".",
"service",
";",
"var",
"operation",
"=",
"this",
".",
"request",
".",
"operation",
";",
"try",
"{",
"config",
"=",
"service",
"... | Creates a new request for the next page of response data, calling the
callback with the page data if a callback is provided.
@callback callback function(err, data)
Called when a page of data is returned from the next request.
@param err [Error] an error object, if an error occurred in the request
@param data [Object] the next page of data, or null, if there are no
more pages left.
@return [AWS.Request] the request object for the next page of data
@return [null] if no callback is provided and there are no pages left
to retrieve.
@since v1.4.0 | [
"Creates",
"a",
"new",
"request",
"for",
"the",
"next",
"page",
"of",
"response",
"data",
"calling",
"the",
"callback",
"with",
"the",
"page",
"data",
"if",
"a",
"callback",
"is",
"provided",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/response.js#L132-L157 | train | Get the next page of the next page | [
30522,
3853,
2279,
13704,
1006,
2655,
5963,
1007,
1063,
13075,
9530,
8873,
2290,
1025,
13075,
2326,
1027,
2023,
1012,
5227,
1012,
2326,
1025,
13075,
3169,
1027,
2023,
1012,
5227,
1012,
3169,
1025,
3046,
1063,
9530,
8873,
2290,
1027,
2326,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | modules/layers/src/solid-polygon-layer/polygon.js | copyFlatRing | function copyFlatRing(target, targetStartIndex, positions, size, srcStartIndex = 0, srcEndIndex) {
srcEndIndex = srcEndIndex || positions.length;
const srcLength = srcEndIndex - srcStartIndex;
if (srcLength <= 0) {
return targetStartIndex;
}
let targetIndex = targetStartIndex;
for (let i = 0; i < srcLength; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
if (!isFlatRingClosed(positions, size, srcStartIndex, srcEndIndex)) {
for (let i = 0; i < size; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
}
return targetIndex;
} | javascript | function copyFlatRing(target, targetStartIndex, positions, size, srcStartIndex = 0, srcEndIndex) {
srcEndIndex = srcEndIndex || positions.length;
const srcLength = srcEndIndex - srcStartIndex;
if (srcLength <= 0) {
return targetStartIndex;
}
let targetIndex = targetStartIndex;
for (let i = 0; i < srcLength; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
if (!isFlatRingClosed(positions, size, srcStartIndex, srcEndIndex)) {
for (let i = 0; i < size; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
}
return targetIndex;
} | [
"function",
"copyFlatRing",
"(",
"target",
",",
"targetStartIndex",
",",
"positions",
",",
"size",
",",
"srcStartIndex",
"=",
"0",
",",
"srcEndIndex",
")",
"{",
"srcEndIndex",
"=",
"srcEndIndex",
"||",
"positions",
".",
"length",
";",
"const",
"srcLength",
"="... | Copy a simple flat array into another flat array, closes the ring if needed.
@param {Float64Array} target - destination
@param {Number} targetStartIndex - index in the destination to start copying into
@param {Array} positions - array of numbers
@param {Number} size - size of a position, 2 (xy) or 3 (xyz)
@param {Number} [srcStartIndex] - start index of the path in the positions array
@param {Number} [srcEndIndex] - end index of the path in the positions array
@returns {Number} - the index of the write head in the destination | [
"Copy",
"a",
"simple",
"flat",
"array",
"into",
"another",
"flat",
"array",
"closes",
"the",
"ring",
"if",
"needed",
"."
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/layers/src/solid-polygon-layer/polygon.js#L117-L135 | train | Copy a flat ring to a flat array | [
30522,
3853,
6100,
10258,
4017,
4892,
1006,
4539,
1010,
7889,
7559,
7629,
3207,
2595,
1010,
4460,
1010,
2946,
1010,
5034,
6169,
7559,
7629,
3207,
2595,
1027,
1014,
1010,
5034,
23865,
30524,
5034,
14321,
3070,
2705,
1027,
5034,
23865,
22254,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(sCurrency) {
// try to lookup currency digits from custom currencies
var mCustomCurrencies = this._get("currency");
if (mCustomCurrencies) {
if (mCustomCurrencies[sCurrency] && mCustomCurrencies[sCurrency].hasOwnProperty("digits")) {
return mCustomCurrencies[sCurrency].digits;
} else if (mCustomCurrencies["DEFAULT"] && mCustomCurrencies["DEFAULT"].hasOwnProperty("digits")) {
return mCustomCurrencies["DEFAULT"].digits;
}
}
var iDigits = this._get("currencyDigits", sCurrency);
if (iDigits == null) {
iDigits = this._get("currencyDigits", "DEFAULT");
if (iDigits == null) {
iDigits = 2; // default
}
}
return iDigits;
} | javascript | function(sCurrency) {
// try to lookup currency digits from custom currencies
var mCustomCurrencies = this._get("currency");
if (mCustomCurrencies) {
if (mCustomCurrencies[sCurrency] && mCustomCurrencies[sCurrency].hasOwnProperty("digits")) {
return mCustomCurrencies[sCurrency].digits;
} else if (mCustomCurrencies["DEFAULT"] && mCustomCurrencies["DEFAULT"].hasOwnProperty("digits")) {
return mCustomCurrencies["DEFAULT"].digits;
}
}
var iDigits = this._get("currencyDigits", sCurrency);
if (iDigits == null) {
iDigits = this._get("currencyDigits", "DEFAULT");
if (iDigits == null) {
iDigits = 2; // default
}
}
return iDigits;
} | [
"function",
"(",
"sCurrency",
")",
"{",
"// try to lookup currency digits from custom currencies",
"var",
"mCustomCurrencies",
"=",
"this",
".",
"_get",
"(",
"\"currency\"",
")",
";",
"if",
"(",
"mCustomCurrencies",
")",
"{",
"if",
"(",
"mCustomCurrencies",
"[",
"sC... | Returns the number of digits of the specified currency.
@param {string} sCurrency ISO 4217 currency code
@returns {int} digits of the currency
@public
@since 1.21.1 | [
"Returns",
"the",
"number",
"of",
"digits",
"of",
"the",
"specified",
"currency",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L963-L984 | train | Returns the number of digits for the given currency | [
30522,
3853,
1006,
8040,
3126,
7389,
5666,
1007,
1063,
1013,
1013,
3046,
2000,
2298,
6279,
9598,
16648,
2013,
7661,
12731,
14343,
14767,
13075,
11338,
19966,
5358,
10841,
14343,
14767,
1027,
2023,
1012,
1035,
2131,
1006,
1000,
9598,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue, sType) {
var sExpectedEdmType = sType === "And" || sType === "Or" ? "Edm.Boolean" : undefined;
// Note: it is safe to modify the caller's object here
oPathValue.complexBinding = false;
return SyncPromise.all([
Expression.parameter(oPathValue, 0, sExpectedEdmType),
Expression.parameter(oPathValue, 1, sExpectedEdmType)
]).then(function (aResults) {
var bNeedsCompare,
oParameter0 = aResults[0],
oParameter1 = aResults[1],
sSpecialType = "",
sValue0,
sValue1;
if (oParameter0.type !== "edm:Null" && oParameter1.type !== "edm:Null") {
oParameter0.category = mType2Category[oParameter0.type];
oParameter1.category = mType2Category[oParameter1.type];
Expression.adjustOperands(oParameter0, oParameter1);
Expression.adjustOperands(oParameter1, oParameter0);
if (oParameter0.category !== oParameter1.category) {
error(oPathValue, "Expected two comparable parameters but instead saw "
+ oParameter0.type + " and " + oParameter1.type);
}
switch (oParameter0.category) {
case "Decimal":
sSpecialType = ",'Decimal'";
break;
case "DateTimeOffset":
sSpecialType = ",'DateTime'";
break;
// no default
}
bNeedsCompare = mTypeCategoryNeedsCompare[oParameter0.category];
}
sValue0 = Expression.formatOperand(oParameter0, !bNeedsCompare);
sValue1 = Expression.formatOperand(oParameter1, !bNeedsCompare);
return {
result : "expression",
type : "Edm.Boolean",
value : bNeedsCompare
? "odata.compare(" + sValue0 + "," + sValue1 + sSpecialType + ")"
+ mOData2JSOperators[sType] + "0"
: sValue0 + mOData2JSOperators[sType] + sValue1
};
});
} | javascript | function (oPathValue, sType) {
var sExpectedEdmType = sType === "And" || sType === "Or" ? "Edm.Boolean" : undefined;
// Note: it is safe to modify the caller's object here
oPathValue.complexBinding = false;
return SyncPromise.all([
Expression.parameter(oPathValue, 0, sExpectedEdmType),
Expression.parameter(oPathValue, 1, sExpectedEdmType)
]).then(function (aResults) {
var bNeedsCompare,
oParameter0 = aResults[0],
oParameter1 = aResults[1],
sSpecialType = "",
sValue0,
sValue1;
if (oParameter0.type !== "edm:Null" && oParameter1.type !== "edm:Null") {
oParameter0.category = mType2Category[oParameter0.type];
oParameter1.category = mType2Category[oParameter1.type];
Expression.adjustOperands(oParameter0, oParameter1);
Expression.adjustOperands(oParameter1, oParameter0);
if (oParameter0.category !== oParameter1.category) {
error(oPathValue, "Expected two comparable parameters but instead saw "
+ oParameter0.type + " and " + oParameter1.type);
}
switch (oParameter0.category) {
case "Decimal":
sSpecialType = ",'Decimal'";
break;
case "DateTimeOffset":
sSpecialType = ",'DateTime'";
break;
// no default
}
bNeedsCompare = mTypeCategoryNeedsCompare[oParameter0.category];
}
sValue0 = Expression.formatOperand(oParameter0, !bNeedsCompare);
sValue1 = Expression.formatOperand(oParameter1, !bNeedsCompare);
return {
result : "expression",
type : "Edm.Boolean",
value : bNeedsCompare
? "odata.compare(" + sValue0 + "," + sValue1 + sSpecialType + ")"
+ mOData2JSOperators[sType] + "0"
: sValue0 + mOData2JSOperators[sType] + sValue1
};
});
} | [
"function",
"(",
"oPathValue",
",",
"sType",
")",
"{",
"var",
"sExpectedEdmType",
"=",
"sType",
"===",
"\"And\"",
"||",
"sType",
"===",
"\"Or\"",
"?",
"\"Edm.Boolean\"",
":",
"undefined",
";",
"// Note: it is safe to modify the caller's object here",
"oPathValue",
"."... | Handling of "14.5.1 Comparison and Logical Operators" except <code>edm:Not</code>.
@param {object} oPathValue
path and value information pointing to the parameter array (see Expression object)
@param {string} sType
the operator as text (like "And" or "Or")
@returns {sap.ui.base.SyncPromise}
a sync promise which resolves with the result object or is rejected with an error | [
"Handling",
"of",
"14",
".",
"5",
".",
"1",
"Comparison",
"and",
"Logical",
"Operators",
"except",
"<code",
">",
"edm",
":",
"Not<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L625-L674 | train | Returns an object with the parameters of the given type and the value of the given path. | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1010,
2358,
18863,
1007,
1063,
13075,
3348,
5051,
10985,
2098,
20492,
18863,
1027,
2358,
30524,
2000,
19933,
1996,
20587,
1005,
1055,
4874,
2182,
6728,
8988,
10175,
5657,
1012,
3375,
8428,
4667,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | docs/app/js/codepen.js | processJs | function processJs(jsFiles) {
var mergedJs = mergeFiles(jsFiles).join(' ');
var script = replaceDemoModuleWithCodepenModule(mergedJs);
return script;
} | javascript | function processJs(jsFiles) {
var mergedJs = mergeFiles(jsFiles).join(' ');
var script = replaceDemoModuleWithCodepenModule(mergedJs);
return script;
} | [
"function",
"processJs",
"(",
"jsFiles",
")",
"{",
"var",
"mergedJs",
"=",
"mergeFiles",
"(",
"jsFiles",
")",
".",
"join",
"(",
"' '",
")",
";",
"var",
"script",
"=",
"replaceDemoModuleWithCodepenModule",
"(",
"mergedJs",
")",
";",
"return",
"script",
";",
... | Applies modifications the javascript prior to sending to codepen. Currently merges js files and replaces the module with the Codepen module. See documentation for replaceDemoModuleWithCodepenModule. | [
"Applies",
"modifications",
"the",
"javascript",
"prior",
"to",
"sending",
"to",
"codepen",
".",
"Currently",
"merges",
"js",
"files",
"and",
"replaces",
"the",
"module",
"with",
"the",
"Codepen",
"module",
".",
"See",
"documentation",
"for",
"replaceDemoModuleWit... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L148-L152 | train | Process the JS files | [
30522,
3853,
2832,
22578,
1006,
1046,
22747,
9463,
2015,
1007,
1063,
13075,
5314,
22578,
1027,
13590,
8873,
4244,
1006,
1046,
22747,
9463,
2015,
1007,
1012,
3693,
1006,
1005,
1005,
1007,
1025,
13075,
5896,
1027,
2999,
6633,
19506,
8566,
257... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oAnnotations, sQualifiedName, bInContainer) {
var o = bInContainer
? oAnnotations.EntityContainer
: oAnnotations.propertyAnnotations;
return o && o[sQualifiedName] || {};
} | javascript | function (oAnnotations, sQualifiedName, bInContainer) {
var o = bInContainer
? oAnnotations.EntityContainer
: oAnnotations.propertyAnnotations;
return o && o[sQualifiedName] || {};
} | [
"function",
"(",
"oAnnotations",
",",
"sQualifiedName",
",",
"bInContainer",
")",
"{",
"var",
"o",
"=",
"bInContainer",
"?",
"oAnnotations",
".",
"EntityContainer",
":",
"oAnnotations",
".",
"propertyAnnotations",
";",
"return",
"o",
"&&",
"o",
"[",
"sQualifiedN... | Gets the map from child name to annotations for a parent with the given qualified
name which lives inside the entity container as indicated.
@param {sap.ui.model.odata.ODataAnnotations} oAnnotations
the OData annotations
@param {string} sQualifiedName
the parent's qualified name
@param {boolean} bInContainer
whether the parent lives inside the entity container (or beside it)
@returns {object}
the map from child name to annotations | [
"Gets",
"the",
"map",
"from",
"child",
"name",
"to",
"annotations",
"for",
"a",
"parent",
"with",
"the",
"given",
"qualified",
"name",
"which",
"lives",
"inside",
"the",
"entity",
"container",
"as",
"indicated",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L632-L637 | train | Returns the annotation for the given qualified name. | [
30522,
3853,
1006,
1051,
11639,
17287,
9285,
1010,
5490,
8787,
7810,
18442,
1010,
8026,
8663,
18249,
2121,
1007,
1063,
13075,
1051,
1027,
8026,
8663,
18249,
2121,
1029,
1051,
11639,
17287,
9285,
1012,
9178,
8663,
18249,
2121,
1024,
1051,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
facebook/watchman | node/bser/index.js | loadFromBuffer | function loadFromBuffer(input) {
var buf = new BunserBuf();
var result = buf.append(input, true);
if (buf.buf.readAvail()) {
throw Error(
'excess data found after input buffer, use BunserBuf instead');
}
if (typeof result === 'undefined') {
throw Error(
'no bser found in string and no error raised!?');
}
return result;
} | javascript | function loadFromBuffer(input) {
var buf = new BunserBuf();
var result = buf.append(input, true);
if (buf.buf.readAvail()) {
throw Error(
'excess data found after input buffer, use BunserBuf instead');
}
if (typeof result === 'undefined') {
throw Error(
'no bser found in string and no error raised!?');
}
return result;
} | [
"function",
"loadFromBuffer",
"(",
"input",
")",
"{",
"var",
"buf",
"=",
"new",
"BunserBuf",
"(",
")",
";",
"var",
"result",
"=",
"buf",
".",
"append",
"(",
"input",
",",
"true",
")",
";",
"if",
"(",
"buf",
".",
"buf",
".",
"readAvail",
"(",
")",
... | synchronously BSER decode a string and return the value | [
"synchronously",
"BSER",
"decode",
"a",
"string",
"and",
"return",
"the",
"value"
] | 8d576a2d3e1191c977f03f584993da63a3b8e5ec | https://github.com/facebook/watchman/blob/8d576a2d3e1191c977f03f584993da63a3b8e5ec/node/bser/index.js#L435-L447 | train | Load from buffer | [
30522,
3853,
7170,
19699,
5358,
8569,
12494,
1006,
7953,
1007,
1063,
13075,
20934,
2546,
1027,
2047,
21122,
8043,
8569,
2546,
1006,
1007,
1025,
13075,
2765,
1027,
20934,
2546,
1012,
10439,
10497,
1006,
7953,
1010,
2995,
1007,
1025,
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... |
angular/material | src/components/tooltip/tooltip.spec.js | buildTooltip | function buildTooltip(markup) {
element = $compile(markup)(parentScope);
parentScope.testModel = {};
parentScope.$apply();
$material.flushOutstandingAnimations();
return element;
} | javascript | function buildTooltip(markup) {
element = $compile(markup)(parentScope);
parentScope.testModel = {};
parentScope.$apply();
$material.flushOutstandingAnimations();
return element;
} | [
"function",
"buildTooltip",
"(",
"markup",
")",
"{",
"element",
"=",
"$compile",
"(",
"markup",
")",
"(",
"parentScope",
")",
";",
"parentScope",
".",
"testModel",
"=",
"{",
"}",
";",
"parentScope",
".",
"$apply",
"(",
")",
";",
"$material",
".",
"flushO... | ****************************************************** Internal Utility methods ****************************************************** | [
"******************************************************",
"Internal",
"Utility",
"methods",
"******************************************************"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tooltip/tooltip.spec.js#L537-L545 | train | Build tooltip element | [
30522,
3853,
3857,
3406,
27914,
11514,
1006,
2928,
6279,
1007,
1063,
5783,
1027,
1002,
4012,
22090,
1006,
2928,
6279,
1007,
1006,
3008,
16186,
1007,
1025,
3008,
16186,
1012,
3231,
5302,
9247,
1027,
1063,
1065,
1025,
3008,
16186,
1012,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.demokit/src/sap/ui/demokit/demoapps/controller/App.controller.js | function (sId, oBindingContext) {
var oBlockLayoutCell;
if (!oBindingContext.getObject().categoryId) { // demo app tile
if (oBindingContext.getObject().teaser) { // teaser cell (loads fragment from demo app)
try {
$.sap.registerResourcePath("test-resources","test-resources");
var sRelativePath = $.sap.getResourcePath(oBindingContext.getObject().teaser);
var oTeaser = sap.ui.xmlfragment(sId, sRelativePath);
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutTeaserCell", this);
oBlockLayoutCell.getContent()[0].addContent(oTeaser);
$.sap.registerResourcePath("test-resources",null);
} catch (oException) {
$.sap.log.warning("Teaser for demo app \"" + oBindingContext.getObject().name + "\" could not be loaded: " + oException);
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutCell", this);
}
} else { // normal cell
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutCell", this);
}
} else { // headline tile
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutHeadlineCell", this);
}
oBlockLayoutCell.setBindingContext(oBindingContext);
return oBlockLayoutCell;
} | javascript | function (sId, oBindingContext) {
var oBlockLayoutCell;
if (!oBindingContext.getObject().categoryId) { // demo app tile
if (oBindingContext.getObject().teaser) { // teaser cell (loads fragment from demo app)
try {
$.sap.registerResourcePath("test-resources","test-resources");
var sRelativePath = $.sap.getResourcePath(oBindingContext.getObject().teaser);
var oTeaser = sap.ui.xmlfragment(sId, sRelativePath);
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutTeaserCell", this);
oBlockLayoutCell.getContent()[0].addContent(oTeaser);
$.sap.registerResourcePath("test-resources",null);
} catch (oException) {
$.sap.log.warning("Teaser for demo app \"" + oBindingContext.getObject().name + "\" could not be loaded: " + oException);
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutCell", this);
}
} else { // normal cell
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutCell", this);
}
} else { // headline tile
oBlockLayoutCell = sap.ui.xmlfragment(sId, "sap.ui.demokit.demoapps.view.BlockLayoutHeadlineCell", this);
}
oBlockLayoutCell.setBindingContext(oBindingContext);
return oBlockLayoutCell;
} | [
"function",
"(",
"sId",
",",
"oBindingContext",
")",
"{",
"var",
"oBlockLayoutCell",
";",
"if",
"(",
"!",
"oBindingContext",
".",
"getObject",
"(",
")",
".",
"categoryId",
")",
"{",
"// demo app tile",
"if",
"(",
"oBindingContext",
".",
"getObject",
"(",
")"... | /* =========================================================== /* lifecycle methods /* ===========================================================
Factory function for creating the demo app cells
@param {string} sId the id for the current cell
@param {sap.ui.model.Context} oBindingContext the context for the current cell
@return {sap.ui.layout.BlockLayoutCell} either a header cell or a demo app cell based on the metadata in the model
@public | [
"/",
"*",
"===========================================================",
"/",
"*",
"lifecycle",
"methods",
"/",
"*",
"===========================================================",
"Factory",
"function",
"for",
"creating",
"the",
"demo",
"app",
"cells"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/demoapps/controller/App.controller.js#L126-L150 | train | Creates a cell for the given id. | [
30522,
3853,
1006,
15765,
1010,
27885,
22254,
2075,
8663,
18209,
1007,
1063,
13075,
27885,
7878,
8485,
5833,
29109,
2140,
1025,
2065,
1006,
999,
27885,
22254,
2075,
8663,
18209,
1012,
2131,
16429,
20614,
1006,
1007,
1012,
4696,
3593,
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... | |
jgraph/mxgraph | javascript/mxClient.js | function(obj, transients, shallow)
{
shallow = (shallow != null) ? shallow : false;
var clone = null;
if (obj != null && typeof(obj.constructor) == 'function')
{
clone = new obj.constructor();
for (var i in obj)
{
if (i != mxObjectIdentity.FIELD_NAME && (transients == null ||
mxUtils.indexOf(transients, i) < 0))
{
if (!shallow && typeof(obj[i]) == 'object')
{
clone[i] = mxUtils.clone(obj[i]);
}
else
{
clone[i] = obj[i];
}
}
}
}
return clone;
} | javascript | function(obj, transients, shallow)
{
shallow = (shallow != null) ? shallow : false;
var clone = null;
if (obj != null && typeof(obj.constructor) == 'function')
{
clone = new obj.constructor();
for (var i in obj)
{
if (i != mxObjectIdentity.FIELD_NAME && (transients == null ||
mxUtils.indexOf(transients, i) < 0))
{
if (!shallow && typeof(obj[i]) == 'object')
{
clone[i] = mxUtils.clone(obj[i]);
}
else
{
clone[i] = obj[i];
}
}
}
}
return clone;
} | [
"function",
"(",
"obj",
",",
"transients",
",",
"shallow",
")",
"{",
"shallow",
"=",
"(",
"shallow",
"!=",
"null",
")",
"?",
"shallow",
":",
"false",
";",
"var",
"clone",
"=",
"null",
";",
"if",
"(",
"obj",
"!=",
"null",
"&&",
"typeof",
"(",
"obj",... | Function: clone
Recursively clones the specified object ignoring all fieldnames in the
given array of transient fields. <mxObjectIdentity.FIELD_NAME> is always
ignored by this function.
Parameters:
obj - Object to be cloned.
transients - Optional array of strings representing the fieldname to be
ignored.
shallow - Optional boolean argument to specify if a shallow clone should
be created, that is, one where all object references are not cloned or,
in other words, one where only atomic (strings, numbers) values are
cloned. Default is false. | [
"Function",
":",
"clone"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3859-L3886 | train | Clones an object | [
30522,
3853,
1006,
27885,
3501,
1010,
25354,
2015,
1010,
8467,
1007,
1063,
8467,
1027,
1006,
8467,
999,
1027,
19701,
1007,
1029,
8467,
1024,
6270,
1025,
13075,
17598,
1027,
19701,
1025,
2065,
1006,
27885,
3501,
999,
1027,
19701,
1004,
1004,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ipfs/js-ipfs | src/core/components/pin.js | flushPins | function flushPins (callback) {
let dLink, rLink, root
series([
// create a DAGLink to the node with direct pins
cb => waterfall([
cb => pinset.storeSet(directKeys(), cb),
({ node, cid }, cb) => DAGLink.create(types.direct, node.size, cid, cb),
(link, cb) => { dLink = link; cb(null) }
], cb),
// create a DAGLink to the node with recursive pins
cb => waterfall([
cb => pinset.storeSet(recursiveKeys(), cb),
({ node, cid }, cb) => DAGLink.create(types.recursive, node.size, cid, cb),
(link, cb) => { rLink = link; cb(null) }
], cb),
// the pin-set nodes link to a special 'empty' node, so make sure it exists
cb => DAGNode.create(Buffer.alloc(0), (err, empty) => {
if (err) { return cb(err) }
dag.put(empty, {
version: 0,
hashAlg: 'sha2-256',
format: 'dag-pb',
preload: false
}, cb)
}),
// create a root node with DAGLinks to the direct and recursive DAGs
cb => DAGNode.create(Buffer.alloc(0), [dLink, rLink], (err, node) => {
if (err) { return cb(err) }
root = node
dag.put(root, {
version: 0,
hashAlg: 'sha2-256',
format: 'dag-pb',
preload: false
}, (err, cid) => {
if (!err) {
root.multihash = cid.buffer
}
cb(err)
})
}),
// hack for CLI tests
cb => repo.closed ? repo.open(cb) : cb(null, null),
// save root to datastore under a consistent key
cb => repo.datastore.put(pinDataStoreKey, root.multihash, cb)
], (err, res) => {
if (err) { return callback(err) }
self.log(`Flushed pins with root: ${root}`)
return callback(null, root)
})
} | javascript | function flushPins (callback) {
let dLink, rLink, root
series([
// create a DAGLink to the node with direct pins
cb => waterfall([
cb => pinset.storeSet(directKeys(), cb),
({ node, cid }, cb) => DAGLink.create(types.direct, node.size, cid, cb),
(link, cb) => { dLink = link; cb(null) }
], cb),
// create a DAGLink to the node with recursive pins
cb => waterfall([
cb => pinset.storeSet(recursiveKeys(), cb),
({ node, cid }, cb) => DAGLink.create(types.recursive, node.size, cid, cb),
(link, cb) => { rLink = link; cb(null) }
], cb),
// the pin-set nodes link to a special 'empty' node, so make sure it exists
cb => DAGNode.create(Buffer.alloc(0), (err, empty) => {
if (err) { return cb(err) }
dag.put(empty, {
version: 0,
hashAlg: 'sha2-256',
format: 'dag-pb',
preload: false
}, cb)
}),
// create a root node with DAGLinks to the direct and recursive DAGs
cb => DAGNode.create(Buffer.alloc(0), [dLink, rLink], (err, node) => {
if (err) { return cb(err) }
root = node
dag.put(root, {
version: 0,
hashAlg: 'sha2-256',
format: 'dag-pb',
preload: false
}, (err, cid) => {
if (!err) {
root.multihash = cid.buffer
}
cb(err)
})
}),
// hack for CLI tests
cb => repo.closed ? repo.open(cb) : cb(null, null),
// save root to datastore under a consistent key
cb => repo.datastore.put(pinDataStoreKey, root.multihash, cb)
], (err, res) => {
if (err) { return callback(err) }
self.log(`Flushed pins with root: ${root}`)
return callback(null, root)
})
} | [
"function",
"flushPins",
"(",
"callback",
")",
"{",
"let",
"dLink",
",",
"rLink",
",",
"root",
"series",
"(",
"[",
"// create a DAGLink to the node with direct pins",
"cb",
"=>",
"waterfall",
"(",
"[",
"cb",
"=>",
"pinset",
".",
"storeSet",
"(",
"directKeys",
... | Encode and write pin key sets to the datastore: a DAGLink for each of the recursive and direct pinsets a DAGNode holding those as DAGLinks, a kind of root pin | [
"Encode",
"and",
"write",
"pin",
"key",
"sets",
"to",
"the",
"datastore",
":",
"a",
"DAGLink",
"for",
"each",
"of",
"the",
"recursive",
"and",
"direct",
"pinsets",
"a",
"DAGNode",
"holding",
"those",
"as",
"DAGLinks",
"a",
"kind",
"of",
"root",
"pin"
] | 97e67601094acda3906549ecb0248fd09f1a8cc3 | https://github.com/ipfs/js-ipfs/blob/97e67601094acda3906549ecb0248fd09f1a8cc3/src/core/components/pin.js#L85-L140 | train | Flushes all pins to the datastore | [
30522,
3853,
13862,
27915,
1006,
2655,
5963,
1007,
1063,
2292,
21469,
19839,
1010,
1054,
13767,
1010,
7117,
2186,
1006,
1031,
1013,
1013,
3443,
1037,
4830,
25394,
8950,
2000,
1996,
13045,
2007,
3622,
16300,
17324,
1027,
1028,
14297,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | dist/js/materialize.js | destroy | function destroy() {
ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.$el), 1);
ScrollSpy._count--;
this._removeEventHandlers();
$(this.options.getActiveElement(this.$el.attr('id'))).removeClass(this.options.activeClass);
this.el.M_ScrollSpy = undefined;
} | javascript | function destroy() {
ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
ScrollSpy._elementsInView.splice(ScrollSpy._elementsInView.indexOf(this), 1);
ScrollSpy._visibleElements.splice(ScrollSpy._visibleElements.indexOf(this.$el), 1);
ScrollSpy._count--;
this._removeEventHandlers();
$(this.options.getActiveElement(this.$el.attr('id'))).removeClass(this.options.activeClass);
this.el.M_ScrollSpy = undefined;
} | [
"function",
"destroy",
"(",
")",
"{",
"ScrollSpy",
".",
"_elements",
".",
"splice",
"(",
"ScrollSpy",
".",
"_elements",
".",
"indexOf",
"(",
"this",
")",
",",
"1",
")",
";",
"ScrollSpy",
".",
"_elementsInView",
".",
"splice",
"(",
"ScrollSpy",
".",
"_ele... | Teardown component | [
"Teardown",
"component"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L6164-L6172 | train | Destroy the element | [
30522,
3853,
6033,
1006,
1007,
1063,
23074,
7685,
1012,
1035,
3787,
1012,
11867,
13231,
1006,
23074,
7685,
1012,
1035,
3787,
1012,
5950,
11253,
1006,
2023,
1007,
1010,
1015,
1007,
1025,
23074,
7685,
1012,
1035,
3787,
2378,
8584,
1012,
11867... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/extensions/table/wwMergedTableManager.js | any | function any(arr, contition) {
let result = false;
util.forEach(arr, item => {
result = contition(item);
return !result;
});
return result;
} | javascript | function any(arr, contition) {
let result = false;
util.forEach(arr, item => {
result = contition(item);
return !result;
});
return result;
} | [
"function",
"any",
"(",
"arr",
",",
"contition",
")",
"{",
"let",
"result",
"=",
"false",
";",
"util",
".",
"forEach",
"(",
"arr",
",",
"item",
"=>",
"{",
"result",
"=",
"contition",
"(",
"item",
")",
";",
"return",
"!",
"result",
";",
"}",
")",
... | Whether one of them is true or not.
@param {Array} arr - target array
@param {function} contition - condition function
@returns {boolean}
@ignore | [
"Whether",
"one",
"of",
"them",
"is",
"true",
"or",
"not",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/wwMergedTableManager.js#L543-L553 | train | Check if any item in an array is a non - empty | [
30522,
3853,
2151,
1006,
12098,
2099,
1010,
9530,
3775,
3508,
1007,
1063,
2292,
2765,
1027,
6270,
1025,
21183,
4014,
1012,
18921,
6776,
1006,
12098,
2099,
1010,
8875,
1027,
1028,
1063,
2765,
1027,
9530,
3775,
3508,
1006,
8875,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/tabs/js/tabsController.js | handleFocusIndexChange | function handleFocusIndexChange (newIndex, oldIndex) {
if (newIndex === oldIndex) return;
if (!getElements().tabs[ newIndex ]) return;
adjustOffset();
redirectFocus();
} | javascript | function handleFocusIndexChange (newIndex, oldIndex) {
if (newIndex === oldIndex) return;
if (!getElements().tabs[ newIndex ]) return;
adjustOffset();
redirectFocus();
} | [
"function",
"handleFocusIndexChange",
"(",
"newIndex",
",",
"oldIndex",
")",
"{",
"if",
"(",
"newIndex",
"===",
"oldIndex",
")",
"return",
";",
"if",
"(",
"!",
"getElements",
"(",
")",
".",
"tabs",
"[",
"newIndex",
"]",
")",
"return",
";",
"adjustOffset",
... | Update the UI whenever `ctrl.focusIndex` is updated
@param {number} newIndex
@param {number} oldIndex | [
"Update",
"the",
"UI",
"whenever",
"ctrl",
".",
"focusIndex",
"is",
"updated"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L248-L253 | train | Handle focus index change | [
30522,
3853,
5047,
14876,
7874,
22254,
10288,
22305,
2063,
1006,
2047,
22254,
10288,
1010,
2214,
22254,
10288,
1007,
1063,
2065,
1006,
2047,
22254,
10288,
1027,
1027,
1027,
2214,
22254,
10288,
1007,
2709,
1025,
2065,
1006,
999,
2131,
12260,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.demokit/src/sap/ui/demokit/explored/view/base.controller.js | function () {
var sJson = this._oStorage.get(this._sStorageKey);
if (!sJson) {
// local storage is empty, apply defaults
this._oViewSettings = this._oDefaultSettings;
} else {
// parse
this._oViewSettings = JSON.parse(sJson);
// clean filter and remove values that do not exist any longer in the data model
// (the cleaned filter are not written back to local storage, this only happens on changing the view settings)
//var oFilterData = this.getView().getModel("filter").getData();
var oFilterData = this.getOwnerComponent().getModel("filter").getData();
var oCleanFilter = {};
jQuery.each(this._oViewSettings.filter, function (sProperty, aValues) {
var aNewValues = [];
jQuery.each(aValues, function (i, aValue) {
var bValueIsClean = false;
jQuery.each(oFilterData[sProperty], function (i, oValue) {
if (oValue.id === aValue) {
bValueIsClean = true;
return false;
}
});
if (bValueIsClean) {
aNewValues.push(aValue);
}
});
if (aNewValues.length > 0) {
oCleanFilter[sProperty] = aNewValues;
}
});
this._oViewSettings.filter = oCleanFilter;
// handling data stored with an older explored versions
if (!this._oViewSettings.hasOwnProperty("compactOn")) { // compactOn was introduced later
this._oViewSettings.compactOn = false;
}
if (!this._oViewSettings.hasOwnProperty("themeActive")) { // themeActive was introduced later
this._oViewSettings.themeActive = "sap_bluecrystal";
} else if (this._oViewSettings.version !== this._oDefaultSettings.version) {
var oVersion = jQuery.sap.Version(sap.ui.version);
if (oVersion.compareTo("1.40.0") >= 0) { // Belize theme is available since 1.40
this._oViewSettings.themeActive = "sap_belize";
} else { // Fallback to BlueCrystal for older versions
this._oViewSettings.themeActive = "sap_bluecrystal";
}
}
if (!this._oViewSettings.hasOwnProperty("rtl")) { // rtl was introduced later
this._oViewSettings.rtl = false;
}
// handle RTL-on in settings as this need a reload
if (this._oViewSettings.rtl && !jQuery.sap.getUriParameters().get('sap-ui-rtl')) {
this._handleRTL(true);
}
}
} | javascript | function () {
var sJson = this._oStorage.get(this._sStorageKey);
if (!sJson) {
// local storage is empty, apply defaults
this._oViewSettings = this._oDefaultSettings;
} else {
// parse
this._oViewSettings = JSON.parse(sJson);
// clean filter and remove values that do not exist any longer in the data model
// (the cleaned filter are not written back to local storage, this only happens on changing the view settings)
//var oFilterData = this.getView().getModel("filter").getData();
var oFilterData = this.getOwnerComponent().getModel("filter").getData();
var oCleanFilter = {};
jQuery.each(this._oViewSettings.filter, function (sProperty, aValues) {
var aNewValues = [];
jQuery.each(aValues, function (i, aValue) {
var bValueIsClean = false;
jQuery.each(oFilterData[sProperty], function (i, oValue) {
if (oValue.id === aValue) {
bValueIsClean = true;
return false;
}
});
if (bValueIsClean) {
aNewValues.push(aValue);
}
});
if (aNewValues.length > 0) {
oCleanFilter[sProperty] = aNewValues;
}
});
this._oViewSettings.filter = oCleanFilter;
// handling data stored with an older explored versions
if (!this._oViewSettings.hasOwnProperty("compactOn")) { // compactOn was introduced later
this._oViewSettings.compactOn = false;
}
if (!this._oViewSettings.hasOwnProperty("themeActive")) { // themeActive was introduced later
this._oViewSettings.themeActive = "sap_bluecrystal";
} else if (this._oViewSettings.version !== this._oDefaultSettings.version) {
var oVersion = jQuery.sap.Version(sap.ui.version);
if (oVersion.compareTo("1.40.0") >= 0) { // Belize theme is available since 1.40
this._oViewSettings.themeActive = "sap_belize";
} else { // Fallback to BlueCrystal for older versions
this._oViewSettings.themeActive = "sap_bluecrystal";
}
}
if (!this._oViewSettings.hasOwnProperty("rtl")) { // rtl was introduced later
this._oViewSettings.rtl = false;
}
// handle RTL-on in settings as this need a reload
if (this._oViewSettings.rtl && !jQuery.sap.getUriParameters().get('sap-ui-rtl')) {
this._handleRTL(true);
}
}
} | [
"function",
"(",
")",
"{",
"var",
"sJson",
"=",
"this",
".",
"_oStorage",
".",
"get",
"(",
"this",
".",
"_sStorageKey",
")",
";",
"if",
"(",
"!",
"sJson",
")",
"{",
"// local storage is empty, apply defaults",
"this",
".",
"_oViewSettings",
"=",
"this",
".... | Inits the view settings. At first local storage is checked. If this is empty defaults are applied. | [
"Inits",
"the",
"view",
"settings",
".",
"At",
"first",
"local",
"storage",
"is",
"checked",
".",
"If",
"this",
"is",
"empty",
"defaults",
"are",
"applied",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/explored/view/base.controller.js#L56-L118 | train | This function is called when the view is being rendered | [
30522,
3853,
1006,
1007,
1063,
13075,
1055,
22578,
2239,
1027,
2023,
1012,
1035,
9808,
4263,
4270,
1012,
2131,
1006,
2023,
1012,
1035,
7020,
4263,
4270,
14839,
1007,
1025,
2065,
1006,
999,
1055,
22578,
2239,
1007,
1063,
1013,
1013,
2334,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
radare/radare2 | shlr/www/graph/js-graph-it.js | Block | function Block(htmlElement, canvas)
{
/*
* initialization
*/
this.canvas = canvas;
this.htmlElement = htmlElement;
this.id = htmlElement.id;
this.blocks = new Array();
this.moveListeners = new Array();
if(this.id == 'description2_out1')
var merda = 0;
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
this.visit = function(element) {
if (element == this.htmlElement) {
// exclude itself
return true;
}
if (isBlock(element)) {
var innerBlock = new Block(element, this.canvas);
innerBlock.initBlock();
this.blocks.push(innerBlock);
this.moveListeners.push(innerBlock);
return false;
}
return true;
}
this.initBlock = function() {
// inspect block children to identify nested blocks
new DocumentScanner(this, true).scan(this.htmlElement);
}
this.top = function() {
return this.currentTop;
}
this.left = function() {
return this.currentLeft;
}
this.width = function() {
return this.htmlElement.offsetWidth;
}
this.height = function() {
return this.htmlElement.offsetHeight;
}
/*
* methods
*/
this.print = function() {
var output = 'block: ' + this.id;
if (this.blocks.length > 0) {
output += '<ul>';
for(var i = 0; i < this.blocks.length; i++) {
output += '<li>';
output += this.blocks[i].print();
output += '</li>';
}
output += '</ul>';
}
return output;
}
/*
* This function searches for a nested block (or the block itself) with a given id
*/
this.findBlock = function(blockId) {
if(this.id == blockId)
return this;
var result;
for(var i = 0; i < this.blocks.length && !result; i++)
result = this.blocks[i].findBlock(blockId);
return result;
}
this.fit = function() {
function getlines(txt) {
return (12*txt.split ("\n").length);
}
function getcolumns(txt) {
var cols = 0;
var txts = txt.split ("\n");
for (var x in txts) {
const len = txts[x].length;
if (len>cols)
cols = len;
}
return 10+ (7*cols);
}
var text = this.htmlElement.innerHTML;
this.htmlElement.style.width = getcolumns (text);
this.htmlElement.style.height = getlines (text);
}
this.move = function(left, top) {
this.htmlElement.style.left = left;
this.htmlElement.style.top = top;
this.onMove();
}
this.onMove = function() {
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
// notify listeners
for(var i = 0; i < this.moveListeners.length; i++)
this.moveListeners[i].onMove();
}
this.toString = function() {
return 'block: ' + this.id;
}
} | javascript | function Block(htmlElement, canvas)
{
/*
* initialization
*/
this.canvas = canvas;
this.htmlElement = htmlElement;
this.id = htmlElement.id;
this.blocks = new Array();
this.moveListeners = new Array();
if(this.id == 'description2_out1')
var merda = 0;
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
this.visit = function(element) {
if (element == this.htmlElement) {
// exclude itself
return true;
}
if (isBlock(element)) {
var innerBlock = new Block(element, this.canvas);
innerBlock.initBlock();
this.blocks.push(innerBlock);
this.moveListeners.push(innerBlock);
return false;
}
return true;
}
this.initBlock = function() {
// inspect block children to identify nested blocks
new DocumentScanner(this, true).scan(this.htmlElement);
}
this.top = function() {
return this.currentTop;
}
this.left = function() {
return this.currentLeft;
}
this.width = function() {
return this.htmlElement.offsetWidth;
}
this.height = function() {
return this.htmlElement.offsetHeight;
}
/*
* methods
*/
this.print = function() {
var output = 'block: ' + this.id;
if (this.blocks.length > 0) {
output += '<ul>';
for(var i = 0; i < this.blocks.length; i++) {
output += '<li>';
output += this.blocks[i].print();
output += '</li>';
}
output += '</ul>';
}
return output;
}
/*
* This function searches for a nested block (or the block itself) with a given id
*/
this.findBlock = function(blockId) {
if(this.id == blockId)
return this;
var result;
for(var i = 0; i < this.blocks.length && !result; i++)
result = this.blocks[i].findBlock(blockId);
return result;
}
this.fit = function() {
function getlines(txt) {
return (12*txt.split ("\n").length);
}
function getcolumns(txt) {
var cols = 0;
var txts = txt.split ("\n");
for (var x in txts) {
const len = txts[x].length;
if (len>cols)
cols = len;
}
return 10+ (7*cols);
}
var text = this.htmlElement.innerHTML;
this.htmlElement.style.width = getcolumns (text);
this.htmlElement.style.height = getlines (text);
}
this.move = function(left, top) {
this.htmlElement.style.left = left;
this.htmlElement.style.top = top;
this.onMove();
}
this.onMove = function() {
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
// notify listeners
for(var i = 0; i < this.moveListeners.length; i++)
this.moveListeners[i].onMove();
}
this.toString = function() {
return 'block: ' + this.id;
}
} | [
"function",
"Block",
"(",
"htmlElement",
",",
"canvas",
")",
"{",
"/*\n\t * initialization\n\t */",
"this",
".",
"canvas",
"=",
"canvas",
";",
"this",
".",
"htmlElement",
"=",
"htmlElement",
";",
"this",
".",
"id",
"=",
"htmlElement",
".",
"id",
";",
"this",... | /*
Block class | [
"/",
"*",
"Block",
"class"
] | bf5e3028810a0ec7c267c6fe4bfad639b4819e35 | https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L387-L505 | train | Block constructor. | [
30522,
3853,
3796,
1006,
16129,
12260,
3672,
1010,
10683,
1007,
1063,
1013,
1008,
1008,
3988,
3989,
1008,
1013,
2023,
1012,
10683,
1027,
10683,
1025,
2023,
1012,
16129,
12260,
3672,
1027,
16129,
12260,
3672,
1025,
2023,
1012,
8909,
1027,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/MessageBox.js | button | function button(sAction) {
var sText;
// Don't check in ResourceBundle library if the button is with custom text
if (MessageBox.Action.hasOwnProperty(sAction)) {
sText = MessageBox._rb.getText("MSGBOX_" + sAction);
}
var oButton = new Button({
id: ElementMetadata.uid("mbox-btn-"),
text: sText || sAction,
press: function () {
oResult = sAction;
oDialog.close();
}
});
return oButton;
} | javascript | function button(sAction) {
var sText;
// Don't check in ResourceBundle library if the button is with custom text
if (MessageBox.Action.hasOwnProperty(sAction)) {
sText = MessageBox._rb.getText("MSGBOX_" + sAction);
}
var oButton = new Button({
id: ElementMetadata.uid("mbox-btn-"),
text: sText || sAction,
press: function () {
oResult = sAction;
oDialog.close();
}
});
return oButton;
} | [
"function",
"button",
"(",
"sAction",
")",
"{",
"var",
"sText",
";",
"// Don't check in ResourceBundle library if the button is with custom text",
"if",
"(",
"MessageBox",
".",
"Action",
".",
"hasOwnProperty",
"(",
"sAction",
")",
")",
"{",
"sText",
"=",
"MessageBox",... | creates a button for the given action | [
"creates",
"a",
"button",
"for",
"the",
"given",
"action"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/MessageBox.js#L324-L341 | train | Create a button | [
30522,
3853,
6462,
1006,
17266,
3508,
1007,
1063,
13075,
26261,
18413,
1025,
1013,
1013,
2123,
1005,
1056,
4638,
1999,
7692,
27265,
2571,
3075,
2065,
1996,
6462,
2003,
2007,
7661,
3793,
2065,
1006,
4471,
8758,
1012,
2895,
1012,
2038,
12384,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Microsoft/vscode | build/gulpfile.vscode.js | computeChecksum | function computeChecksum(filename) {
var contents = fs.readFileSync(filename);
var hash = crypto
.createHash('md5')
.update(contents)
.digest('base64')
.replace(/=+$/, '');
return hash;
} | javascript | function computeChecksum(filename) {
var contents = fs.readFileSync(filename);
var hash = crypto
.createHash('md5')
.update(contents)
.digest('base64')
.replace(/=+$/, '');
return hash;
} | [
"function",
"computeChecksum",
"(",
"filename",
")",
"{",
"var",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
")",
";",
"var",
"hash",
"=",
"crypto",
".",
"createHash",
"(",
"'md5'",
")",
".",
"update",
"(",
"contents",
")",
".",
"digest"... | Compute checksum for a file.
@param {string} filename The absolute path to a filename.
@return {string} The checksum for `filename`. | [
"Compute",
"checksum",
"for",
"a",
"file",
"."
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/gulpfile.vscode.js#L245-L255 | train | Compute the checksum of a file | [
30522,
3853,
24134,
5403,
10603,
2819,
1006,
5371,
18442,
1007,
1063,
13075,
8417,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
5371,
18442,
1007,
1025,
13075,
23325,
1027,
19888,
2080,
1012,
3443,
14949,
2232,
1006,
1005,
91... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-runtime/store/RelayModernRecord.js | create | function create(dataID: DataID, typeName: string): Record {
// See perf note above for why we aren't using computed property access.
const record = {};
record[ID_KEY] = dataID;
record[TYPENAME_KEY] = typeName;
return record;
} | javascript | function create(dataID: DataID, typeName: string): Record {
// See perf note above for why we aren't using computed property access.
const record = {};
record[ID_KEY] = dataID;
record[TYPENAME_KEY] = typeName;
return record;
} | [
"function",
"create",
"(",
"dataID",
":",
"DataID",
",",
"typeName",
":",
"string",
")",
":",
"Record",
"{",
"// See perf note above for why we aren't using computed property access.",
"const",
"record",
"=",
"{",
"}",
";",
"record",
"[",
"ID_KEY",
"]",
"=",
"data... | @public
Create a new record. | [
"@public"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/store/RelayModernRecord.js#L110-L116 | train | Creates a new Record object. | [
30522,
3853,
3443,
1006,
2951,
3593,
1024,
2951,
3593,
1010,
2828,
18442,
1024,
5164,
1007,
1024,
2501,
1063,
1013,
1013,
2156,
2566,
2546,
3602,
2682,
2005,
2339,
2057,
4995,
1005,
1056,
2478,
24806,
3200,
3229,
1012,
9530,
3367,
2501,
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... |
mui-org/material-ui | packages/material-ui-styles/src/styled/styled.js | styled | function styled(Component) {
const componentCreator = (style, options = {}) => {
const { name, ...stylesOptions } = options;
if (process.env.NODE_ENV !== 'production' && Component === undefined) {
throw new Error(
[
'You are calling styled(Component)(style) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production' && !name) {
// Provide a better DX outside production.
classNamePrefix = getDisplayName(Component);
warning(
typeof classNamePrefix === 'string',
[
'Material-UI: the component displayName is invalid. It needs to be a string.',
`Please fix the following component: ${Component}.`,
].join('\n'),
);
}
const stylesOrCreator =
typeof style === 'function'
? theme => ({ root: props => style({ theme, ...props }) })
: { root: style };
const useStyles = makeStyles(stylesOrCreator, {
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
});
let filterProps;
let propTypes = {};
if (style.filterProps) {
filterProps = style.filterProps;
delete style.filterProps;
}
/* eslint-disable react/forbid-foreign-prop-types */
if (style.propTypes) {
propTypes = style.propTypes;
delete style.propTypes;
}
/* eslint-enable react/forbid-foreign-prop-types */
const StyledComponent = React.forwardRef(function StyledComponent(props, ref) {
const {
children,
className: classNameProp,
clone,
component: ComponentProp,
...other
} = props;
const classes = useStyles(props);
const className = clsx(classes.root, classNameProp);
if (clone) {
return React.cloneElement(children, {
className: clsx(children.props.className, className),
});
}
let spread = other;
if (filterProps) {
spread = omit(spread, filterProps);
}
if (typeof children === 'function') {
return children({ className, ...spread });
}
const FinalComponent = ComponentProp || Component;
return (
<FinalComponent ref={ref} className={className} {...spread}>
{children}
</FinalComponent>
);
});
StyledComponent.propTypes = {
/**
* A render function or node.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component will recycle it's children DOM element.
* It's using `React.cloneElement` internally.
*/
clone: chainPropTypes(PropTypes.bool, props => {
if (props.clone && props.component) {
return new Error('You can not use the clone and component properties at the same time.');
}
return null;
}),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
...propTypes,
};
if (process.env.NODE_ENV !== 'production') {
StyledComponent.displayName = `Styled(${classNamePrefix})`;
}
hoistNonReactStatics(StyledComponent, Component);
return StyledComponent;
};
return componentCreator;
} | javascript | function styled(Component) {
const componentCreator = (style, options = {}) => {
const { name, ...stylesOptions } = options;
if (process.env.NODE_ENV !== 'production' && Component === undefined) {
throw new Error(
[
'You are calling styled(Component)(style) with an undefined component.',
'You may have forgotten to import it.',
].join('\n'),
);
}
let classNamePrefix = name;
if (process.env.NODE_ENV !== 'production' && !name) {
// Provide a better DX outside production.
classNamePrefix = getDisplayName(Component);
warning(
typeof classNamePrefix === 'string',
[
'Material-UI: the component displayName is invalid. It needs to be a string.',
`Please fix the following component: ${Component}.`,
].join('\n'),
);
}
const stylesOrCreator =
typeof style === 'function'
? theme => ({ root: props => style({ theme, ...props }) })
: { root: style };
const useStyles = makeStyles(stylesOrCreator, {
Component,
name: name || Component.displayName,
classNamePrefix,
...stylesOptions,
});
let filterProps;
let propTypes = {};
if (style.filterProps) {
filterProps = style.filterProps;
delete style.filterProps;
}
/* eslint-disable react/forbid-foreign-prop-types */
if (style.propTypes) {
propTypes = style.propTypes;
delete style.propTypes;
}
/* eslint-enable react/forbid-foreign-prop-types */
const StyledComponent = React.forwardRef(function StyledComponent(props, ref) {
const {
children,
className: classNameProp,
clone,
component: ComponentProp,
...other
} = props;
const classes = useStyles(props);
const className = clsx(classes.root, classNameProp);
if (clone) {
return React.cloneElement(children, {
className: clsx(children.props.className, className),
});
}
let spread = other;
if (filterProps) {
spread = omit(spread, filterProps);
}
if (typeof children === 'function') {
return children({ className, ...spread });
}
const FinalComponent = ComponentProp || Component;
return (
<FinalComponent ref={ref} className={className} {...spread}>
{children}
</FinalComponent>
);
});
StyledComponent.propTypes = {
/**
* A render function or node.
*/
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
/**
* @ignore
*/
className: PropTypes.string,
/**
* If `true`, the component will recycle it's children DOM element.
* It's using `React.cloneElement` internally.
*/
clone: chainPropTypes(PropTypes.bool, props => {
if (props.clone && props.component) {
return new Error('You can not use the clone and component properties at the same time.');
}
return null;
}),
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.elementType,
...propTypes,
};
if (process.env.NODE_ENV !== 'production') {
StyledComponent.displayName = `Styled(${classNamePrefix})`;
}
hoistNonReactStatics(StyledComponent, Component);
return StyledComponent;
};
return componentCreator;
} | [
"function",
"styled",
"(",
"Component",
")",
"{",
"const",
"componentCreator",
"=",
"(",
"style",
",",
"options",
"=",
"{",
"}",
")",
"=>",
"{",
"const",
"{",
"name",
",",
"...",
"stylesOptions",
"}",
"=",
"options",
";",
"if",
"(",
"process",
".",
"... | styled-components's API removes the mapping between components and styles. Using components as a low-level styling construct can be simpler. | [
"styled",
"-",
"components",
"s",
"API",
"removes",
"the",
"mapping",
"between",
"components",
"and",
"styles",
".",
"Using",
"components",
"as",
"a",
"low",
"-",
"level",
"styling",
"construct",
"can",
"be",
"simpler",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-styles/src/styled/styled.js#L23-L149 | train | Creates a styled component. | [
30522,
3853,
13650,
1006,
6922,
1007,
1063,
9530,
3367,
6922,
16748,
8844,
1027,
1006,
2806,
1010,
7047,
1027,
1063,
1065,
1007,
1027,
1028,
1063,
9530,
3367,
1063,
2171,
1010,
1012,
1012,
1012,
6782,
7361,
9285,
1065,
1027,
7047,
1025,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (aChildren, mChildAnnotations, sTypeClass, aSchemas, fnCallback,
iStartIndex) {
if (!aChildren) {
return;
}
if (iStartIndex) {
aChildren = aChildren.slice(iStartIndex);
}
aChildren.forEach(function (oChild) {
// lift SAP data for easy access to SAP Annotations for OData V 2.0
Utils.liftSAPData(oChild, sTypeClass);
});
aChildren.forEach(function (oChild) {
var oEntityType;
if (sTypeClass === "EntitySet") {
// calculated entity set annotations need to be added before V4
// annotations are merged
oEntityType = Utils.getObject(aSchemas, "entityType", oChild.entityType);
Utils.calculateEntitySetAnnotations(oChild, oEntityType);
}
if (fnCallback) {
fnCallback(oChild);
}
// merge V4 annotations after child annotations are processed
jQuery.extend(oChild, mChildAnnotations[oChild.name || oChild.role]);
});
} | javascript | function (aChildren, mChildAnnotations, sTypeClass, aSchemas, fnCallback,
iStartIndex) {
if (!aChildren) {
return;
}
if (iStartIndex) {
aChildren = aChildren.slice(iStartIndex);
}
aChildren.forEach(function (oChild) {
// lift SAP data for easy access to SAP Annotations for OData V 2.0
Utils.liftSAPData(oChild, sTypeClass);
});
aChildren.forEach(function (oChild) {
var oEntityType;
if (sTypeClass === "EntitySet") {
// calculated entity set annotations need to be added before V4
// annotations are merged
oEntityType = Utils.getObject(aSchemas, "entityType", oChild.entityType);
Utils.calculateEntitySetAnnotations(oChild, oEntityType);
}
if (fnCallback) {
fnCallback(oChild);
}
// merge V4 annotations after child annotations are processed
jQuery.extend(oChild, mChildAnnotations[oChild.name || oChild.role]);
});
} | [
"function",
"(",
"aChildren",
",",
"mChildAnnotations",
",",
"sTypeClass",
",",
"aSchemas",
",",
"fnCallback",
",",
"iStartIndex",
")",
"{",
"if",
"(",
"!",
"aChildren",
")",
"{",
"return",
";",
"}",
"if",
"(",
"iStartIndex",
")",
"{",
"aChildren",
"=",
... | Visits all children inside the given array, lifts "SAPData" extensions and
inlines OData V4 annotations for each child.
@param {object[]} aChildren
any array of children
@param {object} mChildAnnotations
map from child name (or role) to annotations
@param {string} [sTypeClass]
the type class of the given children; supported type classes are "Property"
and "EntitySet"
@param {object[]} [aSchemas]
Array of OData data service schemas (needed only for type class "EntitySet")
@param {function} [fnCallback]
optional callback for each child
@param {number} [iStartIndex=0]
optional start index in the given array | [
"Visits",
"all",
"children",
"inside",
"the",
"given",
"array",
"lifts",
"SAPData",
"extensions",
"and",
"inlines",
"OData",
"V4",
"annotations",
"for",
"each",
"child",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L1023-L1051 | train | This function is called by the annotation processor to process the child annotations | [
30522,
3853,
1006,
9353,
19466,
16200,
2078,
1010,
11338,
19466,
7847,
17048,
10708,
1010,
2358,
18863,
26266,
1010,
2004,
5403,
9335,
1010,
1042,
20909,
3363,
5963,
1010,
21541,
8445,
22254,
10288,
1007,
1063,
2065,
1006,
999,
9353,
19466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/lines-around-directive.js | hasNewlineBefore | function hasNewlineBefore(node) {
const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });
const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
return node.loc.start.line - tokenLineBefore >= 2;
} | javascript | function hasNewlineBefore(node) {
const tokenBefore = sourceCode.getTokenBefore(node, { includeComments: true });
const tokenLineBefore = tokenBefore ? tokenBefore.loc.end.line : 0;
return node.loc.start.line - tokenLineBefore >= 2;
} | [
"function",
"hasNewlineBefore",
"(",
"node",
")",
"{",
"const",
"tokenBefore",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
",",
"{",
"includeComments",
":",
"true",
"}",
")",
";",
"const",
"tokenLineBefore",
"=",
"tokenBefore",
"?",
"tokenBefore",
"... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Check if node is preceded by a blank newline.
@param {ASTNode} node Node to check.
@returns {boolean} Whether or not the passed in node is preceded by a blank newline. | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Check",
"if",
"node",
"is",
"preceded",
"by",
"a",
"blank",
"newline",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-directive.js#L71-L76 | train | Check if node has a newline before token | [
30522,
3853,
8440,
7974,
4179,
4783,
29278,
2063,
1006,
13045,
1007,
1063,
9530,
3367,
19204,
4783,
29278,
2063,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
13045,
1010,
1063,
2421,
9006,
8163,
1024,
2995,
1065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Boolean.js | getMessage | function getMessage(sKey, aParameters) {
return sap.ui.getCore().getLibraryResourceBundle().getText(sKey, aParameters);
} | javascript | function getMessage(sKey, aParameters) {
return sap.ui.getCore().getLibraryResourceBundle().getText(sKey, aParameters);
} | [
"function",
"getMessage",
"(",
"sKey",
",",
"aParameters",
")",
"{",
"return",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLibraryResourceBundle",
"(",
")",
".",
"getText",
"(",
"sKey",
",",
"aParameters",
")",
";",
"}"
] | Returns the locale-dependent text for the given key. Fetches the resource bundle
and stores it in the type if necessary.
@param {string} sKey
the key
@param {any[]} aParameters
the parameters
@returns {string}
the locale-dependent text for the key | [
"Returns",
"the",
"locale",
"-",
"dependent",
"text",
"for",
"the",
"given",
"key",
".",
"Fetches",
"the",
"resource",
"bundle",
"and",
"stores",
"it",
"in",
"the",
"type",
"if",
"necessary",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Boolean.js#L36-L38 | train | Returns the localized message for the given key and parameters. | [
30522,
3853,
2131,
7834,
3736,
3351,
1006,
15315,
3240,
1010,
9706,
5400,
22828,
2015,
1007,
1063,
2709,
20066,
1012,
21318,
1012,
2131,
17345,
1006,
1007,
1012,
2131,
29521,
19848,
16363,
6499,
3126,
3401,
27265,
2571,
1006,
1007,
1012,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/extensions/uml.js | plantUMLReplacer | function plantUMLReplacer(umlCode) {
let renderedHTML;
try {
if (!plantumlEncoder) {
throw new Error('plantuml-encoder dependency required');
}
renderedHTML = `<img src="${rendererURL}${plantumlEncoder.encode(umlCode)}" />`;
} catch (err) {
renderedHTML = `Error occurred on encoding uml: ${err.message}`;
}
return renderedHTML;
} | javascript | function plantUMLReplacer(umlCode) {
let renderedHTML;
try {
if (!plantumlEncoder) {
throw new Error('plantuml-encoder dependency required');
}
renderedHTML = `<img src="${rendererURL}${plantumlEncoder.encode(umlCode)}" />`;
} catch (err) {
renderedHTML = `Error occurred on encoding uml: ${err.message}`;
}
return renderedHTML;
} | [
"function",
"plantUMLReplacer",
"(",
"umlCode",
")",
"{",
"let",
"renderedHTML",
";",
"try",
"{",
"if",
"(",
"!",
"plantumlEncoder",
")",
"{",
"throw",
"new",
"Error",
"(",
"'plantuml-encoder dependency required'",
")",
";",
"}",
"renderedHTML",
"=",
"`",
"${"... | render html from uml
@param {string} umlCode - plant uml code text
@returns {string} - rendered html | [
"render",
"html",
"from",
"uml"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/uml.js#L30-L43 | train | plantUMLReplacer - Placeholder for HTML | [
30522,
3853,
3269,
2819,
20974,
13699,
19217,
2099,
1006,
8529,
22499,
3207,
1007,
1063,
2292,
10155,
11039,
19968,
1025,
3046,
1063,
2065,
1006,
999,
3269,
2819,
7770,
16044,
2099,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
3269,
2819,
2140... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (bodyWrap)
{
var typ = bodyWrap.getAttribute("type");
var cond, conflict;
if (typ !== null && typ == "terminate") {
// an error occurred
Strophe.error("BOSH-Connection failed: " + cond);
cond = bodyWrap.getAttribute("condition");
conflict = bodyWrap.getElementsByTagName("conflict");
if (cond !== null) {
if (cond == "remote-stream-error" && conflict.length > 0) {
cond = "conflict";
}
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
} else {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown");
}
this._conn._doDisconnect();
return Strophe.Status.CONNFAIL;
}
// check to make sure we don't overwrite these if _connect_cb is
// called multiple times in the case of missing stream:features
if (!this.sid) {
this.sid = bodyWrap.getAttribute("sid");
}
var wind = bodyWrap.getAttribute('requests');
if (wind) { this.window = parseInt(wind, 10); }
var hold = bodyWrap.getAttribute('hold');
if (hold) { this.hold = parseInt(hold, 10); }
var wait = bodyWrap.getAttribute('wait');
if (wait) { this.wait = parseInt(wait, 10); }
} | javascript | function (bodyWrap)
{
var typ = bodyWrap.getAttribute("type");
var cond, conflict;
if (typ !== null && typ == "terminate") {
// an error occurred
Strophe.error("BOSH-Connection failed: " + cond);
cond = bodyWrap.getAttribute("condition");
conflict = bodyWrap.getElementsByTagName("conflict");
if (cond !== null) {
if (cond == "remote-stream-error" && conflict.length > 0) {
cond = "conflict";
}
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, cond);
} else {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "unknown");
}
this._conn._doDisconnect();
return Strophe.Status.CONNFAIL;
}
// check to make sure we don't overwrite these if _connect_cb is
// called multiple times in the case of missing stream:features
if (!this.sid) {
this.sid = bodyWrap.getAttribute("sid");
}
var wind = bodyWrap.getAttribute('requests');
if (wind) { this.window = parseInt(wind, 10); }
var hold = bodyWrap.getAttribute('hold');
if (hold) { this.hold = parseInt(hold, 10); }
var wait = bodyWrap.getAttribute('wait');
if (wait) { this.wait = parseInt(wait, 10); }
} | [
"function",
"(",
"bodyWrap",
")",
"{",
"var",
"typ",
"=",
"bodyWrap",
".",
"getAttribute",
"(",
"\"type\"",
")",
";",
"var",
"cond",
",",
"conflict",
";",
"if",
"(",
"typ",
"!==",
"null",
"&&",
"typ",
"==",
"\"terminate\"",
")",
"{",
"// an error occurre... | PrivateFunction: _connect_cb
_Private_ handler for initial connection request.
This handler is used to process the Bosh-part of the initial request.
Parameters:
(Strophe.Request) bodyWrap - The received stanza. | [
"PrivateFunction",
":",
"_connect_cb",
"_Private_",
"handler",
"for",
"initial",
"connection",
"request",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4152-L4184 | train | Returns the status of the next session | [
30522,
3853,
1006,
2303,
13088,
9331,
1007,
1063,
13075,
5939,
2361,
1027,
2303,
13088,
9331,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
1000,
2828,
1000,
1007,
1025,
13075,
9530,
2094,
1010,
4736,
1025,
2065,
1006,
5939,
2361,
999,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/FileTreeView.js | function (classes) {
var extensions = this.props.extensions;
if (extensions && extensions.get("addClass")) {
var data = this.getDataForExtension();
classes = classes + " " + extensions.get("addClass").map(function (callback) {
try {
return callback(data);
} catch (e) {
console.error("Exception thrown in FileTreeView addClass provider: " + e, e.stack);
}
}).filter(isDefined).toArray().join(" ");
}
return classes;
} | javascript | function (classes) {
var extensions = this.props.extensions;
if (extensions && extensions.get("addClass")) {
var data = this.getDataForExtension();
classes = classes + " " + extensions.get("addClass").map(function (callback) {
try {
return callback(data);
} catch (e) {
console.error("Exception thrown in FileTreeView addClass provider: " + e, e.stack);
}
}).filter(isDefined).toArray().join(" ");
}
return classes;
} | [
"function",
"(",
"classes",
")",
"{",
"var",
"extensions",
"=",
"this",
".",
"props",
".",
"extensions",
";",
"if",
"(",
"extensions",
"&&",
"extensions",
".",
"get",
"(",
"\"addClass\"",
")",
")",
"{",
"var",
"data",
"=",
"this",
".",
"getDataForExtensi... | Calls the addClass providers to get the classes (in string form) to add for the current
file or directory.
@param {string} classes Initial classes for this node
@return {string} classes for the current node | [
"Calls",
"the",
"addClass",
"providers",
"to",
"get",
"the",
"classes",
"(",
"in",
"string",
"form",
")",
"to",
"add",
"for",
"the",
"current",
"file",
"or",
"directory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L445-L460 | train | addClass - add class | [
30522,
3853,
1006,
4280,
1007,
1063,
13075,
14305,
1027,
2023,
1012,
24387,
1012,
14305,
1025,
2065,
1006,
14305,
1004,
1004,
14305,
1012,
2131,
1006,
1000,
5587,
26266,
1000,
1007,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2131,
2850,
269... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/LanguageManager.js | _updateFromPrefs | function _updateFromPrefs(pref) {
var newMapping = PreferencesManager.get(pref),
newNames = Object.keys(newMapping),
state = _prefState[pref],
last = state.last,
overridden = state.overridden;
// Look for added and changed names (extensions or filenames)
newNames.forEach(function (name) {
var language;
if (newMapping[name] !== last[name]) {
if (last[name]) {
language = getLanguage(last[name]);
if (language) {
language[state.remove](name);
// If this name that was previously mapped was overriding a default
// restore it now.
_restoreOverriddenDefault(name, state);
}
}
language = exports[state.get](name);
if (language) {
language[state.remove](name);
// We're removing a name that was defined in Brackets or an extension,
// so keep track of how it used to be mapped.
if (!overridden[name]) {
overridden[name] = language.getId();
}
}
language = getLanguage(newMapping[name]);
if (language) {
language[state.add](name);
}
}
if(!getLanguage(newMapping[name])) {
// If the language doesn't exist, restore any overrides and remove it
// from the state.
if(overridden[name]) {
_restoreOverriddenDefault(name, state);
}
delete newMapping[name];
}
});
// Look for removed names (extensions or filenames)
_.difference(Object.keys(last), newNames).forEach(function (name) {
var language = getLanguage(last[name]);
if (language) {
language[state.remove](name);
_restoreOverriddenDefault(name, state);
}
});
state.last = newMapping;
} | javascript | function _updateFromPrefs(pref) {
var newMapping = PreferencesManager.get(pref),
newNames = Object.keys(newMapping),
state = _prefState[pref],
last = state.last,
overridden = state.overridden;
// Look for added and changed names (extensions or filenames)
newNames.forEach(function (name) {
var language;
if (newMapping[name] !== last[name]) {
if (last[name]) {
language = getLanguage(last[name]);
if (language) {
language[state.remove](name);
// If this name that was previously mapped was overriding a default
// restore it now.
_restoreOverriddenDefault(name, state);
}
}
language = exports[state.get](name);
if (language) {
language[state.remove](name);
// We're removing a name that was defined in Brackets or an extension,
// so keep track of how it used to be mapped.
if (!overridden[name]) {
overridden[name] = language.getId();
}
}
language = getLanguage(newMapping[name]);
if (language) {
language[state.add](name);
}
}
if(!getLanguage(newMapping[name])) {
// If the language doesn't exist, restore any overrides and remove it
// from the state.
if(overridden[name]) {
_restoreOverriddenDefault(name, state);
}
delete newMapping[name];
}
});
// Look for removed names (extensions or filenames)
_.difference(Object.keys(last), newNames).forEach(function (name) {
var language = getLanguage(last[name]);
if (language) {
language[state.remove](name);
_restoreOverriddenDefault(name, state);
}
});
state.last = newMapping;
} | [
"function",
"_updateFromPrefs",
"(",
"pref",
")",
"{",
"var",
"newMapping",
"=",
"PreferencesManager",
".",
"get",
"(",
"pref",
")",
",",
"newNames",
"=",
"Object",
".",
"keys",
"(",
"newMapping",
")",
",",
"state",
"=",
"_prefState",
"[",
"pref",
"]",
"... | @private
Updates extension and filename mappings from languages based on the current preferences values.
The preferences look like this in a prefs file:
Map *.foo to javascript, *.vm to html
"language.fileExtensions": {
"foo": "javascript",
"vm": "html"
}
Map "Gemfile" to ruby:
"language.fileNames": {
"Gemfile": "ruby"
} | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L1051-L1108 | train | Update from preferences | [
30522,
3853,
1035,
10651,
19699,
25377,
2890,
10343,
1006,
3653,
2546,
1007,
1063,
13075,
2047,
2863,
14853,
1027,
18394,
24805,
4590,
1012,
2131,
1006,
3653,
2546,
1007,
1010,
2047,
18442,
2015,
1027,
4874,
1012,
6309,
1006,
2047,
2863,
14... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/protractor | website/docgen/processors/tag-fixer.js | buildName | function buildName(obj) {
if (!obj) {
return parts.join('.');
}
if (obj.property && obj.property.name) {
parts.unshift(obj.property.name);
}
if (obj.object && obj.object.name) {
parts.unshift(obj.object.name);
}
return buildName(obj.object);
} | javascript | function buildName(obj) {
if (!obj) {
return parts.join('.');
}
if (obj.property && obj.property.name) {
parts.unshift(obj.property.name);
}
if (obj.object && obj.object.name) {
parts.unshift(obj.object.name);
}
return buildName(obj.object);
} | [
"function",
"buildName",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
"parts",
".",
"join",
"(",
"'.'",
")",
";",
"}",
"if",
"(",
"obj",
".",
"property",
"&&",
"obj",
".",
"property",
".",
"name",
")",
"{",
"parts",
".",
"un... | Recursively create the function name by examining the object property.
@param obj Parsed object.
@return {string} The name of the function. | [
"Recursively",
"create",
"the",
"function",
"name",
"by",
"examining",
"the",
"object",
"property",
"."
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/website/docgen/processors/tag-fixer.js#L39-L53 | train | Build the name of the object | [
30522,
3853,
3857,
18442,
1006,
27885,
3501,
1007,
1063,
2065,
1006,
999,
27885,
3501,
1007,
1063,
2709,
3033,
1012,
3693,
1006,
1005,
1012,
1005,
1007,
1025,
1065,
2065,
1006,
27885,
3501,
1012,
3200,
1004,
1004,
27885,
3501,
1012,
3200,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(sPropertyName) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot remove filter conditions for unknown property name " + sPropertyName; // TODO
}
for (var i = 0; i < this._aConditionUI5Filter.length; i++) {
var oUI5Filter = this._aConditionUI5Filter[i];
if (oUI5Filter.sPath == sPropertyName) {
this._aConditionUI5Filter.splice(i--, 1);
}
}
return this;
} | javascript | function(sPropertyName) {
var oProperty = this._oEntityType.findPropertyByName(sPropertyName);
if (oProperty == null) {
throw "Cannot remove filter conditions for unknown property name " + sPropertyName; // TODO
}
for (var i = 0; i < this._aConditionUI5Filter.length; i++) {
var oUI5Filter = this._aConditionUI5Filter[i];
if (oUI5Filter.sPath == sPropertyName) {
this._aConditionUI5Filter.splice(i--, 1);
}
}
return this;
} | [
"function",
"(",
"sPropertyName",
")",
"{",
"var",
"oProperty",
"=",
"this",
".",
"_oEntityType",
".",
"findPropertyByName",
"(",
"sPropertyName",
")",
";",
"if",
"(",
"oProperty",
"==",
"null",
")",
"{",
"throw",
"\"Cannot remove filter conditions for unknown prope... | Remove all conditions for some property from the filter expression.
All previously set conditions for some property are removed from the filter expression.
@param {string}
sPropertyName The name of the property bound in the condition
@throws Exception
if the property is unknown
@returns {sap.ui.model.analytics.odata4analytics.FilterExpression} This object for method chaining
@public
@function
@name sap.ui.model.analytics.odata4analytics.FilterExpression#removeConditions | [
"Remove",
"all",
"conditions",
"for",
"some",
"property",
"from",
"the",
"filter",
"expression",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3180-L3192 | train | Removes conditions for the given property | [
30522,
3853,
1006,
11867,
18981,
15010,
18442,
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,
1025,
2065,
1006,
6728,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function (oEvent) {
var sValue = oEvent.getParameter("selectedItem").getKey(),
oControl = oEvent.getSource();
this._storage.put(this._LOCAL_STORAGE_KEYS.STANDARD_URL, sValue);
this._resetValueState(oControl);
this._pingUrl(sValue, oControl)
.then(function success() {
oControl.setValueState("Success");
}, function error() {
var sMessage = this._getText("TechInfo.SupportAssistantConfigPopup.NotAvailableAtTheMoment");
this._showError(oControl, sMessage);
Log.error("Support Assistant could not be loaded from the URL you entered");
});
} | javascript | function (oEvent) {
var sValue = oEvent.getParameter("selectedItem").getKey(),
oControl = oEvent.getSource();
this._storage.put(this._LOCAL_STORAGE_KEYS.STANDARD_URL, sValue);
this._resetValueState(oControl);
this._pingUrl(sValue, oControl)
.then(function success() {
oControl.setValueState("Success");
}, function error() {
var sMessage = this._getText("TechInfo.SupportAssistantConfigPopup.NotAvailableAtTheMoment");
this._showError(oControl, sMessage);
Log.error("Support Assistant could not be loaded from the URL you entered");
});
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"sValue",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"selectedItem\"",
")",
".",
"getKey",
"(",
")",
",",
"oControl",
"=",
"oEvent",
".",
"getSource",
"(",
")",
";",
"this",
".",
"_storage",
".",
"put",
"(",
... | Writes the custom bootstrap URL to local storage
@param {sap.ui.base.Event} oEvent The select change event | [
"Writes",
"the",
"custom",
"bootstrap",
"URL",
"to",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L350-L363 | train | Handles the URL change event. | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
17917,
2389,
5657,
1027,
1051,
18697,
3372,
1012,
2131,
28689,
22828,
1006,
1000,
3479,
4221,
2213,
1000,
1007,
1012,
2131,
14839,
1006,
1007,
1010,
1051,
8663,
13181,
2140,
1027,
105... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
wangfupeng1988/wangEditor | src/js/menus/italic/index.js | function (e) {
// 点击菜单将触发这里
const editor = this.editor
const isSeleEmpty = editor.selection.isSelectionEmpty()
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange()
}
// 执行 italic 命令
editor.cmd.do('italic')
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange()
editor.selection.restoreSelection()
}
} | javascript | function (e) {
// 点击菜单将触发这里
const editor = this.editor
const isSeleEmpty = editor.selection.isSelectionEmpty()
if (isSeleEmpty) {
// 选区是空的,插入并选中一个“空白”
editor.selection.createEmptyRange()
}
// 执行 italic 命令
editor.cmd.do('italic')
if (isSeleEmpty) {
// 需要将选取折叠起来
editor.selection.collapseRange()
editor.selection.restoreSelection()
}
} | [
"function",
"(",
"e",
")",
"{",
"// 点击菜单将触发这里",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"isSeleEmpty",
"=",
"editor",
".",
"selection",
".",
"isSelectionEmpty",
"(",
")",
"if",
"(",
"isSeleEmpty",
")",
"{",
"// 选区是空的,插入并选中一个“空白”",
"editor",
"... | 点击事件 | [
"点击事件"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/italic/index.js#L25-L44 | train | on keydown | [
30522,
3853,
1006,
1041,
1007,
1063,
1013,
1013,
100,
100,
100,
100,
100,
100,
100,
100,
1962,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
26354,
12260,
6633,
13876,
2100,
1027,
3559,
1012,
4989,
1012,
26354,
12260,
7542,
6633,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/utils/location.js | relative | function relative(dir, file) {
var isDirectory = file.slice(-1) === '/';
return normalize(path.relative(dir, file)) + (isDirectory? '/': '');
} | javascript | function relative(dir, file) {
var isDirectory = file.slice(-1) === '/';
return normalize(path.relative(dir, file)) + (isDirectory? '/': '');
} | [
"function",
"relative",
"(",
"dir",
",",
"file",
")",
"{",
"var",
"isDirectory",
"=",
"file",
".",
"slice",
"(",
"-",
"1",
")",
"===",
"'/'",
";",
"return",
"normalize",
"(",
"path",
".",
"relative",
"(",
"dir",
",",
"file",
")",
")",
"+",
"(",
"... | Convert an absolute path to a relative path for a specific folder (dir)
('test/', 'hello.md') -> '../hello.md'
@param {String} dir: current directory
@param {String} file: absolute path of file
@return {String} | [
"Convert",
"an",
"absolute",
"path",
"to",
"a",
"relative",
"path",
"for",
"a",
"specific",
"folder",
"(",
"dir",
")",
"(",
"test",
"/",
"hello",
".",
"md",
")",
"-",
">",
"..",
"/",
"hello",
".",
"md"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/location.js#L99-L102 | train | Returns the relative path of the file to the specified directory | [
30522,
3853,
5816,
1006,
16101,
1010,
5371,
1007,
1063,
13075,
2003,
4305,
2890,
16761,
2100,
1027,
5371,
1012,
14704,
1006,
1011,
1015,
1007,
1027,
1027,
1027,
1005,
1013,
1005,
1025,
2709,
3671,
4697,
1006,
4130,
1012,
5816,
1006,
16101,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/QuickOpen.js | highlightMatch | function highlightMatch(item, matchClass, rangeFilter) {
var label = item.label || item;
matchClass = matchClass || "quicksearch-namematch";
var stringRanges = item.stringRanges;
if (!stringRanges) {
// If result didn't come from stringMatch(), highlight nothing
stringRanges = [{
text: label,
matched: false,
includesLastSegment: true
}];
}
var displayName = "";
if (item.scoreDebug) {
var sd = item.scoreDebug;
displayName += '<span title="sp:' + sd.special + ', m:' + sd.match +
', ls:' + sd.lastSegment + ', b:' + sd.beginning +
', ld:' + sd.lengthDeduction + ', c:' + sd.consecutive + ', nsos: ' +
sd.notStartingOnSpecial + ', upper: ' + sd.upper + '">(' + item.matchGoodness + ') </span>';
}
// Put the path pieces together, highlighting the matched parts
stringRanges.forEach(function (range) {
if (range.matched) {
displayName += "<span class='" + matchClass + "'>";
}
var rangeText = rangeFilter ? rangeFilter(range.includesLastSegment, range.text) : range.text;
displayName += StringUtils.breakableUrl(rangeText);
if (range.matched) {
displayName += "</span>";
}
});
return displayName;
} | javascript | function highlightMatch(item, matchClass, rangeFilter) {
var label = item.label || item;
matchClass = matchClass || "quicksearch-namematch";
var stringRanges = item.stringRanges;
if (!stringRanges) {
// If result didn't come from stringMatch(), highlight nothing
stringRanges = [{
text: label,
matched: false,
includesLastSegment: true
}];
}
var displayName = "";
if (item.scoreDebug) {
var sd = item.scoreDebug;
displayName += '<span title="sp:' + sd.special + ', m:' + sd.match +
', ls:' + sd.lastSegment + ', b:' + sd.beginning +
', ld:' + sd.lengthDeduction + ', c:' + sd.consecutive + ', nsos: ' +
sd.notStartingOnSpecial + ', upper: ' + sd.upper + '">(' + item.matchGoodness + ') </span>';
}
// Put the path pieces together, highlighting the matched parts
stringRanges.forEach(function (range) {
if (range.matched) {
displayName += "<span class='" + matchClass + "'>";
}
var rangeText = rangeFilter ? rangeFilter(range.includesLastSegment, range.text) : range.text;
displayName += StringUtils.breakableUrl(rangeText);
if (range.matched) {
displayName += "</span>";
}
});
return displayName;
} | [
"function",
"highlightMatch",
"(",
"item",
",",
"matchClass",
",",
"rangeFilter",
")",
"{",
"var",
"label",
"=",
"item",
".",
"label",
"||",
"item",
";",
"matchClass",
"=",
"matchClass",
"||",
"\"quicksearch-namematch\"",
";",
"var",
"stringRanges",
"=",
"item... | Formats item's label as properly escaped HTML text, highlighting sections that match 'query'.
If item is a SearchResult generated by stringMatch(), uses its metadata about which string ranges
matched; else formats the label with no highlighting.
@param {!string|SearchResult} item
@param {?string} matchClass CSS class for highlighting matched text
@param {?function(boolean, string):string} rangeFilter
@return {!string} bolded, HTML-escaped result | [
"Formats",
"item",
"s",
"label",
"as",
"properly",
"escaped",
"HTML",
"text",
"highlighting",
"sections",
"that",
"match",
"query",
".",
"If",
"item",
"is",
"a",
"SearchResult",
"generated",
"by",
"stringMatch",
"()",
"uses",
"its",
"metadata",
"about",
"which... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L539-L576 | train | Highlights a match in the log | [
30522,
3853,
12944,
18900,
2818,
1006,
8875,
1010,
2674,
26266,
1010,
2846,
8873,
21928,
1007,
1063,
13075,
3830,
1027,
8875,
1012,
3830,
1064,
1064,
8875,
1025,
2674,
26266,
1027,
2674,
26266,
1064,
1064,
1000,
4248,
17310,
11140,
1011,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/search.js | searchBar_openEngineManager | function searchBar_openEngineManager(handler)
{
this.enginesDropDownOpen = true;
var engineManager = this.getElement({type: "engine_manager"});
// Setup the modal dialog handler
md = new modalDialog.modalDialog(this._controller.window);
md.start(handler);
// XXX: Bug 555347 - Process any outstanding events before clicking the entry
this._controller.sleep(0);
this._controller.click(engineManager);
md.waitForDialog();
this._controller.assert(function () {
return this.enginesDropDownOpen == false;
}, "The search engine drop down menu has been closed", this);
} | javascript | function searchBar_openEngineManager(handler)
{
this.enginesDropDownOpen = true;
var engineManager = this.getElement({type: "engine_manager"});
// Setup the modal dialog handler
md = new modalDialog.modalDialog(this._controller.window);
md.start(handler);
// XXX: Bug 555347 - Process any outstanding events before clicking the entry
this._controller.sleep(0);
this._controller.click(engineManager);
md.waitForDialog();
this._controller.assert(function () {
return this.enginesDropDownOpen == false;
}, "The search engine drop down menu has been closed", this);
} | [
"function",
"searchBar_openEngineManager",
"(",
"handler",
")",
"{",
"this",
".",
"enginesDropDownOpen",
"=",
"true",
";",
"var",
"engineManager",
"=",
"this",
".",
"getElement",
"(",
"{",
"type",
":",
"\"engine_manager\"",
"}",
")",
";",
"// Setup the modal dialo... | Open the Engine Manager
@param {function} handler
Callback function for Engine Manager | [
"Open",
"the",
"Engine",
"Manager"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/search.js#L720-L737 | train | Open the engine manager | [
30522,
3853,
3945,
8237,
1035,
2330,
13159,
3170,
24805,
4590,
1006,
28213,
1007,
1063,
2023,
1012,
5209,
25711,
7698,
26915,
1027,
2995,
1025,
13075,
3194,
24805,
4590,
1027,
2023,
1012,
2131,
12260,
3672,
1006,
1063,
2828,
1024,
1000,
319... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/plugin/Plugin.js | _checkAggregationBindingTemplateID | function _checkAggregationBindingTemplateID(oOverlay, vStableElement){
var mAggregationInfo = OverlayUtil.getAggregationInformation(oOverlay, oOverlay.getElement().sParentAggregationName);
if (!mAggregationInfo.templateId) {
return true;
} else {
return !FlexUtils.checkControlId(mAggregationInfo.templateId, vStableElement.appComponent);
}
} | javascript | function _checkAggregationBindingTemplateID(oOverlay, vStableElement){
var mAggregationInfo = OverlayUtil.getAggregationInformation(oOverlay, oOverlay.getElement().sParentAggregationName);
if (!mAggregationInfo.templateId) {
return true;
} else {
return !FlexUtils.checkControlId(mAggregationInfo.templateId, vStableElement.appComponent);
}
} | [
"function",
"_checkAggregationBindingTemplateID",
"(",
"oOverlay",
",",
"vStableElement",
")",
"{",
"var",
"mAggregationInfo",
"=",
"OverlayUtil",
".",
"getAggregationInformation",
"(",
"oOverlay",
",",
"oOverlay",
".",
"getElement",
"(",
")",
".",
"sParentAggregationNa... | Check if related binding template has stable id | [
"Check",
"if",
"related",
"binding",
"template",
"has",
"stable",
"id"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/Plugin.js#L271-L278 | train | Checks if the binding template id is valid | [
30522,
3853,
1035,
4638,
8490,
17603,
12540,
8428,
4667,
18532,
15725,
3593,
1006,
1051,
7840,
8485,
1010,
5443,
10880,
12260,
3672,
1007,
1063,
13075,
23848,
17603,
12540,
2378,
14876,
1027,
2058,
8485,
21823,
2140,
1012,
2131,
8490,
17603,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/node/FindInFilesDomain.js | getFilesizeInBytes | function getFilesizeInBytes(fileName) {
try {
var stats = fs.statSync(fileName);
return stats.size || 0;
} catch (ex) {
console.log(ex);
return 0;
}
} | javascript | function getFilesizeInBytes(fileName) {
try {
var stats = fs.statSync(fileName);
return stats.size || 0;
} catch (ex) {
console.log(ex);
return 0;
}
} | [
"function",
"getFilesizeInBytes",
"(",
"fileName",
")",
"{",
"try",
"{",
"var",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"fileName",
")",
";",
"return",
"stats",
".",
"size",
"||",
"0",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"console",
".",
"log",
... | Gets the file size in bytes.
@param {string} fileName The name of the file to get the size
@returns {Number} the file size in bytes | [
"Gets",
"the",
"file",
"size",
"in",
"bytes",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L195-L203 | train | Get size in bytes of a file | [
30522,
3853,
2131,
8873,
4244,
4697,
2378,
3762,
4570,
1006,
5371,
18442,
1007,
1063,
3046,
1063,
13075,
26319,
1027,
1042,
2015,
1012,
26319,
6038,
2278,
1006,
5371,
18442,
1007,
1025,
2709,
26319,
1012,
2946,
1064,
1064,
1014,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | packages/weex-vue-framework/index.js | reset | function reset () {
clear(instances);
clear(modules);
clear(components);
delete renderer.Document;
delete renderer.Element;
delete renderer.Comment;
delete renderer.sendTasks;
} | javascript | function reset () {
clear(instances);
clear(modules);
clear(components);
delete renderer.Document;
delete renderer.Element;
delete renderer.Comment;
delete renderer.sendTasks;
} | [
"function",
"reset",
"(",
")",
"{",
"clear",
"(",
"instances",
")",
";",
"clear",
"(",
"modules",
")",
";",
"clear",
"(",
"components",
")",
";",
"delete",
"renderer",
".",
"Document",
";",
"delete",
"renderer",
".",
"Element",
";",
"delete",
"renderer",... | Reset framework config and clear all registrations. | [
"Reset",
"framework",
"config",
"and",
"clear",
"all",
"registrations",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/weex-vue-framework/index.js#L43-L51 | train | Clear all the cache | [
30522,
3853,
25141,
1006,
1007,
1063,
3154,
1006,
12107,
1007,
1025,
3154,
1006,
14184,
1007,
1025,
3154,
1006,
6177,
1007,
1025,
3972,
12870,
17552,
2121,
1012,
6254,
1025,
3972,
12870,
17552,
2121,
1012,
5783,
1025,
3972,
12870,
17552,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/utils.js | rewriteJSONFile | function rewriteJSONFile(filePath, rewriteFile, generator) {
const jsonObj = generator.fs.readJSON(filePath);
rewriteFile(jsonObj, generator);
generator.fs.writeJSON(filePath, jsonObj, null, 2);
} | javascript | function rewriteJSONFile(filePath, rewriteFile, generator) {
const jsonObj = generator.fs.readJSON(filePath);
rewriteFile(jsonObj, generator);
generator.fs.writeJSON(filePath, jsonObj, null, 2);
} | [
"function",
"rewriteJSONFile",
"(",
"filePath",
",",
"rewriteFile",
",",
"generator",
")",
"{",
"const",
"jsonObj",
"=",
"generator",
".",
"fs",
".",
"readJSON",
"(",
"filePath",
")",
";",
"rewriteFile",
"(",
"jsonObj",
",",
"generator",
")",
";",
"generator... | Rewrite JSON file
@param {string} filePath file path
@param {function} rewriteFile rewriteFile function
@param {object} generator reference to the generator | [
"Rewrite",
"JSON",
"file"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/utils.js#L152-L156 | train | Rewrite a JSON file | [
30522,
3853,
2128,
26373,
22578,
2239,
8873,
2571,
1006,
5371,
15069,
1010,
2128,
26373,
8873,
2571,
1010,
13103,
1007,
1063,
9530,
3367,
1046,
3385,
16429,
3501,
1027,
13103,
1012,
1042,
2015,
1012,
3191,
22578,
2239,
1006,
5371,
15069,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/padding-line-between-statements.js | verifyForNever | function verifyForNever(context, _, nextNode, paddingLines) {
if (paddingLines.length === 0) {
return;
}
context.report({
node: nextNode,
message: "Unexpected blank line before this statement.",
fix(fixer) {
if (paddingLines.length >= 2) {
return null;
}
const prevToken = paddingLines[0][0];
const nextToken = paddingLines[0][1];
const start = prevToken.range[1];
const end = nextToken.range[0];
const text = context.getSourceCode().text
.slice(start, end)
.replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
return fixer.replaceTextRange([start, end], text);
}
});
} | javascript | function verifyForNever(context, _, nextNode, paddingLines) {
if (paddingLines.length === 0) {
return;
}
context.report({
node: nextNode,
message: "Unexpected blank line before this statement.",
fix(fixer) {
if (paddingLines.length >= 2) {
return null;
}
const prevToken = paddingLines[0][0];
const nextToken = paddingLines[0][1];
const start = prevToken.range[1];
const end = nextToken.range[0];
const text = context.getSourceCode().text
.slice(start, end)
.replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);
return fixer.replaceTextRange([start, end], text);
}
});
} | [
"function",
"verifyForNever",
"(",
"context",
",",
"_",
",",
"nextNode",
",",
"paddingLines",
")",
"{",
"if",
"(",
"paddingLines",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nextNode",
","... | Check and report statements for `never` configuration.
This autofix removes blank lines between the given 2 statements.
However, if comments exist between 2 blank lines, it does not remove those
blank lines automatically.
@param {RuleContext} context The rule context to report.
@param {ASTNode} _ Unused. The previous node to check.
@param {ASTNode} nextNode The next node to check.
@param {Array<Token[]>} paddingLines The array of token pairs that blank
lines exist between the pair.
@returns {void}
@private | [
"Check",
"and",
"report",
"statements",
"for",
"never",
"configuration",
".",
"This",
"autofix",
"removes",
"blank",
"lines",
"between",
"the",
"given",
"2",
"statements",
".",
"However",
"if",
"comments",
"exist",
"between",
"2",
"blank",
"lines",
"it",
"does... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L248-L272 | train | Verify that the next line is not blank | [
30522,
3853,
20410,
29278,
2638,
6299,
30524,
4471,
1024,
1000,
9223,
8744,
2240,
2077,
2023,
4861,
1012,
1000,
1010,
8081,
1006,
8081,
2121,
1007,
1063,
2065,
1006,
11687,
4667,
12735,
1012,
3091,
1028,
1027,
1016,
1007,
1063,
2709,
19701,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/inspector.js | logMessage | function logMessage(message)
{
var repeatCount = 1;
if (message == WebInspector.log.lastMessage)
repeatCount = WebInspector.log.repeatCount + 1;
WebInspector.log.lastMessage = message;
WebInspector.log.repeatCount = repeatCount;
// ConsoleMessage expects a proxy object
message = new WebInspector.RemoteObject.fromPrimitiveValue(message);
// post the message
var msg = new WebInspector.ConsoleMessage(
WebInspector.ConsoleMessage.MessageSource.Other,
WebInspector.ConsoleMessage.MessageType.Log,
messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
-1,
null,
repeatCount,
null,
[message],
null);
self.console.addMessage(msg);
} | javascript | function logMessage(message)
{
var repeatCount = 1;
if (message == WebInspector.log.lastMessage)
repeatCount = WebInspector.log.repeatCount + 1;
WebInspector.log.lastMessage = message;
WebInspector.log.repeatCount = repeatCount;
// ConsoleMessage expects a proxy object
message = new WebInspector.RemoteObject.fromPrimitiveValue(message);
// post the message
var msg = new WebInspector.ConsoleMessage(
WebInspector.ConsoleMessage.MessageSource.Other,
WebInspector.ConsoleMessage.MessageType.Log,
messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
-1,
null,
repeatCount,
null,
[message],
null);
self.console.addMessage(msg);
} | [
"function",
"logMessage",
"(",
"message",
")",
"{",
"var",
"repeatCount",
"=",
"1",
";",
"if",
"(",
"message",
"==",
"WebInspector",
".",
"log",
".",
"lastMessage",
")",
"repeatCount",
"=",
"WebInspector",
".",
"log",
".",
"repeatCount",
"+",
"1",
";",
"... | actually log the message | [
"actually",
"log",
"the",
"message"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/inspector.js#L1239-L1264 | train | Log a message to the console | [
30522,
3853,
8833,
7834,
3736,
3351,
1006,
4471,
1007,
1063,
13075,
9377,
3597,
16671,
1027,
1015,
1025,
2065,
1006,
4471,
1027,
1027,
4773,
7076,
5051,
16761,
1012,
8833,
1012,
2197,
7834,
3736,
3351,
1007,
9377,
3597,
16671,
1027,
4773,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FindReplace.js | clearHighlights | function clearHighlights(cm, state) {
cm.operation(function () {
state.marked.forEach(function (markedRange) {
markedRange.clear();
});
clearCurrentMatchHighlight(cm, state);
});
state.marked.length = 0;
state.markedCurrent = null;
ScrollTrackMarkers.clear();
state.resultSet = [];
state.matchIndex = -1;
} | javascript | function clearHighlights(cm, state) {
cm.operation(function () {
state.marked.forEach(function (markedRange) {
markedRange.clear();
});
clearCurrentMatchHighlight(cm, state);
});
state.marked.length = 0;
state.markedCurrent = null;
ScrollTrackMarkers.clear();
state.resultSet = [];
state.matchIndex = -1;
} | [
"function",
"clearHighlights",
"(",
"cm",
",",
"state",
")",
"{",
"cm",
".",
"operation",
"(",
"function",
"(",
")",
"{",
"state",
".",
"marked",
".",
"forEach",
"(",
"function",
"(",
"markedRange",
")",
"{",
"markedRange",
".",
"clear",
"(",
")",
";",... | Clears all match highlights, including the current match | [
"Clears",
"all",
"match",
"highlights",
"including",
"the",
"current",
"match"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L451-L465 | train | Clear all highlights | [
30522,
3853,
3154,
4048,
5603,
15733,
1006,
4642,
1010,
2110,
1007,
1063,
4642,
1012,
3169,
1006,
3853,
1006,
1007,
1063,
2110,
1012,
4417,
1012,
18921,
6776,
1006,
3853,
1006,
4417,
24388,
2063,
1007,
1063,
4417,
24388,
2063,
1012,
3154,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/xml/escape-attribute.js | escapeAttribute | function escapeAttribute(value) {
return value.replace(/&/g, '&').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
} | javascript | function escapeAttribute(value) {
return value.replace(/&/g, '&').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
} | [
"function",
"escapeAttribute",
"(",
"value",
")",
"{",
"return",
"value",
".",
"replace",
"(",
"/",
"&",
"/",
"g",
",",
"'&'",
")",
".",
"replace",
"(",
"/",
"'",
"/",
"g",
",",
"'''",
")",
".",
"replace",
"(",
"/",
"<",
"/",
"g",
",",
... | Escapes characters that can not be in an XML attribute. | [
"Escapes",
"characters",
"that",
"can",
"not",
"be",
"in",
"an",
"XML",
"attribute",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/xml/escape-attribute.js#L4-L6 | train | Escape the given value. | [
30522,
3853,
4019,
19321,
3089,
8569,
2618,
1006,
3643,
1007,
1063,
2709,
3643,
1012,
5672,
1006,
1013,
1004,
1013,
1043,
1010,
1005,
1004,
23713,
1025,
1005,
1007,
1012,
5672,
1006,
1013,
1005,
1013,
1043,
1010,
1005,
1004,
9706,
2891,
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 | javascript/selenium-core/xpath/dom.js | xmlResolveEntities | function xmlResolveEntities(s) {
var parts = stringSplit(s, '&');
var ret = parts[0];
for (var i = 1; i < parts.length; ++i) {
var rp = parts[i].indexOf(';');
if (rp == -1) {
// no entity reference: just a & but no ;
ret += parts[i];
continue;
}
var entityName = parts[i].substring(0, rp);
var remainderText = parts[i].substring(rp + 1);
var ch;
switch (entityName) {
case 'lt':
ch = '<';
break;
case 'gt':
ch = '>';
break;
case 'amp':
ch = '&';
break;
case 'quot':
ch = '"';
break;
case 'apos':
ch = '\'';
break;
case 'nbsp':
ch = String.fromCharCode(160);
break;
default:
// Cool trick: let the DOM do the entity decoding. We assign
// the entity text through non-W3C DOM properties and read it
// through the W3C DOM. W3C DOM access is specified to resolve
// entities.
var span = domCreateElement(window.document, 'span');
span.innerHTML = '&' + entityName + '; ';
ch = span.childNodes[0].nodeValue.charAt(0);
}
ret += ch + remainderText;
}
return ret;
} | javascript | function xmlResolveEntities(s) {
var parts = stringSplit(s, '&');
var ret = parts[0];
for (var i = 1; i < parts.length; ++i) {
var rp = parts[i].indexOf(';');
if (rp == -1) {
// no entity reference: just a & but no ;
ret += parts[i];
continue;
}
var entityName = parts[i].substring(0, rp);
var remainderText = parts[i].substring(rp + 1);
var ch;
switch (entityName) {
case 'lt':
ch = '<';
break;
case 'gt':
ch = '>';
break;
case 'amp':
ch = '&';
break;
case 'quot':
ch = '"';
break;
case 'apos':
ch = '\'';
break;
case 'nbsp':
ch = String.fromCharCode(160);
break;
default:
// Cool trick: let the DOM do the entity decoding. We assign
// the entity text through non-W3C DOM properties and read it
// through the W3C DOM. W3C DOM access is specified to resolve
// entities.
var span = domCreateElement(window.document, 'span');
span.innerHTML = '&' + entityName + '; ';
ch = span.childNodes[0].nodeValue.charAt(0);
}
ret += ch + remainderText;
}
return ret;
} | [
"function",
"xmlResolveEntities",
"(",
"s",
")",
"{",
"var",
"parts",
"=",
"stringSplit",
"(",
"s",
",",
"'&'",
")",
";",
"var",
"ret",
"=",
"parts",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"parts",
".",
"length",
"... | Resolve entities in XML text fragments. According to the DOM specification, the DOM is supposed to resolve entity references at the API level. I.e. no entity references are passed through the API. See "Entities and the DOM core", p.12, DOM 2 Core Spec. However, different browsers actually pass very different values at the API. See <http://mesch.nyc/test-xml-quote>. | [
"Resolve",
"entities",
"in",
"XML",
"text",
"fragments",
".",
"According",
"to",
"the",
"DOM",
"specification",
"the",
"DOM",
"is",
"supposed",
"to",
"resolve",
"entity",
"references",
"at",
"the",
"API",
"level",
".",
"I",
".",
"e",
".",
"no",
"entity",
... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/dom.js#L18-L67 | train | Resolves the XML entities in the specified string. | [
30522,
3853,
20950,
6072,
4747,
3726,
4765,
6447,
1006,
1055,
1007,
1063,
13075,
3033,
1027,
7817,
24759,
4183,
1006,
1055,
1010,
1005,
1004,
1005,
1007,
1025,
13075,
2128,
2102,
1027,
3033,
1031,
1014,
1033,
1025,
2005,
1006,
13075,
1045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/menus/panel.js | function () {
const menu = this.menu
if (_isCreatedPanelMenus.indexOf(menu) >= 0) {
// 该菜单已经创建了 panel 不能再创建
return
}
const editor = menu.editor
const $body = $('body')
const $textContainerElem = editor.$textContainerElem
const opt = this.opt
// panel 的容器
const $container = $('<div class="w-e-panel-container"></div>')
const width = opt.width || 300 // 默认 300px
$container.css('width', width + 'px')
.css('margin-left', (0 - width)/2 + 'px')
// 添加关闭按钮
const $closeBtn = $('<i class="w-e-icon-close w-e-panel-close"></i>')
$container.append($closeBtn)
$closeBtn.on('click', () => {
this.hide()
})
// 准备 tabs 容器
const $tabTitleContainer = $('<ul class="w-e-panel-tab-title"></ul>')
const $tabContentContainer = $('<div class="w-e-panel-tab-content"></div>')
$container.append($tabTitleContainer).append($tabContentContainer)
// 设置高度
const height = opt.height
if (height) {
$tabContentContainer.css('height', height + 'px').css('overflow-y', 'auto')
}
// tabs
const tabs = opt.tabs || []
const tabTitleArr = []
const tabContentArr = []
tabs.forEach((tab, tabIndex) => {
if (!tab) {
return
}
let title = tab.title || ''
let tpl = tab.tpl || ''
// 替换多语言
title = replaceLang(editor, title)
tpl = replaceLang(editor, tpl)
// 添加到 DOM
const $title = $(`<li class="w-e-item">${title}</li>`)
$tabTitleContainer.append($title)
const $content = $(tpl)
$tabContentContainer.append($content)
// 记录到内存
$title._index = tabIndex
tabTitleArr.push($title)
tabContentArr.push($content)
// 设置 active 项
if (tabIndex === 0) {
$title._active = true
$title.addClass('w-e-active')
} else {
$content.hide()
}
// 绑定 tab 的事件
$title.on('click', e => {
if ($title._active) {
return
}
// 隐藏所有的 tab
tabTitleArr.forEach($title => {
$title._active = false
$title.removeClass('w-e-active')
})
tabContentArr.forEach($content => {
$content.hide()
})
// 显示当前的 tab
$title._active = true
$title.addClass('w-e-active')
$content.show()
})
})
// 绑定关闭事件
$container.on('click', e => {
// 点击时阻止冒泡
e.stopPropagation()
})
$body.on('click', e => {
this.hide()
})
// 添加到 DOM
$textContainerElem.append($container)
// 绑定 opt 的事件,只有添加到 DOM 之后才能绑定成功
tabs.forEach((tab, index) => {
if (!tab) {
return
}
const events = tab.events || []
events.forEach(event => {
const selector = event.selector
const type = event.type
const fn = event.fn || emptyFn
const $content = tabContentArr[index]
$content.find(selector).on(type, (e) => {
e.stopPropagation()
const needToHide = fn(e)
// 执行完事件之后,是否要关闭 panel
if (needToHide) {
this.hide()
}
})
})
})
// focus 第一个 elem
let $inputs = $container.find('input[type=text],textarea')
if ($inputs.length) {
$inputs.get(0).focus()
}
// 添加到属性
this.$container = $container
// 隐藏其他 panel
this._hideOtherPanels()
// 记录该 menu 已经创建了 panel
_isCreatedPanelMenus.push(menu)
} | javascript | function () {
const menu = this.menu
if (_isCreatedPanelMenus.indexOf(menu) >= 0) {
// 该菜单已经创建了 panel 不能再创建
return
}
const editor = menu.editor
const $body = $('body')
const $textContainerElem = editor.$textContainerElem
const opt = this.opt
// panel 的容器
const $container = $('<div class="w-e-panel-container"></div>')
const width = opt.width || 300 // 默认 300px
$container.css('width', width + 'px')
.css('margin-left', (0 - width)/2 + 'px')
// 添加关闭按钮
const $closeBtn = $('<i class="w-e-icon-close w-e-panel-close"></i>')
$container.append($closeBtn)
$closeBtn.on('click', () => {
this.hide()
})
// 准备 tabs 容器
const $tabTitleContainer = $('<ul class="w-e-panel-tab-title"></ul>')
const $tabContentContainer = $('<div class="w-e-panel-tab-content"></div>')
$container.append($tabTitleContainer).append($tabContentContainer)
// 设置高度
const height = opt.height
if (height) {
$tabContentContainer.css('height', height + 'px').css('overflow-y', 'auto')
}
// tabs
const tabs = opt.tabs || []
const tabTitleArr = []
const tabContentArr = []
tabs.forEach((tab, tabIndex) => {
if (!tab) {
return
}
let title = tab.title || ''
let tpl = tab.tpl || ''
// 替换多语言
title = replaceLang(editor, title)
tpl = replaceLang(editor, tpl)
// 添加到 DOM
const $title = $(`<li class="w-e-item">${title}</li>`)
$tabTitleContainer.append($title)
const $content = $(tpl)
$tabContentContainer.append($content)
// 记录到内存
$title._index = tabIndex
tabTitleArr.push($title)
tabContentArr.push($content)
// 设置 active 项
if (tabIndex === 0) {
$title._active = true
$title.addClass('w-e-active')
} else {
$content.hide()
}
// 绑定 tab 的事件
$title.on('click', e => {
if ($title._active) {
return
}
// 隐藏所有的 tab
tabTitleArr.forEach($title => {
$title._active = false
$title.removeClass('w-e-active')
})
tabContentArr.forEach($content => {
$content.hide()
})
// 显示当前的 tab
$title._active = true
$title.addClass('w-e-active')
$content.show()
})
})
// 绑定关闭事件
$container.on('click', e => {
// 点击时阻止冒泡
e.stopPropagation()
})
$body.on('click', e => {
this.hide()
})
// 添加到 DOM
$textContainerElem.append($container)
// 绑定 opt 的事件,只有添加到 DOM 之后才能绑定成功
tabs.forEach((tab, index) => {
if (!tab) {
return
}
const events = tab.events || []
events.forEach(event => {
const selector = event.selector
const type = event.type
const fn = event.fn || emptyFn
const $content = tabContentArr[index]
$content.find(selector).on(type, (e) => {
e.stopPropagation()
const needToHide = fn(e)
// 执行完事件之后,是否要关闭 panel
if (needToHide) {
this.hide()
}
})
})
})
// focus 第一个 elem
let $inputs = $container.find('input[type=text],textarea')
if ($inputs.length) {
$inputs.get(0).focus()
}
// 添加到属性
this.$container = $container
// 隐藏其他 panel
this._hideOtherPanels()
// 记录该 menu 已经创建了 panel
_isCreatedPanelMenus.push(menu)
} | [
"function",
"(",
")",
"{",
"const",
"menu",
"=",
"this",
".",
"menu",
"if",
"(",
"_isCreatedPanelMenus",
".",
"indexOf",
"(",
"menu",
")",
">=",
"0",
")",
"{",
"// 该菜单已经创建了 panel 不能再创建",
"return",
"}",
"const",
"editor",
"=",
"menu",
".",
"editor",
"cons... | 显示(插入DOM) | [
"显示(插入DOM)"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/panel.js#L23-L161 | train | create the panel | [
30522,
3853,
1006,
1007,
1063,
9530,
3367,
12183,
1027,
2023,
1012,
12183,
30524,
100,
2709,
1065,
9530,
3367,
3559,
1027,
12183,
1012,
3559,
9530,
3367,
1002,
2303,
1027,
1002,
1006,
1005,
2303,
1005,
1007,
9530,
3367,
1002,
3793,
8663,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/angular | tools/gulp-tasks/cldr/extract.js | getWeekendRange | function getWeekendRange(localeData) {
const startDay =
localeData.get(`supplemental/weekData/weekendStart/${localeData.attributes.territory}`) ||
localeData.get('supplemental/weekData/weekendStart/001');
const endDay =
localeData.get(`supplemental/weekData/weekendEnd/${localeData.attributes.territory}`) ||
localeData.get('supplemental/weekData/weekendEnd/001');
return [WEEK_DAYS.indexOf(startDay), WEEK_DAYS.indexOf(endDay)];
} | javascript | function getWeekendRange(localeData) {
const startDay =
localeData.get(`supplemental/weekData/weekendStart/${localeData.attributes.territory}`) ||
localeData.get('supplemental/weekData/weekendStart/001');
const endDay =
localeData.get(`supplemental/weekData/weekendEnd/${localeData.attributes.territory}`) ||
localeData.get('supplemental/weekData/weekendEnd/001');
return [WEEK_DAYS.indexOf(startDay), WEEK_DAYS.indexOf(endDay)];
} | [
"function",
"getWeekendRange",
"(",
"localeData",
")",
"{",
"const",
"startDay",
"=",
"localeData",
".",
"get",
"(",
"`",
"${",
"localeData",
".",
"attributes",
".",
"territory",
"}",
"`",
")",
"||",
"localeData",
".",
"get",
"(",
"'supplemental/weekData/weeke... | Returns week-end range for a locale, based on US week days
@returns [number, number] | [
"Returns",
"week",
"-",
"end",
"range",
"for",
"a",
"locale",
"based",
"on",
"US",
"week",
"days"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/cldr/extract.js#L402-L410 | train | Get weekend range | [
30522,
3853,
2131,
28075,
19524,
15465,
1006,
2334,
11960,
2696,
1007,
1063,
9530,
3367,
2707,
10259,
1027,
2334,
11960,
2696,
1012,
2131,
1006,
1036,
27024,
1013,
2733,
2850,
2696,
1013,
13499,
7559,
2102,
1013,
1002,
1063,
2334,
11960,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_vertical/event.js | function() {
this.jsonInit({
"id": "event_whenbroadcastreceived",
"message0": Blockly.Msg.EVENT_WHENBROADCASTRECEIVED,
"args0": [
{
"type": "field_variable",
"name": "BROADCAST_OPTION",
"variableTypes": [Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
}
],
"category": Blockly.Categories.event,
"extensions": ["colours_event", "shape_hat"]
});
} | javascript | function() {
this.jsonInit({
"id": "event_whenbroadcastreceived",
"message0": Blockly.Msg.EVENT_WHENBROADCASTRECEIVED,
"args0": [
{
"type": "field_variable",
"name": "BROADCAST_OPTION",
"variableTypes": [Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
}
],
"category": Blockly.Categories.event,
"extensions": ["colours_event", "shape_hat"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"id\"",
":",
"\"event_whenbroadcastreceived\"",
",",
"\"message0\"",
":",
"Blockly",
".",
"Msg",
".",
"EVENT_WHENBROADCASTRECEIVED",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_variab... | Block for when broadcast received.
@this Blockly.Block | [
"Block",
"for",
"when",
"broadcast",
"received",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L131-L146 | train | Block for broadcast broadcast. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
8909,
1000,
1024,
1000,
2724,
1035,
2043,
12618,
4215,
10526,
2890,
3401,
3512,
2094,
1000,
1010,
1000,
4471,
2692,
1000,
1024,
3796,
2135,
1012,
5796,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | checkHealthDataSend | function checkHealthDataSend(forceSend) {
var result = new $.Deferred(),
isHDTracking = prefs.get("healthDataTracking"),
nextTimeToSend,
currentTime;
HealthLogger.setHealthLogsEnabled(isHDTracking);
window.clearTimeout(timeoutVar);
if (isHDTracking) {
nextTimeToSend = PreferencesManager.getViewState("nextHealthDataSendTime");
currentTime = Date.now();
// Never send data before FIRST_LAUNCH_SEND_DELAY has ellapsed on a fresh install. This gives the user time to read the notification
// popup, learn more, and opt out if desired
if (!nextTimeToSend) {
nextTimeToSend = currentTime + FIRST_LAUNCH_SEND_DELAY;
PreferencesManager.setViewState("nextHealthDataSendTime", nextTimeToSend);
// don't return yet though - still want to set the timeout below
}
if (currentTime >= nextTimeToSend || forceSend) {
// Bump up nextHealthDataSendTime at the begining of chaining to avoid any chance of sending data again before 24 hours, // e.g. if the server request fails or the code below crashes
PreferencesManager.setViewState("nextHealthDataSendTime", currentTime + ONE_DAY);
sendHealthDataToServer().always(function() {
sendAnalyticsDataToServer()
.done(function () {
// We have already sent the health data, so can clear all health data
// Logged till now
HealthLogger.clearHealthData();
result.resolve();
})
.fail(function () {
result.reject();
})
.always(function () {
timeoutVar = setTimeout(checkHealthDataSend, ONE_DAY);
});
});
} else {
timeoutVar = setTimeout(checkHealthDataSend, nextTimeToSend - currentTime);
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | javascript | function checkHealthDataSend(forceSend) {
var result = new $.Deferred(),
isHDTracking = prefs.get("healthDataTracking"),
nextTimeToSend,
currentTime;
HealthLogger.setHealthLogsEnabled(isHDTracking);
window.clearTimeout(timeoutVar);
if (isHDTracking) {
nextTimeToSend = PreferencesManager.getViewState("nextHealthDataSendTime");
currentTime = Date.now();
// Never send data before FIRST_LAUNCH_SEND_DELAY has ellapsed on a fresh install. This gives the user time to read the notification
// popup, learn more, and opt out if desired
if (!nextTimeToSend) {
nextTimeToSend = currentTime + FIRST_LAUNCH_SEND_DELAY;
PreferencesManager.setViewState("nextHealthDataSendTime", nextTimeToSend);
// don't return yet though - still want to set the timeout below
}
if (currentTime >= nextTimeToSend || forceSend) {
// Bump up nextHealthDataSendTime at the begining of chaining to avoid any chance of sending data again before 24 hours, // e.g. if the server request fails or the code below crashes
PreferencesManager.setViewState("nextHealthDataSendTime", currentTime + ONE_DAY);
sendHealthDataToServer().always(function() {
sendAnalyticsDataToServer()
.done(function () {
// We have already sent the health data, so can clear all health data
// Logged till now
HealthLogger.clearHealthData();
result.resolve();
})
.fail(function () {
result.reject();
})
.always(function () {
timeoutVar = setTimeout(checkHealthDataSend, ONE_DAY);
});
});
} else {
timeoutVar = setTimeout(checkHealthDataSend, nextTimeToSend - currentTime);
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | [
"function",
"checkHealthDataSend",
"(",
"forceSend",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"isHDTracking",
"=",
"prefs",
".",
"get",
"(",
"\"healthDataTracking\"",
")",
",",
"nextTimeToSend",
",",
"currentTime",
";",
"He... | /*
Check if the Health Data is to be sent to the server. If the user has enabled tracking, Health Data will be sent once every 24 hours.
Send Health Data to the server if the period is more than 24 hours.
We are sending the data as soon as the user launches brackets. The data will be sent to the server only after the notification dialog
for opt-out/in is closed.
@param forceSend Flag for sending analytics data for testing purpose | [
"/",
"*",
"Check",
"if",
"the",
"Health",
"Data",
"is",
"to",
"be",
"sent",
"to",
"the",
"server",
".",
"If",
"the",
"user",
"has",
"enabled",
"tracking",
"Health",
"Data",
"will",
"be",
"sent",
"once",
"every",
"24",
"hours",
".",
"Send",
"Health",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L246-L293 | train | Check if health data is being sent to the server | [
30522,
3853,
4638,
20192,
24658,
2850,
18260,
4859,
1006,
2749,
10497,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2003,
14945,
6494,
23177,
1027,
3653,
10343,
1012,
2131,
1006,
1000,
2740,
2850,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/rules/Model.support.js | _fnFindBestMatch | function _fnFindBestMatch(aValues, sBindingPath) {
var iJsonModelMin = -1;
var sJsonModelBestMatch = false;
aValues.forEach(function(sKey) {
var iCurrDest = StringAnalyzer.calculateLevenshteinDistance(sBindingPath, sKey);
if (iJsonModelMin === -1 || iCurrDest < iJsonModelMin) {
iJsonModelMin = iCurrDest;
sJsonModelBestMatch = sKey;
}
});
return sJsonModelBestMatch;
} | javascript | function _fnFindBestMatch(aValues, sBindingPath) {
var iJsonModelMin = -1;
var sJsonModelBestMatch = false;
aValues.forEach(function(sKey) {
var iCurrDest = StringAnalyzer.calculateLevenshteinDistance(sBindingPath, sKey);
if (iJsonModelMin === -1 || iCurrDest < iJsonModelMin) {
iJsonModelMin = iCurrDest;
sJsonModelBestMatch = sKey;
}
});
return sJsonModelBestMatch;
} | [
"function",
"_fnFindBestMatch",
"(",
"aValues",
",",
"sBindingPath",
")",
"{",
"var",
"iJsonModelMin",
"=",
"-",
"1",
";",
"var",
"sJsonModelBestMatch",
"=",
"false",
";",
"aValues",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"var",
"iCurrDest",... | Control, Internal, Application | [
"Control",
"Internal",
"Application"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/rules/Model.support.js#L31-L42 | train | Find the best value in the given array of values | [
30522,
3853,
1035,
1042,
2078,
16294,
18939,
4355,
18900,
2818,
1006,
10927,
7630,
2229,
1010,
24829,
22254,
2075,
15069,
1007,
1063,
13075,
1045,
22578,
2239,
5302,
9247,
10020,
1027,
1011,
1015,
1025,
13075,
1055,
22578,
2239,
5302,
9247,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
MithrilJS/mithril.js | mithril.js | removeNodes | function removeNodes(vnodes, start, end) {
for (var i = start; i < end; i++) {
var vnode3 = vnodes[i]
if (vnode3 != null) removeNode(vnode3)
}
} | javascript | function removeNodes(vnodes, start, end) {
for (var i = start; i < end; i++) {
var vnode3 = vnodes[i]
if (vnode3 != null) removeNode(vnode3)
}
} | [
"function",
"removeNodes",
"(",
"vnodes",
",",
"start",
",",
"end",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"var",
"vnode3",
"=",
"vnodes",
"[",
"i",
"]",
"if",
"(",
"vnode3",
"!=",
"null"... | remove | [
"remove"
] | 6d36fe09d129928c6b460720e08d9ed321fcd62b | https://github.com/MithrilJS/mithril.js/blob/6d36fe09d129928c6b460720e08d9ed321fcd62b/mithril.js#L1048-L1053 | train | Remove a range of nodes | [
30522,
3853,
6366,
3630,
6155,
1006,
1058,
3630,
6155,
1010,
2707,
1010,
2203,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
2707,
1025,
1045,
1026,
2203,
1025,
1045,
1009,
1009,
1007,
1063,
13075,
1058,
3630,
3207,
2509,
1027,
1058,
3630,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/DataGrid.js | function()
{
var headerTableColumns = this._headerTableColumnGroup.children;
var tableWidth = this._dataTable.offsetWidth;
var numColumns = headerTableColumns.length;
// Do not attempt to use offsetes if we're not attached to the document tree yet.
if (!this._columnWidthsInitialized && this.element.offsetWidth) {
// Give all the columns initial widths now so that during a resize,
// when the two columns that get resized get a percent value for
// their widths, all the other columns already have percent values
// for their widths.
for (var i = 0; i < numColumns; i++) {
var columnWidth = this.headerTableBody.rows[0].cells[i].offsetWidth;
var percentWidth = ((columnWidth / tableWidth) * 100) + "%";
this._headerTableColumnGroup.children[i].style.width = percentWidth;
this._dataTableColumnGroup.children[i].style.width = percentWidth;
}
this._columnWidthsInitialized = true;
}
this._positionResizers();
this.dispatchEventToListeners("width changed");
} | javascript | function()
{
var headerTableColumns = this._headerTableColumnGroup.children;
var tableWidth = this._dataTable.offsetWidth;
var numColumns = headerTableColumns.length;
// Do not attempt to use offsetes if we're not attached to the document tree yet.
if (!this._columnWidthsInitialized && this.element.offsetWidth) {
// Give all the columns initial widths now so that during a resize,
// when the two columns that get resized get a percent value for
// their widths, all the other columns already have percent values
// for their widths.
for (var i = 0; i < numColumns; i++) {
var columnWidth = this.headerTableBody.rows[0].cells[i].offsetWidth;
var percentWidth = ((columnWidth / tableWidth) * 100) + "%";
this._headerTableColumnGroup.children[i].style.width = percentWidth;
this._dataTableColumnGroup.children[i].style.width = percentWidth;
}
this._columnWidthsInitialized = true;
}
this._positionResizers();
this.dispatchEventToListeners("width changed");
} | [
"function",
"(",
")",
"{",
"var",
"headerTableColumns",
"=",
"this",
".",
"_headerTableColumnGroup",
".",
"children",
";",
"var",
"tableWidth",
"=",
"this",
".",
"_dataTable",
".",
"offsetWidth",
";",
"var",
"numColumns",
"=",
"headerTableColumns",
".",
"length"... | Updates the widths of the table, including the positions of the column resizers. IMPORTANT: This function MUST be called once after the element of the DataGrid is attached to its parent element and every subsequent time the width of the parent element is changed in order to make it possible to resize the columns. If this function is not called after the DataGrid is attached to its parent element, then the DataGrid's columns will not be resizable. | [
"Updates",
"the",
"widths",
"of",
"the",
"table",
"including",
"the",
"positions",
"of",
"the",
"column",
"resizers",
".",
"IMPORTANT",
":",
"This",
"function",
"MUST",
"be",
"called",
"once",
"after",
"the",
"element",
"of",
"the",
"DataGrid",
"is",
"attach... | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/DataGrid.js#L404-L427 | train | This method is called when the width of the table is changed. | [
30522,
3853,
1006,
1007,
1063,
13075,
20346,
10880,
25778,
2819,
3619,
1027,
2023,
1012,
1035,
20346,
10880,
25778,
2819,
3070,
22107,
1012,
2336,
1025,
13075,
2795,
9148,
11927,
2232,
1027,
2023,
1012,
1035,
2951,
10880,
1012,
16396,
9148,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/Agents/DOMHelpers.js | eachNode | function eachNode(src, callback) {
var index = 0;
var text, range, length, payload;
while (index < src.length) {
// find the next tag
range = _findTag(src, index);
if (!range) {
range = { from: src.length, length: 0 };
}
// add the text before the tag
length = range.from - index;
if (length > 0) {
text = src.substr(index, length);
if (/\S/.test(text)) {
payload = extractPayload(text);
payload.sourceOffset = index;
payload.sourceLength = length;
callback(payload);
}
}
// add the tag
if (range.length > 0) {
payload = extractPayload(src.substr(range.from, range.length));
payload.sourceOffset = range.from;
payload.sourceLength = range.length;
callback(payload);
}
// advance
index = range.from + range.length;
}
} | javascript | function eachNode(src, callback) {
var index = 0;
var text, range, length, payload;
while (index < src.length) {
// find the next tag
range = _findTag(src, index);
if (!range) {
range = { from: src.length, length: 0 };
}
// add the text before the tag
length = range.from - index;
if (length > 0) {
text = src.substr(index, length);
if (/\S/.test(text)) {
payload = extractPayload(text);
payload.sourceOffset = index;
payload.sourceLength = length;
callback(payload);
}
}
// add the tag
if (range.length > 0) {
payload = extractPayload(src.substr(range.from, range.length));
payload.sourceOffset = range.from;
payload.sourceLength = range.length;
callback(payload);
}
// advance
index = range.from + range.length;
}
} | [
"function",
"eachNode",
"(",
"src",
",",
"callback",
")",
"{",
"var",
"index",
"=",
"0",
";",
"var",
"text",
",",
"range",
",",
"length",
",",
"payload",
";",
"while",
"(",
"index",
"<",
"src",
".",
"length",
")",
"{",
"// find the next tag",
"range",
... | Split the source string into payloads representing individual nodes
@param {string} source
@param {function(payload)} callback
split a string into individual node contents | [
"Split",
"the",
"source",
"string",
"into",
"payloads",
"representing",
"individual",
"nodes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMHelpers.js#L228-L262 | train | iterate over the nodes in the source string | [
30522,
3853,
2169,
3630,
3207,
1006,
5034,
2278,
1010,
2655,
5963,
1007,
1063,
13075,
5950,
1027,
1014,
1025,
13075,
3793,
1010,
2846,
1010,
3091,
1010,
18093,
1025,
2096,
1006,
5950,
1026,
5034,
2278,
1012,
3091,
1007,
1063,
1013,
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... |
catapult-project/catapult | third_party/polymer3/bower_components/polymer/lib/mixins/property-accessors.js | saveAccessorValue | function saveAccessorValue(model, property) {
// Don't read/store value for any native properties since they could throw
if (!nativeProperties[property]) {
let value = model[property];
if (value !== undefined) {
if (model.__data) {
// Adding accessor to instance; update the property
// It is the user's responsibility to call _flushProperties
model._setPendingProperty(property, value);
} else {
// Adding accessor to proto; save proto's value for instance-time use
if (!model.__dataProto) {
model.__dataProto = {};
} else if (!model.hasOwnProperty(JSCompiler_renameProperty('__dataProto', model))) {
model.__dataProto = Object.create(model.__dataProto);
}
model.__dataProto[property] = value;
}
}
}
} | javascript | function saveAccessorValue(model, property) {
// Don't read/store value for any native properties since they could throw
if (!nativeProperties[property]) {
let value = model[property];
if (value !== undefined) {
if (model.__data) {
// Adding accessor to instance; update the property
// It is the user's responsibility to call _flushProperties
model._setPendingProperty(property, value);
} else {
// Adding accessor to proto; save proto's value for instance-time use
if (!model.__dataProto) {
model.__dataProto = {};
} else if (!model.hasOwnProperty(JSCompiler_renameProperty('__dataProto', model))) {
model.__dataProto = Object.create(model.__dataProto);
}
model.__dataProto[property] = value;
}
}
}
} | [
"function",
"saveAccessorValue",
"(",
"model",
",",
"property",
")",
"{",
"// Don't read/store value for any native properties since they could throw",
"if",
"(",
"!",
"nativeProperties",
"[",
"property",
"]",
")",
"{",
"let",
"value",
"=",
"model",
"[",
"property",
"... | Used to save the value of a property that will be overridden with
an accessor. If the `model` is a prototype, the values will be saved
in `__dataProto`, and it's up to the user (or downstream mixin) to
decide how/when to set these values back into the accessors.
If `model` is already an instance (it has a `__data` property), then
the value will be set as a pending property, meaning the user should
call `_invalidateProperties` or `_flushProperties` to take effect
@param {Object} model Prototype or instance
@param {string} property Name of property
@return {void}
@private | [
"Used",
"to",
"save",
"the",
"value",
"of",
"a",
"property",
"that",
"will",
"be",
"overridden",
"with",
"an",
"accessor",
".",
"If",
"the",
"model",
"is",
"a",
"prototype",
"the",
"values",
"will",
"be",
"saved",
"in",
"__dataProto",
"and",
"it",
"s",
... | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/polymer3/bower_components/polymer/lib/mixins/property-accessors.js#L45-L65 | train | Save accessor value to the model | [
30522,
3853,
3828,
6305,
9623,
21748,
10175,
5657,
1006,
2944,
1010,
3200,
1007,
1063,
1013,
1013,
2123,
1005,
1056,
3191,
1013,
3573,
3643,
2005,
2151,
3128,
5144,
2144,
2027,
2071,
5466,
2065,
1006,
999,
3128,
21572,
4842,
7368,
1031,
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... |
goldfire/howler.js | dist/howler.js | function() {
self._playLock = false;
setParams();
self._refreshBuffer(sound);
// Setup the playback params.
var vol = (sound._muted || self._muted) ? 0 : sound._volume;
node.gain.setValueAtTime(vol, Howler.ctx.currentTime);
sound._playStart = Howler.ctx.currentTime;
// Play the sound using the supported method.
if (typeof node.bufferSource.start === 'undefined') {
sound._loop ? node.bufferSource.noteGrainOn(0, seek, 86400) : node.bufferSource.noteGrainOn(0, seek, duration);
} else {
sound._loop ? node.bufferSource.start(0, seek, 86400) : node.bufferSource.start(0, seek, duration);
}
// Start a new timer if none is present.
if (timeout !== Infinity) {
self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout);
}
if (!internal) {
setTimeout(function() {
self._emit('play', sound._id);
self._loadQueue();
}, 0);
}
} | javascript | function() {
self._playLock = false;
setParams();
self._refreshBuffer(sound);
// Setup the playback params.
var vol = (sound._muted || self._muted) ? 0 : sound._volume;
node.gain.setValueAtTime(vol, Howler.ctx.currentTime);
sound._playStart = Howler.ctx.currentTime;
// Play the sound using the supported method.
if (typeof node.bufferSource.start === 'undefined') {
sound._loop ? node.bufferSource.noteGrainOn(0, seek, 86400) : node.bufferSource.noteGrainOn(0, seek, duration);
} else {
sound._loop ? node.bufferSource.start(0, seek, 86400) : node.bufferSource.start(0, seek, duration);
}
// Start a new timer if none is present.
if (timeout !== Infinity) {
self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout);
}
if (!internal) {
setTimeout(function() {
self._emit('play', sound._id);
self._loadQueue();
}, 0);
}
} | [
"function",
"(",
")",
"{",
"self",
".",
"_playLock",
"=",
"false",
";",
"setParams",
"(",
")",
";",
"self",
".",
"_refreshBuffer",
"(",
"sound",
")",
";",
"// Setup the playback params.",
"var",
"vol",
"=",
"(",
"sound",
".",
"_muted",
"||",
"self",
".",... | Fire this when the sound is ready to play to begin Web Audio playback. | [
"Fire",
"this",
"when",
"the",
"sound",
"is",
"ready",
"to",
"play",
"to",
"begin",
"Web",
"Audio",
"playback",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L825-L853 | train | Play the sound. | [
30522,
3853,
1006,
1007,
1063,
2969,
1012,
1035,
2377,
7878,
1027,
6270,
1025,
2275,
28689,
5244,
1006,
1007,
1025,
2969,
1012,
1035,
25416,
21898,
8569,
12494,
1006,
2614,
1007,
1025,
1013,
1013,
16437,
1996,
18245,
11498,
5244,
1012,
1307... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | addFilesToTern | function addFilesToTern(files) {
// limit the number of files added to tern.
var maxFileCount = preferences.getMaxFileCount();
if (numResolvedFiles + numAddedFiles < maxFileCount) {
var available = maxFileCount - numResolvedFiles - numAddedFiles;
if (available < files.length) {
files = files.slice(0, available);
}
numAddedFiles += files.length;
ternPromise.done(function (ternModule) {
var msg = {
type : MessageIds.TERN_ADD_FILES_MSG,
files : files
};
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} else {
stopAddingFiles = true;
}
return stopAddingFiles;
} | javascript | function addFilesToTern(files) {
// limit the number of files added to tern.
var maxFileCount = preferences.getMaxFileCount();
if (numResolvedFiles + numAddedFiles < maxFileCount) {
var available = maxFileCount - numResolvedFiles - numAddedFiles;
if (available < files.length) {
files = files.slice(0, available);
}
numAddedFiles += files.length;
ternPromise.done(function (ternModule) {
var msg = {
type : MessageIds.TERN_ADD_FILES_MSG,
files : files
};
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} else {
stopAddingFiles = true;
}
return stopAddingFiles;
} | [
"function",
"addFilesToTern",
"(",
"files",
")",
"{",
"// limit the number of files added to tern.",
"var",
"maxFileCount",
"=",
"preferences",
".",
"getMaxFileCount",
"(",
")",
";",
"if",
"(",
"numResolvedFiles",
"+",
"numAddedFiles",
"<",
"maxFileCount",
")",
"{",
... | Add new files to tern, keeping any previous files.
The tern server must be initialized before making
this call.
@param {Array.<string>} files - array of file to add to tern.
@return {boolean} - true if more files may be added, false if maximum has been reached. | [
"Add",
"new",
"files",
"to",
"tern",
"keeping",
"any",
"previous",
"files",
".",
"The",
"tern",
"server",
"must",
"be",
"initialized",
"before",
"making",
"this",
"call",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1028-L1056 | train | Add files to tern. | [
30522,
3853,
5587,
8873,
4244,
3406,
16451,
1006,
6764,
1007,
1063,
1013,
1013,
5787,
1996,
2193,
1997,
6764,
2794,
2000,
28774,
2078,
1012,
13075,
4098,
8873,
2571,
3597,
16671,
1027,
18394,
1012,
2131,
17848,
8873,
2571,
3597,
16671,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | AssertionArguments | function AssertionArguments(args) {
if (args.length == 2) {
this.comment = "";
this.expected = args[0];
this.actual = args[1];
} else {
this.comment = args[0] + "; ";
this.expected = args[1];
this.actual = args[2];
}
} | javascript | function AssertionArguments(args) {
if (args.length == 2) {
this.comment = "";
this.expected = args[0];
this.actual = args[1];
} else {
this.comment = args[0] + "; ";
this.expected = args[1];
this.actual = args[2];
}
} | [
"function",
"AssertionArguments",
"(",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"==",
"2",
")",
"{",
"this",
".",
"comment",
"=",
"\"\"",
";",
"this",
".",
"expected",
"=",
"args",
"[",
"0",
"]",
";",
"this",
".",
"actual",
"=",
"args",
... | Preprocess the arguments to allow for an optional comment. | [
"Preprocess",
"the",
"arguments",
"to",
"allow",
"for",
"an",
"optional",
"comment",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L758-L768 | train | Assertion arguments | [
30522,
3853,
23617,
2906,
22850,
11187,
1006,
12098,
5620,
1007,
1063,
2065,
1006,
12098,
5620,
1012,
3091,
1027,
1027,
1016,
1007,
1063,
2023,
1012,
7615,
1027,
1000,
1000,
1025,
2023,
1012,
3517,
1027,
12098,
5620,
1031,
1014,
1033,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/aria/aria.js | MdAriaProvider | function MdAriaProvider() {
var config = {
/** Whether we should show ARIA warnings in the console if labels are missing on the element */
showWarnings: true
};
return {
disableWarnings: disableWarnings,
$get: function($$rAF, $log, $window, $interpolate) {
return MdAriaService.apply(config, arguments);
}
};
/**
* @ngdoc method
* @name $mdAriaProvider#disableWarnings
* @description Disables all ARIA warnings generated by AngularJS Material.
*/
function disableWarnings() {
config.showWarnings = false;
}
} | javascript | function MdAriaProvider() {
var config = {
/** Whether we should show ARIA warnings in the console if labels are missing on the element */
showWarnings: true
};
return {
disableWarnings: disableWarnings,
$get: function($$rAF, $log, $window, $interpolate) {
return MdAriaService.apply(config, arguments);
}
};
/**
* @ngdoc method
* @name $mdAriaProvider#disableWarnings
* @description Disables all ARIA warnings generated by AngularJS Material.
*/
function disableWarnings() {
config.showWarnings = false;
}
} | [
"function",
"MdAriaProvider",
"(",
")",
"{",
"var",
"config",
"=",
"{",
"/** Whether we should show ARIA warnings in the console if labels are missing on the element */",
"showWarnings",
":",
"true",
"}",
";",
"return",
"{",
"disableWarnings",
":",
"disableWarnings",
",",
"... | @ngdoc service
@name $mdAriaProvider
@module material.core.aria
@description
Modify options of the `$mdAria` service, which will be used by most of the AngularJS Material
components.
You are able to disable `$mdAria` warnings, by using the following markup.
<hljs lang="js">
app.config(function($mdAriaProvider) {
// Globally disables all ARIA warnings.
$mdAriaProvider.disableWarnings();
});
</hljs> | [
"@ngdoc",
"service",
"@name",
"$mdAriaProvider",
"@module",
"material",
".",
"core",
".",
"aria"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/aria/aria.js#L31-L53 | train | AriaProvider provides a provider to use the ARIA warnings. | [
30522,
3853,
9108,
10980,
21572,
17258,
2121,
1006,
1007,
1063,
13075,
9530,
8873,
2290,
1027,
1063,
1013,
1008,
1008,
3251,
2057,
2323,
2265,
9342,
16234,
1999,
1996,
10122,
2065,
10873,
2024,
4394,
2006,
1996,
5783,
1008,
1013,
2265,
9028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DebugCommands/NodeDebugUtils.js | logNodeState | function logNodeState() {
if (brackets.app && brackets.app.getNodeState) {
brackets.app.getNodeState(function (err, port) {
if (err) {
console.log("[NodeDebugUtils] Node is in error state " + err);
} else {
console.log("[NodeDebugUtils] Node is listening on port " + port);
}
});
} else {
console.error("[NodeDebugUtils] No brackets.app.getNodeState function. Maybe you're running the wrong shell?");
}
} | javascript | function logNodeState() {
if (brackets.app && brackets.app.getNodeState) {
brackets.app.getNodeState(function (err, port) {
if (err) {
console.log("[NodeDebugUtils] Node is in error state " + err);
} else {
console.log("[NodeDebugUtils] Node is listening on port " + port);
}
});
} else {
console.error("[NodeDebugUtils] No brackets.app.getNodeState function. Maybe you're running the wrong shell?");
}
} | [
"function",
"logNodeState",
"(",
")",
"{",
"if",
"(",
"brackets",
".",
"app",
"&&",
"brackets",
".",
"app",
".",
"getNodeState",
")",
"{",
"brackets",
".",
"app",
".",
"getNodeState",
"(",
"function",
"(",
"err",
",",
"port",
")",
"{",
"if",
"(",
"er... | Logs the state of the current node server to the console. | [
"Logs",
"the",
"state",
"of",
"the",
"current",
"node",
"server",
"to",
"the",
"console",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/DebugCommands/NodeDebugUtils.js#L47-L59 | train | This function is called by the node. js code to log the node state | [
30522,
3853,
8833,
3630,
6155,
12259,
1006,
1007,
1063,
2065,
1006,
19719,
1012,
10439,
1004,
1004,
19719,
1012,
10439,
1012,
2131,
3630,
6155,
12259,
1007,
1063,
19719,
1012,
10439,
1012,
2131,
3630,
6155,
12259,
1006,
3853,
1006,
9413,
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... |
mdn/browser-compat-data | scripts/render.js | collectCompatNotes | function collectCompatNotes() {
function pushNotes(supportEntry, browserName) {
// collect notes
if (supportEntry.hasOwnProperty('notes')) {
let notes = supportEntry['notes'];
if (Array.isArray(notes)) {
for (let note of notes) {
if (notesArray.indexOf(note) === -1) {
notesArray.push(note);
}
}
} else {
if (notesArray.indexOf(notes) === -1) {
notesArray.push(notes);
}
}
}
// collect flags
if (supportEntry.hasOwnProperty('flag')) {
let flagNote = writeFlagsNote(supportEntry, browserName);
if (notesArray.indexOf(flagNote) === -1) {
notesArray.push(flagNote);
}
}
// collect alternative names
if (supportEntry.hasOwnProperty('alternative_name')) {
let altNameNote = writeAlternativeNameNote(supportEntry.alternative_name);
if (notesArray.indexOf(altNameNote) === -1) {
notesArray.push(altNameNote);
}
}
}
for (let row of features) {
let support = Object.keys(row).map((k) => row[k])[0].support;
for (let browserName of Object.keys(support)) {
if (Array.isArray(support[browserName])) {
for (let entry of support[browserName]) {
pushNotes(entry, browserName);
}
} else {
pushNotes(support[browserName], browserName);
}
}
}
return notesArray;
} | javascript | function collectCompatNotes() {
function pushNotes(supportEntry, browserName) {
// collect notes
if (supportEntry.hasOwnProperty('notes')) {
let notes = supportEntry['notes'];
if (Array.isArray(notes)) {
for (let note of notes) {
if (notesArray.indexOf(note) === -1) {
notesArray.push(note);
}
}
} else {
if (notesArray.indexOf(notes) === -1) {
notesArray.push(notes);
}
}
}
// collect flags
if (supportEntry.hasOwnProperty('flag')) {
let flagNote = writeFlagsNote(supportEntry, browserName);
if (notesArray.indexOf(flagNote) === -1) {
notesArray.push(flagNote);
}
}
// collect alternative names
if (supportEntry.hasOwnProperty('alternative_name')) {
let altNameNote = writeAlternativeNameNote(supportEntry.alternative_name);
if (notesArray.indexOf(altNameNote) === -1) {
notesArray.push(altNameNote);
}
}
}
for (let row of features) {
let support = Object.keys(row).map((k) => row[k])[0].support;
for (let browserName of Object.keys(support)) {
if (Array.isArray(support[browserName])) {
for (let entry of support[browserName]) {
pushNotes(entry, browserName);
}
} else {
pushNotes(support[browserName], browserName);
}
}
}
return notesArray;
} | [
"function",
"collectCompatNotes",
"(",
")",
"{",
"function",
"pushNotes",
"(",
"supportEntry",
",",
"browserName",
")",
"{",
"// collect notes",
"if",
"(",
"supportEntry",
".",
"hasOwnProperty",
"(",
"'notes'",
")",
")",
"{",
"let",
"notes",
"=",
"supportEntry",... | /*
Iterate into all "support" objects, and all browsers under them,
and collect all notes in an array, without duplicates. | [
"/",
"*",
"Iterate",
"into",
"all",
"support",
"objects",
"and",
"all",
"browsers",
"under",
"them",
"and",
"collect",
"all",
"notes",
"in",
"an",
"array",
"without",
"duplicates",
"."
] | 6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b | https://github.com/mdn/browser-compat-data/blob/6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b/scripts/render.js#L279-L325 | train | collectCompatNotes - collect notes from supportEntry | [
30522,
3853,
8145,
9006,
4502,
2102,
20564,
1006,
1007,
1063,
3853,
5245,
20564,
1006,
2490,
4765,
2854,
1010,
16602,
18442,
1007,
1063,
1013,
1013,
8145,
3964,
2065,
1006,
2490,
4765,
2854,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/token-store/index.js | getAdjacentCommentTokensFromCursor | function getAdjacentCommentTokensFromCursor(cursor) {
const tokens = [];
let currentToken = cursor.getOneToken();
while (currentToken && astUtils.isCommentToken(currentToken)) {
tokens.push(currentToken);
currentToken = cursor.getOneToken();
}
return tokens;
} | javascript | function getAdjacentCommentTokensFromCursor(cursor) {
const tokens = [];
let currentToken = cursor.getOneToken();
while (currentToken && astUtils.isCommentToken(currentToken)) {
tokens.push(currentToken);
currentToken = cursor.getOneToken();
}
return tokens;
} | [
"function",
"getAdjacentCommentTokensFromCursor",
"(",
"cursor",
")",
"{",
"const",
"tokens",
"=",
"[",
"]",
";",
"let",
"currentToken",
"=",
"cursor",
".",
"getOneToken",
"(",
")",
";",
"while",
"(",
"currentToken",
"&&",
"astUtils",
".",
"isCommentToken",
"(... | Gets comment tokens that are adjacent to the current cursor position.
@param {Cursor} cursor - A cursor instance.
@returns {Array} An array of comment tokens adjacent to the current cursor position.
@private | [
"Gets",
"comment",
"tokens",
"that",
"are",
"adjacent",
"to",
"the",
"current",
"cursor",
"position",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/token-store/index.js#L183-L193 | train | Get the adjacent comment tokens from the cursor | [
30522,
3853,
2131,
4215,
3900,
13013,
9006,
3672,
18715,
6132,
19699,
5358,
10841,
25301,
2099,
1006,
12731,
25301,
2099,
1007,
1063,
9530,
3367,
19204,
2015,
1027,
1031,
1033,
1025,
2292,
2783,
18715,
2368,
1027,
12731,
25301,
2099,
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/utils/AppInit.js | _dispatchReady | function _dispatchReady(type) {
var i,
myHandlers = _callbacks[type];
// mark this status complete
_status[type] = true;
for (i = 0; i < myHandlers.length; i++) {
_callHandler(myHandlers[i]);
}
// clear all callbacks after being called
_callbacks[type] = [];
} | javascript | function _dispatchReady(type) {
var i,
myHandlers = _callbacks[type];
// mark this status complete
_status[type] = true;
for (i = 0; i < myHandlers.length; i++) {
_callHandler(myHandlers[i]);
}
// clear all callbacks after being called
_callbacks[type] = [];
} | [
"function",
"_dispatchReady",
"(",
"type",
")",
"{",
"var",
"i",
",",
"myHandlers",
"=",
"_callbacks",
"[",
"type",
"]",
";",
"// mark this status complete",
"_status",
"[",
"type",
"]",
"=",
"true",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"myHa... | /*
dispatches the event by calling all handlers registered for that type
@param {string} type - the event type to dispatch (APP_READY, EXTENSIONS_READY, HTML_READY)
@private | [
"/",
"*",
"dispatches",
"the",
"event",
"by",
"calling",
"all",
"handlers",
"registered",
"for",
"that",
"type"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/AppInit.js#L101-L114 | train | dispatch ready event | [
30522,
3853,
1035,
18365,
16416,
5149,
1006,
2828,
1007,
1063,
13075,
1045,
1010,
2026,
11774,
12910,
1027,
1035,
2655,
12221,
30524,
1007,
1063,
1035,
2655,
11774,
3917,
1006,
2026,
11774,
12910,
1031,
1045,
1033,
1007,
1025,
1065,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.