repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function () {
var mData = this._getDeep(this.mData, arguments);
var mCustomData = this._getDeep(this.mCustomData, arguments);
return jQuery.extend({}, mData, mCustomData);
} | javascript | function () {
var mData = this._getDeep(this.mData, arguments);
var mCustomData = this._getDeep(this.mCustomData, arguments);
return jQuery.extend({}, mData, mCustomData);
} | [
"function",
"(",
")",
"{",
"var",
"mData",
"=",
"this",
".",
"_getDeep",
"(",
"this",
".",
"mData",
",",
"arguments",
")",
";",
"var",
"mCustomData",
"=",
"this",
".",
"_getDeep",
"(",
"this",
".",
"mCustomData",
",",
"arguments",
")",
";",
"return",
... | Retrieves merged object from <code>mData</code> extended with <code>mCustomData</code>.
This function merges the content of <code>mData</code> and <code>mCustomData</code> instead of returning one or the other like <code>_get()</code> does.
Note: Properties defined in <code>mCustomData</code> overwrite the ones from <code>mData</code>.
@private
@return {object} merged object | [
"Retrieves",
"merged",
"object",
"from",
"<code",
">",
"mData<",
"/",
"code",
">",
"extended",
"with",
"<code",
">",
"mCustomData<",
"/",
"code",
">",
".",
"This",
"function",
"merges",
"the",
"content",
"of",
"<code",
">",
"mData<",
"/",
"code",
">",
"a... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L3348-L3353 | train | Returns a deep copy of the data and custom data | [
30522,
3853,
1006,
1007,
1063,
13075,
9108,
6790,
1027,
2023,
1012,
1035,
2131,
26095,
2361,
1006,
2023,
1012,
9108,
6790,
1010,
9918,
1007,
1025,
13075,
11338,
19966,
5358,
2850,
2696,
1027,
2023,
1012,
1035,
2131,
26095,
2361,
1006,
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... | |
dimsemenov/PhotoSwipe | src/js/tap.js | function(origEvent, releasePoint, pointerType) {
var e = document.createEvent( 'CustomEvent' ),
eDetail = {
origEvent:origEvent,
target:origEvent.target,
releasePoint: releasePoint,
pointerType:pointerType || 'touch'
};
e.initCustomEvent( 'pswpTap', true, true, eDetail );
origEvent.target.dispatchEvent(e);
} | javascript | function(origEvent, releasePoint, pointerType) {
var e = document.createEvent( 'CustomEvent' ),
eDetail = {
origEvent:origEvent,
target:origEvent.target,
releasePoint: releasePoint,
pointerType:pointerType || 'touch'
};
e.initCustomEvent( 'pswpTap', true, true, eDetail );
origEvent.target.dispatchEvent(e);
} | [
"function",
"(",
"origEvent",
",",
"releasePoint",
",",
"pointerType",
")",
"{",
"var",
"e",
"=",
"document",
".",
"createEvent",
"(",
"'CustomEvent'",
")",
",",
"eDetail",
"=",
"{",
"origEvent",
":",
"origEvent",
",",
"target",
":",
"origEvent",
".",
"tar... | tap.js:
Displatches tap and double-tap events. | [
"tap",
".",
"js",
":"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/tap.js#L10-L21 | train | This function is called by the touchend event handler when the touchend event is triggered. | [
30522,
3853,
1006,
2030,
25538,
15338,
1010,
2713,
8400,
1010,
20884,
13874,
1007,
1063,
13075,
1041,
1027,
6254,
1012,
3443,
18697,
3372,
1006,
1005,
7661,
18697,
3372,
1005,
1007,
1010,
3968,
12928,
4014,
1027,
1063,
2030,
25538,
15338,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseSourceElement | function parseSourceElement() {
if (lookahead.type === Token.Keyword) {
switch (lookahead.value) {
case 'const':
case 'let':
return parseConstLetDeclaration(lookahead.value);
case 'function':
return parseFunctionDeclaration();
default:
return parseStatement();
}
}
if (lookahead.type !== Token.EOF) {
return parseStatement();
}
} | javascript | function parseSourceElement() {
if (lookahead.type === Token.Keyword) {
switch (lookahead.value) {
case 'const':
case 'let':
return parseConstLetDeclaration(lookahead.value);
case 'function':
return parseFunctionDeclaration();
default:
return parseStatement();
}
}
if (lookahead.type !== Token.EOF) {
return parseStatement();
}
} | [
"function",
"parseSourceElement",
"(",
")",
"{",
"if",
"(",
"lookahead",
".",
"type",
"===",
"Token",
".",
"Keyword",
")",
"{",
"switch",
"(",
"lookahead",
".",
"value",
")",
"{",
"case",
"'const'",
":",
"case",
"'let'",
":",
"return",
"parseConstLetDeclar... | 14 Program | [
"14",
"Program"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L3479-L3495 | train | ECMA - 262 13. 2. 1 Source Element | [
30522,
3853,
11968,
8583,
8162,
3401,
12260,
3672,
1006,
1007,
1063,
2065,
1006,
2298,
4430,
13775,
1012,
2828,
1027,
1027,
1027,
19204,
1012,
3145,
18351,
1007,
1063,
6942,
1006,
2298,
4430,
13775,
1012,
3643,
1007,
1063,
2553,
1005,
9530,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/tree/layoutHelper.js | nextLeft | function nextLeft(node) {
var children = node.children;
return children.length && node.isExpand ? children[0] : node.hierNode.thread;
} | javascript | function nextLeft(node) {
var children = node.children;
return children.length && node.isExpand ? children[0] : node.hierNode.thread;
} | [
"function",
"nextLeft",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"return",
"children",
".",
"length",
"&&",
"node",
".",
"isExpand",
"?",
"children",
"[",
"0",
"]",
":",
"node",
".",
"hierNode",
".",
"thread",
";",
... | This function is used to traverse the left contour of a subtree (or a subforest).
It returns the leftmost child of node or the thread of node. The function
returns null if and only if node is on the highest depth of its subtree.
@param {module:echarts/data/Tree~TreeNode} node
@return {module:echarts/data/Tree~TreeNode} | [
"This",
"function",
"is",
"used",
"to",
"traverse",
"the",
"left",
"contour",
"of",
"a",
"subtree",
"(",
"or",
"a",
"subforest",
")",
".",
"It",
"returns",
"the",
"leftmost",
"child",
"of",
"node",
"or",
"the",
"thread",
"of",
"node",
".",
"The",
"func... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L283-L286 | train | Returns the next node in the tree | [
30522,
3853,
2279,
2571,
6199,
1006,
13045,
1007,
1063,
13075,
2336,
1027,
13045,
1012,
2336,
1025,
2709,
2336,
1012,
3091,
1004,
1004,
13045,
1012,
2003,
10288,
9739,
2094,
1029,
2336,
1031,
1014,
1033,
1024,
13045,
1012,
7632,
11795,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/XMLCompositeMetadata.js | function (sClassName, oClassInfo) {
this.InvalidationMode = {
Render: true,
None: false
};
if (!oClassInfo.hasOwnProperty("renderer")) {
oClassInfo.renderer = "sap.ui.core.XMLCompositeRenderer";
}
if (!oClassInfo.hasOwnProperty("alias")) {
oClassInfo.alias = "this";
}
ElementMetadata.apply(this, arguments);
var bClassIsAbstract = this._bAbstract;// notice we cannot use this.getMetadata().isAbstract() yet ...
if (!bClassIsAbstract) {
// class is not abstract so we try to load accompanying xml
if (!oClassInfo.fragment && sClassName !== "sap.ui.core.XMLComposite") {
oClassInfo.fragment = sClassName;
oClassInfo.fragmentUnspecified = true;
}
if (!this._fragment && oClassInfo.fragment) {
try {
if (!this._fragment) {
if (oClassInfo.fragmentContent) { // content provided directly, do NOT load XML from file
if (typeof oClassInfo.fragmentContent === "string") { // parse if not already an XML document
var oParser = new DOMParser();
oClassInfo.fragmentContent = oParser.parseFromString(oClassInfo.fragmentContent, "text/xml").documentElement;
// DOMParser throws an exception in IE11, FF only logs an error, Chrome does nothing; there is a <parsererror> tag in the result, though; only handle Chrome for now
if (oClassInfo.fragmentContent && oClassInfo.fragmentContent.getElementsByTagName("parsererror").length) { // parser error
var sMessage = oClassInfo.fragmentContent.getElementsByTagName("parsererror")[0].innerText; // contains "Below is a rendering of the page up to the first error", but don't bother removing it
throw new Error("There was an error parsing the XML fragment for XMLComposite '" + sClassName + "'. The following message may contain hints to find the problem: " + sMessage);
}
}
this._fragment = oClassInfo.fragmentContent; // otherwise assume XML
} else {
this._fragment = this._loadFragment(oClassInfo.fragment, "control");
}
}
} catch (e) {
if (!oClassInfo.fragmentUnspecified /* fragment xml was explicitly specified so we expect to find something */ || e.message.startsWith("There was an error parsing")) {
throw (e);
} else {
// should the class perhaps have been abstract ...
Log.warning("Implicitly inferred fragment xml " + oClassInfo.fragment + " not found. " + sClassName + " is not abstract!");
}
}
}
}
this._sCompositeAggregation = oClassInfo.metadata ? oClassInfo.metadata.compositeAggregation || null : null;
this._createPrivateAggregationAccessors();
this._applyAggregationSettings();
} | javascript | function (sClassName, oClassInfo) {
this.InvalidationMode = {
Render: true,
None: false
};
if (!oClassInfo.hasOwnProperty("renderer")) {
oClassInfo.renderer = "sap.ui.core.XMLCompositeRenderer";
}
if (!oClassInfo.hasOwnProperty("alias")) {
oClassInfo.alias = "this";
}
ElementMetadata.apply(this, arguments);
var bClassIsAbstract = this._bAbstract;// notice we cannot use this.getMetadata().isAbstract() yet ...
if (!bClassIsAbstract) {
// class is not abstract so we try to load accompanying xml
if (!oClassInfo.fragment && sClassName !== "sap.ui.core.XMLComposite") {
oClassInfo.fragment = sClassName;
oClassInfo.fragmentUnspecified = true;
}
if (!this._fragment && oClassInfo.fragment) {
try {
if (!this._fragment) {
if (oClassInfo.fragmentContent) { // content provided directly, do NOT load XML from file
if (typeof oClassInfo.fragmentContent === "string") { // parse if not already an XML document
var oParser = new DOMParser();
oClassInfo.fragmentContent = oParser.parseFromString(oClassInfo.fragmentContent, "text/xml").documentElement;
// DOMParser throws an exception in IE11, FF only logs an error, Chrome does nothing; there is a <parsererror> tag in the result, though; only handle Chrome for now
if (oClassInfo.fragmentContent && oClassInfo.fragmentContent.getElementsByTagName("parsererror").length) { // parser error
var sMessage = oClassInfo.fragmentContent.getElementsByTagName("parsererror")[0].innerText; // contains "Below is a rendering of the page up to the first error", but don't bother removing it
throw new Error("There was an error parsing the XML fragment for XMLComposite '" + sClassName + "'. The following message may contain hints to find the problem: " + sMessage);
}
}
this._fragment = oClassInfo.fragmentContent; // otherwise assume XML
} else {
this._fragment = this._loadFragment(oClassInfo.fragment, "control");
}
}
} catch (e) {
if (!oClassInfo.fragmentUnspecified /* fragment xml was explicitly specified so we expect to find something */ || e.message.startsWith("There was an error parsing")) {
throw (e);
} else {
// should the class perhaps have been abstract ...
Log.warning("Implicitly inferred fragment xml " + oClassInfo.fragment + " not found. " + sClassName + " is not abstract!");
}
}
}
}
this._sCompositeAggregation = oClassInfo.metadata ? oClassInfo.metadata.compositeAggregation || null : null;
this._createPrivateAggregationAccessors();
this._applyAggregationSettings();
} | [
"function",
"(",
"sClassName",
",",
"oClassInfo",
")",
"{",
"this",
".",
"InvalidationMode",
"=",
"{",
"Render",
":",
"true",
",",
"None",
":",
"false",
"}",
";",
"if",
"(",
"!",
"oClassInfo",
".",
"hasOwnProperty",
"(",
"\"renderer\"",
")",
")",
"{",
... | /*
Creates a new metadata object that describes a subclass of XMLComposite.
@param {string} sClassName fully qualified name of the described class
@param {object} oClassInfo static info to construct the metadata from
@author SAP SE
@version ${version}
@since 1.50.0
@alias sap.ui.core.XMLCompositeMetadata
@extends sap.ui.core.ElementMetadata
@public
@experimental | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLCompositeMetadata.js#L38-L94 | train | Creates a new instance of the XMLComposite class. | [
30522,
3853,
1006,
8040,
27102,
18442,
1010,
1051,
26266,
2378,
14876,
1007,
1063,
2023,
1012,
19528,
3370,
5302,
3207,
1027,
1063,
17552,
1024,
2995,
1010,
3904,
1024,
6270,
1065,
1025,
2065,
1006,
999,
30524,
1063,
1051,
26266,
2378,
1487... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
catapult-project/catapult | tracing/third_party/oboe/src/instanceApi.js | addForgettableCallback | function addForgettableCallback(event, callback, listenerId) {
// listenerId is optional and if not given, the original
// callback will be used
listenerId = listenerId || callback;
var safeCallback = protectedCallback(callback);
event.on( function() {
var discard = false;
oboeApi.forget = function(){
discard = true;
};
apply( arguments, safeCallback );
delete oboeApi.forget;
if( discard ) {
event.un(listenerId);
}
}, listenerId);
return oboeApi; // chaining
} | javascript | function addForgettableCallback(event, callback, listenerId) {
// listenerId is optional and if not given, the original
// callback will be used
listenerId = listenerId || callback;
var safeCallback = protectedCallback(callback);
event.on( function() {
var discard = false;
oboeApi.forget = function(){
discard = true;
};
apply( arguments, safeCallback );
delete oboeApi.forget;
if( discard ) {
event.un(listenerId);
}
}, listenerId);
return oboeApi; // chaining
} | [
"function",
"addForgettableCallback",
"(",
"event",
",",
"callback",
",",
"listenerId",
")",
"{",
"// listenerId is optional and if not given, the original",
"// callback will be used",
"listenerId",
"=",
"listenerId",
"||",
"callback",
";",
"var",
"safeCallback",
"=",
"pro... | Add a callback where, if .forget() is called during the callback's
execution, the callback will be de-registered | [
"Add",
"a",
"callback",
"where",
"if",
".",
"forget",
"()",
"is",
"called",
"during",
"the",
"callback",
"s",
"execution",
"the",
"callback",
"will",
"be",
"de",
"-",
"registered"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/instanceApi.js#L94-L120 | train | Adds a callback to the forgettable event | [
30522,
3853,
5587,
29278,
18150,
10880,
9289,
20850,
8684,
1006,
2724,
1010,
2655,
5963,
1010,
19373,
3593,
1007,
1063,
1013,
1013,
19373,
3593,
2003,
11887,
1998,
2065,
2025,
2445,
1010,
1996,
2434,
1013,
1013,
2655,
5963,
2097,
2022,
2109... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | examples/sprite/sprite.js | function(options) {
var self = this;
self.sounds = [];
// Setup the options to define this sprite display.
self._width = options.width;
self._left = options.left;
self._spriteMap = options.spriteMap;
self._sprite = options.sprite;
self.setupListeners();
// Create our audio sprite definition.
self.sound = new Howl({
src: options.src,
sprite: options.sprite
});
// Setup a resize event and fire it to setup our sprite overlays.
window.addEventListener('resize', function() {
self.resize();
}, false);
self.resize();
// Begin the progress step tick.
requestAnimationFrame(self.step.bind(self));
} | javascript | function(options) {
var self = this;
self.sounds = [];
// Setup the options to define this sprite display.
self._width = options.width;
self._left = options.left;
self._spriteMap = options.spriteMap;
self._sprite = options.sprite;
self.setupListeners();
// Create our audio sprite definition.
self.sound = new Howl({
src: options.src,
sprite: options.sprite
});
// Setup a resize event and fire it to setup our sprite overlays.
window.addEventListener('resize', function() {
self.resize();
}, false);
self.resize();
// Begin the progress step tick.
requestAnimationFrame(self.step.bind(self));
} | [
"function",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"sounds",
"=",
"[",
"]",
";",
"// Setup the options to define this sprite display.",
"self",
".",
"_width",
"=",
"options",
".",
"width",
";",
"self",
".",
"_left",
"=",
"o... | Sprite class containing the state of our sprites to play and their progress.
@param {Object} options Settings to pass into and setup the sound and visuals. | [
"Sprite",
"class",
"containing",
"the",
"state",
"of",
"our",
"sprites",
"to",
"play",
"and",
"their",
"progress",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/sprite/sprite.js#L21-L47 | train | Initialize the howl object | [
30522,
3853,
1006,
7047,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2969,
1012,
4165,
1027,
1031,
1033,
1025,
1013,
1013,
16437,
1996,
7047,
2000,
9375,
2023,
11867,
17625,
4653,
1012,
2969,
1012,
1035,
9381,
1027,
7047,
1012,
9381,
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... | |
dequelabs/axe-core | lib/core/utils/merge-results.js | spliceNodes | function spliceNodes(target, to) {
'use strict';
var firstFromFrame = to[0].node,
sorterResult,
t;
for (var i = 0, l = target.length; i < l; i++) {
t = target[i].node;
sorterResult = axe.utils.nodeSorter(
{ actualNode: t.element },
{ actualNode: firstFromFrame.element }
);
if (
sorterResult > 0 ||
(sorterResult === 0 && firstFromFrame.selector.length < t.selector.length)
) {
target.splice.apply(target, [i, 0].concat(to));
return;
}
}
target.push.apply(target, to);
} | javascript | function spliceNodes(target, to) {
'use strict';
var firstFromFrame = to[0].node,
sorterResult,
t;
for (var i = 0, l = target.length; i < l; i++) {
t = target[i].node;
sorterResult = axe.utils.nodeSorter(
{ actualNode: t.element },
{ actualNode: firstFromFrame.element }
);
if (
sorterResult > 0 ||
(sorterResult === 0 && firstFromFrame.selector.length < t.selector.length)
) {
target.splice.apply(target, [i, 0].concat(to));
return;
}
}
target.push.apply(target, to);
} | [
"function",
"spliceNodes",
"(",
"target",
",",
"to",
")",
"{",
"'use strict'",
";",
"var",
"firstFromFrame",
"=",
"to",
"[",
"0",
"]",
".",
"node",
",",
"sorterResult",
",",
"t",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"target",
".",
... | Adds `to` to `from` and then re-sorts by DOM order
@private
@param {Array} target `nodes` array on a `RuleResult`
@param {Array} to `nodes` array on a `RuleResult`
@return {Array} The merged and sorted result | [
"Adds",
"to",
"to",
"from",
"and",
"then",
"re",
"-",
"sorts",
"by",
"DOM",
"order"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/merge-results.js#L38-L60 | train | Splice nodes from target to to | [
30522,
3853,
11867,
13231,
3630,
6155,
1006,
4539,
1010,
2000,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
2034,
19699,
5358,
15643,
1027,
2000,
1031,
1014,
1033,
1012,
13045,
1010,
4066,
28849,
23722,
2102,
1010,
1056,
1025,
2005,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/extras/primitives/primitives.js | extend | function extend (base, extension) {
if (isUndefined(base)) {
return copy(extension);
}
if (isUndefined(extension)) {
return copy(base);
}
if (isPureObject(base) && isPureObject(extension)) {
return utils.extendDeep(base, extension);
}
return copy(extension);
} | javascript | function extend (base, extension) {
if (isUndefined(base)) {
return copy(extension);
}
if (isUndefined(extension)) {
return copy(base);
}
if (isPureObject(base) && isPureObject(extension)) {
return utils.extendDeep(base, extension);
}
return copy(extension);
} | [
"function",
"extend",
"(",
"base",
",",
"extension",
")",
"{",
"if",
"(",
"isUndefined",
"(",
"base",
")",
")",
"{",
"return",
"copy",
"(",
"extension",
")",
";",
"}",
"if",
"(",
"isUndefined",
"(",
"extension",
")",
")",
"{",
"return",
"copy",
"(",
... | For the base to be extensible, both objects must be pure JavaScript objects.
The function assumes that base is undefined, or null or a pure object. | [
"For",
"the",
"base",
"to",
"be",
"extensible",
"both",
"objects",
"must",
"be",
"pure",
"JavaScript",
"objects",
".",
"The",
"function",
"assumes",
"that",
"base",
"is",
"undefined",
"or",
"null",
"or",
"a",
"pure",
"object",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/extras/primitives/primitives.js#L108-L119 | train | Extend base with extension | [
30522,
3853,
7949,
1006,
2918,
1010,
5331,
1007,
1063,
2065,
1006,
2003,
8630,
28344,
1006,
2918,
1007,
1007,
1063,
2709,
6100,
1006,
5331,
1007,
1025,
1065,
2065,
1006,
2003,
8630,
28344,
1006,
5331,
1007,
1007,
1063,
2709,
6100,
1006,
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... |
google/code-prettify | js-modules/run_prettify.js | loadStylesheetsFallingBack | function loadStylesheetsFallingBack(stylesheets) {
var n = stylesheets.length;
function load(i) {
if (i === n) { return; }
var link = doc.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
if (i + 1 < n) {
// http://pieisgood.org/test/script-link-events/ indicates that many
// versions of IE do not support onerror on <link>s, though
// http://msdn.microsoft.com/en-us/library/ie/ms535848(v=vs.85).aspx
// indicates that recent IEs do support error.
link.error = link.onerror = function () { load(i + 1); };
}
link.href = stylesheets[i];
head.appendChild(link);
}
load(0);
} | javascript | function loadStylesheetsFallingBack(stylesheets) {
var n = stylesheets.length;
function load(i) {
if (i === n) { return; }
var link = doc.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
if (i + 1 < n) {
// http://pieisgood.org/test/script-link-events/ indicates that many
// versions of IE do not support onerror on <link>s, though
// http://msdn.microsoft.com/en-us/library/ie/ms535848(v=vs.85).aspx
// indicates that recent IEs do support error.
link.error = link.onerror = function () { load(i + 1); };
}
link.href = stylesheets[i];
head.appendChild(link);
}
load(0);
} | [
"function",
"loadStylesheetsFallingBack",
"(",
"stylesheets",
")",
"{",
"var",
"n",
"=",
"stylesheets",
".",
"length",
";",
"function",
"load",
"(",
"i",
")",
"{",
"if",
"(",
"i",
"===",
"n",
")",
"{",
"return",
";",
"}",
"var",
"link",
"=",
"doc",
"... | Given a list of URLs to stylesheets, loads the first that loads without triggering an error event. | [
"Given",
"a",
"list",
"of",
"URLs",
"to",
"stylesheets",
"loads",
"the",
"first",
"that",
"loads",
"without",
"triggering",
"an",
"error",
"event",
"."
] | e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc | https://github.com/google/code-prettify/blob/e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc/js-modules/run_prettify.js#L122-L140 | train | Load stylesheets back to head | [
30522,
3853,
15665,
27983,
4095,
15558,
22747,
8095,
2075,
5963,
1006,
6782,
21030,
3215,
1007,
1063,
13075,
1050,
1027,
6782,
21030,
3215,
1012,
3091,
1025,
3853,
7170,
1006,
1045,
1007,
1063,
2065,
1006,
1045,
1027,
1027,
1027,
1050,
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... |
moleculerjs/moleculer | src/middlewares/metrics.js | metricStart | function metricStart(ctx) {
ctx.startTime = Date.now();
ctx.startHrTime = process.hrtime();
ctx.duration = 0;
if (ctx.metrics) {
const payload = generateMetricPayload(ctx);
ctx.broker.emit("metrics.trace.span.start", payload);
}
} | javascript | function metricStart(ctx) {
ctx.startTime = Date.now();
ctx.startHrTime = process.hrtime();
ctx.duration = 0;
if (ctx.metrics) {
const payload = generateMetricPayload(ctx);
ctx.broker.emit("metrics.trace.span.start", payload);
}
} | [
"function",
"metricStart",
"(",
"ctx",
")",
"{",
"ctx",
".",
"startTime",
"=",
"Date",
".",
"now",
"(",
")",
";",
"ctx",
".",
"startHrTime",
"=",
"process",
".",
"hrtime",
"(",
")",
";",
"ctx",
".",
"duration",
"=",
"0",
";",
"if",
"(",
"ctx",
".... | Start metrics & send metric event.
@param {Context} ctx
@private | [
"Start",
"metrics",
"&",
"send",
"metric",
"event",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L40-L49 | train | Start metric | [
30522,
3853,
12046,
14117,
2102,
1006,
14931,
2595,
1007,
1063,
14931,
2595,
1012,
2707,
7292,
1027,
3058,
1012,
2085,
1006,
1007,
1025,
14931,
2595,
1012,
2707,
8093,
7292,
1027,
2832,
1012,
17850,
7292,
1006,
1007,
1025,
14931,
2595,
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... |
SheetJS/js-xlsx | xlsx.js | parse_NameCmt | function parse_NameCmt(blob, length, opts) {
if(opts.biff < 8) { blob.l += length; return; }
var cchName = blob.read_shift(2);
var cchComment = blob.read_shift(2);
var name = parse_XLUnicodeStringNoCch(blob, cchName, opts);
var comment = parse_XLUnicodeStringNoCch(blob, cchComment, opts);
return [name, comment];
} | javascript | function parse_NameCmt(blob, length, opts) {
if(opts.biff < 8) { blob.l += length; return; }
var cchName = blob.read_shift(2);
var cchComment = blob.read_shift(2);
var name = parse_XLUnicodeStringNoCch(blob, cchName, opts);
var comment = parse_XLUnicodeStringNoCch(blob, cchComment, opts);
return [name, comment];
} | [
"function",
"parse_NameCmt",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"if",
"(",
"opts",
".",
"biff",
"<",
"8",
")",
"{",
"blob",
".",
"l",
"+=",
"length",
";",
"return",
";",
"}",
"var",
"cchName",
"=",
"blob",
".",
"read_shift",
"(",
... | /* [MS-XLS] 2.4.176 TODO: check older biff | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"176",
"TODO",
":",
"check",
"older",
"biff"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6275-L6282 | train | Parse a name and comment | [
30522,
3853,
11968,
3366,
1035,
2171,
27487,
2102,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
23569,
2015,
1012,
12170,
4246,
1026,
1022,
1007,
1063,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
3091,
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... |
google/material-design-lite | src/mdlComponentHandler.js | downgradeNodesInternal | function downgradeNodesInternal(nodes) {
/**
* Auxiliary function to downgrade a single node.
* @param {!Node} node the node to be downgraded
*/
var downgradeNode = function(node) {
createdComponents_.filter(function(item) {
return item.element_ === node;
}).forEach(deconstructComponentInternal);
};
if (nodes instanceof Array || nodes instanceof NodeList) {
for (var n = 0; n < nodes.length; n++) {
downgradeNode(nodes[n]);
}
} else if (nodes instanceof Node) {
downgradeNode(nodes);
} else {
throw new Error('Invalid argument provided to downgrade MDL nodes.');
}
} | javascript | function downgradeNodesInternal(nodes) {
/**
* Auxiliary function to downgrade a single node.
* @param {!Node} node the node to be downgraded
*/
var downgradeNode = function(node) {
createdComponents_.filter(function(item) {
return item.element_ === node;
}).forEach(deconstructComponentInternal);
};
if (nodes instanceof Array || nodes instanceof NodeList) {
for (var n = 0; n < nodes.length; n++) {
downgradeNode(nodes[n]);
}
} else if (nodes instanceof Node) {
downgradeNode(nodes);
} else {
throw new Error('Invalid argument provided to downgrade MDL nodes.');
}
} | [
"function",
"downgradeNodesInternal",
"(",
"nodes",
")",
"{",
"/**\n * Auxiliary function to downgrade a single node.\n * @param {!Node} node the node to be downgraded\n */",
"var",
"downgradeNode",
"=",
"function",
"(",
"node",
")",
"{",
"createdComponents_",
".",
"fi... | Downgrade either a given node, an array of nodes, or a NodeList.
@param {!Node|!Array<!Node>|!NodeList} nodes | [
"Downgrade",
"either",
"a",
"given",
"node",
"an",
"array",
"of",
"nodes",
"or",
"a",
"NodeList",
"."
] | 60f441a22ed98ed2c03f6179adf460d888bf459f | https://github.com/google/material-design-lite/blob/60f441a22ed98ed2c03f6179adf460d888bf459f/src/mdlComponentHandler.js#L390-L409 | train | downgrade nodes from the MDL to the top of the MDL | [
30522,
3853,
2091,
24170,
3630,
6155,
18447,
11795,
2389,
1006,
14164,
1007,
1063,
1013,
1008,
1008,
1008,
9830,
3853,
2000,
2091,
30524,
3853,
1006,
8875,
1007,
1063,
2709,
8875,
1012,
5783,
1035,
1027,
1027,
1027,
13045,
1025,
1065,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _purgeAllExceptWorkingSet | function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | javascript | function _purgeAllExceptWorkingSet() {
_mrofList = _createMROFList();
$mrofList.empty();
_createMROFDisplayList(true);
$currentContext = null;
PreferencesManager.setViewState(OPEN_FILES_VIEW_STATE, _mrofList, _getPrefsContext(), true);
} | [
"function",
"_purgeAllExceptWorkingSet",
"(",
")",
"{",
"_mrofList",
"=",
"_createMROFList",
"(",
")",
";",
"$mrofList",
".",
"empty",
"(",
")",
";",
"_createMROFDisplayList",
"(",
"true",
")",
";",
"$currentContext",
"=",
"null",
";",
"PreferencesManager",
".",... | Clears the MROF list in memory and pop over but retains the working set entries
@private | [
"Clears",
"the",
"MROF",
"list",
"in",
"memory",
"and",
"pop",
"over",
"but",
"retains",
"the",
"working",
"set",
"entries"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L389-L395 | train | purge all files except working set | [
30522,
3853,
1035,
24694,
24164,
2595,
3401,
13876,
21398,
13462,
1006,
1007,
1063,
1035,
2720,
11253,
9863,
1027,
1035,
3443,
2213,
3217,
10258,
2923,
1006,
1007,
1025,
1002,
2720,
11253,
9863,
1012,
4064,
1006,
1007,
1025,
1035,
3443,
221... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/column-helper.js | translateTemplates | function translateTemplates(templates) {
var result = [];
for (var _i = 0, templates_1 = templates; _i < templates_1.length; _i++) {
var temp = templates_1[_i];
var col = {};
var props = Object.getOwnPropertyNames(temp);
for (var _a = 0, props_1 = props; _a < props_1.length; _a++) {
var prop = props_1[_a];
col[prop] = temp[prop];
}
if (temp.headerTemplate) {
col.headerTemplate = temp.headerTemplate;
}
if (temp.cellTemplate) {
col.cellTemplate = temp.cellTemplate;
}
if (temp.summaryFunc) {
col.summaryFunc = temp.summaryFunc;
}
if (temp.summaryTemplate) {
col.summaryTemplate = temp.summaryTemplate;
}
result.push(col);
}
return result;
} | javascript | function translateTemplates(templates) {
var result = [];
for (var _i = 0, templates_1 = templates; _i < templates_1.length; _i++) {
var temp = templates_1[_i];
var col = {};
var props = Object.getOwnPropertyNames(temp);
for (var _a = 0, props_1 = props; _a < props_1.length; _a++) {
var prop = props_1[_a];
col[prop] = temp[prop];
}
if (temp.headerTemplate) {
col.headerTemplate = temp.headerTemplate;
}
if (temp.cellTemplate) {
col.cellTemplate = temp.cellTemplate;
}
if (temp.summaryFunc) {
col.summaryFunc = temp.summaryFunc;
}
if (temp.summaryTemplate) {
col.summaryTemplate = temp.summaryTemplate;
}
result.push(col);
}
return result;
} | [
"function",
"translateTemplates",
"(",
"templates",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"_i",
"=",
"0",
",",
"templates_1",
"=",
"templates",
";",
"_i",
"<",
"templates_1",
".",
"length",
";",
"_i",
"++",
")",
"{",
"var"... | Translates templates definitions to objects | [
"Translates",
"templates",
"definitions",
"to",
"objects"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-helper.js#L76-L101 | train | Translate a list of templates | [
30522,
3853,
17637,
18532,
15725,
2015,
1006,
23561,
2015,
1007,
1063,
13075,
2765,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
1035,
1045,
1027,
1014,
1010,
23561,
2015,
1035,
1015,
1027,
23561,
2015,
1025,
1035,
1045,
1026,
23561,
2015,
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/utils/NodeConnection.js | doConnect | function doConnect() {
attemptCount++;
attemptTimestamp = new Date();
attemptSingleConnect().then(
registerHandlersAndDomains, // succeded
function () { // failed this attempt, possibly try again
if (attemptCount < CONNECTION_ATTEMPTS) { //try again
// Calculate how long we should wait before trying again
var now = new Date();
var delay = Math.max(
RETRY_DELAY - (now - attemptTimestamp),
1
);
setTimeout(doConnect, delay);
} else { // too many attempts, give up
deferred.reject("Max connection attempts reached");
}
}
);
} | javascript | function doConnect() {
attemptCount++;
attemptTimestamp = new Date();
attemptSingleConnect().then(
registerHandlersAndDomains, // succeded
function () { // failed this attempt, possibly try again
if (attemptCount < CONNECTION_ATTEMPTS) { //try again
// Calculate how long we should wait before trying again
var now = new Date();
var delay = Math.max(
RETRY_DELAY - (now - attemptTimestamp),
1
);
setTimeout(doConnect, delay);
} else { // too many attempts, give up
deferred.reject("Max connection attempts reached");
}
}
);
} | [
"function",
"doConnect",
"(",
")",
"{",
"attemptCount",
"++",
";",
"attemptTimestamp",
"=",
"new",
"Date",
"(",
")",
";",
"attemptSingleConnect",
"(",
")",
".",
"then",
"(",
"registerHandlersAndDomains",
",",
"// succeded",
"function",
"(",
")",
"{",
"// faile... | Repeatedly tries to connect until we succeed or until we've failed CONNECTION_ATTEMPT times. After each attempt, waits at least RETRY_DELAY before trying again. | [
"Repeatedly",
"tries",
"to",
"connect",
"until",
"we",
"succeed",
"or",
"until",
"we",
"ve",
"failed",
"CONNECTION_ATTEMPT",
"times",
".",
"After",
"each",
"attempt",
"waits",
"at",
"least",
"RETRY_DELAY",
"before",
"trying",
"again",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/NodeConnection.js#L300-L319 | train | doConnect - tries to connect to the server | [
30522,
3853,
9986,
18256,
6593,
1006,
1007,
1063,
3535,
3597,
16671,
1009,
1009,
1025,
3535,
7292,
9153,
8737,
1027,
2047,
3058,
1006,
1007,
1025,
4740,
2075,
2571,
8663,
2638,
6593,
1006,
1007,
1012,
2059,
1006,
4236,
11774,
12910,
5685,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/systems/camera.js | function (newCameraEl) {
var newCamera;
var previousCamera = this.spectatorCameraEl;
var sceneEl = this.sceneEl;
var spectatorCameraEl;
// Same camera.
newCamera = newCameraEl.getObject3D('camera');
if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }
// Disable current camera
if (previousCamera) {
previousCamera.setAttribute('camera', 'spectator', false);
}
spectatorCameraEl = this.spectatorCameraEl = newCameraEl;
sceneEl.addEventListener('enter-vr', this.wrapRender);
sceneEl.addEventListener('exit-vr', this.unwrapRender);
spectatorCameraEl.setAttribute('camera', 'active', false);
spectatorCameraEl.play();
sceneEl.emit('camera-set-spectator', {cameraEl: newCameraEl});
} | javascript | function (newCameraEl) {
var newCamera;
var previousCamera = this.spectatorCameraEl;
var sceneEl = this.sceneEl;
var spectatorCameraEl;
// Same camera.
newCamera = newCameraEl.getObject3D('camera');
if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }
// Disable current camera
if (previousCamera) {
previousCamera.setAttribute('camera', 'spectator', false);
}
spectatorCameraEl = this.spectatorCameraEl = newCameraEl;
sceneEl.addEventListener('enter-vr', this.wrapRender);
sceneEl.addEventListener('exit-vr', this.unwrapRender);
spectatorCameraEl.setAttribute('camera', 'active', false);
spectatorCameraEl.play();
sceneEl.emit('camera-set-spectator', {cameraEl: newCameraEl});
} | [
"function",
"(",
"newCameraEl",
")",
"{",
"var",
"newCamera",
";",
"var",
"previousCamera",
"=",
"this",
".",
"spectatorCameraEl",
";",
"var",
"sceneEl",
"=",
"this",
".",
"sceneEl",
";",
"var",
"spectatorCameraEl",
";",
"// Same camera.",
"newCamera",
"=",
"n... | Set spectator camera to render the scene on a 2D display.
@param {Element} newCameraEl - Entity with camera component. | [
"Set",
"spectator",
"camera",
"to",
"render",
"the",
"scene",
"on",
"a",
"2D",
"display",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L193-L217 | train | Sets spectator camera element | [
30522,
3853,
1006,
2047,
28727,
6906,
2884,
1007,
1063,
13075,
2047,
28727,
6906,
1025,
13075,
3025,
28727,
6906,
1027,
2023,
1012,
21027,
28727,
6906,
2884,
1025,
13075,
3496,
2884,
1027,
2023,
1012,
3496,
2884,
1025,
13075,
21027,
28727,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ecomfe/zrender | src/graphic/Style.js | function (otherStyle, overwrite) {
if (otherStyle) {
for (var name in otherStyle) {
if (otherStyle.hasOwnProperty(name)
&& (overwrite === true
|| (
overwrite === false
? !this.hasOwnProperty(name)
: otherStyle[name] != null
)
)
) {
this[name] = otherStyle[name];
}
}
}
} | javascript | function (otherStyle, overwrite) {
if (otherStyle) {
for (var name in otherStyle) {
if (otherStyle.hasOwnProperty(name)
&& (overwrite === true
|| (
overwrite === false
? !this.hasOwnProperty(name)
: otherStyle[name] != null
)
)
) {
this[name] = otherStyle[name];
}
}
}
} | [
"function",
"(",
"otherStyle",
",",
"overwrite",
")",
"{",
"if",
"(",
"otherStyle",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"otherStyle",
")",
"{",
"if",
"(",
"otherStyle",
".",
"hasOwnProperty",
"(",
"name",
")",
"&&",
"(",
"overwrite",
"===",
"tru... | Extend from other style
@param {zrender/graphic/Style} otherStyle
@param {boolean} overwrite true: overwrirte any way.
false: overwrite only when !target.hasOwnProperty
others: overwrite when property is not null/undefined. | [
"Extend",
"from",
"other",
"style"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/graphic/Style.js#L424-L440 | train | Set the content of this object with the same name as the other one | [
30522,
3853,
1006,
2500,
27983,
1010,
2058,
26373,
1007,
1063,
2065,
1006,
2500,
27983,
1007,
1063,
2005,
1006,
13075,
2171,
1999,
2500,
27983,
1007,
1063,
2065,
1006,
2500,
27983,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
2171,
1007,
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... | |
adobe/brackets | src/project/WorkingSetSort.js | _addListeners | function _addListeners() {
if (_automaticSort && _currentSort && _currentSort.getEvents()) {
MainViewManager
.on(_currentSort.getEvents(), function () {
_currentSort.sort();
})
.on("_workingSetDisableAutoSort.sort", function () {
setAutomatic(false);
});
}
} | javascript | function _addListeners() {
if (_automaticSort && _currentSort && _currentSort.getEvents()) {
MainViewManager
.on(_currentSort.getEvents(), function () {
_currentSort.sort();
})
.on("_workingSetDisableAutoSort.sort", function () {
setAutomatic(false);
});
}
} | [
"function",
"_addListeners",
"(",
")",
"{",
"if",
"(",
"_automaticSort",
"&&",
"_currentSort",
"&&",
"_currentSort",
".",
"getEvents",
"(",
")",
")",
"{",
"MainViewManager",
".",
"on",
"(",
"_currentSort",
".",
"getEvents",
"(",
")",
",",
"function",
"(",
... | Adds the current sort MainViewManager listeners.
@private | [
"Adds",
"the",
"current",
"sort",
"MainViewManager",
"listeners",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L170-L180 | train | Add listeners to the main view manager | [
30522,
3853,
1035,
5587,
9863,
24454,
2015,
1006,
1007,
1063,
2065,
1006,
1035,
6882,
21748,
2102,
1004,
1004,
1035,
14731,
11589,
1004,
1004,
1035,
14731,
11589,
1012,
2131,
18697,
7666,
1006,
1007,
1007,
1063,
2364,
8584,
24805,
4590,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-implicit-coercion.js | isMultiplyByOne | function isMultiplyByOne(node) {
return node.operator === "*" && (
node.left.type === "Literal" && node.left.value === 1 ||
node.right.type === "Literal" && node.right.value === 1
);
} | javascript | function isMultiplyByOne(node) {
return node.operator === "*" && (
node.left.type === "Literal" && node.left.value === 1 ||
node.right.type === "Literal" && node.right.value === 1
);
} | [
"function",
"isMultiplyByOne",
"(",
"node",
")",
"{",
"return",
"node",
".",
"operator",
"===",
"\"*\"",
"&&",
"(",
"node",
".",
"left",
".",
"type",
"===",
"\"Literal\"",
"&&",
"node",
".",
"left",
".",
"value",
"===",
"1",
"||",
"node",
".",
"right",... | Checks whether or not a node is a multiplying by one.
@param {BinaryExpression} node - A BinaryExpression node to check.
@returns {boolean} Whether or not the node is a multiplying by one. | [
"Checks",
"whether",
"or",
"not",
"a",
"node",
"is",
"a",
"multiplying",
"by",
"one",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L64-L69 | train | Checks whether a node is a multiplication by one | [
30522,
3853,
2003,
12274,
7096,
11514,
2135,
3762,
5643,
1006,
13045,
1007,
1063,
2709,
13045,
1012,
6872,
1027,
1027,
1027,
1000,
1008,
1000,
1004,
1004,
1006,
13045,
1012,
2187,
1012,
2828,
1027,
1027,
1027,
1000,
18204,
1000,
1004,
1004,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | scripts/documentation.js | _cleanUpTOCChildren | function _cleanUpTOCChildren(node) {
if (!Array.isArray(node.children)) {
return node;
}
if (_isExampleOrParameterLink(node)) {
return null;
}
const filteredChildren = node.children.reduce((accu, nd) => {
accu.push(_cleanUpTOCChildren(nd));
return accu;
}, []).filter(n => n);
if (!filteredChildren.length) {
return null;
}
return {
...node,
children: filteredChildren
};
} | javascript | function _cleanUpTOCChildren(node) {
if (!Array.isArray(node.children)) {
return node;
}
if (_isExampleOrParameterLink(node)) {
return null;
}
const filteredChildren = node.children.reduce((accu, nd) => {
accu.push(_cleanUpTOCChildren(nd));
return accu;
}, []).filter(n => n);
if (!filteredChildren.length) {
return null;
}
return {
...node,
children: filteredChildren
};
} | [
"function",
"_cleanUpTOCChildren",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"node",
".",
"children",
")",
")",
"{",
"return",
"node",
";",
"}",
"if",
"(",
"_isExampleOrParameterLink",
"(",
"node",
")",
")",
"{",
"return",
"n... | Remove example and parameter link from TOC | [
"Remove",
"example",
"and",
"parameter",
"link",
"from",
"TOC"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/scripts/documentation.js#L204-L227 | train | clean up children of TOC | [
30522,
3853,
1035,
27686,
3406,
25955,
6392,
7389,
1006,
13045,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
13045,
1012,
2336,
1007,
1007,
1063,
2709,
13045,
1025,
1065,
2065,
1006,
1035,
2003,
10288,
16613,
2571,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/Controller.js | loadExtensionProvider | function loadExtensionProvider(oController, bAsync) {
var sProviderName = Controller._sExtensionProvider.replace(/\./g, "/"),
oProvider = mExtensionProvider[sProviderName];
if (bAsync) {
return new Promise(function(resolve, reject) {
if (sProviderName) {
if (oProvider){
resolve(oProvider);
} else {
sap.ui.require([sProviderName], function(ExtensionProvider) {
oProvider = new ExtensionProvider();
mExtensionProvider[sProviderName] = oProvider;
resolve(oProvider);
});
}
} else {
resolve();
}
});
} else if (sProviderName) {
if (oProvider) {
return oProvider;
} else {
var ExtensionProvider = sap.ui.requireSync(sProviderName);
oProvider = new ExtensionProvider();
mExtensionProvider[sProviderName] = oProvider;
return oProvider;
}
}
} | javascript | function loadExtensionProvider(oController, bAsync) {
var sProviderName = Controller._sExtensionProvider.replace(/\./g, "/"),
oProvider = mExtensionProvider[sProviderName];
if (bAsync) {
return new Promise(function(resolve, reject) {
if (sProviderName) {
if (oProvider){
resolve(oProvider);
} else {
sap.ui.require([sProviderName], function(ExtensionProvider) {
oProvider = new ExtensionProvider();
mExtensionProvider[sProviderName] = oProvider;
resolve(oProvider);
});
}
} else {
resolve();
}
});
} else if (sProviderName) {
if (oProvider) {
return oProvider;
} else {
var ExtensionProvider = sap.ui.requireSync(sProviderName);
oProvider = new ExtensionProvider();
mExtensionProvider[sProviderName] = oProvider;
return oProvider;
}
}
} | [
"function",
"loadExtensionProvider",
"(",
"oController",
",",
"bAsync",
")",
"{",
"var",
"sProviderName",
"=",
"Controller",
".",
"_sExtensionProvider",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"/\"",
")",
",",
"oProvider",
"=",
"mExtensionProvider",
... | /* load extension provider
@param {sap.ui.core.mvc.Controller} oController The controller instance
@param {boolean} bAsync Load async or not
@return {ExtensionProvider|Promise|undefined} ExtensionProvider <code>Promise</code> in case of asynchronous loading
or the <code>ExtensionProvider</code> in case of synchronous loading or undefined in case no provider exists | [
"/",
"*",
"load",
"extension",
"provider"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/Controller.js#L303-L332 | train | Loads the extension provider | [
30522,
3853,
7170,
10288,
29048,
21572,
17258,
2121,
1006,
1051,
8663,
13181,
10820,
1010,
19021,
6038,
2278,
1007,
1063,
13075,
11867,
12298,
18688,
18442,
1027,
11486,
1012,
1035,
3348,
29048,
21572,
17258,
2121,
1012,
5672,
1006,
1013,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/core/core.tooltip.js | function() {
var me = this;
var callbacks = me._options.callbacks;
var beforeFooter = callbacks.beforeFooter.apply(me, arguments);
var footer = callbacks.footer.apply(me, arguments);
var afterFooter = callbacks.afterFooter.apply(me, arguments);
var lines = [];
lines = pushOrConcat(lines, splitNewlines(beforeFooter));
lines = pushOrConcat(lines, splitNewlines(footer));
lines = pushOrConcat(lines, splitNewlines(afterFooter));
return lines;
} | javascript | function() {
var me = this;
var callbacks = me._options.callbacks;
var beforeFooter = callbacks.beforeFooter.apply(me, arguments);
var footer = callbacks.footer.apply(me, arguments);
var afterFooter = callbacks.afterFooter.apply(me, arguments);
var lines = [];
lines = pushOrConcat(lines, splitNewlines(beforeFooter));
lines = pushOrConcat(lines, splitNewlines(footer));
lines = pushOrConcat(lines, splitNewlines(afterFooter));
return lines;
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"callbacks",
"=",
"me",
".",
"_options",
".",
"callbacks",
";",
"var",
"beforeFooter",
"=",
"callbacks",
".",
"beforeFooter",
".",
"apply",
"(",
"me",
",",
"arguments",
")",
";",
"var",
... | Get the footer and beforeFooter and afterFooter lines Args are: (tooltipItem, data) | [
"Get",
"the",
"footer",
"and",
"beforeFooter",
"and",
"afterFooter",
"lines",
"Args",
"are",
":",
"(",
"tooltipItem",
"data",
")"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.tooltip.js#L552-L566 | train | Returns an array of lines that are split by newlines | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
2655,
12221,
1027,
2033,
1012,
1035,
7047,
1012,
2655,
12221,
1025,
13075,
2077,
13064,
2121,
1027,
2655,
12221,
1012,
2077,
13064,
2121,
1012,
6611,
1006,
2033,
1010,
991... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
material-components/material-components-web | scripts/cherry-pick-commits.js | getBaseTag | async function getBaseTag(mode) {
const tags = await simpleGit.tags();
// Filter old independent-versioned tags and pre-releases.
// If cherry-picking for a minor release, ignore patch releases to work from the latest major or minor release.
const filteredTags = tags.all.filter((tag) => /^v/.test(tag) && !/-/.test(tag) &&
(mode !== 'minor' || /\.0$/.test(tag)));
return filteredTags[filteredTags.length - 1];
} | javascript | async function getBaseTag(mode) {
const tags = await simpleGit.tags();
// Filter old independent-versioned tags and pre-releases.
// If cherry-picking for a minor release, ignore patch releases to work from the latest major or minor release.
const filteredTags = tags.all.filter((tag) => /^v/.test(tag) && !/-/.test(tag) &&
(mode !== 'minor' || /\.0$/.test(tag)));
return filteredTags[filteredTags.length - 1];
} | [
"async",
"function",
"getBaseTag",
"(",
"mode",
")",
"{",
"const",
"tags",
"=",
"await",
"simpleGit",
".",
"tags",
"(",
")",
";",
"// Filter old independent-versioned tags and pre-releases.",
"// If cherry-picking for a minor release, ignore patch releases to work from the latest... | Resolves to the appropriate git tag to serve as the base for a minor or patch release. The base for minor releases is the latest minor release (*.0). The base for patch releases is the latest patch release. | [
"Resolves",
"to",
"the",
"appropriate",
"git",
"tag",
"to",
"serve",
"as",
"the",
"base",
"for",
"a",
"minor",
"or",
"patch",
"release",
".",
"The",
"base",
"for",
"minor",
"releases",
"is",
"the",
"latest",
"minor",
"release",
"(",
"*",
".",
"0",
")",... | 9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f | https://github.com/material-components/material-components-web/blob/9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f/scripts/cherry-pick-commits.js#L60-L68 | train | Get the base tag from the git repo | [
30522,
2004,
6038,
2278,
3853,
2131,
15058,
15900,
1006,
5549,
1007,
1063,
9530,
3367,
22073,
1027,
26751,
3722,
23806,
1012,
22073,
1006,
1007,
1025,
1013,
1013,
11307,
2214,
2981,
1011,
2544,
2098,
22073,
1998,
3653,
1011,
7085,
1012,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js | function(sViewName, sExtensionPointName, vObject) { // FIXME: currently ONE extension wins, but they should be somehow merged - but how to define the order?
var oResultConfig;
// TODO: checking order of components?
findConfig(CONFIG_VIEW_EXTENSIONS, vObject, function(oConfig) {
oResultConfig = oConfig[sViewName] && oConfig[sViewName][sExtensionPointName];
return !!oResultConfig;
});
return oResultConfig;
} | javascript | function(sViewName, sExtensionPointName, vObject) { // FIXME: currently ONE extension wins, but they should be somehow merged - but how to define the order?
var oResultConfig;
// TODO: checking order of components?
findConfig(CONFIG_VIEW_EXTENSIONS, vObject, function(oConfig) {
oResultConfig = oConfig[sViewName] && oConfig[sViewName][sExtensionPointName];
return !!oResultConfig;
});
return oResultConfig;
} | [
"function",
"(",
"sViewName",
",",
"sExtensionPointName",
",",
"vObject",
")",
"{",
"// FIXME: currently ONE extension wins, but they should be somehow merged - but how to define the order?",
"var",
"oResultConfig",
";",
"// TODO: checking order of components?",
"findConfig",
"(",
"C... | returns the configuration of the given extension point or undefined
@private | [
"returns",
"the",
"configuration",
"of",
"the",
"given",
"extension",
"point",
"or",
"undefined"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js#L170-L178 | train | Returns the configuration for the given extension point. | [
30522,
3853,
1006,
17917,
2666,
7962,
14074,
1010,
3348,
29048,
8400,
18442,
1010,
29536,
2497,
20614,
1007,
1063,
1013,
1013,
8081,
4168,
1024,
2747,
2028,
5331,
5222,
1010,
2021,
2027,
2323,
2022,
5064,
5314,
1011,
2021,
2129,
2000,
9375,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | demos/chrome/popup.js | recurse_bookmarks | function recurse_bookmarks(data, tree, path) {
if(tree.url) data.push({Name: tree.title, Location: tree.url, Path:path});
var T = path ? (path + "::" + tree.title) : tree.title;
(tree.children||[]).forEach(function(C) { recurse_bookmarks(data, C, T); });
} | javascript | function recurse_bookmarks(data, tree, path) {
if(tree.url) data.push({Name: tree.title, Location: tree.url, Path:path});
var T = path ? (path + "::" + tree.title) : tree.title;
(tree.children||[]).forEach(function(C) { recurse_bookmarks(data, C, T); });
} | [
"function",
"recurse_bookmarks",
"(",
"data",
",",
"tree",
",",
"path",
")",
"{",
"if",
"(",
"tree",
".",
"url",
")",
"data",
".",
"push",
"(",
"{",
"Name",
":",
"tree",
".",
"title",
",",
"Location",
":",
"tree",
".",
"url",
",",
"Path",
":",
"p... | /* recursively walk the bookmark tree | [
"/",
"*",
"recursively",
"walk",
"the",
"bookmark",
"tree"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/demos/chrome/popup.js#L11-L15 | train | Recursively builds a tree of bookmarks | [
30522,
3853,
28667,
28393,
1035,
2338,
27373,
1006,
2951,
1010,
3392,
1010,
4130,
1007,
1063,
2065,
1006,
3392,
1012,
24471,
2140,
1007,
2951,
1012,
5245,
1006,
1063,
2171,
1024,
3392,
1012,
2516,
1010,
3295,
1024,
3392,
1012,
24471,
2140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/linter.js | resolveGlobals | function resolveGlobals(providedGlobals, enabledEnvironments) {
return Object.assign(
{},
...enabledEnvironments.filter(env => env.globals).map(env => env.globals),
providedGlobals
);
} | javascript | function resolveGlobals(providedGlobals, enabledEnvironments) {
return Object.assign(
{},
...enabledEnvironments.filter(env => env.globals).map(env => env.globals),
providedGlobals
);
} | [
"function",
"resolveGlobals",
"(",
"providedGlobals",
",",
"enabledEnvironments",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"...",
"enabledEnvironments",
".",
"filter",
"(",
"env",
"=>",
"env",
".",
"globals",
")",
".",
"map",
"(",
"... | Combines the provided globals object with the globals from environments
@param {Object} providedGlobals The 'globals' key in a config
@param {Environments[]} enabledEnvironments The environments enabled in configuration and with inline comments
@returns {Object} The resolved globals object | [
"Combines",
"the",
"provided",
"globals",
"object",
"with",
"the",
"globals",
"from",
"environments"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/linter.js#L383-L389 | train | Resolve the globals from the provided globals array | [
30522,
30524,
8163,
1012,
11307,
1006,
4372,
2615,
1027,
1028,
4372,
2615,
1012,
3795,
2015,
1007,
1012,
4949,
1006,
4372,
2615,
1027,
1028,
4372,
2615,
1012,
3795,
2015,
1007,
1010,
3024,
23296,
16429,
9777,
1007,
1025,
1065,
102,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/strict.js | getUseStrictDirectives | function getUseStrictDirectives(statements) {
const directives = [];
for (let i = 0; i < statements.length; i++) {
const statement = statements[i];
if (
statement.type === "ExpressionStatement" &&
statement.expression.type === "Literal" &&
statement.expression.value === "use strict"
) {
directives[i] = statement;
} else {
break;
}
}
return directives;
} | javascript | function getUseStrictDirectives(statements) {
const directives = [];
for (let i = 0; i < statements.length; i++) {
const statement = statements[i];
if (
statement.type === "ExpressionStatement" &&
statement.expression.type === "Literal" &&
statement.expression.value === "use strict"
) {
directives[i] = statement;
} else {
break;
}
}
return directives;
} | [
"function",
"getUseStrictDirectives",
"(",
"statements",
")",
"{",
"const",
"directives",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"statements",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"statement",
"=",
"statements... | ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------
Gets all of the Use Strict Directives in the Directive Prologue of a group of
statements.
@param {ASTNode[]} statements Statements in the program or function body.
@returns {ASTNode[]} All of the Use Strict Directives. | [
"------------------------------------------------------------------------------",
"Helpers",
"------------------------------------------------------------------------------",
"Gets",
"all",
"of",
"the",
"Use",
"Strict",
"Directives",
"in",
"the",
"Directive",
"Prologue",
"of",
"a",
"... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L24-L42 | train | Get use strict directives | [
30522,
3853,
2131,
25581,
12412,
2102,
4305,
2890,
15277,
2015,
1006,
8635,
1007,
1063,
9530,
3367,
16449,
2015,
1027,
1031,
1033,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
8635,
1012,
3091,
1025,
1045,
1009,
1009,
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... |
babel/babel | packages/babel-plugin-proposal-decorators/src/transformer-legacy.js | applyObjectDecorators | function applyObjectDecorators(path, state) {
if (!hasMethodDecorators(path.node.properties)) return;
return applyTargetDecorators(path, state, path.node.properties);
} | javascript | function applyObjectDecorators(path, state) {
if (!hasMethodDecorators(path.node.properties)) return;
return applyTargetDecorators(path, state, path.node.properties);
} | [
"function",
"applyObjectDecorators",
"(",
"path",
",",
"state",
")",
"{",
"if",
"(",
"!",
"hasMethodDecorators",
"(",
"path",
".",
"node",
".",
"properties",
")",
")",
"return",
";",
"return",
"applyTargetDecorators",
"(",
"path",
",",
"state",
",",
"path",
... | Given an object expression with property decorators, create a new expression
with the proper decorated behavior. | [
"Given",
"an",
"object",
"expression",
"with",
"property",
"decorators",
"create",
"a",
"new",
"expression",
"with",
"the",
"proper",
"decorated",
"behavior",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-plugin-proposal-decorators/src/transformer-legacy.js#L105-L109 | train | Apply object decorators to the path | [
30522,
3853,
6611,
16429,
20614,
3207,
27108,
18926,
1006,
4130,
1010,
2110,
1007,
1063,
2065,
1006,
999,
2038,
11368,
6806,
14141,
8586,
6525,
6591,
1006,
4130,
1012,
13045,
1012,
5144,
1007,
1007,
2709,
1025,
2709,
6611,
7559,
18150,
3207... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FileFilters.js | _getCondensedForm | function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
} | javascript | function _getCondensedForm(filter) {
if (!_.isArray(filter)) {
return "";
}
// Format filter in condensed form
if (filter.length > 2) {
return filter.slice(0, 2).join(", ") + " " +
StringUtils.format(Strings.FILE_FILTER_CLIPPED_SUFFIX, filter.length - 2);
}
return filter.join(", ");
} | [
"function",
"_getCondensedForm",
"(",
"filter",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"filter",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"// Format filter in condensed form",
"if",
"(",
"filter",
".",
"length",
">",
"2",
")",
"{",
"return... | Get the condensed form of the filter set by joining the first two in the set with
a comma separator and appending a short message with the number of filters being clipped.
@param {Array.<string>} filter
@return {string} Condensed form of filter set if `filter` is a valid array.
Otherwise, return an empty string. | [
"Get",
"the",
"condensed",
"form",
"of",
"the",
"filter",
"set",
"by",
"joining",
"the",
"first",
"two",
"in",
"the",
"set",
"with",
"a",
"comma",
"separator",
"and",
"appending",
"a",
"short",
"message",
"with",
"the",
"number",
"of",
"filters",
"being",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L74-L85 | train | Returns condensed form of the filter | [
30522,
3853,
1035,
2131,
8663,
4181,
6924,
14192,
1006,
11307,
1007,
1063,
2065,
1006,
999,
1035,
1012,
18061,
11335,
2100,
1006,
11307,
1007,
1007,
1063,
2709,
1000,
1000,
1025,
1065,
1013,
1013,
4289,
11307,
1999,
25011,
2433,
2065,
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/command/KeyBindingManager.js | _sortByPlatform | function _sortByPlatform(a, b) {
var a1 = (a.platform) ? 1 : 0,
b1 = (b.platform) ? 1 : 0;
return b1 - a1;
} | javascript | function _sortByPlatform(a, b) {
var a1 = (a.platform) ? 1 : 0,
b1 = (b.platform) ? 1 : 0;
return b1 - a1;
} | [
"function",
"_sortByPlatform",
"(",
"a",
",",
"b",
")",
"{",
"var",
"a1",
"=",
"(",
"a",
".",
"platform",
")",
"?",
"1",
":",
"0",
",",
"b1",
"=",
"(",
"b",
".",
"platform",
")",
"?",
"1",
":",
"0",
";",
"return",
"b1",
"-",
"a1",
";",
"}"
... | @private
Sort objects by platform property. Objects with a platform property come
before objects without a platform property. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L828-L832 | train | Sort the array by platform | [
30522,
3853,
1035,
4066,
3762,
24759,
4017,
14192,
1006,
1037,
1010,
1038,
1007,
1063,
13075,
17350,
1027,
1006,
1037,
1012,
4132,
1007,
1029,
1015,
1024,
1014,
1010,
29491,
1027,
1006,
1038,
1012,
4132,
1007,
1029,
1015,
1024,
1014,
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/model/odata/AnnotationParser.js | function(oMetadata) {
var oMetadataSchema = {},
oPropertyTypes = {},
oPropertyExtensions = {},
bPropertyExtensions = false,
sNamespace,
aEntityTypes,
aComplexTypes,
oEntityType = {},
oProperties = {},
oExtensions = {},
bExtensions = false,
oProperty,
oComplexTypeProp,
sPropertyName,
sType,
oPropExtension,
oReturn = {
types : oPropertyTypes
};
if (!oMetadata.dataServices.schema) {
return oReturn;
}
for (var i = oMetadata.dataServices.schema.length - 1; i >= 0; i -= 1) {
oMetadataSchema = oMetadata.dataServices.schema[i];
if (oMetadataSchema.entityType) {
sNamespace = oMetadataSchema.namespace;
aEntityTypes = oMetadataSchema.entityType;
aComplexTypes = oMetadataSchema.complexType;
for (var j = 0; j < aEntityTypes.length; j += 1) {
oEntityType = aEntityTypes[j];
oExtensions = {};
oProperties = {};
if (oEntityType.property) {
for (var k = 0; k < oEntityType.property.length; k += 1) {
oProperty = oEntityType.property[k];
if (oProperty.type.substring(0, sNamespace.length) === sNamespace) {
if (aComplexTypes) {
for (var l = 0; l < aComplexTypes.length; l += 1) {
if (aComplexTypes[l].name === oProperty.type.substring(sNamespace.length + 1)) {
if (aComplexTypes[l].property) {
for (var m = 0; m < aComplexTypes[l].property.length; m += 1) {
oComplexTypeProp = aComplexTypes[l].property[m];
oProperties[aComplexTypes[l].name + "/" + oComplexTypeProp.name] = oComplexTypeProp.type;
}
}
}
}
}
} else {
sPropertyName = oProperty.name;
sType = oProperty.type;
if (oProperty.extensions) {
for (var p = 0; p < oProperty.extensions.length; p += 1) {
oPropExtension = oProperty.extensions[p];
if ((oPropExtension.name === "display-format") && (oPropExtension.value === "Date")) {
sType = "Edm.Date";
} else {
bExtensions = true;
if (!oExtensions[sPropertyName]) {
oExtensions[sPropertyName] = {};
}
if (oPropExtension.namespace && !oExtensions[sPropertyName][oPropExtension.namespace]) {
oExtensions[sPropertyName][oPropExtension.namespace] = {};
}
oExtensions[sPropertyName][oPropExtension.namespace][oPropExtension.name] = oPropExtension.value;
}
}
}
oProperties[sPropertyName] = sType;
}
}
}
if (!oPropertyTypes[sNamespace + "." + oEntityType.name]) {
oPropertyTypes[sNamespace + "." + oEntityType.name] = {};
}
oPropertyTypes[sNamespace + "." + oEntityType.name] = oProperties;
if (bExtensions) {
if (!oPropertyExtensions[sNamespace + "." + oEntityType.name]) {
bPropertyExtensions = true;
}
oPropertyExtensions[sNamespace + "." + oEntityType.name] = {};
oPropertyExtensions[sNamespace + "." + oEntityType.name] = oExtensions;
}
}
}
}
if (bPropertyExtensions) {
oReturn = {
types : oPropertyTypes,
extensions : oPropertyExtensions
};
}
return oReturn;
} | javascript | function(oMetadata) {
var oMetadataSchema = {},
oPropertyTypes = {},
oPropertyExtensions = {},
bPropertyExtensions = false,
sNamespace,
aEntityTypes,
aComplexTypes,
oEntityType = {},
oProperties = {},
oExtensions = {},
bExtensions = false,
oProperty,
oComplexTypeProp,
sPropertyName,
sType,
oPropExtension,
oReturn = {
types : oPropertyTypes
};
if (!oMetadata.dataServices.schema) {
return oReturn;
}
for (var i = oMetadata.dataServices.schema.length - 1; i >= 0; i -= 1) {
oMetadataSchema = oMetadata.dataServices.schema[i];
if (oMetadataSchema.entityType) {
sNamespace = oMetadataSchema.namespace;
aEntityTypes = oMetadataSchema.entityType;
aComplexTypes = oMetadataSchema.complexType;
for (var j = 0; j < aEntityTypes.length; j += 1) {
oEntityType = aEntityTypes[j];
oExtensions = {};
oProperties = {};
if (oEntityType.property) {
for (var k = 0; k < oEntityType.property.length; k += 1) {
oProperty = oEntityType.property[k];
if (oProperty.type.substring(0, sNamespace.length) === sNamespace) {
if (aComplexTypes) {
for (var l = 0; l < aComplexTypes.length; l += 1) {
if (aComplexTypes[l].name === oProperty.type.substring(sNamespace.length + 1)) {
if (aComplexTypes[l].property) {
for (var m = 0; m < aComplexTypes[l].property.length; m += 1) {
oComplexTypeProp = aComplexTypes[l].property[m];
oProperties[aComplexTypes[l].name + "/" + oComplexTypeProp.name] = oComplexTypeProp.type;
}
}
}
}
}
} else {
sPropertyName = oProperty.name;
sType = oProperty.type;
if (oProperty.extensions) {
for (var p = 0; p < oProperty.extensions.length; p += 1) {
oPropExtension = oProperty.extensions[p];
if ((oPropExtension.name === "display-format") && (oPropExtension.value === "Date")) {
sType = "Edm.Date";
} else {
bExtensions = true;
if (!oExtensions[sPropertyName]) {
oExtensions[sPropertyName] = {};
}
if (oPropExtension.namespace && !oExtensions[sPropertyName][oPropExtension.namespace]) {
oExtensions[sPropertyName][oPropExtension.namespace] = {};
}
oExtensions[sPropertyName][oPropExtension.namespace][oPropExtension.name] = oPropExtension.value;
}
}
}
oProperties[sPropertyName] = sType;
}
}
}
if (!oPropertyTypes[sNamespace + "." + oEntityType.name]) {
oPropertyTypes[sNamespace + "." + oEntityType.name] = {};
}
oPropertyTypes[sNamespace + "." + oEntityType.name] = oProperties;
if (bExtensions) {
if (!oPropertyExtensions[sNamespace + "." + oEntityType.name]) {
bPropertyExtensions = true;
}
oPropertyExtensions[sNamespace + "." + oEntityType.name] = {};
oPropertyExtensions[sNamespace + "." + oEntityType.name] = oExtensions;
}
}
}
}
if (bPropertyExtensions) {
oReturn = {
types : oPropertyTypes,
extensions : oPropertyExtensions
};
}
return oReturn;
} | [
"function",
"(",
"oMetadata",
")",
"{",
"var",
"oMetadataSchema",
"=",
"{",
"}",
",",
"oPropertyTypes",
"=",
"{",
"}",
",",
"oPropertyExtensions",
"=",
"{",
"}",
",",
"bPropertyExtensions",
"=",
"false",
",",
"sNamespace",
",",
"aEntityTypes",
",",
"aComplex... | /*
@static
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L628-L724 | train | Returns the property types of the given metadata | [
30522,
3853,
1006,
18168,
12928,
2850,
2696,
1007,
1063,
13075,
18168,
12928,
2850,
10230,
5403,
2863,
1027,
1063,
1065,
1010,
6728,
18981,
15010,
13874,
2015,
1027,
1063,
1065,
1010,
6728,
18981,
15010,
10288,
29048,
2015,
1027,
1063,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js | function (vControl, oAppComponent, mAdditionalSelectorInformation) {
var sControlId = vControl;
if (typeof sControlId !== "string") {
sControlId = (vControl) ? this.getId(vControl) : undefined;
} else if (!oAppComponent) {
throw new Error("App Component instance needed to get a selector from string ID");
}
if (mAdditionalSelectorInformation && (mAdditionalSelectorInformation.id || mAdditionalSelectorInformation.idIsLocal)) {
throw new Error("A selector of control with the ID '" + sControlId + "' was requested, " +
"but core properties were overwritten by the additionally passed information.");
}
var bValidId = this.checkControlId(sControlId, oAppComponent);
if (!bValidId) {
throw new Error("Generated ID attribute found - to offer flexibility a stable control ID is needed to assign the changes to, but for this control the ID was generated by SAPUI5 " + sControlId);
}
var oSelector = Object.assign({}, mAdditionalSelectorInformation, {
id: "",
idIsLocal: false
});
if (this.hasLocalIdSuffix(sControlId, oAppComponent)) {
// get local Id for control at root component and use it as selector ID
var sLocalId = oAppComponent.getLocalId(sControlId);
oSelector.id = sLocalId;
oSelector.idIsLocal = true;
} else {
oSelector.id = sControlId;
}
return oSelector;
} | javascript | function (vControl, oAppComponent, mAdditionalSelectorInformation) {
var sControlId = vControl;
if (typeof sControlId !== "string") {
sControlId = (vControl) ? this.getId(vControl) : undefined;
} else if (!oAppComponent) {
throw new Error("App Component instance needed to get a selector from string ID");
}
if (mAdditionalSelectorInformation && (mAdditionalSelectorInformation.id || mAdditionalSelectorInformation.idIsLocal)) {
throw new Error("A selector of control with the ID '" + sControlId + "' was requested, " +
"but core properties were overwritten by the additionally passed information.");
}
var bValidId = this.checkControlId(sControlId, oAppComponent);
if (!bValidId) {
throw new Error("Generated ID attribute found - to offer flexibility a stable control ID is needed to assign the changes to, but for this control the ID was generated by SAPUI5 " + sControlId);
}
var oSelector = Object.assign({}, mAdditionalSelectorInformation, {
id: "",
idIsLocal: false
});
if (this.hasLocalIdSuffix(sControlId, oAppComponent)) {
// get local Id for control at root component and use it as selector ID
var sLocalId = oAppComponent.getLocalId(sControlId);
oSelector.id = sLocalId;
oSelector.idIsLocal = true;
} else {
oSelector.id = sControlId;
}
return oSelector;
} | [
"function",
"(",
"vControl",
",",
"oAppComponent",
",",
"mAdditionalSelectorInformation",
")",
"{",
"var",
"sControlId",
"=",
"vControl",
";",
"if",
"(",
"typeof",
"sControlId",
"!==",
"\"string\"",
")",
"{",
"sControlId",
"=",
"(",
"vControl",
")",
"?",
"this... | Function for determining the selector that is used later to apply a change for a given control.
The function distinguishes between local IDs generated starting with 1.40 and the global IDs generated in previous versions.
@param {sap.ui.base.ManagedObject|Element|string} vControl - Control or ID string for which the selector should be determined
@param {sap.ui.core.Component} oAppComponent - Application component, needed only if vControl is a string or XML node
@param {object} [mAdditionalSelectorInformation] - Additional mapped data which is added to the selector
@returns {object} oSelector
@returns {string} oSelector.id - ID used for determination of the flexibility target
@returns {boolean} oSelector.idIsLocal - <code>true</code> if the selector.id has to be concatenated with the application component ID while applying the change
@throws {Error} In case no control could be determined an error is thrown
@public | [
"Function",
"for",
"determining",
"the",
"selector",
"that",
"is",
"used",
"later",
"to",
"apply",
"a",
"change",
"for",
"a",
"given",
"control",
".",
"The",
"function",
"distinguishes",
"between",
"local",
"IDs",
"generated",
"starting",
"with",
"1",
".",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js#L114-L147 | train | Returns a selector object for the given control. | [
30522,
3853,
1006,
18315,
12162,
13153,
1010,
1051,
29098,
9006,
29513,
3372,
1010,
5506,
27064,
11246,
22471,
28741,
14192,
3370,
1007,
1063,
13075,
8040,
12162,
13153,
3593,
1027,
18315,
12162,
13153,
1025,
2065,
1006,
2828,
11253,
8040,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jszip.js | function() {
var i, file;
for (i = 0; i < this.files.length; i++) {
file = this.files[i];
this.reader.setIndex(file.localHeaderOffset);
this.checkSignature(sig.LOCAL_FILE_HEADER);
file.readLocalPart(this.reader);
file.handleUTF8();
}
} | javascript | function() {
var i, file;
for (i = 0; i < this.files.length; i++) {
file = this.files[i];
this.reader.setIndex(file.localHeaderOffset);
this.checkSignature(sig.LOCAL_FILE_HEADER);
file.readLocalPart(this.reader);
file.handleUTF8();
}
} | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"file",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"file",
"=",
"this",
".",
"files",
"[",
"i",
"]",
";",
"this",
".",
"reader",
... | Read the local files, based on the offset read in the central part. | [
"Read",
"the",
"local",
"files",
"based",
"on",
"the",
"offset",
"read",
"in",
"the",
"central",
"part",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1781-L1790 | train | read the local part of the file | [
30522,
3853,
1006,
1007,
1063,
13075,
1045,
1010,
5371,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
2023,
1012,
6764,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
5371,
1027,
2023,
1012,
6764,
1031,
1045,
1033,
1025,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/view/MainViewManager.js | _destroyEditorIfNotNeeded | function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
} | javascript | function _destroyEditorIfNotNeeded(document) {
if (!(document instanceof DocumentManager.Document)) {
throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
}
if (document._masterEditor) {
// findPaneForDocument tries to locate the pane in which the document
// is either opened or will be opened (in the event that the document is
// in a working set but has yet to be opened) and then asks the pane
// to destroy the view if it doesn't need it anymore
var pane = _findPaneForDocument(document);
if (pane) {
// let the pane deceide if it wants to destroy the view if it's no needed
pane.destroyViewIfNotNeeded(document._masterEditor);
} else {
// in this case, the document isn't referenced at all so just destroy it
document._masterEditor.destroy();
}
}
} | [
"function",
"_destroyEditorIfNotNeeded",
"(",
"document",
")",
"{",
"if",
"(",
"!",
"(",
"document",
"instanceof",
"DocumentManager",
".",
"Document",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"_destroyEditorIfUnneeded() should be passed a Document\"",
")",
";",
... | Destroys an editor object if a document is no longer referenced
@param {!Document} doc - document to destroy | [
"Destroys",
"an",
"editor",
"object",
"if",
"a",
"document",
"is",
"no",
"longer",
"referenced"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1422-L1441 | train | Destroys the editor if it s not needed | [
30522,
3853,
1035,
3908,
15660,
10128,
17048,
24045,
5732,
1006,
6254,
1007,
1063,
2065,
1006,
999,
1006,
6254,
6013,
11253,
6254,
24805,
4590,
1012,
6254,
1007,
1007,
1063,
5466,
2047,
7561,
1006,
1000,
1035,
3908,
15660,
10128,
4609,
2404... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
MoePlayer/DPlayer | demo/modernizr.js | function(prop) {
var length = prefixes.length;
var cssrule = window.CSSRule;
var rule;
if (typeof cssrule === 'undefined') {
return undefined;
}
if (!prop) {
return false;
}
// remove literal @ from beginning of provided property
prop = prop.replace(/^@/, '');
// CSSRules use underscores instead of dashes
rule = prop.replace(/-/g, '_').toUpperCase() + '_RULE';
if (rule in cssrule) {
return '@' + prop;
}
for (var i = 0; i < length; i++) {
// prefixes gives us something like -o-, and we want O_
var prefix = prefixes[i];
var thisRule = prefix.toUpperCase() + '_' + rule;
if (thisRule in cssrule) {
return '@-' + prefix.toLowerCase() + '-' + prop;
}
}
return false;
} | javascript | function(prop) {
var length = prefixes.length;
var cssrule = window.CSSRule;
var rule;
if (typeof cssrule === 'undefined') {
return undefined;
}
if (!prop) {
return false;
}
// remove literal @ from beginning of provided property
prop = prop.replace(/^@/, '');
// CSSRules use underscores instead of dashes
rule = prop.replace(/-/g, '_').toUpperCase() + '_RULE';
if (rule in cssrule) {
return '@' + prop;
}
for (var i = 0; i < length; i++) {
// prefixes gives us something like -o-, and we want O_
var prefix = prefixes[i];
var thisRule = prefix.toUpperCase() + '_' + rule;
if (thisRule in cssrule) {
return '@-' + prefix.toLowerCase() + '-' + prop;
}
}
return false;
} | [
"function",
"(",
"prop",
")",
"{",
"var",
"length",
"=",
"prefixes",
".",
"length",
";",
"var",
"cssrule",
"=",
"window",
".",
"CSSRule",
";",
"var",
"rule",
";",
"if",
"(",
"typeof",
"cssrule",
"===",
"'undefined'",
")",
"{",
"return",
"undefined",
";... | atRule returns a given CSS property at-rule (eg @keyframes), possibly in
some prefixed form, or false, in the case of an unsupported rule
@memberof Modernizr
@name Modernizr.atRule
@optionName Modernizr.atRule()
@optionProp atRule
@access public
@function atRule
@param {string} prop - String name of the @-rule to test for
@returns {string|boolean} The string representing the (possibly prefixed)
valid version of the @-rule, or `false` when it is unsupported.
@example
```js
var keyframes = Modernizr.atRule('@keyframes');
if (keyframes) {
// keyframes are supported
// could be `@-webkit-keyframes` or `@keyframes`
} else {
// keyframes === `false`
}
``` | [
"atRule",
"returns",
"a",
"given",
"CSS",
"property",
"at",
"-",
"rule",
"(",
"eg",
"@keyframes",
")",
"possibly",
"in",
"some",
"prefixed",
"form",
"or",
"false",
"in",
"the",
"case",
"of",
"an",
"unsupported",
"rule"
] | f5c53f082634a6e5af56cfc72978ad7bad49b989 | https://github.com/MoePlayer/DPlayer/blob/f5c53f082634a6e5af56cfc72978ad7bad49b989/demo/modernizr.js#L623-L657 | train | Returns the name of the property | [
30522,
3853,
1006,
17678,
1007,
1063,
13075,
3091,
1027,
17576,
2229,
1012,
3091,
1025,
13075,
20116,
21338,
9307,
1027,
3332,
1012,
20116,
21338,
9307,
1025,
13075,
3627,
1025,
2065,
1006,
2828,
11253,
20116,
21338,
9307,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/MenuBar.js | function(oThis, oEvent) {
var jRef = get$Item(oThis, oEvent);
if (jRef) {
var sItemIdx = jRef.attr("itemidx");
if (sItemIdx) {
if (sItemIdx == "ovrflw") {
return "ovrflw";
} else {
var iIdx = parseInt(sItemIdx);
var oMenuItem = oThis.getItems()[iIdx];
return oMenuItem;
}
}
}
return null;
} | javascript | function(oThis, oEvent) {
var jRef = get$Item(oThis, oEvent);
if (jRef) {
var sItemIdx = jRef.attr("itemidx");
if (sItemIdx) {
if (sItemIdx == "ovrflw") {
return "ovrflw";
} else {
var iIdx = parseInt(sItemIdx);
var oMenuItem = oThis.getItems()[iIdx];
return oMenuItem;
}
}
}
return null;
} | [
"function",
"(",
"oThis",
",",
"oEvent",
")",
"{",
"var",
"jRef",
"=",
"get$Item",
"(",
"oThis",
",",
"oEvent",
")",
";",
"if",
"(",
"jRef",
")",
"{",
"var",
"sItemIdx",
"=",
"jRef",
".",
"attr",
"(",
"\"itemidx\"",
")",
";",
"if",
"(",
"sItemIdx",... | Returns the item which was the target of the event (if exists) or "ovrflow" for the overflow | [
"Returns",
"the",
"item",
"which",
"was",
"the",
"target",
"of",
"the",
"event",
"(",
"if",
"exists",
")",
"or",
"ovrflow",
"for",
"the",
"overflow"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/MenuBar.js#L427-L442 | train | Returns the item for the given event | [
30522,
3853,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1007,
1063,
13075,
3781,
12879,
1027,
2131,
1002,
8875,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1007,
1025,
2065,
1006,
3781,
12879,
1007,
1063,
13075,
2609,
4328,
2094,
2595,
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... | |
swimlane/ngx-datatable | release/utils/tree.js | groupRowsByParents | function groupRowsByParents(rows, from, to) {
if (from && to) {
var nodeById = {};
var l = rows.length;
var node = null;
nodeById[0] = new TreeNode(); // that's the root node
var uniqIDs = rows.reduce(function (arr, item) {
var toValue = to(item);
if (arr.indexOf(toValue) === -1) {
arr.push(toValue);
}
return arr;
}, []);
for (var i = 0; i < l; i++) { // make TreeNode objects for each item
nodeById[to(rows[i])] = new TreeNode(rows[i]);
}
for (var i = 0; i < l; i++) { // link all TreeNode objects
node = nodeById[to(rows[i])];
var parent_1 = 0;
var fromValue = from(node.row);
if (!!fromValue && (uniqIDs.indexOf(fromValue) > -1)) {
parent_1 = fromValue;
}
node.parent = nodeById[parent_1];
node.row['level'] = node.parent.row['level'] + 1;
node.parent.children.push(node);
}
var resolvedRows_1 = [];
nodeById[0].flatten(function () {
resolvedRows_1 = resolvedRows_1.concat([this.row]);
}, true);
return resolvedRows_1;
}
else {
return rows;
}
} | javascript | function groupRowsByParents(rows, from, to) {
if (from && to) {
var nodeById = {};
var l = rows.length;
var node = null;
nodeById[0] = new TreeNode(); // that's the root node
var uniqIDs = rows.reduce(function (arr, item) {
var toValue = to(item);
if (arr.indexOf(toValue) === -1) {
arr.push(toValue);
}
return arr;
}, []);
for (var i = 0; i < l; i++) { // make TreeNode objects for each item
nodeById[to(rows[i])] = new TreeNode(rows[i]);
}
for (var i = 0; i < l; i++) { // link all TreeNode objects
node = nodeById[to(rows[i])];
var parent_1 = 0;
var fromValue = from(node.row);
if (!!fromValue && (uniqIDs.indexOf(fromValue) > -1)) {
parent_1 = fromValue;
}
node.parent = nodeById[parent_1];
node.row['level'] = node.parent.row['level'] + 1;
node.parent.children.push(node);
}
var resolvedRows_1 = [];
nodeById[0].flatten(function () {
resolvedRows_1 = resolvedRows_1.concat([this.row]);
}, true);
return resolvedRows_1;
}
else {
return rows;
}
} | [
"function",
"groupRowsByParents",
"(",
"rows",
",",
"from",
",",
"to",
")",
"{",
"if",
"(",
"from",
"&&",
"to",
")",
"{",
"var",
"nodeById",
"=",
"{",
"}",
";",
"var",
"l",
"=",
"rows",
".",
"length",
";",
"var",
"node",
"=",
"null",
";",
"nodeBy... | This functions rearrange items by their parents
Also sets the level value to each of the items
Note: Expecting each item has a property called parentId
Note: This algorithm will fail if a list has two or more items with same ID
NOTE: This algorithm will fail if there is a deadlock of relationship
For example,
Input
id -> parent
1 -> 0
2 -> 0
3 -> 1
4 -> 1
5 -> 2
7 -> 8
6 -> 3
Output
id -> level
1 -> 0
--3 -> 1
----6 -> 2
--4 -> 1
2 -> 0
--5 -> 1
7 -> 8
@param rows | [
"This",
"functions",
"rearrange",
"items",
"by",
"their",
"parents",
"Also",
"sets",
"the",
"level",
"value",
"to",
"each",
"of",
"the",
"items"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/tree.js#L44-L80 | train | group rows by parents | [
30522,
3853,
2177,
10524,
14478,
19362,
11187,
1006,
10281,
1010,
2013,
1010,
2000,
1007,
1063,
2065,
1006,
2013,
1004,
1004,
2000,
1007,
1063,
13075,
13045,
3762,
3593,
1027,
1063,
1065,
1025,
13075,
1048,
1027,
10281,
1012,
3091,
1025,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_getCategoryById | function addonsManager_getCategoryById(aSpec) {
var spec = aSpec || { };
var id = spec.id;
if (!id)
throw new Error(arguments.callee.name + ": Category ID not specified.");
return this.getCategories({
attribute: "id",
value: "category-" + id
})[0];
} | javascript | function addonsManager_getCategoryById(aSpec) {
var spec = aSpec || { };
var id = spec.id;
if (!id)
throw new Error(arguments.callee.name + ": Category ID not specified.");
return this.getCategories({
attribute: "id",
value: "category-" + id
})[0];
} | [
"function",
"addonsManager_getCategoryById",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"id",
"=",
"spec",
".",
"id",
";",
"if",
"(",
"!",
"id",
")",
"throw",
"new",
"Error",
"(",
"arguments",
".",
"callee",
".",... | Get the category element for the specified id
@param {object} aSpec
Information for getting a category
Elements: id - Category id (search, discover, languages,
searchengines, extensions, themes, plugins,
availableUpdates, recentUpdates)
@returns Category
@type {ElemBase} | [
"Get",
"the",
"category",
"element",
"for",
"the",
"specified",
"id"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L656-L667 | train | Returns the category with the specified ID | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2131,
16280,
20255,
2100,
3762,
3593,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
8909,
1027,
28699,
1012,
8909,
1025,
2065,
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... |
apache/incubator-echarts | src/data/Tree.js | function (node) {
var parent = node.parentNode;
while (parent) {
if (parent === this) {
return true;
}
parent = parent.parentNode;
}
return false;
} | javascript | function (node) {
var parent = node.parentNode;
while (parent) {
if (parent === this) {
return true;
}
parent = parent.parentNode;
}
return false;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentNode",
";",
"while",
"(",
"parent",
")",
"{",
"if",
"(",
"parent",
"===",
"this",
")",
"{",
"return",
"true",
";",
"}",
"parent",
"=",
"parent",
".",
"parentNode",
";",
"}... | if this is an ancestor of another node
@public
@param {TreeNode} node another node
@return {boolean} if is ancestor | [
"if",
"this",
"is",
"an",
"ancestor",
"of",
"another",
"node"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Tree.js#L314-L323 | train | returns true if the node is a parent of this | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
6687,
1027,
13045,
1012,
6687,
3630,
3207,
1025,
2096,
1006,
6687,
1007,
1063,
2065,
1006,
6687,
1027,
1027,
1027,
2023,
1007,
1063,
2709,
2995,
1025,
1065,
6687,
1027,
6687,
1012,
6687,
3630,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/chart/chart.js | parseDSV2ChartData | function parseDSV2ChartData(code, delimiter) {
// trim all heading/trailing blank lines
code = trimKeepingTabs(code);
csv.COLUMN_SEPARATOR = delimiter || detectDelimiter(code);
let dsv = csv.parse(code);
// trim all values in 2D array
dsv = dsv.map(arr => arr.map(val => val.trim()));
// test a first row for legends. ['anything', '1', '2', '3'] === false, ['anything', 't1', '2', 't3'] === true
const hasLegends = dsv[0].filter((v, i) => i > 0).reduce((hasNaN, item) => hasNaN || !isNumeric(item), false);
const legends = hasLegends ? dsv.shift() : [];
// test a first column for categories
const hasCategories = dsv.slice(1).reduce((hasNaN, row) => hasNaN || !isNumeric(row[0]), false);
const categories = hasCategories ? dsv.map(arr => arr.shift()) : [];
if (hasCategories) {
legends.shift();
}
// transpose dsv, parse number
// [['1','2','3'] [[1,4,7]
// ['4','5','6'] => [2,5,8]
// ['7','8','9']] [3,6,9]]
dsv = dsv[0].map((t, i) => dsv.map(x => parseFloat(x[i])));
// make series
const series = dsv.map((data, i) => hasLegends ? {
name: legends[i],
data
} : {
data
});
return {
categories,
series
};
} | javascript | function parseDSV2ChartData(code, delimiter) {
// trim all heading/trailing blank lines
code = trimKeepingTabs(code);
csv.COLUMN_SEPARATOR = delimiter || detectDelimiter(code);
let dsv = csv.parse(code);
// trim all values in 2D array
dsv = dsv.map(arr => arr.map(val => val.trim()));
// test a first row for legends. ['anything', '1', '2', '3'] === false, ['anything', 't1', '2', 't3'] === true
const hasLegends = dsv[0].filter((v, i) => i > 0).reduce((hasNaN, item) => hasNaN || !isNumeric(item), false);
const legends = hasLegends ? dsv.shift() : [];
// test a first column for categories
const hasCategories = dsv.slice(1).reduce((hasNaN, row) => hasNaN || !isNumeric(row[0]), false);
const categories = hasCategories ? dsv.map(arr => arr.shift()) : [];
if (hasCategories) {
legends.shift();
}
// transpose dsv, parse number
// [['1','2','3'] [[1,4,7]
// ['4','5','6'] => [2,5,8]
// ['7','8','9']] [3,6,9]]
dsv = dsv[0].map((t, i) => dsv.map(x => parseFloat(x[i])));
// make series
const series = dsv.map((data, i) => hasLegends ? {
name: legends[i],
data
} : {
data
});
return {
categories,
series
};
} | [
"function",
"parseDSV2ChartData",
"(",
"code",
",",
"delimiter",
")",
"{",
"// trim all heading/trailing blank lines",
"code",
"=",
"trimKeepingTabs",
"(",
"code",
")",
";",
"csv",
".",
"COLUMN_SEPARATOR",
"=",
"delimiter",
"||",
"detectDelimiter",
"(",
"code",
")",... | parse csv, tsv to chart data
@param {string} code - data code
@param {string|RegExp} delimiter - delimiter
@returns {Object} - tui.chart data
@see https://nhn.github.io/tui.chart/latest/tui.chart.html
@ignore | [
"parse",
"csv",
"tsv",
"to",
"chart",
"data"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/chart/chart.js#L177-L216 | train | Parse DSV2 chart data | [
30522,
3853,
11968,
6924,
2015,
2615,
2475,
7507,
5339,
2850,
2696,
1006,
3642,
1010,
3972,
27605,
3334,
1007,
1063,
1013,
1013,
12241,
2035,
5825,
1013,
12542,
30524,
1007,
1025,
2292,
16233,
2615,
1027,
20116,
2615,
1012,
11968,
3366,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.layout/src/sap/ui/layout/library.js | function(DataType, library) {
"use strict";
/**
* SAPUI5 library with layout controls.
*
* @namespace
* @name sap.ui.layout
* @author SAP SE
* @version ${version}
* @public
*/
// delegate further initialization of this library to the Core
sap.ui.getCore().initLibrary({
name : "sap.ui.layout",
version: "${version}",
dependencies: ["sap.ui.core"],
designtime: "sap/ui/layout/designtime/library.designtime",
types: [
"sap.ui.layout.BackgroundDesign",
"sap.ui.layout.GridIndent",
"sap.ui.layout.GridPosition",
"sap.ui.layout.GridSpan",
"sap.ui.layout.BlockBackgroundType",
"sap.ui.layout.form.GridElementCells",
"sap.ui.layout.form.SimpleFormLayout",
"sap.ui.layout.form.ColumnsXL",
"sap.ui.layout.form.ColumnsL",
"sap.ui.layout.form.ColumnsM",
"sap.ui.layout.form.ColumnCells",
"sap.ui.layout.form.EmptyCells",
"sap.ui.layout.cssgrid.CSSGridTrack",
"sap.ui.layout.cssgrid.CSSGridLine",
"sap.ui.layout.cssgrid.CSSGridGapShortHand"
],
interfaces: [
"sap.ui.layout.cssgrid.IGridConfigurable"
],
controls: [
"sap.ui.layout.AlignedFlowLayout",
"sap.ui.layout.DynamicSideContent",
"sap.ui.layout.FixFlex",
"sap.ui.layout.Grid",
"sap.ui.layout.HorizontalLayout",
"sap.ui.layout.ResponsiveFlowLayout",
"sap.ui.layout.ResponsiveSplitter",
"sap.ui.layout.ResponsiveSplitterPage",
"sap.ui.layout.Splitter",
"sap.ui.layout.VerticalLayout",
"sap.ui.layout.BlockLayoutCell",
"sap.ui.layout.BlockLayoutRow",
"sap.ui.layout.BlockLayout",
"sap.ui.layout.form.Form",
"sap.ui.layout.form.FormLayout",
"sap.ui.layout.form.GridLayout",
"sap.ui.layout.form.ColumnLayout",
"sap.ui.layout.form.ResponsiveGridLayout",
"sap.ui.layout.form.ResponsiveLayout",
"sap.ui.layout.form.SimpleForm",
"sap.ui.layout.cssgrid.CSSGrid"
],
elements: [
"sap.ui.layout.GridData",
"sap.ui.layout.ResponsiveFlowLayoutData",
"sap.ui.layout.SplitterLayoutData",
"sap.ui.layout.form.FormContainer",
"sap.ui.layout.form.FormElement",
"sap.ui.layout.form.GridContainerData",
"sap.ui.layout.PaneContainer",
"sap.ui.layout.SplitPane",
"sap.ui.layout.form.GridElementData",
"sap.ui.layout.form.ColumnElementData",
"sap.ui.layout.form.ColumnContainerData",
"sap.ui.layout.cssgrid.GridItemLayoutData",
"sap.ui.layout.cssgrid.GridLayoutBase",
"sap.ui.layout.cssgrid.GridBasicLayout",
"sap.ui.layout.cssgrid.GridBoxLayout",
"sap.ui.layout.cssgrid.GridResponsiveLayout"
],
extensions: {
flChangeHandlers: {
"sap.ui.layout.BlockLayout": {
"moveControls": "default"
},
"sap.ui.layout.BlockLayoutRow": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.BlockLayoutCell": "sap/ui/layout/flexibility/BlockLayoutCell",
"sap.ui.layout.DynamicSideContent": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.form.SimpleForm": "sap/ui/layout/flexibility/SimpleForm",
"sap.ui.layout.Grid": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.FixFlex": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.form.Form": "sap/ui/layout/flexibility/Form",
"sap.ui.layout.form.FormContainer": "sap/ui/layout/flexibility/FormContainer",
"sap.ui.layout.form.FormElement": "sap/ui/layout/flexibility/FormElement",
"sap.ui.layout.HorizontalLayout": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.Splitter": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.VerticalLayout": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
}
},
//Configuration used for rule loading of Support Assistant
"sap.ui.support": {
publicRules:true,
internalRules:true
}
}
});
/**
* Defines the functions that need to be implemented by a Control which wants
* to have display:grid behavior via sap.ui.layout.cssgrid.GridLayoutDelegate
*
* @since 1.60.0
* @public
* @interface
* @name sap.ui.layout.cssgrid.IGridConfigurable
*/
/**
* The function is used by GridLayoutDelegate to determine on which HTML Elements the display:grid styles should be applied
*
* @returns {sap.ui.core.Control[]|HTMLElement[]} The controls or HTML elements on which display:grid styles should be applied
* @since 1.60.0
* @public
* @function
* @name sap.ui.layout.cssgrid.IGridConfigurable.getGridDomRefs
*/
/**
* The function is used by GridLayoutDelegate to get the grid layout (display:grid styles) to apply
*
* @returns {sap.ui.layout.cssgrid.GridLayoutBase} The display:grid layout to apply
* @since 1.60.0
* @public
* @function
* @name sap.ui.layout.cssgrid.IGridConfigurable.getGridLayoutConfiguration
*/
/**
* Available Background Design.
*
* @enum {string}
* @public
* @since 1.36.0
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BackgroundDesign = {
/**
* A solid background color dependent on the theme.
* @public
*/
Solid : "Solid",
/**
* Transparent background.
* @public
*/
Transparent : "Transparent",
/**
* A translucent background depending on the opacity value of the theme.
* @public
*/
Translucent : "Translucent"
};
/**
* @classdesc
* A string type that represents the indent values of the <code>Grid</code> for large, medium and small screens.
*
* Allowed values are separated by space Letters L, M or S followed by number of columns from 1 to 11
* that the container has to take, for example: <code>L2 M4 S6</code>, <code>M11</code>, <code>s10</code>
* or <code>l4 m4</code>.
*
* <b>Note:</b> The parameters must be provided in the order <large medium small>.
*
* @final
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridIndent = DataType.createType('sap.ui.layout.GridIndent', {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[0-9]|1[0-1]))? ?([Ll](?:[0-9]|1[0-1]))? ?([Mm](?:[0-9]|1[0-1]))? ?([Ss](?:[0-9]|1[0-1]))?)$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* The position of the {@link sap.ui.layout.Grid}. Can be <code>Left</code> (default), <code>Center</code>
* or <code>Right</code>.
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridPosition = {
/**
* <code>Grid</code> is aligned left.
* @public
*/
Left : "Left",
/**
* <code>Grid</code> is aligned to the right.
* @public
*/
Right : "Right",
/**
* <code>Grid</code> is centered on the screen.
* @public
*/
Center : "Center"
};
/**
* @classdesc
* A string type that represents the span values of the <code>Grid</code> for large, medium and small screens.
*
* Allowed values are separated by space Letters L, M or S followed by number of columns from 1 to 12
* that the container has to take, for example: <code>L2 M4 S6</code>, <code>M12</code>,
* <code>s10</code> or <code>l4 m4</code>.
*
* <b>Note:</b> The parameters must be provided in the order <large medium small>.
*
* @final
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridSpan = DataType.createType('sap.ui.layout.GridSpan', {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[1-9]|1[0-2]))? ?([Ll](?:[1-9]|1[0-2]))? ?([Mm](?:[1-9]|1[0-2]))? ?([Ss](?:[1-9]|1[0-2]))?)$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* A string type that is used inside the BlockLayout to set predefined background color to the cells inside
* the control.
* @enum {string}
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockBackgroundType = {
/**
* Background is transparent
* @public
*/
Default: "Default",
/**
* Background is with predefined light colors
* @public
*/
Light: "Light",
/**
* Background with bright and dark background colors
* @deprecated since 1.50
* @public
*/
Mixed: "Mixed",
/**
* Background with pre-defined accent colors
* @public
*/
Accent: "Accent",
/**
* For applications that want to make use of e.g. charts in the Blocks, this layout type has spacings around the Blocks
* @public
*/
Dashboard: "Dashboard"
};
/**
* A string type that is used inside the BlockLayoutRow to set predefined set of colors the cells inside
* the control. Color sets depend on sap.ui.layout.BlockBackgroundType
*
* @enum {string}
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockRowColorSets = {
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 1
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 1
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 1
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet1: "ColorSet1",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 2
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 2
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 2
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet2: "ColorSet2",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 1
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 1
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 3
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet3: "ColorSet3",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 2
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 2
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 4
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet4: "ColorSet4"
};
/**
* A string type that is used inside the BlockLayoutCell to set a predefined set of colors for the cells.
*
* @enum {string}
* @public
* @since 1.48
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockLayoutCellColorSet = {
/**
* Color Set 1
*
* @public
*/
ColorSet1: "ColorSet1",
/**
* Color Set 2
*
* @public
*/
ColorSet2: "ColorSet2",
/**
* Color Set 3
*
* @public
*/
ColorSet3: "ColorSet3",
/**
* Color Set 4
*
* @public
*/
ColorSet4: "ColorSet4",
/**
* Color Set 5
*
* @public
*/
ColorSet5: "ColorSet5",
/**
* Color Set 6
*
* @public
*/
ColorSet6: "ColorSet6",
/**
* Color Set 7
*
* @public
*/
ColorSet7: "ColorSet7",
/**
* Color Set 8
*
* @public
*/
ColorSet8: "ColorSet8",
/**
* Color Set 9
*
* @public
*/
ColorSet9: "ColorSet9",
/**
* Color Set 10
*
* @public
*/
ColorSet10: "ColorSet10",
/**
* Color Set 11
*
* @public
*/
ColorSet11: "ColorSet11"
};
/**
* A string type that is used inside the BlockLayoutCell to set a predefined set of color shades for the cells.
* The colors are defined with sap.ui.layout.BlockLayoutCellColorSet. And this is for the shades only.
*
* @enum {string}
* @public
* @since 1.48
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockLayoutCellColorShade = {
/**
* Shade A
*
* @public
*/
ShadeA: "ShadeA",
/**
* Shade B
*
* @public
*/
ShadeB: "ShadeB",
/**
* Shade C
*
* @public
*/
ShadeC: "ShadeC",
/**
* Shade D
*
* @public
*/
ShadeD: "ShadeD",
/**
* Shade E - available only for Fiori 3 theme
*
* @public
*/
ShadeE: "ShadeE",
/**
* Shade F - available only for Fiori 3 theme
*
* @public
*/
ShadeF: "ShadeF"
};
sap.ui.layout.form = sap.ui.layout.form || {};
/**
* @classdesc A string that defines the number of used cells in a <code>GridLayout</code>. This can be a number from 1 to 16, "auto" or "full".
* If set to "auto" the size is determined by the number of fields and the available cells. For labels the auto size is 3 cells.
* If set to "full" only one field is allowed within the <code>FormElement</code>. It gets the full width of the row and the label is displayed above. <b>Note:</b> For labels full size has no effect.
*
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.GridElementCells = DataType.createType('sap.ui.layout.form.GridElementCells', {
isValid : function(vValue) {
return /^(auto|full|([1-9]|1[0-6]))$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* Available <code>FormLayouts</code> used to render a <code>SimpleForm</code>.
*
* @enum {string}
* @public
* @since 1.16.0
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.SimpleFormLayout = {
/**
* Uses the <code>ResponsiveLayout</code> layout to render the <code>SimpleForm</code> control
* @public
*/
ResponsiveLayout : "ResponsiveLayout",
/**
* Uses the <code>GridLayout</code> layout to render the <code>SimpleForm</code> control
* @public
*/
GridLayout : "GridLayout",
/**
* Uses the <code>ResponsiveGridLayout</code> layout to render the <code>SimpleForm</code> control
* @public
* @since 1.16.0
*/
ResponsiveGridLayout : "ResponsiveGridLayout",
/**
* Uses the <code>ColumnLayout</code> layout to render the <code>SimpleForm</code> control
* @public
* @since 1.56.0
*/
ColumnLayout : "ColumnLayout"
};
/**
* Types of the DynamicSideContent Visibility options
*
* @enum {string}
* @public
* @since 1.30
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentVisibility = {
/**
* Show the side content on any breakpoint
* @public
*/
AlwaysShow: "AlwaysShow",
/**
* Show the side content on XL breakpoint
* @public
*/
ShowAboveL: "ShowAboveL",
/**
* Show the side content on L and XL breakpoints
* @public
*/
ShowAboveM: "ShowAboveM",
/**
* Show the side content on M, L and XL breakpoints
* @public
*/
ShowAboveS: "ShowAboveS",
/**
* Don't show the side content on any breakpoints
* @public
*/
NeverShow: "NeverShow"
};
/**
* Types of the DynamicSideContent FallDown options
*
* @enum {string}
* @public
* @since 1.30
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentFallDown = {
/**
* Side content falls down on breakpoints below XL
* @public
*/
BelowXL: "BelowXL",
/**
* Side content falls down on breakpoints below L
* @public
*/
BelowL: "BelowL",
/**
* Side content falls down on breakpoints below M
* @public
*/
BelowM: "BelowM",
/**
* Side content falls down on breakpoint M and the minimum width for the side content
* @public
*/
OnMinimumWidth: "OnMinimumWidth"
};
/**
* The position of the side content - End (default) and Begin.
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentPosition = {
/**
* The side content is on the right side of the main container in left-to-right mode and on the left side in right-to-left mode.
* @public
*/
End : "End",
/**
* The side content is on the left side of the main container in left-to-right mode and on the right side in right-to-left mode.
* @public
*/
Begin : "Begin"
};
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has extra-large size
*
* Allowed values are numbers from 1 to 4.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsXL = DataType.createType('sap.ui.layout.form.ColumnsXL', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 4) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has large size
*
* Allowed values are numbers from 1 to 3.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsL = DataType.createType('sap.ui.layout.form.ColumnsL', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 3) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has medium size
*
* Allowed values are numbers from 1 to 2.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsM = DataType.createType('sap.ui.layout.form.ColumnsM', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 2) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many cells a control inside of a column
* of a <code>Form</code> control using the <code>ColumnLayout</code> control as layout can use.
*
* Allowed values are numbers from 1 to 12.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnCells = DataType.createType('sap.ui.layout.form.ColumnCells', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 12) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many cells beside the controls
* inside of a column of a <code>Form</code> control using the <code>ColumnLayout</code> control as layout
* are empty.
*
* Allowed values are numbers from 0 to 11.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.EmptyCells = DataType.createType('sap.ui.layout.form.EmptyCells', {
isValid : function(vValue) {
if (vValue >= 0 && vValue < 12) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
// factory for Form to create labels and buttons to be overwritten by commons and mobile library
if (!sap.ui.layout.form.FormHelper) {
sap.ui.layout.form.FormHelper = {
createLabel: function(sText){ throw new Error("no Label control available!"); }, /* must return a Label control */
createButton: function(sId, fPressFunction, fnCallback){ throw new Error("no Button control available!"); }, /* must return a button control */
setButtonContent: function(oButton, sText, sTooltip, sIcon, sIconHovered){ throw new Error("no Button control available!"); },
addFormClass: function(){ return null; },
setToolbar: function(oToolbar){ return oToolbar; }, /* allow to overwrite toolbar settings */
bArrowKeySupport: true, /* enables the keyboard support for arrow keys */
bFinal: false /* if true, the helper must not be overwritten by an other library */
};
}
if (!sap.ui.layout.GridHelper) {
sap.ui.layout.GridHelper = {
getLibrarySpecificClass: function () {
return "";
},
bFinal: false /* if true, the helper must not be overwritten by an other library */
};
}
/**
* @classdesc A string type that represents a grid track (the space between two grid lines)
*
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Grid_tracks}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridTrack = DataType.createType("sap.ui.layout.cssgrid.CSSGridTrack", {
isValid: function (sValue) {
var sCSSSizeRegex = /(auto|inherit|(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%))|calc\(\s*(\(\s*)*[-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%)?)(\s*(\)\s*)*(\s[-+]\s|[*\/])\s*(\(\s*)*([-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%)?)))*\s*(\)\s*)*\))/g;
// Remove valid keywords that can be used as part of a grid track property value
sValue = sValue.replace(/(minmax|repeat|fit-content|max-content|min-content|auto-fill|auto-fit|fr|min|max)/g, "");
// Remove valid CSSSizes
sValue = sValue.replace(sCSSSizeRegex, "");
// Remove expression syntax
sValue = sValue.replace(/\(|\)|\+|\-|\*|\/|calc|\%|\,/g, "");
// Remove any number leftovers which are not CSSSizes
sValue = sValue.replace(/[0-9]/g, "");
// Remove whitespace
sValue = sValue.replace(/\s/g, "");
return sValue.length === 0;
},
parseValue: function (sValue) {
return sValue.trim().split(/\s+/).join(" ");
}
},
DataType.getType("string")
);
/**
* @classdesc A string type that represents a short hand CSS grid gap.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/gap}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridGapShortHand = DataType.createType("sap.ui.layout.cssgrid.CSSGridGapShortHand", {
isValid: function (vValue) {
var bResult = true,
aValues = vValue.split(/\s+/);
aValues.forEach(function (sValue) {
if (!library.CSSSize.isValid(sValue)) {
bResult = false;
}
});
return bResult;
},
parseValue: function (sValue) {
return sValue.trim().split(/\s+/).join(" ");
}
},
DataType.getType("string")
);
/**
* @classdesc A string type that represents one or two grid lines. Used to define the position and size of a single grid item.
*
* Valid values:
* <ul>
* <li>auto</li>
* <li>inherit</li>
* <li>1</li>
* <li>span 2</li>
* <li>span 2 / 5</li>
* <li>span 2 / -5</li>
* <li>5 / 7</li>
* <li>7 / span 5</li>
* <li>span 7 / span 5</li>
* </ul>
*
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Grid_lines MDN web docs: grid lines}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridLine = DataType.createType("sap.ui.layout.cssgrid.CSSGridLine", {
isValid: function (sValue) {
return /^(auto|inherit|((span)?(\s)?-?[0-9]+(\s\/\s(span)?(\s)?-?[0-9]*)?)?)$/.test(sValue);
}
},
DataType.getType("string")
);
/**
* A string type that is used for CSS grid to control how the auto-placement algorithm works,
* specifying exactly how auto-placed items get flowed into the grid.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow}
* @enum {string}
* @since 1.60.0
* @public
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridAutoFlow = {
/**
* Insert auto-placed items by filling each row.
* @public
*/
Row: "Row",
/**
* Insert auto-placed items by filling each column.
* @public
*/
Column: "Column",
/**
* Insert auto-placed items by filling each row, and fill any holes in the grid.
* @public
*/
RowDense: "RowDense",
/**
* Insert auto-placed items by filling each column, and fill any holes in the grid.
* @public
*/
ColumnDense: "ColumnDense"
};
/**
* @classdesc A string type that represents how many boxes per row should be displayed for each screen size. The breakpoints are for extra large (XL), large (L), medium (M) and small (S) screen sizes.
*
* <b>Note:</b> The parameters must be provided in the order <XL L M S>.
*
* @example <code>XL7 L6 M4 S2</code>
* @example <code>XL12 L12 M12 S1</code>
* @since 1.61.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BoxesPerRowConfig = DataType.createType("sap.ui.layout.BoxesPerRowConfig", {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[1-9]|1[0-2]))? ?([Ll](?:[1-9]|1[0-2]))? ?([Mm](?:[1-9]|1[0-2]))? ?([Ss](?:[1-9]|1[0-2]))?)$/.test(vValue);
}
},
DataType.getType("string")
);
return sap.ui.layout;
} | javascript | function(DataType, library) {
"use strict";
/**
* SAPUI5 library with layout controls.
*
* @namespace
* @name sap.ui.layout
* @author SAP SE
* @version ${version}
* @public
*/
// delegate further initialization of this library to the Core
sap.ui.getCore().initLibrary({
name : "sap.ui.layout",
version: "${version}",
dependencies: ["sap.ui.core"],
designtime: "sap/ui/layout/designtime/library.designtime",
types: [
"sap.ui.layout.BackgroundDesign",
"sap.ui.layout.GridIndent",
"sap.ui.layout.GridPosition",
"sap.ui.layout.GridSpan",
"sap.ui.layout.BlockBackgroundType",
"sap.ui.layout.form.GridElementCells",
"sap.ui.layout.form.SimpleFormLayout",
"sap.ui.layout.form.ColumnsXL",
"sap.ui.layout.form.ColumnsL",
"sap.ui.layout.form.ColumnsM",
"sap.ui.layout.form.ColumnCells",
"sap.ui.layout.form.EmptyCells",
"sap.ui.layout.cssgrid.CSSGridTrack",
"sap.ui.layout.cssgrid.CSSGridLine",
"sap.ui.layout.cssgrid.CSSGridGapShortHand"
],
interfaces: [
"sap.ui.layout.cssgrid.IGridConfigurable"
],
controls: [
"sap.ui.layout.AlignedFlowLayout",
"sap.ui.layout.DynamicSideContent",
"sap.ui.layout.FixFlex",
"sap.ui.layout.Grid",
"sap.ui.layout.HorizontalLayout",
"sap.ui.layout.ResponsiveFlowLayout",
"sap.ui.layout.ResponsiveSplitter",
"sap.ui.layout.ResponsiveSplitterPage",
"sap.ui.layout.Splitter",
"sap.ui.layout.VerticalLayout",
"sap.ui.layout.BlockLayoutCell",
"sap.ui.layout.BlockLayoutRow",
"sap.ui.layout.BlockLayout",
"sap.ui.layout.form.Form",
"sap.ui.layout.form.FormLayout",
"sap.ui.layout.form.GridLayout",
"sap.ui.layout.form.ColumnLayout",
"sap.ui.layout.form.ResponsiveGridLayout",
"sap.ui.layout.form.ResponsiveLayout",
"sap.ui.layout.form.SimpleForm",
"sap.ui.layout.cssgrid.CSSGrid"
],
elements: [
"sap.ui.layout.GridData",
"sap.ui.layout.ResponsiveFlowLayoutData",
"sap.ui.layout.SplitterLayoutData",
"sap.ui.layout.form.FormContainer",
"sap.ui.layout.form.FormElement",
"sap.ui.layout.form.GridContainerData",
"sap.ui.layout.PaneContainer",
"sap.ui.layout.SplitPane",
"sap.ui.layout.form.GridElementData",
"sap.ui.layout.form.ColumnElementData",
"sap.ui.layout.form.ColumnContainerData",
"sap.ui.layout.cssgrid.GridItemLayoutData",
"sap.ui.layout.cssgrid.GridLayoutBase",
"sap.ui.layout.cssgrid.GridBasicLayout",
"sap.ui.layout.cssgrid.GridBoxLayout",
"sap.ui.layout.cssgrid.GridResponsiveLayout"
],
extensions: {
flChangeHandlers: {
"sap.ui.layout.BlockLayout": {
"moveControls": "default"
},
"sap.ui.layout.BlockLayoutRow": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.BlockLayoutCell": "sap/ui/layout/flexibility/BlockLayoutCell",
"sap.ui.layout.DynamicSideContent": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.form.SimpleForm": "sap/ui/layout/flexibility/SimpleForm",
"sap.ui.layout.Grid": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.FixFlex": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.form.Form": "sap/ui/layout/flexibility/Form",
"sap.ui.layout.form.FormContainer": "sap/ui/layout/flexibility/FormContainer",
"sap.ui.layout.form.FormElement": "sap/ui/layout/flexibility/FormElement",
"sap.ui.layout.HorizontalLayout": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.Splitter": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
},
"sap.ui.layout.VerticalLayout": {
"moveControls": "default",
"hideControl": "default",
"unhideControl": "default"
}
},
//Configuration used for rule loading of Support Assistant
"sap.ui.support": {
publicRules:true,
internalRules:true
}
}
});
/**
* Defines the functions that need to be implemented by a Control which wants
* to have display:grid behavior via sap.ui.layout.cssgrid.GridLayoutDelegate
*
* @since 1.60.0
* @public
* @interface
* @name sap.ui.layout.cssgrid.IGridConfigurable
*/
/**
* The function is used by GridLayoutDelegate to determine on which HTML Elements the display:grid styles should be applied
*
* @returns {sap.ui.core.Control[]|HTMLElement[]} The controls or HTML elements on which display:grid styles should be applied
* @since 1.60.0
* @public
* @function
* @name sap.ui.layout.cssgrid.IGridConfigurable.getGridDomRefs
*/
/**
* The function is used by GridLayoutDelegate to get the grid layout (display:grid styles) to apply
*
* @returns {sap.ui.layout.cssgrid.GridLayoutBase} The display:grid layout to apply
* @since 1.60.0
* @public
* @function
* @name sap.ui.layout.cssgrid.IGridConfigurable.getGridLayoutConfiguration
*/
/**
* Available Background Design.
*
* @enum {string}
* @public
* @since 1.36.0
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BackgroundDesign = {
/**
* A solid background color dependent on the theme.
* @public
*/
Solid : "Solid",
/**
* Transparent background.
* @public
*/
Transparent : "Transparent",
/**
* A translucent background depending on the opacity value of the theme.
* @public
*/
Translucent : "Translucent"
};
/**
* @classdesc
* A string type that represents the indent values of the <code>Grid</code> for large, medium and small screens.
*
* Allowed values are separated by space Letters L, M or S followed by number of columns from 1 to 11
* that the container has to take, for example: <code>L2 M4 S6</code>, <code>M11</code>, <code>s10</code>
* or <code>l4 m4</code>.
*
* <b>Note:</b> The parameters must be provided in the order <large medium small>.
*
* @final
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridIndent = DataType.createType('sap.ui.layout.GridIndent', {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[0-9]|1[0-1]))? ?([Ll](?:[0-9]|1[0-1]))? ?([Mm](?:[0-9]|1[0-1]))? ?([Ss](?:[0-9]|1[0-1]))?)$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* The position of the {@link sap.ui.layout.Grid}. Can be <code>Left</code> (default), <code>Center</code>
* or <code>Right</code>.
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridPosition = {
/**
* <code>Grid</code> is aligned left.
* @public
*/
Left : "Left",
/**
* <code>Grid</code> is aligned to the right.
* @public
*/
Right : "Right",
/**
* <code>Grid</code> is centered on the screen.
* @public
*/
Center : "Center"
};
/**
* @classdesc
* A string type that represents the span values of the <code>Grid</code> for large, medium and small screens.
*
* Allowed values are separated by space Letters L, M or S followed by number of columns from 1 to 12
* that the container has to take, for example: <code>L2 M4 S6</code>, <code>M12</code>,
* <code>s10</code> or <code>l4 m4</code>.
*
* <b>Note:</b> The parameters must be provided in the order <large medium small>.
*
* @final
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.GridSpan = DataType.createType('sap.ui.layout.GridSpan', {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[1-9]|1[0-2]))? ?([Ll](?:[1-9]|1[0-2]))? ?([Mm](?:[1-9]|1[0-2]))? ?([Ss](?:[1-9]|1[0-2]))?)$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* A string type that is used inside the BlockLayout to set predefined background color to the cells inside
* the control.
* @enum {string}
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockBackgroundType = {
/**
* Background is transparent
* @public
*/
Default: "Default",
/**
* Background is with predefined light colors
* @public
*/
Light: "Light",
/**
* Background with bright and dark background colors
* @deprecated since 1.50
* @public
*/
Mixed: "Mixed",
/**
* Background with pre-defined accent colors
* @public
*/
Accent: "Accent",
/**
* For applications that want to make use of e.g. charts in the Blocks, this layout type has spacings around the Blocks
* @public
*/
Dashboard: "Dashboard"
};
/**
* A string type that is used inside the BlockLayoutRow to set predefined set of colors the cells inside
* the control. Color sets depend on sap.ui.layout.BlockBackgroundType
*
* @enum {string}
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockRowColorSets = {
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 1
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 1
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 1
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet1: "ColorSet1",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 2
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 2
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 2
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet2: "ColorSet2",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 1
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 1
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 3
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet3: "ColorSet3",
/**
* sap.ui.layout.BlockBackgroundType.Default: N/A
* sap.ui.layout.BlockBackgroundType.Light: Color Set 2
* sap.ui.layout.BlockBackgroundType.Mixed: Color Set 2
* sap.ui.layout.BlockBackgroundType.Accent: Color Set 4
* sap.ui.layout.BlockBackgroundType.Dashboard: N/A
* @public
*/
ColorSet4: "ColorSet4"
};
/**
* A string type that is used inside the BlockLayoutCell to set a predefined set of colors for the cells.
*
* @enum {string}
* @public
* @since 1.48
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockLayoutCellColorSet = {
/**
* Color Set 1
*
* @public
*/
ColorSet1: "ColorSet1",
/**
* Color Set 2
*
* @public
*/
ColorSet2: "ColorSet2",
/**
* Color Set 3
*
* @public
*/
ColorSet3: "ColorSet3",
/**
* Color Set 4
*
* @public
*/
ColorSet4: "ColorSet4",
/**
* Color Set 5
*
* @public
*/
ColorSet5: "ColorSet5",
/**
* Color Set 6
*
* @public
*/
ColorSet6: "ColorSet6",
/**
* Color Set 7
*
* @public
*/
ColorSet7: "ColorSet7",
/**
* Color Set 8
*
* @public
*/
ColorSet8: "ColorSet8",
/**
* Color Set 9
*
* @public
*/
ColorSet9: "ColorSet9",
/**
* Color Set 10
*
* @public
*/
ColorSet10: "ColorSet10",
/**
* Color Set 11
*
* @public
*/
ColorSet11: "ColorSet11"
};
/**
* A string type that is used inside the BlockLayoutCell to set a predefined set of color shades for the cells.
* The colors are defined with sap.ui.layout.BlockLayoutCellColorSet. And this is for the shades only.
*
* @enum {string}
* @public
* @since 1.48
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BlockLayoutCellColorShade = {
/**
* Shade A
*
* @public
*/
ShadeA: "ShadeA",
/**
* Shade B
*
* @public
*/
ShadeB: "ShadeB",
/**
* Shade C
*
* @public
*/
ShadeC: "ShadeC",
/**
* Shade D
*
* @public
*/
ShadeD: "ShadeD",
/**
* Shade E - available only for Fiori 3 theme
*
* @public
*/
ShadeE: "ShadeE",
/**
* Shade F - available only for Fiori 3 theme
*
* @public
*/
ShadeF: "ShadeF"
};
sap.ui.layout.form = sap.ui.layout.form || {};
/**
* @classdesc A string that defines the number of used cells in a <code>GridLayout</code>. This can be a number from 1 to 16, "auto" or "full".
* If set to "auto" the size is determined by the number of fields and the available cells. For labels the auto size is 3 cells.
* If set to "full" only one field is allowed within the <code>FormElement</code>. It gets the full width of the row and the label is displayed above. <b>Note:</b> For labels full size has no effect.
*
* @namespace
* @public
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.GridElementCells = DataType.createType('sap.ui.layout.form.GridElementCells', {
isValid : function(vValue) {
return /^(auto|full|([1-9]|1[0-6]))$/.test(vValue);
}
},
DataType.getType('string')
);
/**
* Available <code>FormLayouts</code> used to render a <code>SimpleForm</code>.
*
* @enum {string}
* @public
* @since 1.16.0
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.SimpleFormLayout = {
/**
* Uses the <code>ResponsiveLayout</code> layout to render the <code>SimpleForm</code> control
* @public
*/
ResponsiveLayout : "ResponsiveLayout",
/**
* Uses the <code>GridLayout</code> layout to render the <code>SimpleForm</code> control
* @public
*/
GridLayout : "GridLayout",
/**
* Uses the <code>ResponsiveGridLayout</code> layout to render the <code>SimpleForm</code> control
* @public
* @since 1.16.0
*/
ResponsiveGridLayout : "ResponsiveGridLayout",
/**
* Uses the <code>ColumnLayout</code> layout to render the <code>SimpleForm</code> control
* @public
* @since 1.56.0
*/
ColumnLayout : "ColumnLayout"
};
/**
* Types of the DynamicSideContent Visibility options
*
* @enum {string}
* @public
* @since 1.30
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentVisibility = {
/**
* Show the side content on any breakpoint
* @public
*/
AlwaysShow: "AlwaysShow",
/**
* Show the side content on XL breakpoint
* @public
*/
ShowAboveL: "ShowAboveL",
/**
* Show the side content on L and XL breakpoints
* @public
*/
ShowAboveM: "ShowAboveM",
/**
* Show the side content on M, L and XL breakpoints
* @public
*/
ShowAboveS: "ShowAboveS",
/**
* Don't show the side content on any breakpoints
* @public
*/
NeverShow: "NeverShow"
};
/**
* Types of the DynamicSideContent FallDown options
*
* @enum {string}
* @public
* @since 1.30
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentFallDown = {
/**
* Side content falls down on breakpoints below XL
* @public
*/
BelowXL: "BelowXL",
/**
* Side content falls down on breakpoints below L
* @public
*/
BelowL: "BelowL",
/**
* Side content falls down on breakpoints below M
* @public
*/
BelowM: "BelowM",
/**
* Side content falls down on breakpoint M and the minimum width for the side content
* @public
*/
OnMinimumWidth: "OnMinimumWidth"
};
/**
* The position of the side content - End (default) and Begin.
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.SideContentPosition = {
/**
* The side content is on the right side of the main container in left-to-right mode and on the left side in right-to-left mode.
* @public
*/
End : "End",
/**
* The side content is on the left side of the main container in left-to-right mode and on the right side in right-to-left mode.
* @public
*/
Begin : "Begin"
};
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has extra-large size
*
* Allowed values are numbers from 1 to 4.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsXL = DataType.createType('sap.ui.layout.form.ColumnsXL', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 4) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has large size
*
* Allowed values are numbers from 1 to 3.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsL = DataType.createType('sap.ui.layout.form.ColumnsL', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 3) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many columns a <code>Form</code> control using
* the <code>ColumnLayout</code> as layout can have if it has medium size
*
* Allowed values are numbers from 1 to 2.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnsM = DataType.createType('sap.ui.layout.form.ColumnsM', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 2) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many cells a control inside of a column
* of a <code>Form</code> control using the <code>ColumnLayout</code> control as layout can use.
*
* Allowed values are numbers from 1 to 12.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.ColumnCells = DataType.createType('sap.ui.layout.form.ColumnCells', {
isValid : function(vValue) {
if (vValue > 0 && vValue <= 12) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
/**
* @classdesc An <code>int</code> type that defines how many cells beside the controls
* inside of a column of a <code>Form</code> control using the <code>ColumnLayout</code> control as layout
* are empty.
*
* Allowed values are numbers from 0 to 11.
*
* @final
* @namespace
* @public
* @since 1.56.0
* @ui5-metamodel This simple type also will be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.form.EmptyCells = DataType.createType('sap.ui.layout.form.EmptyCells', {
isValid : function(vValue) {
if (vValue >= 0 && vValue < 12) {
return true;
} else {
return false;
}
}
},
DataType.getType('int')
);
// factory for Form to create labels and buttons to be overwritten by commons and mobile library
if (!sap.ui.layout.form.FormHelper) {
sap.ui.layout.form.FormHelper = {
createLabel: function(sText){ throw new Error("no Label control available!"); }, /* must return a Label control */
createButton: function(sId, fPressFunction, fnCallback){ throw new Error("no Button control available!"); }, /* must return a button control */
setButtonContent: function(oButton, sText, sTooltip, sIcon, sIconHovered){ throw new Error("no Button control available!"); },
addFormClass: function(){ return null; },
setToolbar: function(oToolbar){ return oToolbar; }, /* allow to overwrite toolbar settings */
bArrowKeySupport: true, /* enables the keyboard support for arrow keys */
bFinal: false /* if true, the helper must not be overwritten by an other library */
};
}
if (!sap.ui.layout.GridHelper) {
sap.ui.layout.GridHelper = {
getLibrarySpecificClass: function () {
return "";
},
bFinal: false /* if true, the helper must not be overwritten by an other library */
};
}
/**
* @classdesc A string type that represents a grid track (the space between two grid lines)
*
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Grid_tracks}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridTrack = DataType.createType("sap.ui.layout.cssgrid.CSSGridTrack", {
isValid: function (sValue) {
var sCSSSizeRegex = /(auto|inherit|(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%))|calc\(\s*(\(\s*)*[-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%)?)(\s*(\)\s*)*(\s[-+]\s|[*\/])\s*(\(\s*)*([-+]?(([0-9]+|[0-9]*\.[0-9]+)([rR][eE][mM]|[eE][mM]|[eE][xX]|[pP][xX]|[cC][mM]|[mM][mM]|[iI][nN]|[pP][tT]|[pP][cC]|[vV][wW]|[vV][hH]|[vV][mM][iI][nN]|[vV][mM][aA][xX]|%)?)))*\s*(\)\s*)*\))/g;
// Remove valid keywords that can be used as part of a grid track property value
sValue = sValue.replace(/(minmax|repeat|fit-content|max-content|min-content|auto-fill|auto-fit|fr|min|max)/g, "");
// Remove valid CSSSizes
sValue = sValue.replace(sCSSSizeRegex, "");
// Remove expression syntax
sValue = sValue.replace(/\(|\)|\+|\-|\*|\/|calc|\%|\,/g, "");
// Remove any number leftovers which are not CSSSizes
sValue = sValue.replace(/[0-9]/g, "");
// Remove whitespace
sValue = sValue.replace(/\s/g, "");
return sValue.length === 0;
},
parseValue: function (sValue) {
return sValue.trim().split(/\s+/).join(" ");
}
},
DataType.getType("string")
);
/**
* @classdesc A string type that represents a short hand CSS grid gap.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/gap}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridGapShortHand = DataType.createType("sap.ui.layout.cssgrid.CSSGridGapShortHand", {
isValid: function (vValue) {
var bResult = true,
aValues = vValue.split(/\s+/);
aValues.forEach(function (sValue) {
if (!library.CSSSize.isValid(sValue)) {
bResult = false;
}
});
return bResult;
},
parseValue: function (sValue) {
return sValue.trim().split(/\s+/).join(" ");
}
},
DataType.getType("string")
);
/**
* @classdesc A string type that represents one or two grid lines. Used to define the position and size of a single grid item.
*
* Valid values:
* <ul>
* <li>auto</li>
* <li>inherit</li>
* <li>1</li>
* <li>span 2</li>
* <li>span 2 / 5</li>
* <li>span 2 / -5</li>
* <li>5 / 7</li>
* <li>7 / span 5</li>
* <li>span 7 / span 5</li>
* </ul>
*
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Grid_lines MDN web docs: grid lines}
* @since 1.60.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridLine = DataType.createType("sap.ui.layout.cssgrid.CSSGridLine", {
isValid: function (sValue) {
return /^(auto|inherit|((span)?(\s)?-?[0-9]+(\s\/\s(span)?(\s)?-?[0-9]*)?)?)$/.test(sValue);
}
},
DataType.getType("string")
);
/**
* A string type that is used for CSS grid to control how the auto-placement algorithm works,
* specifying exactly how auto-placed items get flowed into the grid.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow}
* @enum {string}
* @since 1.60.0
* @public
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.cssgrid.CSSGridAutoFlow = {
/**
* Insert auto-placed items by filling each row.
* @public
*/
Row: "Row",
/**
* Insert auto-placed items by filling each column.
* @public
*/
Column: "Column",
/**
* Insert auto-placed items by filling each row, and fill any holes in the grid.
* @public
*/
RowDense: "RowDense",
/**
* Insert auto-placed items by filling each column, and fill any holes in the grid.
* @public
*/
ColumnDense: "ColumnDense"
};
/**
* @classdesc A string type that represents how many boxes per row should be displayed for each screen size. The breakpoints are for extra large (XL), large (L), medium (M) and small (S) screen sizes.
*
* <b>Note:</b> The parameters must be provided in the order <XL L M S>.
*
* @example <code>XL7 L6 M4 S2</code>
* @example <code>XL12 L12 M12 S1</code>
* @since 1.61.0
* @public
* @namespace
* @final
* @ui5-metamodel This simple type will also be described in the UI5 (legacy) designtime metamodel
*/
sap.ui.layout.BoxesPerRowConfig = DataType.createType("sap.ui.layout.BoxesPerRowConfig", {
isValid : function(vValue) {
return /^(([Xx][Ll](?:[1-9]|1[0-2]))? ?([Ll](?:[1-9]|1[0-2]))? ?([Mm](?:[1-9]|1[0-2]))? ?([Ss](?:[1-9]|1[0-2]))?)$/.test(vValue);
}
},
DataType.getType("string")
);
return sap.ui.layout;
} | [
"function",
"(",
"DataType",
",",
"library",
")",
"{",
"\"use strict\"",
";",
"/**\n\t * SAPUI5 library with layout controls.\n\t *\n\t * @namespace\n\t * @name sap.ui.layout\n\t * @author SAP SE\n\t * @version ${version}\n\t * @public\n\t */",
"// delegate further initialization of this library... | library dependency | [
"library",
"dependency"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.layout/src/sap/ui/layout/library.js#L11-L945 | train | The sap. ui. layout library provides a control that can be used to control the layout. | [
30522,
3853,
1006,
2951,
13874,
1010,
3075,
1007,
1063,
1000,
2224,
9384,
1000,
1025,
1013,
1008,
1008,
1008,
20066,
10179,
2629,
3075,
2007,
9621,
7711,
1012,
1008,
1008,
1030,
3415,
15327,
1008,
1030,
2171,
20066,
1012,
21318,
1012,
9621,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/parse/parsePage.js | parsePage | function parsePage(book, page) {
var fs = book.getContentFS();
var file = page.getFile();
return fs.readAsString(file.getPath())
.then(function(content) {
return parsePageFromString(page, content);
});
} | javascript | function parsePage(book, page) {
var fs = book.getContentFS();
var file = page.getFile();
return fs.readAsString(file.getPath())
.then(function(content) {
return parsePageFromString(page, content);
});
} | [
"function",
"parsePage",
"(",
"book",
",",
"page",
")",
"{",
"var",
"fs",
"=",
"book",
".",
"getContentFS",
"(",
")",
";",
"var",
"file",
"=",
"page",
".",
"getFile",
"(",
")",
";",
"return",
"fs",
".",
"readAsString",
"(",
"file",
".",
"getPath",
... | Parse a page, read its content and parse the YAMl header
@param {Book} book
@param {Page} page
@return {Promise<Page>} | [
"Parse",
"a",
"page",
"read",
"its",
"content",
"and",
"parse",
"the",
"YAMl",
"header"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parsePage.js#L10-L18 | train | Parse a page | [
30522,
3853,
11968,
3366,
13704,
1006,
2338,
1010,
3931,
1007,
1063,
13075,
1042,
2015,
1027,
2338,
1012,
2131,
8663,
6528,
24475,
2015,
1006,
1007,
1025,
13075,
5371,
1027,
3931,
1012,
2131,
8873,
2571,
1006,
1007,
1025,
2709,
1042,
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... |
adobe/brackets | src/extensions/default/CodeFolding/foldhelpers/foldgutter.js | onUnFold | function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
} | javascript | function onUnFold(cm, from, to) {
var state = cm.state.foldGutter;
var vp = cm.getViewport();
delete cm._lineFolds[from.line];
updateFoldInfo(cm, from.line, to.line || vp.to);
} | [
"function",
"onUnFold",
"(",
"cm",
",",
"from",
",",
"to",
")",
"{",
"var",
"state",
"=",
"cm",
".",
"state",
".",
"foldGutter",
";",
"var",
"vp",
"=",
"cm",
".",
"getViewport",
"(",
")",
";",
"delete",
"cm",
".",
"_lineFolds",
"[",
"from",
".",
... | Triggered when a folded code segment is unfolded.
@param {!CodeMirror} cm the CodeMirror instance for the active editor
@param {!{line:number, ch:number}} from the ch and line position that designates the start of the region
@param {!{line:number, ch:number}} to the ch and line position that designates the end of the region | [
"Triggered",
"when",
"a",
"folded",
"code",
"segment",
"is",
"unfolded",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L354-L359 | train | Unfolds the line from to to. | [
30522,
3853,
2006,
4609,
10371,
1006,
4642,
1010,
2013,
1010,
2000,
1007,
1063,
13075,
2110,
1027,
4642,
1012,
2110,
1012,
10671,
27920,
3334,
1025,
13075,
21210,
1027,
4642,
1012,
2131,
8584,
6442,
1006,
1007,
1025,
3972,
12870,
4642,
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... |
airbnb/enzyme | packages/enzyme/src/selectors.js | matchGeneralSibling | function matchGeneralSibling(nodes, predicate, root) {
return uniqueReduce((matches, node) => {
const parent = findParentNode(root, node);
if (!parent) {
return matches;
}
const parentChildren = childrenOfNode(parent);
const nodeIndex = parentChildren.indexOf(node);
const youngerSiblings = parentChildren.slice(nodeIndex + 1);
return matches.concat(youngerSiblings.filter(predicate));
}, nodes);
} | javascript | function matchGeneralSibling(nodes, predicate, root) {
return uniqueReduce((matches, node) => {
const parent = findParentNode(root, node);
if (!parent) {
return matches;
}
const parentChildren = childrenOfNode(parent);
const nodeIndex = parentChildren.indexOf(node);
const youngerSiblings = parentChildren.slice(nodeIndex + 1);
return matches.concat(youngerSiblings.filter(predicate));
}, nodes);
} | [
"function",
"matchGeneralSibling",
"(",
"nodes",
",",
"predicate",
",",
"root",
")",
"{",
"return",
"uniqueReduce",
"(",
"(",
"matches",
",",
"node",
")",
"=>",
"{",
"const",
"parent",
"=",
"findParentNode",
"(",
"root",
",",
"node",
")",
";",
"if",
"(",... | Matches only nodes which are general siblings (any sibling *after*)
against a predicate, returning those that match.
@param {Array<Node>} nodes
@param {Function} predicate
@param {Node} root | [
"Matches",
"only",
"nodes",
"which",
"are",
"general",
"siblings",
"(",
"any",
"sibling",
"*",
"after",
"*",
")",
"against",
"a",
"predicate",
"returning",
"those",
"that",
"match",
"."
] | cd430eae95eba151f17e970ee77c18f09476de0e | https://github.com/airbnb/enzyme/blob/cd430eae95eba151f17e970ee77c18f09476de0e/packages/enzyme/src/selectors.js#L329-L340 | train | Match a node with a predicate function on all siblings of the node | [
30522,
3853,
2674,
6914,
21673,
5332,
9709,
1006,
14164,
1010,
3653,
16467,
1010,
7117,
1007,
1063,
2709,
4310,
5596,
18796,
1006,
1006,
3503,
1010,
13045,
1007,
1027,
1028,
1063,
9530,
3367,
6687,
1027,
2424,
19362,
4765,
3630,
3207,
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... |
fex-team/webuploader | src/runtime/html5/image.js | detectSubsampling | function detectSubsampling( img ) {
var iw = img.naturalWidth,
ih = img.naturalHeight,
canvas, ctx;
// subsampling may happen overmegapixel image
if ( iw * ih > 1024 * 1024 ) {
canvas = document.createElement('canvas');
canvas.width = canvas.height = 1;
ctx = canvas.getContext('2d');
ctx.drawImage( img, -iw + 1, 0 );
// subsampled image becomes half smaller in rendering size.
// check alpha channel value to confirm image is covering
// edge pixel or not. if alpha value is 0
// image is not covering, hence subsampled.
return ctx.getImageData( 0, 0, 1, 1 ).data[ 3 ] === 0;
} else {
return false;
}
} | javascript | function detectSubsampling( img ) {
var iw = img.naturalWidth,
ih = img.naturalHeight,
canvas, ctx;
// subsampling may happen overmegapixel image
if ( iw * ih > 1024 * 1024 ) {
canvas = document.createElement('canvas');
canvas.width = canvas.height = 1;
ctx = canvas.getContext('2d');
ctx.drawImage( img, -iw + 1, 0 );
// subsampled image becomes half smaller in rendering size.
// check alpha channel value to confirm image is covering
// edge pixel or not. if alpha value is 0
// image is not covering, hence subsampled.
return ctx.getImageData( 0, 0, 1, 1 ).data[ 3 ] === 0;
} else {
return false;
}
} | [
"function",
"detectSubsampling",
"(",
"img",
")",
"{",
"var",
"iw",
"=",
"img",
".",
"naturalWidth",
",",
"ih",
"=",
"img",
".",
"naturalHeight",
",",
"canvas",
",",
"ctx",
";",
"// subsampling may happen overmegapixel image",
"if",
"(",
"iw",
"*",
"ih",
">"... | Detect subsampling in loaded image.
In iOS, larger images than 2M pixels may be
subsampled in rendering. | [
"Detect",
"subsampling",
"in",
"loaded",
"image",
".",
"In",
"iOS",
"larger",
"images",
"than",
"2M",
"pixels",
"may",
"be",
"subsampled",
"in",
"rendering",
"."
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/src/runtime/html5/image.js#L366-L386 | train | detect if image is subsampled | [
30522,
3853,
11487,
6342,
5910,
16613,
2989,
1006,
10047,
2290,
1007,
1063,
13075,
1045,
2860,
1027,
10047,
2290,
1012,
3019,
9148,
11927,
2232,
1010,
1045,
2232,
1027,
10047,
2290,
1012,
3019,
26036,
13900,
1010,
10683,
1010,
14931,
2595,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | scanPunctuator | function scanPunctuator() {
var start = index,
code = source.charCodeAt(index),
code2,
ch1 = source[index],
ch2,
ch3,
ch4;
switch (code) {
// Check for most common single-character punctuators.
case 0x2E: // . dot
case 0x28: // ( open bracket
case 0x29: // ) close bracket
case 0x3B: // ; semicolon
case 0x2C: // , comma
case 0x7B: // { open curly brace
case 0x7D: // } close curly brace
case 0x5B: // [
case 0x5D: // ]
case 0x3A: // :
case 0x3F: // ?
case 0x7E: // ~
++index;
if (extra.tokenize) {
if (code === 0x28) {
extra.openParenToken = extra.tokens.length;
} else if (code === 0x7B) {
extra.openCurlyToken = extra.tokens.length;
}
}
return {
type: Token.Punctuator,
value: String.fromCharCode(code),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
default:
code2 = source.charCodeAt(index + 1);
// '=' (U+003D) marks an assignment or comparison operator.
if (code2 === 0x3D) {
switch (code) {
case 0x2B: // +
case 0x2D: // -
case 0x2F: // /
case 0x3C: // <
case 0x3E: // >
case 0x5E: // ^
case 0x7C: // |
case 0x25: // %
case 0x26: // &
case 0x2A: // *
index += 2;
return {
type: Token.Punctuator,
value: String.fromCharCode(code) + String.fromCharCode(code2),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
case 0x21: // !
case 0x3D: // =
index += 2;
// !== and ===
if (source.charCodeAt(index) === 0x3D) {
++index;
}
return {
type: Token.Punctuator,
value: source.slice(start, index),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
}
}
// 4-character punctuator: >>>=
ch4 = source.substr(index, 4);
if (ch4 === '>>>=') {
index += 4;
return {
type: Token.Punctuator,
value: ch4,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// 3-character punctuators: === !== >>> <<= >>=
ch3 = ch4.substr(0, 3);
if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') {
index += 3;
return {
type: Token.Punctuator,
value: ch3,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// Other 2-character punctuators: ++ -- << >> && ||
ch2 = ch3.substr(0, 2);
if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') {
index += 2;
return {
type: Token.Punctuator,
value: ch2,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// 1-character punctuators: < > = ! + - * % & | ^ /
if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
++index;
return {
type: Token.Punctuator,
value: ch1,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
} | javascript | function scanPunctuator() {
var start = index,
code = source.charCodeAt(index),
code2,
ch1 = source[index],
ch2,
ch3,
ch4;
switch (code) {
// Check for most common single-character punctuators.
case 0x2E: // . dot
case 0x28: // ( open bracket
case 0x29: // ) close bracket
case 0x3B: // ; semicolon
case 0x2C: // , comma
case 0x7B: // { open curly brace
case 0x7D: // } close curly brace
case 0x5B: // [
case 0x5D: // ]
case 0x3A: // :
case 0x3F: // ?
case 0x7E: // ~
++index;
if (extra.tokenize) {
if (code === 0x28) {
extra.openParenToken = extra.tokens.length;
} else if (code === 0x7B) {
extra.openCurlyToken = extra.tokens.length;
}
}
return {
type: Token.Punctuator,
value: String.fromCharCode(code),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
default:
code2 = source.charCodeAt(index + 1);
// '=' (U+003D) marks an assignment or comparison operator.
if (code2 === 0x3D) {
switch (code) {
case 0x2B: // +
case 0x2D: // -
case 0x2F: // /
case 0x3C: // <
case 0x3E: // >
case 0x5E: // ^
case 0x7C: // |
case 0x25: // %
case 0x26: // &
case 0x2A: // *
index += 2;
return {
type: Token.Punctuator,
value: String.fromCharCode(code) + String.fromCharCode(code2),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
case 0x21: // !
case 0x3D: // =
index += 2;
// !== and ===
if (source.charCodeAt(index) === 0x3D) {
++index;
}
return {
type: Token.Punctuator,
value: source.slice(start, index),
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
}
}
// 4-character punctuator: >>>=
ch4 = source.substr(index, 4);
if (ch4 === '>>>=') {
index += 4;
return {
type: Token.Punctuator,
value: ch4,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// 3-character punctuators: === !== >>> <<= >>=
ch3 = ch4.substr(0, 3);
if (ch3 === '>>>' || ch3 === '<<=' || ch3 === '>>=') {
index += 3;
return {
type: Token.Punctuator,
value: ch3,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// Other 2-character punctuators: ++ -- << >> && ||
ch2 = ch3.substr(0, 2);
if ((ch1 === ch2[1] && ('+-<>&|'.indexOf(ch1) >= 0)) || ch2 === '=>') {
index += 2;
return {
type: Token.Punctuator,
value: ch2,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
// 1-character punctuators: < > = ! + - * % & | ^ /
if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
++index;
return {
type: Token.Punctuator,
value: ch1,
lineNumber: lineNumber,
lineStart: lineStart,
start: start,
end: index
};
}
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
} | [
"function",
"scanPunctuator",
"(",
")",
"{",
"var",
"start",
"=",
"index",
",",
"code",
"=",
"source",
".",
"charCodeAt",
"(",
"index",
")",
",",
"code2",
",",
"ch1",
"=",
"source",
"[",
"index",
"]",
",",
"ch2",
",",
"ch3",
",",
"ch4",
";",
"switc... | 7.7 Punctuators | [
"7",
".",
"7",
"Punctuators"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L639-L787 | train | Scan for a single - character punctuator. | [
30522,
3853,
13594,
14289,
12273,
26302,
4263,
1006,
1007,
1063,
13075,
2707,
1027,
5950,
1010,
3642,
1027,
3120,
1012,
25869,
16044,
4017,
1006,
5950,
1007,
1010,
3642,
2475,
1010,
10381,
2487,
1027,
3120,
1031,
5950,
1033,
1010,
10381,
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... |
angular/protractor | lib/clientsidescripts.js | function(callback) {
if (window.angular) {
var hooks = getNg1Hooks(rootSelector);
if (!hooks){
callback(); // not an angular1 app
}
else{
if (hooks.$$testability) {
hooks.$$testability.whenStable(callback);
} else if (hooks.$injector) {
hooks.$injector.get('$browser')
.notifyWhenNoOutstandingRequests(callback);
} else if (!rootSelector) {
throw new Error(
'Could not automatically find injector on page: "' +
window.location.toString() + '". Consider using config.rootEl');
} else {
throw new Error(
'root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
}
}
else {callback();} // not an angular1 app
} | javascript | function(callback) {
if (window.angular) {
var hooks = getNg1Hooks(rootSelector);
if (!hooks){
callback(); // not an angular1 app
}
else{
if (hooks.$$testability) {
hooks.$$testability.whenStable(callback);
} else if (hooks.$injector) {
hooks.$injector.get('$browser')
.notifyWhenNoOutstandingRequests(callback);
} else if (!rootSelector) {
throw new Error(
'Could not automatically find injector on page: "' +
window.location.toString() + '". Consider using config.rootEl');
} else {
throw new Error(
'root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
}
}
else {callback();} // not an angular1 app
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"window",
".",
"angular",
")",
"{",
"var",
"hooks",
"=",
"getNg1Hooks",
"(",
"rootSelector",
")",
";",
"if",
"(",
"!",
"hooks",
")",
"{",
"callback",
"(",
")",
";",
"// not an angular1 app",
"}",
"else"... | Wait for angular1 testability first and run waitForAngular2 as a callback | [
"Wait",
"for",
"angular1",
"testability",
"first",
"and",
"run",
"waitForAngular2",
"as",
"a",
"callback"
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/lib/clientsidescripts.js#L143-L168 | train | get the injector | [
30522,
3853,
1006,
2655,
5963,
1007,
1063,
2065,
1006,
3332,
1012,
16108,
1007,
1063,
13075,
18008,
1027,
2131,
3070,
2487,
6806,
6559,
2015,
1006,
6147,
12260,
16761,
1007,
1025,
2065,
1006,
999,
18008,
1007,
1063,
2655,
5963,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/QUnitUtils.js | fakeEvent | function fakeEvent(sEventName, oTarget, oParams) {
var oEvent = jQuery.Event({type : sEventName});
if ( oTarget != null ) {
oEvent.target = oTarget;
}
if (oParams) {
for (var x in oParams) {
// propagate property to event
oEvent[x] = oParams[x];
if ( x === 'originalEvent' ) {
// if 'originalEvent' has been changed, fix it
fixOriginalEvent(oEvent[x]);
} else {
// otherwise propagate property to 'originalEvent' as well
oEvent.originalEvent[x] = oParams[x];
}
}
}
return oEvent;
} | javascript | function fakeEvent(sEventName, oTarget, oParams) {
var oEvent = jQuery.Event({type : sEventName});
if ( oTarget != null ) {
oEvent.target = oTarget;
}
if (oParams) {
for (var x in oParams) {
// propagate property to event
oEvent[x] = oParams[x];
if ( x === 'originalEvent' ) {
// if 'originalEvent' has been changed, fix it
fixOriginalEvent(oEvent[x]);
} else {
// otherwise propagate property to 'originalEvent' as well
oEvent.originalEvent[x] = oParams[x];
}
}
}
return oEvent;
} | [
"function",
"fakeEvent",
"(",
"sEventName",
",",
"oTarget",
",",
"oParams",
")",
"{",
"var",
"oEvent",
"=",
"jQuery",
".",
"Event",
"(",
"{",
"type",
":",
"sEventName",
"}",
")",
";",
"if",
"(",
"oTarget",
"!=",
"null",
")",
"{",
"oEvent",
".",
"targ... | /*
Creates a fake event of type jQuery.Event, according to current UI5 practices; it will always
contain a pseudo browser event (property <code>originalEvent</code>).
Please note that the <code>originalEvent</code> could be created as a native browser event (class <code>Event</code>)
as some existing test cases specify a <code>target</code> property which is readonly in the <code>Event</code> class.
Any given <code>oParams</code> are added to the new <code>jQuery.Event</code> as well as to its <code>originalEvent</code>
object. To be compatible with older versions, this function does not propagate properties to <code>originalEvent</code> when
they are given before an eventual <code>originalEvent</code> property in <code>oParams</code>.
@param {string} sEventName mandatory name (type) of the newly created event
@param {DOMElement} [oTarget] optional target of the event
@param {object} [oParams] optional map of properties to be added to the event | [
"/",
"*",
"Creates",
"a",
"fake",
"event",
"of",
"type",
"jQuery",
".",
"Event",
"according",
"to",
"current",
"UI5",
"practices",
";",
"it",
"will",
"always",
"contain",
"a",
"pseudo",
"browser",
"event",
"(",
"property",
"<code",
">",
"originalEvent<",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/QUnitUtils.js#L259-L283 | train | fakeEvent - creates a fake event | [
30522,
3853,
8275,
18697,
3372,
1006,
2698,
2102,
18442,
1010,
27178,
2906,
18150,
1010,
6728,
5400,
5244,
1007,
1063,
13075,
1051,
18697,
3372,
1027,
1046,
4226,
2854,
1012,
2724,
1006,
1063,
2828,
1024,
2698,
2102,
18442,
1065,
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... |
babel/babel | packages/babel-standalone/src/transformScriptTags.js | loadScripts | function loadScripts(transformFn, scripts) {
const result = [];
const count = scripts.length;
function check() {
let script, i;
for (i = 0; i < count; i++) {
script = result[i];
if (script.loaded && !script.executed) {
script.executed = true;
run(transformFn, script);
} else if (!script.loaded && !script.error && !script.async) {
break;
}
}
}
scripts.forEach((script, i) => {
const scriptData = {
// script.async is always true for non-JavaScript script tags
async: script.hasAttribute("async"),
error: false,
executed: false,
plugins: getPluginsOrPresetsFromScript(script, "data-plugins"),
presets: getPluginsOrPresetsFromScript(script, "data-presets"),
};
if (script.src) {
result[i] = {
...scriptData,
content: null,
loaded: false,
url: script.src,
};
load(
script.src,
content => {
result[i].loaded = true;
result[i].content = content;
check();
},
() => {
result[i].error = true;
check();
},
);
} else {
result[i] = {
...scriptData,
content: script.innerHTML,
loaded: true,
url: script.getAttribute("data-module") || null,
};
}
});
check();
} | javascript | function loadScripts(transformFn, scripts) {
const result = [];
const count = scripts.length;
function check() {
let script, i;
for (i = 0; i < count; i++) {
script = result[i];
if (script.loaded && !script.executed) {
script.executed = true;
run(transformFn, script);
} else if (!script.loaded && !script.error && !script.async) {
break;
}
}
}
scripts.forEach((script, i) => {
const scriptData = {
// script.async is always true for non-JavaScript script tags
async: script.hasAttribute("async"),
error: false,
executed: false,
plugins: getPluginsOrPresetsFromScript(script, "data-plugins"),
presets: getPluginsOrPresetsFromScript(script, "data-presets"),
};
if (script.src) {
result[i] = {
...scriptData,
content: null,
loaded: false,
url: script.src,
};
load(
script.src,
content => {
result[i].loaded = true;
result[i].content = content;
check();
},
() => {
result[i].error = true;
check();
},
);
} else {
result[i] = {
...scriptData,
content: script.innerHTML,
loaded: true,
url: script.getAttribute("data-module") || null,
};
}
});
check();
} | [
"function",
"loadScripts",
"(",
"transformFn",
",",
"scripts",
")",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"const",
"count",
"=",
"scripts",
".",
"length",
";",
"function",
"check",
"(",
")",
"{",
"let",
"script",
",",
"i",
";",
"for",
"(",
"i",... | Loop over provided script tags and get the content, via innerHTML if an
inline script, or by using XHR. Transforms are applied if needed. The scripts
are executed in the order they are found on the page. | [
"Loop",
"over",
"provided",
"script",
"tags",
"and",
"get",
"the",
"content",
"via",
"innerHTML",
"if",
"an",
"inline",
"script",
"or",
"by",
"using",
"XHR",
".",
"Transforms",
"are",
"applied",
"if",
"needed",
".",
"The",
"scripts",
"are",
"executed",
"in... | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-standalone/src/transformScriptTags.js#L110-L170 | train | Load scripts from a list of scripts | [
30522,
3853,
15665,
23235,
2015,
1006,
10938,
2546,
2078,
1010,
14546,
1007,
1063,
9530,
3367,
2765,
1027,
1031,
1033,
1025,
9530,
3367,
4175,
1027,
14546,
1012,
3091,
1025,
3853,
4638,
1006,
1007,
1063,
2292,
5896,
1010,
1045,
1025,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Microsoft/vscode | build/lib/watch/index.js | handleDeletions | function handleDeletions() {
return es.mapSync(f => {
if (/\.ts$/.test(f.relative) && !f.contents) {
f.contents = Buffer.from('');
f.stat = { mtime: new Date() };
}
return f;
});
} | javascript | function handleDeletions() {
return es.mapSync(f => {
if (/\.ts$/.test(f.relative) && !f.contents) {
f.contents = Buffer.from('');
f.stat = { mtime: new Date() };
}
return f;
});
} | [
"function",
"handleDeletions",
"(",
")",
"{",
"return",
"es",
".",
"mapSync",
"(",
"f",
"=>",
"{",
"if",
"(",
"/",
"\\.ts$",
"/",
".",
"test",
"(",
"f",
".",
"relative",
")",
"&&",
"!",
"f",
".",
"contents",
")",
"{",
"f",
".",
"contents",
"=",
... | Ugly hack for gulp-tsb | [
"Ugly",
"hack",
"for",
"gulp",
"-",
"tsb"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/watch/index.js#L9-L18 | train | Handle deletion of files | [
30522,
3853,
8971,
12260,
9285,
1006,
1007,
1063,
2709,
9686,
1012,
7341,
6038,
2278,
1006,
1042,
1027,
1028,
1063,
2065,
1006,
1013,
1032,
1012,
24529,
1002,
1013,
1012,
3231,
1006,
1042,
1012,
5816,
1007,
1004,
1004,
999,
1042,
1012,
84... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LiveDevMultiBrowser.js | init | function init(config) {
exports.config = config;
MainViewManager
.on("currentFileChange", _onFileChange);
DocumentManager
.on("documentSaved", _onDocumentSaved)
.on("dirtyFlagChange", _onDirtyFlagChange);
ProjectManager
.on("beforeProjectClose beforeAppClose", close);
// Default transport for live connection messages - can be changed
setTransport(NodeSocketTransport);
// Default launcher for preview browser - can be changed
setLauncher(DefaultLauncher);
// Initialize exports.status
_setStatus(STATUS_INACTIVE);
} | javascript | function init(config) {
exports.config = config;
MainViewManager
.on("currentFileChange", _onFileChange);
DocumentManager
.on("documentSaved", _onDocumentSaved)
.on("dirtyFlagChange", _onDirtyFlagChange);
ProjectManager
.on("beforeProjectClose beforeAppClose", close);
// Default transport for live connection messages - can be changed
setTransport(NodeSocketTransport);
// Default launcher for preview browser - can be changed
setLauncher(DefaultLauncher);
// Initialize exports.status
_setStatus(STATUS_INACTIVE);
} | [
"function",
"init",
"(",
"config",
")",
"{",
"exports",
".",
"config",
"=",
"config",
";",
"MainViewManager",
".",
"on",
"(",
"\"currentFileChange\"",
",",
"_onFileChange",
")",
";",
"DocumentManager",
".",
"on",
"(",
"\"documentSaved\"",
",",
"_onDocumentSaved"... | Initialize the LiveDevelopment module. | [
"Initialize",
"the",
"LiveDevelopment",
"module",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L818-L836 | train | Initialize the application | [
30522,
3853,
1999,
4183,
1006,
9530,
8873,
2290,
1007,
1063,
14338,
1012,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1025,
2364,
8584,
24805,
4590,
1012,
2006,
1006,
1000,
2783,
8873,
2571,
22305,
2063,
1000,
1010,
1035,
2006,
8873,
2571,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxArrowConnector | function mxArrowConnector(points, fill, stroke, strokewidth, arrowWidth, spacing, endSize)
{
mxShape.call(this);
this.points = points;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
this.arrowWidth = (arrowWidth != null) ? arrowWidth : mxConstants.ARROW_WIDTH;
this.arrowSpacing = (spacing != null) ? spacing : mxConstants.ARROW_SPACING;
this.startSize = mxConstants.ARROW_SIZE / 5;
this.endSize = mxConstants.ARROW_SIZE / 5;
} | javascript | function mxArrowConnector(points, fill, stroke, strokewidth, arrowWidth, spacing, endSize)
{
mxShape.call(this);
this.points = points;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
this.arrowWidth = (arrowWidth != null) ? arrowWidth : mxConstants.ARROW_WIDTH;
this.arrowSpacing = (spacing != null) ? spacing : mxConstants.ARROW_SPACING;
this.startSize = mxConstants.ARROW_SIZE / 5;
this.endSize = mxConstants.ARROW_SIZE / 5;
} | [
"function",
"mxArrowConnector",
"(",
"points",
",",
"fill",
",",
"stroke",
",",
"strokewidth",
",",
"arrowWidth",
",",
"spacing",
",",
"endSize",
")",
"{",
"mxShape",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"points",
"=",
"points",
";",
"this",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxArrowConnector
Extends <mxShape> to implement an new rounded arrow shape with support for
waypoints and double arrows. (The shape is used to represent edges, not
vertices.) This shape is registered under <mxConstants.SHAPE_ARROW_CONNECTOR>
in <mxCellRenderer>.
Constructor: mxArrowConnector
Constructs a new arrow shape.
Parameters:
points - Array of <mxPoints> that define the points. This is stored in
<mxShape.points>.
fill - String that defines the fill color. This is stored in <fill>.
stroke - String that defines the stroke color. This is stored in <stroke>.
strokewidth - Optional integer that defines the stroke width. Default is
1. This is stored in <strokewidth>.
arrowWidth - Optional integer that defines the arrow width. Default is
<mxConstants.ARROW_WIDTH>. This is stored in <arrowWidth>.
spacing - Optional integer that defines the spacing between the arrow shape
and its endpoints. Default is <mxConstants.ARROW_SPACING>. This is stored in
<spacing>.
endSize - Optional integer that defines the size of the arrowhead. Default
is <mxConstants.ARROW_SIZE>. This is stored in <endSize>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxArrowConnector"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L25585-L25596 | train | A wrapper around mxShape to create an arrow connector | [
30522,
3853,
25630,
2906,
10524,
8663,
2638,
16761,
1006,
2685,
1010,
6039,
1010,
6909,
1010,
6909,
9148,
11927,
2232,
1010,
8612,
9148,
11927,
2232,
1010,
12403,
6129,
1010,
4515,
4697,
1007,
1063,
25630,
7377,
5051,
1012,
2655,
1006,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | animate | function animate() {
return function animateImpl(properties, params) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
if (!cy.styleEnabled()) {
return this;
}
if (params) {
properties = extend({}, properties, params);
} // manually hook and run the animation
for (var i = 0; i < all.length; i++) {
var ele = all[i];
var queue = ele.animated() && (properties.queue === undefined || properties.queue);
var ani = ele.animation(properties, queue ? {
queue: true
} : undefined);
ani.play();
}
return this; // chaining
};
} | javascript | function animate() {
return function animateImpl(properties, params) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
if (!cy.styleEnabled()) {
return this;
}
if (params) {
properties = extend({}, properties, params);
} // manually hook and run the animation
for (var i = 0; i < all.length; i++) {
var ele = all[i];
var queue = ele.animated() && (properties.queue === undefined || properties.queue);
var ani = ele.animation(properties, queue ? {
queue: true
} : undefined);
ani.play();
}
return this; // chaining
};
} | [
"function",
"animate",
"(",
")",
"{",
"return",
"function",
"animateImpl",
"(",
"properties",
",",
"params",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"selfIsArrayLike",
"=",
"self",
".",
"length",
"!==",
"undefined",
";",
"var",
"all",
"=",
"sel... | animate | [
"animate"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L5899-L5927 | train | Animate the elements in the array | [
30522,
3853,
2019,
21499,
1006,
1007,
1063,
2709,
3853,
2019,
21499,
5714,
24759,
1006,
5144,
1010,
11498,
5244,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
2969,
14268,
11335,
8516,
17339,
1027,
2969,
1012,
3091,
999,
1027,
1027,
615... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | examples/3d/js/controls.js | function(pressed, event) {
var state = this.codes[event.keyCode];
if (!state) {
return;
}
this.states[state] = pressed;
event.preventDefault && event.preventDefault();
event.stopPropagation && event.stopPropagation();
} | javascript | function(pressed, event) {
var state = this.codes[event.keyCode];
if (!state) {
return;
}
this.states[state] = pressed;
event.preventDefault && event.preventDefault();
event.stopPropagation && event.stopPropagation();
} | [
"function",
"(",
"pressed",
",",
"event",
")",
"{",
"var",
"state",
"=",
"this",
".",
"codes",
"[",
"event",
".",
"keyCode",
"]",
";",
"if",
"(",
"!",
"state",
")",
"{",
"return",
";",
"}",
"this",
".",
"states",
"[",
"state",
"]",
"=",
"pressed"... | Handle all keydown and keyup events and update our internal controls state.
@param {Boolean} pressed Whether or not the key is being pressed.
@param {Object} event DOM event data including the key being pressed. | [
"Handle",
"all",
"keydown",
"and",
"keyup",
"events",
"and",
"update",
"our",
"internal",
"controls",
"state",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/controls.js#L39-L49 | train | Handle keydown events | [
30522,
3853,
1006,
4508,
1010,
2724,
1007,
1063,
13075,
2110,
1027,
2023,
1012,
9537,
1031,
2724,
1012,
3145,
16044,
1033,
1025,
2065,
1006,
999,
2110,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
2163,
1031,
2110,
1033,
1027,
4508,
1025,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/consistent-return.js | checkLastSegment | function checkLastSegment(node) {
let loc, name;
/*
* Skip if it expected no return value or unreachable.
* When unreachable, all paths are returned or thrown.
*/
if (!funcInfo.hasReturnValue ||
funcInfo.codePath.currentSegments.every(isUnreachable) ||
astUtils.isES5Constructor(node) ||
isClassConstructor(node)
) {
return;
}
// Adjust a location and a message.
if (node.type === "Program") {
// The head of program.
loc = { line: 1, column: 0 };
name = "program";
} else if (node.type === "ArrowFunctionExpression") {
// `=>` token
loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
} else if (
node.parent.type === "MethodDefinition" ||
(node.parent.type === "Property" && node.parent.method)
) {
// Method name.
loc = node.parent.key.loc.start;
} else {
// Function name or `function` keyword.
loc = (node.id || node).loc.start;
}
if (!name) {
name = astUtils.getFunctionNameWithKind(node);
}
// Reports.
context.report({
node,
loc,
messageId: "missingReturn",
data: { name }
});
} | javascript | function checkLastSegment(node) {
let loc, name;
/*
* Skip if it expected no return value or unreachable.
* When unreachable, all paths are returned or thrown.
*/
if (!funcInfo.hasReturnValue ||
funcInfo.codePath.currentSegments.every(isUnreachable) ||
astUtils.isES5Constructor(node) ||
isClassConstructor(node)
) {
return;
}
// Adjust a location and a message.
if (node.type === "Program") {
// The head of program.
loc = { line: 1, column: 0 };
name = "program";
} else if (node.type === "ArrowFunctionExpression") {
// `=>` token
loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
} else if (
node.parent.type === "MethodDefinition" ||
(node.parent.type === "Property" && node.parent.method)
) {
// Method name.
loc = node.parent.key.loc.start;
} else {
// Function name or `function` keyword.
loc = (node.id || node).loc.start;
}
if (!name) {
name = astUtils.getFunctionNameWithKind(node);
}
// Reports.
context.report({
node,
loc,
messageId: "missingReturn",
data: { name }
});
} | [
"function",
"checkLastSegment",
"(",
"node",
")",
"{",
"let",
"loc",
",",
"name",
";",
"/*\n * Skip if it expected no return value or unreachable.\n * When unreachable, all paths are returned or thrown.\n */",
"if",
"(",
"!",
"funcInfo",
".",
"ha... | Checks whether of not the implicit returning is consistent if the last
code path segment is reachable.
@param {ASTNode} node - A program/function node to check.
@returns {void} | [
"Checks",
"whether",
"of",
"not",
"the",
"implicit",
"returning",
"is",
"consistent",
"if",
"the",
"last",
"code",
"path",
"segment",
"is",
"reachable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/consistent-return.js#L95-L144 | train | Check last segment of a function call. | [
30522,
3853,
4638,
8523,
3215,
13910,
3672,
1006,
13045,
1007,
1063,
2292,
8840,
2278,
1010,
2171,
1025,
1013,
1008,
1008,
13558,
2065,
2009,
3517,
2053,
2709,
3643,
2030,
4895,
16416,
7507,
3468,
1012,
1008,
2043,
4895,
16416,
7507,
3468,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(event) {
var onSelect, dateStr, sel,
inst = $.datepicker._getInst(event.target),
handled = true,
isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
inst._keyEvent = true;
if ($.datepicker._datepickerShowing) {
switch (event.keyCode) {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
$.datepicker._currentClass + ")", inst.dpDiv);
if (sel[0]) {
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
}
onSelect = $.datepicker._get(inst, "onSelect");
if (onSelect) {
dateStr = $.datepicker._formatDate(inst);
// trigger custom callback
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
} else {
$.datepicker._hideDatepicker();
}
return false; // don't submit the form
case 27: $.datepicker._hideDatepicker();
break; // hide on escape
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
break; // previous month/year on page up/+ ctrl
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
break; // next month/year on page down/+ ctrl
case 35: if (event.ctrlKey || event.metaKey) {
$.datepicker._clearDate(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // clear on ctrl or command +end
case 36: if (event.ctrlKey || event.metaKey) {
$.datepicker._gotoToday(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // current on ctrl or command +home
case 37: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
}
handled = event.ctrlKey || event.metaKey;
// -1 day on ctrl or command +left
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +left on Mac
break;
case 38: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, -7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // -1 week on ctrl or command +up
case 39: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
}
handled = event.ctrlKey || event.metaKey;
// +1 day on ctrl or command +right
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +right
break;
case 40: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, +7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // +1 week on ctrl or command +down
default: handled = false;
}
} else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
$.datepicker._showDatepicker(this);
} else {
handled = false;
}
if (handled) {
event.preventDefault();
event.stopPropagation();
}
} | javascript | function(event) {
var onSelect, dateStr, sel,
inst = $.datepicker._getInst(event.target),
handled = true,
isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
inst._keyEvent = true;
if ($.datepicker._datepickerShowing) {
switch (event.keyCode) {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
$.datepicker._currentClass + ")", inst.dpDiv);
if (sel[0]) {
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
}
onSelect = $.datepicker._get(inst, "onSelect");
if (onSelect) {
dateStr = $.datepicker._formatDate(inst);
// trigger custom callback
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
} else {
$.datepicker._hideDatepicker();
}
return false; // don't submit the form
case 27: $.datepicker._hideDatepicker();
break; // hide on escape
case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
break; // previous month/year on page up/+ ctrl
case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
break; // next month/year on page down/+ ctrl
case 35: if (event.ctrlKey || event.metaKey) {
$.datepicker._clearDate(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // clear on ctrl or command +end
case 36: if (event.ctrlKey || event.metaKey) {
$.datepicker._gotoToday(event.target);
}
handled = event.ctrlKey || event.metaKey;
break; // current on ctrl or command +home
case 37: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
}
handled = event.ctrlKey || event.metaKey;
// -1 day on ctrl or command +left
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
-$.datepicker._get(inst, "stepBigMonths") :
-$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +left on Mac
break;
case 38: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, -7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // -1 week on ctrl or command +up
case 39: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
}
handled = event.ctrlKey || event.metaKey;
// +1 day on ctrl or command +right
if (event.originalEvent.altKey) {
$.datepicker._adjustDate(event.target, (event.ctrlKey ?
+$.datepicker._get(inst, "stepBigMonths") :
+$.datepicker._get(inst, "stepMonths")), "M");
}
// next month/year on alt +right
break;
case 40: if (event.ctrlKey || event.metaKey) {
$.datepicker._adjustDate(event.target, +7, "D");
}
handled = event.ctrlKey || event.metaKey;
break; // +1 week on ctrl or command +down
default: handled = false;
}
} else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
$.datepicker._showDatepicker(this);
} else {
handled = false;
}
if (handled) {
event.preventDefault();
event.stopPropagation();
}
} | [
"function",
"(",
"event",
")",
"{",
"var",
"onSelect",
",",
"dateStr",
",",
"sel",
",",
"inst",
"=",
"$",
".",
"datepicker",
".",
"_getInst",
"(",
"event",
".",
"target",
")",
",",
"handled",
"=",
"true",
",",
"isRTL",
"=",
"inst",
".",
"dpDiv",
".... | /* Handle keystrokes. | [
"/",
"*",
"Handle",
"keystrokes",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8161-L8256 | train | handle keydown and backspace keypress events | [
30522,
3853,
1006,
2724,
1007,
1063,
13075,
2006,
11246,
22471,
1010,
5246,
16344,
1010,
7367,
2140,
1010,
16021,
2102,
1027,
1002,
1012,
3058,
24330,
5484,
1012,
1035,
2131,
7076,
2102,
1006,
2724,
1012,
4539,
1007,
1010,
8971,
1027,
2995,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | performCleanup | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | javascript | function performCleanup(requester, filesToCache, notifyBack) {
var currentRequester = requester || "";
function filterFilesAndNotify(files, filesToCacheArr, notifyBackToBrackets) {
files.forEach(function (file) {
var fileExt = path.extname(path.basename(file));
if (filesToCacheArr.indexOf(fileExt) < 0) {
var fileFullPath = updateDir + '/' + file;
try {
fs.removeSync(fileFullPath);
} catch (e) {
console.log("AutoUpdate : Exception occured in removing ", fileFullPath, e);
}
}
});
if (notifyBackToBrackets) {
postMessageToBrackets(MessageIds.NOTIFY_SAFE_TO_DOWNLOAD, currentRequester);
}
}
fs.stat(updateDir)
.then(function (stats) {
if (stats) {
if (filesToCache) {
fs.readdir(updateDir)
.then(function (files) {
filterFilesAndNotify(files, filesToCache, notifyBack);
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_READ_FAILED);
});
} else {
fs.remove(updateDir)
.then(function () {
console.log('AutoUpdate : Update Directory in AppData Cleaned: Complete');
})
.catch(function (err) {
console.log("AutoUpdate : Error in Cleaning Update Dir : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
}
}
})
.catch(function (err) {
console.log("AutoUpdate : Error in Reading Update Dir stats for Cleanup : " + err.toString());
postMessageToBrackets(MessageIds.SHOW_ERROR_MESSAGE,
currentRequester, nodeErrorMessages.UPDATEDIR_CLEAN_FAILED);
});
} | [
"function",
"performCleanup",
"(",
"requester",
",",
"filesToCache",
",",
"notifyBack",
")",
"{",
"var",
"currentRequester",
"=",
"requester",
"||",
"\"\"",
";",
"function",
"filterFilesAndNotify",
"(",
"files",
",",
"filesToCacheArr",
",",
"notifyBackToBrackets",
"... | Performs clean up for the contents in Update Directory in AppData
@param {Array} filesToCache - array of file types to cache
@param {boolean} notifyBack - true if Brackets needs to be
notified post cleanup, false otherwise | [
"Performs",
"clean",
"up",
"for",
"the",
"contents",
"in",
"Update",
"Directory",
"in",
"AppData"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L332-L382 | train | This function is called by the cleanup process to clean up the update directory | [
30522,
3853,
4685,
14321,
24076,
2361,
1006,
5227,
2121,
1010,
6764,
3406,
3540,
5403,
1010,
2025,
8757,
5963,
1007,
1063,
13075,
2783,
2890,
15500,
2121,
1027,
5227,
2121,
1064,
1064,
1000,
1000,
1025,
3853,
11307,
8873,
4244,
5685,
17048,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CloseOthers/main.js | contextMenuOpenHandler | function contextMenuOpenHandler() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
var targetIndex = MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, file.fullPath),
workingSetListSize = MainViewManager.getWorkingSetSize(MainViewManager.ACTIVE_PANE);
if (targetIndex === workingSetListSize - 1) { // hide "Close Others Below" if the last file in Working Files is selected
CommandManager.get(closeBelow).setEnabled(false);
} else {
CommandManager.get(closeBelow).setEnabled(true);
}
if (workingSetListSize === 1) { // hide "Close Others" if there is only one file in Working Files
CommandManager.get(closeOthers).setEnabled(false);
} else {
CommandManager.get(closeOthers).setEnabled(true);
}
if (targetIndex === 0) { // hide "Close Others Above" if the first file in Working Files is selected
CommandManager.get(closeAbove).setEnabled(false);
} else {
CommandManager.get(closeAbove).setEnabled(true);
}
}
} | javascript | function contextMenuOpenHandler() {
var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
if (file) {
var targetIndex = MainViewManager.findInWorkingSet(MainViewManager.ACTIVE_PANE, file.fullPath),
workingSetListSize = MainViewManager.getWorkingSetSize(MainViewManager.ACTIVE_PANE);
if (targetIndex === workingSetListSize - 1) { // hide "Close Others Below" if the last file in Working Files is selected
CommandManager.get(closeBelow).setEnabled(false);
} else {
CommandManager.get(closeBelow).setEnabled(true);
}
if (workingSetListSize === 1) { // hide "Close Others" if there is only one file in Working Files
CommandManager.get(closeOthers).setEnabled(false);
} else {
CommandManager.get(closeOthers).setEnabled(true);
}
if (targetIndex === 0) { // hide "Close Others Above" if the first file in Working Files is selected
CommandManager.get(closeAbove).setEnabled(false);
} else {
CommandManager.get(closeAbove).setEnabled(true);
}
}
} | [
"function",
"contextMenuOpenHandler",
"(",
")",
"{",
"var",
"file",
"=",
"MainViewManager",
".",
"getCurrentlyViewedFile",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
";",
"if",
"(",
"file",
")",
"{",
"var",
"targetIndex",
"=",
"MainViewManager",
".",
"find... | Enable/Disable the menu items depending on which document is selected in the working set | [
"Enable",
"/",
"Disable",
"the",
"menu",
"items",
"depending",
"on",
"which",
"document",
"is",
"selected",
"in",
"the",
"working",
"set"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L79-L104 | train | Open the context menu | [
30522,
3853,
6123,
3549,
19098,
11837,
11774,
3917,
1006,
1007,
1063,
13075,
5371,
1027,
2364,
8584,
24805,
4590,
1012,
2131,
10841,
14343,
20630,
8584,
2098,
8873,
2571,
1006,
2364,
8584,
24805,
4590,
1012,
3161,
1035,
6090,
2063,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (aSchemas, oMetaModel) {
/**
* Process all types in the given array.
* @param {object[]} [aTypes] A list of complex types or entity types.
*/
function processTypes(aTypes) {
(aTypes || []).forEach(function (oType) {
(oType.property || []).forEach(function (oProperty) {
var sAnnotationName,
oInterface,
sSemantics,
oTarget,
oUnitPath,
sUnitPath = oProperty["sap:unit"],
oUnitProperty;
if (sUnitPath) {
oInterface = {
getModel : function () {
return oMetaModel;
},
getPath : function () {
return oType.$path;
}
};
oUnitPath = {"Path" : sUnitPath};
oTarget = _AnnotationHelperBasics.followPath(oInterface, oUnitPath);
if (oTarget && oTarget.resolvedPath) {
oUnitProperty = oMetaModel.getProperty(oTarget.resolvedPath);
sSemantics = oUnitProperty["sap:semantics"];
if (sSemantics === "unit-of-measure") {
sAnnotationName = "Org.OData.Measures.V1.Unit";
} else if (sSemantics === "currency-code") {
sAnnotationName = "Org.OData.Measures.V1.ISOCurrency";
} else if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Unsupported sap:semantics='"
+ sSemantics + "' at sap:unit='" + sUnitPath + "'; "
+ "expected 'currency-code' or 'unit-of-measure'",
oType.namespace + "." + oType.name + "/" + oProperty.name,
sLoggingModule);
}
// Do not overwrite an existing annotation
if (sAnnotationName && !(sAnnotationName in oProperty)) {
oProperty[sAnnotationName] = oUnitPath;
}
} else if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Path '" + sUnitPath
+ "' for sap:unit cannot be resolved",
oType.namespace + "." + oType.name + "/" + oProperty.name,
sLoggingModule);
}
}
});
});
}
aSchemas.forEach(function (oSchema) {
processTypes(oSchema.complexType);
processTypes(oSchema.entityType);
});
} | javascript | function (aSchemas, oMetaModel) {
/**
* Process all types in the given array.
* @param {object[]} [aTypes] A list of complex types or entity types.
*/
function processTypes(aTypes) {
(aTypes || []).forEach(function (oType) {
(oType.property || []).forEach(function (oProperty) {
var sAnnotationName,
oInterface,
sSemantics,
oTarget,
oUnitPath,
sUnitPath = oProperty["sap:unit"],
oUnitProperty;
if (sUnitPath) {
oInterface = {
getModel : function () {
return oMetaModel;
},
getPath : function () {
return oType.$path;
}
};
oUnitPath = {"Path" : sUnitPath};
oTarget = _AnnotationHelperBasics.followPath(oInterface, oUnitPath);
if (oTarget && oTarget.resolvedPath) {
oUnitProperty = oMetaModel.getProperty(oTarget.resolvedPath);
sSemantics = oUnitProperty["sap:semantics"];
if (sSemantics === "unit-of-measure") {
sAnnotationName = "Org.OData.Measures.V1.Unit";
} else if (sSemantics === "currency-code") {
sAnnotationName = "Org.OData.Measures.V1.ISOCurrency";
} else if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Unsupported sap:semantics='"
+ sSemantics + "' at sap:unit='" + sUnitPath + "'; "
+ "expected 'currency-code' or 'unit-of-measure'",
oType.namespace + "." + oType.name + "/" + oProperty.name,
sLoggingModule);
}
// Do not overwrite an existing annotation
if (sAnnotationName && !(sAnnotationName in oProperty)) {
oProperty[sAnnotationName] = oUnitPath;
}
} else if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Path '" + sUnitPath
+ "' for sap:unit cannot be resolved",
oType.namespace + "." + oType.name + "/" + oProperty.name,
sLoggingModule);
}
}
});
});
}
aSchemas.forEach(function (oSchema) {
processTypes(oSchema.complexType);
processTypes(oSchema.entityType);
});
} | [
"function",
"(",
"aSchemas",
",",
"oMetaModel",
")",
"{",
"/**\n\t\t\t * Process all types in the given array.\n\t\t\t * @param {object[]} [aTypes] A list of complex types or entity types.\n\t\t\t */",
"function",
"processTypes",
"(",
"aTypes",
")",
"{",
"(",
"aTypes",
"||",
"[",
... | Adds unit annotations to properties that have a <code>sap:unit</code> OData V2
annotation.
Iterates over the given schemas and searches in their complex and entity types for
properties with a <code>sap:unit</code> OData V2 annotation. Creates a corresponding
OData V4 annotation <code>Org.OData.Measures.V1.Unit</code> or
<code>Org.OData.Measures.V1.ISOCurrency</code> based on the
<code>sap:semantics</code> V2 annotation of the referenced unit property, unless such an
annotation already exists.
@param {object[]} aSchemas
the array of schemas
@param {sap.ui.model.odata.ODataMetaModel} oMetaModel
the OData meta model | [
"Adds",
"unit",
"annotations",
"to",
"properties",
"that",
"have",
"a",
"<code",
">",
"sap",
":",
"unit<",
"/",
"code",
">",
"OData",
"V2",
"annotation",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L387-L447 | train | Process all types in the given array. | [
30522,
3853,
1006,
2004,
5403,
9335,
1010,
18168,
12928,
5302,
9247,
1007,
1063,
1013,
1008,
1008,
1008,
2832,
2035,
4127,
1999,
1996,
2445,
9140,
1012,
1008,
1030,
11498,
2213,
1063,
4874,
1031,
1033,
1065,
1031,
2012,
18863,
2015,
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... | |
pouchdb/pouchdb | bin/build-pouchdb.js | buildForBrowser | function buildForBrowser() {
return doBrowserify('pouchdb', 'lib/index-browser.js', {
standalone: 'PouchDB'
}).then(function (code) {
code = comments.pouchdb + code;
return all([
writeFile(addPath('pouchdb', 'dist/pouchdb.js'), code),
doUglify('pouchdb', code, comments.pouchdb, 'dist/pouchdb.min.js')
]);
});
} | javascript | function buildForBrowser() {
return doBrowserify('pouchdb', 'lib/index-browser.js', {
standalone: 'PouchDB'
}).then(function (code) {
code = comments.pouchdb + code;
return all([
writeFile(addPath('pouchdb', 'dist/pouchdb.js'), code),
doUglify('pouchdb', code, comments.pouchdb, 'dist/pouchdb.min.js')
]);
});
} | [
"function",
"buildForBrowser",
"(",
")",
"{",
"return",
"doBrowserify",
"(",
"'pouchdb'",
",",
"'lib/index-browser.js'",
",",
"{",
"standalone",
":",
"'PouchDB'",
"}",
")",
".",
"then",
"(",
"function",
"(",
"code",
")",
"{",
"code",
"=",
"comments",
".",
... | build for the browser (dist) | [
"build",
"for",
"the",
"browser",
"(",
"dist",
")"
] | 858660e9b37959d96eebf667ea9b8b1273f0d62c | https://github.com/pouchdb/pouchdb/blob/858660e9b37959d96eebf667ea9b8b1273f0d62c/bin/build-pouchdb.js#L114-L124 | train | Build the pouchdb. js file for browser | [
30522,
3853,
3857,
29278,
12618,
9333,
2121,
1006,
1007,
1063,
2709,
2079,
12618,
9333,
11124,
12031,
1006,
1005,
21445,
18939,
1005,
1010,
1005,
5622,
2497,
1013,
5950,
1011,
16602,
1012,
1046,
2015,
1005,
1010,
1063,
26609,
1024,
1005,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js | function(locationUrl, options) {
try {
// Try to start play-mode
this.play(locationUrl, options);
} catch (e) {
// If play-mode could not be started, try to record instead.
var oUri = new URI(locationUrl);
var sExtension = oUri.suffix();
// Check if the provided URL is a har file, maybe the wrong url is provided
if (sExtension != "har") {
_private.oLog.warning(sModuleName + " - Invalid file extension: " + sExtension + ", please use '.har' files.");
}
this.record(oUri.filename().replace("." + sExtension, ""), options);
}
} | javascript | function(locationUrl, options) {
try {
// Try to start play-mode
this.play(locationUrl, options);
} catch (e) {
// If play-mode could not be started, try to record instead.
var oUri = new URI(locationUrl);
var sExtension = oUri.suffix();
// Check if the provided URL is a har file, maybe the wrong url is provided
if (sExtension != "har") {
_private.oLog.warning(sModuleName + " - Invalid file extension: " + sExtension + ", please use '.har' files.");
}
this.record(oUri.filename().replace("." + sExtension, ""), options);
}
} | [
"function",
"(",
"locationUrl",
",",
"options",
")",
"{",
"try",
"{",
"// Try to start play-mode",
"this",
".",
"play",
"(",
"locationUrl",
",",
"options",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// If play-mode could not be started, try to record instead.",
... | Start with existing locationUrl or inline entries results in a playback. If the file does not exist, XMLHttpRequests are not faked and the recording starts.
@param {string|Array} locationUrl Specifies from which location the file is loaded. If it is not found, the recording is started. The provided filename is the name of the output har file.
This parameter can be the entries array for overloading the function.
@param {object} [options] Contains optional parameters to config the RequestRecorder:
{boolean|object} [options.delay] If a the parameter is equals true, the recorded delay timings are used, instead of the default delay equals zero. If a map as parameter is used, the delay is calculated with the delaysettings in the object. Possible settings are max, min, offset, factor.
{function} [options.customGroupNameCallback] A callback is used to determine the custom groupname of the current XMLHttpRequest. If the callback returns a falsy value, the default groupname is used.
{boolean} [options.disableDownload] Set this flag to true if you don´t want to download the recording after the recording is finished. This parameter is only used for testing purposes.
{boolean} [options.promptForDownloadFilename] Activates a prompt popup after stop is called to enter a desired filename.
{array|RegExp} [options.entriesUrlFilter] A list of regular expressions, if it matches the URL the request-entry is filtered.
array|object} [options.entriesUrlReplace] A list of objects with regex and value to replace. E.g.: "{ regex: new RegExp("RegexToSearchForInUrl"), "value": "newValueString" }" | [
"Start",
"with",
"existing",
"locationUrl",
"or",
"inline",
"entries",
"results",
"in",
"a",
"playback",
".",
"If",
"the",
"file",
"does",
"not",
"exist",
"XMLHttpRequests",
"are",
"not",
"faked",
"and",
"the",
"recording",
"starts",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L543-L557 | train | Play the specified file | [
30522,
3853,
1006,
3295,
3126,
2140,
1010,
7047,
1007,
1063,
3046,
1063,
1013,
1013,
3046,
2000,
2707,
2377,
1011,
5549,
2023,
1012,
2377,
1006,
3295,
3126,
2140,
1010,
7047,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
1013,
1013,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
postmanlabs/newman | lib/reporters/cli/cli-utils.js | function () {
var tty,
width,
height;
try { tty = require('tty'); }
catch (e) { tty = null; }
if (tty && tty.isatty(1) && tty.isatty(2)) {
if (process.stdout.getWindowSize) {
width = process.stdout.getWindowSize(1)[0];
height = process.stdout.getWindowSize(1)[1];
}
else if (tty.getWindowSize) {
width = tty.getWindowSize()[1];
height = tty.getWindowSize()[0];
}
else if (process.stdout.columns && process.stdout.rows) {
height = process.stdout.rows;
width = process.stdout.columns;
}
}
return {
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
width: width,
height: height
};
} | javascript | function () {
var tty,
width,
height;
try { tty = require('tty'); }
catch (e) { tty = null; }
if (tty && tty.isatty(1) && tty.isatty(2)) {
if (process.stdout.getWindowSize) {
width = process.stdout.getWindowSize(1)[0];
height = process.stdout.getWindowSize(1)[1];
}
else if (tty.getWindowSize) {
width = tty.getWindowSize()[1];
height = tty.getWindowSize()[0];
}
else if (process.stdout.columns && process.stdout.rows) {
height = process.stdout.rows;
width = process.stdout.columns;
}
}
return {
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
width: width,
height: height
};
} | [
"function",
"(",
")",
"{",
"var",
"tty",
",",
"width",
",",
"height",
";",
"try",
"{",
"tty",
"=",
"require",
"(",
"'tty'",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"tty",
"=",
"null",
";",
"}",
"if",
"(",
"tty",
"&&",
"tty",
".",
"isatty"... | A CLI utility helper method to compute and scae the size of the CLI table to be displayed.
@returns {Object} - A set of properties: width, height, and TTY existance. | [
"A",
"CLI",
"utility",
"helper",
"method",
"to",
"compute",
"and",
"scae",
"the",
"size",
"of",
"the",
"CLI",
"table",
"to",
"be",
"displayed",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L155-L183 | train | Returns an object containing information about the current term size | [
30522,
3853,
1006,
1007,
1063,
13075,
23746,
2100,
1010,
9381,
1010,
4578,
1025,
3046,
1063,
23746,
2100,
1027,
5478,
1006,
1005,
23746,
2100,
1005,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
23746,
2100,
1027,
19701,
1025,
1065,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/node/optparse.js | formatHelpMsg | function formatHelpMsg(usage, options) {
var prog = path.basename(
process.argv[0]) + ' ' + path.basename(process.argv[1]);
var help = [
usage.replace(/\$0\b/g, prog),
'',
'Options:',
formatOption('help', 'Show this message and exit')
];
Object.keys(options).sort().forEach(function(key) {
help.push(formatOption(key, options[key].help));
});
help.push('');
return help.join('\n');
} | javascript | function formatHelpMsg(usage, options) {
var prog = path.basename(
process.argv[0]) + ' ' + path.basename(process.argv[1]);
var help = [
usage.replace(/\$0\b/g, prog),
'',
'Options:',
formatOption('help', 'Show this message and exit')
];
Object.keys(options).sort().forEach(function(key) {
help.push(formatOption(key, options[key].help));
});
help.push('');
return help.join('\n');
} | [
"function",
"formatHelpMsg",
"(",
"usage",
",",
"options",
")",
"{",
"var",
"prog",
"=",
"path",
".",
"basename",
"(",
"process",
".",
"argv",
"[",
"0",
"]",
")",
"+",
"' '",
"+",
"path",
".",
"basename",
"(",
"process",
".",
"argv",
"[",
"1",
"]",... | Formats a help message for the given parser.
@param {string} usage The usage string. All occurences of "$0" will be
replaced with the name of the current program.
@param {!Object.<!Option>} options The options to format.
@return {string} The formatted help message. | [
"Formats",
"a",
"help",
"message",
"for",
"the",
"given",
"parser",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/optparse.js#L123-L140 | train | Format help message | [
30522,
3853,
4289,
16001,
9737,
28745,
1006,
8192,
1010,
7047,
1007,
1063,
13075,
4013,
2290,
1027,
4130,
1012,
2918,
18442,
1006,
2832,
1012,
12098,
2290,
2615,
1031,
1014,
1033,
1007,
1009,
1005,
1005,
1009,
4130,
1012,
2918,
18442,
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... |
TryGhost/Ghost | core/server/api/v0.1/notifications.js | handlePermissions | function handlePermissions(options) {
return canThis(options.context).destroy.notification().then(() => {
return options;
}, () => {
return Promise.reject(new common.errors.NoPermissionError({
message: common.i18n.t('errors.api.notifications.noPermissionToDestroyNotif')
}));
});
} | javascript | function handlePermissions(options) {
return canThis(options.context).destroy.notification().then(() => {
return options;
}, () => {
return Promise.reject(new common.errors.NoPermissionError({
message: common.i18n.t('errors.api.notifications.noPermissionToDestroyNotif')
}));
});
} | [
"function",
"handlePermissions",
"(",
"options",
")",
"{",
"return",
"canThis",
"(",
"options",
".",
"context",
")",
".",
"destroy",
".",
"notification",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"return",
"options",
";",
"}",
",",
"(",
")",
"... | ### 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#L229-L237 | train | Check if the user has the right permissions to destroy the notification | [
30522,
3853,
5047,
4842,
25481,
2015,
1006,
7047,
1007,
1063,
2709,
2064,
15222,
2015,
1006,
7047,
1012,
6123,
1007,
1012,
6033,
1012,
26828,
1006,
1007,
1012,
2059,
1006,
1006,
1007,
1027,
1028,
1063,
2709,
7047,
1025,
1065,
1010,
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... |
mui-org/material-ui | docs/src/pages/components/grid-list/TitlebarGridList.js | TitlebarGridList | function TitlebarGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={180} className={classes.gridList}>
<GridListTile key="Subheader" cols={2} style={{ height: 'auto' }}>
<ListSubheader component="div">December</ListSubheader>
</GridListTile>
{tileData.map(tile => (
<GridListTile key={tile.img}>
<img src={tile.img} alt={tile.title} />
<GridListTileBar
title={tile.title}
subtitle={<span>by: {tile.author}</span>}
actionIcon={
<IconButton className={classes.icon}>
<InfoIcon />
</IconButton>
}
/>
</GridListTile>
))}
</GridList>
</div>
);
} | javascript | function TitlebarGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={180} className={classes.gridList}>
<GridListTile key="Subheader" cols={2} style={{ height: 'auto' }}>
<ListSubheader component="div">December</ListSubheader>
</GridListTile>
{tileData.map(tile => (
<GridListTile key={tile.img}>
<img src={tile.img} alt={tile.title} />
<GridListTileBar
title={tile.title}
subtitle={<span>by: {tile.author}</span>}
actionIcon={
<IconButton className={classes.icon}>
<InfoIcon />
</IconButton>
}
/>
</GridListTile>
))}
</GridList>
</div>
);
} | [
"function",
"TitlebarGridList",
"(",
")",
"{",
"const",
"classes",
"=",
"useStyles",
"(",
")",
";",
"return",
"(",
"<",
"div",
"className",
"=",
"{",
"classes",
".",
"root",
"}",
">",
"\n ",
"<",
"GridList",
"cellHeight",
"=",
"{",
"180",
"}",
"cl... | The example data is structured as follows:
import image from 'path/to/image.jpg';
[etc...]
const tileData = [
{
img: image,
title: 'Image',
author: 'author',
},
{
[etc...]
},
]; | [
"The",
"example",
"data",
"is",
"structured",
"as",
"follows",
":"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/components/grid-list/TitlebarGridList.js#L45-L71 | train | A titlebar grid list | [
30522,
3853,
2516,
8237,
16523,
3593,
9863,
1006,
1007,
1063,
9530,
3367,
4280,
1027,
3594,
27983,
2015,
1006,
1007,
1025,
2709,
1006,
1026,
4487,
2615,
2465,
18442,
1027,
1063,
4280,
1012,
7117,
1065,
1028,
1026,
8370,
9863,
3526,
26036,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.unified/src/sap/ui/unified/calendar/CalendarDate.js | createUTCDate | function createUTCDate(oDate) {
var oUTCDate = new Date(Date.UTC(0, 0, 1));
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
return oUTCDate;
} | javascript | function createUTCDate(oDate) {
var oUTCDate = new Date(Date.UTC(0, 0, 1));
oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate());
return oUTCDate;
} | [
"function",
"createUTCDate",
"(",
"oDate",
")",
"{",
"var",
"oUTCDate",
"=",
"new",
"Date",
"(",
"Date",
".",
"UTC",
"(",
"0",
",",
"0",
",",
"1",
")",
")",
";",
"oUTCDate",
".",
"setUTCFullYear",
"(",
"oDate",
".",
"getFullYear",
"(",
")",
",",
"o... | Creates a JavaScript UTC Date corresponding to the given JavaScript Date.
@param {Date} oDate JavaScript date object. Time related information is cut.
@returns {Date} JavaScript date created from the date object, but this time considered as UTC date information. | [
"Creates",
"a",
"JavaScript",
"UTC",
"Date",
"corresponding",
"to",
"the",
"given",
"JavaScript",
"Date",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.unified/src/sap/ui/unified/calendar/CalendarDate.js#L341-L347 | train | Creates a new Date instance with the correct UTC date | [
30522,
3853,
3443,
4904,
19797,
3686,
1006,
1051,
13701,
1007,
1063,
13075,
2041,
19797,
3686,
1027,
2047,
3058,
1006,
3058,
1012,
11396,
1006,
1014,
1010,
1014,
1010,
1015,
1007,
1007,
1025,
2041,
19797,
3686,
1012,
2275,
4904,
2278,
7699,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetView.js | _suppressScrollShadowsOnAllViews | function _suppressScrollShadowsOnAllViews(disable) {
_.forEach(_views, function (view) {
if (disable) {
ViewUtils.removeScrollerShadow(view.$openFilesContainer[0], null);
} else if (view.$openFilesContainer[0].scrollHeight > view.$openFilesContainer[0].clientHeight) {
ViewUtils.addScrollerShadow(view.$openFilesContainer[0], null, true);
}
});
} | javascript | function _suppressScrollShadowsOnAllViews(disable) {
_.forEach(_views, function (view) {
if (disable) {
ViewUtils.removeScrollerShadow(view.$openFilesContainer[0], null);
} else if (view.$openFilesContainer[0].scrollHeight > view.$openFilesContainer[0].clientHeight) {
ViewUtils.addScrollerShadow(view.$openFilesContainer[0], null, true);
}
});
} | [
"function",
"_suppressScrollShadowsOnAllViews",
"(",
"disable",
")",
"{",
"_",
".",
"forEach",
"(",
"_views",
",",
"function",
"(",
"view",
")",
"{",
"if",
"(",
"disable",
")",
"{",
"ViewUtils",
".",
"removeScrollerShadow",
"(",
"view",
".",
"$openFilesContain... | turns off the scroll shadow on view containers so they don't interfere with dragging
@private
@param {Boolean} disable - true to disable, false to enable | [
"turns",
"off",
"the",
"scroll",
"shadow",
"on",
"view",
"containers",
"so",
"they",
"don",
"t",
"interfere",
"with",
"dragging"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L188-L196 | train | suppress scroll shadows on all views | [
30522,
3853,
1035,
16081,
11020,
28402,
7377,
3527,
9333,
16026,
2140,
8584,
2015,
1006,
4487,
19150,
1007,
1063,
1035,
1012,
18921,
6776,
1006,
1035,
5328,
1010,
3853,
1006,
3193,
1007,
1063,
2065,
1006,
4487,
19150,
1007,
1063,
3193,
2182... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/View.js | initPreprocessorQueues | function initPreprocessorQueues(oView, mSettings) {
var oViewClass = oView.getMetadata().getClass();
function resolvePreprocessors(oPreprocessor) {
oPreprocessor.preprocessor = initPreprocessor(oPreprocessor, mSettings.async);
}
// shallow copy to avoid issues when manipulating the internal object structure
oView.mPreprocessors = jQuery.extend({}, mSettings.preprocessors);
for (var _sType in oViewClass.PreprocessorType) {
// build the array structure
var sType = oViewClass.PreprocessorType[_sType];
if (oView.mPreprocessors[sType] && !Array.isArray(oView.mPreprocessors[sType])) {
oView.mPreprocessors[sType] = [oView.mPreprocessors[sType]];
} else if (!oView.mPreprocessors[sType]) {
oView.mPreprocessors[sType] = [];
}
oView.mPreprocessors[sType].forEach(alignPreprocessorStructure);
oView.mPreprocessors[sType] = getPreprocessorQueue.call(oView, oViewClass._sType, sType);
oView.mPreprocessors[sType].forEach(resolvePreprocessors);
}
} | javascript | function initPreprocessorQueues(oView, mSettings) {
var oViewClass = oView.getMetadata().getClass();
function resolvePreprocessors(oPreprocessor) {
oPreprocessor.preprocessor = initPreprocessor(oPreprocessor, mSettings.async);
}
// shallow copy to avoid issues when manipulating the internal object structure
oView.mPreprocessors = jQuery.extend({}, mSettings.preprocessors);
for (var _sType in oViewClass.PreprocessorType) {
// build the array structure
var sType = oViewClass.PreprocessorType[_sType];
if (oView.mPreprocessors[sType] && !Array.isArray(oView.mPreprocessors[sType])) {
oView.mPreprocessors[sType] = [oView.mPreprocessors[sType]];
} else if (!oView.mPreprocessors[sType]) {
oView.mPreprocessors[sType] = [];
}
oView.mPreprocessors[sType].forEach(alignPreprocessorStructure);
oView.mPreprocessors[sType] = getPreprocessorQueue.call(oView, oViewClass._sType, sType);
oView.mPreprocessors[sType].forEach(resolvePreprocessors);
}
} | [
"function",
"initPreprocessorQueues",
"(",
"oView",
",",
"mSettings",
")",
"{",
"var",
"oViewClass",
"=",
"oView",
".",
"getMetadata",
"(",
")",
".",
"getClass",
"(",
")",
";",
"function",
"resolvePreprocessors",
"(",
"oPreprocessor",
")",
"{",
"oPreprocessor",
... | init internal registry and convert single declarations to array, for compatibility
@param {sap.ui.core.mvc.View} oView This view instance
@param {object} mSettings Settings for the view
@private | [
"init",
"internal",
"registry",
"and",
"convert",
"single",
"declarations",
"to",
"array",
"for",
"compatibility"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/View.js#L308-L329 | train | Initializes the preprocessors for the given view | [
30522,
3853,
1999,
4183,
28139,
21572,
9623,
21748,
4226,
15808,
1006,
1051,
8584,
1010,
5796,
18319,
3070,
2015,
1007,
1063,
13075,
1051,
8584,
26266,
1027,
1051,
8584,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1012,
2131,
26266,
1006,
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... |
dcloudio/mui | examples/hello-mui/js/mui.js | function(p1, p2, props) {
if(!props) {
props = ['x', 'y'];
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return sqrt((x * x) + (y * y));
} | javascript | function(p1, p2, props) {
if(!props) {
props = ['x', 'y'];
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return sqrt((x * x) + (y * y));
} | [
"function",
"(",
"p1",
",",
"p2",
",",
"props",
")",
"{",
"if",
"(",
"!",
"props",
")",
"{",
"props",
"=",
"[",
"'x'",
",",
"'y'",
"]",
";",
"}",
"var",
"x",
"=",
"p2",
"[",
"props",
"[",
"0",
"]",
"]",
"-",
"p1",
"[",
"props",
"[",
"0",
... | distance
@param {type} p1
@param {type} p2
@returns {Number} | [
"distance"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L1181-L1188 | train | Returns the distance between two points | [
30522,
3853,
1006,
1052,
2487,
1010,
1052,
2475,
1010,
24387,
1007,
1063,
2065,
1006,
999,
24387,
1007,
1063,
24387,
1027,
1031,
1005,
1060,
1005,
1010,
1005,
1061,
1005,
1033,
1025,
1065,
13075,
1060,
1027,
1052,
2475,
1031,
24387,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/tooltip/tooltip.js | register | function register(type, handler, useCapture) {
var handlers = listeners[type] = listeners[type] || [];
if (!handlers.length) {
useCapture ? window.addEventListener(type, globalEventHandler, true) :
ngWindow.on(type, globalEventHandler);
}
if (handlers.indexOf(handler) === -1) {
handlers.push(handler);
}
} | javascript | function register(type, handler, useCapture) {
var handlers = listeners[type] = listeners[type] || [];
if (!handlers.length) {
useCapture ? window.addEventListener(type, globalEventHandler, true) :
ngWindow.on(type, globalEventHandler);
}
if (handlers.indexOf(handler) === -1) {
handlers.push(handler);
}
} | [
"function",
"register",
"(",
"type",
",",
"handler",
",",
"useCapture",
")",
"{",
"var",
"handlers",
"=",
"listeners",
"[",
"type",
"]",
"=",
"listeners",
"[",
"type",
"]",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"handlers",
".",
"length",
")",
"{",
"... | Registers a new handler with the service.
@param {string} type Type of event to be registered.
@param {!Function} handler Event handler.
@param {boolean} useCapture Whether to use event capturing. | [
"Registers",
"a",
"new",
"handler",
"with",
"the",
"service",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tooltip/tooltip.js#L451-L462 | train | Register a listener for a specific event type | [
30522,
3853,
4236,
1006,
2828,
1010,
28213,
1010,
2224,
17695,
11244,
1007,
1063,
13075,
28213,
2015,
1027,
13810,
1031,
2828,
1033,
1027,
13810,
1031,
2828,
1033,
1064,
1064,
1031,
1033,
1025,
2065,
1006,
999,
28213,
2015,
1012,
3091,
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... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
.removeClass( "ui-state-active" );
} | javascript | function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
.removeClass( "ui-state-active" );
} | [
"function",
"(",
"startMenu",
")",
"{",
"if",
"(",
"!",
"startMenu",
")",
"{",
"startMenu",
"=",
"this",
".",
"active",
"?",
"this",
".",
"active",
".",
"parent",
"(",
")",
":",
"this",
".",
"element",
";",
"}",
"startMenu",
".",
"find",
"(",
"\".u... | With no arguments, closes the currently active menu - if nothing is active it closes all menus. If passed an argument, it will search for menus BELOW | [
"With",
"no",
"arguments",
"closes",
"the",
"currently",
"active",
"menu",
"-",
"if",
"nothing",
"is",
"active",
"it",
"closes",
"all",
"menus",
".",
"If",
"passed",
"an",
"argument",
"it",
"will",
"search",
"for",
"menus",
"BELOW"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L11899-L11912 | train | Hide the menu | [
30522,
3853,
30524,
3549,
2226,
1007,
1063,
2707,
3549,
2226,
1027,
2023,
1012,
3161,
1029,
2023,
1012,
3161,
1012,
6687,
1006,
1007,
1024,
2023,
1012,
5783,
1025,
1065,
2707,
3549,
2226,
1012,
2424,
1006,
1000,
1012,
21318,
1011,
12183,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseConstLetDeclaration | function parseConstLetDeclaration(kind) {
var declarations, startToken;
startToken = lookahead;
expectKeyword(kind);
declarations = parseVariableDeclarationList(kind);
consumeSemicolon();
return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind), startToken);
} | javascript | function parseConstLetDeclaration(kind) {
var declarations, startToken;
startToken = lookahead;
expectKeyword(kind);
declarations = parseVariableDeclarationList(kind);
consumeSemicolon();
return delegate.markEnd(delegate.createVariableDeclaration(declarations, kind), startToken);
} | [
"function",
"parseConstLetDeclaration",
"(",
"kind",
")",
"{",
"var",
"declarations",
",",
"startToken",
";",
"startToken",
"=",
"lookahead",
";",
"expectKeyword",
"(",
"kind",
")",
";",
"declarations",
"=",
"parseVariableDeclarationList",
"(",
"kind",
")",
";",
... | kind may be `const` or `let` Both are experimental and not in the specification yet. see http://wiki.ecmascript.org/doku.php?id=harmony:const and http://wiki.ecmascript.org/doku.php?id=harmony:let | [
"kind",
"may",
"be",
"const",
"or",
"let",
"Both",
"are",
"experimental",
"and",
"not",
"in",
"the",
"specification",
"yet",
".",
"see",
"http",
":",
"//",
"wiki",
".",
"ecmascript",
".",
"org",
"/",
"doku",
".",
"php?id",
"=",
"harmony",
":",
"const",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2708-L2720 | train | ECMA - 262 12. 2 ConstLetDeclaration | [
30522,
3853,
11968,
3366,
8663,
22516,
2102,
3207,
20464,
25879,
3258,
1006,
2785,
1007,
1063,
13075,
8170,
2015,
1010,
2707,
18715,
2368,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
1025,
5987,
14839,
18351,
1006,
2785,
1007,
1025,
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.core/src/sap/ui/model/odata/AnnotationParser.js | function() {
var xPath = {};
var mParserData = AnnotationParser._parserData;
if (Device.browser.msie) {// old IE
xPath = {
setNameSpace : function(outNode) {
outNode.setProperty("SelectionNamespaces",
'xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:d="http://docs.oasis-open.org/odata/ns/edm"');
outNode.setProperty("SelectionLanguage", "XPath");
return outNode;
},
selectNodes : function(xPath, inNode) {
return inNode.selectNodes(xPath);
},
nextNode : function(node) {
return node.nextNode();
},
getNodeText : function(node) {
return node.text;
}
};
} else {// Chrome, Firefox, Opera, etc.
xPath = {
setNameSpace : function(outNode) {
return outNode;
},
nsResolver : function(prefix) {
var ns = {
"edmx" : "http://docs.oasis-open.org/odata/ns/edmx",
"d" : "http://docs.oasis-open.org/odata/ns/edm"
};
return ns[prefix] || null;
},
selectNodes : function(sPath, inNode) {
var xmlNodes = mParserData.xmlDocument.evaluate(sPath, inNode, this.nsResolver, /* ORDERED_NODE_SNAPSHOT_TYPE: */ 7, null);
xmlNodes.length = xmlNodes.snapshotLength;
return xmlNodes;
},
nextNode : function(node, item) {
return node.snapshotItem(item);
},
getNodeText : function(node) {
return node.textContent;
}
};
}
xPath.getPath = function(oNode) {
var sPath = "";
var sId = "getAttribute" in oNode ? oNode.getAttribute("id") : "";
var sTagName = oNode.tagName ? oNode.tagName : "";
if (sId) {
// If node has an ID, use that
sPath = 'id("' + sId + '")';
} else if (oNode instanceof Document) {
sPath = "/";
} else if (sTagName.toLowerCase() === "body") {
// If node is the body element, just return its tag name
sPath = sTagName;
} else if (oNode.parentNode) {
// Count the position in the parent and get the path of the parent recursively
var iPos = 1;
for (var i = 0; i < oNode.parentNode.childNodes.length; ++i) {
if (oNode.parentNode.childNodes[i] === oNode) {
// Found the node inside its parent
sPath = xPath.getPath(oNode.parentNode) + "/" + sTagName + "[" + iPos + "]";
break;
} else if (oNode.parentNode.childNodes[i].nodeType === 1 && oNode.parentNode.childNodes[i].tagName === sTagName) {
// In case there are other elements of the same kind, count them
++iPos;
}
}
} else {
Log.error("Wrong Input node - cannot find XPath to it: " + sTagName);
}
return sPath;
};
return xPath;
} | javascript | function() {
var xPath = {};
var mParserData = AnnotationParser._parserData;
if (Device.browser.msie) {// old IE
xPath = {
setNameSpace : function(outNode) {
outNode.setProperty("SelectionNamespaces",
'xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:d="http://docs.oasis-open.org/odata/ns/edm"');
outNode.setProperty("SelectionLanguage", "XPath");
return outNode;
},
selectNodes : function(xPath, inNode) {
return inNode.selectNodes(xPath);
},
nextNode : function(node) {
return node.nextNode();
},
getNodeText : function(node) {
return node.text;
}
};
} else {// Chrome, Firefox, Opera, etc.
xPath = {
setNameSpace : function(outNode) {
return outNode;
},
nsResolver : function(prefix) {
var ns = {
"edmx" : "http://docs.oasis-open.org/odata/ns/edmx",
"d" : "http://docs.oasis-open.org/odata/ns/edm"
};
return ns[prefix] || null;
},
selectNodes : function(sPath, inNode) {
var xmlNodes = mParserData.xmlDocument.evaluate(sPath, inNode, this.nsResolver, /* ORDERED_NODE_SNAPSHOT_TYPE: */ 7, null);
xmlNodes.length = xmlNodes.snapshotLength;
return xmlNodes;
},
nextNode : function(node, item) {
return node.snapshotItem(item);
},
getNodeText : function(node) {
return node.textContent;
}
};
}
xPath.getPath = function(oNode) {
var sPath = "";
var sId = "getAttribute" in oNode ? oNode.getAttribute("id") : "";
var sTagName = oNode.tagName ? oNode.tagName : "";
if (sId) {
// If node has an ID, use that
sPath = 'id("' + sId + '")';
} else if (oNode instanceof Document) {
sPath = "/";
} else if (sTagName.toLowerCase() === "body") {
// If node is the body element, just return its tag name
sPath = sTagName;
} else if (oNode.parentNode) {
// Count the position in the parent and get the path of the parent recursively
var iPos = 1;
for (var i = 0; i < oNode.parentNode.childNodes.length; ++i) {
if (oNode.parentNode.childNodes[i] === oNode) {
// Found the node inside its parent
sPath = xPath.getPath(oNode.parentNode) + "/" + sTagName + "[" + iPos + "]";
break;
} else if (oNode.parentNode.childNodes[i].nodeType === 1 && oNode.parentNode.childNodes[i].tagName === sTagName) {
// In case there are other elements of the same kind, count them
++iPos;
}
}
} else {
Log.error("Wrong Input node - cannot find XPath to it: " + sTagName);
}
return sPath;
};
return xPath;
} | [
"function",
"(",
")",
"{",
"var",
"xPath",
"=",
"{",
"}",
";",
"var",
"mParserData",
"=",
"AnnotationParser",
".",
"_parserData",
";",
"if",
"(",
"Device",
".",
"browser",
".",
"msie",
")",
"{",
"// old IE",
"xPath",
"=",
"{",
"setNameSpace",
":",
"fun... | /*
@static
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L1210-L1293 | train | Returns the XML nodes that are selected by XPath. | [
30522,
3853,
1006,
1007,
1063,
13075,
26726,
8988,
1027,
1063,
1065,
1025,
13075,
6131,
11650,
2121,
2850,
2696,
1027,
5754,
17287,
3508,
19362,
8043,
1012,
1035,
11968,
8043,
2850,
2696,
1025,
2065,
1006,
5080,
1012,
16602,
1012,
5796,
266... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jquery-mobile-custom.js | stopHandler | function stopHandler( event ) {
$this.unbind( touchMoveEvent, moveHandler )
.unbind( touchStopEvent, stopHandler );
if ( start && stop ) {
$.event.special.swipe.handleSwipe( start, stop );
}
start = stop = undefined;
} | javascript | function stopHandler( event ) {
$this.unbind( touchMoveEvent, moveHandler )
.unbind( touchStopEvent, stopHandler );
if ( start && stop ) {
$.event.special.swipe.handleSwipe( start, stop );
}
start = stop = undefined;
} | [
"function",
"stopHandler",
"(",
"event",
")",
"{",
"$this",
".",
"unbind",
"(",
"touchMoveEvent",
",",
"moveHandler",
")",
".",
"unbind",
"(",
"touchStopEvent",
",",
"stopHandler",
")",
";",
"if",
"(",
"start",
"&&",
"stop",
")",
"{",
"$",
".",
"event",
... | SAP MODIFICATION Because touchcancel is used together with touchend, jQuery.fn.bind is used to replace jQuery.fn.one due to the fact that jQuery.fn.one doesn't work for multiple events. | [
"SAP",
"MODIFICATION",
"Because",
"touchcancel",
"is",
"used",
"together",
"with",
"touchend",
"jQuery",
".",
"fn",
".",
"bind",
"is",
"used",
"to",
"replace",
"jQuery",
".",
"fn",
".",
"one",
"due",
"to",
"the",
"fact",
"that",
"jQuery",
".",
"fn",
".",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jquery-mobile-custom.js#L2096-L2104 | train | stop event handler | [
30522,
3853,
2644,
11774,
3917,
1006,
2724,
1007,
1063,
1002,
2023,
1012,
4895,
8428,
2094,
1006,
3543,
5302,
3726,
18697,
3372,
1010,
2693,
11774,
3917,
1007,
1012,
4895,
8428,
2094,
1006,
3543,
16033,
5051,
15338,
1010,
2644,
11774,
3917,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Target.js | function(oData, fnFunction, oListener) {
var bHasListener = this.hasListeners("titleChanged"),
sTitle = this._oTitleProvider && this._oTitleProvider.getTitle();
this.attachEvent(this.M_EVENTS.TITLE_CHANGED, oData, fnFunction, oListener);
// in case the title is changed before the first event listener is attached, we need to notify, too
if (!bHasListener && sTitle && this._bIsDisplayed) {
this.fireTitleChanged({
name: this._oOptions._name,
title: sTitle
});
}
return this;
} | javascript | function(oData, fnFunction, oListener) {
var bHasListener = this.hasListeners("titleChanged"),
sTitle = this._oTitleProvider && this._oTitleProvider.getTitle();
this.attachEvent(this.M_EVENTS.TITLE_CHANGED, oData, fnFunction, oListener);
// in case the title is changed before the first event listener is attached, we need to notify, too
if (!bHasListener && sTitle && this._bIsDisplayed) {
this.fireTitleChanged({
name: this._oOptions._name,
title: sTitle
});
}
return this;
} | [
"function",
"(",
"oData",
",",
"fnFunction",
",",
"oListener",
")",
"{",
"var",
"bHasListener",
"=",
"this",
".",
"hasListeners",
"(",
"\"titleChanged\"",
")",
",",
"sTitle",
"=",
"this",
".",
"_oTitleProvider",
"&&",
"this",
".",
"_oTitleProvider",
".",
"ge... | Will be fired when the title of this Target has been changed.
@name sap.ui.core.routing.Target#titleChanged
@event
@param {object} oEvent
@param {sap.ui.base.EventProvider} oEvent.getSource
@param {object} oEvent.getParameters
@param {string} oEvent.getParameters.title The name of this target
@param {string} oEvent.getParameters.title The current displayed title
@private
Attach event-handler <code>fnFunction</code> to the 'titleChanged' event of this <code>sap.ui.core.routing.Target</code>.<br/>
When the first event handler is registered later than the last title change, it's still called with the last changed title because
when title is set with static text, the event is fired synchronously with the instantiation of this Target and the event handler can't
be registered before the event is fired.
@param {object} [oData] The object, that should be passed along with the event-object when firing the event.
@param {function} fnFunction The function to call, when the event occurs. This function will be called on the
oListener-instance (if present) or in a 'static way'.
@param {object} [oListener] Object on which to call the given function.
@return {sap.ui.core.routing.Target} <code>this</code> to allow method chaining
@private | [
"Will",
"be",
"fired",
"when",
"the",
"title",
"of",
"this",
"Target",
"has",
"been",
"changed",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Target.js#L209-L222 | train | attach titleChanged event to the control | [
30522,
3853,
1006,
1051,
2850,
2696,
1010,
1042,
2078,
11263,
27989,
1010,
19330,
27870,
3678,
1007,
1063,
13075,
1038,
14949,
9863,
24454,
1027,
2023,
1012,
30524,
4183,
2571,
21572,
17258,
2121,
1012,
2131,
3775,
9286,
1006,
1007,
1025,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
electron/electron | lib/browser/guest-window-manager.js | function (embedder, url, referrer, frameName, options, postData) {
let guest = frameToGuest.get(frameName)
if (frameName && (guest != null)) {
guest.loadURL(url)
return guest.webContents.id
}
// Remember the embedder window's id.
if (options.webPreferences == null) {
options.webPreferences = {}
}
guest = new BrowserWindow(options)
if (!options.webContents) {
// We should not call `loadURL` if the window was constructed from an
// existing webContents (window.open in a sandboxed renderer).
//
// Navigating to the url when creating the window from an existing
// webContents is not necessary (it will navigate there anyway).
const loadOptions = {
httpReferrer: referrer
}
if (postData != null) {
loadOptions.postData = postData
loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded'
if (postData.length > 0) {
const postDataFront = postData[0].bytes.toString()
const boundary = /^--.*[^-\r\n]/.exec(postDataFront)
if (boundary != null) {
loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}`
}
}
}
guest.loadURL(url, loadOptions)
}
return setupGuest(embedder, frameName, guest, options)
} | javascript | function (embedder, url, referrer, frameName, options, postData) {
let guest = frameToGuest.get(frameName)
if (frameName && (guest != null)) {
guest.loadURL(url)
return guest.webContents.id
}
// Remember the embedder window's id.
if (options.webPreferences == null) {
options.webPreferences = {}
}
guest = new BrowserWindow(options)
if (!options.webContents) {
// We should not call `loadURL` if the window was constructed from an
// existing webContents (window.open in a sandboxed renderer).
//
// Navigating to the url when creating the window from an existing
// webContents is not necessary (it will navigate there anyway).
const loadOptions = {
httpReferrer: referrer
}
if (postData != null) {
loadOptions.postData = postData
loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded'
if (postData.length > 0) {
const postDataFront = postData[0].bytes.toString()
const boundary = /^--.*[^-\r\n]/.exec(postDataFront)
if (boundary != null) {
loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}`
}
}
}
guest.loadURL(url, loadOptions)
}
return setupGuest(embedder, frameName, guest, options)
} | [
"function",
"(",
"embedder",
",",
"url",
",",
"referrer",
",",
"frameName",
",",
"options",
",",
"postData",
")",
"{",
"let",
"guest",
"=",
"frameToGuest",
".",
"get",
"(",
"frameName",
")",
"if",
"(",
"frameName",
"&&",
"(",
"guest",
"!=",
"null",
")"... | Create a new guest created by |embedder| with |options|. | [
"Create",
"a",
"new",
"guest",
"created",
"by",
"|embedder|",
"with",
"|options|",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/guest-window-manager.js#L109-L146 | train | Creates a new window from the embedder window. | [
30522,
3853,
1006,
7861,
8270,
4063,
1010,
24471,
2140,
1010,
6523,
14544,
1010,
4853,
18442,
1010,
7047,
1010,
2695,
2850,
2696,
1007,
1063,
2292,
4113,
30524,
999,
1027,
19701,
1007,
1007,
1063,
4113,
1012,
7170,
3126,
2140,
1006,
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... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(rm, oRoadMap, oStep){
var fCreateIcon = function(rm, oRoadMap, sId, sIcon, sAdditonalClass){
rm.write("<div");
rm.writeAttribute("id", sId + "-ico");
rm.addClass("sapUiRoadMapStepIco");
if (sAdditonalClass) {
rm.addClass(sAdditonalClass);
}
rm.writeClasses();
rm.write("></div>");
};
var bIsExpanded = oStep.getExpanded();
//Render the start step with an additional icon
renderStep(rm, oRoadMap, oStep, bIsExpanded ? ["sapUiRoadMapExpanded"] : null, function(rm, oRoadMap, oStep){
fCreateIcon(rm, oRoadMap, oStep.getId(), bIsExpanded ? "roundtripstart.gif" : "roundtrip.gif");
});
//Render the sub steps
var aSteps = oStep.getSubSteps();
for (var i = 0; i < aSteps.length; i++) {
var aClasses = ["sapUiRoadMapSubStep"];
if (!bIsExpanded && aSteps[i].getVisible()) {
aClasses.push("sapUiRoadMapHidden");
}
renderStep(rm, oRoadMap, aSteps[i], aClasses);
}
//Render the end step with an additional icon
aClasses = ["sapUiRoadMapExpanded", "sapUiRoadMapStepEnd"];
if (!bIsExpanded) {
aClasses.push("sapUiRoadMapHidden");
}
renderStep(rm, oRoadMap, oStep, aClasses, function(rm, oRoadMap, oStep){
fCreateIcon(rm, oRoadMap, oStep.getId() + "-expandend", "roundtripend.gif");
}, oStep.getId() + "-expandend");
} | javascript | function(rm, oRoadMap, oStep){
var fCreateIcon = function(rm, oRoadMap, sId, sIcon, sAdditonalClass){
rm.write("<div");
rm.writeAttribute("id", sId + "-ico");
rm.addClass("sapUiRoadMapStepIco");
if (sAdditonalClass) {
rm.addClass(sAdditonalClass);
}
rm.writeClasses();
rm.write("></div>");
};
var bIsExpanded = oStep.getExpanded();
//Render the start step with an additional icon
renderStep(rm, oRoadMap, oStep, bIsExpanded ? ["sapUiRoadMapExpanded"] : null, function(rm, oRoadMap, oStep){
fCreateIcon(rm, oRoadMap, oStep.getId(), bIsExpanded ? "roundtripstart.gif" : "roundtrip.gif");
});
//Render the sub steps
var aSteps = oStep.getSubSteps();
for (var i = 0; i < aSteps.length; i++) {
var aClasses = ["sapUiRoadMapSubStep"];
if (!bIsExpanded && aSteps[i].getVisible()) {
aClasses.push("sapUiRoadMapHidden");
}
renderStep(rm, oRoadMap, aSteps[i], aClasses);
}
//Render the end step with an additional icon
aClasses = ["sapUiRoadMapExpanded", "sapUiRoadMapStepEnd"];
if (!bIsExpanded) {
aClasses.push("sapUiRoadMapHidden");
}
renderStep(rm, oRoadMap, oStep, aClasses, function(rm, oRoadMap, oStep){
fCreateIcon(rm, oRoadMap, oStep.getId() + "-expandend", "roundtripend.gif");
}, oStep.getId() + "-expandend");
} | [
"function",
"(",
"rm",
",",
"oRoadMap",
",",
"oStep",
")",
"{",
"var",
"fCreateIcon",
"=",
"function",
"(",
"rm",
",",
"oRoadMap",
",",
"sId",
",",
"sIcon",
",",
"sAdditonalClass",
")",
"{",
"rm",
".",
"write",
"(",
"\"<div\"",
")",
";",
"rm",
".",
... | Writes the step HTML of the expandable step and its children into the rendermanger | [
"Writes",
"the",
"step",
"HTML",
"of",
"the",
"expandable",
"step",
"and",
"its",
"children",
"into",
"the",
"rendermanger"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L718-L755 | train | Renders the given step | [
30522,
3853,
1006,
28549,
1010,
20298,
4215,
2863,
2361,
1010,
9808,
2618,
2361,
1007,
1063,
13075,
4429,
29313,
28524,
1027,
3853,
1006,
28549,
1010,
20298,
4215,
2863,
2361,
1010,
15765,
1010,
14387,
2239,
1010,
6517,
23194,
16026,
26266,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/factory.js | updateAttrs | function updateAttrs (oldVnode, vnode) {
if (!oldVnode.data.attrs && !vnode.data.attrs) {
return
}
var key, cur, old;
var elm = vnode.elm;
var oldAttrs = oldVnode.data.attrs || {};
var attrs = vnode.data.attrs || {};
// clone observed objects, as the user probably wants to mutate it
if (attrs.__ob__) {
attrs = vnode.data.attrs = extend({}, attrs);
}
for (key in attrs) {
cur = attrs[key];
old = oldAttrs[key];
if (old !== cur) {
elm.setAttr(key, cur);
}
}
for (key in oldAttrs) {
if (attrs[key] == null) {
elm.setAttr(key);
}
}
} | javascript | function updateAttrs (oldVnode, vnode) {
if (!oldVnode.data.attrs && !vnode.data.attrs) {
return
}
var key, cur, old;
var elm = vnode.elm;
var oldAttrs = oldVnode.data.attrs || {};
var attrs = vnode.data.attrs || {};
// clone observed objects, as the user probably wants to mutate it
if (attrs.__ob__) {
attrs = vnode.data.attrs = extend({}, attrs);
}
for (key in attrs) {
cur = attrs[key];
old = oldAttrs[key];
if (old !== cur) {
elm.setAttr(key, cur);
}
}
for (key in oldAttrs) {
if (attrs[key] == null) {
elm.setAttr(key);
}
}
} | [
"function",
"updateAttrs",
"(",
"oldVnode",
",",
"vnode",
")",
"{",
"if",
"(",
"!",
"oldVnode",
".",
"data",
".",
"attrs",
"&&",
"!",
"vnode",
".",
"data",
".",
"attrs",
")",
"{",
"return",
"}",
"var",
"key",
",",
"cur",
",",
"old",
";",
"var",
"... | /* | [
"/",
"*"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/weex-vue-framework/factory.js#L4997-L5022 | train | update attrs of a node | [
30522,
3853,
10651,
19321,
2869,
1006,
2214,
16022,
10244,
1010,
1058,
3630,
3207,
1007,
1063,
2065,
1006,
999,
2214,
16022,
10244,
1012,
2951,
1012,
2012,
16344,
2015,
1004,
1004,
999,
1058,
3630,
3207,
1012,
2951,
1012,
2012,
16344,
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... |
eslint/eslint | lib/rules/no-this-before-super.js | setInvalid | function setInvalid(node) {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].invalidNodes.push(node);
}
}
} | javascript | function setInvalid(node) {
const segments = funcInfo.codePath.currentSegments;
for (let i = 0; i < segments.length; ++i) {
const segment = segments[i];
if (segment.reachable) {
segInfoMap[segment.id].invalidNodes.push(node);
}
}
} | [
"function",
"setInvalid",
"(",
"node",
")",
"{",
"const",
"segments",
"=",
"funcInfo",
".",
"codePath",
".",
"currentSegments",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"segments",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"segme... | Sets a given node as invalid.
@param {ASTNode} node - A node to set as invalid. This is one of
a ThisExpression and a Super.
@returns {void} | [
"Sets",
"a",
"given",
"node",
"as",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-this-before-super.js#L106-L116 | train | set invalid node | [
30522,
3853,
2275,
2378,
10175,
3593,
1006,
13045,
1007,
1063,
9530,
3367,
9214,
1027,
4569,
15459,
14876,
1012,
3642,
15069,
1012,
14731,
13910,
8163,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
9214,
1012,
3091,
1025,
1009... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
caolan/async | lib/some.js | some | function some(coll, iteratee, callback) {
return createTester(Boolean, res => res)(eachOf, coll, iteratee, callback)
} | javascript | function some(coll, iteratee, callback) {
return createTester(Boolean, res => res)(eachOf, coll, iteratee, callback)
} | [
"function",
"some",
"(",
"coll",
",",
"iteratee",
",",
"callback",
")",
"{",
"return",
"createTester",
"(",
"Boolean",
",",
"res",
"=>",
"res",
")",
"(",
"eachOf",
",",
"coll",
",",
"iteratee",
",",
"callback",
")",
"}"
] | Returns `true` if at least one element in the `coll` satisfies an async test.
If any iteratee call returns `true`, the main `callback` is immediately
called.
@name some
@static
@memberOf module:Collections
@method
@alias any
@category Collection
@param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
@param {AsyncFunction} iteratee - An async truth test to apply to each item
in the collections in parallel.
The iteratee should complete with a boolean `result` value.
Invoked with (item, callback).
@param {Function} [callback] - A callback which is called as soon as any
iteratee returns `true`, or after all the iteratee functions have finished.
Result will be either `true` or `false` depending on the values of the async
tests. Invoked with (err, result).
@returns {Promise} a promise, if no callback provided
@example
async.some(['file1','file2','file3'], function(filePath, callback) {
fs.access(filePath, function(err) {
callback(null, !err)
});
}, function(err, result) {
// if result is true then at least one of the files exists
}); | [
"Returns",
"true",
"if",
"at",
"least",
"one",
"element",
"in",
"the",
"coll",
"satisfies",
"an",
"async",
"test",
".",
"If",
"any",
"iteratee",
"call",
"returns",
"true",
"the",
"main",
"callback",
"is",
"immediately",
"called",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/some.js#L36-L38 | train | Returns true if coll contains any elements of iteratee. | [
30522,
3853,
2070,
1006,
8902,
2140,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
2709,
3443,
22199,
2121,
1006,
22017,
20898,
1010,
24501,
1027,
1028,
24501,
1007,
1006,
2169,
11253,
1010,
8902,
2140,
1010,
2009,
22139,
2063,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js | normalizeConfiguration | function normalizeConfiguration(oObject, oConfiguration) {
var oMetadata = oObject.getMetadata(),
aProperties = Object.keys(oMetadata.getAllProperties()),
aAggregations = Object.keys(oMetadata.getAllAggregations()),
aAssociations = Object.keys(oMetadata.getAllAssociations()),
aBindings = uniqueSort(aProperties.concat(aAggregations)),
aEvents = Object.keys(oMetadata.getAllEvents());
oConfiguration.properties = oConfiguration.properties === true ? aProperties : oConfiguration.properties;
oConfiguration.aggregations = oConfiguration.aggregations === true ? aAggregations : oConfiguration.aggregations;
oConfiguration.associations = oConfiguration.associations === true ? aAssociations : oConfiguration.associations;
oConfiguration.bindings = oConfiguration.bindings === true ? aBindings : oConfiguration.bindings;
oConfiguration.events = oConfiguration.events === true ? aEvents : oConfiguration.events;
oConfiguration.destroy = (oConfiguration.destroy == null) ? false : oConfiguration.destroy;
oConfiguration.parent = (oConfiguration.parent == null) ? false : oConfiguration.parent;
} | javascript | function normalizeConfiguration(oObject, oConfiguration) {
var oMetadata = oObject.getMetadata(),
aProperties = Object.keys(oMetadata.getAllProperties()),
aAggregations = Object.keys(oMetadata.getAllAggregations()),
aAssociations = Object.keys(oMetadata.getAllAssociations()),
aBindings = uniqueSort(aProperties.concat(aAggregations)),
aEvents = Object.keys(oMetadata.getAllEvents());
oConfiguration.properties = oConfiguration.properties === true ? aProperties : oConfiguration.properties;
oConfiguration.aggregations = oConfiguration.aggregations === true ? aAggregations : oConfiguration.aggregations;
oConfiguration.associations = oConfiguration.associations === true ? aAssociations : oConfiguration.associations;
oConfiguration.bindings = oConfiguration.bindings === true ? aBindings : oConfiguration.bindings;
oConfiguration.events = oConfiguration.events === true ? aEvents : oConfiguration.events;
oConfiguration.destroy = (oConfiguration.destroy == null) ? false : oConfiguration.destroy;
oConfiguration.parent = (oConfiguration.parent == null) ? false : oConfiguration.parent;
} | [
"function",
"normalizeConfiguration",
"(",
"oObject",
",",
"oConfiguration",
")",
"{",
"var",
"oMetadata",
"=",
"oObject",
".",
"getMetadata",
"(",
")",
",",
"aProperties",
"=",
"Object",
".",
"keys",
"(",
"oMetadata",
".",
"getAllProperties",
"(",
")",
")",
... | in case the configuration for a specific type is set to true translate this to the complete array in order not to get in trouble when deregistering properties | [
"in",
"case",
"the",
"configuration",
"for",
"a",
"specific",
"type",
"is",
"set",
"to",
"true",
"translate",
"this",
"to",
"the",
"complete",
"array",
"in",
"order",
"not",
"to",
"get",
"in",
"trouble",
"when",
"deregistering",
"properties"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js#L692-L708 | train | Normalizes the given configuration object. | [
30522,
3853,
3671,
4697,
8663,
8873,
27390,
3370,
1006,
1051,
16429,
20614,
1010,
1051,
8663,
8873,
27390,
3370,
1007,
1063,
13075,
18168,
12928,
2850,
2696,
1027,
1051,
16429,
20614,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1010,
19804,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/respondable.js | publish | function publish(source, data, keepalive) {
var topic = data.topic;
var subscriber = subscribers[topic];
if (subscriber) {
var responder = createResponder(source, null, data.uuid);
subscriber(data.message, keepalive, responder);
}
} | javascript | function publish(source, data, keepalive) {
var topic = data.topic;
var subscriber = subscribers[topic];
if (subscriber) {
var responder = createResponder(source, null, data.uuid);
subscriber(data.message, keepalive, responder);
}
} | [
"function",
"publish",
"(",
"source",
",",
"data",
",",
"keepalive",
")",
"{",
"var",
"topic",
"=",
"data",
".",
"topic",
";",
"var",
"subscriber",
"=",
"subscribers",
"[",
"topic",
"]",
";",
"if",
"(",
"subscriber",
")",
"{",
"var",
"responder",
"=",
... | Publishes the "respondable" message to the appropriate subscriber
@private
@param {Window} source The window from which the message originated
@param {Object} data The data sent with the message
@param {Boolean} keepalive Whether to allow multiple responses - default is false | [
"Publishes",
"the",
"respondable",
"message",
"to",
"the",
"appropriate",
"subscriber"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/respondable.js#L151-L159 | train | Publishes a message to a topic | [
30522,
3853,
10172,
1006,
3120,
1010,
2951,
1010,
2562,
11475,
3726,
1007,
1063,
13075,
8476,
1027,
2951,
1012,
8476,
1025,
13075,
4942,
29234,
2099,
1027,
17073,
1031,
8476,
1033,
1025,
2065,
1006,
4942,
29234,
2099,
1007,
1063,
13075,
686... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/npm-utils.js | check | function check(packages, opt) {
let deps = [];
const pkgJson = (opt) ? findPackageJson(opt.startDir) : findPackageJson();
let fileJson;
if (!pkgJson) {
throw new Error("Could not find a package.json file. Run 'npm init' to create one.");
}
try {
fileJson = JSON.parse(fs.readFileSync(pkgJson, "utf8"));
} catch (e) {
const error = new Error(e);
error.messageTemplate = "failed-to-read-json";
error.messageData = {
path: pkgJson,
message: e.message
};
throw error;
}
if (opt.devDependencies && typeof fileJson.devDependencies === "object") {
deps = deps.concat(Object.keys(fileJson.devDependencies));
}
if (opt.dependencies && typeof fileJson.dependencies === "object") {
deps = deps.concat(Object.keys(fileJson.dependencies));
}
return packages.reduce((status, pkg) => {
status[pkg] = deps.indexOf(pkg) !== -1;
return status;
}, {});
} | javascript | function check(packages, opt) {
let deps = [];
const pkgJson = (opt) ? findPackageJson(opt.startDir) : findPackageJson();
let fileJson;
if (!pkgJson) {
throw new Error("Could not find a package.json file. Run 'npm init' to create one.");
}
try {
fileJson = JSON.parse(fs.readFileSync(pkgJson, "utf8"));
} catch (e) {
const error = new Error(e);
error.messageTemplate = "failed-to-read-json";
error.messageData = {
path: pkgJson,
message: e.message
};
throw error;
}
if (opt.devDependencies && typeof fileJson.devDependencies === "object") {
deps = deps.concat(Object.keys(fileJson.devDependencies));
}
if (opt.dependencies && typeof fileJson.dependencies === "object") {
deps = deps.concat(Object.keys(fileJson.dependencies));
}
return packages.reduce((status, pkg) => {
status[pkg] = deps.indexOf(pkg) !== -1;
return status;
}, {});
} | [
"function",
"check",
"(",
"packages",
",",
"opt",
")",
"{",
"let",
"deps",
"=",
"[",
"]",
";",
"const",
"pkgJson",
"=",
"(",
"opt",
")",
"?",
"findPackageJson",
"(",
"opt",
".",
"startDir",
")",
":",
"findPackageJson",
"(",
")",
";",
"let",
"fileJson... | Check whether node modules are include in a project's package.json.
@param {string[]} packages Array of node module names
@param {Object} opt Options Object
@param {boolean} opt.dependencies Set to true to check for direct dependencies
@param {boolean} opt.devDependencies Set to true to check for development dependencies
@param {boolean} opt.startdir Directory to begin searching from
@returns {Object} An object whose keys are the module names
and values are booleans indicating installation. | [
"Check",
"whether",
"node",
"modules",
"are",
"include",
"in",
"a",
"project",
"s",
"package",
".",
"json",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/npm-utils.js#L100-L132 | train | Check if a list of packages is valid | [
30522,
3853,
4638,
1006,
14555,
1010,
23569,
1007,
1063,
2292,
2139,
4523,
1027,
1031,
1033,
1025,
9530,
3367,
1052,
2243,
2290,
22578,
2239,
1027,
1006,
23569,
1007,
1029,
2424,
23947,
4270,
22578,
2239,
1006,
23569,
1012,
2707,
4305,
2099... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
statsd/statsd | stats.js | flushMetrics | function flushMetrics() {
var time_stamp = Math.round(new Date().getTime() / 1000);
if (old_timestamp > 0) {
gauges[timestamp_lag_namespace] = (time_stamp - old_timestamp - (Number(conf.flushInterval)/1000));
}
old_timestamp = time_stamp;
var metrics_hash = {
counters: counters,
gauges: gauges,
timers: timers,
timer_counters: timer_counters,
sets: sets,
counter_rates: counter_rates,
timer_data: timer_data,
pctThreshold: pctThreshold,
histogram: conf.histogram
};
// After all listeners, reset the stats
backendEvents.once('flush', function clear_metrics(ts, metrics) {
// TODO: a lot of this should be moved up into an init/constructor so we don't have to do it every
// single flushInterval....
// allows us to flag all of these on with a single config but still override them individually
conf.deleteIdleStats = conf.deleteIdleStats !== undefined ? conf.deleteIdleStats : false;
if (conf.deleteIdleStats) {
conf.deleteCounters = conf.deleteCounters !== undefined ? conf.deleteCounters : true;
conf.deleteTimers = conf.deleteTimers !== undefined ? conf.deleteTimers : true;
conf.deleteSets = conf.deleteSets !== undefined ? conf.deleteSets : true;
conf.deleteGauges = conf.deleteGauges !== undefined ? conf.deleteGauges : true;
}
// Clear the counters
conf.deleteCounters = conf.deleteCounters || false;
for (var counter_key in metrics.counters) {
if (conf.deleteCounters) {
if ((counter_key.indexOf("packets_received") != -1) ||
(counter_key.indexOf("metrics_received") != -1) ||
(counter_key.indexOf("bad_lines_seen") != -1)) {
metrics.counters[counter_key] = 0;
} else {
delete(metrics.counters[counter_key]);
}
} else {
metrics.counters[counter_key] = 0;
}
}
// Clear the timers
conf.deleteTimers = conf.deleteTimers || false;
for (var timer_key in metrics.timers) {
if (conf.deleteTimers) {
delete(metrics.timers[timer_key]);
delete(metrics.timer_counters[timer_key]);
} else {
metrics.timers[timer_key] = [];
metrics.timer_counters[timer_key] = 0;
}
}
// Clear the sets
conf.deleteSets = conf.deleteSets || false;
for (var set_key in metrics.sets) {
if (conf.deleteSets) {
delete(metrics.sets[set_key]);
} else {
metrics.sets[set_key] = new set.Set();
}
}
// Normally gauges are not reset. so if we don't delete them, continue to persist previous value
conf.deleteGauges = conf.deleteGauges || false;
if (conf.deleteGauges) {
for (var gauge_key in metrics.gauges) {
delete(metrics.gauges[gauge_key]);
}
}
});
pm.process_metrics(metrics_hash, flushInterval, time_stamp, function emitFlush(metrics) {
backendEvents.emit('flush', time_stamp, metrics);
});
// Performing this setTimeout at the end of this method rather than the beginning
// helps ensure we adapt to negative clock skew by letting the method's latency
// introduce a short delay that should more than compensate.
setTimeout(flushMetrics, getFlushTimeout(flushInterval));
} | javascript | function flushMetrics() {
var time_stamp = Math.round(new Date().getTime() / 1000);
if (old_timestamp > 0) {
gauges[timestamp_lag_namespace] = (time_stamp - old_timestamp - (Number(conf.flushInterval)/1000));
}
old_timestamp = time_stamp;
var metrics_hash = {
counters: counters,
gauges: gauges,
timers: timers,
timer_counters: timer_counters,
sets: sets,
counter_rates: counter_rates,
timer_data: timer_data,
pctThreshold: pctThreshold,
histogram: conf.histogram
};
// After all listeners, reset the stats
backendEvents.once('flush', function clear_metrics(ts, metrics) {
// TODO: a lot of this should be moved up into an init/constructor so we don't have to do it every
// single flushInterval....
// allows us to flag all of these on with a single config but still override them individually
conf.deleteIdleStats = conf.deleteIdleStats !== undefined ? conf.deleteIdleStats : false;
if (conf.deleteIdleStats) {
conf.deleteCounters = conf.deleteCounters !== undefined ? conf.deleteCounters : true;
conf.deleteTimers = conf.deleteTimers !== undefined ? conf.deleteTimers : true;
conf.deleteSets = conf.deleteSets !== undefined ? conf.deleteSets : true;
conf.deleteGauges = conf.deleteGauges !== undefined ? conf.deleteGauges : true;
}
// Clear the counters
conf.deleteCounters = conf.deleteCounters || false;
for (var counter_key in metrics.counters) {
if (conf.deleteCounters) {
if ((counter_key.indexOf("packets_received") != -1) ||
(counter_key.indexOf("metrics_received") != -1) ||
(counter_key.indexOf("bad_lines_seen") != -1)) {
metrics.counters[counter_key] = 0;
} else {
delete(metrics.counters[counter_key]);
}
} else {
metrics.counters[counter_key] = 0;
}
}
// Clear the timers
conf.deleteTimers = conf.deleteTimers || false;
for (var timer_key in metrics.timers) {
if (conf.deleteTimers) {
delete(metrics.timers[timer_key]);
delete(metrics.timer_counters[timer_key]);
} else {
metrics.timers[timer_key] = [];
metrics.timer_counters[timer_key] = 0;
}
}
// Clear the sets
conf.deleteSets = conf.deleteSets || false;
for (var set_key in metrics.sets) {
if (conf.deleteSets) {
delete(metrics.sets[set_key]);
} else {
metrics.sets[set_key] = new set.Set();
}
}
// Normally gauges are not reset. so if we don't delete them, continue to persist previous value
conf.deleteGauges = conf.deleteGauges || false;
if (conf.deleteGauges) {
for (var gauge_key in metrics.gauges) {
delete(metrics.gauges[gauge_key]);
}
}
});
pm.process_metrics(metrics_hash, flushInterval, time_stamp, function emitFlush(metrics) {
backendEvents.emit('flush', time_stamp, metrics);
});
// Performing this setTimeout at the end of this method rather than the beginning
// helps ensure we adapt to negative clock skew by letting the method's latency
// introduce a short delay that should more than compensate.
setTimeout(flushMetrics, getFlushTimeout(flushInterval));
} | [
"function",
"flushMetrics",
"(",
")",
"{",
"var",
"time_stamp",
"=",
"Math",
".",
"round",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"/",
"1000",
")",
";",
"if",
"(",
"old_timestamp",
">",
"0",
")",
"{",
"gauges",
"[",
"timestamp_lag_na... | Flush metrics to each backend. | [
"Flush",
"metrics",
"to",
"each",
"backend",
"."
] | ef8e4d76d76c3a0cf771e3724cf79ea22f3c50d9 | https://github.com/statsd/statsd/blob/ef8e4d76d76c3a0cf771e3724cf79ea22f3c50d9/stats.js#L72-L159 | train | Flush metrics to the backend | [
30522,
3853,
13862,
12589,
2015,
1006,
1007,
1063,
13075,
2051,
1035,
11359,
1027,
8785,
1012,
2461,
1006,
2047,
3058,
1006,
1007,
1012,
2131,
7292,
1006,
1007,
1013,
6694,
1007,
1025,
2065,
1006,
2214,
1035,
2335,
15464,
2361,
1028,
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... |
vuejs/vue-devtools | src/devtools/index.js | initApp | function initApp (shell) {
shell.connect(bridge => {
window.bridge = bridge
if (Vue.prototype.hasOwnProperty('$shared')) {
destroySharedData()
} else {
Object.defineProperty(Vue.prototype, '$shared', {
get: () => SharedData
})
}
initSharedData({
bridge,
Vue,
persist: true
})
if (SharedData.logDetected) {
bridge.send('log-detected-vue')
}
bridge.once('ready', version => {
store.commit(
'SHOW_MESSAGE',
'Ready. Detected Vue ' + version + '.'
)
bridge.send('events:toggle-recording', store.state.events.enabled)
if (isChrome) {
chrome.runtime.sendMessage('vue-panel-load')
}
})
bridge.once('proxy-fail', () => {
store.commit(
'SHOW_MESSAGE',
'Proxy injection failed.'
)
})
bridge.on('flush', payload => {
store.commit('components/FLUSH', parse(payload))
})
bridge.on('instance-details', details => {
store.commit('components/RECEIVE_INSTANCE_DETAILS', parse(details))
})
bridge.on('toggle-instance', payload => {
store.commit('components/TOGGLE_INSTANCE', parse(payload))
})
bridge.on('vuex:init', () => {
store.commit('vuex/INIT')
})
bridge.on('vuex:mutation', payload => {
store.commit('vuex/RECEIVE_MUTATION', payload)
})
bridge.on('vuex:inspected-state', ({ index, snapshot }) => {
store.commit('vuex/RECEIVE_STATE', { index, snapshot })
if (index === -1) {
store.commit('vuex/UPDATE_BASE_STATE', snapshot)
} else if (store.getters['vuex/absoluteInspectedIndex'] === index) {
store.commit('vuex/UPDATE_INSPECTED_STATE', snapshot)
}
if (VuexResolve.travel) {
VuexResolve.travel(snapshot)
}
requestAnimationFrame(() => {
SharedData.snapshotLoading = false
})
})
bridge.on('event:triggered', payload => {
store.commit('events/RECEIVE_EVENT', parse(payload))
if (router.currentRoute.name !== 'events') {
store.commit('events/INCREASE_NEW_EVENT_COUNT')
}
})
bridge.on('router:init', payload => {
store.commit('router/INIT', parse(payload))
})
bridge.on('router:changed', payload => {
store.commit('router/CHANGED', parse(payload))
})
bridge.on('routes:init', payload => {
store.commit('routes/INIT', parse(payload))
})
bridge.on('routes:changed', payload => {
store.commit('routes/CHANGED', parse(payload))
})
// register filters
Vue.filter('formatTime', function (timestamp) {
return (new Date(timestamp)).toString().match(/\d\d:\d\d:\d\d/)[0]
})
bridge.on('events:reset', () => {
store.commit('events/RESET')
})
bridge.on('inspect-instance', id => {
ensurePaneShown(() => {
inspectInstance(id)
})
})
bridge.on('perf:add-metric', data => {
store.commit('perf/ADD_METRIC', data)
})
bridge.on('perf:upsert-metric', ({ type, data }) => {
store.commit('perf/UPSERT_METRIC', { type, data })
})
initEnv(Vue)
app = new Vue({
extends: App,
router,
store,
data: {
isBeta
},
watch: {
'$shared.theme': {
handler (value) {
if (value === 'dark' || (value === 'auto' && chromeTheme === 'dark')) {
document.body.classList.add('vue-ui-dark-mode')
} else {
document.body.classList.remove('vue-ui-dark-mode')
}
},
immediate: true
}
}
}).$mount('#app')
})
} | javascript | function initApp (shell) {
shell.connect(bridge => {
window.bridge = bridge
if (Vue.prototype.hasOwnProperty('$shared')) {
destroySharedData()
} else {
Object.defineProperty(Vue.prototype, '$shared', {
get: () => SharedData
})
}
initSharedData({
bridge,
Vue,
persist: true
})
if (SharedData.logDetected) {
bridge.send('log-detected-vue')
}
bridge.once('ready', version => {
store.commit(
'SHOW_MESSAGE',
'Ready. Detected Vue ' + version + '.'
)
bridge.send('events:toggle-recording', store.state.events.enabled)
if (isChrome) {
chrome.runtime.sendMessage('vue-panel-load')
}
})
bridge.once('proxy-fail', () => {
store.commit(
'SHOW_MESSAGE',
'Proxy injection failed.'
)
})
bridge.on('flush', payload => {
store.commit('components/FLUSH', parse(payload))
})
bridge.on('instance-details', details => {
store.commit('components/RECEIVE_INSTANCE_DETAILS', parse(details))
})
bridge.on('toggle-instance', payload => {
store.commit('components/TOGGLE_INSTANCE', parse(payload))
})
bridge.on('vuex:init', () => {
store.commit('vuex/INIT')
})
bridge.on('vuex:mutation', payload => {
store.commit('vuex/RECEIVE_MUTATION', payload)
})
bridge.on('vuex:inspected-state', ({ index, snapshot }) => {
store.commit('vuex/RECEIVE_STATE', { index, snapshot })
if (index === -1) {
store.commit('vuex/UPDATE_BASE_STATE', snapshot)
} else if (store.getters['vuex/absoluteInspectedIndex'] === index) {
store.commit('vuex/UPDATE_INSPECTED_STATE', snapshot)
}
if (VuexResolve.travel) {
VuexResolve.travel(snapshot)
}
requestAnimationFrame(() => {
SharedData.snapshotLoading = false
})
})
bridge.on('event:triggered', payload => {
store.commit('events/RECEIVE_EVENT', parse(payload))
if (router.currentRoute.name !== 'events') {
store.commit('events/INCREASE_NEW_EVENT_COUNT')
}
})
bridge.on('router:init', payload => {
store.commit('router/INIT', parse(payload))
})
bridge.on('router:changed', payload => {
store.commit('router/CHANGED', parse(payload))
})
bridge.on('routes:init', payload => {
store.commit('routes/INIT', parse(payload))
})
bridge.on('routes:changed', payload => {
store.commit('routes/CHANGED', parse(payload))
})
// register filters
Vue.filter('formatTime', function (timestamp) {
return (new Date(timestamp)).toString().match(/\d\d:\d\d:\d\d/)[0]
})
bridge.on('events:reset', () => {
store.commit('events/RESET')
})
bridge.on('inspect-instance', id => {
ensurePaneShown(() => {
inspectInstance(id)
})
})
bridge.on('perf:add-metric', data => {
store.commit('perf/ADD_METRIC', data)
})
bridge.on('perf:upsert-metric', ({ type, data }) => {
store.commit('perf/UPSERT_METRIC', { type, data })
})
initEnv(Vue)
app = new Vue({
extends: App,
router,
store,
data: {
isBeta
},
watch: {
'$shared.theme': {
handler (value) {
if (value === 'dark' || (value === 'auto' && chromeTheme === 'dark')) {
document.body.classList.add('vue-ui-dark-mode')
} else {
document.body.classList.remove('vue-ui-dark-mode')
}
},
immediate: true
}
}
}).$mount('#app')
})
} | [
"function",
"initApp",
"(",
"shell",
")",
"{",
"shell",
".",
"connect",
"(",
"bridge",
"=>",
"{",
"window",
".",
"bridge",
"=",
"bridge",
"if",
"(",
"Vue",
".",
"prototype",
".",
"hasOwnProperty",
"(",
"'$shared'",
")",
")",
"{",
"destroySharedData",
"("... | Connect then init the app. We need to reconnect on every reload, because a
new backend will be injected.
@param {Object} shell | [
"Connect",
"then",
"init",
"the",
"app",
".",
"We",
"need",
"to",
"reconnect",
"on",
"every",
"reload",
"because",
"a",
"new",
"backend",
"will",
"be",
"injected",
"."
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/devtools/index.js#L87-L237 | train | Initialize the app | [
30522,
3853,
1999,
6590,
9397,
1006,
5806,
1007,
1063,
5806,
1012,
7532,
1006,
2958,
1027,
1028,
1063,
3332,
1012,
2958,
1027,
2958,
2065,
1006,
24728,
2063,
1012,
8773,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
1005,
1002,
4207,
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/autocomplete/js/autocompleteParentScopeDirective.js | connectScopes | function connectScopes() {
var scopeDigesting = false;
var newScopeDigesting = false;
scope.$watch(function() {
if (newScopeDigesting || scopeDigesting) {
return;
}
scopeDigesting = true;
scope.$$postDigest(function() {
if (!newScopeDigesting) {
newScope.$digest();
}
scopeDigesting = newScopeDigesting = false;
});
});
newScope.$watch(function() {
newScopeDigesting = true;
});
} | javascript | function connectScopes() {
var scopeDigesting = false;
var newScopeDigesting = false;
scope.$watch(function() {
if (newScopeDigesting || scopeDigesting) {
return;
}
scopeDigesting = true;
scope.$$postDigest(function() {
if (!newScopeDigesting) {
newScope.$digest();
}
scopeDigesting = newScopeDigesting = false;
});
});
newScope.$watch(function() {
newScopeDigesting = true;
});
} | [
"function",
"connectScopes",
"(",
")",
"{",
"var",
"scopeDigesting",
"=",
"false",
";",
"var",
"newScopeDigesting",
"=",
"false",
";",
"scope",
".",
"$watch",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"newScopeDigesting",
"||",
"scopeDigesting",
")",
"{",
... | Creates watchers on scope and newScope that ensure that for any
$digest of scope, newScope is also $digested. | [
"Creates",
"watchers",
"on",
"scope",
"and",
"newScope",
"that",
"ensure",
"that",
"for",
"any",
"$digest",
"of",
"scope",
"newScope",
"is",
"also",
"$digested",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteParentScopeDirective.js#L50-L72 | train | Connect scopes to the new scope | [
30522,
3853,
8539,
16186,
2015,
1006,
1007,
1063,
13075,
9531,
4305,
8449,
3436,
1027,
6270,
1025,
13075,
2739,
16186,
4305,
8449,
3436,
1027,
6270,
1025,
9531,
1012,
1002,
3422,
1006,
3853,
1006,
1007,
1063,
2065,
1006,
2739,
16186,
4305,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(sAnimationMode) {
checkEnum(Configuration.AnimationMode, sAnimationMode, "animationMode");
// Set the animation to on or off depending on the animation mode to ensure backward compatibility.
this.animation = (sAnimationMode !== Configuration.AnimationMode.minimal && sAnimationMode !== Configuration.AnimationMode.none);
// Set the animation mode and update html attributes.
this.animationMode = sAnimationMode;
if (this._oCore && this._oCore._setupAnimation) {
this._oCore._setupAnimation();
}
} | javascript | function(sAnimationMode) {
checkEnum(Configuration.AnimationMode, sAnimationMode, "animationMode");
// Set the animation to on or off depending on the animation mode to ensure backward compatibility.
this.animation = (sAnimationMode !== Configuration.AnimationMode.minimal && sAnimationMode !== Configuration.AnimationMode.none);
// Set the animation mode and update html attributes.
this.animationMode = sAnimationMode;
if (this._oCore && this._oCore._setupAnimation) {
this._oCore._setupAnimation();
}
} | [
"function",
"(",
"sAnimationMode",
")",
"{",
"checkEnum",
"(",
"Configuration",
".",
"AnimationMode",
",",
"sAnimationMode",
",",
"\"animationMode\"",
")",
";",
"// Set the animation to on or off depending on the animation mode to ensure backward compatibility.",
"this",
".",
"... | Sets the current animation mode.
Expects an animation mode as string and validates it. If a wrong animation mode was set, an error is
thrown. If the mode is valid it is set, then the attributes <code>data-sap-ui-animation</code> and
<code>data-sap-ui-animation-mode</code> of the HTML document root element are also updated.
If the <code>animationMode</code> is <code>Configuration.AnimationMode.none</code> the old
<code>animation</code> property is set to <code>false</code>, otherwise it is set to <code>true</code>.
@param {sap.ui.core.Configuration.AnimationMode} sAnimationMode A valid animation mode
@throws {Error} If the provided <code>sAnimationMode</code> does not exist, an error is thrown
@since 1.50.0
@public | [
"Sets",
"the",
"current",
"animation",
"mode",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Configuration.js#L1016-L1027 | train | Sets the animation mode of the control. | [
30522,
3853,
1006,
2624,
9581,
3508,
5302,
3207,
1007,
1063,
4638,
2368,
2819,
1006,
9563,
1012,
7284,
5302,
3207,
1010,
2624,
9581,
3508,
5302,
3207,
1010,
1000,
7284,
5302,
3207,
1000,
1007,
1025,
1013,
1013,
2275,
1996,
7284,
2000,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/text.js | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and perform cached load.
fontSrc = this.lookupFont(data.font || DEFAULT_FONT) || data.font;
cache.get(fontSrc, function doLoadFont () {
return loadFont(fontSrc, data.yOffset);
}).then(function setFont (font) {
var fontImgSrc;
if (font.pages.length !== 1) {
throw new Error('Currently only single-page bitmap fonts are supported.');
}
if (!fontWidthFactors[fontSrc]) {
font.widthFactor = fontWidthFactors[font] = computeFontWidthFactor(font);
}
// Update geometry given font metrics.
self.updateGeometry(geometry, font);
// Set font and update layout.
self.currentFont = font;
self.updateLayout();
// Look up font image URL to use, and perform cached load.
fontImgSrc = self.getFontImageSrc();
cache.get(fontImgSrc, function () {
return loadTexture(fontImgSrc);
}).then(function (image) {
// Make mesh visible and apply font image as texture.
var texture = self.texture;
texture.image = image;
texture.needsUpdate = true;
textures[data.font] = texture;
self.texture = texture;
self.mesh.visible = true;
el.emit('textfontset', {font: data.font, fontObj: font});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
} | javascript | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and perform cached load.
fontSrc = this.lookupFont(data.font || DEFAULT_FONT) || data.font;
cache.get(fontSrc, function doLoadFont () {
return loadFont(fontSrc, data.yOffset);
}).then(function setFont (font) {
var fontImgSrc;
if (font.pages.length !== 1) {
throw new Error('Currently only single-page bitmap fonts are supported.');
}
if (!fontWidthFactors[fontSrc]) {
font.widthFactor = fontWidthFactors[font] = computeFontWidthFactor(font);
}
// Update geometry given font metrics.
self.updateGeometry(geometry, font);
// Set font and update layout.
self.currentFont = font;
self.updateLayout();
// Look up font image URL to use, and perform cached load.
fontImgSrc = self.getFontImageSrc();
cache.get(fontImgSrc, function () {
return loadTexture(fontImgSrc);
}).then(function (image) {
// Make mesh visible and apply font image as texture.
var texture = self.texture;
texture.image = image;
texture.needsUpdate = true;
textures[data.font] = texture;
self.texture = texture;
self.mesh.visible = true;
el.emit('textfontset', {font: data.font, fontObj: font});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"fontSrc",
";",
"var",
"geometry",
"=",
"this",
".",
"geometry",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"da... | Load font for geometry, load font image for material, and apply. | [
"Load",
"font",
"for",
"geometry",
"load",
"font",
"image",
"for",
"material",
"and",
"apply",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L194-L249 | train | Update the geometry and layout | [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
3449,
1027,
2023,
1012,
30524,
15489,
9675,
1012,
2478,
1996,
12398,
15489,
1012,
1005,
1007,
1025,
1065,
1013,
1013,
2191,
8841,
2076,
15489,
19948,
1012,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/ExtensionLoader.js | loadExtension | function loadExtension(name, config, entryPoint) {
var promise = new $.Deferred();
// Try to load the package.json to figure out if we are loading a theme.
ExtensionUtils.loadMetadata(config.baseUrl).always(promise.resolve);
return promise
.then(function (metadata) {
// No special handling for themes... Let the promise propagate into the ExtensionManager
if (metadata && metadata.theme) {
return;
}
if (!metadata.disabled) {
return loadExtensionModule(name, config, entryPoint);
} else {
return new $.Deferred().reject("disabled").promise();
}
})
.then(function () {
exports.trigger("load", config.baseUrl);
}, function (err) {
if (err === "disabled") {
exports.trigger("disabled", config.baseUrl);
} else {
exports.trigger("loadFailed", config.baseUrl);
}
});
} | javascript | function loadExtension(name, config, entryPoint) {
var promise = new $.Deferred();
// Try to load the package.json to figure out if we are loading a theme.
ExtensionUtils.loadMetadata(config.baseUrl).always(promise.resolve);
return promise
.then(function (metadata) {
// No special handling for themes... Let the promise propagate into the ExtensionManager
if (metadata && metadata.theme) {
return;
}
if (!metadata.disabled) {
return loadExtensionModule(name, config, entryPoint);
} else {
return new $.Deferred().reject("disabled").promise();
}
})
.then(function () {
exports.trigger("load", config.baseUrl);
}, function (err) {
if (err === "disabled") {
exports.trigger("disabled", config.baseUrl);
} else {
exports.trigger("loadFailed", config.baseUrl);
}
});
} | [
"function",
"loadExtension",
"(",
"name",
",",
"config",
",",
"entryPoint",
")",
"{",
"var",
"promise",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// Try to load the package.json to figure out if we are loading a theme.",
"ExtensionUtils",
".",
"loadMetadata",
... | Loads the extension that lives at baseUrl into its own Require.js context
@param {!string} name, used to identify the extension
@param {!{baseUrl: string}} config object with baseUrl property containing absolute path of extension
@param {!string} entryPoint, name of the main js file to load
@return {!$.Promise} A promise object that is resolved when the extension is loaded, or rejected
if the extension fails to load or throws an exception immediately when loaded.
(Note: if extension contains a JS syntax error, promise is resolved not rejected). | [
"Loads",
"the",
"extension",
"that",
"lives",
"at",
"baseUrl",
"into",
"its",
"own",
"Require",
".",
"js",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L248-L276 | train | Load an extension module | [
30522,
3853,
7170,
10288,
29048,
1006,
2171,
1010,
9530,
8873,
2290,
1010,
4443,
8400,
1007,
1063,
13075,
4872,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
1013,
1013,
3046,
2000,
7170,
1996,
7427,
1012,
1046,
3385,
2000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onSignInWithCustomToken | function onSignInWithCustomToken(event) {
// The token can be directly specified on the html element.
var token = $('#user-custom-token').val();
auth.signInWithCustomToken(token)
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | function onSignInWithCustomToken(event) {
// The token can be directly specified on the html element.
var token = $('#user-custom-token').val();
auth.signInWithCustomToken(token)
.then(onAuthUserCredentialSuccess, onAuthError);
} | [
"function",
"onSignInWithCustomToken",
"(",
"event",
")",
"{",
"// The token can be directly specified on the html element.",
"var",
"token",
"=",
"$",
"(",
"'#user-custom-token'",
")",
".",
"val",
"(",
")",
";",
"auth",
".",
"signInWithCustomToken",
"(",
"token",
")"... | Signs in with a custom token.
@param {DOMEvent} event HTML DOM event returned by the listener. | [
"Signs",
"in",
"with",
"a",
"custom",
"token",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L373-L379 | train | Signs in with a custom token | [
30522,
3853,
2006,
5332,
29076,
2078,
24415,
7874,
20389,
18715,
2368,
1006,
2724,
1007,
1063,
1013,
1013,
1996,
19204,
2064,
2022,
3495,
9675,
2006,
1996,
16129,
5783,
1012,
13075,
19204,
1027,
1002,
1006,
1005,
1001,
5310,
1011,
7661,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/NavigationAndHistory/NavigationProvider.js | _validateFrame | function _validateFrame(entry) {
var deferred = new $.Deferred(),
fileEntry = FileSystem.getFileForPath(entry.filePath);
if (entry.inMem) {
var indexInWS = MainViewManager.findInWorkingSet(entry.paneId, entry.filePath);
// Remove entry if InMemoryFile is not found in Working set
if (indexInWS === -1) {
deferred.reject();
} else {
deferred.resolve();
}
} else {
fileEntry.exists(function (err, exists) {
if (!err && exists) {
// Additional check to handle external modification and mutation of the doc text affecting markers
if (fileEntry._hash !== entry._hash) {
deferred.reject();
} else if (!entry._validateMarkers()) {
deferred.reject();
} else {
deferred.resolve();
}
} else {
deferred.reject();
}
});
}
return deferred.promise();
} | javascript | function _validateFrame(entry) {
var deferred = new $.Deferred(),
fileEntry = FileSystem.getFileForPath(entry.filePath);
if (entry.inMem) {
var indexInWS = MainViewManager.findInWorkingSet(entry.paneId, entry.filePath);
// Remove entry if InMemoryFile is not found in Working set
if (indexInWS === -1) {
deferred.reject();
} else {
deferred.resolve();
}
} else {
fileEntry.exists(function (err, exists) {
if (!err && exists) {
// Additional check to handle external modification and mutation of the doc text affecting markers
if (fileEntry._hash !== entry._hash) {
deferred.reject();
} else if (!entry._validateMarkers()) {
deferred.reject();
} else {
deferred.resolve();
}
} else {
deferred.reject();
}
});
}
return deferred.promise();
} | [
"function",
"_validateFrame",
"(",
"entry",
")",
"{",
"var",
"deferred",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"fileEntry",
"=",
"FileSystem",
".",
"getFileForPath",
"(",
"entry",
".",
"filePath",
")",
";",
"if",
"(",
"entry",
".",
"inMem",
... | Function to check existence of a file entry, validity of markers
@private | [
"Function",
"to",
"check",
"existence",
"of",
"a",
"file",
"entry",
"validity",
"of",
"markers"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/NavigationProvider.js#L98-L128 | train | Validate a frame | [
30522,
3853,
1035,
9398,
3686,
15643,
1006,
4443,
1007,
1063,
13075,
13366,
28849,
2094,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
5371,
4765,
2854,
1027,
6764,
27268,
6633,
1012,
2131,
8873,
2571,
29278,
15069,
1006,
44... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | dist/howler.js | function() {
var self = this;
var parent = self._parent;
// Round up the duration to account for the lower precision in HTML5 Audio.
parent._duration = Math.ceil(self._node.duration * 10) / 10;
// Setup a sprite if none is defined.
if (Object.keys(parent._sprite).length === 0) {
parent._sprite = {__default: [0, parent._duration * 1000]};
}
if (parent._state !== 'loaded') {
parent._state = 'loaded';
parent._emit('load');
parent._loadQueue();
}
// Clear the event listener.
self._node.removeEventListener(Howler._canPlayEvent, self._loadFn, false);
} | javascript | function() {
var self = this;
var parent = self._parent;
// Round up the duration to account for the lower precision in HTML5 Audio.
parent._duration = Math.ceil(self._node.duration * 10) / 10;
// Setup a sprite if none is defined.
if (Object.keys(parent._sprite).length === 0) {
parent._sprite = {__default: [0, parent._duration * 1000]};
}
if (parent._state !== 'loaded') {
parent._state = 'loaded';
parent._emit('load');
parent._loadQueue();
}
// Clear the event listener.
self._node.removeEventListener(Howler._canPlayEvent, self._loadFn, false);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"parent",
"=",
"self",
".",
"_parent",
";",
"// Round up the duration to account for the lower precision in HTML5 Audio.",
"parent",
".",
"_duration",
"=",
"Math",
".",
"ceil",
"(",
"self",
".",
... | HTML5 Audio canplaythrough listener callback. | [
"HTML5",
"Audio",
"canplaythrough",
"listener",
"callback",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2270-L2290 | train | Load the audio. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
6687,
1027,
2969,
1012,
1035,
6687,
1025,
1013,
1013,
2461,
2039,
1996,
9367,
2000,
4070,
2005,
1996,
2896,
11718,
1999,
16129,
2629,
5746,
1012,
6687,
1012,
1035,
9367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/react-native.js | urlencode | function urlencode(obj) {
var pairs = [];
for (var key in obj) {
if ({}.hasOwnProperty.call(obj, key))
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
}
return pairs.join('&');
} | javascript | function urlencode(obj) {
var pairs = [];
for (var key in obj) {
if ({}.hasOwnProperty.call(obj, key))
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
}
return pairs.join('&');
} | [
"function",
"urlencode",
"(",
"obj",
")",
"{",
"var",
"pairs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"{",
"}",
".",
"hasOwnProperty",
".",
"call",
"(",
"obj",
",",
"key",
")",
")",
"pairs",
".",
"push",... | Extract key/value pairs from an object and encode them for
use in a query string | [
"Extract",
"key",
"/",
"value",
"pairs",
"from",
"an",
"object",
"and",
"encode",
"them",
"for",
"use",
"in",
"a",
"query",
"string"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/plugins/react-native.js#L45-L52 | train | Encode an object to a string | [
30522,
3853,
24471,
7770,
16044,
30524,
1006,
3145,
1007,
1009,
1005,
1027,
1005,
1009,
4372,
16044,
9496,
9006,
29513,
3372,
1006,
27885,
3501,
1031,
3145,
1033,
1007,
1007,
1025,
1065,
2709,
7689,
1012,
3693,
1006,
1005,
1004,
1005,
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/languageTools/LanguageClient/ProtocolAdapter.js | initialize | function initialize(connection, params) {
var rootPath = params.rootPath,
workspaceFolders = params.rootPaths;
if(!rootPath && workspaceFolders && Array.isArray(workspaceFolders)) {
rootPath = workspaceFolders[0];
}
if (!workspaceFolders) {
workspaceFolders = [rootPath];
}
if (workspaceFolders.length) {
workspaceFolders = Utils.convertToWorkspaceFolders(workspaceFolders);
}
var _params = {
rootPath: rootPath,
rootUri: Utils.pathToUri(rootPath),
processId: process.pid,
capabilities: params.capabilities,
workspaceFolders: workspaceFolders
};
return connection.sendRequest(protocol.InitializeRequest.type, _params);
} | javascript | function initialize(connection, params) {
var rootPath = params.rootPath,
workspaceFolders = params.rootPaths;
if(!rootPath && workspaceFolders && Array.isArray(workspaceFolders)) {
rootPath = workspaceFolders[0];
}
if (!workspaceFolders) {
workspaceFolders = [rootPath];
}
if (workspaceFolders.length) {
workspaceFolders = Utils.convertToWorkspaceFolders(workspaceFolders);
}
var _params = {
rootPath: rootPath,
rootUri: Utils.pathToUri(rootPath),
processId: process.pid,
capabilities: params.capabilities,
workspaceFolders: workspaceFolders
};
return connection.sendRequest(protocol.InitializeRequest.type, _params);
} | [
"function",
"initialize",
"(",
"connection",
",",
"params",
")",
"{",
"var",
"rootPath",
"=",
"params",
".",
"rootPath",
",",
"workspaceFolders",
"=",
"params",
".",
"rootPaths",
";",
"if",
"(",
"!",
"rootPath",
"&&",
"workspaceFolders",
"&&",
"Array",
".",
... | Server commands | [
"Server",
"commands"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/languageTools/LanguageClient/ProtocolAdapter.js#L283-L308 | train | Initialize the application | [
30522,
3853,
3988,
4697,
1006,
4434,
1010,
11498,
5244,
1007,
1063,
13075,
7117,
15069,
1027,
11498,
5244,
1012,
7117,
15069,
1010,
2573,
15327,
10371,
2545,
1027,
11498,
5244,
1012,
7117,
15069,
2015,
1025,
2065,
1006,
999,
7117,
15069,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nodejs/node-gyp | lib/configure.js | findPython | function findPython() {
const SKIP=0, FAIL=1
const toCheck = [
{
before: () => {
if (!this.configPython) {
this.addLog(
'Python is not set from command line or npm configuration')
return SKIP
}
this.addLog('checking Python explicitly set from command line or ' +
'npm configuration')
this.addLog('- "--python=" or "npm config get python" is ' +
`"${this.configPython}"`)
},
check: this.checkCommand,
arg: this.configPython,
},
{
before: () => {
if (!this.env.PYTHON) {
this.addLog('Python is not set from environment variable PYTHON')
return SKIP
}
this.addLog(
'checking Python explicitly set from environment variable PYTHON')
this.addLog(`- process.env.PYTHON is "${this.env.PYTHON}"`)
},
check: this.checkCommand,
arg: this.env.PYTHON,
},
{
before: () => { this.addLog('checking if "python2" can be used') },
check: this.checkCommand,
arg: 'python2',
},
{
before: () => { this.addLog('checking if "python" can be used') },
check: this.checkCommand,
arg: 'python',
},
{
before: () => {
if (!this.win) {
// Everything after this is Windows specific
return FAIL
}
this.addLog(
'checking if the py launcher can be used to find Python 2')
},
check: this.checkPyLauncher,
},
{
before: () => {
this.addLog(
'checking if Python 2 is installed in the default location')
},
check: this.checkExecPath,
arg: this.defaultLocation,
},
]
function runChecks(err) {
this.log.silly('runChecks: err = %j', err && err.stack || err)
const check = toCheck.shift()
if (!check) {
return this.fail()
}
const before = check.before.apply(this)
if (before === SKIP) {
return runChecks.apply(this)
}
if (before === FAIL) {
return this.fail()
}
const args = [ runChecks.bind(this) ]
if (check.arg) {
args.unshift(check.arg)
}
check.check.apply(this, args)
}
runChecks.apply(this)
} | javascript | function findPython() {
const SKIP=0, FAIL=1
const toCheck = [
{
before: () => {
if (!this.configPython) {
this.addLog(
'Python is not set from command line or npm configuration')
return SKIP
}
this.addLog('checking Python explicitly set from command line or ' +
'npm configuration')
this.addLog('- "--python=" or "npm config get python" is ' +
`"${this.configPython}"`)
},
check: this.checkCommand,
arg: this.configPython,
},
{
before: () => {
if (!this.env.PYTHON) {
this.addLog('Python is not set from environment variable PYTHON')
return SKIP
}
this.addLog(
'checking Python explicitly set from environment variable PYTHON')
this.addLog(`- process.env.PYTHON is "${this.env.PYTHON}"`)
},
check: this.checkCommand,
arg: this.env.PYTHON,
},
{
before: () => { this.addLog('checking if "python2" can be used') },
check: this.checkCommand,
arg: 'python2',
},
{
before: () => { this.addLog('checking if "python" can be used') },
check: this.checkCommand,
arg: 'python',
},
{
before: () => {
if (!this.win) {
// Everything after this is Windows specific
return FAIL
}
this.addLog(
'checking if the py launcher can be used to find Python 2')
},
check: this.checkPyLauncher,
},
{
before: () => {
this.addLog(
'checking if Python 2 is installed in the default location')
},
check: this.checkExecPath,
arg: this.defaultLocation,
},
]
function runChecks(err) {
this.log.silly('runChecks: err = %j', err && err.stack || err)
const check = toCheck.shift()
if (!check) {
return this.fail()
}
const before = check.before.apply(this)
if (before === SKIP) {
return runChecks.apply(this)
}
if (before === FAIL) {
return this.fail()
}
const args = [ runChecks.bind(this) ]
if (check.arg) {
args.unshift(check.arg)
}
check.check.apply(this, args)
}
runChecks.apply(this)
} | [
"function",
"findPython",
"(",
")",
"{",
"const",
"SKIP",
"=",
"0",
",",
"FAIL",
"=",
"1",
"const",
"toCheck",
"=",
"[",
"{",
"before",
":",
"(",
")",
"=>",
"{",
"if",
"(",
"!",
"this",
".",
"configPython",
")",
"{",
"this",
".",
"addLog",
"(",
... | Find Python by trying a sequence of possibilities. Ignore errors, keep trying until Python is found. | [
"Find",
"Python",
"by",
"trying",
"a",
"sequence",
"of",
"possibilities",
".",
"Ignore",
"errors",
"keep",
"trying",
"until",
"Python",
"is",
"found",
"."
] | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/configure.js#L398-L484 | train | Find Python in the current directory | [
30522,
3853,
2424,
7685,
2705,
2239,
1006,
1007,
1063,
9530,
3367,
13558,
1027,
1014,
1010,
8246,
1027,
1015,
9530,
3367,
2000,
5403,
3600,
1027,
1031,
1063,
2077,
1024,
1006,
1007,
1027,
1028,
1063,
2065,
1006,
999,
2023,
1012,
9530,
887... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HTMLDOMDiff.js | function (beforeID, isBeingDeleted) {
newEdits.forEach(function (edit) {
// elementDeletes don't need any positioning information
if (edit.type !== "elementDelete") {
edit.beforeID = beforeID;
}
});
edits.push.apply(edits, newEdits);
newEdits = [];
// If the item we made this set of edits relative to
// is being deleted, we can't use it as the afterID for future
// edits. It's okay to just keep the previous afterID, since
// this node will no longer be in the tree by the time we get
// to any future edit that needs an afterID.
if (!isBeingDeleted) {
textAfterID = beforeID;
}
} | javascript | function (beforeID, isBeingDeleted) {
newEdits.forEach(function (edit) {
// elementDeletes don't need any positioning information
if (edit.type !== "elementDelete") {
edit.beforeID = beforeID;
}
});
edits.push.apply(edits, newEdits);
newEdits = [];
// If the item we made this set of edits relative to
// is being deleted, we can't use it as the afterID for future
// edits. It's okay to just keep the previous afterID, since
// this node will no longer be in the tree by the time we get
// to any future edit that needs an afterID.
if (!isBeingDeleted) {
textAfterID = beforeID;
}
} | [
"function",
"(",
"beforeID",
",",
"isBeingDeleted",
")",
"{",
"newEdits",
".",
"forEach",
"(",
"function",
"(",
"edit",
")",
"{",
"// elementDeletes don't need any positioning information",
"if",
"(",
"edit",
".",
"type",
"!==",
"\"elementDelete\"",
")",
"{",
"edi... | We initially put new edit objects into the `newEdits` array so that we
can fix them up with proper positioning information. This function is
responsible for doing that fixup.
The `beforeID` that appears in many edits tells the browser to make the
change before the element with the given ID. In other words, an
elementInsert with a `beforeID` of 32 would result in something like
`parentElement.insertBefore(newChildElement, _queryBracketsID(32))`
Many new edits are captured in the `newEdits` array so that a suitable
`beforeID` can be added to them before they are added to the main edits
list. This function sets the `beforeID` on any pending edits and adds
them to the main list.
If this item is not being deleted, then it will be used as the `afterID`
for text edits that follow.
@param {int} beforeID ID to set on the pending edits
@param {boolean} isBeingDeleted true if the given item is being deleted. If so,
we can't use it as the `afterID` for future edits--whatever previous item
was set as the `textAfterID` is still okay. | [
"We",
"initially",
"put",
"new",
"edit",
"objects",
"into",
"the",
"newEdits",
"array",
"so",
"that",
"we",
"can",
"fix",
"them",
"up",
"with",
"proper",
"positioning",
"information",
".",
"This",
"function",
"is",
"responsible",
"for",
"doing",
"that",
"fix... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLDOMDiff.js#L131-L149 | train | This function is called when the node is being deleted | [
30522,
3853,
1006,
2077,
3593,
1010,
2003,
19205,
3070,
9247,
12870,
2094,
1007,
1063,
2047,
2098,
12762,
1012,
18921,
6776,
1006,
3853,
1006,
10086,
1007,
1063,
1013,
1013,
5783,
9247,
12870,
2015,
2123,
1005,
1056,
2342,
2151,
19120,
2592... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | examples/hello-mui/js/mui.imageViewer.js | function() {
var self = this;
self.viewer = $.dom("<div class='mui-imageviewer'><div class='mui-imageviewer-mask'></div><div class='mui-imageviewer-header'><i class='mui-icon mui-icon-closeempty mui-imageviewer-close'></i><span class='mui-imageviewer-state'></span></div><i class='mui-icon mui-icon-arrowleft mui-imageviewer-left'></i><i class='mui-icon mui-icon-arrowright mui-imageviewer-right'></i></div>");
self.viewer = self.viewer[0] || self.viewer;
//self.viewer.style.height = screen.height;
self.closeButton = self.viewer.querySelector('.mui-imageviewer-close');
self.state = self.viewer.querySelector('.mui-imageviewer-state');
self.leftButton = self.viewer.querySelector('.mui-imageviewer-left');
self.rightButton = self.viewer.querySelector('.mui-imageviewer-right');
self.mask = self.viewer.querySelector('.mui-imageviewer-mask');
document.body.appendChild(self.viewer);
} | javascript | function() {
var self = this;
self.viewer = $.dom("<div class='mui-imageviewer'><div class='mui-imageviewer-mask'></div><div class='mui-imageviewer-header'><i class='mui-icon mui-icon-closeempty mui-imageviewer-close'></i><span class='mui-imageviewer-state'></span></div><i class='mui-icon mui-icon-arrowleft mui-imageviewer-left'></i><i class='mui-icon mui-icon-arrowright mui-imageviewer-right'></i></div>");
self.viewer = self.viewer[0] || self.viewer;
//self.viewer.style.height = screen.height;
self.closeButton = self.viewer.querySelector('.mui-imageviewer-close');
self.state = self.viewer.querySelector('.mui-imageviewer-state');
self.leftButton = self.viewer.querySelector('.mui-imageviewer-left');
self.rightButton = self.viewer.querySelector('.mui-imageviewer-right');
self.mask = self.viewer.querySelector('.mui-imageviewer-mask');
document.body.appendChild(self.viewer);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"viewer",
"=",
"$",
".",
"dom",
"(",
"\"<div class='mui-imageviewer'><div class='mui-imageviewer-mask'></div><div class='mui-imageviewer-header'><i class='mui-icon mui-icon-closeempty mui-imageviewer-close'></... | 创建图片预览组件的整体 UI | [
"创建图片预览组件的整体",
"UI"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.imageViewer.js#L52-L63 | train | Creates the image viewer element | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2969,
1012,
13972,
1027,
1002,
1012,
14383,
1006,
1000,
1026,
4487,
2615,
2465,
30524,
1011,
3746,
8584,
2121,
1011,
7308,
1005,
1028,
1026,
1013,
4487,
2615,
1028,
1026,
4487,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/web/shared/middlewares/api/cors.js | handleCORS | function handleCORS(req, cb) {
const origin = req.get('origin');
const trustedDomains = req.client && req.client.trustedDomains;
// Request must have an Origin header
if (!origin) {
return cb(null, DISABLE_CORS);
}
// Origin matches a client_trusted_domain
if (some(trustedDomains, {trusted_domain: origin})) {
return cb(null, ENABLE_CORS);
}
// Origin matches whitelist
if (getWhitelist().indexOf(url.parse(origin).hostname) > -1) {
return cb(null, ENABLE_CORS);
}
return cb(null, DISABLE_CORS);
} | javascript | function handleCORS(req, cb) {
const origin = req.get('origin');
const trustedDomains = req.client && req.client.trustedDomains;
// Request must have an Origin header
if (!origin) {
return cb(null, DISABLE_CORS);
}
// Origin matches a client_trusted_domain
if (some(trustedDomains, {trusted_domain: origin})) {
return cb(null, ENABLE_CORS);
}
// Origin matches whitelist
if (getWhitelist().indexOf(url.parse(origin).hostname) > -1) {
return cb(null, ENABLE_CORS);
}
return cb(null, DISABLE_CORS);
} | [
"function",
"handleCORS",
"(",
"req",
",",
"cb",
")",
"{",
"const",
"origin",
"=",
"req",
".",
"get",
"(",
"'origin'",
")",
";",
"const",
"trustedDomains",
"=",
"req",
".",
"client",
"&&",
"req",
".",
"client",
".",
"trustedDomains",
";",
"// Request mus... | Checks the origin and enables/disables CORS headers in the response.
@param {Object} req express request object.
@param {Function} cb callback that configures CORS.
@return {null} | [
"Checks",
"the",
"origin",
"and",
"enables",
"/",
"disables",
"CORS",
"headers",
"in",
"the",
"response",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/web/shared/middlewares/api/cors.js#L67-L87 | train | Handle CORS requests | [
30522,
3853,
5047,
27108,
2015,
1006,
2128,
4160,
1010,
17324,
1007,
1063,
9530,
3367,
4761,
1027,
2128,
4160,
1012,
2131,
1006,
1005,
4761,
1005,
1007,
1025,
9530,
3367,
9480,
9527,
28247,
1027,
2128,
4160,
1012,
7396,
1004,
1004,
2128,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
graphql/graphql-js | src/validation/rules/FieldsOnCorrectType.js | getSuggestedTypeNames | function getSuggestedTypeNames(
schema: GraphQLSchema,
type: GraphQLOutputType,
fieldName: string,
): Array<string> {
if (isAbstractType(type)) {
const suggestedObjectTypes = [];
const interfaceUsageCount = Object.create(null);
for (const possibleType of schema.getPossibleTypes(type)) {
if (!possibleType.getFields()[fieldName]) {
continue;
}
// This object type defines this field.
suggestedObjectTypes.push(possibleType.name);
for (const possibleInterface of possibleType.getInterfaces()) {
if (!possibleInterface.getFields()[fieldName]) {
continue;
}
// This interface type defines this field.
interfaceUsageCount[possibleInterface.name] =
(interfaceUsageCount[possibleInterface.name] || 0) + 1;
}
}
// Suggest interface types based on how common they are.
const suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(
(a, b) => interfaceUsageCount[b] - interfaceUsageCount[a],
);
// Suggest both interface and object types.
return suggestedInterfaceTypes.concat(suggestedObjectTypes);
}
// Otherwise, must be an Object type, which does not have possible fields.
return [];
} | javascript | function getSuggestedTypeNames(
schema: GraphQLSchema,
type: GraphQLOutputType,
fieldName: string,
): Array<string> {
if (isAbstractType(type)) {
const suggestedObjectTypes = [];
const interfaceUsageCount = Object.create(null);
for (const possibleType of schema.getPossibleTypes(type)) {
if (!possibleType.getFields()[fieldName]) {
continue;
}
// This object type defines this field.
suggestedObjectTypes.push(possibleType.name);
for (const possibleInterface of possibleType.getInterfaces()) {
if (!possibleInterface.getFields()[fieldName]) {
continue;
}
// This interface type defines this field.
interfaceUsageCount[possibleInterface.name] =
(interfaceUsageCount[possibleInterface.name] || 0) + 1;
}
}
// Suggest interface types based on how common they are.
const suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(
(a, b) => interfaceUsageCount[b] - interfaceUsageCount[a],
);
// Suggest both interface and object types.
return suggestedInterfaceTypes.concat(suggestedObjectTypes);
}
// Otherwise, must be an Object type, which does not have possible fields.
return [];
} | [
"function",
"getSuggestedTypeNames",
"(",
"schema",
":",
"GraphQLSchema",
",",
"type",
":",
"GraphQLOutputType",
",",
"fieldName",
":",
"string",
",",
")",
":",
"Array",
"<",
"string",
">",
"{",
"if",
"(",
"isAbstractType",
"(",
"type",
")",
")",
"{",
"con... | Go through all of the implementations of type, as well as the interfaces that
they implement. If any of those types include the provided field, suggest
them, sorted by how often the type is referenced, starting with Interfaces. | [
"Go",
"through",
"all",
"of",
"the",
"implementations",
"of",
"type",
"as",
"well",
"as",
"the",
"interfaces",
"that",
"they",
"implement",
".",
"If",
"any",
"of",
"those",
"types",
"include",
"the",
"provided",
"field",
"suggest",
"them",
"sorted",
"by",
... | b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef | https://github.com/graphql/graphql-js/blob/b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef/src/validation/rules/FieldsOnCorrectType.js#L91-L126 | train | Get the names of all types that are not declared in the given field. | [
30522,
3853,
4152,
15916,
8449,
3064,
13874,
18442,
2015,
1006,
8040,
28433,
1024,
10629,
4160,
4877,
5403,
2863,
1010,
2828,
1024,
10629,
4160,
23743,
25856,
4904,
13874,
1010,
2492,
18442,
1024,
5164,
1010,
1007,
1024,
9140,
1026,
5164,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.