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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
adobe/brackets | src/features/ParameterHintsManager.js | installListeners | function installListeners(editor) {
editor.on("keydown.ParameterHinting", function (event, editor, domEvent) {
if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) {
dismissHint(editor);
}
}).on("scroll.ParameterHinting", function () {
dismissHint(editor);
})
.on("editorChange.ParameterHinting", _handleChange)
.on("keypress.ParameterHinting", _handleKeypressEvent);
} | javascript | function installListeners(editor) {
editor.on("keydown.ParameterHinting", function (event, editor, domEvent) {
if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) {
dismissHint(editor);
}
}).on("scroll.ParameterHinting", function () {
dismissHint(editor);
})
.on("editorChange.ParameterHinting", _handleChange)
.on("keypress.ParameterHinting", _handleKeypressEvent);
} | [
"function",
"installListeners",
"(",
"editor",
")",
"{",
"editor",
".",
"on",
"(",
"\"keydown.ParameterHinting\"",
",",
"function",
"(",
"event",
",",
"editor",
",",
"domEvent",
")",
"{",
"if",
"(",
"domEvent",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK... | Install function hint listeners.
@param {Editor} editor - editor context on which to listen for
changes | [
"Install",
"function",
"hint",
"listeners",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L318-L328 | train | installs listeners for parameter hinting | [
30522,
3853,
16500,
9863,
24454,
2015,
1006,
3559,
1007,
1063,
3559,
1012,
2006,
1006,
1000,
3145,
7698,
1012,
16381,
10606,
3436,
1000,
1010,
3853,
1006,
2724,
1010,
3559,
1010,
8514,
15338,
1007,
1063,
2065,
1006,
8514,
15338,
1012,
3145,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/tabs.js | tabBrowser_openTab | function tabBrowser_openTab(aEvent) {
var event = aEvent || { };
var type = (event.type == undefined) ? "menu" : event.type;
// Disable tab closing animation for default behavior
prefs.preferences.setPref(PREF_TABS_ANIMATE, false);
// Add event listener to wait until the tab has been opened
var self = { opened: false };
function checkTabOpened() { self.opened = true; }
this._controller.window.addEventListener("TabOpen", checkTabOpened, false);
switch (type) {
case "menu":
var menuitem = new elementslib.Elem(this._controller.menus['file-menu'].menu_newNavigatorTab);
this._controller.click(menuitem);
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
this._controller.keypress(null, cmdKey, {accelKey: true});
break;
case "newTabButton":
var newTabButton = this.getElement({type: "tabs_newTabButton"});
this._controller.click(newTabButton);
break;
case "tabStrip":
var tabStrip = this.getElement({type: "tabs_strip"});
// RTL-locales need to be treated separately
if (utils.getEntity(this.getDtds(), "locale.dir") == "rtl") {
// XXX: Workaround until bug 537968 has been fixed
this._controller.click(tabStrip, 100, 3);
// Todo: Calculate the correct x position
this._controller.doubleClick(tabStrip, 100, 3);
} else {
// XXX: Workaround until bug 537968 has been fixed
this._controller.click(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
// Todo: Calculate the correct x position
this._controller.doubleClick(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
}
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " + type);
}
try {
this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
{tab: self});
} finally {
this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
}
} | javascript | function tabBrowser_openTab(aEvent) {
var event = aEvent || { };
var type = (event.type == undefined) ? "menu" : event.type;
// Disable tab closing animation for default behavior
prefs.preferences.setPref(PREF_TABS_ANIMATE, false);
// Add event listener to wait until the tab has been opened
var self = { opened: false };
function checkTabOpened() { self.opened = true; }
this._controller.window.addEventListener("TabOpen", checkTabOpened, false);
switch (type) {
case "menu":
var menuitem = new elementslib.Elem(this._controller.menus['file-menu'].menu_newNavigatorTab);
this._controller.click(menuitem);
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
this._controller.keypress(null, cmdKey, {accelKey: true});
break;
case "newTabButton":
var newTabButton = this.getElement({type: "tabs_newTabButton"});
this._controller.click(newTabButton);
break;
case "tabStrip":
var tabStrip = this.getElement({type: "tabs_strip"});
// RTL-locales need to be treated separately
if (utils.getEntity(this.getDtds(), "locale.dir") == "rtl") {
// XXX: Workaround until bug 537968 has been fixed
this._controller.click(tabStrip, 100, 3);
// Todo: Calculate the correct x position
this._controller.doubleClick(tabStrip, 100, 3);
} else {
// XXX: Workaround until bug 537968 has been fixed
this._controller.click(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
// Todo: Calculate the correct x position
this._controller.doubleClick(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
}
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " + type);
}
try {
this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
{tab: self});
} finally {
this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
}
} | [
"function",
"tabBrowser_openTab",
"(",
"aEvent",
")",
"{",
"var",
"event",
"=",
"aEvent",
"||",
"{",
"}",
";",
"var",
"type",
"=",
"(",
"event",
".",
"type",
"==",
"undefined",
")",
"?",
"\"menu\"",
":",
"event",
".",
"type",
";",
"// Disable tab closing... | Open a new tab
@param {object} aEvent
The event specifies how to open a new tab (menu, shortcut,
Elements: type - Type of event (menu, newTabButton, shortcut, tabStrip)
[optional - default: menu] | [
"Open",
"a",
"new",
"tab"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabs.js#L416-L468 | train | Open a new tab | [
30522,
3853,
21628,
12618,
9333,
2121,
1035,
2330,
2696,
2497,
1006,
29347,
15338,
1007,
1063,
13075,
2724,
1027,
29347,
15338,
1064,
1064,
1063,
1065,
1025,
13075,
2828,
1027,
1006,
2724,
1012,
2828,
1027,
1027,
6151,
28344,
1007,
1029,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | write_dos_date | function write_dos_date(buf, date) {
if(typeof date === "string") date = new Date(date);
var hms = date.getHours();
hms = hms << 6 | date.getMinutes();
hms = hms << 5 | (date.getSeconds()>>>1);
buf.write_shift(2, hms);
var ymd = (date.getFullYear() - 1980);
ymd = ymd << 4 | (date.getMonth()+1);
ymd = ymd << 5 | date.getDate();
buf.write_shift(2, ymd);
} | javascript | function write_dos_date(buf, date) {
if(typeof date === "string") date = new Date(date);
var hms = date.getHours();
hms = hms << 6 | date.getMinutes();
hms = hms << 5 | (date.getSeconds()>>>1);
buf.write_shift(2, hms);
var ymd = (date.getFullYear() - 1980);
ymd = ymd << 4 | (date.getMonth()+1);
ymd = ymd << 5 | date.getDate();
buf.write_shift(2, ymd);
} | [
"function",
"write_dos_date",
"(",
"buf",
",",
"date",
")",
"{",
"if",
"(",
"typeof",
"date",
"===",
"\"string\"",
")",
"date",
"=",
"new",
"Date",
"(",
"date",
")",
";",
"var",
"hms",
"=",
"date",
".",
"getHours",
"(",
")",
";",
"hms",
"=",
"hms",... | /* -------------------------------------------------------------------------- /* DOS Date format:
high|YYYYYYYm.mmmddddd.HHHHHMMM.MMMSSSSS|low
add 1980 to stored year
stored second should be doubled
/* write JS date to buf as a DOS date | [
"/",
"*",
"--------------------------------------------------------------------------",
"/",
"*",
"DOS",
"Date",
"format",
":",
"high|YYYYYYYm",
".",
"mmmddddd",
".",
"HHHHHMMM",
".",
"MMMSSSSS|low",
"add",
"1980",
"to",
"stored",
"year",
"stored",
"second",
"should",
... | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L1278-L1288 | train | Writes a Date to a Buffer | [
30522,
3853,
4339,
1035,
9998,
1035,
3058,
1006,
20934,
2546,
1010,
3058,
1007,
1063,
2065,
1006,
2828,
11253,
3058,
1027,
1027,
1027,
1000,
5164,
1000,
1007,
3058,
1027,
2047,
3058,
1006,
3058,
1007,
1025,
13075,
7220,
1027,
3058,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/GrowingEnablement.js | function(oContext, oBindingInfo) {
this._iRenderedDataItems++;
var oItem = oBindingInfo.factory(ManagedObjectMetadata.uid("clone"), oContext);
return oItem.setBindingContext(oContext, oBindingInfo.model);
} | javascript | function(oContext, oBindingInfo) {
this._iRenderedDataItems++;
var oItem = oBindingInfo.factory(ManagedObjectMetadata.uid("clone"), oContext);
return oItem.setBindingContext(oContext, oBindingInfo.model);
} | [
"function",
"(",
"oContext",
",",
"oBindingInfo",
")",
"{",
"this",
".",
"_iRenderedDataItems",
"++",
";",
"var",
"oItem",
"=",
"oBindingInfo",
".",
"factory",
"(",
"ManagedObjectMetadata",
".",
"uid",
"(",
"\"clone\"",
")",
",",
"oContext",
")",
";",
"retur... | creates list item from the factory | [
"creates",
"list",
"item",
"from",
"the",
"factory"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/GrowingEnablement.js#L361-L365 | train | Creates a new data item and sets the binding context | [
30522,
3853,
1006,
1051,
8663,
18209,
1010,
27885,
22254,
2075,
2378,
14876,
1007,
1063,
2023,
1012,
1035,
20868,
10497,
6850,
2850,
15444,
18532,
2015,
1009,
1009,
1025,
13075,
1051,
4221,
2213,
1027,
27885,
22254,
2075,
2378,
14876,
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... | |
google/closure-library | closure/goog/html/sanitizer/noclobber.js | getElementsByTagName | function getElementsByTagName(element, name) {
return Array.from(genericMethodCall(
Methods.GET_ELEMENTS_BY_TAG_NAME, element, 'getElementsByTagName',
[name]));
} | javascript | function getElementsByTagName(element, name) {
return Array.from(genericMethodCall(
Methods.GET_ELEMENTS_BY_TAG_NAME, element, 'getElementsByTagName',
[name]));
} | [
"function",
"getElementsByTagName",
"(",
"element",
",",
"name",
")",
"{",
"return",
"Array",
".",
"from",
"(",
"genericMethodCall",
"(",
"Methods",
".",
"GET_ELEMENTS_BY_TAG_NAME",
",",
"element",
",",
"'getElementsByTagName'",
",",
"[",
"name",
"]",
")",
")",
... | Get the children of a specific tag matching the provided tag name without
falling prey to things like <form><input name="getElementsByTagName"></form>.
Equivalent to {@code element.getElementsByTagName("foo")}.
@param {!Element} element
@param {string} name
@return {!Array<!Element>} | [
"Get",
"the",
"children",
"of",
"a",
"specific",
"tag",
"matching",
"the",
"provided",
"tag",
"name",
"without",
"falling",
"prey",
"to",
"things",
"like",
"<form",
">",
"<input",
"name",
"=",
"getElementsByTagName",
">",
"<",
"/",
"form",
">",
".",
"Equiv... | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/sanitizer/noclobber.js#L284-L288 | train | Get all elements by tag name | [
30522,
3853,
2131,
12260,
8163,
3762,
15900,
18442,
1006,
5783,
1010,
2171,
1007,
1063,
2709,
9140,
1012,
2013,
1006,
12391,
11368,
6806,
16409,
8095,
1006,
4725,
1012,
2131,
1035,
3787,
1035,
2011,
1035,
6415,
1035,
2171,
1010,
5783,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | logAdditionalUserInfo | function logAdditionalUserInfo(response) {
if (response.additionalUserInfo) {
if (response.additionalUserInfo.username) {
log(response.additionalUserInfo['providerId'] + ' username: ' +
response.additionalUserInfo.username);
}
if (response.additionalUserInfo.profile) {
log(response.additionalUserInfo['providerId'] + ' profile information:');
log(JSON.stringify(response.additionalUserInfo.profile, null, 2));
}
if (typeof response.additionalUserInfo.isNewUser !== 'undefined') {
log(response.additionalUserInfo['providerId'] + ' isNewUser: ' +
response.additionalUserInfo.isNewUser);
}
}
} | javascript | function logAdditionalUserInfo(response) {
if (response.additionalUserInfo) {
if (response.additionalUserInfo.username) {
log(response.additionalUserInfo['providerId'] + ' username: ' +
response.additionalUserInfo.username);
}
if (response.additionalUserInfo.profile) {
log(response.additionalUserInfo['providerId'] + ' profile information:');
log(JSON.stringify(response.additionalUserInfo.profile, null, 2));
}
if (typeof response.additionalUserInfo.isNewUser !== 'undefined') {
log(response.additionalUserInfo['providerId'] + ' isNewUser: ' +
response.additionalUserInfo.isNewUser);
}
}
} | [
"function",
"logAdditionalUserInfo",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"additionalUserInfo",
")",
"{",
"if",
"(",
"response",
".",
"additionalUserInfo",
".",
"username",
")",
"{",
"log",
"(",
"response",
".",
"additionalUserInfo",
"[",
"'p... | Logs additional user info returned by a sign-in event, if available.
@param {!Object} response | [
"Logs",
"additional",
"user",
"info",
"returned",
"by",
"a",
"sign",
"-",
"in",
"event",
"if",
"available",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L1077-L1092 | train | Log additional user information | [
30522,
3853,
8833,
4215,
27064,
20330,
2378,
14876,
1006,
3433,
1007,
1063,
2065,
1006,
3433,
1012,
3176,
20330,
2378,
14876,
1007,
1063,
2065,
1006,
3433,
1012,
3176,
20330,
2378,
14876,
1012,
5310,
18442,
1007,
1063,
8833,
1006,
3433,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/indent-legacy.js | checkFirstNodeLineIndent | function checkFirstNodeLineIndent(node, firstLineIndent) {
const startIndent = getNodeIndent(node, false);
if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
report(
node,
firstLineIndent,
startIndent.space,
startIndent.tab,
{ line: node.loc.start.line, column: node.loc.start.column }
);
}
} | javascript | function checkFirstNodeLineIndent(node, firstLineIndent) {
const startIndent = getNodeIndent(node, false);
if ((startIndent.goodChar !== firstLineIndent || startIndent.badChar !== 0) && isNodeFirstInLine(node)) {
report(
node,
firstLineIndent,
startIndent.space,
startIndent.tab,
{ line: node.loc.start.line, column: node.loc.start.column }
);
}
} | [
"function",
"checkFirstNodeLineIndent",
"(",
"node",
",",
"firstLineIndent",
")",
"{",
"const",
"startIndent",
"=",
"getNodeIndent",
"(",
"node",
",",
"false",
")",
";",
"if",
"(",
"(",
"startIndent",
".",
"goodChar",
"!==",
"firstLineIndent",
"||",
"startIndent... | Check first node line indent is correct
@param {ASTNode} node Node to examine
@param {int} firstLineIndent needed indent
@returns {void} | [
"Check",
"first",
"node",
"line",
"indent",
"is",
"correct"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L490-L502 | train | Check first node line indent | [
30522,
3853,
4638,
8873,
12096,
3630,
9247,
3170,
22254,
4765,
1006,
13045,
1010,
2034,
4179,
22254,
4765,
1007,
1063,
9530,
3367,
2707,
22254,
4765,
1027,
2131,
3630,
3207,
22254,
4765,
1006,
13045,
1010,
6270,
1007,
1025,
2065,
1006,
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... |
NervJS/taro | packages/taro-components/src/components/slider/index.js | parseType | function parseType (props) {
const {
min,
max,
step,
disabled,
value,
backgroundColor,
activeColor,
blockSize,
blockColor,
showValue,
onChange,
onChanging
} = props
// 抛出错误信息
const throwErrorMsg = type => {
throw new TypeError(type)
}
if (min) isNumber(min) ? '' : throwErrorMsg('min')
if (max) isNumber(max) ? '' : throwErrorMsg('max')
if (step) isNumber(step) ? '' : throwErrorMsg('step')
if (value) isNumber(value) ? '' : throwErrorMsg('value')
if (blockSize) isNumber(blockSize) ? '' : throwErrorMsg('blockSize')
if (disabled) isBoolean(disabled) ? '' : throwErrorMsg('disabled')
if (showValue) isBoolean(showValue) ? '' : throwErrorMsg('showValue')
if (backgroundColor) {
isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
}
if (activeColor) isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (blockColor) isString(blockColor) ? '' : throwErrorMsg('blockColor')
if (onChange) isFunction(onChange) ? '' : throwErrorMsg('onChange')
if (onChanging) isFunction(onChanging) ? '' : throwErrorMsg('onChanging')
} | javascript | function parseType (props) {
const {
min,
max,
step,
disabled,
value,
backgroundColor,
activeColor,
blockSize,
blockColor,
showValue,
onChange,
onChanging
} = props
// 抛出错误信息
const throwErrorMsg = type => {
throw new TypeError(type)
}
if (min) isNumber(min) ? '' : throwErrorMsg('min')
if (max) isNumber(max) ? '' : throwErrorMsg('max')
if (step) isNumber(step) ? '' : throwErrorMsg('step')
if (value) isNumber(value) ? '' : throwErrorMsg('value')
if (blockSize) isNumber(blockSize) ? '' : throwErrorMsg('blockSize')
if (disabled) isBoolean(disabled) ? '' : throwErrorMsg('disabled')
if (showValue) isBoolean(showValue) ? '' : throwErrorMsg('showValue')
if (backgroundColor) {
isString(backgroundColor) ? '' : throwErrorMsg('backgroundColor')
}
if (activeColor) isString(activeColor) ? '' : throwErrorMsg('activeColor')
if (blockColor) isString(blockColor) ? '' : throwErrorMsg('blockColor')
if (onChange) isFunction(onChange) ? '' : throwErrorMsg('onChange')
if (onChanging) isFunction(onChanging) ? '' : throwErrorMsg('onChanging')
} | [
"function",
"parseType",
"(",
"props",
")",
"{",
"const",
"{",
"min",
",",
"max",
",",
"step",
",",
"disabled",
",",
"value",
",",
"backgroundColor",
",",
"activeColor",
",",
"blockSize",
",",
"blockColor",
",",
"showValue",
",",
"onChange",
",",
"onChangi... | props 类型检测
@param {Object} props | [
"props",
"类型检测"
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro-components/src/components/slider/index.js#L11-L50 | train | Parse type | [
30522,
3853,
11968,
13462,
18863,
1006,
24387,
1007,
1063,
9530,
3367,
1063,
8117,
1010,
4098,
1010,
3357,
1010,
9776,
1010,
3643,
1010,
4281,
18717,
1010,
3161,
18717,
1010,
5991,
4697,
1010,
3796,
18717,
1010,
2265,
10175,
5657,
1010,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/data/importer/index.js | function (handler, directory) {
var globPattern = this.getExtensionGlob(handler.extensions, ALL_DIRS);
return _.map(glob.sync(globPattern, {cwd: directory}), function (file) {
return {name: file, path: path.join(directory, file)};
});
} | javascript | function (handler, directory) {
var globPattern = this.getExtensionGlob(handler.extensions, ALL_DIRS);
return _.map(glob.sync(globPattern, {cwd: directory}), function (file) {
return {name: file, path: path.join(directory, file)};
});
} | [
"function",
"(",
"handler",
",",
"directory",
")",
"{",
"var",
"globPattern",
"=",
"this",
".",
"getExtensionGlob",
"(",
"handler",
".",
"extensions",
",",
"ALL_DIRS",
")",
";",
"return",
"_",
".",
"map",
"(",
"glob",
".",
"sync",
"(",
"globPattern",
","... | Use the handler extensions to get a globbing pattern, then use that to fetch all the files from the zip which
are relevant to the given handler, and return them as a name and path combo
@param {Object} handler
@param {String} directory
@returns [] Files | [
"Use",
"the",
"handler",
"extensions",
"to",
"get",
"a",
"globbing",
"pattern",
"then",
"use",
"that",
"to",
"fetch",
"all",
"the",
"files",
"from",
"the",
"zip",
"which",
"are",
"relevant",
"to",
"the",
"given",
"handler",
"and",
"return",
"them",
"as",
... | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/data/importer/index.js#L186-L191 | train | Get the list of files in the given directory | [
30522,
3853,
1006,
28213,
1010,
14176,
1007,
1063,
13075,
1043,
4135,
2497,
4502,
12079,
2078,
1027,
2023,
1012,
2131,
10288,
29048,
23296,
16429,
1006,
28213,
1012,
14305,
1010,
2035,
1035,
16101,
2015,
1007,
1025,
2709,
1035,
1012,
4949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/editor/EditorManager.js | _handleCurrentFileChange | function _handleCurrentFileChange(e, file) {
var doc = file && DocumentManager.getOpenDocumentForPath(file.fullPath);
_notifyActiveEditorChanged(doc && doc._masterEditor);
} | javascript | function _handleCurrentFileChange(e, file) {
var doc = file && DocumentManager.getOpenDocumentForPath(file.fullPath);
_notifyActiveEditorChanged(doc && doc._masterEditor);
} | [
"function",
"_handleCurrentFileChange",
"(",
"e",
",",
"file",
")",
"{",
"var",
"doc",
"=",
"file",
"&&",
"DocumentManager",
".",
"getOpenDocumentForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"_notifyActiveEditorChanged",
"(",
"doc",
"&&",
"doc",
".",
"_ma... | Current File Changed handler
MainViewManager dispatches a "currentFileChange" event whenever the currently viewed
file changes. Which could mean that the previously viewed file has been closed or a
non-editor view (image) has been given focus. _notifyAcitveEditorChanged is also hooked
up to editor.focus to handle focus events for editors which handles changing focus between
two editors but, because editormanager maintains a "_lastFocusedEditor" state, we have to
"nullify" that state whenever the focus goes to a non-editor or when the current editor is closed
@private
@param {!jQuery.Event} e - event
@param {?File} file - current file (can be null) | [
"Current",
"File",
"Changed",
"handler",
"MainViewManager",
"dispatches",
"a",
"currentFileChange",
"event",
"whenever",
"the",
"currently",
"viewed",
"file",
"changes",
".",
"Which",
"could",
"mean",
"that",
"the",
"previously",
"viewed",
"file",
"has",
"been",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorManager.js#L167-L170 | train | Handle current file change | [
30522,
3853,
1035,
5047,
10841,
14343,
3372,
8873,
2571,
22305,
2063,
1006,
1041,
1010,
5371,
1007,
1063,
13075,
9986,
1027,
5371,
1004,
1004,
6254,
24805,
4590,
1012,
2131,
26915,
3527,
24894,
4765,
29278,
15069,
1006,
5371,
1012,
2440,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | toggleCodeBlock | function toggleCodeBlock(editor) {
var fenceCharsToInsert = editor.options.blockStyles.code;
function fencing_line(line) {
/* return true, if this is a ``` or ~~~ line */
if(typeof line !== "object") {
throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof line + ": " + line;
}
return line.styles && line.styles[2] && line.styles[2].indexOf("formatting-code-block") !== -1;
}
function token_state(token) {
// base goes an extra level deep when mode backdrops are used, e.g. spellchecker on
return token.state.base.base || token.state.base;
}
function code_type(cm, line_num, line, firstTok, lastTok) {
/*
* Return "single", "indented", "fenced" or false
*
* cm and line_num are required. Others are optional for efficiency
* To check in the middle of a line, pass in firstTok yourself.
*/
line = line || cm.getLineHandle(line_num);
firstTok = firstTok || cm.getTokenAt({
line: line_num,
ch: 1
});
lastTok = lastTok || (!!line.text && cm.getTokenAt({
line: line_num,
ch: line.text.length - 1
}));
var types = firstTok.type ? firstTok.type.split(" ") : [];
if(lastTok && token_state(lastTok).indentedCode) {
// have to check last char, since first chars of first line aren"t marked as indented
return "indented";
} else if(types.indexOf("comment") === -1) {
// has to be after "indented" check, since first chars of first indented line aren"t marked as such
return false;
} else if(token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)) {
return "fenced";
} else {
return "single";
}
}
function insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert) {
var start_line_sel = cur_start.line + 1,
end_line_sel = cur_end.line + 1,
sel_multi = cur_start.line !== cur_end.line,
repl_start = fenceCharsToInsert + "\n",
repl_end = "\n" + fenceCharsToInsert;
if(sel_multi) {
end_line_sel++;
}
// handle last char including \n or not
if(sel_multi && cur_end.ch === 0) {
repl_end = fenceCharsToInsert + "\n";
end_line_sel--;
}
_replaceSelection(cm, false, [repl_start, repl_end]);
cm.setSelection({
line: start_line_sel,
ch: 0
}, {
line: end_line_sel,
ch: 0
});
}
var cm = editor.codemirror,
cur_start = cm.getCursor("start"),
cur_end = cm.getCursor("end"),
tok = cm.getTokenAt({
line: cur_start.line,
ch: cur_start.ch || 1
}), // avoid ch 0 which is a cursor pos but not token
line = cm.getLineHandle(cur_start.line),
is_code = code_type(cm, cur_start.line, line, tok);
var block_start, block_end, lineCount;
if(is_code === "single") {
// similar to some SimpleMDE _toggleBlock logic
var start = line.text.slice(0, cur_start.ch).replace("`", ""),
end = line.text.slice(cur_start.ch).replace("`", "");
cm.replaceRange(start + end, {
line: cur_start.line,
ch: 0
}, {
line: cur_start.line,
ch: 99999999999999
});
cur_start.ch--;
if(cur_start !== cur_end) {
cur_end.ch--;
}
cm.setSelection(cur_start, cur_end);
cm.focus();
} else if(is_code === "fenced") {
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
// use selection
// find the fenced line so we know what type it is (tilde, backticks, number of them)
for(block_start = cur_start.line; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(fencing_line(line)) {
break;
}
}
var fencedTok = cm.getTokenAt({
line: block_start,
ch: 1
});
var fence_chars = token_state(fencedTok).fencedChars;
var start_text, start_line;
var end_text, end_line;
// check for selection going up against fenced lines, in which case we don't want to add more fencing
if(fencing_line(cm.getLineHandle(cur_start.line))) {
start_text = "";
start_line = cur_start.line;
} else if(fencing_line(cm.getLineHandle(cur_start.line - 1))) {
start_text = "";
start_line = cur_start.line - 1;
} else {
start_text = fence_chars + "\n";
start_line = cur_start.line;
}
if(fencing_line(cm.getLineHandle(cur_end.line))) {
end_text = "";
end_line = cur_end.line;
if(cur_end.ch === 0) {
end_line += 1;
}
} else if(cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))) {
end_text = "";
end_line = cur_end.line + 1;
} else {
end_text = fence_chars + "\n";
end_line = cur_end.line + 1;
}
if(cur_end.ch === 0) {
// full last line selected, putting cursor at beginning of next
end_line -= 1;
}
cm.operation(function() {
// end line first, so that line numbers don't change
cm.replaceRange(end_text, {
line: end_line,
ch: 0
}, {
line: end_line + (end_text ? 0 : 1),
ch: 0
});
cm.replaceRange(start_text, {
line: start_line,
ch: 0
}, {
line: start_line + (start_text ? 0 : 1),
ch: 0
});
});
cm.setSelection({
line: start_line + (start_text ? 1 : 0),
ch: 0
}, {
line: end_line + (start_text ? 1 : -1),
ch: 0
});
cm.focus();
} else {
// no selection, search for ends of this fenced block
var search_from = cur_start.line;
if(fencing_line(cm.getLineHandle(cur_start.line))) { // gets a little tricky if cursor is right on a fenced line
if(code_type(cm, cur_start.line + 1) === "fenced") {
block_start = cur_start.line;
search_from = cur_start.line + 1; // for searching for "end"
} else {
block_end = cur_start.line;
search_from = cur_start.line - 1; // for searching for "start"
}
}
if(block_start === undefined) {
for(block_start = search_from; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(fencing_line(line)) {
break;
}
}
}
if(block_end === undefined) {
lineCount = cm.lineCount();
for(block_end = search_from; block_end < lineCount; block_end++) {
line = cm.getLineHandle(block_end);
if(fencing_line(line)) {
break;
}
}
}
cm.operation(function() {
cm.replaceRange("", {
line: block_start,
ch: 0
}, {
line: block_start + 1,
ch: 0
});
cm.replaceRange("", {
line: block_end - 1,
ch: 0
}, {
line: block_end,
ch: 0
});
});
cm.focus();
}
} else if(is_code === "indented") {
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
// use selection
block_start = cur_start.line;
block_end = cur_end.line;
if(cur_end.ch === 0) {
block_end--;
}
} else {
// no selection, search for ends of this indented block
for(block_start = cur_start.line; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(line.text.match(/^\s*$/)) {
// empty or all whitespace - keep going
continue;
} else {
if(code_type(cm, block_start, line) !== "indented") {
block_start += 1;
break;
}
}
}
lineCount = cm.lineCount();
for(block_end = cur_start.line; block_end < lineCount; block_end++) {
line = cm.getLineHandle(block_end);
if(line.text.match(/^\s*$/)) {
// empty or all whitespace - keep going
continue;
} else {
if(code_type(cm, block_end, line) !== "indented") {
block_end -= 1;
break;
}
}
}
}
// if we are going to un-indent based on a selected set of lines, and the next line is indented too, we need to
// insert a blank line so that the next line(s) continue to be indented code
var next_line = cm.getLineHandle(block_end + 1),
next_line_last_tok = next_line && cm.getTokenAt({
line: block_end + 1,
ch: next_line.text.length - 1
}),
next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
if(next_line_indented) {
cm.replaceRange("\n", {
line: block_end + 1,
ch: 0
});
}
for(var i = block_start; i <= block_end; i++) {
cm.indentLine(i, "subtract"); // TODO: this doesn't get tracked in the history, so can't be undone :(
}
cm.focus();
} else {
// insert code formatting
var no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0);
var sel_multi = cur_start.line !== cur_end.line;
if(no_sel_and_starting_of_line || sel_multi) {
insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert);
} else {
_replaceSelection(cm, false, ["`", "`"]);
}
}
} | javascript | function toggleCodeBlock(editor) {
var fenceCharsToInsert = editor.options.blockStyles.code;
function fencing_line(line) {
/* return true, if this is a ``` or ~~~ line */
if(typeof line !== "object") {
throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof line + ": " + line;
}
return line.styles && line.styles[2] && line.styles[2].indexOf("formatting-code-block") !== -1;
}
function token_state(token) {
// base goes an extra level deep when mode backdrops are used, e.g. spellchecker on
return token.state.base.base || token.state.base;
}
function code_type(cm, line_num, line, firstTok, lastTok) {
/*
* Return "single", "indented", "fenced" or false
*
* cm and line_num are required. Others are optional for efficiency
* To check in the middle of a line, pass in firstTok yourself.
*/
line = line || cm.getLineHandle(line_num);
firstTok = firstTok || cm.getTokenAt({
line: line_num,
ch: 1
});
lastTok = lastTok || (!!line.text && cm.getTokenAt({
line: line_num,
ch: line.text.length - 1
}));
var types = firstTok.type ? firstTok.type.split(" ") : [];
if(lastTok && token_state(lastTok).indentedCode) {
// have to check last char, since first chars of first line aren"t marked as indented
return "indented";
} else if(types.indexOf("comment") === -1) {
// has to be after "indented" check, since first chars of first indented line aren"t marked as such
return false;
} else if(token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)) {
return "fenced";
} else {
return "single";
}
}
function insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert) {
var start_line_sel = cur_start.line + 1,
end_line_sel = cur_end.line + 1,
sel_multi = cur_start.line !== cur_end.line,
repl_start = fenceCharsToInsert + "\n",
repl_end = "\n" + fenceCharsToInsert;
if(sel_multi) {
end_line_sel++;
}
// handle last char including \n or not
if(sel_multi && cur_end.ch === 0) {
repl_end = fenceCharsToInsert + "\n";
end_line_sel--;
}
_replaceSelection(cm, false, [repl_start, repl_end]);
cm.setSelection({
line: start_line_sel,
ch: 0
}, {
line: end_line_sel,
ch: 0
});
}
var cm = editor.codemirror,
cur_start = cm.getCursor("start"),
cur_end = cm.getCursor("end"),
tok = cm.getTokenAt({
line: cur_start.line,
ch: cur_start.ch || 1
}), // avoid ch 0 which is a cursor pos but not token
line = cm.getLineHandle(cur_start.line),
is_code = code_type(cm, cur_start.line, line, tok);
var block_start, block_end, lineCount;
if(is_code === "single") {
// similar to some SimpleMDE _toggleBlock logic
var start = line.text.slice(0, cur_start.ch).replace("`", ""),
end = line.text.slice(cur_start.ch).replace("`", "");
cm.replaceRange(start + end, {
line: cur_start.line,
ch: 0
}, {
line: cur_start.line,
ch: 99999999999999
});
cur_start.ch--;
if(cur_start !== cur_end) {
cur_end.ch--;
}
cm.setSelection(cur_start, cur_end);
cm.focus();
} else if(is_code === "fenced") {
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
// use selection
// find the fenced line so we know what type it is (tilde, backticks, number of them)
for(block_start = cur_start.line; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(fencing_line(line)) {
break;
}
}
var fencedTok = cm.getTokenAt({
line: block_start,
ch: 1
});
var fence_chars = token_state(fencedTok).fencedChars;
var start_text, start_line;
var end_text, end_line;
// check for selection going up against fenced lines, in which case we don't want to add more fencing
if(fencing_line(cm.getLineHandle(cur_start.line))) {
start_text = "";
start_line = cur_start.line;
} else if(fencing_line(cm.getLineHandle(cur_start.line - 1))) {
start_text = "";
start_line = cur_start.line - 1;
} else {
start_text = fence_chars + "\n";
start_line = cur_start.line;
}
if(fencing_line(cm.getLineHandle(cur_end.line))) {
end_text = "";
end_line = cur_end.line;
if(cur_end.ch === 0) {
end_line += 1;
}
} else if(cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))) {
end_text = "";
end_line = cur_end.line + 1;
} else {
end_text = fence_chars + "\n";
end_line = cur_end.line + 1;
}
if(cur_end.ch === 0) {
// full last line selected, putting cursor at beginning of next
end_line -= 1;
}
cm.operation(function() {
// end line first, so that line numbers don't change
cm.replaceRange(end_text, {
line: end_line,
ch: 0
}, {
line: end_line + (end_text ? 0 : 1),
ch: 0
});
cm.replaceRange(start_text, {
line: start_line,
ch: 0
}, {
line: start_line + (start_text ? 0 : 1),
ch: 0
});
});
cm.setSelection({
line: start_line + (start_text ? 1 : 0),
ch: 0
}, {
line: end_line + (start_text ? 1 : -1),
ch: 0
});
cm.focus();
} else {
// no selection, search for ends of this fenced block
var search_from = cur_start.line;
if(fencing_line(cm.getLineHandle(cur_start.line))) { // gets a little tricky if cursor is right on a fenced line
if(code_type(cm, cur_start.line + 1) === "fenced") {
block_start = cur_start.line;
search_from = cur_start.line + 1; // for searching for "end"
} else {
block_end = cur_start.line;
search_from = cur_start.line - 1; // for searching for "start"
}
}
if(block_start === undefined) {
for(block_start = search_from; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(fencing_line(line)) {
break;
}
}
}
if(block_end === undefined) {
lineCount = cm.lineCount();
for(block_end = search_from; block_end < lineCount; block_end++) {
line = cm.getLineHandle(block_end);
if(fencing_line(line)) {
break;
}
}
}
cm.operation(function() {
cm.replaceRange("", {
line: block_start,
ch: 0
}, {
line: block_start + 1,
ch: 0
});
cm.replaceRange("", {
line: block_end - 1,
ch: 0
}, {
line: block_end,
ch: 0
});
});
cm.focus();
}
} else if(is_code === "indented") {
if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
// use selection
block_start = cur_start.line;
block_end = cur_end.line;
if(cur_end.ch === 0) {
block_end--;
}
} else {
// no selection, search for ends of this indented block
for(block_start = cur_start.line; block_start >= 0; block_start--) {
line = cm.getLineHandle(block_start);
if(line.text.match(/^\s*$/)) {
// empty or all whitespace - keep going
continue;
} else {
if(code_type(cm, block_start, line) !== "indented") {
block_start += 1;
break;
}
}
}
lineCount = cm.lineCount();
for(block_end = cur_start.line; block_end < lineCount; block_end++) {
line = cm.getLineHandle(block_end);
if(line.text.match(/^\s*$/)) {
// empty or all whitespace - keep going
continue;
} else {
if(code_type(cm, block_end, line) !== "indented") {
block_end -= 1;
break;
}
}
}
}
// if we are going to un-indent based on a selected set of lines, and the next line is indented too, we need to
// insert a blank line so that the next line(s) continue to be indented code
var next_line = cm.getLineHandle(block_end + 1),
next_line_last_tok = next_line && cm.getTokenAt({
line: block_end + 1,
ch: next_line.text.length - 1
}),
next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
if(next_line_indented) {
cm.replaceRange("\n", {
line: block_end + 1,
ch: 0
});
}
for(var i = block_start; i <= block_end; i++) {
cm.indentLine(i, "subtract"); // TODO: this doesn't get tracked in the history, so can't be undone :(
}
cm.focus();
} else {
// insert code formatting
var no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0);
var sel_multi = cur_start.line !== cur_end.line;
if(no_sel_and_starting_of_line || sel_multi) {
insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert);
} else {
_replaceSelection(cm, false, ["`", "`"]);
}
}
} | [
"function",
"toggleCodeBlock",
"(",
"editor",
")",
"{",
"var",
"fenceCharsToInsert",
"=",
"editor",
".",
"options",
".",
"blockStyles",
".",
"code",
";",
"function",
"fencing_line",
"(",
"line",
")",
"{",
"/* return true, if this is a ``` or ~~~ line */",
"if",
"(",... | Action for toggling code block. | [
"Action",
"for",
"toggling",
"code",
"block",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L256-L537 | train | Toggle the code block | [
30522,
3853,
2000,
24679,
16044,
23467,
1006,
3559,
1007,
1063,
13075,
8638,
7507,
12096,
28765,
8043,
2102,
1027,
3559,
1012,
7047,
1012,
5991,
27983,
2015,
1012,
3642,
1025,
3853,
15962,
1035,
2240,
1006,
2240,
1007,
1063,
1013,
1008,
270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ProjectModel.js | _renameItem | function _renameItem(oldPath, newPath, newName, isFolder) {
var result = new $.Deferred();
if (oldPath === newPath) {
result.resolve();
} else if (!isValidFilename(newName)) {
result.reject(ERROR_INVALID_FILENAME);
} else {
var entry = isFolder ? FileSystem.getDirectoryForPath(oldPath) : FileSystem.getFileForPath(oldPath);
entry.rename(newPath, function (err) {
if (err) {
result.reject(err);
} else {
result.resolve();
}
});
}
return result.promise();
} | javascript | function _renameItem(oldPath, newPath, newName, isFolder) {
var result = new $.Deferred();
if (oldPath === newPath) {
result.resolve();
} else if (!isValidFilename(newName)) {
result.reject(ERROR_INVALID_FILENAME);
} else {
var entry = isFolder ? FileSystem.getDirectoryForPath(oldPath) : FileSystem.getFileForPath(oldPath);
entry.rename(newPath, function (err) {
if (err) {
result.reject(err);
} else {
result.resolve();
}
});
}
return result.promise();
} | [
"function",
"_renameItem",
"(",
"oldPath",
",",
"newPath",
",",
"newName",
",",
"isFolder",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"oldPath",
"===",
"newPath",
")",
"{",
"result",
".",
"resolve",
"(",
"... | Rename a file/folder. This will update the project tree data structures
and send notifications about the rename.
@param {string} oldPath Old name of the item with the path
@param {string} newPath New name of the item with the path
@param {string} newName New name of the item
@param {boolean} isFolder True if item is a folder; False if it is a file.
@return {$.Promise} A promise object that will be resolved or rejected when
the rename is finished. | [
"Rename",
"a",
"file",
"/",
"folder",
".",
"This",
"will",
"update",
"the",
"project",
"tree",
"data",
"structures",
"and",
"send",
"notifications",
"about",
"the",
"rename",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectModel.js#L920-L939 | train | rename an item | [
30522,
3853,
1035,
14916,
14074,
4221,
2213,
1006,
2214,
15069,
1010,
2047,
15069,
1010,
2047,
18442,
1010,
2003,
10371,
2121,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
30524,
10663,
1006,
1007,
1025,
1065,
2842,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | services/nuget/nuget-v3-service-family.js | createServiceFamily | function createServiceFamily({
defaultLabel,
serviceBaseUrl,
withTenant = true,
apiDomain,
apiBaseUrl,
withFeed = true,
}) {
class NugetVersionService extends BaseJsonService {
static get category() {
return 'version'
}
static get route() {
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
.push('(v|vpre)', 'which')
.push('(.*)', 'packageName')
.toObject()
}
static get examples() {
return []
}
static get defaultBadgeData() {
return {
label: defaultLabel,
}
}
static render(props) {
return renderVersionBadge(props)
}
async handle({ tenant, feed, which, packageName }) {
const baseUrl = apiUrl({
withTenant,
apiBaseUrl,
apiDomain,
tenant,
withFeed,
feed,
})
const { versions } = await fetch(this, { baseUrl, packageName })
let latest = versions.slice(-1).pop()
const includePrereleases = which === 'vpre'
if (!includePrereleases) {
const filtered = versions.filter(item => !item.version.includes('-'))
if (filtered.length) {
latest = filtered.slice(-1).pop()
}
}
const { version } = latest
return this.constructor.render({ version, feed })
}
}
class NugetDownloadService extends BaseJsonService {
static get category() {
return 'downloads'
}
static get route() {
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
.push('dt')
.push('(.*)', 'packageName')
.toObject()
}
static get examples() {
return []
}
static render(props) {
return renderDownloadBadge(props)
}
async handle({ tenant, feed, which, packageName }) {
const baseUrl = apiUrl({
withTenant,
apiBaseUrl,
apiDomain,
tenant,
withFeed,
feed,
})
const packageInfo = await fetch(this, { baseUrl, packageName })
// Official NuGet server uses "totalDownloads" whereas MyGet uses
// "totaldownloads" (lowercase D). Ugh.
const downloads =
packageInfo.totalDownloads || packageInfo.totaldownloads || 0
return this.constructor.render({ downloads })
}
}
return {
NugetVersionService,
NugetDownloadService,
}
} | javascript | function createServiceFamily({
defaultLabel,
serviceBaseUrl,
withTenant = true,
apiDomain,
apiBaseUrl,
withFeed = true,
}) {
class NugetVersionService extends BaseJsonService {
static get category() {
return 'version'
}
static get route() {
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
.push('(v|vpre)', 'which')
.push('(.*)', 'packageName')
.toObject()
}
static get examples() {
return []
}
static get defaultBadgeData() {
return {
label: defaultLabel,
}
}
static render(props) {
return renderVersionBadge(props)
}
async handle({ tenant, feed, which, packageName }) {
const baseUrl = apiUrl({
withTenant,
apiBaseUrl,
apiDomain,
tenant,
withFeed,
feed,
})
const { versions } = await fetch(this, { baseUrl, packageName })
let latest = versions.slice(-1).pop()
const includePrereleases = which === 'vpre'
if (!includePrereleases) {
const filtered = versions.filter(item => !item.version.includes('-'))
if (filtered.length) {
latest = filtered.slice(-1).pop()
}
}
const { version } = latest
return this.constructor.render({ version, feed })
}
}
class NugetDownloadService extends BaseJsonService {
static get category() {
return 'downloads'
}
static get route() {
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
.push('dt')
.push('(.*)', 'packageName')
.toObject()
}
static get examples() {
return []
}
static render(props) {
return renderDownloadBadge(props)
}
async handle({ tenant, feed, which, packageName }) {
const baseUrl = apiUrl({
withTenant,
apiBaseUrl,
apiDomain,
tenant,
withFeed,
feed,
})
const packageInfo = await fetch(this, { baseUrl, packageName })
// Official NuGet server uses "totalDownloads" whereas MyGet uses
// "totaldownloads" (lowercase D). Ugh.
const downloads =
packageInfo.totalDownloads || packageInfo.totaldownloads || 0
return this.constructor.render({ downloads })
}
}
return {
NugetVersionService,
NugetDownloadService,
}
} | [
"function",
"createServiceFamily",
"(",
"{",
"defaultLabel",
",",
"serviceBaseUrl",
",",
"withTenant",
"=",
"true",
",",
"apiDomain",
",",
"apiBaseUrl",
",",
"withFeed",
"=",
"true",
",",
"}",
")",
"{",
"class",
"NugetVersionService",
"extends",
"BaseJsonService",... | /*
Create a version and download service for a NuGet v2 API. Return an object
containing both services.
defaultLabel: The label for the left hand side of the badge.
serviceBaseUrl: The base URL for the Shields service, e.g. nuget
withTenant: When true, an optional `tenant` is extracted from the badge
URL, which represents the subdomain of the API. When no tenant is
provided, defaults to `www`.
apiDomain: When `withTenant` is true, this is the rest of the domain,
e.g. `myget.org`.
apiBaseUrl: When `withTenant` is false, this is the base URL of the API,
e.g. https://api.nuget.org/v3
withFeed: When true, the badge URL includes a required feed name, which is
added to the request API. | [
"/",
"*",
"Create",
"a",
"version",
"and",
"download",
"service",
"for",
"a",
"NuGet",
"v2",
"API",
".",
"Return",
"an",
"object",
"containing",
"both",
"services",
"."
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/nuget/nuget-v3-service-family.js#L143-L246 | train | Creates a service family | [
30522,
3853,
9005,
2121,
7903,
12879,
10631,
2135,
1006,
1063,
12398,
20470,
2884,
1010,
2326,
15058,
3126,
2140,
1010,
2007,
6528,
4630,
1027,
2995,
1010,
17928,
9527,
8113,
1010,
17928,
15058,
3126,
2140,
1010,
2007,
7959,
2098,
1027,
299... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/column-prop-getters.js | numericIndexGetter | function numericIndexGetter(row, index) {
if (row == null)
return '';
// mimic behavior of deepValueGetter
if (!row || index == null)
return row;
var value = row[index];
if (value == null)
return '';
return value;
} | javascript | function numericIndexGetter(row, index) {
if (row == null)
return '';
// mimic behavior of deepValueGetter
if (!row || index == null)
return row;
var value = row[index];
if (value == null)
return '';
return value;
} | [
"function",
"numericIndexGetter",
"(",
"row",
",",
"index",
")",
"{",
"if",
"(",
"row",
"==",
"null",
")",
"return",
"''",
";",
"// mimic behavior of deepValueGetter",
"if",
"(",
"!",
"row",
"||",
"index",
"==",
"null",
")",
"return",
"row",
";",
"var",
... | Returns the value at this numeric index.
@param row array of values
@param index numeric index
@returns {any} or '' if invalid index | [
"Returns",
"the",
"value",
"at",
"this",
"numeric",
"index",
"."
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-prop-getters.js#L39-L49 | train | This function is a helper function to get numeric values from a row | [
30522,
3853,
16371,
25531,
22254,
10288,
18150,
3334,
1006,
5216,
1010,
5950,
1007,
1063,
2065,
1006,
5216,
1027,
1027,
19701,
1007,
2709,
1005,
1005,
1025,
1013,
1013,
23150,
5248,
1997,
2784,
10175,
5657,
18150,
3334,
2065,
1006,
999,
521... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ramda/ramda | source/applySpec.js | mapValues | function mapValues(fn, obj) {
return keys(obj).reduce(function(acc, key) {
acc[key] = fn(obj[key]);
return acc;
}, {});
} | javascript | function mapValues(fn, obj) {
return keys(obj).reduce(function(acc, key) {
acc[key] = fn(obj[key]);
return acc;
}, {});
} | [
"function",
"mapValues",
"(",
"fn",
",",
"obj",
")",
"{",
"return",
"keys",
"(",
"obj",
")",
".",
"reduce",
"(",
"function",
"(",
"acc",
",",
"key",
")",
"{",
"acc",
"[",
"key",
"]",
"=",
"fn",
"(",
"obj",
"[",
"key",
"]",
")",
";",
"return",
... | Use custom mapValues function to avoid issues with specs that include a "map" key and R.map delegating calls to .map | [
"Use",
"custom",
"mapValues",
"function",
"to",
"avoid",
"issues",
"with",
"specs",
"that",
"include",
"a",
"map",
"key",
"and",
"R",
".",
"map",
"delegating",
"calls",
"to",
".",
"map"
] | 072d417a345e7087a95466a9825d43b6ca3a4941 | https://github.com/ramda/ramda/blob/072d417a345e7087a95466a9825d43b6ca3a4941/source/applySpec.js#L12-L17 | train | Map values from obj to fn | [
30522,
3853,
4949,
10175,
15808,
1006,
1042,
2078,
1010,
27885,
3501,
1007,
1063,
2709,
6309,
1006,
27885,
3501,
1007,
1012,
5547,
1006,
3853,
1006,
16222,
1010,
3145,
1007,
1063,
16222,
1031,
3145,
1033,
1027,
1042,
2078,
1006,
27885,
3501... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js | function(oEvent) {
var iLocationY = ExtensionHelper._getEventPosition(oEvent, this).y;
var iMin = this.$().offset().top;
if (iLocationY > iMin) {
this.$("ghost").css("top", iLocationY + "px");
}
} | javascript | function(oEvent) {
var iLocationY = ExtensionHelper._getEventPosition(oEvent, this).y;
var iMin = this.$().offset().top;
if (iLocationY > iMin) {
this.$("ghost").css("top", iLocationY + "px");
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"iLocationY",
"=",
"ExtensionHelper",
".",
"_getEventPosition",
"(",
"oEvent",
",",
"this",
")",
".",
"y",
";",
"var",
"iMin",
"=",
"this",
".",
"$",
"(",
")",
".",
"offset",
"(",
")",
".",
"top",
";",
"i... | /*
Handler for the move events while dragging the horizontal resize bar. | [
"/",
"*",
"Handler",
"for",
"the",
"move",
"events",
"while",
"dragging",
"the",
"horizontal",
"resize",
"bar",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L436-L442 | train | This method is called when the event is triggered by the container | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
6335,
23909,
2100,
1027,
5331,
16001,
4842,
1012,
1035,
2131,
18697,
3372,
26994,
1006,
1051,
18697,
3372,
1010,
2023,
1007,
1012,
1061,
1025,
13075,
10047,
2378,
1027,
2023,
1012,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/utils/fs.js | ensureFile | function ensureFile(filename) {
var base = path.dirname(filename);
return Promise.nfcall(mkdirp, base);
} | javascript | function ensureFile(filename) {
var base = path.dirname(filename);
return Promise.nfcall(mkdirp, base);
} | [
"function",
"ensureFile",
"(",
"filename",
")",
"{",
"var",
"base",
"=",
"path",
".",
"dirname",
"(",
"filename",
")",
";",
"return",
"Promise",
".",
"nfcall",
"(",
"mkdirp",
",",
"base",
")",
";",
"}"
] | Create all required folder to create a file | [
"Create",
"all",
"required",
"folder",
"to",
"create",
"a",
"file"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L88-L91 | train | Ensure the specified file exists. | [
30522,
3853,
5676,
8873,
2571,
1006,
5371,
18442,
1007,
1063,
13075,
2918,
1027,
4130,
1012,
16101,
18442,
1006,
5371,
18442,
1007,
1025,
2709,
4872,
1012,
22309,
8095,
1006,
12395,
4305,
14536,
1010,
2918,
1007,
1025,
1065,
102,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/templating/replaceShortcuts.js | replaceShortcuts | function replaceShortcuts(blocks, filePath, content) {
var shortcuts = listShortcuts(blocks, filePath);
return shortcuts.reduce(applyShortcut, content);
} | javascript | function replaceShortcuts(blocks, filePath, content) {
var shortcuts = listShortcuts(blocks, filePath);
return shortcuts.reduce(applyShortcut, content);
} | [
"function",
"replaceShortcuts",
"(",
"blocks",
",",
"filePath",
",",
"content",
")",
"{",
"var",
"shortcuts",
"=",
"listShortcuts",
"(",
"blocks",
",",
"filePath",
")",
";",
"return",
"shortcuts",
".",
"reduce",
"(",
"applyShortcut",
",",
"content",
")",
";"... | Replace shortcuts from blocks in a string
@param {List<TemplateBlock>} engine
@param {String} filePath
@param {String} content
@return {String} | [
"Replace",
"shortcuts",
"from",
"blocks",
"in",
"a",
"string"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/templating/replaceShortcuts.js#L34-L37 | train | Replace all shortcuts in the given content with the content of the file | [
30522,
3853,
20736,
27794,
12690,
2015,
1006,
5991,
1010,
5371,
15069,
1010,
4180,
1007,
1063,
13075,
2460,
12690,
2015,
1027,
7201,
27794,
12690,
2015,
1006,
5991,
1010,
5371,
15069,
1007,
1025,
2709,
2460,
12690,
2015,
1012,
5547,
1006,
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... |
jgraph/mxgraph | javascript/mxClient.js | mxTemporaryCellStates | function mxTemporaryCellStates(view, scale, cells, isCellVisibleFn, getLinkForCellState)
{
scale = (scale != null) ? scale : 1;
this.view = view;
// Stores the previous state
this.oldValidateCellState = view.validateCellState;
this.oldBounds = view.getGraphBounds();
this.oldStates = view.getStates();
this.oldScale = view.getScale();
this.oldDoRedrawShape = view.graph.cellRenderer.doRedrawShape;
var self = this;
// Overrides doRedrawShape and paint shape to add links on shapes
if (getLinkForCellState != null)
{
view.graph.cellRenderer.doRedrawShape = function(state)
{
var oldPaint = state.shape.paint;
state.shape.paint = function(c)
{
var link = getLinkForCellState(state);
if (link != null)
{
c.setLink(link);
}
oldPaint.apply(this, arguments);
if (link != null)
{
c.setLink(null);
}
};
self.oldDoRedrawShape.apply(view.graph.cellRenderer, arguments);
state.shape.paint = oldPaint;
};
}
// Overrides validateCellState to ignore invisible cells
view.validateCellState = function(cell, resurse)
{
if (cell == null || isCellVisibleFn == null || isCellVisibleFn(cell))
{
return self.oldValidateCellState.apply(view, arguments);
}
return null;
};
// Creates space for new states
view.setStates(new mxDictionary());
view.setScale(scale);
if (cells != null)
{
view.resetValidationState();
var bbox = null;
// Validates the vertices and edges without adding them to
// the model so that the original cells are not modified
for (var i = 0; i < cells.length; i++)
{
var bounds = view.getBoundingBox(view.validateCellState(view.validateCell(cells[i])));
if (bbox == null)
{
bbox = bounds;
}
else
{
bbox.add(bounds);
}
}
view.setGraphBounds(bbox || new mxRectangle());
}
} | javascript | function mxTemporaryCellStates(view, scale, cells, isCellVisibleFn, getLinkForCellState)
{
scale = (scale != null) ? scale : 1;
this.view = view;
// Stores the previous state
this.oldValidateCellState = view.validateCellState;
this.oldBounds = view.getGraphBounds();
this.oldStates = view.getStates();
this.oldScale = view.getScale();
this.oldDoRedrawShape = view.graph.cellRenderer.doRedrawShape;
var self = this;
// Overrides doRedrawShape and paint shape to add links on shapes
if (getLinkForCellState != null)
{
view.graph.cellRenderer.doRedrawShape = function(state)
{
var oldPaint = state.shape.paint;
state.shape.paint = function(c)
{
var link = getLinkForCellState(state);
if (link != null)
{
c.setLink(link);
}
oldPaint.apply(this, arguments);
if (link != null)
{
c.setLink(null);
}
};
self.oldDoRedrawShape.apply(view.graph.cellRenderer, arguments);
state.shape.paint = oldPaint;
};
}
// Overrides validateCellState to ignore invisible cells
view.validateCellState = function(cell, resurse)
{
if (cell == null || isCellVisibleFn == null || isCellVisibleFn(cell))
{
return self.oldValidateCellState.apply(view, arguments);
}
return null;
};
// Creates space for new states
view.setStates(new mxDictionary());
view.setScale(scale);
if (cells != null)
{
view.resetValidationState();
var bbox = null;
// Validates the vertices and edges without adding them to
// the model so that the original cells are not modified
for (var i = 0; i < cells.length; i++)
{
var bounds = view.getBoundingBox(view.validateCellState(view.validateCell(cells[i])));
if (bbox == null)
{
bbox = bounds;
}
else
{
bbox.add(bounds);
}
}
view.setGraphBounds(bbox || new mxRectangle());
}
} | [
"function",
"mxTemporaryCellStates",
"(",
"view",
",",
"scale",
",",
"cells",
",",
"isCellVisibleFn",
",",
"getLinkForCellState",
")",
"{",
"scale",
"=",
"(",
"scale",
"!=",
"null",
")",
"?",
"scale",
":",
"1",
";",
"this",
".",
"view",
"=",
"view",
";",... | Copyright (c) 2006-2017, JGraph Ltd
Copyright (c) 2006-2017, Gaudenz Alder
Class: mxTemporaryCellStates
Creates a temporary set of cell states. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2017",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2017",
"Gaudenz",
"Alder",
"Class",
":",
"mxTemporaryCellStates"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L69081-L69162 | train | Creates a temporary cell states | [
30522,
3853,
25630,
18532,
17822,
5649,
29109,
4877,
12259,
2015,
1006,
3193,
1010,
4094,
1010,
4442,
1010,
2003,
29109,
28530,
7028,
2546,
2078,
1010,
2131,
13767,
14821,
12718,
12259,
1007,
1063,
4094,
1027,
1006,
4094,
999,
1027,
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... |
SAP/openui5 | src/sap.uxap/src/sap/uxap/component/ObjectPageLayoutUXDrivenFactory.controller.js | function (sParentId, oBindingContext) {
var oControlInfo = oBindingContext.getProperty(""), oControl, oControlClass, oControlMetadata;
try {
//retrieve the block class
oControlClass = sap.ui.requireSync(oControlInfo.Type.replace(/\./g, "/"));
oControlMetadata = oControlClass.getMetadata();
//pre-processing: substitute event handler as strings by their function instance
jQueryDOM.each(oControlMetadata._mAllEvents, jQueryDOM.proxy(function (sEventName, oEventProperties) {
if (typeof oControlInfo[sEventName] == "string") {
oControlInfo[sEventName] = this.convertEventHandler(oControlInfo[sEventName]);
}
}, this));
//creates the control with control info = create with provided properties
oControl = ManagedObject.create(oControlInfo);
//post-processing: bind properties on the objectPageLayoutMetadata model
jQueryDOM.each(oControlMetadata._mAllProperties, jQueryDOM.proxy(function (sPropertyName, oProperty) {
if (oControlInfo[sPropertyName]) {
oControl.bindProperty(sPropertyName, "objectPageLayoutMetadata>" + oBindingContext.getPath() + "/" + sPropertyName);
}
}, this));
} catch (sError) {
Log.error("ObjectPageLayoutFactory :: error in control creation from config: " + sError);
}
return oControl;
} | javascript | function (sParentId, oBindingContext) {
var oControlInfo = oBindingContext.getProperty(""), oControl, oControlClass, oControlMetadata;
try {
//retrieve the block class
oControlClass = sap.ui.requireSync(oControlInfo.Type.replace(/\./g, "/"));
oControlMetadata = oControlClass.getMetadata();
//pre-processing: substitute event handler as strings by their function instance
jQueryDOM.each(oControlMetadata._mAllEvents, jQueryDOM.proxy(function (sEventName, oEventProperties) {
if (typeof oControlInfo[sEventName] == "string") {
oControlInfo[sEventName] = this.convertEventHandler(oControlInfo[sEventName]);
}
}, this));
//creates the control with control info = create with provided properties
oControl = ManagedObject.create(oControlInfo);
//post-processing: bind properties on the objectPageLayoutMetadata model
jQueryDOM.each(oControlMetadata._mAllProperties, jQueryDOM.proxy(function (sPropertyName, oProperty) {
if (oControlInfo[sPropertyName]) {
oControl.bindProperty(sPropertyName, "objectPageLayoutMetadata>" + oBindingContext.getPath() + "/" + sPropertyName);
}
}, this));
} catch (sError) {
Log.error("ObjectPageLayoutFactory :: error in control creation from config: " + sError);
}
return oControl;
} | [
"function",
"(",
"sParentId",
",",
"oBindingContext",
")",
"{",
"var",
"oControlInfo",
"=",
"oBindingContext",
".",
"getProperty",
"(",
"\"\"",
")",
",",
"oControl",
",",
"oControlClass",
",",
"oControlMetadata",
";",
"try",
"{",
"//retrieve the block class",
"oCo... | generates a control to be used in actions, blocks or moreBlocks aggregations
known issue: bindings are not applied, the control is built with data only
@param {string} sParentId the Id of the parent
@param {object} oBindingContext binding context
@returns {*} new control | [
"generates",
"a",
"control",
"to",
"be",
"used",
"in",
"actions",
"blocks",
"or",
"moreBlocks",
"aggregations",
"known",
"issue",
":",
"bindings",
"are",
"not",
"applied",
"the",
"control",
"is",
"built",
"with",
"data",
"only"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/ObjectPageLayoutUXDrivenFactory.controller.js#L76-L105 | train | Creates a new control instance | [
30522,
3853,
1006,
8622,
16778,
2094,
1010,
27885,
22254,
2075,
8663,
18209,
1007,
1063,
13075,
1051,
8663,
13181,
4115,
14876,
1027,
27885,
22254,
2075,
8663,
18209,
1012,
2131,
21572,
4842,
3723,
1006,
1000,
1000,
1007,
1010,
1051,
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... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/MessageBox.js | cell | function cell(oContent) {
return new MatrixLayoutCell({
padding: Padding.None,
vAlign: VAlign.Top,
content: oContent
});
} | javascript | function cell(oContent) {
return new MatrixLayoutCell({
padding: Padding.None,
vAlign: VAlign.Top,
content: oContent
});
} | [
"function",
"cell",
"(",
"oContent",
")",
"{",
"return",
"new",
"MatrixLayoutCell",
"(",
"{",
"padding",
":",
"Padding",
".",
"None",
",",
"vAlign",
":",
"VAlign",
".",
"Top",
",",
"content",
":",
"oContent",
"}",
")",
";",
"}"
] | wraps the given control in a top aligned MatrixLayoutCell with no padding | [
"wraps",
"the",
"given",
"control",
"in",
"a",
"top",
"aligned",
"MatrixLayoutCell",
"with",
"no",
"padding"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/MessageBox.js#L234-L240 | train | Creates a cell for a given content | [
30522,
3853,
3526,
1006,
1051,
8663,
6528,
2102,
1007,
1063,
2709,
2047,
8185,
8485,
5833,
29109,
2140,
1006,
1063,
11687,
4667,
1024,
11687,
4667,
1012,
3904,
1010,
11748,
23773,
1024,
11748,
23773,
1012,
2327,
1010,
4180,
1024,
1051,
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... |
hinesboy/mavonEditor | src/lib/core/extra-function.js | judgeItalicAndBold | function judgeItalicAndBold(prefix, subfix, tmpStr, startPos, endPos) {
if (prefix === '*' && subfix === '*') {
if (tmpStr.substring(startPos - 2, startPos - 1) === '*' && tmpStr.substring(endPos + 1, endPos + 2) === '*') {
return false
}
}
return true
} | javascript | function judgeItalicAndBold(prefix, subfix, tmpStr, startPos, endPos) {
if (prefix === '*' && subfix === '*') {
if (tmpStr.substring(startPos - 2, startPos - 1) === '*' && tmpStr.substring(endPos + 1, endPos + 2) === '*') {
return false
}
}
return true
} | [
"function",
"judgeItalicAndBold",
"(",
"prefix",
",",
"subfix",
",",
"tmpStr",
",",
"startPos",
",",
"endPos",
")",
"{",
"if",
"(",
"prefix",
"===",
"'*'",
"&&",
"subfix",
"===",
"'*'",
")",
"{",
"if",
"(",
"tmpStr",
".",
"substring",
"(",
"startPos",
... | 处理粗体与斜体冲突问题 | [
"处理粗体与斜体冲突问题"
] | 7ef3db471d80c40c4e1d7a9e7ddb8400f3e4ab60 | https://github.com/hinesboy/mavonEditor/blob/7ef3db471d80c40c4e1d7a9e7ddb8400f3e4ab60/src/lib/core/extra-function.js#L52-L59 | train | Judge if it s italic and bold | [
30522,
3853,
3648,
18400,
5555,
4859,
27495,
1006,
17576,
1010,
4942,
8873,
2595,
1010,
1056,
25370,
16344,
1010,
2707,
6873,
2015,
1010,
2203,
6873,
2015,
1007,
1063,
2065,
1006,
17576,
1027,
1027,
1027,
1005,
1008,
1005,
1004,
1004,
4942,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.commons/src/sap/ui/commons/Toolbar.js | getLeftItemsWithVisibilityTrue | function getLeftItemsWithVisibilityTrue() {
var aItems = [];
this.getItems().forEach(function (item) {
if (item instanceof sap.ui.commons.ToolbarSeparator || item.getVisible()) {
aItems.push(item);
}
});
return aItems;
} | javascript | function getLeftItemsWithVisibilityTrue() {
var aItems = [];
this.getItems().forEach(function (item) {
if (item instanceof sap.ui.commons.ToolbarSeparator || item.getVisible()) {
aItems.push(item);
}
});
return aItems;
} | [
"function",
"getLeftItemsWithVisibilityTrue",
"(",
")",
"{",
"var",
"aItems",
"=",
"[",
"]",
";",
"this",
".",
"getItems",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"item",
"instanceof",
"sap",
".",
"ui",
".",
"common... | **************************************************************** Private functions ****************************************************************
Returns all items with API property visibility = true, including toolbar separator(s)
@returns {Array} all items with API property visibility = true, including toolbar separator(s)
@private | [
"****************************************************************",
"Private",
"functions",
"****************************************************************",
"Returns",
"all",
"items",
"with",
"API",
"property",
"visibility",
"=",
"true",
"including",
"toolbar",
"separator",
"(",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/Toolbar.js#L1000-L1008 | train | Returns an array of items with visibility true | [
30522,
3853,
2131,
2571,
6199,
4221,
5244,
24415,
11365,
13464,
16344,
5657,
1006,
1007,
1063,
13075,
9932,
18532,
2015,
1027,
1031,
1033,
1025,
2023,
1012,
2131,
4221,
5244,
1006,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
8875,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | mxCoordinateAssignment | function mxCoordinateAssignment(layout, intraCellSpacing, interRankCellSpacing,
orientation, initialX, parallelEdgeSpacing)
{
this.layout = layout;
this.intraCellSpacing = intraCellSpacing;
this.interRankCellSpacing = interRankCellSpacing;
this.orientation = orientation;
this.initialX = initialX;
this.parallelEdgeSpacing = parallelEdgeSpacing;
} | javascript | function mxCoordinateAssignment(layout, intraCellSpacing, interRankCellSpacing,
orientation, initialX, parallelEdgeSpacing)
{
this.layout = layout;
this.intraCellSpacing = intraCellSpacing;
this.interRankCellSpacing = interRankCellSpacing;
this.orientation = orientation;
this.initialX = initialX;
this.parallelEdgeSpacing = parallelEdgeSpacing;
} | [
"function",
"mxCoordinateAssignment",
"(",
"layout",
",",
"intraCellSpacing",
",",
"interRankCellSpacing",
",",
"orientation",
",",
"initialX",
",",
"parallelEdgeSpacing",
")",
"{",
"this",
".",
"layout",
"=",
"layout",
";",
"this",
".",
"intraCellSpacing",
"=",
"... | Copyright (c) 2006-2018, JGraph Ltd
Copyright (c) 2006-2018, Gaudenz Alder
Class: mxCoordinateAssignment
Sets the horizontal locations of node and edge dummy nodes on each layer.
Uses median down and up weighings as well as heuristics to straighten edges as
far as possible.
Constructor: mxCoordinateAssignment
Creates a coordinate assignment.
Arguments:
intraCellSpacing - the minimum buffer between cells on the same rank
interRankCellSpacing - the minimum distance between cells on adjacent ranks
orientation - the position of the root node(s) relative to the graph
initialX - the leftmost coordinate node placement starts at | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2018",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2018",
"Gaudenz",
"Alder",
"Class",
":",
"mxCoordinateAssignment"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L35661-L35670 | train | This function is used to assign a coordinate to a cell | [
30522,
3853,
25630,
3597,
8551,
14776,
12054,
24838,
1006,
9621,
1010,
26721,
29109,
4877,
19498,
2075,
1010,
6970,
26763,
29109,
4877,
19498,
2075,
1010,
10296,
1010,
3988,
2595,
1010,
5903,
24225,
13102,
26217,
1007,
1063,
2023,
1012,
9621,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TopicDetailInitial.controller.js | function () {
jQuery0.ajax(this.getConfig().docuPath + "disclaimer.json", {dataType: "json"}).then(function (oData) {
var oView = this.getView();
if (oData.showDisclaimer && oData.message) {
oView.byId("disclaimerBlock").setVisible(true);
oView.byId("disclaimerMessage").setText(oData.message);
}
}.bind(this), function () {
// This functionality should fail silently
});
} | javascript | function () {
jQuery0.ajax(this.getConfig().docuPath + "disclaimer.json", {dataType: "json"}).then(function (oData) {
var oView = this.getView();
if (oData.showDisclaimer && oData.message) {
oView.byId("disclaimerBlock").setVisible(true);
oView.byId("disclaimerMessage").setText(oData.message);
}
}.bind(this), function () {
// This functionality should fail silently
});
} | [
"function",
"(",
")",
"{",
"jQuery0",
".",
"ajax",
"(",
"this",
".",
"getConfig",
"(",
")",
".",
"docuPath",
"+",
"\"disclaimer.json\"",
",",
"{",
"dataType",
":",
"\"json\"",
"}",
")",
".",
"then",
"(",
"function",
"(",
"oData",
")",
"{",
"var",
"oV... | Documentation disclaimer handler. This method fetches the disclaimer json file and modify's the view
to show disclaimer message if such is available in the loaded json file. | [
"Documentation",
"disclaimer",
"handler",
".",
"This",
"method",
"fetches",
"the",
"disclaimer",
"json",
"file",
"and",
"modify",
"s",
"the",
"view",
"to",
"show",
"disclaimer",
"message",
"if",
"such",
"is",
"available",
"in",
"the",
"loaded",
"json",
"file",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/TopicDetailInitial.controller.js#L34-L44 | train | Show disclaimer message | [
30522,
3853,
1006,
1007,
1063,
1046,
4226,
2854,
2692,
1012,
18176,
1006,
2023,
1012,
2131,
8663,
8873,
2290,
1006,
1007,
1012,
9986,
6279,
8988,
1009,
1000,
5860,
19771,
5017,
1012,
1046,
3385,
1000,
1010,
1063,
2951,
13874,
1024,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js | CubicBezier | function CubicBezier(coordinates) {
if (typeof coordinates === "string") {
this.coordinates = coordinates.split(",");
} else {
this.coordinates = coordinates;
}
if (!this.coordinates) {
throw "No offsets were defined";
}
this.coordinates = this.coordinates.map(function (n) { return +n; });
var i;
for (i = 3; i >= 0; i--) {
var xy = this.coordinates[i];
if (isNaN(xy) || (((i % 2) === 0) && (xy < 0 || xy > 1))) {
throw "Wrong coordinate at " + i + "(" + xy + ")";
}
}
} | javascript | function CubicBezier(coordinates) {
if (typeof coordinates === "string") {
this.coordinates = coordinates.split(",");
} else {
this.coordinates = coordinates;
}
if (!this.coordinates) {
throw "No offsets were defined";
}
this.coordinates = this.coordinates.map(function (n) { return +n; });
var i;
for (i = 3; i >= 0; i--) {
var xy = this.coordinates[i];
if (isNaN(xy) || (((i % 2) === 0) && (xy < 0 || xy > 1))) {
throw "Wrong coordinate at " + i + "(" + xy + ")";
}
}
} | [
"function",
"CubicBezier",
"(",
"coordinates",
")",
"{",
"if",
"(",
"typeof",
"coordinates",
"===",
"\"string\"",
")",
"{",
"this",
".",
"coordinates",
"=",
"coordinates",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"else",
"{",
"this",
".",
"coordinates",
... | CubicBezier object constructor
@param {string|Array.number[4]} coordinates Four parameters passes to cubic-bezier()
either in string or array format. | [
"CubicBezier",
"object",
"constructor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js#L50-L70 | train | CubicBezier constructor. | [
30522,
3853,
11919,
4783,
21548,
1006,
12093,
1007,
1063,
2065,
1006,
2828,
11253,
12093,
1027,
1027,
1027,
1000,
5164,
1000,
1007,
1063,
2023,
1012,
12093,
1027,
12093,
1012,
3975,
1006,
1000,
1010,
1000,
1007,
1025,
1065,
2842,
1063,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/prefer-const.js | hasMemberExpressionAssignment | function hasMemberExpressionAssignment(node) {
switch (node.type) {
case "ObjectPattern":
return node.properties.some(prop => {
if (prop) {
/*
* Spread elements have an argument property while
* others have a value property. Because different
* parsers use different node types for spread elements,
* we just check if there is an argument property.
*/
return hasMemberExpressionAssignment(prop.argument || prop.value);
}
return false;
});
case "ArrayPattern":
return node.elements.some(element => {
if (element) {
return hasMemberExpressionAssignment(element);
}
return false;
});
case "AssignmentPattern":
return hasMemberExpressionAssignment(node.left);
case "MemberExpression":
return true;
// no default
}
return false;
} | javascript | function hasMemberExpressionAssignment(node) {
switch (node.type) {
case "ObjectPattern":
return node.properties.some(prop => {
if (prop) {
/*
* Spread elements have an argument property while
* others have a value property. Because different
* parsers use different node types for spread elements,
* we just check if there is an argument property.
*/
return hasMemberExpressionAssignment(prop.argument || prop.value);
}
return false;
});
case "ArrayPattern":
return node.elements.some(element => {
if (element) {
return hasMemberExpressionAssignment(element);
}
return false;
});
case "AssignmentPattern":
return hasMemberExpressionAssignment(node.left);
case "MemberExpression":
return true;
// no default
}
return false;
} | [
"function",
"hasMemberExpressionAssignment",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"ObjectPattern\"",
":",
"return",
"node",
".",
"properties",
".",
"some",
"(",
"prop",
"=>",
"{",
"if",
"(",
"prop",
")",
"{",
"/*... | Determines if a destructuring assignment node contains
any MemberExpression nodes. This is used to determine if a
variable that is only written once using destructuring can be
safely converted into a const declaration.
@param {ASTNode} node The ObjectPattern or ArrayPattern node to check.
@returns {boolean} True if the destructuring pattern contains
a MemberExpression, false if not. | [
"Determines",
"if",
"a",
"destructuring",
"assignment",
"node",
"contains",
"any",
"MemberExpression",
"nodes",
".",
"This",
"is",
"used",
"to",
"determine",
"if",
"a",
"variable",
"that",
"is",
"only",
"written",
"once",
"using",
"destructuring",
"can",
"be",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-const.js#L109-L146 | train | Check if a node has an assignment to a member expression | [
30522,
3853,
2038,
4168,
21784,
10288,
20110,
3258,
12054,
24838,
1006,
13045,
1007,
1063,
6942,
1006,
13045,
1012,
2828,
1007,
1063,
2553,
1000,
4874,
4502,
12079,
2078,
1000,
1024,
2709,
13045,
1012,
5144,
1012,
2070,
1006,
17678,
1027,
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... |
sass/node-sass | lib/index.js | getStyle | function getStyle(options) {
var styles = {
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
return styles[options.outputStyle] || 0;
} | javascript | function getStyle(options) {
var styles = {
nested: 0,
expanded: 1,
compact: 2,
compressed: 3
};
return styles[options.outputStyle] || 0;
} | [
"function",
"getStyle",
"(",
"options",
")",
"{",
"var",
"styles",
"=",
"{",
"nested",
":",
"0",
",",
"expanded",
":",
"1",
",",
"compact",
":",
"2",
",",
"compressed",
":",
"3",
"}",
";",
"return",
"styles",
"[",
"options",
".",
"outputStyle",
"]",
... | Get style
@param {Object} options
@api private | [
"Get",
"style"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L99-L108 | train | Get the style of the output | [
30522,
3853,
4152,
27983,
1006,
7047,
1007,
1063,
13075,
6782,
1027,
1063,
9089,
2098,
1024,
1014,
1010,
4423,
1024,
1015,
1010,
9233,
1024,
1016,
1010,
16620,
1024,
1017,
1065,
1025,
2709,
6782,
1031,
7047,
1012,
27852,
27983,
1033,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/max-nested-callbacks.js | checkFunction | function checkFunction(node) {
const parent = node.parent;
if (parent.type === "CallExpression") {
callbackStack.push(node);
}
if (callbackStack.length > THRESHOLD) {
const opts = { num: callbackStack.length, max: THRESHOLD };
context.report({ node, messageId: "exceed", data: opts });
}
} | javascript | function checkFunction(node) {
const parent = node.parent;
if (parent.type === "CallExpression") {
callbackStack.push(node);
}
if (callbackStack.length > THRESHOLD) {
const opts = { num: callbackStack.length, max: THRESHOLD };
context.report({ node, messageId: "exceed", data: opts });
}
} | [
"function",
"checkFunction",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"if",
"(",
"parent",
".",
"type",
"===",
"\"CallExpression\"",
")",
"{",
"callbackStack",
".",
"push",
"(",
"node",
")",
";",
"}",
"if",
"(",
"callb... | Checks a given function node for too many callbacks.
@param {ASTNode} node The node to check.
@returns {void}
@private | [
"Checks",
"a",
"given",
"function",
"node",
"for",
"too",
"many",
"callbacks",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-nested-callbacks.js#L81-L93 | train | Check if a function is a call | [
30522,
3853,
4638,
11263,
27989,
1006,
13045,
1007,
1063,
9530,
3367,
6687,
1027,
13045,
1012,
6687,
1025,
2065,
1006,
6687,
1012,
2828,
1027,
1027,
1027,
1000,
2655,
10288,
20110,
3258,
1000,
1007,
1063,
2655,
12221,
2696,
3600,
1012,
5245... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebaseui-web | javascript/utils/acclient.js | function(resp, opt_error) {
if (resp && resp['account'] && opt_onAccountSelected) {
opt_onAccountSelected(
firebaseui.auth.Account.fromPlainObject(resp['account']));
} else if (opt_onAddAccount) {
// Check if accountchooser.com is available and pass to add account.
var isUnavailable = firebaseui.auth.acClient.isUnavailable_(opt_error);
// Either an error happened or user clicked the add account button.
opt_onAddAccount(!isUnavailable);
}
} | javascript | function(resp, opt_error) {
if (resp && resp['account'] && opt_onAccountSelected) {
opt_onAccountSelected(
firebaseui.auth.Account.fromPlainObject(resp['account']));
} else if (opt_onAddAccount) {
// Check if accountchooser.com is available and pass to add account.
var isUnavailable = firebaseui.auth.acClient.isUnavailable_(opt_error);
// Either an error happened or user clicked the add account button.
opt_onAddAccount(!isUnavailable);
}
} | [
"function",
"(",
"resp",
",",
"opt_error",
")",
"{",
"if",
"(",
"resp",
"&&",
"resp",
"[",
"'account'",
"]",
"&&",
"opt_onAccountSelected",
")",
"{",
"opt_onAccountSelected",
"(",
"firebaseui",
".",
"auth",
".",
"Account",
".",
"fromPlainObject",
"(",
"resp"... | Save the add account callback for later use. | [
"Save",
"the",
"add",
"account",
"callback",
"for",
"later",
"use",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/javascript/utils/acclient.js#L86-L96 | train | Handle accountchooser. com response. | [
30522,
3853,
1006,
24501,
2361,
1010,
23569,
1035,
7561,
1007,
1063,
2065,
1006,
24501,
2361,
1004,
1004,
24501,
2361,
1031,
1005,
4070,
1005,
1033,
1004,
1004,
23569,
1035,
2006,
6305,
3597,
16671,
11246,
22471,
2098,
1007,
1063,
23569,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js | function () {
var tempRules = Storage.getRules(),
loadingFromAdditionalRuleSets = this.model.getProperty("/loadingAdditionalRuleSets");
if (tempRules && !loadingFromAdditionalRuleSets && !this.tempRulesLoaded) {
this.tempRulesFromStorage = tempRules;
this.tempRulesLoaded = true;
tempRules.forEach(function (tempRule) {
CommunicationBus.publish(channelNames.VERIFY_CREATE_RULE, RuleSerializer.serialize(tempRule));
});
this.persistedTempRulesCount = tempRules.length;
}
} | javascript | function () {
var tempRules = Storage.getRules(),
loadingFromAdditionalRuleSets = this.model.getProperty("/loadingAdditionalRuleSets");
if (tempRules && !loadingFromAdditionalRuleSets && !this.tempRulesLoaded) {
this.tempRulesFromStorage = tempRules;
this.tempRulesLoaded = true;
tempRules.forEach(function (tempRule) {
CommunicationBus.publish(channelNames.VERIFY_CREATE_RULE, RuleSerializer.serialize(tempRule));
});
this.persistedTempRulesCount = tempRules.length;
}
} | [
"function",
"(",
")",
"{",
"var",
"tempRules",
"=",
"Storage",
".",
"getRules",
"(",
")",
",",
"loadingFromAdditionalRuleSets",
"=",
"this",
".",
"model",
".",
"getProperty",
"(",
"\"/loadingAdditionalRuleSets\"",
")",
";",
"if",
"(",
"tempRules",
"&&",
"!",
... | Loads temporary rules from the local storage | [
"Loads",
"temporary",
"rules",
"from",
"the",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L725-L739 | train | This function is called when the model is loaded | [
30522,
3853,
1006,
1007,
1063,
13075,
8915,
8737,
6820,
4244,
1027,
5527,
1012,
2131,
6820,
4244,
1006,
1007,
1010,
10578,
19699,
9626,
14141,
22753,
2389,
6820,
24527,
3215,
1027,
2023,
1012,
2944,
1012,
2131,
21572,
4842,
3723,
1006,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/config/config-validator.js | formatErrors | function formatErrors(errors) {
return errors.map(error => {
if (error.keyword === "additionalProperties") {
const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
return `Unexpected top-level property "${formattedPropertyPath}"`;
}
if (error.keyword === "type") {
const formattedField = error.dataPath.slice(1);
const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
const formattedValue = JSON.stringify(error.data);
return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
}
const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
}).map(message => `\t- ${message}.\n`).join("");
} | javascript | function formatErrors(errors) {
return errors.map(error => {
if (error.keyword === "additionalProperties") {
const formattedPropertyPath = error.dataPath.length ? `${error.dataPath.slice(1)}.${error.params.additionalProperty}` : error.params.additionalProperty;
return `Unexpected top-level property "${formattedPropertyPath}"`;
}
if (error.keyword === "type") {
const formattedField = error.dataPath.slice(1);
const formattedExpectedType = Array.isArray(error.schema) ? error.schema.join("/") : error.schema;
const formattedValue = JSON.stringify(error.data);
return `Property "${formattedField}" is the wrong type (expected ${formattedExpectedType} but got \`${formattedValue}\`)`;
}
const field = error.dataPath[0] === "." ? error.dataPath.slice(1) : error.dataPath;
return `"${field}" ${error.message}. Value: ${JSON.stringify(error.data)}`;
}).map(message => `\t- ${message}.\n`).join("");
} | [
"function",
"formatErrors",
"(",
"errors",
")",
"{",
"return",
"errors",
".",
"map",
"(",
"error",
"=>",
"{",
"if",
"(",
"error",
".",
"keyword",
"===",
"\"additionalProperties\"",
")",
"{",
"const",
"formattedPropertyPath",
"=",
"error",
".",
"dataPath",
".... | Formats an array of schema validation errors.
@param {Array} errors An array of error messages to format.
@returns {string} Formatted error message | [
"Formats",
"an",
"array",
"of",
"schema",
"validation",
"errors",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L207-L226 | train | Format an array of errors | [
30522,
3853,
4289,
2121,
29165,
2015,
1006,
10697,
1007,
1063,
2709,
10697,
1012,
4949,
1006,
7561,
1027,
1028,
1063,
2065,
1006,
7561,
1012,
3145,
18351,
1027,
1027,
1027,
1000,
3176,
21572,
4842,
7368,
1000,
1007,
1063,
9530,
3367,
30524,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/Painter.js | function (opts) {
opts = opts || {};
if (this._singleCanvas && !this._compositeManually) {
return this._layers[CANVAS_ZLEVEL].dom;
}
var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
imageLayer.initContext();
imageLayer.clear(false, opts.backgroundColor || this._backgroundColor);
if (opts.pixelRatio <= this.dpr) {
this.refresh();
var width = imageLayer.dom.width;
var height = imageLayer.dom.height;
var ctx = imageLayer.ctx;
this.eachLayer(function (layer) {
if (layer.__builtin__) {
ctx.drawImage(layer.dom, 0, 0, width, height);
}
else if (layer.renderToCanvas) {
imageLayer.ctx.save();
layer.renderToCanvas(imageLayer.ctx);
imageLayer.ctx.restore();
}
});
}
else {
// PENDING, echarts-gl and incremental rendering.
var scope = {};
var displayList = this.storage.getDisplayList(true);
for (var i = 0; i < displayList.length; i++) {
var el = displayList[i];
this._doPaintEl(el, imageLayer, true, scope);
}
}
return imageLayer.dom;
} | javascript | function (opts) {
opts = opts || {};
if (this._singleCanvas && !this._compositeManually) {
return this._layers[CANVAS_ZLEVEL].dom;
}
var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
imageLayer.initContext();
imageLayer.clear(false, opts.backgroundColor || this._backgroundColor);
if (opts.pixelRatio <= this.dpr) {
this.refresh();
var width = imageLayer.dom.width;
var height = imageLayer.dom.height;
var ctx = imageLayer.ctx;
this.eachLayer(function (layer) {
if (layer.__builtin__) {
ctx.drawImage(layer.dom, 0, 0, width, height);
}
else if (layer.renderToCanvas) {
imageLayer.ctx.save();
layer.renderToCanvas(imageLayer.ctx);
imageLayer.ctx.restore();
}
});
}
else {
// PENDING, echarts-gl and incremental rendering.
var scope = {};
var displayList = this.storage.getDisplayList(true);
for (var i = 0; i < displayList.length; i++) {
var el = displayList[i];
this._doPaintEl(el, imageLayer, true, scope);
}
}
return imageLayer.dom;
} | [
"function",
"(",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"if",
"(",
"this",
".",
"_singleCanvas",
"&&",
"!",
"this",
".",
"_compositeManually",
")",
"{",
"return",
"this",
".",
"_layers",
"[",
"CANVAS_ZLEVEL",
"]",
".",
"dom",
";"... | Get canvas which has all thing rendered
@param {Object} opts
@param {string} [opts.backgroundColor]
@param {number} [opts.pixelRatio] | [
"Get",
"canvas",
"which",
"has",
"all",
"thing",
"rendered"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/Painter.js#L913-L951 | train | Creates an image layer | [
30522,
3853,
1006,
23569,
2015,
1007,
1063,
23569,
2015,
1027,
23569,
2015,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
2023,
1012,
1035,
2309,
9336,
12044,
1004,
1004,
999,
2023,
1012,
1035,
12490,
2386,
28488,
1007,
1063,
2709,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_open | function addonsManager_open(aSpec) {
var spec = aSpec || { };
var type = (spec.type == undefined) ? "menu" : spec.type;
var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor;
switch (type) {
case "menu":
var menuItem = new elementslib.Elem(this._controller.
menus["tools-menu"].menu_openAddons);
this._controller.click(menuItem);
break;
case "shortcut":
var cmdKey = utils.getEntity(this.dtds, "addons.commandkey");
this._controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " +
event.type);
}
return waitFor ? this.waitForOpened() : null;
} | javascript | function addonsManager_open(aSpec) {
var spec = aSpec || { };
var type = (spec.type == undefined) ? "menu" : spec.type;
var waitFor = (spec.waitFor == undefined) ? true : spec.waitFor;
switch (type) {
case "menu":
var menuItem = new elementslib.Elem(this._controller.
menus["tools-menu"].menu_openAddons);
this._controller.click(menuItem);
break;
case "shortcut":
var cmdKey = utils.getEntity(this.dtds, "addons.commandkey");
this._controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
default:
throw new Error(arguments.callee.name + ": Unknown event type - " +
event.type);
}
return waitFor ? this.waitForOpened() : null;
} | [
"function",
"addonsManager_open",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"type",
"=",
"(",
"spec",
".",
"type",
"==",
"undefined",
")",
"?",
"\"menu\"",
":",
"spec",
".",
"type",
";",
"var",
"waitFor",
"=",
... | Open the Add-ons Manager
@param {object} aSpec
Information how to open the Add-ons Manager
Elements: type - Event, can be menu, or shortcut
[optional - default: menu]
waitFor - Wait until the Add-ons Manager has been opened
[optional - default: true]
@returns Reference the tab with the Add-ons Manager open
@type {object}
Elements: controller - Mozmill Controller of the window
index - Index of the tab | [
"Open",
"the",
"Add",
"-",
"ons",
"Manager"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L131-L152 | train | Open the addons manager | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2330,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
2828,
1027,
1006,
28699,
1012,
2828,
1027,
1027,
6151,
28344,
1007,
1029,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/syncXHRFix.js | wrapTimerHandler | function wrapTimerHandler(vHandler) {
var fnWrappedHandler = function() {
var aArgs, fnHandler;
if (bPromisesQueued) {
aArgs = [fnWrappedHandler, 0].concat(arguments);
_timeout.apply(window, aArgs);
} else {
fnHandler = typeof vHandler !== "function" ? new Function(vHandler) : vHandler; // eslint-disable-line no-new-func
fnHandler.apply(window, arguments);
}
};
return fnWrappedHandler;
} | javascript | function wrapTimerHandler(vHandler) {
var fnWrappedHandler = function() {
var aArgs, fnHandler;
if (bPromisesQueued) {
aArgs = [fnWrappedHandler, 0].concat(arguments);
_timeout.apply(window, aArgs);
} else {
fnHandler = typeof vHandler !== "function" ? new Function(vHandler) : vHandler; // eslint-disable-line no-new-func
fnHandler.apply(window, arguments);
}
};
return fnWrappedHandler;
} | [
"function",
"wrapTimerHandler",
"(",
"vHandler",
")",
"{",
"var",
"fnWrappedHandler",
"=",
"function",
"(",
")",
"{",
"var",
"aArgs",
",",
"fnHandler",
";",
"if",
"(",
"bPromisesQueued",
")",
"{",
"aArgs",
"=",
"[",
"fnWrappedHandler",
",",
"0",
"]",
".",
... | If there are promise handlers waiting for execution at the time the timeout fires, start another timeout to postpone timer execution after promise execution. | [
"If",
"there",
"are",
"promise",
"handlers",
"waiting",
"for",
"execution",
"at",
"the",
"time",
"the",
"timeout",
"fires",
"start",
"another",
"timeout",
"to",
"postpone",
"timer",
"execution",
"after",
"promise",
"execution",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/syncXHRFix.js#L94-L106 | train | wrap timer handler | [
30522,
3853,
10236,
7292,
25032,
5685,
3917,
1006,
1058,
11774,
3917,
1007,
1063,
13075,
1042,
2078,
13088,
29098,
2098,
11774,
3917,
1027,
3853,
1006,
1007,
1063,
13075,
9779,
10623,
2015,
1010,
1042,
25311,
5685,
3917,
1025,
2065,
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... |
LLK/scratch-blocks | blocks_vertical/looks.js | function() {
this.jsonInit({
"message0": Blockly.Msg.LOOKS_GOTOFRONTBACK,
"args0": [
{
"type": "field_dropdown",
"name": "FRONT_BACK",
"options": [
[Blockly.Msg.LOOKS_GOTOFRONTBACK_FRONT, 'front'],
[Blockly.Msg.LOOKS_GOTOFRONTBACK_BACK, 'back']
]
}
],
"category": Blockly.Categories.looks,
"extensions": ["colours_looks", "shape_statement"]
});
} | javascript | function() {
this.jsonInit({
"message0": Blockly.Msg.LOOKS_GOTOFRONTBACK,
"args0": [
{
"type": "field_dropdown",
"name": "FRONT_BACK",
"options": [
[Blockly.Msg.LOOKS_GOTOFRONTBACK_FRONT, 'front'],
[Blockly.Msg.LOOKS_GOTOFRONTBACK_BACK, 'back']
]
}
],
"category": Blockly.Categories.looks,
"extensions": ["colours_looks", "shape_statement"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"Blockly",
".",
"Msg",
".",
"LOOKS_GOTOFRONTBACK",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"FRONT_BACK\"",
",",
"\"opti... | "Go to front/back" Block.
@this Blockly.Block | [
"Go",
"to",
"front",
"/",
"back",
"Block",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L460-L476 | train | Block for the goth of front back. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
3796,
2135,
1012,
5796,
2290,
1012,
3504,
1035,
30524,
1031,
3796,
2135,
1012,
5796,
2290,
1012,
3504,
1035,
2288,
11253,
4948,
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... | |
aws/aws-sdk-js | lib/service.js | attemptFailEvent | function attemptFailEvent(request) {
var monitoringEvent = this.apiAttemptEvent(request);
var response = request.response;
var error = response.error;
if (response.httpResponse.statusCode > 299 ) {
if (error.code) monitoringEvent.AwsException = error.code;
if (error.message) monitoringEvent.AwsExceptionMessage = error.message;
} else {
if (error.code || error.name) monitoringEvent.SdkException = error.code || error.name;
if (error.message) monitoringEvent.SdkExceptionMessage = error.message;
}
return monitoringEvent;
} | javascript | function attemptFailEvent(request) {
var monitoringEvent = this.apiAttemptEvent(request);
var response = request.response;
var error = response.error;
if (response.httpResponse.statusCode > 299 ) {
if (error.code) monitoringEvent.AwsException = error.code;
if (error.message) monitoringEvent.AwsExceptionMessage = error.message;
} else {
if (error.code || error.name) monitoringEvent.SdkException = error.code || error.name;
if (error.message) monitoringEvent.SdkExceptionMessage = error.message;
}
return monitoringEvent;
} | [
"function",
"attemptFailEvent",
"(",
"request",
")",
"{",
"var",
"monitoringEvent",
"=",
"this",
".",
"apiAttemptEvent",
"(",
"request",
")",
";",
"var",
"response",
"=",
"request",
".",
"response",
";",
"var",
"error",
"=",
"response",
".",
"error",
";",
... | Add metrics of failed request.
@api private | [
"Add",
"metrics",
"of",
"failed",
"request",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L367-L379 | train | Attempt to send an error to the service | [
30522,
3853,
3535,
7011,
9463,
15338,
1006,
5227,
1007,
1063,
13075,
8822,
18697,
3372,
1027,
2023,
1012,
17928,
19321,
6633,
13876,
18697,
3372,
1006,
5227,
1007,
1025,
13075,
3433,
1027,
5227,
1012,
3433,
1025,
13075,
7561,
1027,
3433,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/HyphenationSupport.js | diffTexts | function diffTexts(mTextsMain, mTextsToDiff) {
var aDiffs = [];
Object.keys(mTextsMain).forEach(function(sKey) {
if (!(sKey in mTextsToDiff && mTextsMain[sKey] === mTextsToDiff[sKey])) {
aDiffs.push(sKey);
}
});
return aDiffs;
} | javascript | function diffTexts(mTextsMain, mTextsToDiff) {
var aDiffs = [];
Object.keys(mTextsMain).forEach(function(sKey) {
if (!(sKey in mTextsToDiff && mTextsMain[sKey] === mTextsToDiff[sKey])) {
aDiffs.push(sKey);
}
});
return aDiffs;
} | [
"function",
"diffTexts",
"(",
"mTextsMain",
",",
"mTextsToDiff",
")",
"{",
"var",
"aDiffs",
"=",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"mTextsMain",
")",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"if",
"(",
"!",
"(",
"sKey",
"in",
... | Checks which keys are not present in mTextsToDiff or their values are different
@param {map} mTextsMain The map of texts to compare
@param {map} mTextsToDiff The map of texts to compare against
@returns {Array} An array containing all keys for which there is difference
@private | [
"Checks",
"which",
"keys",
"are",
"not",
"present",
"in",
"mTextsToDiff",
"or",
"their",
"values",
"are",
"different"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/HyphenationSupport.js#L89-L97 | train | diff text objects | [
30522,
3853,
4487,
4246,
18209,
2015,
1006,
11047,
10288,
3215,
24238,
1010,
11047,
10288,
3215,
3406,
4305,
4246,
1007,
1063,
13075,
27133,
21807,
1027,
1031,
1033,
1025,
4874,
1012,
6309,
1006,
11047,
10288,
3215,
24238,
1007,
1012,
18921,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | _draft/music/webuploader.js | function( block ) {
var me = this,
file = block.file,
promise;
me.pool.push( block );
me.remaning++;
// 如果没有分片,则直接使用原始的。
// 不会丢失content-type信息。
block.blob = block.chunks === 1 ? file.source :
file.source.slice( block.start, block.end );
// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
me._doSend( block );
} else {
me._popBlock( block );
Base.nextTick( me.__tick );
}
});
// 如果为fail了,则跳过此分片。
promise.fail(function() {
if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
me._popBlock( block );
me.owner.trigger( 'uploadComplete', file );
Base.nextTick( me.__tick );
});
} else {
block.percentage = 1;
me._popBlock( block );
Base.nextTick( me.__tick );
}
});
} | javascript | function( block ) {
var me = this,
file = block.file,
promise;
me.pool.push( block );
me.remaning++;
// 如果没有分片,则直接使用原始的。
// 不会丢失content-type信息。
block.blob = block.chunks === 1 ? file.source :
file.source.slice( block.start, block.end );
// hook, 每个分片发送之前可能要做些异步的事情。
promise = me.request( 'before-send', block, function() {
// 有可能文件已经上传出错了,所以不需要再传输了。
if ( file.getStatus() === Status.PROGRESS ) {
me._doSend( block );
} else {
me._popBlock( block );
Base.nextTick( me.__tick );
}
});
// 如果为fail了,则跳过此分片。
promise.fail(function() {
if ( file.remaning === 1 ) {
me._finishFile( file ).always(function() {
block.percentage = 1;
me._popBlock( block );
me.owner.trigger( 'uploadComplete', file );
Base.nextTick( me.__tick );
});
} else {
block.percentage = 1;
me._popBlock( block );
Base.nextTick( me.__tick );
}
});
} | [
"function",
"(",
"block",
")",
"{",
"var",
"me",
"=",
"this",
",",
"file",
"=",
"block",
".",
"file",
",",
"promise",
";",
"me",
".",
"pool",
".",
"push",
"(",
"block",
")",
";",
"me",
".",
"remaning",
"++",
";",
"// 如果没有分片,则直接使用原始的。",
"// 不会丢失conten... | 开始上传,可以被掉过。如果promise被reject了,则表示跳过此分片。 | [
"开始上传,可以被掉过。如果promise被reject了,则表示跳过此分片。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/_draft/music/webuploader.js#L5007-L5047 | train | send a file to the server | [
30522,
3853,
1006,
3796,
1007,
1063,
13075,
2033,
1027,
2023,
1010,
5371,
1027,
3796,
1012,
5371,
1010,
4872,
1025,
2033,
1012,
4770,
1012,
5245,
1006,
3796,
1007,
1025,
2033,
1012,
2128,
20799,
3070,
1009,
1009,
1025,
1013,
1013,
100,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/CSSUtils.js | extractAllNamedFlows | function extractAllNamedFlows(text) {
var namedFlowRegEx = /(?:flow\-(into|from)\:\s*)([\w\-]+)(?:\s*;)/gi,
result = [],
names = {},
thisMatch;
// Reduce the content so that matches
// inside strings and comments are ignored
text = reduceStyleSheetForRegExParsing(text);
// Find the first match
thisMatch = namedFlowRegEx.exec(text);
// Iterate over the matches and add them to result
while (thisMatch) {
var thisName = thisMatch[2];
if (IGNORED_FLOW_NAMES.indexOf(thisName) === -1 && !names.hasOwnProperty(thisName)) {
names[thisName] = result.push(thisName);
}
thisMatch = namedFlowRegEx.exec(text);
}
return result;
} | javascript | function extractAllNamedFlows(text) {
var namedFlowRegEx = /(?:flow\-(into|from)\:\s*)([\w\-]+)(?:\s*;)/gi,
result = [],
names = {},
thisMatch;
// Reduce the content so that matches
// inside strings and comments are ignored
text = reduceStyleSheetForRegExParsing(text);
// Find the first match
thisMatch = namedFlowRegEx.exec(text);
// Iterate over the matches and add them to result
while (thisMatch) {
var thisName = thisMatch[2];
if (IGNORED_FLOW_NAMES.indexOf(thisName) === -1 && !names.hasOwnProperty(thisName)) {
names[thisName] = result.push(thisName);
}
thisMatch = namedFlowRegEx.exec(text);
}
return result;
} | [
"function",
"extractAllNamedFlows",
"(",
"text",
")",
"{",
"var",
"namedFlowRegEx",
"=",
"/",
"(?:flow\\-(into|from)\\:\\s*)([\\w\\-]+)(?:\\s*;)",
"/",
"gi",
",",
"result",
"=",
"[",
"]",
",",
"names",
"=",
"{",
"}",
",",
"thisMatch",
";",
"// Reduce the content s... | Extracts all named flow instances
@param {!string} text to extract from
@return {Array.<string>} array of unique flow names found in the content (empty if none) | [
"Extracts",
"all",
"named",
"flow",
"instances"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1729-L1753 | train | Extract all named flows from a text | [
30522,
3853,
14817,
8095,
18442,
20952,
8261,
2015,
1006,
3793,
1007,
1063,
13075,
2315,
12314,
2890,
3351,
2595,
1027,
1013,
1006,
1029,
1024,
4834,
1032,
1011,
1006,
2046,
1064,
2013,
1007,
1032,
1024,
1032,
1055,
1008,
1007,
1006,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/core/util.js | function (cb, context) {
context !== void 0 && (cb = bind(cb, context));
for (var key in this.data) {
this.data.hasOwnProperty(key) && cb(this.data[key], key);
}
} | javascript | function (cb, context) {
context !== void 0 && (cb = bind(cb, context));
for (var key in this.data) {
this.data.hasOwnProperty(key) && cb(this.data[key], key);
}
} | [
"function",
"(",
"cb",
",",
"context",
")",
"{",
"context",
"!==",
"void",
"0",
"&&",
"(",
"cb",
"=",
"bind",
"(",
"cb",
",",
"context",
")",
")",
";",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"data",
")",
"{",
"this",
".",
"data",
".",
"... | Although util.each can be performed on this hashMap directly, user should not use the exposed keys, who are prefixed. | [
"Although",
"util",
".",
"each",
"can",
"be",
"performed",
"on",
"this",
"hashMap",
"directly",
"user",
"should",
"not",
"use",
"the",
"exposed",
"keys",
"who",
"are",
"prefixed",
"."
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/core/util.js#L642-L647 | train | Returns the current language code | [
30522,
3853,
1006,
17324,
1010,
6123,
1007,
1063,
6123,
999,
1027,
1027,
11675,
1014,
1004,
1004,
1006,
17324,
1027,
14187,
1006,
17324,
1010,
6123,
1007,
1007,
1025,
2005,
1006,
13075,
3145,
1999,
2023,
1012,
2951,
1007,
1063,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
transloadit/uppy | packages/@uppy/companion/src/server/controllers/s3.js | completeMultipartUpload | function completeMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
const { parts } = req.body
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!Array.isArray(parts) || !parts.every(isValidPart)) {
return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' })
}
client.completeMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
MultipartUpload: {
Parts: parts
}
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
location: data.Location
})
})
} | javascript | function completeMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
const { parts } = req.body
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!Array.isArray(parts) || !parts.every(isValidPart)) {
return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' })
}
client.completeMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
MultipartUpload: {
Parts: parts
}
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
location: data.Location
})
})
} | [
"function",
"completeMultipartUpload",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// @ts-ignore The `uppy` property is added by middleware before reaching here.",
"const",
"client",
"=",
"req",
".",
"uppy",
".",
"s3Client",
"const",
"{",
"uploadId",
"}",
"=",
"re... | Complete a multipart upload, combining all the parts into a single object in the S3 bucket.
Expected URL parameters:
- uploadId - The uploadId returned from `createMultipartUpload`.
Expected query parameters:
- key - The object key in the S3 bucket.
Expected JSON body:
- parts - An array of parts, see the `getUploadedParts` response JSON.
Response JSON:
- location - The full URL to the object in the S3 bucket. | [
"Complete",
"a",
"multipart",
"upload",
"combining",
"all",
"the",
"parts",
"into",
"a",
"single",
"object",
"in",
"the",
"S3",
"bucket",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L239-L269 | train | Complete a multipart upload | [
30522,
3853,
3143,
12274,
7096,
11514,
8445,
6279,
11066,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
1030,
24529,
1011,
8568,
1996,
1036,
2039,
7685,
1036,
3200,
2003,
2794,
2011,
2690,
8059,
2077,
4285,
2182,
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... |
GitbookIO/gitbook | lib/plugins/locateRootFolder.js | locateRootFolder | function locateRootFolder() {
var firstDefaultPlugin = DEFAULT_PLUGINS.first();
var pluginPath = resolve.sync(firstDefaultPlugin.getNpmID() + '/package.json', {
basedir: __dirname
});
var nodeModules = path.resolve(pluginPath, '../../..');
return nodeModules;
} | javascript | function locateRootFolder() {
var firstDefaultPlugin = DEFAULT_PLUGINS.first();
var pluginPath = resolve.sync(firstDefaultPlugin.getNpmID() + '/package.json', {
basedir: __dirname
});
var nodeModules = path.resolve(pluginPath, '../../..');
return nodeModules;
} | [
"function",
"locateRootFolder",
"(",
")",
"{",
"var",
"firstDefaultPlugin",
"=",
"DEFAULT_PLUGINS",
".",
"first",
"(",
")",
";",
"var",
"pluginPath",
"=",
"resolve",
".",
"sync",
"(",
"firstDefaultPlugin",
".",
"getNpmID",
"(",
")",
"+",
"'/package.json'",
","... | Resolve the root folder containing for node_modules
since gitbook can be used as a library and dependency can be flattened.
@return {String} folderPath | [
"Resolve",
"the",
"root",
"folder",
"containing",
"for",
"node_modules",
"since",
"gitbook",
"can",
"be",
"used",
"as",
"a",
"library",
"and",
"dependency",
"can",
"be",
"flattened",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/locateRootFolder.js#L12-L20 | train | Locates the root folder of the node_modules folder | [
30522,
3853,
12453,
3217,
4140,
10371,
2121,
1006,
1007,
1063,
13075,
2034,
3207,
7011,
11314,
24759,
15916,
2378,
1027,
12398,
1035,
13354,
7076,
1012,
2034,
1006,
1007,
1025,
13075,
13354,
2378,
15069,
1027,
10663,
1012,
26351,
1006,
2034,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(id) {
var self = this;
if (self._endTimers[id]) {
// Clear the timeout or remove the ended listener.
if (typeof self._endTimers[id] !== 'function') {
clearTimeout(self._endTimers[id]);
} else {
var sound = self._soundById(id);
if (sound && sound._node) {
sound._node.removeEventListener('ended', self._endTimers[id], false);
}
}
delete self._endTimers[id];
}
return self;
} | javascript | function(id) {
var self = this;
if (self._endTimers[id]) {
// Clear the timeout or remove the ended listener.
if (typeof self._endTimers[id] !== 'function') {
clearTimeout(self._endTimers[id]);
} else {
var sound = self._soundById(id);
if (sound && sound._node) {
sound._node.removeEventListener('ended', self._endTimers[id], false);
}
}
delete self._endTimers[id];
}
return self;
} | [
"function",
"(",
"id",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"_endTimers",
"[",
"id",
"]",
")",
"{",
"// Clear the timeout or remove the ended listener.",
"if",
"(",
"typeof",
"self",
".",
"_endTimers",
"[",
"id",
"]",
"!==",
... | Clear the end timer for a sound playback.
@param {Number} id The sound ID.
@return {Howl} | [
"Clear",
"the",
"end",
"timer",
"for",
"a",
"sound",
"playback",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1967-L1985 | train | Removes a timeout or a listener for a specific sound | [
30522,
3853,
1006,
8909,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
2969,
1012,
1035,
2203,
7292,
2869,
1031,
8909,
1033,
1007,
1063,
1013,
1013,
3154,
1996,
2051,
5833,
2030,
6366,
1996,
3092,
19373,
1012,
2065,
1006,
2828,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aws/aws-sdk-js | features/extra/helpers.js | function(size) {
var match;
var buffer;
if (match = size.match(/(\d+)KB/)) {
buffer = new Buffer(parseInt(match[1]) * 1024);
} else if (match = size.match(/(\d+)MB/)) {
buffer = new Buffer(parseInt(match[1]) * 1024 * 1024);
} else {
switch (size) {
case 'empty': buffer = new Buffer(0); break;
case 'small': buffer = new Buffer(1024 * 1024); break;
case 'large': buffer = new Buffer(1024 * 1024 * 20); break;
default: return new Buffer(1024 * 1024);
}
}
buffer.fill('x');
return buffer;
} | javascript | function(size) {
var match;
var buffer;
if (match = size.match(/(\d+)KB/)) {
buffer = new Buffer(parseInt(match[1]) * 1024);
} else if (match = size.match(/(\d+)MB/)) {
buffer = new Buffer(parseInt(match[1]) * 1024 * 1024);
} else {
switch (size) {
case 'empty': buffer = new Buffer(0); break;
case 'small': buffer = new Buffer(1024 * 1024); break;
case 'large': buffer = new Buffer(1024 * 1024 * 20); break;
default: return new Buffer(1024 * 1024);
}
}
buffer.fill('x');
return buffer;
} | [
"function",
"(",
"size",
")",
"{",
"var",
"match",
";",
"var",
"buffer",
";",
"if",
"(",
"match",
"=",
"size",
".",
"match",
"(",
"/",
"(\\d+)KB",
"/",
")",
")",
"{",
"buffer",
"=",
"new",
"Buffer",
"(",
"parseInt",
"(",
"match",
"[",
"1",
"]",
... | Creates and returns a buffer of given size | [
"Creates",
"and",
"returns",
"a",
"buffer",
"of",
"given",
"size"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/helpers.js#L167-L184 | train | Returns a buffer of the specified size | [
30522,
3853,
1006,
2946,
1007,
1063,
13075,
2674,
1025,
13075,
17698,
1025,
2065,
1006,
2674,
1027,
2946,
1012,
2674,
1006,
1013,
1006,
1032,
1040,
1009,
1007,
21677,
1013,
1007,
1007,
1063,
17698,
1027,
2047,
17698,
1006,
11968,
20240,
337... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableAccRenderExtension.js | function(oRm, oTable, oCreationRow) {
if (!oTable._getAccExtension().getAccMode()) {
return;
}
_writeAccText(oRm, oCreationRow.getId(), "label", TableUtils.getResourceText("TBL_CREATEROW_LABEL"));
} | javascript | function(oRm, oTable, oCreationRow) {
if (!oTable._getAccExtension().getAccMode()) {
return;
}
_writeAccText(oRm, oCreationRow.getId(), "label", TableUtils.getResourceText("TBL_CREATEROW_LABEL"));
} | [
"function",
"(",
"oRm",
",",
"oTable",
",",
"oCreationRow",
")",
"{",
"if",
"(",
"!",
"oTable",
".",
"_getAccExtension",
"(",
")",
".",
"getAccMode",
"(",
")",
")",
"{",
"return",
";",
"}",
"_writeAccText",
"(",
"oRm",
",",
"oCreationRow",
".",
"getId"... | Renders the hidden label for a creation row.
@param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the Render-Output-Buffer.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {sap.ui.table.CreationRow} oCreationRow Instance of the creation row.
@see sap.ui.table.CreationRowRenderer#render
@public | [
"Renders",
"the",
"hidden",
"label",
"for",
"a",
"creation",
"row",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccRenderExtension.js#L223-L229 | train | Writes the label of the creation row. | [
30522,
3853,
1006,
2030,
2213,
1010,
27178,
3085,
1010,
1051,
16748,
3370,
10524,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1012,
1035,
2131,
6305,
3401,
18413,
6132,
3258,
1006,
1007,
1012,
2131,
6305,
27487,
10244,
1006,
1007,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ColorlibHQ/AdminLTE | bower_components/jvectormap/lib/world-map.js | function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
} | javascript | function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
} | [
"function",
"(",
"markers",
",",
"seriesData",
")",
"{",
"var",
"i",
";",
"seriesData",
"=",
"seriesData",
"||",
"[",
"]",
";",
"this",
".",
"createMarkers",
"(",
"markers",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"seriesData",
".",
"le... | Add set of marker to the map.
@param {Object|Array} markers Markers to add to the map. In case of array is provided, codes of markers will be set as string representations of array indexes.
@param {Array} seriesData Values to add to the data series. | [
"Add",
"set",
"of",
"marker",
"to",
"the",
"map",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L777-L786 | train | set markers and series data | [
30522,
3853,
1006,
16387,
1010,
2186,
2850,
2696,
1007,
1063,
13075,
1045,
1025,
2186,
2850,
2696,
1027,
2186,
2850,
2696,
1064,
1064,
1031,
1033,
1025,
2023,
1012,
3443,
10665,
2545,
1006,
16387,
1007,
1025,
2005,
1006,
1045,
1027,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
facebook/relay | packages/relay-compiler/core/isEquivalentType.js | isEquivalentType | function isEquivalentType(typeA: GraphQLType, typeB: GraphQLType): boolean {
// Easy short-circuit: equal types are equal.
if (typeA === typeB) {
return true;
}
// If either type is non-null, the other must also be non-null.
if (typeA instanceof GraphQLNonNull && typeB instanceof GraphQLNonNull) {
return isEquivalentType(typeA.ofType, typeB.ofType);
}
// If either type is a list, the other must also be a list.
if (typeA instanceof GraphQLList && typeB instanceof GraphQLList) {
return isEquivalentType(typeA.ofType, typeB.ofType);
}
// Make sure the two types are of the same class
if (typeA.constructor.name === typeB.constructor.name) {
const rawA = getRawType(typeA);
const rawB = getRawType(typeB);
// And they must have the exact same name
return rawA.name === rawB.name;
}
// Otherwise the types are not equal.
return false;
} | javascript | function isEquivalentType(typeA: GraphQLType, typeB: GraphQLType): boolean {
// Easy short-circuit: equal types are equal.
if (typeA === typeB) {
return true;
}
// If either type is non-null, the other must also be non-null.
if (typeA instanceof GraphQLNonNull && typeB instanceof GraphQLNonNull) {
return isEquivalentType(typeA.ofType, typeB.ofType);
}
// If either type is a list, the other must also be a list.
if (typeA instanceof GraphQLList && typeB instanceof GraphQLList) {
return isEquivalentType(typeA.ofType, typeB.ofType);
}
// Make sure the two types are of the same class
if (typeA.constructor.name === typeB.constructor.name) {
const rawA = getRawType(typeA);
const rawB = getRawType(typeB);
// And they must have the exact same name
return rawA.name === rawB.name;
}
// Otherwise the types are not equal.
return false;
} | [
"function",
"isEquivalentType",
"(",
"typeA",
":",
"GraphQLType",
",",
"typeB",
":",
"GraphQLType",
")",
":",
"boolean",
"{",
"// Easy short-circuit: equal types are equal.",
"if",
"(",
"typeA",
"===",
"typeB",
")",
"{",
"return",
"true",
";",
"}",
"// If either t... | Determine if a type is the same type (same name and class) as another type.
Needed if we're comparing IRs created at different times: we don't yet have
an IR schema, so the type we assign to an IR field could be !== than
what we assign to it after adding some schema definitions or extensions. | [
"Determine",
"if",
"a",
"type",
"is",
"the",
"same",
"type",
"(",
"same",
"name",
"and",
"class",
")",
"as",
"another",
"type",
".",
"Needed",
"if",
"we",
"re",
"comparing",
"IRs",
"created",
"at",
"different",
"times",
":",
"we",
"don",
"t",
"yet",
... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/isEquivalentType.js#L24-L51 | train | Returns true if the two types are equivalent. | [
30522,
3853,
2003,
2063,
15549,
24879,
13874,
1006,
2828,
2050,
1024,
10629,
4160,
24228,
5051,
1010,
2828,
2497,
1024,
10629,
4160,
24228,
5051,
1007,
1024,
22017,
20898,
1063,
1013,
1013,
3733,
2460,
1011,
4984,
1024,
5020,
4127,
2024,
50... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeView.js | function () {
var fullname = this.props.name;
var node = this.refs.name;
node.setSelectionRange(0, fullname.length);
node.focus(); // set focus on the rename input
ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true);
} | javascript | function () {
var fullname = this.props.name;
var node = this.refs.name;
node.setSelectionRange(0, fullname.length);
node.focus(); // set focus on the rename input
ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true);
} | [
"function",
"(",
")",
"{",
"var",
"fullname",
"=",
"this",
".",
"props",
".",
"name",
";",
"var",
"node",
"=",
"this",
".",
"refs",
".",
"name",
";",
"node",
".",
"setSelectionRange",
"(",
"0",
",",
"fullname",
".",
"length",
")",
";",
"node",
".",... | When this component is displayed, we scroll it into view and select the folder name. | [
"When",
"this",
"component",
"is",
"displayed",
"we",
"scroll",
"it",
"into",
"view",
"and",
"select",
"the",
"folder",
"name",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L717-L724 | train | renames the file | [
30522,
3853,
1006,
1007,
1063,
13075,
2440,
18442,
1027,
2023,
1012,
24387,
1012,
2171,
1025,
13075,
13045,
1027,
2023,
1012,
25416,
2015,
1012,
2171,
1025,
13045,
1012,
4520,
12260,
7542,
24388,
2063,
1006,
1014,
1010,
2440,
18442,
1012,
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... | |
angular/angular | aio/tools/transforms/angular-base-package/processors/generateKeywords.js | tokenize | function tokenize(text) {
const rawTokens = text.split(/[\s\/]+/mg);
const tokens = [];
rawTokens.forEach(token => {
// Strip off unwanted trivial characters
token = token
.trim()
.replace(/^[_\-"'`({[<$*)}\]>.]+/, '')
.replace(/[_\-"'`({[<$*)}\]>.]+$/, '');
// Ignore tokens that contain weird characters
if (/^[\w.\-]+$/.test(token)) {
tokens.push(token.toLowerCase());
const ngTokenMatch = /^[nN]g([A-Z]\w*)/.exec(token);
if (ngTokenMatch) {
tokens.push(ngTokenMatch[1].toLowerCase());
}
}
});
return tokens;
} | javascript | function tokenize(text) {
const rawTokens = text.split(/[\s\/]+/mg);
const tokens = [];
rawTokens.forEach(token => {
// Strip off unwanted trivial characters
token = token
.trim()
.replace(/^[_\-"'`({[<$*)}\]>.]+/, '')
.replace(/[_\-"'`({[<$*)}\]>.]+$/, '');
// Ignore tokens that contain weird characters
if (/^[\w.\-]+$/.test(token)) {
tokens.push(token.toLowerCase());
const ngTokenMatch = /^[nN]g([A-Z]\w*)/.exec(token);
if (ngTokenMatch) {
tokens.push(ngTokenMatch[1].toLowerCase());
}
}
});
return tokens;
} | [
"function",
"tokenize",
"(",
"text",
")",
"{",
"const",
"rawTokens",
"=",
"text",
".",
"split",
"(",
"/",
"[\\s\\/]+",
"/",
"mg",
")",
";",
"const",
"tokens",
"=",
"[",
"]",
";",
"rawTokens",
".",
"forEach",
"(",
"token",
"=>",
"{",
"// Strip off unwan... | If the heading contains a name starting with ng, e.g. "ngController", then add the name without the ng to the text, e.g. "controller". | [
"If",
"the",
"heading",
"contains",
"a",
"name",
"starting",
"with",
"ng",
"e",
".",
"g",
".",
"ngController",
"then",
"add",
"the",
"name",
"without",
"the",
"ng",
"to",
"the",
"text",
"e",
".",
"g",
".",
"controller",
"."
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/aio/tools/transforms/angular-base-package/processors/generateKeywords.js#L135-L154 | train | Split text into tokens | [
30522,
3853,
19204,
4697,
1006,
3793,
1007,
1063,
9530,
3367,
6315,
18715,
6132,
1027,
3793,
1012,
3975,
1006,
1013,
1031,
1032,
1055,
1032,
1013,
1033,
1009,
1013,
11460,
1007,
1025,
9530,
3367,
19204,
2015,
1027,
1031,
1033,
1025,
6315,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/delegate/ScrollEnablement.js | function(oIconTabBar, fnScrollEndCallback, fnScrollStartCallback) {
this._oIconTabBar = oIconTabBar;
this._fnScrollEndCallback = jQuery.proxy(fnScrollEndCallback, oIconTabBar);
this._fnScrollStartCallback = jQuery.proxy(fnScrollStartCallback, oIconTabBar);
return this;
} | javascript | function(oIconTabBar, fnScrollEndCallback, fnScrollStartCallback) {
this._oIconTabBar = oIconTabBar;
this._fnScrollEndCallback = jQuery.proxy(fnScrollEndCallback, oIconTabBar);
this._fnScrollStartCallback = jQuery.proxy(fnScrollStartCallback, oIconTabBar);
return this;
} | [
"function",
"(",
"oIconTabBar",
",",
"fnScrollEndCallback",
",",
"fnScrollStartCallback",
")",
"{",
"this",
".",
"_oIconTabBar",
"=",
"oIconTabBar",
";",
"this",
".",
"_fnScrollEndCallback",
"=",
"jQuery",
".",
"proxy",
"(",
"fnScrollEndCallback",
",",
"oIconTabBar"... | Sets IconTabBar control to scroll container
@param {sap.m.IconTabBar} oIconTabBar instance
@param {function} fnScrollEndCallback callback function for the scroll end event
@param {function} fnScrollStartCallback callback function for the scroll start event
@protected
@since 1.16.1 | [
"Sets",
"IconTabBar",
"control",
"to",
"scroll",
"container"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/delegate/ScrollEnablement.js#L174-L179 | train | Sets the IconTabBar instance and sets the scroll end and start callbacks | [
30522,
3853,
1006,
1051,
28524,
2696,
22414,
2099,
1010,
1042,
3619,
26775,
14511,
10497,
9289,
20850,
8684,
1010,
1042,
3619,
26775,
14511,
14117,
13535,
8095,
5963,
1007,
1063,
2023,
1012,
1035,
1051,
28524,
2696,
22414,
2099,
1027,
1051,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | src/ol/format/KML.js | writePlacemark | function writePlacemark(node, feature, objectStack) {
const /** @type {import("../xml.js").NodeStackItem} */ context = {node: node};
// set id
if (feature.getId()) {
node.setAttribute('id', /** @type {string} */ (feature.getId()));
}
// serialize properties (properties unknown to KML are not serialized)
const properties = feature.getProperties();
// don't export these to ExtendedData
const filter = {'address': 1, 'description': 1, 'name': 1, 'open': 1,
'phoneNumber': 1, 'styleUrl': 1, 'visibility': 1};
filter[feature.getGeometryName()] = 1;
const keys = Object.keys(properties || {}).sort().filter(function(v) {
return !filter[v];
});
if (keys.length > 0) {
const sequence = makeSequence(properties, keys);
const namesAndValues = {names: keys, values: sequence};
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
EXTENDEDDATA_NODE_FACTORY, [namesAndValues], objectStack);
}
const styleFunction = feature.getStyleFunction();
if (styleFunction) {
// FIXME the styles returned by the style function are supposed to be
// resolution-independent here
const styles = styleFunction(feature, 0);
if (styles) {
const style = Array.isArray(styles) ? styles[0] : styles;
if (this.writeStyles_) {
properties['Style'] = style;
}
const textStyle = style.getText();
if (textStyle) {
properties['name'] = textStyle.getText();
}
}
}
const parentNode = objectStack[objectStack.length - 1].node;
const orderedKeys = PLACEMARK_SEQUENCE[parentNode.namespaceURI];
const values = makeSequence(properties, orderedKeys);
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
// serialize geometry
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
let geometry = feature.getGeometry();
if (geometry) {
geometry = transformGeometryWithOptions(geometry, true, options);
}
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
GEOMETRY_NODE_FACTORY, [geometry], objectStack);
} | javascript | function writePlacemark(node, feature, objectStack) {
const /** @type {import("../xml.js").NodeStackItem} */ context = {node: node};
// set id
if (feature.getId()) {
node.setAttribute('id', /** @type {string} */ (feature.getId()));
}
// serialize properties (properties unknown to KML are not serialized)
const properties = feature.getProperties();
// don't export these to ExtendedData
const filter = {'address': 1, 'description': 1, 'name': 1, 'open': 1,
'phoneNumber': 1, 'styleUrl': 1, 'visibility': 1};
filter[feature.getGeometryName()] = 1;
const keys = Object.keys(properties || {}).sort().filter(function(v) {
return !filter[v];
});
if (keys.length > 0) {
const sequence = makeSequence(properties, keys);
const namesAndValues = {names: keys, values: sequence};
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
EXTENDEDDATA_NODE_FACTORY, [namesAndValues], objectStack);
}
const styleFunction = feature.getStyleFunction();
if (styleFunction) {
// FIXME the styles returned by the style function are supposed to be
// resolution-independent here
const styles = styleFunction(feature, 0);
if (styles) {
const style = Array.isArray(styles) ? styles[0] : styles;
if (this.writeStyles_) {
properties['Style'] = style;
}
const textStyle = style.getText();
if (textStyle) {
properties['name'] = textStyle.getText();
}
}
}
const parentNode = objectStack[objectStack.length - 1].node;
const orderedKeys = PLACEMARK_SEQUENCE[parentNode.namespaceURI];
const values = makeSequence(properties, orderedKeys);
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
OBJECT_PROPERTY_NODE_FACTORY, values, objectStack, orderedKeys);
// serialize geometry
const options = /** @type {import("./Feature.js").WriteOptions} */ (objectStack[0]);
let geometry = feature.getGeometry();
if (geometry) {
geometry = transformGeometryWithOptions(geometry, true, options);
}
pushSerializeAndPop(context, PLACEMARK_SERIALIZERS,
GEOMETRY_NODE_FACTORY, [geometry], objectStack);
} | [
"function",
"writePlacemark",
"(",
"node",
",",
"feature",
",",
"objectStack",
")",
"{",
"const",
"/** @type {import(\"../xml.js\").NodeStackItem} */",
"context",
"=",
"{",
"node",
":",
"node",
"}",
";",
"// set id",
"if",
"(",
"feature",
".",
"getId",
"(",
")",... | FIXME currently we do serialize arbitrary/custom feature properties
(ExtendedData).
@param {Element} node Node.
@param {Feature} feature Feature.
@param {Array<*>} objectStack Object stack.
@this {KML} | [
"FIXME",
"currently",
"we",
"do",
"serialize",
"arbitrary",
"/",
"custom",
"feature",
"properties",
"(",
"ExtendedData",
")",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/KML.js#L2668-L2724 | train | Writes a placemark node | [
30522,
3853,
4339,
24759,
10732,
10665,
1006,
13045,
1010,
3444,
1010,
5200,
2696,
3600,
1007,
1063,
9530,
3367,
1013,
1008,
1008,
1030,
2828,
1063,
12324,
1006,
1000,
1012,
1012,
1013,
20950,
1012,
1046,
2015,
1000,
1007,
1012,
14164,
2696... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
elastic/elasticsearch-js | api/api/update.js | buildUpdate | function buildUpdate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request
*
* @param {string} id - Document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {string} lang - The script language (default: painless)
* @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0)
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term
* @param {object} body - The request definition requires either `script` or partial `doc`
*/
const acceptedQuerystring = [
'wait_for_active_shards',
'_source',
'_source_excludes',
'_source_includes',
'lang',
'parent',
'refresh',
'retry_on_conflict',
'routing',
'timeout',
'if_seq_no',
'if_primary_term',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function update (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, id, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildUpdate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request
*
* @param {string} id - Document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {string} lang - The script language (default: painless)
* @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0)
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term
* @param {object} body - The request definition requires either `script` or partial `doc`
*/
const acceptedQuerystring = [
'wait_for_active_shards',
'_source',
'_source_excludes',
'_source_includes',
'lang',
'parent',
'refresh',
'retry_on_conflict',
'routing',
'timeout',
'if_seq_no',
'if_primary_term',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function update (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, id, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildUpdate",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [update](http://www.elastic.co/guide/en/elast... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/update.js#L25-L144 | train | Build an update operation. | [
30522,
3853,
3857,
6279,
13701,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
30524,
1033,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
21274,
1012,
2522,
1013,
5009,
1013,
4372,
1013,
21274,
17310,
1114... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
codemirror/CodeMirror | src/model/history.js | removeClearedSpans | function removeClearedSpans(spans) {
if (!spans) return null
let out
for (let i = 0; i < spans.length; ++i) {
if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i) }
else if (out) out.push(spans[i])
}
return !out ? spans : out.length ? out : null
} | javascript | function removeClearedSpans(spans) {
if (!spans) return null
let out
for (let i = 0; i < spans.length; ++i) {
if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i) }
else if (out) out.push(spans[i])
}
return !out ? spans : out.length ? out : null
} | [
"function",
"removeClearedSpans",
"(",
"spans",
")",
"{",
"if",
"(",
"!",
"spans",
")",
"return",
"null",
"let",
"out",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"spans",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"spans",
"[",
... | When un/re-doing restores text containing marked spans, those that have been explicitly cleared should not be restored. | [
"When",
"un",
"/",
"re",
"-",
"doing",
"restores",
"text",
"containing",
"marked",
"spans",
"those",
"that",
"have",
"been",
"explicitly",
"cleared",
"should",
"not",
"be",
"restored",
"."
] | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/model/history.js#L158-L166 | train | Remove any previously cleared spans | [
30522,
3853,
6366,
14321,
12069,
5104,
9739,
2015,
1006,
14798,
1007,
1063,
2065,
1006,
999,
14798,
1007,
2709,
19701,
2292,
2041,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
14798,
1012,
3091,
1025,
1009,
1009,
1045,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/source-code.js | validate | function validate(ast) {
if (!ast.tokens) {
throw new Error("AST is missing the tokens array.");
}
if (!ast.comments) {
throw new Error("AST is missing the comments array.");
}
if (!ast.loc) {
throw new Error("AST is missing location information.");
}
if (!ast.range) {
throw new Error("AST is missing range information");
}
} | javascript | function validate(ast) {
if (!ast.tokens) {
throw new Error("AST is missing the tokens array.");
}
if (!ast.comments) {
throw new Error("AST is missing the comments array.");
}
if (!ast.loc) {
throw new Error("AST is missing location information.");
}
if (!ast.range) {
throw new Error("AST is missing range information");
}
} | [
"function",
"validate",
"(",
"ast",
")",
"{",
"if",
"(",
"!",
"ast",
".",
"tokens",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"AST is missing the tokens array.\"",
")",
";",
"}",
"if",
"(",
"!",
"ast",
".",
"comments",
")",
"{",
"throw",
"new",
"Error"... | ------------------------------------------------------------------------------ Private ------------------------------------------------------------------------------
Validates that the given AST has the required information.
@param {ASTNode} ast The Program node of the AST to check.
@throws {Error} If the AST doesn't contain the correct information.
@returns {void}
@private | [
"------------------------------------------------------------------------------",
"Private",
"------------------------------------------------------------------------------",
"Validates",
"that",
"the",
"given",
"AST",
"has",
"the",
"required",
"information",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code.js#L27-L43 | train | Validate the AST | [
30522,
3853,
9398,
3686,
1006,
2004,
2102,
1007,
1063,
2065,
1006,
999,
2004,
2102,
1012,
19204,
2015,
1007,
1063,
5466,
2047,
7561,
1006,
1000,
2004,
2102,
2003,
4394,
1996,
19204,
2015,
9140,
1012,
1000,
1007,
1025,
1065,
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... |
feathericons/feather | src/icon.js | attrsToString | function attrsToString(attrs) {
return Object.keys(attrs)
.map(key => `${key}="${attrs[key]}"`)
.join(' ');
} | javascript | function attrsToString(attrs) {
return Object.keys(attrs)
.map(key => `${key}="${attrs[key]}"`)
.join(' ');
} | [
"function",
"attrsToString",
"(",
"attrs",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"attrs",
")",
".",
"map",
"(",
"key",
"=>",
"`",
"${",
"key",
"}",
"${",
"attrs",
"[",
"key",
"]",
"}",
"`",
")",
".",
"join",
"(",
"' '",
")",
";",
"}"
... | Convert attributes object to string of HTML attributes.
@param {Object} attrs
@returns {string} | [
"Convert",
"attributes",
"object",
"to",
"string",
"of",
"HTML",
"attributes",
"."
] | 8f658193d25e943b196a2367319b5d9e85ee9f9f | https://github.com/feathericons/feather/blob/8f658193d25e943b196a2367319b5d9e85ee9f9f/src/icon.js#L49-L53 | train | Convert an object to a string | [
30522,
3853,
2012,
16344,
16033,
3367,
4892,
1006,
2012,
16344,
2015,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
2012,
16344,
2015,
1007,
1012,
4949,
1006,
3145,
1027,
1028,
1036,
1002,
1063,
3145,
1065,
1027,
1000,
1002,
1063,
2012,
16344,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/Package.js | install | function install(path, nameHint, _doUpdate) {
return _extensionManagerCall(function (extensionManager) {
var d = new $.Deferred(),
destinationDirectory = ExtensionLoader.getUserExtensionPath(),
disabledDirectory = destinationDirectory.replace(/\/user$/, "/disabled"),
systemDirectory = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/default/";
var operation = _doUpdate ? "update" : "install";
extensionManager[operation](path, destinationDirectory, {
disabledDirectory: disabledDirectory,
systemExtensionDirectory: systemDirectory,
apiVersion: brackets.metadata.apiVersion,
nameHint: nameHint,
proxy: PreferencesManager.get("proxy")
})
.done(function (result) {
result.keepFile = false;
if (result.installationStatus !== InstallationStatuses.INSTALLED || _doUpdate) {
d.resolve(result);
} else {
// This was a new extension and everything looked fine.
// We load it into Brackets right away.
ExtensionLoader.loadExtension(result.name, {
// On Windows, it looks like Node converts Unix-y paths to backslashy paths.
// We need to convert them back.
baseUrl: FileUtils.convertWindowsPathToUnixPath(result.installedTo)
}, "main").then(function () {
d.resolve(result);
}, function () {
d.reject(Errors.ERROR_LOADING);
});
}
})
.fail(function (error) {
d.reject(error);
});
return d.promise();
});
} | javascript | function install(path, nameHint, _doUpdate) {
return _extensionManagerCall(function (extensionManager) {
var d = new $.Deferred(),
destinationDirectory = ExtensionLoader.getUserExtensionPath(),
disabledDirectory = destinationDirectory.replace(/\/user$/, "/disabled"),
systemDirectory = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/default/";
var operation = _doUpdate ? "update" : "install";
extensionManager[operation](path, destinationDirectory, {
disabledDirectory: disabledDirectory,
systemExtensionDirectory: systemDirectory,
apiVersion: brackets.metadata.apiVersion,
nameHint: nameHint,
proxy: PreferencesManager.get("proxy")
})
.done(function (result) {
result.keepFile = false;
if (result.installationStatus !== InstallationStatuses.INSTALLED || _doUpdate) {
d.resolve(result);
} else {
// This was a new extension and everything looked fine.
// We load it into Brackets right away.
ExtensionLoader.loadExtension(result.name, {
// On Windows, it looks like Node converts Unix-y paths to backslashy paths.
// We need to convert them back.
baseUrl: FileUtils.convertWindowsPathToUnixPath(result.installedTo)
}, "main").then(function () {
d.resolve(result);
}, function () {
d.reject(Errors.ERROR_LOADING);
});
}
})
.fail(function (error) {
d.reject(error);
});
return d.promise();
});
} | [
"function",
"install",
"(",
"path",
",",
"nameHint",
",",
"_doUpdate",
")",
"{",
"return",
"_extensionManagerCall",
"(",
"function",
"(",
"extensionManager",
")",
"{",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"destinationDirectory",
"=",
... | Validates and installs the package at the given path. Validation and
installation is handled by the Node process.
The extension will be installed into the user's extensions directory.
If the user already has the extension installed, it will instead go
into their disabled extensions directory.
The promise is resolved with an object:
{ errors: Array.<{string}>, metadata: { name:string, version:string, ... },
disabledReason:string, installedTo:string, commonPrefix:string }
metadata is pulled straight from package.json and is likely to be undefined
if there are errors. It is null if there was no package.json.
disabledReason is either null or the reason the extension was installed disabled.
@param {string} path Absolute path to the package zip file
@param {?string} nameHint Hint for the extension folder's name (used in favor of
path's filename if present, and if no package metadata present).
@param {?boolean} _doUpdate private argument used to signal an update
@return {$.Promise} A promise that is resolved with information about the package
(which may include errors, in which case the extension was disabled), or
rejected with an error object. | [
"Validates",
"and",
"installs",
"the",
"package",
"at",
"the",
"given",
"path",
".",
"Validation",
"and",
"installation",
"is",
"handled",
"by",
"the",
"Node",
"process",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/Package.js#L158-L198 | train | Installs the extension | [
30522,
3853,
16500,
1006,
4130,
1010,
2171,
10606,
2102,
1010,
1035,
2079,
6279,
13701,
1007,
1063,
2709,
1035,
5331,
24805,
4590,
9289,
2140,
1006,
3853,
1006,
5331,
24805,
4590,
1007,
1063,
13075,
1040,
1027,
2047,
1002,
1012,
13366,
2884... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
electron/electron | lib/browser/rpc-server.js | function (sender, frameId, contextId, args) {
const metaToValue = function (meta) {
switch (meta.type) {
case 'value':
return meta.value
case 'remote-object':
return objectsRegistry.get(meta.id)
case 'array':
return unwrapArgs(sender, frameId, contextId, meta.value)
case 'buffer':
return bufferUtils.metaToBuffer(meta.value)
case 'date':
return new Date(meta.value)
case 'promise':
return Promise.resolve({
then: metaToValue(meta.then)
})
case 'object': {
const ret = {}
Object.defineProperty(ret.constructor, 'name', { value: meta.name })
for (const { name, value } of meta.members) {
ret[name] = metaToValue(value)
}
return ret
}
case 'function-with-return-value':
const returnValue = metaToValue(meta.value)
return function () {
return returnValue
}
case 'function': {
// Merge contextId and meta.id, since meta.id can be the same in
// different webContents.
const objectId = [contextId, meta.id]
// Cache the callbacks in renderer.
if (rendererFunctions.has(objectId)) {
return rendererFunctions.get(objectId)
}
const callIntoRenderer = function (...args) {
let succeed = false
if (!sender.isDestroyed()) {
succeed = sender._sendToFrameInternal(frameId, 'ELECTRON_RENDERER_CALLBACK', contextId, meta.id, valueToMeta(sender, contextId, args))
}
if (!succeed) {
removeRemoteListenersAndLogWarning(this, callIntoRenderer)
}
}
v8Util.setHiddenValue(callIntoRenderer, 'location', meta.location)
Object.defineProperty(callIntoRenderer, 'length', { value: meta.length })
v8Util.setRemoteCallbackFreer(callIntoRenderer, contextId, meta.id, sender)
rendererFunctions.set(objectId, callIntoRenderer)
return callIntoRenderer
}
default:
throw new TypeError(`Unknown type: ${meta.type}`)
}
}
return args.map(metaToValue)
} | javascript | function (sender, frameId, contextId, args) {
const metaToValue = function (meta) {
switch (meta.type) {
case 'value':
return meta.value
case 'remote-object':
return objectsRegistry.get(meta.id)
case 'array':
return unwrapArgs(sender, frameId, contextId, meta.value)
case 'buffer':
return bufferUtils.metaToBuffer(meta.value)
case 'date':
return new Date(meta.value)
case 'promise':
return Promise.resolve({
then: metaToValue(meta.then)
})
case 'object': {
const ret = {}
Object.defineProperty(ret.constructor, 'name', { value: meta.name })
for (const { name, value } of meta.members) {
ret[name] = metaToValue(value)
}
return ret
}
case 'function-with-return-value':
const returnValue = metaToValue(meta.value)
return function () {
return returnValue
}
case 'function': {
// Merge contextId and meta.id, since meta.id can be the same in
// different webContents.
const objectId = [contextId, meta.id]
// Cache the callbacks in renderer.
if (rendererFunctions.has(objectId)) {
return rendererFunctions.get(objectId)
}
const callIntoRenderer = function (...args) {
let succeed = false
if (!sender.isDestroyed()) {
succeed = sender._sendToFrameInternal(frameId, 'ELECTRON_RENDERER_CALLBACK', contextId, meta.id, valueToMeta(sender, contextId, args))
}
if (!succeed) {
removeRemoteListenersAndLogWarning(this, callIntoRenderer)
}
}
v8Util.setHiddenValue(callIntoRenderer, 'location', meta.location)
Object.defineProperty(callIntoRenderer, 'length', { value: meta.length })
v8Util.setRemoteCallbackFreer(callIntoRenderer, contextId, meta.id, sender)
rendererFunctions.set(objectId, callIntoRenderer)
return callIntoRenderer
}
default:
throw new TypeError(`Unknown type: ${meta.type}`)
}
}
return args.map(metaToValue)
} | [
"function",
"(",
"sender",
",",
"frameId",
",",
"contextId",
",",
"args",
")",
"{",
"const",
"metaToValue",
"=",
"function",
"(",
"meta",
")",
"{",
"switch",
"(",
"meta",
".",
"type",
")",
"{",
"case",
"'value'",
":",
"return",
"meta",
".",
"value",
... | Convert array of meta data from renderer into array of real values. | [
"Convert",
"array",
"of",
"meta",
"data",
"from",
"renderer",
"into",
"array",
"of",
"real",
"values",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/rpc-server.js#L183-L245 | train | Returns the value of the given meta | [
30522,
3853,
1006,
4604,
2121,
1010,
4853,
3593,
1010,
6123,
3593,
1010,
12098,
5620,
1007,
30524,
1012,
3643,
2553,
1005,
6556,
1011,
4874,
1005,
1024,
2709,
5200,
2890,
24063,
2854,
1012,
2131,
1006,
18804,
1012,
8909,
1007,
2553,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Entity.controller.js | function (sId, oDoc, oEntity, oControlsData) {
// convert docu
var oData = this._convertEntityInfo(sId, oDoc, oControlsData),
bShouldShowSamplesSection = false,
iSamplesCount = 0;
oData.show.introLink = false;
if (oEntity) {
// show the description as intro text if the entity is not deprecated
if (!oData.shortDescription && oEntity.description) {
oData.shortDescription = oEntity.description;
}
if (!oData.baseName) {
oData.baseName = oEntity.name;
}
// make intro text active if a documentation link is set
if (oEntity.docuLink) {
oData.show.introLink = true;
oData.docuLink = oEntity.docuLink.replace("docs/guide", "topic").replace(/\.html$/, "");
oData.docuLinkText = oData.baseName;
}
bShouldShowSamplesSection = oEntity.samples.length > 0;
iSamplesCount = oEntity.samples.length;
}
// apply entity related stuff
oData.show.samples = bShouldShowSamplesSection;
oData.count.samples = iSamplesCount;
oData.entity = oEntity;
if (oDoc) {
// make intro text active if a documentation link is set
if (oDoc.docuLink) {
oData.show.introLink = true;
oData.docuLink = "#/topic/" + oDoc.docuLink;
oData.docuLinkText = oDoc.docuLinkText;
}
oData.uxGuidelinesLink = oDoc.uxGuidelinesLink;
oData.uxGuidelinesLinkText = oDoc.uxGuidelinesLinkText;
}
// done
return oData;
} | javascript | function (sId, oDoc, oEntity, oControlsData) {
// convert docu
var oData = this._convertEntityInfo(sId, oDoc, oControlsData),
bShouldShowSamplesSection = false,
iSamplesCount = 0;
oData.show.introLink = false;
if (oEntity) {
// show the description as intro text if the entity is not deprecated
if (!oData.shortDescription && oEntity.description) {
oData.shortDescription = oEntity.description;
}
if (!oData.baseName) {
oData.baseName = oEntity.name;
}
// make intro text active if a documentation link is set
if (oEntity.docuLink) {
oData.show.introLink = true;
oData.docuLink = oEntity.docuLink.replace("docs/guide", "topic").replace(/\.html$/, "");
oData.docuLinkText = oData.baseName;
}
bShouldShowSamplesSection = oEntity.samples.length > 0;
iSamplesCount = oEntity.samples.length;
}
// apply entity related stuff
oData.show.samples = bShouldShowSamplesSection;
oData.count.samples = iSamplesCount;
oData.entity = oEntity;
if (oDoc) {
// make intro text active if a documentation link is set
if (oDoc.docuLink) {
oData.show.introLink = true;
oData.docuLink = "#/topic/" + oDoc.docuLink;
oData.docuLinkText = oDoc.docuLinkText;
}
oData.uxGuidelinesLink = oDoc.uxGuidelinesLink;
oData.uxGuidelinesLinkText = oDoc.uxGuidelinesLinkText;
}
// done
return oData;
} | [
"function",
"(",
"sId",
",",
"oDoc",
",",
"oEntity",
",",
"oControlsData",
")",
"{",
"// convert docu",
"var",
"oData",
"=",
"this",
".",
"_convertEntityInfo",
"(",
"sId",
",",
"oDoc",
",",
"oControlsData",
")",
",",
"bShouldShowSamplesSection",
"=",
"false",
... | ========= internal =========================================================================== | [
"=========",
"internal",
"==========================================================================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Entity.controller.js#L217-L267 | train | Converts the given entity to a data structure | [
30522,
3853,
1006,
15765,
1010,
1051,
3527,
2278,
1010,
1051,
4765,
3012,
1010,
1051,
8663,
13181,
4877,
2850,
2696,
1007,
1063,
1013,
1013,
10463,
9986,
2226,
13075,
1051,
2850,
2696,
1027,
2023,
1012,
1035,
10463,
4765,
3012,
2378,
14876,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ColorlibHQ/AdminLTE | bower_components/raphael/dev/raphael.core.js | function (items) {
this.items = [];
this.length = 0;
this.type = "set";
if (items) {
for (var i = 0, ii = items.length; i < ii; i++) {
if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {
this[this.items.length] = this.items[this.items.length] = items[i];
this.length++;
}
}
}
} | javascript | function (items) {
this.items = [];
this.length = 0;
this.type = "set";
if (items) {
for (var i = 0, ii = items.length; i < ii; i++) {
if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {
this[this.items.length] = this.items[this.items.length] = items[i];
this.length++;
}
}
}
} | [
"function",
"(",
"items",
")",
"{",
"this",
".",
"items",
"=",
"[",
"]",
";",
"this",
".",
"length",
"=",
"0",
";",
"this",
".",
"type",
"=",
"\"set\"",
";",
"if",
"(",
"items",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"i... | Set | [
"Set"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/raphael/dev/raphael.core.js#L4806-L4818 | train | A set of | [
30522,
3853,
1006,
5167,
1007,
1063,
2023,
1012,
5167,
1027,
1031,
1033,
1025,
2023,
1012,
3091,
1027,
1014,
1025,
2023,
1012,
2828,
1027,
1000,
2275,
1000,
1025,
2065,
1006,
5167,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | dangerfile.js | createComparisonFilter | function createComparisonFilter(parsedThreshold, gzipThreshold) {
return comparisonEntry => {
const [, snapshot] = comparisonEntry;
return (
Math.abs(snapshot.parsed.absoluteDiff) >= parsedThreshold ||
Math.abs(snapshot.gzip.absoluteDiff) >= gzipThreshold
);
};
} | javascript | function createComparisonFilter(parsedThreshold, gzipThreshold) {
return comparisonEntry => {
const [, snapshot] = comparisonEntry;
return (
Math.abs(snapshot.parsed.absoluteDiff) >= parsedThreshold ||
Math.abs(snapshot.gzip.absoluteDiff) >= gzipThreshold
);
};
} | [
"function",
"createComparisonFilter",
"(",
"parsedThreshold",
",",
"gzipThreshold",
")",
"{",
"return",
"comparisonEntry",
"=>",
"{",
"const",
"[",
",",
"snapshot",
"]",
"=",
"comparisonEntry",
";",
"return",
"(",
"Math",
".",
"abs",
"(",
"snapshot",
".",
"par... | creates a callback for Object.entries(comparison).filter that excludes every
entry that does not exceed the given threshold values for parsed and gzip size
@param {number} parsedThreshold
@param {number} gzipThreshold | [
"creates",
"a",
"callback",
"for",
"Object",
".",
"entries",
"(",
"comparison",
")",
".",
"filter",
"that",
"excludes",
"every",
"entry",
"that",
"does",
"not",
"exceed",
"the",
"given",
"threshold",
"values",
"for",
"parsed",
"and",
"gzip",
"size"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/dangerfile.js#L45-L53 | train | Creates a filter function that checks if a file is compressed or not. | [
30522,
3853,
3443,
9006,
19362,
10929,
8873,
21928,
1006,
11968,
6924,
2705,
21898,
11614,
1010,
1043,
5831,
13876,
28362,
22231,
6392,
1007,
1063,
2709,
7831,
4765,
2854,
1027,
1028,
1063,
9530,
3367,
1031,
1010,
20057,
12326,
1033,
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/components/dialog/dialog.js | lockScreenReader | function lockScreenReader(element, options) {
var isHidden = true;
// get raw DOM node
walkDOM(element[0]);
options.unlockScreenReader = function () {
isHidden = false;
walkDOM(element[0]);
options.unlockScreenReader = null;
};
/**
* Get all of an element's parent elements up the DOM tree
* @return {Array} The parent elements
*/
function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
}
/**
* Walk DOM to apply or remove aria-hidden on sibling nodes
* and parent sibling nodes
*/
function walkDOM(element) {
var elements = getParents(element);
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('aria-hidden', isHidden);
}
}
} | javascript | function lockScreenReader(element, options) {
var isHidden = true;
// get raw DOM node
walkDOM(element[0]);
options.unlockScreenReader = function () {
isHidden = false;
walkDOM(element[0]);
options.unlockScreenReader = null;
};
/**
* Get all of an element's parent elements up the DOM tree
* @return {Array} The parent elements
*/
function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
}
/**
* Walk DOM to apply or remove aria-hidden on sibling nodes
* and parent sibling nodes
*/
function walkDOM(element) {
var elements = getParents(element);
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('aria-hidden', isHidden);
}
}
} | [
"function",
"lockScreenReader",
"(",
"element",
",",
"options",
")",
"{",
"var",
"isHidden",
"=",
"true",
";",
"// get raw DOM node",
"walkDOM",
"(",
"element",
"[",
"0",
"]",
")",
";",
"options",
".",
"unlockScreenReader",
"=",
"function",
"(",
")",
"{",
... | Prevents screen reader interaction behind modal window
on swipe interfaces | [
"Prevents",
"screen",
"reader",
"interaction",
"behind",
"modal",
"window",
"on",
"swipe",
"interfaces"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L1142-L1190 | train | Lock screen reader | [
30522,
3853,
11223,
24410,
16416,
4063,
1006,
5783,
1010,
7047,
1007,
1063,
13075,
2003,
27511,
4181,
1027,
2995,
1025,
1013,
1013,
2131,
6315,
14383,
13045,
3328,
9527,
1006,
5783,
1031,
1014,
1033,
1007,
1025,
7047,
1012,
19829,
18182,
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.fl/src/sap/ui/fl/variants/VariantManagement.js | function(oRm, oControl) {
oRm.write("<div ");
oRm.writeControlData(oControl);
oRm.addClass("sapUiFlVarMngmt");
oRm.writeClasses();
oRm.write(">");
oRm.renderControl(oControl.oVariantLayout);
oRm.write("</div>");
} | javascript | function(oRm, oControl) {
oRm.write("<div ");
oRm.writeControlData(oControl);
oRm.addClass("sapUiFlVarMngmt");
oRm.writeClasses();
oRm.write(">");
oRm.renderControl(oControl.oVariantLayout);
oRm.write("</div>");
} | [
"function",
"(",
"oRm",
",",
"oControl",
")",
"{",
"oRm",
".",
"write",
"(",
"\"<div \"",
")",
";",
"oRm",
".",
"writeControlData",
"(",
"oControl",
")",
";",
"oRm",
".",
"addClass",
"(",
"\"sapUiFlVarMngmt\"",
")",
";",
"oRm",
".",
"writeClasses",
"(",
... | Renders the HTML for the given control, using the provided {@link sap.ui.core.RenderManager}.
@param {sap.ui.core.RenderManager} oRm the RenderManager that can be used for writing to the render output buffer
@param {sap.ui.core.Control} oControl an object representation of the control that should be rendered | [
"Renders",
"the",
"HTML",
"for",
"the",
"given",
"control",
"using",
"the",
"provided",
"{"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/variants/VariantManagement.js#L208-L218 | train | Renders the variant layout | [
30522,
3853,
1006,
2030,
2213,
1010,
1051,
8663,
13181,
2140,
1007,
1063,
2030,
2213,
1012,
4339,
1006,
1000,
1026,
4487,
2615,
1000,
1007,
1025,
2030,
2213,
1012,
4339,
8663,
13181,
15150,
2696,
1006,
1051,
8663,
13181,
2140,
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... | |
apache/incubator-echarts | src/chart/tree/layoutHelper.js | nextAncestor | function nextAncestor(nodeInLeft, node, ancestor) {
return nodeInLeft.hierNode.ancestor.parentNode === node.parentNode
? nodeInLeft.hierNode.ancestor : ancestor;
} | javascript | function nextAncestor(nodeInLeft, node, ancestor) {
return nodeInLeft.hierNode.ancestor.parentNode === node.parentNode
? nodeInLeft.hierNode.ancestor : ancestor;
} | [
"function",
"nextAncestor",
"(",
"nodeInLeft",
",",
"node",
",",
"ancestor",
")",
"{",
"return",
"nodeInLeft",
".",
"hierNode",
".",
"ancestor",
".",
"parentNode",
"===",
"node",
".",
"parentNode",
"?",
"nodeInLeft",
".",
"hierNode",
".",
"ancestor",
":",
"a... | If nodeInLeft’s ancestor is a sibling of node, returns nodeInLeft’s ancestor.
Otherwise, returns the specified ancestor.
@param {module:echarts/data/Tree~TreeNode} nodeInLeft
@param {module:echarts/data/Tree~TreeNode} node
@param {module:echarts/data/Tree~TreeNode} ancestor
@return {module:echarts/data/Tree~TreeNode} | [
"If",
"nodeInLeft’s",
"ancestor",
"is",
"a",
"sibling",
"of",
"node",
"returns",
"nodeInLeft’s",
"ancestor",
".",
"Otherwise",
"returns",
"the",
"specified",
"ancestor",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L297-L300 | train | Returns the next ancestor of node in left | [
30522,
3853,
2279,
26755,
4263,
1006,
13045,
2378,
2571,
6199,
1010,
13045,
1010,
13032,
1007,
1063,
2709,
13045,
2378,
2571,
6199,
1012,
7632,
11795,
10244,
1012,
13032,
1012,
6687,
3630,
3207,
1027,
1027,
1027,
13045,
1012,
6687,
3630,
32... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/context/ContextManager.js | function(aContextObjects, aDesignTimeContextIdsByUrl) {
var aActiveContexts = [];
aContextObjects.forEach(function (oContext) {
var bContextActive = ((aDesignTimeContextIdsByUrl ? Array.prototype.indexOf.call(aDesignTimeContextIdsByUrl, oContext.id) : -1)) !== -1;
if (bContextActive) {
aActiveContexts.push(oContext.id);
}
});
return aActiveContexts;
} | javascript | function(aContextObjects, aDesignTimeContextIdsByUrl) {
var aActiveContexts = [];
aContextObjects.forEach(function (oContext) {
var bContextActive = ((aDesignTimeContextIdsByUrl ? Array.prototype.indexOf.call(aDesignTimeContextIdsByUrl, oContext.id) : -1)) !== -1;
if (bContextActive) {
aActiveContexts.push(oContext.id);
}
});
return aActiveContexts;
} | [
"function",
"(",
"aContextObjects",
",",
"aDesignTimeContextIdsByUrl",
")",
"{",
"var",
"aActiveContexts",
"=",
"[",
"]",
";",
"aContextObjects",
".",
"forEach",
"(",
"function",
"(",
"oContext",
")",
"{",
"var",
"bContextActive",
"=",
"(",
"(",
"aDesignTimeCont... | Function to filter all contexts by the context URL parameters.
@param {string[]} aDesignTimeContextIdsByUrl - list of ids passed via URL
@param {object[]} aContextObjects - context objects within the application
@returns {string[]} aActiveContexts - id list of all active contexts | [
"Function",
"to",
"filter",
"all",
"contexts",
"by",
"the",
"context",
"URL",
"parameters",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/context/ContextManager.js#L120-L132 | train | Returns an array of context ids that are active in the given design time context objects | [
30522,
3853,
1006,
9353,
28040,
30524,
18209,
9821,
3762,
3126,
2140,
1007,
1063,
13075,
9779,
15277,
8663,
18209,
2015,
1027,
1031,
1033,
1025,
9353,
28040,
18413,
16429,
20614,
2015,
1012,
18921,
6776,
1006,
3853,
1006,
1051,
8663,
18209,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/command/KeyBindingManager.js | _quitAltGrMode | function _quitAltGrMode() {
_enabled = true;
_ctrlDown = CtrlDownStates.NOT_YET_DETECTED;
_altGrDown = false;
_lastTimeStamp = null;
_lastKeyIdentifier = null;
$(window).off("keyup", _onCtrlUp);
} | javascript | function _quitAltGrMode() {
_enabled = true;
_ctrlDown = CtrlDownStates.NOT_YET_DETECTED;
_altGrDown = false;
_lastTimeStamp = null;
_lastKeyIdentifier = null;
$(window).off("keyup", _onCtrlUp);
} | [
"function",
"_quitAltGrMode",
"(",
")",
"{",
"_enabled",
"=",
"true",
";",
"_ctrlDown",
"=",
"CtrlDownStates",
".",
"NOT_YET_DETECTED",
";",
"_altGrDown",
"=",
"false",
";",
"_lastTimeStamp",
"=",
"null",
";",
"_lastKeyIdentifier",
"=",
"null",
";",
"$",
"(",
... | @private
Resets all the flags and removes _onCtrlUp event listener. | [
"@private",
"Resets",
"all",
"the",
"flags",
"and",
"removes",
"_onCtrlUp",
"event",
"listener",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L200-L207 | train | Quit AltGr mode | [
30522,
3853,
1035,
8046,
2389,
2102,
16523,
5302,
3207,
1006,
1007,
1063,
1035,
9124,
1027,
2995,
1025,
1035,
14931,
12190,
7698,
1027,
14931,
12190,
7698,
9153,
4570,
1012,
2025,
1035,
2664,
1035,
11156,
1025,
1035,
12456,
16523,
7698,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/samples/InlineImageViewer/main.js | _getStringAtPos | function _getStringAtPos(hostEditor, pos) {
var token = hostEditor._codeMirror.getTokenAt(pos, true);
// If the pos is at the beginning of a name, token will be the
// preceding whitespace or dot. In that case, try the next pos.
if (!/\S/.test(token.string) || token.string === ".") {
token = hostEditor._codeMirror.getTokenAt({line: pos.line, ch: pos.ch + 1}, true);
}
if (token.type === "string") {
var string = token.string;
// Strip quotes
var ch = string[0];
if (ch === "\"" || ch === "'") {
string = string.substr(1);
}
ch = string[string.length - 1];
if (ch === "\"" || ch === "'") {
string = string.substr(0, string.length - 1);
}
return string;
} else {
// Check for url(...);
var line = hostEditor._codeMirror.getLine(pos.line);
var match = /url\s*\(([^)]*)\)/.exec(line);
if (match && match[1]) {
// URLs are relative to the doc
var docPath = hostEditor.document.file.fullPath;
docPath = docPath.substr(0, docPath.lastIndexOf("/"));
return docPath + "/" + match[1];
}
}
return "";
} | javascript | function _getStringAtPos(hostEditor, pos) {
var token = hostEditor._codeMirror.getTokenAt(pos, true);
// If the pos is at the beginning of a name, token will be the
// preceding whitespace or dot. In that case, try the next pos.
if (!/\S/.test(token.string) || token.string === ".") {
token = hostEditor._codeMirror.getTokenAt({line: pos.line, ch: pos.ch + 1}, true);
}
if (token.type === "string") {
var string = token.string;
// Strip quotes
var ch = string[0];
if (ch === "\"" || ch === "'") {
string = string.substr(1);
}
ch = string[string.length - 1];
if (ch === "\"" || ch === "'") {
string = string.substr(0, string.length - 1);
}
return string;
} else {
// Check for url(...);
var line = hostEditor._codeMirror.getLine(pos.line);
var match = /url\s*\(([^)]*)\)/.exec(line);
if (match && match[1]) {
// URLs are relative to the doc
var docPath = hostEditor.document.file.fullPath;
docPath = docPath.substr(0, docPath.lastIndexOf("/"));
return docPath + "/" + match[1];
}
}
return "";
} | [
"function",
"_getStringAtPos",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"token",
"=",
"hostEditor",
".",
"_codeMirror",
".",
"getTokenAt",
"(",
"pos",
",",
"true",
")",
";",
"// If the pos is at the beginning of a name, token will be the",
"// preceding whitespac... | Return the token string that is at the specified position.
@param hostEditor {!Editor} editor
@param {!{line:Number, ch:Number}} pos
@return {String} token string at the specified position | [
"Return",
"the",
"token",
"string",
"that",
"is",
"at",
"the",
"specified",
"position",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/samples/InlineImageViewer/main.js#L44-L84 | train | Get the string at pos | [
30522,
3853,
1035,
4152,
18886,
13807,
25856,
2891,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1063,
13075,
19204,
1027,
4354,
15660,
1012,
1035,
3642,
14503,
29165,
1012,
2131,
18715,
8189,
2102,
1006,
13433,
2015,
1010,
2995,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableKeyboardExtension.js | function(oExtension) {
var oTable = oExtension.getTable();
var $Table = oTable.$();
var iColumnCount = TableUtils.getVisibleColumnCount(oTable);
var iTotalColumnCount = iColumnCount;
var bHasRowHeader = TableUtils.hasRowHeader(oTable);
var bHasRowActions = TableUtils.hasRowActions(oTable);
var bHasFixedColumns = TableUtils.hasFixedColumns(oTable);
// create the list of item dom refs
var aItemDomRefs = [],
aRowHdrDomRefs, aRowActionDomRefs, $topLeft, $middleLeft, $bottomLeft;
if (bHasFixedColumns) {
$topLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowFixed:not(.sapUiTableCHT)");
$middleLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowScroll:not(.sapUiTableCHT)");
$bottomLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowFixedBottom:not(.sapUiTableCHT)");
}
var $topRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowFixed:not(.sapUiTableCHT)");
var $middleRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowScroll:not(.sapUiTableCHT)");
var $bottomRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowFixedBottom:not(.sapUiTableCHT)");
if (bHasRowHeader) {
aRowHdrDomRefs = $Table.find(".sapUiTableRowSelectionCell").get();
iTotalColumnCount++;
}
if (bHasRowActions) {
aRowActionDomRefs = $Table.find(".sapUiTableRowActionCell").get();
iTotalColumnCount++;
}
for (var i = 0; i < oTable.getVisibleRowCount(); i++) {
if (bHasRowHeader) {
aItemDomRefs.push(aRowHdrDomRefs[i]);
}
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($topLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($topRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($middleLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($middleRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($bottomLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($bottomRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasRowActions) {
aItemDomRefs.push(aRowActionDomRefs[i]);
}
}
// add the column headers and select all
if (oTable.getColumnHeaderVisible()) {
var aHeaderDomRefs = [];
// Returns the .sapUiTableColHdr elements (.sapUiTableColHdrCnt .sapUiTableCtrlFixed .sapUiTableColHdrTr)
var $FixedHeaders = $Table.find(".sapUiTableCHT.sapUiTableCtrlFixed>tbody>tr");
// Returns the .sapUiTableColHdr elements (.sapUiTableColHdrCnt .sapUiTableCtrlScr .sapUiTableColHdrTr)
var $ScrollHeaders = $Table.find(".sapUiTableCHT.sapUiTableCtrlScroll>tbody>tr");
for (var i = 0; i < TableUtils.getHeaderRowCount(oTable); i++) {
if (bHasRowHeader) {
aHeaderDomRefs.push(oTable.getDomRef("selall"));
}
if ($FixedHeaders.length) {
aHeaderDomRefs = aHeaderDomRefs.concat(jQuery($FixedHeaders.get(i)).find(".sapUiTableHeaderCell").get());
}
if ($ScrollHeaders.length) {
aHeaderDomRefs = aHeaderDomRefs.concat(jQuery($ScrollHeaders.get(i)).find(".sapUiTableHeaderCell").get());
}
if (bHasRowActions) {
// Only add a dummy (inivisible inner text) to fullfill matrix for item navigation.
// Header should not be focuable.
aHeaderDomRefs.push($Table.find(".sapUiTableRowActionHeaderCell").children().get(0));
}
}
aItemDomRefs = aHeaderDomRefs.concat(aItemDomRefs);
}
// initialization of item navigation for the Table control
if (!oExtension._itemNavigation) {
oExtension._itemNavigation = new ItemNavigation();
oExtension._itemNavigation.setTableMode(true);
oExtension._itemNavigation.attachEvent(ItemNavigation.Events.AfterFocus, function(oEvent) {
var oInfo = TableUtils.getFocusedItemInfo(oTable);
oInfo.header = TableUtils.getHeaderRowCount(oTable);
oInfo.domRef = null; //Do not keep dom references
if (oInfo.row >= oInfo.header) {
oExtension._oLastFocusedCellInfo = oInfo;
}
}, oTable);
}
// configure the item navigation
oExtension._itemNavigation.setColumns(iTotalColumnCount);
oExtension._itemNavigation.setRootDomRef($Table.find(".sapUiTableCnt").get(0));
oExtension._itemNavigation.setItemDomRefs(aItemDomRefs);
oExtension._itemNavigation.setFocusedIndex(ExtensionHelper.getInitialItemNavigationIndex(oExtension));
// revert invalidation flag
oExtension._itemNavigationInvalidated = false;
} | javascript | function(oExtension) {
var oTable = oExtension.getTable();
var $Table = oTable.$();
var iColumnCount = TableUtils.getVisibleColumnCount(oTable);
var iTotalColumnCount = iColumnCount;
var bHasRowHeader = TableUtils.hasRowHeader(oTable);
var bHasRowActions = TableUtils.hasRowActions(oTable);
var bHasFixedColumns = TableUtils.hasFixedColumns(oTable);
// create the list of item dom refs
var aItemDomRefs = [],
aRowHdrDomRefs, aRowActionDomRefs, $topLeft, $middleLeft, $bottomLeft;
if (bHasFixedColumns) {
$topLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowFixed:not(.sapUiTableCHT)");
$middleLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowScroll:not(.sapUiTableCHT)");
$bottomLeft = $Table.find(".sapUiTableCtrlFixed.sapUiTableCtrlRowFixedBottom:not(.sapUiTableCHT)");
}
var $topRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowFixed:not(.sapUiTableCHT)");
var $middleRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowScroll:not(.sapUiTableCHT)");
var $bottomRight = $Table.find(".sapUiTableCtrlScroll.sapUiTableCtrlRowFixedBottom:not(.sapUiTableCHT)");
if (bHasRowHeader) {
aRowHdrDomRefs = $Table.find(".sapUiTableRowSelectionCell").get();
iTotalColumnCount++;
}
if (bHasRowActions) {
aRowActionDomRefs = $Table.find(".sapUiTableRowActionCell").get();
iTotalColumnCount++;
}
for (var i = 0; i < oTable.getVisibleRowCount(); i++) {
if (bHasRowHeader) {
aItemDomRefs.push(aRowHdrDomRefs[i]);
}
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($topLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($topRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($middleLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($middleRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasFixedColumns) {
aItemDomRefs = aItemDomRefs.concat($bottomLeft.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
}
aItemDomRefs = aItemDomRefs.concat($bottomRight.find("tr[data-sap-ui-rowindex=\"" + i + "\"]").find("td[tabindex]").get());
if (bHasRowActions) {
aItemDomRefs.push(aRowActionDomRefs[i]);
}
}
// add the column headers and select all
if (oTable.getColumnHeaderVisible()) {
var aHeaderDomRefs = [];
// Returns the .sapUiTableColHdr elements (.sapUiTableColHdrCnt .sapUiTableCtrlFixed .sapUiTableColHdrTr)
var $FixedHeaders = $Table.find(".sapUiTableCHT.sapUiTableCtrlFixed>tbody>tr");
// Returns the .sapUiTableColHdr elements (.sapUiTableColHdrCnt .sapUiTableCtrlScr .sapUiTableColHdrTr)
var $ScrollHeaders = $Table.find(".sapUiTableCHT.sapUiTableCtrlScroll>tbody>tr");
for (var i = 0; i < TableUtils.getHeaderRowCount(oTable); i++) {
if (bHasRowHeader) {
aHeaderDomRefs.push(oTable.getDomRef("selall"));
}
if ($FixedHeaders.length) {
aHeaderDomRefs = aHeaderDomRefs.concat(jQuery($FixedHeaders.get(i)).find(".sapUiTableHeaderCell").get());
}
if ($ScrollHeaders.length) {
aHeaderDomRefs = aHeaderDomRefs.concat(jQuery($ScrollHeaders.get(i)).find(".sapUiTableHeaderCell").get());
}
if (bHasRowActions) {
// Only add a dummy (inivisible inner text) to fullfill matrix for item navigation.
// Header should not be focuable.
aHeaderDomRefs.push($Table.find(".sapUiTableRowActionHeaderCell").children().get(0));
}
}
aItemDomRefs = aHeaderDomRefs.concat(aItemDomRefs);
}
// initialization of item navigation for the Table control
if (!oExtension._itemNavigation) {
oExtension._itemNavigation = new ItemNavigation();
oExtension._itemNavigation.setTableMode(true);
oExtension._itemNavigation.attachEvent(ItemNavigation.Events.AfterFocus, function(oEvent) {
var oInfo = TableUtils.getFocusedItemInfo(oTable);
oInfo.header = TableUtils.getHeaderRowCount(oTable);
oInfo.domRef = null; //Do not keep dom references
if (oInfo.row >= oInfo.header) {
oExtension._oLastFocusedCellInfo = oInfo;
}
}, oTable);
}
// configure the item navigation
oExtension._itemNavigation.setColumns(iTotalColumnCount);
oExtension._itemNavigation.setRootDomRef($Table.find(".sapUiTableCnt").get(0));
oExtension._itemNavigation.setItemDomRefs(aItemDomRefs);
oExtension._itemNavigation.setFocusedIndex(ExtensionHelper.getInitialItemNavigationIndex(oExtension));
// revert invalidation flag
oExtension._itemNavigationInvalidated = false;
} | [
"function",
"(",
"oExtension",
")",
"{",
"var",
"oTable",
"=",
"oExtension",
".",
"getTable",
"(",
")",
";",
"var",
"$Table",
"=",
"oTable",
".",
"$",
"(",
")",
";",
"var",
"iColumnCount",
"=",
"TableUtils",
".",
"getVisibleColumnCount",
"(",
"oTable",
"... | /*
Initialize ItemNavigations (content and header) and transfer relevant dom elements.
TabIndexes are set by the ItemNavigation. | [
"/",
"*",
"Initialize",
"ItemNavigations",
"(",
"content",
"and",
"header",
")",
"and",
"transfer",
"relevant",
"dom",
"elements",
".",
"TabIndexes",
"are",
"set",
"by",
"the",
"ItemNavigation",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableKeyboardExtension.js#L153-L261 | train | Creates the dom refs for the items in the table that are not fixed | [
30522,
3853,
1006,
1051,
10288,
29048,
1007,
1063,
13075,
27178,
3085,
1027,
1051,
10288,
29048,
1012,
2131,
10880,
1006,
1007,
1025,
13075,
1002,
2795,
1027,
27178,
3085,
1012,
1002,
1006,
1007,
1025,
13075,
24582,
4747,
2819,
15305,
16671,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onChangeEmail | function onChangeEmail() {
var email = $('#changed-email').val();
activeUser().updateEmail(email).then(function() {
refreshUserData();
alertSuccess('Email changed!');
}, onAuthError);
} | javascript | function onChangeEmail() {
var email = $('#changed-email').val();
activeUser().updateEmail(email).then(function() {
refreshUserData();
alertSuccess('Email changed!');
}, onAuthError);
} | [
"function",
"onChangeEmail",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#changed-email'",
")",
".",
"val",
"(",
")",
";",
"activeUser",
"(",
")",
".",
"updateEmail",
"(",
"email",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"refreshUserData"... | Changes the user's email. | [
"Changes",
"the",
"user",
"s",
"email",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L601-L607 | train | Change email | [
30522,
3853,
2006,
22305,
21564,
12502,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
2904,
1011,
10373,
1005,
1007,
1012,
11748,
1006,
1007,
1025,
3161,
20330,
1006,
1007,
1012,
10651,
14545,
4014,
1006,
10373,
1007,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc | examples/node/dynamic_codegen/route_guide/route_guide_client.js | runRecordRoute | function runRecordRoute(callback) {
var argv = parseArgs(process.argv, {
string: 'db_path'
});
fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) {
callback(err);
return;
}
var feature_list = JSON.parse(data);
var num_points = 10;
var call = client.recordRoute(function(error, stats) {
if (error) {
callback(error);
return;
}
console.log('Finished trip with', stats.point_count, 'points');
console.log('Passed', stats.feature_count, 'features');
console.log('Travelled', stats.distance, 'meters');
console.log('It took', stats.elapsed_time, 'seconds');
callback();
});
/**
* Constructs a function that asynchronously sends the given point and then
* delays sending its callback
* @param {number} lat The latitude to send
* @param {number} lng The longitude to send
* @return {function(function)} The function that sends the point
*/
function pointSender(lat, lng) {
/**
* Sends the point, then calls the callback after a delay
* @param {function} callback Called when complete
*/
return function(callback) {
console.log('Visiting point ' + lat/COORD_FACTOR + ', ' +
lng/COORD_FACTOR);
call.write({
latitude: lat,
longitude: lng
});
_.delay(callback, _.random(500, 1500));
};
}
var point_senders = [];
for (var i = 0; i < num_points; i++) {
var rand_point = feature_list[_.random(0, feature_list.length - 1)];
point_senders[i] = pointSender(rand_point.location.latitude,
rand_point.location.longitude);
}
async.series(point_senders, function() {
call.end();
});
});
} | javascript | function runRecordRoute(callback) {
var argv = parseArgs(process.argv, {
string: 'db_path'
});
fs.readFile(path.resolve(argv.db_path), function(err, data) {
if (err) {
callback(err);
return;
}
var feature_list = JSON.parse(data);
var num_points = 10;
var call = client.recordRoute(function(error, stats) {
if (error) {
callback(error);
return;
}
console.log('Finished trip with', stats.point_count, 'points');
console.log('Passed', stats.feature_count, 'features');
console.log('Travelled', stats.distance, 'meters');
console.log('It took', stats.elapsed_time, 'seconds');
callback();
});
/**
* Constructs a function that asynchronously sends the given point and then
* delays sending its callback
* @param {number} lat The latitude to send
* @param {number} lng The longitude to send
* @return {function(function)} The function that sends the point
*/
function pointSender(lat, lng) {
/**
* Sends the point, then calls the callback after a delay
* @param {function} callback Called when complete
*/
return function(callback) {
console.log('Visiting point ' + lat/COORD_FACTOR + ', ' +
lng/COORD_FACTOR);
call.write({
latitude: lat,
longitude: lng
});
_.delay(callback, _.random(500, 1500));
};
}
var point_senders = [];
for (var i = 0; i < num_points; i++) {
var rand_point = feature_list[_.random(0, feature_list.length - 1)];
point_senders[i] = pointSender(rand_point.location.latitude,
rand_point.location.longitude);
}
async.series(point_senders, function() {
call.end();
});
});
} | [
"function",
"runRecordRoute",
"(",
"callback",
")",
"{",
"var",
"argv",
"=",
"parseArgs",
"(",
"process",
".",
"argv",
",",
"{",
"string",
":",
"'db_path'",
"}",
")",
";",
"fs",
".",
"readFile",
"(",
"path",
".",
"resolve",
"(",
"argv",
".",
"db_path",... | Run the recordRoute demo. Sends several randomly chosen points from the
pre-generated feature database with a variable delay in between. Prints the
statistics when they are sent from the server.
@param {function} callback Called when this demo is complete | [
"Run",
"the",
"recordRoute",
"demo",
".",
"Sends",
"several",
"randomly",
"chosen",
"points",
"from",
"the",
"pre",
"-",
"generated",
"feature",
"database",
"with",
"a",
"variable",
"delay",
"in",
"between",
".",
"Prints",
"the",
"statistics",
"when",
"they",
... | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/dynamic_codegen/route_guide/route_guide_client.js#L110-L165 | train | Runs the record route | [
30522,
3853,
2448,
2890,
27108,
22196,
10421,
1006,
2655,
5963,
1007,
1063,
13075,
12098,
2290,
2615,
1027,
11968,
17310,
10623,
2015,
1006,
2832,
1012,
12098,
2290,
2615,
1010,
1063,
5164,
1024,
1005,
16962,
1035,
4130,
1005,
1065,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/controllers/controller.bar.js | function(last) {
var me = this;
var chart = me.chart;
var scale = me._getIndexScale();
var stacked = scale.options.stacked;
var ilen = last === undefined ? chart.data.datasets.length : last + 1;
var stacks = [];
var i, meta;
for (i = 0; i < ilen; ++i) {
meta = chart.getDatasetMeta(i);
if (meta.bar && chart.isDatasetVisible(i) &&
(stacked === false ||
(stacked === true && stacks.indexOf(meta.stack) === -1) ||
(stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
stacks.push(meta.stack);
}
}
return stacks;
} | javascript | function(last) {
var me = this;
var chart = me.chart;
var scale = me._getIndexScale();
var stacked = scale.options.stacked;
var ilen = last === undefined ? chart.data.datasets.length : last + 1;
var stacks = [];
var i, meta;
for (i = 0; i < ilen; ++i) {
meta = chart.getDatasetMeta(i);
if (meta.bar && chart.isDatasetVisible(i) &&
(stacked === false ||
(stacked === true && stacks.indexOf(meta.stack) === -1) ||
(stacked === undefined && (meta.stack === undefined || stacks.indexOf(meta.stack) === -1)))) {
stacks.push(meta.stack);
}
}
return stacks;
} | [
"function",
"(",
"last",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"chart",
"=",
"me",
".",
"chart",
";",
"var",
"scale",
"=",
"me",
".",
"_getIndexScale",
"(",
")",
";",
"var",
"stacked",
"=",
"scale",
".",
"options",
".",
"stacked",
";",
... | Returns the stacks based on groups and bar visibility.
@param {number} [last] - The dataset index
@returns {string[]} The list of stack IDs
@private | [
"Returns",
"the",
"stacks",
"based",
"on",
"groups",
"and",
"bar",
"visibility",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/controllers/controller.bar.js#L197-L217 | train | Returns the stack for the last dataset | [
30522,
3853,
1006,
2197,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
3673,
1027,
2033,
1012,
3673,
1025,
13075,
4094,
1027,
2033,
1012,
1035,
2131,
22254,
10288,
15782,
2571,
1006,
1007,
1025,
13075,
16934,
1027,
4094,
1012,
7047,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
if (this._bIsUpdatable != null) {
return this._bIsUpdatable;
}
var oUpdatablePropertyNameSet = this._oQueryResult.getEntitySet().getUpdatablePropertyNameSet();
return (oUpdatablePropertyNameSet[this.getName()] != undefined);
} | javascript | function() {
if (this._bIsUpdatable != null) {
return this._bIsUpdatable;
}
var oUpdatablePropertyNameSet = this._oQueryResult.getEntitySet().getUpdatablePropertyNameSet();
return (oUpdatablePropertyNameSet[this.getName()] != undefined);
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_bIsUpdatable",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"_bIsUpdatable",
";",
"}",
"var",
"oUpdatablePropertyNameSet",
"=",
"this",
".",
"_oQueryResult",
".",
"getEntitySet",
"(",
")",
".",
"getUpd... | Get indicator whether or not the measure is updatable
@returns {boolean} True iff the measure is updatable
@public
@function
@name sap.ui.model.analytics.odata4analytics.Measure#isUpdatable | [
"Get",
"indicator",
"whether",
"or",
"not",
"the",
"measure",
"is",
"updatable"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L2211-L2218 | train | Returns true if the query result is updatable. | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
20377,
6279,
2850,
10880,
999,
1027,
19701,
1007,
1063,
2709,
2023,
1012,
1035,
20377,
6279,
2850,
10880,
1025,
1065,
13075,
15068,
17299,
27892,
21572,
4842,
25680,
14074,
13462,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/Exact.js | function(oThis, oEvent){
oThis.fireRefineSearch({
query: oThis._sSearchQuery,
changedAttribute: oEvent.getParameter("attribute"),
allSelectedAttributes: oEvent.getParameter("allAttributes")
});
} | javascript | function(oThis, oEvent){
oThis.fireRefineSearch({
query: oThis._sSearchQuery,
changedAttribute: oEvent.getParameter("attribute"),
allSelectedAttributes: oEvent.getParameter("allAttributes")
});
} | [
"function",
"(",
"oThis",
",",
"oEvent",
")",
"{",
"oThis",
".",
"fireRefineSearch",
"(",
"{",
"query",
":",
"oThis",
".",
"_sSearchQuery",
",",
"changedAttribute",
":",
"oEvent",
".",
"getParameter",
"(",
"\"attribute\"",
")",
",",
"allSelectedAttributes",
":... | Handles attribute selections | [
"Handles",
"attribute",
"selections"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/Exact.js#L229-L235 | train | Fires the refine search event | [
30522,
3853,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1007,
1063,
27178,
24158,
1012,
2543,
2890,
23460,
17310,
11140,
1006,
1063,
23032,
1024,
27178,
24158,
1012,
1035,
7020,
14644,
2818,
4226,
2854,
1010,
2904,
19321,
3089,
8569,
2618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ccxt/ccxt | build/transpile.js | replaceInFile | function replaceInFile (filename, regex, replacement) {
let contents = fs.readFileSync (filename, 'utf8')
const parts = contents.split (regex)
const newContents = parts[0] + replacement + parts[1]
fs.truncateSync (filename)
fs.writeFileSync (filename, newContents)
} | javascript | function replaceInFile (filename, regex, replacement) {
let contents = fs.readFileSync (filename, 'utf8')
const parts = contents.split (regex)
const newContents = parts[0] + replacement + parts[1]
fs.truncateSync (filename)
fs.writeFileSync (filename, newContents)
} | [
"function",
"replaceInFile",
"(",
"filename",
",",
"regex",
",",
"replacement",
")",
"{",
"let",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
",",
"'utf8'",
")",
"const",
"parts",
"=",
"contents",
".",
"split",
"(",
"regex",
")",
"const",
... | --------------------------------------------------------------------------- | [
"---------------------------------------------------------------------------"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/build/transpile.js#L23-L29 | train | Replace a string in a file | [
30522,
3853,
5672,
2378,
8873,
2571,
1006,
5371,
18442,
1010,
19723,
10288,
1010,
6110,
1007,
1063,
2292,
8417,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
5371,
18442,
1010,
1005,
21183,
2546,
2620,
1005,
1007,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function (sHierarchyDimensionName, bIncludeExternalKey,
bIncludeText) {
var oDimension;
if (!sHierarchyDimensionName) {
return;
}
// sHierarchyDimensionName is the name of a dimension property (and not e.g. of a
// dimension's text property), findDimensionByName can be used instead of
// findDimensionByPropertyName
oDimension = this._oQueryResult.findDimensionByName(sHierarchyDimensionName);
if (!oDimension) {
throw new Error("'" + sHierarchyDimensionName + "' is not a dimension property");
}
if (!oDimension.getHierarchy()) {
throw new Error("Dimension '" + sHierarchyDimensionName
+ "' does not have a hierarchy");
}
// reset previously compiled list of selected properties
this._oSelectedPropertyNames = null;
this._oDimensionHierarchies[sHierarchyDimensionName] = {
externalKey : bIncludeExternalKey,
id: true,
text : bIncludeText
};
} | javascript | function (sHierarchyDimensionName, bIncludeExternalKey,
bIncludeText) {
var oDimension;
if (!sHierarchyDimensionName) {
return;
}
// sHierarchyDimensionName is the name of a dimension property (and not e.g. of a
// dimension's text property), findDimensionByName can be used instead of
// findDimensionByPropertyName
oDimension = this._oQueryResult.findDimensionByName(sHierarchyDimensionName);
if (!oDimension) {
throw new Error("'" + sHierarchyDimensionName + "' is not a dimension property");
}
if (!oDimension.getHierarchy()) {
throw new Error("Dimension '" + sHierarchyDimensionName
+ "' does not have a hierarchy");
}
// reset previously compiled list of selected properties
this._oSelectedPropertyNames = null;
this._oDimensionHierarchies[sHierarchyDimensionName] = {
externalKey : bIncludeExternalKey,
id: true,
text : bIncludeText
};
} | [
"function",
"(",
"sHierarchyDimensionName",
",",
"bIncludeExternalKey",
",",
"bIncludeText",
")",
"{",
"var",
"oDimension",
";",
"if",
"(",
"!",
"sHierarchyDimensionName",
")",
"{",
"return",
";",
"}",
"// sHierarchyDimensionName is the name of a dimension property (and not... | Adds a recursive hierarchy to the aggregation level.
@param {string} sHierarchyDimensionName
Name of dimension whose hierarchy shall be part of the aggregation level
@param {boolean} bIncludeExternalKey
Indicator whether or not to include the external node key (if available) in the query
result
@param {boolean} bIncludeText
Indicator whether or not to include the node text (if available) in the query result
@throws {Error}
If the given name is not a name of a dimension or the corresponding dimension does not
have a hierarchy.
@public
@function
@name sap.ui.model.analytics.odata4analytics.QueryResultRequest#addRecursiveHierarchy | [
"Adds",
"a",
"recursive",
"hierarchy",
"to",
"the",
"aggregation",
"level",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L4065-L4091 | train | Sets the hierarchy of the given dimension | [
30522,
3853,
1006,
11895,
6906,
29389,
22172,
6132,
3258,
18442,
1010,
8026,
20464,
12672,
10288,
16451,
2389,
14839,
1010,
8026,
20464,
12672,
18209,
1007,
1063,
13075,
21045,
3549,
10992,
1025,
2065,
1006,
999,
11895,
6906,
30524,
1998,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/operator-linebreak.js | validateNode | function validateNode(node, leftSide) {
/*
* When the left part of a binary expression is a single expression wrapped in
* parentheses (ex: `(a) + b`), leftToken will be the last token of the expression
* and operatorToken will be the closing parenthesis.
* The leftToken should be the last closing parenthesis, and the operatorToken
* should be the token right after that.
*/
const operatorToken = sourceCode.getTokenAfter(leftSide, astUtils.isNotClosingParenToken);
const leftToken = sourceCode.getTokenBefore(operatorToken);
const rightToken = sourceCode.getTokenAfter(operatorToken);
const operator = operatorToken.value;
const operatorStyleOverride = styleOverrides[operator];
const style = operatorStyleOverride || globalStyle;
const fix = getFixer(operatorToken, style);
// if single line
if (astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
// do nothing.
} else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
!astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
// lone operator
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "Bad line breaking before and after '{{operator}}'.",
data: {
operator
},
fix
});
} else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "'{{operator}}' should be placed at the beginning of the line.",
data: {
operator
},
fix
});
} else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "'{{operator}}' should be placed at the end of the line.",
data: {
operator
},
fix
});
} else if (style === "none") {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "There should be no line break before or after '{{operator}}'.",
data: {
operator
},
fix
});
}
} | javascript | function validateNode(node, leftSide) {
/*
* When the left part of a binary expression is a single expression wrapped in
* parentheses (ex: `(a) + b`), leftToken will be the last token of the expression
* and operatorToken will be the closing parenthesis.
* The leftToken should be the last closing parenthesis, and the operatorToken
* should be the token right after that.
*/
const operatorToken = sourceCode.getTokenAfter(leftSide, astUtils.isNotClosingParenToken);
const leftToken = sourceCode.getTokenBefore(operatorToken);
const rightToken = sourceCode.getTokenAfter(operatorToken);
const operator = operatorToken.value;
const operatorStyleOverride = styleOverrides[operator];
const style = operatorStyleOverride || globalStyle;
const fix = getFixer(operatorToken, style);
// if single line
if (astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
// do nothing.
} else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) &&
!astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
// lone operator
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "Bad line breaking before and after '{{operator}}'.",
data: {
operator
},
fix
});
} else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "'{{operator}}' should be placed at the beginning of the line.",
data: {
operator
},
fix
});
} else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "'{{operator}}' should be placed at the end of the line.",
data: {
operator
},
fix
});
} else if (style === "none") {
context.report({
node,
loc: {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
},
message: "There should be no line break before or after '{{operator}}'.",
data: {
operator
},
fix
});
}
} | [
"function",
"validateNode",
"(",
"node",
",",
"leftSide",
")",
"{",
"/*\n * When the left part of a binary expression is a single expression wrapped in\n * parentheses (ex: `(a) + b`), leftToken will be the last token of the expression\n * and operatorToken will b... | Checks the operator placement
@param {ASTNode} node The node to check
@param {ASTNode} leftSide The node that comes before the operator in `node`
@private
@returns {void} | [
"Checks",
"the",
"operator",
"placement"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/operator-linebreak.js#L139-L225 | train | Validate a binary expression node. | [
30522,
3853,
9398,
3686,
3630,
3207,
1006,
13045,
1010,
2187,
7363,
1007,
1063,
1013,
1008,
1008,
2043,
1996,
2187,
2112,
1997,
1037,
12441,
3670,
2003,
1037,
2309,
3670,
5058,
1999,
1008,
27393,
1006,
4654,
1024,
1036,
1006,
1037,
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.m/src/sap/m/GrowingEnablement.js | function(oContext, oBindingInfo, bSuppressInvalidate) {
var oControl = this._oControl,
oBinding = oBindingInfo.binding,
oItem = this.createListItem(oContext, oBindingInfo);
if (oBinding.isGrouped()) {
// creates group header if need
var aItems = oControl.getItems(true),
oLastItem = aItems[aItems.length - 1],
sModelName = oBindingInfo.model,
oGroupInfo = oBinding.getGroup(oItem.getBindingContext(sModelName));
if (oLastItem && oLastItem.isGroupHeader()) {
oControl.removeAggregation("items", oLastItem, true);
this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oLastItem, bSuppressInvalidate);
oLastItem = aItems[aItems.length - 1];
}
if (!oLastItem || oGroupInfo.key !== oBinding.getGroup(oLastItem.getBindingContext(sModelName)).key) {
var oGroupHeader = (oBindingInfo.groupHeaderFactory) ? oBindingInfo.groupHeaderFactory(oGroupInfo) : null;
if (oControl.getGrowingDirection() == ListGrowingDirection.Upwards) {
this.applyPendingGroupItem();
this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oGroupHeader, bSuppressInvalidate);
} else {
this.appendGroupItem(oGroupInfo, oGroupHeader, bSuppressInvalidate);
}
}
}
oControl.addAggregation("items", oItem, bSuppressInvalidate);
if (bSuppressInvalidate) {
this._aChunk.push(oItem);
}
} | javascript | function(oContext, oBindingInfo, bSuppressInvalidate) {
var oControl = this._oControl,
oBinding = oBindingInfo.binding,
oItem = this.createListItem(oContext, oBindingInfo);
if (oBinding.isGrouped()) {
// creates group header if need
var aItems = oControl.getItems(true),
oLastItem = aItems[aItems.length - 1],
sModelName = oBindingInfo.model,
oGroupInfo = oBinding.getGroup(oItem.getBindingContext(sModelName));
if (oLastItem && oLastItem.isGroupHeader()) {
oControl.removeAggregation("items", oLastItem, true);
this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oLastItem, bSuppressInvalidate);
oLastItem = aItems[aItems.length - 1];
}
if (!oLastItem || oGroupInfo.key !== oBinding.getGroup(oLastItem.getBindingContext(sModelName)).key) {
var oGroupHeader = (oBindingInfo.groupHeaderFactory) ? oBindingInfo.groupHeaderFactory(oGroupInfo) : null;
if (oControl.getGrowingDirection() == ListGrowingDirection.Upwards) {
this.applyPendingGroupItem();
this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oGroupHeader, bSuppressInvalidate);
} else {
this.appendGroupItem(oGroupInfo, oGroupHeader, bSuppressInvalidate);
}
}
}
oControl.addAggregation("items", oItem, bSuppressInvalidate);
if (bSuppressInvalidate) {
this._aChunk.push(oItem);
}
} | [
"function",
"(",
"oContext",
",",
"oBindingInfo",
",",
"bSuppressInvalidate",
")",
"{",
"var",
"oControl",
"=",
"this",
".",
"_oControl",
",",
"oBinding",
"=",
"oBindingInfo",
".",
"binding",
",",
"oItem",
"=",
"this",
".",
"createListItem",
"(",
"oContext",
... | appends single list item to the list | [
"appends",
"single",
"list",
"item",
"to",
"the",
"list"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/GrowingEnablement.js#L310-L344 | train | Creates an item in the list. | [
30522,
3853,
1006,
1051,
8663,
18209,
1010,
27885,
22254,
2075,
2378,
14876,
1010,
18667,
6279,
20110,
2378,
10175,
8524,
2618,
1007,
1063,
13075,
1051,
8663,
13181,
2140,
1027,
2023,
1012,
1035,
1051,
8663,
13181,
2140,
1010,
27885,
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... | |
fex-team/webuploader | build/tasks/concat.js | filesFilter | function filesFilter( f, files ) {
var cwd = f.cwd || '',
ret = [],
process = function( file ) {
var fileinfo = path.join( cwd, file ),
dirpath = path.dirname( fileinfo ),
depends = [],
str, matches, idx;
if ( !grunt.file.exists( fileinfo ) ) {
return;
}
ret.push( file );
str = grunt.file.read( fileinfo );
// 从require( dps )中找
// 从defind( id?, dps, factory )中找
str = str.replace( /(?:define|require)\s*\(\s*\[([^\]]+?)\],/g, function( _, m1 ) {
m1 = m1.replace(/\s/g, '').split(',');
depends = depends.concat( m1.map(function( item ) {
item = item.substring( 1, item.length - 1 );
item = item.substring(0, 1) === '.' ?
path.join( dirpath, item ):
path.join( cwd, item );
return path.relative( cwd, item ) + '.js';
}) );
return _;
});
str = str.replace( /require\s*\(\s*('|")(.+?)\1/g, function( _, m1, item ) {
item = item.substring(0, 1) === '.' ?
path.join( dirpath, item ):
path.join( cwd, item );
depends.push( path.relative( cwd, item ) + '.js' );
return _;
});
if ( depends.length ) {
depends = depends.filter(function( item, idx, array ) {
return array.indexOf( item ) === idx && grunt.file.exists( path.join( cwd, item ) );
});
idx = ret.indexOf( file );
[].splice.apply( ret, [ idx, 0 ].concat( depends ) );
depends.forEach( process );
}
};
// console.log( files );
files.forEach( process );
ret = ret.filter(function( item, idx, arr ){
return idx === arr.indexOf( item );
});
ret.unshift( path.relative( cwd, intro ) );
ret.push( path.relative( cwd, outro ) );
return ret;
} | javascript | function filesFilter( f, files ) {
var cwd = f.cwd || '',
ret = [],
process = function( file ) {
var fileinfo = path.join( cwd, file ),
dirpath = path.dirname( fileinfo ),
depends = [],
str, matches, idx;
if ( !grunt.file.exists( fileinfo ) ) {
return;
}
ret.push( file );
str = grunt.file.read( fileinfo );
// 从require( dps )中找
// 从defind( id?, dps, factory )中找
str = str.replace( /(?:define|require)\s*\(\s*\[([^\]]+?)\],/g, function( _, m1 ) {
m1 = m1.replace(/\s/g, '').split(',');
depends = depends.concat( m1.map(function( item ) {
item = item.substring( 1, item.length - 1 );
item = item.substring(0, 1) === '.' ?
path.join( dirpath, item ):
path.join( cwd, item );
return path.relative( cwd, item ) + '.js';
}) );
return _;
});
str = str.replace( /require\s*\(\s*('|")(.+?)\1/g, function( _, m1, item ) {
item = item.substring(0, 1) === '.' ?
path.join( dirpath, item ):
path.join( cwd, item );
depends.push( path.relative( cwd, item ) + '.js' );
return _;
});
if ( depends.length ) {
depends = depends.filter(function( item, idx, array ) {
return array.indexOf( item ) === idx && grunt.file.exists( path.join( cwd, item ) );
});
idx = ret.indexOf( file );
[].splice.apply( ret, [ idx, 0 ].concat( depends ) );
depends.forEach( process );
}
};
// console.log( files );
files.forEach( process );
ret = ret.filter(function( item, idx, arr ){
return idx === arr.indexOf( item );
});
ret.unshift( path.relative( cwd, intro ) );
ret.push( path.relative( cwd, outro ) );
return ret;
} | [
"function",
"filesFilter",
"(",
"f",
",",
"files",
")",
"{",
"var",
"cwd",
"=",
"f",
".",
"cwd",
"||",
"''",
",",
"ret",
"=",
"[",
"]",
",",
"process",
"=",
"function",
"(",
"file",
")",
"{",
"var",
"fileinfo",
"=",
"path",
".",
"join",
"(",
"c... | 排序,把依赖的文件移动到最上面。 | [
"排序,把依赖的文件移动到最上面。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/build/tasks/concat.js#L38-L103 | train | filter files | [
30522,
3853,
6764,
8873,
21928,
1006,
1042,
1010,
6764,
1007,
1063,
13075,
19296,
2094,
1027,
1042,
1012,
19296,
2094,
1064,
1064,
1005,
1005,
1010,
2128,
2102,
1027,
1031,
1033,
1010,
2832,
1027,
3853,
1006,
5371,
1007,
1063,
13075,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/ProjectManager.js | _watchProjectRoot | function _watchProjectRoot(rootPath) {
FileSystem.on("change", _fileSystemChange);
FileSystem.on("rename", _fileSystemRename);
FileSystem.watch(FileSystem.getDirectoryForPath(rootPath), ProjectModel._shouldShowName, ProjectModel.defaultIgnoreGlobs, function (err) {
if (err === FileSystemError.TOO_MANY_ENTRIES) {
if (!_projectWarnedForTooManyFiles) {
_showErrorDialog(ERR_TYPE_MAX_FILES);
_projectWarnedForTooManyFiles = true;
}
} else if (err) {
console.error("Error watching project root: ", rootPath, err);
}
});
// Reset allFiles cache
model._resetCache();
} | javascript | function _watchProjectRoot(rootPath) {
FileSystem.on("change", _fileSystemChange);
FileSystem.on("rename", _fileSystemRename);
FileSystem.watch(FileSystem.getDirectoryForPath(rootPath), ProjectModel._shouldShowName, ProjectModel.defaultIgnoreGlobs, function (err) {
if (err === FileSystemError.TOO_MANY_ENTRIES) {
if (!_projectWarnedForTooManyFiles) {
_showErrorDialog(ERR_TYPE_MAX_FILES);
_projectWarnedForTooManyFiles = true;
}
} else if (err) {
console.error("Error watching project root: ", rootPath, err);
}
});
// Reset allFiles cache
model._resetCache();
} | [
"function",
"_watchProjectRoot",
"(",
"rootPath",
")",
"{",
"FileSystem",
".",
"on",
"(",
"\"change\"",
",",
"_fileSystemChange",
")",
";",
"FileSystem",
".",
"on",
"(",
"\"rename\"",
",",
"_fileSystemRename",
")",
";",
"FileSystem",
".",
"watch",
"(",
"FileSy... | @private
Watches the project for filesystem changes so that the tree can be updated. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L789-L806 | train | Watch project root | [
30522,
3853,
1035,
3422,
21572,
20614,
3217,
4140,
1006,
7117,
15069,
1007,
1063,
6764,
27268,
6633,
1012,
2006,
1006,
1000,
2689,
1000,
1010,
1035,
6764,
27268,
6633,
22305,
2063,
1007,
1025,
6764,
27268,
6633,
1012,
2006,
1006,
1000,
1491... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js | disableTextSelectAndDrag | function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) {
// Disable text selection.
document.onselectstart = function(e) {
if (!(opt_allowSelectStart && opt_allowSelectStart.call(this, e)))
e.preventDefault();
};
// Disable dragging.
document.ondragstart = function(e) {
if (!(opt_allowDragStart && opt_allowDragStart.call(this, e)))
e.preventDefault();
};
} | javascript | function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) {
// Disable text selection.
document.onselectstart = function(e) {
if (!(opt_allowSelectStart && opt_allowSelectStart.call(this, e)))
e.preventDefault();
};
// Disable dragging.
document.ondragstart = function(e) {
if (!(opt_allowDragStart && opt_allowDragStart.call(this, e)))
e.preventDefault();
};
} | [
"function",
"disableTextSelectAndDrag",
"(",
"opt_allowSelectStart",
",",
"opt_allowDragStart",
")",
"{",
"// Disable text selection.",
"document",
".",
"onselectstart",
"=",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"(",
"opt_allowSelectStart",
"&&",
"opt_allow... | Disables text selection and dragging, with optional whitelist callbacks.
@param {function(Event):boolean=} opt_allowSelectStart Unless this function
is defined and returns true, the onselectionstart event will be
surpressed.
@param {function(Event):boolean=} opt_allowDragStart Unless this function
is defined and returns true, the ondragstart event will be surpressed. | [
"Disables",
"text",
"selection",
"and",
"dragging",
"with",
"optional",
"whitelist",
"callbacks",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js#L148-L160 | train | Disable text selection and dragging | [
30522,
3853,
4487,
19150,
18209,
11246,
22471,
5685,
7265,
2290,
1006,
23569,
1035,
4473,
12260,
16649,
7559,
2102,
1010,
23569,
1035,
3499,
7265,
5620,
7559,
2102,
1007,
1063,
1013,
1013,
4487,
19150,
3793,
4989,
1012,
6254,
1012,
2006,
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... |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | wordCount | function wordCount(data) {
var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var m = data.match(pattern);
var count = 0;
if(m === null) return count;
for(var i = 0; i < m.length; i++) {
if(m[i].charCodeAt(0) >= 0x4E00) {
count += m[i].length;
} else {
count += 1;
}
}
return count;
} | javascript | function wordCount(data) {
var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var m = data.match(pattern);
var count = 0;
if(m === null) return count;
for(var i = 0; i < m.length; i++) {
if(m[i].charCodeAt(0) >= 0x4E00) {
count += m[i].length;
} else {
count += 1;
}
}
return count;
} | [
"function",
"wordCount",
"(",
"data",
")",
"{",
"var",
"pattern",
"=",
"/",
"[a-zA-Z0-9_\\u0392-\\u03c9\\u0410-\\u04F9]+|[\\u4E00-\\u9FFF\\u3400-\\u4dbf\\uf900-\\ufaff\\u3040-\\u309f\\uac00-\\ud7af]+",
"/",
"g",
";",
"var",
"m",
"=",
"data",
".",
"match",
"(",
"pattern",
... | /* The right word count in respect for CJK. | [
"/",
"*",
"The",
"right",
"word",
"count",
"in",
"respect",
"for",
"CJK",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L1054-L1067 | train | Count the number of words in the given string | [
30522,
3853,
2773,
3597,
16671,
1006,
2951,
1007,
1063,
13075,
5418,
1027,
1013,
1031,
1037,
1011,
23564,
1011,
1062,
2692,
1011,
1023,
1035,
1032,
1057,
2692,
23499,
2475,
1011,
1032,
1057,
2692,
2509,
2278,
2683,
1032,
1057,
2692,
23632,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | verifyForAlways | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
let prevToken = getActualLastToken(sourceCode, prevNode);
const nextToken = sourceCode.getFirstTokenBetween(
prevToken,
nextNode,
{
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is not a trailing comment.
* @private
*/
filter(token) {
if (astUtils.isTokenOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}
return true;
}
}
) || nextNode;
const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken)
? "\n\n"
: "\n";
return fixer.insertTextAfter(prevToken, insertText);
}
});
} | javascript | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
let prevToken = getActualLastToken(sourceCode, prevNode);
const nextToken = sourceCode.getFirstTokenBetween(
prevToken,
nextNode,
{
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is not a trailing comment.
* @private
*/
filter(token) {
if (astUtils.isTokenOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}
return true;
}
}
) || nextNode;
const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken)
? "\n\n"
: "\n";
return fixer.insertTextAfter(prevToken, insertText);
}
});
} | [
"function",
"verifyForAlways",
"(",
"context",
",",
"prevNode",
",",
"nextNode",
",",
"paddingLines",
")",
"{",
"if",
"(",
"paddingLines",
".",
"length",
">",
"0",
")",
"{",
"return",
";",
"}",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nextNode",... | Check and report statements for `always` configuration.
This autofix inserts a blank line between the given 2 statements.
If the `prevNode` has trailing comments, it inserts a blank line after the
trailing comments.
@param {RuleContext} context The rule context to report.
@param {ASTNode} prevNode 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",
"always",
"configuration",
".",
"This",
"autofix",
"inserts",
"a",
"blank",
"line",
"between",
"the",
"given",
"2",
"statements",
".",
"If",
"the",
"prevNode",
"has",
"trailing",
"comments",
"it",
"inserts",
"a",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L288-L342 | train | Verifies that the next node is always. | [
30522,
3853,
20410,
29278,
2389,
14035,
1006,
6123,
1010,
3653,
16022,
10244,
1010,
2279,
3630,
3207,
1010,
11687,
4667,
12735,
1007,
1063,
2065,
1006,
11687,
4667,
12735,
1012,
3091,
1028,
1014,
1007,
1063,
2709,
1025,
1065,
6123,
1012,
31... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/ui5loader.js | Module | function Module(name) {
this.name = name;
this.state = INITIAL;
/*
* Whether processing of the module is complete.
* This is very similar to, but not the same as state >= READY because declareModule() sets state=READY very early.
* That state transition is 'legacy' from the library-all files; it needs to checked whether it can be removed.
*/
this.settled = false;
this.url =
this._deferred =
this.data =
this.group =
this.error =
this.pending = null;
this.content = NOT_YET_DETERMINED;
} | javascript | function Module(name) {
this.name = name;
this.state = INITIAL;
/*
* Whether processing of the module is complete.
* This is very similar to, but not the same as state >= READY because declareModule() sets state=READY very early.
* That state transition is 'legacy' from the library-all files; it needs to checked whether it can be removed.
*/
this.settled = false;
this.url =
this._deferred =
this.data =
this.group =
this.error =
this.pending = null;
this.content = NOT_YET_DETERMINED;
} | [
"function",
"Module",
"(",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"state",
"=",
"INITIAL",
";",
"/*\n\t\t * Whether processing of the module is complete.\n\t\t * This is very similar to, but not the same as state >= READY because declareModule() set... | A module/resource as managed by the module system.
Each module is an object with the following properties
<ul>
<li>{int} state one of the module states defined in this function</li>
<li>{string} url URL where the module has been loaded from</li>
<li>{any} data temp. raw content of the module (between loaded and ready or when preloaded)</li>
<li>{string} group the bundle with which a resource was loaded or null</li>
<li>{string} error an error description for state <code>FAILED</code></li>
<li>{any} content the content of the module as exported via define()<(li>
</ul>
@param {string} name Name of the module, including extension | [
"A",
"module",
"/",
"resource",
"as",
"managed",
"by",
"the",
"module",
"system",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L738-L754 | train | The module object | [
30522,
3853,
11336,
1006,
2171,
1007,
1063,
2023,
1012,
2171,
1027,
2171,
1025,
2023,
1012,
2110,
1027,
3988,
1025,
1013,
1008,
1008,
3251,
6364,
1997,
1996,
11336,
2003,
3143,
1012,
1008,
2023,
2003,
2200,
2714,
2000,
1010,
2021,
2025,
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... |
PrismJS/prism | plugins/line-numbers/prism-line-numbers.js | function (element) {
if (!element) {
return null;
}
return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null);
} | javascript | function (element) {
if (!element) {
return null;
}
return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null);
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
")",
"{",
"return",
"null",
";",
"}",
"return",
"window",
".",
"getComputedStyle",
"?",
"getComputedStyle",
"(",
"element",
")",
":",
"(",
"element",
".",
"currentStyle",
"||",
"null",
")",... | Returns style declarations for the element
@param {Element} element | [
"Returns",
"style",
"declarations",
"for",
"the",
"element"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/line-numbers/prism-line-numbers.js#L57-L63 | train | Returns the current style of an element | [
30522,
3853,
1006,
5783,
1007,
1063,
2065,
1006,
999,
5783,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
3332,
1012,
2131,
9006,
29462,
21756,
2571,
1029,
2131,
9006,
29462,
21756,
2571,
1006,
5783,
1007,
1024,
1006,
5783,
1012,
14731,
27983,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | performCleanup | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | javascript | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | [
"function",
"performCleanup",
"(",
"requester",
",",
"filesToCache",
",",
"notifyBack",
")",
"{",
"var",
"currentRequester",
"=",
"requester",
"||",
"\"\"",
";",
"function",
"filterFilesAndNotify",
"(",
"files",
",",
"filesToCacheArr",
",",
"notifyBackToBrackets",
"... | Performs clean up for the contents in Update Directory in AppData
@param {Array} filesToCache - array of file types to cache
@param {boolean} notifyBack - true if Brackets needs to be
notified post cleanup, false otherwise | [
"Performs",
"clean",
"up",
"for",
"the",
"contents",
"in",
"Update",
"Directory",
"in",
"AppData"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L332-L382 | train | This function is called by the cleanup process to clean up the update directory | [
30522,
3853,
4685,
14321,
24076,
2361,
1006,
5227,
2121,
1010,
6764,
3406,
3540,
5403,
1010,
2025,
8757,
5963,
1007,
1063,
13075,
2783,
2890,
15500,
2121,
1027,
5227,
2121,
1064,
1064,
1000,
1000,
1025,
3853,
11307,
8873,
4244,
5685,
17048,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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({
"message0": Blockly.Msg.EVENT_WHENGREATERTHAN,
"args0": [
{
"type": "field_dropdown",
"name": "WHENGREATERTHANMENU",
"options": [
[Blockly.Msg.EVENT_WHENGREATERTHAN_LOUDNESS, 'LOUDNESS'],
[Blockly.Msg.EVENT_WHENGREATERTHAN_TIMER, 'TIMER']
]
},
{
"type": "input_value",
"name": "VALUE"
}
],
"category": Blockly.Categories.event,
"extensions": ["colours_event", "shape_hat"]
});
} | javascript | function() {
this.jsonInit({
"message0": Blockly.Msg.EVENT_WHENGREATERTHAN,
"args0": [
{
"type": "field_dropdown",
"name": "WHENGREATERTHANMENU",
"options": [
[Blockly.Msg.EVENT_WHENGREATERTHAN_LOUDNESS, 'LOUDNESS'],
[Blockly.Msg.EVENT_WHENGREATERTHAN_TIMER, 'TIMER']
]
},
{
"type": "input_value",
"name": "VALUE"
}
],
"category": Blockly.Categories.event,
"extensions": ["colours_event", "shape_hat"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"Blockly",
".",
"Msg",
".",
"EVENT_WHENGREATERTHAN",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"WHENGREATERTHANMENU\"",
","... | Block for when loudness/timer/video motion is greater than the value.
@this Blockly.Block | [
"Block",
"for",
"when",
"loudness",
"/",
"timer",
"/",
"video",
"motion",
"is",
"greater",
"than",
"the",
"value",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L177-L197 | train | Block for whomerening between two terms. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
3796,
2135,
1012,
5796,
2290,
1012,
2724,
1035,
2043,
17603,
24932,
21604,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js | function () {
var tempRules = [],
rawLSData;
try {
rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
if (!rawLSData) {
return null;
}
tempRules = JSON.parse(decode(rawLSData));
tempRules = tempRules.map(function (tempRule) {
return RuleSerializer.deserialize(tempRule, true);
});
} catch (oError) {
// Swallow "Access Denied" exceptions in cross-origin scenarios.
}
return tempRules;
} | javascript | function () {
var tempRules = [],
rawLSData;
try {
rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
if (!rawLSData) {
return null;
}
tempRules = JSON.parse(decode(rawLSData));
tempRules = tempRules.map(function (tempRule) {
return RuleSerializer.deserialize(tempRule, true);
});
} catch (oError) {
// Swallow "Access Denied" exceptions in cross-origin scenarios.
}
return tempRules;
} | [
"function",
"(",
")",
"{",
"var",
"tempRules",
"=",
"[",
"]",
",",
"rawLSData",
";",
"try",
"{",
"rawLSData",
"=",
"localStorage",
".",
"getItem",
"(",
"constants",
".",
"LOCAL_STORAGE_TEMP_RULES_KEY",
")",
";",
"if",
"(",
"!",
"rawLSData",
")",
"{",
"re... | Returns all previously created temporary rules.
@private
@name sap.ui.support.Storage.getRules
@method
@returns {object[]} An array containing all the temporary rules. | [
"Returns",
"all",
"previously",
"created",
"temporary",
"rules",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js#L69-L90 | train | Returns the list of temp rules | [
30522,
3853,
1006,
1007,
1063,
13075,
8915,
8737,
6820,
4244,
1027,
1031,
1033,
1010,
6315,
4877,
2850,
2696,
1025,
3046,
1063,
6315,
4877,
2850,
2696,
1027,
10575,
4263,
4270,
1012,
2131,
4221,
2213,
1006,
5377,
2015,
1012,
2334,
1035,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/Agents/DOMAgent.js | _mapDocumentToSource | function _mapDocumentToSource(source) {
var node = exports.root;
DOMHelpers.eachNode(source, function each(payload) {
if (!node) {
return true;
}
if (payload.closing) {
var parent = node.findParentForNextNodeMatchingPayload(payload);
if (!parent) {
return console.warn("Matching Parent not at " + payload.sourceOffset + " (" + payload.nodeName + ")");
}
parent.closeLocation = payload.sourceOffset;
parent.closeLength = payload.sourceLength;
} else {
var next = node.findNextNodeMatchingPayload(payload);
if (!next) {
return console.warn("Skipping Source Node at " + payload.sourceOffset);
}
node = next;
node.location = payload.sourceOffset;
node.length = payload.sourceLength;
if (payload.closed) {
node.closed = payload.closed;
}
}
});
} | javascript | function _mapDocumentToSource(source) {
var node = exports.root;
DOMHelpers.eachNode(source, function each(payload) {
if (!node) {
return true;
}
if (payload.closing) {
var parent = node.findParentForNextNodeMatchingPayload(payload);
if (!parent) {
return console.warn("Matching Parent not at " + payload.sourceOffset + " (" + payload.nodeName + ")");
}
parent.closeLocation = payload.sourceOffset;
parent.closeLength = payload.sourceLength;
} else {
var next = node.findNextNodeMatchingPayload(payload);
if (!next) {
return console.warn("Skipping Source Node at " + payload.sourceOffset);
}
node = next;
node.location = payload.sourceOffset;
node.length = payload.sourceLength;
if (payload.closed) {
node.closed = payload.closed;
}
}
});
} | [
"function",
"_mapDocumentToSource",
"(",
"source",
")",
"{",
"var",
"node",
"=",
"exports",
".",
"root",
";",
"DOMHelpers",
".",
"eachNode",
"(",
"source",
",",
"function",
"each",
"(",
"payload",
")",
"{",
"if",
"(",
"!",
"node",
")",
"{",
"return",
"... | Map the DOM document to the source text
@param {string} source | [
"Map",
"the",
"DOM",
"document",
"to",
"the",
"source",
"text"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L134-L160 | train | map document to source | [
30522,
3853,
1035,
4949,
3527,
24894,
4765,
13122,
8162,
3401,
1006,
3120,
1007,
1063,
13075,
13045,
1027,
14338,
1012,
7117,
1025,
14383,
16001,
7347,
1012,
2169,
3630,
3207,
1006,
3120,
1010,
3853,
2169,
1006,
18093,
1007,
1063,
2065,
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... |
ecomfe/zrender | src/svg/graphic.js | pathDataToString | function pathDataToString(path) {
var str = [];
var data = path.data;
var dataLength = path.len();
for (var i = 0; i < dataLength;) {
var cmd = data[i++];
var cmdStr = '';
var nData = 0;
switch (cmd) {
case CMD.M:
cmdStr = 'M';
nData = 2;
break;
case CMD.L:
cmdStr = 'L';
nData = 2;
break;
case CMD.Q:
cmdStr = 'Q';
nData = 4;
break;
case CMD.C:
cmdStr = 'C';
nData = 6;
break;
case CMD.A:
var cx = data[i++];
var cy = data[i++];
var rx = data[i++];
var ry = data[i++];
var theta = data[i++];
var dTheta = data[i++];
var psi = data[i++];
var clockwise = data[i++];
var dThetaPositive = Math.abs(dTheta);
var isCircle = isAroundZero(dThetaPositive - PI2)
&& !isAroundZero(dThetaPositive);
var large = false;
if (dThetaPositive >= PI2) {
large = true;
}
else if (isAroundZero(dThetaPositive)) {
large = false;
}
else {
large = (dTheta > -PI && dTheta < 0 || dTheta > PI)
=== !!clockwise;
}
var x0 = round4(cx + rx * mathCos(theta));
var y0 = round4(cy + ry * mathSin(theta));
// It will not draw if start point and end point are exactly the same
// We need to shift the end point with a small value
// FIXME A better way to draw circle ?
if (isCircle) {
if (clockwise) {
dTheta = PI2 - 1e-4;
}
else {
dTheta = -PI2 + 1e-4;
}
large = true;
if (i === 9) {
// Move to (x0, y0) only when CMD.A comes at the
// first position of a shape.
// For instance, when drawing a ring, CMD.A comes
// after CMD.M, so it's unnecessary to move to
// (x0, y0).
str.push('M', x0, y0);
}
}
var x = round4(cx + rx * mathCos(theta + dTheta));
var y = round4(cy + ry * mathSin(theta + dTheta));
// FIXME Ellipse
str.push('A', round4(rx), round4(ry),
mathRound(psi * degree), +large, +clockwise, x, y);
break;
case CMD.Z:
cmdStr = 'Z';
break;
case CMD.R:
var x = round4(data[i++]);
var y = round4(data[i++]);
var w = round4(data[i++]);
var h = round4(data[i++]);
str.push(
'M', x, y,
'L', x + w, y,
'L', x + w, y + h,
'L', x, y + h,
'L', x, y
);
break;
}
cmdStr && str.push(cmdStr);
for (var j = 0; j < nData; j++) {
// PENDING With scale
str.push(round4(data[i++]));
}
}
return str.join(' ');
} | javascript | function pathDataToString(path) {
var str = [];
var data = path.data;
var dataLength = path.len();
for (var i = 0; i < dataLength;) {
var cmd = data[i++];
var cmdStr = '';
var nData = 0;
switch (cmd) {
case CMD.M:
cmdStr = 'M';
nData = 2;
break;
case CMD.L:
cmdStr = 'L';
nData = 2;
break;
case CMD.Q:
cmdStr = 'Q';
nData = 4;
break;
case CMD.C:
cmdStr = 'C';
nData = 6;
break;
case CMD.A:
var cx = data[i++];
var cy = data[i++];
var rx = data[i++];
var ry = data[i++];
var theta = data[i++];
var dTheta = data[i++];
var psi = data[i++];
var clockwise = data[i++];
var dThetaPositive = Math.abs(dTheta);
var isCircle = isAroundZero(dThetaPositive - PI2)
&& !isAroundZero(dThetaPositive);
var large = false;
if (dThetaPositive >= PI2) {
large = true;
}
else if (isAroundZero(dThetaPositive)) {
large = false;
}
else {
large = (dTheta > -PI && dTheta < 0 || dTheta > PI)
=== !!clockwise;
}
var x0 = round4(cx + rx * mathCos(theta));
var y0 = round4(cy + ry * mathSin(theta));
// It will not draw if start point and end point are exactly the same
// We need to shift the end point with a small value
// FIXME A better way to draw circle ?
if (isCircle) {
if (clockwise) {
dTheta = PI2 - 1e-4;
}
else {
dTheta = -PI2 + 1e-4;
}
large = true;
if (i === 9) {
// Move to (x0, y0) only when CMD.A comes at the
// first position of a shape.
// For instance, when drawing a ring, CMD.A comes
// after CMD.M, so it's unnecessary to move to
// (x0, y0).
str.push('M', x0, y0);
}
}
var x = round4(cx + rx * mathCos(theta + dTheta));
var y = round4(cy + ry * mathSin(theta + dTheta));
// FIXME Ellipse
str.push('A', round4(rx), round4(ry),
mathRound(psi * degree), +large, +clockwise, x, y);
break;
case CMD.Z:
cmdStr = 'Z';
break;
case CMD.R:
var x = round4(data[i++]);
var y = round4(data[i++]);
var w = round4(data[i++]);
var h = round4(data[i++]);
str.push(
'M', x, y,
'L', x + w, y,
'L', x + w, y + h,
'L', x, y + h,
'L', x, y
);
break;
}
cmdStr && str.push(cmdStr);
for (var j = 0; j < nData; j++) {
// PENDING With scale
str.push(round4(data[i++]));
}
}
return str.join(' ');
} | [
"function",
"pathDataToString",
"(",
"path",
")",
"{",
"var",
"str",
"=",
"[",
"]",
";",
"var",
"data",
"=",
"path",
".",
"data",
";",
"var",
"dataLength",
"=",
"path",
".",
"len",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",... | *************************************************
PATH
************************************************ | [
"*************************************************",
"PATH",
"************************************************"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/svg/graphic.js#L108-L216 | train | Converts a path to a string | [
30522,
3853,
4130,
2850,
29336,
14122,
4892,
1006,
4130,
1007,
1063,
13075,
2358,
2099,
1027,
1031,
1033,
1025,
13075,
2951,
1027,
4130,
1012,
2951,
1025,
13075,
2951,
7770,
13512,
2232,
1027,
4130,
1012,
18798,
1006,
1007,
1025,
2005,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/math.js | removeProcessedColumns | function removeProcessedColumns(columnsToResize, columnsProcessed) {
for (var _i = 0, columnsProcessed_1 = columnsProcessed; _i < columnsProcessed_1.length; _i++) {
var column = columnsProcessed_1[_i];
var index = columnsToResize.indexOf(column);
columnsToResize.splice(index, 1);
}
} | javascript | function removeProcessedColumns(columnsToResize, columnsProcessed) {
for (var _i = 0, columnsProcessed_1 = columnsProcessed; _i < columnsProcessed_1.length; _i++) {
var column = columnsProcessed_1[_i];
var index = columnsToResize.indexOf(column);
columnsToResize.splice(index, 1);
}
} | [
"function",
"removeProcessedColumns",
"(",
"columnsToResize",
",",
"columnsProcessed",
")",
"{",
"for",
"(",
"var",
"_i",
"=",
"0",
",",
"columnsProcessed_1",
"=",
"columnsProcessed",
";",
"_i",
"<",
"columnsProcessed_1",
".",
"length",
";",
"_i",
"++",
")",
"... | Remove the processed columns from the current active columns. | [
"Remove",
"the",
"processed",
"columns",
"from",
"the",
"current",
"active",
"columns",
"."
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/math.js#L142-L148 | train | Remove processed columns from the columnsToResize array | [
30522,
3853,
6366,
21572,
9623,
6924,
25778,
2819,
3619,
1006,
7753,
19277,
5332,
4371,
1010,
7753,
21572,
9623,
6924,
1007,
1063,
2005,
1006,
13075,
1035,
1045,
1027,
1014,
1010,
7753,
21572,
9623,
6924,
1035,
1015,
1027,
7753,
21572,
9623... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/line/poly.js | drawMono | function drawMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
var prevIdx = 0;
var idx = start;
for (var k = 0; k < segLen; k++) {
var p = points[idx];
if (idx >= allLen || idx < 0) {
break;
}
if (isPointNull(p)) {
if (connectNulls) {
idx += dir;
continue;
}
break;
}
if (idx === start) {
ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
else {
if (smooth > 0) {
var prevP = points[prevIdx];
var dim = smoothMonotone === 'y' ? 1 : 0;
// Length of control point to p, either in x or y, but not both
var ctrlLen = (p[dim] - prevP[dim]) * smooth;
v2Copy(cp0, prevP);
cp0[dim] = prevP[dim] + ctrlLen;
v2Copy(cp1, p);
cp1[dim] = p[dim] - ctrlLen;
ctx.bezierCurveTo(
cp0[0], cp0[1],
cp1[0], cp1[1],
p[0], p[1]
);
}
else {
ctx.lineTo(p[0], p[1]);
}
}
prevIdx = idx;
idx += dir;
}
return k;
} | javascript | function drawMono(
ctx, points, start, segLen, allLen,
dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
) {
var prevIdx = 0;
var idx = start;
for (var k = 0; k < segLen; k++) {
var p = points[idx];
if (idx >= allLen || idx < 0) {
break;
}
if (isPointNull(p)) {
if (connectNulls) {
idx += dir;
continue;
}
break;
}
if (idx === start) {
ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
}
else {
if (smooth > 0) {
var prevP = points[prevIdx];
var dim = smoothMonotone === 'y' ? 1 : 0;
// Length of control point to p, either in x or y, but not both
var ctrlLen = (p[dim] - prevP[dim]) * smooth;
v2Copy(cp0, prevP);
cp0[dim] = prevP[dim] + ctrlLen;
v2Copy(cp1, p);
cp1[dim] = p[dim] - ctrlLen;
ctx.bezierCurveTo(
cp0[0], cp0[1],
cp1[0], cp1[1],
p[0], p[1]
);
}
else {
ctx.lineTo(p[0], p[1]);
}
}
prevIdx = idx;
idx += dir;
}
return k;
} | [
"function",
"drawMono",
"(",
"ctx",
",",
"points",
",",
"start",
",",
"segLen",
",",
"allLen",
",",
"dir",
",",
"smoothMin",
",",
"smoothMax",
",",
"smooth",
",",
"smoothMonotone",
",",
"connectNulls",
")",
"{",
"var",
"prevIdx",
"=",
"0",
";",
"var",
... | var dim = smoothMonotone === 'x' ? 0 : 1; var last = points[0][dim]; var lastDiff = 0; for (var i = 1; i < points.length; ++i) { var diff = points[i][dim] - last; if (!isNaN(diff) && !isNaN(lastDiff) && diff !== 0 && lastDiff !== 0 && ((diff >= 0) !== (lastDiff >= 0)) ) { return false; } if (!isNaN(diff) && diff !== 0) { lastDiff = diff; last = points[i][dim]; } } return true; }
Draw smoothed line in monotone, in which only vertical or horizontal bezier
control points will be used. This should be used when points are monotone
either in x or y dimension. | [
"var",
"dim",
"=",
"smoothMonotone",
"===",
"x",
"?",
"0",
":",
"1",
";",
"var",
"last",
"=",
"points",
"[",
"0",
"]",
"[",
"dim",
"]",
";",
"var",
"lastDiff",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"points",
".",
"... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/line/poly.js#L112-L164 | train | Draws a monotone line | [
30522,
3853,
4009,
8202,
2080,
1006,
14931,
2595,
1010,
2685,
1010,
2707,
1010,
7367,
9354,
2078,
1010,
2035,
7770,
1010,
16101,
1010,
5744,
10020,
1010,
5744,
17848,
1010,
5744,
1010,
5744,
8202,
25862,
2063,
1010,
7532,
11231,
12718,
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... |
mochajs/mocha | lib/errors.js | createInvalidReporterError | function createInvalidReporterError(message, reporter) {
var err = new TypeError(message);
err.code = 'ERR_MOCHA_INVALID_REPORTER';
err.reporter = reporter;
return err;
} | javascript | function createInvalidReporterError(message, reporter) {
var err = new TypeError(message);
err.code = 'ERR_MOCHA_INVALID_REPORTER';
err.reporter = reporter;
return err;
} | [
"function",
"createInvalidReporterError",
"(",
"message",
",",
"reporter",
")",
"{",
"var",
"err",
"=",
"new",
"TypeError",
"(",
"message",
")",
";",
"err",
".",
"code",
"=",
"'ERR_MOCHA_INVALID_REPORTER'",
";",
"err",
".",
"reporter",
"=",
"reporter",
";",
... | Creates an error object to be thrown when the reporter specified in the options was not found.
@public
@param {string} message - Error message to be displayed.
@param {string} reporter - User-specified reporter value.
@returns {Error} instance detailing the error condition | [
"Creates",
"an",
"error",
"object",
"to",
"be",
"thrown",
"when",
"the",
"reporter",
"specified",
"in",
"the",
"options",
"was",
"not",
"found",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/errors.js#L32-L37 | train | Create an error object that can t be thrown when a reporter is not supported. | [
30522,
3853,
3443,
2378,
10175,
3593,
2890,
6442,
7869,
18933,
2099,
1006,
4471,
1010,
6398,
1007,
1063,
13075,
9413,
2099,
1027,
2047,
2828,
2121,
29165,
1006,
4471,
1007,
1025,
9413,
2099,
1012,
3642,
1027,
1005,
9413,
2099,
1035,
9587,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc-node | packages/grpc-native-core/src/server.js | ServerUnaryCall | function ServerUnaryCall(call, metadata) {
EventEmitter.call(this);
this.call = call;
/**
* Indicates if the call has been cancelled
* @member {boolean} grpc~ServerUnaryCall#cancelled
*/
this.cancelled = false;
/**
* The request metadata from the client
* @member {grpc.Metadata} grpc~ServerUnaryCall#metadata
*/
this.metadata = metadata;
/**
* The request message from the client
* @member {*} grpc~ServerUnaryCall#request
*/
this.request = undefined;
} | javascript | function ServerUnaryCall(call, metadata) {
EventEmitter.call(this);
this.call = call;
/**
* Indicates if the call has been cancelled
* @member {boolean} grpc~ServerUnaryCall#cancelled
*/
this.cancelled = false;
/**
* The request metadata from the client
* @member {grpc.Metadata} grpc~ServerUnaryCall#metadata
*/
this.metadata = metadata;
/**
* The request message from the client
* @member {*} grpc~ServerUnaryCall#request
*/
this.request = undefined;
} | [
"function",
"ServerUnaryCall",
"(",
"call",
",",
"metadata",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"call",
"=",
"call",
";",
"/**\n * Indicates if the call has been cancelled\n * @member {boolean} grpc~ServerUnaryCall#cancelled\n *... | An EventEmitter. Used for unary calls.
@constructor grpc~ServerUnaryCall
@extends external:EventEmitter
@param {grpc.internal~Call} call The call object associated with the request
@param {grpc.Metadata} metadata The request metadata from the client | [
"An",
"EventEmitter",
".",
"Used",
"for",
"unary",
"calls",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L230-L248 | train | ServerUnaryCall constructor. | [
30522,
3853,
8241,
9521,
2854,
9289,
2140,
1006,
2655,
1010,
27425,
1007,
1063,
2724,
23238,
12079,
1012,
2655,
1006,
2023,
1007,
1025,
2023,
1012,
2655,
1027,
2655,
1025,
1013,
1008,
1008,
1008,
7127,
2065,
1996,
2655,
2038,
2042,
8014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/website/createTemplateEngine.js | getPageByPath | function getPageByPath(filePath) {
var page = output.getPage(filePath);
if (!page) return undefined;
return JSONUtils.encodePage(page, summary);
} | javascript | function getPageByPath(filePath) {
var page = output.getPage(filePath);
if (!page) return undefined;
return JSONUtils.encodePage(page, summary);
} | [
"function",
"getPageByPath",
"(",
"filePath",
")",
"{",
"var",
"page",
"=",
"output",
".",
"getPage",
"(",
"filePath",
")",
";",
"if",
"(",
"!",
"page",
")",
"return",
"undefined",
";",
"return",
"JSONUtils",
".",
"encodePage",
"(",
"page",
",",
"summary... | Return a page by its path
@param {String} filePath
@return {Object|undefined} | [
"Return",
"a",
"page",
"by",
"its",
"path"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/createTemplateEngine.js#L87-L92 | train | Get a page by path | [
30522,
3853,
2131,
13704,
3762,
15069,
1006,
5371,
15069,
1007,
1063,
13075,
3931,
1027,
6434,
1012,
2131,
13704,
1006,
5371,
15069,
1007,
1025,
2065,
1006,
999,
3931,
1007,
2709,
6151,
28344,
1025,
2709,
1046,
3385,
21823,
4877,
1012,
4372... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/variants/util/VariantUtil.js | function(oComponent) {
var aTechnicalParameters = flUtils.getTechnicalParametersForComponent(oComponent);
return aTechnicalParameters
&& aTechnicalParameters[VariantUtil.variantTechnicalParameterName]
&& Array.isArray(aTechnicalParameters[VariantUtil.variantTechnicalParameterName])
&& aTechnicalParameters[VariantUtil.variantTechnicalParameterName][0];
} | javascript | function(oComponent) {
var aTechnicalParameters = flUtils.getTechnicalParametersForComponent(oComponent);
return aTechnicalParameters
&& aTechnicalParameters[VariantUtil.variantTechnicalParameterName]
&& Array.isArray(aTechnicalParameters[VariantUtil.variantTechnicalParameterName])
&& aTechnicalParameters[VariantUtil.variantTechnicalParameterName][0];
} | [
"function",
"(",
"oComponent",
")",
"{",
"var",
"aTechnicalParameters",
"=",
"flUtils",
".",
"getTechnicalParametersForComponent",
"(",
"oComponent",
")",
";",
"return",
"aTechnicalParameters",
"&&",
"aTechnicalParameters",
"[",
"VariantUtil",
".",
"variantTechnicalParame... | Returns control variant technical parameter for the passed component.
@param {object} oComponent - Component instance used to get the technical parameters
@returns {string|undefined} Returns the control variant technical parameter | [
"Returns",
"control",
"variant",
"technical",
"parameter",
"for",
"the",
"passed",
"component",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/variants/util/VariantUtil.js#L118-L124 | train | Returns the index of the highest priority parameter for a component | [
30522,
3853,
1006,
1051,
9006,
29513,
3372,
1007,
1063,
13075,
8823,
2818,
20913,
28689,
22828,
2015,
1027,
19857,
3775,
4877,
1012,
2131,
15007,
20913,
28689,
22828,
22747,
2953,
9006,
29513,
3372,
1006,
1051,
9006,
29513,
3372,
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... | |
moleculerjs/moleculer | src/strategies/index.js | resolve | function resolve(opt) {
if (Strategies.Base.isPrototypeOf(opt)) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "RoundRobin");
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt.type}'.`, { type: opt.type });
}
return Strategies.RoundRobin;
} | javascript | function resolve(opt) {
if (Strategies.Base.isPrototypeOf(opt)) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "RoundRobin");
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt.type}'.`, { type: opt.type });
}
return Strategies.RoundRobin;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"Strategies",
".",
"Base",
".",
"isPrototypeOf",
"(",
"opt",
")",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"SerializerCla... | Resolve strategy by name
@param {object|string} opt
@returns {Strategy}
@memberof ServiceBroker | [
"Resolve",
"strategy",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/strategies/index.js#L37-L56 | train | Resolve a strategy | [
30522,
3853,
10663,
1006,
23569,
1007,
1063,
2065,
1006,
9942,
1012,
2918,
1012,
2003,
21572,
3406,
13874,
11253,
1006,
23569,
1007,
1007,
1063,
2709,
23569,
1025,
1065,
2842,
2065,
1006,
1035,
1012,
26354,
18886,
3070,
1006,
23569,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/closure-library | closure/goog/html/cssspecificity.js | calculateSpecificity | function calculateSpecificity(selector) {
var specificity = [0, 0, 0, 0];
// Cannot use RegExp literals for all regular expressions, IE does not accept
// the syntax.
// Matches a backslash followed by six hexadecimal digits followed by an
// optional single whitespace character.
var escapeHexadecimalRegex = new RegExp('\\\\[0-9A-Fa-f]{6}\\s?', 'g');
// Matches a backslash followed by fewer than six hexadecimal digits
// followed by a mandatory single whitespace character.
var escapeHexadecimalRegex2 = new RegExp('\\\\[0-9A-Fa-f]{1,5}\\s', 'g');
// Matches a backslash followed by any character
var escapeSpecialCharacter = /\\./g;
selector = replaceWithPlainText(selector, escapeHexadecimalRegex);
selector = replaceWithPlainText(selector, escapeHexadecimalRegex2);
selector = replaceWithPlainText(selector, escapeSpecialCharacter);
// Remove the negation pseudo-class (:not) but leave its argument because
// specificity is calculated on its argument.
var pseudoClassWithNotRegex = new RegExp(':not\\(([^\\)]*)\\)', 'g');
selector = selector.replace(pseudoClassWithNotRegex, ' $1 ');
// Remove anything after a left brace in case a user has pasted in a rule,
// not just a selector.
var rulesRegex = new RegExp('{[^]*', 'gm');
selector = selector.replace(rulesRegex, '');
// The following regular expressions assume that selectors matching the
// preceding regular expressions have been removed.
// SPECIFICITY 2: Counts attribute selectors.
var attributeRegex = new RegExp('(\\[[^\\]]+\\])', 'g');
selector = replaceWithEmptyText(selector, specificity, attributeRegex, 2);
// SPECIFICITY 1: Counts ID selectors.
var idRegex = new RegExp('(#[^\\#\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, idRegex, 1);
// SPECIFICITY 2: Counts class selectors.
var classRegex = new RegExp('(\\.[^\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, classRegex, 2);
// SPECIFICITY 3: Counts pseudo-element selectors.
var pseudoElementRegex =
/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
selector = replaceWithEmptyText(selector, specificity, pseudoElementRegex, 3);
// SPECIFICITY 2: Counts pseudo-class selectors.
// A regex for pseudo classes with brackets. For example:
// :nth-child()
// :nth-last-child()
// :nth-of-type()
// :nth-last-type()
// :lang()
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
selector = replaceWithEmptyText(
selector, specificity, pseudoClassWithBracketsRegex, 2);
// A regex for other pseudo classes, which don't have brackets.
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, pseudoClassRegex, 2);
// Remove universal selector and separator characters.
selector = selector.replace(/[\*\s\+>~]/g, ' ');
// Remove any stray dots or hashes which aren't attached to words.
// These may be present if the user is live-editing this selector.
selector = selector.replace(/[#\.]/g, ' ');
// SPECIFICITY 3: The only things left should be element selectors.
var elementRegex = /([^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, elementRegex, 3);
return specificity;
} | javascript | function calculateSpecificity(selector) {
var specificity = [0, 0, 0, 0];
// Cannot use RegExp literals for all regular expressions, IE does not accept
// the syntax.
// Matches a backslash followed by six hexadecimal digits followed by an
// optional single whitespace character.
var escapeHexadecimalRegex = new RegExp('\\\\[0-9A-Fa-f]{6}\\s?', 'g');
// Matches a backslash followed by fewer than six hexadecimal digits
// followed by a mandatory single whitespace character.
var escapeHexadecimalRegex2 = new RegExp('\\\\[0-9A-Fa-f]{1,5}\\s', 'g');
// Matches a backslash followed by any character
var escapeSpecialCharacter = /\\./g;
selector = replaceWithPlainText(selector, escapeHexadecimalRegex);
selector = replaceWithPlainText(selector, escapeHexadecimalRegex2);
selector = replaceWithPlainText(selector, escapeSpecialCharacter);
// Remove the negation pseudo-class (:not) but leave its argument because
// specificity is calculated on its argument.
var pseudoClassWithNotRegex = new RegExp(':not\\(([^\\)]*)\\)', 'g');
selector = selector.replace(pseudoClassWithNotRegex, ' $1 ');
// Remove anything after a left brace in case a user has pasted in a rule,
// not just a selector.
var rulesRegex = new RegExp('{[^]*', 'gm');
selector = selector.replace(rulesRegex, '');
// The following regular expressions assume that selectors matching the
// preceding regular expressions have been removed.
// SPECIFICITY 2: Counts attribute selectors.
var attributeRegex = new RegExp('(\\[[^\\]]+\\])', 'g');
selector = replaceWithEmptyText(selector, specificity, attributeRegex, 2);
// SPECIFICITY 1: Counts ID selectors.
var idRegex = new RegExp('(#[^\\#\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, idRegex, 1);
// SPECIFICITY 2: Counts class selectors.
var classRegex = new RegExp('(\\.[^\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, classRegex, 2);
// SPECIFICITY 3: Counts pseudo-element selectors.
var pseudoElementRegex =
/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
selector = replaceWithEmptyText(selector, specificity, pseudoElementRegex, 3);
// SPECIFICITY 2: Counts pseudo-class selectors.
// A regex for pseudo classes with brackets. For example:
// :nth-child()
// :nth-last-child()
// :nth-of-type()
// :nth-last-type()
// :lang()
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
selector = replaceWithEmptyText(
selector, specificity, pseudoClassWithBracketsRegex, 2);
// A regex for other pseudo classes, which don't have brackets.
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, pseudoClassRegex, 2);
// Remove universal selector and separator characters.
selector = selector.replace(/[\*\s\+>~]/g, ' ');
// Remove any stray dots or hashes which aren't attached to words.
// These may be present if the user is live-editing this selector.
selector = selector.replace(/[#\.]/g, ' ');
// SPECIFICITY 3: The only things left should be element selectors.
var elementRegex = /([^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, elementRegex, 3);
return specificity;
} | [
"function",
"calculateSpecificity",
"(",
"selector",
")",
"{",
"var",
"specificity",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
";",
"// Cannot use RegExp literals for all regular expressions, IE does not accept",
"// the syntax.",
"// Matches a backslash followed by... | Calculates the specificity of CSS selectors
@see http://www.w3.org/TR/css3-selectors/#specificity
@see https://github.com/keeganstreet/specificity
@see https://specificity.keegan.st/
@param {string} selector
@return {!Array<number>} The CSS specificity. | [
"Calculates",
"the",
"specificity",
"of",
"CSS",
"selectors"
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/cssspecificity.js#L98-L172 | train | Calculates the specificity of a selector. | [
30522,
3853,
18422,
13102,
8586,
18513,
3012,
1006,
27000,
1007,
1063,
13075,
3563,
3012,
1027,
1031,
1014,
1010,
1014,
1010,
1014,
1010,
1014,
1033,
1025,
1013,
1013,
3685,
2224,
19723,
10288,
2361,
18204,
2015,
2005,
2035,
3180,
11423,
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... |
Microsoft/vscode | src/vs/code/electron-browser/workbench/workbench.js | showPartsSplash | function showPartsSplash(configuration) {
perf.mark('willShowPartsSplash');
let data;
if (typeof configuration.partsSplashPath === 'string') {
try {
data = JSON.parse(require('fs').readFileSync(configuration.partsSplashPath, 'utf8'));
} catch (e) {
// ignore
}
}
// high contrast mode has been turned on from the outside, e.g OS -> ignore stored colors and layouts
if (data && configuration.highContrast && data.baseTheme !== 'hc-black') {
data = undefined;
}
// developing an extension -> ignore stored layouts
if (data && configuration.extensionDevelopmentPath) {
data.layoutInfo = undefined;
}
// minimal color configuration (works with or without persisted data)
const baseTheme = data ? data.baseTheme : configuration.highContrast ? 'hc-black' : 'vs-dark';
const shellBackground = data ? data.colorInfo.editorBackground : configuration.highContrast ? '#000000' : '#1E1E1E';
const shellForeground = data ? data.colorInfo.foreground : configuration.highContrast ? '#FFFFFF' : '#CCCCCC';
const style = document.createElement('style');
style.className = 'initialShellColors';
document.head.appendChild(style);
document.body.className = `monaco-shell ${baseTheme}`;
style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`;
if (data && data.layoutInfo) {
// restore parts if possible (we might not always store layout info)
const { id, layoutInfo, colorInfo } = data;
const splash = document.createElement('div');
splash.id = id;
// ensure there is enough space
layoutInfo.sideBarWidth = Math.min(layoutInfo.sideBarWidth, window.innerWidth - (layoutInfo.activityBarWidth + layoutInfo.editorPartMinWidth));
if (configuration.folderUri || configuration.workspace) {
// folder or workspace -> status bar color, sidebar
splash.innerHTML = `
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: ${layoutInfo.activityBarWidth}px; width: ${layoutInfo.sideBarWidth}px; background-color: ${colorInfo.sideBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarBackground};"></div>
`;
} else {
// empty -> speical status bar color, no sidebar
splash.innerHTML = `
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarNoFolderBackground};"></div>
`;
}
document.body.appendChild(splash);
}
perf.mark('didShowPartsSplash');
} | javascript | function showPartsSplash(configuration) {
perf.mark('willShowPartsSplash');
let data;
if (typeof configuration.partsSplashPath === 'string') {
try {
data = JSON.parse(require('fs').readFileSync(configuration.partsSplashPath, 'utf8'));
} catch (e) {
// ignore
}
}
// high contrast mode has been turned on from the outside, e.g OS -> ignore stored colors and layouts
if (data && configuration.highContrast && data.baseTheme !== 'hc-black') {
data = undefined;
}
// developing an extension -> ignore stored layouts
if (data && configuration.extensionDevelopmentPath) {
data.layoutInfo = undefined;
}
// minimal color configuration (works with or without persisted data)
const baseTheme = data ? data.baseTheme : configuration.highContrast ? 'hc-black' : 'vs-dark';
const shellBackground = data ? data.colorInfo.editorBackground : configuration.highContrast ? '#000000' : '#1E1E1E';
const shellForeground = data ? data.colorInfo.foreground : configuration.highContrast ? '#FFFFFF' : '#CCCCCC';
const style = document.createElement('style');
style.className = 'initialShellColors';
document.head.appendChild(style);
document.body.className = `monaco-shell ${baseTheme}`;
style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`;
if (data && data.layoutInfo) {
// restore parts if possible (we might not always store layout info)
const { id, layoutInfo, colorInfo } = data;
const splash = document.createElement('div');
splash.id = id;
// ensure there is enough space
layoutInfo.sideBarWidth = Math.min(layoutInfo.sideBarWidth, window.innerWidth - (layoutInfo.activityBarWidth + layoutInfo.editorPartMinWidth));
if (configuration.folderUri || configuration.workspace) {
// folder or workspace -> status bar color, sidebar
splash.innerHTML = `
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: ${layoutInfo.activityBarWidth}px; width: ${layoutInfo.sideBarWidth}px; background-color: ${colorInfo.sideBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarBackground};"></div>
`;
} else {
// empty -> speical status bar color, no sidebar
splash.innerHTML = `
<div style="position: absolute; width: 100%; left: 0; top: 0; height: ${layoutInfo.titleBarHeight}px; background-color: ${colorInfo.titleBarBackground}; -webkit-app-region: drag;"></div>
<div style="position: absolute; height: calc(100% - ${layoutInfo.titleBarHeight}px); top: ${layoutInfo.titleBarHeight}px; ${layoutInfo.sideBarSide}: 0; width: ${layoutInfo.activityBarWidth}px; background-color: ${colorInfo.activityBarBackground};"></div>
<div style="position: absolute; width: 100%; bottom: 0; left: 0; height: ${layoutInfo.statusBarHeight}px; background-color: ${colorInfo.statusBarNoFolderBackground};"></div>
`;
}
document.body.appendChild(splash);
}
perf.mark('didShowPartsSplash');
} | [
"function",
"showPartsSplash",
"(",
"configuration",
")",
"{",
"perf",
".",
"mark",
"(",
"'willShowPartsSplash'",
")",
";",
"let",
"data",
";",
"if",
"(",
"typeof",
"configuration",
".",
"partsSplashPath",
"===",
"'string'",
")",
"{",
"try",
"{",
"data",
"="... | // configuration: IWindowConfiguration
@param {{
partsSplashPath?: string,
highContrast?: boolean,
extensionDevelopmentPath?: string | string[],
folderUri?: object,
workspace?: object
}} configuration | [
"//",
"configuration",
":",
"IWindowConfiguration"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/src/vs/code/electron-browser/workbench/workbench.js#L61-L122 | train | Show the splash of the parts | [
30522,
3853,
2265,
26950,
13102,
27067,
1006,
9563,
1007,
1063,
2566,
2546,
1012,
2928,
1006,
1005,
17234,
14406,
26950,
13102,
27067,
1005,
1007,
1025,
2292,
2951,
1025,
2065,
1006,
2828,
11253,
9563,
1012,
3033,
13102,
27067,
15069,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/Controller.js | instantiateController | function instantiateController(ControllerClass, sName) {
var oController;
if (mRegistry[sName]) {
oController = new ControllerClass(sName);
} else {
oController = new ControllerClass();
}
if (!oController) {
throw new Error("Controller " + sName + " couldn't be instantiated");
}
return oController;
} | javascript | function instantiateController(ControllerClass, sName) {
var oController;
if (mRegistry[sName]) {
oController = new ControllerClass(sName);
} else {
oController = new ControllerClass();
}
if (!oController) {
throw new Error("Controller " + sName + " couldn't be instantiated");
}
return oController;
} | [
"function",
"instantiateController",
"(",
"ControllerClass",
",",
"sName",
")",
"{",
"var",
"oController",
";",
"if",
"(",
"mRegistry",
"[",
"sName",
"]",
")",
"{",
"oController",
"=",
"new",
"ControllerClass",
"(",
"sName",
")",
";",
"}",
"else",
"{",
"oC... | /*
Instantiation of a controller
@param {function} ControllerClass The controller constructor
@param {string} sName the controller name
@param {boolean} bAsync Load async or not
@return {sap.ui.core.mvc.Controller|Promise} A <code>Promise</code> in case of asynchronous extend
or the <code>controller</code> in case of synchronous extend | [
"/",
"*",
"Instantiation",
"of",
"a",
"controller"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/Controller.js#L344-L355 | train | Instantiate a controller | [
30522,
3853,
7107,
13143,
8663,
13181,
10820,
1006,
11486,
26266,
1010,
1055,
18442,
1007,
1063,
13075,
1051,
8663,
13181,
10820,
1025,
2065,
1006,
2720,
13910,
2923,
2854,
1031,
1055,
18442,
1033,
1007,
1063,
1051,
8663,
13181,
10820,
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... |
GitbookIO/gitbook | lib/modifiers/summary/mergeAtLevel.js | editArticleInList | function editArticleInList(articles, level, newArticle) {
return articles.map(function(article) {
var articleLevel = article.getLevel();
if (articleLevel === level) {
// it is the article to edit
return article.merge(newArticle);
} else if (level.indexOf(articleLevel) === 0) {
// it is a parent
var articles = editArticleInList(article.getArticles(), level, newArticle);
return article.set('articles', articles);
} else {
// This is not the article you are looking for
return article;
}
});
} | javascript | function editArticleInList(articles, level, newArticle) {
return articles.map(function(article) {
var articleLevel = article.getLevel();
if (articleLevel === level) {
// it is the article to edit
return article.merge(newArticle);
} else if (level.indexOf(articleLevel) === 0) {
// it is a parent
var articles = editArticleInList(article.getArticles(), level, newArticle);
return article.set('articles', articles);
} else {
// This is not the article you are looking for
return article;
}
});
} | [
"function",
"editArticleInList",
"(",
"articles",
",",
"level",
",",
"newArticle",
")",
"{",
"return",
"articles",
".",
"map",
"(",
"function",
"(",
"article",
")",
"{",
"var",
"articleLevel",
"=",
"article",
".",
"getLevel",
"(",
")",
";",
"if",
"(",
"a... | Edit a list of articles
@param {List<Article>} articles
@param {String} level
@param {Article} newArticle
@return {List<Article>} | [
"Edit",
"a",
"list",
"of",
"articles"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/mergeAtLevel.js#L10-L26 | train | editArticleInList - edit article in list | [
30522,
3853,
10086,
8445,
25128,
2378,
9863,
1006,
4790,
1010,
2504,
1010,
2047,
8445,
25128,
1007,
1063,
2709,
4790,
1012,
4949,
1006,
3853,
1006,
3720,
1007,
1063,
13075,
3720,
20414,
2884,
1027,
3720,
1012,
2131,
20414,
2884,
1006,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.