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
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
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...
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...
[ "function", "_fnFindBestMatch", "(", "aValues", ",", "sBindingPath", ")", "{", "var", "iJsonModelMin", "=", "-", "1", ";", "var", "sJsonModelBestMatch", "=", "false", ";", "aValues", ".", "forEach", "(", "function", "(", "sKey", ")", "{", "var", "iCurrDest",...
Control, Internal, Application
[ "Control", "Internal", "Application" ]
8a832fca01cb1cdf8df589788e0c5723e2a33c70
https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/rules/Model.support.js#L31-L42
train
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().getVa...
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().getVa...
[ "function", "(", "vRawValue", ",", "oDetails", ")", "{", "var", "sPath", "=", "typeof", "vRawValue", "===", "\"string\"", "?", "\"/\"", "+", "oDetails", ".", "schemaChildName", "+", "\"/\"", "+", "vRawValue", ":", "oDetails", ".", "context", ".", "getPath", ...
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.$$valueAsPro...
[ "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
train
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 !==...
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 !==...
[ "function", "(", "oOperand1", ",", "oOperand2", ")", "{", "if", "(", "oOperand1", ".", "result", "!==", "\"constant\"", "&&", "oOperand1", ".", "category", "===", "\"number\"", "&&", "oOperand2", ".", "result", "===", "\"constant\"", "&&", "oOperand2", ".", ...
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
train
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 no...
javascript
function (oPathValue) { if (oPathValue.value === undefined) { return undefined; } Measurement.average(sPerformanceGetExpression, "", aPerformanceCategories); if (!bSimpleParserWarningLogged && ManagedObject.bindingParser === BindingParser.simpleParser) { Log.warning("Complex binding syntax no...
[ "function", "(", "oPathValue", ")", "{", "if", "(", "oPathValue", ".", "value", "===", "undefined", ")", "{", "return", "undefined", ";", "}", "Measurement", ".", "average", "(", "sPerformanceGetExpression", ",", "\"\"", ",", "aPerformanceCategories", ")", ";"...
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>undefi...
[ "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
train
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 =...
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 =...
[ "function", "getAllLibraries", "(", "aExcludedLibraries", ",", "bIncludeDistLayer", ")", "{", "var", "mLibraries", "=", "sap", ".", "ui", ".", "getCore", "(", ")", ".", "getLoadedLibraries", "(", ")", ",", "sInfoLibName", ",", "bNewLibrary", ",", "oInfo", ",",...
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-laye...
[ "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
train
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(aL...
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(aL...
[ "function", "getRequestedLibraries", "(", "aLibrariesToTest", ")", "{", "var", "mLibraries", "=", "sap", ".", "ui", ".", "getCore", "(", ")", ".", "getLoadedLibraries", "(", ")", ",", "bNewLibrary", ",", "i", ";", "// make sure the explicitly requested libraries are...
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
train
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....
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....
[ "function", "(", "aLibrariesToTest", ",", "aExcludedLibraries", ",", "bIncludeDistLayer", ",", "QUnit", ")", "{", "var", "mLibraries", "=", "aLibrariesToTest", "?", "getRequestedLibraries", "(", "aLibrariesToTest", ")", ":", "getAllLibraries", "(", "aExcludedLibraries",...
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
train
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(sCon...
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(sCon...
[ "function", "(", "aControls", ",", "aControlsToTest", ",", "aExcludedControls", ",", "bIncludeNonRenderable", ",", "bIncludeNonInstantiable", ",", "fnCallback", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "var", ...
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
train
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", ":...
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
train
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 namesp...
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 namesp...
[ "function", "MetadataConverter", "(", ")", "{", "this", ".", "aliases", "=", "{", "}", ";", "// maps alias -> namespace", "this", ".", "oAnnotatable", "=", "null", ";", "// the current annotatable, see function annotatable", "this", ".", "entityContainer", "=", "null"...
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
train
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 = fals...
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 = fals...
[ "function", "Measurement", "(", "sId", ",", "sInfo", ",", "iStart", ",", "iEnd", ",", "aCategories", ")", "{", "this", ".", "id", "=", "sId", ";", "this", ".", "info", "=", "sInfo", ";", "this", ".", "start", "=", "iStart", ";", "this", ".", "end",...
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 optio...
[ "Single", "Measurement", "Entry" ]
8a832fca01cb1cdf8df589788e0c5723e2a33c70
https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/Measurement.js#L37-L50
train
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...
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", "(", "sTopicId", ",", "oModel", ")", "{", "var", "oTree", "=", "this", ".", "byId", "(", "\"tree\"", ")", ",", "oData", "=", "oModel", ".", "getData", "(", ")", ";", "// Find the path to the new node, traversing the model", "var", "aTopicIds", "=",...
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
train
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 ...
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 ...
[ "function", "(", "oEvent", ")", "{", "// Update filter value", "this", ".", "_sFilter", "=", "oEvent", ".", "getParameter", "(", "\"newValue\"", ")", ".", "trim", "(", ")", ";", "if", "(", "this", ".", "_filterTimeout", ")", "{", "clearTimeout", "(", "this...
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
train
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", "(", "{", "p...
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
train
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", ".",...
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
train
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...
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...
[ "function", "(", "oPathValue", ",", "sExpectedType", ")", "{", "var", "bError", ",", "vValue", "=", "oPathValue", ".", "value", ";", "if", "(", "sExpectedType", "===", "\"array\"", ")", "{", "bError", "=", "!", "Array", ".", "isArray", "(", "vValue", ")"...
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...
[ "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
train
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 (bAddT...
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 (bAddT...
[ "function", "(", "oResult", ",", "bExpression", ",", "bWithType", ")", "{", "var", "vValue", "=", "oResult", ".", "value", ";", "function", "binding", "(", "bAddType", ")", "{", "var", "sConstraints", ",", "sResult", ";", "bAddType", "=", "bAddType", "&&",...
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 ...
[ "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
train
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; } } ...
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; } } ...
[ "function", "(", "vValue", ")", "{", "var", "sJSON", ";", "if", "(", "typeof", "vValue", "!==", "\"function\"", ")", "{", "try", "{", "sJSON", "=", "Basics", ".", "toJSON", "(", "vValue", ")", ";", "// undefined --> undefined", "// null, NaN, Infinity --> \"nu...
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
train
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 quo...
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 quo...
[ "function", "(", "vValue", ")", "{", "var", "sStringified", ",", "bEscaped", "=", "false", ",", "sResult", "=", "\"\"", ",", "i", ",", "c", ";", "sStringified", "=", "JSON", ".", "stringify", "(", "vValue", ")", ";", "if", "(", "sStringified", "===", ...
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
train
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.l...
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.l...
[ "function", "_trim", "(", "sValue", ",", "aParams", ")", "{", "var", "i", "=", "0", ",", "aTrims", "=", "aParams", ";", "if", "(", "!", "aTrims", ")", "{", "aTrims", "=", "[", "\" \"", "]", ";", "}", "while", "(", "i", "<", "aTrims", ".", "leng...
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
train
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 vCollecti...
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 vCollecti...
[ "function", "(", "vCollection", ",", "vValue", ",", "iFromIndex", ")", "{", "if", "(", "typeof", "iFromIndex", "!==", "'number'", ")", "{", "iFromIndex", "=", "0", ";", "}", "// Use native (Array.prototype.includes, String.prototype.includes) includes functions if availab...
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 i...
[ "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
train
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...
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...
[ "function", "(", "oEvent", ")", "{", "var", "oSource", "=", "oEvent", ".", "getSource", "(", ")", ";", "var", "sLayerBindingPath", "=", "oSource", ".", "getBindingContextPath", "(", ")", ".", "substring", "(", "1", ")", ";", "var", "oLayerModelData", "=", ...
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
train
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) { oL...
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) { oL...
[ "function", "refreshMapping", "(", "oLabel", ",", "bDestroy", ")", "{", "var", "sLabelId", "=", "oLabel", ".", "getId", "(", ")", ";", "var", "sOldId", "=", "oLabel", ".", "__sLabeledControl", ";", "var", "sNewId", "=", "bDestroy", "?", "null", ":", "fin...
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
train
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 ...
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 ...
[ "function", "checkLabelEnablementPreconditions", "(", "oControl", ")", "{", "if", "(", "!", "oControl", ")", "{", "throw", "new", "Error", "(", "\"sap.ui.core.LabelEnablement cannot enrich null\"", ")", ";", "}", "var", "oMetadata", "=", "oControl", ".", "getMetadat...
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
train
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", ".", "oMetaCon...
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
train
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]; }...
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]; }...
[ "function", "(", "sProperty", ",", "vGetter", ",", "aArgs", ",", "caller", ")", "{", "if", "(", "!", "vGetter", ")", "{", "return", ";", "}", "if", "(", "!", "caller", ")", "{", "caller", "=", "this", ";", "}", "Object", ".", "defineProperty", "(",...
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 vG...
[ "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
train
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(sValueP...
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(sValueP...
[ "function", "(", "sValuePath", ",", "sType", ")", "{", "var", "sPath", "=", "\"{\"", ";", "if", "(", "this", ".", "modelName", ")", "{", "sPath", "=", "sPath", "+", "\"model: '\"", "+", "this", ".", "modelName", "+", "\"',\"", ";", "}", "if", "(", ...
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
train
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 // ad...
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 // ad...
[ "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 be...
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
train
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", ...
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
train
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 ==...
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 ==...
[ "function", "getParam", "(", "mOptions", ")", "{", "var", "oParams", "=", "getParameters", "(", ")", ";", "if", "(", "mOptions", ".", "scopeName", ")", "{", "oParams", "=", "oParams", "[", "\"scopes\"", "]", "[", "mOptions", ".", "scopeName", "]", ";", ...
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 ...
[ "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
train
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 (fnErrorHan...
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 (fnErrorHan...
[ "function", "(", "bRestoreFocus", ",", "oEvent", ")", "{", "if", "(", "!", "this", ".", "_bBlurOrKeyDownStarted", ")", "{", "this", ".", "_bBlurOrKeyDownStarted", "=", "true", ";", "if", "(", "oEvent", ")", "{", "RenameHandler", ".", "_preventDefault", ".", ...
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
train
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
train
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.ad...
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.ad...
[ "function", "(", "rm", ",", "oRoadMap", ",", "bStart", ")", "{", "var", "sType", "=", "bStart", "?", "\"Start\"", ":", "\"End\"", ";", "rm", ".", "write", "(", "\"<div\"", ")", ";", "rm", ".", "writeAttribute", "(", "\"id\"", ",", "oRoadMap", ".", "g...
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
train
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.__ste...
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.__ste...
[ "function", "(", "rm", ",", "oRoadMap", ",", "oStep", ",", "aAdditionalClasses", ",", "fAddAdditionalBoxContent", ",", "sId", ")", "{", "rm", ".", "write", "(", "\"<li\"", ")", ";", "if", "(", "sId", ")", "{", "//Write the given Id if available, otherwise use wr...
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
train
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", "(", ")", ".", "get...
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
train
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-di...
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-di...
[ "function", "(", "rm", ",", "oRoadMap", ",", "oStep", ",", "bIsExpandable", ")", "{", "if", "(", "!", "sap", ".", "ui", ".", "getCore", "(", ")", ".", "getConfiguration", "(", ")", ".", "getAccessibility", "(", ")", ")", "{", "return", ";", "}", "r...
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
train
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", ...
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
train
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++) { ...
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++) { ...
[ "function", "(", "oStep", ")", "{", "var", "bIsTopLevel", "=", "oStep", ".", "getParent", "(", ")", "instanceof", "sap", ".", "ui", ".", "commons", ".", "RoadMap", ";", "var", "iIdx", "=", "oStep", ".", "getParent", "(", ")", "[", "bIsTopLevel", "?", ...
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
train
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", "?",...
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
train
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>"); }...
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>"); }...
[ "function", "(", "rm", ",", "oRoadMap", ",", "oStep", ")", "{", "var", "fCreateIcon", "=", "function", "(", "rm", ",", "oRoadMap", ",", "sId", ",", "sIcon", ",", "sAdditonalClass", ")", "{", "rm", ".", "write", "(", "\"<div\"", ")", ";", "rm", ".", ...
Writes the step HTML of the expandable step and its children into the rendermanger
[ "Writes", "the", "step", "HTML", "of", "the", "expandable", "step", "and", "its", "children", "into", "the", "rendermanger" ]
8a832fca01cb1cdf8df589788e0c5723e2a33c70
https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L718-L755
train
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 * iScro...
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 * iScro...
[ "function", "(", "oRoadMap", ")", "{", "var", "iRTLFactor", "=", "getRTLFactor", "(", ")", ";", "var", "jStepArea", "=", "oRoadMap", ".", "$", "(", "\"steparea\"", ")", ";", "var", "iScrollLeft", "=", "getScrollLeft", "(", "jStepArea", ")", ";", "var", "...
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
train
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", "(", ")", ")"...
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
train
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.iStepWid...
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.iStepWid...
[ "function", "(", "oRoadMap", ",", "iNewPos", ",", "bSkipAnim", ",", "fEndCallBack", ")", "{", "var", "jStepArea", "=", "oRoadMap", ".", "$", "(", "\"steparea\"", ")", ";", "jStepArea", ".", "stop", "(", "false", ",", "true", ")", ";", "if", "(", "iNewP...
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
train
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().setAttr...
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().setAttr...
[ "function", "handleAriaSize", "(", "aVisibleTiles", ")", "{", "var", "iTilesCount", ",", "i", ",", "oTile", ";", "aVisibleTiles", "=", "aVisibleTiles", "||", "this", ".", "_getVisibleTiles", "(", ")", ";", "iTilesCount", "=", "aVisibleTiles", ".", "length", ";...
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
train
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,...
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,...
[ "function", "handleAriaPositionInSet", "(", "iStartIndex", ",", "iEndIndex", ",", "aVisibleTiles", ")", "{", "var", "i", ",", "oTile", "=", "null", ";", "aVisibleTiles", "=", "aVisibleTiles", "||", "this", ".", "_getVisibleTiles", "(", ")", ";", "for", "(", ...
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. @privat...
[ "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
train
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://")...
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://")...
[ "function", "resolve", "(", "opt", ")", "{", "if", "(", "opt", "instanceof", "Transporters", ".", "Base", ")", "{", "return", "opt", ";", "}", "else", "if", "(", "_", ".", "isString", "(", "opt", ")", ")", "{", "let", "TransporterClass", "=", "getByN...
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
train
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...
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...
[ "function", "resolve", "(", "opt", ")", "{", "if", "(", "opt", "instanceof", "Cachers", ".", "Base", ")", "{", "return", "opt", ";", "}", "else", "if", "(", "opt", "===", "true", ")", "{", "return", "new", "Cachers", ".", "Memory", "(", ")", ";", ...
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
train
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)...
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)...
[ "function", "resolve", "(", "opt", ")", "{", "if", "(", "Strategies", ".", "Base", ".", "isPrototypeOf", "(", "opt", ")", ")", "{", "return", "opt", ";", "}", "else", "if", "(", "_", ".", "isString", "(", "opt", ")", ")", "{", "let", "SerializerCla...
Resolve strategy by name @param {object|string} opt @returns {Strategy} @memberof ServiceBroker
[ "Resolve", "strategy", "by", "name" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/strategies/index.js#L37-L56
train
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", "<", "ke...
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 {boo...
[ "Properties", "of", "a", "PacketEvent", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L44-L50
train
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", ")", ...
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 {st...
[ "Properties", "of", "a", "PacketRequest", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L365-L370
train
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", ")", ...
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 @proper...
[ "Properties", "of", "a", "PacketResponse", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L800-L805
train
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", ")", ...
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.IPa...
[ "Properties", "of", "a", "PacketDiscover", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1145-L1150
train
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", "<", "key...
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}...
[ "Properties", "of", "a", "PacketInfo", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1361-L1367
train
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 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...
[ "Properties", "of", "a", "Client", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1718-L1723
train
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", ")",...
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 @para...
[ "Properties", "of", "a", "PacketDisconnect", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1952-L1957
train
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", ")", ...
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...
[ "Properties", "of", "a", "PacketHeartbeat", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2163-L2168
train
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 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 @p...
[ "Properties", "of", "a", "PacketPing", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2395-L2400
train
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 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 ...
[ "Properties", "of", "a", "PacketPong", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2642-L2647
train
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", ")"...
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...
[ "Properties", "of", "a", "PacketGossipHello", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L2924-L2929
train
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", "...
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 Construct...
[ "Properties", "of", "a", "PacketGossipRequest", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L3178-L3183
train
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", ...
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 Con...
[ "Properties", "of", "a", "PacketGossipResponse", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L3432-L3437
train
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...
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
train
moleculerjs/moleculer
src/middlewares/metrics.js
metricStart
function metricStart(ctx) { ctx.startTime = Date.now(); ctx.startHrTime = process.hrtime(); ctx.duration = 0; if (ctx.metrics) { const payload = generateMetricPayload(ctx); ctx.broker.emit("metrics.trace.span.start", payload); } }
javascript
function metricStart(ctx) { ctx.startTime = Date.now(); ctx.startHrTime = process.hrtime(); ctx.duration = 0; if (ctx.metrics) { const payload = generateMetricPayload(ctx); ctx.broker.emit("metrics.trace.span.start", payload); } }
[ "function", "metricStart", "(", "ctx", ")", "{", "ctx", ".", "startTime", "=", "Date", ".", "now", "(", ")", ";", "ctx", ".", "startHrTime", "=", "process", ".", "hrtime", "(", ")", ";", "ctx", ".", "duration", "=", "0", ";", "if", "(", "ctx", "....
Start metrics & send metric event. @param {Context} ctx @private
[ "Start", "metrics", "&", "send", "metric", "event", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L40-L49
train
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....
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....
[ "function", "generateMetricPayload", "(", "ctx", ")", "{", "let", "payload", "=", "{", "id", ":", "ctx", ".", "id", ",", "requestID", ":", "ctx", ".", "requestID", ",", "level", ":", "ctx", ".", "level", ",", "startTime", ":", "ctx", ".", "startTime", ...
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
train
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.stopTi...
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.stopTi...
[ "function", "metricFinish", "(", "ctx", ",", "error", ")", "{", "if", "(", "ctx", ".", "startHrTime", ")", "{", "let", "diff", "=", "process", ".", "hrtime", "(", "ctx", ".", "startHrTime", ")", ";", "ctx", ".", "duration", "=", "(", "diff", "[", "...
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
train
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]...
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]...
[ "function", "assignExtraMetrics", "(", "ctx", ",", "name", ",", "payload", ")", "{", "let", "def", "=", "ctx", ".", "action", ".", "metrics", "[", "name", "]", ";", "// if metrics definitions is boolean do default, metrics=true", "if", "(", "def", "===", "true",...
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
train
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", "...
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
train
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; })); } ...
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; })); } ...
[ "function", "sanitizeHooks", "(", "hooks", ",", "service", ")", "{", "if", "(", "_", ".", "isString", "(", "hooks", ")", ")", "return", "service", "&&", "_", ".", "isFunction", "(", "service", "[", "hooks", "]", ")", "?", "service", "[", "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
train
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...
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...
[ "function", "resolve", "(", "opt", ")", "{", "if", "(", "opt", "instanceof", "Serializers", ".", "Base", ")", "{", "return", "opt", ";", "}", "else", "if", "(", "_", ".", "isString", "(", "opt", ")", ")", "{", "let", "SerializerClass", "=", "getByNam...
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
train
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); cal...
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); cal...
[ "function", "callNext", "(", ")", "{", "/* istanbul ignore next */", "if", "(", "queue", ".", "length", "==", "0", ")", "return", ";", "/* istanbul ignore next */", "if", "(", "currentInFlight", ">=", "opts", ".", "concurrency", ")", "return", ";", "const", "i...
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
train
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":...
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":...
[ "function", "recreateError", "(", "err", ")", "{", "const", "Class", "=", "module", ".", "exports", "[", "err", ".", "name", "]", ";", "if", "(", "Class", ")", "{", "switch", "(", "err", ".", "name", ")", "{", "case", "\"MoleculerError\"", ":", "retu...
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
train
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.typ...
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.typ...
[ "function", "paramConverterMiddleware", "(", "handler", ",", "action", ")", "{", "function", "convertProperties", "(", "obj", ",", "schema", ")", "{", "Object", ".", "keys", "(", "schema", ")", ".", "forEach", "(", "key", "=>", "{", "const", "s", "=", "s...
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
train
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.createServic...
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.createServic...
[ "function", "createBrokers", "(", "transporter", ")", "{", "let", "b1", "=", "new", "ServiceBroker", "(", "{", "transporter", ",", "//requestTimeout: 0,", "logger", ":", "false", ",", "//logLevel: \"debug\",", "nodeID", ":", "\"node-1\"", "}", ")", ";", "let", ...
, "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
train
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") .opt...
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") .opt...
[ "function", "processFlags", "(", ")", "{", "Args", ".", "option", "(", "\"config\"", ",", "\"Load the configuration from a file\"", ")", ".", "option", "(", "\"repl\"", ",", "\"Start REPL mode\"", ",", "false", ")", ".", "option", "(", "[", "\"H\"", ",", "\"ho...
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...
[ "Process", "command", "line", "arguments" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L67-L96
train
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...
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...
[ "function", "loadEnvFile", "(", ")", "{", "if", "(", "flags", ".", "env", "||", "flags", ".", "envfile", ")", "{", "try", "{", "const", "dotenv", "=", "require", "(", "\"dotenv\"", ")", ";", "if", "(", "flags", ".", "envfile", ")", "dotenv", ".", "...
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
train
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 va...
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 va...
[ "function", "mergeOptions", "(", ")", "{", "config", "=", "_", ".", "defaultsDeep", "(", "configFile", ",", "Moleculer", ".", "ServiceBroker", ".", "defaultOptions", ")", ";", "if", "(", "config", ".", "logger", "==", "null", "&&", "!", "flags", ".", "si...
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: `circ...
[ "Merge", "broker", "options" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L172-L243
train
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...
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...
[ "function", "loadServices", "(", ")", "{", "const", "fileMask", "=", "flags", ".", "mask", "||", "\"**/*.service.js\"", ";", "const", "serviceDir", "=", "process", ".", "env", ".", "SERVICEDIR", "||", "\"\"", ";", "const", "svcDir", "=", "path", ".", "isAb...
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 `SE...
[ "Load", "services", "from", "files", "or", "directories" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L292-L354
train
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(() =>...
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(() =>...
[ "function", "startBroker", "(", ")", "{", "let", "worker", "=", "cluster", ".", "worker", ";", "if", "(", "worker", ")", "{", "Object", ".", "assign", "(", "config", ",", "{", "nodeID", ":", "(", "config", ".", "nodeID", "||", "utils", ".", "getNodeI...
Start Moleculer broker
[ "Start", "Moleculer", "broker" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/bin/moleculer-runner.js#L410-L429
train
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}' endpo...
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}' endpo...
[ "function", "resetStore", "(", ")", "{", "if", "(", "!", "logger", ")", "return", ";", "logger", ".", "debug", "(", "\"Reset circuit-breaker endpoint states...\"", ")", ";", "store", ".", "forEach", "(", "(", "item", ",", "key", ")", "=>", "{", "if", "("...
Clear endpoint state store
[ "Clear", "endpoint", "state", "store" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L33-L48
train
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", ",", "failur...
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
train
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
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
success
function success(item, ctx) { item.count++; if (item.state === C.CIRCUIT_HALF_OPEN_WAIT) circuitClose(item, ctx); else checkThreshold(item, ctx); }
javascript
function success(item, ctx) { item.count++; if (item.state === C.CIRCUIT_HALF_OPEN_WAIT) circuitClose(item, ctx); else checkThreshold(item, ctx); }
[ "function", "success", "(", "item", ",", "ctx", ")", "{", "item", ".", "count", "++", ";", "if", "(", "item", ".", "state", "===", "C", ".", "CIRCUIT_HALF_OPEN_WAIT", ")", "circuitClose", "(", "item", ",", "ctx", ")", ";", "else", "checkThreshold", "("...
Increment request counter and switch CB to CLOSE if it is on HALF_OPEN_WAIT. @param {Object} item @param {Context} ctx
[ "Increment", "request", "counter", "and", "switch", "CB", "to", "CLOSE", "if", "it", "is", "on", "HALF_OPEN_WAIT", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L93-L100
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
checkThreshold
function checkThreshold(item, ctx) { if (item.count >= item.opts.minRequestCount) { const rate = item.failures / item.count; if (rate >= item.opts.threshold) trip(item, ctx); } }
javascript
function checkThreshold(item, ctx) { if (item.count >= item.opts.minRequestCount) { const rate = item.failures / item.count; if (rate >= item.opts.threshold) trip(item, ctx); } }
[ "function", "checkThreshold", "(", "item", ",", "ctx", ")", "{", "if", "(", "item", ".", "count", ">=", "item", ".", "opts", ".", "minRequestCount", ")", "{", "const", "rate", "=", "item", ".", "failures", "/", "item", ".", "count", ";", "if", "(", ...
Check circuit-breaker failure threshold of Endpoint @param {Object} item @param {Context} ctx
[ "Check", "circuit", "-", "breaker", "failure", "threshold", "of", "Endpoint" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L108-L114
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
trip
function trip(item, ctx) { item.state = C.CIRCUIT_OPEN; item.ep.state = false; if (item.cbTimer) { clearTimeout(item.cbTimer); item.cbTimer = null; } item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime); item.cbTimer.unref(); const rate = item.count > 0 ? item.failures / i...
javascript
function trip(item, ctx) { item.state = C.CIRCUIT_OPEN; item.ep.state = false; if (item.cbTimer) { clearTimeout(item.cbTimer); item.cbTimer = null; } item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime); item.cbTimer.unref(); const rate = item.count > 0 ? item.failures / i...
[ "function", "trip", "(", "item", ",", "ctx", ")", "{", "item", ".", "state", "=", "C", ".", "CIRCUIT_OPEN", ";", "item", ".", "ep", ".", "state", "=", "false", ";", "if", "(", "item", ".", "cbTimer", ")", "{", "clearTimeout", "(", "item", ".", "c...
Trip the circuit-breaker, change the status to open @param {Object} item @param {Context} ctx
[ "Trip", "the", "circuit", "-", "breaker", "change", "the", "status", "to", "open" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L122-L137
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
halfOpen
function halfOpen(item) { item.state = C.CIRCUIT_HALF_OPEN; item.ep.state = true; logger.debug(`Circuit breaker has been half-opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name }); broker.broadcast("$circuit-breaker.half-opened", { nodeID: item.ep.id, action: item.ep.act...
javascript
function halfOpen(item) { item.state = C.CIRCUIT_HALF_OPEN; item.ep.state = true; logger.debug(`Circuit breaker has been half-opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name }); broker.broadcast("$circuit-breaker.half-opened", { nodeID: item.ep.id, action: item.ep.act...
[ "function", "halfOpen", "(", "item", ")", "{", "item", ".", "state", "=", "C", ".", "CIRCUIT_HALF_OPEN", ";", "item", ".", "ep", ".", "state", "=", "true", ";", "logger", ".", "debug", "(", "`", "${", "item", ".", "ep", ".", "name", "}", "`", ","...
Change circuit-breaker status to half-open @param {Object} item @param {Context} ctx
[ "Change", "circuit", "-", "breaker", "status", "to", "half", "-", "open" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L145-L157
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
halfOpenWait
function halfOpenWait(item, ctx) { item.state = C.CIRCUIT_HALF_OPEN_WAIT; item.ep.state = false; // Anti-stick protection item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime); item.cbTimer.unref(); }
javascript
function halfOpenWait(item, ctx) { item.state = C.CIRCUIT_HALF_OPEN_WAIT; item.ep.state = false; // Anti-stick protection item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime); item.cbTimer.unref(); }
[ "function", "halfOpenWait", "(", "item", ",", "ctx", ")", "{", "item", ".", "state", "=", "C", ".", "CIRCUIT_HALF_OPEN_WAIT", ";", "item", ".", "ep", ".", "state", "=", "false", ";", "// Anti-stick protection", "item", ".", "cbTimer", "=", "setTimeout", "(...
Change circuit-breaker status to half-open waiting. First request is invoked after half-open. @param {Object} item @param {Context} ctx
[ "Change", "circuit", "-", "breaker", "status", "to", "half", "-", "open", "waiting", ".", "First", "request", "is", "invoked", "after", "half", "-", "open", "." ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L165-L172
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
circuitClose
function circuitClose(item) { item.state = C.CIRCUIT_CLOSE; item.ep.state = true; item.failures = 0; item.count = 0; logger.debug(`Circuit breaker has been closed on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name }); broker.broadcast("$circuit-breaker.closed", { nodeID: it...
javascript
function circuitClose(item) { item.state = C.CIRCUIT_CLOSE; item.ep.state = true; item.failures = 0; item.count = 0; logger.debug(`Circuit breaker has been closed on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name }); broker.broadcast("$circuit-breaker.closed", { nodeID: it...
[ "function", "circuitClose", "(", "item", ")", "{", "item", ".", "state", "=", "C", ".", "CIRCUIT_CLOSE", ";", "item", ".", "ep", ".", "state", "=", "true", ";", "item", ".", "failures", "=", "0", ";", "item", ".", "count", "=", "0", ";", "logger", ...
Change circuit-breaker status to close @param {Object} item @param {Context} ctx
[ "Change", "circuit", "-", "breaker", "status", "to", "close" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L180-L194
train
moleculerjs/moleculer
src/middlewares/circuit-breaker.js
wrapCBMiddleware
function wrapCBMiddleware(handler, action) { // Merge action option and broker options const opts = Object.assign({}, this.options.circuitBreaker || {}, action.circuitBreaker || {}); if (opts.enabled) { return function circuitBreakerMiddleware(ctx) { // Get endpoint state item const ep = ctx.endpoint; ...
javascript
function wrapCBMiddleware(handler, action) { // Merge action option and broker options const opts = Object.assign({}, this.options.circuitBreaker || {}, action.circuitBreaker || {}); if (opts.enabled) { return function circuitBreakerMiddleware(ctx) { // Get endpoint state item const ep = ctx.endpoint; ...
[ "function", "wrapCBMiddleware", "(", "handler", ",", "action", ")", "{", "// Merge action option and broker options", "const", "opts", "=", "Object", ".", "assign", "(", "{", "}", ",", "this", ".", "options", ".", "circuitBreaker", "||", "{", "}", ",", "action...
Middleware wrapper function @param {Function} handler @param {Action} action @returns {Function}
[ "Middleware", "wrapper", "function" ]
f95aadc2d61b0d0e3c643a43c3ed28bca6425cde
https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L203-L238
train
postmanlabs/newman
lib/run/options.js
function (value, options, callback) { /** * The post collection load handler. * * @param {?Error} err - An Error instance / null, passed from the collection loader. * @param {Object} collection - The collection / raw JSON object, passed from the collection...
javascript
function (value, options, callback) { /** * The post collection load handler. * * @param {?Error} err - An Error instance / null, passed from the collection loader. * @param {Object} collection - The collection / raw JSON object, passed from the collection...
[ "function", "(", "value", ",", "options", ",", "callback", ")", "{", "/**\n * The post collection load handler.\n *\n * @param {?Error} err - An Error instance / null, passed from the collection loader.\n * @param {Object} collection - The collection...
The collection file load helper for the current run. @param {Object|String} value - The collection, specified as a JSON object, or the path to it's file. @param {Object} options - The set of wrapped options. @param {Function} callback - The callback function invoked to mark the end of the collection load routine. @ret...
[ "The", "collection", "file", "load", "helper", "for", "the", "current", "run", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L172-L216
train
postmanlabs/newman
lib/run/options.js
function (err, collection) { if (err) { return callback(err); } // ensure that the collection option is present before starting a run if (!_.isObject(collection)) { return callback(new Error(COLLECTION_LOAD_ERROR_ME...
javascript
function (err, collection) { if (err) { return callback(err); } // ensure that the collection option is present before starting a run if (!_.isObject(collection)) { return callback(new Error(COLLECTION_LOAD_ERROR_ME...
[ "function", "(", "err", ",", "collection", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "// ensure that the collection option is present before starting a run", "if", "(", "!", "_", ".", "isObject", "(", "collection", ...
The post collection load handler. @param {?Error} err - An Error instance / null, passed from the collection loader. @param {Object} collection - The collection / raw JSON object, passed from the collection loader. @returns {*}
[ "The", "post", "collection", "load", "handler", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L180-L199
train
postmanlabs/newman
lib/run/options.js
function (value, options, callback) { if (!value.length) { return callback(); // avoids empty string or array } if (Array.isArray(value) && value.length === 1) { return callback(null, value[0]); // avoids using multipleIdOrName strategy for a single i...
javascript
function (value, options, callback) { if (!value.length) { return callback(); // avoids empty string or array } if (Array.isArray(value) && value.length === 1) { return callback(null, value[0]); // avoids using multipleIdOrName strategy for a single i...
[ "function", "(", "value", ",", "options", ",", "callback", ")", "{", "if", "(", "!", "value", ".", "length", ")", "{", "return", "callback", "(", ")", ";", "// avoids empty string or array", "}", "if", "(", "Array", ".", "isArray", "(", "value", ")", "...
Helper function to sanitize folder option. @param {String[]|String} value - The list of folders to execute @param {Object} options - The set of wrapped options. @param {Function} callback - The callback function invoked to mark the end of the folder load routine. @returns {*}
[ "Helper", "function", "to", "sanitize", "folder", "option", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L240-L250
train
postmanlabs/newman
lib/run/options.js
function (location, options, callback) { if (_.isArray(location)) { return callback(null, location); } util.fetch(location, function (err, data) { if (err) { return callback(err); } // Try loading as a JSON, fall-back to CSV. ...
javascript
function (location, options, callback) { if (_.isArray(location)) { return callback(null, location); } util.fetch(location, function (err, data) { if (err) { return callback(err); } // Try loading as a JSON, fall-back to CSV. ...
[ "function", "(", "location", ",", "options", ",", "callback", ")", "{", "if", "(", "_", ".", "isArray", "(", "location", ")", ")", "{", "return", "callback", "(", "null", ",", "location", ")", ";", "}", "util", ".", "fetch", "(", "location", ",", "...
The iterationData loader module, with support for JSON or CSV data files. @param {String|Object[]} location - The path to the iteration data file for the current collection run, or the array of iteration data objects. @param {Object} options - The set of wrapped options. @param {Function} callback - The function invok...
[ "The", "iterationData", "loader", "module", "with", "support", "for", "JSON", "or", "CSV", "data", "files", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L261-L300
train
postmanlabs/newman
npm/publish-docs.js
function (next) { console.info(colors.yellow.bold('Generating and publishing documentation for postman-collection')); try { // go to the out directory and create a *new* Git repo cd('out/docs'); exec('git init'); // inside this gi...
javascript
function (next) { console.info(colors.yellow.bold('Generating and publishing documentation for postman-collection')); try { // go to the out directory and create a *new* Git repo cd('out/docs'); exec('git init'); // inside this gi...
[ "function", "(", "next", ")", "{", "console", ".", "info", "(", "colors", ".", "yellow", ".", "bold", "(", "'Generating and publishing documentation for postman-collection'", ")", ")", ";", "try", "{", "// go to the out directory and create a *new* Git repo", "cd", "(",...
Publish the documentation built in the previous step of the pipeline. @param {Function} next - The callback function invoked to mark the completion of the publish routine, either way. @returns {*}
[ "Publish", "the", "documentation", "built", "in", "the", "previous", "step", "of", "the", "pipeline", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/npm/publish-docs.js#L20-L51
train
postmanlabs/newman
lib/reporters/cli/cli-utils.js
function (color) { return (color === 'off') || (color !== 'on') && (Boolean(process.env.CI) || !process.stdout.isTTY); // eslint-disable-line no-process-env }
javascript
function (color) { return (color === 'off') || (color !== 'on') && (Boolean(process.env.CI) || !process.stdout.isTTY); // eslint-disable-line no-process-env }
[ "function", "(", "color", ")", "{", "return", "(", "color", "===", "'off'", ")", "||", "(", "color", "!==", "'on'", ")", "&&", "(", "Boolean", "(", "process", ".", "env", ".", "CI", ")", "||", "!", "process", ".", "stdout", ".", "isTTY", ")", ";"...
A CLI utility helper method that checks for the non TTY compliance of the current run environment. color: | noTTY: 'on' -> false 'off' -> true otherwise -> Based on CI or isTTY. @param {String} color - A flag to indicate usage of the --color option. @returns {Boolean} - A boolean value depicting the res...
[ "A", "CLI", "utility", "helper", "method", "that", "checks", "for", "the", "non", "TTY", "compliance", "of", "the", "current", "run", "environment", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L101-L104
train
postmanlabs/newman
lib/reporters/cli/cli-utils.js
function (runOptions) { var dimension = cliUtils.dimension(), options = { depth: 25, maxArrayLength: 100, // only supported in Node v6.1.0 and up: https://github.com/nodejs/node/pull/6334 colors: !cliUtils.noTTY(runOptions.color), //...
javascript
function (runOptions) { var dimension = cliUtils.dimension(), options = { depth: 25, maxArrayLength: 100, // only supported in Node v6.1.0 and up: https://github.com/nodejs/node/pull/6334 colors: !cliUtils.noTTY(runOptions.color), //...
[ "function", "(", "runOptions", ")", "{", "var", "dimension", "=", "cliUtils", ".", "dimension", "(", ")", ",", "options", "=", "{", "depth", ":", "25", ",", "maxArrayLength", ":", "100", ",", "// only supported in Node v6.1.0 and up: https://github.com/nodejs/node/p...
A CLI utility helper method that generates a color inspector function for CLI reports. @param {Object} runOptions - The set of run options acquired via the runner. @returns {Function} - A function to perform utils.inspect, given a sample item, under pre-existing options.
[ "A", "CLI", "utility", "helper", "method", "that", "generates", "a", "color", "inspector", "function", "for", "CLI", "reports", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L112-L129
train
postmanlabs/newman
lib/reporters/cli/cli-utils.js
function () { var dimension = cliUtils.dimension(), // note that similar dimension calculation is in utils.wrapper width = ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 6; return function (text, indent) { return wrap(text, { ...
javascript
function () { var dimension = cliUtils.dimension(), // note that similar dimension calculation is in utils.wrapper width = ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 6; return function (text, indent) { return wrap(text, { ...
[ "function", "(", ")", "{", "var", "dimension", "=", "cliUtils", ".", "dimension", "(", ")", ",", "// note that similar dimension calculation is in utils.wrapper", "width", "=", "(", "(", "dimension", ".", "exists", "&&", "(", "dimension", ".", "width", ">", "20"...
A CLI utility helper method to provide content wrapping functionality for CLI reports. @returns {Function} - A sub-method to wrap content, given a piece of text, and indent value.
[ "A", "CLI", "utility", "helper", "method", "to", "provide", "content", "wrapping", "functionality", "for", "CLI", "reports", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L136-L148
train
postmanlabs/newman
lib/reporters/cli/cli-utils.js
function () { var tty, width, height; try { tty = require('tty'); } catch (e) { tty = null; } if (tty && tty.isatty(1) && tty.isatty(2)) { if (process.stdout.getWindowSize) { width = process.stdout.getWindowSize(1)[0]; ...
javascript
function () { var tty, width, height; try { tty = require('tty'); } catch (e) { tty = null; } if (tty && tty.isatty(1) && tty.isatty(2)) { if (process.stdout.getWindowSize) { width = process.stdout.getWindowSize(1)[0]; ...
[ "function", "(", ")", "{", "var", "tty", ",", "width", ",", "height", ";", "try", "{", "tty", "=", "require", "(", "'tty'", ")", ";", "}", "catch", "(", "e", ")", "{", "tty", "=", "null", ";", "}", "if", "(", "tty", "&&", "tty", ".", "isatty"...
A CLI utility helper method to compute and scae the size of the CLI table to be displayed. @returns {Object} - A set of properties: width, height, and TTY existance.
[ "A", "CLI", "utility", "helper", "method", "to", "compute", "and", "scae", "the", "size", "of", "the", "CLI", "table", "to", "be", "displayed", "." ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/reporters/cli/cli-utils.js#L155-L183
train
postmanlabs/newman
npm/server.js
createRawEchoServer
function createRawEchoServer () { var server; server = net.createServer(function (socket) { socket.on('data', function (chunk) { if (this.data === undefined) { this.data = ''; setTimeout(() => { // Status Line socket.w...
javascript
function createRawEchoServer () { var server; server = net.createServer(function (socket) { socket.on('data', function (chunk) { if (this.data === undefined) { this.data = ''; setTimeout(() => { // Status Line socket.w...
[ "function", "createRawEchoServer", "(", ")", "{", "var", "server", ";", "server", "=", "net", ".", "createServer", "(", "function", "(", "socket", ")", "{", "socket", ".", "on", "(", "'data'", ",", "function", "(", "chunk", ")", "{", "if", "(", "this",...
Echo raw request message to test - Body for HTTP methods like GET, HEAD - Custom HTTP methods @example var s = createRawEchoServer(); s.listen(3000, function() { console.log(s.port); s.close(); }); @note For HEAD request, read body from `raw-request` response header
[ "Echo", "raw", "request", "message", "to", "test", "-", "Body", "for", "HTTP", "methods", "like", "GET", "HEAD", "-", "Custom", "HTTP", "methods" ]
c05a5a1e82aa3c2021e94ba09e627ba4718af69e
https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/npm/server.js#L20-L60
train
graphql/graphiql
src/utility/fillLeafs.js
defaultGetDefaultFieldNames
function defaultGetDefaultFieldNames(type) { // If this type cannot access fields, then return an empty set. if (!type.getFields) { return []; } const fields = type.getFields(); // Is there an `id` field? if (fields['id']) { return ['id']; } // Is there an `edges` field? if (fields['edges']...
javascript
function defaultGetDefaultFieldNames(type) { // If this type cannot access fields, then return an empty set. if (!type.getFields) { return []; } const fields = type.getFields(); // Is there an `id` field? if (fields['id']) { return ['id']; } // Is there an `edges` field? if (fields['edges']...
[ "function", "defaultGetDefaultFieldNames", "(", "type", ")", "{", "// If this type cannot access fields, then return an empty set.", "if", "(", "!", "type", ".", "getFields", ")", "{", "return", "[", "]", ";", "}", "const", "fields", "=", "type", ".", "getFields", ...
The default function to use for producing the default fields from a type. This function first looks for some common patterns, and falls back to including all leaf-type fields.
[ "The", "default", "function", "to", "use", "for", "producing", "the", "default", "fields", "from", "a", "type", ".", "This", "function", "first", "looks", "for", "some", "common", "patterns", "and", "falls", "back", "to", "including", "all", "leaf", "-", "...
5d0f31d6059edc5f816edba3962c3b57fdabd478
https://github.com/graphql/graphiql/blob/5d0f31d6059edc5f816edba3962c3b57fdabd478/src/utility/fillLeafs.js#L73-L104
train
graphql/graphiql
src/utility/fillLeafs.js
buildSelectionSet
function buildSelectionSet(type, getDefaultFieldNames) { // Unwrap any non-null or list types. const namedType = getNamedType(type); // Unknown types and leaf types do not have selection sets. if (!type || isLeafType(type)) { return; } // Get an array of field names to use. const fieldNames = getDef...
javascript
function buildSelectionSet(type, getDefaultFieldNames) { // Unwrap any non-null or list types. const namedType = getNamedType(type); // Unknown types and leaf types do not have selection sets. if (!type || isLeafType(type)) { return; } // Get an array of field names to use. const fieldNames = getDef...
[ "function", "buildSelectionSet", "(", "type", ",", "getDefaultFieldNames", ")", "{", "// Unwrap any non-null or list types.", "const", "namedType", "=", "getNamedType", "(", "type", ")", ";", "// Unknown types and leaf types do not have selection sets.", "if", "(", "!", "ty...
Given a GraphQL type, and a function which produces field names, recursively generate a SelectionSet which includes default fields.
[ "Given", "a", "GraphQL", "type", "and", "a", "function", "which", "produces", "field", "names", "recursively", "generate", "a", "SelectionSet", "which", "includes", "default", "fields", "." ]
5d0f31d6059edc5f816edba3962c3b57fdabd478
https://github.com/graphql/graphiql/blob/5d0f31d6059edc5f816edba3962c3b57fdabd478/src/utility/fillLeafs.js#L108-L141
train