id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,700 | SAP/openui5 | src/sap.ui.core/src/ui5loader.js | handleConfigObject | function handleConfigObject(oCfg, mHandlers) {
function processConfig(key, value) {
var handler = mHandlers[key];
if ( typeof handler === 'function' ) {
if ( handler.length === 1) {
handler(value);
} else if ( value != null ) {
forEach(value, handler);
}
} else {
log.warning("configuration option " + key + " not supported (ignored)");
}
}
// Make sure the 'baseUrl' handler is called first as
// other handlers (e.g. paths) depend on it
if (oCfg.baseUrl) {
processConfig("baseUrl", oCfg.baseUrl);
}
forEach(oCfg, function(key, value) {
// Ignore "baseUrl" here as it will be handled above
if (key !== "baseUrl") {
processConfig(key, value);
}
});
} | javascript | function handleConfigObject(oCfg, mHandlers) {
function processConfig(key, value) {
var handler = mHandlers[key];
if ( typeof handler === 'function' ) {
if ( handler.length === 1) {
handler(value);
} else if ( value != null ) {
forEach(value, handler);
}
} else {
log.warning("configuration option " + key + " not supported (ignored)");
}
}
// Make sure the 'baseUrl' handler is called first as
// other handlers (e.g. paths) depend on it
if (oCfg.baseUrl) {
processConfig("baseUrl", oCfg.baseUrl);
}
forEach(oCfg, function(key, value) {
// Ignore "baseUrl" here as it will be handled above
if (key !== "baseUrl") {
processConfig(key, value);
}
});
} | [
"function",
"handleConfigObject",
"(",
"oCfg",
",",
"mHandlers",
")",
"{",
"function",
"processConfig",
"(",
"key",
",",
"value",
")",
"{",
"var",
"handler",
"=",
"mHandlers",
"[",
"key",
"]",
";",
"if",
"(",
"typeof",
"handler",
"===",
"'function'",
")",
"{",
"if",
"(",
"handler",
".",
"length",
"===",
"1",
")",
"{",
"handler",
"(",
"value",
")",
";",
"}",
"else",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"forEach",
"(",
"value",
",",
"handler",
")",
";",
"}",
"}",
"else",
"{",
"log",
".",
"warning",
"(",
"\"configuration option \"",
"+",
"key",
"+",
"\" not supported (ignored)\"",
")",
";",
"}",
"}",
"// Make sure the 'baseUrl' handler is called first as",
"// other handlers (e.g. paths) depend on it",
"if",
"(",
"oCfg",
".",
"baseUrl",
")",
"{",
"processConfig",
"(",
"\"baseUrl\"",
",",
"oCfg",
".",
"baseUrl",
")",
";",
"}",
"forEach",
"(",
"oCfg",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"// Ignore \"baseUrl\" here as it will be handled above",
"if",
"(",
"key",
"!==",
"\"baseUrl\"",
")",
"{",
"processConfig",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
")",
";",
"}"
] | Executes all available handlers which are defined in the config object
@param {object} oCfg config to handle
@param {map} mHandlers all available handlers | [
"Executes",
"all",
"available",
"handlers",
"which",
"are",
"defined",
"in",
"the",
"config",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L2200-L2227 |
4,701 | SAP/openui5 | src/sap.ui.core/src/sap/ui/debug/LogViewer.js | function(oWindow, sRootId) {
this.oWindow = oWindow;
this.oDomNode = oWindow.document.getElementById(sRootId);
if (!this.oDomNode) {
var oDiv = this.oWindow.document.createElement("DIV");
oDiv.setAttribute("id", sRootId);
oDiv.style.overflow = "auto";
oDiv.style.tabIndex = "-1";
oDiv.style.position = "absolute";
oDiv.style.bottom = "0px";
oDiv.style.left = "0px";
oDiv.style.right = "202px";
oDiv.style.height = "200px";
oDiv.style.border = "1px solid gray";
oDiv.style.fontFamily = "Arial monospaced for SAP,monospace";
oDiv.style.fontSize = "11px";
oDiv.style.zIndex = "999999";
this.oWindow.document.body.appendChild(oDiv);
this.oDomNode = oDiv;
}
this.iLogLevel = 3; /* Log.LogLevel.INFO */
this.sLogEntryClassPrefix = undefined;
this.clear();
this.setFilter(LogViewer.NO_FILTER);
} | javascript | function(oWindow, sRootId) {
this.oWindow = oWindow;
this.oDomNode = oWindow.document.getElementById(sRootId);
if (!this.oDomNode) {
var oDiv = this.oWindow.document.createElement("DIV");
oDiv.setAttribute("id", sRootId);
oDiv.style.overflow = "auto";
oDiv.style.tabIndex = "-1";
oDiv.style.position = "absolute";
oDiv.style.bottom = "0px";
oDiv.style.left = "0px";
oDiv.style.right = "202px";
oDiv.style.height = "200px";
oDiv.style.border = "1px solid gray";
oDiv.style.fontFamily = "Arial monospaced for SAP,monospace";
oDiv.style.fontSize = "11px";
oDiv.style.zIndex = "999999";
this.oWindow.document.body.appendChild(oDiv);
this.oDomNode = oDiv;
}
this.iLogLevel = 3; /* Log.LogLevel.INFO */
this.sLogEntryClassPrefix = undefined;
this.clear();
this.setFilter(LogViewer.NO_FILTER);
} | [
"function",
"(",
"oWindow",
",",
"sRootId",
")",
"{",
"this",
".",
"oWindow",
"=",
"oWindow",
";",
"this",
".",
"oDomNode",
"=",
"oWindow",
".",
"document",
".",
"getElementById",
"(",
"sRootId",
")",
";",
"if",
"(",
"!",
"this",
".",
"oDomNode",
")",
"{",
"var",
"oDiv",
"=",
"this",
".",
"oWindow",
".",
"document",
".",
"createElement",
"(",
"\"DIV\"",
")",
";",
"oDiv",
".",
"setAttribute",
"(",
"\"id\"",
",",
"sRootId",
")",
";",
"oDiv",
".",
"style",
".",
"overflow",
"=",
"\"auto\"",
";",
"oDiv",
".",
"style",
".",
"tabIndex",
"=",
"\"-1\"",
";",
"oDiv",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"oDiv",
".",
"style",
".",
"bottom",
"=",
"\"0px\"",
";",
"oDiv",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"oDiv",
".",
"style",
".",
"right",
"=",
"\"202px\"",
";",
"oDiv",
".",
"style",
".",
"height",
"=",
"\"200px\"",
";",
"oDiv",
".",
"style",
".",
"border",
"=",
"\"1px solid gray\"",
";",
"oDiv",
".",
"style",
".",
"fontFamily",
"=",
"\"Arial monospaced for SAP,monospace\"",
";",
"oDiv",
".",
"style",
".",
"fontSize",
"=",
"\"11px\"",
";",
"oDiv",
".",
"style",
".",
"zIndex",
"=",
"\"999999\"",
";",
"this",
".",
"oWindow",
".",
"document",
".",
"body",
".",
"appendChild",
"(",
"oDiv",
")",
";",
"this",
".",
"oDomNode",
"=",
"oDiv",
";",
"}",
"this",
".",
"iLogLevel",
"=",
"3",
";",
"/* Log.LogLevel.INFO */",
"this",
".",
"sLogEntryClassPrefix",
"=",
"undefined",
";",
"this",
".",
"clear",
"(",
")",
";",
"this",
".",
"setFilter",
"(",
"LogViewer",
".",
"NO_FILTER",
")",
";",
"}"
] | Constructs a LogViewer in the given window, embedded into the given DOM element.
If the DOM element doesn't exist, a DIV is created.
@param {Window} oTargetWindow the window where the log will be displayed in
@param {sRootId} sRootId id of the top level element that will contain the log entries
@class HTML LogViewer that displays all entries of a Logger, as long as they match a filter and a minimal log level
@alias sap.ui.debug.LogViewer | [
"Constructs",
"a",
"LogViewer",
"in",
"the",
"given",
"window",
"embedded",
"into",
"the",
"given",
"DOM",
"element",
".",
"If",
"the",
"DOM",
"element",
"doesn",
"t",
"exist",
"a",
"DIV",
"is",
"created",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/debug/LogViewer.js#L20-L44 |
|
4,702 | SAP/openui5 | src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js | processPlaceholder | function processPlaceholder (sPlaceholder, oParam) {
var sISODate = new Date().toISOString();
var sProcessed = sPlaceholder.replace("{{parameters.NOW_ISO}}", sISODate);
sProcessed = sProcessed.replace("{{parameters.TODAY_ISO}}", sISODate.slice(0, 10));
if (oParam) {
for (var oProperty in oParam) {
sProcessed = sProcessed.replace("{{parameters." + oProperty + "}}", oParam[oProperty].value);
}
}
return sProcessed;
} | javascript | function processPlaceholder (sPlaceholder, oParam) {
var sISODate = new Date().toISOString();
var sProcessed = sPlaceholder.replace("{{parameters.NOW_ISO}}", sISODate);
sProcessed = sProcessed.replace("{{parameters.TODAY_ISO}}", sISODate.slice(0, 10));
if (oParam) {
for (var oProperty in oParam) {
sProcessed = sProcessed.replace("{{parameters." + oProperty + "}}", oParam[oProperty].value);
}
}
return sProcessed;
} | [
"function",
"processPlaceholder",
"(",
"sPlaceholder",
",",
"oParam",
")",
"{",
"var",
"sISODate",
"=",
"new",
"Date",
"(",
")",
".",
"toISOString",
"(",
")",
";",
"var",
"sProcessed",
"=",
"sPlaceholder",
".",
"replace",
"(",
"\"{{parameters.NOW_ISO}}\"",
",",
"sISODate",
")",
";",
"sProcessed",
"=",
"sProcessed",
".",
"replace",
"(",
"\"{{parameters.TODAY_ISO}}\"",
",",
"sISODate",
".",
"slice",
"(",
"0",
",",
"10",
")",
")",
";",
"if",
"(",
"oParam",
")",
"{",
"for",
"(",
"var",
"oProperty",
"in",
"oParam",
")",
"{",
"sProcessed",
"=",
"sProcessed",
".",
"replace",
"(",
"\"{{parameters.\"",
"+",
"oProperty",
"+",
"\"}}\"",
",",
"oParam",
"[",
"oProperty",
"]",
".",
"value",
")",
";",
"}",
"}",
"return",
"sProcessed",
";",
"}"
] | Replace all placeholders inside the string.
@private
@param {string} sPlaceholder The value to process.
@param {Object} oParam The parameter from the configuration.
@returns {string} The string with replaced placeholders. | [
"Replace",
"all",
"placeholders",
"inside",
"the",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js#L212-L223 |
4,703 | SAP/openui5 | src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js | process | function process (oObject, oTranslator, iCurrentLevel, iMaxLevel, oParams) {
if (iCurrentLevel === iMaxLevel) {
return;
}
if (Array.isArray(oObject)) {
oObject.forEach(function (vItem, iIndex, aArray) {
if (typeof vItem === "object") {
process(vItem, oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(vItem, oObject, oParams)) {
aArray[iIndex] = processPlaceholder(vItem, oParams);
} else if (isTranslatable(vItem) && oTranslator) {
aArray[iIndex] = oTranslator.getText(vItem.substring(2, vItem.length - 2));
}
}, this);
} else {
for (var sProp in oObject) {
if (typeof oObject[sProp] === "object") {
process(oObject[sProp], oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(oObject[sProp], oObject, oParams)) {
oObject[sProp] = processPlaceholder(oObject[sProp], oParams);
} else if (isTranslatable(oObject[sProp]) && oTranslator) {
oObject[sProp] = oTranslator.getText(oObject[sProp].substring(2, oObject[sProp].length - 2));
}
}
}
} | javascript | function process (oObject, oTranslator, iCurrentLevel, iMaxLevel, oParams) {
if (iCurrentLevel === iMaxLevel) {
return;
}
if (Array.isArray(oObject)) {
oObject.forEach(function (vItem, iIndex, aArray) {
if (typeof vItem === "object") {
process(vItem, oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(vItem, oObject, oParams)) {
aArray[iIndex] = processPlaceholder(vItem, oParams);
} else if (isTranslatable(vItem) && oTranslator) {
aArray[iIndex] = oTranslator.getText(vItem.substring(2, vItem.length - 2));
}
}, this);
} else {
for (var sProp in oObject) {
if (typeof oObject[sProp] === "object") {
process(oObject[sProp], oTranslator, iCurrentLevel + 1, iMaxLevel, oParams);
} else if (isProcessable(oObject[sProp], oObject, oParams)) {
oObject[sProp] = processPlaceholder(oObject[sProp], oParams);
} else if (isTranslatable(oObject[sProp]) && oTranslator) {
oObject[sProp] = oTranslator.getText(oObject[sProp].substring(2, oObject[sProp].length - 2));
}
}
}
} | [
"function",
"process",
"(",
"oObject",
",",
"oTranslator",
",",
"iCurrentLevel",
",",
"iMaxLevel",
",",
"oParams",
")",
"{",
"if",
"(",
"iCurrentLevel",
"===",
"iMaxLevel",
")",
"{",
"return",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"oObject",
")",
")",
"{",
"oObject",
".",
"forEach",
"(",
"function",
"(",
"vItem",
",",
"iIndex",
",",
"aArray",
")",
"{",
"if",
"(",
"typeof",
"vItem",
"===",
"\"object\"",
")",
"{",
"process",
"(",
"vItem",
",",
"oTranslator",
",",
"iCurrentLevel",
"+",
"1",
",",
"iMaxLevel",
",",
"oParams",
")",
";",
"}",
"else",
"if",
"(",
"isProcessable",
"(",
"vItem",
",",
"oObject",
",",
"oParams",
")",
")",
"{",
"aArray",
"[",
"iIndex",
"]",
"=",
"processPlaceholder",
"(",
"vItem",
",",
"oParams",
")",
";",
"}",
"else",
"if",
"(",
"isTranslatable",
"(",
"vItem",
")",
"&&",
"oTranslator",
")",
"{",
"aArray",
"[",
"iIndex",
"]",
"=",
"oTranslator",
".",
"getText",
"(",
"vItem",
".",
"substring",
"(",
"2",
",",
"vItem",
".",
"length",
"-",
"2",
")",
")",
";",
"}",
"}",
",",
"this",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"sProp",
"in",
"oObject",
")",
"{",
"if",
"(",
"typeof",
"oObject",
"[",
"sProp",
"]",
"===",
"\"object\"",
")",
"{",
"process",
"(",
"oObject",
"[",
"sProp",
"]",
",",
"oTranslator",
",",
"iCurrentLevel",
"+",
"1",
",",
"iMaxLevel",
",",
"oParams",
")",
";",
"}",
"else",
"if",
"(",
"isProcessable",
"(",
"oObject",
"[",
"sProp",
"]",
",",
"oObject",
",",
"oParams",
")",
")",
"{",
"oObject",
"[",
"sProp",
"]",
"=",
"processPlaceholder",
"(",
"oObject",
"[",
"sProp",
"]",
",",
"oParams",
")",
";",
"}",
"else",
"if",
"(",
"isTranslatable",
"(",
"oObject",
"[",
"sProp",
"]",
")",
"&&",
"oTranslator",
")",
"{",
"oObject",
"[",
"sProp",
"]",
"=",
"oTranslator",
".",
"getText",
"(",
"oObject",
"[",
"sProp",
"]",
".",
"substring",
"(",
"2",
",",
"oObject",
"[",
"sProp",
"]",
".",
"length",
"-",
"2",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Process a manifest.
@private
@param {Object} oObject The Manifest to process.
@param {Object} oTranslator The translator.
@param {number} iCurrentLevel The current level of recursion.
@param {number} iMaxLevel The maximum level of recursion.
@param {Object} oParams The parameters to be replaced in the manifest. | [
"Process",
"a",
"manifest",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js#L235-L261 |
4,704 | SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js | _getElementTreeLeftColumnOfListItem | function _getElementTreeLeftColumnOfListItem(controls, paddingLeft) {
var html = "<offset style=\"padding-left:" + paddingLeft + "px\" >";
if (controls.content.length > 0) {
html += "<arrow down=\"true\"></arrow>";
} else {
html += "<place-holder></place-holder>";
}
html += "</offset>";
return html;
} | javascript | function _getElementTreeLeftColumnOfListItem(controls, paddingLeft) {
var html = "<offset style=\"padding-left:" + paddingLeft + "px\" >";
if (controls.content.length > 0) {
html += "<arrow down=\"true\"></arrow>";
} else {
html += "<place-holder></place-holder>";
}
html += "</offset>";
return html;
} | [
"function",
"_getElementTreeLeftColumnOfListItem",
"(",
"controls",
",",
"paddingLeft",
")",
"{",
"var",
"html",
"=",
"\"<offset style=\\\"padding-left:\"",
"+",
"paddingLeft",
"+",
"\"px\\\" >\"",
";",
"if",
"(",
"controls",
".",
"content",
".",
"length",
">",
"0",
")",
"{",
"html",
"+=",
"\"<arrow down=\\\"true\\\"></arrow>\"",
";",
"}",
"else",
"{",
"html",
"+=",
"\"<place-holder></place-holder>\"",
";",
"}",
"html",
"+=",
"\"</offset>\"",
";",
"return",
"html",
";",
"}"
] | Create HTML for the left part of the ElementTree list item.
@param {ElementTreeOptions.controls} controls
@param {number} paddingLeft
@returns {string}
@private | [
"Create",
"HTML",
"for",
"the",
"left",
"part",
"of",
"the",
"ElementTree",
"list",
"item",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L60-L72 |
4,705 | SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js | _getElementTreeRightColumnOfListItem | function _getElementTreeRightColumnOfListItem(control, numberOfIssues) {
var splitControlName = control.name.split(".");
var name = splitControlName[splitControlName.length - 1];
var nameSpace = control.name.replace(name, "");
var hideShowClass = (numberOfIssues > 0) ? "showNumbOfIssues" : "hideNumbOfIssues";
return "<tag data-search=\"" + control.name + control.id + "\">" +
"<" +
"<namespace>" + nameSpace + "</namespace>" +
name +
"<attribute> id=\"<attribute-value>" + control.id + "</attribute-value>\"</attribute>" +
">" +
"</tag>" + "<span class = " + hideShowClass + ">[" + numberOfIssues + " issue(s)] </span>";
} | javascript | function _getElementTreeRightColumnOfListItem(control, numberOfIssues) {
var splitControlName = control.name.split(".");
var name = splitControlName[splitControlName.length - 1];
var nameSpace = control.name.replace(name, "");
var hideShowClass = (numberOfIssues > 0) ? "showNumbOfIssues" : "hideNumbOfIssues";
return "<tag data-search=\"" + control.name + control.id + "\">" +
"<" +
"<namespace>" + nameSpace + "</namespace>" +
name +
"<attribute> id=\"<attribute-value>" + control.id + "</attribute-value>\"</attribute>" +
">" +
"</tag>" + "<span class = " + hideShowClass + ">[" + numberOfIssues + " issue(s)] </span>";
} | [
"function",
"_getElementTreeRightColumnOfListItem",
"(",
"control",
",",
"numberOfIssues",
")",
"{",
"var",
"splitControlName",
"=",
"control",
".",
"name",
".",
"split",
"(",
"\".\"",
")",
";",
"var",
"name",
"=",
"splitControlName",
"[",
"splitControlName",
".",
"length",
"-",
"1",
"]",
";",
"var",
"nameSpace",
"=",
"control",
".",
"name",
".",
"replace",
"(",
"name",
",",
"\"\"",
")",
";",
"var",
"hideShowClass",
"=",
"(",
"numberOfIssues",
">",
"0",
")",
"?",
"\"showNumbOfIssues\"",
":",
"\"hideNumbOfIssues\"",
";",
"return",
"\"<tag data-search=\\\"\"",
"+",
"control",
".",
"name",
"+",
"control",
".",
"id",
"+",
"\"\\\">\"",
"+",
"\"<\"",
"+",
"\"<namespace>\"",
"+",
"nameSpace",
"+",
"\"</namespace>\"",
"+",
"name",
"+",
"\"<attribute> id=\\\"<attribute-value>\"",
"+",
"control",
".",
"id",
"+",
"\"</attribute-value>\\\"</attribute>\"",
"+",
"\">\"",
"+",
"\"</tag>\"",
"+",
"\"<span class = \"",
"+",
"hideShowClass",
"+",
"\">[\"",
"+",
"numberOfIssues",
"+",
"\" issue(s)] </span>\"",
";",
"}"
] | Create HTML for the right part of the ElementTree list item.
@param {Object} control - JSON object form {ElementTreeOptions.controls}
@returns {string}
@private | [
"Create",
"HTML",
"for",
"the",
"right",
"part",
"of",
"the",
"ElementTree",
"list",
"item",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L80-L93 |
4,706 | SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js | _findNearestDOMParent | function _findNearestDOMParent(element, parentNodeName) {
while (element.nodeName !== parentNodeName) {
if (element.nodeName === "CONTROL-TREE") {
break;
}
element = element.parentNode;
}
return element;
} | javascript | function _findNearestDOMParent(element, parentNodeName) {
while (element.nodeName !== parentNodeName) {
if (element.nodeName === "CONTROL-TREE") {
break;
}
element = element.parentNode;
}
return element;
} | [
"function",
"_findNearestDOMParent",
"(",
"element",
",",
"parentNodeName",
")",
"{",
"while",
"(",
"element",
".",
"nodeName",
"!==",
"parentNodeName",
")",
"{",
"if",
"(",
"element",
".",
"nodeName",
"===",
"\"CONTROL-TREE\"",
")",
"{",
"break",
";",
"}",
"element",
"=",
"element",
".",
"parentNode",
";",
"}",
"return",
"element",
";",
"}"
] | Search for the nearest parent Node.
@param {element} element - HTML DOM element that will be the root of the search
@param {string} parentNodeName - The desired HTML parent element nodeName
@returns {Object} HTML DOM element
@private | [
"Search",
"for",
"the",
"nearest",
"parent",
"Node",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L102-L111 |
4,707 | SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js | ElementTree | function ElementTree(id, instantiationOptions) {
var areInstantiationOptionsAnObject = _isObject(instantiationOptions);
var options;
/**
* Make sure that the options parameter is Object and
* that the ElementTree can be instantiate without initial options.
*/
if (areInstantiationOptionsAnObject) {
options = instantiationOptions;
} else {
options = {};
}
// Save DOM reference
this._ElementTreeContainer = document.getElementById(id);
/**
* Method fired when the number of issues against an element is clicked
*/
this.onIssueCountClicked = options.onIssueCountClicked ? options.onIssueCountClicked : function () {};
/**
* Method fired when the selected element in the ElementTree is changed.
* @param {string} selectedElementId - The selected element id
*/
this.onSelectionChanged = options.onSelectionChanged ? options.onSelectionChanged : function (selectedElementId) {};
/**
* Method fired when the hovered element in the ElementTree is changed.
* @param {string} hoveredElementId - The hovered element id
*/
this.onHoverChanged = options.onHoverChanged ? options.onHoverChanged : function (hoveredElementId) {};
/**
* Method fired when the mouse is out of the ElementTree.
*/
this.onMouseOut = options.onMouseOut ? options.onMouseOut : function () {};
/**
* Method fired when the initial ElementTree rendering is done.
*/
this.onInitialRendering = options.onInitialRendering ? options.onInitialRendering : function () {};
// Object with the tree model that will be visualized
this.setData(options.data);
} | javascript | function ElementTree(id, instantiationOptions) {
var areInstantiationOptionsAnObject = _isObject(instantiationOptions);
var options;
/**
* Make sure that the options parameter is Object and
* that the ElementTree can be instantiate without initial options.
*/
if (areInstantiationOptionsAnObject) {
options = instantiationOptions;
} else {
options = {};
}
// Save DOM reference
this._ElementTreeContainer = document.getElementById(id);
/**
* Method fired when the number of issues against an element is clicked
*/
this.onIssueCountClicked = options.onIssueCountClicked ? options.onIssueCountClicked : function () {};
/**
* Method fired when the selected element in the ElementTree is changed.
* @param {string} selectedElementId - The selected element id
*/
this.onSelectionChanged = options.onSelectionChanged ? options.onSelectionChanged : function (selectedElementId) {};
/**
* Method fired when the hovered element in the ElementTree is changed.
* @param {string} hoveredElementId - The hovered element id
*/
this.onHoverChanged = options.onHoverChanged ? options.onHoverChanged : function (hoveredElementId) {};
/**
* Method fired when the mouse is out of the ElementTree.
*/
this.onMouseOut = options.onMouseOut ? options.onMouseOut : function () {};
/**
* Method fired when the initial ElementTree rendering is done.
*/
this.onInitialRendering = options.onInitialRendering ? options.onInitialRendering : function () {};
// Object with the tree model that will be visualized
this.setData(options.data);
} | [
"function",
"ElementTree",
"(",
"id",
",",
"instantiationOptions",
")",
"{",
"var",
"areInstantiationOptionsAnObject",
"=",
"_isObject",
"(",
"instantiationOptions",
")",
";",
"var",
"options",
";",
"/**\n\t\t\t * Make sure that the options parameter is Object and\n\t\t\t * that the ElementTree can be instantiate without initial options.\n\t\t\t */",
"if",
"(",
"areInstantiationOptionsAnObject",
")",
"{",
"options",
"=",
"instantiationOptions",
";",
"}",
"else",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"// Save DOM reference",
"this",
".",
"_ElementTreeContainer",
"=",
"document",
".",
"getElementById",
"(",
"id",
")",
";",
"/**\n\t\t\t * Method fired when the number of issues against an element is clicked\n\t\t\t */",
"this",
".",
"onIssueCountClicked",
"=",
"options",
".",
"onIssueCountClicked",
"?",
"options",
".",
"onIssueCountClicked",
":",
"function",
"(",
")",
"{",
"}",
";",
"/**\n\t\t\t * Method fired when the selected element in the ElementTree is changed.\n\t\t\t * @param {string} selectedElementId - The selected element id\n\t\t\t */",
"this",
".",
"onSelectionChanged",
"=",
"options",
".",
"onSelectionChanged",
"?",
"options",
".",
"onSelectionChanged",
":",
"function",
"(",
"selectedElementId",
")",
"{",
"}",
";",
"/**\n\t\t\t * Method fired when the hovered element in the ElementTree is changed.\n\t\t\t * @param {string} hoveredElementId - The hovered element id\n\t\t\t */",
"this",
".",
"onHoverChanged",
"=",
"options",
".",
"onHoverChanged",
"?",
"options",
".",
"onHoverChanged",
":",
"function",
"(",
"hoveredElementId",
")",
"{",
"}",
";",
"/**\n\t\t\t * Method fired when the mouse is out of the ElementTree.\n\t\t\t */",
"this",
".",
"onMouseOut",
"=",
"options",
".",
"onMouseOut",
"?",
"options",
".",
"onMouseOut",
":",
"function",
"(",
")",
"{",
"}",
";",
"/**\n\t\t\t * Method fired when the initial ElementTree rendering is done.\n\t\t\t */",
"this",
".",
"onInitialRendering",
"=",
"options",
".",
"onInitialRendering",
"?",
"options",
".",
"onInitialRendering",
":",
"function",
"(",
")",
"{",
"}",
";",
"// Object with the tree model that will be visualized",
"this",
".",
"setData",
"(",
"options",
".",
"data",
")",
";",
"}"
] | ElementTree constructor.
@param {string} id - The id of the DOM container
@param {ElementTree} instantiationOptions
@constructor | [
"ElementTree",
"constructor",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L119-L165 |
4,708 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/Support.js | _storeBreakpoints | function _storeBreakpoints() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportInfosBreakpoints/" + document.location.href, JSON.stringify(aSupportInfosBreakpoints));
}
} | javascript | function _storeBreakpoints() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportInfosBreakpoints/" + document.location.href, JSON.stringify(aSupportInfosBreakpoints));
}
} | [
"function",
"_storeBreakpoints",
"(",
")",
"{",
"if",
"(",
"bHasLocalStorage",
")",
"{",
"localStorage",
".",
"setItem",
"(",
"\"sap-ui-support.aSupportInfosBreakpoints/\"",
"+",
"document",
".",
"location",
".",
"href",
",",
"JSON",
".",
"stringify",
"(",
"aSupportInfosBreakpoints",
")",
")",
";",
"}",
"}"
] | store breakpoints to local storage | [
"store",
"breakpoints",
"to",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/Support.js#L645-L649 |
4,709 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/Support.js | _storeXMLModifications | function _storeXMLModifications() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications));
}
} | javascript | function _storeXMLModifications() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications));
}
} | [
"function",
"_storeXMLModifications",
"(",
")",
"{",
"if",
"(",
"bHasLocalStorage",
")",
"{",
"localStorage",
".",
"setItem",
"(",
"\"sap-ui-support.aSupportXMLModifications/\"",
"+",
"document",
".",
"location",
".",
"href",
",",
"JSON",
".",
"stringify",
"(",
"aSupportXMLModifications",
")",
")",
";",
"}",
"}"
] | store xml modification to local storage | [
"store",
"xml",
"modification",
"to",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/Support.js#L652-L656 |
4,710 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function (oConfig, oParent) {
if (!oConfig.name) {
Log.error("A name has to be specified for every route", this);
}
if (this._oRoutes[oConfig.name]) {
Log.error("Route with name " + oConfig.name + " already exists", this);
}
this._oRoutes[oConfig.name] = this._createRoute(this, oConfig, oParent);
} | javascript | function (oConfig, oParent) {
if (!oConfig.name) {
Log.error("A name has to be specified for every route", this);
}
if (this._oRoutes[oConfig.name]) {
Log.error("Route with name " + oConfig.name + " already exists", this);
}
this._oRoutes[oConfig.name] = this._createRoute(this, oConfig, oParent);
} | [
"function",
"(",
"oConfig",
",",
"oParent",
")",
"{",
"if",
"(",
"!",
"oConfig",
".",
"name",
")",
"{",
"Log",
".",
"error",
"(",
"\"A name has to be specified for every route\"",
",",
"this",
")",
";",
"}",
"if",
"(",
"this",
".",
"_oRoutes",
"[",
"oConfig",
".",
"name",
"]",
")",
"{",
"Log",
".",
"error",
"(",
"\"Route with name \"",
"+",
"oConfig",
".",
"name",
"+",
"\" already exists\"",
",",
"this",
")",
";",
"}",
"this",
".",
"_oRoutes",
"[",
"oConfig",
".",
"name",
"]",
"=",
"this",
".",
"_createRoute",
"(",
"this",
",",
"oConfig",
",",
"oParent",
")",
";",
"}"
] | Adds a route to the router
@param {object} oConfig configuration object for the route @see sap.ui.core.routing.Route#constructor
@param {sap.ui.core.routing.Route} oParent The parent route - if a parent route is given, the routeMatched event of this route will also trigger the route matched of the parent and it will also create the view of the parent (if provided).
@public | [
"Adds",
"a",
"route",
"to",
"the",
"router"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L287-L296 |
|
4,711 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function (sName, oParameters) {
if (oParameters === undefined) {
//even if there are only optional parameters crossroads cannot navigate with undefined
oParameters = {};
}
var oRoute = this.getRoute(sName);
if (!oRoute) {
Log.warning("Route with name " + sName + " does not exist", this);
return;
}
return oRoute.getURL(oParameters);
} | javascript | function (sName, oParameters) {
if (oParameters === undefined) {
//even if there are only optional parameters crossroads cannot navigate with undefined
oParameters = {};
}
var oRoute = this.getRoute(sName);
if (!oRoute) {
Log.warning("Route with name " + sName + " does not exist", this);
return;
}
return oRoute.getURL(oParameters);
} | [
"function",
"(",
"sName",
",",
"oParameters",
")",
"{",
"if",
"(",
"oParameters",
"===",
"undefined",
")",
"{",
"//even if there are only optional parameters crossroads cannot navigate with undefined",
"oParameters",
"=",
"{",
"}",
";",
"}",
"var",
"oRoute",
"=",
"this",
".",
"getRoute",
"(",
"sName",
")",
";",
"if",
"(",
"!",
"oRoute",
")",
"{",
"Log",
".",
"warning",
"(",
"\"Route with name \"",
"+",
"sName",
"+",
"\" does not exist\"",
",",
"this",
")",
";",
"return",
";",
"}",
"return",
"oRoute",
".",
"getURL",
"(",
"oParameters",
")",
";",
"}"
] | Returns the URL for the route and replaces the placeholders with the values in oParameters
@param {string} sName Name of the route
@param {object} [oParameters] Parameters for the route
@return {string} the unencoded pattern with interpolated arguments
@public | [
"Returns",
"the",
"URL",
"for",
"the",
"route",
"and",
"replaces",
"the",
"placeholders",
"with",
"the",
"values",
"in",
"oParameters"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L513-L525 |
|
4,712 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function (sHash) {
return Object.keys(this._oRoutes).some(function(sRouteName) {
return this._oRoutes[sRouteName].match(sHash);
}.bind(this));
} | javascript | function (sHash) {
return Object.keys(this._oRoutes).some(function(sRouteName) {
return this._oRoutes[sRouteName].match(sHash);
}.bind(this));
} | [
"function",
"(",
"sHash",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"this",
".",
"_oRoutes",
")",
".",
"some",
"(",
"function",
"(",
"sRouteName",
")",
"{",
"return",
"this",
".",
"_oRoutes",
"[",
"sRouteName",
"]",
".",
"match",
"(",
"sHash",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Returns whether the given hash can be matched by any one of the Route in the Router.
@param {string} hash which will be tested by the Router
@return {boolean} whether the hash can be matched
@public
@since 1.58.0 | [
"Returns",
"whether",
"the",
"given",
"hash",
"can",
"be",
"matched",
"by",
"any",
"one",
"of",
"the",
"Route",
"in",
"the",
"Router",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L535-L539 |
|
4,713 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function (sViewName, sViewType, sViewId) {
Log.warning("Deprecated API Router#getView called - use Router#getViews instead.", this);
var oView = this._oViews._getViewWithGlobalId({
viewName: sViewName,
type: sViewType,
id: sViewId
});
this.fireViewCreated({
view: oView,
viewName: sViewName,
type: sViewType
});
return oView;
} | javascript | function (sViewName, sViewType, sViewId) {
Log.warning("Deprecated API Router#getView called - use Router#getViews instead.", this);
var oView = this._oViews._getViewWithGlobalId({
viewName: sViewName,
type: sViewType,
id: sViewId
});
this.fireViewCreated({
view: oView,
viewName: sViewName,
type: sViewType
});
return oView;
} | [
"function",
"(",
"sViewName",
",",
"sViewType",
",",
"sViewId",
")",
"{",
"Log",
".",
"warning",
"(",
"\"Deprecated API Router#getView called - use Router#getViews instead.\"",
",",
"this",
")",
";",
"var",
"oView",
"=",
"this",
".",
"_oViews",
".",
"_getViewWithGlobalId",
"(",
"{",
"viewName",
":",
"sViewName",
",",
"type",
":",
"sViewType",
",",
"id",
":",
"sViewId",
"}",
")",
";",
"this",
".",
"fireViewCreated",
"(",
"{",
"view",
":",
"oView",
",",
"viewName",
":",
"sViewName",
",",
"type",
":",
"sViewType",
"}",
")",
";",
"return",
"oView",
";",
"}"
] | Returns a cached view for a given name or creates it if it does not yet exists
@deprecated Since 1.28.1 use {@link #getViews} instead.
@param {string} sViewName Name of the view
@param {string} sViewType Type of the view
@param {string} sViewId Optional view id
@return {sap.ui.core.mvc.View} the view instance
@public | [
"Returns",
"a",
"cached",
"view",
"for",
"a",
"given",
"name",
"or",
"creates",
"it",
"if",
"it",
"does",
"not",
"yet",
"exists"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L586-L602 |
|
4,714 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function(oData, fnFunction, oListener) {
return this.attachEvent(Router.M_EVENTS.BYPASSED, oData, fnFunction, oListener);
} | javascript | function(oData, fnFunction, oListener) {
return this.attachEvent(Router.M_EVENTS.BYPASSED, oData, fnFunction, oListener);
} | [
"function",
"(",
"oData",
",",
"fnFunction",
",",
"oListener",
")",
"{",
"return",
"this",
".",
"attachEvent",
"(",
"Router",
".",
"M_EVENTS",
".",
"BYPASSED",
",",
"oData",
",",
"fnFunction",
",",
"oListener",
")",
";",
"}"
] | The 'bypassed' event is fired, when no route of the router matches the changed URL hash
@name sap.ui.core.routing.Router#bypassed
@event
@param {sap.ui.base.Event} oEvent
@param {sap.ui.base.EventProvider} oEvent.getSource
@param {object} oEvent.getParameters
@param {string} oEvent.getParameters.hash the current URL hash which did not match any route
@public
Attach event-handler <code>fnFunction</code> to the 'bypassed' event of this <code>sap.ui.core.routing.Router</code>.<br/>
The event will get fired, if none of the routes of the routes is matching. <br/>
@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. If empty, this router is used.
@return {sap.ui.core.routing.Router} <code>this</code> to allow method chaining
@public | [
"The",
"bypassed",
"event",
"is",
"fired",
"when",
"no",
"route",
"of",
"the",
"router",
"matches",
"the",
"changed",
"URL",
"hash"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L949-L951 |
|
4,715 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function(oData, fnFunction, oListener) {
this.attachEvent(Router.M_EVENTS.TITLE_CHANGED, oData, fnFunction, oListener);
return this;
} | javascript | function(oData, fnFunction, oListener) {
this.attachEvent(Router.M_EVENTS.TITLE_CHANGED, oData, fnFunction, oListener);
return this;
} | [
"function",
"(",
"oData",
",",
"fnFunction",
",",
"oListener",
")",
"{",
"this",
".",
"attachEvent",
"(",
"Router",
".",
"M_EVENTS",
".",
"TITLE_CHANGED",
",",
"oData",
",",
"fnFunction",
",",
"oListener",
")",
";",
"return",
"this",
";",
"}"
] | Will be fired when the title of the "TitleTarget" in the currently matching Route has been changed.
<pre>
A "TitleTarget" is resolved as the following:
1. When the Route only has one target configured, the "TitleTarget" is resolved with this target when its {@link sap.ui.core.routing.Targets#constructor|title} options is set.
2. When the Route has more than one target configured, the "TitleTarget" is resolved by default with the first target which has a {@link sap.ui.core.routing.Targets#constructor|title} option.
3. When the {@link sap.ui.core.routing.Route#constructor|titleTarget} option on the Route is configured, this specific target is then used as the "TitleTarget".
</pre>
@name sap.ui.core.routing.Router#titleChanged
@event
@param {object} oEvent
@param {sap.ui.base.EventProvider} oEvent.getSource
@param {object} oEvent.getParameters
@param {string} oEvent.getParameters.title The current displayed title
@param {array} oEvent.getParameters.history An array which contains the history of previous titles
@param {string} oEvent.getParameters.history.title The title
@param {string} oEvent.getParameters.history.hash The hash
@param {boolean} oEvent.getParameters.history.isHome The app home indicator
@public
Attach event-handler <code>fnFunction</code> to the 'titleChanged' event of this <code>sap.ui.core.routing.Router</code>.<br/>
@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.Router} <code>this</code> to allow method chaining
@public | [
"Will",
"be",
"fired",
"when",
"the",
"title",
"of",
"the",
"TitleTarget",
"in",
"the",
"currently",
"matching",
"Route",
"has",
"been",
"changed",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L1014-L1017 |
|
4,716 | SAP/openui5 | src/sap.ui.core/src/sap/ui/dom/patch.js | patch | function patch(oOldDom, oNewDom) {
// start checking with most common use case and backwards compatible
if (oOldDom.childElementCount != oNewDom.childElementCount ||
oOldDom.tagName != oNewDom.tagName) {
oOldDom.parentNode.replaceChild(oNewDom, oOldDom);
return false;
}
// go with native... if nodes are equal there is nothing to do
// http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isEqualNode
if (oOldDom.isEqualNode(oNewDom)) {
return true;
}
// remove outdated attributes from old dom
var aOldAttributes = oOldDom.attributes;
for (var i = 0, ii = aOldAttributes.length; i < ii; i++) {
var sAttrName = aOldAttributes[i].name;
if (oNewDom.getAttribute(sAttrName) === null) {
oOldDom.removeAttribute(sAttrName);
ii = ii - 1;
i = i - 1;
}
}
// patch new or changed attributes to the old dom
var aNewAttributes = oNewDom.attributes;
for (var i = 0, ii = aNewAttributes.length; i < ii; i++) {
var sAttrName = aNewAttributes[i].name,
vOldAttrValue = oOldDom.getAttribute(sAttrName),
vNewAttrValue = oNewDom.getAttribute(sAttrName);
if (vOldAttrValue === null || vOldAttrValue !== vNewAttrValue) {
oOldDom.setAttribute(sAttrName, vNewAttrValue);
}
}
// check whether more child nodes to continue or not
var iNewChildNodesCount = oNewDom.childNodes.length;
if (!iNewChildNodesCount && !oOldDom.hasChildNodes()) {
return true;
}
// maybe no more child elements
if (!oNewDom.childElementCount) {
// but child nodes(e.g. Text Nodes) still needs to be replaced
if (!iNewChildNodesCount) {
// new dom does not have any child node, so we can clean the old one
oOldDom.textContent = "";
} else if (iNewChildNodesCount == 1 && oNewDom.firstChild.nodeType == 3 /* TEXT_NODE */) {
// update the text content for the first text node
oOldDom.textContent = oNewDom.textContent;
} else {
// in case of comments or other node types are used
oOldDom.innerHTML = oNewDom.innerHTML;
}
return true;
}
// patch child nodes
for (var i = 0, r = 0, ii = iNewChildNodesCount; i < ii; i++) {
var oOldDomChildNode = oOldDom.childNodes[i],
oNewDomChildNode = oNewDom.childNodes[i - r];
if (oNewDomChildNode.nodeType == 1 /* ELEMENT_NODE */) {
// recursively patch child elements
if (!patch(oOldDomChildNode, oNewDomChildNode)) {
// if patch is not possible we replace nodes
// in this case replaced node is removed
r = r + 1;
}
} else {
// when not element update only node values
oOldDomChildNode.nodeValue = oNewDomChildNode.nodeValue;
}
}
return true;
} | javascript | function patch(oOldDom, oNewDom) {
// start checking with most common use case and backwards compatible
if (oOldDom.childElementCount != oNewDom.childElementCount ||
oOldDom.tagName != oNewDom.tagName) {
oOldDom.parentNode.replaceChild(oNewDom, oOldDom);
return false;
}
// go with native... if nodes are equal there is nothing to do
// http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isEqualNode
if (oOldDom.isEqualNode(oNewDom)) {
return true;
}
// remove outdated attributes from old dom
var aOldAttributes = oOldDom.attributes;
for (var i = 0, ii = aOldAttributes.length; i < ii; i++) {
var sAttrName = aOldAttributes[i].name;
if (oNewDom.getAttribute(sAttrName) === null) {
oOldDom.removeAttribute(sAttrName);
ii = ii - 1;
i = i - 1;
}
}
// patch new or changed attributes to the old dom
var aNewAttributes = oNewDom.attributes;
for (var i = 0, ii = aNewAttributes.length; i < ii; i++) {
var sAttrName = aNewAttributes[i].name,
vOldAttrValue = oOldDom.getAttribute(sAttrName),
vNewAttrValue = oNewDom.getAttribute(sAttrName);
if (vOldAttrValue === null || vOldAttrValue !== vNewAttrValue) {
oOldDom.setAttribute(sAttrName, vNewAttrValue);
}
}
// check whether more child nodes to continue or not
var iNewChildNodesCount = oNewDom.childNodes.length;
if (!iNewChildNodesCount && !oOldDom.hasChildNodes()) {
return true;
}
// maybe no more child elements
if (!oNewDom.childElementCount) {
// but child nodes(e.g. Text Nodes) still needs to be replaced
if (!iNewChildNodesCount) {
// new dom does not have any child node, so we can clean the old one
oOldDom.textContent = "";
} else if (iNewChildNodesCount == 1 && oNewDom.firstChild.nodeType == 3 /* TEXT_NODE */) {
// update the text content for the first text node
oOldDom.textContent = oNewDom.textContent;
} else {
// in case of comments or other node types are used
oOldDom.innerHTML = oNewDom.innerHTML;
}
return true;
}
// patch child nodes
for (var i = 0, r = 0, ii = iNewChildNodesCount; i < ii; i++) {
var oOldDomChildNode = oOldDom.childNodes[i],
oNewDomChildNode = oNewDom.childNodes[i - r];
if (oNewDomChildNode.nodeType == 1 /* ELEMENT_NODE */) {
// recursively patch child elements
if (!patch(oOldDomChildNode, oNewDomChildNode)) {
// if patch is not possible we replace nodes
// in this case replaced node is removed
r = r + 1;
}
} else {
// when not element update only node values
oOldDomChildNode.nodeValue = oNewDomChildNode.nodeValue;
}
}
return true;
} | [
"function",
"patch",
"(",
"oOldDom",
",",
"oNewDom",
")",
"{",
"// start checking with most common use case and backwards compatible",
"if",
"(",
"oOldDom",
".",
"childElementCount",
"!=",
"oNewDom",
".",
"childElementCount",
"||",
"oOldDom",
".",
"tagName",
"!=",
"oNewDom",
".",
"tagName",
")",
"{",
"oOldDom",
".",
"parentNode",
".",
"replaceChild",
"(",
"oNewDom",
",",
"oOldDom",
")",
";",
"return",
"false",
";",
"}",
"// go with native... if nodes are equal there is nothing to do",
"// http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isEqualNode",
"if",
"(",
"oOldDom",
".",
"isEqualNode",
"(",
"oNewDom",
")",
")",
"{",
"return",
"true",
";",
"}",
"// remove outdated attributes from old dom",
"var",
"aOldAttributes",
"=",
"oOldDom",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"aOldAttributes",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"var",
"sAttrName",
"=",
"aOldAttributes",
"[",
"i",
"]",
".",
"name",
";",
"if",
"(",
"oNewDom",
".",
"getAttribute",
"(",
"sAttrName",
")",
"===",
"null",
")",
"{",
"oOldDom",
".",
"removeAttribute",
"(",
"sAttrName",
")",
";",
"ii",
"=",
"ii",
"-",
"1",
";",
"i",
"=",
"i",
"-",
"1",
";",
"}",
"}",
"// patch new or changed attributes to the old dom",
"var",
"aNewAttributes",
"=",
"oNewDom",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"aNewAttributes",
".",
"length",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"var",
"sAttrName",
"=",
"aNewAttributes",
"[",
"i",
"]",
".",
"name",
",",
"vOldAttrValue",
"=",
"oOldDom",
".",
"getAttribute",
"(",
"sAttrName",
")",
",",
"vNewAttrValue",
"=",
"oNewDom",
".",
"getAttribute",
"(",
"sAttrName",
")",
";",
"if",
"(",
"vOldAttrValue",
"===",
"null",
"||",
"vOldAttrValue",
"!==",
"vNewAttrValue",
")",
"{",
"oOldDom",
".",
"setAttribute",
"(",
"sAttrName",
",",
"vNewAttrValue",
")",
";",
"}",
"}",
"// check whether more child nodes to continue or not",
"var",
"iNewChildNodesCount",
"=",
"oNewDom",
".",
"childNodes",
".",
"length",
";",
"if",
"(",
"!",
"iNewChildNodesCount",
"&&",
"!",
"oOldDom",
".",
"hasChildNodes",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// maybe no more child elements",
"if",
"(",
"!",
"oNewDom",
".",
"childElementCount",
")",
"{",
"// but child nodes(e.g. Text Nodes) still needs to be replaced",
"if",
"(",
"!",
"iNewChildNodesCount",
")",
"{",
"// new dom does not have any child node, so we can clean the old one",
"oOldDom",
".",
"textContent",
"=",
"\"\"",
";",
"}",
"else",
"if",
"(",
"iNewChildNodesCount",
"==",
"1",
"&&",
"oNewDom",
".",
"firstChild",
".",
"nodeType",
"==",
"3",
"/* TEXT_NODE */",
")",
"{",
"// update the text content for the first text node",
"oOldDom",
".",
"textContent",
"=",
"oNewDom",
".",
"textContent",
";",
"}",
"else",
"{",
"// in case of comments or other node types are used",
"oOldDom",
".",
"innerHTML",
"=",
"oNewDom",
".",
"innerHTML",
";",
"}",
"return",
"true",
";",
"}",
"// patch child nodes",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"r",
"=",
"0",
",",
"ii",
"=",
"iNewChildNodesCount",
";",
"i",
"<",
"ii",
";",
"i",
"++",
")",
"{",
"var",
"oOldDomChildNode",
"=",
"oOldDom",
".",
"childNodes",
"[",
"i",
"]",
",",
"oNewDomChildNode",
"=",
"oNewDom",
".",
"childNodes",
"[",
"i",
"-",
"r",
"]",
";",
"if",
"(",
"oNewDomChildNode",
".",
"nodeType",
"==",
"1",
"/* ELEMENT_NODE */",
")",
"{",
"// recursively patch child elements",
"if",
"(",
"!",
"patch",
"(",
"oOldDomChildNode",
",",
"oNewDomChildNode",
")",
")",
"{",
"// if patch is not possible we replace nodes",
"// in this case replaced node is removed",
"r",
"=",
"r",
"+",
"1",
";",
"}",
"}",
"else",
"{",
"// when not element update only node values",
"oOldDomChildNode",
".",
"nodeValue",
"=",
"oNewDomChildNode",
".",
"nodeValue",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | This method tries to patch two HTML elements according to changed attributes.
As a fallback it replaces DOM nodes.
@function
@since 1.58
@param {HTMLElement} oOldDom Existing element to be patched
@param {HTMLElement} oNewDom The new node to patch old dom
@return {boolean} true when patch is applied correctly or false when nodes are replaced
@alias module:sap/ui/dom/patch
@private
@ui5-restricted sap.ui.core | [
"This",
"method",
"tries",
"to",
"patch",
"two",
"HTML",
"elements",
"according",
"to",
"changed",
"attributes",
".",
"As",
"a",
"fallback",
"it",
"replaces",
"DOM",
"nodes",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/patch.js#L24-L103 |
4,717 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/ODataModel.js | _submit | function _submit(){
// execute the request and use the metadata if available
if (that.bUseBatch) {
that.updateSecurityToken();
// batch requests only need the path without the service URL
// extract query of url and combine it with the path...
var sUriQuery = URI.parse(oRequest.requestUri).query;
//var sRequestUrl = sPath.replace(/\/$/, ""); // remove trailing slash if any
//sRequestUrl += sUriQuery ? "?" + sUriQuery : "";
var sRequestUrl = that._createRequestUrl(sPath, null, sUriQuery, that.bUseBatch);
oRequest = that._createRequest(sRequestUrl, "GET", true);
var oBatchRequest = that._createBatchRequest([oRequest],true);
oRequestHandle = that._request(oBatchRequest, _handleSuccess, _handleError, OData.batchHandler, undefined, that.getServiceMetadata());
} else {
oRequestHandle = that._request(oRequest, _handleSuccess, _handleError, that.oHandler, undefined, that.getServiceMetadata());
}
if (fnHandleUpdate) {
// Create a wrapper for the request handle to be able to differentiate
// between intentionally aborted requests and failed requests
var oWrappedHandle = {
abort: function() {
oRequestHandle.bAborted = true;
oRequestHandle.abort();
}
};
fnHandleUpdate(oWrappedHandle);
}
} | javascript | function _submit(){
// execute the request and use the metadata if available
if (that.bUseBatch) {
that.updateSecurityToken();
// batch requests only need the path without the service URL
// extract query of url and combine it with the path...
var sUriQuery = URI.parse(oRequest.requestUri).query;
//var sRequestUrl = sPath.replace(/\/$/, ""); // remove trailing slash if any
//sRequestUrl += sUriQuery ? "?" + sUriQuery : "";
var sRequestUrl = that._createRequestUrl(sPath, null, sUriQuery, that.bUseBatch);
oRequest = that._createRequest(sRequestUrl, "GET", true);
var oBatchRequest = that._createBatchRequest([oRequest],true);
oRequestHandle = that._request(oBatchRequest, _handleSuccess, _handleError, OData.batchHandler, undefined, that.getServiceMetadata());
} else {
oRequestHandle = that._request(oRequest, _handleSuccess, _handleError, that.oHandler, undefined, that.getServiceMetadata());
}
if (fnHandleUpdate) {
// Create a wrapper for the request handle to be able to differentiate
// between intentionally aborted requests and failed requests
var oWrappedHandle = {
abort: function() {
oRequestHandle.bAborted = true;
oRequestHandle.abort();
}
};
fnHandleUpdate(oWrappedHandle);
}
} | [
"function",
"_submit",
"(",
")",
"{",
"// execute the request and use the metadata if available",
"if",
"(",
"that",
".",
"bUseBatch",
")",
"{",
"that",
".",
"updateSecurityToken",
"(",
")",
";",
"// batch requests only need the path without the service URL",
"// extract query of url and combine it with the path...",
"var",
"sUriQuery",
"=",
"URI",
".",
"parse",
"(",
"oRequest",
".",
"requestUri",
")",
".",
"query",
";",
"//var sRequestUrl = sPath.replace(/\\/$/, \"\"); // remove trailing slash if any",
"//sRequestUrl += sUriQuery ? \"?\" + sUriQuery : \"\";",
"var",
"sRequestUrl",
"=",
"that",
".",
"_createRequestUrl",
"(",
"sPath",
",",
"null",
",",
"sUriQuery",
",",
"that",
".",
"bUseBatch",
")",
";",
"oRequest",
"=",
"that",
".",
"_createRequest",
"(",
"sRequestUrl",
",",
"\"GET\"",
",",
"true",
")",
";",
"var",
"oBatchRequest",
"=",
"that",
".",
"_createBatchRequest",
"(",
"[",
"oRequest",
"]",
",",
"true",
")",
";",
"oRequestHandle",
"=",
"that",
".",
"_request",
"(",
"oBatchRequest",
",",
"_handleSuccess",
",",
"_handleError",
",",
"OData",
".",
"batchHandler",
",",
"undefined",
",",
"that",
".",
"getServiceMetadata",
"(",
")",
")",
";",
"}",
"else",
"{",
"oRequestHandle",
"=",
"that",
".",
"_request",
"(",
"oRequest",
",",
"_handleSuccess",
",",
"_handleError",
",",
"that",
".",
"oHandler",
",",
"undefined",
",",
"that",
".",
"getServiceMetadata",
"(",
")",
")",
";",
"}",
"if",
"(",
"fnHandleUpdate",
")",
"{",
"// Create a wrapper for the request handle to be able to differentiate",
"// between intentionally aborted requests and failed requests",
"var",
"oWrappedHandle",
"=",
"{",
"abort",
":",
"function",
"(",
")",
"{",
"oRequestHandle",
".",
"bAborted",
"=",
"true",
";",
"oRequestHandle",
".",
"abort",
"(",
")",
";",
"}",
"}",
";",
"fnHandleUpdate",
"(",
"oWrappedHandle",
")",
";",
"}",
"}"
] | this method is used to retrieve all desired data. It triggers additional read requests if the server paging size
permits to return all the requested data. This could only happen for servers with support for oData > 2.0. | [
"this",
"method",
"is",
"used",
"to",
"retrieve",
"all",
"desired",
"data",
".",
"It",
"triggers",
"additional",
"read",
"requests",
"if",
"the",
"server",
"paging",
"size",
"permits",
"to",
"return",
"all",
"the",
"requested",
"data",
".",
"This",
"could",
"only",
"happen",
"for",
"servers",
"with",
"support",
"for",
"oData",
">",
"2",
".",
"0",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/ODataModel.js#L831-L860 |
4,718 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataRequestor.js | function (sUrl, bAnnotations, bPrefetch) {
var oPromise;
function convertXMLMetadata(oJSON) {
var Converter = sODataVersion === "4.0" || bAnnotations
? _V4MetadataConverter
: _V2MetadataConverter,
oData = oJSON.$XML;
delete oJSON.$XML; // be nice to the garbage collector
return jQuery.extend(new Converter().convertXMLMetadata(oData, sUrl),
oJSON);
}
if (sUrl in mUrl2Promise) {
if (bPrefetch) {
throw new Error("Must not prefetch twice: " + sUrl);
}
oPromise = mUrl2Promise[sUrl].then(convertXMLMetadata);
delete mUrl2Promise[sUrl];
} else {
oPromise = new Promise(function (fnResolve, fnReject) {
jQuery.ajax(bAnnotations ? sUrl : sUrl + sQueryStr, {
method : "GET",
headers : mHeaders
}).then(function (oData, sTextStatus, jqXHR) {
var sDate = jqXHR.getResponseHeader("Date"),
sETag = jqXHR.getResponseHeader("ETag"),
oJSON = {$XML : oData},
sLastModified = jqXHR.getResponseHeader("Last-Modified");
if (sDate) {
oJSON.$Date = sDate;
}
if (sETag) {
oJSON.$ETag = sETag;
}
if (sLastModified) {
oJSON.$LastModified = sLastModified;
}
fnResolve(oJSON);
}, function (jqXHR, sTextStatus, sErrorMessage) {
var oError = _Helper.createError(jqXHR, "Could not load metadata");
Log.error("GET " + sUrl, oError.message,
"sap.ui.model.odata.v4.lib._MetadataRequestor");
fnReject(oError);
});
});
if (bPrefetch) {
mUrl2Promise[sUrl] = oPromise;
} else {
oPromise = oPromise.then(convertXMLMetadata);
}
}
return oPromise;
} | javascript | function (sUrl, bAnnotations, bPrefetch) {
var oPromise;
function convertXMLMetadata(oJSON) {
var Converter = sODataVersion === "4.0" || bAnnotations
? _V4MetadataConverter
: _V2MetadataConverter,
oData = oJSON.$XML;
delete oJSON.$XML; // be nice to the garbage collector
return jQuery.extend(new Converter().convertXMLMetadata(oData, sUrl),
oJSON);
}
if (sUrl in mUrl2Promise) {
if (bPrefetch) {
throw new Error("Must not prefetch twice: " + sUrl);
}
oPromise = mUrl2Promise[sUrl].then(convertXMLMetadata);
delete mUrl2Promise[sUrl];
} else {
oPromise = new Promise(function (fnResolve, fnReject) {
jQuery.ajax(bAnnotations ? sUrl : sUrl + sQueryStr, {
method : "GET",
headers : mHeaders
}).then(function (oData, sTextStatus, jqXHR) {
var sDate = jqXHR.getResponseHeader("Date"),
sETag = jqXHR.getResponseHeader("ETag"),
oJSON = {$XML : oData},
sLastModified = jqXHR.getResponseHeader("Last-Modified");
if (sDate) {
oJSON.$Date = sDate;
}
if (sETag) {
oJSON.$ETag = sETag;
}
if (sLastModified) {
oJSON.$LastModified = sLastModified;
}
fnResolve(oJSON);
}, function (jqXHR, sTextStatus, sErrorMessage) {
var oError = _Helper.createError(jqXHR, "Could not load metadata");
Log.error("GET " + sUrl, oError.message,
"sap.ui.model.odata.v4.lib._MetadataRequestor");
fnReject(oError);
});
});
if (bPrefetch) {
mUrl2Promise[sUrl] = oPromise;
} else {
oPromise = oPromise.then(convertXMLMetadata);
}
}
return oPromise;
} | [
"function",
"(",
"sUrl",
",",
"bAnnotations",
",",
"bPrefetch",
")",
"{",
"var",
"oPromise",
";",
"function",
"convertXMLMetadata",
"(",
"oJSON",
")",
"{",
"var",
"Converter",
"=",
"sODataVersion",
"===",
"\"4.0\"",
"||",
"bAnnotations",
"?",
"_V4MetadataConverter",
":",
"_V2MetadataConverter",
",",
"oData",
"=",
"oJSON",
".",
"$XML",
";",
"delete",
"oJSON",
".",
"$XML",
";",
"// be nice to the garbage collector",
"return",
"jQuery",
".",
"extend",
"(",
"new",
"Converter",
"(",
")",
".",
"convertXMLMetadata",
"(",
"oData",
",",
"sUrl",
")",
",",
"oJSON",
")",
";",
"}",
"if",
"(",
"sUrl",
"in",
"mUrl2Promise",
")",
"{",
"if",
"(",
"bPrefetch",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Must not prefetch twice: \"",
"+",
"sUrl",
")",
";",
"}",
"oPromise",
"=",
"mUrl2Promise",
"[",
"sUrl",
"]",
".",
"then",
"(",
"convertXMLMetadata",
")",
";",
"delete",
"mUrl2Promise",
"[",
"sUrl",
"]",
";",
"}",
"else",
"{",
"oPromise",
"=",
"new",
"Promise",
"(",
"function",
"(",
"fnResolve",
",",
"fnReject",
")",
"{",
"jQuery",
".",
"ajax",
"(",
"bAnnotations",
"?",
"sUrl",
":",
"sUrl",
"+",
"sQueryStr",
",",
"{",
"method",
":",
"\"GET\"",
",",
"headers",
":",
"mHeaders",
"}",
")",
".",
"then",
"(",
"function",
"(",
"oData",
",",
"sTextStatus",
",",
"jqXHR",
")",
"{",
"var",
"sDate",
"=",
"jqXHR",
".",
"getResponseHeader",
"(",
"\"Date\"",
")",
",",
"sETag",
"=",
"jqXHR",
".",
"getResponseHeader",
"(",
"\"ETag\"",
")",
",",
"oJSON",
"=",
"{",
"$XML",
":",
"oData",
"}",
",",
"sLastModified",
"=",
"jqXHR",
".",
"getResponseHeader",
"(",
"\"Last-Modified\"",
")",
";",
"if",
"(",
"sDate",
")",
"{",
"oJSON",
".",
"$Date",
"=",
"sDate",
";",
"}",
"if",
"(",
"sETag",
")",
"{",
"oJSON",
".",
"$ETag",
"=",
"sETag",
";",
"}",
"if",
"(",
"sLastModified",
")",
"{",
"oJSON",
".",
"$LastModified",
"=",
"sLastModified",
";",
"}",
"fnResolve",
"(",
"oJSON",
")",
";",
"}",
",",
"function",
"(",
"jqXHR",
",",
"sTextStatus",
",",
"sErrorMessage",
")",
"{",
"var",
"oError",
"=",
"_Helper",
".",
"createError",
"(",
"jqXHR",
",",
"\"Could not load metadata\"",
")",
";",
"Log",
".",
"error",
"(",
"\"GET \"",
"+",
"sUrl",
",",
"oError",
".",
"message",
",",
"\"sap.ui.model.odata.v4.lib._MetadataRequestor\"",
")",
";",
"fnReject",
"(",
"oError",
")",
";",
"}",
")",
";",
"}",
")",
";",
"if",
"(",
"bPrefetch",
")",
"{",
"mUrl2Promise",
"[",
"sUrl",
"]",
"=",
"oPromise",
";",
"}",
"else",
"{",
"oPromise",
"=",
"oPromise",
".",
"then",
"(",
"convertXMLMetadata",
")",
";",
"}",
"}",
"return",
"oPromise",
";",
"}"
] | Reads a metadata document from the given URL.
@param {string} sUrl
The URL of a metadata document, it must not contain a query string or a
fragment part
@param {boolean} [bAnnotations=false]
<code>true</code> if an additional annotation file is read, otherwise it is
expected to be a metadata document in the correct OData version
@param {boolean} [bPrefetch=false]
Whether to just read the metadata document, but not yet convert it from XML to
JSON. For any given URL, this is useful in an optional early call that precedes
a normal call without this flag.
@returns {Promise}
A promise fulfilled with the metadata as a JSON object, enriched with a
<code>$Date</code>, <code>$ETag</code> or <code>$LastModified</code> property
that contains the value of the response header "Date", "ETag" or
"Last-Modified" respectively; these additional properties are missing if there
is no such header. In case of <code>bPrefetch</code>, the JSON object is
empty except for <code>$XML</code> (which contains the unconverted metadata as
XML) and the additional properties described before.
@throws {Error}
If <code>bPrefetch</code> is set in two consecutive calls for the same URL | [
"Reads",
"a",
"metadata",
"document",
"from",
"the",
"given",
"URL",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataRequestor.js#L56-L112 |
|
4,719 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/rules/Model.support.js | _fnFindBestMatch | function _fnFindBestMatch(aValues, sBindingPath) {
var iJsonModelMin = -1;
var sJsonModelBestMatch = false;
aValues.forEach(function(sKey) {
var iCurrDest = StringAnalyzer.calculateLevenshteinDistance(sBindingPath, sKey);
if (iJsonModelMin === -1 || iCurrDest < iJsonModelMin) {
iJsonModelMin = iCurrDest;
sJsonModelBestMatch = sKey;
}
});
return sJsonModelBestMatch;
} | javascript | function _fnFindBestMatch(aValues, sBindingPath) {
var iJsonModelMin = -1;
var sJsonModelBestMatch = false;
aValues.forEach(function(sKey) {
var iCurrDest = StringAnalyzer.calculateLevenshteinDistance(sBindingPath, sKey);
if (iJsonModelMin === -1 || iCurrDest < iJsonModelMin) {
iJsonModelMin = iCurrDest;
sJsonModelBestMatch = sKey;
}
});
return sJsonModelBestMatch;
} | [
"function",
"_fnFindBestMatch",
"(",
"aValues",
",",
"sBindingPath",
")",
"{",
"var",
"iJsonModelMin",
"=",
"-",
"1",
";",
"var",
"sJsonModelBestMatch",
"=",
"false",
";",
"aValues",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"var",
"iCurrDest",
"=",
"StringAnalyzer",
".",
"calculateLevenshteinDistance",
"(",
"sBindingPath",
",",
"sKey",
")",
";",
"if",
"(",
"iJsonModelMin",
"===",
"-",
"1",
"||",
"iCurrDest",
"<",
"iJsonModelMin",
")",
"{",
"iJsonModelMin",
"=",
"iCurrDest",
";",
"sJsonModelBestMatch",
"=",
"sKey",
";",
"}",
"}",
")",
";",
"return",
"sJsonModelBestMatch",
";",
"}"
] | Control, Internal, Application | [
"Control",
"Internal",
"Application"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/rules/Model.support.js#L31-L42 |
4,720 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js | function (vRawValue, oDetails) {
var sPath = typeof vRawValue === "string"
? "/" + oDetails.schemaChildName + "/" + vRawValue
: oDetails.context.getPath();
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchValueListType(sPath).unwrap()
: oDetails.context.getModel().getValueListType(sPath);
} | javascript | function (vRawValue, oDetails) {
var sPath = typeof vRawValue === "string"
? "/" + oDetails.schemaChildName + "/" + vRawValue
: oDetails.context.getPath();
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchValueListType(sPath).unwrap()
: oDetails.context.getModel().getValueListType(sPath);
} | [
"function",
"(",
"vRawValue",
",",
"oDetails",
")",
"{",
"var",
"sPath",
"=",
"typeof",
"vRawValue",
"===",
"\"string\"",
"?",
"\"/\"",
"+",
"oDetails",
".",
"schemaChildName",
"+",
"\"/\"",
"+",
"vRawValue",
":",
"oDetails",
".",
"context",
".",
"getPath",
"(",
")",
";",
"return",
"oDetails",
".",
"$$valueAsPromise",
"?",
"oDetails",
".",
"context",
".",
"getModel",
"(",
")",
".",
"fetchValueListType",
"(",
"sPath",
")",
".",
"unwrap",
"(",
")",
":",
"oDetails",
".",
"context",
".",
"getModel",
"(",
")",
".",
"getValueListType",
"(",
"sPath",
")",
";",
"}"
] | Determines which type of value list exists for the given property.
@param {any} vRawValue
The raw value from the meta model; must be either a property or a path pointing to
a property (relative to <code>oDetails.schemaChildName</code>)
@param {object} oDetails
The details object
@param {boolean} [oDetails.$$valueAsPromise]
Whether a <code>Promise</code> may be returned if the needed metadata is not yet
loaded (since 1.57.0)
@param {sap.ui.model.Context} oDetails.context
Points to the given path, that is
<code>oDetails.context.getProperty("") === vRawValue</code>
@param {string} oDetails.schemaChildName
The qualified name of the schema child where the computed annotation has been
found, for example "name.space.EntityType"
@returns {sap.ui.model.odata.v4.ValueListType|Promise}
The type of the value list or a <code>Promise</code> resolving with the type of the
value list or rejected, if the property cannot be found in the metadata
@throws {Error}
If the property cannot be found in the metadata, or if
<code>$$valueAsPromise</code> is not set to <code>true</code> and the metadata is
not yet loaded
@public
@since 1.47.0 | [
"Determines",
"which",
"type",
"of",
"value",
"list",
"exists",
"for",
"the",
"given",
"property",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L331-L339 |
|
4,721 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oOperand1, oOperand2) {
if (oOperand1.result !== "constant" && oOperand1.category === "number"
&& oOperand2.result === "constant" && oOperand2.type === "Edm.Int64") {
// adjust an integer constant of type "Edm.Int64" to the number
oOperand2.category = "number";
}
if (oOperand1.result !== "constant" && oOperand1.category === "Decimal"
&& oOperand2.result === "constant" && oOperand2.type === "Edm.Int32") {
// adjust an integer constant of type "Edm.Int32" to the decimal
oOperand2.category = "Decimal";
oOperand2.type = oOperand1.type;
}
} | javascript | function (oOperand1, oOperand2) {
if (oOperand1.result !== "constant" && oOperand1.category === "number"
&& oOperand2.result === "constant" && oOperand2.type === "Edm.Int64") {
// adjust an integer constant of type "Edm.Int64" to the number
oOperand2.category = "number";
}
if (oOperand1.result !== "constant" && oOperand1.category === "Decimal"
&& oOperand2.result === "constant" && oOperand2.type === "Edm.Int32") {
// adjust an integer constant of type "Edm.Int32" to the decimal
oOperand2.category = "Decimal";
oOperand2.type = oOperand1.type;
}
} | [
"function",
"(",
"oOperand1",
",",
"oOperand2",
")",
"{",
"if",
"(",
"oOperand1",
".",
"result",
"!==",
"\"constant\"",
"&&",
"oOperand1",
".",
"category",
"===",
"\"number\"",
"&&",
"oOperand2",
".",
"result",
"===",
"\"constant\"",
"&&",
"oOperand2",
".",
"type",
"===",
"\"Edm.Int64\"",
")",
"{",
"// adjust an integer constant of type \"Edm.Int64\" to the number",
"oOperand2",
".",
"category",
"=",
"\"number\"",
";",
"}",
"if",
"(",
"oOperand1",
".",
"result",
"!==",
"\"constant\"",
"&&",
"oOperand1",
".",
"category",
"===",
"\"Decimal\"",
"&&",
"oOperand2",
".",
"result",
"===",
"\"constant\"",
"&&",
"oOperand2",
".",
"type",
"===",
"\"Edm.Int32\"",
")",
"{",
"// adjust an integer constant of type \"Edm.Int32\" to the decimal",
"oOperand2",
".",
"category",
"=",
"\"Decimal\"",
";",
"oOperand2",
".",
"type",
"=",
"oOperand1",
".",
"type",
";",
"}",
"}"
] | Adjusts the second operand so that both have the same category, if possible.
@param {object} oOperand1
the operand 1 (as a result object with category)
@param {object} oOperand2
the operand 2 (as a result object with category) - may be modified | [
"Adjusts",
"the",
"second",
"operand",
"so",
"that",
"both",
"have",
"the",
"same",
"category",
"if",
"possible",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L144-L156 |
|
4,722 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue) {
if (oPathValue.value === undefined) {
return undefined;
}
Measurement.average(sPerformanceGetExpression, "", aPerformanceCategories);
if (!bSimpleParserWarningLogged
&& ManagedObject.bindingParser === BindingParser.simpleParser) {
Log.warning("Complex binding syntax not active", null, sAnnotationHelper);
bSimpleParserWarningLogged = true;
}
return Expression.expression(oPathValue).then(function (oResult) {
return Basics.resultToString(oResult, false, oPathValue.complexBinding);
}, function (e) {
if (e instanceof SyntaxError) {
return "Unsupported: " + BindingParser.complexParser.escape(
Basics.toErrorString(oPathValue.value));
}
throw e;
}).finally(function () {
Measurement.end(sPerformanceGetExpression);
}).unwrap();
} | javascript | function (oPathValue) {
if (oPathValue.value === undefined) {
return undefined;
}
Measurement.average(sPerformanceGetExpression, "", aPerformanceCategories);
if (!bSimpleParserWarningLogged
&& ManagedObject.bindingParser === BindingParser.simpleParser) {
Log.warning("Complex binding syntax not active", null, sAnnotationHelper);
bSimpleParserWarningLogged = true;
}
return Expression.expression(oPathValue).then(function (oResult) {
return Basics.resultToString(oResult, false, oPathValue.complexBinding);
}, function (e) {
if (e instanceof SyntaxError) {
return "Unsupported: " + BindingParser.complexParser.escape(
Basics.toErrorString(oPathValue.value));
}
throw e;
}).finally(function () {
Measurement.end(sPerformanceGetExpression);
}).unwrap();
} | [
"function",
"(",
"oPathValue",
")",
"{",
"if",
"(",
"oPathValue",
".",
"value",
"===",
"undefined",
")",
"{",
"return",
"undefined",
";",
"}",
"Measurement",
".",
"average",
"(",
"sPerformanceGetExpression",
",",
"\"\"",
",",
"aPerformanceCategories",
")",
";",
"if",
"(",
"!",
"bSimpleParserWarningLogged",
"&&",
"ManagedObject",
".",
"bindingParser",
"===",
"BindingParser",
".",
"simpleParser",
")",
"{",
"Log",
".",
"warning",
"(",
"\"Complex binding syntax not active\"",
",",
"null",
",",
"sAnnotationHelper",
")",
";",
"bSimpleParserWarningLogged",
"=",
"true",
";",
"}",
"return",
"Expression",
".",
"expression",
"(",
"oPathValue",
")",
".",
"then",
"(",
"function",
"(",
"oResult",
")",
"{",
"return",
"Basics",
".",
"resultToString",
"(",
"oResult",
",",
"false",
",",
"oPathValue",
".",
"complexBinding",
")",
";",
"}",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"SyntaxError",
")",
"{",
"return",
"\"Unsupported: \"",
"+",
"BindingParser",
".",
"complexParser",
".",
"escape",
"(",
"Basics",
".",
"toErrorString",
"(",
"oPathValue",
".",
"value",
")",
")",
";",
"}",
"throw",
"e",
";",
"}",
")",
".",
"finally",
"(",
"function",
"(",
")",
"{",
"Measurement",
".",
"end",
"(",
"sPerformanceGetExpression",
")",
";",
"}",
")",
".",
"unwrap",
"(",
")",
";",
"}"
] | Calculates an expression. Ensures that errors that are thrown while processing are
handled accordingly.
@param {object} oPathValue
path and value information pointing to the expression (see Expression object)
@returns {Promise|string}
the expression value or "Unsupported: oRawValue" in case of an error or
<code>undefined</code> in case the raw value is undefined; may instead return a
<code>Promise</code> resolving with that result. | [
"Calculates",
"an",
"expression",
".",
"Ensures",
"that",
"errors",
"that",
"are",
"thrown",
"while",
"processing",
"are",
"handled",
"accordingly",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L566-L590 |
|
4,723 | SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js | getAllLibraries | function getAllLibraries(aExcludedLibraries, bIncludeDistLayer) {
var mLibraries = sap.ui.getCore().getLoadedLibraries(),
sInfoLibName,
bNewLibrary,
oInfo,
i;
// discover what is available in order to also test other libraries than those loaded in bootstrap
oInfo = sap.ui.getVersionInfo();
for (i = 0; i < oInfo.libraries.length; i++) {
sInfoLibName = oInfo.libraries[i].name;
if (jQuery.inArray(sInfoLibName, aExcludedLibraries) === -1 && !mLibraries[sInfoLibName]) {
Log.info("Libary '" + sInfoLibName + "' is not loaded!");
try {
sap.ui.getCore().loadLibrary(sInfoLibName);
bNewLibrary = true;
} catch (e) {
// not a control lib? This happens for e.g. "themelib_sap_bluecrystal"...
}
}
}
// Renew the libraries object if new libraries are added
if (bNewLibrary) {
mLibraries = sap.ui.getCore().getLoadedLibraries();
}
// excluded libraries should even be excluded when already loaded initially
aExcludedLibraries.forEach(function(sLibraryName) {
mLibraries[sLibraryName] = undefined;
});
// ignore dist-layer libraries if requested
if (!bIncludeDistLayer) {
for (var sLibName in mLibraries) {
if (!ControlIterator.isKnownRuntimeLayerLibrary(sLibName)) {
mLibraries[sLibName] = undefined;
}
}
}
return mLibraries;
} | javascript | function getAllLibraries(aExcludedLibraries, bIncludeDistLayer) {
var mLibraries = sap.ui.getCore().getLoadedLibraries(),
sInfoLibName,
bNewLibrary,
oInfo,
i;
// discover what is available in order to also test other libraries than those loaded in bootstrap
oInfo = sap.ui.getVersionInfo();
for (i = 0; i < oInfo.libraries.length; i++) {
sInfoLibName = oInfo.libraries[i].name;
if (jQuery.inArray(sInfoLibName, aExcludedLibraries) === -1 && !mLibraries[sInfoLibName]) {
Log.info("Libary '" + sInfoLibName + "' is not loaded!");
try {
sap.ui.getCore().loadLibrary(sInfoLibName);
bNewLibrary = true;
} catch (e) {
// not a control lib? This happens for e.g. "themelib_sap_bluecrystal"...
}
}
}
// Renew the libraries object if new libraries are added
if (bNewLibrary) {
mLibraries = sap.ui.getCore().getLoadedLibraries();
}
// excluded libraries should even be excluded when already loaded initially
aExcludedLibraries.forEach(function(sLibraryName) {
mLibraries[sLibraryName] = undefined;
});
// ignore dist-layer libraries if requested
if (!bIncludeDistLayer) {
for (var sLibName in mLibraries) {
if (!ControlIterator.isKnownRuntimeLayerLibrary(sLibName)) {
mLibraries[sLibName] = undefined;
}
}
}
return mLibraries;
} | [
"function",
"getAllLibraries",
"(",
"aExcludedLibraries",
",",
"bIncludeDistLayer",
")",
"{",
"var",
"mLibraries",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLoadedLibraries",
"(",
")",
",",
"sInfoLibName",
",",
"bNewLibrary",
",",
"oInfo",
",",
"i",
";",
"// discover what is available in order to also test other libraries than those loaded in bootstrap",
"oInfo",
"=",
"sap",
".",
"ui",
".",
"getVersionInfo",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"oInfo",
".",
"libraries",
".",
"length",
";",
"i",
"++",
")",
"{",
"sInfoLibName",
"=",
"oInfo",
".",
"libraries",
"[",
"i",
"]",
".",
"name",
";",
"if",
"(",
"jQuery",
".",
"inArray",
"(",
"sInfoLibName",
",",
"aExcludedLibraries",
")",
"===",
"-",
"1",
"&&",
"!",
"mLibraries",
"[",
"sInfoLibName",
"]",
")",
"{",
"Log",
".",
"info",
"(",
"\"Libary '\"",
"+",
"sInfoLibName",
"+",
"\"' is not loaded!\"",
")",
";",
"try",
"{",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"loadLibrary",
"(",
"sInfoLibName",
")",
";",
"bNewLibrary",
"=",
"true",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// not a control lib? This happens for e.g. \"themelib_sap_bluecrystal\"...",
"}",
"}",
"}",
"// Renew the libraries object if new libraries are added",
"if",
"(",
"bNewLibrary",
")",
"{",
"mLibraries",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLoadedLibraries",
"(",
")",
";",
"}",
"// excluded libraries should even be excluded when already loaded initially",
"aExcludedLibraries",
".",
"forEach",
"(",
"function",
"(",
"sLibraryName",
")",
"{",
"mLibraries",
"[",
"sLibraryName",
"]",
"=",
"undefined",
";",
"}",
")",
";",
"// ignore dist-layer libraries if requested",
"if",
"(",
"!",
"bIncludeDistLayer",
")",
"{",
"for",
"(",
"var",
"sLibName",
"in",
"mLibraries",
")",
"{",
"if",
"(",
"!",
"ControlIterator",
".",
"isKnownRuntimeLayerLibrary",
"(",
"sLibName",
")",
")",
"{",
"mLibraries",
"[",
"sLibName",
"]",
"=",
"undefined",
";",
"}",
"}",
"}",
"return",
"mLibraries",
";",
"}"
] | Returns a map with all libraries found, depending on the given arguments
@param {Array} aExcludedLibraries the list of libraries to exclude
@param {boolean} bIncludeDistLayer whether the list of libraries should be restricted to known runtime-layer libraries (superset of the OpenUI5 libraries) or include any dist-layer libraries
@returns a map of library infos | [
"Returns",
"a",
"map",
"with",
"all",
"libraries",
"found",
"depending",
"on",
"the",
"given",
"arguments"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L239-L281 |
4,724 | SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js | getRequestedLibraries | function getRequestedLibraries(aLibrariesToTest) {
var mLibraries = sap.ui.getCore().getLoadedLibraries(),
bNewLibrary,
i;
// make sure the explicitly requested libraries are there
for (i = 0; i < aLibrariesToTest.length; i++) {
if (!mLibraries[aLibrariesToTest[i]]) {
sap.ui.getCore().loadLibrary(aLibrariesToTest[i]); // no try-catch, as this library was explicitly requested
bNewLibrary = true;
}
}
if (bNewLibrary) {
mLibraries = sap.ui.getCore().getLoadedLibraries();
}
for (var sLibraryName in mLibraries) {
if (aLibrariesToTest.indexOf(sLibraryName) === -1) {
mLibraries[sLibraryName] = undefined;
}
}
return mLibraries;
} | javascript | function getRequestedLibraries(aLibrariesToTest) {
var mLibraries = sap.ui.getCore().getLoadedLibraries(),
bNewLibrary,
i;
// make sure the explicitly requested libraries are there
for (i = 0; i < aLibrariesToTest.length; i++) {
if (!mLibraries[aLibrariesToTest[i]]) {
sap.ui.getCore().loadLibrary(aLibrariesToTest[i]); // no try-catch, as this library was explicitly requested
bNewLibrary = true;
}
}
if (bNewLibrary) {
mLibraries = sap.ui.getCore().getLoadedLibraries();
}
for (var sLibraryName in mLibraries) {
if (aLibrariesToTest.indexOf(sLibraryName) === -1) {
mLibraries[sLibraryName] = undefined;
}
}
return mLibraries;
} | [
"function",
"getRequestedLibraries",
"(",
"aLibrariesToTest",
")",
"{",
"var",
"mLibraries",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLoadedLibraries",
"(",
")",
",",
"bNewLibrary",
",",
"i",
";",
"// make sure the explicitly requested libraries are there",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"aLibrariesToTest",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"mLibraries",
"[",
"aLibrariesToTest",
"[",
"i",
"]",
"]",
")",
"{",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"loadLibrary",
"(",
"aLibrariesToTest",
"[",
"i",
"]",
")",
";",
"// no try-catch, as this library was explicitly requested",
"bNewLibrary",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"bNewLibrary",
")",
"{",
"mLibraries",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLoadedLibraries",
"(",
")",
";",
"}",
"for",
"(",
"var",
"sLibraryName",
"in",
"mLibraries",
")",
"{",
"if",
"(",
"aLibrariesToTest",
".",
"indexOf",
"(",
"sLibraryName",
")",
"===",
"-",
"1",
")",
"{",
"mLibraries",
"[",
"sLibraryName",
"]",
"=",
"undefined",
";",
"}",
"}",
"return",
"mLibraries",
";",
"}"
] | Returns a map with library infos for the requested libraries
@param {Array} aLibrariesToTest list of libraries to load
@returns a map of library infos | [
"Returns",
"a",
"map",
"with",
"library",
"infos",
"for",
"the",
"requested",
"libraries"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L290-L314 |
4,725 | SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js | function(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit) {
var mLibraries = aLibrariesToTest ?
getRequestedLibraries(aLibrariesToTest)
:
getAllLibraries(aExcludedLibraries, bIncludeDistLayer);
QUnit.test("Should load at least one library and some controls", function(assert) {
assert.expect(2);
var bLibFound = false;
for (var sLibName in mLibraries) {
if (mLibraries[sLibName]) {
if (!bLibFound) {
assert.ok(mLibraries[sLibName], "Should have loaded at least one library");
bLibFound = true;
}
var iControls = mLibraries[sLibName].controls ? mLibraries[sLibName].controls.length : 0;
if (iControls > 0) {
assert.ok(iControls > 0, "Should find at least 10 controls in a library");
break;
}
}
}
});
return mLibraries;
} | javascript | function(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit) {
var mLibraries = aLibrariesToTest ?
getRequestedLibraries(aLibrariesToTest)
:
getAllLibraries(aExcludedLibraries, bIncludeDistLayer);
QUnit.test("Should load at least one library and some controls", function(assert) {
assert.expect(2);
var bLibFound = false;
for (var sLibName in mLibraries) {
if (mLibraries[sLibName]) {
if (!bLibFound) {
assert.ok(mLibraries[sLibName], "Should have loaded at least one library");
bLibFound = true;
}
var iControls = mLibraries[sLibName].controls ? mLibraries[sLibName].controls.length : 0;
if (iControls > 0) {
assert.ok(iControls > 0, "Should find at least 10 controls in a library");
break;
}
}
}
});
return mLibraries;
} | [
"function",
"(",
"aLibrariesToTest",
",",
"aExcludedLibraries",
",",
"bIncludeDistLayer",
",",
"QUnit",
")",
"{",
"var",
"mLibraries",
"=",
"aLibrariesToTest",
"?",
"getRequestedLibraries",
"(",
"aLibrariesToTest",
")",
":",
"getAllLibraries",
"(",
"aExcludedLibraries",
",",
"bIncludeDistLayer",
")",
";",
"QUnit",
".",
"test",
"(",
"\"Should load at least one library and some controls\"",
",",
"function",
"(",
"assert",
")",
"{",
"assert",
".",
"expect",
"(",
"2",
")",
";",
"var",
"bLibFound",
"=",
"false",
";",
"for",
"(",
"var",
"sLibName",
"in",
"mLibraries",
")",
"{",
"if",
"(",
"mLibraries",
"[",
"sLibName",
"]",
")",
"{",
"if",
"(",
"!",
"bLibFound",
")",
"{",
"assert",
".",
"ok",
"(",
"mLibraries",
"[",
"sLibName",
"]",
",",
"\"Should have loaded at least one library\"",
")",
";",
"bLibFound",
"=",
"true",
";",
"}",
"var",
"iControls",
"=",
"mLibraries",
"[",
"sLibName",
"]",
".",
"controls",
"?",
"mLibraries",
"[",
"sLibName",
"]",
".",
"controls",
".",
"length",
":",
"0",
";",
"if",
"(",
"iControls",
">",
"0",
")",
"{",
"assert",
".",
"ok",
"(",
"iControls",
">",
"0",
",",
"\"Should find at least 10 controls in a library\"",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
")",
";",
"return",
"mLibraries",
";",
"}"
] | Returns a map of libraries - either exactly those requested in aLibrariesToTest, if defined, or all discoverable libraries
under the given conditions. | [
"Returns",
"a",
"map",
"of",
"libraries",
"-",
"either",
"exactly",
"those",
"requested",
"in",
"aLibrariesToTest",
"if",
"defined",
"or",
"all",
"discoverable",
"libraries",
"under",
"the",
"given",
"conditions",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L321-L348 |
|
4,726 | SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js | function(aControls, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback) {
return new Promise(function(resolve, reject){
var iControlCountInLib = 0;
var loop = function(i) {
if (i < aControls.length) {
var sControlName = aControls[i];
handleControl(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(bCountThisControl){
if (bCountThisControl) {
iControlCountInLib++;
}
loop(i + 1);
});
} else {
resolve(iControlCountInLib);
}
};
loop(0);
});
} | javascript | function(aControls, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback) {
return new Promise(function(resolve, reject){
var iControlCountInLib = 0;
var loop = function(i) {
if (i < aControls.length) {
var sControlName = aControls[i];
handleControl(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(bCountThisControl){
if (bCountThisControl) {
iControlCountInLib++;
}
loop(i + 1);
});
} else {
resolve(iControlCountInLib);
}
};
loop(0);
});
} | [
"function",
"(",
"aControls",
",",
"aControlsToTest",
",",
"aExcludedControls",
",",
"bIncludeNonRenderable",
",",
"bIncludeNonInstantiable",
",",
"fnCallback",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"iControlCountInLib",
"=",
"0",
";",
"var",
"loop",
"=",
"function",
"(",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"aControls",
".",
"length",
")",
"{",
"var",
"sControlName",
"=",
"aControls",
"[",
"i",
"]",
";",
"handleControl",
"(",
"sControlName",
",",
"aControlsToTest",
",",
"aExcludedControls",
",",
"bIncludeNonRenderable",
",",
"bIncludeNonInstantiable",
",",
"fnCallback",
")",
".",
"then",
"(",
"function",
"(",
"bCountThisControl",
")",
"{",
"if",
"(",
"bCountThisControl",
")",
"{",
"iControlCountInLib",
"++",
";",
"}",
"loop",
"(",
"i",
"+",
"1",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"iControlCountInLib",
")",
";",
"}",
"}",
";",
"loop",
"(",
"0",
")",
";",
"}",
")",
";",
"}"
] | Calls the callback function for all controls in the given array, unless they are explicitly excluded | [
"Calls",
"the",
"callback",
"function",
"for",
"all",
"controls",
"in",
"the",
"given",
"array",
"unless",
"they",
"are",
"explicitly",
"excluded"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L380-L401 |
|
4,727 | SAP/openui5 | src/sap.ui.integration/src/sap/ui/integration/host/HostConfigurationCompiler.js | loadResource | function loadResource(sUrl, sType) {
return new Promise(function (resolve, reject) {
jQuery.ajax({
url: sUrl,
async: true,
dataType: sType,
success: function (oJson) {
resolve(oJson);
},
error: function () {
reject();
}
});
});
} | javascript | function loadResource(sUrl, sType) {
return new Promise(function (resolve, reject) {
jQuery.ajax({
url: sUrl,
async: true,
dataType: sType,
success: function (oJson) {
resolve(oJson);
},
error: function () {
reject();
}
});
});
} | [
"function",
"loadResource",
"(",
"sUrl",
",",
"sType",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"jQuery",
".",
"ajax",
"(",
"{",
"url",
":",
"sUrl",
",",
"async",
":",
"true",
",",
"dataType",
":",
"sType",
",",
"success",
":",
"function",
"(",
"oJson",
")",
"{",
"resolve",
"(",
"oJson",
")",
";",
"}",
",",
"error",
":",
"function",
"(",
")",
"{",
"reject",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | Loads a resource of a given type async and returns a promise
@param {string} sUrl the URL to load
@param {string} sType the expected type of response "json" or "text"
@retunrs {Promise}
@private | [
"Loads",
"a",
"resource",
"of",
"a",
"given",
"type",
"async",
"and",
"returns",
"a",
"promise"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.integration/src/sap/ui/integration/host/HostConfigurationCompiler.js#L29-L43 |
4,728 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataConverter.js | MetadataConverter | function MetadataConverter() {
this.aliases = {}; // maps alias -> namespace
this.oAnnotatable = null; // the current annotatable, see function annotatable
this.entityContainer = null; // the current EntityContainer
this.entitySet = null; // the current EntitySet/Singleton
this.namespace = null; // the namespace of the current Schema
this.oOperation = null; // the current operation (action or function)
this.reference = null; // the current Reference
this.schema = null; // the current Schema
this.type = null; // the current EntityType/ComplexType
this.result = null; // the result of the conversion
this.url = null; // the document URL (for error messages)
this.xmlns = null; // the expected XML namespace
} | javascript | function MetadataConverter() {
this.aliases = {}; // maps alias -> namespace
this.oAnnotatable = null; // the current annotatable, see function annotatable
this.entityContainer = null; // the current EntityContainer
this.entitySet = null; // the current EntitySet/Singleton
this.namespace = null; // the namespace of the current Schema
this.oOperation = null; // the current operation (action or function)
this.reference = null; // the current Reference
this.schema = null; // the current Schema
this.type = null; // the current EntityType/ComplexType
this.result = null; // the result of the conversion
this.url = null; // the document URL (for error messages)
this.xmlns = null; // the expected XML namespace
} | [
"function",
"MetadataConverter",
"(",
")",
"{",
"this",
".",
"aliases",
"=",
"{",
"}",
";",
"// maps alias -> namespace",
"this",
".",
"oAnnotatable",
"=",
"null",
";",
"// the current annotatable, see function annotatable",
"this",
".",
"entityContainer",
"=",
"null",
";",
"// the current EntityContainer",
"this",
".",
"entitySet",
"=",
"null",
";",
"// the current EntitySet/Singleton",
"this",
".",
"namespace",
"=",
"null",
";",
"// the namespace of the current Schema",
"this",
".",
"oOperation",
"=",
"null",
";",
"// the current operation (action or function)",
"this",
".",
"reference",
"=",
"null",
";",
"// the current Reference",
"this",
".",
"schema",
"=",
"null",
";",
"// the current Schema",
"this",
".",
"type",
"=",
"null",
";",
"// the current EntityType/ComplexType",
"this",
".",
"result",
"=",
"null",
";",
"// the result of the conversion",
"this",
".",
"url",
"=",
"null",
";",
"// the document URL (for error messages)",
"this",
".",
"xmlns",
"=",
"null",
";",
"// the expected XML namespace",
"}"
] | Creates the base class for the metadata converters.
@constructor | [
"Creates",
"the",
"base",
"class",
"for",
"the",
"metadata",
"converters",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataConverter.js#L17-L30 |
4,729 | SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/Measurement.js | Measurement | function Measurement(sId, sInfo, iStart, iEnd, aCategories) {
this.id = sId;
this.info = sInfo;
this.start = iStart;
this.end = iEnd;
this.pause = 0;
this.resume = 0;
this.duration = 0; // used time
this.time = 0; // time from start to end
this.categories = aCategories;
this.average = false; //average duration enabled
this.count = 0; //average count
this.completeDuration = 0; //complete duration
} | javascript | function Measurement(sId, sInfo, iStart, iEnd, aCategories) {
this.id = sId;
this.info = sInfo;
this.start = iStart;
this.end = iEnd;
this.pause = 0;
this.resume = 0;
this.duration = 0; // used time
this.time = 0; // time from start to end
this.categories = aCategories;
this.average = false; //average duration enabled
this.count = 0; //average count
this.completeDuration = 0; //complete duration
} | [
"function",
"Measurement",
"(",
"sId",
",",
"sInfo",
",",
"iStart",
",",
"iEnd",
",",
"aCategories",
")",
"{",
"this",
".",
"id",
"=",
"sId",
";",
"this",
".",
"info",
"=",
"sInfo",
";",
"this",
".",
"start",
"=",
"iStart",
";",
"this",
".",
"end",
"=",
"iEnd",
";",
"this",
".",
"pause",
"=",
"0",
";",
"this",
".",
"resume",
"=",
"0",
";",
"this",
".",
"duration",
"=",
"0",
";",
"// used time",
"this",
".",
"time",
"=",
"0",
";",
"// time from start to end",
"this",
".",
"categories",
"=",
"aCategories",
";",
"this",
".",
"average",
"=",
"false",
";",
"//average duration enabled",
"this",
".",
"count",
"=",
"0",
";",
"//average count",
"this",
".",
"completeDuration",
"=",
"0",
";",
"//complete duration",
"}"
] | Single Measurement Entry
@public
@typedef {object} module:sap/ui/performance/Measurement.Entry
@property {string} sId ID of the measurement
@property {string} sInfo Info for the measurement
@property {int} iStart Start time
@property {int} iEnd End time
@property {string | string[]} [aCategories="javascript"] An optional list of categories for the measure | [
"Single",
"Measurement",
"Entry"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/Measurement.js#L37-L50 |
4,730 | SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js | function (sTopicId, oModel) {
var oTree = this.byId("tree"),
oData = oModel.getData();
// Find the path to the new node, traversing the model
var aTopicIds = this._oTreeUtil.getPathToNode(sTopicId, oData);
// Expand all nodes on the path to the target node
var oLastItem;
aTopicIds.forEach(function(sId) {
var oItem = this._findTreeItem(sId);
if (oItem) {
oTree.getBinding("items").expand(oTree.indexOfItem(oItem));
oLastItem = oItem;
}
}, this);
// Select the target node and scroll to it
if (oLastItem) {
oLastItem.setSelected(true);
this.oSelectedItem = {
sTopicId: sTopicId,
oModel: oModel
};
// Only scroll after the dom is ready
setTimeout(function () {
if (oLastItem.getDomRef() && !isInViewport(oLastItem.getDomRef())) {
this._scrollTreeItemIntoView(oLastItem);
}
}.bind(this), 0);
}
} | javascript | function (sTopicId, oModel) {
var oTree = this.byId("tree"),
oData = oModel.getData();
// Find the path to the new node, traversing the model
var aTopicIds = this._oTreeUtil.getPathToNode(sTopicId, oData);
// Expand all nodes on the path to the target node
var oLastItem;
aTopicIds.forEach(function(sId) {
var oItem = this._findTreeItem(sId);
if (oItem) {
oTree.getBinding("items").expand(oTree.indexOfItem(oItem));
oLastItem = oItem;
}
}, this);
// Select the target node and scroll to it
if (oLastItem) {
oLastItem.setSelected(true);
this.oSelectedItem = {
sTopicId: sTopicId,
oModel: oModel
};
// Only scroll after the dom is ready
setTimeout(function () {
if (oLastItem.getDomRef() && !isInViewport(oLastItem.getDomRef())) {
this._scrollTreeItemIntoView(oLastItem);
}
}.bind(this), 0);
}
} | [
"function",
"(",
"sTopicId",
",",
"oModel",
")",
"{",
"var",
"oTree",
"=",
"this",
".",
"byId",
"(",
"\"tree\"",
")",
",",
"oData",
"=",
"oModel",
".",
"getData",
"(",
")",
";",
"// Find the path to the new node, traversing the model",
"var",
"aTopicIds",
"=",
"this",
".",
"_oTreeUtil",
".",
"getPathToNode",
"(",
"sTopicId",
",",
"oData",
")",
";",
"// Expand all nodes on the path to the target node",
"var",
"oLastItem",
";",
"aTopicIds",
".",
"forEach",
"(",
"function",
"(",
"sId",
")",
"{",
"var",
"oItem",
"=",
"this",
".",
"_findTreeItem",
"(",
"sId",
")",
";",
"if",
"(",
"oItem",
")",
"{",
"oTree",
".",
"getBinding",
"(",
"\"items\"",
")",
".",
"expand",
"(",
"oTree",
".",
"indexOfItem",
"(",
"oItem",
")",
")",
";",
"oLastItem",
"=",
"oItem",
";",
"}",
"}",
",",
"this",
")",
";",
"// Select the target node and scroll to it",
"if",
"(",
"oLastItem",
")",
"{",
"oLastItem",
".",
"setSelected",
"(",
"true",
")",
";",
"this",
".",
"oSelectedItem",
"=",
"{",
"sTopicId",
":",
"sTopicId",
",",
"oModel",
":",
"oModel",
"}",
";",
"// Only scroll after the dom is ready",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"oLastItem",
".",
"getDomRef",
"(",
")",
"&&",
"!",
"isInViewport",
"(",
"oLastItem",
".",
"getDomRef",
"(",
")",
")",
")",
"{",
"this",
".",
"_scrollTreeItemIntoView",
"(",
"oLastItem",
")",
";",
"}",
"}",
".",
"bind",
"(",
"this",
")",
",",
"0",
")",
";",
"}",
"}"
] | Makes the tree open all nodes up to the node with "sTopicId" and then selects it
@private | [
"Makes",
"the",
"tree",
"open",
"all",
"nodes",
"up",
"to",
"the",
"node",
"with",
"sTopicId",
"and",
"then",
"selects",
"it"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js#L35-L66 |
|
4,731 | SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js | function (oEvent) {
// Update filter value
this._sFilter = oEvent.getParameter("newValue").trim();
if (this._filterTimeout) {
clearTimeout(this._filterTimeout);
}
this._filterTimeout = setTimeout(function () {
if (this.buildAndApplyFilters()) {
this._expandAllNodes();
} else {
this._collapseAllNodes();
if (this.oSelectedItem) {
this._expandTreeToNode(this.oSelectedItem.sTopicId, this.oSelectedItem.oModel);
}
}
this._filterTimeout = null;
}.bind(this), 250);
} | javascript | function (oEvent) {
// Update filter value
this._sFilter = oEvent.getParameter("newValue").trim();
if (this._filterTimeout) {
clearTimeout(this._filterTimeout);
}
this._filterTimeout = setTimeout(function () {
if (this.buildAndApplyFilters()) {
this._expandAllNodes();
} else {
this._collapseAllNodes();
if (this.oSelectedItem) {
this._expandTreeToNode(this.oSelectedItem.sTopicId, this.oSelectedItem.oModel);
}
}
this._filterTimeout = null;
}.bind(this), 250);
} | [
"function",
"(",
"oEvent",
")",
"{",
"// Update filter value",
"this",
".",
"_sFilter",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"newValue\"",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"this",
".",
"_filterTimeout",
")",
"{",
"clearTimeout",
"(",
"this",
".",
"_filterTimeout",
")",
";",
"}",
"this",
".",
"_filterTimeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"buildAndApplyFilters",
"(",
")",
")",
"{",
"this",
".",
"_expandAllNodes",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"_collapseAllNodes",
"(",
")",
";",
"if",
"(",
"this",
".",
"oSelectedItem",
")",
"{",
"this",
".",
"_expandTreeToNode",
"(",
"this",
".",
"oSelectedItem",
".",
"sTopicId",
",",
"this",
".",
"oSelectedItem",
".",
"oModel",
")",
";",
"}",
"}",
"this",
".",
"_filterTimeout",
"=",
"null",
";",
"}",
".",
"bind",
"(",
"this",
")",
",",
"250",
")",
";",
"}"
] | Handler for the SearchField
@param oEvent | [
"Handler",
"for",
"the",
"SearchField"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js#L95-L117 |
|
4,732 | SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js | function () {
var oBinding = this.byId("tree").getBinding("items");
if (this._sFilter) {
oBinding.filter(new Filter({
path: "name",
operator: FilterOperator.Contains,
value1: this._sFilter
}));
return true;
} else {
oBinding.filter();
return false;
}
} | javascript | function () {
var oBinding = this.byId("tree").getBinding("items");
if (this._sFilter) {
oBinding.filter(new Filter({
path: "name",
operator: FilterOperator.Contains,
value1: this._sFilter
}));
return true;
} else {
oBinding.filter();
return false;
}
} | [
"function",
"(",
")",
"{",
"var",
"oBinding",
"=",
"this",
".",
"byId",
"(",
"\"tree\"",
")",
".",
"getBinding",
"(",
"\"items\"",
")",
";",
"if",
"(",
"this",
".",
"_sFilter",
")",
"{",
"oBinding",
".",
"filter",
"(",
"new",
"Filter",
"(",
"{",
"path",
":",
"\"name\"",
",",
"operator",
":",
"FilterOperator",
".",
"Contains",
",",
"value1",
":",
"this",
".",
"_sFilter",
"}",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"oBinding",
".",
"filter",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Build and apply filters to the tree model.
@returns {boolean} if search filter is applied | [
"Build",
"and",
"apply",
"filters",
"to",
"the",
"tree",
"model",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js#L123-L136 |
|
4,733 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (oPathValue, sMessage, sComponent) {
sMessage = oPathValue.path + ": " + sMessage;
Log.error(sMessage, Basics.toErrorString(oPathValue.value),
sComponent || sAnnotationHelper);
throw new SyntaxError(sMessage);
} | javascript | function (oPathValue, sMessage, sComponent) {
sMessage = oPathValue.path + ": " + sMessage;
Log.error(sMessage, Basics.toErrorString(oPathValue.value),
sComponent || sAnnotationHelper);
throw new SyntaxError(sMessage);
} | [
"function",
"(",
"oPathValue",
",",
"sMessage",
",",
"sComponent",
")",
"{",
"sMessage",
"=",
"oPathValue",
".",
"path",
"+",
"\": \"",
"+",
"sMessage",
";",
"Log",
".",
"error",
"(",
"sMessage",
",",
"Basics",
".",
"toErrorString",
"(",
"oPathValue",
".",
"value",
")",
",",
"sComponent",
"||",
"sAnnotationHelper",
")",
";",
"throw",
"new",
"SyntaxError",
"(",
"sMessage",
")",
";",
"}"
] | Logs the error message for the given path and throws a SyntaxError.
@param {object} oPathValue
a path/value pair
@param {string} sMessage
the message to log
@param {string} [sComponent="sap.ui.model.odata.AnnotationHelper"]
Name of the component that produced the log entry | [
"Logs",
"the",
"error",
"message",
"for",
"the",
"given",
"path",
"and",
"throws",
"a",
"SyntaxError",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L91-L96 |
|
4,734 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (oPathValue, sExpectedType) {
var bError,
vValue = oPathValue.value;
if (sExpectedType === "array") {
bError = !Array.isArray(vValue);
} else {
bError = typeof vValue !== sExpectedType
|| vValue === null
|| Array.isArray(vValue);
}
if (bError) {
Basics.error(oPathValue, "Expected " + sExpectedType);
}
} | javascript | function (oPathValue, sExpectedType) {
var bError,
vValue = oPathValue.value;
if (sExpectedType === "array") {
bError = !Array.isArray(vValue);
} else {
bError = typeof vValue !== sExpectedType
|| vValue === null
|| Array.isArray(vValue);
}
if (bError) {
Basics.error(oPathValue, "Expected " + sExpectedType);
}
} | [
"function",
"(",
"oPathValue",
",",
"sExpectedType",
")",
"{",
"var",
"bError",
",",
"vValue",
"=",
"oPathValue",
".",
"value",
";",
"if",
"(",
"sExpectedType",
"===",
"\"array\"",
")",
"{",
"bError",
"=",
"!",
"Array",
".",
"isArray",
"(",
"vValue",
")",
";",
"}",
"else",
"{",
"bError",
"=",
"typeof",
"vValue",
"!==",
"sExpectedType",
"||",
"vValue",
"===",
"null",
"||",
"Array",
".",
"isArray",
"(",
"vValue",
")",
";",
"}",
"if",
"(",
"bError",
")",
"{",
"Basics",
".",
"error",
"(",
"oPathValue",
",",
"\"Expected \"",
"+",
"sExpectedType",
")",
";",
"}",
"}"
] | Logs an error and throws an error if the value is not of the expected type.
@param {object} oPathValue
a path/value pair
@param {string} oPathValue.path
the meta model path to start at
@param {any} oPathValue.value
the value at this path
@param {string} sExpectedType
the expected type (tested w/ typeof) or the special value "array" for an array
@throws {SyntaxError}
if the result is not of the expected type | [
"Logs",
"an",
"error",
"and",
"throws",
"an",
"error",
"if",
"the",
"value",
"is",
"not",
"of",
"the",
"expected",
"type",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L112-L126 |
|
4,735 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (oResult, bExpression, bWithType) {
var vValue = oResult.value;
function binding(bAddType) {
var sConstraints, sResult;
bAddType = bAddType && !oResult.ignoreTypeInPath && oResult.type;
if (bAddType || rBadChars.test(vValue)) {
sResult = "{path:" + Basics.toJSON(vValue);
if (bAddType) {
sResult += ",type:'" + mUi5TypeForEdmType[oResult.type] + "'";
sConstraints = Basics.toJSON(oResult.constraints);
if (sConstraints && sConstraints !== "{}") {
sResult += ",constraints:" + sConstraints;
}
}
return sResult + "}";
}
return "{" + vValue + "}";
}
function constant(oResult) {
switch (oResult.type) {
case "Edm.Boolean":
case "Edm.Double":
case "Edm.Int32":
return String(oResult.value);
default:
return Basics.toJSON(oResult.value);
}
}
switch (oResult.result) {
case "binding":
return (bExpression ? "$" : "") + binding(bWithType);
case "composite":
if (bExpression) {
throw new Error(
"Trying to embed a composite binding into an expression binding");
}
return vValue; // Note: it's already a composite binding string
case "constant":
if (oResult.type === "edm:Null") {
return bExpression ? "null" : null;
}
if (bExpression) {
return constant(oResult);
}
return typeof vValue === "string"
? BindingParser.complexParser.escape(vValue)
: String(vValue);
case "expression":
return bExpression ? vValue : "{=" + vValue + "}";
// no default
}
} | javascript | function (oResult, bExpression, bWithType) {
var vValue = oResult.value;
function binding(bAddType) {
var sConstraints, sResult;
bAddType = bAddType && !oResult.ignoreTypeInPath && oResult.type;
if (bAddType || rBadChars.test(vValue)) {
sResult = "{path:" + Basics.toJSON(vValue);
if (bAddType) {
sResult += ",type:'" + mUi5TypeForEdmType[oResult.type] + "'";
sConstraints = Basics.toJSON(oResult.constraints);
if (sConstraints && sConstraints !== "{}") {
sResult += ",constraints:" + sConstraints;
}
}
return sResult + "}";
}
return "{" + vValue + "}";
}
function constant(oResult) {
switch (oResult.type) {
case "Edm.Boolean":
case "Edm.Double":
case "Edm.Int32":
return String(oResult.value);
default:
return Basics.toJSON(oResult.value);
}
}
switch (oResult.result) {
case "binding":
return (bExpression ? "$" : "") + binding(bWithType);
case "composite":
if (bExpression) {
throw new Error(
"Trying to embed a composite binding into an expression binding");
}
return vValue; // Note: it's already a composite binding string
case "constant":
if (oResult.type === "edm:Null") {
return bExpression ? "null" : null;
}
if (bExpression) {
return constant(oResult);
}
return typeof vValue === "string"
? BindingParser.complexParser.escape(vValue)
: String(vValue);
case "expression":
return bExpression ? vValue : "{=" + vValue + "}";
// no default
}
} | [
"function",
"(",
"oResult",
",",
"bExpression",
",",
"bWithType",
")",
"{",
"var",
"vValue",
"=",
"oResult",
".",
"value",
";",
"function",
"binding",
"(",
"bAddType",
")",
"{",
"var",
"sConstraints",
",",
"sResult",
";",
"bAddType",
"=",
"bAddType",
"&&",
"!",
"oResult",
".",
"ignoreTypeInPath",
"&&",
"oResult",
".",
"type",
";",
"if",
"(",
"bAddType",
"||",
"rBadChars",
".",
"test",
"(",
"vValue",
")",
")",
"{",
"sResult",
"=",
"\"{path:\"",
"+",
"Basics",
".",
"toJSON",
"(",
"vValue",
")",
";",
"if",
"(",
"bAddType",
")",
"{",
"sResult",
"+=",
"\",type:'\"",
"+",
"mUi5TypeForEdmType",
"[",
"oResult",
".",
"type",
"]",
"+",
"\"'\"",
";",
"sConstraints",
"=",
"Basics",
".",
"toJSON",
"(",
"oResult",
".",
"constraints",
")",
";",
"if",
"(",
"sConstraints",
"&&",
"sConstraints",
"!==",
"\"{}\"",
")",
"{",
"sResult",
"+=",
"\",constraints:\"",
"+",
"sConstraints",
";",
"}",
"}",
"return",
"sResult",
"+",
"\"}\"",
";",
"}",
"return",
"\"{\"",
"+",
"vValue",
"+",
"\"}\"",
";",
"}",
"function",
"constant",
"(",
"oResult",
")",
"{",
"switch",
"(",
"oResult",
".",
"type",
")",
"{",
"case",
"\"Edm.Boolean\"",
":",
"case",
"\"Edm.Double\"",
":",
"case",
"\"Edm.Int32\"",
":",
"return",
"String",
"(",
"oResult",
".",
"value",
")",
";",
"default",
":",
"return",
"Basics",
".",
"toJSON",
"(",
"oResult",
".",
"value",
")",
";",
"}",
"}",
"switch",
"(",
"oResult",
".",
"result",
")",
"{",
"case",
"\"binding\"",
":",
"return",
"(",
"bExpression",
"?",
"\"$\"",
":",
"\"\"",
")",
"+",
"binding",
"(",
"bWithType",
")",
";",
"case",
"\"composite\"",
":",
"if",
"(",
"bExpression",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Trying to embed a composite binding into an expression binding\"",
")",
";",
"}",
"return",
"vValue",
";",
"// Note: it's already a composite binding string",
"case",
"\"constant\"",
":",
"if",
"(",
"oResult",
".",
"type",
"===",
"\"edm:Null\"",
")",
"{",
"return",
"bExpression",
"?",
"\"null\"",
":",
"null",
";",
"}",
"if",
"(",
"bExpression",
")",
"{",
"return",
"constant",
"(",
"oResult",
")",
";",
"}",
"return",
"typeof",
"vValue",
"===",
"\"string\"",
"?",
"BindingParser",
".",
"complexParser",
".",
"escape",
"(",
"vValue",
")",
":",
"String",
"(",
"vValue",
")",
";",
"case",
"\"expression\"",
":",
"return",
"bExpression",
"?",
"vValue",
":",
"\"{=\"",
"+",
"vValue",
"+",
"\"}\"",
";",
"// no default",
"}",
"}"
] | Converts the result's value to a string.
@param {object} oResult
an object with the following properties:
result: "constant", "binding", "composite" or "expression"
value: {any} the value to write into the resulting string depending on result:
when "constant": the constant value as a string (from the annotation)
when "binding": the binding path
when "expression": a binding expression not wrapped (no "{=" and "}")
when "composite": a composite binding string
type: an EDM data type (like "Edm.String")
constraints: {object} optional type constraints when result is "binding"
@param {boolean} bExpression
if true the value is to be embedded into a binding expression, otherwise in a
composite binding
@param {boolean} [bWithType=false]
if <code>true</code> and <code>oResult.result</code> is "binding", type and constraint
information is written to the resulting binding string
@returns {string}
the resulting string to embed into a composite binding or a binding expression | [
"Converts",
"the",
"result",
"s",
"value",
"to",
"a",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L333-L392 |
|
4,736 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (vValue) {
var sJSON;
if (typeof vValue !== "function") {
try {
sJSON = Basics.toJSON(vValue);
// undefined --> undefined
// null, NaN, Infinity --> "null"
// all are correctly handled by String
if (sJSON !== undefined && sJSON !== "null") {
return sJSON;
}
} catch (e) {
// "converting circular structure to JSON"
}
}
return String(vValue);
} | javascript | function (vValue) {
var sJSON;
if (typeof vValue !== "function") {
try {
sJSON = Basics.toJSON(vValue);
// undefined --> undefined
// null, NaN, Infinity --> "null"
// all are correctly handled by String
if (sJSON !== undefined && sJSON !== "null") {
return sJSON;
}
} catch (e) {
// "converting circular structure to JSON"
}
}
return String(vValue);
} | [
"function",
"(",
"vValue",
")",
"{",
"var",
"sJSON",
";",
"if",
"(",
"typeof",
"vValue",
"!==",
"\"function\"",
")",
"{",
"try",
"{",
"sJSON",
"=",
"Basics",
".",
"toJSON",
"(",
"vValue",
")",
";",
"// undefined --> undefined",
"// null, NaN, Infinity --> \"null\"",
"// all are correctly handled by String",
"if",
"(",
"sJSON",
"!==",
"undefined",
"&&",
"sJSON",
"!==",
"\"null\"",
")",
"{",
"return",
"sJSON",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"// \"converting circular structure to JSON\"",
"}",
"}",
"return",
"String",
"(",
"vValue",
")",
";",
"}"
] | Stringifies the value for usage in an error message. Special handling for functions and
object trees with circular references.
@param {any} vValue the value
@returns {string} the stringified value | [
"Stringifies",
"the",
"value",
"for",
"usage",
"in",
"an",
"error",
"message",
".",
"Special",
"handling",
"for",
"functions",
"and",
"object",
"trees",
"with",
"circular",
"references",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L401-L418 |
|
4,737 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (vValue) {
var sStringified,
bEscaped = false,
sResult = "",
i, c;
sStringified = JSON.stringify(vValue);
if (sStringified === undefined) {
return undefined;
}
for (i = 0; i < sStringified.length; i += 1) {
switch (c = sStringified.charAt(i)) {
case "'": // a single quote must be escaped (can only occur in a string)
sResult += "\\'";
break;
case '"':
if (bEscaped) { // a double quote needs no escaping (only in a string)
sResult += c;
bEscaped = false;
} else { // string begin or end with single quotes
sResult += "'";
}
break;
case "\\":
if (bEscaped) { // an escaped backslash
sResult += "\\\\";
}
bEscaped = !bEscaped;
break;
default:
if (bEscaped) {
sResult += "\\";
bEscaped = false;
}
sResult += c;
}
}
return sResult;
} | javascript | function (vValue) {
var sStringified,
bEscaped = false,
sResult = "",
i, c;
sStringified = JSON.stringify(vValue);
if (sStringified === undefined) {
return undefined;
}
for (i = 0; i < sStringified.length; i += 1) {
switch (c = sStringified.charAt(i)) {
case "'": // a single quote must be escaped (can only occur in a string)
sResult += "\\'";
break;
case '"':
if (bEscaped) { // a double quote needs no escaping (only in a string)
sResult += c;
bEscaped = false;
} else { // string begin or end with single quotes
sResult += "'";
}
break;
case "\\":
if (bEscaped) { // an escaped backslash
sResult += "\\\\";
}
bEscaped = !bEscaped;
break;
default:
if (bEscaped) {
sResult += "\\";
bEscaped = false;
}
sResult += c;
}
}
return sResult;
} | [
"function",
"(",
"vValue",
")",
"{",
"var",
"sStringified",
",",
"bEscaped",
"=",
"false",
",",
"sResult",
"=",
"\"\"",
",",
"i",
",",
"c",
";",
"sStringified",
"=",
"JSON",
".",
"stringify",
"(",
"vValue",
")",
";",
"if",
"(",
"sStringified",
"===",
"undefined",
")",
"{",
"return",
"undefined",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"sStringified",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"switch",
"(",
"c",
"=",
"sStringified",
".",
"charAt",
"(",
"i",
")",
")",
"{",
"case",
"\"'\"",
":",
"// a single quote must be escaped (can only occur in a string)",
"sResult",
"+=",
"\"\\\\'\"",
";",
"break",
";",
"case",
"'\"'",
":",
"if",
"(",
"bEscaped",
")",
"{",
"// a double quote needs no escaping (only in a string)",
"sResult",
"+=",
"c",
";",
"bEscaped",
"=",
"false",
";",
"}",
"else",
"{",
"// string begin or end with single quotes",
"sResult",
"+=",
"\"'\"",
";",
"}",
"break",
";",
"case",
"\"\\\\\"",
":",
"if",
"(",
"bEscaped",
")",
"{",
"// an escaped backslash",
"sResult",
"+=",
"\"\\\\\\\\\"",
";",
"}",
"bEscaped",
"=",
"!",
"bEscaped",
";",
"break",
";",
"default",
":",
"if",
"(",
"bEscaped",
")",
"{",
"sResult",
"+=",
"\"\\\\\"",
";",
"bEscaped",
"=",
"false",
";",
"}",
"sResult",
"+=",
"c",
";",
"}",
"}",
"return",
"sResult",
";",
"}"
] | Converts the value to a JSON string. Prefers the single quote over the double quote.
This suits better for usage in an XML attribute.
@param {any} vValue the value
@returns {string} the stringified value | [
"Converts",
"the",
"value",
"to",
"a",
"JSON",
"string",
".",
"Prefers",
"the",
"single",
"quote",
"over",
"the",
"double",
"quote",
".",
"This",
"suits",
"better",
"for",
"usage",
"in",
"an",
"XML",
"attribute",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L427-L465 |
|
4,738 | SAP/openui5 | src/sap.m/src/sap/m/DateRangeSelection.js | _trim | function _trim(sValue, aParams) {
var i = 0,
aTrims = aParams;
if (!aTrims) {
aTrims = [" "];
}
while (i < aTrims.length) {
if (_endsWith(sValue, aTrims[i])) {
sValue = sValue.substring(0, sValue.length - aTrims[i].length);
i = 0;
continue;
}
i++;
}
i = 0;
while (i < aTrims.length) {
if (_startsWith(sValue, aTrims[i])) {
sValue = sValue.substring(aTrims[i].length);
i = 0;
continue;
}
i++;
}
return sValue;
} | javascript | function _trim(sValue, aParams) {
var i = 0,
aTrims = aParams;
if (!aTrims) {
aTrims = [" "];
}
while (i < aTrims.length) {
if (_endsWith(sValue, aTrims[i])) {
sValue = sValue.substring(0, sValue.length - aTrims[i].length);
i = 0;
continue;
}
i++;
}
i = 0;
while (i < aTrims.length) {
if (_startsWith(sValue, aTrims[i])) {
sValue = sValue.substring(aTrims[i].length);
i = 0;
continue;
}
i++;
}
return sValue;
} | [
"function",
"_trim",
"(",
"sValue",
",",
"aParams",
")",
"{",
"var",
"i",
"=",
"0",
",",
"aTrims",
"=",
"aParams",
";",
"if",
"(",
"!",
"aTrims",
")",
"{",
"aTrims",
"=",
"[",
"\" \"",
"]",
";",
"}",
"while",
"(",
"i",
"<",
"aTrims",
".",
"length",
")",
"{",
"if",
"(",
"_endsWith",
"(",
"sValue",
",",
"aTrims",
"[",
"i",
"]",
")",
")",
"{",
"sValue",
"=",
"sValue",
".",
"substring",
"(",
"0",
",",
"sValue",
".",
"length",
"-",
"aTrims",
"[",
"i",
"]",
".",
"length",
")",
";",
"i",
"=",
"0",
";",
"continue",
";",
"}",
"i",
"++",
";",
"}",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"aTrims",
".",
"length",
")",
"{",
"if",
"(",
"_startsWith",
"(",
"sValue",
",",
"aTrims",
"[",
"i",
"]",
")",
")",
"{",
"sValue",
"=",
"sValue",
".",
"substring",
"(",
"aTrims",
"[",
"i",
"]",
".",
"length",
")",
";",
"i",
"=",
"0",
";",
"continue",
";",
"}",
"i",
"++",
";",
"}",
"return",
"sValue",
";",
"}"
] | Trims all occurrences of the given string values from both ends of the specified string.
@param {string} sValue The value to be trimmed
@param {string[]} aParams All values to be removed
@returns {string} The trimmed value
@private | [
"Trims",
"all",
"occurrences",
"of",
"the",
"given",
"string",
"values",
"from",
"both",
"ends",
"of",
"the",
"specified",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/DateRangeSelection.js#L1148-L1176 |
4,739 | SAP/openui5 | src/sap.ui.core/src/sap/base/util/includes.js | function (vCollection, vValue, iFromIndex) {
if (typeof iFromIndex !== 'number') {
iFromIndex = 0;
}
// Use native (Array.prototype.includes, String.prototype.includes) includes functions if available
if (Array.isArray(vCollection)) {
if (typeof vCollection.includes === 'function') {
return vCollection.includes(vValue, iFromIndex);
}
iFromIndex = iFromIndex < 0 ? iFromIndex + vCollection.length : iFromIndex;
iFromIndex = iFromIndex < 0 ? 0 : iFromIndex;
for (var i = iFromIndex; i < vCollection.length; i++) {
if (equals(vCollection[i], vValue)) {
return true;
}
}
return false;
} else if (typeof vCollection === 'string') {
iFromIndex = iFromIndex < 0 ? vCollection.length + iFromIndex : iFromIndex;
if (typeof vCollection.includes === 'function') {
return vCollection.includes(vValue, iFromIndex);
}
return vCollection.indexOf(vValue, iFromIndex) !== -1;
} else {
// values(...) always returns an array therefore deep recursion is avoided
return fnIncludes(values(vCollection), vValue, iFromIndex);
}
} | javascript | function (vCollection, vValue, iFromIndex) {
if (typeof iFromIndex !== 'number') {
iFromIndex = 0;
}
// Use native (Array.prototype.includes, String.prototype.includes) includes functions if available
if (Array.isArray(vCollection)) {
if (typeof vCollection.includes === 'function') {
return vCollection.includes(vValue, iFromIndex);
}
iFromIndex = iFromIndex < 0 ? iFromIndex + vCollection.length : iFromIndex;
iFromIndex = iFromIndex < 0 ? 0 : iFromIndex;
for (var i = iFromIndex; i < vCollection.length; i++) {
if (equals(vCollection[i], vValue)) {
return true;
}
}
return false;
} else if (typeof vCollection === 'string') {
iFromIndex = iFromIndex < 0 ? vCollection.length + iFromIndex : iFromIndex;
if (typeof vCollection.includes === 'function') {
return vCollection.includes(vValue, iFromIndex);
}
return vCollection.indexOf(vValue, iFromIndex) !== -1;
} else {
// values(...) always returns an array therefore deep recursion is avoided
return fnIncludes(values(vCollection), vValue, iFromIndex);
}
} | [
"function",
"(",
"vCollection",
",",
"vValue",
",",
"iFromIndex",
")",
"{",
"if",
"(",
"typeof",
"iFromIndex",
"!==",
"'number'",
")",
"{",
"iFromIndex",
"=",
"0",
";",
"}",
"// Use native (Array.prototype.includes, String.prototype.includes) includes functions if available",
"if",
"(",
"Array",
".",
"isArray",
"(",
"vCollection",
")",
")",
"{",
"if",
"(",
"typeof",
"vCollection",
".",
"includes",
"===",
"'function'",
")",
"{",
"return",
"vCollection",
".",
"includes",
"(",
"vValue",
",",
"iFromIndex",
")",
";",
"}",
"iFromIndex",
"=",
"iFromIndex",
"<",
"0",
"?",
"iFromIndex",
"+",
"vCollection",
".",
"length",
":",
"iFromIndex",
";",
"iFromIndex",
"=",
"iFromIndex",
"<",
"0",
"?",
"0",
":",
"iFromIndex",
";",
"for",
"(",
"var",
"i",
"=",
"iFromIndex",
";",
"i",
"<",
"vCollection",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"equals",
"(",
"vCollection",
"[",
"i",
"]",
",",
"vValue",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"typeof",
"vCollection",
"===",
"'string'",
")",
"{",
"iFromIndex",
"=",
"iFromIndex",
"<",
"0",
"?",
"vCollection",
".",
"length",
"+",
"iFromIndex",
":",
"iFromIndex",
";",
"if",
"(",
"typeof",
"vCollection",
".",
"includes",
"===",
"'function'",
")",
"{",
"return",
"vCollection",
".",
"includes",
"(",
"vValue",
",",
"iFromIndex",
")",
";",
"}",
"return",
"vCollection",
".",
"indexOf",
"(",
"vValue",
",",
"iFromIndex",
")",
"!==",
"-",
"1",
";",
"}",
"else",
"{",
"// values(...) always returns an array therefore deep recursion is avoided",
"return",
"fnIncludes",
"(",
"values",
"(",
"vCollection",
")",
",",
"vValue",
",",
"iFromIndex",
")",
";",
"}",
"}"
] | Checks if value is included in collection
@example
sap.ui.require(["sap/base/util/includes"], function(includes){
// arrays
includes(["1", "8", "7"], "8"); // true
includes(["1", "8", "7"], "8", 0); // true
includes(["1", "8", "7"], "8", 1); // true
includes(["1", "8", "7"], "8", 2); // false
includes(["1", "8", "7"], "8", 3); // false
includes(["1", "8", "7"], "8", -1); // false
includes(["1", "8", "7"], "8", -2); // true
includes(["1", "8", "7"], "8", -3); // true
// strings
includes("187", "8"); // true
includes("187", "8", 0); // true
includes("187", "8", 1); // true
includes("187", "8", 2); // false
includes("187", "8", 3); // false
includes("187", "8", -1); // false
includes("187", "8", -2); // true
includes("187", "8", -3); // true
});
@function
@since 1.58
@alias module:sap/base/util/includes
@param {Array|object|string} vCollection - Collection to be checked
@param {*} vValue - The value to be checked
@param {int} [iFromIndex=0] - optional start index, negative start index will start from the end
@returns {boolean} - true if value is in the collection, false otherwise
@public | [
"Checks",
"if",
"value",
"is",
"included",
"in",
"collection"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/util/includes.js#L65-L95 |
|
4,740 | SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js | function (oEvent) {
var oSource = oEvent.getSource();
var sLayerBindingPath = oSource.getBindingContextPath().substring(1);
var oLayerModelData = this.getView().getModel("layers").getData();
var sLayerName = oLayerModelData[sLayerBindingPath].name;
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("LayerContentMaster", {"layer": sLayerName});
} | javascript | function (oEvent) {
var oSource = oEvent.getSource();
var sLayerBindingPath = oSource.getBindingContextPath().substring(1);
var oLayerModelData = this.getView().getModel("layers").getData();
var sLayerName = oLayerModelData[sLayerBindingPath].name;
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("LayerContentMaster", {"layer": sLayerName});
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oSource",
"=",
"oEvent",
".",
"getSource",
"(",
")",
";",
"var",
"sLayerBindingPath",
"=",
"oSource",
".",
"getBindingContextPath",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"var",
"oLayerModelData",
"=",
"this",
".",
"getView",
"(",
")",
".",
"getModel",
"(",
"\"layers\"",
")",
".",
"getData",
"(",
")",
";",
"var",
"sLayerName",
"=",
"oLayerModelData",
"[",
"sLayerBindingPath",
"]",
".",
"name",
";",
"var",
"oRouter",
"=",
"sap",
".",
"ui",
".",
"core",
".",
"UIComponent",
".",
"getRouterFor",
"(",
"this",
")",
";",
"oRouter",
".",
"navTo",
"(",
"\"LayerContentMaster\"",
",",
"{",
"\"layer\"",
":",
"sLayerName",
"}",
")",
";",
"}"
] | Handler for triggering the navigation to a selected layer.
@param {Object} oEvent
@public | [
"Handler",
"for",
"triggering",
"the",
"navigation",
"to",
"a",
"selected",
"layer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/Layers.controller.js#L26-L34 |
|
4,741 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LabelEnablement.js | refreshMapping | function refreshMapping(oLabel, bDestroy){
var sLabelId = oLabel.getId();
var sOldId = oLabel.__sLabeledControl;
var sNewId = bDestroy ? null : findLabelForControl(oLabel);
if (sOldId == sNewId) {
return;
}
//Invalidate the label itself (see setLabelFor, setAlternativeLabelFor)
if (!bDestroy) {
oLabel.invalidate();
}
//Update the label to control mapping (1-1 mapping)
if (sNewId) {
oLabel.__sLabeledControl = sNewId;
} else {
delete oLabel.__sLabeledControl;
}
//Update the control to label mapping (1-n mapping)
var aLabelsOfControl;
if (sOldId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sOldId];
if (aLabelsOfControl) {
aLabelsOfControl = aLabelsOfControl.filter(function(sCurrentLabelId) {
return sCurrentLabelId != sLabelId;
});
if (aLabelsOfControl.length) {
CONTROL_TO_LABELS_MAPPING[sOldId] = aLabelsOfControl;
} else {
delete CONTROL_TO_LABELS_MAPPING[sOldId];
}
}
}
if (sNewId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sNewId] || [];
aLabelsOfControl.push(sLabelId);
CONTROL_TO_LABELS_MAPPING[sNewId] = aLabelsOfControl;
}
//Invalidate related controls
var oOldControl = toControl(sOldId, true);
var oNewControl = toControl(sNewId, true);
if (oOldControl) {
oLabel.detachRequiredChange(oOldControl);
}
if (oNewControl) {
oLabel.attachRequiredChange(oNewControl);
}
} | javascript | function refreshMapping(oLabel, bDestroy){
var sLabelId = oLabel.getId();
var sOldId = oLabel.__sLabeledControl;
var sNewId = bDestroy ? null : findLabelForControl(oLabel);
if (sOldId == sNewId) {
return;
}
//Invalidate the label itself (see setLabelFor, setAlternativeLabelFor)
if (!bDestroy) {
oLabel.invalidate();
}
//Update the label to control mapping (1-1 mapping)
if (sNewId) {
oLabel.__sLabeledControl = sNewId;
} else {
delete oLabel.__sLabeledControl;
}
//Update the control to label mapping (1-n mapping)
var aLabelsOfControl;
if (sOldId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sOldId];
if (aLabelsOfControl) {
aLabelsOfControl = aLabelsOfControl.filter(function(sCurrentLabelId) {
return sCurrentLabelId != sLabelId;
});
if (aLabelsOfControl.length) {
CONTROL_TO_LABELS_MAPPING[sOldId] = aLabelsOfControl;
} else {
delete CONTROL_TO_LABELS_MAPPING[sOldId];
}
}
}
if (sNewId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sNewId] || [];
aLabelsOfControl.push(sLabelId);
CONTROL_TO_LABELS_MAPPING[sNewId] = aLabelsOfControl;
}
//Invalidate related controls
var oOldControl = toControl(sOldId, true);
var oNewControl = toControl(sNewId, true);
if (oOldControl) {
oLabel.detachRequiredChange(oOldControl);
}
if (oNewControl) {
oLabel.attachRequiredChange(oNewControl);
}
} | [
"function",
"refreshMapping",
"(",
"oLabel",
",",
"bDestroy",
")",
"{",
"var",
"sLabelId",
"=",
"oLabel",
".",
"getId",
"(",
")",
";",
"var",
"sOldId",
"=",
"oLabel",
".",
"__sLabeledControl",
";",
"var",
"sNewId",
"=",
"bDestroy",
"?",
"null",
":",
"findLabelForControl",
"(",
"oLabel",
")",
";",
"if",
"(",
"sOldId",
"==",
"sNewId",
")",
"{",
"return",
";",
"}",
"//Invalidate the label itself (see setLabelFor, setAlternativeLabelFor)",
"if",
"(",
"!",
"bDestroy",
")",
"{",
"oLabel",
".",
"invalidate",
"(",
")",
";",
"}",
"//Update the label to control mapping (1-1 mapping)",
"if",
"(",
"sNewId",
")",
"{",
"oLabel",
".",
"__sLabeledControl",
"=",
"sNewId",
";",
"}",
"else",
"{",
"delete",
"oLabel",
".",
"__sLabeledControl",
";",
"}",
"//Update the control to label mapping (1-n mapping)",
"var",
"aLabelsOfControl",
";",
"if",
"(",
"sOldId",
")",
"{",
"aLabelsOfControl",
"=",
"CONTROL_TO_LABELS_MAPPING",
"[",
"sOldId",
"]",
";",
"if",
"(",
"aLabelsOfControl",
")",
"{",
"aLabelsOfControl",
"=",
"aLabelsOfControl",
".",
"filter",
"(",
"function",
"(",
"sCurrentLabelId",
")",
"{",
"return",
"sCurrentLabelId",
"!=",
"sLabelId",
";",
"}",
")",
";",
"if",
"(",
"aLabelsOfControl",
".",
"length",
")",
"{",
"CONTROL_TO_LABELS_MAPPING",
"[",
"sOldId",
"]",
"=",
"aLabelsOfControl",
";",
"}",
"else",
"{",
"delete",
"CONTROL_TO_LABELS_MAPPING",
"[",
"sOldId",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"sNewId",
")",
"{",
"aLabelsOfControl",
"=",
"CONTROL_TO_LABELS_MAPPING",
"[",
"sNewId",
"]",
"||",
"[",
"]",
";",
"aLabelsOfControl",
".",
"push",
"(",
"sLabelId",
")",
";",
"CONTROL_TO_LABELS_MAPPING",
"[",
"sNewId",
"]",
"=",
"aLabelsOfControl",
";",
"}",
"//Invalidate related controls",
"var",
"oOldControl",
"=",
"toControl",
"(",
"sOldId",
",",
"true",
")",
";",
"var",
"oNewControl",
"=",
"toControl",
"(",
"sNewId",
",",
"true",
")",
";",
"if",
"(",
"oOldControl",
")",
"{",
"oLabel",
".",
"detachRequiredChange",
"(",
"oOldControl",
")",
";",
"}",
"if",
"(",
"oNewControl",
")",
"{",
"oLabel",
".",
"attachRequiredChange",
"(",
"oNewControl",
")",
";",
"}",
"}"
] | Updates the mapping tables for the given label, in destroy case only a cleanup is done | [
"Updates",
"the",
"mapping",
"tables",
"for",
"the",
"given",
"label",
"in",
"destroy",
"case",
"only",
"a",
"cleanup",
"is",
"done"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LabelEnablement.js#L40-L94 |
4,742 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LabelEnablement.js | checkLabelEnablementPreconditions | function checkLabelEnablementPreconditions(oControl) {
if (!oControl) {
throw new Error("sap.ui.core.LabelEnablement cannot enrich null");
}
var oMetadata = oControl.getMetadata();
if (!oMetadata.isInstanceOf("sap.ui.core.Label")) {
throw new Error("sap.ui.core.LabelEnablement only supports Controls with interface sap.ui.core.Label");
}
var oLabelForAssociation = oMetadata.getAssociation("labelFor");
if (!oLabelForAssociation || oLabelForAssociation.multiple) {
throw new Error("sap.ui.core.LabelEnablement only supports Controls with a to-1 association 'labelFor'");
}
//Add more detailed checks here ?
} | javascript | function checkLabelEnablementPreconditions(oControl) {
if (!oControl) {
throw new Error("sap.ui.core.LabelEnablement cannot enrich null");
}
var oMetadata = oControl.getMetadata();
if (!oMetadata.isInstanceOf("sap.ui.core.Label")) {
throw new Error("sap.ui.core.LabelEnablement only supports Controls with interface sap.ui.core.Label");
}
var oLabelForAssociation = oMetadata.getAssociation("labelFor");
if (!oLabelForAssociation || oLabelForAssociation.multiple) {
throw new Error("sap.ui.core.LabelEnablement only supports Controls with a to-1 association 'labelFor'");
}
//Add more detailed checks here ?
} | [
"function",
"checkLabelEnablementPreconditions",
"(",
"oControl",
")",
"{",
"if",
"(",
"!",
"oControl",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"sap.ui.core.LabelEnablement cannot enrich null\"",
")",
";",
"}",
"var",
"oMetadata",
"=",
"oControl",
".",
"getMetadata",
"(",
")",
";",
"if",
"(",
"!",
"oMetadata",
".",
"isInstanceOf",
"(",
"\"sap.ui.core.Label\"",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"sap.ui.core.LabelEnablement only supports Controls with interface sap.ui.core.Label\"",
")",
";",
"}",
"var",
"oLabelForAssociation",
"=",
"oMetadata",
".",
"getAssociation",
"(",
"\"labelFor\"",
")",
";",
"if",
"(",
"!",
"oLabelForAssociation",
"||",
"oLabelForAssociation",
".",
"multiple",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"sap.ui.core.LabelEnablement only supports Controls with a to-1 association 'labelFor'\"",
")",
";",
"}",
"//Add more detailed checks here ?",
"}"
] | Checks whether enrich function can be applied on the given control or prototype. | [
"Checks",
"whether",
"enrich",
"function",
"can",
"be",
"applied",
"on",
"the",
"given",
"control",
"or",
"prototype",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LabelEnablement.js#L97-L110 |
4,743 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js | function() {
if (!this.metaPath) {
this.oMetaContext = this.oMetaModel.getMetaContext(this.path);
this.metaPath = this.oMetaContext.getPath();
} else {
this.oMetaContext = this.oMetaModel.createBindingContext(this.metaPath);
}
} | javascript | function() {
if (!this.metaPath) {
this.oMetaContext = this.oMetaModel.getMetaContext(this.path);
this.metaPath = this.oMetaContext.getPath();
} else {
this.oMetaContext = this.oMetaModel.createBindingContext(this.metaPath);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"metaPath",
")",
"{",
"this",
".",
"oMetaContext",
"=",
"this",
".",
"oMetaModel",
".",
"getMetaContext",
"(",
"this",
".",
"path",
")",
";",
"this",
".",
"metaPath",
"=",
"this",
".",
"oMetaContext",
".",
"getPath",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"oMetaContext",
"=",
"this",
".",
"oMetaModel",
".",
"createBindingContext",
"(",
"this",
".",
"metaPath",
")",
";",
"}",
"}"
] | Individual init method for Adapters
@protected | [
"Individual",
"init",
"method",
"for",
"Adapters"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js#L76-L83 |
|
4,744 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js | function(sProperty, vGetter, aArgs, caller) {
if (!vGetter) {
return;
}
if (!caller) {
caller = this;
}
Object.defineProperty(this, sProperty, {
configurable: true,
get: function() {
if (this._mCustomPropertyBag[sProperty]) {
return this._mCustomPropertyBag[sProperty];
}
if (!this._mPropertyBag.hasOwnProperty(sProperty)) {
this._mPropertyBag[sProperty] = new SyncPromise(function(resolve, reject) {
if (typeof vGetter == 'function') {
resolve(vGetter.apply(caller, aArgs));
} else {
resolve(vGetter);
}
});
}
return this._mPropertyBag[sProperty];
},
set: function(vValue) {
this._mCustomPropertyBag[sProperty] = vValue;
}
});
} | javascript | function(sProperty, vGetter, aArgs, caller) {
if (!vGetter) {
return;
}
if (!caller) {
caller = this;
}
Object.defineProperty(this, sProperty, {
configurable: true,
get: function() {
if (this._mCustomPropertyBag[sProperty]) {
return this._mCustomPropertyBag[sProperty];
}
if (!this._mPropertyBag.hasOwnProperty(sProperty)) {
this._mPropertyBag[sProperty] = new SyncPromise(function(resolve, reject) {
if (typeof vGetter == 'function') {
resolve(vGetter.apply(caller, aArgs));
} else {
resolve(vGetter);
}
});
}
return this._mPropertyBag[sProperty];
},
set: function(vValue) {
this._mCustomPropertyBag[sProperty] = vValue;
}
});
} | [
"function",
"(",
"sProperty",
",",
"vGetter",
",",
"aArgs",
",",
"caller",
")",
"{",
"if",
"(",
"!",
"vGetter",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"caller",
")",
"{",
"caller",
"=",
"this",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"sProperty",
",",
"{",
"configurable",
":",
"true",
",",
"get",
":",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_mCustomPropertyBag",
"[",
"sProperty",
"]",
")",
"{",
"return",
"this",
".",
"_mCustomPropertyBag",
"[",
"sProperty",
"]",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_mPropertyBag",
".",
"hasOwnProperty",
"(",
"sProperty",
")",
")",
"{",
"this",
".",
"_mPropertyBag",
"[",
"sProperty",
"]",
"=",
"new",
"SyncPromise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"if",
"(",
"typeof",
"vGetter",
"==",
"'function'",
")",
"{",
"resolve",
"(",
"vGetter",
".",
"apply",
"(",
"caller",
",",
"aArgs",
")",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"vGetter",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"this",
".",
"_mPropertyBag",
"[",
"sProperty",
"]",
";",
"}",
",",
"set",
":",
"function",
"(",
"vValue",
")",
"{",
"this",
".",
"_mCustomPropertyBag",
"[",
"sProperty",
"]",
"=",
"vValue",
";",
"}",
"}",
")",
";",
"}"
] | Puts a deferred property to the corresponding adapter
@param {string} sProperty the name of an adapters property
@param {object} vGetter a getter which can be either an object or a function
@param {array} aArgs an optional array of arguments used if vGetter is a function
@param {object} the caller that inhabits the vGetter function if not supplied the caller is the current closure | [
"Puts",
"a",
"deferred",
"property",
"to",
"the",
"corresponding",
"adapter"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js#L100-L133 |
|
4,745 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js | function(sValuePath, sType) {
var sPath = "{";
if (this.modelName) {
sPath = sPath + "model: '" + this.modelName + "',";
}
if (this.sContextPath && sValuePath.startsWith(this.sContextPath)) {
sValuePath = sValuePath.replace(this.sContextPath,"");
}
sPath = sPath + "path: '" + escape(sValuePath) + "'";
if (sType) {
sPath = sPath + ", type: '" + sType + "'";
}
sPath = sPath + "}";
return sPath;
} | javascript | function(sValuePath, sType) {
var sPath = "{";
if (this.modelName) {
sPath = sPath + "model: '" + this.modelName + "',";
}
if (this.sContextPath && sValuePath.startsWith(this.sContextPath)) {
sValuePath = sValuePath.replace(this.sContextPath,"");
}
sPath = sPath + "path: '" + escape(sValuePath) + "'";
if (sType) {
sPath = sPath + ", type: '" + sType + "'";
}
sPath = sPath + "}";
return sPath;
} | [
"function",
"(",
"sValuePath",
",",
"sType",
")",
"{",
"var",
"sPath",
"=",
"\"{\"",
";",
"if",
"(",
"this",
".",
"modelName",
")",
"{",
"sPath",
"=",
"sPath",
"+",
"\"model: '\"",
"+",
"this",
".",
"modelName",
"+",
"\"',\"",
";",
"}",
"if",
"(",
"this",
".",
"sContextPath",
"&&",
"sValuePath",
".",
"startsWith",
"(",
"this",
".",
"sContextPath",
")",
")",
"{",
"sValuePath",
"=",
"sValuePath",
".",
"replace",
"(",
"this",
".",
"sContextPath",
",",
"\"\"",
")",
";",
"}",
"sPath",
"=",
"sPath",
"+",
"\"path: '\"",
"+",
"escape",
"(",
"sValuePath",
")",
"+",
"\"'\"",
";",
"if",
"(",
"sType",
")",
"{",
"sPath",
"=",
"sPath",
"+",
"\", type: '\"",
"+",
"sType",
"+",
"\"'\"",
";",
"}",
"sPath",
"=",
"sPath",
"+",
"\"}\"",
";",
"return",
"sPath",
";",
"}"
] | The binding as a path within the model name
@param {string} sValuePath the path to the property value, e.g 'Payed'
@param {string} sType the optional name of the UI5 model type, e.g. 'sap.ui.model.type.string'
@returns {string} the representation of a simple binding syntax | [
"The",
"binding",
"as",
"a",
"path",
"within",
"the",
"model",
"name"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/meta/BaseAdapter.js#L141-L161 |
|
4,746 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function(mTargetAnnotations, mSourceAnnotations) {
// Merge must be done on Term level, this is why the original line does not suffice any more:
// jQuery.extend(true, this.oAnnotations, mAnnotations);
// Terms are defined on different levels, the main one is below the target level, which is directly
// added as property to the annotations object and then in the same way inside two special properties
// named "propertyAnnotations" and "EntityContainer"
var sTarget, sTerm;
var aSpecialCases = ["annotationsAtArrays", "propertyAnnotations", "EntityContainer", "annotationReferences"];
// First merge standard annotations
for (sTarget in mSourceAnnotations) {
if (aSpecialCases.indexOf(sTarget) !== -1) {
// Skip these as they are special properties that contain Target level definitions
continue;
}
// ...all others contain Term level definitions
AnnotationParser._mergeAnnotation(sTarget, mSourceAnnotations, mTargetAnnotations);
}
// Now merge special cases except "annotationsAtArrays"
for (var i = 1; i < aSpecialCases.length; ++i) {
var sSpecialCase = aSpecialCases[i];
mTargetAnnotations[sSpecialCase] = mTargetAnnotations[sSpecialCase] || {}; // Make sure the target namespace exists
for (sTarget in mSourceAnnotations[sSpecialCase]) {
for (sTerm in mSourceAnnotations[sSpecialCase][sTarget]) {
// Now merge every term
mTargetAnnotations[sSpecialCase][sTarget] = mTargetAnnotations[sSpecialCase][sTarget] || {};
AnnotationParser._mergeAnnotation(sTerm, mSourceAnnotations[sSpecialCase][sTarget], mTargetAnnotations[sSpecialCase][sTarget]);
}
}
}
if (mSourceAnnotations.annotationsAtArrays) {
mTargetAnnotations.annotationsAtArrays = (mTargetAnnotations.annotationsAtArrays || [])
.concat(mSourceAnnotations.annotationsAtArrays);
}
} | javascript | function(mTargetAnnotations, mSourceAnnotations) {
// Merge must be done on Term level, this is why the original line does not suffice any more:
// jQuery.extend(true, this.oAnnotations, mAnnotations);
// Terms are defined on different levels, the main one is below the target level, which is directly
// added as property to the annotations object and then in the same way inside two special properties
// named "propertyAnnotations" and "EntityContainer"
var sTarget, sTerm;
var aSpecialCases = ["annotationsAtArrays", "propertyAnnotations", "EntityContainer", "annotationReferences"];
// First merge standard annotations
for (sTarget in mSourceAnnotations) {
if (aSpecialCases.indexOf(sTarget) !== -1) {
// Skip these as they are special properties that contain Target level definitions
continue;
}
// ...all others contain Term level definitions
AnnotationParser._mergeAnnotation(sTarget, mSourceAnnotations, mTargetAnnotations);
}
// Now merge special cases except "annotationsAtArrays"
for (var i = 1; i < aSpecialCases.length; ++i) {
var sSpecialCase = aSpecialCases[i];
mTargetAnnotations[sSpecialCase] = mTargetAnnotations[sSpecialCase] || {}; // Make sure the target namespace exists
for (sTarget in mSourceAnnotations[sSpecialCase]) {
for (sTerm in mSourceAnnotations[sSpecialCase][sTarget]) {
// Now merge every term
mTargetAnnotations[sSpecialCase][sTarget] = mTargetAnnotations[sSpecialCase][sTarget] || {};
AnnotationParser._mergeAnnotation(sTerm, mSourceAnnotations[sSpecialCase][sTarget], mTargetAnnotations[sSpecialCase][sTarget]);
}
}
}
if (mSourceAnnotations.annotationsAtArrays) {
mTargetAnnotations.annotationsAtArrays = (mTargetAnnotations.annotationsAtArrays || [])
.concat(mSourceAnnotations.annotationsAtArrays);
}
} | [
"function",
"(",
"mTargetAnnotations",
",",
"mSourceAnnotations",
")",
"{",
"// Merge must be done on Term level, this is why the original line does not suffice any more:",
"// jQuery.extend(true, this.oAnnotations, mAnnotations);",
"// Terms are defined on different levels, the main one is below the target level, which is directly",
"// added as property to the annotations object and then in the same way inside two special properties",
"// named \"propertyAnnotations\" and \"EntityContainer\"",
"var",
"sTarget",
",",
"sTerm",
";",
"var",
"aSpecialCases",
"=",
"[",
"\"annotationsAtArrays\"",
",",
"\"propertyAnnotations\"",
",",
"\"EntityContainer\"",
",",
"\"annotationReferences\"",
"]",
";",
"// First merge standard annotations",
"for",
"(",
"sTarget",
"in",
"mSourceAnnotations",
")",
"{",
"if",
"(",
"aSpecialCases",
".",
"indexOf",
"(",
"sTarget",
")",
"!==",
"-",
"1",
")",
"{",
"// Skip these as they are special properties that contain Target level definitions",
"continue",
";",
"}",
"// ...all others contain Term level definitions",
"AnnotationParser",
".",
"_mergeAnnotation",
"(",
"sTarget",
",",
"mSourceAnnotations",
",",
"mTargetAnnotations",
")",
";",
"}",
"// Now merge special cases except \"annotationsAtArrays\"",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"aSpecialCases",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"sSpecialCase",
"=",
"aSpecialCases",
"[",
"i",
"]",
";",
"mTargetAnnotations",
"[",
"sSpecialCase",
"]",
"=",
"mTargetAnnotations",
"[",
"sSpecialCase",
"]",
"||",
"{",
"}",
";",
"// Make sure the target namespace exists",
"for",
"(",
"sTarget",
"in",
"mSourceAnnotations",
"[",
"sSpecialCase",
"]",
")",
"{",
"for",
"(",
"sTerm",
"in",
"mSourceAnnotations",
"[",
"sSpecialCase",
"]",
"[",
"sTarget",
"]",
")",
"{",
"// Now merge every term",
"mTargetAnnotations",
"[",
"sSpecialCase",
"]",
"[",
"sTarget",
"]",
"=",
"mTargetAnnotations",
"[",
"sSpecialCase",
"]",
"[",
"sTarget",
"]",
"||",
"{",
"}",
";",
"AnnotationParser",
".",
"_mergeAnnotation",
"(",
"sTerm",
",",
"mSourceAnnotations",
"[",
"sSpecialCase",
"]",
"[",
"sTarget",
"]",
",",
"mTargetAnnotations",
"[",
"sSpecialCase",
"]",
"[",
"sTarget",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"mSourceAnnotations",
".",
"annotationsAtArrays",
")",
"{",
"mTargetAnnotations",
".",
"annotationsAtArrays",
"=",
"(",
"mTargetAnnotations",
".",
"annotationsAtArrays",
"||",
"[",
"]",
")",
".",
"concat",
"(",
"mSourceAnnotations",
".",
"annotationsAtArrays",
")",
";",
"}",
"}"
] | Merges the given parsed annotation map into the given target annotation map.
@param {map} mTargetAnnotations The target annotation map into which the source annotations should be merged
@param {map} mSourceAnnotations The source annotation map that should be merged into the target annotation map
@static
@protected | [
"Merges",
"the",
"given",
"parsed",
"annotation",
"map",
"into",
"the",
"given",
"target",
"annotation",
"map",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L92-L133 |
|
4,747 | SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function (mAnnotations) {
if (mAnnotations.annotationsAtArrays) {
mAnnotations.annotationsAtArrays.forEach(function (aSegments) {
AnnotationParser.syncAnnotationsAtArrays(mAnnotations, aSegments);
});
}
} | javascript | function (mAnnotations) {
if (mAnnotations.annotationsAtArrays) {
mAnnotations.annotationsAtArrays.forEach(function (aSegments) {
AnnotationParser.syncAnnotationsAtArrays(mAnnotations, aSegments);
});
}
} | [
"function",
"(",
"mAnnotations",
")",
"{",
"if",
"(",
"mAnnotations",
".",
"annotationsAtArrays",
")",
"{",
"mAnnotations",
".",
"annotationsAtArrays",
".",
"forEach",
"(",
"function",
"(",
"aSegments",
")",
"{",
"AnnotationParser",
".",
"syncAnnotationsAtArrays",
"(",
"mAnnotations",
",",
"aSegments",
")",
";",
"}",
")",
";",
"}",
"}"
] | Restores annotations at arrays which might have been lost due to serialization.
@param {object} mAnnotations - The annotation map
@protected
@see AnnotationParser.backupAnnotationAtArray
@see AnnotationParser.syncAnnotationsAtArrays
@static | [
"Restores",
"annotations",
"at",
"arrays",
"which",
"might",
"have",
"been",
"lost",
"due",
"to",
"serialization",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L504-L510 |
|
4,748 | SAP/openui5 | src/sap.ui.core/src/sap/ui/core/theming/Parameters.js | getParam | function getParam(mOptions) {
var oParams = getParameters();
if (mOptions.scopeName) {
oParams = oParams["scopes"][mOptions.scopeName];
} else {
oParams = oParams["default"];
}
var sParam = oParams[mOptions.parameterName];
if (typeof sParam === "undefined" && typeof mOptions.parameterName === "string") {
// compatibility for theming parameters with colon
var iIndex = mOptions.parameterName.indexOf(":");
if (iIndex !== -1) {
mOptions.parameterName = mOptions.parameterName.substr(iIndex + 1);
}
sParam = oParams[mOptions.parameterName];
}
if (mOptions.loadPendingParameters && typeof sParam === "undefined") {
loadPendingLibraryParameters();
sParam = getParam({
parameterName: mOptions.parameterName,
scopeName: mOptions.scopeName,
loadPendingParameters: false // prevent recursion
});
}
return sParam;
} | javascript | function getParam(mOptions) {
var oParams = getParameters();
if (mOptions.scopeName) {
oParams = oParams["scopes"][mOptions.scopeName];
} else {
oParams = oParams["default"];
}
var sParam = oParams[mOptions.parameterName];
if (typeof sParam === "undefined" && typeof mOptions.parameterName === "string") {
// compatibility for theming parameters with colon
var iIndex = mOptions.parameterName.indexOf(":");
if (iIndex !== -1) {
mOptions.parameterName = mOptions.parameterName.substr(iIndex + 1);
}
sParam = oParams[mOptions.parameterName];
}
if (mOptions.loadPendingParameters && typeof sParam === "undefined") {
loadPendingLibraryParameters();
sParam = getParam({
parameterName: mOptions.parameterName,
scopeName: mOptions.scopeName,
loadPendingParameters: false // prevent recursion
});
}
return sParam;
} | [
"function",
"getParam",
"(",
"mOptions",
")",
"{",
"var",
"oParams",
"=",
"getParameters",
"(",
")",
";",
"if",
"(",
"mOptions",
".",
"scopeName",
")",
"{",
"oParams",
"=",
"oParams",
"[",
"\"scopes\"",
"]",
"[",
"mOptions",
".",
"scopeName",
"]",
";",
"}",
"else",
"{",
"oParams",
"=",
"oParams",
"[",
"\"default\"",
"]",
";",
"}",
"var",
"sParam",
"=",
"oParams",
"[",
"mOptions",
".",
"parameterName",
"]",
";",
"if",
"(",
"typeof",
"sParam",
"===",
"\"undefined\"",
"&&",
"typeof",
"mOptions",
".",
"parameterName",
"===",
"\"string\"",
")",
"{",
"// compatibility for theming parameters with colon",
"var",
"iIndex",
"=",
"mOptions",
".",
"parameterName",
".",
"indexOf",
"(",
"\":\"",
")",
";",
"if",
"(",
"iIndex",
"!==",
"-",
"1",
")",
"{",
"mOptions",
".",
"parameterName",
"=",
"mOptions",
".",
"parameterName",
".",
"substr",
"(",
"iIndex",
"+",
"1",
")",
";",
"}",
"sParam",
"=",
"oParams",
"[",
"mOptions",
".",
"parameterName",
"]",
";",
"}",
"if",
"(",
"mOptions",
".",
"loadPendingParameters",
"&&",
"typeof",
"sParam",
"===",
"\"undefined\"",
")",
"{",
"loadPendingLibraryParameters",
"(",
")",
";",
"sParam",
"=",
"getParam",
"(",
"{",
"parameterName",
":",
"mOptions",
".",
"parameterName",
",",
"scopeName",
":",
"mOptions",
".",
"scopeName",
",",
"loadPendingParameters",
":",
"false",
"// prevent recursion",
"}",
")",
";",
"}",
"return",
"sParam",
";",
"}"
] | Returns parameter value from given map and handles legacy parameter names
@param {object} mOptions options map
@param {string} mOptions.parameterName Parameter name / key
@param {string} mOptions.scopeName Scope name
@param {boolean} mOptions.loadPendingParameters If set to "true" and no parameter value is found,
all pending parameters will be loaded (see Parameters._addLibraryTheme)
@returns {string} parameter value or undefined
@private | [
"Returns",
"parameter",
"value",
"from",
"given",
"map",
"and",
"handles",
"legacy",
"parameter",
"names"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/theming/Parameters.js#L261-L290 |
4,749 | SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/plugin/RenameHandler.js | function (bRestoreFocus, oEvent) {
if (!this._bBlurOrKeyDownStarted) {
this._bBlurOrKeyDownStarted = true;
if (oEvent) {
RenameHandler._preventDefault.call(this, oEvent);
RenameHandler._stopPropagation.call(this, oEvent);
}
return this._emitLabelChangeEvent()
.then(function (fnErrorHandler) {
this.stopEdit(bRestoreFocus);
if (typeof fnErrorHandler === "function") {
fnErrorHandler(); // contains startEdit() and valueStateMessage
}
}.bind(this));
}
return Promise.resolve();
} | javascript | function (bRestoreFocus, oEvent) {
if (!this._bBlurOrKeyDownStarted) {
this._bBlurOrKeyDownStarted = true;
if (oEvent) {
RenameHandler._preventDefault.call(this, oEvent);
RenameHandler._stopPropagation.call(this, oEvent);
}
return this._emitLabelChangeEvent()
.then(function (fnErrorHandler) {
this.stopEdit(bRestoreFocus);
if (typeof fnErrorHandler === "function") {
fnErrorHandler(); // contains startEdit() and valueStateMessage
}
}.bind(this));
}
return Promise.resolve();
} | [
"function",
"(",
"bRestoreFocus",
",",
"oEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_bBlurOrKeyDownStarted",
")",
"{",
"this",
".",
"_bBlurOrKeyDownStarted",
"=",
"true",
";",
"if",
"(",
"oEvent",
")",
"{",
"RenameHandler",
".",
"_preventDefault",
".",
"call",
"(",
"this",
",",
"oEvent",
")",
";",
"RenameHandler",
".",
"_stopPropagation",
".",
"call",
"(",
"this",
",",
"oEvent",
")",
";",
"}",
"return",
"this",
".",
"_emitLabelChangeEvent",
"(",
")",
".",
"then",
"(",
"function",
"(",
"fnErrorHandler",
")",
"{",
"this",
".",
"stopEdit",
"(",
"bRestoreFocus",
")",
";",
"if",
"(",
"typeof",
"fnErrorHandler",
"===",
"\"function\"",
")",
"{",
"fnErrorHandler",
"(",
")",
";",
"// contains startEdit() and valueStateMessage",
"}",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}"
] | Handles events after rename has been performed
@param {boolean} bRestoreFocus - to restore focus to overlay after rename completes
@private | [
"Handles",
"events",
"after",
"rename",
"has",
"been",
"performed"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/RenameHandler.js#L291-L307 |
|
4,750 | SAP/openui5 | src/sap.ui.core/src/sap/ui/events/jquery/EventExtension.js | function(oEvent) {
while (oEvent && oEvent.originalEvent && oEvent !== oEvent.originalEvent) {
oEvent = oEvent.originalEvent;
}
return oEvent;
} | javascript | function(oEvent) {
while (oEvent && oEvent.originalEvent && oEvent !== oEvent.originalEvent) {
oEvent = oEvent.originalEvent;
}
return oEvent;
} | [
"function",
"(",
"oEvent",
")",
"{",
"while",
"(",
"oEvent",
"&&",
"oEvent",
".",
"originalEvent",
"&&",
"oEvent",
"!==",
"oEvent",
".",
"originalEvent",
")",
"{",
"oEvent",
"=",
"oEvent",
".",
"originalEvent",
";",
"}",
"return",
"oEvent",
";",
"}"
] | Get the real native browser event from a jQuery event object | [
"Get",
"the",
"real",
"native",
"browser",
"event",
"from",
"a",
"jQuery",
"event",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/jquery/EventExtension.js#L178-L183 |
|
4,751 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(rm, oRoadMap, bStart){
var sType = bStart ? "Start" : "End";
rm.write("<div");
rm.writeAttribute("id", oRoadMap.getId() + "-" + sType);
rm.writeAttribute("tabindex", "-1");
var hasHiddenSteps = true; //Simply assume that there are hidden steps -> updated later (see function updateScrollState)
rm.addClass(hasHiddenSteps ? "sapUiRoadMap" + sType + "Scroll" : "sapUiRoadMap" + sType + "Fixed");
rm.addClass("sapUiRoadMapDelim");
rm.addClass("sapUiRoadMapContent");
rm.writeClasses();
rm.write("></div>");
} | javascript | function(rm, oRoadMap, bStart){
var sType = bStart ? "Start" : "End";
rm.write("<div");
rm.writeAttribute("id", oRoadMap.getId() + "-" + sType);
rm.writeAttribute("tabindex", "-1");
var hasHiddenSteps = true; //Simply assume that there are hidden steps -> updated later (see function updateScrollState)
rm.addClass(hasHiddenSteps ? "sapUiRoadMap" + sType + "Scroll" : "sapUiRoadMap" + sType + "Fixed");
rm.addClass("sapUiRoadMapDelim");
rm.addClass("sapUiRoadMapContent");
rm.writeClasses();
rm.write("></div>");
} | [
"function",
"(",
"rm",
",",
"oRoadMap",
",",
"bStart",
")",
"{",
"var",
"sType",
"=",
"bStart",
"?",
"\"Start\"",
":",
"\"End\"",
";",
"rm",
".",
"write",
"(",
"\"<div\"",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"oRoadMap",
".",
"getId",
"(",
")",
"+",
"\"-\"",
"+",
"sType",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"tabindex\"",
",",
"\"-1\"",
")",
";",
"var",
"hasHiddenSteps",
"=",
"true",
";",
"//Simply assume that there are hidden steps -> updated later (see function updateScrollState)",
"rm",
".",
"addClass",
"(",
"hasHiddenSteps",
"?",
"\"sapUiRoadMap\"",
"+",
"sType",
"+",
"\"Scroll\"",
":",
"\"sapUiRoadMap\"",
"+",
"sType",
"+",
"\"Fixed\"",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapDelim\"",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapContent\"",
")",
";",
"rm",
".",
"writeClasses",
"(",
")",
";",
"rm",
".",
"write",
"(",
"\"></div>\"",
")",
";",
"}"
] | Writes the delimiter HTML into the rendermanger | [
"Writes",
"the",
"delimiter",
"HTML",
"into",
"the",
"rendermanger"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L540-L551 |
|
4,752 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(rm, oRoadMap, oStep, aAdditionalClasses, fAddAdditionalBoxContent, sId){
rm.write("<li");
if (sId) { //Write the given Id if available, otherwise use writeControlData
rm.writeAttribute("id", sId);
} else {
rm.writeElementData(oStep);
}
var sStepName = getStepName(oRoadMap, oStep);
oStep.__stepName = sStepName;
var sTooltip = getStepTooltip(oStep);
rm.addClass("sapUiRoadMapContent");
rm.addClass("sapUiRoadMapStep");
if (!oStep.getVisible()) {
rm.addClass("sapUiRoadMapHidden");
}
if (oStep.getEnabled()) {
if (oRoadMap.getSelectedStep() == oStep.getId()) {
rm.addClass("sapUiRoadMapSelected");
}
} else {
rm.addClass("sapUiRoadMapDisabled");
}
if (aAdditionalClasses) { //Write additional CSS classes if available
for (var i = 0; i < aAdditionalClasses.length; i++) {
rm.addClass(aAdditionalClasses[i]);
}
}
rm.writeClasses();
rm.write(">");
renderAdditionalStyleElem(rm, sId ? sId : oStep.getId(), 1);
rm.write("<div");
rm.writeAttribute("id", (sId ? sId : oStep.getId()) + "-box");
rm.writeAttribute("tabindex", "-1");
rm.addClass("sapUiRoadMapStepBox");
rm.writeClasses();
rm.writeAttributeEscaped("title", sTooltip);
writeStepAria(rm, oRoadMap, oStep, fAddAdditionalBoxContent ? true : false);
rm.write("><span>");
rm.write(sStepName);
rm.write("</span>");
//Call callback function to render additional content
if (fAddAdditionalBoxContent) {
fAddAdditionalBoxContent(rm, oRoadMap, oStep);
}
rm.write("</div>");
rm.write("<label");
rm.writeAttribute("id", (sId ? sId : oStep.getId()) + "-label");
rm.addClass("sapUiRoadMapTitle");
rm.writeAttributeEscaped("title", sTooltip);
rm.writeClasses();
rm.write(">");
var sLabel = oStep.getLabel();
if (sLabel) {
rm.writeEscaped(sLabel);
}
rm.write("</label>");
renderAdditionalStyleElem(rm, sId ? sId : oStep.getId(), 2);
rm.write("</li>");
} | javascript | function(rm, oRoadMap, oStep, aAdditionalClasses, fAddAdditionalBoxContent, sId){
rm.write("<li");
if (sId) { //Write the given Id if available, otherwise use writeControlData
rm.writeAttribute("id", sId);
} else {
rm.writeElementData(oStep);
}
var sStepName = getStepName(oRoadMap, oStep);
oStep.__stepName = sStepName;
var sTooltip = getStepTooltip(oStep);
rm.addClass("sapUiRoadMapContent");
rm.addClass("sapUiRoadMapStep");
if (!oStep.getVisible()) {
rm.addClass("sapUiRoadMapHidden");
}
if (oStep.getEnabled()) {
if (oRoadMap.getSelectedStep() == oStep.getId()) {
rm.addClass("sapUiRoadMapSelected");
}
} else {
rm.addClass("sapUiRoadMapDisabled");
}
if (aAdditionalClasses) { //Write additional CSS classes if available
for (var i = 0; i < aAdditionalClasses.length; i++) {
rm.addClass(aAdditionalClasses[i]);
}
}
rm.writeClasses();
rm.write(">");
renderAdditionalStyleElem(rm, sId ? sId : oStep.getId(), 1);
rm.write("<div");
rm.writeAttribute("id", (sId ? sId : oStep.getId()) + "-box");
rm.writeAttribute("tabindex", "-1");
rm.addClass("sapUiRoadMapStepBox");
rm.writeClasses();
rm.writeAttributeEscaped("title", sTooltip);
writeStepAria(rm, oRoadMap, oStep, fAddAdditionalBoxContent ? true : false);
rm.write("><span>");
rm.write(sStepName);
rm.write("</span>");
//Call callback function to render additional content
if (fAddAdditionalBoxContent) {
fAddAdditionalBoxContent(rm, oRoadMap, oStep);
}
rm.write("</div>");
rm.write("<label");
rm.writeAttribute("id", (sId ? sId : oStep.getId()) + "-label");
rm.addClass("sapUiRoadMapTitle");
rm.writeAttributeEscaped("title", sTooltip);
rm.writeClasses();
rm.write(">");
var sLabel = oStep.getLabel();
if (sLabel) {
rm.writeEscaped(sLabel);
}
rm.write("</label>");
renderAdditionalStyleElem(rm, sId ? sId : oStep.getId(), 2);
rm.write("</li>");
} | [
"function",
"(",
"rm",
",",
"oRoadMap",
",",
"oStep",
",",
"aAdditionalClasses",
",",
"fAddAdditionalBoxContent",
",",
"sId",
")",
"{",
"rm",
".",
"write",
"(",
"\"<li\"",
")",
";",
"if",
"(",
"sId",
")",
"{",
"//Write the given Id if available, otherwise use writeControlData",
"rm",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"sId",
")",
";",
"}",
"else",
"{",
"rm",
".",
"writeElementData",
"(",
"oStep",
")",
";",
"}",
"var",
"sStepName",
"=",
"getStepName",
"(",
"oRoadMap",
",",
"oStep",
")",
";",
"oStep",
".",
"__stepName",
"=",
"sStepName",
";",
"var",
"sTooltip",
"=",
"getStepTooltip",
"(",
"oStep",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapContent\"",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapStep\"",
")",
";",
"if",
"(",
"!",
"oStep",
".",
"getVisible",
"(",
")",
")",
"{",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapHidden\"",
")",
";",
"}",
"if",
"(",
"oStep",
".",
"getEnabled",
"(",
")",
")",
"{",
"if",
"(",
"oRoadMap",
".",
"getSelectedStep",
"(",
")",
"==",
"oStep",
".",
"getId",
"(",
")",
")",
"{",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapSelected\"",
")",
";",
"}",
"}",
"else",
"{",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapDisabled\"",
")",
";",
"}",
"if",
"(",
"aAdditionalClasses",
")",
"{",
"//Write additional CSS classes if available",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aAdditionalClasses",
".",
"length",
";",
"i",
"++",
")",
"{",
"rm",
".",
"addClass",
"(",
"aAdditionalClasses",
"[",
"i",
"]",
")",
";",
"}",
"}",
"rm",
".",
"writeClasses",
"(",
")",
";",
"rm",
".",
"write",
"(",
"\">\"",
")",
";",
"renderAdditionalStyleElem",
"(",
"rm",
",",
"sId",
"?",
"sId",
":",
"oStep",
".",
"getId",
"(",
")",
",",
"1",
")",
";",
"rm",
".",
"write",
"(",
"\"<div\"",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"(",
"sId",
"?",
"sId",
":",
"oStep",
".",
"getId",
"(",
")",
")",
"+",
"\"-box\"",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"tabindex\"",
",",
"\"-1\"",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapStepBox\"",
")",
";",
"rm",
".",
"writeClasses",
"(",
")",
";",
"rm",
".",
"writeAttributeEscaped",
"(",
"\"title\"",
",",
"sTooltip",
")",
";",
"writeStepAria",
"(",
"rm",
",",
"oRoadMap",
",",
"oStep",
",",
"fAddAdditionalBoxContent",
"?",
"true",
":",
"false",
")",
";",
"rm",
".",
"write",
"(",
"\"><span>\"",
")",
";",
"rm",
".",
"write",
"(",
"sStepName",
")",
";",
"rm",
".",
"write",
"(",
"\"</span>\"",
")",
";",
"//Call callback function to render additional content",
"if",
"(",
"fAddAdditionalBoxContent",
")",
"{",
"fAddAdditionalBoxContent",
"(",
"rm",
",",
"oRoadMap",
",",
"oStep",
")",
";",
"}",
"rm",
".",
"write",
"(",
"\"</div>\"",
")",
";",
"rm",
".",
"write",
"(",
"\"<label\"",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"id\"",
",",
"(",
"sId",
"?",
"sId",
":",
"oStep",
".",
"getId",
"(",
")",
")",
"+",
"\"-label\"",
")",
";",
"rm",
".",
"addClass",
"(",
"\"sapUiRoadMapTitle\"",
")",
";",
"rm",
".",
"writeAttributeEscaped",
"(",
"\"title\"",
",",
"sTooltip",
")",
";",
"rm",
".",
"writeClasses",
"(",
")",
";",
"rm",
".",
"write",
"(",
"\">\"",
")",
";",
"var",
"sLabel",
"=",
"oStep",
".",
"getLabel",
"(",
")",
";",
"if",
"(",
"sLabel",
")",
"{",
"rm",
".",
"writeEscaped",
"(",
"sLabel",
")",
";",
"}",
"rm",
".",
"write",
"(",
"\"</label>\"",
")",
";",
"renderAdditionalStyleElem",
"(",
"rm",
",",
"sId",
"?",
"sId",
":",
"oStep",
".",
"getId",
"(",
")",
",",
"2",
")",
";",
"rm",
".",
"write",
"(",
"\"</li>\"",
")",
";",
"}"
] | Writes the step HTML into the rendermanger | [
"Writes",
"the",
"step",
"HTML",
"into",
"the",
"rendermanger"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L555-L624 |
|
4,753 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oStep){
var sTooltip = oStep.getTooltip_AsString();
if (!sTooltip && !oStep.getTooltip() && sap.ui.getCore().getConfiguration().getAccessibility()) {
sTooltip = getText("RDMP_DEFAULT_STEP_TOOLTIP", [oStep.__stepName]);
}
return sTooltip || "";
} | javascript | function(oStep){
var sTooltip = oStep.getTooltip_AsString();
if (!sTooltip && !oStep.getTooltip() && sap.ui.getCore().getConfiguration().getAccessibility()) {
sTooltip = getText("RDMP_DEFAULT_STEP_TOOLTIP", [oStep.__stepName]);
}
return sTooltip || "";
} | [
"function",
"(",
"oStep",
")",
"{",
"var",
"sTooltip",
"=",
"oStep",
".",
"getTooltip_AsString",
"(",
")",
";",
"if",
"(",
"!",
"sTooltip",
"&&",
"!",
"oStep",
".",
"getTooltip",
"(",
")",
"&&",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"getAccessibility",
"(",
")",
")",
"{",
"sTooltip",
"=",
"getText",
"(",
"\"RDMP_DEFAULT_STEP_TOOLTIP\"",
",",
"[",
"oStep",
".",
"__stepName",
"]",
")",
";",
"}",
"return",
"sTooltip",
"||",
"\"\"",
";",
"}"
] | Returns the tooltip of the given step | [
"Returns",
"the",
"tooltip",
"of",
"the",
"given",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L628-L634 |
|
4,754 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(rm, oRoadMap, oStep, bIsExpandable){
if (!sap.ui.getCore().getConfiguration().getAccessibility()) {
return;
}
rm.writeAttribute("role", "treeitem");
if (oStep.getEnabled()) {
rm.writeAttribute("aria-checked", oRoadMap.getSelectedStep() == oStep.getId());
} else {
rm.writeAttribute("aria-disabled", true);
}
rm.writeAttribute("aria-haspopup", bIsExpandable);
rm.writeAttribute("aria-level", oStep.getParent() instanceof sap.ui.commons.RoadMap ? 1 : 2);
rm.writeAttribute("aria-posinset", getAriaPosInSet(oStep));
rm.writeAttribute("aria-setsize", getAriaSetSize(oStep));
rm.writeAttributeEscaped("aria-label", getAriaLabel(oStep, oStep.getLabel()));
if (!bIsExpandable) {
return;
}
rm.writeAttribute("aria-expanded", oStep.getExpanded());
} | javascript | function(rm, oRoadMap, oStep, bIsExpandable){
if (!sap.ui.getCore().getConfiguration().getAccessibility()) {
return;
}
rm.writeAttribute("role", "treeitem");
if (oStep.getEnabled()) {
rm.writeAttribute("aria-checked", oRoadMap.getSelectedStep() == oStep.getId());
} else {
rm.writeAttribute("aria-disabled", true);
}
rm.writeAttribute("aria-haspopup", bIsExpandable);
rm.writeAttribute("aria-level", oStep.getParent() instanceof sap.ui.commons.RoadMap ? 1 : 2);
rm.writeAttribute("aria-posinset", getAriaPosInSet(oStep));
rm.writeAttribute("aria-setsize", getAriaSetSize(oStep));
rm.writeAttributeEscaped("aria-label", getAriaLabel(oStep, oStep.getLabel()));
if (!bIsExpandable) {
return;
}
rm.writeAttribute("aria-expanded", oStep.getExpanded());
} | [
"function",
"(",
"rm",
",",
"oRoadMap",
",",
"oStep",
",",
"bIsExpandable",
")",
"{",
"if",
"(",
"!",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"getAccessibility",
"(",
")",
")",
"{",
"return",
";",
"}",
"rm",
".",
"writeAttribute",
"(",
"\"role\"",
",",
"\"treeitem\"",
")",
";",
"if",
"(",
"oStep",
".",
"getEnabled",
"(",
")",
")",
"{",
"rm",
".",
"writeAttribute",
"(",
"\"aria-checked\"",
",",
"oRoadMap",
".",
"getSelectedStep",
"(",
")",
"==",
"oStep",
".",
"getId",
"(",
")",
")",
";",
"}",
"else",
"{",
"rm",
".",
"writeAttribute",
"(",
"\"aria-disabled\"",
",",
"true",
")",
";",
"}",
"rm",
".",
"writeAttribute",
"(",
"\"aria-haspopup\"",
",",
"bIsExpandable",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"aria-level\"",
",",
"oStep",
".",
"getParent",
"(",
")",
"instanceof",
"sap",
".",
"ui",
".",
"commons",
".",
"RoadMap",
"?",
"1",
":",
"2",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"aria-posinset\"",
",",
"getAriaPosInSet",
"(",
"oStep",
")",
")",
";",
"rm",
".",
"writeAttribute",
"(",
"\"aria-setsize\"",
",",
"getAriaSetSize",
"(",
"oStep",
")",
")",
";",
"rm",
".",
"writeAttributeEscaped",
"(",
"\"aria-label\"",
",",
"getAriaLabel",
"(",
"oStep",
",",
"oStep",
".",
"getLabel",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"bIsExpandable",
")",
"{",
"return",
";",
"}",
"rm",
".",
"writeAttribute",
"(",
"\"aria-expanded\"",
",",
"oStep",
".",
"getExpanded",
"(",
")",
")",
";",
"}"
] | Writes the ARIA properties of a step | [
"Writes",
"the",
"ARIA",
"properties",
"of",
"a",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L648-L672 |
|
4,755 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oStep, sLabel){
var bIsExpandable = oStep.getParent() instanceof sap.ui.commons.RoadMap && oStep.getSubSteps().length > 0;
var sResult = sLabel || "";
if (oStep.getEnabled()) {
sResult = getText(bIsExpandable ? "RDMP_ARIA_EXPANDABLE_STEP" : "RDMP_ARIA_STANDARD_STEP", [sResult]);
}
return sResult;
} | javascript | function(oStep, sLabel){
var bIsExpandable = oStep.getParent() instanceof sap.ui.commons.RoadMap && oStep.getSubSteps().length > 0;
var sResult = sLabel || "";
if (oStep.getEnabled()) {
sResult = getText(bIsExpandable ? "RDMP_ARIA_EXPANDABLE_STEP" : "RDMP_ARIA_STANDARD_STEP", [sResult]);
}
return sResult;
} | [
"function",
"(",
"oStep",
",",
"sLabel",
")",
"{",
"var",
"bIsExpandable",
"=",
"oStep",
".",
"getParent",
"(",
")",
"instanceof",
"sap",
".",
"ui",
".",
"commons",
".",
"RoadMap",
"&&",
"oStep",
".",
"getSubSteps",
"(",
")",
".",
"length",
">",
"0",
";",
"var",
"sResult",
"=",
"sLabel",
"||",
"\"\"",
";",
"if",
"(",
"oStep",
".",
"getEnabled",
"(",
")",
")",
"{",
"sResult",
"=",
"getText",
"(",
"bIsExpandable",
"?",
"\"RDMP_ARIA_EXPANDABLE_STEP\"",
":",
"\"RDMP_ARIA_STANDARD_STEP\"",
",",
"[",
"sResult",
"]",
")",
";",
"}",
"return",
"sResult",
";",
"}"
] | Computes how the aria-label property should be set for the given step | [
"Computes",
"how",
"the",
"aria",
"-",
"label",
"property",
"should",
"be",
"set",
"for",
"the",
"given",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L676-L685 |
|
4,756 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var iIdx = oStep.getParent()[bIsTopLevel ? "indexOfStep" : "indexOfSubStep"](oStep);
var iCountInvisible = 0;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
for (var i = 0; i < iIdx; i++) {
if (!aSteps[i].getVisible()) {
iCountInvisible++;
}
}
return iIdx + 1 - iCountInvisible;
} | javascript | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var iIdx = oStep.getParent()[bIsTopLevel ? "indexOfStep" : "indexOfSubStep"](oStep);
var iCountInvisible = 0;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
for (var i = 0; i < iIdx; i++) {
if (!aSteps[i].getVisible()) {
iCountInvisible++;
}
}
return iIdx + 1 - iCountInvisible;
} | [
"function",
"(",
"oStep",
")",
"{",
"var",
"bIsTopLevel",
"=",
"oStep",
".",
"getParent",
"(",
")",
"instanceof",
"sap",
".",
"ui",
".",
"commons",
".",
"RoadMap",
";",
"var",
"iIdx",
"=",
"oStep",
".",
"getParent",
"(",
")",
"[",
"bIsTopLevel",
"?",
"\"indexOfStep\"",
":",
"\"indexOfSubStep\"",
"]",
"(",
"oStep",
")",
";",
"var",
"iCountInvisible",
"=",
"0",
";",
"var",
"aSteps",
"=",
"oStep",
".",
"getParent",
"(",
")",
"[",
"bIsTopLevel",
"?",
"\"getSteps\"",
":",
"\"getSubSteps\"",
"]",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"iIdx",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"aSteps",
"[",
"i",
"]",
".",
"getVisible",
"(",
")",
")",
"{",
"iCountInvisible",
"++",
";",
"}",
"}",
"return",
"iIdx",
"+",
"1",
"-",
"iCountInvisible",
";",
"}"
] | Computes how the aria-posinset property should be set for the given step | [
"Computes",
"how",
"the",
"aria",
"-",
"posinset",
"property",
"should",
"be",
"set",
"for",
"the",
"given",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L689-L700 |
|
4,757 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
var iCount = aSteps.length;
for (var i = 0; i < aSteps.length; i++) {
if (!aSteps[i].getVisible()) {
iCount--;
}
}
return iCount;
} | javascript | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
var iCount = aSteps.length;
for (var i = 0; i < aSteps.length; i++) {
if (!aSteps[i].getVisible()) {
iCount--;
}
}
return iCount;
} | [
"function",
"(",
"oStep",
")",
"{",
"var",
"bIsTopLevel",
"=",
"oStep",
".",
"getParent",
"(",
")",
"instanceof",
"sap",
".",
"ui",
".",
"commons",
".",
"RoadMap",
";",
"var",
"aSteps",
"=",
"oStep",
".",
"getParent",
"(",
")",
"[",
"bIsTopLevel",
"?",
"\"getSteps\"",
":",
"\"getSubSteps\"",
"]",
"(",
")",
";",
"var",
"iCount",
"=",
"aSteps",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aSteps",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"aSteps",
"[",
"i",
"]",
".",
"getVisible",
"(",
")",
")",
"{",
"iCount",
"--",
";",
"}",
"}",
"return",
"iCount",
";",
"}"
] | Computes how the aria-setsize property should be set for the given step | [
"Computes",
"how",
"the",
"aria",
"-",
"setsize",
"property",
"should",
"be",
"set",
"for",
"the",
"given",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L704-L714 |
|
4,758 | 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",
".",
"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\"",
")",
";",
"}"
] | 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 |
|
4,759 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oRoadMap){
var iRTLFactor = getRTLFactor();
var jStepArea = oRoadMap.$("steparea");
var iScrollLeft = getScrollLeft(jStepArea);
var jStartDelim = oRoadMap.$("Start");
jStartDelim.removeClass("sapUiRoadMapStartScroll").removeClass("sapUiRoadMapStartFixed");
jStartDelim.addClass(iRTLFactor * iScrollLeft >= oRoadMap.iStepWidth ? "sapUiRoadMapStartScroll" : "sapUiRoadMapStartFixed");
var jEndDelim = oRoadMap.$("End");
jEndDelim.removeClass("sapUiRoadMapEndScroll").removeClass("sapUiRoadMapEndFixed");
var bEndReached = jStepArea.get(0).scrollWidth - iRTLFactor * iScrollLeft - jStepArea.width() < oRoadMap.iStepWidth;
jEndDelim.addClass(bEndReached ? "sapUiRoadMapEndFixed" : "sapUiRoadMapEndScroll");
} | javascript | function(oRoadMap){
var iRTLFactor = getRTLFactor();
var jStepArea = oRoadMap.$("steparea");
var iScrollLeft = getScrollLeft(jStepArea);
var jStartDelim = oRoadMap.$("Start");
jStartDelim.removeClass("sapUiRoadMapStartScroll").removeClass("sapUiRoadMapStartFixed");
jStartDelim.addClass(iRTLFactor * iScrollLeft >= oRoadMap.iStepWidth ? "sapUiRoadMapStartScroll" : "sapUiRoadMapStartFixed");
var jEndDelim = oRoadMap.$("End");
jEndDelim.removeClass("sapUiRoadMapEndScroll").removeClass("sapUiRoadMapEndFixed");
var bEndReached = jStepArea.get(0).scrollWidth - iRTLFactor * iScrollLeft - jStepArea.width() < oRoadMap.iStepWidth;
jEndDelim.addClass(bEndReached ? "sapUiRoadMapEndFixed" : "sapUiRoadMapEndScroll");
} | [
"function",
"(",
"oRoadMap",
")",
"{",
"var",
"iRTLFactor",
"=",
"getRTLFactor",
"(",
")",
";",
"var",
"jStepArea",
"=",
"oRoadMap",
".",
"$",
"(",
"\"steparea\"",
")",
";",
"var",
"iScrollLeft",
"=",
"getScrollLeft",
"(",
"jStepArea",
")",
";",
"var",
"jStartDelim",
"=",
"oRoadMap",
".",
"$",
"(",
"\"Start\"",
")",
";",
"jStartDelim",
".",
"removeClass",
"(",
"\"sapUiRoadMapStartScroll\"",
")",
".",
"removeClass",
"(",
"\"sapUiRoadMapStartFixed\"",
")",
";",
"jStartDelim",
".",
"addClass",
"(",
"iRTLFactor",
"*",
"iScrollLeft",
">=",
"oRoadMap",
".",
"iStepWidth",
"?",
"\"sapUiRoadMapStartScroll\"",
":",
"\"sapUiRoadMapStartFixed\"",
")",
";",
"var",
"jEndDelim",
"=",
"oRoadMap",
".",
"$",
"(",
"\"End\"",
")",
";",
"jEndDelim",
".",
"removeClass",
"(",
"\"sapUiRoadMapEndScroll\"",
")",
".",
"removeClass",
"(",
"\"sapUiRoadMapEndFixed\"",
")",
";",
"var",
"bEndReached",
"=",
"jStepArea",
".",
"get",
"(",
"0",
")",
".",
"scrollWidth",
"-",
"iRTLFactor",
"*",
"iScrollLeft",
"-",
"jStepArea",
".",
"width",
"(",
")",
"<",
"oRoadMap",
".",
"iStepWidth",
";",
"jEndDelim",
".",
"addClass",
"(",
"bEndReached",
"?",
"\"sapUiRoadMapEndFixed\"",
":",
"\"sapUiRoadMapEndScroll\"",
")",
";",
"}"
] | Refreshs the delimiters according to the current scroll state | [
"Refreshs",
"the",
"delimiters",
"according",
"to",
"the",
"current",
"scroll",
"state"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L779-L794 |
|
4,760 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(jStepArea, jStep){
var iPos = jStep.position().left;
if (sap.ui.getCore().getConfiguration().getRTL()) { //Recompute in RTL case
iPos = jStepArea.width() - iPos - jStep.outerWidth();
}
return iPos;
} | javascript | function(jStepArea, jStep){
var iPos = jStep.position().left;
if (sap.ui.getCore().getConfiguration().getRTL()) { //Recompute in RTL case
iPos = jStepArea.width() - iPos - jStep.outerWidth();
}
return iPos;
} | [
"function",
"(",
"jStepArea",
",",
"jStep",
")",
"{",
"var",
"iPos",
"=",
"jStep",
".",
"position",
"(",
")",
".",
"left",
";",
"if",
"(",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"getRTL",
"(",
")",
")",
"{",
"//Recompute in RTL case",
"iPos",
"=",
"jStepArea",
".",
"width",
"(",
")",
"-",
"iPos",
"-",
"jStep",
".",
"outerWidth",
"(",
")",
";",
"}",
"return",
"iPos",
";",
"}"
] | Returns the position left attribute of the given step within the scroll area | [
"Returns",
"the",
"position",
"left",
"attribute",
"of",
"the",
"given",
"step",
"within",
"the",
"scroll",
"area"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L831-L837 |
|
4,761 | SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oRoadMap, iNewPos, bSkipAnim, fEndCallBack){
var jStepArea = oRoadMap.$("steparea");
jStepArea.stop(false, true);
if (iNewPos == "next") {
iNewPos = jStepArea.scrollLeft() + oRoadMap.iStepWidth * getRTLFactor();
} else if (iNewPos == "prev") {
iNewPos = jStepArea.scrollLeft() - oRoadMap.iStepWidth * getRTLFactor();
} else if (iNewPos == "keep") {
iNewPos = jStepArea.scrollLeft();
} else {
iNewPos = iNewPos * getRTLFactor();
}
var fDoAfterScroll = function(){
updateDelimiters(oRoadMap);
if (fEndCallBack) {
var jFirstVisibleRef = RoadMapRenderer.getFirstVisibleRef(oRoadMap);
fEndCallBack(jFirstVisibleRef.attr("id"));
}
};
if (!jQuery.fx.off && !bSkipAnim) {
jStepArea.animate({scrollLeft: iNewPos}, "fast", fDoAfterScroll);
} else {
jStepArea.scrollLeft(iNewPos);
fDoAfterScroll();
}
} | javascript | function(oRoadMap, iNewPos, bSkipAnim, fEndCallBack){
var jStepArea = oRoadMap.$("steparea");
jStepArea.stop(false, true);
if (iNewPos == "next") {
iNewPos = jStepArea.scrollLeft() + oRoadMap.iStepWidth * getRTLFactor();
} else if (iNewPos == "prev") {
iNewPos = jStepArea.scrollLeft() - oRoadMap.iStepWidth * getRTLFactor();
} else if (iNewPos == "keep") {
iNewPos = jStepArea.scrollLeft();
} else {
iNewPos = iNewPos * getRTLFactor();
}
var fDoAfterScroll = function(){
updateDelimiters(oRoadMap);
if (fEndCallBack) {
var jFirstVisibleRef = RoadMapRenderer.getFirstVisibleRef(oRoadMap);
fEndCallBack(jFirstVisibleRef.attr("id"));
}
};
if (!jQuery.fx.off && !bSkipAnim) {
jStepArea.animate({scrollLeft: iNewPos}, "fast", fDoAfterScroll);
} else {
jStepArea.scrollLeft(iNewPos);
fDoAfterScroll();
}
} | [
"function",
"(",
"oRoadMap",
",",
"iNewPos",
",",
"bSkipAnim",
",",
"fEndCallBack",
")",
"{",
"var",
"jStepArea",
"=",
"oRoadMap",
".",
"$",
"(",
"\"steparea\"",
")",
";",
"jStepArea",
".",
"stop",
"(",
"false",
",",
"true",
")",
";",
"if",
"(",
"iNewPos",
"==",
"\"next\"",
")",
"{",
"iNewPos",
"=",
"jStepArea",
".",
"scrollLeft",
"(",
")",
"+",
"oRoadMap",
".",
"iStepWidth",
"*",
"getRTLFactor",
"(",
")",
";",
"}",
"else",
"if",
"(",
"iNewPos",
"==",
"\"prev\"",
")",
"{",
"iNewPos",
"=",
"jStepArea",
".",
"scrollLeft",
"(",
")",
"-",
"oRoadMap",
".",
"iStepWidth",
"*",
"getRTLFactor",
"(",
")",
";",
"}",
"else",
"if",
"(",
"iNewPos",
"==",
"\"keep\"",
")",
"{",
"iNewPos",
"=",
"jStepArea",
".",
"scrollLeft",
"(",
")",
";",
"}",
"else",
"{",
"iNewPos",
"=",
"iNewPos",
"*",
"getRTLFactor",
"(",
")",
";",
"}",
"var",
"fDoAfterScroll",
"=",
"function",
"(",
")",
"{",
"updateDelimiters",
"(",
"oRoadMap",
")",
";",
"if",
"(",
"fEndCallBack",
")",
"{",
"var",
"jFirstVisibleRef",
"=",
"RoadMapRenderer",
".",
"getFirstVisibleRef",
"(",
"oRoadMap",
")",
";",
"fEndCallBack",
"(",
"jFirstVisibleRef",
".",
"attr",
"(",
"\"id\"",
")",
")",
";",
"}",
"}",
";",
"if",
"(",
"!",
"jQuery",
".",
"fx",
".",
"off",
"&&",
"!",
"bSkipAnim",
")",
"{",
"jStepArea",
".",
"animate",
"(",
"{",
"scrollLeft",
":",
"iNewPos",
"}",
",",
"\"fast\"",
",",
"fDoAfterScroll",
")",
";",
"}",
"else",
"{",
"jStepArea",
".",
"scrollLeft",
"(",
"iNewPos",
")",
";",
"fDoAfterScroll",
"(",
")",
";",
"}",
"}"
] | Scrolls to the given position | [
"Scrolls",
"to",
"the",
"given",
"position"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L872-L901 |
|
4,762 | SAP/openui5 | src/sap.m/src/sap/m/TileContainer.js | handleAriaSize | function handleAriaSize (aVisibleTiles) {
var iTilesCount,
i,
oTile;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
iTilesCount = aVisibleTiles.length;
for (i = 0; i < iTilesCount; i++) {
oTile = aVisibleTiles[i];
if (oTile._rendered && oTile.getDomRef()) {
oTile.getDomRef().setAttribute("aria-setsize", iTilesCount);
}
}
} | javascript | function handleAriaSize (aVisibleTiles) {
var iTilesCount,
i,
oTile;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
iTilesCount = aVisibleTiles.length;
for (i = 0; i < iTilesCount; i++) {
oTile = aVisibleTiles[i];
if (oTile._rendered && oTile.getDomRef()) {
oTile.getDomRef().setAttribute("aria-setsize", iTilesCount);
}
}
} | [
"function",
"handleAriaSize",
"(",
"aVisibleTiles",
")",
"{",
"var",
"iTilesCount",
",",
"i",
",",
"oTile",
";",
"aVisibleTiles",
"=",
"aVisibleTiles",
"||",
"this",
".",
"_getVisibleTiles",
"(",
")",
";",
"iTilesCount",
"=",
"aVisibleTiles",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"iTilesCount",
";",
"i",
"++",
")",
"{",
"oTile",
"=",
"aVisibleTiles",
"[",
"i",
"]",
";",
"if",
"(",
"oTile",
".",
"_rendered",
"&&",
"oTile",
".",
"getDomRef",
"(",
")",
")",
"{",
"oTile",
".",
"getDomRef",
"(",
")",
".",
"setAttribute",
"(",
"\"aria-setsize\"",
",",
"iTilesCount",
")",
";",
"}",
"}",
"}"
] | Handles the WAI ARIA property aria-setsize after a change in the TileContainer.
@private | [
"Handles",
"the",
"WAI",
"ARIA",
"property",
"aria",
"-",
"setsize",
"after",
"a",
"change",
"in",
"the",
"TileContainer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/TileContainer.js#L2141-L2155 |
4,763 | SAP/openui5 | src/sap.m/src/sap/m/TileContainer.js | handleAriaPositionInSet | function handleAriaPositionInSet(iStartIndex, iEndIndex, aVisibleTiles) {
var i,
oTile = null;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
for (i = iStartIndex; i < iEndIndex; i++) {
oTile = aVisibleTiles[i];
if (oTile) {
oTile.$().attr('aria-posinset', this._indexOfVisibleTile(oTile, aVisibleTiles) + 1);
}
}
} | javascript | function handleAriaPositionInSet(iStartIndex, iEndIndex, aVisibleTiles) {
var i,
oTile = null;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
for (i = iStartIndex; i < iEndIndex; i++) {
oTile = aVisibleTiles[i];
if (oTile) {
oTile.$().attr('aria-posinset', this._indexOfVisibleTile(oTile, aVisibleTiles) + 1);
}
}
} | [
"function",
"handleAriaPositionInSet",
"(",
"iStartIndex",
",",
"iEndIndex",
",",
"aVisibleTiles",
")",
"{",
"var",
"i",
",",
"oTile",
"=",
"null",
";",
"aVisibleTiles",
"=",
"aVisibleTiles",
"||",
"this",
".",
"_getVisibleTiles",
"(",
")",
";",
"for",
"(",
"i",
"=",
"iStartIndex",
";",
"i",
"<",
"iEndIndex",
";",
"i",
"++",
")",
"{",
"oTile",
"=",
"aVisibleTiles",
"[",
"i",
"]",
";",
"if",
"(",
"oTile",
")",
"{",
"oTile",
".",
"$",
"(",
")",
".",
"attr",
"(",
"'aria-posinset'",
",",
"this",
".",
"_indexOfVisibleTile",
"(",
"oTile",
",",
"aVisibleTiles",
")",
"+",
"1",
")",
";",
"}",
"}",
"}"
] | Handles the WAI ARIA property aria-posinset after a change in the TileContainer.
@param {int} iStartIndex The index of the Tile to start with
@param {int} iEndIndex The index of the Tile to complete with
@param {sap.m.Tile[]} [aVisibleTiles] optional list of visible tiles in order to avoid filtering them again.
@private | [
"Handles",
"the",
"WAI",
"ARIA",
"property",
"aria",
"-",
"posinset",
"after",
"a",
"change",
"in",
"the",
"TileContainer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/TileContainer.js#L2163-L2175 |
4,764 | moleculerjs/moleculer | src/transporters/index.js | resolve | function resolve(opt) {
if (opt instanceof Transporters.Base) {
return opt;
} else if (_.isString(opt)) {
let TransporterClass = getByName(opt);
if (TransporterClass)
return new TransporterClass();
if (opt.startsWith("nats://"))
TransporterClass = Transporters.NATS;
else if (opt.startsWith("mqtt://") || opt.startsWith("mqtts://"))
TransporterClass = Transporters.MQTT;
else if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
TransporterClass = Transporters.Redis;
else if (opt.startsWith("amqp://") || opt.startsWith("amqps://"))
TransporterClass = Transporters.AMQP;
else if (opt.startsWith("kafka://"))
TransporterClass = Transporters.Kafka;
else if (opt.startsWith("stan://"))
TransporterClass = Transporters.STAN;
else if (opt.startsWith("tcp://"))
TransporterClass = Transporters.TCP;
if (TransporterClass)
return new TransporterClass(opt);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let TransporterClass = getByName(opt.type || "NATS");
if (TransporterClass)
return new TransporterClass(opt.options);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt.type}'.`, { type: opt.type });
}
return null;
} | javascript | function resolve(opt) {
if (opt instanceof Transporters.Base) {
return opt;
} else if (_.isString(opt)) {
let TransporterClass = getByName(opt);
if (TransporterClass)
return new TransporterClass();
if (opt.startsWith("nats://"))
TransporterClass = Transporters.NATS;
else if (opt.startsWith("mqtt://") || opt.startsWith("mqtts://"))
TransporterClass = Transporters.MQTT;
else if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
TransporterClass = Transporters.Redis;
else if (opt.startsWith("amqp://") || opt.startsWith("amqps://"))
TransporterClass = Transporters.AMQP;
else if (opt.startsWith("kafka://"))
TransporterClass = Transporters.Kafka;
else if (opt.startsWith("stan://"))
TransporterClass = Transporters.STAN;
else if (opt.startsWith("tcp://"))
TransporterClass = Transporters.TCP;
if (TransporterClass)
return new TransporterClass(opt);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let TransporterClass = getByName(opt.type || "NATS");
if (TransporterClass)
return new TransporterClass(opt.options);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt.type}'.`, { type: opt.type });
}
return null;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"opt",
"instanceof",
"Transporters",
".",
"Base",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"TransporterClass",
"=",
"getByName",
"(",
"opt",
")",
";",
"if",
"(",
"TransporterClass",
")",
"return",
"new",
"TransporterClass",
"(",
")",
";",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"nats://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"NATS",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"mqtt://\"",
")",
"||",
"opt",
".",
"startsWith",
"(",
"\"mqtts://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"MQTT",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"redis://\"",
")",
"||",
"opt",
".",
"startsWith",
"(",
"\"rediss://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"Redis",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"amqp://\"",
")",
"||",
"opt",
".",
"startsWith",
"(",
"\"amqps://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"AMQP",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"kafka://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"Kafka",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"stan://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"STAN",
";",
"else",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"tcp://\"",
")",
")",
"TransporterClass",
"=",
"Transporters",
".",
"TCP",
";",
"if",
"(",
"TransporterClass",
")",
"return",
"new",
"TransporterClass",
"(",
"opt",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
"}",
"`",
",",
"{",
"type",
":",
"opt",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"opt",
")",
")",
"{",
"let",
"TransporterClass",
"=",
"getByName",
"(",
"opt",
".",
"type",
"||",
"\"NATS\"",
")",
";",
"if",
"(",
"TransporterClass",
")",
"return",
"new",
"TransporterClass",
"(",
"opt",
".",
"options",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
".",
"type",
"}",
"`",
",",
"{",
"type",
":",
"opt",
".",
"type",
"}",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Resolve transporter by name
@param {object|string} opt
@returns {Transporter} | [
"Resolve",
"transporter",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/transporters/index.js#L40-L78 |
4,765 | moleculerjs/moleculer | src/cachers/index.js | resolve | function resolve(opt) {
if (opt instanceof Cachers.Base) {
return opt;
} else if (opt === true) {
return new Cachers.Memory();
} else if (_.isString(opt)) {
let CacherClass = getByName(opt);
if (CacherClass)
return new CacherClass();
if (opt.startsWith("redis://"))
CacherClass = Cachers.Redis;
if (CacherClass)
return new CacherClass(opt);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let CacherClass = getByName(opt.type || "Memory");
if (CacherClass)
return new CacherClass(opt.options);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt.type}'.`, { type: opt.type });
}
return null;
} | javascript | function resolve(opt) {
if (opt instanceof Cachers.Base) {
return opt;
} else if (opt === true) {
return new Cachers.Memory();
} else if (_.isString(opt)) {
let CacherClass = getByName(opt);
if (CacherClass)
return new CacherClass();
if (opt.startsWith("redis://"))
CacherClass = Cachers.Redis;
if (CacherClass)
return new CacherClass(opt);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let CacherClass = getByName(opt.type || "Memory");
if (CacherClass)
return new CacherClass(opt.options);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt.type}'.`, { type: opt.type });
}
return null;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"opt",
"instanceof",
"Cachers",
".",
"Base",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"opt",
"===",
"true",
")",
"{",
"return",
"new",
"Cachers",
".",
"Memory",
"(",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"CacherClass",
"=",
"getByName",
"(",
"opt",
")",
";",
"if",
"(",
"CacherClass",
")",
"return",
"new",
"CacherClass",
"(",
")",
";",
"if",
"(",
"opt",
".",
"startsWith",
"(",
"\"redis://\"",
")",
")",
"CacherClass",
"=",
"Cachers",
".",
"Redis",
";",
"if",
"(",
"CacherClass",
")",
"return",
"new",
"CacherClass",
"(",
"opt",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
"}",
"`",
",",
"{",
"type",
":",
"opt",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"opt",
")",
")",
"{",
"let",
"CacherClass",
"=",
"getByName",
"(",
"opt",
".",
"type",
"||",
"\"Memory\"",
")",
";",
"if",
"(",
"CacherClass",
")",
"return",
"new",
"CacherClass",
"(",
"opt",
".",
"options",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
".",
"type",
"}",
"`",
",",
"{",
"type",
":",
"opt",
".",
"type",
"}",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Resolve cacher by name
@param {object|string} opt
@returns {Cacher} | [
"Resolve",
"cacher",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/cachers/index.js#L35-L62 |
4,766 | moleculerjs/moleculer | src/strategies/index.js | resolve | function resolve(opt) {
if (Strategies.Base.isPrototypeOf(opt)) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "RoundRobin");
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt.type}'.`, { type: opt.type });
}
return Strategies.RoundRobin;
} | javascript | function resolve(opt) {
if (Strategies.Base.isPrototypeOf(opt)) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "RoundRobin");
if (SerializerClass)
return SerializerClass;
else
throw new BrokerOptionsError(`Invalid strategy type '${opt.type}'.`, { type: opt.type });
}
return Strategies.RoundRobin;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"Strategies",
".",
"Base",
".",
"isPrototypeOf",
"(",
"opt",
")",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"SerializerClass",
"=",
"getByName",
"(",
"opt",
")",
";",
"if",
"(",
"SerializerClass",
")",
"return",
"SerializerClass",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
"}",
"`",
",",
"{",
"type",
":",
"opt",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"opt",
")",
")",
"{",
"let",
"SerializerClass",
"=",
"getByName",
"(",
"opt",
".",
"type",
"||",
"\"RoundRobin\"",
")",
";",
"if",
"(",
"SerializerClass",
")",
"return",
"SerializerClass",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
".",
"type",
"}",
"`",
",",
"{",
"type",
":",
"opt",
".",
"type",
"}",
")",
";",
"}",
"return",
"Strategies",
".",
"RoundRobin",
";",
"}"
] | Resolve strategy by name
@param {object|string} opt
@returns {Strategy}
@memberof ServiceBroker | [
"Resolve",
"strategy",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/strategies/index.js#L37-L56 |
4,767 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketEvent | function PacketEvent(properties) {
this.groups = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketEvent(properties) {
this.groups = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketEvent",
"(",
"properties",
")",
"{",
"this",
".",
"groups",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketEvent.
@memberof packets
@interface IPacketEvent
@property {string} ver PacketEvent ver
@property {string} sender PacketEvent sender
@property {string} event PacketEvent event
@property {string|null} [data] PacketEvent data
@property {Array.<string>|null} [groups] PacketEvent groups
@property {boolean} broadcast PacketEvent broadcast
Constructs a new PacketEvent.
@memberof packets
@classdesc Represents a PacketEvent.
@implements IPacketEvent
@constructor
@param {packets.IPacketEvent=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketEvent",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L44-L50 |
4,768 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketRequest | function PacketRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketRequest",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketRequest.
@memberof packets
@interface IPacketRequest
@property {string} ver PacketRequest ver
@property {string} sender PacketRequest sender
@property {string} id PacketRequest id
@property {string} action PacketRequest action
@property {Uint8Array|null} [params] PacketRequest params
@property {string} meta PacketRequest meta
@property {number} timeout PacketRequest timeout
@property {number} level PacketRequest level
@property {boolean|null} [metrics] PacketRequest metrics
@property {string|null} [parentID] PacketRequest parentID
@property {string|null} [requestID] PacketRequest requestID
@property {boolean|null} [stream] PacketRequest stream
Constructs a new PacketRequest.
@memberof packets
@classdesc Represents a PacketRequest.
@implements IPacketRequest
@constructor
@param {packets.IPacketRequest=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketRequest",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L365-L370 |
4,769 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketResponse | function PacketResponse(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketResponse(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketResponse",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketResponse.
@memberof packets
@interface IPacketResponse
@property {string} ver PacketResponse ver
@property {string} sender PacketResponse sender
@property {string} id PacketResponse id
@property {boolean} success PacketResponse success
@property {Uint8Array|null} [data] PacketResponse data
@property {string|null} [error] PacketResponse error
@property {string} meta PacketResponse meta
@property {boolean|null} [stream] PacketResponse stream
Constructs a new PacketResponse.
@memberof packets
@classdesc Represents a PacketResponse.
@implements IPacketResponse
@constructor
@param {packets.IPacketResponse=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketResponse",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L800-L805 |
4,770 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketDiscover | function PacketDiscover(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketDiscover(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketDiscover",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketDiscover.
@memberof packets
@interface IPacketDiscover
@property {string} ver PacketDiscover ver
@property {string} sender PacketDiscover sender
Constructs a new PacketDiscover.
@memberof packets
@classdesc Represents a PacketDiscover.
@implements IPacketDiscover
@constructor
@param {packets.IPacketDiscover=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketDiscover",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1145-L1150 |
4,771 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketInfo | function PacketInfo(properties) {
this.ipList = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketInfo(properties) {
this.ipList = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketInfo",
"(",
"properties",
")",
"{",
"this",
".",
"ipList",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketInfo.
@memberof packets
@interface IPacketInfo
@property {string} ver PacketInfo ver
@property {string} sender PacketInfo sender
@property {string} services PacketInfo services
@property {string} config PacketInfo config
@property {Array.<string>|null} [ipList] PacketInfo ipList
@property {string} hostname PacketInfo hostname
@property {packets.PacketInfo.IClient} client PacketInfo client
@property {number|null} [seq] PacketInfo seq
Constructs a new PacketInfo.
@memberof packets
@classdesc Represents a PacketInfo.
@implements IPacketInfo
@constructor
@param {packets.IPacketInfo=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketInfo",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1361-L1367 |
4,772 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | Client | function Client(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function Client(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"Client",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a Client.
@memberof packets.PacketInfo
@interface IClient
@property {string} type Client type
@property {string} version Client version
@property {string} langVersion Client langVersion
Constructs a new Client.
@memberof packets.PacketInfo
@classdesc Represents a Client.
@implements IClient
@constructor
@param {packets.PacketInfo.IClient=} [properties] Properties to set | [
"Properties",
"of",
"a",
"Client",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1718-L1723 |
4,773 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketDisconnect | function PacketDisconnect(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketDisconnect(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketDisconnect",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketDisconnect.
@memberof packets
@interface IPacketDisconnect
@property {string} ver PacketDisconnect ver
@property {string} sender PacketDisconnect sender
Constructs a new PacketDisconnect.
@memberof packets
@classdesc Represents a PacketDisconnect.
@implements IPacketDisconnect
@constructor
@param {packets.IPacketDisconnect=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketDisconnect",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1952-L1957 |
4,774 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketHeartbeat | function PacketHeartbeat(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketHeartbeat(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketHeartbeat",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketHeartbeat.
@memberof packets
@interface IPacketHeartbeat
@property {string} ver PacketHeartbeat ver
@property {string} sender PacketHeartbeat sender
@property {number} cpu PacketHeartbeat cpu
Constructs a new PacketHeartbeat.
@memberof packets
@classdesc Represents a PacketHeartbeat.
@implements IPacketHeartbeat
@constructor
@param {packets.IPacketHeartbeat=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketHeartbeat",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2163-L2168 |
4,775 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketPing | function PacketPing(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketPing(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketPing",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketPing.
@memberof packets
@interface IPacketPing
@property {string} ver PacketPing ver
@property {string} sender PacketPing sender
@property {number|Long} time PacketPing time
Constructs a new PacketPing.
@memberof packets
@classdesc Represents a PacketPing.
@implements IPacketPing
@constructor
@param {packets.IPacketPing=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketPing",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2395-L2400 |
4,776 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketPong | function PacketPong(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketPong(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketPong",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketPong.
@memberof packets
@interface IPacketPong
@property {string} ver PacketPong ver
@property {string} sender PacketPong sender
@property {number|Long} time PacketPong time
@property {number|Long} arrived PacketPong arrived
Constructs a new PacketPong.
@memberof packets
@classdesc Represents a PacketPong.
@implements IPacketPong
@constructor
@param {packets.IPacketPong=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketPong",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2642-L2647 |
4,777 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketGossipHello | function PacketGossipHello(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketGossipHello(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketGossipHello",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketGossipHello.
@memberof packets
@interface IPacketGossipHello
@property {string} ver PacketGossipHello ver
@property {string} sender PacketGossipHello sender
@property {string} host PacketGossipHello host
@property {number} port PacketGossipHello port
Constructs a new PacketGossipHello.
@memberof packets
@classdesc Represents a PacketGossipHello.
@implements IPacketGossipHello
@constructor
@param {packets.IPacketGossipHello=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketGossipHello",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2924-L2929 |
4,778 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketGossipRequest | function PacketGossipRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketGossipRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketGossipRequest",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketGossipRequest.
@memberof packets
@interface IPacketGossipRequest
@property {string} ver PacketGossipRequest ver
@property {string} sender PacketGossipRequest sender
@property {string|null} [online] PacketGossipRequest online
@property {string|null} [offline] PacketGossipRequest offline
Constructs a new PacketGossipRequest.
@memberof packets
@classdesc Represents a PacketGossipRequest.
@implements IPacketGossipRequest
@constructor
@param {packets.IPacketGossipRequest=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketGossipRequest",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L3178-L3183 |
4,779 | moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketGossipResponse | function PacketGossipResponse(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketGossipResponse(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketGossipResponse",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
"if",
"(",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
"!=",
"null",
")",
"this",
"[",
"keys",
"[",
"i",
"]",
"]",
"=",
"properties",
"[",
"keys",
"[",
"i",
"]",
"]",
";",
"}"
] | Properties of a PacketGossipResponse.
@memberof packets
@interface IPacketGossipResponse
@property {string} ver PacketGossipResponse ver
@property {string} sender PacketGossipResponse sender
@property {string|null} [online] PacketGossipResponse online
@property {string|null} [offline] PacketGossipResponse offline
Constructs a new PacketGossipResponse.
@memberof packets
@classdesc Represents a PacketGossipResponse.
@implements IPacketGossipResponse
@constructor
@param {packets.IPacketGossipResponse=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketGossipResponse",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L3432-L3437 |
4,780 | moleculerjs/moleculer | src/middlewares/metrics.js | shouldMetric | function shouldMetric(ctx) {
if (ctx.broker.options.metrics) {
sampleCounter++;
if (sampleCounter * ctx.broker.options.metricsRate >= 1.0) {
sampleCounter = 0;
return true;
}
}
return false;
} | javascript | function shouldMetric(ctx) {
if (ctx.broker.options.metrics) {
sampleCounter++;
if (sampleCounter * ctx.broker.options.metricsRate >= 1.0) {
sampleCounter = 0;
return true;
}
}
return false;
} | [
"function",
"shouldMetric",
"(",
"ctx",
")",
"{",
"if",
"(",
"ctx",
".",
"broker",
".",
"options",
".",
"metrics",
")",
"{",
"sampleCounter",
"++",
";",
"if",
"(",
"sampleCounter",
"*",
"ctx",
".",
"broker",
".",
"options",
".",
"metricsRate",
">=",
"1.0",
")",
"{",
"sampleCounter",
"=",
"0",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check should metric the current context
@param {Context} ctx
@returns {Boolean}
@memberof ServiceBroker | [
"Check",
"should",
"metric",
"the",
"current",
"context"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L21-L31 |
4,781 | 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",
".",
"metrics",
")",
"{",
"const",
"payload",
"=",
"generateMetricPayload",
"(",
"ctx",
")",
";",
"ctx",
".",
"broker",
".",
"emit",
"(",
"\"metrics.trace.span.start\"",
",",
"payload",
")",
";",
"}",
"}"
] | 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 |
4,782 | moleculerjs/moleculer | src/middlewares/metrics.js | generateMetricPayload | function generateMetricPayload(ctx) {
let payload = {
id: ctx.id,
requestID: ctx.requestID,
level: ctx.level,
startTime: ctx.startTime,
remoteCall: ctx.nodeID !== ctx.broker.nodeID
};
// Process extra metrics
processExtraMetrics(ctx, payload);
if (ctx.action) {
payload.action = {
name: ctx.action.name
};
}
if (ctx.service) {
payload.service = {
name: ctx.service.name,
version: ctx.service.version
};
}
if (ctx.parentID)
payload.parent = ctx.parentID;
payload.nodeID = ctx.broker.nodeID;
if (payload.remoteCall)
payload.callerNodeID = ctx.nodeID;
return payload;
} | javascript | function generateMetricPayload(ctx) {
let payload = {
id: ctx.id,
requestID: ctx.requestID,
level: ctx.level,
startTime: ctx.startTime,
remoteCall: ctx.nodeID !== ctx.broker.nodeID
};
// Process extra metrics
processExtraMetrics(ctx, payload);
if (ctx.action) {
payload.action = {
name: ctx.action.name
};
}
if (ctx.service) {
payload.service = {
name: ctx.service.name,
version: ctx.service.version
};
}
if (ctx.parentID)
payload.parent = ctx.parentID;
payload.nodeID = ctx.broker.nodeID;
if (payload.remoteCall)
payload.callerNodeID = ctx.nodeID;
return payload;
} | [
"function",
"generateMetricPayload",
"(",
"ctx",
")",
"{",
"let",
"payload",
"=",
"{",
"id",
":",
"ctx",
".",
"id",
",",
"requestID",
":",
"ctx",
".",
"requestID",
",",
"level",
":",
"ctx",
".",
"level",
",",
"startTime",
":",
"ctx",
".",
"startTime",
",",
"remoteCall",
":",
"ctx",
".",
"nodeID",
"!==",
"ctx",
".",
"broker",
".",
"nodeID",
"}",
";",
"// Process extra metrics",
"processExtraMetrics",
"(",
"ctx",
",",
"payload",
")",
";",
"if",
"(",
"ctx",
".",
"action",
")",
"{",
"payload",
".",
"action",
"=",
"{",
"name",
":",
"ctx",
".",
"action",
".",
"name",
"}",
";",
"}",
"if",
"(",
"ctx",
".",
"service",
")",
"{",
"payload",
".",
"service",
"=",
"{",
"name",
":",
"ctx",
".",
"service",
".",
"name",
",",
"version",
":",
"ctx",
".",
"service",
".",
"version",
"}",
";",
"}",
"if",
"(",
"ctx",
".",
"parentID",
")",
"payload",
".",
"parent",
"=",
"ctx",
".",
"parentID",
";",
"payload",
".",
"nodeID",
"=",
"ctx",
".",
"broker",
".",
"nodeID",
";",
"if",
"(",
"payload",
".",
"remoteCall",
")",
"payload",
".",
"callerNodeID",
"=",
"ctx",
".",
"nodeID",
";",
"return",
"payload",
";",
"}"
] | Generate metrics payload
@param {Context} ctx
@returns {Object} | [
"Generate",
"metrics",
"payload"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L57-L89 |
4,783 | moleculerjs/moleculer | src/middlewares/metrics.js | metricFinish | function metricFinish(ctx, error) {
if (ctx.startHrTime) {
let diff = process.hrtime(ctx.startHrTime);
ctx.duration = (diff[0] * 1e3) + (diff[1] / 1e6); // milliseconds
}
ctx.stopTime = ctx.startTime + ctx.duration;
if (ctx.metrics) {
const payload = generateMetricPayload(ctx);
payload.endTime = ctx.stopTime;
payload.duration = ctx.duration;
payload.fromCache = ctx.cachedResult;
if (error) {
payload.error = {
name: error.name,
code: error.code,
type: error.type,
message: error.message
};
}
ctx.broker.emit("metrics.trace.span.finish", payload);
}
} | javascript | function metricFinish(ctx, error) {
if (ctx.startHrTime) {
let diff = process.hrtime(ctx.startHrTime);
ctx.duration = (diff[0] * 1e3) + (diff[1] / 1e6); // milliseconds
}
ctx.stopTime = ctx.startTime + ctx.duration;
if (ctx.metrics) {
const payload = generateMetricPayload(ctx);
payload.endTime = ctx.stopTime;
payload.duration = ctx.duration;
payload.fromCache = ctx.cachedResult;
if (error) {
payload.error = {
name: error.name,
code: error.code,
type: error.type,
message: error.message
};
}
ctx.broker.emit("metrics.trace.span.finish", payload);
}
} | [
"function",
"metricFinish",
"(",
"ctx",
",",
"error",
")",
"{",
"if",
"(",
"ctx",
".",
"startHrTime",
")",
"{",
"let",
"diff",
"=",
"process",
".",
"hrtime",
"(",
"ctx",
".",
"startHrTime",
")",
";",
"ctx",
".",
"duration",
"=",
"(",
"diff",
"[",
"0",
"]",
"*",
"1e3",
")",
"+",
"(",
"diff",
"[",
"1",
"]",
"/",
"1e6",
")",
";",
"// milliseconds",
"}",
"ctx",
".",
"stopTime",
"=",
"ctx",
".",
"startTime",
"+",
"ctx",
".",
"duration",
";",
"if",
"(",
"ctx",
".",
"metrics",
")",
"{",
"const",
"payload",
"=",
"generateMetricPayload",
"(",
"ctx",
")",
";",
"payload",
".",
"endTime",
"=",
"ctx",
".",
"stopTime",
";",
"payload",
".",
"duration",
"=",
"ctx",
".",
"duration",
";",
"payload",
".",
"fromCache",
"=",
"ctx",
".",
"cachedResult",
";",
"if",
"(",
"error",
")",
"{",
"payload",
".",
"error",
"=",
"{",
"name",
":",
"error",
".",
"name",
",",
"code",
":",
"error",
".",
"code",
",",
"type",
":",
"error",
".",
"type",
",",
"message",
":",
"error",
".",
"message",
"}",
";",
"}",
"ctx",
".",
"broker",
".",
"emit",
"(",
"\"metrics.trace.span.finish\"",
",",
"payload",
")",
";",
"}",
"}"
] | Stop metrics & send finish metric event.
@param {Context} ctx
@param {Error} error
@private | [
"Stop",
"metrics",
"&",
"send",
"finish",
"metric",
"event",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L99-L123 |
4,784 | moleculerjs/moleculer | src/middlewares/metrics.js | assignExtraMetrics | function assignExtraMetrics(ctx, name, payload) {
let def = ctx.action.metrics[name];
// if metrics definitions is boolean do default, metrics=true
if (def === true) {
payload[name] = ctx[name];
} else if (_.isArray(def)) {
payload[name] = _.pick(ctx[name], def);
} else if (_.isFunction(def)) {
payload[name] = def(ctx[name]);
}
} | javascript | function assignExtraMetrics(ctx, name, payload) {
let def = ctx.action.metrics[name];
// if metrics definitions is boolean do default, metrics=true
if (def === true) {
payload[name] = ctx[name];
} else if (_.isArray(def)) {
payload[name] = _.pick(ctx[name], def);
} else if (_.isFunction(def)) {
payload[name] = def(ctx[name]);
}
} | [
"function",
"assignExtraMetrics",
"(",
"ctx",
",",
"name",
",",
"payload",
")",
"{",
"let",
"def",
"=",
"ctx",
".",
"action",
".",
"metrics",
"[",
"name",
"]",
";",
"// if metrics definitions is boolean do default, metrics=true",
"if",
"(",
"def",
"===",
"true",
")",
"{",
"payload",
"[",
"name",
"]",
"=",
"ctx",
"[",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isArray",
"(",
"def",
")",
")",
"{",
"payload",
"[",
"name",
"]",
"=",
"_",
".",
"pick",
"(",
"ctx",
"[",
"name",
"]",
",",
"def",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isFunction",
"(",
"def",
")",
")",
"{",
"payload",
"[",
"name",
"]",
"=",
"def",
"(",
"ctx",
"[",
"name",
"]",
")",
";",
"}",
"}"
] | Assign extra metrics taking into account action definitions
@param {Context} ctx
@param {string} name Field of the context to be assigned.
@param {any} payload Object for assignment.
@private | [
"Assign",
"extra",
"metrics",
"taking",
"into",
"account",
"action",
"definitions"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L134-L144 |
4,785 | moleculerjs/moleculer | src/middlewares/metrics.js | processExtraMetrics | function processExtraMetrics(ctx, payload) {
// extra metrics (params and meta)
if (_.isObject(ctx.action.metrics)) {
// custom metrics def
assignExtraMetrics(ctx, "params", payload);
assignExtraMetrics(ctx, "meta", payload);
}
} | javascript | function processExtraMetrics(ctx, payload) {
// extra metrics (params and meta)
if (_.isObject(ctx.action.metrics)) {
// custom metrics def
assignExtraMetrics(ctx, "params", payload);
assignExtraMetrics(ctx, "meta", payload);
}
} | [
"function",
"processExtraMetrics",
"(",
"ctx",
",",
"payload",
")",
"{",
"// extra metrics (params and meta)",
"if",
"(",
"_",
".",
"isObject",
"(",
"ctx",
".",
"action",
".",
"metrics",
")",
")",
"{",
"// custom metrics def",
"assignExtraMetrics",
"(",
"ctx",
",",
"\"params\"",
",",
"payload",
")",
";",
"assignExtraMetrics",
"(",
"ctx",
",",
"\"meta\"",
",",
"payload",
")",
";",
"}",
"}"
] | Decide and process extra metrics taking into account action definitions
@param {Context} ctx
@param {any} payload Object for assignment.
@private | [
"Decide",
"and",
"process",
"extra",
"metrics",
"taking",
"into",
"account",
"action",
"definitions"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L154-L161 |
4,786 | moleculerjs/moleculer | src/middlewares/action-hook.js | sanitizeHooks | function sanitizeHooks(hooks, service) {
if (_.isString(hooks))
return service && _.isFunction(service[hooks]) ? service[hooks] : null;
if (Array.isArray(hooks)) {
return _.compact(hooks.map(h => {
if (_.isString(h))
return service && _.isFunction(service[h]) ? service[h] : null;
return h;
}));
}
return hooks;
} | javascript | function sanitizeHooks(hooks, service) {
if (_.isString(hooks))
return service && _.isFunction(service[hooks]) ? service[hooks] : null;
if (Array.isArray(hooks)) {
return _.compact(hooks.map(h => {
if (_.isString(h))
return service && _.isFunction(service[h]) ? service[h] : null;
return h;
}));
}
return hooks;
} | [
"function",
"sanitizeHooks",
"(",
"hooks",
",",
"service",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"hooks",
")",
")",
"return",
"service",
"&&",
"_",
".",
"isFunction",
"(",
"service",
"[",
"hooks",
"]",
")",
"?",
"service",
"[",
"hooks",
"]",
":",
"null",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"hooks",
")",
")",
"{",
"return",
"_",
".",
"compact",
"(",
"hooks",
".",
"map",
"(",
"h",
"=>",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"h",
")",
")",
"return",
"service",
"&&",
"_",
".",
"isFunction",
"(",
"service",
"[",
"h",
"]",
")",
"?",
"service",
"[",
"h",
"]",
":",
"null",
";",
"return",
"h",
";",
"}",
")",
")",
";",
"}",
"return",
"hooks",
";",
"}"
] | Sanitize hooks. If the hook is a string, convert it to Service method calling.
@param {Function|String|Array<any>} hooks
@param {Service?} service
@returns | [
"Sanitize",
"hooks",
".",
"If",
"the",
"hook",
"is",
"a",
"string",
"convert",
"it",
"to",
"Service",
"method",
"calling",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/action-hook.js#L35-L49 |
4,787 | moleculerjs/moleculer | src/serializers/index.js | resolve | function resolve(opt) {
if (opt instanceof Serializers.Base) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return new SerializerClass();
else
throw new BrokerOptionsError(`Invalid serializer type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "JSON");
if (SerializerClass)
return new SerializerClass(opt.options);
else
throw new BrokerOptionsError(`Invalid serializer type '${opt.type}'.`, { type: opt.type });
}
return new Serializers.JSON();
} | javascript | function resolve(opt) {
if (opt instanceof Serializers.Base) {
return opt;
} else if (_.isString(opt)) {
let SerializerClass = getByName(opt);
if (SerializerClass)
return new SerializerClass();
else
throw new BrokerOptionsError(`Invalid serializer type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let SerializerClass = getByName(opt.type || "JSON");
if (SerializerClass)
return new SerializerClass(opt.options);
else
throw new BrokerOptionsError(`Invalid serializer type '${opt.type}'.`, { type: opt.type });
}
return new Serializers.JSON();
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"opt",
"instanceof",
"Serializers",
".",
"Base",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"SerializerClass",
"=",
"getByName",
"(",
"opt",
")",
";",
"if",
"(",
"SerializerClass",
")",
"return",
"new",
"SerializerClass",
"(",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
"}",
"`",
",",
"{",
"type",
":",
"opt",
"}",
")",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isObject",
"(",
"opt",
")",
")",
"{",
"let",
"SerializerClass",
"=",
"getByName",
"(",
"opt",
".",
"type",
"||",
"\"JSON\"",
")",
";",
"if",
"(",
"SerializerClass",
")",
"return",
"new",
"SerializerClass",
"(",
"opt",
".",
"options",
")",
";",
"else",
"throw",
"new",
"BrokerOptionsError",
"(",
"`",
"${",
"opt",
".",
"type",
"}",
"`",
",",
"{",
"type",
":",
"opt",
".",
"type",
"}",
")",
";",
"}",
"return",
"new",
"Serializers",
".",
"JSON",
"(",
")",
";",
"}"
] | Resolve serializer by name
@param {object|string} opt
@returns {Serializer}
@memberof ServiceBroker | [
"Resolve",
"serializer",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/index.js#L39-L58 |
4,788 | moleculerjs/moleculer | src/middlewares/bulkhead.js | callNext | function callNext() {
/* istanbul ignore next */
if (queue.length == 0) return;
/* istanbul ignore next */
if (currentInFlight >= opts.concurrency) return;
const item = queue.shift();
currentInFlight++;
handler(item.ctx)
.then(res => {
currentInFlight--;
item.resolve(res);
callNext();
})
.catch(err => {
currentInFlight--;
item.reject(err);
callNext();
});
} | javascript | function callNext() {
/* istanbul ignore next */
if (queue.length == 0) return;
/* istanbul ignore next */
if (currentInFlight >= opts.concurrency) return;
const item = queue.shift();
currentInFlight++;
handler(item.ctx)
.then(res => {
currentInFlight--;
item.resolve(res);
callNext();
})
.catch(err => {
currentInFlight--;
item.reject(err);
callNext();
});
} | [
"function",
"callNext",
"(",
")",
"{",
"/* istanbul ignore next */",
"if",
"(",
"queue",
".",
"length",
"==",
"0",
")",
"return",
";",
"/* istanbul ignore next */",
"if",
"(",
"currentInFlight",
">=",
"opts",
".",
"concurrency",
")",
"return",
";",
"const",
"item",
"=",
"queue",
".",
"shift",
"(",
")",
";",
"currentInFlight",
"++",
";",
"handler",
"(",
"item",
".",
"ctx",
")",
".",
"then",
"(",
"res",
"=>",
"{",
"currentInFlight",
"--",
";",
"item",
".",
"resolve",
"(",
"res",
")",
";",
"callNext",
"(",
")",
";",
"}",
")",
".",
"catch",
"(",
"err",
"=>",
"{",
"currentInFlight",
"--",
";",
"item",
".",
"reject",
"(",
"err",
")",
";",
"callNext",
"(",
")",
";",
"}",
")",
";",
"}"
] | Call the next request from the queue | [
"Call",
"the",
"next",
"request",
"from",
"the",
"queue"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/bulkhead.js#L19-L40 |
4,789 | moleculerjs/moleculer | src/errors.js | recreateError | function recreateError(err) {
const Class = module.exports[err.name];
if (Class) {
switch(err.name) {
case "MoleculerError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerRetryableError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerServerError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerClientError": return new Class(err.message, err.code, err.type, err.data);
case "ValidationError": return new Class(err.message, err.type, err.data);
case "ServiceNotFoundError": return new Class(err.data);
case "ServiceNotAvailableError": return new Class(err.data);
case "RequestTimeoutError": return new Class(err.data);
case "RequestSkippedError": return new Class(err.data);
case "RequestRejectedError": return new Class(err.data);
case "QueueIsFullError": return new Class(err.data);
case "MaxCallLevelError": return new Class(err.data);
case "GracefulStopTimeoutError": return new Class(err.data);
case "ProtocolVersionMismatchError": return new Class(err.data);
case "InvalidPacketDataError": return new Class(err.data);
case "ServiceSchemaError":
case "BrokerOptionsError": return new Class(err.message, err.data);
}
}
} | javascript | function recreateError(err) {
const Class = module.exports[err.name];
if (Class) {
switch(err.name) {
case "MoleculerError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerRetryableError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerServerError": return new Class(err.message, err.code, err.type, err.data);
case "MoleculerClientError": return new Class(err.message, err.code, err.type, err.data);
case "ValidationError": return new Class(err.message, err.type, err.data);
case "ServiceNotFoundError": return new Class(err.data);
case "ServiceNotAvailableError": return new Class(err.data);
case "RequestTimeoutError": return new Class(err.data);
case "RequestSkippedError": return new Class(err.data);
case "RequestRejectedError": return new Class(err.data);
case "QueueIsFullError": return new Class(err.data);
case "MaxCallLevelError": return new Class(err.data);
case "GracefulStopTimeoutError": return new Class(err.data);
case "ProtocolVersionMismatchError": return new Class(err.data);
case "InvalidPacketDataError": return new Class(err.data);
case "ServiceSchemaError":
case "BrokerOptionsError": return new Class(err.message, err.data);
}
}
} | [
"function",
"recreateError",
"(",
"err",
")",
"{",
"const",
"Class",
"=",
"module",
".",
"exports",
"[",
"err",
".",
"name",
"]",
";",
"if",
"(",
"Class",
")",
"{",
"switch",
"(",
"err",
".",
"name",
")",
"{",
"case",
"\"MoleculerError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"code",
",",
"err",
".",
"type",
",",
"err",
".",
"data",
")",
";",
"case",
"\"MoleculerRetryableError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"code",
",",
"err",
".",
"type",
",",
"err",
".",
"data",
")",
";",
"case",
"\"MoleculerServerError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"code",
",",
"err",
".",
"type",
",",
"err",
".",
"data",
")",
";",
"case",
"\"MoleculerClientError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"code",
",",
"err",
".",
"type",
",",
"err",
".",
"data",
")",
";",
"case",
"\"ValidationError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"type",
",",
"err",
".",
"data",
")",
";",
"case",
"\"ServiceNotFoundError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"ServiceNotAvailableError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"RequestTimeoutError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"RequestSkippedError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"RequestRejectedError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"QueueIsFullError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"MaxCallLevelError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"GracefulStopTimeoutError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"ProtocolVersionMismatchError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"InvalidPacketDataError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"data",
")",
";",
"case",
"\"ServiceSchemaError\"",
":",
"case",
"\"BrokerOptionsError\"",
":",
"return",
"new",
"Class",
"(",
"err",
".",
"message",
",",
"err",
".",
"data",
")",
";",
"}",
"}",
"}"
] | Recreate an error from a transferred payload `err`
@param {Error} err
@returns {MoleculerError} | [
"Recreate",
"an",
"error",
"from",
"a",
"transferred",
"payload",
"err"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/errors.js#L370-L396 |
4,790 | moleculerjs/moleculer | dev/param-mixin.js | paramConverterMiddleware | function paramConverterMiddleware(handler, action) {
function convertProperties(obj, schema) {
Object.keys(schema).forEach(key => {
const s = schema[key];
const val = obj[key];
if (val == null)
return;
if (s.type == "string" && typeof val !== "string") {
obj[key] = "" + val;
} else if (s.type == "number" && typeof val !== "number") {
obj[key] = Number(val);
} else if (s.type == "boolean" && typeof val !== "boolean") {
obj[key] = String(val).toLowerCase() === "true";
} else if (s.type == "date" && !(val instanceof Date)) {
obj[key] = new Date(val);
} else if (s.type == "object")
convertProperties(val, s.props);
});
}
// Wrap a param validator
if (action.params && typeof action.params === "object") {
return function convertContextParams(ctx) {
convertProperties(ctx.params, action.params);
return handler(ctx);
};
}
return handler;
} | javascript | function paramConverterMiddleware(handler, action) {
function convertProperties(obj, schema) {
Object.keys(schema).forEach(key => {
const s = schema[key];
const val = obj[key];
if (val == null)
return;
if (s.type == "string" && typeof val !== "string") {
obj[key] = "" + val;
} else if (s.type == "number" && typeof val !== "number") {
obj[key] = Number(val);
} else if (s.type == "boolean" && typeof val !== "boolean") {
obj[key] = String(val).toLowerCase() === "true";
} else if (s.type == "date" && !(val instanceof Date)) {
obj[key] = new Date(val);
} else if (s.type == "object")
convertProperties(val, s.props);
});
}
// Wrap a param validator
if (action.params && typeof action.params === "object") {
return function convertContextParams(ctx) {
convertProperties(ctx.params, action.params);
return handler(ctx);
};
}
return handler;
} | [
"function",
"paramConverterMiddleware",
"(",
"handler",
",",
"action",
")",
"{",
"function",
"convertProperties",
"(",
"obj",
",",
"schema",
")",
"{",
"Object",
".",
"keys",
"(",
"schema",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"const",
"s",
"=",
"schema",
"[",
"key",
"]",
";",
"const",
"val",
"=",
"obj",
"[",
"key",
"]",
";",
"if",
"(",
"val",
"==",
"null",
")",
"return",
";",
"if",
"(",
"s",
".",
"type",
"==",
"\"string\"",
"&&",
"typeof",
"val",
"!==",
"\"string\"",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"\"\"",
"+",
"val",
";",
"}",
"else",
"if",
"(",
"s",
".",
"type",
"==",
"\"number\"",
"&&",
"typeof",
"val",
"!==",
"\"number\"",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"Number",
"(",
"val",
")",
";",
"}",
"else",
"if",
"(",
"s",
".",
"type",
"==",
"\"boolean\"",
"&&",
"typeof",
"val",
"!==",
"\"boolean\"",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"String",
"(",
"val",
")",
".",
"toLowerCase",
"(",
")",
"===",
"\"true\"",
";",
"}",
"else",
"if",
"(",
"s",
".",
"type",
"==",
"\"date\"",
"&&",
"!",
"(",
"val",
"instanceof",
"Date",
")",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"new",
"Date",
"(",
"val",
")",
";",
"}",
"else",
"if",
"(",
"s",
".",
"type",
"==",
"\"object\"",
")",
"convertProperties",
"(",
"val",
",",
"s",
".",
"props",
")",
";",
"}",
")",
";",
"}",
"// Wrap a param validator",
"if",
"(",
"action",
".",
"params",
"&&",
"typeof",
"action",
".",
"params",
"===",
"\"object\"",
")",
"{",
"return",
"function",
"convertContextParams",
"(",
"ctx",
")",
"{",
"convertProperties",
"(",
"ctx",
".",
"params",
",",
"action",
".",
"params",
")",
";",
"return",
"handler",
"(",
"ctx",
")",
";",
"}",
";",
"}",
"return",
"handler",
";",
"}"
] | Proof-of-Concept middleware to convert context params
@param {Function} handler
@param {Action} action | [
"Proof",
"-",
"of",
"-",
"Concept",
"middleware",
"to",
"convert",
"context",
"params"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/dev/param-mixin.js#L10-L41 |
4,791 | moleculerjs/moleculer | benchmark/suites/transporters.js | createBrokers | function createBrokers(transporter) {
let b1 = new ServiceBroker({
transporter,
//requestTimeout: 0,
logger: false,
//logLevel: "debug",
nodeID: "node-1"
});
let b2 = new ServiceBroker({
transporter,
//requestTimeout: 0,
logger: false,
//logLevel: "debug",
nodeID: "node-2"
});
b2.createService({
name: "echo",
actions: {
reply(ctx) {
return ctx.params;
}
}
});
return Promise.all([
b1.start(),
b2.start()
]).then(() => [b1, b2]);
} | javascript | function createBrokers(transporter) {
let b1 = new ServiceBroker({
transporter,
//requestTimeout: 0,
logger: false,
//logLevel: "debug",
nodeID: "node-1"
});
let b2 = new ServiceBroker({
transporter,
//requestTimeout: 0,
logger: false,
//logLevel: "debug",
nodeID: "node-2"
});
b2.createService({
name: "echo",
actions: {
reply(ctx) {
return ctx.params;
}
}
});
return Promise.all([
b1.start(),
b2.start()
]).then(() => [b1, b2]);
} | [
"function",
"createBrokers",
"(",
"transporter",
")",
"{",
"let",
"b1",
"=",
"new",
"ServiceBroker",
"(",
"{",
"transporter",
",",
"//requestTimeout: 0,",
"logger",
":",
"false",
",",
"//logLevel: \"debug\",",
"nodeID",
":",
"\"node-1\"",
"}",
")",
";",
"let",
"b2",
"=",
"new",
"ServiceBroker",
"(",
"{",
"transporter",
",",
"//requestTimeout: 0,",
"logger",
":",
"false",
",",
"//logLevel: \"debug\",",
"nodeID",
":",
"\"node-2\"",
"}",
")",
";",
"b2",
".",
"createService",
"(",
"{",
"name",
":",
"\"echo\"",
",",
"actions",
":",
"{",
"reply",
"(",
"ctx",
")",
"{",
"return",
"ctx",
".",
"params",
";",
"}",
"}",
"}",
")",
";",
"return",
"Promise",
".",
"all",
"(",
"[",
"b1",
".",
"start",
"(",
")",
",",
"b2",
".",
"start",
"(",
")",
"]",
")",
".",
"then",
"(",
"(",
")",
"=>",
"[",
"b1",
",",
"b2",
"]",
")",
";",
"}"
] | , "150", "1k", "10k", "50k", "100k", "1M"]; | [
"150",
"1k",
"10k",
"50k",
"100k",
"1M",
"]",
";"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/benchmark/suites/transporters.js#L14-L44 |
4,792 | moleculerjs/moleculer | bin/moleculer-runner.js | processFlags | function processFlags() {
Args
.option("config", "Load the configuration from a file")
.option("repl", "Start REPL mode", false)
.option(["H", "hot"], "Hot reload services if changed", false)
.option("silent", "Silent mode. No logger", false)
.option("env", "Load .env file from the current directory")
.option("envfile", "Load a specified .env file")
.option("instances", "Launch [number] instances node (load balanced)")
.option("mask", "Filemask for service loading");
flags = Args.parse(process.argv, {
mri: {
alias: {
c: "config",
r: "repl",
H: "hot",
s: "silent",
e: "env",
E: "envfile",
i: "instances",
m: "mask"
},
boolean: ["repl", "silent", "hot", "env"],
string: ["config", "envfile", "mask"]
}
});
servicePaths = Args.sub;
} | javascript | function processFlags() {
Args
.option("config", "Load the configuration from a file")
.option("repl", "Start REPL mode", false)
.option(["H", "hot"], "Hot reload services if changed", false)
.option("silent", "Silent mode. No logger", false)
.option("env", "Load .env file from the current directory")
.option("envfile", "Load a specified .env file")
.option("instances", "Launch [number] instances node (load balanced)")
.option("mask", "Filemask for service loading");
flags = Args.parse(process.argv, {
mri: {
alias: {
c: "config",
r: "repl",
H: "hot",
s: "silent",
e: "env",
E: "envfile",
i: "instances",
m: "mask"
},
boolean: ["repl", "silent", "hot", "env"],
string: ["config", "envfile", "mask"]
}
});
servicePaths = Args.sub;
} | [
"function",
"processFlags",
"(",
")",
"{",
"Args",
".",
"option",
"(",
"\"config\"",
",",
"\"Load the configuration from a file\"",
")",
".",
"option",
"(",
"\"repl\"",
",",
"\"Start REPL mode\"",
",",
"false",
")",
".",
"option",
"(",
"[",
"\"H\"",
",",
"\"hot\"",
"]",
",",
"\"Hot reload services if changed\"",
",",
"false",
")",
".",
"option",
"(",
"\"silent\"",
",",
"\"Silent mode. No logger\"",
",",
"false",
")",
".",
"option",
"(",
"\"env\"",
",",
"\"Load .env file from the current directory\"",
")",
".",
"option",
"(",
"\"envfile\"",
",",
"\"Load a specified .env file\"",
")",
".",
"option",
"(",
"\"instances\"",
",",
"\"Launch [number] instances node (load balanced)\"",
")",
".",
"option",
"(",
"\"mask\"",
",",
"\"Filemask for service loading\"",
")",
";",
"flags",
"=",
"Args",
".",
"parse",
"(",
"process",
".",
"argv",
",",
"{",
"mri",
":",
"{",
"alias",
":",
"{",
"c",
":",
"\"config\"",
",",
"r",
":",
"\"repl\"",
",",
"H",
":",
"\"hot\"",
",",
"s",
":",
"\"silent\"",
",",
"e",
":",
"\"env\"",
",",
"E",
":",
"\"envfile\"",
",",
"i",
":",
"\"instances\"",
",",
"m",
":",
"\"mask\"",
"}",
",",
"boolean",
":",
"[",
"\"repl\"",
",",
"\"silent\"",
",",
"\"hot\"",
",",
"\"env\"",
"]",
",",
"string",
":",
"[",
"\"config\"",
",",
"\"envfile\"",
",",
"\"mask\"",
"]",
"}",
"}",
")",
";",
"servicePaths",
"=",
"Args",
".",
"sub",
";",
"}"
] | Process command line arguments
Available options:
-c, --config Load the configuration from a file
-e, --env Load .env file from the current directory
-E, --envfile Load a specified .env file
-h, --help Output usage information
-H, --hot Hot reload services if changed (disabled by default)
-i, --instances Launch [number] instances node (load balanced)
-m, --mask Filemask for service loading
-r, --repl Start REPL mode (disabled by default)
-s, --silent Silent mode. No logger (disabled by default)
-v, --version Output the version number | [
"Process",
"command",
"line",
"arguments"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L67-L96 |
4,793 | moleculerjs/moleculer | bin/moleculer-runner.js | loadEnvFile | function loadEnvFile() {
if (flags.env || flags.envfile) {
try {
const dotenv = require("dotenv");
if (flags.envfile)
dotenv.config({ path: flags.envfile });
else
dotenv.config();
} catch(err) {
throw new Error("The 'dotenv' package is missing! Please install it with 'npm install dotenv --save' command.");
}
}
} | javascript | function loadEnvFile() {
if (flags.env || flags.envfile) {
try {
const dotenv = require("dotenv");
if (flags.envfile)
dotenv.config({ path: flags.envfile });
else
dotenv.config();
} catch(err) {
throw new Error("The 'dotenv' package is missing! Please install it with 'npm install dotenv --save' command.");
}
}
} | [
"function",
"loadEnvFile",
"(",
")",
"{",
"if",
"(",
"flags",
".",
"env",
"||",
"flags",
".",
"envfile",
")",
"{",
"try",
"{",
"const",
"dotenv",
"=",
"require",
"(",
"\"dotenv\"",
")",
";",
"if",
"(",
"flags",
".",
"envfile",
")",
"dotenv",
".",
"config",
"(",
"{",
"path",
":",
"flags",
".",
"envfile",
"}",
")",
";",
"else",
"dotenv",
".",
"config",
"(",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"The 'dotenv' package is missing! Please install it with 'npm install dotenv --save' command.\"",
")",
";",
"}",
"}",
"}"
] | Load environment variables from '.env' file | [
"Load",
"environment",
"variables",
"from",
".",
"env",
"file"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L101-L114 |
4,794 | moleculerjs/moleculer | bin/moleculer-runner.js | mergeOptions | function mergeOptions() {
config = _.defaultsDeep(configFile, Moleculer.ServiceBroker.defaultOptions);
if (config.logger == null && !flags.silent)
config.logger = console;
function normalizeEnvValue(value) {
if (value.toLowerCase() === "true" || value.toLowerCase() === "false") {
// Convert to boolean
value = value === "true";
} else if (!isNaN(value)) {
// Convert to number
value = Number(value);
}
return value;
}
function overwriteFromEnv(obj, prefix) {
Object.keys(obj).forEach(key => {
const envName = ((prefix ? prefix + "_" : "") + key).toUpperCase();
if (process.env[envName]) {
obj[key] = normalizeEnvValue(process.env[envName]);
}
if (_.isPlainObject(obj[key]))
obj[key] = overwriteFromEnv(obj[key], (prefix ? prefix + "_" : "") + key);
});
const moleculerPrefix = "MOL_";
Object.keys(process.env)
.filter(key => key.startsWith(moleculerPrefix))
.map(key => ({
key,
withoutPrefix: key.substr(moleculerPrefix.length)
}))
.forEach(variable => {
const dotted = variable.withoutPrefix
.split("__")
.map(level => level.toLocaleLowerCase())
.map(level =>
level
.split("_")
.map((value, index) => {
if (index == 0) {
return value;
} else {
return value[0].toUpperCase() + value.substring(1);
}
})
.join("")
)
.join(".");
obj = utils.dotSet(obj, dotted, normalizeEnvValue(process.env[variable.key]));
});
return obj;
}
config = overwriteFromEnv(config);
if (flags.silent) {
config.logger = null;
}
if (flags.hot) {
config.hotReload = true;
}
//console.log("Config", config);
} | javascript | function mergeOptions() {
config = _.defaultsDeep(configFile, Moleculer.ServiceBroker.defaultOptions);
if (config.logger == null && !flags.silent)
config.logger = console;
function normalizeEnvValue(value) {
if (value.toLowerCase() === "true" || value.toLowerCase() === "false") {
// Convert to boolean
value = value === "true";
} else if (!isNaN(value)) {
// Convert to number
value = Number(value);
}
return value;
}
function overwriteFromEnv(obj, prefix) {
Object.keys(obj).forEach(key => {
const envName = ((prefix ? prefix + "_" : "") + key).toUpperCase();
if (process.env[envName]) {
obj[key] = normalizeEnvValue(process.env[envName]);
}
if (_.isPlainObject(obj[key]))
obj[key] = overwriteFromEnv(obj[key], (prefix ? prefix + "_" : "") + key);
});
const moleculerPrefix = "MOL_";
Object.keys(process.env)
.filter(key => key.startsWith(moleculerPrefix))
.map(key => ({
key,
withoutPrefix: key.substr(moleculerPrefix.length)
}))
.forEach(variable => {
const dotted = variable.withoutPrefix
.split("__")
.map(level => level.toLocaleLowerCase())
.map(level =>
level
.split("_")
.map((value, index) => {
if (index == 0) {
return value;
} else {
return value[0].toUpperCase() + value.substring(1);
}
})
.join("")
)
.join(".");
obj = utils.dotSet(obj, dotted, normalizeEnvValue(process.env[variable.key]));
});
return obj;
}
config = overwriteFromEnv(config);
if (flags.silent) {
config.logger = null;
}
if (flags.hot) {
config.hotReload = true;
}
//console.log("Config", config);
} | [
"function",
"mergeOptions",
"(",
")",
"{",
"config",
"=",
"_",
".",
"defaultsDeep",
"(",
"configFile",
",",
"Moleculer",
".",
"ServiceBroker",
".",
"defaultOptions",
")",
";",
"if",
"(",
"config",
".",
"logger",
"==",
"null",
"&&",
"!",
"flags",
".",
"silent",
")",
"config",
".",
"logger",
"=",
"console",
";",
"function",
"normalizeEnvValue",
"(",
"value",
")",
"{",
"if",
"(",
"value",
".",
"toLowerCase",
"(",
")",
"===",
"\"true\"",
"||",
"value",
".",
"toLowerCase",
"(",
")",
"===",
"\"false\"",
")",
"{",
"// Convert to boolean",
"value",
"=",
"value",
"===",
"\"true\"",
";",
"}",
"else",
"if",
"(",
"!",
"isNaN",
"(",
"value",
")",
")",
"{",
"// Convert to number",
"value",
"=",
"Number",
"(",
"value",
")",
";",
"}",
"return",
"value",
";",
"}",
"function",
"overwriteFromEnv",
"(",
"obj",
",",
"prefix",
")",
"{",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"const",
"envName",
"=",
"(",
"(",
"prefix",
"?",
"prefix",
"+",
"\"_\"",
":",
"\"\"",
")",
"+",
"key",
")",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"process",
".",
"env",
"[",
"envName",
"]",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"normalizeEnvValue",
"(",
"process",
".",
"env",
"[",
"envName",
"]",
")",
";",
"}",
"if",
"(",
"_",
".",
"isPlainObject",
"(",
"obj",
"[",
"key",
"]",
")",
")",
"obj",
"[",
"key",
"]",
"=",
"overwriteFromEnv",
"(",
"obj",
"[",
"key",
"]",
",",
"(",
"prefix",
"?",
"prefix",
"+",
"\"_\"",
":",
"\"\"",
")",
"+",
"key",
")",
";",
"}",
")",
";",
"const",
"moleculerPrefix",
"=",
"\"MOL_\"",
";",
"Object",
".",
"keys",
"(",
"process",
".",
"env",
")",
".",
"filter",
"(",
"key",
"=>",
"key",
".",
"startsWith",
"(",
"moleculerPrefix",
")",
")",
".",
"map",
"(",
"key",
"=>",
"(",
"{",
"key",
",",
"withoutPrefix",
":",
"key",
".",
"substr",
"(",
"moleculerPrefix",
".",
"length",
")",
"}",
")",
")",
".",
"forEach",
"(",
"variable",
"=>",
"{",
"const",
"dotted",
"=",
"variable",
".",
"withoutPrefix",
".",
"split",
"(",
"\"__\"",
")",
".",
"map",
"(",
"level",
"=>",
"level",
".",
"toLocaleLowerCase",
"(",
")",
")",
".",
"map",
"(",
"level",
"=>",
"level",
".",
"split",
"(",
"\"_\"",
")",
".",
"map",
"(",
"(",
"value",
",",
"index",
")",
"=>",
"{",
"if",
"(",
"index",
"==",
"0",
")",
"{",
"return",
"value",
";",
"}",
"else",
"{",
"return",
"value",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"value",
".",
"substring",
"(",
"1",
")",
";",
"}",
"}",
")",
".",
"join",
"(",
"\"\"",
")",
")",
".",
"join",
"(",
"\".\"",
")",
";",
"obj",
"=",
"utils",
".",
"dotSet",
"(",
"obj",
",",
"dotted",
",",
"normalizeEnvValue",
"(",
"process",
".",
"env",
"[",
"variable",
".",
"key",
"]",
")",
")",
";",
"}",
")",
";",
"return",
"obj",
";",
"}",
"config",
"=",
"overwriteFromEnv",
"(",
"config",
")",
";",
"if",
"(",
"flags",
".",
"silent",
")",
"{",
"config",
".",
"logger",
"=",
"null",
";",
"}",
"if",
"(",
"flags",
".",
"hot",
")",
"{",
"config",
".",
"hotReload",
"=",
"true",
";",
"}",
"//console.log(\"Config\", config);",
"}"
] | Merge broker options
Merge options from environment variables and config file. First
load the config file if exists. After it overwrite the vars from
the environment values.
Example options:
Original broker option: `logLevel`
Config file property: `logLevel`
Env variable: `LOGLEVEL`
Original broker option: `circuitBreaker.enabled`
Config file property: `circuitBreaker.enabled`
Env variable: `CIRCUITBREAKER_ENABLED` | [
"Merge",
"broker",
"options"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L172-L243 |
4,795 | moleculerjs/moleculer | bin/moleculer-runner.js | loadServices | function loadServices() {
const fileMask = flags.mask || "**/*.service.js";
const serviceDir = process.env.SERVICEDIR || "";
const svcDir = path.isAbsolute(serviceDir) ? serviceDir : path.resolve(process.cwd(), serviceDir);
let patterns = servicePaths;
if (process.env.SERVICES || process.env.SERVICEDIR) {
if (isDirectory(svcDir) && !process.env.SERVICES) {
// Load all services from directory (from subfolders too)
broker.loadServices(svcDir, fileMask);
} else if (process.env.SERVICES) {
// Load services from env list
patterns = Array.isArray(process.env.SERVICES) ? process.env.SERVICES : process.env.SERVICES.split(",");
}
}
if (patterns.length > 0) {
let serviceFiles = [];
patterns.map(s => s.trim()).forEach(p => {
const skipping = p[0] == "!";
if (skipping)
p = p.slice(1);
if (p.startsWith("npm:")) {
// Load NPM module
loadNpmModule(p.slice(4));
} else {
let files;
const svcPath = path.isAbsolute(p) ? p : path.resolve(svcDir, p);
// Check is it a directory?
if (isDirectory(svcPath)) {
files = glob(svcPath + "/" + fileMask, { absolute: true });
if (files.length == 0)
return broker.logger.warn(chalk.yellow.bold(`There is no service files in directory: '${svcPath}'`));
} else if (isServiceFile(svcPath)) {
files = [svcPath.replace(/\\/g, "/")];
} else if (isServiceFile(svcPath + ".service.js")) {
files = [svcPath.replace(/\\/g, "/") + ".service.js"];
} else {
// Load with glob
files = glob(p, { cwd: svcDir, absolute: true });
if (files.length == 0)
broker.logger.warn(chalk.yellow.bold(`There is no matched file for pattern: '${p}'`));
}
if (files && files.length > 0) {
if (skipping)
serviceFiles = serviceFiles.filter(f => files.indexOf(f) === -1);
else
serviceFiles.push(...files);
}
}
});
_.uniq(serviceFiles).forEach(f => broker.loadService(f));
}
} | javascript | function loadServices() {
const fileMask = flags.mask || "**/*.service.js";
const serviceDir = process.env.SERVICEDIR || "";
const svcDir = path.isAbsolute(serviceDir) ? serviceDir : path.resolve(process.cwd(), serviceDir);
let patterns = servicePaths;
if (process.env.SERVICES || process.env.SERVICEDIR) {
if (isDirectory(svcDir) && !process.env.SERVICES) {
// Load all services from directory (from subfolders too)
broker.loadServices(svcDir, fileMask);
} else if (process.env.SERVICES) {
// Load services from env list
patterns = Array.isArray(process.env.SERVICES) ? process.env.SERVICES : process.env.SERVICES.split(",");
}
}
if (patterns.length > 0) {
let serviceFiles = [];
patterns.map(s => s.trim()).forEach(p => {
const skipping = p[0] == "!";
if (skipping)
p = p.slice(1);
if (p.startsWith("npm:")) {
// Load NPM module
loadNpmModule(p.slice(4));
} else {
let files;
const svcPath = path.isAbsolute(p) ? p : path.resolve(svcDir, p);
// Check is it a directory?
if (isDirectory(svcPath)) {
files = glob(svcPath + "/" + fileMask, { absolute: true });
if (files.length == 0)
return broker.logger.warn(chalk.yellow.bold(`There is no service files in directory: '${svcPath}'`));
} else if (isServiceFile(svcPath)) {
files = [svcPath.replace(/\\/g, "/")];
} else if (isServiceFile(svcPath + ".service.js")) {
files = [svcPath.replace(/\\/g, "/") + ".service.js"];
} else {
// Load with glob
files = glob(p, { cwd: svcDir, absolute: true });
if (files.length == 0)
broker.logger.warn(chalk.yellow.bold(`There is no matched file for pattern: '${p}'`));
}
if (files && files.length > 0) {
if (skipping)
serviceFiles = serviceFiles.filter(f => files.indexOf(f) === -1);
else
serviceFiles.push(...files);
}
}
});
_.uniq(serviceFiles).forEach(f => broker.loadService(f));
}
} | [
"function",
"loadServices",
"(",
")",
"{",
"const",
"fileMask",
"=",
"flags",
".",
"mask",
"||",
"\"**/*.service.js\"",
";",
"const",
"serviceDir",
"=",
"process",
".",
"env",
".",
"SERVICEDIR",
"||",
"\"\"",
";",
"const",
"svcDir",
"=",
"path",
".",
"isAbsolute",
"(",
"serviceDir",
")",
"?",
"serviceDir",
":",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"serviceDir",
")",
";",
"let",
"patterns",
"=",
"servicePaths",
";",
"if",
"(",
"process",
".",
"env",
".",
"SERVICES",
"||",
"process",
".",
"env",
".",
"SERVICEDIR",
")",
"{",
"if",
"(",
"isDirectory",
"(",
"svcDir",
")",
"&&",
"!",
"process",
".",
"env",
".",
"SERVICES",
")",
"{",
"// Load all services from directory (from subfolders too)",
"broker",
".",
"loadServices",
"(",
"svcDir",
",",
"fileMask",
")",
";",
"}",
"else",
"if",
"(",
"process",
".",
"env",
".",
"SERVICES",
")",
"{",
"// Load services from env list",
"patterns",
"=",
"Array",
".",
"isArray",
"(",
"process",
".",
"env",
".",
"SERVICES",
")",
"?",
"process",
".",
"env",
".",
"SERVICES",
":",
"process",
".",
"env",
".",
"SERVICES",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"}",
"if",
"(",
"patterns",
".",
"length",
">",
"0",
")",
"{",
"let",
"serviceFiles",
"=",
"[",
"]",
";",
"patterns",
".",
"map",
"(",
"s",
"=>",
"s",
".",
"trim",
"(",
")",
")",
".",
"forEach",
"(",
"p",
"=>",
"{",
"const",
"skipping",
"=",
"p",
"[",
"0",
"]",
"==",
"\"!\"",
";",
"if",
"(",
"skipping",
")",
"p",
"=",
"p",
".",
"slice",
"(",
"1",
")",
";",
"if",
"(",
"p",
".",
"startsWith",
"(",
"\"npm:\"",
")",
")",
"{",
"// Load NPM module",
"loadNpmModule",
"(",
"p",
".",
"slice",
"(",
"4",
")",
")",
";",
"}",
"else",
"{",
"let",
"files",
";",
"const",
"svcPath",
"=",
"path",
".",
"isAbsolute",
"(",
"p",
")",
"?",
"p",
":",
"path",
".",
"resolve",
"(",
"svcDir",
",",
"p",
")",
";",
"// Check is it a directory?",
"if",
"(",
"isDirectory",
"(",
"svcPath",
")",
")",
"{",
"files",
"=",
"glob",
"(",
"svcPath",
"+",
"\"/\"",
"+",
"fileMask",
",",
"{",
"absolute",
":",
"true",
"}",
")",
";",
"if",
"(",
"files",
".",
"length",
"==",
"0",
")",
"return",
"broker",
".",
"logger",
".",
"warn",
"(",
"chalk",
".",
"yellow",
".",
"bold",
"(",
"`",
"${",
"svcPath",
"}",
"`",
")",
")",
";",
"}",
"else",
"if",
"(",
"isServiceFile",
"(",
"svcPath",
")",
")",
"{",
"files",
"=",
"[",
"svcPath",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"\"/\"",
")",
"]",
";",
"}",
"else",
"if",
"(",
"isServiceFile",
"(",
"svcPath",
"+",
"\".service.js\"",
")",
")",
"{",
"files",
"=",
"[",
"svcPath",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"\"/\"",
")",
"+",
"\".service.js\"",
"]",
";",
"}",
"else",
"{",
"// Load with glob",
"files",
"=",
"glob",
"(",
"p",
",",
"{",
"cwd",
":",
"svcDir",
",",
"absolute",
":",
"true",
"}",
")",
";",
"if",
"(",
"files",
".",
"length",
"==",
"0",
")",
"broker",
".",
"logger",
".",
"warn",
"(",
"chalk",
".",
"yellow",
".",
"bold",
"(",
"`",
"${",
"p",
"}",
"`",
")",
")",
";",
"}",
"if",
"(",
"files",
"&&",
"files",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"skipping",
")",
"serviceFiles",
"=",
"serviceFiles",
".",
"filter",
"(",
"f",
"=>",
"files",
".",
"indexOf",
"(",
"f",
")",
"===",
"-",
"1",
")",
";",
"else",
"serviceFiles",
".",
"push",
"(",
"...",
"files",
")",
";",
"}",
"}",
"}",
")",
";",
"_",
".",
"uniq",
"(",
"serviceFiles",
")",
".",
"forEach",
"(",
"f",
"=>",
"broker",
".",
"loadService",
"(",
"f",
")",
")",
";",
"}",
"}"
] | Load services from files or directories
1. If find `SERVICEDIR` env var and not find `SERVICES` env var, load all services from the `SERVICEDIR` directory
2. If find `SERVICEDIR` env var and `SERVICES` env var, load the specified services from the `SERVICEDIR` directory
3. If not find `SERVICEDIR` env var but find `SERVICES` env var, load the specified services from the current directory
4. check the CLI arguments. If it find filename(s), load it/them
5. If find directory(ies), load it/them
Please note: you can use shorthand names for `SERVICES` env var.
E.g.
SERVICES=posts,users
It will be load the `posts.service.js` and `users.service.js` files | [
"Load",
"services",
"from",
"files",
"or",
"directories"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L292-L354 |
4,796 | moleculerjs/moleculer | bin/moleculer-runner.js | startBroker | function startBroker() {
let worker = cluster.worker;
if (worker) {
Object.assign(config, {
nodeID: (config.nodeID || utils.getNodeID()) + "-" + worker.id
});
}
// Create service broker
broker = new Moleculer.ServiceBroker(Object.assign({}, config));
loadServices();
return broker.start()
.then(() => {
if (flags.repl && (!worker || worker.id === 1))
broker.repl();
});
} | javascript | function startBroker() {
let worker = cluster.worker;
if (worker) {
Object.assign(config, {
nodeID: (config.nodeID || utils.getNodeID()) + "-" + worker.id
});
}
// Create service broker
broker = new Moleculer.ServiceBroker(Object.assign({}, config));
loadServices();
return broker.start()
.then(() => {
if (flags.repl && (!worker || worker.id === 1))
broker.repl();
});
} | [
"function",
"startBroker",
"(",
")",
"{",
"let",
"worker",
"=",
"cluster",
".",
"worker",
";",
"if",
"(",
"worker",
")",
"{",
"Object",
".",
"assign",
"(",
"config",
",",
"{",
"nodeID",
":",
"(",
"config",
".",
"nodeID",
"||",
"utils",
".",
"getNodeID",
"(",
")",
")",
"+",
"\"-\"",
"+",
"worker",
".",
"id",
"}",
")",
";",
"}",
"// Create service broker",
"broker",
"=",
"new",
"Moleculer",
".",
"ServiceBroker",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"config",
")",
")",
";",
"loadServices",
"(",
")",
";",
"return",
"broker",
".",
"start",
"(",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"flags",
".",
"repl",
"&&",
"(",
"!",
"worker",
"||",
"worker",
".",
"id",
"===",
"1",
")",
")",
"broker",
".",
"repl",
"(",
")",
";",
"}",
")",
";",
"}"
] | Start Moleculer broker | [
"Start",
"Moleculer",
"broker"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L410-L429 |
4,797 | moleculerjs/moleculer | src/middlewares/circuit-breaker.js | resetStore | function resetStore() {
if (!logger) return;
logger.debug("Reset circuit-breaker endpoint states...");
store.forEach((item, key) => {
if (item.count == 0) {
logger.debug(`Remove '${key}' endpoint state because it is not used`);
store.delete(key);
return;
}
logger.debug(`Clean '${key}' endpoint state.`);
item.count = 0;
item.failures = 0;
});
} | javascript | function resetStore() {
if (!logger) return;
logger.debug("Reset circuit-breaker endpoint states...");
store.forEach((item, key) => {
if (item.count == 0) {
logger.debug(`Remove '${key}' endpoint state because it is not used`);
store.delete(key);
return;
}
logger.debug(`Clean '${key}' endpoint state.`);
item.count = 0;
item.failures = 0;
});
} | [
"function",
"resetStore",
"(",
")",
"{",
"if",
"(",
"!",
"logger",
")",
"return",
";",
"logger",
".",
"debug",
"(",
"\"Reset circuit-breaker endpoint states...\"",
")",
";",
"store",
".",
"forEach",
"(",
"(",
"item",
",",
"key",
")",
"=>",
"{",
"if",
"(",
"item",
".",
"count",
"==",
"0",
")",
"{",
"logger",
".",
"debug",
"(",
"`",
"${",
"key",
"}",
"`",
")",
";",
"store",
".",
"delete",
"(",
"key",
")",
";",
"return",
";",
"}",
"logger",
".",
"debug",
"(",
"`",
"${",
"key",
"}",
"`",
")",
";",
"item",
".",
"count",
"=",
"0",
";",
"item",
".",
"failures",
"=",
"0",
";",
"}",
")",
";",
"}"
] | Clear endpoint state store | [
"Clear",
"endpoint",
"state",
"store"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L33-L48 |
4,798 | moleculerjs/moleculer | src/middlewares/circuit-breaker.js | getEpState | function getEpState(ep, opts) {
let item = store.get(ep.name);
if (!item) {
item = {
ep,
opts,
count: 0,
failures: 0,
state: C.CIRCUIT_CLOSE,
cbTimer: null
};
store.set(ep.name, item);
}
return item;
} | javascript | function getEpState(ep, opts) {
let item = store.get(ep.name);
if (!item) {
item = {
ep,
opts,
count: 0,
failures: 0,
state: C.CIRCUIT_CLOSE,
cbTimer: null
};
store.set(ep.name, item);
}
return item;
} | [
"function",
"getEpState",
"(",
"ep",
",",
"opts",
")",
"{",
"let",
"item",
"=",
"store",
".",
"get",
"(",
"ep",
".",
"name",
")",
";",
"if",
"(",
"!",
"item",
")",
"{",
"item",
"=",
"{",
"ep",
",",
"opts",
",",
"count",
":",
"0",
",",
"failures",
":",
"0",
",",
"state",
":",
"C",
".",
"CIRCUIT_CLOSE",
",",
"cbTimer",
":",
"null",
"}",
";",
"store",
".",
"set",
"(",
"ep",
".",
"name",
",",
"item",
")",
";",
"}",
"return",
"item",
";",
"}"
] | Get Endpoint state from store. If not exists, create it.
@param {Endpoint} ep
@param {Object} opts
@returns {Object} | [
"Get",
"Endpoint",
"state",
"from",
"store",
".",
"If",
"not",
"exists",
"create",
"it",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L57-L71 |
4,799 | moleculerjs/moleculer | src/middlewares/circuit-breaker.js | failure | function failure(item, err, ctx) {
item.count++;
item.failures++;
checkThreshold(item, ctx);
} | javascript | function failure(item, err, ctx) {
item.count++;
item.failures++;
checkThreshold(item, ctx);
} | [
"function",
"failure",
"(",
"item",
",",
"err",
",",
"ctx",
")",
"{",
"item",
".",
"count",
"++",
";",
"item",
".",
"failures",
"++",
";",
"checkThreshold",
"(",
"item",
",",
"ctx",
")",
";",
"}"
] | Increment failure counter
@param {Object} item
@param {Error} err
@param {Context} ctx | [
"Increment",
"failure",
"counter"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L80-L85 |
Subsets and Splits