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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ReactiveX/rxjs | docs_app/src/app/search/search-worker.js | loadIndex | function loadIndex(searchInfo /*: SearchInfo */) {
return function(index) {
// Store the pages data to be used in mapping query results back to pages
// Add search terms from each page to the search index
searchInfo.forEach(function(page /*: PageInfo */) {
index.add(page);
pages[page.path] = page;
});
};
} | javascript | function loadIndex(searchInfo /*: SearchInfo */) {
return function(index) {
// Store the pages data to be used in mapping query results back to pages
// Add search terms from each page to the search index
searchInfo.forEach(function(page /*: PageInfo */) {
index.add(page);
pages[page.path] = page;
});
};
} | [
"function",
"loadIndex",
"(",
"searchInfo",
"/*: SearchInfo */",
")",
"{",
"return",
"function",
"(",
"index",
")",
"{",
"// Store the pages data to be used in mapping query results back to pages",
"// Add search terms from each page to the search index",
"searchInfo",
".",
"forEac... | Create the search index from the searchInfo which contains the information about each page to be indexed | [
"Create",
"the",
"search",
"index",
"from",
"the",
"searchInfo",
"which",
"contains",
"the",
"information",
"about",
"each",
"page",
"to",
"be",
"indexed"
] | 1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f | https://github.com/ReactiveX/rxjs/blob/1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f/docs_app/src/app/search/search-worker.js#L75-L84 | train | Load the search index | [
30522,
3853,
7170,
22254,
10288,
1006,
3945,
2378,
14876,
1013,
1008,
1024,
3945,
2378,
14876,
1008,
1013,
1007,
1063,
2709,
3853,
1006,
5950,
1007,
1063,
1013,
1013,
3573,
1996,
5530,
2951,
2000,
2022,
2109,
1999,
12375,
23032,
3463,
2067,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sSkeleton, oAvailableFormats, sCalendarType, vDiff) {
var vPattern, aPatterns, oIntervalFormats;
if (!vDiff) {
// the call is from getCustomDateTimePattern
vPattern = oAvailableFormats[sSkeleton];
} else if (typeof vDiff === "string") {
// vDiff is given as a symbol
if (vDiff == "j" || vDiff == "J") {
vDiff = this.getPreferredHourSymbol();
}
oIntervalFormats = oAvailableFormats[sSkeleton];
vPattern = oIntervalFormats && oIntervalFormats[vDiff];
}
if (vPattern) {
if (typeof vPattern === "object") {
aPatterns = Object.keys(vPattern).map(function(sKey) {
return vPattern[sKey];
});
} else {
return vPattern;
}
}
if (!aPatterns) {
aPatterns = this._createFormatPattern(sSkeleton, oAvailableFormats, sCalendarType, vDiff);
}
if (aPatterns && aPatterns.length === 1) {
return aPatterns[0];
}
return aPatterns;
} | javascript | function(sSkeleton, oAvailableFormats, sCalendarType, vDiff) {
var vPattern, aPatterns, oIntervalFormats;
if (!vDiff) {
// the call is from getCustomDateTimePattern
vPattern = oAvailableFormats[sSkeleton];
} else if (typeof vDiff === "string") {
// vDiff is given as a symbol
if (vDiff == "j" || vDiff == "J") {
vDiff = this.getPreferredHourSymbol();
}
oIntervalFormats = oAvailableFormats[sSkeleton];
vPattern = oIntervalFormats && oIntervalFormats[vDiff];
}
if (vPattern) {
if (typeof vPattern === "object") {
aPatterns = Object.keys(vPattern).map(function(sKey) {
return vPattern[sKey];
});
} else {
return vPattern;
}
}
if (!aPatterns) {
aPatterns = this._createFormatPattern(sSkeleton, oAvailableFormats, sCalendarType, vDiff);
}
if (aPatterns && aPatterns.length === 1) {
return aPatterns[0];
}
return aPatterns;
} | [
"function",
"(",
"sSkeleton",
",",
"oAvailableFormats",
",",
"sCalendarType",
",",
"vDiff",
")",
"{",
"var",
"vPattern",
",",
"aPatterns",
",",
"oIntervalFormats",
";",
"if",
"(",
"!",
"vDiff",
")",
"{",
"// the call is from getCustomDateTimePattern",
"vPattern",
... | /* Helper functions for skeleton pattern processing | [
"/",
"*",
"Helper",
"functions",
"for",
"skeleton",
"pattern",
"processing"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L350-L384 | train | Returns the pattern for the given format skeleton. | [
30522,
3853,
1006,
7020,
11705,
18903,
2078,
1010,
1051,
12462,
11733,
3468,
14192,
11149,
1010,
4094,
8943,
30524,
1013,
1013,
1996,
2655,
2003,
2013,
2131,
7874,
20389,
13701,
7292,
4502,
12079,
2078,
21210,
20097,
2078,
1027,
1051,
12462,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(sPropertyName) {
if (!sPropertyName) {
return;
}
var oSorter = this._containsSorter(sPropertyName);
if (oSorter) {
this._removeFromArray(this._aSortCondition, oSorter.index);
}
} | javascript | function(sPropertyName) {
if (!sPropertyName) {
return;
}
var oSorter = this._containsSorter(sPropertyName);
if (oSorter) {
this._removeFromArray(this._aSortCondition, oSorter.index);
}
} | [
"function",
"(",
"sPropertyName",
")",
"{",
"if",
"(",
"!",
"sPropertyName",
")",
"{",
"return",
";",
"}",
"var",
"oSorter",
"=",
"this",
".",
"_containsSorter",
"(",
"sPropertyName",
")",
";",
"if",
"(",
"oSorter",
")",
"{",
"this",
".",
"_removeFromArr... | Removes the order by expression for the given property name from the list
of order by expression. If no order by expression with this property name
exists the method does nothing.
@param {string}
sPropertyName The name of the property to be removed from the
condition
@public
@function
@name sap.ui.model.analytics.odata4analytics.SortExpression#removeSorter | [
"Removes",
"the",
"order",
"by",
"expression",
"for",
"the",
"given",
"property",
"name",
"from",
"the",
"list",
"of",
"order",
"by",
"expression",
".",
"If",
"no",
"order",
"by",
"expression",
"with",
"this",
"property",
"name",
"exists",
"the",
"method",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3722-L3731 | train | Removes the property from the sort condition | [
30522,
3853,
1006,
11867,
18981,
15010,
18442,
1007,
1063,
2065,
1006,
999,
11867,
18981,
15010,
18442,
1007,
1063,
2709,
1025,
1065,
13075,
9808,
11589,
2121,
1027,
2023,
1012,
1035,
3397,
21748,
3334,
1006,
11867,
18981,
15010,
18442,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js | function(oFragment, sIdPrefix) {
var oParseError = XMLHelper.getParseError(oFragment);
if (oParseError.errorCode !== 0) {
throw new Error(oFragment.parseError.reason);
}
var oControlNodes = oFragment.documentElement;
var aRootChildren = [], aChildren = [];
if (oControlNodes.localName === "FragmentDefinition") {
aRootChildren = this._getElementNodeChildren(oControlNodes);
} else {
aRootChildren = [oControlNodes];
}
aChildren = [].concat(aRootChildren);
// get all children and their children
function oCallback(oChild) {
aChildren.push(oChild);
}
for (var i = 0, n = aRootChildren.length; i < n; i++) {
this._traverseXmlTree(oCallback, aRootChildren[i]);
}
for (var j = 0, m = aChildren.length; j < m; j++) {
// aChildren[j].id is not available in IE11, therefore using .getAttribute/.setAttribute
if (aChildren[j].getAttribute("id")) {
aChildren[j].setAttribute("id", sIdPrefix + "." + aChildren[j].getAttribute("id"));
} else {
throw new Error("At least one control does not have a stable ID");
}
}
return oControlNodes;
} | javascript | function(oFragment, sIdPrefix) {
var oParseError = XMLHelper.getParseError(oFragment);
if (oParseError.errorCode !== 0) {
throw new Error(oFragment.parseError.reason);
}
var oControlNodes = oFragment.documentElement;
var aRootChildren = [], aChildren = [];
if (oControlNodes.localName === "FragmentDefinition") {
aRootChildren = this._getElementNodeChildren(oControlNodes);
} else {
aRootChildren = [oControlNodes];
}
aChildren = [].concat(aRootChildren);
// get all children and their children
function oCallback(oChild) {
aChildren.push(oChild);
}
for (var i = 0, n = aRootChildren.length; i < n; i++) {
this._traverseXmlTree(oCallback, aRootChildren[i]);
}
for (var j = 0, m = aChildren.length; j < m; j++) {
// aChildren[j].id is not available in IE11, therefore using .getAttribute/.setAttribute
if (aChildren[j].getAttribute("id")) {
aChildren[j].setAttribute("id", sIdPrefix + "." + aChildren[j].getAttribute("id"));
} else {
throw new Error("At least one control does not have a stable ID");
}
}
return oControlNodes;
} | [
"function",
"(",
"oFragment",
",",
"sIdPrefix",
")",
"{",
"var",
"oParseError",
"=",
"XMLHelper",
".",
"getParseError",
"(",
"oFragment",
")",
";",
"if",
"(",
"oParseError",
".",
"errorCode",
"!==",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"oFragment",... | This function takes the fragment, goes through all the children and adds a prefix to the control's ID.
Can also handle 'FragmentDefinition' as root node, then all the children's IDs are prefixed.
Adds a '.' at the end of the prefix to separate it from the original ID.
Throws an error if any one of the controls in the fragment have no ID specified.
Aggregations will be ignored and don't need an ID.
@param {Element} oFragment - Fragment in XML
@param {string} sIdPrefix - String which will be used to prefix the IDs
@returns {Element} Original fragment in XML with updated IDs | [
"This",
"function",
"takes",
"the",
"fragment",
"goes",
"through",
"all",
"the",
"children",
"and",
"adds",
"a",
"prefix",
"to",
"the",
"control",
"s",
"ID",
".",
"Can",
"also",
"handle",
"FragmentDefinition",
"as",
"root",
"node",
"then",
"all",
"the",
"c... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js#L206-L240 | train | Returns the DOM nodes of the given fragment | [
30522,
3853,
1006,
1997,
29181,
3672,
1010,
15765,
28139,
8873,
2595,
1007,
1063,
13075,
6728,
11650,
11510,
29165,
1027,
20950,
16001,
4842,
1012,
2131,
19362,
19763,
18933,
2099,
1006,
1997,
29181,
3672,
1007,
1025,
2065,
1006,
6728,
11650,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/search.js | searchBar_checkSearchResultPage | function searchBar_checkSearchResultPage(searchTerm) {
// Retrieve the URL which is used for the currently selected search engine
var targetUrl = this._bss.currentEngine.getSubmission(searchTerm, null).uri;
var currentUrl = this._controller.tabs.activeTabWindow.document.location.href;
// Check if pure domain names are identical
var domainName = targetUrl.host.replace(/.+\.(\w+)\.\w+$/gi, "$1");
var index = currentUrl.indexOf(domainName);
this._controller.assertJS("subject.URLContainsDomain == true",
{URLContainsDomain: currentUrl.indexOf(domainName) != -1});
// Check if search term is listed in URL
this._controller.assertJS("subject.URLContainsText == true",
{URLContainsText: currentUrl.toLowerCase().indexOf(searchTerm.toLowerCase()) != -1});
} | javascript | function searchBar_checkSearchResultPage(searchTerm) {
// Retrieve the URL which is used for the currently selected search engine
var targetUrl = this._bss.currentEngine.getSubmission(searchTerm, null).uri;
var currentUrl = this._controller.tabs.activeTabWindow.document.location.href;
// Check if pure domain names are identical
var domainName = targetUrl.host.replace(/.+\.(\w+)\.\w+$/gi, "$1");
var index = currentUrl.indexOf(domainName);
this._controller.assertJS("subject.URLContainsDomain == true",
{URLContainsDomain: currentUrl.indexOf(domainName) != -1});
// Check if search term is listed in URL
this._controller.assertJS("subject.URLContainsText == true",
{URLContainsText: currentUrl.toLowerCase().indexOf(searchTerm.toLowerCase()) != -1});
} | [
"function",
"searchBar_checkSearchResultPage",
"(",
"searchTerm",
")",
"{",
"// Retrieve the URL which is used for the currently selected search engine",
"var",
"targetUrl",
"=",
"this",
".",
"_bss",
".",
"currentEngine",
".",
"getSubmission",
"(",
"searchTerm",
",",
"null",
... | Checks if the correct target URL has been opened for the search
@param {string} searchTerm
Text which should be checked for | [
"Checks",
"if",
"the",
"correct",
"target",
"URL",
"has",
"been",
"opened",
"for",
"the",
"search"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/search.js#L513-L528 | train | Checks if the search term is listed in the current search engine | [
30522,
3853,
3945,
8237,
1035,
14148,
14644,
2818,
6072,
11314,
13704,
1006,
3945,
3334,
2213,
1007,
1063,
1013,
1013,
12850,
1996,
24471,
2140,
2029,
2003,
2109,
2005,
1996,
2747,
3479,
3945,
3194,
13075,
4539,
3126,
2140,
1027,
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... |
dequelabs/axe-core | lib/core/utils/scroll-state.js | setScroll | function setScroll(elm, top, left) {
if (elm === window) {
return elm.scroll(left, top);
} else {
elm.scrollTop = top;
elm.scrollLeft = left;
}
} | javascript | function setScroll(elm, top, left) {
if (elm === window) {
return elm.scroll(left, top);
} else {
elm.scrollTop = top;
elm.scrollLeft = left;
}
} | [
"function",
"setScroll",
"(",
"elm",
",",
"top",
",",
"left",
")",
"{",
"if",
"(",
"elm",
"===",
"window",
")",
"{",
"return",
"elm",
".",
"scroll",
"(",
"left",
",",
"top",
")",
";",
"}",
"else",
"{",
"elm",
".",
"scrollTop",
"=",
"top",
";",
... | set the scroll position of an element | [
"set",
"the",
"scroll",
"position",
"of",
"an",
"element"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/scroll-state.js#L21-L28 | train | set scroll position | [
30522,
3853,
4520,
26775,
14511,
1006,
17709,
1010,
2327,
1010,
2187,
1007,
1063,
2065,
1006,
17709,
1027,
1027,
1027,
3332,
1007,
1063,
2709,
17709,
1012,
17186,
1006,
2187,
1010,
2327,
1007,
1025,
1065,
2842,
1063,
17709,
1012,
17186,
143... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableRendererUtils.js | function(rm, oTable, oConfig) {
oConfig = oConfig || {};
rm.write("<", oConfig.tag || "div");
TAGCONTEXT = oConfig;
if (oConfig.furtherSettings) {
oConfig.furtherSettings(rm, oTable);
}
if (Array.isArray(oConfig.classname) && oConfig.classname.length) {
for (var i = 0; i < oConfig.classname.length; i++) {
TableRendererUtils.addClass(rm, oConfig.classname[i]);
}
} else if (oConfig.classname) {
TableRendererUtils.addClass(rm, oConfig.classname);
}
if (oConfig.id) {
rm.writeAttribute("id", (oConfig.element || oTable).getId() + "-" + oConfig.id);
} else if (oConfig.element) {
if (oConfig.element instanceof Control) {
rm.writeControlData(oConfig.element);
} else {
rm.writeElementData(oConfig.element);
}
}
if (oConfig.attributes) {
for (var name in oConfig.attributes) {
if (oConfig.attributes.hasOwnProperty(name)) {
rm.writeAttribute(name, oConfig.attributes[name]);
}
}
}
if (typeof oConfig.tabindex === "number") {
rm.writeAttribute("tabindex", "" + oConfig.tabindex);
}
if (oConfig.aria) {
oTable._getAccRenderExtension().writeAriaAttributesFor(rm, oTable, oConfig.aria, oConfig.ariaconfig);
}
if (TAGCONTEXT.writeClasses) {
rm.writeClasses();
}
if (TAGCONTEXT.writeStyles) {
rm.writeStyles();
}
TAGCONTEXT = null;
rm.write(">");
return TableRendererUtils;
} | javascript | function(rm, oTable, oConfig) {
oConfig = oConfig || {};
rm.write("<", oConfig.tag || "div");
TAGCONTEXT = oConfig;
if (oConfig.furtherSettings) {
oConfig.furtherSettings(rm, oTable);
}
if (Array.isArray(oConfig.classname) && oConfig.classname.length) {
for (var i = 0; i < oConfig.classname.length; i++) {
TableRendererUtils.addClass(rm, oConfig.classname[i]);
}
} else if (oConfig.classname) {
TableRendererUtils.addClass(rm, oConfig.classname);
}
if (oConfig.id) {
rm.writeAttribute("id", (oConfig.element || oTable).getId() + "-" + oConfig.id);
} else if (oConfig.element) {
if (oConfig.element instanceof Control) {
rm.writeControlData(oConfig.element);
} else {
rm.writeElementData(oConfig.element);
}
}
if (oConfig.attributes) {
for (var name in oConfig.attributes) {
if (oConfig.attributes.hasOwnProperty(name)) {
rm.writeAttribute(name, oConfig.attributes[name]);
}
}
}
if (typeof oConfig.tabindex === "number") {
rm.writeAttribute("tabindex", "" + oConfig.tabindex);
}
if (oConfig.aria) {
oTable._getAccRenderExtension().writeAriaAttributesFor(rm, oTable, oConfig.aria, oConfig.ariaconfig);
}
if (TAGCONTEXT.writeClasses) {
rm.writeClasses();
}
if (TAGCONTEXT.writeStyles) {
rm.writeStyles();
}
TAGCONTEXT = null;
rm.write(">");
return TableRendererUtils;
} | [
"function",
"(",
"rm",
",",
"oTable",
",",
"oConfig",
")",
"{",
"oConfig",
"=",
"oConfig",
"||",
"{",
"}",
";",
"rm",
".",
"write",
"(",
"\"<\"",
",",
"oConfig",
".",
"tag",
"||",
"\"div\"",
")",
";",
"TAGCONTEXT",
"=",
"oConfig",
";",
"if",
"(",
... | Writes the starting tag of an element with the given settings.
@param {sap.ui.core.RenderManager} rm Instance of the rendermanager
@param {sap.ui.table.Table} oTable Instance of the table
@param {object} oConfig the configuration of the start tag
@param {string} [oConfig.tag] The tag type which should be used. If nothing is given <code>div</code> is used.
@param {string|string[]} [oConfig.classname] CSS class(es) which should be added to the element.
@param {string} [oConfig.id] The id which should be used. The id is automatically prefixed with the id of the <code>oTable</code>
of with the id of <code>oConfig.element</code> (if given).
@param {sap.ui.core.Element} [oConfig.element] If an id is given, the id is prefixed with the id of <code>oConfig.element</code>. If no id is given
the control/element data of this element is written.
@param {number} [oConfig.tabindex] The value of the tabindex attribute, if needed.
@param {object} [oConfig.attributes] Map of name value pairs of further attributes which should be written (NOTE: No escaping is done!)
@param {string} [oConfig.aria] The key as defined in the AccRenderExtension to render the aria attributes (see writeAriaAttributesFor)
@param {object} [oConfig.ariaconfig] Map of further aria configurations (see <code>writeAriaAttributesFor</code>)
@param {function} [oConfig.furtherSettings] Callback function which can be used for additional settings (which are not covered by the features of this function)
on the start element
@param {boolean} [oConfig.writeClasses] Whether the <code>writeClasses</code> function of the render manager should be called. This flag is automatically set
when the <code>classname</code> attribute is given or when the <code>TableRendererUtils.addClass</code> function is
used within the <code>furtherSettings</code> callback.
@param {boolean} [oConfig.writeStyles] Whether the <code>writeStyles</code> function of the render manager should be called. This flag is automatically set
when the <code>TableRendererUtils.addStyle</code> function is used within the <code>furtherSettings</code> callback.
@returns TableRendererUtils to allow method chaining
@private | [
"Writes",
"the",
"starting",
"tag",
"of",
"an",
"element",
"with",
"the",
"given",
"settings",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableRendererUtils.js#L92-L146 | train | Writes the markup for the control | [
30522,
3853,
1006,
28549,
1010,
27178,
3085,
1010,
1051,
8663,
8873,
2290,
1007,
1063,
1051,
8663,
8873,
2290,
1027,
1051,
8663,
8873,
2290,
1064,
1064,
1063,
1065,
1025,
28549,
1012,
4339,
1006,
1000,
1026,
1000,
1010,
1051,
8663,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/multiline-ternary.js | reportError | function reportError(node, parentNode, expected) {
context.report({
node,
messageId: `${expected ? "expected" : "unexpected"}${node === parentNode.test ? "TestCons" : "ConsAlt"}`
});
} | javascript | function reportError(node, parentNode, expected) {
context.report({
node,
messageId: `${expected ? "expected" : "unexpected"}${node === parentNode.test ? "TestCons" : "ConsAlt"}`
});
} | [
"function",
"reportError",
"(",
"node",
",",
"parentNode",
",",
"expected",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"messageId",
":",
"`",
"${",
"expected",
"?",
"\"expected\"",
":",
"\"unexpected\"",
"}",
"${",
"node",
"===",
"parentNod... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Tests whether node is preceded by supplied tokens
@param {ASTNode} node - node to check
@param {ASTNode} parentNode - parent of node to report
@param {boolean} expected - whether newline was expected or not
@returns {void}
@private | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Tests",
"whether",
"node",
"is",
"preceded",
"by",
"supplied",
"tokens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-ternary.js#L55-L60 | train | Report an error if the node is not expected | [
30522,
3853,
6398,
29165,
1006,
13045,
1010,
6687,
3630,
3207,
1010,
3517,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
4471,
3593,
1024,
1036,
1002,
1063,
3517,
1029,
1000,
3517,
1000,
1024,
1000,
9223,
1000,
1065,
1002,
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... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | function(chartArea) {
var me = this;
var options = me.options;
if (!me._isVisible()) {
return;
}
var chart = me.chart;
var context = me.ctx;
var globalDefaults = core_defaults.global;
var defaultFontColor = globalDefaults.defaultFontColor;
var optionTicks = options.ticks.minor;
var optionMajorTicks = options.ticks.major || optionTicks;
var gridLines = options.gridLines;
var scaleLabel = options.scaleLabel;
var position = options.position;
var isRotated = me.labelRotation !== 0;
var isMirrored = optionTicks.mirror;
var isHorizontal = me.isHorizontal();
var parseFont = helpers$1.options._parseFont;
var ticks = optionTicks.display && optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
var tickFontColor = valueOrDefault$9(optionTicks.fontColor, defaultFontColor);
var tickFont = parseFont(optionTicks);
var lineHeight = tickFont.lineHeight;
var majorTickFontColor = valueOrDefault$9(optionMajorTicks.fontColor, defaultFontColor);
var majorTickFont = parseFont(optionMajorTicks);
var tickPadding = optionTicks.padding;
var labelOffset = optionTicks.labelOffset;
var tl = gridLines.drawTicks ? gridLines.tickMarkLength : 0;
var scaleLabelFontColor = valueOrDefault$9(scaleLabel.fontColor, defaultFontColor);
var scaleLabelFont = parseFont(scaleLabel);
var scaleLabelPadding = helpers$1.options.toPadding(scaleLabel.padding);
var labelRotationRadians = helpers$1.toRadians(me.labelRotation);
var itemsToDraw = [];
var axisWidth = gridLines.drawBorder ? valueAtIndexOrDefault(gridLines.lineWidth, 0, 0) : 0;
var alignPixel = helpers$1._alignPixel;
var borderValue, tickStart, tickEnd;
if (position === 'top') {
borderValue = alignPixel(chart, me.bottom, axisWidth);
tickStart = me.bottom - tl;
tickEnd = borderValue - axisWidth / 2;
} else if (position === 'bottom') {
borderValue = alignPixel(chart, me.top, axisWidth);
tickStart = borderValue + axisWidth / 2;
tickEnd = me.top + tl;
} else if (position === 'left') {
borderValue = alignPixel(chart, me.right, axisWidth);
tickStart = me.right - tl;
tickEnd = borderValue - axisWidth / 2;
} else {
borderValue = alignPixel(chart, me.left, axisWidth);
tickStart = borderValue + axisWidth / 2;
tickEnd = me.left + tl;
}
var epsilon = 0.0000001; // 0.0000001 is margin in pixels for Accumulated error.
helpers$1.each(ticks, function(tick, index) {
// autoskipper skipped this tick (#4635)
if (helpers$1.isNullOrUndef(tick.label)) {
return;
}
var label = tick.label;
var lineWidth, lineColor, borderDash, borderDashOffset;
if (index === me.zeroLineIndex && options.offset === gridLines.offsetGridLines) {
// Draw the first index specially
lineWidth = gridLines.zeroLineWidth;
lineColor = gridLines.zeroLineColor;
borderDash = gridLines.zeroLineBorderDash || [];
borderDashOffset = gridLines.zeroLineBorderDashOffset || 0.0;
} else {
lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, index);
lineColor = valueAtIndexOrDefault(gridLines.color, index);
borderDash = gridLines.borderDash || [];
borderDashOffset = gridLines.borderDashOffset || 0.0;
}
// Common properties
var tx1, ty1, tx2, ty2, x1, y1, x2, y2, labelX, labelY, textOffset, textAlign;
var labelCount = helpers$1.isArray(label) ? label.length : 1;
var lineValue = getPixelForGridLine(me, index, gridLines.offsetGridLines);
if (isHorizontal) {
var labelYOffset = tl + tickPadding;
if (lineValue < me.left - epsilon) {
lineColor = 'rgba(0,0,0,0)';
}
tx1 = tx2 = x1 = x2 = alignPixel(chart, lineValue, lineWidth);
ty1 = tickStart;
ty2 = tickEnd;
labelX = me.getPixelForTick(index) + labelOffset; // x values for optionTicks (need to consider offsetLabel option)
if (position === 'top') {
y1 = alignPixel(chart, chartArea.top, axisWidth) + axisWidth / 2;
y2 = chartArea.bottom;
textOffset = ((!isRotated ? 0.5 : 1) - labelCount) * lineHeight;
textAlign = !isRotated ? 'center' : 'left';
labelY = me.bottom - labelYOffset;
} else {
y1 = chartArea.top;
y2 = alignPixel(chart, chartArea.bottom, axisWidth) - axisWidth / 2;
textOffset = (!isRotated ? 0.5 : 0) * lineHeight;
textAlign = !isRotated ? 'center' : 'right';
labelY = me.top + labelYOffset;
}
} else {
var labelXOffset = (isMirrored ? 0 : tl) + tickPadding;
if (lineValue < me.top - epsilon) {
lineColor = 'rgba(0,0,0,0)';
}
tx1 = tickStart;
tx2 = tickEnd;
ty1 = ty2 = y1 = y2 = alignPixel(chart, lineValue, lineWidth);
labelY = me.getPixelForTick(index) + labelOffset;
textOffset = (1 - labelCount) * lineHeight / 2;
if (position === 'left') {
x1 = alignPixel(chart, chartArea.left, axisWidth) + axisWidth / 2;
x2 = chartArea.right;
textAlign = isMirrored ? 'left' : 'right';
labelX = me.right - labelXOffset;
} else {
x1 = chartArea.left;
x2 = alignPixel(chart, chartArea.right, axisWidth) - axisWidth / 2;
textAlign = isMirrored ? 'right' : 'left';
labelX = me.left + labelXOffset;
}
}
itemsToDraw.push({
tx1: tx1,
ty1: ty1,
tx2: tx2,
ty2: ty2,
x1: x1,
y1: y1,
x2: x2,
y2: y2,
labelX: labelX,
labelY: labelY,
glWidth: lineWidth,
glColor: lineColor,
glBorderDash: borderDash,
glBorderDashOffset: borderDashOffset,
rotation: -1 * labelRotationRadians,
label: label,
major: tick.major,
textOffset: textOffset,
textAlign: textAlign
});
});
// Draw all of the tick labels, tick marks, and grid lines at the correct places
helpers$1.each(itemsToDraw, function(itemToDraw) {
var glWidth = itemToDraw.glWidth;
var glColor = itemToDraw.glColor;
if (gridLines.display && glWidth && glColor) {
context.save();
context.lineWidth = glWidth;
context.strokeStyle = glColor;
if (context.setLineDash) {
context.setLineDash(itemToDraw.glBorderDash);
context.lineDashOffset = itemToDraw.glBorderDashOffset;
}
context.beginPath();
if (gridLines.drawTicks) {
context.moveTo(itemToDraw.tx1, itemToDraw.ty1);
context.lineTo(itemToDraw.tx2, itemToDraw.ty2);
}
if (gridLines.drawOnChartArea) {
context.moveTo(itemToDraw.x1, itemToDraw.y1);
context.lineTo(itemToDraw.x2, itemToDraw.y2);
}
context.stroke();
context.restore();
}
if (optionTicks.display) {
// Make sure we draw text in the correct color and font
context.save();
context.translate(itemToDraw.labelX, itemToDraw.labelY);
context.rotate(itemToDraw.rotation);
context.font = itemToDraw.major ? majorTickFont.string : tickFont.string;
context.fillStyle = itemToDraw.major ? majorTickFontColor : tickFontColor;
context.textBaseline = 'middle';
context.textAlign = itemToDraw.textAlign;
var label = itemToDraw.label;
var y = itemToDraw.textOffset;
if (helpers$1.isArray(label)) {
for (var i = 0; i < label.length; ++i) {
// We just make sure the multiline element is a string here..
context.fillText('' + label[i], 0, y);
y += lineHeight;
}
} else {
context.fillText(label, 0, y);
}
context.restore();
}
});
if (scaleLabel.display) {
// Draw the scale label
var scaleLabelX;
var scaleLabelY;
var rotation = 0;
var halfLineHeight = scaleLabelFont.lineHeight / 2;
if (isHorizontal) {
scaleLabelX = me.left + ((me.right - me.left) / 2); // midpoint of the width
scaleLabelY = position === 'bottom'
? me.bottom - halfLineHeight - scaleLabelPadding.bottom
: me.top + halfLineHeight + scaleLabelPadding.top;
} else {
var isLeft = position === 'left';
scaleLabelX = isLeft
? me.left + halfLineHeight + scaleLabelPadding.top
: me.right - halfLineHeight - scaleLabelPadding.top;
scaleLabelY = me.top + ((me.bottom - me.top) / 2);
rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
}
context.save();
context.translate(scaleLabelX, scaleLabelY);
context.rotate(rotation);
context.textAlign = 'center';
context.textBaseline = 'middle';
context.fillStyle = scaleLabelFontColor; // render in correct colour
context.font = scaleLabelFont.string;
context.fillText(scaleLabel.labelString, 0, 0);
context.restore();
}
if (axisWidth) {
// Draw the line at the edge of the axis
var firstLineWidth = axisWidth;
var lastLineWidth = valueAtIndexOrDefault(gridLines.lineWidth, ticks.length - 1, 0);
var x1, x2, y1, y2;
if (isHorizontal) {
x1 = alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2;
x2 = alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2;
y1 = y2 = borderValue;
} else {
y1 = alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2;
y2 = alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2;
x1 = x2 = borderValue;
}
context.lineWidth = axisWidth;
context.strokeStyle = valueAtIndexOrDefault(gridLines.color, 0);
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke();
}
} | javascript | function(chartArea) {
var me = this;
var options = me.options;
if (!me._isVisible()) {
return;
}
var chart = me.chart;
var context = me.ctx;
var globalDefaults = core_defaults.global;
var defaultFontColor = globalDefaults.defaultFontColor;
var optionTicks = options.ticks.minor;
var optionMajorTicks = options.ticks.major || optionTicks;
var gridLines = options.gridLines;
var scaleLabel = options.scaleLabel;
var position = options.position;
var isRotated = me.labelRotation !== 0;
var isMirrored = optionTicks.mirror;
var isHorizontal = me.isHorizontal();
var parseFont = helpers$1.options._parseFont;
var ticks = optionTicks.display && optionTicks.autoSkip ? me._autoSkip(me.getTicks()) : me.getTicks();
var tickFontColor = valueOrDefault$9(optionTicks.fontColor, defaultFontColor);
var tickFont = parseFont(optionTicks);
var lineHeight = tickFont.lineHeight;
var majorTickFontColor = valueOrDefault$9(optionMajorTicks.fontColor, defaultFontColor);
var majorTickFont = parseFont(optionMajorTicks);
var tickPadding = optionTicks.padding;
var labelOffset = optionTicks.labelOffset;
var tl = gridLines.drawTicks ? gridLines.tickMarkLength : 0;
var scaleLabelFontColor = valueOrDefault$9(scaleLabel.fontColor, defaultFontColor);
var scaleLabelFont = parseFont(scaleLabel);
var scaleLabelPadding = helpers$1.options.toPadding(scaleLabel.padding);
var labelRotationRadians = helpers$1.toRadians(me.labelRotation);
var itemsToDraw = [];
var axisWidth = gridLines.drawBorder ? valueAtIndexOrDefault(gridLines.lineWidth, 0, 0) : 0;
var alignPixel = helpers$1._alignPixel;
var borderValue, tickStart, tickEnd;
if (position === 'top') {
borderValue = alignPixel(chart, me.bottom, axisWidth);
tickStart = me.bottom - tl;
tickEnd = borderValue - axisWidth / 2;
} else if (position === 'bottom') {
borderValue = alignPixel(chart, me.top, axisWidth);
tickStart = borderValue + axisWidth / 2;
tickEnd = me.top + tl;
} else if (position === 'left') {
borderValue = alignPixel(chart, me.right, axisWidth);
tickStart = me.right - tl;
tickEnd = borderValue - axisWidth / 2;
} else {
borderValue = alignPixel(chart, me.left, axisWidth);
tickStart = borderValue + axisWidth / 2;
tickEnd = me.left + tl;
}
var epsilon = 0.0000001; // 0.0000001 is margin in pixels for Accumulated error.
helpers$1.each(ticks, function(tick, index) {
// autoskipper skipped this tick (#4635)
if (helpers$1.isNullOrUndef(tick.label)) {
return;
}
var label = tick.label;
var lineWidth, lineColor, borderDash, borderDashOffset;
if (index === me.zeroLineIndex && options.offset === gridLines.offsetGridLines) {
// Draw the first index specially
lineWidth = gridLines.zeroLineWidth;
lineColor = gridLines.zeroLineColor;
borderDash = gridLines.zeroLineBorderDash || [];
borderDashOffset = gridLines.zeroLineBorderDashOffset || 0.0;
} else {
lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, index);
lineColor = valueAtIndexOrDefault(gridLines.color, index);
borderDash = gridLines.borderDash || [];
borderDashOffset = gridLines.borderDashOffset || 0.0;
}
// Common properties
var tx1, ty1, tx2, ty2, x1, y1, x2, y2, labelX, labelY, textOffset, textAlign;
var labelCount = helpers$1.isArray(label) ? label.length : 1;
var lineValue = getPixelForGridLine(me, index, gridLines.offsetGridLines);
if (isHorizontal) {
var labelYOffset = tl + tickPadding;
if (lineValue < me.left - epsilon) {
lineColor = 'rgba(0,0,0,0)';
}
tx1 = tx2 = x1 = x2 = alignPixel(chart, lineValue, lineWidth);
ty1 = tickStart;
ty2 = tickEnd;
labelX = me.getPixelForTick(index) + labelOffset; // x values for optionTicks (need to consider offsetLabel option)
if (position === 'top') {
y1 = alignPixel(chart, chartArea.top, axisWidth) + axisWidth / 2;
y2 = chartArea.bottom;
textOffset = ((!isRotated ? 0.5 : 1) - labelCount) * lineHeight;
textAlign = !isRotated ? 'center' : 'left';
labelY = me.bottom - labelYOffset;
} else {
y1 = chartArea.top;
y2 = alignPixel(chart, chartArea.bottom, axisWidth) - axisWidth / 2;
textOffset = (!isRotated ? 0.5 : 0) * lineHeight;
textAlign = !isRotated ? 'center' : 'right';
labelY = me.top + labelYOffset;
}
} else {
var labelXOffset = (isMirrored ? 0 : tl) + tickPadding;
if (lineValue < me.top - epsilon) {
lineColor = 'rgba(0,0,0,0)';
}
tx1 = tickStart;
tx2 = tickEnd;
ty1 = ty2 = y1 = y2 = alignPixel(chart, lineValue, lineWidth);
labelY = me.getPixelForTick(index) + labelOffset;
textOffset = (1 - labelCount) * lineHeight / 2;
if (position === 'left') {
x1 = alignPixel(chart, chartArea.left, axisWidth) + axisWidth / 2;
x2 = chartArea.right;
textAlign = isMirrored ? 'left' : 'right';
labelX = me.right - labelXOffset;
} else {
x1 = chartArea.left;
x2 = alignPixel(chart, chartArea.right, axisWidth) - axisWidth / 2;
textAlign = isMirrored ? 'right' : 'left';
labelX = me.left + labelXOffset;
}
}
itemsToDraw.push({
tx1: tx1,
ty1: ty1,
tx2: tx2,
ty2: ty2,
x1: x1,
y1: y1,
x2: x2,
y2: y2,
labelX: labelX,
labelY: labelY,
glWidth: lineWidth,
glColor: lineColor,
glBorderDash: borderDash,
glBorderDashOffset: borderDashOffset,
rotation: -1 * labelRotationRadians,
label: label,
major: tick.major,
textOffset: textOffset,
textAlign: textAlign
});
});
// Draw all of the tick labels, tick marks, and grid lines at the correct places
helpers$1.each(itemsToDraw, function(itemToDraw) {
var glWidth = itemToDraw.glWidth;
var glColor = itemToDraw.glColor;
if (gridLines.display && glWidth && glColor) {
context.save();
context.lineWidth = glWidth;
context.strokeStyle = glColor;
if (context.setLineDash) {
context.setLineDash(itemToDraw.glBorderDash);
context.lineDashOffset = itemToDraw.glBorderDashOffset;
}
context.beginPath();
if (gridLines.drawTicks) {
context.moveTo(itemToDraw.tx1, itemToDraw.ty1);
context.lineTo(itemToDraw.tx2, itemToDraw.ty2);
}
if (gridLines.drawOnChartArea) {
context.moveTo(itemToDraw.x1, itemToDraw.y1);
context.lineTo(itemToDraw.x2, itemToDraw.y2);
}
context.stroke();
context.restore();
}
if (optionTicks.display) {
// Make sure we draw text in the correct color and font
context.save();
context.translate(itemToDraw.labelX, itemToDraw.labelY);
context.rotate(itemToDraw.rotation);
context.font = itemToDraw.major ? majorTickFont.string : tickFont.string;
context.fillStyle = itemToDraw.major ? majorTickFontColor : tickFontColor;
context.textBaseline = 'middle';
context.textAlign = itemToDraw.textAlign;
var label = itemToDraw.label;
var y = itemToDraw.textOffset;
if (helpers$1.isArray(label)) {
for (var i = 0; i < label.length; ++i) {
// We just make sure the multiline element is a string here..
context.fillText('' + label[i], 0, y);
y += lineHeight;
}
} else {
context.fillText(label, 0, y);
}
context.restore();
}
});
if (scaleLabel.display) {
// Draw the scale label
var scaleLabelX;
var scaleLabelY;
var rotation = 0;
var halfLineHeight = scaleLabelFont.lineHeight / 2;
if (isHorizontal) {
scaleLabelX = me.left + ((me.right - me.left) / 2); // midpoint of the width
scaleLabelY = position === 'bottom'
? me.bottom - halfLineHeight - scaleLabelPadding.bottom
: me.top + halfLineHeight + scaleLabelPadding.top;
} else {
var isLeft = position === 'left';
scaleLabelX = isLeft
? me.left + halfLineHeight + scaleLabelPadding.top
: me.right - halfLineHeight - scaleLabelPadding.top;
scaleLabelY = me.top + ((me.bottom - me.top) / 2);
rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;
}
context.save();
context.translate(scaleLabelX, scaleLabelY);
context.rotate(rotation);
context.textAlign = 'center';
context.textBaseline = 'middle';
context.fillStyle = scaleLabelFontColor; // render in correct colour
context.font = scaleLabelFont.string;
context.fillText(scaleLabel.labelString, 0, 0);
context.restore();
}
if (axisWidth) {
// Draw the line at the edge of the axis
var firstLineWidth = axisWidth;
var lastLineWidth = valueAtIndexOrDefault(gridLines.lineWidth, ticks.length - 1, 0);
var x1, x2, y1, y2;
if (isHorizontal) {
x1 = alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2;
x2 = alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2;
y1 = y2 = borderValue;
} else {
y1 = alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2;
y2 = alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2;
x1 = x2 = borderValue;
}
context.lineWidth = axisWidth;
context.strokeStyle = valueAtIndexOrDefault(gridLines.color, 0);
context.beginPath();
context.moveTo(x1, y1);
context.lineTo(x2, y2);
context.stroke();
}
} | [
"function",
"(",
"chartArea",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"options",
"=",
"me",
".",
"options",
";",
"if",
"(",
"!",
"me",
".",
"_isVisible",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"chart",
"=",
"me",
".",
"chart",
"... | Actually draw the scale on the canvas
@param {object} chartArea - the area of the chart to draw full grid lines on | [
"Actually",
"draw",
"the",
"scale",
"on",
"the",
"canvas"
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L10849-L11124 | train | Draw the ticks and labels | [
30522,
3853,
1006,
3673,
12069,
2050,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
7047,
1027,
2033,
1012,
7047,
1025,
2065,
1006,
999,
2033,
1012,
1035,
2003,
11365,
7028,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
13075,
3673,
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/plugins/resolveVersion.js | initNPM | function initNPM() {
if (npmIsReady) return npmIsReady;
npmIsReady = Promise.nfcall(npm.load, {
silent: true,
loglevel: 'silent'
});
return npmIsReady;
} | javascript | function initNPM() {
if (npmIsReady) return npmIsReady;
npmIsReady = Promise.nfcall(npm.load, {
silent: true,
loglevel: 'silent'
});
return npmIsReady;
} | [
"function",
"initNPM",
"(",
")",
"{",
"if",
"(",
"npmIsReady",
")",
"return",
"npmIsReady",
";",
"npmIsReady",
"=",
"Promise",
".",
"nfcall",
"(",
"npm",
".",
"load",
",",
"{",
"silent",
":",
"true",
",",
"loglevel",
":",
"'silent'",
"}",
")",
";",
"... | Initialize and prepare NPM
@return {Promise} | [
"Initialize",
"and",
"prepare",
"NPM"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/resolveVersion.js#L16-L25 | train | init NPM | [
30522,
3853,
1999,
4183,
16275,
2213,
1006,
1007,
1063,
2065,
1006,
27937,
15630,
16416,
5149,
1007,
2709,
27937,
15630,
16416,
5149,
1025,
27937,
15630,
16416,
5149,
1027,
4872,
1012,
22309,
8095,
1006,
27937,
2213,
1012,
7170,
1010,
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... |
tensorflow/tfjs-models | knn-classifier/demo/camera.js | setupGui | function setupGui() {
// Create training buttons and info texts
for (let i = 0; i < NUM_CLASSES; i++) {
const div = document.createElement('div');
document.body.appendChild(div);
div.style.marginBottom = '10px';
// Create training button
const button = document.createElement('button');
button.innerText = 'Train ' + i;
div.appendChild(button);
// Listen for mouse events when clicking the button
button.addEventListener('click', () => {
training = i;
requestAnimationFrame(() => training = -1);
});
// Create info text
const infoText = document.createElement('span');
infoText.innerText = ' No examples added';
div.appendChild(infoText);
infoTexts.push(infoText);
}
} | javascript | function setupGui() {
// Create training buttons and info texts
for (let i = 0; i < NUM_CLASSES; i++) {
const div = document.createElement('div');
document.body.appendChild(div);
div.style.marginBottom = '10px';
// Create training button
const button = document.createElement('button');
button.innerText = 'Train ' + i;
div.appendChild(button);
// Listen for mouse events when clicking the button
button.addEventListener('click', () => {
training = i;
requestAnimationFrame(() => training = -1);
});
// Create info text
const infoText = document.createElement('span');
infoText.innerText = ' No examples added';
div.appendChild(infoText);
infoTexts.push(infoText);
}
} | [
"function",
"setupGui",
"(",
")",
"{",
"// Create training buttons and info texts",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"NUM_CLASSES",
";",
"i",
"++",
")",
"{",
"const",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"... | Setup training GUI. Adds a training button for each class,
and sets up mouse events. | [
"Setup",
"training",
"GUI",
".",
"Adds",
"a",
"training",
"button",
"for",
"each",
"class",
"and",
"sets",
"up",
"mouse",
"events",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/knn-classifier/demo/camera.js#L87-L111 | train | Creates the GUI for the training buttons | [
30522,
3853,
16437,
25698,
1006,
1007,
1063,
1013,
1013,
3443,
2731,
11287,
1998,
18558,
6981,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
16371,
2213,
1035,
4280,
1025,
1045,
1009,
1009,
1007,
1063,
9530,
3367,
4487,
2615,
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... |
aws/aws-sdk-js | lib/service.js | Service | function Service(config) {
if (!this.loadServiceClass) {
throw AWS.util.error(new Error(),
'Service must be constructed with `new\' operator');
}
var ServiceClass = this.loadServiceClass(config || {});
if (ServiceClass) {
var originalConfig = AWS.util.copy(config);
var svc = new ServiceClass(config);
Object.defineProperty(svc, '_originalConfig', {
get: function() { return originalConfig; },
enumerable: false,
configurable: true
});
svc._clientId = ++clientCount;
return svc;
}
this.initialize(config);
} | javascript | function Service(config) {
if (!this.loadServiceClass) {
throw AWS.util.error(new Error(),
'Service must be constructed with `new\' operator');
}
var ServiceClass = this.loadServiceClass(config || {});
if (ServiceClass) {
var originalConfig = AWS.util.copy(config);
var svc = new ServiceClass(config);
Object.defineProperty(svc, '_originalConfig', {
get: function() { return originalConfig; },
enumerable: false,
configurable: true
});
svc._clientId = ++clientCount;
return svc;
}
this.initialize(config);
} | [
"function",
"Service",
"(",
"config",
")",
"{",
"if",
"(",
"!",
"this",
".",
"loadServiceClass",
")",
"{",
"throw",
"AWS",
".",
"util",
".",
"error",
"(",
"new",
"Error",
"(",
")",
",",
"'Service must be constructed with `new\\' operator'",
")",
";",
"}",
... | Create a new service object with a configuration object
@param config [map] a map of configuration options | [
"Create",
"a",
"new",
"service",
"object",
"with",
"a",
"configuration",
"object"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L23-L41 | train | Creates a new Service instance | [
30522,
3853,
2326,
1006,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
999,
2023,
1012,
15665,
2121,
7903,
8586,
27102,
1007,
1063,
5466,
22091,
2015,
1012,
21183,
4014,
1012,
7561,
1006,
2047,
7561,
1006,
1007,
1010,
1005,
2326,
2442,
2022,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/examples/run-example-e2e.js | runProtractorAoT | function runProtractorAoT(appDir, outputFile) {
fs.appendFileSync(outputFile, '++ AoT version ++\n');
const aotBuildSpawnInfo = spawnExt('yarn', ['build:aot'], {cwd: appDir});
let promise = aotBuildSpawnInfo.promise;
const copyFileCmd = 'copy-dist-files.js';
if (fs.existsSync(appDir + '/' + copyFileCmd)) {
promise = promise.then(() => spawnExt('node', [copyFileCmd], {cwd: appDir}).promise);
}
const aotRunSpawnInfo = spawnExt('yarn', ['serve:aot'], {cwd: appDir}, true);
return runProtractorSystemJS(promise, appDir, aotRunSpawnInfo, outputFile);
} | javascript | function runProtractorAoT(appDir, outputFile) {
fs.appendFileSync(outputFile, '++ AoT version ++\n');
const aotBuildSpawnInfo = spawnExt('yarn', ['build:aot'], {cwd: appDir});
let promise = aotBuildSpawnInfo.promise;
const copyFileCmd = 'copy-dist-files.js';
if (fs.existsSync(appDir + '/' + copyFileCmd)) {
promise = promise.then(() => spawnExt('node', [copyFileCmd], {cwd: appDir}).promise);
}
const aotRunSpawnInfo = spawnExt('yarn', ['serve:aot'], {cwd: appDir}, true);
return runProtractorSystemJS(promise, appDir, aotRunSpawnInfo, outputFile);
} | [
"function",
"runProtractorAoT",
"(",
"appDir",
",",
"outputFile",
")",
"{",
"fs",
".",
"appendFileSync",
"(",
"outputFile",
",",
"'++ AoT version ++\\n'",
")",
";",
"const",
"aotBuildSpawnInfo",
"=",
"spawnExt",
"(",
"'yarn'",
",",
"[",
"'build:aot'",
"]",
",",
... | Run e2e tests over the AOT build for projects that examples it. | [
"Run",
"e2e",
"tests",
"over",
"the",
"AOT",
"build",
"for",
"projects",
"that",
"examples",
"it",
"."
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/aio/tools/examples/run-example-e2e.js#L223-L234 | train | Runs the protractor system. js | [
30522,
3853,
2448,
21572,
6494,
16761,
7113,
2102,
1006,
10439,
4305,
2099,
1010,
6434,
8873,
2571,
1007,
1063,
1042,
2015,
30524,
2102,
2544,
1009,
1009,
1032,
1050,
1005,
1007,
1025,
9530,
3367,
20118,
2102,
8569,
4014,
5104,
4502,
7962,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FileSyncManager.js | findExternalChanges | function findExternalChanges(docs) {
toReload = [];
toClose = [];
editConflicts = [];
deleteConflicts = [];
function checkDoc(doc) {
var result = new $.Deferred();
// Check file timestamp / existence
if (doc.isUntitled()) {
result.resolve();
} else if (doc.file.donotWatch) { // Some file might not like to be watched!
result.resolve();
} else {
doc.file.stat(function (err, stat) {
if (!err) {
// Does file's timestamp differ from last sync time on the Document?
var fileTime = stat.mtime.getTime();
if (fileTime !== doc.diskTimestamp.getTime()) {
// If the user has chosen to keep changes that conflict with the
// current state of the file on disk, then do nothing. This means
// that even if the user later undoes back to clean, we won't
// automatically reload the file on window reactivation. We could
// make it do that, but it seems better to be consistent with the
// deletion case below, where it seems clear that you don't want
// to auto-delete the file on window reactivation just because you
// undid back to clean.
if (doc.keepChangesTime !== fileTime) {
if (doc.isDirty) {
editConflicts.push({doc: doc, fileTime: fileTime});
} else {
toReload.push(doc);
}
}
}
result.resolve();
} else {
// File has been deleted externally
if (err === FileSystemError.NOT_FOUND) {
// If the user has chosen to keep changes previously, and the file
// has been deleted, then do nothing. Like the case above, this
// means that even if the user later undoes back to clean, we won't
// then automatically delete the file on window reactivation.
// (We use -1 as the "mod time" to indicate that the file didn't
// exist, since there's no actual modification time to keep track of
// and -1 isn't a valid mod time for a real file.)
if (doc.keepChangesTime !== -1) {
if (doc.isDirty) {
deleteConflicts.push({doc: doc, fileTime: -1});
} else {
toClose.push(doc);
}
}
result.resolve();
} else {
// Some other error fetching metadata: treat as a real error
console.log("Error checking modification status of " + doc.file.fullPath, err);
result.reject();
}
}
});
}
return result.promise();
}
// Check all docs in parallel
// (fail fast b/c we won't continue syncing if there was any error fetching timestamps)
return Async.doInParallel(docs, checkDoc, true);
} | javascript | function findExternalChanges(docs) {
toReload = [];
toClose = [];
editConflicts = [];
deleteConflicts = [];
function checkDoc(doc) {
var result = new $.Deferred();
// Check file timestamp / existence
if (doc.isUntitled()) {
result.resolve();
} else if (doc.file.donotWatch) { // Some file might not like to be watched!
result.resolve();
} else {
doc.file.stat(function (err, stat) {
if (!err) {
// Does file's timestamp differ from last sync time on the Document?
var fileTime = stat.mtime.getTime();
if (fileTime !== doc.diskTimestamp.getTime()) {
// If the user has chosen to keep changes that conflict with the
// current state of the file on disk, then do nothing. This means
// that even if the user later undoes back to clean, we won't
// automatically reload the file on window reactivation. We could
// make it do that, but it seems better to be consistent with the
// deletion case below, where it seems clear that you don't want
// to auto-delete the file on window reactivation just because you
// undid back to clean.
if (doc.keepChangesTime !== fileTime) {
if (doc.isDirty) {
editConflicts.push({doc: doc, fileTime: fileTime});
} else {
toReload.push(doc);
}
}
}
result.resolve();
} else {
// File has been deleted externally
if (err === FileSystemError.NOT_FOUND) {
// If the user has chosen to keep changes previously, and the file
// has been deleted, then do nothing. Like the case above, this
// means that even if the user later undoes back to clean, we won't
// then automatically delete the file on window reactivation.
// (We use -1 as the "mod time" to indicate that the file didn't
// exist, since there's no actual modification time to keep track of
// and -1 isn't a valid mod time for a real file.)
if (doc.keepChangesTime !== -1) {
if (doc.isDirty) {
deleteConflicts.push({doc: doc, fileTime: -1});
} else {
toClose.push(doc);
}
}
result.resolve();
} else {
// Some other error fetching metadata: treat as a real error
console.log("Error checking modification status of " + doc.file.fullPath, err);
result.reject();
}
}
});
}
return result.promise();
}
// Check all docs in parallel
// (fail fast b/c we won't continue syncing if there was any error fetching timestamps)
return Async.doInParallel(docs, checkDoc, true);
} | [
"function",
"findExternalChanges",
"(",
"docs",
")",
"{",
"toReload",
"=",
"[",
"]",
";",
"toClose",
"=",
"[",
"]",
";",
"editConflicts",
"=",
"[",
"]",
";",
"deleteConflicts",
"=",
"[",
"]",
";",
"function",
"checkDoc",
"(",
"doc",
")",
"{",
"var",
... | Scans all the given Documents for changes on disk, and sorts them into four buckets,
populating the corresponding arrays:
toReload - changed on disk; unchanged within Brackets
toClose - deleted on disk; unchanged within Brackets
editConflicts - changed on disk; also dirty in Brackets
deleteConflicts - deleted on disk; also dirty in Brackets
@param {!Array.<Document>} docs
@return {$.Promise} Resolved when all scanning done, or rejected immediately if there's any
error while reading file timestamps. Errors are logged but no UI is shown. | [
"Scans",
"all",
"the",
"given",
"Documents",
"for",
"changes",
"on",
"disk",
"and",
"sorts",
"them",
"into",
"four",
"buckets",
"populating",
"the",
"corresponding",
"arrays",
":",
"toReload",
"-",
"changed",
"on",
"disk",
";",
"unchanged",
"within",
"Brackets... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileSyncManager.js#L100-L172 | train | Find external changes | [
30522,
3853,
2424,
10288,
16451,
2389,
22305,
2229,
1006,
9986,
2015,
1007,
1063,
9538,
11066,
1027,
1031,
1033,
1025,
2000,
20464,
9232,
1027,
1031,
1033,
1025,
10086,
8663,
29301,
2015,
1027,
1031,
1033,
1025,
3972,
12870,
8663,
29301,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
codemirror/CodeMirror | src/model/changes.js | rebaseHistSelSingle | function rebaseHistSelSingle(pos, from, to, diff) {
if (to < pos.line) {
pos.line += diff
} else if (from < pos.line) {
pos.line = from
pos.ch = 0
}
} | javascript | function rebaseHistSelSingle(pos, from, to, diff) {
if (to < pos.line) {
pos.line += diff
} else if (from < pos.line) {
pos.line = from
pos.ch = 0
}
} | [
"function",
"rebaseHistSelSingle",
"(",
"pos",
",",
"from",
",",
"to",
",",
"diff",
")",
"{",
"if",
"(",
"to",
"<",
"pos",
".",
"line",
")",
"{",
"pos",
".",
"line",
"+=",
"diff",
"}",
"else",
"if",
"(",
"from",
"<",
"pos",
".",
"line",
")",
"{... | Rebasing/resetting history to deal with externally-sourced changes | [
"Rebasing",
"/",
"resetting",
"history",
"to",
"deal",
"with",
"externally",
"-",
"sourced",
"changes"
] | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/model/changes.js#L276-L283 | train | rebase the histsel of a single line | [
30522,
3853,
2128,
15058,
24158,
3215,
9050,
2075,
2571,
1006,
13433,
2015,
1010,
2013,
1010,
2000,
1010,
4487,
4246,
1007,
1063,
2065,
1006,
2000,
1026,
13433,
2015,
1012,
2240,
1007,
1063,
13433,
2015,
1012,
2240,
1009,
1027,
4487,
4246,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function (sBuildTimestamp) {
var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern: "dd.MM.yyyy HH:mm:ss"}),
sBuildDate = oDateFormat.format(this._convertBuildDate(sBuildTimestamp));
return this._getText("TechInfo.VersionBuildTime.Text", sBuildDate);
} | javascript | function (sBuildTimestamp) {
var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({pattern: "dd.MM.yyyy HH:mm:ss"}),
sBuildDate = oDateFormat.format(this._convertBuildDate(sBuildTimestamp));
return this._getText("TechInfo.VersionBuildTime.Text", sBuildDate);
} | [
"function",
"(",
"sBuildTimestamp",
")",
"{",
"var",
"oDateFormat",
"=",
"sap",
".",
"ui",
".",
"core",
".",
"format",
".",
"DateFormat",
".",
"getDateInstance",
"(",
"{",
"pattern",
":",
"\"dd.MM.yyyy HH:mm:ss\"",
"}",
")",
",",
"sBuildDate",
"=",
"oDateFor... | Generates formatted and localized text from passed timestamp
@param {string} sBuildTimestamp Timestamp as string
@private | [
"Generates",
"formatted",
"and",
"localized",
"text",
"from",
"passed",
"timestamp"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L716-L721 | train | Returns the text that represents the build time of the TechInfo. | [
30522,
3853,
1006,
24829,
19231,
11927,
14428,
9153,
8737,
1007,
1063,
13075,
1051,
13701,
14192,
4017,
1027,
20066,
1012,
21318,
1012,
4563,
1012,
4289,
1012,
3058,
14192,
4017,
1012,
2131,
13701,
7076,
26897,
1006,
1063,
5418,
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/LiveDevelopment/Agents/GotoAgent.js | open | function open(url, location, noFlash) {
console.assert(url.substr(0, 7) === "file://", "Cannot open non-file URLs");
var result = new $.Deferred();
url = _urlWithoutQueryString(url);
// Extract the path, also strip the third slash when on Windows
var path = url.slice(brackets.platform === "win" ? 8 : 7);
// URL-decode the path ('%20' => ' ')
path = decodeURI(path);
var promise = CommandManager.execute(Commands.FILE_OPEN, {fullPath: path});
promise.done(function onDone(doc) {
if (location) {
openLocation(location, noFlash);
}
result.resolve();
});
promise.fail(function onErr(err) {
console.error(err);
result.reject(err);
});
return result.promise();
} | javascript | function open(url, location, noFlash) {
console.assert(url.substr(0, 7) === "file://", "Cannot open non-file URLs");
var result = new $.Deferred();
url = _urlWithoutQueryString(url);
// Extract the path, also strip the third slash when on Windows
var path = url.slice(brackets.platform === "win" ? 8 : 7);
// URL-decode the path ('%20' => ' ')
path = decodeURI(path);
var promise = CommandManager.execute(Commands.FILE_OPEN, {fullPath: path});
promise.done(function onDone(doc) {
if (location) {
openLocation(location, noFlash);
}
result.resolve();
});
promise.fail(function onErr(err) {
console.error(err);
result.reject(err);
});
return result.promise();
} | [
"function",
"open",
"(",
"url",
",",
"location",
",",
"noFlash",
")",
"{",
"console",
".",
"assert",
"(",
"url",
".",
"substr",
"(",
"0",
",",
"7",
")",
"===",
"\"file://\"",
",",
"\"Cannot open non-file URLs\"",
")",
";",
"var",
"result",
"=",
"new",
... | Open the editor at the given url and editor location
@param {string} url
@param {integer} optional location in file | [
"Open",
"the",
"editor",
"at",
"the",
"given",
"url",
"and",
"editor",
"location"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/GotoAgent.js#L160-L183 | train | Open a file | [
30522,
3853,
2330,
1006,
24471,
2140,
1010,
3295,
1010,
2053,
10258,
11823,
1007,
1063,
10122,
1012,
20865,
1006,
24471,
2140,
1012,
4942,
3367,
2099,
30524,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
24471,
2140,
1027,
1035,
24471,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | batchData | function batchData(map) {
var cy = this;
return this.batch(function () {
var ids = Object.keys(map);
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var data = map[id];
var ele = cy.getElementById(id);
ele.data(data);
}
});
} | javascript | function batchData(map) {
var cy = this;
return this.batch(function () {
var ids = Object.keys(map);
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var data = map[id];
var ele = cy.getElementById(id);
ele.data(data);
}
});
} | [
"function",
"batchData",
"(",
"map",
")",
"{",
"var",
"cy",
"=",
"this",
";",
"return",
"this",
".",
"batch",
"(",
"function",
"(",
")",
"{",
"var",
"ids",
"=",
"Object",
".",
"keys",
"(",
"map",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",... | for backwards compatibility | [
"for",
"backwards",
"compatibility"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L13604-L13616 | train | Batch data to the database | [
30522,
3853,
14108,
2850,
2696,
1006,
4949,
1007,
1063,
13075,
22330,
1027,
2023,
1025,
2709,
2023,
1012,
14108,
1006,
3853,
1006,
1007,
1063,
13075,
8909,
2015,
1027,
4874,
1012,
6309,
1006,
4949,
1007,
1025,
2005,
1006,
13075,
1045,
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... |
NervJS/taro | packages/taro/src/internal/_common.js | listCacheDelete | function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
} | javascript | function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
} | [
"function",
"listCacheDelete",
"(",
"key",
")",
"{",
"var",
"data",
"=",
"this",
".",
"__data__",
",",
"index",
"=",
"assocIndexOf",
"(",
"data",
",",
"key",
")",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"false",
"}",
"var",
"lastIndex",
"="... | Removes `key` and its value from the list cache.
@private
@name delete
@memberOf ListCache
@param {string} key The key of the value to remove.
@returns {boolean} Returns `true` if the entry was removed, else `false`. | [
"Removes",
"key",
"and",
"its",
"value",
"from",
"the",
"list",
"cache",
"."
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L273-L287 | train | Delete a cache item | [
30522,
3853,
2862,
3540,
7690,
12260,
2618,
1006,
3145,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
1035,
1035,
2951,
1035,
1035,
1010,
5950,
1027,
4632,
10085,
22254,
10288,
11253,
1006,
2951,
1010,
3145,
1007,
2065,
1006,
5950,
1026,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/node/selenium-webdriver/lib/capabilities.js | serialize | function serialize(caps) {
let ret = {};
for (let key of caps.keys()) {
let cap = caps.get(key);
if (cap !== undefined && cap !== null) {
ret[key] = cap;
}
}
return ret;
} | javascript | function serialize(caps) {
let ret = {};
for (let key of caps.keys()) {
let cap = caps.get(key);
if (cap !== undefined && cap !== null) {
ret[key] = cap;
}
}
return ret;
} | [
"function",
"serialize",
"(",
"caps",
")",
"{",
"let",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"key",
"of",
"caps",
".",
"keys",
"(",
")",
")",
"{",
"let",
"cap",
"=",
"caps",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"cap",
"!==",
... | Serializes a capabilities object. This is defined as a standalone function
so it may be type checked (where Capabilities[Symbols.serialize] has type
checking disabled since it is defined with [] access on a struct).
@param {!Capabilities} caps The capabilities to serialize.
@return {!Object<string, ?>} The JSON representation of this instance.
Note, the returned object may contain nested promised values. | [
"Serializes",
"a",
"capabilities",
"object",
".",
"This",
"is",
"defined",
"as",
"a",
"standalone",
"function",
"so",
"it",
"may",
"be",
"type",
"checked",
"(",
"where",
"Capabilities",
"[",
"Symbols",
".",
"serialize",
"]",
"has",
"type",
"checking",
"disab... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/lib/capabilities.js#L527-L536 | train | Serialize a caportar | [
30522,
3853,
7642,
4697,
1006,
9700,
1007,
1063,
2292,
2128,
2102,
1027,
1063,
1065,
1025,
2005,
1006,
2292,
3145,
1997,
9700,
1012,
6309,
1006,
1007,
1007,
1063,
2292,
6178,
1027,
9700,
1012,
2131,
1006,
3145,
1007,
1025,
2065,
1006,
617... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | function(module, shim) {
if ( Array.isArray(shim) ) {
shim = { deps : shim };
}
mShims[module + '.js'] = shim;
} | javascript | function(module, shim) {
if ( Array.isArray(shim) ) {
shim = { deps : shim };
}
mShims[module + '.js'] = shim;
} | [
"function",
"(",
"module",
",",
"shim",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"shim",
")",
")",
"{",
"shim",
"=",
"{",
"deps",
":",
"shim",
"}",
";",
"}",
"mShims",
"[",
"module",
"+",
"'.js'",
"]",
"=",
"shim",
";",
"}"
] | has length 2 | [
"has",
"length",
"2"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L2111-L2116 | train | Add a shim to the module | [
30522,
3853,
1006,
11336,
1010,
11895,
2213,
1007,
1063,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
11895,
2213,
1007,
1007,
1063,
11895,
2213,
1027,
1063,
2139,
4523,
1024,
11895,
2213,
1065,
1025,
1065,
5796,
14341,
2015,
1031,
113... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/table/mergeCell.js | _updateColMergeWith | function _updateColMergeWith(targetRows, startColIndex, endColIndex, colMergeWith) {
const limitColIndex = endColIndex + 1;
targetRows.forEach(rowData => {
rowData.slice(startColIndex, limitColIndex).forEach(cellData => {
cellData.colMergeWith = colMergeWith;
});
});
} | javascript | function _updateColMergeWith(targetRows, startColIndex, endColIndex, colMergeWith) {
const limitColIndex = endColIndex + 1;
targetRows.forEach(rowData => {
rowData.slice(startColIndex, limitColIndex).forEach(cellData => {
cellData.colMergeWith = colMergeWith;
});
});
} | [
"function",
"_updateColMergeWith",
"(",
"targetRows",
",",
"startColIndex",
",",
"endColIndex",
",",
"colMergeWith",
")",
"{",
"const",
"limitColIndex",
"=",
"endColIndex",
"+",
"1",
";",
"targetRows",
".",
"forEach",
"(",
"rowData",
"=>",
"{",
"rowData",
".",
... | Update colMergeWith property of target rows for column merge.
@param {Array.<Array.<object>>} targetRows - target rows
@param {number} startColIndex - start column index
@param {number} endColIndex - end column index
@param {number} colMergeWith - index of column merger
@private | [
"Update",
"colMergeWith",
"property",
"of",
"target",
"rows",
"for",
"column",
"merge",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/mergeCell.js#L117-L125 | train | Update colMergeWith property of target rows | [
30522,
3853,
1035,
10651,
25778,
5017,
3351,
24415,
1006,
4539,
10524,
2015,
1010,
2707,
25778,
22254,
10288,
1010,
2203,
25778,
22254,
10288,
1010,
8902,
5017,
3351,
24415,
1007,
1063,
9530,
3367,
5787,
25778,
22254,
10288,
1027,
2203,
25778... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | packages/weex-vue-framework/index.js | getInstanceTimer | function getInstanceTimer (instanceId, moduleGetter) {
var instance = instances[instanceId];
var timer = moduleGetter('timer');
var timerAPIs = {
setTimeout: function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var handler = function () {
args[0].apply(args, args.slice(2));
};
timer.setTimeout(handler, args[1]);
return instance.callbackId.toString()
},
setInterval: function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var handler = function () {
args[0].apply(args, args.slice(2));
};
timer.setInterval(handler, args[1]);
return instance.callbackId.toString()
},
clearTimeout: function (n) {
timer.clearTimeout(n);
},
clearInterval: function (n) {
timer.clearInterval(n);
}
};
return timerAPIs
} | javascript | function getInstanceTimer (instanceId, moduleGetter) {
var instance = instances[instanceId];
var timer = moduleGetter('timer');
var timerAPIs = {
setTimeout: function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var handler = function () {
args[0].apply(args, args.slice(2));
};
timer.setTimeout(handler, args[1]);
return instance.callbackId.toString()
},
setInterval: function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var handler = function () {
args[0].apply(args, args.slice(2));
};
timer.setInterval(handler, args[1]);
return instance.callbackId.toString()
},
clearTimeout: function (n) {
timer.clearTimeout(n);
},
clearInterval: function (n) {
timer.clearInterval(n);
}
};
return timerAPIs
} | [
"function",
"getInstanceTimer",
"(",
"instanceId",
",",
"moduleGetter",
")",
"{",
"var",
"instance",
"=",
"instances",
"[",
"instanceId",
"]",
";",
"var",
"timer",
"=",
"moduleGetter",
"(",
"'timer'",
")",
";",
"var",
"timerAPIs",
"=",
"{",
"setTimeout",
":"... | Generate HTML5 Timer APIs. An important point is that the callback
will be converted into callback id when sent to native. So the
framework can make sure no side effect of the callback happened after
an instance destroyed.
@param {[type]} instanceId [description]
@param {[type]} moduleGetter [description]
@return {[type]} [description] | [
"Generate",
"HTML5",
"Timer",
"APIs",
".",
"An",
"important",
"point",
"is",
"that",
"the",
"callback",
"will",
"be",
"converted",
"into",
"callback",
"id",
"when",
"sent",
"to",
"native",
".",
"So",
"the",
"framework",
"can",
"make",
"sure",
"no",
"side",... | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/weex-vue-framework/index.js#L354-L386 | train | Get instance timer | [
30522,
3853,
2131,
7076,
26897,
7292,
2099,
1006,
6013,
3593,
1010,
11336,
18150,
3334,
1007,
1063,
13075,
6013,
1027,
12107,
1031,
6013,
3593,
1033,
1025,
13075,
25309,
1027,
11336,
18150,
3334,
1006,
1005,
25309,
1005,
1007,
1025,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_Bes | function parse_Bes(blob) {
var v = blob.read_shift(1), t = blob.read_shift(1);
return t === 0x01 ? v : v === 0x01;
} | javascript | function parse_Bes(blob) {
var v = blob.read_shift(1), t = blob.read_shift(1);
return t === 0x01 ? v : v === 0x01;
} | [
"function",
"parse_Bes",
"(",
"blob",
")",
"{",
"var",
"v",
"=",
"blob",
".",
"read_shift",
"(",
"1",
")",
",",
"t",
"=",
"blob",
".",
"read_shift",
"(",
"1",
")",
";",
"return",
"t",
"===",
"0x01",
"?",
"v",
":",
"v",
"===",
"0x01",
";",
"}"
] | /* --- 2.5 Structures --- /* [MS-XLS] 2.5.10 Bes (boolean or error) | [
"/",
"*",
"---",
"2",
".",
"5",
"Structures",
"---",
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"10",
"Bes",
"(",
"boolean",
"or",
"error",
")"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5365-L5368 | train | Parse BES | [
30522,
3853,
11968,
3366,
1035,
2022,
2015,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
1058,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1015,
1007,
1010,
1056,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1015,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
var i,
sheet,
text = "";
for (i = 0; i < window.document.styleSheets.length; i++) {
sheet = window.document.styleSheets[i];
// if it was already 'reloaded'
if (sheet.ownerNode.id === msg.params.url) {
text = sheet.ownerNode.textContent;
} else if (sheet.href === msg.params.url && !sheet.disabled) {
var j,
rules;
// Deal with Firefox's SecurityError when accessing sheets
// from other domains, and Chrome returning `undefined`.
try {
rules = window.document.styleSheets[i].cssRules;
} catch (e) {
if (e.name !== "SecurityError") {
throw e;
}
}
if (!rules) {
return;
}
for (j = 0; j < rules.length; j++) {
text += rules[j].cssText + '\n';
}
}
}
MessageBroker.respond(msg, {
text: text
});
} | javascript | function (msg) {
var i,
sheet,
text = "";
for (i = 0; i < window.document.styleSheets.length; i++) {
sheet = window.document.styleSheets[i];
// if it was already 'reloaded'
if (sheet.ownerNode.id === msg.params.url) {
text = sheet.ownerNode.textContent;
} else if (sheet.href === msg.params.url && !sheet.disabled) {
var j,
rules;
// Deal with Firefox's SecurityError when accessing sheets
// from other domains, and Chrome returning `undefined`.
try {
rules = window.document.styleSheets[i].cssRules;
} catch (e) {
if (e.name !== "SecurityError") {
throw e;
}
}
if (!rules) {
return;
}
for (j = 0; j < rules.length; j++) {
text += rules[j].cssText + '\n';
}
}
}
MessageBroker.respond(msg, {
text: text
});
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"i",
",",
"sheet",
",",
"text",
"=",
"\"\"",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"window",
".",
"document",
".",
"styleSheets",
".",
"length",
";",
"i",
"++",
")",
"{",
"sheet",
"=",
"window",... | retrieves the content of the stylesheet
TODO: it now depends on reloadCSS implementation | [
"retrieves",
"the",
"content",
"of",
"the",
"stylesheet",
"TODO",
":",
"it",
"now",
"depends",
"on",
"reloadCSS",
"implementation"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L193-L228 | train | Aliquivo a un url | [
30522,
3853,
1006,
5796,
2290,
1007,
1063,
13075,
1045,
1010,
7123,
1010,
3793,
1027,
1000,
1000,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
3332,
1012,
6254,
1012,
6782,
21030,
3215,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js | Builder | function Builder(text, startOffset, startOffsetPos) {
this.stack = [];
this.text = text;
this.t = new Tokenizer(text);
this.currentTag = null;
this.startOffset = startOffset || 0;
this.startOffsetPos = startOffsetPos || {line: 0, ch: 0};
} | javascript | function Builder(text, startOffset, startOffsetPos) {
this.stack = [];
this.text = text;
this.t = new Tokenizer(text);
this.currentTag = null;
this.startOffset = startOffset || 0;
this.startOffsetPos = startOffsetPos || {line: 0, ch: 0};
} | [
"function",
"Builder",
"(",
"text",
",",
"startOffset",
",",
"startOffsetPos",
")",
"{",
"this",
".",
"stack",
"=",
"[",
"]",
";",
"this",
".",
"text",
"=",
"text",
";",
"this",
".",
"t",
"=",
"new",
"Tokenizer",
"(",
"text",
")",
";",
"this",
".",... | @constructor
A Builder creates a SimpleDOM tree of SimpleNode objects representing the
"important" contents of an HTML document. It does not include things like comments.
The nodes include information about their position in the text provided.
@param {string} text The text to parse
@param {?int} startOffset starting offset in the text
@param {?{line: int, ch: int}} startOffsetPos line/ch position in the text | [
"@constructor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/language/HTMLSimpleDOM.js#L236-L243 | train | Build a builder for a log file | [
30522,
3853,
12508,
1006,
3793,
1010,
2707,
27475,
3388,
1010,
2707,
27475,
3388,
6873,
2015,
1007,
1063,
2023,
1012,
9991,
1027,
1031,
1033,
1025,
2023,
1012,
3793,
1027,
3793,
1025,
2023,
1012,
1056,
1027,
2047,
19204,
17629,
1006,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
verdaccio/verdaccio | src/lib/bootstrap.js | startVerdaccio | function startVerdaccio(config: any, cliListen: string, configPath: string, pkgVersion: string, pkgName: string, callback: Callback) {
if (isObject(config) === false) {
throw new Error(API_ERROR.CONFIG_BAD_FORMAT);
}
endPointAPI(config).then(app => {
const addresses = getListListenAddresses(cliListen, config.listen);
addresses.forEach(function(addr) {
let webServer;
if (addr.proto === 'https') {
// https must either have key cert and ca or a pfx and (optionally) a passphrase
if (!config.https || !((config.https.key && config.https.cert && config.https.ca) || config.https.pfx)) {
logHTTPSWarning(configPath);
}
webServer = handleHTTPS(app, configPath, config);
} else {
// http
webServer = http.createServer(app);
}
if (config.server && config.server.keepAliveTimeout) {
// $FlowFixMe library definition for node is not up to date (doesn't contain recent 8.0 changes)
webServer.keepAliveTimeout = config.server.keepAliveTimeout * 1000;
}
unlinkAddressPath(addr);
callback(webServer, addr, pkgName, pkgVersion);
});
});
} | javascript | function startVerdaccio(config: any, cliListen: string, configPath: string, pkgVersion: string, pkgName: string, callback: Callback) {
if (isObject(config) === false) {
throw new Error(API_ERROR.CONFIG_BAD_FORMAT);
}
endPointAPI(config).then(app => {
const addresses = getListListenAddresses(cliListen, config.listen);
addresses.forEach(function(addr) {
let webServer;
if (addr.proto === 'https') {
// https must either have key cert and ca or a pfx and (optionally) a passphrase
if (!config.https || !((config.https.key && config.https.cert && config.https.ca) || config.https.pfx)) {
logHTTPSWarning(configPath);
}
webServer = handleHTTPS(app, configPath, config);
} else {
// http
webServer = http.createServer(app);
}
if (config.server && config.server.keepAliveTimeout) {
// $FlowFixMe library definition for node is not up to date (doesn't contain recent 8.0 changes)
webServer.keepAliveTimeout = config.server.keepAliveTimeout * 1000;
}
unlinkAddressPath(addr);
callback(webServer, addr, pkgName, pkgVersion);
});
});
} | [
"function",
"startVerdaccio",
"(",
"config",
":",
"any",
",",
"cliListen",
":",
"string",
",",
"configPath",
":",
"string",
",",
"pkgVersion",
":",
"string",
",",
"pkgName",
":",
"string",
",",
"callback",
":",
"Callback",
")",
"{",
"if",
"(",
"isObject",
... | Trigger the server after configuration has been loaded.
@param {Object} config
@param {Object} cliArguments
@param {String} configPath
@param {String} pkgVersion
@param {String} pkgName | [
"Trigger",
"the",
"server",
"after",
"configuration",
"has",
"been",
"loaded",
"."
] | daa7e897b6d093bf8282ff12df3f450bcd73476c | https://github.com/verdaccio/verdaccio/blob/daa7e897b6d093bf8282ff12df3f450bcd73476c/src/lib/bootstrap.js#L30-L60 | train | Starts verdaccio | [
30522,
3853,
2707,
6299,
2850,
14693,
2080,
1006,
9530,
8873,
2290,
1024,
2151,
1010,
18856,
24411,
6528,
1024,
5164,
1010,
9530,
8873,
21600,
8988,
1024,
5164,
1010,
1052,
2243,
2290,
27774,
1024,
5164,
1010,
1052,
2243,
16989,
4168,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-js/src/raven.js | function(dsn, options) {
var self = this;
if (self._globalServer) {
this._logDebug('error', 'Error: Raven has already been configured');
return self;
}
if (!dsn) return self;
var globalOptions = self._globalOptions;
// merge in options
if (options) {
each(options, function(key, value) {
// tags and extra are special and need to be put into context
if (key === 'tags' || key === 'extra' || key === 'user') {
self._globalContext[key] = value;
} else {
globalOptions[key] = value;
}
});
}
self.setDSN(dsn);
// "Script error." is hard coded into browsers for errors that it can't read.
// this is the result of a script being pulled in from an external domain and CORS.
globalOptions.ignoreErrors.push(/^Script error\.?$/);
globalOptions.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/);
// join regexp rules into one big rule
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length
? joinRegExp(globalOptions.ignoreUrls)
: false;
globalOptions.whitelistUrls = globalOptions.whitelistUrls.length
? joinRegExp(globalOptions.whitelistUrls)
: false;
globalOptions.includePaths = joinRegExp(globalOptions.includePaths);
globalOptions.maxBreadcrumbs = Math.max(
0,
Math.min(globalOptions.maxBreadcrumbs || 100, 100)
); // default and hard limit is 100
var autoBreadcrumbDefaults = {
xhr: true,
console: true,
dom: true,
location: true,
sentry: true
};
var autoBreadcrumbs = globalOptions.autoBreadcrumbs;
if ({}.toString.call(autoBreadcrumbs) === '[object Object]') {
autoBreadcrumbs = objectMerge(autoBreadcrumbDefaults, autoBreadcrumbs);
} else if (autoBreadcrumbs !== false) {
autoBreadcrumbs = autoBreadcrumbDefaults;
}
globalOptions.autoBreadcrumbs = autoBreadcrumbs;
var instrumentDefaults = {
tryCatch: true
};
var instrument = globalOptions.instrument;
if ({}.toString.call(instrument) === '[object Object]') {
instrument = objectMerge(instrumentDefaults, instrument);
} else if (instrument !== false) {
instrument = instrumentDefaults;
}
globalOptions.instrument = instrument;
TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;
// return for chaining
return self;
} | javascript | function(dsn, options) {
var self = this;
if (self._globalServer) {
this._logDebug('error', 'Error: Raven has already been configured');
return self;
}
if (!dsn) return self;
var globalOptions = self._globalOptions;
// merge in options
if (options) {
each(options, function(key, value) {
// tags and extra are special and need to be put into context
if (key === 'tags' || key === 'extra' || key === 'user') {
self._globalContext[key] = value;
} else {
globalOptions[key] = value;
}
});
}
self.setDSN(dsn);
// "Script error." is hard coded into browsers for errors that it can't read.
// this is the result of a script being pulled in from an external domain and CORS.
globalOptions.ignoreErrors.push(/^Script error\.?$/);
globalOptions.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/);
// join regexp rules into one big rule
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length
? joinRegExp(globalOptions.ignoreUrls)
: false;
globalOptions.whitelistUrls = globalOptions.whitelistUrls.length
? joinRegExp(globalOptions.whitelistUrls)
: false;
globalOptions.includePaths = joinRegExp(globalOptions.includePaths);
globalOptions.maxBreadcrumbs = Math.max(
0,
Math.min(globalOptions.maxBreadcrumbs || 100, 100)
); // default and hard limit is 100
var autoBreadcrumbDefaults = {
xhr: true,
console: true,
dom: true,
location: true,
sentry: true
};
var autoBreadcrumbs = globalOptions.autoBreadcrumbs;
if ({}.toString.call(autoBreadcrumbs) === '[object Object]') {
autoBreadcrumbs = objectMerge(autoBreadcrumbDefaults, autoBreadcrumbs);
} else if (autoBreadcrumbs !== false) {
autoBreadcrumbs = autoBreadcrumbDefaults;
}
globalOptions.autoBreadcrumbs = autoBreadcrumbs;
var instrumentDefaults = {
tryCatch: true
};
var instrument = globalOptions.instrument;
if ({}.toString.call(instrument) === '[object Object]') {
instrument = objectMerge(instrumentDefaults, instrument);
} else if (instrument !== false) {
instrument = instrumentDefaults;
}
globalOptions.instrument = instrument;
TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;
// return for chaining
return self;
} | [
"function",
"(",
"dsn",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"_globalServer",
")",
"{",
"this",
".",
"_logDebug",
"(",
"'error'",
",",
"'Error: Raven has already been configured'",
")",
";",
"return",
"self",
"... | alias to TraceKit /*
Configure Raven with a DSN and extra options
@param {string} dsn The public Sentry DSN
@param {object} options Set of global options [optional]
@return {Raven} | [
"alias",
"to",
"TraceKit",
"/",
"*",
"Configure",
"Raven",
"with",
"a",
"DSN",
"and",
"extra",
"options"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/src/raven.js#L154-L230 | train | Raven is a bit of a hack to get the server | [
30522,
3853,
1006,
16233,
2078,
1010,
7047,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
2969,
1012,
1035,
3795,
8043,
6299,
1007,
1063,
2023,
1012,
1035,
8833,
3207,
8569,
2290,
1006,
1005,
7561,
1005,
1010,
1005,
7561,
1024,
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... | |
aframevr/aframe | src/components/tracked-controls-webxr.js | function () {
this.controller = controllerUtils.findMatchingControllerWebXR(
this.system.controllers,
this.data.hand
);
// Legacy handle to the controller for old components.
this.el.components['tracked-controls'].controller = this.controller;
if (this.data.autoHide) { this.el.object3D.visible = !!this.controller; }
} | javascript | function () {
this.controller = controllerUtils.findMatchingControllerWebXR(
this.system.controllers,
this.data.hand
);
// Legacy handle to the controller for old components.
this.el.components['tracked-controls'].controller = this.controller;
if (this.data.autoHide) { this.el.object3D.visible = !!this.controller; }
} | [
"function",
"(",
")",
"{",
"this",
".",
"controller",
"=",
"controllerUtils",
".",
"findMatchingControllerWebXR",
"(",
"this",
".",
"system",
".",
"controllers",
",",
"this",
".",
"data",
".",
"hand",
")",
";",
"// Legacy handle to the controller for old components.... | Handle update controller match criteria (such as `id`, `idPrefix`, `hand`, `controller`) | [
"Handle",
"update",
"controller",
"match",
"criteria",
"(",
"such",
"as",
"id",
"idPrefix",
"hand",
"controller",
")"
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webxr.js#L65-L74 | train | Find the controller for the current component | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
11486,
1027,
11486,
21823,
4877,
1012,
2424,
18900,
8450,
8663,
13181,
10820,
8545,
2497,
2595,
2099,
1006,
2023,
1012,
2291,
1012,
21257,
1010,
2023,
1012,
2951,
1012,
2192,
1007,
1025,
1013,
1013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/api/v0.1/notifications.js | handlePermissions | function handlePermissions(options) {
if (permissions.parseContext(options.context).internal) {
return Promise.resolve(options);
}
return canThis(options.context).add.notification().then(() => {
return options;
}, () => {
return Promise.reject(new common.errors.NoPermissionError({
message: common.i18n.t('errors.api.notifications.noPermissionToAddNotif')
}));
});
} | javascript | function handlePermissions(options) {
if (permissions.parseContext(options.context).internal) {
return Promise.resolve(options);
}
return canThis(options.context).add.notification().then(() => {
return options;
}, () => {
return Promise.reject(new common.errors.NoPermissionError({
message: common.i18n.t('errors.api.notifications.noPermissionToAddNotif')
}));
});
} | [
"function",
"handlePermissions",
"(",
"options",
")",
"{",
"if",
"(",
"permissions",
".",
"parseContext",
"(",
"options",
".",
"context",
")",
".",
"internal",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"options",
")",
";",
"}",
"return",
"canThis... | ### Handle Permissions
We need to be an authorised user to perform this action
@param {Object} options
@returns {Object} options | [
"###",
"Handle",
"Permissions",
"We",
"need",
"to",
"be",
"an",
"authorised",
"user",
"to",
"perform",
"this",
"action"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/notifications.js#L118-L130 | train | Handle permissions | [
30522,
3853,
5047,
4842,
25481,
2015,
1006,
7047,
1007,
1063,
2065,
1006,
6656,
2015,
1012,
11968,
3366,
8663,
18209,
1006,
7047,
1012,
6123,
1007,
1012,
4722,
1007,
1063,
2709,
4872,
1012,
10663,
1006,
7047,
1007,
1025,
1065,
2709,
2064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_DataSpaceDefinition | function parse_DataSpaceDefinition(blob) {
var o = [];
blob.l += 4; // must be 0x8
var cnt = blob.read_shift(4);
while(cnt-- > 0) o.push(blob.read_shift(0, 'lpp4'));
return o;
} | javascript | function parse_DataSpaceDefinition(blob) {
var o = [];
blob.l += 4; // must be 0x8
var cnt = blob.read_shift(4);
while(cnt-- > 0) o.push(blob.read_shift(0, 'lpp4'));
return o;
} | [
"function",
"parse_DataSpaceDefinition",
"(",
"blob",
")",
"{",
"var",
"o",
"=",
"[",
"]",
";",
"blob",
".",
"l",
"+=",
"4",
";",
"// must be 0x8",
"var",
"cnt",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"while",
"(",
"cnt",
"--",
">",
"0... | /* [MS-OFFCRYPTO] 2.1.7 DataSpaceDefinition | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"1",
".",
"7",
"DataSpaceDefinition"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L8165-L8171 | train | Parse DataSpace Definition | [
30522,
3853,
11968,
3366,
1035,
2951,
23058,
3207,
16294,
22753,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
1051,
1027,
1031,
1033,
1025,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1018,
1025,
1013,
1013,
2442,
2022,
1014,
2595,
2620,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | function( data ) {
if ( data && rnotwhite.test( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
} | javascript | function( data ) {
if ( data && rnotwhite.test( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"data",
"&&",
"rnotwhite",
".",
"test",
"(",
"data",
")",
")",
"{",
"// We use execScript on Internet Explorer",
"// We use an anonymous function so that context is window",
"// rather than jQuery in Firefox",
"(",
"window",
"... | Evaluates a script in a global context Workarounds based on findings by Jim Driscoll http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context | [
"Evaluates",
"a",
"script",
"in",
"a",
"global",
"context",
"Workarounds",
"based",
"on",
"findings",
"by",
"Jim",
"Driscoll",
"http",
":",
"//",
"weblogs",
".",
"java",
".",
"net",
"/",
"blog",
"/",
"driscoll",
"/",
"archive",
"/",
"2009",
"/",
"09",
... | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L606-L615 | train | This function is used to execute a script in the browser | [
30522,
3853,
1006,
2951,
1007,
1063,
2065,
1006,
2951,
1004,
1004,
29300,
4140,
2860,
16584,
2063,
1012,
3231,
1006,
2951,
1007,
1007,
1063,
1013,
1013,
2057,
2224,
4654,
8586,
22483,
2006,
4274,
10566,
1013,
1013,
2057,
2224,
2019,
10812,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | lib/jsdoc/ui5/plugin.js | analyzeModuleDefinition | function analyzeModuleDefinition(node) {
var args = node.arguments;
var arg = 0;
if ( arg < args.length
&& args[arg].type === Syntax.Literal && typeof args[arg].value === 'string' ) {
warning("module explicitly defined a module name '" + args[arg].value + "'");
currentModule.name = args[arg].value;
arg++;
}
if ( arg < args.length && args[arg].type === Syntax.ArrayExpression ) {
currentModule.dependencies = convertValue(args[arg], "string[]");
arg++;
}
if ( arg < args.length && args[arg].type === Syntax.FunctionExpression ) {
currentModule.factory = args[arg];
arg++;
}
if ( currentModule.dependencies && currentModule.factory ) {
for ( var i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) {
var name = currentModule.factory.params[i].name;
var module = resolveModuleName(currentModule.module, currentModule.dependencies[i]);
debug(" import " + name + " from '" + module + "'");
currentModule.localNames[name] = {
module: module
// no (or empty) path
};
}
}
if ( currentModule.factory ) {
collectShortcuts(currentModule.factory.body);
}
} | javascript | function analyzeModuleDefinition(node) {
var args = node.arguments;
var arg = 0;
if ( arg < args.length
&& args[arg].type === Syntax.Literal && typeof args[arg].value === 'string' ) {
warning("module explicitly defined a module name '" + args[arg].value + "'");
currentModule.name = args[arg].value;
arg++;
}
if ( arg < args.length && args[arg].type === Syntax.ArrayExpression ) {
currentModule.dependencies = convertValue(args[arg], "string[]");
arg++;
}
if ( arg < args.length && args[arg].type === Syntax.FunctionExpression ) {
currentModule.factory = args[arg];
arg++;
}
if ( currentModule.dependencies && currentModule.factory ) {
for ( var i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) {
var name = currentModule.factory.params[i].name;
var module = resolveModuleName(currentModule.module, currentModule.dependencies[i]);
debug(" import " + name + " from '" + module + "'");
currentModule.localNames[name] = {
module: module
// no (or empty) path
};
}
}
if ( currentModule.factory ) {
collectShortcuts(currentModule.factory.body);
}
} | [
"function",
"analyzeModuleDefinition",
"(",
"node",
")",
"{",
"var",
"args",
"=",
"node",
".",
"arguments",
";",
"var",
"arg",
"=",
"0",
";",
"if",
"(",
"arg",
"<",
"args",
".",
"length",
"&&",
"args",
"[",
"arg",
"]",
".",
"type",
"===",
"Syntax",
... | ---- AMD handling | [
"----",
"AMD",
"handling"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/plugin.js#L249-L280 | train | Analyzes a module definition. | [
30522,
3853,
17908,
5302,
8566,
3709,
12879,
5498,
3508,
1006,
13045,
1007,
1063,
13075,
12098,
5620,
1027,
13045,
1012,
9918,
1025,
13075,
12098,
2290,
1027,
1014,
1025,
2065,
1006,
12098,
2290,
1026,
12098,
5620,
1012,
3091,
1004,
1004,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js | function(bForce) {
if (oPendingInteraction) {
// set provisionary processing time from start to end and calculate later
if (!bForce) {
oPendingInteraction.processing = now() - oPendingInteraction.start;
} else {
finalizeInteraction(now());
}
}
} | javascript | function(bForce) {
if (oPendingInteraction) {
// set provisionary processing time from start to end and calculate later
if (!bForce) {
oPendingInteraction.processing = now() - oPendingInteraction.start;
} else {
finalizeInteraction(now());
}
}
} | [
"function",
"(",
"bForce",
")",
"{",
"if",
"(",
"oPendingInteraction",
")",
"{",
"// set provisionary processing time from start to end and calculate later",
"if",
"(",
"!",
"bForce",
")",
"{",
"oPendingInteraction",
".",
"processing",
"=",
"now",
"(",
")",
"-",
"oP... | End an interaction measurements.
@param {boolean} bForce forces end of interaction now and ignores further re-renderings
@static
@private | [
"End",
"an",
"interaction",
"measurements",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js#L385-L394 | train | set the processing time of the pending interaction | [
30522,
3853,
1006,
28939,
2953,
3401,
1007,
1063,
2065,
1006,
2330,
4667,
18447,
6906,
7542,
1007,
1063,
1013,
1013,
2275,
9347,
5649,
6364,
2051,
2013,
2707,
2000,
2203,
1998,
18422,
2101,
2065,
1006,
999,
28939,
2953,
3401,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/parse/parseIgnore.js | parseIgnore | function parseIgnore(book) {
if (book.isLanguageBook()) {
return Promise.reject(new Error('Ignore files could be parsed for language books'));
}
var fs = book.getFS();
var ignore = book.getIgnore();
ignore = ignore.add(DEFAULT_IGNORES);
return Promise.serie(IGNORE_FILES, function(filename) {
return fs.readAsString(filename)
.then(function(content) {
ignore = ignore.add(content.toString().split(/\r?\n/));
}, function(err) {
return Promise();
});
})
.then(function() {
return book.setIgnore(ignore);
});
} | javascript | function parseIgnore(book) {
if (book.isLanguageBook()) {
return Promise.reject(new Error('Ignore files could be parsed for language books'));
}
var fs = book.getFS();
var ignore = book.getIgnore();
ignore = ignore.add(DEFAULT_IGNORES);
return Promise.serie(IGNORE_FILES, function(filename) {
return fs.readAsString(filename)
.then(function(content) {
ignore = ignore.add(content.toString().split(/\r?\n/));
}, function(err) {
return Promise();
});
})
.then(function() {
return book.setIgnore(ignore);
});
} | [
"function",
"parseIgnore",
"(",
"book",
")",
"{",
"if",
"(",
"book",
".",
"isLanguageBook",
"(",
")",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Ignore files could be parsed for language books'",
")",
")",
";",
"}",
"var",
"fs"... | Parse ignore files
@param {Book}
@return {Book} | [
"Parse",
"ignore",
"files"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseIgnore.js#L27-L49 | train | Parse ignore files | [
30522,
3853,
11968,
20240,
26745,
2890,
1006,
2338,
1007,
1063,
2065,
1006,
2338,
1012,
25340,
3070,
6692,
3351,
8654,
1006,
1007,
1007,
1063,
2709,
4872,
1012,
15454,
1006,
2047,
30524,
12398,
1035,
26663,
1007,
1025,
2709,
4872,
1012,
866... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-misleading-character-class.js | verify | function verify(node, pattern, flags) {
const patternNode = parser.parsePattern(
pattern,
0,
pattern.length,
flags.includes("u")
);
const has = {
surrogatePairWithoutUFlag: false,
combiningClass: false,
variationSelector: false,
emojiModifier: false,
regionalIndicatorSymbol: false,
zwj: false
};
visitRegExpAST(patternNode, {
onCharacterClassEnter(ccNode) {
for (const chars of iterateCharacterSequence(ccNode.elements)) {
for (const kind of kinds) {
has[kind] = has[kind] || hasCharacterSequence[kind](chars);
}
}
}
});
for (const kind of kinds) {
if (has[kind]) {
context.report({ node, messageId: kind });
}
}
} | javascript | function verify(node, pattern, flags) {
const patternNode = parser.parsePattern(
pattern,
0,
pattern.length,
flags.includes("u")
);
const has = {
surrogatePairWithoutUFlag: false,
combiningClass: false,
variationSelector: false,
emojiModifier: false,
regionalIndicatorSymbol: false,
zwj: false
};
visitRegExpAST(patternNode, {
onCharacterClassEnter(ccNode) {
for (const chars of iterateCharacterSequence(ccNode.elements)) {
for (const kind of kinds) {
has[kind] = has[kind] || hasCharacterSequence[kind](chars);
}
}
}
});
for (const kind of kinds) {
if (has[kind]) {
context.report({ node, messageId: kind });
}
}
} | [
"function",
"verify",
"(",
"node",
",",
"pattern",
",",
"flags",
")",
"{",
"const",
"patternNode",
"=",
"parser",
".",
"parsePattern",
"(",
"pattern",
",",
"0",
",",
"pattern",
".",
"length",
",",
"flags",
".",
"includes",
"(",
"\"u\"",
")",
")",
";",
... | Verify a given regular expression.
@param {Node} node The node to report.
@param {string} pattern The regular expression pattern to verify.
@param {string} flags The flags of the regular expression.
@returns {void} | [
"Verify",
"a",
"given",
"regular",
"expression",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-misleading-character-class.js#L133-L164 | train | Verify a pattern | [
30522,
3853,
20410,
1006,
13045,
1010,
5418,
1010,
9245,
1007,
1063,
9530,
3367,
5418,
3630,
3207,
1027,
11968,
8043,
1012,
11968,
3366,
4502,
12079,
2078,
1006,
5418,
1010,
1014,
1010,
5418,
1012,
3091,
30524,
29147,
16339,
4305,
8873,
212... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/PerfUtils.js | PerfMeasurement | function PerfMeasurement(id, name, reent) {
this.name = name;
this.reent = reent;
if (id) {
this.id = id;
} else {
this.id = (reent) ? "[reent " + this.reent + "] " + name : name;
}
} | javascript | function PerfMeasurement(id, name, reent) {
this.name = name;
this.reent = reent;
if (id) {
this.id = id;
} else {
this.id = (reent) ? "[reent " + this.reent + "] " + name : name;
}
} | [
"function",
"PerfMeasurement",
"(",
"id",
",",
"name",
",",
"reent",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"reent",
"=",
"reent",
";",
"if",
"(",
"id",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"}",
"else",
"{",
"this... | @private
A unique key to log performance data
@param {(string|undefined)} id Unique ID for this measurement name
@param {!string} name A short name for this measurement
@param {?number} reent Sequence identifier for parallel tests of the same name | [
"@private",
"A",
"unique",
"key",
"to",
"log",
"performance",
"data"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L78-L86 | train | Perf measurement | [
30522,
3853,
2566,
16715,
5243,
28632,
3672,
1006,
8909,
1010,
2171,
1010,
2128,
4765,
1007,
1063,
2023,
1012,
2171,
1027,
2171,
1025,
2023,
1012,
2128,
4765,
1027,
2128,
4765,
1025,
2065,
1006,
8909,
1007,
1063,
2023,
1012,
8909,
1027,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/SearchField.js | function(oRM, oCtrl){
oRM.write("<div");
oRM.writeAttributeEscaped('id', oCtrl.getId() + '-searchico');
oRM.writeAttribute('unselectable', 'on');
if (sap.ui.getCore().getConfiguration().getAccessibility()) {
oRM.writeAttribute("role", "presentation");
}
oRM.addClass("sapUiSearchFieldIco");
oRM.writeClasses();
oRM.write("></div>");
} | javascript | function(oRM, oCtrl){
oRM.write("<div");
oRM.writeAttributeEscaped('id', oCtrl.getId() + '-searchico');
oRM.writeAttribute('unselectable', 'on');
if (sap.ui.getCore().getConfiguration().getAccessibility()) {
oRM.writeAttribute("role", "presentation");
}
oRM.addClass("sapUiSearchFieldIco");
oRM.writeClasses();
oRM.write("></div>");
} | [
"function",
"(",
"oRM",
",",
"oCtrl",
")",
"{",
"oRM",
".",
"write",
"(",
"\"<div\"",
")",
";",
"oRM",
".",
"writeAttributeEscaped",
"(",
"'id'",
",",
"oCtrl",
".",
"getId",
"(",
")",
"+",
"'-searchico'",
")",
";",
"oRM",
".",
"writeAttribute",
"(",
... | *********************************************** *********************************************** Inner Controls *********************************************** | [
"***********************************************",
"***********************************************",
"Inner",
"Controls",
"***********************************************"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/SearchField.js#L647-L657 | train | Writes the searchico element | [
30522,
3853,
1006,
2030,
2213,
1010,
13323,
12190,
1007,
1063,
2030,
2213,
1012,
4339,
1006,
1000,
1026,
4487,
2615,
1000,
1007,
1025,
2030,
2213,
1012,
4339,
19321,
3089,
8569,
30524,
1007,
1025,
2030,
2213,
1012,
4339,
19321,
3089,
8569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/DateTime.js | adjustConstraints | function adjustConstraints(oType, oConstraints) {
var oAdjustedConstraints = {};
if (oConstraints) {
switch (oConstraints.displayFormat) {
case "Date":
oAdjustedConstraints.isDateOnly = true;
break;
case undefined:
break;
default:
Log.warning("Illegal displayFormat: " + oConstraints.displayFormat,
null, oType.getName());
}
oAdjustedConstraints.nullable = oConstraints.nullable;
}
return oAdjustedConstraints;
} | javascript | function adjustConstraints(oType, oConstraints) {
var oAdjustedConstraints = {};
if (oConstraints) {
switch (oConstraints.displayFormat) {
case "Date":
oAdjustedConstraints.isDateOnly = true;
break;
case undefined:
break;
default:
Log.warning("Illegal displayFormat: " + oConstraints.displayFormat,
null, oType.getName());
}
oAdjustedConstraints.nullable = oConstraints.nullable;
}
return oAdjustedConstraints;
} | [
"function",
"adjustConstraints",
"(",
"oType",
",",
"oConstraints",
")",
"{",
"var",
"oAdjustedConstraints",
"=",
"{",
"}",
";",
"if",
"(",
"oConstraints",
")",
"{",
"switch",
"(",
"oConstraints",
".",
"displayFormat",
")",
"{",
"case",
"\"Date\"",
":",
"oAd... | Adjusts the constraints for DateTimeBase.
@param {sap.ui.model.odata.type.DateTime} oType
the type
@param {object} [oConstraints]
constraints, see {@link #constructor}
@returns {object}
the constraints adjusted for DateTimeBase | [
"Adjusts",
"the",
"constraints",
"for",
"DateTimeBase",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/DateTime.js#L21-L38 | train | Adjusts the constraints of a type to be a date only | [
30522,
3853,
14171,
8663,
20528,
18447,
2015,
1006,
27178,
18863,
1010,
1051,
8663,
20528,
18447,
2015,
1007,
1063,
13075,
1051,
4215,
29427,
2098,
8663,
20528,
18447,
2015,
1027,
1063,
1065,
1025,
2065,
1006,
1051,
8663,
20528,
18447,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-js/plugins/ember.js | emberPlugin | function emberPlugin(Raven, Ember) {
Ember = Ember || window.Ember;
// quit if Ember isn't on the page
if (!Ember) return;
var _oldOnError = Ember.onerror;
Ember.onerror = function EmberOnError(error) {
Raven.captureException(error);
if (typeof _oldOnError === 'function') {
_oldOnError.call(this, error);
}
};
Ember.RSVP.on('error', function(reason) {
if (reason instanceof Error) {
Raven.captureException(reason, {
extra: {context: 'Unhandled Promise error detected'}
});
} else {
Raven.captureMessage('Unhandled Promise error detected', {extra: {reason: reason}});
}
});
} | javascript | function emberPlugin(Raven, Ember) {
Ember = Ember || window.Ember;
// quit if Ember isn't on the page
if (!Ember) return;
var _oldOnError = Ember.onerror;
Ember.onerror = function EmberOnError(error) {
Raven.captureException(error);
if (typeof _oldOnError === 'function') {
_oldOnError.call(this, error);
}
};
Ember.RSVP.on('error', function(reason) {
if (reason instanceof Error) {
Raven.captureException(reason, {
extra: {context: 'Unhandled Promise error detected'}
});
} else {
Raven.captureMessage('Unhandled Promise error detected', {extra: {reason: reason}});
}
});
} | [
"function",
"emberPlugin",
"(",
"Raven",
",",
"Ember",
")",
"{",
"Ember",
"=",
"Ember",
"||",
"window",
".",
"Ember",
";",
"// quit if Ember isn't on the page",
"if",
"(",
"!",
"Ember",
")",
"return",
";",
"var",
"_oldOnError",
"=",
"Ember",
".",
"onerror",
... | Ember.js plugin
Patches event handler callbacks and ajax callbacks. | [
"Ember",
".",
"js",
"plugin"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/plugins/ember.js#L6-L28 | train | Ember plugin. | [
30522,
3853,
7861,
5677,
24759,
15916,
2378,
1006,
10000,
1010,
7861,
5677,
1007,
1063,
7861,
5677,
1027,
7861,
5677,
1064,
1064,
3332,
1012,
7861,
5677,
1025,
1013,
1013,
8046,
2065,
7861,
5677,
3475,
1005,
1056,
2006,
1996,
3931,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | processMetadata | function processMetadata () {
//only interprete the metadata if the analytics model was not initialised yet
if (that.bIsInitialized) {
return;
}
//mark analytics model as initialized
that.bIsInitialized = true;
/*
* add extra annotations if provided
*/
if (mParameter && mParameter.sAnnotationJSONDoc) {
that.mergeV2Annotations(mParameter.sAnnotationJSONDoc);
}
that._interpreteMetadata(that._oModel.getServiceMetadata().dataServices);
} | javascript | function processMetadata () {
//only interprete the metadata if the analytics model was not initialised yet
if (that.bIsInitialized) {
return;
}
//mark analytics model as initialized
that.bIsInitialized = true;
/*
* add extra annotations if provided
*/
if (mParameter && mParameter.sAnnotationJSONDoc) {
that.mergeV2Annotations(mParameter.sAnnotationJSONDoc);
}
that._interpreteMetadata(that._oModel.getServiceMetadata().dataServices);
} | [
"function",
"processMetadata",
"(",
")",
"{",
"//only interprete the metadata if the analytics model was not initialised yet",
"if",
"(",
"that",
".",
"bIsInitialized",
")",
"{",
"return",
";",
"}",
"//mark analytics model as initialized",
"that",
".",
"bIsInitialized",
"=",
... | Kickstart the interpretation of the metadata,
either called directly if metadata is available, or deferred and then
executed via callback by the model during the metadata loaded event. | [
"Kickstart",
"the",
"interpretation",
"of",
"the",
"metadata",
"either",
"called",
"directly",
"if",
"metadata",
"is",
"available",
"or",
"deferred",
"and",
"then",
"executed",
"via",
"callback",
"by",
"the",
"model",
"during",
"the",
"metadata",
"loaded",
"even... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L314-L331 | train | process metadata | [
30522,
3853,
2832,
11368,
8447,
2696,
1006,
1007,
1063,
1013,
1013,
2069,
17841,
2063,
1996,
27425,
2065,
1996,
25095,
2944,
2001,
2025,
3988,
5084,
2664,
2065,
1006,
2008,
1012,
20377,
5498,
20925,
3550,
1007,
1063,
2709,
1025,
1065,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BrainJS/brain.js | examples/stream-example.js | function(obj) {
console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);
const result01 = net.run([0, 1]);
const result00 = net.run([0, 0]);
const result11 = net.run([1, 1]);
const result10 = net.run([1, 0]);
assert(result01[0] > 0.9);
assert(result00[0] < 0.1);
assert(result11[0] < 0.1);
assert(result10[0] > 0.9);
console.log('0 XOR 1: ', result01); // 0.987
console.log('0 XOR 0: ', result00); // 0.058
console.log('1 XOR 1: ', result11); // 0.087
console.log('1 XOR 0: ', result10); // 0.934
} | javascript | function(obj) {
console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);
const result01 = net.run([0, 1]);
const result00 = net.run([0, 0]);
const result11 = net.run([1, 1]);
const result10 = net.run([1, 0]);
assert(result01[0] > 0.9);
assert(result00[0] < 0.1);
assert(result11[0] < 0.1);
assert(result10[0] > 0.9);
console.log('0 XOR 1: ', result01); // 0.987
console.log('0 XOR 0: ', result00); // 0.058
console.log('1 XOR 1: ', result11); // 0.087
console.log('1 XOR 0: ', result10); // 0.934
} | [
"function",
"(",
"obj",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"obj",
".",
"iterations",
"}",
"${",
"obj",
".",
"error",
"}",
"`",
")",
";",
"const",
"result01",
"=",
"net",
".",
"run",
"(",
"[",
"0",
",",
"1",
"]",
")",
";",
"const... | Called when the network is done training. | [
"Called",
"when",
"the",
"network",
"is",
"done",
"training",
"."
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/examples/stream-example.js#L25-L42 | train | This function is called when the network is not ready | [
30522,
3853,
1006,
27885,
3501,
1007,
1063,
10122,
1012,
8833,
1006,
1036,
4738,
1999,
1002,
1063,
27885,
3501,
1012,
27758,
2015,
1065,
27758,
2015,
2007,
7561,
1024,
30524,
1006,
1031,
1014,
1010,
1014,
1033,
1007,
1025,
9530,
3367,
2765,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-spaced-func.js | detectOpenSpaces | function detectOpenSpaces(node) {
const lastCalleeToken = sourceCode.getLastToken(node.callee);
let prevToken = lastCalleeToken,
parenToken = sourceCode.getTokenAfter(lastCalleeToken);
// advances to an open parenthesis.
while (
parenToken &&
parenToken.range[1] < node.range[1] &&
parenToken.value !== "("
) {
prevToken = parenToken;
parenToken = sourceCode.getTokenAfter(parenToken);
}
// look for a space between the callee and the open paren
if (parenToken &&
parenToken.range[1] < node.range[1] &&
sourceCode.isSpaceBetweenTokens(prevToken, parenToken)
) {
context.report({
node,
loc: lastCalleeToken.loc.start,
message: "Unexpected space between function name and paren.",
fix(fixer) {
return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
}
});
}
} | javascript | function detectOpenSpaces(node) {
const lastCalleeToken = sourceCode.getLastToken(node.callee);
let prevToken = lastCalleeToken,
parenToken = sourceCode.getTokenAfter(lastCalleeToken);
// advances to an open parenthesis.
while (
parenToken &&
parenToken.range[1] < node.range[1] &&
parenToken.value !== "("
) {
prevToken = parenToken;
parenToken = sourceCode.getTokenAfter(parenToken);
}
// look for a space between the callee and the open paren
if (parenToken &&
parenToken.range[1] < node.range[1] &&
sourceCode.isSpaceBetweenTokens(prevToken, parenToken)
) {
context.report({
node,
loc: lastCalleeToken.loc.start,
message: "Unexpected space between function name and paren.",
fix(fixer) {
return fixer.removeRange([prevToken.range[1], parenToken.range[0]]);
}
});
}
} | [
"function",
"detectOpenSpaces",
"(",
"node",
")",
"{",
"const",
"lastCalleeToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
".",
"callee",
")",
";",
"let",
"prevToken",
"=",
"lastCalleeToken",
",",
"parenToken",
"=",
"sourceCode",
".",
"getTokenAfter... | Check if open space is present in a function name
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"open",
"space",
"is",
"present",
"in",
"a",
"function",
"name"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-spaced-func.js#L42-L71 | train | Detects open spaces between the callee and the open parenthesis. | [
30522,
3853,
11487,
26915,
23058,
2015,
1006,
13045,
1007,
1063,
9530,
3367,
2197,
9289,
10559,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
1012,
2655,
4402,
1007,
1025,
2292,
3653,
2615,
18715,
2368,
1027,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/services/glacier.js | computeChecksums | function computeChecksums(data) {
if (!AWS.util.Buffer.isBuffer(data)) data = new AWS.util.Buffer(data);
var mb = 1024 * 1024;
var hashes = [];
var hash = AWS.util.crypto.createHash('sha256');
// build leaf nodes in 1mb chunks
for (var i = 0; i < data.length; i += mb) {
var chunk = data.slice(i, Math.min(i + mb, data.length));
hash.update(chunk);
hashes.push(AWS.util.crypto.sha256(chunk));
}
return {
linearHash: hash.digest('hex'),
treeHash: this.buildHashTree(hashes)
};
} | javascript | function computeChecksums(data) {
if (!AWS.util.Buffer.isBuffer(data)) data = new AWS.util.Buffer(data);
var mb = 1024 * 1024;
var hashes = [];
var hash = AWS.util.crypto.createHash('sha256');
// build leaf nodes in 1mb chunks
for (var i = 0; i < data.length; i += mb) {
var chunk = data.slice(i, Math.min(i + mb, data.length));
hash.update(chunk);
hashes.push(AWS.util.crypto.sha256(chunk));
}
return {
linearHash: hash.digest('hex'),
treeHash: this.buildHashTree(hashes)
};
} | [
"function",
"computeChecksums",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"AWS",
".",
"util",
".",
"Buffer",
".",
"isBuffer",
"(",
"data",
")",
")",
"data",
"=",
"new",
"AWS",
".",
"util",
".",
"Buffer",
"(",
"data",
")",
";",
"var",
"mb",
"=",
"102... | @!group Computing Checksums
Computes the SHA-256 linear and tree hash checksums for a given
block of Buffer data. Pass the tree hash of the computed checksums
as the checksum input to the {completeMultipartUpload} when performing
a multi-part upload.
@example Calculate checksum of 5.5MB data chunk
var glacier = new AWS.Glacier();
var data = new Buffer(5.5 * 1024 * 1024);
data.fill('0'); // fill with zeros
var results = glacier.computeChecksums(data);
// Result: { linearHash: '68aff0c5a9...', treeHash: '154e26c78f...' }
@param data [Buffer, String] data to calculate the checksum for
@return [map<linearHash:String,treeHash:String>] a map containing
the linearHash and treeHash properties representing hex based digests
of the respective checksums.
@see completeMultipartUpload | [
"@!group",
"Computing",
"Checksums",
"Computes",
"the",
"SHA",
"-",
"256",
"linear",
"and",
"tree",
"hash",
"checksums",
"for",
"a",
"given",
"block",
"of",
"Buffer",
"data",
".",
"Pass",
"the",
"tree",
"hash",
"of",
"the",
"computed",
"checksums",
"as",
"... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/glacier.js#L72-L90 | train | Compute checksums for the given data | [
30522,
3853,
24134,
5403,
10603,
18163,
1006,
2951,
1007,
1063,
2065,
1006,
999,
22091,
2015,
1012,
21183,
4014,
1012,
17698,
1012,
2003,
8569,
12494,
1006,
2951,
1007,
1007,
2951,
1027,
2047,
22091,
2015,
1012,
21183,
4014,
1012,
17698,
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/JSUtils.js | function (node) {
if (node.value && node.value.type === "FunctionExpression") {
if (node.key && node.key.type === "Identifier") {
_addResult(node.key);
}
}
} | javascript | function (node) {
if (node.value && node.value.type === "FunctionExpression") {
if (node.key && node.key.type === "Identifier") {
_addResult(node.key);
}
}
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"value",
"&&",
"node",
".",
"value",
".",
"type",
"===",
"\"FunctionExpression\"",
")",
"{",
"if",
"(",
"node",
".",
"key",
"&&",
"node",
".",
"key",
".",
"type",
"===",
"\"Identifier\"",
")"... | /*
{
<functionName>: function() {}
} | [
"/",
"*",
"{",
"<functionName",
">",
":",
"function",
"()",
"{}",
"}"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L147-L153 | train | Add result to result list | [
30522,
3853,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
3643,
1004,
1004,
13045,
1012,
3643,
1012,
2828,
1027,
1027,
1027,
1000,
3853,
10288,
20110,
3258,
1000,
1007,
1063,
2065,
1006,
13045,
1012,
3145,
1004,
1004,
13045,
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... | |
nhn/tui.editor | src/js/htmlSanitizer.js | finalizeHtml | function finalizeHtml($html, needHtmlText) {
let returnValue;
if (needHtmlText) {
returnValue = $html[0].innerHTML;
} else {
const frag = document.createDocumentFragment();
const childNodes = util.toArray($html[0].childNodes);
const {length} = childNodes;
for (let i = 0; i < length; i += 1) {
frag.appendChild(childNodes[i]);
}
returnValue = frag;
}
return returnValue;
} | javascript | function finalizeHtml($html, needHtmlText) {
let returnValue;
if (needHtmlText) {
returnValue = $html[0].innerHTML;
} else {
const frag = document.createDocumentFragment();
const childNodes = util.toArray($html[0].childNodes);
const {length} = childNodes;
for (let i = 0; i < length; i += 1) {
frag.appendChild(childNodes[i]);
}
returnValue = frag;
}
return returnValue;
} | [
"function",
"finalizeHtml",
"(",
"$html",
",",
"needHtmlText",
")",
"{",
"let",
"returnValue",
";",
"if",
"(",
"needHtmlText",
")",
"{",
"returnValue",
"=",
"$html",
"[",
"0",
"]",
".",
"innerHTML",
";",
"}",
"else",
"{",
"const",
"frag",
"=",
"document"... | Finalize html result
@private
@param {jQuery} $html jQuery instance
@param {boolean} needHtmlText pass true if need html text
@returns {string|DocumentFragment} result | [
"Finalize",
"html",
"result"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/htmlSanitizer.js#L92-L109 | train | Finalizes the HTML content | [
30522,
3853,
2345,
4697,
11039,
19968,
1006,
1002,
16129,
1010,
2342,
11039,
19968,
18209,
1007,
1063,
2292,
2709,
10175,
5657,
1025,
2065,
1006,
2342,
11039,
19968,
18209,
1007,
1063,
2709,
10175,
5657,
1027,
1002,
16129,
1031,
1014,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js | setScrollTopForDocument | function setScrollTopForDocument(doc, value) {
doc.documentElement.scrollTop = doc.body.scrollTop = value;
} | javascript | function setScrollTopForDocument(doc, value) {
doc.documentElement.scrollTop = doc.body.scrollTop = value;
} | [
"function",
"setScrollTopForDocument",
"(",
"doc",
",",
"value",
")",
"{",
"doc",
".",
"documentElement",
".",
"scrollTop",
"=",
"doc",
".",
"body",
".",
"scrollTop",
"=",
"value",
";",
"}"
] | Alias for document.scrollTop setter.
@param {!HTMLDocument} doc The document node where information will be
queried from.
@param {number} value The target Y scroll offset. | [
"Alias",
"for",
"document",
".",
"scrollTop",
"setter",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js#L315-L317 | train | Set the scrollTop of a document | [
30522,
3853,
4520,
26775,
14511,
14399,
3877,
10085,
27417,
2102,
1006,
9986,
1010,
3643,
1007,
1063,
9986,
1012,
6254,
12260,
3672,
1012,
17186,
14399,
1027,
9986,
1012,
2303,
1012,
17186,
14399,
1027,
3643,
1025,
1065,
102,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | handleBidiStreaming | function handleBidiStreaming(call, handler, metadata) {
var stream = new ServerDuplexStream(call, metadata, handler.serialize,
handler.deserialize);
stream.waitForCancel();
handler.func(stream);
} | javascript | function handleBidiStreaming(call, handler, metadata) {
var stream = new ServerDuplexStream(call, metadata, handler.serialize,
handler.deserialize);
stream.waitForCancel();
handler.func(stream);
} | [
"function",
"handleBidiStreaming",
"(",
"call",
",",
"handler",
",",
"metadata",
")",
"{",
"var",
"stream",
"=",
"new",
"ServerDuplexStream",
"(",
"call",
",",
"metadata",
",",
"handler",
".",
"serialize",
",",
"handler",
".",
"deserialize",
")",
";",
"strea... | User provided method to handle bidirectional streaming calls on the server.
@callback grpc.Server~handleBidiStreamingCall
@param {grpc~ServerDuplexStream} call The call object
Fully handle a bidirectional streaming call
@private
@param {grpc.internal~Call} call The call to handle
@param {Object} handler Request handler object for the method that was called
@param {grpc~Server.handleBidiStreamingCall} handler.func The handler
function
@param {grpc~deserialize} handler.deserialize The deserialization function
for request data
@param {grpc~serialize} handler.serialize The serialization function for
response data
@param {Metadata} metadata Metadata from the client | [
"User",
"provided",
"method",
"to",
"handle",
"bidirectional",
"streaming",
"calls",
"on",
"the",
"server",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L702-L707 | train | Handle bidirectional streaming | [
30522,
3853,
5047,
17062,
2923,
16416,
6562,
1006,
2655,
1010,
28213,
1010,
27425,
1007,
1063,
13075,
5460,
1027,
2047,
8241,
8566,
19386,
21422,
1006,
2655,
1010,
27425,
1010,
28213,
1012,
7642,
4697,
1010,
28213,
1012,
4078,
11610,
3669,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/autoconfig.js | extendFromRecommended | function extendFromRecommended(config) {
const newConfig = Object.assign({}, config);
ConfigOps.normalizeToStrings(newConfig);
const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
recRules.forEach(ruleId => {
if (lodash.isEqual(recConfig.rules[ruleId], newConfig.rules[ruleId])) {
delete newConfig.rules[ruleId];
}
});
newConfig.extends = RECOMMENDED_CONFIG_NAME;
return newConfig;
} | javascript | function extendFromRecommended(config) {
const newConfig = Object.assign({}, config);
ConfigOps.normalizeToStrings(newConfig);
const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId]));
recRules.forEach(ruleId => {
if (lodash.isEqual(recConfig.rules[ruleId], newConfig.rules[ruleId])) {
delete newConfig.rules[ruleId];
}
});
newConfig.extends = RECOMMENDED_CONFIG_NAME;
return newConfig;
} | [
"function",
"extendFromRecommended",
"(",
"config",
")",
"{",
"const",
"newConfig",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"config",
")",
";",
"ConfigOps",
".",
"normalizeToStrings",
"(",
"newConfig",
")",
";",
"const",
"recRules",
"=",
"Object",
... | Extract rule configuration into eslint:recommended where possible.
This will return a new config with `"extends": "eslint:recommended"` and
only the rules which have configurations different from the recommended config.
@param {Object} config config object
@returns {Object} config object using `"extends": "eslint:recommended"` | [
"Extract",
"rule",
"configuration",
"into",
"eslint",
":",
"recommended",
"where",
"possible",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/autoconfig.js#L334-L348 | train | Extend the given config with the recommended config | [
30522,
3853,
7949,
19699,
5358,
2890,
9006,
3549,
5732,
1006,
9530,
8873,
2290,
1007,
1063,
9530,
3367,
2047,
8663,
8873,
2290,
1027,
4874,
1012,
23911,
1006,
1063,
1065,
1010,
9530,
8873,
2290,
1007,
1025,
9530,
8873,
3995,
4523,
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... |
apache/incubator-echarts | src/coord/calendar/Calendar.js | function (data, clamp) {
var point = this.dataToPoint(data, clamp);
return {
contentShape: {
x: point[0] - (this._sw - this._lineWidth) / 2,
y: point[1] - (this._sh - this._lineWidth) / 2,
width: this._sw - this._lineWidth,
height: this._sh - this._lineWidth
},
center: point,
tl: [
point[0] - this._sw / 2,
point[1] - this._sh / 2
],
tr: [
point[0] + this._sw / 2,
point[1] - this._sh / 2
],
br: [
point[0] + this._sw / 2,
point[1] + this._sh / 2
],
bl: [
point[0] - this._sw / 2,
point[1] + this._sh / 2
]
};
} | javascript | function (data, clamp) {
var point = this.dataToPoint(data, clamp);
return {
contentShape: {
x: point[0] - (this._sw - this._lineWidth) / 2,
y: point[1] - (this._sh - this._lineWidth) / 2,
width: this._sw - this._lineWidth,
height: this._sh - this._lineWidth
},
center: point,
tl: [
point[0] - this._sw / 2,
point[1] - this._sh / 2
],
tr: [
point[0] + this._sw / 2,
point[1] - this._sh / 2
],
br: [
point[0] + this._sw / 2,
point[1] + this._sh / 2
],
bl: [
point[0] - this._sw / 2,
point[1] + this._sh / 2
]
};
} | [
"function",
"(",
"data",
",",
"clamp",
")",
"{",
"var",
"point",
"=",
"this",
".",
"dataToPoint",
"(",
"data",
",",
"clamp",
")",
";",
"return",
"{",
"contentShape",
":",
"{",
"x",
":",
"point",
"[",
"0",
"]",
"-",
"(",
"this",
".",
"_sw",
"-",
... | Convert a time date item to (x, y) four point.
@param {Array} data date[0] is date
@param {boolean} [clamp=true] out of range
@return {Object} point | [
"Convert",
"a",
"time",
"date",
"item",
"to",
"(",
"x",
"y",
")",
"four",
"point",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/calendar/Calendar.js#L249-L283 | train | Returns an object with the information about the tag | [
30522,
3853,
1006,
2951,
1010,
18856,
16613,
1007,
1063,
13075,
2391,
1027,
2023,
1012,
2951,
14399,
25785,
1006,
2951,
1010,
18856,
16613,
1007,
1025,
2709,
1063,
8417,
3270,
5051,
1024,
1063,
1060,
1024,
2391,
1031,
1014,
1033,
1011,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | bits/76_xls.js | parse_compobj | function parse_compobj(obj/*:CFBEntry*/) {
var v = {};
var o = obj.content;
/*:: if(o == null) return; */
/* [MS-OLEDS] 2.3.7 CompObjHeader -- All fields MUST be ignored */
o.l = 28;
v.AnsiUserType = o.read_shift(0, "lpstr-ansi");
v.AnsiClipboardFormat = parse_ClipboardFormatOrAnsiString(o);
if(o.length - o.l <= 4) return v;
var m/*:number*/ = o.read_shift(4);
if(m == 0 || m > 40) return v;
o.l-=4; v.Reserved1 = o.read_shift(0, "lpstr-ansi");
if(o.length - o.l <= 4) return v;
m = o.read_shift(4);
if(m !== 0x71b239f4) return v;
v.UnicodeClipboardFormat = parse_ClipboardFormatOrUnicodeString(o);
m = o.read_shift(4);
if(m == 0 || m > 40) return v;
o.l-=4; v.Reserved2 = o.read_shift(0, "lpwstr");
} | javascript | function parse_compobj(obj/*:CFBEntry*/) {
var v = {};
var o = obj.content;
/*:: if(o == null) return; */
/* [MS-OLEDS] 2.3.7 CompObjHeader -- All fields MUST be ignored */
o.l = 28;
v.AnsiUserType = o.read_shift(0, "lpstr-ansi");
v.AnsiClipboardFormat = parse_ClipboardFormatOrAnsiString(o);
if(o.length - o.l <= 4) return v;
var m/*:number*/ = o.read_shift(4);
if(m == 0 || m > 40) return v;
o.l-=4; v.Reserved1 = o.read_shift(0, "lpstr-ansi");
if(o.length - o.l <= 4) return v;
m = o.read_shift(4);
if(m !== 0x71b239f4) return v;
v.UnicodeClipboardFormat = parse_ClipboardFormatOrUnicodeString(o);
m = o.read_shift(4);
if(m == 0 || m > 40) return v;
o.l-=4; v.Reserved2 = o.read_shift(0, "lpwstr");
} | [
"function",
"parse_compobj",
"(",
"obj",
"/*:CFBEntry*/",
")",
"{",
"var",
"v",
"=",
"{",
"}",
";",
"var",
"o",
"=",
"obj",
".",
"content",
";",
"/*:: if(o == null) return; */",
"/* [MS-OLEDS] 2.3.7 CompObjHeader -- All fields MUST be ignored */",
"o",
".",
"l",
"="... | /* [MS-OLEDS] 2.3.8 CompObjStream | [
"/",
"*",
"[",
"MS",
"-",
"OLEDS",
"]",
"2",
".",
"3",
".",
"8",
"CompObjStream"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/76_xls.js#L2-L27 | train | Parse CompObj | [
30522,
3853,
11968,
3366,
1035,
4012,
6873,
2497,
3501,
1006,
27885,
3501,
1013,
1008,
1024,
12935,
10609,
11129,
1008,
1013,
1007,
1063,
13075,
1058,
1027,
1063,
1065,
1025,
13075,
1051,
1027,
27885,
3501,
1012,
4180,
1025,
1013,
1008,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/JSONView.js | function(oSettings) {
var oMetadata = this.getMetadata(),
aValidKeys = oMetadata.getJSONKeys(), // UID names required, they're part of the documented contract
sKey, oValue, oKeyInfo;
for (sKey in oSettings) {
// get info object for the key
if ( (oKeyInfo = aValidKeys[sKey]) !== undefined ) {
oValue = oSettings[sKey];
switch (oKeyInfo._iKind) {
case 3: // SINGLE ASSOCIATIONS
// prefix the association ids with the view id
if ( typeof oValue === "string" ) {
oSettings[sKey] = that.createId(oValue);
}
break;
case 5: // EVENTS
if ( typeof oValue === "string" ) {
oSettings[sKey] = EventHandlerResolver.resolveEventHandler(oValue, oController);
}
break;
}
}
}
} | javascript | function(oSettings) {
var oMetadata = this.getMetadata(),
aValidKeys = oMetadata.getJSONKeys(), // UID names required, they're part of the documented contract
sKey, oValue, oKeyInfo;
for (sKey in oSettings) {
// get info object for the key
if ( (oKeyInfo = aValidKeys[sKey]) !== undefined ) {
oValue = oSettings[sKey];
switch (oKeyInfo._iKind) {
case 3: // SINGLE ASSOCIATIONS
// prefix the association ids with the view id
if ( typeof oValue === "string" ) {
oSettings[sKey] = that.createId(oValue);
}
break;
case 5: // EVENTS
if ( typeof oValue === "string" ) {
oSettings[sKey] = EventHandlerResolver.resolveEventHandler(oValue, oController);
}
break;
}
}
}
} | [
"function",
"(",
"oSettings",
")",
"{",
"var",
"oMetadata",
"=",
"this",
".",
"getMetadata",
"(",
")",
",",
"aValidKeys",
"=",
"oMetadata",
".",
"getJSONKeys",
"(",
")",
",",
"// UID names required, they're part of the documented contract",
"sKey",
",",
"oValue",
... | preprocess 'mSettings' for setting the controller as Listener for defined events => make sure to store old preprocessor in case of nested views | [
"preprocess",
"mSettings",
"for",
"setting",
"the",
"controller",
"as",
"Listener",
"for",
"defined",
"events",
"=",
">",
"make",
"sure",
"to",
"store",
"old",
"preprocessor",
"in",
"case",
"of",
"nested",
"views"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/JSONView.js#L216-L239 | train | Creates the view id and event handlers for the given controller | [
30522,
3853,
1006,
9808,
18319,
3070,
2015,
1007,
1063,
13075,
18168,
12928,
2850,
2696,
1027,
2023,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1010,
10927,
21273,
14839,
2015,
1027,
18168,
12928,
2850,
2696,
1012,
2131,
22578,
2239,
14839,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/api/encodeGlobal.js | function(filePath) {
var page = output.getPage(filePath);
if (!page) return undefined;
return encodePage(output, page);
} | javascript | function(filePath) {
var page = output.getPage(filePath);
if (!page) return undefined;
return encodePage(output, page);
} | [
"function",
"(",
"filePath",
")",
"{",
"var",
"page",
"=",
"output",
".",
"getPage",
"(",
"filePath",
")",
";",
"if",
"(",
"!",
"page",
")",
"return",
"undefined",
";",
"return",
"encodePage",
"(",
"output",
",",
"page",
")",
";",
"}"
] | Resolve a page by it path
@param {String} filePath
@return {String} | [
"Resolve",
"a",
"page",
"by",
"it",
"path"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeGlobal.js#L92-L97 | train | Get the page name from a file | [
30522,
3853,
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,
4372,
16044,
13704,
1006,
6434,
1010,
3931,
1007,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/search/FindReplace.js | doSearch | function doSearch(editor, searchBackwards) {
var state = getSearchState(editor._codeMirror);
if (state.parsedQuery) {
findNext(editor, searchBackwards);
} else {
openSearchBar(editor, false);
}
} | javascript | function doSearch(editor, searchBackwards) {
var state = getSearchState(editor._codeMirror);
if (state.parsedQuery) {
findNext(editor, searchBackwards);
} else {
openSearchBar(editor, false);
}
} | [
"function",
"doSearch",
"(",
"editor",
",",
"searchBackwards",
")",
"{",
"var",
"state",
"=",
"getSearchState",
"(",
"editor",
".",
"_codeMirror",
")",
";",
"if",
"(",
"state",
".",
"parsedQuery",
")",
"{",
"findNext",
"(",
"editor",
",",
"searchBackwards",
... | If no search pending, opens the Find dialog. If search bar already open, moves to
next/prev result (depending on 'searchBackwards') | [
"If",
"no",
"search",
"pending",
"opens",
"the",
"Find",
"dialog",
".",
"If",
"search",
"bar",
"already",
"open",
"moves",
"to",
"next",
"/",
"prev",
"result",
"(",
"depending",
"on",
"searchBackwards",
")"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L655-L663 | train | doSearch - Search for a search term | [
30522,
3853,
13004,
2906,
2818,
1006,
3559,
1010,
3945,
5963,
7652,
2015,
1007,
1063,
13075,
2110,
1027,
4152,
14644,
18069,
12259,
1006,
3559,
1012,
1035,
3642,
14503,
29165,
1007,
1025,
2065,
1006,
2110,
1012,
11968,
6924,
4226,
2854,
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... |
cytoscape/cytoscape.js | src/collection/style.js | function( property, includeNonDefault = true ){
let ele = this[0];
let cy = ele.cy();
if( !cy.styleEnabled() ){ return; }
if( ele ){
let overriddenStyle = ele._private.style[ property ];
if( overriddenStyle != null ){
return overriddenStyle;
} else if( includeNonDefault ){
return cy.style().getDefaultProperty( property );
} else {
return null;
}
}
} | javascript | function( property, includeNonDefault = true ){
let ele = this[0];
let cy = ele.cy();
if( !cy.styleEnabled() ){ return; }
if( ele ){
let overriddenStyle = ele._private.style[ property ];
if( overriddenStyle != null ){
return overriddenStyle;
} else if( includeNonDefault ){
return cy.style().getDefaultProperty( property );
} else {
return null;
}
}
} | [
"function",
"(",
"property",
",",
"includeNonDefault",
"=",
"true",
")",
"{",
"let",
"ele",
"=",
"this",
"[",
"0",
"]",
";",
"let",
"cy",
"=",
"ele",
".",
"cy",
"(",
")",
";",
"if",
"(",
"!",
"cy",
".",
"styleEnabled",
"(",
")",
")",
"{",
"retu... | get the internal parsed style object for the specified property | [
"get",
"the",
"internal",
"parsed",
"style",
"object",
"for",
"the",
"specified",
"property"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/src/collection/style.js#L116-L133 | train | Returns the value of a specific style property | [
30522,
3853,
1006,
3200,
1010,
2421,
8540,
3207,
7011,
11314,
1027,
2995,
1007,
1063,
2292,
3449,
2063,
1027,
2023,
1031,
1014,
1033,
1025,
2292,
22330,
1027,
3449,
2063,
1012,
22330,
1006,
1007,
1025,
2065,
1006,
999,
22330,
1012,
2806,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
vuejs/vuepress | packages/@vuepress/core/lib/node/dev/index.js | resolvePort | async function resolvePort (port) {
const portfinder = require('portfinder')
portfinder.basePort = parseInt(port) || 8080
port = await portfinder.getPortPromise()
return port
} | javascript | async function resolvePort (port) {
const portfinder = require('portfinder')
portfinder.basePort = parseInt(port) || 8080
port = await portfinder.getPortPromise()
return port
} | [
"async",
"function",
"resolvePort",
"(",
"port",
")",
"{",
"const",
"portfinder",
"=",
"require",
"(",
"'portfinder'",
")",
"portfinder",
".",
"basePort",
"=",
"parseInt",
"(",
"port",
")",
"||",
"8080",
"port",
"=",
"await",
"portfinder",
".",
"getPortPromi... | Resolve port.
@param {number} port user's port
@returns {Promise<number>} | [
"Resolve",
"port",
"."
] | 15784acc0cf2e87de3c147895b2c3977b0195d78 | https://github.com/vuejs/vuepress/blob/15784acc0cf2e87de3c147895b2c3977b0195d78/packages/@vuepress/core/lib/node/dev/index.js#L287-L292 | train | Resolve a port | [
30522,
2004,
6038,
2278,
3853,
10663,
6442,
1006,
3417,
1007,
1063,
9530,
3367,
3417,
23695,
1027,
5478,
1006,
1005,
3417,
23695,
1005,
1007,
3417,
23695,
1012,
2918,
6442,
1027,
11968,
20240,
3372,
1006,
3417,
1007,
1064,
1064,
3770,
17914... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(element) {
// There should be exactly 1 element child which is a P:
if (element.children.length != 1 || element.children[0].tagName !== "P") {
return false;
}
// And there should be no text nodes with real content
return !this._someNode(element.childNodes, function(node) {
return node.nodeType === this.TEXT_NODE &&
this.REGEXPS.hasContent.test(node.textContent);
});
} | javascript | function(element) {
// There should be exactly 1 element child which is a P:
if (element.children.length != 1 || element.children[0].tagName !== "P") {
return false;
}
// And there should be no text nodes with real content
return !this._someNode(element.childNodes, function(node) {
return node.nodeType === this.TEXT_NODE &&
this.REGEXPS.hasContent.test(node.textContent);
});
} | [
"function",
"(",
"element",
")",
"{",
"// There should be exactly 1 element child which is a P:",
"if",
"(",
"element",
".",
"children",
".",
"length",
"!=",
"1",
"||",
"element",
".",
"children",
"[",
"0",
"]",
".",
"tagName",
"!==",
"\"P\"",
")",
"{",
"retur... | Check if this node has only whitespace and a single P element
Returns false if the DIV node contains non-empty text nodes
or if it contains no P or more than 1 element.
@param Element | [
"Check",
"if",
"this",
"node",
"has",
"only",
"whitespace",
"and",
"a",
"single",
"P",
"element",
"Returns",
"false",
"if",
"the",
"DIV",
"node",
"contains",
"non",
"-",
"empty",
"text",
"nodes",
"or",
"if",
"it",
"contains",
"no",
"P",
"or",
"more",
"... | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1284-L1295 | train | Returns true if the element has no children | [
30522,
3853,
1006,
5783,
1007,
1063,
1013,
1013,
2045,
2323,
2022,
3599,
1015,
5783,
2775,
2029,
2003,
1037,
1052,
1024,
2065,
1006,
5783,
1012,
2336,
1012,
3091,
999,
1027,
1015,
1064,
1064,
5783,
1012,
2336,
1031,
1014,
1033,
1012,
6415... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | findSelectorAtDocumentPos | function findSelectorAtDocumentPos(editor, pos) {
var cm = editor._codeMirror;
var ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
var selector = "", foundChars = false;
var isPreprocessorDoc = isCSSPreprocessorFile(editor.document.file.fullPath);
var selectorArray = [];
function _skipToOpeningBracket(ctx, startChar) {
var unmatchedBraces = 0;
if (!startChar) {
startChar = "}";
}
while (true) {
if (startChar === ctx.token.string) {
unmatchedBraces++;
} else if (ctx.token.string.match(_invertedBracketPairs[startChar])) {
unmatchedBraces--;
if (unmatchedBraces <= 0) {
return;
}
}
if (!TokenUtils.movePrevToken(ctx)) {
return;
}
}
}
// Parse a selector. Assumes ctx is pointing at the opening
// { that is after the selector name.
function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
}
var skipPrevSibling = false,
state = _getContextState(ctx);
// If the cursor is inside a non-whitespace token with "block" or "top" state, then it is inside a
// selector. The only exception is when it is immediately after the '{'.
if (isPreprocessorDoc && _hasNonWhitespace(ctx.token.string) && ctx.token.string !== "{" &&
(state.state === "block" || state.state === "top")) {
foundChars = true;
}
// scan backwards to see if the cursor is in a rule
do {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "}") {
if (isPreprocessorDoc) {
if (state.state === "top") {
break;
}
skipPrevSibling = true;
// Skip past the entire preceding block until the matching "{"
_skipToOpeningBracket(ctx, "}");
} else {
break;
}
} else if (ctx.token.string === "{") {
selector = _parseSelector(ctx);
if (isPreprocessorDoc) {
if (!skipPrevSibling && !/^\s*@/.test(selector)) {
selectorArray.unshift(selector);
}
if (skipPrevSibling) {
skipPrevSibling = false;
}
} else {
break;
}
} else {
if (!isPreprocessorDoc && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
}
TokenUtils.movePrevToken(ctx);
}
} else {
TokenUtils.movePrevToken(ctx);
}
} while (!TokenUtils.isAtStart(ctx));
selector = _stripAtRules(selector);
// Reset the context to original scan position
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
// special case - we aren't in a selector and haven't found any chars,
// look at the next immediate token to see if it is non-whitespace.
// For preprocessor documents we need to move the cursor to next non-whitespace
// token so that we can collect the current selector if the cursor is inside it.
if ((!selector && !foundChars && !isPreprocessorDoc) ||
(isPreprocessorDoc && (ctx.token.string === "" || /\s+/.test(ctx.token.string)))) {
if (TokenUtils.moveNextToken(ctx) && ctx.token.type !== "comment" && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
}
}
// At this point if we haven't found a selector, but have seen chars when
// scanning, assume we are in the middle of a selector. For a preprocessor
// document we also need to collect the current selector if the cursor is
// within the selector or whitespaces immediately before or after it.
if ((!selector || isPreprocessorDoc) && foundChars) {
// scan forward to see if the cursor is in a selector
while (true) {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "{") {
selector = _parseSelector(ctx);
if (isPreprocessorDoc && !/^\s*@/.test(selector)) {
selectorArray.push(selector);
}
break;
} else if (ctx.token.string === "}" || ctx.token.string === ";") {
break;
}
}
if (!TokenUtils.moveNextToken(ctx)) {
break;
}
}
}
if (isPreprocessorDoc) {
return _getSelectorInFinalCSSForm(selectorArray);
}
return _stripAtRules(selector);
} | javascript | function findSelectorAtDocumentPos(editor, pos) {
var cm = editor._codeMirror;
var ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
var selector = "", foundChars = false;
var isPreprocessorDoc = isCSSPreprocessorFile(editor.document.file.fullPath);
var selectorArray = [];
function _skipToOpeningBracket(ctx, startChar) {
var unmatchedBraces = 0;
if (!startChar) {
startChar = "}";
}
while (true) {
if (startChar === ctx.token.string) {
unmatchedBraces++;
} else if (ctx.token.string.match(_invertedBracketPairs[startChar])) {
unmatchedBraces--;
if (unmatchedBraces <= 0) {
return;
}
}
if (!TokenUtils.movePrevToken(ctx)) {
return;
}
}
}
// Parse a selector. Assumes ctx is pointing at the opening
// { that is after the selector name.
function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
}
var skipPrevSibling = false,
state = _getContextState(ctx);
// If the cursor is inside a non-whitespace token with "block" or "top" state, then it is inside a
// selector. The only exception is when it is immediately after the '{'.
if (isPreprocessorDoc && _hasNonWhitespace(ctx.token.string) && ctx.token.string !== "{" &&
(state.state === "block" || state.state === "top")) {
foundChars = true;
}
// scan backwards to see if the cursor is in a rule
do {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "}") {
if (isPreprocessorDoc) {
if (state.state === "top") {
break;
}
skipPrevSibling = true;
// Skip past the entire preceding block until the matching "{"
_skipToOpeningBracket(ctx, "}");
} else {
break;
}
} else if (ctx.token.string === "{") {
selector = _parseSelector(ctx);
if (isPreprocessorDoc) {
if (!skipPrevSibling && !/^\s*@/.test(selector)) {
selectorArray.unshift(selector);
}
if (skipPrevSibling) {
skipPrevSibling = false;
}
} else {
break;
}
} else {
if (!isPreprocessorDoc && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
}
TokenUtils.movePrevToken(ctx);
}
} else {
TokenUtils.movePrevToken(ctx);
}
} while (!TokenUtils.isAtStart(ctx));
selector = _stripAtRules(selector);
// Reset the context to original scan position
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
// special case - we aren't in a selector and haven't found any chars,
// look at the next immediate token to see if it is non-whitespace.
// For preprocessor documents we need to move the cursor to next non-whitespace
// token so that we can collect the current selector if the cursor is inside it.
if ((!selector && !foundChars && !isPreprocessorDoc) ||
(isPreprocessorDoc && (ctx.token.string === "" || /\s+/.test(ctx.token.string)))) {
if (TokenUtils.moveNextToken(ctx) && ctx.token.type !== "comment" && _hasNonWhitespace(ctx.token.string)) {
foundChars = true;
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
}
}
// At this point if we haven't found a selector, but have seen chars when
// scanning, assume we are in the middle of a selector. For a preprocessor
// document we also need to collect the current selector if the cursor is
// within the selector or whitespaces immediately before or after it.
if ((!selector || isPreprocessorDoc) && foundChars) {
// scan forward to see if the cursor is in a selector
while (true) {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "{") {
selector = _parseSelector(ctx);
if (isPreprocessorDoc && !/^\s*@/.test(selector)) {
selectorArray.push(selector);
}
break;
} else if (ctx.token.string === "}" || ctx.token.string === ";") {
break;
}
}
if (!TokenUtils.moveNextToken(ctx)) {
break;
}
}
}
if (isPreprocessorDoc) {
return _getSelectorInFinalCSSForm(selectorArray);
}
return _stripAtRules(selector);
} | [
"function",
"findSelectorAtDocumentPos",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
";",
"var",
"ctx",
"=",
"TokenUtils",
".",
"getInitialContext",
"(",
"cm",
",",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"pos",
... | Returns the selector(s) of the rule at the specified document pos, or "" if the position is
is not within a style rule.
@param {!Editor} editor Editor to search
@param {!{line: number, ch: number}} pos Position to search
@return {string} Selector(s) for the rule at the specified position, or "" if the position
is not within a style rule. If the rule has multiple selectors, a comma-separated
selector string is returned. | [
"Returns",
"the",
"selector",
"(",
"s",
")",
"of",
"the",
"rule",
"at",
"the",
"specified",
"document",
"pos",
"or",
"if",
"the",
"position",
"is",
"is",
"not",
"within",
"a",
"style",
"rule",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1533-L1689 | train | Find a selector at the given position. | [
30522,
3853,
4858,
12260,
16761,
4017,
3527,
24894,
4765,
6873,
2015,
1006,
3559,
1010,
13433,
2015,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
1035,
3642,
14503,
29165,
1025,
13075,
14931,
2595,
1027,
19204,
21823,
4877,
1012,
2131,
5498,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | fileExists | function fileExists(filename) {
var d = Promise.defer();
fs.exists(filename, function(exists) {
d.resolve(exists);
});
return d.promise;
} | javascript | function fileExists(filename) {
var d = Promise.defer();
fs.exists(filename, function(exists) {
d.resolve(exists);
});
return d.promise;
} | [
"function",
"fileExists",
"(",
"filename",
")",
"{",
"var",
"d",
"=",
"Promise",
".",
"defer",
"(",
")",
";",
"fs",
".",
"exists",
"(",
"filename",
",",
"function",
"(",
"exists",
")",
"{",
"d",
".",
"resolve",
"(",
"exists",
")",
";",
"}",
")",
... | Return a promise resolved with a boolean | [
"Return",
"a",
"promise",
"resolved",
"with",
"a",
"boolean"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L43-L51 | train | Check if a file exists | [
30522,
3853,
5371,
10288,
5130,
1006,
5371,
18442,
30524,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/TargetCache.js | function (sName, sType, oObject) {
var oInstanceCache;
this._checkName(sName, sType);
assert(sType === "View" || sType === "Component", "sType must be either 'View' or 'Component'");
oInstanceCache = this._oCache[sType.toLowerCase()][sName];
if (!oInstanceCache) {
oInstanceCache = this._oCache[sType.toLowerCase()][sName] = {};
}
oInstanceCache[undefined] = oObject;
return this;
} | javascript | function (sName, sType, oObject) {
var oInstanceCache;
this._checkName(sName, sType);
assert(sType === "View" || sType === "Component", "sType must be either 'View' or 'Component'");
oInstanceCache = this._oCache[sType.toLowerCase()][sName];
if (!oInstanceCache) {
oInstanceCache = this._oCache[sType.toLowerCase()][sName] = {};
}
oInstanceCache[undefined] = oObject;
return this;
} | [
"function",
"(",
"sName",
",",
"sType",
",",
"oObject",
")",
"{",
"var",
"oInstanceCache",
";",
"this",
".",
"_checkName",
"(",
"sName",
",",
"sType",
")",
";",
"assert",
"(",
"sType",
"===",
"\"View\"",
"||",
"sType",
"===",
"\"Component\"",
",",
"\"sTy... | Adds or overwrites a view or a component in the TargetCache. The given object is cached under its name and the 'undefined' key.
If the third parameter is set to null or undefined, the previous cache view or component under the same name isn't managed by the TargetCache instance.
The lifecycle (for example the destroy) of the view or component instance should be maintained by additional code.
@param {string} sName Name of the view or component, may differ from the actual name of the oObject parameter provided, since you can retrieve this view or component per {@link #.getObject}.
@param {string} sType whether the object is a "View" or "Component". Views and components are stored separately in the cache. This means that a view and a component instance
could be stored under the same name.
@param {sap.ui.core.mvc.View|sap.ui.core.UIComponent|null|undefined} oObject the view or component instance
@return {sap.ui.core.routing.TargetCache} this for chaining.
@private | [
"Adds",
"or",
"overwrites",
"a",
"view",
"or",
"a",
"component",
"in",
"the",
"TargetCache",
".",
"The",
"given",
"object",
"is",
"cached",
"under",
"its",
"name",
"and",
"the",
"undefined",
"key",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/TargetCache.js#L133-L148 | train | Sets an object in the cache for the given type. | [
30522,
3853,
1006,
1055,
18442,
1010,
2358,
18863,
1010,
1051,
16429,
20614,
1007,
1063,
13075,
1051,
7076,
26897,
3540,
5403,
1025,
2023,
1012,
1035,
4638,
18442,
1006,
1055,
18442,
1010,
2358,
18863,
1007,
1025,
20865,
1006,
2358,
18863,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-unused-labels.js | markAsUsed | function markAsUsed(node) {
if (!node.label) {
return;
}
const label = node.label.name;
let info = scopeInfo;
while (info) {
if (info.label === label) {
info.used = true;
break;
}
info = info.upper;
}
} | javascript | function markAsUsed(node) {
if (!node.label) {
return;
}
const label = node.label.name;
let info = scopeInfo;
while (info) {
if (info.label === label) {
info.used = true;
break;
}
info = info.upper;
}
} | [
"function",
"markAsUsed",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"label",
")",
"{",
"return",
";",
"}",
"const",
"label",
"=",
"node",
".",
"label",
".",
"name",
";",
"let",
"info",
"=",
"scopeInfo",
";",
"while",
"(",
"info",
")",
"... | Marks the label of a given node as used.
@param {ASTNode} node - A node to mark. This is a BreakStatement or
ContinueStatement.
@returns {void} | [
"Marks",
"the",
"label",
"of",
"a",
"given",
"node",
"as",
"used",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-labels.js#L89-L104 | train | Mark node as used | [
30522,
3853,
2928,
3022,
13901,
1006,
13045,
1007,
1063,
2065,
1006,
999,
13045,
1012,
3830,
1007,
1063,
2709,
1025,
1065,
9530,
3367,
3830,
1027,
13045,
1012,
3830,
1012,
2171,
1025,
2292,
18558,
1027,
9531,
2378,
14876,
1025,
2096,
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... |
angular/material | src/components/datepicker/js/datepickerDirective.js | DatePickerCtrl | function DatePickerCtrl($scope, $element, $attrs, $window, $mdConstant, $mdTheming, $mdUtil,
$mdDateLocale, $$mdDateUtil, $$rAF, $filter, $timeout) {
/** @final */
this.$window = $window;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.$mdConstant = $mdConstant;
/** @final */
this.$mdUtil = $mdUtil;
/** @final */
this.$$rAF = $$rAF;
/** @final */
this.$mdDateLocale = $mdDateLocale;
/** @final */
this.$timeout = $timeout;
/**
* The root document element. This is used for attaching a top-level click handler to
* close the calendar panel when a click outside said panel occurs. We use `documentElement`
* instead of body because, when scrolling is disabled, some browsers consider the body element
* to be completely off the screen and propagate events directly to the html element.
* @type {!angular.JQLite}
*/
this.documentElement = angular.element(document.documentElement);
/** @type {!angular.NgModelController} */
this.ngModelCtrl = null;
/** @type {HTMLInputElement} */
this.inputElement = $element[0].querySelector('input');
/** @final {!angular.JQLite} */
this.ngInputElement = angular.element(this.inputElement);
/** @type {HTMLElement} */
this.inputContainer = $element[0].querySelector('.md-datepicker-input-container');
/** @type {HTMLElement} Floating calendar pane. */
this.calendarPane = $element[0].querySelector('.md-datepicker-calendar-pane');
/** @type {HTMLElement} Calendar icon button. */
this.calendarButton = $element[0].querySelector('.md-datepicker-button');
/**
* Element covering everything but the input in the top of the floating calendar pane.
* @type {!angular.JQLite}
*/
this.inputMask = angular.element($element[0].querySelector('.md-datepicker-input-mask-opaque'));
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final {!angular.Attributes} */
this.$attrs = $attrs;
/** @final {!angular.Scope} */
this.$scope = $scope;
/** @type {Date} */
this.date = null;
/** @type {boolean} */
this.isFocused = false;
/** @type {boolean} */
this.isDisabled;
this.setDisabled($element[0].disabled || angular.isString($attrs.disabled));
/** @type {boolean} Whether the date-picker's calendar pane is open. */
this.isCalendarOpen = false;
/** @type {boolean} Whether the calendar should open when the input is focused. */
this.openOnFocus = $attrs.hasOwnProperty('mdOpenOnFocus');
/** @final */
this.mdInputContainer = null;
/**
* Element from which the calendar pane was opened. Keep track of this so that we can return
* focus to it when the pane is closed.
* @type {HTMLElement}
*/
this.calendarPaneOpenedFrom = null;
/** @type {String} Unique id for the calendar pane. */
this.calendarPaneId = 'md-date-pane-' + $mdUtil.nextUid();
/** Pre-bound click handler is saved so that the event listener can be removed. */
this.bodyClickHandler = angular.bind(this, this.handleBodyClick);
/**
* Name of the event that will trigger a close. Necessary to sniff the browser, because
* the resize event doesn't make sense on mobile and can have a negative impact since it
* triggers whenever the browser zooms in on a focused input.
*/
this.windowEventName = IS_MOBILE_REGEX.test(
navigator.userAgent || navigator.vendor || window.opera
) ? 'orientationchange' : 'resize';
/** Pre-bound close handler so that the event listener can be removed. */
this.windowEventHandler = $mdUtil.debounce(angular.bind(this, this.closeCalendarPane), 100);
/** Pre-bound handler for the window blur event. Allows for it to be removed later. */
this.windowBlurHandler = angular.bind(this, this.handleWindowBlur);
/** The built-in AngularJS date filter. */
this.ngDateFilter = $filter('date');
/** @type {Number} Extra margin for the left side of the floating calendar pane. */
this.leftMargin = 20;
/** @type {Number} Extra margin for the top of the floating calendar. Gets determined on the first open. */
this.topMargin = null;
// Unless the user specifies so, the datepicker should not be a tab stop.
// This is necessary because ngAria might add a tabindex to anything with an ng-model
// (based on whether or not the user has turned that particular feature on/off).
if ($attrs.tabindex) {
this.ngInputElement.attr('tabindex', $attrs.tabindex);
$attrs.$set('tabindex', null);
} else {
$attrs.$set('tabindex', '-1');
}
$attrs.$set('aria-owns', this.calendarPaneId);
$mdTheming($element);
$mdTheming(angular.element(this.calendarPane));
var self = this;
$scope.$on('$destroy', function() {
self.detachCalendarPane();
});
if ($attrs.mdIsOpen) {
$scope.$watch('ctrl.isOpen', function(shouldBeOpen) {
if (shouldBeOpen) {
self.openCalendarPane({
target: self.inputElement
});
} else {
self.closeCalendarPane();
}
});
}
// For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are pre-assigned,
// manually call the $onInit hook.
if (angular.version.major === 1 && angular.version.minor <= 4) {
this.$onInit();
}
} | javascript | function DatePickerCtrl($scope, $element, $attrs, $window, $mdConstant, $mdTheming, $mdUtil,
$mdDateLocale, $$mdDateUtil, $$rAF, $filter, $timeout) {
/** @final */
this.$window = $window;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.$mdConstant = $mdConstant;
/** @final */
this.$mdUtil = $mdUtil;
/** @final */
this.$$rAF = $$rAF;
/** @final */
this.$mdDateLocale = $mdDateLocale;
/** @final */
this.$timeout = $timeout;
/**
* The root document element. This is used for attaching a top-level click handler to
* close the calendar panel when a click outside said panel occurs. We use `documentElement`
* instead of body because, when scrolling is disabled, some browsers consider the body element
* to be completely off the screen and propagate events directly to the html element.
* @type {!angular.JQLite}
*/
this.documentElement = angular.element(document.documentElement);
/** @type {!angular.NgModelController} */
this.ngModelCtrl = null;
/** @type {HTMLInputElement} */
this.inputElement = $element[0].querySelector('input');
/** @final {!angular.JQLite} */
this.ngInputElement = angular.element(this.inputElement);
/** @type {HTMLElement} */
this.inputContainer = $element[0].querySelector('.md-datepicker-input-container');
/** @type {HTMLElement} Floating calendar pane. */
this.calendarPane = $element[0].querySelector('.md-datepicker-calendar-pane');
/** @type {HTMLElement} Calendar icon button. */
this.calendarButton = $element[0].querySelector('.md-datepicker-button');
/**
* Element covering everything but the input in the top of the floating calendar pane.
* @type {!angular.JQLite}
*/
this.inputMask = angular.element($element[0].querySelector('.md-datepicker-input-mask-opaque'));
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final {!angular.Attributes} */
this.$attrs = $attrs;
/** @final {!angular.Scope} */
this.$scope = $scope;
/** @type {Date} */
this.date = null;
/** @type {boolean} */
this.isFocused = false;
/** @type {boolean} */
this.isDisabled;
this.setDisabled($element[0].disabled || angular.isString($attrs.disabled));
/** @type {boolean} Whether the date-picker's calendar pane is open. */
this.isCalendarOpen = false;
/** @type {boolean} Whether the calendar should open when the input is focused. */
this.openOnFocus = $attrs.hasOwnProperty('mdOpenOnFocus');
/** @final */
this.mdInputContainer = null;
/**
* Element from which the calendar pane was opened. Keep track of this so that we can return
* focus to it when the pane is closed.
* @type {HTMLElement}
*/
this.calendarPaneOpenedFrom = null;
/** @type {String} Unique id for the calendar pane. */
this.calendarPaneId = 'md-date-pane-' + $mdUtil.nextUid();
/** Pre-bound click handler is saved so that the event listener can be removed. */
this.bodyClickHandler = angular.bind(this, this.handleBodyClick);
/**
* Name of the event that will trigger a close. Necessary to sniff the browser, because
* the resize event doesn't make sense on mobile and can have a negative impact since it
* triggers whenever the browser zooms in on a focused input.
*/
this.windowEventName = IS_MOBILE_REGEX.test(
navigator.userAgent || navigator.vendor || window.opera
) ? 'orientationchange' : 'resize';
/** Pre-bound close handler so that the event listener can be removed. */
this.windowEventHandler = $mdUtil.debounce(angular.bind(this, this.closeCalendarPane), 100);
/** Pre-bound handler for the window blur event. Allows for it to be removed later. */
this.windowBlurHandler = angular.bind(this, this.handleWindowBlur);
/** The built-in AngularJS date filter. */
this.ngDateFilter = $filter('date');
/** @type {Number} Extra margin for the left side of the floating calendar pane. */
this.leftMargin = 20;
/** @type {Number} Extra margin for the top of the floating calendar. Gets determined on the first open. */
this.topMargin = null;
// Unless the user specifies so, the datepicker should not be a tab stop.
// This is necessary because ngAria might add a tabindex to anything with an ng-model
// (based on whether or not the user has turned that particular feature on/off).
if ($attrs.tabindex) {
this.ngInputElement.attr('tabindex', $attrs.tabindex);
$attrs.$set('tabindex', null);
} else {
$attrs.$set('tabindex', '-1');
}
$attrs.$set('aria-owns', this.calendarPaneId);
$mdTheming($element);
$mdTheming(angular.element(this.calendarPane));
var self = this;
$scope.$on('$destroy', function() {
self.detachCalendarPane();
});
if ($attrs.mdIsOpen) {
$scope.$watch('ctrl.isOpen', function(shouldBeOpen) {
if (shouldBeOpen) {
self.openCalendarPane({
target: self.inputElement
});
} else {
self.closeCalendarPane();
}
});
}
// For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are pre-assigned,
// manually call the $onInit hook.
if (angular.version.major === 1 && angular.version.minor <= 4) {
this.$onInit();
}
} | [
"function",
"DatePickerCtrl",
"(",
"$scope",
",",
"$element",
",",
"$attrs",
",",
"$window",
",",
"$mdConstant",
",",
"$mdTheming",
",",
"$mdUtil",
",",
"$mdDateLocale",
",",
"$$mdDateUtil",
",",
"$$rAF",
",",
"$filter",
",",
"$timeout",
")",
"{",
"/** @final ... | Controller for md-datepicker.
@ngInject @constructor | [
"Controller",
"for",
"md",
"-",
"datepicker",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/datepickerDirective.js#L255-L416 | train | The controller for the datepicker directive. | [
30522,
3853,
3058,
24330,
5484,
6593,
12190,
1006,
1002,
9531,
1010,
1002,
5783,
1010,
1002,
2012,
16344,
2015,
1010,
1002,
3332,
1010,
1002,
9108,
8663,
12693,
2102,
1010,
1002,
9108,
10760,
6562,
1010,
1002,
9108,
21823,
2140,
1010,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js | function(sUrl) {
for (var i = 0; i < this.aEntriesUrlReplace.length; i++) {
var oEntry = this.aEntriesUrlReplace[i];
if (oEntry.regex instanceof RegExp && oEntry.value !== undefined) {
sUrl = sUrl.replace(oEntry.regex, oEntry.value);
} else {
this.oLog.warning(sModuleName + " - Invalid regular expression for url replace.");
}
}
return sUrl;
} | javascript | function(sUrl) {
for (var i = 0; i < this.aEntriesUrlReplace.length; i++) {
var oEntry = this.aEntriesUrlReplace[i];
if (oEntry.regex instanceof RegExp && oEntry.value !== undefined) {
sUrl = sUrl.replace(oEntry.regex, oEntry.value);
} else {
this.oLog.warning(sModuleName + " - Invalid regular expression for url replace.");
}
}
return sUrl;
} | [
"function",
"(",
"sUrl",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"aEntriesUrlReplace",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"oEntry",
"=",
"this",
".",
"aEntriesUrlReplace",
"[",
"i",
"]",
";",
"if",
"("... | Applies the provided Regex on the URL and replaces the needed parts.
@param {string} sUrl The URL on which the replaces are applied.
@returns {string} The new URL with the replaced parts. | [
"Applies",
"the",
"provided",
"Regex",
"on",
"the",
"URL",
"and",
"replaces",
"the",
"needed",
"parts",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L209-L219 | train | Replaces the given url with the value of the entry | [
30522,
3853,
1006,
7505,
2140,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2023,
1012,
29347,
3372,
5134,
3126,
20974,
13699,
19217,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
13075,
1051,
4765,
2854,
1027,
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... | |
SeleniumHQ/selenium | javascript/selenium-core/xpath/xpath.js | xpathCollectDescendants | function xpathCollectDescendants(nodelist, node, opt_tagName) {
if (opt_tagName && node.getElementsByTagName) {
copyArray(nodelist, node.getElementsByTagName(opt_tagName));
return;
}
for (var n = node.firstChild; n; n = n.nextSibling) {
nodelist.push(n);
xpathCollectDescendants(nodelist, n);
}
} | javascript | function xpathCollectDescendants(nodelist, node, opt_tagName) {
if (opt_tagName && node.getElementsByTagName) {
copyArray(nodelist, node.getElementsByTagName(opt_tagName));
return;
}
for (var n = node.firstChild; n; n = n.nextSibling) {
nodelist.push(n);
xpathCollectDescendants(nodelist, n);
}
} | [
"function",
"xpathCollectDescendants",
"(",
"nodelist",
",",
"node",
",",
"opt_tagName",
")",
"{",
"if",
"(",
"opt_tagName",
"&&",
"node",
".",
"getElementsByTagName",
")",
"{",
"copyArray",
"(",
"nodelist",
",",
"node",
".",
"getElementsByTagName",
"(",
"opt_ta... | Local utility functions that are used by the lexer or parser. | [
"Local",
"utility",
"functions",
"that",
"are",
"used",
"by",
"the",
"lexer",
"or",
"parser",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/xpath.js#L2362-L2371 | train | Recursively collect all descendant nodes of node | [
30522,
3853,
26726,
8988,
26895,
22471,
6155,
23865,
11390,
1006,
13045,
9863,
1010,
13045,
1010,
23569,
1035,
6415,
18442,
1007,
1063,
2065,
1006,
23569,
1035,
6415,
18442,
1004,
1004,
13045,
1012,
2131,
12260,
8163,
3762,
15900,
18442,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
if (this._oSortExpression == null) {
var oEntityType = this._oParameter.getContainingParameterization().getEntityType();
this._oSortExpression = new odata4analytics.SortExpression(oEntityType.getModel(), oEntityType.getSchema(),
oEntityType);
}
return this._oSortExpression;
} | javascript | function() {
if (this._oSortExpression == null) {
var oEntityType = this._oParameter.getContainingParameterization().getEntityType();
this._oSortExpression = new odata4analytics.SortExpression(oEntityType.getModel(), oEntityType.getSchema(),
oEntityType);
}
return this._oSortExpression;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_oSortExpression",
"==",
"null",
")",
"{",
"var",
"oEntityType",
"=",
"this",
".",
"_oParameter",
".",
"getContainingParameterization",
"(",
")",
".",
"getEntityType",
"(",
")",
";",
"this",
".",
"_oSortE... | Get the sort expression for this request.
Expressions are represented by separate objects. If none exists so far, a
new expression object gets created.
@returns {sap.ui.model.analytics.odata4analytics.SortExpression} The sort object
associated to this request.
@public
@function
@name sap.ui.model.analytics.odata4analytics.ParameterValueSetRequest#getSortExpression | [
"Get",
"the",
"sort",
"expression",
"for",
"this",
"request",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L5012-L5019 | train | Returns the sort expression for the parameterization | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
9808,
11589,
10288,
20110,
3258,
1027,
1027,
19701,
1007,
1063,
13075,
1051,
4765,
3012,
13874,
1027,
2023,
1012,
1035,
6728,
5400,
22828,
1012,
2131,
8663,
18249,
2075,
28689,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | examples/wms-custom-proj.js | CHtoWGSlat | function CHtoWGSlat(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
const y_aux = (y - 600000) / 1000000;
const x_aux = (x - 200000) / 1000000;
// Process lat
let lat = 16.9023892 +
3.238272 * x_aux -
0.270978 * Math.pow(y_aux, 2) -
0.002528 * Math.pow(x_aux, 2) -
0.0447 * Math.pow(y_aux, 2) * x_aux -
0.0140 * Math.pow(x_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lat = lat * 100 / 36;
return lat;
} | javascript | function CHtoWGSlat(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
const y_aux = (y - 600000) / 1000000;
const x_aux = (x - 200000) / 1000000;
// Process lat
let lat = 16.9023892 +
3.238272 * x_aux -
0.270978 * Math.pow(y_aux, 2) -
0.002528 * Math.pow(x_aux, 2) -
0.0447 * Math.pow(y_aux, 2) * x_aux -
0.0140 * Math.pow(x_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lat = lat * 100 / 36;
return lat;
} | [
"function",
"CHtoWGSlat",
"(",
"y",
",",
"x",
")",
"{",
"// Converts militar to civil and to unit = 1000km",
"// Axiliary values (% Bern)",
"const",
"y_aux",
"=",
"(",
"y",
"-",
"600000",
")",
"/",
"1000000",
";",
"const",
"x_aux",
"=",
"(",
"x",
"-",
"200000",... | Convert CH y/x to WGS lat | [
"Convert",
"CH",
"y",
"/",
"x",
"to",
"WGS",
"lat"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/wms-custom-proj.js#L147-L167 | train | Converts CH to WG - Laat | [
30522,
3853,
10381,
18790,
5620,
20051,
1006,
1061,
1010,
1060,
1007,
1063,
1013,
1013,
19884,
23689,
6590,
2099,
2000,
2942,
1998,
2000,
3131,
1027,
6694,
22287,
1013,
1013,
22260,
27861,
2854,
5300,
1006,
1003,
16595,
1007,
9530,
3367,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Time.js | toModel | function toModel(oDate) {
return {
__edmType : "Edm.Time",
ms : ((oDate.getUTCHours() * 60 + oDate.getUTCMinutes()) * 60 + oDate.getUTCSeconds())
* 1000 + oDate.getUTCMilliseconds()
};
} | javascript | function toModel(oDate) {
return {
__edmType : "Edm.Time",
ms : ((oDate.getUTCHours() * 60 + oDate.getUTCMinutes()) * 60 + oDate.getUTCSeconds())
* 1000 + oDate.getUTCMilliseconds()
};
} | [
"function",
"toModel",
"(",
"oDate",
")",
"{",
"return",
"{",
"__edmType",
":",
"\"Edm.Time\"",
",",
"ms",
":",
"(",
"(",
"oDate",
".",
"getUTCHours",
"(",
")",
"*",
"60",
"+",
"oDate",
".",
"getUTCMinutes",
"(",
")",
")",
"*",
"60",
"+",
"oDate",
... | Converts the given Date to a time object.
@param {Date} oDate
the date (day, month and year are ignored)
@returns {object}
a time object with __edmType and ms | [
"Converts",
"the",
"given",
"Date",
"to",
"a",
"time",
"object",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Time.js#L115-L121 | train | Converts a Date to a model. | [
30522,
3853,
3419,
10244,
2140,
1006,
1051,
13701,
1007,
1063,
2709,
1063,
1035,
1035,
3968,
20492,
18863,
1024,
1000,
3968,
2213,
1012,
2051,
1000,
1010,
5796,
1024,
1006,
1006,
1051,
13701,
1012,
2131,
4904,
9905,
9236,
1006,
1007,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/lines-around-comment.js | codeAroundComment | function codeAroundComment(token) {
let currentToken = token;
do {
currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) {
return true;
}
currentToken = token;
do {
currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) {
return true;
}
return false;
} | javascript | function codeAroundComment(token) {
let currentToken = token;
do {
currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnSameLine(currentToken, token)) {
return true;
}
currentToken = token;
do {
currentToken = sourceCode.getTokenAfter(currentToken, { includeComments: true });
} while (currentToken && astUtils.isCommentToken(currentToken));
if (currentToken && astUtils.isTokenOnSameLine(token, currentToken)) {
return true;
}
return false;
} | [
"function",
"codeAroundComment",
"(",
"token",
")",
"{",
"let",
"currentToken",
"=",
"token",
";",
"do",
"{",
"currentToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"currentToken",
",",
"{",
"includeComments",
":",
"true",
"}",
")",
";",
"}",
"while"... | Returns whether or not comments are on lines starting with or ending with code
@param {token} token The comment token to check.
@returns {boolean} True if the comment is not alone. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"on",
"lines",
"starting",
"with",
"or",
"ending",
"with",
"code"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L152-L173 | train | Check if a comment is on a line | [
30522,
3853,
3642,
24490,
9006,
3672,
1006,
19204,
1007,
1063,
2292,
2783,
18715,
2368,
1027,
19204,
1025,
2079,
1063,
2783,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
2783,
18715,
2368,
1010,
1063,
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... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | documentLeave | function documentLeave ( event, data ) {
if ( event.type === "mouseout" && event.target.nodeName === "HTML" && event.relatedTarget === null ){
eventEnd (event, data);
}
} | javascript | function documentLeave ( event, data ) {
if ( event.type === "mouseout" && event.target.nodeName === "HTML" && event.relatedTarget === null ){
eventEnd (event, data);
}
} | [
"function",
"documentLeave",
"(",
"event",
",",
"data",
")",
"{",
"if",
"(",
"event",
".",
"type",
"===",
"\"mouseout\"",
"&&",
"event",
".",
"target",
".",
"nodeName",
"===",
"\"HTML\"",
"&&",
"event",
".",
"relatedTarget",
"===",
"null",
")",
"{",
"eve... | Fire 'end' when a mouse or pen leaves the document. | [
"Fire",
"end",
"when",
"a",
"mouse",
"or",
"pen",
"leaves",
"the",
"document",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1477-L1481 | train | handle mouseout event | [
30522,
3853,
6254,
19738,
3726,
1006,
2724,
1010,
30524,
2828,
1027,
1027,
1027,
1000,
8000,
5833,
1000,
1004,
1004,
2724,
1012,
4539,
1012,
13045,
18442,
1027,
1027,
1027,
1000,
16129,
1000,
1004,
1004,
2724,
1012,
3141,
7559,
18150,
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... |
keplergl/kepler.gl | examples/demo-app/src/utils/cloud-providers/dropbox.js | shareFile | function shareFile(metadata) {
return dropbox.sharingCreateSharedLinkWithSettings({
path: metadata.path_display || metadata.path_lower
}).then(
// Update URL to avoid CORS issue
// Unfortunately this is not the ideal scenario but it will make sure people
// can share dropbox urls with users without the dropbox account (publish on twitter, facebook)
result => ({
...result,
folder_link: KEPLER_DROPBOX_FOLDER_LINK,
url: overrideUrl(result.url)
})
);
} | javascript | function shareFile(metadata) {
return dropbox.sharingCreateSharedLinkWithSettings({
path: metadata.path_display || metadata.path_lower
}).then(
// Update URL to avoid CORS issue
// Unfortunately this is not the ideal scenario but it will make sure people
// can share dropbox urls with users without the dropbox account (publish on twitter, facebook)
result => ({
...result,
folder_link: KEPLER_DROPBOX_FOLDER_LINK,
url: overrideUrl(result.url)
})
);
} | [
"function",
"shareFile",
"(",
"metadata",
")",
"{",
"return",
"dropbox",
".",
"sharingCreateSharedLinkWithSettings",
"(",
"{",
"path",
":",
"metadata",
".",
"path_display",
"||",
"metadata",
".",
"path_lower",
"}",
")",
".",
"then",
"(",
"// Update URL to avoid CO... | It will set access to file to public
@param {Object} metadata metadata response from uploading the file
@returns {Promise<DropboxTypes.sharing.FileLinkMetadataReference | DropboxTypes.sharing.FolderLinkMetadataReference | DropboxTypes.sharing.SharedLinkMetadataReference>} | [
"It",
"will",
"set",
"access",
"to",
"file",
"to",
"public"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/utils/cloud-providers/dropbox.js#L92-L105 | train | share file with the dropbox account | [
30522,
3853,
3745,
8873,
2571,
1006,
27425,
1007,
1063,
2709,
4530,
8758,
1012,
6631,
16748,
8520,
8167,
2098,
13767,
24415,
21678,
8613,
1006,
1063,
4130,
1024,
27425,
1012,
4130,
1035,
4653,
1064,
1064,
27425,
1012,
4130,
1035,
2896,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/layout/PositionContainer.js | function(oThis, sProp, oValue, bNotifyLayout) {
var bSuppressRerendering = !!oThis.getDomRef();
oThis.setProperty(sProp, oValue, bSuppressRerendering);
if (bSuppressRerendering && bNotifyLayout) {
notifyLayoutOnChange(oThis, "CTRL_POS");
}
return bSuppressRerendering;
} | javascript | function(oThis, sProp, oValue, bNotifyLayout) {
var bSuppressRerendering = !!oThis.getDomRef();
oThis.setProperty(sProp, oValue, bSuppressRerendering);
if (bSuppressRerendering && bNotifyLayout) {
notifyLayoutOnChange(oThis, "CTRL_POS");
}
return bSuppressRerendering;
} | [
"function",
"(",
"oThis",
",",
"sProp",
",",
"oValue",
",",
"bNotifyLayout",
")",
"{",
"var",
"bSuppressRerendering",
"=",
"!",
"!",
"oThis",
".",
"getDomRef",
"(",
")",
";",
"oThis",
".",
"setProperty",
"(",
"sProp",
",",
"oValue",
",",
"bSuppressRerender... | **** Private Helper Functions ****
Sets the value of the given property and notifies the layout
if necessary and desired.
@private | [
"****",
"Private",
"Helper",
"Functions",
"****",
"Sets",
"the",
"value",
"of",
"the",
"given",
"property",
"and",
"notifies",
"the",
"layout",
"if",
"necessary",
"and",
"desired",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/layout/PositionContainer.js#L334-L341 | train | Sets the value of the given property on the control. | [
30522,
3853,
1006,
27178,
24158,
1010,
11867,
18981,
1010,
9242,
5657,
1010,
24869,
4140,
8757,
8485,
5833,
1007,
1063,
13075,
18667,
6279,
20110,
14544,
10497,
7999,
1027,
999,
999,
27178,
24158,
1012,
2131,
9527,
2890,
2546,
1006,
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... | |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | getMarkLength | function getMarkLength(markType, nodes) {
let length = 0;
while (nodes[length] && nodes[length].marks.includes(markType)) {
++length;
}
return { markType, length };
} | javascript | function getMarkLength(markType, nodes) {
let length = 0;
while (nodes[length] && nodes[length].marks.includes(markType)) {
++length;
}
return { markType, length };
} | [
"function",
"getMarkLength",
"(",
"markType",
",",
"nodes",
")",
"{",
"let",
"length",
"=",
"0",
";",
"while",
"(",
"nodes",
"[",
"length",
"]",
"&&",
"nodes",
"[",
"length",
"]",
".",
"marks",
".",
"includes",
"(",
"markType",
")",
")",
"{",
"++",
... | Get the number of consecutive Slate nodes containing a given mark beginning
from the first received node. | [
"Get",
"the",
"number",
"of",
"consecutive",
"Slate",
"nodes",
"containing",
"a",
"given",
"mark",
"beginning",
"from",
"the",
"first",
"received",
"node",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L373-L379 | train | Get the length of a node | [
30522,
3853,
2131,
10665,
7770,
13512,
2232,
1006,
2928,
13874,
1010,
14164,
1007,
1063,
2292,
3091,
1027,
1014,
1025,
2096,
1006,
14164,
1031,
3091,
1033,
1004,
1004,
14164,
1031,
3091,
1033,
1012,
6017,
1012,
2950,
1006,
2928,
13874,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/node/npm-installer.js | performNpmInstallIfRequired | function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
} | javascript | function performNpmInstallIfRequired(npmOptions, validationResult, callback) {
function finish() {
callback(null, validationResult);
}
var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
var packageJson;
try {
packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
} catch (e) {
packageJson = null;
}
if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
return finish();
}
_performNpmInstall(installDirectory, npmOptions, function (err) {
if (err) {
validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
}
finish();
});
} | [
"function",
"performNpmInstallIfRequired",
"(",
"npmOptions",
",",
"validationResult",
",",
"callback",
")",
"{",
"function",
"finish",
"(",
")",
"{",
"callback",
"(",
"null",
",",
"validationResult",
")",
";",
"}",
"var",
"installDirectory",
"=",
"path",
".",
... | Checks package.json of the extracted extension for npm dependencies
and runs npm install when required.
@param {Object} validationResult return value of the validation procedure
@param {Function} callback function to be called after the end of validation procedure | [
"Checks",
"package",
".",
"json",
"of",
"the",
"extracted",
"extension",
"for",
"npm",
"dependencies",
"and",
"runs",
"npm",
"install",
"when",
"required",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/npm-installer.js#L93-L118 | train | This function will check if the npm installation is required | [
30522,
3853,
4685,
16275,
21266,
9080,
3669,
19699,
2063,
15549,
5596,
1006,
27937,
5302,
16790,
2015,
1010,
27354,
6072,
11314,
1010,
2655,
5963,
1007,
1063,
3853,
3926,
1006,
1007,
1063,
2655,
5963,
1006,
19701,
1010,
27354,
6072,
11314,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(root, path)
{
var parent = root;
if (path != null)
{
var tokens = path.split(mxCellPath.PATH_SEPARATOR);
for (var i=0; i<tokens.length; i++)
{
parent = parent.getChildAt(parseInt(tokens[i]));
}
}
return parent;
} | javascript | function(root, path)
{
var parent = root;
if (path != null)
{
var tokens = path.split(mxCellPath.PATH_SEPARATOR);
for (var i=0; i<tokens.length; i++)
{
parent = parent.getChildAt(parseInt(tokens[i]));
}
}
return parent;
} | [
"function",
"(",
"root",
",",
"path",
")",
"{",
"var",
"parent",
"=",
"root",
";",
"if",
"(",
"path",
"!=",
"null",
")",
"{",
"var",
"tokens",
"=",
"path",
".",
"split",
"(",
"mxCellPath",
".",
"PATH_SEPARATOR",
")",
";",
"for",
"(",
"var",
"i",
... | Function: resolve
Returns the cell for the specified cell path using the given root as the
root of the path.
Parameters:
root - Root cell of the path to be resolved.
path - String that defines the path. | [
"Function",
":",
"resolve"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L43304-L43319 | train | Returns the parent of the given path | [
30522,
3853,
1006,
7117,
1010,
4130,
1007,
1063,
13075,
6687,
1027,
7117,
1025,
2065,
1006,
4130,
999,
1027,
19701,
1007,
1063,
13075,
19204,
2015,
1027,
4130,
1012,
3975,
1006,
25630,
29109,
14277,
8988,
1012,
4130,
1035,
19802,
25879,
295... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/wwCodeBlockManager.js | sanitizeHtmlCode | function sanitizeHtmlCode(code) {
return code ? code.replace(/[<>&]/g, tag => tagEntities[tag] || tag) : '';
} | javascript | function sanitizeHtmlCode(code) {
return code ? code.replace(/[<>&]/g, tag => tagEntities[tag] || tag) : '';
} | [
"function",
"sanitizeHtmlCode",
"(",
"code",
")",
"{",
"return",
"code",
"?",
"code",
".",
"replace",
"(",
"/",
"[<>&]",
"/",
"g",
",",
"tag",
"=>",
"tagEntities",
"[",
"tag",
"]",
"||",
"tag",
")",
":",
"''",
";",
"}"
] | Sanitize HTML code
@param {string} code code string
@returns {string}
@ignore | [
"Sanitize",
"HTML",
"code"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wwCodeBlockManager.js#L388-L390 | train | Sanitize HTML code | [
30522,
3853,
2624,
25090,
4371,
11039,
19968,
16044,
1006,
3642,
1007,
1063,
2709,
3642,
1029,
3642,
1012,
5672,
1006,
1013,
1031,
1026,
1028,
1004,
1033,
1013,
1043,
1010,
6415,
1027,
1028,
6415,
4765,
6447,
1031,
6415,
1033,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2Requestor.js | addSelects | function addSelects(vSelects, sExpandPath) {
if (!Array.isArray(vSelects)) {
vSelects = vSelects.split(",");
}
vSelects.forEach(function (sSelect) {
var iIndex = sSelect.indexOf("/");
if (iIndex >= 0 && sSelect.indexOf(".") < 0) {
// only strip if there is no type cast and no bound action (avoid "correcting"
// unsupported selects in V2)
sSelect = sSelect.slice(0, iIndex);
}
mSelects[_Helper.buildPath(sExpandPath, sSelect)] = true;
});
} | javascript | function addSelects(vSelects, sExpandPath) {
if (!Array.isArray(vSelects)) {
vSelects = vSelects.split(",");
}
vSelects.forEach(function (sSelect) {
var iIndex = sSelect.indexOf("/");
if (iIndex >= 0 && sSelect.indexOf(".") < 0) {
// only strip if there is no type cast and no bound action (avoid "correcting"
// unsupported selects in V2)
sSelect = sSelect.slice(0, iIndex);
}
mSelects[_Helper.buildPath(sExpandPath, sSelect)] = true;
});
} | [
"function",
"addSelects",
"(",
"vSelects",
",",
"sExpandPath",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"vSelects",
")",
")",
"{",
"vSelects",
"=",
"vSelects",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"vSelects",
".",
"forEach",
"(",
... | Strips all selects to their first segment and adds them to mSelects.
@param {string|string[]} vSelects The selects for the given expand path as
comma-separated list or array
@param {string} [sExpandPath] The expand path | [
"Strips",
"all",
"selects",
"to",
"their",
"first",
"segment",
"and",
"adds",
"them",
"to",
"mSelects",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2Requestor.js#L643-L657 | train | Add a selection to the select map | [
30522,
3853,
9909,
12260,
16649,
1006,
5443,
12260,
16649,
1010,
3348,
9739,
18927,
8988,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
5443,
12260,
16649,
1007,
1007,
1063,
5443,
12260,
16649,
1027,
5443,
12260,
16649,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/config/config-file.js | writeJSONConfigFile | function writeJSONConfigFile(config, filePath) {
debug(`Writing JSON config file: ${filePath}`);
const content = stringify(config, { cmp: sortByKey, space: 4 });
fs.writeFileSync(filePath, content, "utf8");
} | javascript | function writeJSONConfigFile(config, filePath) {
debug(`Writing JSON config file: ${filePath}`);
const content = stringify(config, { cmp: sortByKey, space: 4 });
fs.writeFileSync(filePath, content, "utf8");
} | [
"function",
"writeJSONConfigFile",
"(",
"config",
",",
"filePath",
")",
"{",
"debug",
"(",
"`",
"${",
"filePath",
"}",
"`",
")",
";",
"const",
"content",
"=",
"stringify",
"(",
"config",
",",
"{",
"cmp",
":",
"sortByKey",
",",
"space",
":",
"4",
"}",
... | Writes a configuration file in JSON format.
@param {Object} config The configuration object to write.
@param {string} filePath The filename to write to.
@returns {void}
@private | [
"Writes",
"a",
"configuration",
"file",
"in",
"JSON",
"format",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-file.js#L251-L257 | train | Write a JSON config file | [
30522,
3853,
4339,
22578,
2239,
8663,
8873,
25708,
9463,
1006,
9530,
8873,
2290,
1010,
5371,
15069,
1007,
1063,
2139,
8569,
2290,
1006,
1036,
3015,
1046,
3385,
9530,
8873,
2290,
5371,
1024,
1002,
1063,
5371,
15069,
1065,
1036,
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.core/src/sap/ui/core/Configuration.js | function(sFormatLocale) {
var oFormatLocale = convertToLocaleOrNull(sFormatLocale),
mChanges;
check(sFormatLocale == null || typeof sFormatLocale === "string" && oFormatLocale, "sFormatLocale must be a BCP47 language tag or Java Locale id or null");
if ( toLanguageTag(oFormatLocale) !== toLanguageTag(this.formatLocale) ) {
this.formatLocale = oFormatLocale;
mChanges = this._collect();
mChanges.formatLocale = toLanguageTag(oFormatLocale);
this._endCollect();
}
return this;
} | javascript | function(sFormatLocale) {
var oFormatLocale = convertToLocaleOrNull(sFormatLocale),
mChanges;
check(sFormatLocale == null || typeof sFormatLocale === "string" && oFormatLocale, "sFormatLocale must be a BCP47 language tag or Java Locale id or null");
if ( toLanguageTag(oFormatLocale) !== toLanguageTag(this.formatLocale) ) {
this.formatLocale = oFormatLocale;
mChanges = this._collect();
mChanges.formatLocale = toLanguageTag(oFormatLocale);
this._endCollect();
}
return this;
} | [
"function",
"(",
"sFormatLocale",
")",
"{",
"var",
"oFormatLocale",
"=",
"convertToLocaleOrNull",
"(",
"sFormatLocale",
")",
",",
"mChanges",
";",
"check",
"(",
"sFormatLocale",
"==",
"null",
"||",
"typeof",
"sFormatLocale",
"===",
"\"string\"",
"&&",
"oFormatLoca... | Sets a new format locale to be used from now on for retrieving locale
specific formatters. Modifying this setting does not have an impact on
the retrieval of translated texts!
Can either be set to a concrete value (a BCP47 or Java locale compliant
language tag) or to <code>null</code>. When set to <code>null</code> (default
value) then locale specific formatters are retrieved for the current language.
After changing the format locale, the framework tries to update localization
specific parts of the UI. See the documentation of {@link #setLanguage} for
details and restrictions.
<b>Note</b>: When a format locale is set, it has higher priority than a number,
date or time format defined with a call to <code>setLegacyNumberFormat</code>,
<code>setLegacyDateFormat</code> or <code>setLegacyTimeFormat</code>.
<b>Note</b>: See documentation of {@link #setLanguage} for restrictions.
@param {string|null} sFormatLocale the new format locale as a BCP47 compliant language tag;
case doesn't matter and underscores can be used instead of dashes to separate
components (compatibility with Java Locale IDs)
@return {sap.ui.core.Configuration} <code>this</code> to allow method chaining
@public
@throws {Error} When <code>sFormatLocale</code> is given, but is not a valid BCP47 language
tag or Java locale identifier | [
"Sets",
"a",
"new",
"format",
"locale",
"to",
"be",
"used",
"from",
"now",
"on",
"for",
"retrieving",
"locale",
"specific",
"formatters",
".",
"Modifying",
"this",
"setting",
"does",
"not",
"have",
"an",
"impact",
"on",
"the",
"retrieval",
"of",
"translated"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Configuration.js#L921-L934 | train | Sets the format locale of the current locale. | [
30522,
3853,
1006,
16420,
2953,
18900,
4135,
9289,
2063,
1007,
1063,
13075,
1997,
2953,
18900,
4135,
9289,
2063,
1027,
10463,
3406,
4135,
30524,
11338,
18003,
2229,
1025,
4638,
1006,
16420,
2953,
18900,
4135,
9289,
2063,
1027,
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... | |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | merge | function merge(toAdd) {
var _p = this._private;
var cy = _p.cy;
if (!toAdd) {
return this;
}
if (toAdd && string(toAdd)) {
var selector = toAdd;
toAdd = cy.mutableElements().filter(selector);
}
var map = _p.map;
for (var i = 0; i < toAdd.length; i++) {
var toAddEle = toAdd[i];
var id = toAddEle._private.data.id;
var add = !map.has(id);
if (add) {
var index = this.length++;
this[index] = toAddEle;
map.set(id, {
ele: toAddEle,
index: index
});
} else {
// replace
var _index = map.get(id).index;
this[_index] = toAddEle;
map.set(id, {
ele: toAddEle,
index: _index
});
}
}
return this; // chaining
} | javascript | function merge(toAdd) {
var _p = this._private;
var cy = _p.cy;
if (!toAdd) {
return this;
}
if (toAdd && string(toAdd)) {
var selector = toAdd;
toAdd = cy.mutableElements().filter(selector);
}
var map = _p.map;
for (var i = 0; i < toAdd.length; i++) {
var toAddEle = toAdd[i];
var id = toAddEle._private.data.id;
var add = !map.has(id);
if (add) {
var index = this.length++;
this[index] = toAddEle;
map.set(id, {
ele: toAddEle,
index: index
});
} else {
// replace
var _index = map.get(id).index;
this[_index] = toAddEle;
map.set(id, {
ele: toAddEle,
index: _index
});
}
}
return this; // chaining
} | [
"function",
"merge",
"(",
"toAdd",
")",
"{",
"var",
"_p",
"=",
"this",
".",
"_private",
";",
"var",
"cy",
"=",
"_p",
".",
"cy",
";",
"if",
"(",
"!",
"toAdd",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"toAdd",
"&&",
"string",
"(",
"toAdd"... | in place merge on calling collection | [
"in",
"place",
"merge",
"on",
"calling",
"collection"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L10233-L10272 | train | Merge the elements in this array into another array | [
30522,
3853,
13590,
1006,
21344,
2094,
1007,
1063,
13075,
1035,
1052,
1027,
2023,
1012,
1035,
2797,
1025,
13075,
22330,
1027,
1035,
1052,
1012,
22330,
1025,
2065,
1006,
999,
21344,
2094,
1007,
1063,
2709,
2023,
1025,
1065,
2065,
1006,
21344... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fengyuanchen/cropper | dist/cropper.common.js | arrayBufferToDataURL | function arrayBufferToDataURL(arrayBuffer, mimeType) {
var uint8 = new Uint8Array(arrayBuffer);
var data = '';
// TypedArray.prototype.forEach is not supported in some browsers.
forEach(uint8, function (value) {
data += fromCharCode(value);
});
return 'data:' + mimeType + ';base64,' + btoa(data);
} | javascript | function arrayBufferToDataURL(arrayBuffer, mimeType) {
var uint8 = new Uint8Array(arrayBuffer);
var data = '';
// TypedArray.prototype.forEach is not supported in some browsers.
forEach(uint8, function (value) {
data += fromCharCode(value);
});
return 'data:' + mimeType + ';base64,' + btoa(data);
} | [
"function",
"arrayBufferToDataURL",
"(",
"arrayBuffer",
",",
"mimeType",
")",
"{",
"var",
"uint8",
"=",
"new",
"Uint8Array",
"(",
"arrayBuffer",
")",
";",
"var",
"data",
"=",
"''",
";",
"// TypedArray.prototype.forEach is not supported in some browsers.",
"forEach",
"... | Transform array buffer to Data URL.
@param {ArrayBuffer} arrayBuffer - The array buffer to transform.
@param {string} mimeType - The mime type of the Data URL.
@returns {string} The result Data URL. | [
"Transform",
"array",
"buffer",
"to",
"Data",
"URL",
"."
] | 6677332a6a375b647f58808dfc24ea09f5804041 | https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L1034-L1044 | train | Converts an arraybuffer to a data URL | [
30522,
3853,
9140,
8569,
12494,
3406,
2850,
2696,
3126,
2140,
1006,
9140,
8569,
12494,
1010,
2771,
11368,
18863,
1007,
1063,
13075,
21318,
3372,
2620,
1027,
2047,
21318,
3372,
2620,
2906,
30524,
2025,
3569,
1999,
2070,
16602,
2015,
1012,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/protractor | lib/clientsidescripts.js | wrapWithHelpers | function wrapWithHelpers(fun) {
var helpers = Array.prototype.slice.call(arguments, 1);
if (!helpers.length) {
return fun;
}
var FunClass = Function; // Get the linter to allow this eval
return new FunClass(
helpers.join(';') + String.fromCharCode(59) +
' return (' + fun.toString() + ').apply(this, arguments);');
} | javascript | function wrapWithHelpers(fun) {
var helpers = Array.prototype.slice.call(arguments, 1);
if (!helpers.length) {
return fun;
}
var FunClass = Function; // Get the linter to allow this eval
return new FunClass(
helpers.join(';') + String.fromCharCode(59) +
' return (' + fun.toString() + ').apply(this, arguments);');
} | [
"function",
"wrapWithHelpers",
"(",
"fun",
")",
"{",
"var",
"helpers",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"if",
"(",
"!",
"helpers",
".",
"length",
")",
"{",
"return",
"fun",
";",
"}",
"... | ///////////////////////////////////////////////////// // //// // HELPERS //// // //// ///////////////////////////////////////////////////// /* Wraps a function up into a string with its helper functions so that it can
call those helper functions client side
@param {function} fun The function to wrap up with its helpers
@param {...function} The helper functions. Each function must be named
@return {string} The string which, when executed, will invoke fun in such a
way that it has access to its helper functions | [
"/////////////////////////////////////////////////////",
"//",
"////",
"//",
"HELPERS",
"////",
"//",
"////",
"/////////////////////////////////////////////////////",
"/",
"*",
"Wraps",
"a",
"function",
"up",
"into",
"a",
"string",
"with",
"its",
"helper",
"functions",
"s... | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/lib/clientsidescripts.js#L35-L44 | train | Wrap a function with the given helpers | [
30522,
3853,
10236,
24415,
16001,
7347,
1006,
4569,
1007,
1063,
13075,
2393,
2545,
1027,
9140,
1012,
8773,
1012,
14704,
1012,
2655,
1006,
9918,
1010,
1015,
1007,
1025,
2065,
1006,
999,
2393,
2545,
1012,
3091,
1007,
1063,
2709,
4569,
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... |
NetEase/pomelo | lib/components/connector.js | function(app, opts) {
opts = opts || {};
this.app = app;
this.connector = getConnector(app, opts);
this.encode = opts.encode;
this.decode = opts.decode;
this.useCrypto = opts.useCrypto;
this.useHostFilter = opts.useHostFilter;
this.useAsyncCoder = opts.useAsyncCoder;
this.blacklistFun = opts.blacklistFun;
this.keys = {};
this.blacklist = [];
if (opts.useDict) {
app.load(pomelo.dictionary, app.get('dictionaryConfig'));
}
if (opts.useProtobuf) {
app.load(pomelo.protobuf, app.get('protobufConfig'));
}
// component dependencies
this.server = null;
this.session = null;
this.connection = null;
} | javascript | function(app, opts) {
opts = opts || {};
this.app = app;
this.connector = getConnector(app, opts);
this.encode = opts.encode;
this.decode = opts.decode;
this.useCrypto = opts.useCrypto;
this.useHostFilter = opts.useHostFilter;
this.useAsyncCoder = opts.useAsyncCoder;
this.blacklistFun = opts.blacklistFun;
this.keys = {};
this.blacklist = [];
if (opts.useDict) {
app.load(pomelo.dictionary, app.get('dictionaryConfig'));
}
if (opts.useProtobuf) {
app.load(pomelo.protobuf, app.get('protobufConfig'));
}
// component dependencies
this.server = null;
this.session = null;
this.connection = null;
} | [
"function",
"(",
"app",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"app",
"=",
"app",
";",
"this",
".",
"connector",
"=",
"getConnector",
"(",
"app",
",",
"opts",
")",
";",
"this",
".",
"encode",
"=",
"opts",
... | Connector component. Receive client requests and attach session with socket.
@param {Object} app current application context
@param {Object} opts attach parameters
opts.connector {Object} provides low level network and protocol details implementation between server and clients. | [
"Connector",
"component",
".",
"Receive",
"client",
"requests",
"and",
"attach",
"session",
"with",
"socket",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/components/connector.js#L19-L44 | train | Initialize a new Knockout object. | [
30522,
3853,
1006,
10439,
1010,
23569,
2015,
1007,
1063,
23569,
2015,
1027,
23569,
2015,
1064,
1064,
1063,
1065,
1025,
2023,
1012,
10439,
1027,
10439,
1025,
2023,
1012,
19400,
1027,
2131,
8663,
2638,
16761,
1006,
10439,
1010,
23569,
2015,
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... | |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | generate | function generate(scale, min, max, capacity) {
var adapter = scale._adapter;
var options = scale.options;
var timeOpts = options.time;
var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
var major = determineMajorUnit(minor);
var stepSize = valueOrDefault$c(timeOpts.stepSize, timeOpts.unitStepSize);
var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
var majorTicksEnabled = options.ticks.major.enabled;
var interval = INTERVALS[minor];
var first = min;
var last = max;
var ticks = [];
var time;
if (!stepSize) {
stepSize = determineStepSize(min, max, minor, capacity);
}
// For 'week' unit, handle the first day of week option
if (weekday) {
first = +adapter.startOf(first, 'isoWeek', weekday);
last = +adapter.startOf(last, 'isoWeek', weekday);
}
// Align first/last ticks on unit
first = +adapter.startOf(first, weekday ? 'day' : minor);
last = +adapter.startOf(last, weekday ? 'day' : minor);
// Make sure that the last tick include max
if (last < max) {
last = +adapter.add(last, 1, minor);
}
time = first;
if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
// Align the first tick on the previous `minor` unit aligned on the `major` unit:
// we first aligned time on the previous `major` unit then add the number of full
// stepSize there is between first and the previous major time.
time = +adapter.startOf(time, major);
time = +adapter.add(time, ~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
}
for (; time < last; time = +adapter.add(time, stepSize, minor)) {
ticks.push(+time);
}
ticks.push(+time);
return ticks;
} | javascript | function generate(scale, min, max, capacity) {
var adapter = scale._adapter;
var options = scale.options;
var timeOpts = options.time;
var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, capacity);
var major = determineMajorUnit(minor);
var stepSize = valueOrDefault$c(timeOpts.stepSize, timeOpts.unitStepSize);
var weekday = minor === 'week' ? timeOpts.isoWeekday : false;
var majorTicksEnabled = options.ticks.major.enabled;
var interval = INTERVALS[minor];
var first = min;
var last = max;
var ticks = [];
var time;
if (!stepSize) {
stepSize = determineStepSize(min, max, minor, capacity);
}
// For 'week' unit, handle the first day of week option
if (weekday) {
first = +adapter.startOf(first, 'isoWeek', weekday);
last = +adapter.startOf(last, 'isoWeek', weekday);
}
// Align first/last ticks on unit
first = +adapter.startOf(first, weekday ? 'day' : minor);
last = +adapter.startOf(last, weekday ? 'day' : minor);
// Make sure that the last tick include max
if (last < max) {
last = +adapter.add(last, 1, minor);
}
time = first;
if (majorTicksEnabled && major && !weekday && !timeOpts.round) {
// Align the first tick on the previous `minor` unit aligned on the `major` unit:
// we first aligned time on the previous `major` unit then add the number of full
// stepSize there is between first and the previous major time.
time = +adapter.startOf(time, major);
time = +adapter.add(time, ~~((first - time) / (interval.size * stepSize)) * stepSize, minor);
}
for (; time < last; time = +adapter.add(time, stepSize, minor)) {
ticks.push(+time);
}
ticks.push(+time);
return ticks;
} | [
"function",
"generate",
"(",
"scale",
",",
"min",
",",
"max",
",",
"capacity",
")",
"{",
"var",
"adapter",
"=",
"scale",
".",
"_adapter",
";",
"var",
"options",
"=",
"scale",
".",
"options",
";",
"var",
"timeOpts",
"=",
"options",
".",
"time",
";",
"... | Generates a maximum of `capacity` timestamps between min and max, rounded to the
`minor` unit, aligned on the `major` unit and using the given scale time `options`.
Important: this method can return ticks outside the min and max range, it's the
responsibility of the calling code to clamp values if needed. | [
"Generates",
"a",
"maximum",
"of",
"capacity",
"timestamps",
"between",
"min",
"and",
"max",
"rounded",
"to",
"the",
"minor",
"unit",
"aligned",
"on",
"the",
"major",
"unit",
"and",
"using",
"the",
"given",
"scale",
"time",
"options",
".",
"Important",
":",
... | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L12850-L12901 | train | Generate a time series | [
30522,
3853,
9699,
1006,
4094,
1010,
8117,
1010,
4098,
1010,
3977,
1007,
1063,
13075,
15581,
2121,
1027,
4094,
1012,
1035,
15581,
2121,
1025,
13075,
7047,
1027,
4094,
1012,
7047,
1025,
13075,
2051,
7361,
3215,
1027,
7047,
1012,
2051,
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... |
GitbookIO/gitbook | lib/api/encodeGlobal.js | function(fileName, content) {
return Promise()
.then(function() {
var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
return fs.ensureFile(filePath)
.then(function() {
return fs.writeFile(filePath, content);
});
});
} | javascript | function(fileName, content) {
return Promise()
.then(function() {
var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
return fs.ensureFile(filePath)
.then(function() {
return fs.writeFile(filePath, content);
});
});
} | [
"function",
"(",
"fileName",
",",
"content",
")",
"{",
"return",
"Promise",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"var",
"filePath",
"=",
"PathUtils",
".",
"resolveInRoot",
"(",
"outputFolder",
",",
"fileName",
")",
";",
"return",
"fs",
... | Write a file to the output folder,
It creates the required folder
@param {String} fileName
@param {Buffer} content
@return {Promise} | [
"Write",
"a",
"file",
"to",
"the",
"output",
"folder",
"It",
"creates",
"the",
"required",
"folder"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeGlobal.js#L197-L207 | train | Writes a file to the output folder | [
30522,
3853,
1006,
5371,
18442,
1010,
4180,
1007,
1063,
2709,
4872,
1006,
1007,
1012,
2059,
1006,
3853,
1006,
1007,
1063,
13075,
5371,
15069,
1027,
4130,
21823,
4877,
1012,
10663,
2378,
3217,
4140,
1006,
6434,
10371,
2121,
1010,
5371,
18442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(iColIndex, oEvent) {
var oTable = this.getTable();
if (oTable && TableUtils.Column.isColumnMovable(oTable.getColumns()[iColIndex])) {
// Starting column drag & drop. We wait 200ms to make sure it is no click on the column to open the menu.
oTable._mTimeouts.delayedColumnReorderTimerId = setTimeout(function() {
ReorderHelper.initReordering(this, iColIndex, oEvent);
}.bind(oTable), 200);
}
} | javascript | function(iColIndex, oEvent) {
var oTable = this.getTable();
if (oTable && TableUtils.Column.isColumnMovable(oTable.getColumns()[iColIndex])) {
// Starting column drag & drop. We wait 200ms to make sure it is no click on the column to open the menu.
oTable._mTimeouts.delayedColumnReorderTimerId = setTimeout(function() {
ReorderHelper.initReordering(this, iColIndex, oEvent);
}.bind(oTable), 200);
}
} | [
"function",
"(",
"iColIndex",
",",
"oEvent",
")",
"{",
"var",
"oTable",
"=",
"this",
".",
"getTable",
"(",
")",
";",
"if",
"(",
"oTable",
"&&",
"TableUtils",
".",
"Column",
".",
"isColumnMovable",
"(",
"oTable",
".",
"getColumns",
"(",
")",
"[",
"iColI... | Initialize the basic event handling for column reordering and starts the reordering.
@param {int} iColIndex The index of the column to resize.
@param {jQuery.Event} oEvent The event object. | [
"Initialize",
"the",
"basic",
"event",
"handling",
"for",
"column",
"reordering",
"and",
"starts",
"the",
"reordering",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L1007-L1015 | train | Called when the column is moved | [
30522,
3853,
1006,
24582,
18861,
3207,
2595,
1010,
1051,
18697,
3372,
1007,
1063,
13075,
27178,
3085,
1027,
2023,
1012,
2131,
10880,
1006,
1007,
1025,
2065,
1006,
27178,
3085,
1004,
1004,
2795,
21823,
4877,
1012,
5930,
1012,
2003,
25778,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
fengyuanchen/cropper | dist/cropper.common.js | removeData | function removeData(element, name) {
if (isObject(element[name])) {
try {
delete element[name];
} catch (e) {
element[name] = undefined;
}
} else if (element.dataset) {
// #128 Safari not allows to delete dataset property
try {
delete element.dataset[name];
} catch (e) {
element.dataset[name] = undefined;
}
} else {
element.removeAttribute('data-' + hyphenate(name));
}
} | javascript | function removeData(element, name) {
if (isObject(element[name])) {
try {
delete element[name];
} catch (e) {
element[name] = undefined;
}
} else if (element.dataset) {
// #128 Safari not allows to delete dataset property
try {
delete element.dataset[name];
} catch (e) {
element.dataset[name] = undefined;
}
} else {
element.removeAttribute('data-' + hyphenate(name));
}
} | [
"function",
"removeData",
"(",
"element",
",",
"name",
")",
"{",
"if",
"(",
"isObject",
"(",
"element",
"[",
"name",
"]",
")",
")",
"{",
"try",
"{",
"delete",
"element",
"[",
"name",
"]",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"element",
"[",
"na... | Remove data from the given element.
@param {Element} element - The target element.
@param {string} name - The data key to remove. | [
"Remove",
"data",
"from",
"the",
"given",
"element",
"."
] | 6677332a6a375b647f58808dfc24ea09f5804041 | https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L506-L523 | train | Remove data from an element | [
30522,
3853,
3718,
6790,
1006,
5783,
1010,
2171,
1007,
1063,
2065,
1006,
11163,
2497,
20614,
1006,
5783,
1031,
2171,
1033,
1007,
1007,
1063,
3046,
1063,
3972,
12870,
5783,
1031,
2171,
1033,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
5783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/queue.js | function(fn) {
funcGuard(fn);
if (completeQueue !== noop) {
throw new Error('queue `then` already set');
}
if (!err) {
completeQueue = fn;
if (!remaining) {
complete = true;
completeQueue(tasks);
}
}
return q;
} | javascript | function(fn) {
funcGuard(fn);
if (completeQueue !== noop) {
throw new Error('queue `then` already set');
}
if (!err) {
completeQueue = fn;
if (!remaining) {
complete = true;
completeQueue(tasks);
}
}
return q;
} | [
"function",
"(",
"fn",
")",
"{",
"funcGuard",
"(",
"fn",
")",
";",
"if",
"(",
"completeQueue",
"!==",
"noop",
")",
"{",
"throw",
"new",
"Error",
"(",
"'queue `then` already set'",
")",
";",
"}",
"if",
"(",
"!",
"err",
")",
"{",
"completeQueue",
"=",
... | The callback to execute once all "deferred" functions have completed. Will only be invoked once.
@param {Function} f The callback, receives an array of the return/callbacked
values of each of the "deferred" functions | [
"The",
"callback",
"to",
"execute",
"once",
"all",
"deferred",
"functions",
"have",
"completed",
".",
"Will",
"only",
"be",
"invoked",
"once",
"."
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/queue.js#L100-L113 | train | The queue function is called when all tasks have been completed | [
30522,
3853,
1006,
1042,
2078,
1007,
1063,
4569,
2278,
18405,
1006,
1042,
2078,
1007,
1025,
2065,
1006,
3143,
4226,
5657,
999,
1027,
1027,
2053,
7361,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
24240,
1036,
2059,
1036,
2525,
2275,
1005,
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... | |
NetEase/pomelo | lib/util/countDownLatch.js | function(count, opts, cb) {
this.count = count;
this.cb = cb;
var self = this;
if (opts.timeout) {
this.timerId = setTimeout(function() {
self.cb(true);
}, opts.timeout);
}
} | javascript | function(count, opts, cb) {
this.count = count;
this.cb = cb;
var self = this;
if (opts.timeout) {
this.timerId = setTimeout(function() {
self.cb(true);
}, opts.timeout);
}
} | [
"function",
"(",
"count",
",",
"opts",
",",
"cb",
")",
"{",
"this",
".",
"count",
"=",
"count",
";",
"this",
".",
"cb",
"=",
"cb",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"opts",
".",
"timeout",
")",
"{",
"this",
".",
"timerId",
"=",
... | Count down to zero or timeout and invoke cb finally. | [
"Count",
"down",
"to",
"zero",
"or",
"timeout",
"and",
"invoke",
"cb",
"finally",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/util/countDownLatch.js#L6-L15 | train | A kludge algorithm for the algorithm | [
30522,
3853,
1006,
4175,
1010,
23569,
2015,
1010,
17324,
1007,
1063,
2023,
1012,
4175,
1027,
4175,
1025,
2023,
1012,
17324,
1027,
17324,
30524,
1025,
2065,
1006,
23569,
2015,
1012,
2051,
5833,
1007,
1063,
2023,
1012,
25309,
3593,
1027,
2275... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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() {
localStorage.removeItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY);
} | javascript | function() {
localStorage.removeItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY);
} | [
"function",
"(",
")",
"{",
"localStorage",
".",
"removeItem",
"(",
"constants",
".",
"LOCAL_STORAGE_TEMP_RULES_KEY",
")",
";",
"localStorage",
".",
"removeItem",
"(",
"constants",
".",
"LOCAL_STORAGE_SELECTED_RULES_KEY",
")",
";",
"localStorage",
".",
"removeItem",
... | Removes all data from LocalStorage persistence layer.
@private
@method
@name sap.ui.support.Storage.removeAllData | [
"Removes",
"all",
"data",
"from",
"LocalStorage",
"persistence",
"layer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js#L258-L266 | train | Removes the local storage items | [
30522,
3853,
1006,
1007,
1063,
10575,
4263,
4270,
1012,
6366,
4221,
2213,
1006,
5377,
2015,
1012,
2334,
1035,
5527,
1035,
8915,
8737,
1035,
3513,
1035,
3145,
1007,
1025,
10575,
4263,
4270,
1012,
6366,
4221,
2213,
1006,
5377,
2015,
1012,
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... | |
expressjs/express | examples/web-service/index.js | error | function error(status, msg) {
var err = new Error(msg);
err.status = status;
return err;
} | javascript | function error(status, msg) {
var err = new Error(msg);
err.status = status;
return err;
} | [
"function",
"error",
"(",
"status",
",",
"msg",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"msg",
")",
";",
"err",
".",
"status",
"=",
"status",
";",
"return",
"err",
";",
"}"
] | create an error with .status. we can then use the property in our custom error handler (Connect repects this prop as well) | [
"create",
"an",
"error",
"with",
".",
"status",
".",
"we",
"can",
"then",
"use",
"the",
"property",
"in",
"our",
"custom",
"error",
"handler",
"(",
"Connect",
"repects",
"this",
"prop",
"as",
"well",
")"
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/examples/web-service/index.js#L13-L17 | train | Error helper function | [
30522,
3853,
7561,
1006,
3570,
1010,
5796,
2290,
1007,
1063,
13075,
9413,
2099,
1027,
2047,
7561,
1006,
5796,
2290,
1007,
1025,
9413,
2099,
1012,
3570,
1027,
3570,
1025,
2709,
9413,
2099,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/webdriver/logging.js | consoleHandler | function consoleHandler(record) {
if (typeof console === 'undefined' || !console) {
return;
}
record = /** @type {!LogRecord} */(record);
var timestamp = new Date(record.getMillis());
var msg =
'[' + timestamp.getUTCFullYear() + '-' +
padNumber(timestamp.getUTCMonth() + 1, 2) + '-' +
padNumber(timestamp.getUTCDate(), 2) + 'T' +
padNumber(timestamp.getUTCHours(), 2) + ':' +
padNumber(timestamp.getUTCMinutes(), 2) + ':' +
padNumber(timestamp.getUTCSeconds(), 2) + 'Z]' +
'[' + record.getLevel().name + ']' +
'[' + record.getLoggerName() + '] ' +
record.getMessage();
var level = record.getLevel().value;
if (level >= Logger.Level.SEVERE.value) {
console.error(msg);
} else if (level >= Logger.Level.WARNING.value) {
console.warn(msg);
} else {
console.log(msg);
}
} | javascript | function consoleHandler(record) {
if (typeof console === 'undefined' || !console) {
return;
}
record = /** @type {!LogRecord} */(record);
var timestamp = new Date(record.getMillis());
var msg =
'[' + timestamp.getUTCFullYear() + '-' +
padNumber(timestamp.getUTCMonth() + 1, 2) + '-' +
padNumber(timestamp.getUTCDate(), 2) + 'T' +
padNumber(timestamp.getUTCHours(), 2) + ':' +
padNumber(timestamp.getUTCMinutes(), 2) + ':' +
padNumber(timestamp.getUTCSeconds(), 2) + 'Z]' +
'[' + record.getLevel().name + ']' +
'[' + record.getLoggerName() + '] ' +
record.getMessage();
var level = record.getLevel().value;
if (level >= Logger.Level.SEVERE.value) {
console.error(msg);
} else if (level >= Logger.Level.WARNING.value) {
console.warn(msg);
} else {
console.log(msg);
}
} | [
"function",
"consoleHandler",
"(",
"record",
")",
"{",
"if",
"(",
"typeof",
"console",
"===",
"'undefined'",
"||",
"!",
"console",
")",
"{",
"return",
";",
"}",
"record",
"=",
"/** @type {!LogRecord} */",
"(",
"record",
")",
";",
"var",
"timestamp",
"=",
"... | Logs all messages to the Console API. | [
"Logs",
"all",
"messages",
"to",
"the",
"Console",
"API",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/webdriver/logging.js#L113-L138 | train | consoleHandler - console handler | [
30522,
3853,
10122,
11774,
3917,
1006,
2501,
1007,
1063,
2065,
1006,
2828,
11253,
10122,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1064,
1064,
999,
10122,
1007,
1063,
2709,
1025,
1065,
2501,
1027,
1013,
1008,
1008,
1030,
2828,
1063,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/ViewCommandHandlers.js | init | function init() {
currFontFamily = prefs.get("fontFamily");
_addDynamicFontFamily(currFontFamily);
currFontSize = prefs.get("fontSize");
_addDynamicFontSize(currFontSize);
_updateUI();
} | javascript | function init() {
currFontFamily = prefs.get("fontFamily");
_addDynamicFontFamily(currFontFamily);
currFontSize = prefs.get("fontSize");
_addDynamicFontSize(currFontSize);
_updateUI();
} | [
"function",
"init",
"(",
")",
"{",
"currFontFamily",
"=",
"prefs",
".",
"get",
"(",
"\"fontFamily\"",
")",
";",
"_addDynamicFontFamily",
"(",
"currFontFamily",
")",
";",
"currFontSize",
"=",
"prefs",
".",
"get",
"(",
"\"fontSize\"",
")",
";",
"_addDynamicFontS... | Initializes the different settings that need to loaded | [
"Initializes",
"the",
"different",
"settings",
"that",
"need",
"to",
"loaded"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/ViewCommandHandlers.js#L393-L399 | train | Initialize the language | [
30522,
3853,
1999,
4183,
1006,
1007,
1063,
12731,
12171,
14876,
3372,
7011,
4328,
2135,
1027,
3653,
10343,
1012,
2131,
1006,
1000,
15489,
7011,
4328,
2135,
1000,
1007,
1025,
1035,
5587,
5149,
28987,
2278,
14876,
3372,
7011,
4328,
2135,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/main.js | _setLabel | function _setLabel($btn, text, style, tooltip) {
// Clear text/styles from previous status
$("span", $btn).remove();
$btn.removeClass(_allStatusStyles);
// Set text/styles for new status
if (text && text.length > 0) {
$("<span class=\"label\">")
.addClass(style)
.text(text)
.appendTo($btn);
} else {
$btn.addClass(style);
}
if (tooltip) {
$btn.attr("title", tooltip);
}
} | javascript | function _setLabel($btn, text, style, tooltip) {
// Clear text/styles from previous status
$("span", $btn).remove();
$btn.removeClass(_allStatusStyles);
// Set text/styles for new status
if (text && text.length > 0) {
$("<span class=\"label\">")
.addClass(style)
.text(text)
.appendTo($btn);
} else {
$btn.addClass(style);
}
if (tooltip) {
$btn.attr("title", tooltip);
}
} | [
"function",
"_setLabel",
"(",
"$btn",
",",
"text",
",",
"style",
",",
"tooltip",
")",
"{",
"// Clear text/styles from previous status",
"$",
"(",
"\"span\"",
",",
"$btn",
")",
".",
"remove",
"(",
")",
";",
"$btn",
".",
"removeClass",
"(",
"_allStatusStyles",
... | Change the appearance of a button. Omit text to remove any extra text; omit style to return to default styling;
omit tooltip to leave tooltip unchanged. | [
"Change",
"the",
"appearance",
"of",
"a",
"button",
".",
"Omit",
"text",
"to",
"remove",
"any",
"extra",
"text",
";",
"omit",
"style",
"to",
"return",
"to",
"default",
"styling",
";",
"omit",
"tooltip",
"to",
"leave",
"tooltip",
"unchanged",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L150-L168 | train | Set label for status | [
30522,
3853,
1035,
2275,
20470,
2884,
1006,
1002,
18411,
2078,
1010,
3793,
1010,
2806,
1010,
6994,
25101,
1007,
1063,
1013,
1013,
3154,
3793,
1013,
6782,
2013,
3025,
3570,
1002,
1006,
1000,
8487,
1000,
1010,
1002,
18411,
2078,
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... |
angular/material | src/core/services/theming/theming.js | updateThemeClass | function updateThemeClass(theme) {
if (!theme) return;
if (!registered(theme)) {
$log.warn('Attempted to use unregistered theme \'' + theme + '\'. ' +
'Register it with $mdThemingProvider.theme().');
}
var oldTheme = el.data('$mdThemeName');
if (oldTheme) el.removeClass('md-' + oldTheme +'-theme');
el.addClass('md-' + theme + '-theme');
el.data('$mdThemeName', theme);
if (ctrl) {
el.data('$mdThemeController', ctrl);
}
} | javascript | function updateThemeClass(theme) {
if (!theme) return;
if (!registered(theme)) {
$log.warn('Attempted to use unregistered theme \'' + theme + '\'. ' +
'Register it with $mdThemingProvider.theme().');
}
var oldTheme = el.data('$mdThemeName');
if (oldTheme) el.removeClass('md-' + oldTheme +'-theme');
el.addClass('md-' + theme + '-theme');
el.data('$mdThemeName', theme);
if (ctrl) {
el.data('$mdThemeController', ctrl);
}
} | [
"function",
"updateThemeClass",
"(",
"theme",
")",
"{",
"if",
"(",
"!",
"theme",
")",
"return",
";",
"if",
"(",
"!",
"registered",
"(",
"theme",
")",
")",
"{",
"$log",
".",
"warn",
"(",
"'Attempted to use unregistered theme \\''",
"+",
"theme",
"+",
"'\\'.... | Remove old theme class and apply a new one
NOTE: if not a valid theme name, then the current name is not changed | [
"Remove",
"old",
"theme",
"class",
"and",
"apply",
"a",
"new",
"one",
"NOTE",
":",
"if",
"not",
"a",
"valid",
"theme",
"name",
"then",
"the",
"current",
"name",
"is",
"not",
"changed"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L823-L837 | train | Update theme class | [
30522,
3853,
10651,
10760,
4168,
26266,
1006,
4323,
1007,
1063,
2065,
1006,
999,
4323,
1007,
2709,
1025,
2065,
1006,
999,
5068,
1006,
4323,
1007,
1007,
1063,
1002,
8833,
1012,
11582,
1006,
1005,
4692,
2000,
2224,
4895,
2890,
24063,
6850,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/semi-spacing.js | isLastTokenInCurrentLine | function isLastTokenInCurrentLine(token) {
const tokenAfter = sourceCode.getTokenAfter(token);
return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
} | javascript | function isLastTokenInCurrentLine(token) {
const tokenAfter = sourceCode.getTokenAfter(token);
return !(tokenAfter && astUtils.isTokenOnSameLine(token, tokenAfter));
} | [
"function",
"isLastTokenInCurrentLine",
"(",
"token",
")",
"{",
"const",
"tokenAfter",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"token",
")",
";",
"return",
"!",
"(",
"tokenAfter",
"&&",
"astUtils",
".",
"isTokenOnSameLine",
"(",
"token",
",",
"tokenAfter",... | Checks if the given token is the last token in its line.
@param {Token} token The token to check.
@returns {boolean} Whether or not the token is the last in its line. | [
"Checks",
"if",
"the",
"given",
"token",
"is",
"the",
"last",
"token",
"in",
"its",
"line",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-spacing.js#L84-L88 | train | Check if the given token is the last token in the current line | [
30522,
3853,
25340,
3367,
18715,
18595,
12273,
29264,
4179,
1006,
19204,
1007,
1063,
9530,
3367,
19204,
10354,
3334,
1027,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
2121,
1006,
19204,
1007,
1025,
2709,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/treemap/treemapLayout.js | statistic | function statistic(nodeModel, children, orderBy) {
// Calculate sum.
var sum = 0;
for (var i = 0, len = children.length; i < len; i++) {
sum += children[i].getValue();
}
// Statistic data extent for latter visual coding.
// Notice: data extent should be calculate based on raw children
// but not filtered view children, otherwise visual mapping will not
// be stable when zoom (where children is filtered by visibleMin).
var dimension = nodeModel.get('visualDimension');
var dataExtent;
// The same as area dimension.
if (!children || !children.length) {
dataExtent = [NaN, NaN];
}
else if (dimension === 'value' && orderBy) {
dataExtent = [
children[children.length - 1].getValue(),
children[0].getValue()
];
orderBy === 'asc' && dataExtent.reverse();
}
// Other dimension.
else {
var dataExtent = [Infinity, -Infinity];
each(children, function (child) {
var value = child.getValue(dimension);
value < dataExtent[0] && (dataExtent[0] = value);
value > dataExtent[1] && (dataExtent[1] = value);
});
}
return {sum: sum, dataExtent: dataExtent};
} | javascript | function statistic(nodeModel, children, orderBy) {
// Calculate sum.
var sum = 0;
for (var i = 0, len = children.length; i < len; i++) {
sum += children[i].getValue();
}
// Statistic data extent for latter visual coding.
// Notice: data extent should be calculate based on raw children
// but not filtered view children, otherwise visual mapping will not
// be stable when zoom (where children is filtered by visibleMin).
var dimension = nodeModel.get('visualDimension');
var dataExtent;
// The same as area dimension.
if (!children || !children.length) {
dataExtent = [NaN, NaN];
}
else if (dimension === 'value' && orderBy) {
dataExtent = [
children[children.length - 1].getValue(),
children[0].getValue()
];
orderBy === 'asc' && dataExtent.reverse();
}
// Other dimension.
else {
var dataExtent = [Infinity, -Infinity];
each(children, function (child) {
var value = child.getValue(dimension);
value < dataExtent[0] && (dataExtent[0] = value);
value > dataExtent[1] && (dataExtent[1] = value);
});
}
return {sum: sum, dataExtent: dataExtent};
} | [
"function",
"statistic",
"(",
"nodeModel",
",",
"children",
",",
"orderBy",
")",
"{",
"// Calculate sum.",
"var",
"sum",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"children",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"+... | Statistic | [
"Statistic"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L362-L399 | train | Returns the statistic data extent for the given node model. | [
30522,
3853,
28093,
6553,
1006,
13045,
5302,
9247,
1010,
2336,
1010,
2344,
3762,
1007,
1063,
1013,
1013,
18422,
7680,
1012,
13075,
7680,
1027,
1014,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
18798,
1027,
2336,
1012,
3091,
1025,
1045,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
juliangarnier/anime | lib/anime.js | getFunctionValue | function getFunctionValue(val, animatable) {
if (!is.fnc(val)) { return val; }
return val(animatable.target, animatable.id, animatable.total);
} | javascript | function getFunctionValue(val, animatable) {
if (!is.fnc(val)) { return val; }
return val(animatable.target, animatable.id, animatable.total);
} | [
"function",
"getFunctionValue",
"(",
"val",
",",
"animatable",
")",
"{",
"if",
"(",
"!",
"is",
".",
"fnc",
"(",
"val",
")",
")",
"{",
"return",
"val",
";",
"}",
"return",
"val",
"(",
"animatable",
".",
"target",
",",
"animatable",
".",
"id",
",",
"... | Values | [
"Values"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/lib/anime.js#L435-L438 | train | Get function value | [
30522,
3853,
2131,
11263,
27989,
10175,
5657,
1006,
11748,
1010,
2019,
9581,
10880,
1007,
1063,
2065,
1006,
999,
2003,
1012,
1042,
12273,
1006,
11748,
1007,
1007,
1063,
2709,
11748,
1025,
1065,
2709,
11748,
1006,
2019,
9581,
10880,
1012,
45... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | scripts/utopia.js | function(obj) {
if(obj === null) { return 'null'; }
if(obj === undefined) { return 'undefined'; }
var ret = Object.prototype.toString.call(obj).match(/^\[object\s+(.*?)\]$/)[1];
ret = ret? ret.toLowerCase() : '';
if(ret == 'number' && isNaN(obj)) {
return 'NaN';
}
return ret;
} | javascript | function(obj) {
if(obj === null) { return 'null'; }
if(obj === undefined) { return 'undefined'; }
var ret = Object.prototype.toString.call(obj).match(/^\[object\s+(.*?)\]$/)[1];
ret = ret? ret.toLowerCase() : '';
if(ret == 'number' && isNaN(obj)) {
return 'NaN';
}
return ret;
} | [
"function",
"(",
"obj",
")",
"{",
"if",
"(",
"obj",
"===",
"null",
")",
"{",
"return",
"'null'",
";",
"}",
"if",
"(",
"obj",
"===",
"undefined",
")",
"{",
"return",
"'undefined'",
";",
"}",
"var",
"ret",
"=",
"Object",
".",
"prototype",
".",
"toStr... | Returns the [[Class]] of an object in lowercase (eg. array, date, regexp, string etc)
Caution: Results for DOM elements and collections aren't reliable.
@param {Object} obj
@return {String} | [
"Returns",
"the",
"[[",
"Class",
"]]",
"of",
"an",
"object",
"in",
"lowercase",
"(",
"eg",
".",
"array",
"date",
"regexp",
"string",
"etc",
")",
"Caution",
":",
"Results",
"for",
"DOM",
"elements",
"and",
"collections",
"aren",
"t",
"reliable",
".",
"@pa... | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L59-L73 | train | Returns the type of obj | [
30522,
3853,
1006,
27885,
3501,
1007,
1063,
2065,
1006,
27885,
3501,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
1005,
19701,
1005,
1025,
1065,
2065,
1006,
27885,
3501,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
2709,
1005,
6151,
28344,
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... | |
angular/material | src/components/gridList/grid-list.js | watchMedia | function watchMedia() {
for (var mediaName in $mdConstant.MEDIA) {
$mdMedia(mediaName); // initialize
$mdMedia.getQuery($mdConstant.MEDIA[mediaName])
.addListener(invalidateLayout);
}
return $mdMedia.watchResponsiveAttributes(
['md-cols', 'md-row-height', 'md-gutter'], attrs, layoutIfMediaMatch);
} | javascript | function watchMedia() {
for (var mediaName in $mdConstant.MEDIA) {
$mdMedia(mediaName); // initialize
$mdMedia.getQuery($mdConstant.MEDIA[mediaName])
.addListener(invalidateLayout);
}
return $mdMedia.watchResponsiveAttributes(
['md-cols', 'md-row-height', 'md-gutter'], attrs, layoutIfMediaMatch);
} | [
"function",
"watchMedia",
"(",
")",
"{",
"for",
"(",
"var",
"mediaName",
"in",
"$mdConstant",
".",
"MEDIA",
")",
"{",
"$mdMedia",
"(",
"mediaName",
")",
";",
"// initialize",
"$mdMedia",
".",
"getQuery",
"(",
"$mdConstant",
".",
"MEDIA",
"[",
"mediaName",
... | Watches for changes in media, invalidating layout as necessary. | [
"Watches",
"for",
"changes",
"in",
"media",
"invalidating",
"layout",
"as",
"necessary",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L122-L130 | train | watches the media for changes | [
30522,
3853,
3422,
16969,
1006,
1007,
1063,
2005,
1006,
13075,
3991,
14074,
1999,
1002,
9108,
8663,
12693,
2102,
1012,
2865,
1007,
1063,
1002,
9108,
16969,
1006,
3991,
14074,
1007,
1025,
1013,
1013,
3988,
4697,
1002,
9108,
16969,
1012,
2131... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/path-utils.js | getRelativePath | function getRelativePath(filepath, baseDir) {
const absolutePath = path.isAbsolute(filepath)
? filepath
: path.resolve(filepath);
if (baseDir) {
if (!path.isAbsolute(baseDir)) {
throw new Error(`baseDir should be an absolute path: ${baseDir}`);
}
return path.relative(baseDir, absolutePath);
}
return absolutePath.replace(/^\//u, "");
} | javascript | function getRelativePath(filepath, baseDir) {
const absolutePath = path.isAbsolute(filepath)
? filepath
: path.resolve(filepath);
if (baseDir) {
if (!path.isAbsolute(baseDir)) {
throw new Error(`baseDir should be an absolute path: ${baseDir}`);
}
return path.relative(baseDir, absolutePath);
}
return absolutePath.replace(/^\//u, "");
} | [
"function",
"getRelativePath",
"(",
"filepath",
",",
"baseDir",
")",
"{",
"const",
"absolutePath",
"=",
"path",
".",
"isAbsolute",
"(",
"filepath",
")",
"?",
"filepath",
":",
"path",
".",
"resolve",
"(",
"filepath",
")",
";",
"if",
"(",
"baseDir",
")",
"... | Converts an absolute filepath to a relative path from a given base path
For example, if the filepath is `/my/awesome/project/foo.bar`,
and the base directory is `/my/awesome/project/`,
then this function should return `foo.bar`.
path.relative() does something similar, but it requires a baseDir (`from` argument).
This function makes it optional and just removes a leading slash if the baseDir is not given.
It does not take into account symlinks (for now).
@param {string} filepath Path to convert to relative path. If already relative,
it will be assumed to be relative to process.cwd(),
converted to absolute, and then processed.
@param {string} [baseDir] Absolute base directory to resolve the filepath from.
If not provided, all this function will do is remove
a leading slash.
@returns {string} Relative filepath | [
"Converts",
"an",
"absolute",
"filepath",
"to",
"a",
"relative",
"path",
"from",
"a",
"given",
"base",
"path"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/path-utils.js#L50-L63 | train | Get the relative path of a file | [
30522,
3853,
2131,
16570,
8082,
15069,
1006,
5371,
15069,
1010,
2241,
4313,
1007,
1063,
9530,
3367,
7619,
15069,
1027,
4130,
1012,
18061,
5910,
4747,
10421,
1006,
5371,
15069,
1007,
1029,
5371,
15069,
1024,
4130,
1012,
10663,
1006,
5371,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.