repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
adobe/brackets | src/extensibility/ExtensionManager.js | synchronizeEntry | function synchronizeEntry(id) {
var entry = extensions[id];
// Do nothing if we only have one set of data
if (!entry || !entry.installInfo || !entry.registryInfo) {
return;
}
entry.installInfo.owner = entry.registryInfo.owner;
// Assume false
entry.installInfo.updateAvailable = false;
entry.registryInfo.updateAvailable = false;
entry.installInfo.updateCompatible = false;
entry.registryInfo.updateCompatible = false;
var currentVersion = entry.installInfo.metadata ? entry.installInfo.metadata.version : null;
if (currentVersion && semver.lt(currentVersion, entry.registryInfo.metadata.version)) {
// Note: available update may still be incompatible; we check for this when rendering the Update button in ExtensionManagerView._renderItem()
entry.registryInfo.updateAvailable = true;
entry.installInfo.updateAvailable = true;
// Calculate updateCompatible to check if there's an update for current version of Brackets
var lastCompatibleVersionInfo = _.findLast(entry.registryInfo.versions, function (versionInfo) {
return !versionInfo.brackets || semver.satisfies(brackets.metadata.apiVersion, versionInfo.brackets);
});
if (lastCompatibleVersionInfo && lastCompatibleVersionInfo.version && semver.lt(currentVersion, lastCompatibleVersionInfo.version)) {
entry.installInfo.updateCompatible = true;
entry.registryInfo.updateCompatible = true;
entry.installInfo.lastCompatibleVersion = lastCompatibleVersionInfo.version;
entry.registryInfo.lastCompatibleVersion = lastCompatibleVersionInfo.version;
}
}
exports.trigger("registryUpdate", id);
} | javascript | function synchronizeEntry(id) {
var entry = extensions[id];
// Do nothing if we only have one set of data
if (!entry || !entry.installInfo || !entry.registryInfo) {
return;
}
entry.installInfo.owner = entry.registryInfo.owner;
// Assume false
entry.installInfo.updateAvailable = false;
entry.registryInfo.updateAvailable = false;
entry.installInfo.updateCompatible = false;
entry.registryInfo.updateCompatible = false;
var currentVersion = entry.installInfo.metadata ? entry.installInfo.metadata.version : null;
if (currentVersion && semver.lt(currentVersion, entry.registryInfo.metadata.version)) {
// Note: available update may still be incompatible; we check for this when rendering the Update button in ExtensionManagerView._renderItem()
entry.registryInfo.updateAvailable = true;
entry.installInfo.updateAvailable = true;
// Calculate updateCompatible to check if there's an update for current version of Brackets
var lastCompatibleVersionInfo = _.findLast(entry.registryInfo.versions, function (versionInfo) {
return !versionInfo.brackets || semver.satisfies(brackets.metadata.apiVersion, versionInfo.brackets);
});
if (lastCompatibleVersionInfo && lastCompatibleVersionInfo.version && semver.lt(currentVersion, lastCompatibleVersionInfo.version)) {
entry.installInfo.updateCompatible = true;
entry.registryInfo.updateCompatible = true;
entry.installInfo.lastCompatibleVersion = lastCompatibleVersionInfo.version;
entry.registryInfo.lastCompatibleVersion = lastCompatibleVersionInfo.version;
}
}
exports.trigger("registryUpdate", id);
} | [
"function",
"synchronizeEntry",
"(",
"id",
")",
"{",
"var",
"entry",
"=",
"extensions",
"[",
"id",
"]",
";",
"// Do nothing if we only have one set of data",
"if",
"(",
"!",
"entry",
"||",
"!",
"entry",
".",
"installInfo",
"||",
"!",
"entry",
".",
"registryInf... | @private
Synchronizes the information between the public registry and the installed
extensions. Specifically, this makes the `owner` available in each and sets
an `updateAvailable` flag.
@param {string} id of the extension to synchronize | [
"@private",
"Synchronizes",
"the",
"information",
"between",
"the",
"public",
"registry",
"and",
"the",
"installed",
"extensions",
".",
"Specifically",
"this",
"makes",
"the",
"owner",
"available",
"in",
"each",
"and",
"sets",
"an",
"updateAvailable",
"flag",
"."
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L123-L157 | train | Synchronize the registry with the current version of the extension | [
30522,
3853,
26351,
8093,
10698,
23940,
3372,
2854,
1006,
8909,
1007,
1063,
13075,
4443,
1027,
14305,
1031,
30524,
4443,
1012,
16500,
2378,
14876,
1064,
1064,
999,
4443,
1012,
15584,
2378,
14876,
1007,
1063,
2709,
1025,
1065,
4443,
1012,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/parallel/parallelPreprocessor.js | mergeAxisOptionFromParallel | function mergeAxisOptionFromParallel(option) {
var axes = modelUtil.normalizeToArray(option.parallelAxis);
zrUtil.each(axes, function (axisOption) {
if (!zrUtil.isObject(axisOption)) {
return;
}
var parallelIndex = axisOption.parallelIndex || 0;
var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
if (parallelOption && parallelOption.parallelAxisDefault) {
zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
}
});
} | javascript | function mergeAxisOptionFromParallel(option) {
var axes = modelUtil.normalizeToArray(option.parallelAxis);
zrUtil.each(axes, function (axisOption) {
if (!zrUtil.isObject(axisOption)) {
return;
}
var parallelIndex = axisOption.parallelIndex || 0;
var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
if (parallelOption && parallelOption.parallelAxisDefault) {
zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
}
});
} | [
"function",
"mergeAxisOptionFromParallel",
"(",
"option",
")",
"{",
"var",
"axes",
"=",
"modelUtil",
".",
"normalizeToArray",
"(",
"option",
".",
"parallelAxis",
")",
";",
"zrUtil",
".",
"each",
"(",
"axes",
",",
"function",
"(",
"axisOption",
")",
"{",
"if"... | Merge aixs definition from parallel option (if exists) to axis option.
@inner | [
"Merge",
"aixs",
"definition",
"from",
"parallel",
"option",
"(",
"if",
"exists",
")",
"to",
"axis",
"option",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/parallelPreprocessor.js#L54-L69 | train | Merge parallel axis option from parallel option | [
30522,
3853,
13590,
8528,
19565,
16790,
19699,
25377,
5400,
6216,
2140,
1006,
5724,
1007,
1063,
13075,
19589,
1027,
2944,
21823,
2140,
1012,
3671,
4697,
3406,
2906,
9447,
1006,
5724,
1012,
5903,
8528,
2483,
1007,
1025,
1062,
22134,
4014,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js | function (sPath) {
var iIndexOfAt;
if (!sPath || sPath[0] === "@") {
return "";
}
if (rCount.test(sPath)) {
return sPath.slice(0, -7);
}
iIndexOfAt = sPath.indexOf("@");
if (iIndexOfAt > -1) {
sPath = sPath.slice(0, iIndexOfAt);
}
if (sPath[sPath.length - 1] === "/") {
sPath = sPath.slice(0, -1);
}
if (sPath.indexOf(".") > -1) {
sPath = sPath.split("/")
.filter(function (sSegment) { // remove type casts
return sSegment.indexOf(".") < 0;
}).join("/");
}
return sPath;
} | javascript | function (sPath) {
var iIndexOfAt;
if (!sPath || sPath[0] === "@") {
return "";
}
if (rCount.test(sPath)) {
return sPath.slice(0, -7);
}
iIndexOfAt = sPath.indexOf("@");
if (iIndexOfAt > -1) {
sPath = sPath.slice(0, iIndexOfAt);
}
if (sPath[sPath.length - 1] === "/") {
sPath = sPath.slice(0, -1);
}
if (sPath.indexOf(".") > -1) {
sPath = sPath.split("/")
.filter(function (sSegment) { // remove type casts
return sSegment.indexOf(".") < 0;
}).join("/");
}
return sPath;
} | [
"function",
"(",
"sPath",
")",
"{",
"var",
"iIndexOfAt",
";",
"if",
"(",
"!",
"sPath",
"||",
"sPath",
"[",
"0",
"]",
"===",
"\"@\"",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"rCount",
".",
"test",
"(",
"sPath",
")",
")",
"{",
"return",
... | A function that helps to interpret OData V4 annotations. It knows about the syntax
of the path value used by the following dynamic expressions:
<ul>
<li>"14.5.2 Expression edm:AnnotationPath"</li>
<li>"14.5.11 Expression edm:NavigationPropertyPath"</li>
<li>"14.5.12 Expression edm:Path"</li>
<li>"14.5.13 Expression edm:PropertyPath"</li>
</ul>
It returns the path of structural and navigation properties from the given path
value, but removes "$count", types casts, term casts, and annotations of navigation
properties.
@param {string} sPath
The path value from the meta model, for example
"ToSupplier/@com.sap.vocabularies.Communication.v1.Address" or
"@com.sap.vocabularies.UI.v1.FieldGroup#Dimensions"
@returns {string}
The path of structural and navigation properties, for example "ToSupplier" or ""
@public
@since 1.43.0 | [
"A",
"function",
"that",
"helps",
"to",
"interpret",
"OData",
"V4",
"annotations",
".",
"It",
"knows",
"about",
"the",
"syntax",
"of",
"the",
"path",
"value",
"used",
"by",
"the",
"following",
"dynamic",
"expressions",
":",
"<ul",
">",
"<li",
">",
"14",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L274-L301 | train | Returns the path of the node | [
30522,
3853,
1006,
14690,
2232,
1007,
1063,
13075,
2462,
13629,
2595,
11253,
4017,
1025,
2065,
1006,
999,
14690,
2232,
1064,
1064,
14690,
2232,
1031,
1014,
1033,
1027,
1027,
1027,
1000,
1030,
1000,
1007,
1063,
2709,
1000,
1000,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/tooltip/tooltip.js | globalEventHandler | function globalEventHandler(event) {
if (listeners[event.type]) {
listeners[event.type].forEach(function(currentHandler) {
currentHandler.call(this, event);
}, this);
}
} | javascript | function globalEventHandler(event) {
if (listeners[event.type]) {
listeners[event.type].forEach(function(currentHandler) {
currentHandler.call(this, event);
}, this);
}
} | [
"function",
"globalEventHandler",
"(",
"event",
")",
"{",
"if",
"(",
"listeners",
"[",
"event",
".",
"type",
"]",
")",
"{",
"listeners",
"[",
"event",
".",
"type",
"]",
".",
"forEach",
"(",
"function",
"(",
"currentHandler",
")",
"{",
"currentHandler",
"... | Global event handler that dispatches the registered handlers in the
service.
@param {!Event} event Event object passed in by the browser | [
"Global",
"event",
"handler",
"that",
"dispatches",
"the",
"registered",
"handlers",
"in",
"the",
"service",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tooltip/tooltip.js#L437-L443 | train | Global event handler | [
30522,
3853,
3795,
18697,
3372,
11774,
3917,
1006,
2724,
1007,
1063,
2065,
1006,
13810,
1031,
2724,
1012,
2828,
1033,
1007,
1063,
13810,
1031,
2724,
1012,
2828,
1033,
1012,
18921,
6776,
1006,
3853,
1006,
2783,
11774,
3917,
1007,
1063,
2783,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/features/ParameterHintsManager.js | formatHint | function formatHint(hints) {
$hintContent.empty();
$hintContent.addClass("brackets-hints");
function appendSeparators(separators) {
$hintContent.append(separators);
}
function appendParameter(param, documentation, index) {
if (hints.currentIndex === index) {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("current-parameter"));
} else {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("parameter"));
}
}
if (hints.parameters.length > 0) {
_formatParameterHint(hints.parameters, appendSeparators, appendParameter);
} else {
$hintContent.append(_.escape(Strings.NO_ARGUMENTS));
}
} | javascript | function formatHint(hints) {
$hintContent.empty();
$hintContent.addClass("brackets-hints");
function appendSeparators(separators) {
$hintContent.append(separators);
}
function appendParameter(param, documentation, index) {
if (hints.currentIndex === index) {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("current-parameter"));
} else {
$hintContent.append($("<span>")
.append(_.escape(param))
.addClass("parameter"));
}
}
if (hints.parameters.length > 0) {
_formatParameterHint(hints.parameters, appendSeparators, appendParameter);
} else {
$hintContent.append(_.escape(Strings.NO_ARGUMENTS));
}
} | [
"function",
"formatHint",
"(",
"hints",
")",
"{",
"$hintContent",
".",
"empty",
"(",
")",
";",
"$hintContent",
".",
"addClass",
"(",
"\"brackets-hints\"",
")",
";",
"function",
"appendSeparators",
"(",
"separators",
")",
"{",
"$hintContent",
".",
"append",
"("... | Bold the parameter at the caret.
@param {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number}}} functionInfo -
tells if the caret is in a function call and the position
of the function call. | [
"Bold",
"the",
"parameter",
"at",
"the",
"caret",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/ParameterHintsManager.js#L199-L224 | train | Format hint | [
30522,
3853,
4289,
10606,
2102,
1006,
20385,
1007,
1063,
1002,
9374,
8663,
6528,
2102,
1012,
4064,
1006,
1007,
1025,
1002,
9374,
8663,
6528,
2102,
1012,
5587,
26266,
1006,
1000,
19719,
1011,
20385,
1000,
1007,
1025,
3853,
10439,
10497,
3366... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/closure-library | closure/goog/html/sanitizer/noclobber.js | prototypeMethodOrNull | function prototypeMethodOrNull(className, method) {
var ctor = goog.global[className];
return (ctor && ctor.prototype && ctor.prototype[method]) || null;
} | javascript | function prototypeMethodOrNull(className, method) {
var ctor = goog.global[className];
return (ctor && ctor.prototype && ctor.prototype[method]) || null;
} | [
"function",
"prototypeMethodOrNull",
"(",
"className",
",",
"method",
")",
"{",
"var",
"ctor",
"=",
"goog",
".",
"global",
"[",
"className",
"]",
";",
"return",
"(",
"ctor",
"&&",
"ctor",
".",
"prototype",
"&&",
"ctor",
".",
"prototype",
"[",
"method",
"... | Shorthand for `DOMInterface.prototype.method` to improve readability
during initialization of `Methods`.
@param {string} className
@param {string} method
@return {?Function} | [
"Shorthand",
"for",
"DOMInterface",
".",
"prototype",
".",
"method",
"to",
"improve",
"readability",
"during",
"initialization",
"of",
"Methods",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/sanitizer/noclobber.js#L73-L76 | train | Returns the prototype method of the given class or method. | [
30522,
3853,
8773,
11368,
6806,
7983,
11231,
3363,
1006,
2465,
18442,
1010,
4118,
1007,
1063,
13075,
14931,
2953,
1027,
27571,
2290,
1012,
3795,
1031,
2465,
18442,
1033,
1025,
2709,
1006,
14931,
2953,
1004,
1004,
14931,
2953,
1012,
8773,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ReactiveX/rxjs | docs_app/src/app/search/search-worker.js | createIndex | function createIndex(addFn) {
return lunr(/** @this */function() {
this.pipeline.remove(lunr.stopWordFilter);
this.ref('path');
this.field('titleWords', {boost: 100});
this.field('headingWords', {boost: 50});
this.field('members', {boost: 40});
this.field('keywords', {boost: 20});
addFn(this);
});
} | javascript | function createIndex(addFn) {
return lunr(/** @this */function() {
this.pipeline.remove(lunr.stopWordFilter);
this.ref('path');
this.field('titleWords', {boost: 100});
this.field('headingWords', {boost: 50});
this.field('members', {boost: 40});
this.field('keywords', {boost: 20});
addFn(this);
});
} | [
"function",
"createIndex",
"(",
"addFn",
")",
"{",
"return",
"lunr",
"(",
"/** @this */",
"function",
"(",
")",
"{",
"this",
".",
"pipeline",
".",
"remove",
"(",
"lunr",
".",
"stopWordFilter",
")",
";",
"this",
".",
"ref",
"(",
"'path'",
")",
";",
"thi... | Create the lunr index - the docs should be an array of objects, each object containing the path and search terms for a page | [
"Create",
"the",
"lunr",
"index",
"-",
"the",
"docs",
"should",
"be",
"an",
"array",
"of",
"objects",
"each",
"object",
"containing",
"the",
"path",
"and",
"search",
"terms",
"for",
"a",
"page"
] | 1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f | https://github.com/ReactiveX/rxjs/blob/1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f/docs_app/src/app/search/search-worker.js#L29-L39 | train | Creates an index function for the lunr object. | [
30522,
3853,
3443,
22254,
10288,
1006,
5587,
2546,
2078,
1007,
1063,
2709,
11320,
16118,
1006,
1013,
1008,
1008,
1030,
2023,
1008,
1013,
3853,
1006,
1007,
1063,
2023,
1012,
13117,
1012,
6366,
1006,
11320,
16118,
1012,
2644,
18351,
8873,
219... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getinsomnia/insomnia | packages/insomnia-importers/src/importers/swagger2.js | prepareBody | function prepareBody(endpointSchema, globalMimeTypes) {
const mimeTypes = endpointSchema.consumes || globalMimeTypes || [];
const isAvailable = m => mimeTypes.includes(m);
const supportedMimeType = SUPPORTED_MIME_TYPES.find(isAvailable);
if (supportedMimeType === MIMETYPE_JSON) {
const isSendInBody = p => p.in === 'body';
const parameters = endpointSchema.parameters || [];
const bodyParameter = parameters.find(isSendInBody);
if (!bodyParameter) {
return {
mimeType: supportedMimeType,
};
}
const example = bodyParameter ? generateParameterExample(bodyParameter.schema) : undefined;
const text = JSON.stringify(example, null, 2);
return {
mimeType: supportedMimeType,
text,
};
}
if (mimeTypes && mimeTypes.length) {
return {
mimeType: mimeTypes[0] || undefined,
};
} else {
return {};
}
} | javascript | function prepareBody(endpointSchema, globalMimeTypes) {
const mimeTypes = endpointSchema.consumes || globalMimeTypes || [];
const isAvailable = m => mimeTypes.includes(m);
const supportedMimeType = SUPPORTED_MIME_TYPES.find(isAvailable);
if (supportedMimeType === MIMETYPE_JSON) {
const isSendInBody = p => p.in === 'body';
const parameters = endpointSchema.parameters || [];
const bodyParameter = parameters.find(isSendInBody);
if (!bodyParameter) {
return {
mimeType: supportedMimeType,
};
}
const example = bodyParameter ? generateParameterExample(bodyParameter.schema) : undefined;
const text = JSON.stringify(example, null, 2);
return {
mimeType: supportedMimeType,
text,
};
}
if (mimeTypes && mimeTypes.length) {
return {
mimeType: mimeTypes[0] || undefined,
};
} else {
return {};
}
} | [
"function",
"prepareBody",
"(",
"endpointSchema",
",",
"globalMimeTypes",
")",
"{",
"const",
"mimeTypes",
"=",
"endpointSchema",
".",
"consumes",
"||",
"globalMimeTypes",
"||",
"[",
"]",
";",
"const",
"isAvailable",
"=",
"m",
"=>",
"mimeTypes",
".",
"includes",
... | Imports insomnia request body definitions, including data mock (if available)
If multiple types are available, the one for which an example can be generated will be selected first (i.e. application/json)
@param {Object} endpointSchema - swagger 2.0 endpoint schema
@param {string[]} globalMimeTypes - list of mimeTypes available in document globally (i.e. document.consumes)
@return {Object} insomnia request's body definition | [
"Imports",
"insomnia",
"request",
"body",
"definitions",
"including",
"data",
"mock",
"(",
"if",
"available",
")"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-importers/src/importers/swagger2.js#L223-L253 | train | Prepare the body for the request | [
30522,
3853,
7374,
23684,
1006,
2203,
26521,
5403,
2863,
1010,
3795,
4328,
11368,
18863,
2015,
1007,
1063,
9530,
3367,
2771,
11368,
18863,
2015,
1027,
2203,
26521,
5403,
2863,
1012,
16678,
2015,
1064,
1064,
3795,
4328,
11368,
18863,
2015,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable, sIdSuffix, fnHandler, bRegisterParent) {
var oDomRef;
if (typeof sIdSuffix == "string") {
oDomRef = oTable.getDomRef(sIdSuffix);
} else {
Log.error("sIdSuffix must be a string", oTable);
return undefined;
}
if (typeof fnHandler !== "function") {
Log.error("fnHandler must be a function", oTable);
return undefined;
}
// make sure that each DOM element of the table can only have one resize handler in order to avoid memory leaks
TableUtils.deregisterResizeHandler(oTable, sIdSuffix);
if (!oTable._mResizeHandlerIds) {
oTable._mResizeHandlerIds = {};
}
if (bRegisterParent && oDomRef) {
oDomRef = oDomRef.parentNode;
}
if (oDomRef) {
oTable._mResizeHandlerIds[sIdSuffix] = ResizeHandler.register(oDomRef, fnHandler);
}
return oTable._mResizeHandlerIds[sIdSuffix];
} | javascript | function(oTable, sIdSuffix, fnHandler, bRegisterParent) {
var oDomRef;
if (typeof sIdSuffix == "string") {
oDomRef = oTable.getDomRef(sIdSuffix);
} else {
Log.error("sIdSuffix must be a string", oTable);
return undefined;
}
if (typeof fnHandler !== "function") {
Log.error("fnHandler must be a function", oTable);
return undefined;
}
// make sure that each DOM element of the table can only have one resize handler in order to avoid memory leaks
TableUtils.deregisterResizeHandler(oTable, sIdSuffix);
if (!oTable._mResizeHandlerIds) {
oTable._mResizeHandlerIds = {};
}
if (bRegisterParent && oDomRef) {
oDomRef = oDomRef.parentNode;
}
if (oDomRef) {
oTable._mResizeHandlerIds[sIdSuffix] = ResizeHandler.register(oDomRef, fnHandler);
}
return oTable._mResizeHandlerIds[sIdSuffix];
} | [
"function",
"(",
"oTable",
",",
"sIdSuffix",
",",
"fnHandler",
",",
"bRegisterParent",
")",
"{",
"var",
"oDomRef",
";",
"if",
"(",
"typeof",
"sIdSuffix",
"==",
"\"string\"",
")",
"{",
"oDomRef",
"=",
"oTable",
".",
"getDomRef",
"(",
"sIdSuffix",
")",
";",
... | Registers a ResizeHandler for a DOM reference identified by its ID suffix. The ResizeHandler ID is tracked
in _mResizeHandlerIds of the table instance. The sIdSuffix is used as key.
Existing ResizeHandlers will be de-registered before the new one is registered.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {string} sIdSuffix ID suffix to identify the DOM element for which to register the ResizeHandler.
@param {Function} fnHandler Function to handle the resize event.
@param {boolean}[bRegisterParent] Flag to register the ResizeHandler for the parent DOM element of the one identified by sIdSuffix.
@returns {int | undefined} ResizeHandler ID or undefined if the DOM element could not be found. | [
"Registers",
"a",
"ResizeHandler",
"for",
"a",
"DOM",
"reference",
"identified",
"by",
"its",
"ID",
"suffix",
".",
"The",
"ResizeHandler",
"ID",
"is",
"tracked",
"in",
"_mResizeHandlerIds",
"of",
"the",
"table",
"instance",
".",
"The",
"sIdSuffix",
"is",
"used... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L917-L947 | train | Registers a resize handler for the given table. | [
30522,
3853,
1006,
27178,
3085,
1010,
15765,
6342,
26989,
2595,
1010,
1042,
25311,
5685,
3917,
1010,
7987,
13910,
12911,
19362,
4765,
1007,
1063,
13075,
1051,
9527,
2890,
2546,
1025,
2065,
1006,
2828,
11253,
15765,
6342,
26989,
2595,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.f/src/sap/f/cards/BindingResolver.js | resolveBinding | function resolveBinding(sBinding, oModel, sPath) {
if (!sBinding) {
return sBinding;
}
var oBindingInfo = ManagedObject.bindingParser(sBinding);
if (!oBindingInfo) {
return sBinding;
}
if (!sPath) {
sPath = "/";
}
oSimpleControl.setModel(oModel);
oSimpleControl.bindObject(sPath);
oSimpleControl.bindProperty("resolved", oBindingInfo);
var vValue = oSimpleControl.getResolved();
oSimpleControl.unbindProperty("resolved");
oSimpleControl.unbindObject();
oSimpleControl.setModel(null);
return vValue;
} | javascript | function resolveBinding(sBinding, oModel, sPath) {
if (!sBinding) {
return sBinding;
}
var oBindingInfo = ManagedObject.bindingParser(sBinding);
if (!oBindingInfo) {
return sBinding;
}
if (!sPath) {
sPath = "/";
}
oSimpleControl.setModel(oModel);
oSimpleControl.bindObject(sPath);
oSimpleControl.bindProperty("resolved", oBindingInfo);
var vValue = oSimpleControl.getResolved();
oSimpleControl.unbindProperty("resolved");
oSimpleControl.unbindObject();
oSimpleControl.setModel(null);
return vValue;
} | [
"function",
"resolveBinding",
"(",
"sBinding",
",",
"oModel",
",",
"sPath",
")",
"{",
"if",
"(",
"!",
"sBinding",
")",
"{",
"return",
"sBinding",
";",
"}",
"var",
"oBindingInfo",
"=",
"ManagedObject",
".",
"bindingParser",
"(",
"sBinding",
")",
";",
"if",
... | Resolves a single binding syntax.
@param {string} sBinding The value to resolve.
@param {sap.ui.model.Model} oModel The model.
@param {string} [sPath] The path to the referenced entity which is going to be used as a binding context.
@private
@returns {*} The resolved value. | [
"Resolves",
"a",
"single",
"binding",
"syntax",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.f/src/sap/f/cards/BindingResolver.js#L88-L113 | train | Resolves the binding and returns the resolved value | [
30522,
3853,
10663,
30524,
1010,
14690,
2232,
1007,
1063,
2065,
1006,
999,
24829,
22254,
2075,
1007,
1063,
2709,
24829,
22254,
2075,
1025,
1065,
13075,
27885,
22254,
2075,
2378,
14876,
1027,
3266,
16429,
20614,
1012,
8031,
19362,
8043,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/ExtensionLoader.js | _loadAll | function _loadAll(directory, config, entryPoint, processExtension) {
var result = new $.Deferred();
FileSystem.getDirectoryForPath(directory).getContents(function (err, contents) {
if (!err) {
var i,
extensions = [];
for (i = 0; i < contents.length; i++) {
if (contents[i].isDirectory) {
// FUTURE (JRB): read package.json instead of just using the entrypoint "main".
// Also, load sub-extensions defined in package.json.
extensions.push(contents[i].name);
}
}
if (extensions.length === 0) {
result.resolve();
return;
}
Async.doInParallel(extensions, function (item) {
var extConfig = {
baseUrl: config.baseUrl + "/" + item,
paths: config.paths
};
return processExtension(item, extConfig, entryPoint);
}).always(function () {
// Always resolve the promise even if some extensions had errors
result.resolve();
});
} else {
console.error("[Extension] Error -- could not read native directory: " + directory);
result.reject();
}
});
return result.promise();
} | javascript | function _loadAll(directory, config, entryPoint, processExtension) {
var result = new $.Deferred();
FileSystem.getDirectoryForPath(directory).getContents(function (err, contents) {
if (!err) {
var i,
extensions = [];
for (i = 0; i < contents.length; i++) {
if (contents[i].isDirectory) {
// FUTURE (JRB): read package.json instead of just using the entrypoint "main".
// Also, load sub-extensions defined in package.json.
extensions.push(contents[i].name);
}
}
if (extensions.length === 0) {
result.resolve();
return;
}
Async.doInParallel(extensions, function (item) {
var extConfig = {
baseUrl: config.baseUrl + "/" + item,
paths: config.paths
};
return processExtension(item, extConfig, entryPoint);
}).always(function () {
// Always resolve the promise even if some extensions had errors
result.resolve();
});
} else {
console.error("[Extension] Error -- could not read native directory: " + directory);
result.reject();
}
});
return result.promise();
} | [
"function",
"_loadAll",
"(",
"directory",
",",
"config",
",",
"entryPoint",
",",
"processExtension",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"FileSystem",
".",
"getDirectoryForPath",
"(",
"directory",
")",
".",
"getContent... | @private
Loads a file entryPoint from each extension folder within the baseUrl into its own Require.js context
@param {!string} directory, an absolute native path that contains a directory of extensions.
each subdirectory is interpreted as an independent extension
@param {!{baseUrl: string}} config object with baseUrl property containing absolute path of extension folder
@param {!string} entryPoint Module name to load (without .js suffix)
@param {function} processExtension
@return {!$.Promise} A promise object that is resolved when all extensions complete loading. | [
"@private",
"Loads",
"a",
"file",
"entryPoint",
"from",
"each",
"extension",
"folder",
"within",
"the",
"baseUrl",
"into",
"its",
"own",
"Require",
".",
"js",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L321-L359 | train | Load all extensions from a directory | [
30522,
3853,
1035,
7170,
8095,
1006,
14176,
1010,
9530,
8873,
2290,
1010,
4443,
8400,
1010,
2832,
10288,
29048,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
6764,
27268,
6633,
1012,
2131,
4305,
2890... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/HTMLViewRenderer.js | function(oControl) {
var sTemp = HTMLViewRenderer._getHTML(rm, oControl, sHTML);
if (sTemp) {
sHTML = sTemp;
} else {
aDeferred.push(oControl);
}
} | javascript | function(oControl) {
var sTemp = HTMLViewRenderer._getHTML(rm, oControl, sHTML);
if (sTemp) {
sHTML = sTemp;
} else {
aDeferred.push(oControl);
}
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"sTemp",
"=",
"HTMLViewRenderer",
".",
"_getHTML",
"(",
"rm",
",",
"oControl",
",",
"sHTML",
")",
";",
"if",
"(",
"sTemp",
")",
"{",
"sHTML",
"=",
"sTemp",
";",
"}",
"else",
"{",
"aDeferred",
".",
"push",... | helper method to render the controls | [
"helper",
"method",
"to",
"render",
"the",
"controls"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/HTMLViewRenderer.js#L54-L61 | train | If the control is not in the control list then it is not in the list of deferred items | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
7872,
2361,
1027,
16129,
8584,
7389,
4063,
2121,
1012,
1035,
2131,
11039,
19968,
1006,
28549,
1010,
1051,
8663,
13181,
2140,
1010,
14021,
21246,
2140,
1007,
1025,
2065,
1006,
78... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-duplicate-imports.js | getValue | function getValue(node) {
if (node && node.source && node.source.value) {
return node.source.value.trim();
}
return "";
} | javascript | function getValue(node) {
if (node && node.source && node.source.value) {
return node.source.value.trim();
}
return "";
} | [
"function",
"getValue",
"(",
"node",
")",
"{",
"if",
"(",
"node",
"&&",
"node",
".",
"source",
"&&",
"node",
".",
"source",
".",
"value",
")",
"{",
"return",
"node",
".",
"source",
".",
"value",
".",
"trim",
"(",
")",
";",
"}",
"return",
"\"\"",
... | ------------------------------------------------------------------------------ Rule Definition ------------------------------------------------------------------------------
Returns the name of the module imported or re-exported.
@param {ASTNode} node - A node to get.
@returns {string} the name of the module, or empty string if no name. | [
"------------------------------------------------------------------------------",
"Rule",
"Definition",
"------------------------------------------------------------------------------",
"Returns",
"the",
"name",
"of",
"the",
"module",
"imported",
"or",
"re",
"-",
"exported",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-duplicate-imports.js#L17-L23 | train | Get the value of a node | [
30522,
3853,
2131,
10175,
5657,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1004,
1004,
13045,
1012,
3120,
1004,
1004,
13045,
1012,
3120,
1012,
3643,
1007,
1063,
2709,
13045,
1012,
3120,
1012,
3643,
1012,
12241,
1006,
1007,
1025,
1065,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | isFileExcludedInternal | function isFileExcludedInternal(path) {
// The detectedExclusions are files detected to be troublesome with current versions of Tern.
// detectedExclusions is an array of full paths.
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [];
if (detectedExclusions && detectedExclusions.indexOf(path) !== -1) {
return true;
}
return false;
} | javascript | function isFileExcludedInternal(path) {
// The detectedExclusions are files detected to be troublesome with current versions of Tern.
// detectedExclusions is an array of full paths.
var detectedExclusions = PreferencesManager.get("jscodehints.detectedExclusions") || [];
if (detectedExclusions && detectedExclusions.indexOf(path) !== -1) {
return true;
}
return false;
} | [
"function",
"isFileExcludedInternal",
"(",
"path",
")",
"{",
"// The detectedExclusions are files detected to be troublesome with current versions of Tern.",
"// detectedExclusions is an array of full paths.",
"var",
"detectedExclusions",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"... | Test if the file path is an internal exclusion.
@param {string} path file path to test for exclusion.
@return {boolean} true if excluded, false otherwise. | [
"Test",
"if",
"the",
"file",
"path",
"is",
"an",
"internal",
"exclusion",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L230-L239 | train | Check if a file is excluded from the current version of Tern. | [
30522,
3853,
2003,
8873,
10559,
2595,
20464,
13936,
18447,
11795,
2389,
1006,
4130,
1007,
1063,
1013,
1013,
1996,
11156,
10288,
20464,
22016,
2024,
6764,
11156,
2000,
2022,
13460,
8462,
2007,
2783,
4617,
1997,
28774,
2078,
1012,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/TokenUtils.js | getTokenAt | function getTokenAt(cm, pos, precise) {
if (precise) {
_clearCache(); // reset cache
return cm.getTokenAt(pos, precise);
}
var cachedTokens = _manageCache(cm, pos.line),
tokenIndex = _.sortedIndex(cachedTokens, {end: pos.ch}, "end"), // binary search is faster for long arrays
token = cachedTokens[tokenIndex];
return token || cm.getTokenAt(pos, precise); // fall back to CMs getTokenAt, for example in an empty line
} | javascript | function getTokenAt(cm, pos, precise) {
if (precise) {
_clearCache(); // reset cache
return cm.getTokenAt(pos, precise);
}
var cachedTokens = _manageCache(cm, pos.line),
tokenIndex = _.sortedIndex(cachedTokens, {end: pos.ch}, "end"), // binary search is faster for long arrays
token = cachedTokens[tokenIndex];
return token || cm.getTokenAt(pos, precise); // fall back to CMs getTokenAt, for example in an empty line
} | [
"function",
"getTokenAt",
"(",
"cm",
",",
"pos",
",",
"precise",
")",
"{",
"if",
"(",
"precise",
")",
"{",
"_clearCache",
"(",
")",
";",
"// reset cache",
"return",
"cm",
".",
"getTokenAt",
"(",
"pos",
",",
"precise",
")",
";",
"}",
"var",
"cachedToken... | /*
Like cm.getTokenAt, but with caching. Way more performant for long lines.
@param {!CodeMirror} cm
@param {!{ch:number, line:number}} pos
@param {boolean} precise If given, results in more current results. Suppresses caching.
@return {Object} Token for position | [
"/",
"*",
"Like",
"cm",
".",
"getTokenAt",
"but",
"with",
"caching",
".",
"Way",
"more",
"performant",
"for",
"long",
"lines",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L76-L85 | train | Get a token from the cache | [
30522,
3853,
2131,
18715,
8189,
2102,
1006,
4642,
1010,
13433,
2015,
1010,
10480,
1007,
1063,
2065,
1006,
10480,
1007,
1063,
1035,
3154,
3540,
5403,
1006,
1007,
1025,
1013,
1013,
25141,
17053,
2709,
4642,
1012,
2131,
18715,
8189,
2102,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/HyphenationSupport.js | hyphenateTexts | function hyphenateTexts(oControl) {
if (!shouldControlHyphenate(oControl) || !shouldUseThirdParty()) {
// no hyphenation needed
oControl._mHyphenatedTexts = {};
oControl._mUnhyphenatedTexts = {};
return;
}
var mTexts = oControl.getTextsToBeHyphenated(),
aChangedTextKeys = diffTexts(mTexts, oControl._mUnhyphenatedTexts);
if (aChangedTextKeys.length > 0) {
oControl._mUnhyphenatedTexts = mTexts;
aChangedTextKeys.forEach(function(sKey) {
delete oControl._mHyphenatedTexts[sKey];
});
var oHyphenation = Hyphenation.getInstance();
if (!oHyphenation.isLanguageInitialized()) {
oHyphenation.initialize().then(function () {
var mDomRefs = oControl.isActive() ? oControl.getDomRefsForHyphenatedTexts() : null,
bNeedInvalidate = false;
aChangedTextKeys.forEach(function(sKey) {
oControl._mHyphenatedTexts[sKey] = oHyphenation.hyphenate(mTexts[sKey]);
if (mDomRefs && sKey in mDomRefs) {
setNodeValue(mDomRefs[sKey], oControl._mHyphenatedTexts[sKey]);
} else {
bNeedInvalidate = true;
}
});
if (bNeedInvalidate) {
oControl.invalidate();
}
});
} else {
aChangedTextKeys.forEach(function(sKey) {
oControl._mHyphenatedTexts[sKey] = oHyphenation.hyphenate(mTexts[sKey]);
});
}
}
} | javascript | function hyphenateTexts(oControl) {
if (!shouldControlHyphenate(oControl) || !shouldUseThirdParty()) {
// no hyphenation needed
oControl._mHyphenatedTexts = {};
oControl._mUnhyphenatedTexts = {};
return;
}
var mTexts = oControl.getTextsToBeHyphenated(),
aChangedTextKeys = diffTexts(mTexts, oControl._mUnhyphenatedTexts);
if (aChangedTextKeys.length > 0) {
oControl._mUnhyphenatedTexts = mTexts;
aChangedTextKeys.forEach(function(sKey) {
delete oControl._mHyphenatedTexts[sKey];
});
var oHyphenation = Hyphenation.getInstance();
if (!oHyphenation.isLanguageInitialized()) {
oHyphenation.initialize().then(function () {
var mDomRefs = oControl.isActive() ? oControl.getDomRefsForHyphenatedTexts() : null,
bNeedInvalidate = false;
aChangedTextKeys.forEach(function(sKey) {
oControl._mHyphenatedTexts[sKey] = oHyphenation.hyphenate(mTexts[sKey]);
if (mDomRefs && sKey in mDomRefs) {
setNodeValue(mDomRefs[sKey], oControl._mHyphenatedTexts[sKey]);
} else {
bNeedInvalidate = true;
}
});
if (bNeedInvalidate) {
oControl.invalidate();
}
});
} else {
aChangedTextKeys.forEach(function(sKey) {
oControl._mHyphenatedTexts[sKey] = oHyphenation.hyphenate(mTexts[sKey]);
});
}
}
} | [
"function",
"hyphenateTexts",
"(",
"oControl",
")",
"{",
"if",
"(",
"!",
"shouldControlHyphenate",
"(",
"oControl",
")",
"||",
"!",
"shouldUseThirdParty",
"(",
")",
")",
"{",
"// no hyphenation needed",
"oControl",
".",
"_mHyphenatedTexts",
"=",
"{",
"}",
";",
... | Hyphenates all texts needed for the given control.
@param {sap.m.IHyphenation} oControl The control whose texts need hyphenation
@private | [
"Hyphenates",
"all",
"texts",
"needed",
"for",
"the",
"given",
"control",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/HyphenationSupport.js#L148-L192 | train | hyphenates all text in the given control | [
30522,
3853,
1044,
22571,
10222,
3686,
18209,
2015,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
2065,
1006,
999,
2323,
8663,
13181,
2140,
10536,
8458,
8189,
2618,
1006,
1051,
8663,
13181,
2140,
1007,
1064,
1064,
999,
2323,
8557,
15222,
4103,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(node) {
node.readability = {"contentScore": 0};
switch (node.tagName) {
case 'DIV':
node.readability.contentScore += 5;
break;
case 'PRE':
case 'TD':
case 'BLOCKQUOTE':
node.readability.contentScore += 3;
break;
case 'ADDRESS':
case 'OL':
case 'UL':
case 'DL':
case 'DD':
case 'DT':
case 'LI':
case 'FORM':
node.readability.contentScore -= 3;
break;
case 'H1':
case 'H2':
case 'H3':
case 'H4':
case 'H5':
case 'H6':
case 'TH':
node.readability.contentScore -= 5;
break;
}
node.readability.contentScore += this._getClassWeight(node);
} | javascript | function(node) {
node.readability = {"contentScore": 0};
switch (node.tagName) {
case 'DIV':
node.readability.contentScore += 5;
break;
case 'PRE':
case 'TD':
case 'BLOCKQUOTE':
node.readability.contentScore += 3;
break;
case 'ADDRESS':
case 'OL':
case 'UL':
case 'DL':
case 'DD':
case 'DT':
case 'LI':
case 'FORM':
node.readability.contentScore -= 3;
break;
case 'H1':
case 'H2':
case 'H3':
case 'H4':
case 'H5':
case 'H6':
case 'TH':
node.readability.contentScore -= 5;
break;
}
node.readability.contentScore += this._getClassWeight(node);
} | [
"function",
"(",
"node",
")",
"{",
"node",
".",
"readability",
"=",
"{",
"\"contentScore\"",
":",
"0",
"}",
";",
"switch",
"(",
"node",
".",
"tagName",
")",
"{",
"case",
"'DIV'",
":",
"node",
".",
"readability",
".",
"contentScore",
"+=",
"5",
";",
"... | Initialize a node with the readability object. Also checks the
className/id for special names to add to its score.
@param Element
@return void | [
"Initialize",
"a",
"node",
"with",
"the",
"readability",
"object",
".",
"Also",
"checks",
"the",
"className",
"/",
"id",
"for",
"special",
"names",
"to",
"add",
"to",
"its",
"score",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L624-L661 | train | Calculate the readability of a node | [
30522,
3853,
1006,
13045,
1007,
1063,
13045,
1012,
3191,
8010,
1027,
1063,
1000,
8417,
17345,
1000,
1024,
1014,
1065,
1025,
6942,
1006,
13045,
1012,
6415,
18442,
1007,
1063,
2553,
1005,
4487,
2615,
1005,
1024,
13045,
1012,
3191,
8010,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js | function(oEvent) {
this.byId("phoneImage").setVisible(oEvent.name === "Phone");
this.byId("desktopImage").setVisible(oEvent.name !== "Phone");
this.byId("phoneImage").toggleStyleClass("phoneHeaderImageDesktop", oEvent.name === "Phone");
} | javascript | function(oEvent) {
this.byId("phoneImage").setVisible(oEvent.name === "Phone");
this.byId("desktopImage").setVisible(oEvent.name !== "Phone");
this.byId("phoneImage").toggleStyleClass("phoneHeaderImageDesktop", oEvent.name === "Phone");
} | [
"function",
"(",
"oEvent",
")",
"{",
"this",
".",
"byId",
"(",
"\"phoneImage\"",
")",
".",
"setVisible",
"(",
"oEvent",
".",
"name",
"===",
"\"Phone\"",
")",
";",
"this",
".",
"byId",
"(",
"\"desktopImage\"",
")",
".",
"setVisible",
"(",
"oEvent",
".",
... | Switches the image to phone and hides the download icon when decreasing the window size
@param {sap.ui.base.Event} oEvent Device media change event
@private | [
"Switches",
"the",
"image",
"to",
"phone",
"and",
"hides",
"the",
"download",
"icon",
"when",
"decreasing",
"the",
"window",
"size"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/DemoApps.controller.js#L134-L138 | train | Toggle the phone image and the desktop image | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
2023,
1012,
2011,
3593,
1006,
1000,
3042,
9581,
3351,
1000,
1007,
1012,
2275,
11365,
7028,
1006,
1051,
18697,
3372,
1012,
2171,
1027,
1027,
1027,
1000,
3042,
1000,
1007,
1025,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/report/IssueRenderer.js | render | function render(issues, enableFiltering) {
var content = '';
if (enableFiltering) {
content += '<div class="filters">' + getSeverityFilters(issues) + '<div>\n';
}
content += '<div>' + getIssues(issues) + '</div>';
return '<div>' + content + '</div>';
} | javascript | function render(issues, enableFiltering) {
var content = '';
if (enableFiltering) {
content += '<div class="filters">' + getSeverityFilters(issues) + '<div>\n';
}
content += '<div>' + getIssues(issues) + '</div>';
return '<div>' + content + '</div>';
} | [
"function",
"render",
"(",
"issues",
",",
"enableFiltering",
")",
"{",
"var",
"content",
"=",
"''",
";",
"if",
"(",
"enableFiltering",
")",
"{",
"content",
"+=",
"'<div class=\"filters\">'",
"+",
"getSeverityFilters",
"(",
"issues",
")",
"+",
"'<div>\\n'",
";"... | Public functions
Creates an html string containing the issues.
@param {Object} issues - the issues in viewmodel format
@param {Boolean} enableFiltering - if true renders the severity filters
@returns {String} | [
"Public",
"functions",
"Creates",
"an",
"html",
"string",
"containing",
"the",
"issues",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/report/IssueRenderer.js#L168-L178 | train | Render the issue list | [
30522,
3853,
17552,
1006,
3314,
1010,
9585,
8873,
21928,
2075,
1007,
1063,
13075,
4180,
1027,
1005,
1005,
1025,
2065,
1006,
9585,
8873,
21928,
2075,
1007,
1063,
4180,
1009,
1027,
1005,
1026,
4487,
2615,
2465,
1027,
1000,
17736,
1000,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/Suggest.js | createDialog | function createDialog() {
var dialog,
originalValue,
dialogSearchField,
customHeader,
closeButton;
// use sap.ui.require to avoid circular dependency between the SearchField and Suggest
dialogSearchField = new (sap.ui.require('sap/m/SearchField'))({
liveChange : function (oEvent) {
var value = oEvent.getParameter("newValue");
oInput.setValue(value);
oInput.fireLiveChange({newValue: value});
oInput.fireSuggest({suggestValue: value});
self.update();
},
search : function (oEvent) {
if (!oEvent.getParameter("clearButtonPressed")) {
dialog.close();
}
}
});
customHeader = new Bar({
contentLeft: dialogSearchField
});
closeButton = new Button({
text : sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("MSGBOX_CANCEL"),
press : function() {
dialog._oCloseTrigger = true;
dialog.close();
}
});
dialog = new (sap.ui.require('sap/m/Dialog'))({
stretch: true,
customHeader: customHeader,
content: getList(),
beginButton : closeButton,
beforeOpen: function() {
originalValue = oInput.getValue();
dialogSearchField.setValue(originalValue);
},
beforeClose: function(oEvent) {
if (oEvent.getParameter("origin")) {
// Cancel button: set original value
oInput.setValue(originalValue);
} else { // set current value
oInput.setValue(dialogSearchField.getValue());
}
},
afterClose: function(oEvent) {
if (!oEvent.getParameter("origin")) { // fire the search event if not cancelled
oInput.fireSearch({
query: oInput.getValue(),
refreshButtonPressed: false,
clearButtonPressed: false
});
}
}
});
dialog.addEventDelegate({
ontap: ontap
}, oInput);
return dialog;
} | javascript | function createDialog() {
var dialog,
originalValue,
dialogSearchField,
customHeader,
closeButton;
// use sap.ui.require to avoid circular dependency between the SearchField and Suggest
dialogSearchField = new (sap.ui.require('sap/m/SearchField'))({
liveChange : function (oEvent) {
var value = oEvent.getParameter("newValue");
oInput.setValue(value);
oInput.fireLiveChange({newValue: value});
oInput.fireSuggest({suggestValue: value});
self.update();
},
search : function (oEvent) {
if (!oEvent.getParameter("clearButtonPressed")) {
dialog.close();
}
}
});
customHeader = new Bar({
contentLeft: dialogSearchField
});
closeButton = new Button({
text : sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("MSGBOX_CANCEL"),
press : function() {
dialog._oCloseTrigger = true;
dialog.close();
}
});
dialog = new (sap.ui.require('sap/m/Dialog'))({
stretch: true,
customHeader: customHeader,
content: getList(),
beginButton : closeButton,
beforeOpen: function() {
originalValue = oInput.getValue();
dialogSearchField.setValue(originalValue);
},
beforeClose: function(oEvent) {
if (oEvent.getParameter("origin")) {
// Cancel button: set original value
oInput.setValue(originalValue);
} else { // set current value
oInput.setValue(dialogSearchField.getValue());
}
},
afterClose: function(oEvent) {
if (!oEvent.getParameter("origin")) { // fire the search event if not cancelled
oInput.fireSearch({
query: oInput.getValue(),
refreshButtonPressed: false,
clearButtonPressed: false
});
}
}
});
dialog.addEventDelegate({
ontap: ontap
}, oInput);
return dialog;
} | [
"function",
"createDialog",
"(",
")",
"{",
"var",
"dialog",
",",
"originalValue",
",",
"dialogSearchField",
",",
"customHeader",
",",
"closeButton",
";",
"// use sap.ui.require to avoid circular dependency between the SearchField and Suggest",
"dialogSearchField",
"=",
"new",
... | /* =========================================================== /* internal helper functions /* =========================================================== | [
"/",
"*",
"===========================================================",
"/",
"*",
"internal",
"helper",
"functions",
"/",
"*",
"==========================================================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/Suggest.js#L70-L136 | train | Creates a dialog | [
30522,
3853,
2580,
4818,
8649,
1006,
1007,
1063,
13075,
13764,
8649,
1010,
2434,
10175,
5657,
1010,
13764,
8649,
17310,
11140,
3790,
1010,
7661,
4974,
2121,
1010,
2485,
8569,
15474,
1025,
1013,
1013,
2224,
20066,
1012,
21318,
1012,
5478,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
expressjs/express | lib/response.js | sendfile | function sendfile(res, file, options, callback) {
var done = false;
var streaming;
// request aborted
function onaborted() {
if (done) return;
done = true;
var err = new Error('Request aborted');
err.code = 'ECONNABORTED';
callback(err);
}
// directory
function ondirectory() {
if (done) return;
done = true;
var err = new Error('EISDIR, read');
err.code = 'EISDIR';
callback(err);
}
// errors
function onerror(err) {
if (done) return;
done = true;
callback(err);
}
// ended
function onend() {
if (done) return;
done = true;
callback();
}
// file
function onfile() {
streaming = false;
}
// finished
function onfinish(err) {
if (err && err.code === 'ECONNRESET') return onaborted();
if (err) return onerror(err);
if (done) return;
setImmediate(function () {
if (streaming !== false && !done) {
onaborted();
return;
}
if (done) return;
done = true;
callback();
});
}
// streaming
function onstream() {
streaming = true;
}
file.on('directory', ondirectory);
file.on('end', onend);
file.on('error', onerror);
file.on('file', onfile);
file.on('stream', onstream);
onFinished(res, onfinish);
if (options.headers) {
// set headers on successful transfer
file.on('headers', function headers(res) {
var obj = options.headers;
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
res.setHeader(k, obj[k]);
}
});
}
// pipe
file.pipe(res);
} | javascript | function sendfile(res, file, options, callback) {
var done = false;
var streaming;
// request aborted
function onaborted() {
if (done) return;
done = true;
var err = new Error('Request aborted');
err.code = 'ECONNABORTED';
callback(err);
}
// directory
function ondirectory() {
if (done) return;
done = true;
var err = new Error('EISDIR, read');
err.code = 'EISDIR';
callback(err);
}
// errors
function onerror(err) {
if (done) return;
done = true;
callback(err);
}
// ended
function onend() {
if (done) return;
done = true;
callback();
}
// file
function onfile() {
streaming = false;
}
// finished
function onfinish(err) {
if (err && err.code === 'ECONNRESET') return onaborted();
if (err) return onerror(err);
if (done) return;
setImmediate(function () {
if (streaming !== false && !done) {
onaborted();
return;
}
if (done) return;
done = true;
callback();
});
}
// streaming
function onstream() {
streaming = true;
}
file.on('directory', ondirectory);
file.on('end', onend);
file.on('error', onerror);
file.on('file', onfile);
file.on('stream', onstream);
onFinished(res, onfinish);
if (options.headers) {
// set headers on successful transfer
file.on('headers', function headers(res) {
var obj = options.headers;
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
res.setHeader(k, obj[k]);
}
});
}
// pipe
file.pipe(res);
} | [
"function",
"sendfile",
"(",
"res",
",",
"file",
",",
"options",
",",
"callback",
")",
"{",
"var",
"done",
"=",
"false",
";",
"var",
"streaming",
";",
"// request aborted",
"function",
"onaborted",
"(",
")",
"{",
"if",
"(",
"done",
")",
"return",
";",
... | pipe the send file stream | [
"pipe",
"the",
"send",
"file",
"stream"
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/lib/response.js#L1012-L1100 | train | sendfile - Sends a file to the client | [
30522,
3853,
4604,
8873,
2571,
1006,
24501,
1010,
5371,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
13075,
2589,
1027,
6270,
1025,
13075,
11058,
1025,
1013,
1013,
5227,
11113,
15613,
3853,
2006,
7875,
15613,
1006,
1007,
1063,
2065,
1006,
2589... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/util.js | function (element) {
var parent = element.parent();
// jqLite might return a non-null, but still empty, parent; so check for parent and length
while (hasComputedStyle(parent, 'pointer-events', 'none')) {
parent = parent.parent();
}
return parent;
} | javascript | function (element) {
var parent = element.parent();
// jqLite might return a non-null, but still empty, parent; so check for parent and length
while (hasComputedStyle(parent, 'pointer-events', 'none')) {
parent = parent.parent();
}
return parent;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"parent",
"=",
"element",
".",
"parent",
"(",
")",
";",
"// jqLite might return a non-null, but still empty, parent; so check for parent and length",
"while",
"(",
"hasComputedStyle",
"(",
"parent",
",",
"'pointer-events'",
","... | Scan up dom hierarchy for enabled parent; | [
"Scan",
"up",
"dom",
"hierarchy",
"for",
"enabled",
"parent",
";"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L733-L742 | train | Returns the parent of the element | [
30522,
3853,
1006,
5783,
1007,
1063,
13075,
6687,
1027,
5783,
1012,
6687,
1006,
1007,
1025,
1013,
1013,
1046,
4160,
22779,
2453,
2709,
1037,
2512,
1011,
19701,
1010,
2021,
2145,
4064,
1010,
6687,
1025,
2061,
4638,
2005,
6687,
1998,
3091,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
marcuswestin/store.js | src/store-engine.js | function(key, value) {
if (value === undefined) {
return this.remove(key)
}
this.storage.write(this._namespacePrefix + key, this._serialize(value))
return value
} | javascript | function(key, value) {
if (value === undefined) {
return this.remove(key)
}
this.storage.write(this._namespacePrefix + key, this._serialize(value))
return value
} | [
"function",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"return",
"this",
".",
"remove",
"(",
"key",
")",
"}",
"this",
".",
"storage",
".",
"write",
"(",
"this",
".",
"_namespacePrefix",
"+",
"key",
",",
"t... | set will store the given value at key and returns value. Calling set with value === undefined is equivalent to calling remove. | [
"set",
"will",
"store",
"the",
"given",
"value",
"at",
"key",
"and",
"returns",
"value",
".",
"Calling",
"set",
"with",
"value",
"===",
"undefined",
"is",
"equivalent",
"to",
"calling",
"remove",
"."
] | b8e22fea8738fc19da4d9e7dbf1cda6e5185c481 | https://github.com/marcuswestin/store.js/blob/b8e22fea8738fc19da4d9e7dbf1cda6e5185c481/src/store-engine.js#L28-L34 | train | Set a value in the cache | [
30522,
3853,
1006,
3145,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
2709,
2023,
1012,
6366,
1006,
3145,
1007,
1065,
2023,
1012,
5527,
1012,
4339,
1006,
2023,
1012,
1035,
3415,
15327,
28139,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | docs/app/js/anchor.js | createContentURL | function createContentURL() {
var path = '';
var name = element.text();
// Use $window.location.pathname to get the path with the baseURL included.
// $location.path() does not include the baseURL. This is important to support how the docs
// are deployed with baseURLs like /latest, /HEAD, /1.1.13, etc.
if (scope.$root.$window && scope.$root.$window.location) {
path = scope.$root.$window.location.pathname;
}
name = name
.trim() // Trim text due to browsers extra whitespace.
.replace(/'/g, '') // Transform apostrophes words to a single one.
.replace(unsafeCharRegex, '-') // Replace unsafe chars with a dash symbol.
.replace(/-{2,}/g, '-') // Remove repeating dash symbols.
.replace(/^-|-$/g, '') // Remove preceding or ending dashes.
.toLowerCase(); // Link should be lower-case for accessible URL.
scope.name = name;
scope.href = path + '#' + name;
} | javascript | function createContentURL() {
var path = '';
var name = element.text();
// Use $window.location.pathname to get the path with the baseURL included.
// $location.path() does not include the baseURL. This is important to support how the docs
// are deployed with baseURLs like /latest, /HEAD, /1.1.13, etc.
if (scope.$root.$window && scope.$root.$window.location) {
path = scope.$root.$window.location.pathname;
}
name = name
.trim() // Trim text due to browsers extra whitespace.
.replace(/'/g, '') // Transform apostrophes words to a single one.
.replace(unsafeCharRegex, '-') // Replace unsafe chars with a dash symbol.
.replace(/-{2,}/g, '-') // Remove repeating dash symbols.
.replace(/^-|-$/g, '') // Remove preceding or ending dashes.
.toLowerCase(); // Link should be lower-case for accessible URL.
scope.name = name;
scope.href = path + '#' + name;
} | [
"function",
"createContentURL",
"(",
")",
"{",
"var",
"path",
"=",
"''",
";",
"var",
"name",
"=",
"element",
".",
"text",
"(",
")",
";",
"// Use $window.location.pathname to get the path with the baseURL included.",
"// $location.path() does not include the baseURL. This is i... | Creates URL from the text content of the element and writes it into the scope. | [
"Creates",
"URL",
"from",
"the",
"text",
"content",
"of",
"the",
"element",
"and",
"writes",
"it",
"into",
"the",
"scope",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/anchor.js#L43-L61 | train | Create the content URL | [
30522,
3853,
3443,
8663,
6528,
20689,
2140,
1006,
1007,
1063,
13075,
4130,
1027,
1005,
1005,
1025,
13075,
2171,
1027,
5783,
1012,
3793,
1006,
1007,
1025,
1013,
1013,
2224,
1002,
3332,
1012,
3295,
1012,
4130,
18442,
2000,
2131,
1996,
4130,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/computed-property-spacing.js | reportRequiredBeginningSpace | function reportRequiredBeginningSpace(node, token) {
context.report({
node,
loc: token.loc.start,
messageId: "missingSpaceAfter",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextAfter(token, " ");
}
});
} | javascript | function reportRequiredBeginningSpace(node, token) {
context.report({
node,
loc: token.loc.start,
messageId: "missingSpaceAfter",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.insertTextAfter(token, " ");
}
});
} | [
"function",
"reportRequiredBeginningSpace",
"(",
"node",
",",
"token",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"token",
".",
"loc",
".",
"start",
",",
"messageId",
":",
"\"missingSpaceAfter\"",
",",
"data",
":",
"{",
"tokenVa... | Reports that there should be a space after the first token
@param {ASTNode} node - The node to report in the event of an error.
@param {Token} token - The token to use for the report.
@returns {void} | [
"Reports",
"that",
"there",
"should",
"be",
"a",
"space",
"after",
"the",
"first",
"token"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/computed-property-spacing.js#L97-L109 | train | Reports a missing space after the first token. | [
30522,
3853,
3189,
2890,
15549,
5596,
4783,
11528,
5582,
23058,
1006,
13045,
1010,
19204,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
8840,
2278,
1024,
19204,
1012,
8840,
2278,
1012,
2707,
1010,
4471,
3593,
1024,
1000,
4394,
2305... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-unused-vars.js | getRhsNode | function getRhsNode(ref, prevRhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
const refScope = ref.from.variableScope;
const varScope = ref.resolved.scope.variableScope;
const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);
/*
* Inherits the previous node if this reference is in the node.
* This is for `a = a + a`-like code.
*/
if (prevRhsNode && isInside(id, prevRhsNode)) {
return prevRhsNode;
}
if (parent.type === "AssignmentExpression" &&
granpa.type === "ExpressionStatement" &&
id === parent.left &&
!canBeUsedLater
) {
return parent.right;
}
return null;
} | javascript | function getRhsNode(ref, prevRhsNode) {
const id = ref.identifier;
const parent = id.parent;
const granpa = parent.parent;
const refScope = ref.from.variableScope;
const varScope = ref.resolved.scope.variableScope;
const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);
/*
* Inherits the previous node if this reference is in the node.
* This is for `a = a + a`-like code.
*/
if (prevRhsNode && isInside(id, prevRhsNode)) {
return prevRhsNode;
}
if (parent.type === "AssignmentExpression" &&
granpa.type === "ExpressionStatement" &&
id === parent.left &&
!canBeUsedLater
) {
return parent.right;
}
return null;
} | [
"function",
"getRhsNode",
"(",
"ref",
",",
"prevRhsNode",
")",
"{",
"const",
"id",
"=",
"ref",
".",
"identifier",
";",
"const",
"parent",
"=",
"id",
".",
"parent",
";",
"const",
"granpa",
"=",
"parent",
".",
"parent",
";",
"const",
"refScope",
"=",
"re... | If a given reference is left-hand side of an assignment, this gets
the right-hand side node of the assignment.
In the following cases, this returns null.
- The reference is not the LHS of an assignment expression.
- The reference is inside of a loop.
- The reference is inside of a function scope which is different from
the declaration.
@param {eslint-scope.Reference} ref - A reference to check.
@param {ASTNode} prevRhsNode - The previous RHS node.
@returns {ASTNode|null} The RHS node or null.
@private | [
"If",
"a",
"given",
"reference",
"is",
"left",
"-",
"hand",
"side",
"of",
"an",
"assignment",
"this",
"gets",
"the",
"right",
"-",
"hand",
"side",
"node",
"of",
"the",
"assignment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L284-L308 | train | Returns the right - hand side of the given reference node. | [
30522,
3853,
2131,
25032,
2015,
3630,
3207,
1006,
25416,
1010,
3653,
19716,
7898,
3630,
3207,
1007,
1063,
9530,
3367,
8909,
1027,
25416,
1012,
8909,
4765,
18095,
1025,
9530,
3367,
6687,
1027,
8909,
1012,
6687,
1025,
9530,
3367,
12604,
4502,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_ColRelU | function parse_ColRelU(blob, length) {
var c = blob.read_shift(length == 1 ? 1 : 2);
return [c & 0x3FFF, (c >> 14) & 1, (c >> 15) & 1];
} | javascript | function parse_ColRelU(blob, length) {
var c = blob.read_shift(length == 1 ? 1 : 2);
return [c & 0x3FFF, (c >> 14) & 1, (c >> 15) & 1];
} | [
"function",
"parse_ColRelU",
"(",
"blob",
",",
"length",
")",
"{",
"var",
"c",
"=",
"blob",
".",
"read_shift",
"(",
"length",
"==",
"1",
"?",
"1",
":",
"2",
")",
";",
"return",
"[",
"c",
"&",
"0x3FFF",
",",
"(",
"c",
">>",
"14",
")",
"&",
"1",
... | /* [MS-XLS] 2.5.51 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"51"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10228-L10231 | train | Parse ColRelU | [
30522,
3853,
11968,
3366,
1035,
8902,
16570,
2226,
1006,
1038,
4135,
2497,
1010,
3091,
1007,
1063,
13075,
1039,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
3091,
1027,
1027,
1015,
1029,
1015,
1024,
1016,
1007,
1025,
2709,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tensorflow/tfjs-models | posenet/demos/coco.js | visualizeOutputs | function visualizeOutputs(
partId, drawHeatmaps, drawOffsetVectors, drawDisplacements, ctx) {
const {heatmapScores, offsets, displacementFwd, displacementBwd} =
modelOutputs;
const outputStride = +guiState.outputStride;
const [height, width] = heatmapScores.shape;
ctx.globalAlpha = 0;
const heatmapScoresArr = heatmapScores.arraySync();
const offsetsArr = offsets.arraySync();
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const score = heatmapScoresArr[y][x][partId];
// to save on performance, don't draw anything with a low score.
if (score < 0.05) continue;
// set opacity of drawn elements based on the score
ctx.globalAlpha = score;
if (drawHeatmaps) {
drawPoint(ctx, y * outputStride, x * outputStride, 2, 'yellow');
}
const offsetsVectorY = offsetsArr[y][x][partId];
const offsetsVectorX = offsetsArr[y][x][partId + 17];
if (drawOffsetVectors) {
drawOffsetVector(
ctx, y, x, outputStride, offsetsVectorY, offsetsVectorX);
}
if (drawDisplacements) {
// exponentially affect the alpha of the displacements;
ctx.globalAlpha *= score;
drawDisplacementEdgesFrom(
ctx, partId, displacementFwd, outputStride, parentToChildEdges, y,
x, offsetsVectorY, offsetsVectorX);
drawDisplacementEdgesFrom(
ctx, partId, displacementBwd, outputStride, childToParentEdges, y,
x, offsetsVectorY, offsetsVectorX);
}
}
ctx.globalAlpha = 1;
}
} | javascript | function visualizeOutputs(
partId, drawHeatmaps, drawOffsetVectors, drawDisplacements, ctx) {
const {heatmapScores, offsets, displacementFwd, displacementBwd} =
modelOutputs;
const outputStride = +guiState.outputStride;
const [height, width] = heatmapScores.shape;
ctx.globalAlpha = 0;
const heatmapScoresArr = heatmapScores.arraySync();
const offsetsArr = offsets.arraySync();
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const score = heatmapScoresArr[y][x][partId];
// to save on performance, don't draw anything with a low score.
if (score < 0.05) continue;
// set opacity of drawn elements based on the score
ctx.globalAlpha = score;
if (drawHeatmaps) {
drawPoint(ctx, y * outputStride, x * outputStride, 2, 'yellow');
}
const offsetsVectorY = offsetsArr[y][x][partId];
const offsetsVectorX = offsetsArr[y][x][partId + 17];
if (drawOffsetVectors) {
drawOffsetVector(
ctx, y, x, outputStride, offsetsVectorY, offsetsVectorX);
}
if (drawDisplacements) {
// exponentially affect the alpha of the displacements;
ctx.globalAlpha *= score;
drawDisplacementEdgesFrom(
ctx, partId, displacementFwd, outputStride, parentToChildEdges, y,
x, offsetsVectorY, offsetsVectorX);
drawDisplacementEdgesFrom(
ctx, partId, displacementBwd, outputStride, childToParentEdges, y,
x, offsetsVectorY, offsetsVectorX);
}
}
ctx.globalAlpha = 1;
}
} | [
"function",
"visualizeOutputs",
"(",
"partId",
",",
"drawHeatmaps",
",",
"drawOffsetVectors",
",",
"drawDisplacements",
",",
"ctx",
")",
"{",
"const",
"{",
"heatmapScores",
",",
"offsets",
",",
"displacementFwd",
",",
"displacementBwd",
"}",
"=",
"modelOutputs",
"... | Visualizes the outputs from the model which are used for decoding poses.
Limited to visualizing the outputs for a single part.
@param partId The id of the part to visualize | [
"Visualizes",
"the",
"outputs",
"from",
"the",
"model",
"which",
"are",
"used",
"for",
"decoding",
"poses",
".",
"Limited",
"to",
"visualizing",
"the",
"outputs",
"for",
"a",
"single",
"part",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/posenet/demos/coco.js#L227-L277 | train | visualize the outputs of the model | [
30522,
3853,
5107,
4697,
5833,
18780,
2015,
1006,
2112,
3593,
1010,
4009,
20192,
29418,
4523,
1010,
4009,
27475,
3388,
3726,
24817,
1010,
4009,
10521,
24759,
10732,
8163,
1010,
14931,
2595,
1007,
1063,
9530,
3367,
1063,
3684,
2863,
4523,
17... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-loop-func.js | isSafe | function isSafe(loopNode, reference) {
const variable = reference.resolved;
const definition = variable && variable.defs[0];
const declaration = definition && definition.parent;
const kind = (declaration && declaration.type === "VariableDeclaration")
? declaration.kind
: "";
// Variables which are declared by `const` is safe.
if (kind === "const") {
return true;
}
/*
* Variables which are declared by `let` in the loop is safe.
* It's a different instance from the next loop step's.
*/
if (kind === "let" &&
declaration.range[0] > loopNode.range[0] &&
declaration.range[1] < loopNode.range[1]
) {
return true;
}
/*
* WriteReferences which exist after this border are unsafe because those
* can modify the variable.
*/
const border = getTopLoopNode(
loopNode,
(kind === "let") ? declaration : null
).range[0];
/**
* Checks whether a given reference is safe or not.
* The reference is every reference of the upper scope's variable we are
* looking now.
*
* It's safeafe if the reference matches one of the following condition.
* - is readonly.
* - doesn't exist inside a local function and after the border.
*
* @param {eslint-scope.Reference} upperRef - A reference to check.
* @returns {boolean} `true` if the reference is safe.
*/
function isSafeReference(upperRef) {
const id = upperRef.identifier;
return (
!upperRef.isWrite() ||
variable.scope.variableScope === upperRef.from.variableScope &&
id.range[0] < border
);
}
return Boolean(variable) && variable.references.every(isSafeReference);
} | javascript | function isSafe(loopNode, reference) {
const variable = reference.resolved;
const definition = variable && variable.defs[0];
const declaration = definition && definition.parent;
const kind = (declaration && declaration.type === "VariableDeclaration")
? declaration.kind
: "";
// Variables which are declared by `const` is safe.
if (kind === "const") {
return true;
}
/*
* Variables which are declared by `let` in the loop is safe.
* It's a different instance from the next loop step's.
*/
if (kind === "let" &&
declaration.range[0] > loopNode.range[0] &&
declaration.range[1] < loopNode.range[1]
) {
return true;
}
/*
* WriteReferences which exist after this border are unsafe because those
* can modify the variable.
*/
const border = getTopLoopNode(
loopNode,
(kind === "let") ? declaration : null
).range[0];
/**
* Checks whether a given reference is safe or not.
* The reference is every reference of the upper scope's variable we are
* looking now.
*
* It's safeafe if the reference matches one of the following condition.
* - is readonly.
* - doesn't exist inside a local function and after the border.
*
* @param {eslint-scope.Reference} upperRef - A reference to check.
* @returns {boolean} `true` if the reference is safe.
*/
function isSafeReference(upperRef) {
const id = upperRef.identifier;
return (
!upperRef.isWrite() ||
variable.scope.variableScope === upperRef.from.variableScope &&
id.range[0] < border
);
}
return Boolean(variable) && variable.references.every(isSafeReference);
} | [
"function",
"isSafe",
"(",
"loopNode",
",",
"reference",
")",
"{",
"const",
"variable",
"=",
"reference",
".",
"resolved",
";",
"const",
"definition",
"=",
"variable",
"&&",
"variable",
".",
"defs",
"[",
"0",
"]",
";",
"const",
"declaration",
"=",
"definit... | Checks whether a given reference which refers to an upper scope's variable is
safe or not.
@param {ASTNode} loopNode - A containing loop node.
@param {eslint-scope.Reference} reference - A reference to check.
@returns {boolean} `true` if the reference is safe or not. | [
"Checks",
"whether",
"a",
"given",
"reference",
"which",
"refers",
"to",
"an",
"upper",
"scope",
"s",
"variable",
"is",
"safe",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-loop-func.js#L93-L149 | train | Checks whether a given reference is safe or not. | [
30522,
3853,
26354,
10354,
2063,
1006,
7077,
3630,
3207,
1010,
4431,
1007,
1063,
9530,
3367,
8023,
1027,
4431,
1012,
10395,
1025,
9530,
3367,
6210,
1027,
8023,
1004,
1004,
8023,
1012,
13366,
2015,
1031,
1014,
1033,
1025,
9530,
3367,
8170,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
zalmoxisus/redux-devtools-extension | src/browser/extension/inject/contentScript.js | handleMessages | function handleMessages(event) {
if (!isAllowed()) return;
if (!event || event.source !== window || typeof event.data !== 'object') return;
const message = event.data;
if (message.source !== pageSource) return;
if (message.type === 'DISCONNECT') {
if (bg) {
bg.disconnect();
connected = false;
}
return;
}
tryCatch(send, message);
} | javascript | function handleMessages(event) {
if (!isAllowed()) return;
if (!event || event.source !== window || typeof event.data !== 'object') return;
const message = event.data;
if (message.source !== pageSource) return;
if (message.type === 'DISCONNECT') {
if (bg) {
bg.disconnect();
connected = false;
}
return;
}
tryCatch(send, message);
} | [
"function",
"handleMessages",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"isAllowed",
"(",
")",
")",
"return",
";",
"if",
"(",
"!",
"event",
"||",
"event",
".",
"source",
"!==",
"window",
"||",
"typeof",
"event",
".",
"data",
"!==",
"'object'",
")",
"re... | Resend messages from the page to the background script | [
"Resend",
"messages",
"from",
"the",
"page",
"to",
"the",
"background",
"script"
] | d127175196388c9b1f874b04b2792cf487c5d5e0 | https://github.com/zalmoxisus/redux-devtools-extension/blob/d127175196388c9b1f874b04b2792cf487c5d5e0/src/browser/extension/inject/contentScript.js#L102-L116 | train | Handle messages from the page | [
30522,
3853,
5047,
7834,
3736,
8449,
1006,
2724,
1007,
1063,
2065,
1006,
999,
18061,
7174,
15557,
1006,
1007,
1007,
2709,
1025,
2065,
1006,
999,
2724,
1064,
1064,
2724,
1012,
3120,
999,
1027,
1027,
3332,
1064,
1064,
2828,
11253,
2724,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
markdown-it/markdown-it | support/demo_template/index.js | buildScrollMap | function buildScrollMap() {
var i, offset, nonEmptyList, pos, a, b, lineHeightMap, linesCount,
acc, sourceLikeDiv, textarea = $('.source'),
_scrollMap;
sourceLikeDiv = $('<div />').css({
position: 'absolute',
visibility: 'hidden',
height: 'auto',
width: textarea[0].clientWidth,
'font-size': textarea.css('font-size'),
'font-family': textarea.css('font-family'),
'line-height': textarea.css('line-height'),
'white-space': textarea.css('white-space')
}).appendTo('body');
offset = $('.result-html').scrollTop() - $('.result-html').offset().top;
_scrollMap = [];
nonEmptyList = [];
lineHeightMap = [];
acc = 0;
textarea.val().split('\n').forEach(function (str) {
var h, lh;
lineHeightMap.push(acc);
if (str.length === 0) {
acc++;
return;
}
sourceLikeDiv.text(str);
h = parseFloat(sourceLikeDiv.css('height'));
lh = parseFloat(sourceLikeDiv.css('line-height'));
acc += Math.round(h / lh);
});
sourceLikeDiv.remove();
lineHeightMap.push(acc);
linesCount = acc;
for (i = 0; i < linesCount; i++) { _scrollMap.push(-1); }
nonEmptyList.push(0);
_scrollMap[0] = 0;
$('.line').each(function (n, el) {
var $el = $(el), t = $el.data('line');
if (t === '') { return; }
t = lineHeightMap[t];
if (t !== 0) { nonEmptyList.push(t); }
_scrollMap[t] = Math.round($el.offset().top + offset);
});
nonEmptyList.push(linesCount);
_scrollMap[linesCount] = $('.result-html')[0].scrollHeight;
pos = 0;
for (i = 1; i < linesCount; i++) {
if (_scrollMap[i] !== -1) {
pos++;
continue;
}
a = nonEmptyList[pos];
b = nonEmptyList[pos + 1];
_scrollMap[i] = Math.round((_scrollMap[b] * (i - a) + _scrollMap[a] * (b - i)) / (b - a));
}
return _scrollMap;
} | javascript | function buildScrollMap() {
var i, offset, nonEmptyList, pos, a, b, lineHeightMap, linesCount,
acc, sourceLikeDiv, textarea = $('.source'),
_scrollMap;
sourceLikeDiv = $('<div />').css({
position: 'absolute',
visibility: 'hidden',
height: 'auto',
width: textarea[0].clientWidth,
'font-size': textarea.css('font-size'),
'font-family': textarea.css('font-family'),
'line-height': textarea.css('line-height'),
'white-space': textarea.css('white-space')
}).appendTo('body');
offset = $('.result-html').scrollTop() - $('.result-html').offset().top;
_scrollMap = [];
nonEmptyList = [];
lineHeightMap = [];
acc = 0;
textarea.val().split('\n').forEach(function (str) {
var h, lh;
lineHeightMap.push(acc);
if (str.length === 0) {
acc++;
return;
}
sourceLikeDiv.text(str);
h = parseFloat(sourceLikeDiv.css('height'));
lh = parseFloat(sourceLikeDiv.css('line-height'));
acc += Math.round(h / lh);
});
sourceLikeDiv.remove();
lineHeightMap.push(acc);
linesCount = acc;
for (i = 0; i < linesCount; i++) { _scrollMap.push(-1); }
nonEmptyList.push(0);
_scrollMap[0] = 0;
$('.line').each(function (n, el) {
var $el = $(el), t = $el.data('line');
if (t === '') { return; }
t = lineHeightMap[t];
if (t !== 0) { nonEmptyList.push(t); }
_scrollMap[t] = Math.round($el.offset().top + offset);
});
nonEmptyList.push(linesCount);
_scrollMap[linesCount] = $('.result-html')[0].scrollHeight;
pos = 0;
for (i = 1; i < linesCount; i++) {
if (_scrollMap[i] !== -1) {
pos++;
continue;
}
a = nonEmptyList[pos];
b = nonEmptyList[pos + 1];
_scrollMap[i] = Math.round((_scrollMap[b] * (i - a) + _scrollMap[a] * (b - i)) / (b - a));
}
return _scrollMap;
} | [
"function",
"buildScrollMap",
"(",
")",
"{",
"var",
"i",
",",
"offset",
",",
"nonEmptyList",
",",
"pos",
",",
"a",
",",
"b",
",",
"lineHeightMap",
",",
"linesCount",
",",
"acc",
",",
"sourceLikeDiv",
",",
"textarea",
"=",
"$",
"(",
"'.source'",
")",
",... | Build offsets for each line (lines can be wrapped) That's a bit dirty to process each line everytime, but ok for demo. Optimizations are required only for big texts. | [
"Build",
"offsets",
"for",
"each",
"line",
"(",
"lines",
"can",
"be",
"wrapped",
")",
"That",
"s",
"a",
"bit",
"dirty",
"to",
"process",
"each",
"line",
"everytime",
"but",
"ok",
"for",
"demo",
".",
"Optimizations",
"are",
"required",
"only",
"for",
"big... | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/support/demo_template/index.js#L230-L300 | train | Build the scroll map | [
30522,
3853,
16473,
26775,
14511,
2863,
2361,
1006,
1007,
1063,
13075,
1045,
1010,
16396,
1010,
3904,
27718,
8516,
2923,
1010,
13433,
2015,
1010,
1037,
1010,
1038,
1010,
2240,
26036,
13900,
2863,
2361,
1010,
3210,
3597,
16671,
1010,
16222,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-slider/bootstrap-slider.js | function(percentage) {
var min = (this.options.min === 0) ? 0 : Math.log(this.options.min);
var max = Math.log(this.options.max);
var value = Math.exp(min + (max - min) * percentage / 100);
value = this.options.min + Math.round((value - this.options.min) / this.options.step) * this.options.step;
/* Rounding to the nearest step could exceed the min or
* max, so clip to those values. */
if (value < this.options.min) {
return this.options.min;
} else if (value > this.options.max) {
return this.options.max;
} else {
return value;
}
} | javascript | function(percentage) {
var min = (this.options.min === 0) ? 0 : Math.log(this.options.min);
var max = Math.log(this.options.max);
var value = Math.exp(min + (max - min) * percentage / 100);
value = this.options.min + Math.round((value - this.options.min) / this.options.step) * this.options.step;
/* Rounding to the nearest step could exceed the min or
* max, so clip to those values. */
if (value < this.options.min) {
return this.options.min;
} else if (value > this.options.max) {
return this.options.max;
} else {
return value;
}
} | [
"function",
"(",
"percentage",
")",
"{",
"var",
"min",
"=",
"(",
"this",
".",
"options",
".",
"min",
"===",
"0",
")",
"?",
"0",
":",
"Math",
".",
"log",
"(",
"this",
".",
"options",
".",
"min",
")",
";",
"var",
"max",
"=",
"Math",
".",
"log",
... | /* Based on http://stackoverflow.com/questions/846221/logarithmic-slider | [
"/",
"*",
"Based",
"on",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"846221",
"/",
"logarithmic",
"-",
"slider"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-slider/bootstrap-slider.js#L266-L280 | train | Calculate the value of the logarithmic value | [
30522,
3853,
1006,
7017,
1007,
1063,
13075,
8117,
1027,
1006,
2023,
1012,
7047,
1012,
8117,
1027,
1027,
1027,
1014,
1007,
1029,
1014,
1024,
8785,
1012,
8833,
1006,
2023,
1012,
7047,
1012,
8117,
1007,
1025,
13075,
4098,
1027,
8785,
1012,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
NervJS/taro | packages/taro/src/internal/_common.js | baseToString | function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value === 'string') {
return value
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''
}
var result = value + ''
return result == '0' && 1 / value == -INFINITY ? '-0' : result
} | javascript | function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value === 'string') {
return value
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''
}
var result = value + ''
return result == '0' && 1 / value == -INFINITY ? '-0' : result
} | [
"function",
"baseToString",
"(",
"value",
")",
"{",
"// Exit early for strings to avoid a performance hit in some environments.",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
")",
"{",
"return",
"value",
"}",
"if",
"(",
"isSymbol",
"(",
"value",
")",
")",
"{",
... | The base implementation of `_.toString` which doesn't convert nullish
values to empty strings.
@private
@param {*} value The value to process.
@returns {string} Returns the string. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"toString",
"which",
"doesn",
"t",
"convert",
"nullish",
"values",
"to",
"empty",
"strings",
"."
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L503-L513 | train | The base implementation of _. toString which is similar to _. toString except that it is not a string. | [
30522,
3853,
2918,
13122,
18886,
3070,
1006,
3643,
1007,
1063,
1013,
1013,
6164,
2220,
2005,
7817,
2000,
4468,
1037,
2836,
2718,
1999,
2070,
10058,
1012,
2065,
1006,
2828,
11253,
3643,
1027,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
googleapis/google-api-nodejs-client | samples/customsearch/customsearch.js | runSample | async function runSample(options) {
console.log(options);
const res = await customsearch.cse.list({
cx: options.cx,
q: options.q,
auth: options.apiKey,
});
console.log(res.data);
return res.data;
} | javascript | async function runSample(options) {
console.log(options);
const res = await customsearch.cse.list({
cx: options.cx,
q: options.q,
auth: options.apiKey,
});
console.log(res.data);
return res.data;
} | [
"async",
"function",
"runSample",
"(",
"options",
")",
"{",
"console",
".",
"log",
"(",
"options",
")",
";",
"const",
"res",
"=",
"await",
"customsearch",
".",
"cse",
".",
"list",
"(",
"{",
"cx",
":",
"options",
".",
"cx",
",",
"q",
":",
"options",
... | Ex: node customsearch.js "Google Node.js" "API KEY" "CUSTOM ENGINE ID" | [
"Ex",
":",
"node",
"customsearch",
".",
"js",
"Google",
"Node",
".",
"js",
"API",
"KEY",
"CUSTOM",
"ENGINE",
"ID"
] | e6e632a29d0b246d058e3067de3a5c3827e2b54e | https://github.com/googleapis/google-api-nodejs-client/blob/e6e632a29d0b246d058e3067de3a5c3827e2b54e/samples/customsearch/customsearch.js#L26-L35 | train | A sample function that runs the customsearch API | [
30522,
2004,
6038,
2278,
3853,
3216,
16613,
2571,
1006,
7047,
1007,
1063,
10122,
1012,
8833,
1006,
7047,
1007,
1025,
9530,
3367,
24501,
1027,
26751,
8205,
14644,
2818,
1012,
20116,
2063,
1012,
2862,
1006,
1063,
1039,
2595,
1024,
7047,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-node/lib/client.js | Client | function Client(dsn, options) {
if (dsn instanceof Client) return dsn;
var ravenInstance = new Raven();
return ravenInstance.config.apply(ravenInstance, arguments);
} | javascript | function Client(dsn, options) {
if (dsn instanceof Client) return dsn;
var ravenInstance = new Raven();
return ravenInstance.config.apply(ravenInstance, arguments);
} | [
"function",
"Client",
"(",
"dsn",
",",
"options",
")",
"{",
"if",
"(",
"dsn",
"instanceof",
"Client",
")",
"return",
"dsn",
";",
"var",
"ravenInstance",
"=",
"new",
"Raven",
"(",
")",
";",
"return",
"ravenInstance",
".",
"config",
".",
"apply",
"(",
"r... | Maintain old API compat, need to make sure arguments length is preserved | [
"Maintain",
"old",
"API",
"compat",
"need",
"to",
"make",
"sure",
"arguments",
"length",
"is",
"preserved"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-node/lib/client.js#L662-L666 | train | Create a new client | [
30522,
3853,
7396,
1006,
16233,
2078,
1010,
7047,
1007,
1063,
2065,
1006,
16233,
2078,
6013,
11253,
7396,
1007,
2709,
16233,
2078,
1025,
13075,
10000,
7076,
26897,
1027,
2047,
10000,
1006,
1007,
1025,
2709,
10000,
7076,
26897,
1012,
9530,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
exceljs/exceljs | lib/xlsx/xform/style/styles-xform.js | function(id) {
// if the style doesn't exist return null
var style = this.model.styles[id];
if (!style) return null;
// have we built this model before?
var model = this.index.model[id];
if (model) return model;
// build a new model
model = this.index.model[id] = {};
// -------------------------------------------------------
// number format
if (style.numFmtId) {
var numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId);
if (numFmt) {
model.numFmt = numFmt;
}
}
function addStyle(name, group, styleId) {
if (styleId) {
var part = group[styleId];
if (part) {
model[name] = part;
}
}
}
addStyle('font', this.model.fonts, style.fontId);
addStyle('border', this.model.borders, style.borderId);
addStyle('fill', this.model.fills, style.fillId);
// -------------------------------------------------------
// alignment
if (style.alignment) {
model.alignment = style.alignment;
}
return model;
} | javascript | function(id) {
// if the style doesn't exist return null
var style = this.model.styles[id];
if (!style) return null;
// have we built this model before?
var model = this.index.model[id];
if (model) return model;
// build a new model
model = this.index.model[id] = {};
// -------------------------------------------------------
// number format
if (style.numFmtId) {
var numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId);
if (numFmt) {
model.numFmt = numFmt;
}
}
function addStyle(name, group, styleId) {
if (styleId) {
var part = group[styleId];
if (part) {
model[name] = part;
}
}
}
addStyle('font', this.model.fonts, style.fontId);
addStyle('border', this.model.borders, style.borderId);
addStyle('fill', this.model.fills, style.fillId);
// -------------------------------------------------------
// alignment
if (style.alignment) {
model.alignment = style.alignment;
}
return model;
} | [
"function",
"(",
"id",
")",
"{",
"// if the style doesn't exist return null",
"var",
"style",
"=",
"this",
".",
"model",
".",
"styles",
"[",
"id",
"]",
";",
"if",
"(",
"!",
"style",
")",
"return",
"null",
";",
"// have we built this model before?",
"var",
"mod... | given a styleId (i.e. s="n"), get the cell's style model objects are shared where possible. | [
"given",
"a",
"styleId",
"(",
"i",
".",
"e",
".",
"s",
"=",
"n",
")",
"get",
"the",
"cell",
"s",
"style",
"model",
"objects",
"are",
"shared",
"where",
"possible",
"."
] | c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2 | https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/xlsx/xform/style/styles-xform.js#L292-L333 | train | returns a model for the given id | [
30522,
3853,
1006,
8909,
1007,
1063,
1013,
1013,
2065,
1996,
2806,
2987,
1005,
1056,
4839,
2709,
19701,
13075,
2806,
1027,
2023,
1012,
2944,
1012,
6782,
1031,
8909,
1033,
1025,
2065,
1006,
999,
2806,
1007,
2709,
19701,
1025,
1013,
30524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/lines-around-comment.js | isCommentAtParentStart | function isCommentAtParentStart(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
token.loc.start.line - parent.loc.start.line === 1;
} | javascript | function isCommentAtParentStart(token, nodeType) {
const parent = getParentNodeOfToken(token);
return parent && isParentNodeType(parent, nodeType) &&
token.loc.start.line - parent.loc.start.line === 1;
} | [
"function",
"isCommentAtParentStart",
"(",
"token",
",",
"nodeType",
")",
"{",
"const",
"parent",
"=",
"getParentNodeOfToken",
"(",
"token",
")",
";",
"return",
"parent",
"&&",
"isParentNodeType",
"(",
"parent",
",",
"nodeType",
")",
"&&",
"token",
".",
"loc",... | Returns whether or not comments are at the parent start or not.
@param {token} token The Comment token.
@param {string} nodeType The parent type to check against.
@returns {boolean} True if the comment is at parent start. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"at",
"the",
"parent",
"start",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L202-L207 | train | Check if comment is at parent start of node | [
30522,
3853,
2003,
9006,
3672,
4017,
19362,
11187,
7559,
2102,
1006,
19204,
1010,
13045,
13874,
1007,
1063,
9530,
3367,
6687,
1027,
2131,
19362,
4765,
3630,
3207,
15794,
11045,
2078,
1006,
19204,
1007,
1025,
2709,
6687,
1004,
1004,
2003,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sDateStyle, sTimeStyle, sCalendarType) {
assert(sDateStyle == "short" || sDateStyle == "medium" || sDateStyle == "long" || sDateStyle == "full", "sStyle must be short, medium, long or full");
assert(sTimeStyle == "short" || sTimeStyle == "medium" || sTimeStyle == "long" || sTimeStyle == "full", "sStyle must be short, medium, long or full");
var sDateTimePattern = this.getDateTimePattern(sDateStyle, sCalendarType),
sDatePattern = this.getDatePattern(sDateStyle, sCalendarType),
sTimePattern = this.getTimePattern(sTimeStyle, sCalendarType);
return sDateTimePattern.replace("{0}", sTimePattern).replace("{1}", sDatePattern);
} | javascript | function(sDateStyle, sTimeStyle, sCalendarType) {
assert(sDateStyle == "short" || sDateStyle == "medium" || sDateStyle == "long" || sDateStyle == "full", "sStyle must be short, medium, long or full");
assert(sTimeStyle == "short" || sTimeStyle == "medium" || sTimeStyle == "long" || sTimeStyle == "full", "sStyle must be short, medium, long or full");
var sDateTimePattern = this.getDateTimePattern(sDateStyle, sCalendarType),
sDatePattern = this.getDatePattern(sDateStyle, sCalendarType),
sTimePattern = this.getTimePattern(sTimeStyle, sCalendarType);
return sDateTimePattern.replace("{0}", sTimePattern).replace("{1}", sDatePattern);
} | [
"function",
"(",
"sDateStyle",
",",
"sTimeStyle",
",",
"sCalendarType",
")",
"{",
"assert",
"(",
"sDateStyle",
"==",
"\"short\"",
"||",
"sDateStyle",
"==",
"\"medium\"",
"||",
"sDateStyle",
"==",
"\"long\"",
"||",
"sDateStyle",
"==",
"\"full\"",
",",
"\"sStyle m... | Get combined datetime pattern with given date and and time style.
@param {string} sDateStyle the required style for the date part
@param {string} sTimeStyle the required style for the time part
@param {sap.ui.core.CalendarType} [sCalendarType] the type of calendar. If it's not set, it falls back to the calendar type either set in configuration or calculated from locale.
@returns {string} the combined datetime pattern
@public | [
"Get",
"combined",
"datetime",
"pattern",
"with",
"given",
"date",
"and",
"and",
"time",
"style",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L247-L254 | train | Returns a date time pattern for the given date style and time style. | [
30522,
3853,
1006,
17371,
8520,
27983,
1010,
2358,
14428,
21756,
2571,
1010,
4094,
8943,
5339,
18863,
1007,
1063,
20865,
1006,
17371,
8520,
27983,
1027,
1027,
1000,
2460,
1000,
1064,
1064,
17371,
8520,
27983,
1027,
1027,
1000,
5396,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_getCategoryId | function addonsManager_getCategoryId(aSpec) {
var spec = aSpec || { };
var category = spec.category;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
return category.getNode().id;
} | javascript | function addonsManager_getCategoryId(aSpec) {
var spec = aSpec || { };
var category = spec.category;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
return category.getNode().id;
} | [
"function",
"addonsManager_getCategoryId",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"category",
"=",
"spec",
".",
"category",
";",
"if",
"(",
"!",
"category",
")",
"throw",
"new",
"Error",
"(",
"arguments",
".",
... | Get the ID of the given category element
@param {object} aSpec
Information for getting a category
Elements: category - Category to get the id from
@returns Category Id
@type {string} | [
"Get",
"the",
"ID",
"of",
"the",
"given",
"category",
"element"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L679-L687 | train | Returns the category id for the given add - ons | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2131,
16280,
20255,
10139,
2094,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
4696,
1027,
28699,
1012,
4696,
1025,
2065,
1006,
999... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/commons/color/get-background-color.js | contentOverlapping | function contentOverlapping(targetElement, bgNode) {
// get content box of target element
// check to see if the current bgNode is overlapping
var targetRect = targetElement.getClientRects()[0];
var obscuringElements = dom.shadowElementsFromPoint(
targetRect.left,
targetRect.top
);
if (obscuringElements) {
for (var i = 0; i < obscuringElements.length; i++) {
if (
obscuringElements[i] !== targetElement &&
obscuringElements[i] === bgNode
) {
return true;
}
}
}
return false;
} | javascript | function contentOverlapping(targetElement, bgNode) {
// get content box of target element
// check to see if the current bgNode is overlapping
var targetRect = targetElement.getClientRects()[0];
var obscuringElements = dom.shadowElementsFromPoint(
targetRect.left,
targetRect.top
);
if (obscuringElements) {
for (var i = 0; i < obscuringElements.length; i++) {
if (
obscuringElements[i] !== targetElement &&
obscuringElements[i] === bgNode
) {
return true;
}
}
}
return false;
} | [
"function",
"contentOverlapping",
"(",
"targetElement",
",",
"bgNode",
")",
"{",
"// get content box of target element",
"// check to see if the current bgNode is overlapping",
"var",
"targetRect",
"=",
"targetElement",
".",
"getClientRects",
"(",
")",
"[",
"0",
"]",
";",
... | Determines overlap of node's content with a bgNode. Used for inline elements
@private
@param {Element} targetElement
@param {Element} bgNode
@return {Boolean} | [
"Determines",
"overlap",
"of",
"node",
"s",
"content",
"with",
"a",
"bgNode",
".",
"Used",
"for",
"inline",
"elements"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/color/get-background-color.js#L338-L357 | train | check if target element is overlapping with bgNode | [
30522,
3853,
4180,
7840,
2721,
14853,
1006,
4539,
12260,
3672,
1010,
1038,
26745,
3207,
1007,
1063,
1013,
1013,
2131,
4180,
3482,
1997,
4539,
5783,
1013,
1013,
4638,
2000,
2156,
2065,
1996,
2783,
1038,
26745,
3207,
2003,
20567,
13075,
4539,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | examples/3d/js/map.js | function(point, angle, range) {
var sin = Math.sin(angle);
var cos = Math.cos(angle);
return this.ray(sin, cos, range, {
x: point.x,
y: point.y,
height: 0,
dist: 0
});
} | javascript | function(point, angle, range) {
var sin = Math.sin(angle);
var cos = Math.cos(angle);
return this.ray(sin, cos, range, {
x: point.x,
y: point.y,
height: 0,
dist: 0
});
} | [
"function",
"(",
"point",
",",
"angle",
",",
"range",
")",
"{",
"var",
"sin",
"=",
"Math",
".",
"sin",
"(",
"angle",
")",
";",
"var",
"cos",
"=",
"Math",
".",
"cos",
"(",
"angle",
")",
";",
"return",
"this",
".",
"ray",
"(",
"sin",
",",
"cos",
... | Casts a ray from the camera and returns the results.
@param {Object} point Player/camera's x/y position.
@param {Number} angle Angle (in radians) of camera.
@param {Number} range Max length of the ray. | [
"Casts",
"a",
"ray",
"from",
"the",
"camera",
"and",
"returns",
"the",
"results",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/map.js#L140-L150 | train | Returns a ray of the given point on the cluster | [
30522,
3853,
1006,
2391,
1010,
6466,
1010,
2846,
1007,
1063,
13075,
8254,
1027,
8785,
1012,
8254,
1006,
6466,
1007,
1025,
13075,
2522,
2015,
1027,
8785,
1012,
2522,
2015,
1006,
6466,
1007,
1025,
2709,
2023,
1012,
4097,
1006,
8254,
1010,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GoogleChrome/workbox | packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js | generateMetadataForAssets | function generateMetadataForAssets(assets, chunks) {
const mapping = {};
// Start out by getting metadata for all the assets associated with a chunk.
for (const chunk of chunks) {
for (const file of chunk.files) {
mapping[file] = {
chunkName: chunk.name,
hash: chunk.renderedHash,
};
}
}
// Next, loop through the total list of assets and find anything that isn't
// associated with a chunk.
for (const [file, asset] of Object.entries(assets)) {
if (file in mapping) {
continue;
}
mapping[file] = {
// Just use an empty string to denote the lack of chunk association.
chunkName: '',
hash: getAssetHash(asset),
};
}
return mapping;
} | javascript | function generateMetadataForAssets(assets, chunks) {
const mapping = {};
// Start out by getting metadata for all the assets associated with a chunk.
for (const chunk of chunks) {
for (const file of chunk.files) {
mapping[file] = {
chunkName: chunk.name,
hash: chunk.renderedHash,
};
}
}
// Next, loop through the total list of assets and find anything that isn't
// associated with a chunk.
for (const [file, asset] of Object.entries(assets)) {
if (file in mapping) {
continue;
}
mapping[file] = {
// Just use an empty string to denote the lack of chunk association.
chunkName: '',
hash: getAssetHash(asset),
};
}
return mapping;
} | [
"function",
"generateMetadataForAssets",
"(",
"assets",
",",
"chunks",
")",
"{",
"const",
"mapping",
"=",
"{",
"}",
";",
"// Start out by getting metadata for all the assets associated with a chunk.",
"for",
"(",
"const",
"chunk",
"of",
"chunks",
")",
"{",
"for",
"(",... | Takes in compilation.assets and compilation.chunks, and assigns metadata
to each file listed in assets:
- If the asset was created by a chunk, it assigns the existing chunk name and
chunk hash.
- If the asset was created outside of a chunk, it assigns a chunk name of ''
and generates a hash of the asset.
@param {Object} assets The compilation.assets
@param {Array<Object>} chunks The compilation.chunks
@return {Object<string, Object>} Mapping of asset paths to chunk name and
hash metadata.
@private | [
"Takes",
"in",
"compilation",
".",
"assets",
"and",
"compilation",
".",
"chunks",
"and",
"assigns",
"metadata",
"to",
"each",
"file",
"listed",
"in",
"assets",
":"
] | 8379c51b6deaf52faed5879206fe84579cae41f0 | https://github.com/GoogleChrome/workbox/blob/8379c51b6deaf52faed5879206fe84579cae41f0/packages/workbox-webpack-plugin/src/lib/get-manifest-entries-from-compilation.js#L99-L127 | train | Generate metadata for all the assets associated with a chunk. | [
30522,
3853,
9699,
11368,
8447,
2696,
29278,
27241,
3215,
1006,
7045,
1010,
24839,
1007,
1063,
9530,
3367,
12375,
1027,
1063,
1065,
1025,
1013,
1013,
2707,
2041,
2011,
2893,
27425,
2005,
2035,
1996,
7045,
3378,
2007,
1037,
20000,
1012,
2005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebaseui-web | gulpfile.js | buildFirebaseUiJs | function buildFirebaseUiJs(locale) {
const flags = {
closure_entry_point: 'firebaseui.auth.exports',
define: `goog.LOCALE='${locale}'`,
externs: [
'node_modules/firebase/externs/firebase-app-externs.js',
'node_modules/firebase/externs/firebase-auth-externs.js',
'node_modules/firebase/externs/firebase-client-auth-externs.js'
],
only_closure_dependencies: true,
output_wrapper: OUTPUT_WRAPPER,
// This is required to match XTB IDs to the JS/Soy messages.
translations_project: 'FirebaseUI'
};
if (locale !== DEFAULT_LOCALE) {
flags.translations_file = `translations/${locale}.xtb`;
}
return compile([
'node_modules/google-closure-templates/javascript/soyutils_usegoog.js',
'node_modules/google-closure-library/closure/goog/**/*.js',
'node_modules/google-closure-library/third_party/closure/goog/**/*.js',
`${TMP_DIR}/**/*.js`,
'javascript/**/*.js'
], getTmpJsPath(locale), flags);
} | javascript | function buildFirebaseUiJs(locale) {
const flags = {
closure_entry_point: 'firebaseui.auth.exports',
define: `goog.LOCALE='${locale}'`,
externs: [
'node_modules/firebase/externs/firebase-app-externs.js',
'node_modules/firebase/externs/firebase-auth-externs.js',
'node_modules/firebase/externs/firebase-client-auth-externs.js'
],
only_closure_dependencies: true,
output_wrapper: OUTPUT_WRAPPER,
// This is required to match XTB IDs to the JS/Soy messages.
translations_project: 'FirebaseUI'
};
if (locale !== DEFAULT_LOCALE) {
flags.translations_file = `translations/${locale}.xtb`;
}
return compile([
'node_modules/google-closure-templates/javascript/soyutils_usegoog.js',
'node_modules/google-closure-library/closure/goog/**/*.js',
'node_modules/google-closure-library/third_party/closure/goog/**/*.js',
`${TMP_DIR}/**/*.js`,
'javascript/**/*.js'
], getTmpJsPath(locale), flags);
} | [
"function",
"buildFirebaseUiJs",
"(",
"locale",
")",
"{",
"const",
"flags",
"=",
"{",
"closure_entry_point",
":",
"'firebaseui.auth.exports'",
",",
"define",
":",
"`",
"${",
"locale",
"}",
"`",
",",
"externs",
":",
"[",
"'node_modules/firebase/externs/firebase-app-e... | Builds the core FirebaseUI binary in the given locale.
@param {string} locale
@return {*} A stream that finishes when compilation finishes. | [
"Builds",
"the",
"core",
"FirebaseUI",
"binary",
"in",
"the",
"given",
"locale",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/gulpfile.js#L186-L211 | train | Build Firebase UI JS | [
30522,
3853,
3857,
10273,
15058,
10179,
22578,
1006,
2334,
2063,
1007,
1063,
9530,
3367,
9245,
1027,
1063,
8503,
1035,
4443,
1035,
2391,
1024,
1005,
2543,
15058,
10179,
1012,
8740,
2705,
1012,
14338,
1005,
1010,
9375,
1024,
1036,
27571,
229... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/util/symbol.js | symbolPathSetColor | function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
} | javascript | function symbolPathSetColor(color, innerColor) {
if (this.type !== 'image') {
var symbolStyle = this.style;
var symbolShape = this.shape;
if (symbolShape && symbolShape.symbolType === 'line') {
symbolStyle.stroke = color;
}
else if (this.__isEmptyBrush) {
symbolStyle.stroke = color;
symbolStyle.fill = innerColor || '#fff';
}
else {
// FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
symbolStyle.fill && (symbolStyle.fill = color);
symbolStyle.stroke && (symbolStyle.stroke = color);
}
this.dirty(false);
}
} | [
"function",
"symbolPathSetColor",
"(",
"color",
",",
"innerColor",
")",
"{",
"if",
"(",
"this",
".",
"type",
"!==",
"'image'",
")",
"{",
"var",
"symbolStyle",
"=",
"this",
".",
"style",
";",
"var",
"symbolShape",
"=",
"this",
".",
"shape",
";",
"if",
"... | Provide setColor helper method to avoid determine if set the fill or stroke outside | [
"Provide",
"setColor",
"helper",
"method",
"to",
"avoid",
"determine",
"if",
"set",
"the",
"fill",
"or",
"stroke",
"outside"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/symbol.js#L301-L319 | train | set color of symbol | [
30522,
3853,
6454,
15069,
13462,
18717,
1006,
3609,
1010,
5110,
18717,
1007,
1063,
2065,
1006,
2023,
1012,
2828,
999,
1027,
1027,
1005,
3746,
1005,
1007,
1063,
13075,
9255,
27983,
1027,
2023,
1012,
2806,
1025,
13075,
9255,
3270,
5051,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FindInFiles.js | _removeListeners | function _removeListeners() {
DocumentModule.off("documentChange", _documentChangeHandler);
FileSystem.off("change", _debouncedFileSystemChangeHandler);
DocumentManager.off("fileNameChange", _fileNameChangeHandler);
} | javascript | function _removeListeners() {
DocumentModule.off("documentChange", _documentChangeHandler);
FileSystem.off("change", _debouncedFileSystemChangeHandler);
DocumentManager.off("fileNameChange", _fileNameChangeHandler);
} | [
"function",
"_removeListeners",
"(",
")",
"{",
"DocumentModule",
".",
"off",
"(",
"\"documentChange\"",
",",
"_documentChangeHandler",
")",
";",
"FileSystem",
".",
"off",
"(",
"\"change\"",
",",
"_debouncedFileSystemChangeHandler",
")",
";",
"DocumentManager",
".",
... | Remove the listeners that were tracking potential search result changes | [
"Remove",
"the",
"listeners",
"that",
"were",
"tracking",
"potential",
"search",
"result",
"changes"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFiles.js#L91-L95 | train | Remove all listeners | [
30522,
3853,
1035,
6366,
9863,
24454,
2015,
1006,
1007,
1063,
6254,
5302,
8566,
2571,
1012,
2125,
1006,
1000,
6254,
22305,
2063,
1000,
1010,
1035,
6254,
22305,
24660,
21222,
1007,
1025,
6764,
27268,
6633,
1012,
2125,
1006,
1000,
2689,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js | function (sBootstrapURL) {
var oModel = this._oDialog.getModel("view"),
oSettings = {
// start the application in support mode
support: "true",
// open in new window
window: oModel.getProperty("/OpenSupportAssistantInNewWindow")
};
this._loadAssistant(sBootstrapURL, oSettings);
} | javascript | function (sBootstrapURL) {
var oModel = this._oDialog.getModel("view"),
oSettings = {
// start the application in support mode
support: "true",
// open in new window
window: oModel.getProperty("/OpenSupportAssistantInNewWindow")
};
this._loadAssistant(sBootstrapURL, oSettings);
} | [
"function",
"(",
"sBootstrapURL",
")",
"{",
"var",
"oModel",
"=",
"this",
".",
"_oDialog",
".",
"getModel",
"(",
"\"view\"",
")",
",",
"oSettings",
"=",
"{",
"// start the application in support mode",
"support",
":",
"\"true\"",
",",
"// open in new window",
"win... | Start the support assistant with the given bootstrap URL
By default, it is started with the current version for >=1.48 release or SAPUI5 CDN version for lower releases.
This behavior can be overridden by specifying a custom bootstrap URL where the support assistant is loaded from
@param {string} [sBootstrapURL] If specified, the support assistant will be started with a custom bootstrap URL.
@private | [
"Start",
"the",
"support",
"assistant",
"with",
"the",
"given",
"bootstrap",
"URL",
"By",
"default",
"it",
"is",
"started",
"with",
"the",
"current",
"version",
"for",
">",
"=",
"1",
".",
"48",
"release",
"or",
"SAPUI5",
"CDN",
"version",
"for",
"lower",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/TechnicalInfo.js#L511-L521 | train | Load the assistant | [
30522,
3853,
1006,
24829,
17206,
20528,
5311,
2140,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
2023,
1012,
1035,
21045,
23067,
2290,
1012,
2131,
5302,
9247,
1006,
1000,
3193,
1000,
1007,
1010,
9808,
18319,
3070,
2015,
1027,
1063,
1013,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | examples/hello-mui/js/update.js | update | function update() {
mui.getJSON(server, {
"appid": plus.runtime.appid,
"version": plus.runtime.version,
"imei": plus.device.imei
}, function(data) {
if (data.status) {
plus.nativeUI.confirm(data.note, function(event) {
if (0 == event.index) {
plus.runtime.openURL(data.url);
}
}, data.title, ["立即更新", "取 消"]);
}
});
} | javascript | function update() {
mui.getJSON(server, {
"appid": plus.runtime.appid,
"version": plus.runtime.version,
"imei": plus.device.imei
}, function(data) {
if (data.status) {
plus.nativeUI.confirm(data.note, function(event) {
if (0 == event.index) {
plus.runtime.openURL(data.url);
}
}, data.title, ["立即更新", "取 消"]);
}
});
} | [
"function",
"update",
"(",
")",
"{",
"mui",
".",
"getJSON",
"(",
"server",
",",
"{",
"\"appid\"",
":",
"plus",
".",
"runtime",
".",
"appid",
",",
"\"version\"",
":",
"plus",
".",
"runtime",
".",
"version",
",",
"\"imei\"",
":",
"plus",
".",
"device",
... | 获取升级描述文件服务器地址 | [
"获取升级描述文件服务器地址"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/update.js#L19-L33 | train | update the device | [
30522,
3853,
10651,
1006,
1007,
1063,
14163,
2072,
1012,
2131,
22578,
2239,
1006,
8241,
1010,
1063,
1000,
10439,
3593,
1000,
1024,
4606,
1012,
2448,
7292,
1012,
10439,
3593,
1010,
1000,
2544,
1000,
1024,
4606,
1012,
2448,
7292,
1012,
2544,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function (sPropertyValue) {
var bIsBinding = false;
if (sPropertyValue && typeof sPropertyValue === "string" && sPropertyValue.substring(0, 1) === "{" && sPropertyValue.slice(-1) === "}") {
bIsBinding = true;
}
return bIsBinding;
} | javascript | function (sPropertyValue) {
var bIsBinding = false;
if (sPropertyValue && typeof sPropertyValue === "string" && sPropertyValue.substring(0, 1) === "{" && sPropertyValue.slice(-1) === "}") {
bIsBinding = true;
}
return bIsBinding;
} | [
"function",
"(",
"sPropertyValue",
")",
"{",
"var",
"bIsBinding",
"=",
"false",
";",
"if",
"(",
"sPropertyValue",
"&&",
"typeof",
"sPropertyValue",
"===",
"\"string\"",
"&&",
"sPropertyValue",
".",
"substring",
"(",
"0",
",",
"1",
")",
"===",
"\"{\"",
"&&",
... | Indicates if the property value represents a binding
@param {object} sPropertyValue - Property value
@returns {boolean} true if value represents a binding
@public
@function
@name sap.ui.fl.Utils.isBinding | [
"Indicates",
"if",
"the",
"property",
"value",
"represents",
"a",
"binding"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L316-L322 | train | Determines if the given property value is a binding | [
30522,
3853,
1006,
11867,
18981,
15010,
10175,
5657,
1007,
1063,
13075,
20377,
8428,
4667,
1027,
6270,
1025,
2065,
1006,
11867,
18981,
15010,
10175,
5657,
1004,
1004,
2828,
11253,
11867,
18981,
15010,
10175,
5657,
1027,
1027,
1027,
1000,
5164... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/util/timing.js | alignLeft | function alignLeft(str, len, ch) {
return str + new Array(len - str.length + 1).join(ch || " ");
} | javascript | function alignLeft(str, len, ch) {
return str + new Array(len - str.length + 1).join(ch || " ");
} | [
"function",
"alignLeft",
"(",
"str",
",",
"len",
",",
"ch",
")",
"{",
"return",
"str",
"+",
"new",
"Array",
"(",
"len",
"-",
"str",
".",
"length",
"+",
"1",
")",
".",
"join",
"(",
"ch",
"||",
"\" \"",
")",
";",
"}"
] | /* istanbul ignore next
Align the string to left
@param {string} str string to evaluate
@param {int} len length of the string
@param {string} ch delimiter character
@returns {string} modified string
@private | [
"/",
"*",
"istanbul",
"ignore",
"next",
"Align",
"the",
"string",
"to",
"left"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/timing.js#L21-L23 | train | Aligns str to the left | [
30522,
3853,
25705,
2571,
6199,
1006,
2358,
2099,
1010,
18798,
1010,
10381,
1007,
1063,
2709,
2358,
2099,
1009,
2047,
9140,
1006,
18798,
1011,
2358,
2099,
1012,
3091,
1009,
1015,
1007,
1012,
3693,
1006,
10381,
1064,
1064,
1000,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/ast-utils.js | equalTokens | function equalTokens(left, right, sourceCode) {
const tokensL = sourceCode.getTokens(left);
const tokensR = sourceCode.getTokens(right);
if (tokensL.length !== tokensR.length) {
return false;
}
for (let i = 0; i < tokensL.length; ++i) {
if (tokensL[i].type !== tokensR[i].type ||
tokensL[i].value !== tokensR[i].value
) {
return false;
}
}
return true;
} | javascript | function equalTokens(left, right, sourceCode) {
const tokensL = sourceCode.getTokens(left);
const tokensR = sourceCode.getTokens(right);
if (tokensL.length !== tokensR.length) {
return false;
}
for (let i = 0; i < tokensL.length; ++i) {
if (tokensL[i].type !== tokensR[i].type ||
tokensL[i].value !== tokensR[i].value
) {
return false;
}
}
return true;
} | [
"function",
"equalTokens",
"(",
"left",
",",
"right",
",",
"sourceCode",
")",
"{",
"const",
"tokensL",
"=",
"sourceCode",
".",
"getTokens",
"(",
"left",
")",
";",
"const",
"tokensR",
"=",
"sourceCode",
".",
"getTokens",
"(",
"right",
")",
";",
"if",
"(",... | Checks whether or not the tokens of two given nodes are same.
@param {ASTNode} left - A node 1 to compare.
@param {ASTNode} right - A node 2 to compare.
@param {SourceCode} sourceCode - The ESLint source code object.
@returns {boolean} the source code for the given node. | [
"Checks",
"whether",
"or",
"not",
"the",
"tokens",
"of",
"two",
"given",
"nodes",
"are",
"same",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/ast-utils.js#L412-L428 | train | Check if two tokens are equal | [
30522,
3853,
5020,
18715,
6132,
1006,
2187,
1010,
2157,
1010,
3120,
16044,
1007,
1063,
9530,
3367,
19204,
14540,
1027,
3120,
16044,
1012,
2131,
18715,
6132,
1006,
2187,
1007,
1025,
9530,
3367,
19204,
21338,
1027,
3120,
16044,
1012,
2131,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RecordRTC | WebGL-Recording/view.js | init | function init() {
var menu = $('#menu').show();
var scorecard = $('#scorecard').hide();
scorecard.find('.info').html(menu.find('.info').html());
var canvas = $('canvas');
var debug = $('#debug');
// Standard GLGE initialization.
var renderer = new GLGE.Renderer(canvas[0]);
scene = doc.getElement('mainscene');
renderer.setScene(scene);
window.camera = scene.getCamera(); // XXX
var bob = doc.getElement('bob');
var disappear = doc.getElement('disappear');
// TODO: Update this.
var viewport = {
top: 15,
bottom: -15,
left: -25,
right: 25
};
// Initialize the player's ship.
ship.setLocZ(3);
ship.setRotX(Math.PI / 2);
ship.setRotY(Math.PI / 2);
ship.setScale(0.3);
ship.setFrameRate(60);
scene.addChild(ship);
// Initialize the aiming target.
target.setLocZ(0.4);
target.setScale(0.001);
target.setRotX(Math.PI / 2);
target.setRotY(Math.PI / 2);
scene.addChild(target);
// Create the Backbone model and controller.
var ducks = {};
var game = new GameController();
// Show or hide the target and cursor depending on the game mode.
// Cursor-hiding tricks learned from http://stackoverflow.com/questions/2636068
game.bind('start', function() {
if (game.mode === game.PLAY_MODE) {
target.setVisible(GLGE.TRUE);
canvas.css('cursor', 'url(' + blankCursor.src + '), none');
} else {
target.setVisible(GLGE.FALSE);
canvas.css('cursor', 'pointer');
}
});
// Show the scorecard when the last duck has been cleared. Wait a little bit
// after the duck is cleared, otherwise the experience is sudden and jarring.
game.bind('gameover', function(seconds) {
setTimeout(function() {
var rank = game.getRank(seconds);
scorecard.find('.time').text(seconds + ' sec.');
scorecard.find('.rank').text(rank[0]);
scorecard.find('.byline').text(rank[1]);
scorecard.show();
game.start(game.DEMO_MODE);
}, 1000);
});
// Update the model during any mouse movements.
canvas.on('mousemove', function(e) {
if (game.mode !== game.PLAY_MODE) return;
// Get the cursor position.
var mx, my;
if (typeof e.offsetX === 'undefined') {
mx = e.pageX - canvas.position().left;
my = e.pageY - canvas.position().top;
} else {
mx = e.offsetX;
my = e.offsetY;
}
// This is stupid. I should really be casting a ray from the camera to the
// ground, but I'm lazy, and this is close enough.
var cw = canvas.width(), ch = canvas.height();
var vx = (mx / cw) * (viewport.right + -viewport.left) + viewport.left;
var vy = (my / ch) * (viewport.top + -viewport.bottom) + viewport.bottom;
game.setTarget(vx, -vy);
});
// When the ship or target move, update the GLGE objects. Currently the game
// and OpenGL are using the same units so no translation needs to be done.
var oldBank = 0;
game.ship.bind('change', function(model) {
// Update the ship model.
var a = model.attributes;
ship.setLocX(a.x);
ship.setLocY(a.y);
ship.setRotY(Trig.deg2rad(a.dir) + 1.57);
// Update the mouse target.
target.setLocX(a.targetX);
target.setLocY(a.targetY);
// If the ship direction has changed, make it bank to one side or the other.
// BUG: Sometimes the plane banks the wrong way.
var newBank = a.delta < 0 ? -1 : a.delta > 0 ? 1 : 0;
if (newBank != oldBank) {
ship.blendTo({ DRotZ: newBank * 0.7 }, 500);
oldBank = newBank;
}
});
// When a duck is added, create it and add it to the scene. Keep track of it
// in the `ducks` map so we can remove it later.
game.ducks.bind('add', function(model) {
var obj = createDuckie(model, bob);
scene.addChild(obj);
ducks[model.cid] = obj; // Backbone generates the cid property automatically.
});
// Remove a duck once it's removed from the collection invidiually.
game.ducks.bind('remove', function(model) {
var obj = ducks[model.cid];
obj.setAnimation(disappear);
obj.setLoop(GLGE.FALSE);
obj.addEventListener('animFinished', function() {
scene.removeChild(obj);
});
delete ducks[model.cid];
if (game.mode === game.PLAY_MODE) {
pickup.stop().play();
}
});
// If there's a bulk update to the ducks, don't do any animation.
game.ducks.bind('reset', function(models) {
_.each(_.values(ducks), function(obj) {
scene.removeChild(obj);
delete ducks[obj.cid];
});
_.each(models, function(model) {
game.ducks.trigger('add', model);
});
});
// Handle canvas resizing (buggy)
function resize() {
var w = $(window).width(), h = $(window).height();
canvas.attr({ width: w, height: h });
scene.getCamera().setAspect(w / h);
renderer.clearViewport();
}
$(document).on('ready', resize);
$(window).on('resize', resize);
resize();
// Animation loop
(function animloop(){
requestAnimFrame(animloop);
renderer.render();
})();
// Handle the big "Play!" button on the menu and scorecard.
function startNewGame() {
game.start(game.PLAY_MODE);
menu.hide();
scorecard.hide();
}
menu.on('click', 'button', startNewGame);
scorecard.on('click', 'button', startNewGame);
// Start the demo and play some music.
game.start(game.DEMO_MODE);
music.play();
} | javascript | function init() {
var menu = $('#menu').show();
var scorecard = $('#scorecard').hide();
scorecard.find('.info').html(menu.find('.info').html());
var canvas = $('canvas');
var debug = $('#debug');
// Standard GLGE initialization.
var renderer = new GLGE.Renderer(canvas[0]);
scene = doc.getElement('mainscene');
renderer.setScene(scene);
window.camera = scene.getCamera(); // XXX
var bob = doc.getElement('bob');
var disappear = doc.getElement('disappear');
// TODO: Update this.
var viewport = {
top: 15,
bottom: -15,
left: -25,
right: 25
};
// Initialize the player's ship.
ship.setLocZ(3);
ship.setRotX(Math.PI / 2);
ship.setRotY(Math.PI / 2);
ship.setScale(0.3);
ship.setFrameRate(60);
scene.addChild(ship);
// Initialize the aiming target.
target.setLocZ(0.4);
target.setScale(0.001);
target.setRotX(Math.PI / 2);
target.setRotY(Math.PI / 2);
scene.addChild(target);
// Create the Backbone model and controller.
var ducks = {};
var game = new GameController();
// Show or hide the target and cursor depending on the game mode.
// Cursor-hiding tricks learned from http://stackoverflow.com/questions/2636068
game.bind('start', function() {
if (game.mode === game.PLAY_MODE) {
target.setVisible(GLGE.TRUE);
canvas.css('cursor', 'url(' + blankCursor.src + '), none');
} else {
target.setVisible(GLGE.FALSE);
canvas.css('cursor', 'pointer');
}
});
// Show the scorecard when the last duck has been cleared. Wait a little bit
// after the duck is cleared, otherwise the experience is sudden and jarring.
game.bind('gameover', function(seconds) {
setTimeout(function() {
var rank = game.getRank(seconds);
scorecard.find('.time').text(seconds + ' sec.');
scorecard.find('.rank').text(rank[0]);
scorecard.find('.byline').text(rank[1]);
scorecard.show();
game.start(game.DEMO_MODE);
}, 1000);
});
// Update the model during any mouse movements.
canvas.on('mousemove', function(e) {
if (game.mode !== game.PLAY_MODE) return;
// Get the cursor position.
var mx, my;
if (typeof e.offsetX === 'undefined') {
mx = e.pageX - canvas.position().left;
my = e.pageY - canvas.position().top;
} else {
mx = e.offsetX;
my = e.offsetY;
}
// This is stupid. I should really be casting a ray from the camera to the
// ground, but I'm lazy, and this is close enough.
var cw = canvas.width(), ch = canvas.height();
var vx = (mx / cw) * (viewport.right + -viewport.left) + viewport.left;
var vy = (my / ch) * (viewport.top + -viewport.bottom) + viewport.bottom;
game.setTarget(vx, -vy);
});
// When the ship or target move, update the GLGE objects. Currently the game
// and OpenGL are using the same units so no translation needs to be done.
var oldBank = 0;
game.ship.bind('change', function(model) {
// Update the ship model.
var a = model.attributes;
ship.setLocX(a.x);
ship.setLocY(a.y);
ship.setRotY(Trig.deg2rad(a.dir) + 1.57);
// Update the mouse target.
target.setLocX(a.targetX);
target.setLocY(a.targetY);
// If the ship direction has changed, make it bank to one side or the other.
// BUG: Sometimes the plane banks the wrong way.
var newBank = a.delta < 0 ? -1 : a.delta > 0 ? 1 : 0;
if (newBank != oldBank) {
ship.blendTo({ DRotZ: newBank * 0.7 }, 500);
oldBank = newBank;
}
});
// When a duck is added, create it and add it to the scene. Keep track of it
// in the `ducks` map so we can remove it later.
game.ducks.bind('add', function(model) {
var obj = createDuckie(model, bob);
scene.addChild(obj);
ducks[model.cid] = obj; // Backbone generates the cid property automatically.
});
// Remove a duck once it's removed from the collection invidiually.
game.ducks.bind('remove', function(model) {
var obj = ducks[model.cid];
obj.setAnimation(disappear);
obj.setLoop(GLGE.FALSE);
obj.addEventListener('animFinished', function() {
scene.removeChild(obj);
});
delete ducks[model.cid];
if (game.mode === game.PLAY_MODE) {
pickup.stop().play();
}
});
// If there's a bulk update to the ducks, don't do any animation.
game.ducks.bind('reset', function(models) {
_.each(_.values(ducks), function(obj) {
scene.removeChild(obj);
delete ducks[obj.cid];
});
_.each(models, function(model) {
game.ducks.trigger('add', model);
});
});
// Handle canvas resizing (buggy)
function resize() {
var w = $(window).width(), h = $(window).height();
canvas.attr({ width: w, height: h });
scene.getCamera().setAspect(w / h);
renderer.clearViewport();
}
$(document).on('ready', resize);
$(window).on('resize', resize);
resize();
// Animation loop
(function animloop(){
requestAnimFrame(animloop);
renderer.render();
})();
// Handle the big "Play!" button on the menu and scorecard.
function startNewGame() {
game.start(game.PLAY_MODE);
menu.hide();
scorecard.hide();
}
menu.on('click', 'button', startNewGame);
scorecard.on('click', 'button', startNewGame);
// Start the demo and play some music.
game.start(game.DEMO_MODE);
music.play();
} | [
"function",
"init",
"(",
")",
"{",
"var",
"menu",
"=",
"$",
"(",
"'#menu'",
")",
".",
"show",
"(",
")",
";",
"var",
"scorecard",
"=",
"$",
"(",
"'#scorecard'",
")",
".",
"hide",
"(",
")",
";",
"scorecard",
".",
"find",
"(",
"'.info'",
")",
".",
... | Main ==== | [
"Main",
"===="
] | 3c6bad427b9da35c1cf617199ed13dda056c38ba | https://github.com/muaz-khan/RecordRTC/blob/3c6bad427b9da35c1cf617199ed13dda056c38ba/WebGL-Recording/view.js#L138-L316 | train | Initialize the GLGE. | [
30522,
3853,
1999,
4183,
1006,
1007,
1063,
13075,
12183,
1027,
1002,
1006,
1005,
1001,
12183,
1005,
1007,
1012,
2265,
1006,
1007,
1025,
13075,
3556,
30524,
1027,
1002,
1006,
1005,
10683,
1005,
1007,
1025,
13075,
2139,
8569,
2290,
1027,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
airyland/vux | build/build-components.js | buildPlugin | function buildPlugin(name) {
delete config.entry
config.plugins.forEach((one, index) => {
if (one.constructor.name === 'ExtractTextPlugin') {
config.plugins.splice(index, 1)
}
})
config.plugins.push(new ExtractTextPlugin({
filename: 'index.min.css'
}))
config.entry = config.entry || {}
config.entry['plugin'] = `src/plugins/${name.toLowerCase()}/index.js`
config.output = {}
config.output.libraryTarget = 'umd'
config.output.library = `${namespace}${name}Plugin`
config.output.filename = `index.min.js`
config.output.path = path.resolve(__dirname, `../dist/plugins/${name.toLowerCase()}`)
delete config.__vueOptions__
return config
} | javascript | function buildPlugin(name) {
delete config.entry
config.plugins.forEach((one, index) => {
if (one.constructor.name === 'ExtractTextPlugin') {
config.plugins.splice(index, 1)
}
})
config.plugins.push(new ExtractTextPlugin({
filename: 'index.min.css'
}))
config.entry = config.entry || {}
config.entry['plugin'] = `src/plugins/${name.toLowerCase()}/index.js`
config.output = {}
config.output.libraryTarget = 'umd'
config.output.library = `${namespace}${name}Plugin`
config.output.filename = `index.min.js`
config.output.path = path.resolve(__dirname, `../dist/plugins/${name.toLowerCase()}`)
delete config.__vueOptions__
return config
} | [
"function",
"buildPlugin",
"(",
"name",
")",
"{",
"delete",
"config",
".",
"entry",
"config",
".",
"plugins",
".",
"forEach",
"(",
"(",
"one",
",",
"index",
")",
"=>",
"{",
"if",
"(",
"one",
".",
"constructor",
".",
"name",
"===",
"'ExtractTextPlugin'",
... | build plugins | [
"build",
"plugins"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/build/build-components.js#L208-L229 | train | Build a plugin | [
30522,
3853,
3857,
24759,
15916,
2378,
1006,
2171,
1007,
1063,
3972,
12870,
9530,
8873,
2290,
1012,
4443,
9530,
8873,
2290,
1012,
13354,
7076,
1012,
18921,
6776,
1006,
1006,
2028,
1010,
5950,
1007,
1027,
1028,
1063,
2065,
1006,
2028,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moleculerjs/moleculer | examples/middlewares/index.js | middleware2 | function middleware2() {
return function (handler) {
return function mw2(ctx) {
broker.logger.info(chalk.magenta("mw2 before-promise", ctx.action.name));
return new broker.Promise(resolve => {
setTimeout(() => {
broker.logger.info(chalk.magenta("mw2 before", ctx.action.name));
//resolve("data from mw2");
resolve();
}, 300);
}).then(() => {
return handler(ctx);
}).then(res => {
broker.logger.info(chalk.magenta("mw2 after", ctx.action.name));
return res;
});
};
};
} | javascript | function middleware2() {
return function (handler) {
return function mw2(ctx) {
broker.logger.info(chalk.magenta("mw2 before-promise", ctx.action.name));
return new broker.Promise(resolve => {
setTimeout(() => {
broker.logger.info(chalk.magenta("mw2 before", ctx.action.name));
//resolve("data from mw2");
resolve();
}, 300);
}).then(() => {
return handler(ctx);
}).then(res => {
broker.logger.info(chalk.magenta("mw2 after", ctx.action.name));
return res;
});
};
};
} | [
"function",
"middleware2",
"(",
")",
"{",
"return",
"function",
"(",
"handler",
")",
"{",
"return",
"function",
"mw2",
"(",
"ctx",
")",
"{",
"broker",
".",
"logger",
".",
"info",
"(",
"chalk",
".",
"magenta",
"(",
"\"mw2 before-promise\"",
",",
"ctx",
".... | Promise example | [
"Promise",
"example"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/examples/middlewares/index.js#L25-L44 | train | Middleware for middleware2 | [
30522,
3853,
2690,
8059,
2475,
1006,
1007,
1063,
2709,
3853,
1006,
28213,
1007,
1063,
2709,
3853,
12464,
2475,
1006,
14931,
2595,
1007,
1063,
20138,
1012,
8833,
4590,
1012,
18558,
1006,
16833,
1012,
17454,
12380,
1006,
1000,
12464,
2475,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/StepEditor.js | function (settings) {
var setting, i, j, last, interval,
sp = this.stepParams,
isStart = (sp.timing === "start"),
p = [];
var defaultSettings = {
bgColor: "transparent",
borderColor: "#bbb",
stepColor: "#2893ef",
dashColor: "#b8b8b8",
borderWidth: 0.00667,
stepLineWidth: 0.02,
dashLineWidth: 0.008,
pointLineWidth: 0.008,
pointRadius: 0.015
};
this.settings = settings || {};
for (setting in defaultSettings) {
if (defaultSettings.hasOwnProperty(setting)) {
if (!this.settings.hasOwnProperty(setting)) {
this.settings[setting] = defaultSettings[setting];
}
}
}
this.ctx = this.canvas.getContext("2d");
// Build points array. There's a starting point at 0,0
// plus a point for each step
p[0] = { x: 0, y: 0 };
for (i = 1; i <= sp.count; i++) {
interval = i / sp.count;
p[i] = { x: interval, y: interval };
}
// Start with a clean slate
this.ctx.clearRect(-0.5, -0.5, 2, 2);
this.drawBackground();
// Draw each interval
last = p.length - 1;
for (i = 0, j = 1; i < last; i++, j++) {
if (isStart) {
this.drawStartInterval(p[i].x, p[i].y, p[j].x, p[j].y);
} else {
this.drawEndInterval(p[i].x, p[i].y, p[j].x, p[j].y);
}
}
// Each interval draws start and mid point for that interval,
// so we need to draw last point. It's always filled.
this.drawPoint(p[last].x, p[last].y, true);
} | javascript | function (settings) {
var setting, i, j, last, interval,
sp = this.stepParams,
isStart = (sp.timing === "start"),
p = [];
var defaultSettings = {
bgColor: "transparent",
borderColor: "#bbb",
stepColor: "#2893ef",
dashColor: "#b8b8b8",
borderWidth: 0.00667,
stepLineWidth: 0.02,
dashLineWidth: 0.008,
pointLineWidth: 0.008,
pointRadius: 0.015
};
this.settings = settings || {};
for (setting in defaultSettings) {
if (defaultSettings.hasOwnProperty(setting)) {
if (!this.settings.hasOwnProperty(setting)) {
this.settings[setting] = defaultSettings[setting];
}
}
}
this.ctx = this.canvas.getContext("2d");
// Build points array. There's a starting point at 0,0
// plus a point for each step
p[0] = { x: 0, y: 0 };
for (i = 1; i <= sp.count; i++) {
interval = i / sp.count;
p[i] = { x: interval, y: interval };
}
// Start with a clean slate
this.ctx.clearRect(-0.5, -0.5, 2, 2);
this.drawBackground();
// Draw each interval
last = p.length - 1;
for (i = 0, j = 1; i < last; i++, j++) {
if (isStart) {
this.drawStartInterval(p[i].x, p[i].y, p[j].x, p[j].y);
} else {
this.drawEndInterval(p[i].x, p[i].y, p[j].x, p[j].y);
}
}
// Each interval draws start and mid point for that interval,
// so we need to draw last point. It's always filled.
this.drawPoint(p[last].x, p[last].y, true);
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"setting",
",",
"i",
",",
"j",
",",
"last",
",",
"interval",
",",
"sp",
"=",
"this",
".",
"stepParams",
",",
"isStart",
"=",
"(",
"sp",
".",
"timing",
"===",
"\"start\"",
")",
",",
"p",
"=",
"[",
"]",... | Paint canvas
@param {Object} settings Paint settings | [
"Paint",
"canvas"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/StepEditor.js#L158-L213 | train | This function is the main function of the algorithm | [
30522,
3853,
1006,
10906,
1007,
1063,
13075,
4292,
1010,
1045,
1010,
1046,
1010,
2197,
1010,
13483,
1010,
11867,
1027,
2023,
1012,
3357,
28689,
5244,
1010,
26354,
7559,
2102,
1027,
1006,
11867,
1012,
10984,
1027,
1027,
1027,
1000,
2707,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/StaticServer/node/StaticServerDomain.js | _cmdSetRequestFilterPaths | function _cmdSetRequestFilterPaths(root, paths) {
var pathKey = getPathKey(root),
rewritePaths = {};
// reset list of filtered paths for each call to setRequestFilterPaths
_rewritePaths[pathKey] = rewritePaths;
paths.forEach(function (path) {
rewritePaths[path] = pathJoin(root, path);
});
} | javascript | function _cmdSetRequestFilterPaths(root, paths) {
var pathKey = getPathKey(root),
rewritePaths = {};
// reset list of filtered paths for each call to setRequestFilterPaths
_rewritePaths[pathKey] = rewritePaths;
paths.forEach(function (path) {
rewritePaths[path] = pathJoin(root, path);
});
} | [
"function",
"_cmdSetRequestFilterPaths",
"(",
"root",
",",
"paths",
")",
"{",
"var",
"pathKey",
"=",
"getPathKey",
"(",
"root",
")",
",",
"rewritePaths",
"=",
"{",
"}",
";",
"// reset list of filtered paths for each call to setRequestFilterPaths",
"_rewritePaths",
"[",
... | @private
Defines a set of paths from a server's root path to watch and fire "request" events for.
@param {string} path The absolute path whose server we should watch
@param {Array.<string>} paths An array of root-relative paths to watch.
Each path should begin with a forward slash "/". | [
"@private",
"Defines",
"a",
"set",
"of",
"paths",
"from",
"a",
"server",
"s",
"root",
"path",
"to",
"watch",
"and",
"fire",
"request",
"events",
"for",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/StaticServer/node/StaticServerDomain.js#L313-L323 | train | Set the paths to be filtered by the application | [
30522,
3853,
1035,
4642,
5104,
3388,
2890,
15500,
8873,
21928,
15069,
2015,
1006,
7117,
1010,
10425,
1007,
1063,
13075,
4130,
14839,
1027,
2131,
15069,
14839,
1006,
7117,
1007,
1010,
2128,
26373,
15069,
2015,
1027,
1063,
1065,
1025,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (elem)
{
var i, el, j, tag, attribute, value, css, cssAttrs, attr, cssName, cssValue;
if (elem.nodeType == Strophe.ElementType.NORMAL) {
tag = elem.nodeName;
if(Strophe.XHTML.validTag(tag)) {
try {
el = Strophe.xmlElement(tag);
for(i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
attribute = Strophe.XHTML.attributes[tag][i];
value = elem.getAttribute(attribute);
if(typeof value == 'undefined' || value === null || value === '' || value === false || value === 0) {
continue;
}
if(attribute == 'style' && typeof value == 'object') {
if(typeof value.cssText != 'undefined') {
value = value.cssText; // we're dealing with IE, need to get CSS out
}
}
// filter out invalid css styles
if(attribute == 'style') {
css = [];
cssAttrs = value.split(';');
for(j = 0; j < cssAttrs.length; j++) {
attr = cssAttrs[j].split(':');
cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
if(Strophe.XHTML.validCSS(cssName)) {
cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
css.push(cssName + ': ' + cssValue);
}
}
if(css.length > 0) {
value = css.join('; ');
el.setAttribute(attribute, value);
}
} else {
el.setAttribute(attribute, value);
}
}
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
} catch(e) { // invalid elements
el = Strophe.xmlTextNode('');
}
} else {
el = Strophe.xmlGenerator().createDocumentFragment();
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
}
} else if (elem.nodeType == Strophe.ElementType.FRAGMENT) {
el = Strophe.xmlGenerator().createDocumentFragment();
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
} else if (elem.nodeType == Strophe.ElementType.TEXT) {
el = Strophe.xmlTextNode(elem.nodeValue);
}
return el;
} | javascript | function (elem)
{
var i, el, j, tag, attribute, value, css, cssAttrs, attr, cssName, cssValue;
if (elem.nodeType == Strophe.ElementType.NORMAL) {
tag = elem.nodeName;
if(Strophe.XHTML.validTag(tag)) {
try {
el = Strophe.xmlElement(tag);
for(i = 0; i < Strophe.XHTML.attributes[tag].length; i++) {
attribute = Strophe.XHTML.attributes[tag][i];
value = elem.getAttribute(attribute);
if(typeof value == 'undefined' || value === null || value === '' || value === false || value === 0) {
continue;
}
if(attribute == 'style' && typeof value == 'object') {
if(typeof value.cssText != 'undefined') {
value = value.cssText; // we're dealing with IE, need to get CSS out
}
}
// filter out invalid css styles
if(attribute == 'style') {
css = [];
cssAttrs = value.split(';');
for(j = 0; j < cssAttrs.length; j++) {
attr = cssAttrs[j].split(':');
cssName = attr[0].replace(/^\s*/, "").replace(/\s*$/, "").toLowerCase();
if(Strophe.XHTML.validCSS(cssName)) {
cssValue = attr[1].replace(/^\s*/, "").replace(/\s*$/, "");
css.push(cssName + ': ' + cssValue);
}
}
if(css.length > 0) {
value = css.join('; ');
el.setAttribute(attribute, value);
}
} else {
el.setAttribute(attribute, value);
}
}
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
} catch(e) { // invalid elements
el = Strophe.xmlTextNode('');
}
} else {
el = Strophe.xmlGenerator().createDocumentFragment();
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
}
} else if (elem.nodeType == Strophe.ElementType.FRAGMENT) {
el = Strophe.xmlGenerator().createDocumentFragment();
for (i = 0; i < elem.childNodes.length; i++) {
el.appendChild(Strophe.createHtml(elem.childNodes[i]));
}
} else if (elem.nodeType == Strophe.ElementType.TEXT) {
el = Strophe.xmlTextNode(elem.nodeValue);
}
return el;
} | [
"function",
"(",
"elem",
")",
"{",
"var",
"i",
",",
"el",
",",
"j",
",",
"tag",
",",
"attribute",
",",
"value",
",",
"css",
",",
"cssAttrs",
",",
"attr",
",",
"cssName",
",",
"cssValue",
";",
"if",
"(",
"elem",
".",
"nodeType",
"==",
"Strophe",
"... | Function: createHtml
Copy an HTML DOM element into an XML DOM.
This function copies a DOM element and all its descendants and returns
the new copy.
Parameters:
(HTMLElement) elem - A DOM element.
Returns:
A new, copied DOM element tree. | [
"Function",
":",
"createHtml",
"Copy",
"an",
"HTML",
"DOM",
"element",
"into",
"an",
"XML",
"DOM",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L1183-L1245 | train | Returns the current page s page s page structure | [
30522,
3853,
1006,
3449,
6633,
1007,
1063,
13075,
1045,
1010,
3449,
1010,
1046,
1010,
6415,
1010,
17961,
1010,
3643,
1010,
20116,
2015,
1010,
20116,
16846,
16344,
2015,
1010,
2012,
16344,
1010,
20116,
2015,
18442,
1010,
20116,
2015,
10175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
goldfire/howler.js | dist/howler.js | function(id) {
var self = this;
var duration = self._duration;
// If we pass an ID, get the sound and return the sprite length.
var sound = self._soundById(id);
if (sound) {
duration = self._sprite[sound._sprite][1] / 1000;
}
return duration;
} | javascript | function(id) {
var self = this;
var duration = self._duration;
// If we pass an ID, get the sound and return the sprite length.
var sound = self._soundById(id);
if (sound) {
duration = self._sprite[sound._sprite][1] / 1000;
}
return duration;
} | [
"function",
"(",
"id",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"duration",
"=",
"self",
".",
"_duration",
";",
"// If we pass an ID, get the sound and return the sprite length.",
"var",
"sound",
"=",
"self",
".",
"_soundById",
"(",
"id",
")",
";",
"i... | Get the duration of this sound. Passing a sound id will return the sprite duration.
@param {Number} id The sound id to check. If none is passed, return full source duration.
@return {Number} Audio duration in seconds. | [
"Get",
"the",
"duration",
"of",
"this",
"sound",
".",
"Passing",
"a",
"sound",
"id",
"will",
"return",
"the",
"sprite",
"duration",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1677-L1688 | train | Returns the duration of the sound | [
30522,
3853,
1006,
8909,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
9367,
1027,
2969,
1012,
1035,
9367,
1025,
1013,
1013,
2065,
2057,
3413,
2019,
8909,
1010,
2131,
1996,
2614,
1998,
2709,
1996,
11867,
17625,
3091,
1012,
13075,
2614,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | getBarrelCurveConstants | function getBarrelCurveConstants(width, height) {
return {
heightOffset: Math.min(15, 0.05 * height),
widthOffset: Math.min(100, 0.25 * width),
ctrlPtOffsetPct: 0.05
};
} | javascript | function getBarrelCurveConstants(width, height) {
return {
heightOffset: Math.min(15, 0.05 * height),
widthOffset: Math.min(100, 0.25 * width),
ctrlPtOffsetPct: 0.05
};
} | [
"function",
"getBarrelCurveConstants",
"(",
"width",
",",
"height",
")",
"{",
"return",
"{",
"heightOffset",
":",
"Math",
".",
"min",
"(",
"15",
",",
"0.05",
"*",
"height",
")",
",",
"widthOffset",
":",
"Math",
".",
"min",
"(",
"100",
",",
"0.25",
"*",... | get curve width, height, and control point position offsets as a percentage of node height / width | [
"get",
"curve",
"width",
"height",
"and",
"control",
"point",
"position",
"offsets",
"as",
"a",
"percentage",
"of",
"node",
"height",
"/",
"width"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L3192-L3198 | train | Returns the constants for the arrel curve | [
30522,
3853,
2131,
8237,
16570,
10841,
2099,
3726,
8663,
12693,
3215,
1006,
9381,
1010,
4578,
1007,
1063,
2709,
1063,
4578,
27475,
3388,
1024,
8785,
1012,
8117,
1006,
2321,
1010,
1014,
1012,
5709,
1008,
4578,
1007,
1010,
9381,
27475,
3388,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | grunt/config/aliases.js | function(mode) {
if (!mode || (mode !== 'src' && mode !== 'target')) {
mode = 'src';
}
var taskName = 'openui5_connect:' + mode;
if (grunt.option('watch') && mode === 'src') {
grunt.task.run([ taskName, 'watch']);
} else {
grunt.task.run(taskName + ':keepalive');
}
} | javascript | function(mode) {
if (!mode || (mode !== 'src' && mode !== 'target')) {
mode = 'src';
}
var taskName = 'openui5_connect:' + mode;
if (grunt.option('watch') && mode === 'src') {
grunt.task.run([ taskName, 'watch']);
} else {
grunt.task.run(taskName + ':keepalive');
}
} | [
"function",
"(",
"mode",
")",
"{",
"if",
"(",
"!",
"mode",
"||",
"(",
"mode",
"!==",
"'src'",
"&&",
"mode",
"!==",
"'target'",
")",
")",
"{",
"mode",
"=",
"'src'",
";",
"}",
"var",
"taskName",
"=",
"'openui5_connect:'",
"+",
"mode",
";",
"if",
"(",... | Server task | [
"Server",
"task"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/grunt/config/aliases.js#L13-L24 | train | connects to the remote node | [
30522,
3853,
1006,
5549,
1007,
1063,
2065,
1006,
999,
5549,
1064,
1064,
1006,
5549,
999,
1027,
1027,
1005,
5034,
2278,
1005,
1004,
1004,
5549,
999,
1027,
1027,
1005,
4539,
1005,
1007,
1007,
1063,
5549,
1027,
1005,
5034,
2278,
1005,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/systems/camera.js | function () {
var cameraEls;
var newActiveCameraEl;
cameraEls = this.sceneEl.querySelectorAll('[camera]');
newActiveCameraEl = cameraEls[cameraEls.length - 1];
newActiveCameraEl.setAttribute('camera', 'active', true);
} | javascript | function () {
var cameraEls;
var newActiveCameraEl;
cameraEls = this.sceneEl.querySelectorAll('[camera]');
newActiveCameraEl = cameraEls[cameraEls.length - 1];
newActiveCameraEl.setAttribute('camera', 'active', true);
} | [
"function",
"(",
")",
"{",
"var",
"cameraEls",
";",
"var",
"newActiveCameraEl",
";",
"cameraEls",
"=",
"this",
".",
"sceneEl",
".",
"querySelectorAll",
"(",
"'[camera]'",
")",
";",
"newActiveCameraEl",
"=",
"cameraEls",
"[",
"cameraEls",
".",
"length",
"-",
... | Set a different active camera.
When we choose a (sort of) random scene camera as the replacement, set its `active` to
true. The camera component will call `setActiveCamera` and handle passing the torch to
the new camera. | [
"Set",
"a",
"different",
"active",
"camera",
".",
"When",
"we",
"choose",
"a",
"(",
"sort",
"of",
")",
"random",
"scene",
"camera",
"as",
"the",
"replacement",
"set",
"its",
"active",
"to",
"true",
".",
"The",
"camera",
"component",
"will",
"call",
"setA... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L132-L138 | train | Sets the active camera on the last camera element | [
30522,
3853,
1006,
1007,
1063,
13075,
4950,
9050,
1025,
13075,
2047,
19620,
28727,
6906,
2884,
1025,
4950,
9050,
1027,
2023,
1012,
3496,
2884,
1012,
23032,
11246,
22471,
6525,
3363,
1006,
1005,
1031,
4950,
1033,
1005,
1007,
1025,
2047,
1962... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable) {
if (!oTable || !oTable.getDomRef()) {
return false;
}
return oTable.getDomRef().querySelector("#" + oTable.getId() + "-sapUiTableGridCnt > .sapUiLocalBusyIndicator") != null;
} | javascript | function(oTable) {
if (!oTable || !oTable.getDomRef()) {
return false;
}
return oTable.getDomRef().querySelector("#" + oTable.getId() + "-sapUiTableGridCnt > .sapUiLocalBusyIndicator") != null;
} | [
"function",
"(",
"oTable",
")",
"{",
"if",
"(",
"!",
"oTable",
"||",
"!",
"oTable",
".",
"getDomRef",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"oTable",
".",
"getDomRef",
"(",
")",
".",
"querySelector",
"(",
"\"#\"",
"+",
"oTable",
... | Returns whether the busy indicator is visible. It is considered as visible when the busy indicator element exists in the DOM as
a child of the table element. It is not checked whether the indicator is actually visible on the screen.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {boolean} Whether the busy indicator is visible. | [
"Returns",
"whether",
"the",
"busy",
"indicator",
"is",
"visible",
".",
"It",
"is",
"considered",
"as",
"visible",
"when",
"the",
"busy",
"indicator",
"element",
"exists",
"in",
"the",
"DOM",
"as",
"a",
"child",
"of",
"the",
"table",
"element",
".",
"It",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L377-L383 | train | Returns true if the busy indicator is present in the table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1064,
1064,
999,
27178,
3085,
1012,
2131,
9527,
2890,
2546,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
2709,
27178,
3085,
1012,
2131,
9527,
2890,
2546,
30524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(node, touchingIsIntersecting) {
assertRangeValid(this);
assertNode(node, "NOT_FOUND_ERR");
if (getDocument(node) !== getRangeDocument(this)) {
return false;
}
var parent = node.parentNode, offset = getNodeIndex(node);
assertNode(parent, "NOT_FOUND_ERR");
var startComparison = comparePoints(parent, offset, this.endContainer, this.endOffset),
endComparison = comparePoints(parent, offset + 1, this.startContainer, this.startOffset);
return touchingIsIntersecting ? startComparison <= 0 && endComparison >= 0 : startComparison < 0 && endComparison > 0;
} | javascript | function(node, touchingIsIntersecting) {
assertRangeValid(this);
assertNode(node, "NOT_FOUND_ERR");
if (getDocument(node) !== getRangeDocument(this)) {
return false;
}
var parent = node.parentNode, offset = getNodeIndex(node);
assertNode(parent, "NOT_FOUND_ERR");
var startComparison = comparePoints(parent, offset, this.endContainer, this.endOffset),
endComparison = comparePoints(parent, offset + 1, this.startContainer, this.startOffset);
return touchingIsIntersecting ? startComparison <= 0 && endComparison >= 0 : startComparison < 0 && endComparison > 0;
} | [
"function",
"(",
"node",
",",
"touchingIsIntersecting",
")",
"{",
"assertRangeValid",
"(",
"this",
")",
";",
"assertNode",
"(",
"node",
",",
"\"NOT_FOUND_ERR\"",
")",
";",
"if",
"(",
"getDocument",
"(",
"node",
")",
"!==",
"getRangeDocument",
"(",
"this",
")... | touchingIsIntersecting determines whether this method considers a node that borders a range intersects with it (as in WebKit) or not (as in Gecko pre-1.9, and the default) | [
"touchingIsIntersecting",
"determines",
"whether",
"this",
"method",
"considers",
"a",
"node",
"that",
"borders",
"a",
"range",
"intersects",
"with",
"it",
"(",
"as",
"in",
"WebKit",
")",
"or",
"not",
"(",
"as",
"in",
"Gecko",
"pre",
"-",
"1",
".",
"9",
... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L1663-L1677 | train | Returns true if node is in the range of the specified node | [
30522,
3853,
1006,
13045,
1010,
7244,
17417,
10111,
22573,
11873,
1007,
1063,
20865,
24388,
13331,
21273,
1006,
2023,
1007,
1025,
20865,
3630,
3207,
1006,
13045,
1010,
1000,
2025,
1035,
2179,
1035,
9413,
2099,
1000,
1007,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/sessionstore.js | undoClosedWindow | function undoClosedWindow(controller, event)
{
var count = sessionStoreService.getClosedWindowCount(controller.window);
switch (event.type) {
case "menu":
throw new Error("Menu gets build dynamically and cannot be accessed.");
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "newNavigatorCmd.key");
controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
}
if (count > 0)
controller.assertJS("subject.newWindowCount < subject.oldWindowCount",
{
newWindowCount : sessionStoreService.getClosedWindowCount(controller.window),
oldWindowCount : count
});
} | javascript | function undoClosedWindow(controller, event)
{
var count = sessionStoreService.getClosedWindowCount(controller.window);
switch (event.type) {
case "menu":
throw new Error("Menu gets build dynamically and cannot be accessed.");
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "newNavigatorCmd.key");
controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
}
if (count > 0)
controller.assertJS("subject.newWindowCount < subject.oldWindowCount",
{
newWindowCount : sessionStoreService.getClosedWindowCount(controller.window),
oldWindowCount : count
});
} | [
"function",
"undoClosedWindow",
"(",
"controller",
",",
"event",
")",
"{",
"var",
"count",
"=",
"sessionStoreService",
".",
"getClosedWindowCount",
"(",
"controller",
".",
"window",
")",
";",
"switch",
"(",
"event",
".",
"type",
")",
"{",
"case",
"\"menu\"",
... | Restores the window which has been recently closed
@param {MozMillController} controller
MozMillController of the window to operate on
@param {object} event
Specifies the event to use to execute the command | [
"Restores",
"the",
"window",
"which",
"has",
"been",
"recently",
"closed"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/sessionstore.js#L289-L309 | train | Undo a closed window | [
30522,
3853,
25672,
20464,
24768,
11101,
5004,
1006,
11486,
1010,
2724,
1007,
1063,
13075,
4175,
1027,
6521,
19277,
8043,
7903,
2063,
1012,
2131,
20464,
24768,
11101,
5004,
3597,
16671,
1006,
11486,
1012,
3332,
1007,
1025,
6942,
1006,
2724,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/animation.js | function () {
var component;
var componentName;
for (componentName in this.el.components) {
component = this.el.components[componentName];
if (componentName === this.attrName) { continue; }
if (component.name !== 'animation') { continue; }
if (!component.animationIsPlaying) { continue; }
if (component.data.property !== this.data.property) { continue; }
component.animationIsPlaying = false;
}
} | javascript | function () {
var component;
var componentName;
for (componentName in this.el.components) {
component = this.el.components[componentName];
if (componentName === this.attrName) { continue; }
if (component.name !== 'animation') { continue; }
if (!component.animationIsPlaying) { continue; }
if (component.data.property !== this.data.property) { continue; }
component.animationIsPlaying = false;
}
} | [
"function",
"(",
")",
"{",
"var",
"component",
";",
"var",
"componentName",
";",
"for",
"(",
"componentName",
"in",
"this",
".",
"el",
".",
"components",
")",
"{",
"component",
"=",
"this",
".",
"el",
".",
"components",
"[",
"componentName",
"]",
";",
... | Make sure two animations on the same property don't fight each other.
e.g., animation__mouseenter="property: material.opacity"
animation__mouseleave="property: material.opacity" | [
"Make",
"sure",
"two",
"animations",
"on",
"the",
"same",
"property",
"don",
"t",
"fight",
"each",
"other",
".",
"e",
".",
"g",
".",
"animation__mouseenter",
"=",
"property",
":",
"material",
".",
"opacity",
"animation__mouseleave",
"=",
"property",
":",
"ma... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L468-L479 | train | This function is called by the animation component when the animation is playing | [
30522,
3853,
1006,
1007,
1063,
13075,
6922,
1025,
13075,
6922,
18442,
1025,
2005,
1006,
6922,
18442,
1999,
2023,
1012,
3449,
1012,
6177,
1007,
1063,
6922,
1027,
2023,
1012,
3449,
1012,
6177,
1031,
6922,
18442,
1033,
1025,
2065,
1006,
6922,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/command/KeyBindingManager.js | _translateKeyboardEvent | function _translateKeyboardEvent(event) {
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false,
hasCtrl = (brackets.platform !== "mac") ? (event.ctrlKey) : (event.metaKey),
hasAlt = (event.altKey),
hasShift = (event.shiftKey),
key = String.fromCharCode(event.keyCode);
//From the W3C, if we can get the KeyboardEvent.keyIdentifier then look here
//As that will let us use keys like then function keys "F5" for commands. The
//full set of values we can use is here
//http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/keyset.html#KeySet-Set
var ident = event.keyIdentifier;
if (ident) {
if (ident.charAt(0) === "U" && ident.charAt(1) === "+") {
//This is a unicode code point like "U+002A", get the 002A and use that
key = String.fromCharCode(parseInt(ident.substring(2), 16));
} else {
//This is some non-character key, just use the raw identifier
key = ident;
}
}
// Translate some keys to their common names
if (key === "\t") {
key = "Tab";
} else if (key === " ") {
key = "Space";
} else if (key === "\b") {
key = "Backspace";
} else if (key === "Help") {
key = "Insert";
} else if (event.keyCode === KeyEvent.DOM_VK_DELETE) {
key = "Delete";
} else {
key = _mapKeycodeToKey(event.keyCode, key);
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | javascript | function _translateKeyboardEvent(event) {
var hasMacCtrl = (brackets.platform === "mac") ? (event.ctrlKey) : false,
hasCtrl = (brackets.platform !== "mac") ? (event.ctrlKey) : (event.metaKey),
hasAlt = (event.altKey),
hasShift = (event.shiftKey),
key = String.fromCharCode(event.keyCode);
//From the W3C, if we can get the KeyboardEvent.keyIdentifier then look here
//As that will let us use keys like then function keys "F5" for commands. The
//full set of values we can use is here
//http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/keyset.html#KeySet-Set
var ident = event.keyIdentifier;
if (ident) {
if (ident.charAt(0) === "U" && ident.charAt(1) === "+") {
//This is a unicode code point like "U+002A", get the 002A and use that
key = String.fromCharCode(parseInt(ident.substring(2), 16));
} else {
//This is some non-character key, just use the raw identifier
key = ident;
}
}
// Translate some keys to their common names
if (key === "\t") {
key = "Tab";
} else if (key === " ") {
key = "Space";
} else if (key === "\b") {
key = "Backspace";
} else if (key === "Help") {
key = "Insert";
} else if (event.keyCode === KeyEvent.DOM_VK_DELETE) {
key = "Delete";
} else {
key = _mapKeycodeToKey(event.keyCode, key);
}
return _buildKeyDescriptor(hasMacCtrl, hasCtrl, hasAlt, hasShift, key);
} | [
"function",
"_translateKeyboardEvent",
"(",
"event",
")",
"{",
"var",
"hasMacCtrl",
"=",
"(",
"brackets",
".",
"platform",
"===",
"\"mac\"",
")",
"?",
"(",
"event",
".",
"ctrlKey",
")",
":",
"false",
",",
"hasCtrl",
"=",
"(",
"brackets",
".",
"platform",
... | Takes a keyboard event and translates it into a key in a key map | [
"Takes",
"a",
"keyboard",
"event",
"and",
"translates",
"it",
"into",
"a",
"key",
"in",
"a",
"key",
"map"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L482-L520 | train | Translate a keyboard event to a key descriptor | [
30522,
3853,
1035,
17637,
14839,
6277,
18697,
3372,
1006,
2724,
1007,
1063,
13075,
2038,
22911,
6593,
12190,
1027,
1006,
19719,
1012,
4132,
1027,
1027,
1027,
1000,
6097,
1000,
1007,
1029,
1006,
2724,
1012,
14931,
12190,
14839,
1007,
1024,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/lib/prototype.js | function() {
this.deltaX = window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
} | javascript | function() {
this.deltaX = window.pageXOffset
|| document.documentElement.scrollLeft
|| document.body.scrollLeft
|| 0;
this.deltaY = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
} | [
"function",
"(",
")",
"{",
"this",
".",
"deltaX",
"=",
"window",
".",
"pageXOffset",
"||",
"document",
".",
"documentElement",
".",
"scrollLeft",
"||",
"document",
".",
"body",
".",
"scrollLeft",
"||",
"0",
";",
"this",
".",
"deltaY",
"=",
"window",
".",... | must be called before calling withinIncludingScrolloffset, every time the page is scrolled | [
"must",
"be",
"called",
"before",
"calling",
"withinIncludingScrolloffset",
"every",
"time",
"the",
"page",
"is",
"scrolled"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/lib/prototype.js#L1784-L1793 | train | This is the function that is called when the page is scrolled. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
7160,
2595,
1027,
3332,
1012,
3931,
2595,
27475,
3388,
1064,
1064,
6254,
1012,
6254,
12260,
3672,
1012,
17186,
2571,
6199,
1064,
1064,
6254,
1012,
2303,
1012,
17186,
2571,
6199,
1064,
1064,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/output/website/copyPluginAssets.js | copyPluginAssets | function copyPluginAssets(output) {
var book = output.getBook();
// Don't copy plugins assets for language book
// It'll be resolved to the parent folder
if (book.isLanguageBook()) {
return Promise(output);
}
var plugins = output.getPlugins()
// We reverse the order of plugins to copy
// so that first plugins can replace assets from other plugins.
.reverse();
return Promise.forEach(plugins, function(plugin) {
return copyAssets(output, plugin)
.then(function() {
return copyResources(output, plugin);
});
})
.thenResolve(output);
} | javascript | function copyPluginAssets(output) {
var book = output.getBook();
// Don't copy plugins assets for language book
// It'll be resolved to the parent folder
if (book.isLanguageBook()) {
return Promise(output);
}
var plugins = output.getPlugins()
// We reverse the order of plugins to copy
// so that first plugins can replace assets from other plugins.
.reverse();
return Promise.forEach(plugins, function(plugin) {
return copyAssets(output, plugin)
.then(function() {
return copyResources(output, plugin);
});
})
.thenResolve(output);
} | [
"function",
"copyPluginAssets",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"// Don't copy plugins assets for language book",
"// It'll be resolved to the parent folder",
"if",
"(",
"book",
".",
"isLanguageBook",
"(",
")",
")"... | Copy all assets from plugins.
Assets are files stored in "_assets"
nd resources declared in the plugin itself.
@param {Output}
@return {Promise} | [
"Copy",
"all",
"assets",
"from",
"plugins",
".",
"Assets",
"are",
"files",
"stored",
"in",
"_assets",
"nd",
"resources",
"declared",
"in",
"the",
"plugin",
"itself",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/copyPluginAssets.js#L15-L37 | train | Copy assets from all plugins to the output folder | [
30522,
3853,
6100,
24759,
15916,
15227,
13462,
2015,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
1013,
1013,
2123,
1005,
1056,
6100,
13354,
7076,
7045,
2005,
2653,
2338,
1013,
1013,
2009,
1005,
2222,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/component/toolbox/feature/DataView.js | groupSeries | function groupSeries(ecModel) {
var seriesGroupByCategoryAxis = {};
var otherSeries = [];
var meta = [];
ecModel.eachRawSeries(function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
var baseAxis = coordSys.getBaseAxis();
if (baseAxis.type === 'category') {
var key = baseAxis.dim + '_' + baseAxis.index;
if (!seriesGroupByCategoryAxis[key]) {
seriesGroupByCategoryAxis[key] = {
categoryAxis: baseAxis,
valueAxis: coordSys.getOtherAxis(baseAxis),
series: []
};
meta.push({
axisDim: baseAxis.dim,
axisIndex: baseAxis.index
});
}
seriesGroupByCategoryAxis[key].series.push(seriesModel);
}
else {
otherSeries.push(seriesModel);
}
}
else {
otherSeries.push(seriesModel);
}
});
return {
seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
other: otherSeries,
meta: meta
};
} | javascript | function groupSeries(ecModel) {
var seriesGroupByCategoryAxis = {};
var otherSeries = [];
var meta = [];
ecModel.eachRawSeries(function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
var baseAxis = coordSys.getBaseAxis();
if (baseAxis.type === 'category') {
var key = baseAxis.dim + '_' + baseAxis.index;
if (!seriesGroupByCategoryAxis[key]) {
seriesGroupByCategoryAxis[key] = {
categoryAxis: baseAxis,
valueAxis: coordSys.getOtherAxis(baseAxis),
series: []
};
meta.push({
axisDim: baseAxis.dim,
axisIndex: baseAxis.index
});
}
seriesGroupByCategoryAxis[key].series.push(seriesModel);
}
else {
otherSeries.push(seriesModel);
}
}
else {
otherSeries.push(seriesModel);
}
});
return {
seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
other: otherSeries,
meta: meta
};
} | [
"function",
"groupSeries",
"(",
"ecModel",
")",
"{",
"var",
"seriesGroupByCategoryAxis",
"=",
"{",
"}",
";",
"var",
"otherSeries",
"=",
"[",
"]",
";",
"var",
"meta",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachRawSeries",
"(",
"function",
"(",
"seriesModel",
... | Group series into two types
1. on category axis, like line, bar
2. others, like scatter, pie
@param {module:echarts/model/Global} ecModel
@return {Object}
@inner | [
"Group",
"series",
"into",
"two",
"types",
"1",
".",
"on",
"category",
"axis",
"like",
"line",
"bar",
"2",
".",
"others",
"like",
"scatter",
"pie"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/toolbox/feature/DataView.js#L38-L76 | train | groupSeries - group series by category axis | [
30522,
3853,
2967,
28077,
1006,
14925,
5302,
9247,
1007,
1063,
13075,
2186,
17058,
3762,
16280,
20255,
3148,
9048,
2015,
1027,
1063,
1065,
1025,
13075,
2500,
28077,
1027,
1031,
1033,
1025,
13075,
18804,
1027,
1031,
1033,
1025,
14925,
5302,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | services/endpoint-common.js | validateEndpointData | function validateEndpointData(
data,
{ prettyErrorMessage = 'invalid response data', includeKeys = false } = {}
) {
return validate(
{
ErrorClass: InvalidResponse,
prettyErrorMessage,
includeKeys,
traceErrorMessage: 'Response did not match schema',
traceSuccessMessage: 'Response after validation',
allowAndStripUnknownKeys: false,
},
data,
endpointSchema
)
} | javascript | function validateEndpointData(
data,
{ prettyErrorMessage = 'invalid response data', includeKeys = false } = {}
) {
return validate(
{
ErrorClass: InvalidResponse,
prettyErrorMessage,
includeKeys,
traceErrorMessage: 'Response did not match schema',
traceSuccessMessage: 'Response after validation',
allowAndStripUnknownKeys: false,
},
data,
endpointSchema
)
} | [
"function",
"validateEndpointData",
"(",
"data",
",",
"{",
"prettyErrorMessage",
"=",
"'invalid response data'",
",",
"includeKeys",
"=",
"false",
"}",
"=",
"{",
"}",
")",
"{",
"return",
"validate",
"(",
"{",
"ErrorClass",
":",
"InvalidResponse",
",",
"prettyErr... | Strictly validate according to the endpoint schema. This rejects unknown / invalid keys. Optionally it prints those keys in the message in order to provide detailed feedback. | [
"Strictly",
"validate",
"according",
"to",
"the",
"endpoint",
"schema",
".",
"This",
"rejects",
"unknown",
"/",
"invalid",
"keys",
".",
"Optionally",
"it",
"prints",
"those",
"keys",
"in",
"the",
"message",
"in",
"order",
"to",
"provide",
"detailed",
"feedback... | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/endpoint-common.js#L45-L61 | train | Validate endpoint data | [
30522,
3853,
9398,
3686,
10497,
8400,
2850,
2696,
1006,
2951,
1010,
1063,
3492,
2121,
29165,
7834,
3736,
3351,
1027,
1005,
19528,
3433,
2951,
1005,
1010,
2421,
14839,
30524,
1010,
2421,
14839,
2015,
1010,
7637,
2121,
29165,
7834,
3736,
3351... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | src/ol/format/MVT.js | readRawFeature | function readRawFeature(pbf, layer, i) {
pbf.pos = layer.features[i];
const end = pbf.readVarint() + pbf.pos;
const feature = {
layer: layer,
type: 0,
properties: {}
};
pbf.readFields(featurePBFReader, feature, end);
return feature;
} | javascript | function readRawFeature(pbf, layer, i) {
pbf.pos = layer.features[i];
const end = pbf.readVarint() + pbf.pos;
const feature = {
layer: layer,
type: 0,
properties: {}
};
pbf.readFields(featurePBFReader, feature, end);
return feature;
} | [
"function",
"readRawFeature",
"(",
"pbf",
",",
"layer",
",",
"i",
")",
"{",
"pbf",
".",
"pos",
"=",
"layer",
".",
"features",
"[",
"i",
"]",
";",
"const",
"end",
"=",
"pbf",
".",
"readVarint",
"(",
")",
"+",
"pbf",
".",
"pos",
";",
"const",
"feat... | Read a raw feature from the pbf offset stored at index `i` in the raw layer.
@param {PBF} pbf PBF.
@param {Object} layer Raw layer.
@param {number} i Index of the feature in the raw layer's `features` array.
@return {Object} Raw feature. | [
"Read",
"a",
"raw",
"feature",
"from",
"the",
"pbf",
"offset",
"stored",
"at",
"index",
"i",
"in",
"the",
"raw",
"layer",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/MVT.js#L371-L382 | train | Reads a raw feature from a layer | [
30522,
3853,
3191,
2527,
2860,
7959,
4017,
5397,
1006,
1052,
29292,
1010,
6741,
1010,
1045,
1007,
1063,
1052,
29292,
1012,
13433,
2015,
1027,
6741,
1012,
2838,
1031,
1045,
1033,
1025,
9530,
3367,
2203,
1027,
1052,
29292,
1012,
3191,
10755,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
NervJS/taro | packages/taro/src/internal/_common.js | baseAssignValue | function baseAssignValue(object, key, value) {
if (key == '__proto__') {
Object.defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
})
} else {
object[key] = value
}
} | javascript | function baseAssignValue(object, key, value) {
if (key == '__proto__') {
Object.defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
})
} else {
object[key] = value
}
} | [
"function",
"baseAssignValue",
"(",
"object",
",",
"key",
",",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"'__proto__'",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"object",
",",
"key",
",",
"{",
"'configurable'",
":",
"true",
",",
"'enumerable'",
"... | The base implementation of `assignValue` and `assignMergeValue` without
value checks.
@private
@param {Object} object The object to modify.
@param {string} key The key of the property to assign.
@param {*} value The value to assign. | [
"The",
"base",
"implementation",
"of",
"assignValue",
"and",
"assignMergeValue",
"without",
"value",
"checks",
"."
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L945-L956 | train | baseAssignValue - base assign value to object | [
30522,
3853,
2918,
12054,
23773,
10175,
5657,
1006,
4874,
1010,
3145,
1010,
3643,
1007,
1063,
2065,
1006,
3145,
1027,
1027,
1005,
1035,
1035,
15053,
1035,
1035,
1005,
1007,
1063,
4874,
1012,
9375,
21572,
4842,
3723,
1006,
4874,
1010,
3145,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-alert.js | isShadowed | function isShadowed(scope, node) {
const reference = findReference(scope, node);
return reference && reference.resolved && reference.resolved.defs.length > 0;
} | javascript | function isShadowed(scope, node) {
const reference = findReference(scope, node);
return reference && reference.resolved && reference.resolved.defs.length > 0;
} | [
"function",
"isShadowed",
"(",
"scope",
",",
"node",
")",
"{",
"const",
"reference",
"=",
"findReference",
"(",
"scope",
",",
"node",
")",
";",
"return",
"reference",
"&&",
"reference",
".",
"resolved",
"&&",
"reference",
".",
"resolved",
".",
"defs",
".",... | Checks if the given identifier node is shadowed in the given scope.
@param {Object} scope The current scope.
@param {string} node The identifier node to check
@returns {boolean} Whether or not the name is shadowed. | [
"Checks",
"if",
"the",
"given",
"identifier",
"node",
"is",
"shadowed",
"in",
"the",
"given",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-alert.js#L48-L52 | train | Returns true if node is shadowed | [
30522,
3853,
26354,
16102,
15096,
1006,
9531,
1010,
13045,
1007,
1063,
9530,
3367,
4431,
1027,
2424,
2890,
25523,
1006,
9531,
1010,
13045,
1007,
1025,
2709,
4431,
1004,
1004,
4431,
1012,
10395,
1004,
1004,
4431,
1012,
10395,
1012,
13366,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | common/src/web/jquery-1.3.2.js | num | function num(elem, prop) {
return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
} | javascript | function num(elem, prop) {
return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
} | [
"function",
"num",
"(",
"elem",
",",
"prop",
")",
"{",
"return",
"elem",
"[",
"0",
"]",
"&&",
"parseInt",
"(",
"jQuery",
".",
"curCSS",
"(",
"elem",
"[",
"0",
"]",
",",
"prop",
",",
"true",
")",
",",
"10",
")",
"||",
"0",
";",
"}"
] | Helper function used by the dimensions and offset modules | [
"Helper",
"function",
"used",
"by",
"the",
"dimensions",
"and",
"offset",
"modules"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/common/src/web/jquery-1.3.2.js#L1266-L1268 | train | Get the number of elements in the DOM | [
30522,
3853,
16371,
2213,
1006,
3449,
6633,
1010,
17678,
1007,
1063,
2709,
3449,
6633,
1031,
1014,
1033,
1004,
1004,
11968,
20240,
3372,
1006,
1046,
4226,
2854,
1012,
12731,
11890,
4757,
1006,
3449,
6633,
1031,
1014,
1033,
1010,
17678,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( size, pointLength, units ) {
var unit;
units = units || [ 'B', 'K', 'M', 'G', 'TB' ];
while ( (unit = units.shift()) && size > 1024 ) {
size = size / 1024;
}
return (unit === 'B' ? size : size.toFixed( pointLength || 2 )) +
unit;
} | javascript | function( size, pointLength, units ) {
var unit;
units = units || [ 'B', 'K', 'M', 'G', 'TB' ];
while ( (unit = units.shift()) && size > 1024 ) {
size = size / 1024;
}
return (unit === 'B' ? size : size.toFixed( pointLength || 2 )) +
unit;
} | [
"function",
"(",
"size",
",",
"pointLength",
",",
"units",
")",
"{",
"var",
"unit",
";",
"units",
"=",
"units",
"||",
"[",
"'B'",
",",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'TB'",
"]",
";",
"while",
"(",
"(",
"unit",
"=",
"units",
".",
"shift",
... | 格式化文件大小, 输出成带单位的字符串
@method formatSize
@grammar Base.formatSize( size ) => String
@grammar Base.formatSize( size, pointLength ) => String
@grammar Base.formatSize( size, pointLength, units ) => String
@param {Number} size 文件大小
@param {Number} [pointLength=2] 精确到的小数点数。
@param {Array} [units=[ 'B', 'K', 'M', 'G', 'TB' ]] 单位数组。从字节,到千字节,一直往上指定。如果单位数组里面只指定了到了K(千字节),同时文件大小大于M, 此方法的输出将还是显示成多少K.
@example
console.log( Base.formatSize( 100 ) ); // => 100B
console.log( Base.formatSize( 1024 ) ); // => 1.00K
console.log( Base.formatSize( 1024, 0 ) ); // => 1K
console.log( Base.formatSize( 1024 * 1024 ) ); // => 1.00M
console.log( Base.formatSize( 1024 * 1024 * 1024 ) ); // => 1.00G
console.log( Base.formatSize( 1024 * 1024 * 1024, 0, ['B', 'KB', 'MB'] ) ); // => 1024MB | [
"格式化文件大小",
"输出成带单位的字符串"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L479-L490 | train | Returns the size of the image in bytes | [
30522,
3853,
1006,
2946,
1010,
2391,
7770,
13512,
2232,
1010,
3197,
1007,
1063,
13075,
3131,
1025,
3197,
1027,
3197,
1064,
1064,
1031,
1005,
1038,
1005,
1010,
1005,
1047,
1005,
1010,
1005,
1049,
1005,
1010,
1005,
1043,
1005,
1010,
1005,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/search.js | searchBar_clear | function searchBar_clear()
{
var activeElement = this._controller.window.document.activeElement;
var searchInput = this.getElement({type: "searchBar_input"});
var cmdKey = utils.getEntity(this.getDtds(), "selectAllCmd.key");
this._controller.keypress(searchInput, cmdKey, {accelKey: true});
this._controller.keypress(searchInput, 'VK_DELETE', {});
if (activeElement)
activeElement.focus();
} | javascript | function searchBar_clear()
{
var activeElement = this._controller.window.document.activeElement;
var searchInput = this.getElement({type: "searchBar_input"});
var cmdKey = utils.getEntity(this.getDtds(), "selectAllCmd.key");
this._controller.keypress(searchInput, cmdKey, {accelKey: true});
this._controller.keypress(searchInput, 'VK_DELETE', {});
if (activeElement)
activeElement.focus();
} | [
"function",
"searchBar_clear",
"(",
")",
"{",
"var",
"activeElement",
"=",
"this",
".",
"_controller",
".",
"window",
".",
"document",
".",
"activeElement",
";",
"var",
"searchInput",
"=",
"this",
".",
"getElement",
"(",
"{",
"type",
":",
"\"searchBar_input\""... | Clear the search field | [
"Clear",
"the",
"search",
"field"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/search.js#L533-L544 | train | Clear all search items | [
30522,
3853,
3945,
8237,
1035,
3154,
1006,
1007,
1063,
13075,
3161,
12260,
3672,
1027,
2023,
1012,
1035,
11486,
1012,
3332,
1012,
6254,
1012,
3161,
12260,
3672,
1025,
13075,
3945,
2378,
18780,
1027,
2023,
1012,
2131,
12260,
3672,
1006,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/History.js | function () {
var aOutput = [];
_aRuns.forEach(function (oRun) {
var oTmp = _generateRootLevelKeys(oRun);
for (var sLibraryName in oRun.rules) {
_generateLibraryStructure(oTmp, sLibraryName, oRun);
for (var sRuleName in oRun.rules[sLibraryName]) {
_generateRuleStructure(oTmp, sLibraryName, sRuleName, oRun);
}
}
aOutput.push(oTmp);
});
return aOutput;
} | javascript | function () {
var aOutput = [];
_aRuns.forEach(function (oRun) {
var oTmp = _generateRootLevelKeys(oRun);
for (var sLibraryName in oRun.rules) {
_generateLibraryStructure(oTmp, sLibraryName, oRun);
for (var sRuleName in oRun.rules[sLibraryName]) {
_generateRuleStructure(oTmp, sLibraryName, sRuleName, oRun);
}
}
aOutput.push(oTmp);
});
return aOutput;
} | [
"function",
"(",
")",
"{",
"var",
"aOutput",
"=",
"[",
"]",
";",
"_aRuns",
".",
"forEach",
"(",
"function",
"(",
"oRun",
")",
"{",
"var",
"oTmp",
"=",
"_generateRootLevelKeys",
"(",
"oRun",
")",
";",
"for",
"(",
"var",
"sLibraryName",
"in",
"oRun",
"... | Gets all passed analyses in a JSON object that can easily be converted into a string.
@public
@method
@name sap.ui.support.History.getHistory
@returns {Array} Which contains all passed run analysis objects. | [
"Gets",
"all",
"passed",
"analyses",
"in",
"a",
"JSON",
"object",
"that",
"can",
"easily",
"be",
"converted",
"into",
"a",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/History.js#L191-L209 | train | Generates the structure of all the run objects | [
30522,
30524,
1027,
1035,
9699,
3217,
4140,
20414,
2884,
14839,
2015,
1006,
2030,
4609,
1007,
1025,
2005,
1006,
13075,
22889,
12322,
19848,
18279,
4168,
1999,
2030,
4609,
1012,
3513,
1007,
1063,
1035,
9699,
29521,
19848,
27268,
6820,
14890,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | removeData | function removeData(params) {
var defaults$$1 = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = extend({}, defaults$$1, params);
return function removeDataImpl(names) {
var p = params;
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
// .removeData('foo bar')
if (string(names)) {
// then get the list of keys, and delete them
var keys = names.split(/\s+/);
var l = keys.length;
for (var i = 0; i < l; i++) {
// delete each non-empty key
var key = keys[i];
if (emptyString(key)) {
continue;
}
var valid = !p.immutableKeys[key]; // not valid if immutable
if (valid) {
for (var i_a = 0, l_a = all.length; i_a < l_a; i_a++) {
all[i_a]._private[p.field][key] = undefined;
}
}
}
if (p.triggerEvent) {
self[p.triggerFnName](p.event);
} // .removeData()
} else if (names === undefined) {
// then delete all keys
for (var _i_a = 0, _l_a = all.length; _i_a < _l_a; _i_a++) {
var _privateFields = all[_i_a]._private[p.field];
var _keys = Object.keys(_privateFields);
for (var _i2 = 0; _i2 < _keys.length; _i2++) {
var _key = _keys[_i2];
var validKeyToDelete = !p.immutableKeys[_key];
if (validKeyToDelete) {
_privateFields[_key] = undefined;
}
}
}
if (p.triggerEvent) {
self[p.triggerFnName](p.event);
}
}
return self; // maintain chaining
}; // function
} | javascript | function removeData(params) {
var defaults$$1 = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = extend({}, defaults$$1, params);
return function removeDataImpl(names) {
var p = params;
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
// .removeData('foo bar')
if (string(names)) {
// then get the list of keys, and delete them
var keys = names.split(/\s+/);
var l = keys.length;
for (var i = 0; i < l; i++) {
// delete each non-empty key
var key = keys[i];
if (emptyString(key)) {
continue;
}
var valid = !p.immutableKeys[key]; // not valid if immutable
if (valid) {
for (var i_a = 0, l_a = all.length; i_a < l_a; i_a++) {
all[i_a]._private[p.field][key] = undefined;
}
}
}
if (p.triggerEvent) {
self[p.triggerFnName](p.event);
} // .removeData()
} else if (names === undefined) {
// then delete all keys
for (var _i_a = 0, _l_a = all.length; _i_a < _l_a; _i_a++) {
var _privateFields = all[_i_a]._private[p.field];
var _keys = Object.keys(_privateFields);
for (var _i2 = 0; _i2 < _keys.length; _i2++) {
var _key = _keys[_i2];
var validKeyToDelete = !p.immutableKeys[_key];
if (validKeyToDelete) {
_privateFields[_key] = undefined;
}
}
}
if (p.triggerEvent) {
self[p.triggerFnName](p.event);
}
}
return self; // maintain chaining
}; // function
} | [
"function",
"removeData",
"(",
"params",
")",
"{",
"var",
"defaults$$1",
"=",
"{",
"field",
":",
"'data'",
",",
"event",
":",
"'data'",
",",
"triggerFnName",
":",
"'trigger'",
",",
"triggerEvent",
":",
"false",
",",
"immutableKeys",
":",
"{",
"}",
"// key ... | data remove data field | [
"data",
"remove",
"data",
"field"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L6107-L6174 | train | removeData - remove data | [
30522,
3853,
3718,
6790,
1006,
11498,
5244,
1007,
1063,
13075,
12398,
2015,
1002,
1002,
1015,
1027,
1063,
2492,
1024,
1005,
2951,
1005,
1010,
2724,
1024,
1005,
2951,
1005,
1010,
9495,
2546,
9516,
4168,
1024,
1005,
9495,
1005,
1010,
9495,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/select/select.js | SelectDirective | function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $parse, $sce,
$injector) {
var keyCodes = $mdConstant.KEY_CODE;
var NAVIGATION_KEYS = [keyCodes.SPACE, keyCodes.ENTER, keyCodes.UP_ARROW, keyCodes.DOWN_ARROW];
return {
restrict: 'E',
require: ['^?mdInputContainer', 'mdSelect', 'ngModel', '?^form'],
compile: compile,
controller: function() {
} // empty placeholder controller to be initialized in link
};
function compile(element, attr) {
// add the select value that will hold our placeholder or selected option value
var valueEl = angular.element('<md-select-value><span></span></md-select-value>');
valueEl.append('<span class="md-select-icon" aria-hidden="true"></span>');
valueEl.addClass('md-select-value');
if (!valueEl[0].hasAttribute('id')) {
valueEl.attr('id', 'select_value_label_' + $mdUtil.nextUid());
}
// There's got to be an md-content inside. If there's not one, let's add it.
var mdContentEl = element.find('md-content');
if (!mdContentEl.length) {
element.append(angular.element('<md-content>').append(element.contents()));
}
mdContentEl.attr('role', 'presentation');
// Add progress spinner for md-options-loading
if (attr.mdOnOpen) {
// Show progress indicator while loading async
// Use ng-hide for `display:none` so the indicator does not interfere with the options list
element
.find('md-content')
.prepend(angular.element(
'<div>' +
' <md-progress-circular md-mode="indeterminate" ng-if="$$loadingAsyncDone === false" md-diameter="25px"></md-progress-circular>' +
'</div>'
));
// Hide list [of item options] while loading async
element
.find('md-option')
.attr('ng-show', '$$loadingAsyncDone');
}
if (attr.name) {
var autofillClone = angular.element('<select class="md-visually-hidden"></select>');
autofillClone.attr({
'name': attr.name,
'aria-hidden': 'true',
'tabindex': '-1'
});
var opts = element.find('md-option');
angular.forEach(opts, function(el) {
var newEl = angular.element('<option>' + el.innerHTML + '</option>');
if (el.hasAttribute('ng-value')) newEl.attr('ng-value', el.getAttribute('ng-value'));
else if (el.hasAttribute('value')) newEl.attr('value', el.getAttribute('value'));
autofillClone.append(newEl);
});
// Adds an extra option that will hold the selected value for the
// cases where the select is a part of a non-angular form. This can be done with a ng-model,
// however if the `md-option` is being `ng-repeat`-ed, AngularJS seems to insert a similar
// `option` node, but with a value of `? string: <value> ?` which would then get submitted.
// This also goes around having to prepend a dot to the name attribute.
autofillClone.append(
'<option ng-value="' + attr.ngModel + '" selected></option>'
);
element.parent().append(autofillClone);
}
var isMultiple = $mdUtil.parseAttributeBoolean(attr.multiple);
// Use everything that's left inside element.contents() as the contents of the menu
var multipleContent = isMultiple ? 'multiple' : '';
var selectTemplate = '' +
'<div class="md-select-menu-container" aria-hidden="true" role="presentation">' +
'<md-select-menu role="presentation" {0}>{1}</md-select-menu>' +
'</div>';
selectTemplate = $mdUtil.supplant(selectTemplate, [multipleContent, element.html()]);
element.empty().append(valueEl);
element.append(selectTemplate);
if (!attr.tabindex){
attr.$set('tabindex', 0);
}
return function postLink(scope, element, attr, ctrls) {
var untouched = true;
var isDisabled, ariaLabelBase;
var containerCtrl = ctrls[0];
var mdSelectCtrl = ctrls[1];
var ngModelCtrl = ctrls[2];
var formCtrl = ctrls[3];
// grab a reference to the select menu value label
var valueEl = element.find('md-select-value');
var isReadonly = angular.isDefined(attr.readonly);
var disableAsterisk = $mdUtil.parseAttributeBoolean(attr.mdNoAsterisk);
if (disableAsterisk) {
element.addClass('md-no-asterisk');
}
if (containerCtrl) {
var isErrorGetter = containerCtrl.isErrorGetter || function() {
return ngModelCtrl.$invalid && (ngModelCtrl.$touched || (formCtrl && formCtrl.$submitted));
};
if (containerCtrl.input) {
// We ignore inputs that are in the md-select-header (one
// case where this might be useful would be adding as searchbox)
if (element.find('md-select-header').find('input')[0] !== containerCtrl.input[0]) {
throw new Error("<md-input-container> can only have *one* child <input>, <textarea> or <select> element!");
}
}
containerCtrl.input = element;
if (!containerCtrl.label) {
$mdAria.expect(element, 'aria-label', element.attr('placeholder'));
}
scope.$watch(isErrorGetter, containerCtrl.setInvalid);
}
var selectContainer, selectScope, selectMenuCtrl;
findSelectContainer();
$mdTheming(element);
var originalRender = ngModelCtrl.$render;
ngModelCtrl.$render = function() {
originalRender();
syncLabelText();
syncAriaLabel();
inputCheckValue();
};
attr.$observe('placeholder', ngModelCtrl.$render);
if (containerCtrl && containerCtrl.label) {
attr.$observe('required', function (value) {
// Toggle the md-required class on the input containers label, because the input container is automatically
// applying the asterisk indicator on the label.
containerCtrl.label.toggleClass('md-required', value && !disableAsterisk);
});
}
mdSelectCtrl.setLabelText = function(text) {
mdSelectCtrl.setIsPlaceholder(!text);
// Whether the select label has been given via user content rather than the internal
// template of <md-option>
var isSelectLabelFromUser = false;
if (attr.mdSelectedText && attr.mdSelectedHtml) {
throw Error('md-select cannot have both `md-selected-text` and `md-selected-html`');
}
if (attr.mdSelectedText || attr.mdSelectedHtml) {
text = $parse(attr.mdSelectedText || attr.mdSelectedHtml)(scope);
isSelectLabelFromUser = true;
} else if (!text) {
// Use placeholder attribute, otherwise fallback to the md-input-container label
var tmpPlaceholder = attr.placeholder ||
(containerCtrl && containerCtrl.label ? containerCtrl.label.text() : '');
text = tmpPlaceholder || '';
isSelectLabelFromUser = true;
}
var target = valueEl.children().eq(0);
if (attr.mdSelectedHtml) {
// Using getTrustedHtml will run the content through $sanitize if it is not already
// explicitly trusted. If the ngSanitize module is not loaded, this will
// *correctly* throw an sce error.
target.html($sce.getTrustedHtml(text));
} else if (isSelectLabelFromUser) {
target.text(text);
} else {
// If we've reached this point, the text is not user-provided.
target.html(text);
}
};
mdSelectCtrl.setIsPlaceholder = function(isPlaceholder) {
if (isPlaceholder) {
valueEl.addClass('md-select-placeholder');
if (containerCtrl && containerCtrl.label) {
containerCtrl.label.addClass('md-placeholder');
}
} else {
valueEl.removeClass('md-select-placeholder');
if (containerCtrl && containerCtrl.label) {
containerCtrl.label.removeClass('md-placeholder');
}
}
};
if (!isReadonly) {
element
.on('focus', function(ev) {
// Always focus the container (if we have one) so floating labels and other styles are
// applied properly
containerCtrl && containerCtrl.setFocused(true);
});
// Attach before ngModel's blur listener to stop propagation of blur event
// to prevent from setting $touched.
element.on('blur', function(event) {
if (untouched) {
untouched = false;
if (selectScope._mdSelectIsOpen) {
event.stopImmediatePropagation();
}
}
if (selectScope._mdSelectIsOpen) return;
containerCtrl && containerCtrl.setFocused(false);
inputCheckValue();
});
}
mdSelectCtrl.triggerClose = function() {
$parse(attr.mdOnClose)(scope);
};
scope.$$postDigest(function() {
initAriaLabel();
syncLabelText();
syncAriaLabel();
});
function initAriaLabel() {
var labelText = element.attr('aria-label') || element.attr('placeholder');
if (!labelText && containerCtrl && containerCtrl.label) {
labelText = containerCtrl.label.text();
}
ariaLabelBase = labelText;
$mdAria.expect(element, 'aria-label', labelText);
}
scope.$watch(function() {
return selectMenuCtrl.selectedLabels();
}, syncLabelText);
function syncLabelText() {
if (selectContainer) {
selectMenuCtrl = selectMenuCtrl || selectContainer.find('md-select-menu').controller('mdSelectMenu');
mdSelectCtrl.setLabelText(selectMenuCtrl.selectedLabels());
}
}
function syncAriaLabel() {
if (!ariaLabelBase) return;
var ariaLabels = selectMenuCtrl.selectedLabels({mode: 'aria'});
element.attr('aria-label', ariaLabels.length ? ariaLabelBase + ': ' + ariaLabels : ariaLabelBase);
}
var deregisterWatcher;
attr.$observe('ngMultiple', function(val) {
if (deregisterWatcher) deregisterWatcher();
var parser = $parse(val);
deregisterWatcher = scope.$watch(function() {
return parser(scope);
}, function(multiple, prevVal) {
if (multiple === undefined && prevVal === undefined) return; // assume compiler did a good job
if (multiple) {
element.attr('multiple', 'multiple');
} else {
element.removeAttr('multiple');
}
element.attr('aria-multiselectable', multiple ? 'true' : 'false');
if (selectContainer) {
selectMenuCtrl.setMultiple(multiple);
originalRender = ngModelCtrl.$render;
ngModelCtrl.$render = function() {
originalRender();
syncLabelText();
syncAriaLabel();
inputCheckValue();
};
ngModelCtrl.$render();
}
});
});
attr.$observe('disabled', function(disabled) {
if (angular.isString(disabled)) {
disabled = true;
}
// Prevent click event being registered twice
if (isDisabled !== undefined && isDisabled === disabled) {
return;
}
isDisabled = disabled;
if (disabled) {
element
.attr({'aria-disabled': 'true'})
.removeAttr('tabindex')
.off('click', openSelect)
.off('keydown', handleKeypress);
} else {
element
.attr({'tabindex': attr.tabindex, 'aria-disabled': 'false'})
.on('click', openSelect)
.on('keydown', handleKeypress);
}
});
if (!attr.hasOwnProperty('disabled') && !attr.hasOwnProperty('ngDisabled')) {
element.attr({'aria-disabled': 'false'});
element.on('click', openSelect);
element.on('keydown', handleKeypress);
}
var ariaAttrs = {
role: 'listbox',
'aria-expanded': 'false',
'aria-multiselectable': isMultiple && !attr.ngMultiple ? 'true' : 'false'
};
if (!element[0].hasAttribute('id')) {
ariaAttrs.id = 'select_' + $mdUtil.nextUid();
}
var containerId = 'select_container_' + $mdUtil.nextUid();
selectContainer.attr('id', containerId);
// Only add aria-owns if element ownership is NOT represented in the DOM.
if (!element.find('md-select-menu').length) {
ariaAttrs['aria-owns'] = containerId;
}
element.attr(ariaAttrs);
scope.$on('$destroy', function() {
$mdSelect
.destroy()
.finally(function() {
if (containerCtrl) {
containerCtrl.setFocused(false);
containerCtrl.setHasValue(false);
containerCtrl.input = null;
}
ngModelCtrl.$setTouched();
});
});
function inputCheckValue() {
// The select counts as having a value if one or more options are selected,
// or if the input's validity state says it has bad input (eg string in a number input)
// we must do this on nextTick as the $render is sometimes invoked on nextTick.
$mdUtil.nextTick(function () {
containerCtrl && containerCtrl.setHasValue(selectMenuCtrl.selectedLabels().length > 0 || (element[0].validity || {}).badInput);
});
}
function findSelectContainer() {
selectContainer = angular.element(
element[0].querySelector('.md-select-menu-container')
);
selectScope = scope;
if (attr.mdContainerClass) {
var value = selectContainer[0].getAttribute('class') + ' ' + attr.mdContainerClass;
selectContainer[0].setAttribute('class', value);
}
selectMenuCtrl = selectContainer.find('md-select-menu').controller('mdSelectMenu');
selectMenuCtrl.init(ngModelCtrl, attr.ngModel);
element.on('$destroy', function() {
selectContainer.remove();
});
}
function handleKeypress(e) {
if ($mdConstant.isNavigationKey(e)) {
// prevent page scrolling on interaction
e.preventDefault();
openSelect(e);
} else {
if (shouldHandleKey(e, $mdConstant)) {
e.preventDefault();
var node = selectMenuCtrl.optNodeForKeyboardSearch(e);
if (!node || node.hasAttribute('disabled')) return;
var optionCtrl = angular.element(node).controller('mdOption');
if (!selectMenuCtrl.isMultiple) {
selectMenuCtrl.deselect(Object.keys(selectMenuCtrl.selected)[0]);
}
selectMenuCtrl.select(optionCtrl.hashKey, optionCtrl.value);
selectMenuCtrl.refreshViewValue();
}
}
}
function openSelect() {
selectScope._mdSelectIsOpen = true;
element.attr('aria-expanded', 'true');
$mdSelect.show({
scope: selectScope,
preserveScope: true,
skipCompile: true,
element: selectContainer,
target: element[0],
selectCtrl: mdSelectCtrl,
preserveElement: true,
hasBackdrop: true,
loadingAsync: attr.mdOnOpen ? scope.$eval(attr.mdOnOpen) || true : false
}).finally(function() {
selectScope._mdSelectIsOpen = false;
element.focus();
element.attr('aria-expanded', 'false');
ngModelCtrl.$setTouched();
});
}
};
}
} | javascript | function SelectDirective($mdSelect, $mdUtil, $mdConstant, $mdTheming, $mdAria, $parse, $sce,
$injector) {
var keyCodes = $mdConstant.KEY_CODE;
var NAVIGATION_KEYS = [keyCodes.SPACE, keyCodes.ENTER, keyCodes.UP_ARROW, keyCodes.DOWN_ARROW];
return {
restrict: 'E',
require: ['^?mdInputContainer', 'mdSelect', 'ngModel', '?^form'],
compile: compile,
controller: function() {
} // empty placeholder controller to be initialized in link
};
function compile(element, attr) {
// add the select value that will hold our placeholder or selected option value
var valueEl = angular.element('<md-select-value><span></span></md-select-value>');
valueEl.append('<span class="md-select-icon" aria-hidden="true"></span>');
valueEl.addClass('md-select-value');
if (!valueEl[0].hasAttribute('id')) {
valueEl.attr('id', 'select_value_label_' + $mdUtil.nextUid());
}
// There's got to be an md-content inside. If there's not one, let's add it.
var mdContentEl = element.find('md-content');
if (!mdContentEl.length) {
element.append(angular.element('<md-content>').append(element.contents()));
}
mdContentEl.attr('role', 'presentation');
// Add progress spinner for md-options-loading
if (attr.mdOnOpen) {
// Show progress indicator while loading async
// Use ng-hide for `display:none` so the indicator does not interfere with the options list
element
.find('md-content')
.prepend(angular.element(
'<div>' +
' <md-progress-circular md-mode="indeterminate" ng-if="$$loadingAsyncDone === false" md-diameter="25px"></md-progress-circular>' +
'</div>'
));
// Hide list [of item options] while loading async
element
.find('md-option')
.attr('ng-show', '$$loadingAsyncDone');
}
if (attr.name) {
var autofillClone = angular.element('<select class="md-visually-hidden"></select>');
autofillClone.attr({
'name': attr.name,
'aria-hidden': 'true',
'tabindex': '-1'
});
var opts = element.find('md-option');
angular.forEach(opts, function(el) {
var newEl = angular.element('<option>' + el.innerHTML + '</option>');
if (el.hasAttribute('ng-value')) newEl.attr('ng-value', el.getAttribute('ng-value'));
else if (el.hasAttribute('value')) newEl.attr('value', el.getAttribute('value'));
autofillClone.append(newEl);
});
// Adds an extra option that will hold the selected value for the
// cases where the select is a part of a non-angular form. This can be done with a ng-model,
// however if the `md-option` is being `ng-repeat`-ed, AngularJS seems to insert a similar
// `option` node, but with a value of `? string: <value> ?` which would then get submitted.
// This also goes around having to prepend a dot to the name attribute.
autofillClone.append(
'<option ng-value="' + attr.ngModel + '" selected></option>'
);
element.parent().append(autofillClone);
}
var isMultiple = $mdUtil.parseAttributeBoolean(attr.multiple);
// Use everything that's left inside element.contents() as the contents of the menu
var multipleContent = isMultiple ? 'multiple' : '';
var selectTemplate = '' +
'<div class="md-select-menu-container" aria-hidden="true" role="presentation">' +
'<md-select-menu role="presentation" {0}>{1}</md-select-menu>' +
'</div>';
selectTemplate = $mdUtil.supplant(selectTemplate, [multipleContent, element.html()]);
element.empty().append(valueEl);
element.append(selectTemplate);
if (!attr.tabindex){
attr.$set('tabindex', 0);
}
return function postLink(scope, element, attr, ctrls) {
var untouched = true;
var isDisabled, ariaLabelBase;
var containerCtrl = ctrls[0];
var mdSelectCtrl = ctrls[1];
var ngModelCtrl = ctrls[2];
var formCtrl = ctrls[3];
// grab a reference to the select menu value label
var valueEl = element.find('md-select-value');
var isReadonly = angular.isDefined(attr.readonly);
var disableAsterisk = $mdUtil.parseAttributeBoolean(attr.mdNoAsterisk);
if (disableAsterisk) {
element.addClass('md-no-asterisk');
}
if (containerCtrl) {
var isErrorGetter = containerCtrl.isErrorGetter || function() {
return ngModelCtrl.$invalid && (ngModelCtrl.$touched || (formCtrl && formCtrl.$submitted));
};
if (containerCtrl.input) {
// We ignore inputs that are in the md-select-header (one
// case where this might be useful would be adding as searchbox)
if (element.find('md-select-header').find('input')[0] !== containerCtrl.input[0]) {
throw new Error("<md-input-container> can only have *one* child <input>, <textarea> or <select> element!");
}
}
containerCtrl.input = element;
if (!containerCtrl.label) {
$mdAria.expect(element, 'aria-label', element.attr('placeholder'));
}
scope.$watch(isErrorGetter, containerCtrl.setInvalid);
}
var selectContainer, selectScope, selectMenuCtrl;
findSelectContainer();
$mdTheming(element);
var originalRender = ngModelCtrl.$render;
ngModelCtrl.$render = function() {
originalRender();
syncLabelText();
syncAriaLabel();
inputCheckValue();
};
attr.$observe('placeholder', ngModelCtrl.$render);
if (containerCtrl && containerCtrl.label) {
attr.$observe('required', function (value) {
// Toggle the md-required class on the input containers label, because the input container is automatically
// applying the asterisk indicator on the label.
containerCtrl.label.toggleClass('md-required', value && !disableAsterisk);
});
}
mdSelectCtrl.setLabelText = function(text) {
mdSelectCtrl.setIsPlaceholder(!text);
// Whether the select label has been given via user content rather than the internal
// template of <md-option>
var isSelectLabelFromUser = false;
if (attr.mdSelectedText && attr.mdSelectedHtml) {
throw Error('md-select cannot have both `md-selected-text` and `md-selected-html`');
}
if (attr.mdSelectedText || attr.mdSelectedHtml) {
text = $parse(attr.mdSelectedText || attr.mdSelectedHtml)(scope);
isSelectLabelFromUser = true;
} else if (!text) {
// Use placeholder attribute, otherwise fallback to the md-input-container label
var tmpPlaceholder = attr.placeholder ||
(containerCtrl && containerCtrl.label ? containerCtrl.label.text() : '');
text = tmpPlaceholder || '';
isSelectLabelFromUser = true;
}
var target = valueEl.children().eq(0);
if (attr.mdSelectedHtml) {
// Using getTrustedHtml will run the content through $sanitize if it is not already
// explicitly trusted. If the ngSanitize module is not loaded, this will
// *correctly* throw an sce error.
target.html($sce.getTrustedHtml(text));
} else if (isSelectLabelFromUser) {
target.text(text);
} else {
// If we've reached this point, the text is not user-provided.
target.html(text);
}
};
mdSelectCtrl.setIsPlaceholder = function(isPlaceholder) {
if (isPlaceholder) {
valueEl.addClass('md-select-placeholder');
if (containerCtrl && containerCtrl.label) {
containerCtrl.label.addClass('md-placeholder');
}
} else {
valueEl.removeClass('md-select-placeholder');
if (containerCtrl && containerCtrl.label) {
containerCtrl.label.removeClass('md-placeholder');
}
}
};
if (!isReadonly) {
element
.on('focus', function(ev) {
// Always focus the container (if we have one) so floating labels and other styles are
// applied properly
containerCtrl && containerCtrl.setFocused(true);
});
// Attach before ngModel's blur listener to stop propagation of blur event
// to prevent from setting $touched.
element.on('blur', function(event) {
if (untouched) {
untouched = false;
if (selectScope._mdSelectIsOpen) {
event.stopImmediatePropagation();
}
}
if (selectScope._mdSelectIsOpen) return;
containerCtrl && containerCtrl.setFocused(false);
inputCheckValue();
});
}
mdSelectCtrl.triggerClose = function() {
$parse(attr.mdOnClose)(scope);
};
scope.$$postDigest(function() {
initAriaLabel();
syncLabelText();
syncAriaLabel();
});
function initAriaLabel() {
var labelText = element.attr('aria-label') || element.attr('placeholder');
if (!labelText && containerCtrl && containerCtrl.label) {
labelText = containerCtrl.label.text();
}
ariaLabelBase = labelText;
$mdAria.expect(element, 'aria-label', labelText);
}
scope.$watch(function() {
return selectMenuCtrl.selectedLabels();
}, syncLabelText);
function syncLabelText() {
if (selectContainer) {
selectMenuCtrl = selectMenuCtrl || selectContainer.find('md-select-menu').controller('mdSelectMenu');
mdSelectCtrl.setLabelText(selectMenuCtrl.selectedLabels());
}
}
function syncAriaLabel() {
if (!ariaLabelBase) return;
var ariaLabels = selectMenuCtrl.selectedLabels({mode: 'aria'});
element.attr('aria-label', ariaLabels.length ? ariaLabelBase + ': ' + ariaLabels : ariaLabelBase);
}
var deregisterWatcher;
attr.$observe('ngMultiple', function(val) {
if (deregisterWatcher) deregisterWatcher();
var parser = $parse(val);
deregisterWatcher = scope.$watch(function() {
return parser(scope);
}, function(multiple, prevVal) {
if (multiple === undefined && prevVal === undefined) return; // assume compiler did a good job
if (multiple) {
element.attr('multiple', 'multiple');
} else {
element.removeAttr('multiple');
}
element.attr('aria-multiselectable', multiple ? 'true' : 'false');
if (selectContainer) {
selectMenuCtrl.setMultiple(multiple);
originalRender = ngModelCtrl.$render;
ngModelCtrl.$render = function() {
originalRender();
syncLabelText();
syncAriaLabel();
inputCheckValue();
};
ngModelCtrl.$render();
}
});
});
attr.$observe('disabled', function(disabled) {
if (angular.isString(disabled)) {
disabled = true;
}
// Prevent click event being registered twice
if (isDisabled !== undefined && isDisabled === disabled) {
return;
}
isDisabled = disabled;
if (disabled) {
element
.attr({'aria-disabled': 'true'})
.removeAttr('tabindex')
.off('click', openSelect)
.off('keydown', handleKeypress);
} else {
element
.attr({'tabindex': attr.tabindex, 'aria-disabled': 'false'})
.on('click', openSelect)
.on('keydown', handleKeypress);
}
});
if (!attr.hasOwnProperty('disabled') && !attr.hasOwnProperty('ngDisabled')) {
element.attr({'aria-disabled': 'false'});
element.on('click', openSelect);
element.on('keydown', handleKeypress);
}
var ariaAttrs = {
role: 'listbox',
'aria-expanded': 'false',
'aria-multiselectable': isMultiple && !attr.ngMultiple ? 'true' : 'false'
};
if (!element[0].hasAttribute('id')) {
ariaAttrs.id = 'select_' + $mdUtil.nextUid();
}
var containerId = 'select_container_' + $mdUtil.nextUid();
selectContainer.attr('id', containerId);
// Only add aria-owns if element ownership is NOT represented in the DOM.
if (!element.find('md-select-menu').length) {
ariaAttrs['aria-owns'] = containerId;
}
element.attr(ariaAttrs);
scope.$on('$destroy', function() {
$mdSelect
.destroy()
.finally(function() {
if (containerCtrl) {
containerCtrl.setFocused(false);
containerCtrl.setHasValue(false);
containerCtrl.input = null;
}
ngModelCtrl.$setTouched();
});
});
function inputCheckValue() {
// The select counts as having a value if one or more options are selected,
// or if the input's validity state says it has bad input (eg string in a number input)
// we must do this on nextTick as the $render is sometimes invoked on nextTick.
$mdUtil.nextTick(function () {
containerCtrl && containerCtrl.setHasValue(selectMenuCtrl.selectedLabels().length > 0 || (element[0].validity || {}).badInput);
});
}
function findSelectContainer() {
selectContainer = angular.element(
element[0].querySelector('.md-select-menu-container')
);
selectScope = scope;
if (attr.mdContainerClass) {
var value = selectContainer[0].getAttribute('class') + ' ' + attr.mdContainerClass;
selectContainer[0].setAttribute('class', value);
}
selectMenuCtrl = selectContainer.find('md-select-menu').controller('mdSelectMenu');
selectMenuCtrl.init(ngModelCtrl, attr.ngModel);
element.on('$destroy', function() {
selectContainer.remove();
});
}
function handleKeypress(e) {
if ($mdConstant.isNavigationKey(e)) {
// prevent page scrolling on interaction
e.preventDefault();
openSelect(e);
} else {
if (shouldHandleKey(e, $mdConstant)) {
e.preventDefault();
var node = selectMenuCtrl.optNodeForKeyboardSearch(e);
if (!node || node.hasAttribute('disabled')) return;
var optionCtrl = angular.element(node).controller('mdOption');
if (!selectMenuCtrl.isMultiple) {
selectMenuCtrl.deselect(Object.keys(selectMenuCtrl.selected)[0]);
}
selectMenuCtrl.select(optionCtrl.hashKey, optionCtrl.value);
selectMenuCtrl.refreshViewValue();
}
}
}
function openSelect() {
selectScope._mdSelectIsOpen = true;
element.attr('aria-expanded', 'true');
$mdSelect.show({
scope: selectScope,
preserveScope: true,
skipCompile: true,
element: selectContainer,
target: element[0],
selectCtrl: mdSelectCtrl,
preserveElement: true,
hasBackdrop: true,
loadingAsync: attr.mdOnOpen ? scope.$eval(attr.mdOnOpen) || true : false
}).finally(function() {
selectScope._mdSelectIsOpen = false;
element.focus();
element.attr('aria-expanded', 'false');
ngModelCtrl.$setTouched();
});
}
};
}
} | [
"function",
"SelectDirective",
"(",
"$mdSelect",
",",
"$mdUtil",
",",
"$mdConstant",
",",
"$mdTheming",
",",
"$mdAria",
",",
"$parse",
",",
"$sce",
",",
"$injector",
")",
"{",
"var",
"keyCodes",
"=",
"$mdConstant",
".",
"KEY_CODE",
";",
"var",
"NAVIGATION_KEYS... | @ngdoc directive
@name mdSelect
@restrict E
@module material.components.select
@description Displays a select box, bound to an `ng-model`. Selectable options are defined using
the <a ng-href="/api/directive/mdOption">md-option</a> element directive. Options can be grouped
using the <a ng-href="/api/directive/mdOptgroup">md-optgroup</a> element directive.
When the select is required and uses a floating label, then the label will automatically contain
an asterisk (`*`). This behavior can be disabled by using the `md-no-asterisk` attribute.
By default, the select will display with an underline to match other form elements. This can be
disabled by applying the `md-no-underline` CSS class.
@param {expression} ng-model Assignable angular expression to data-bind to.
@param {expression=} ng-change Expression to be executed when the model value changes.
@param {boolean=} multiple When present, allows for more than one option to be selected.
The model is an array with the selected choices. **Note:** This attribute is only evaluated
once; it is not watched.
@param {expression=} md-on-close Expression to be evaluated when the select is closed.
@param {expression=} md-on-open Expression to be evaluated when opening the select.
Will hide the select options and show a spinner until the evaluated promise resolves.
@param {expression=} md-selected-text Expression to be evaluated that will return a string
to be displayed as a placeholder in the select input box when it is closed. The value
will be treated as *text* (not html).
@param {expression=} md-selected-html Expression to be evaluated that will return a string
to be displayed as a placeholder in the select input box when it is closed. The value
will be treated as *html*. The value must either be explicitly marked as trustedHtml or
the ngSanitize module must be loaded.
@param {string=} placeholder Placeholder hint text.
@param {boolean=} md-no-asterisk When set to true, an asterisk will not be appended to the
floating label. **Note:** This attribute is only evaluated once; it is not watched.
@param {string=} aria-label Optional label for accessibility. Only necessary if no placeholder or
explicit label is present.
@param {string=} md-container-class Class list to get applied to the `.md-select-menu-container`
element (for custom styling).
@usage
With a placeholder (label and aria-label are added dynamically)
<hljs lang="html">
<md-input-container>
<md-select
ng-model="someModel"
placeholder="Select a state">
<md-option ng-value="opt" ng-repeat="opt in neighborhoods2">{{ opt }}</md-option>
</md-select>
</md-input-container>
</hljs>
With an explicit label
<hljs lang="html">
<md-input-container>
<label>State</label>
<md-select
ng-model="someModel">
<md-option ng-value="opt" ng-repeat="opt in neighborhoods2">{{ opt }}</md-option>
</md-select>
</md-input-container>
</hljs>
Using the `md-select-header` element directive
When a developer needs to put more than just a text label in the `md-select-menu`, they should
use one or more `md-select-header`s. These elements can contain custom HTML which can be styled
as desired. Use cases for this element include a sticky search bar and custom option group
labels.
<hljs lang="html">
<md-input-container>
<md-select ng-model="someModel">
<md-select-header>
<span> Neighborhoods - </span>
</md-select-header>
<md-option ng-value="opt" ng-repeat="opt in neighborhoods2">{{ opt }}</md-option>
</md-select>
</md-input-container>
</hljs>
## Selects and object equality
When using a `md-select` to pick from a list of objects, it is important to realize how javascript handles
equality. Consider the following example:
<hljs lang="js">
angular.controller('MyCtrl', function($scope) {
$scope.users = [
{ id: 1, name: 'Bob' },
{ id: 2, name: 'Alice' },
{ id: 3, name: 'Steve' }
];
$scope.selectedUser = { id: 1, name: 'Bob' };
});
</hljs>
<hljs lang="html">
<div ng-controller="MyCtrl">
<md-select ng-model="selectedUser">
<md-option ng-value="user" ng-repeat="user in users">{{ user.name }}</md-option>
</md-select>
</div>
</hljs>
At first one might expect that the select should be populated with "Bob" as the selected user.
However, this is not true. To determine whether something is selected,
`ngModelController` is looking at whether `$scope.selectedUser == (any user in $scope.users);`;
Javascript's `==` operator does not check for deep equality (ie. that all properties
on the object are the same), but instead whether the objects are *the same object in memory*.
In this case, we have two instances of identical objects, but they exist in memory as unique
entities. Because of this, the select will have no value populated for a selected user.
To get around this, `ngModelController` provides a `track by` option that allows us to specify a
different expression which will be used for the equality operator. As such, we can update our
`html` to make use of this by specifying the `ng-model-options="{trackBy: '$value.id'}"` on the
`md-select` element. This converts our equality expression to be
`$scope.selectedUser.id == (any id in $scope.users.map(function(u) { return u.id; }));`
which results in Bob being selected as desired.
**Note:** We do not support AngularJS's `track by` syntax. For instance
`ng-options="user in users track by user.id"` will not work with `md-select`.
Working HTML:
<hljs lang="html">
<div ng-controller="MyCtrl">
<md-select ng-model="selectedUser" ng-model-options="{trackBy: '$value.id'}">
<md-option ng-value="user" ng-repeat="user in users">{{ user.name }}</md-option>
</md-select>
</div>
</hljs> | [
"@ngdoc",
"directive",
"@name",
"mdSelect",
"@restrict",
"E",
"@module",
"material",
".",
"components",
".",
"select"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L158-L584 | train | Select directive. | [
30522,
3853,
7276,
4305,
2890,
15277,
1006,
1002,
9108,
11246,
22471,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
9108,
8663,
12693,
2102,
1010,
1002,
9108,
10760,
6562,
1010,
1002,
9108,
10980,
1010,
1002,
11968,
3366,
1010,
1002,
8040,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
vuejs/vue-devtools | shells/chrome/src/devtools.js | injectScript | function injectScript (scriptName, cb) {
const src = `
(function() {
var script = document.constructor.prototype.createElement.call(document, 'script');
script.src = "${scriptName}";
document.documentElement.appendChild(script);
script.parentNode.removeChild(script);
})()
`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
cb()
})
} | javascript | function injectScript (scriptName, cb) {
const src = `
(function() {
var script = document.constructor.prototype.createElement.call(document, 'script');
script.src = "${scriptName}";
document.documentElement.appendChild(script);
script.parentNode.removeChild(script);
})()
`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
cb()
})
} | [
"function",
"injectScript",
"(",
"scriptName",
",",
"cb",
")",
"{",
"const",
"src",
"=",
"`",
"${",
"scriptName",
"}",
"`",
"chrome",
".",
"devtools",
".",
"inspectedWindow",
".",
"eval",
"(",
"src",
",",
"function",
"(",
"res",
",",
"err",
")",
"{",
... | Inject a globally evaluated script, in the same context with the actual
user app.
@param {String} scriptName
@param {Function} cb | [
"Inject",
"a",
"globally",
"evaluated",
"script",
"in",
"the",
"same",
"context",
"with",
"the",
"actual",
"user",
"app",
"."
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/shells/chrome/src/devtools.js#L60-L75 | train | Inject a script into the page | [
30522,
3853,
1999,
20614,
22483,
1006,
5896,
18442,
1010,
17324,
1007,
1063,
9530,
3367,
5034,
2278,
1027,
1036,
1006,
3853,
1006,
1007,
1063,
13075,
5896,
1027,
6254,
1012,
9570,
2953,
1012,
8773,
1012,
3443,
12260,
3672,
1012,
2655,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/modifiers/summary/insertArticle.js | insertArticle | function insertArticle(summary, article, level) {
article = SummaryArticle(article);
level = is.string(level)? level : level.getLevel();
var parent = summary.getParent(level);
if (!parent) {
return summary;
}
// Find the index to insert at
var articles = parent.getArticles();
var index = getLeafIndex(level);
// Insert the article at the right index
articles = articles.insert(index, article);
// Reindex the level from here
parent = parent.set('articles', articles);
parent = indexArticleLevels(parent);
return mergeAtLevel(summary, parent.getLevel(), parent);
} | javascript | function insertArticle(summary, article, level) {
article = SummaryArticle(article);
level = is.string(level)? level : level.getLevel();
var parent = summary.getParent(level);
if (!parent) {
return summary;
}
// Find the index to insert at
var articles = parent.getArticles();
var index = getLeafIndex(level);
// Insert the article at the right index
articles = articles.insert(index, article);
// Reindex the level from here
parent = parent.set('articles', articles);
parent = indexArticleLevels(parent);
return mergeAtLevel(summary, parent.getLevel(), parent);
} | [
"function",
"insertArticle",
"(",
"summary",
",",
"article",
",",
"level",
")",
"{",
"article",
"=",
"SummaryArticle",
"(",
"article",
")",
";",
"level",
"=",
"is",
".",
"string",
"(",
"level",
")",
"?",
"level",
":",
"level",
".",
"getLevel",
"(",
")"... | Returns a new Summary with the article at the given level, with
subsequent article shifted.
@param {Summary} summary
@param {Article} article
@param {String|Article} level: level to insert at
@return {Summary} | [
"Returns",
"a",
"new",
"Summary",
"with",
"the",
"article",
"at",
"the",
"given",
"level",
"with",
"subsequent",
"article",
"shifted",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/insertArticle.js#L15-L36 | train | Insert an article into the summary at the given level | [
30522,
3853,
19274,
8445,
25128,
1006,
12654,
1010,
3720,
1010,
2504,
1007,
1063,
3720,
1027,
12654,
8445,
25128,
1006,
3720,
1007,
1025,
2504,
1027,
2003,
1012,
5164,
1006,
2504,
1007,
1029,
2504,
1024,
2504,
1012,
2131,
20414,
2884,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/lib/image/cached-image-size-from-url.js | getCachedImageSizeFromUrl | function getCachedImageSizeFromUrl(url) {
if (!url || url === undefined || url === null) {
return;
}
// image size is not in cache
if (!cache[url]) {
return imageSize.getImageSizeFromUrl(url).then(function (res) {
cache[url] = res;
debug('Cached image:', url);
return cache[url];
}).catch(common.errors.NotFoundError, function () {
debug('Cached image (not found):', url);
// in case of error we just attach the url
cache[url] = url;
return cache[url];
}).catch(function (err) {
debug('Cached image (error):', url);
common.logging.error(err);
// in case of error we just attach the url
cache[url] = url;
return cache[url];
});
}
debug('Read image from cache:', url);
// returns image size from cache
return cache[url];
} | javascript | function getCachedImageSizeFromUrl(url) {
if (!url || url === undefined || url === null) {
return;
}
// image size is not in cache
if (!cache[url]) {
return imageSize.getImageSizeFromUrl(url).then(function (res) {
cache[url] = res;
debug('Cached image:', url);
return cache[url];
}).catch(common.errors.NotFoundError, function () {
debug('Cached image (not found):', url);
// in case of error we just attach the url
cache[url] = url;
return cache[url];
}).catch(function (err) {
debug('Cached image (error):', url);
common.logging.error(err);
// in case of error we just attach the url
cache[url] = url;
return cache[url];
});
}
debug('Read image from cache:', url);
// returns image size from cache
return cache[url];
} | [
"function",
"getCachedImageSizeFromUrl",
"(",
"url",
")",
"{",
"if",
"(",
"!",
"url",
"||",
"url",
"===",
"undefined",
"||",
"url",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// image size is not in cache",
"if",
"(",
"!",
"cache",
"[",
"url",
"]",
")... | Get cached image size from URL
Always returns {object} imageSizeCache
@param {string} url
@returns {Promise<Object>} imageSizeCache
@description Takes a url and returns image width and height from cache if available.
If not in cache, `getImageSizeFromUrl` is called and returns the dimensions in a Promise. | [
"Get",
"cached",
"image",
"size",
"from",
"URL",
"Always",
"returns",
"{",
"object",
"}",
"imageSizeCache"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/lib/image/cached-image-size-from-url.js#L14-L46 | train | Get image size from cache | [
30522,
3853,
2131,
3540,
7690,
9581,
8449,
4697,
19699,
5358,
3126,
2140,
1006,
24471,
2140,
1007,
1063,
2065,
1006,
999,
24471,
2140,
1064,
1064,
24471,
2140,
1027,
1027,
1027,
6151,
28344,
1064,
1064,
24471,
2140,
1027,
1027,
1027,
19701,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/jquery.sap.history.js | getAppendId | function getAppendId(sHash){
var iIndex = jQuery.inArray(currentHash, hashHistory),
i, sHistory;
if (iIndex > -1) {
for (i = 0 ; i < iIndex + 1 ; i++) {
sHistory = hashHistory[i];
if (sHistory.slice(0, sHistory.length - 2) === sHash) {
return uid();
}
}
}
return "";
} | javascript | function getAppendId(sHash){
var iIndex = jQuery.inArray(currentHash, hashHistory),
i, sHistory;
if (iIndex > -1) {
for (i = 0 ; i < iIndex + 1 ; i++) {
sHistory = hashHistory[i];
if (sHistory.slice(0, sHistory.length - 2) === sHash) {
return uid();
}
}
}
return "";
} | [
"function",
"getAppendId",
"(",
"sHash",
")",
"{",
"var",
"iIndex",
"=",
"jQuery",
".",
"inArray",
"(",
"currentHash",
",",
"hashHistory",
")",
",",
"i",
",",
"sHistory",
";",
"if",
"(",
"iIndex",
">",
"-",
"1",
")",
"{",
"for",
"(",
"i",
"=",
"0",... | This function checks if the combination of the identifier and data is unique in the current history stack.
If yes, it returns an empty string. Otherwise it returns a unique id.
@private | [
"This",
"function",
"checks",
"if",
"the",
"combination",
"of",
"the",
"identifier",
"and",
"data",
"is",
"unique",
"in",
"the",
"current",
"history",
"stack",
".",
"If",
"yes",
"it",
"returns",
"an",
"empty",
"string",
".",
"Otherwise",
"it",
"returns",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/jquery.sap.history.js#L506-L519 | train | Returns the id of the append element | [
30522,
3853,
2131,
29098,
10497,
3593,
1006,
21146,
4095,
1007,
1063,
13075,
2462,
13629,
2595,
1027,
1046,
4226,
2854,
1012,
27118,
11335,
2100,
1006,
2783,
14949,
2232,
1010,
23325,
24158,
7062,
1007,
1010,
1045,
1010,
11895,
23809,
2100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function (node) {
var next = node;
while (next
&& (next.nodeType != this.ELEMENT_NODE)
&& this.REGEXPS.whitespace.test(next.textContent)) {
next = next.nextSibling;
}
return next;
} | javascript | function (node) {
var next = node;
while (next
&& (next.nodeType != this.ELEMENT_NODE)
&& this.REGEXPS.whitespace.test(next.textContent)) {
next = next.nextSibling;
}
return next;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"next",
"=",
"node",
";",
"while",
"(",
"next",
"&&",
"(",
"next",
".",
"nodeType",
"!=",
"this",
".",
"ELEMENT_NODE",
")",
"&&",
"this",
".",
"REGEXPS",
".",
"whitespace",
".",
"test",
"(",
"next",
".",
"t... | Finds the next element, starting from the given node, and ignoring
whitespace in between. If the given node is an element, the same node is
returned. | [
"Finds",
"the",
"next",
"element",
"starting",
"from",
"the",
"given",
"node",
"and",
"ignoring",
"whitespace",
"in",
"between",
".",
"If",
"the",
"given",
"node",
"is",
"an",
"element",
"the",
"same",
"node",
"is",
"returned",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L449-L457 | train | Returns the next sibling of node | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
2279,
1027,
13045,
1025,
2096,
1006,
2279,
1004,
1004,
1006,
2279,
1012,
13045,
13874,
999,
1027,
2023,
1012,
5783,
1035,
13045,
1007,
1004,
1004,
2023,
1012,
19723,
10288,
4523,
1012,
12461,
153... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/debug/LogViewer.js | function(oWindow, sRootId) {
this.oWindow = oWindow;
this.oDomNode = oWindow.document.getElementById(sRootId);
if (!this.oDomNode) {
var oDiv = this.oWindow.document.createElement("DIV");
oDiv.setAttribute("id", sRootId);
oDiv.style.overflow = "auto";
oDiv.style.tabIndex = "-1";
oDiv.style.position = "absolute";
oDiv.style.bottom = "0px";
oDiv.style.left = "0px";
oDiv.style.right = "202px";
oDiv.style.height = "200px";
oDiv.style.border = "1px solid gray";
oDiv.style.fontFamily = "Arial monospaced for SAP,monospace";
oDiv.style.fontSize = "11px";
oDiv.style.zIndex = "999999";
this.oWindow.document.body.appendChild(oDiv);
this.oDomNode = oDiv;
}
this.iLogLevel = 3; /* Log.LogLevel.INFO */
this.sLogEntryClassPrefix = undefined;
this.clear();
this.setFilter(LogViewer.NO_FILTER);
} | javascript | function(oWindow, sRootId) {
this.oWindow = oWindow;
this.oDomNode = oWindow.document.getElementById(sRootId);
if (!this.oDomNode) {
var oDiv = this.oWindow.document.createElement("DIV");
oDiv.setAttribute("id", sRootId);
oDiv.style.overflow = "auto";
oDiv.style.tabIndex = "-1";
oDiv.style.position = "absolute";
oDiv.style.bottom = "0px";
oDiv.style.left = "0px";
oDiv.style.right = "202px";
oDiv.style.height = "200px";
oDiv.style.border = "1px solid gray";
oDiv.style.fontFamily = "Arial monospaced for SAP,monospace";
oDiv.style.fontSize = "11px";
oDiv.style.zIndex = "999999";
this.oWindow.document.body.appendChild(oDiv);
this.oDomNode = oDiv;
}
this.iLogLevel = 3; /* Log.LogLevel.INFO */
this.sLogEntryClassPrefix = undefined;
this.clear();
this.setFilter(LogViewer.NO_FILTER);
} | [
"function",
"(",
"oWindow",
",",
"sRootId",
")",
"{",
"this",
".",
"oWindow",
"=",
"oWindow",
";",
"this",
".",
"oDomNode",
"=",
"oWindow",
".",
"document",
".",
"getElementById",
"(",
"sRootId",
")",
";",
"if",
"(",
"!",
"this",
".",
"oDomNode",
")",
... | Constructs a LogViewer in the given window, embedded into the given DOM element.
If the DOM element doesn't exist, a DIV is created.
@param {Window} oTargetWindow the window where the log will be displayed in
@param {sRootId} sRootId id of the top level element that will contain the log entries
@class HTML LogViewer that displays all entries of a Logger, as long as they match a filter and a minimal log level
@alias sap.ui.debug.LogViewer | [
"Constructs",
"a",
"LogViewer",
"in",
"the",
"given",
"window",
"embedded",
"into",
"the",
"given",
"DOM",
"element",
".",
"If",
"the",
"DOM",
"element",
"doesn",
"t",
"exist",
"a",
"DIV",
"is",
"created",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/debug/LogViewer.js#L20-L44 | train | Initializes the log viewer. | [
30522,
3853,
1006,
27593,
22254,
5004,
1010,
5034,
17206,
3593,
1007,
1063,
2023,
1012,
27593,
22254,
5004,
1027,
27593,
22254,
5004,
1025,
2023,
1012,
1051,
9527,
3630,
3207,
1027,
27593,
22254,
5004,
1012,
6254,
1012,
2131,
12260,
3672,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/component/dataZoom/DataZoomModel.js | function (opt, ignoreUpdateRangeUsg) {
var option = this.option;
each([['start', 'startValue'], ['end', 'endValue']], function (names) {
// If only one of 'start' and 'startValue' is not null/undefined, the other
// should be cleared, which enable clear the option.
// If both of them are not set, keep option with the original value, which
// enable use only set start but not set end when calling `dispatchAction`.
// The same as 'end' and 'endValue'.
if (opt[names[0]] != null || opt[names[1]] != null) {
option[names[0]] = opt[names[0]];
option[names[1]] = opt[names[1]];
}
}, this);
!ignoreUpdateRangeUsg && updateRangeUse(this, opt);
} | javascript | function (opt, ignoreUpdateRangeUsg) {
var option = this.option;
each([['start', 'startValue'], ['end', 'endValue']], function (names) {
// If only one of 'start' and 'startValue' is not null/undefined, the other
// should be cleared, which enable clear the option.
// If both of them are not set, keep option with the original value, which
// enable use only set start but not set end when calling `dispatchAction`.
// The same as 'end' and 'endValue'.
if (opt[names[0]] != null || opt[names[1]] != null) {
option[names[0]] = opt[names[0]];
option[names[1]] = opt[names[1]];
}
}, this);
!ignoreUpdateRangeUsg && updateRangeUse(this, opt);
} | [
"function",
"(",
"opt",
",",
"ignoreUpdateRangeUsg",
")",
"{",
"var",
"option",
"=",
"this",
".",
"option",
";",
"each",
"(",
"[",
"[",
"'start'",
",",
"'startValue'",
"]",
",",
"[",
"'end'",
",",
"'endValue'",
"]",
"]",
",",
"function",
"(",
"names",
... | If not specified, set to undefined.
@public
@param {Object} opt
@param {number} [opt.start]
@param {number} [opt.end]
@param {number} [opt.startValue]
@param {number} [opt.endValue]
@param {boolean} [ignoreUpdateRangeUsg=false] | [
"If",
"not",
"specified",
"set",
"to",
"undefined",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/DataZoomModel.js#L455-L470 | train | Update the options of the current page | [
30522,
3853,
1006,
23569,
1010,
8568,
6279,
13701,
24388,
10600,
2290,
1007,
1063,
13075,
5724,
1027,
2023,
1012,
5724,
1025,
2169,
1006,
1031,
1031,
1005,
2707,
1005,
1010,
1005,
2707,
10175,
5657,
1005,
1033,
1010,
1031,
1005,
2203,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/selenium-core/lib/scriptaculous/dragdrop.js | function (element, containerTag) {
if (element && element.hasChildNodes)
for (var i = 0; i < element.childNodes.length; ++i)
if (element.childNodes[i].tagName == containerTag)
return element.childNodes[i];
return null;
} | javascript | function (element, containerTag) {
if (element && element.hasChildNodes)
for (var i = 0; i < element.childNodes.length; ++i)
if (element.childNodes[i].tagName == containerTag)
return element.childNodes[i];
return null;
} | [
"function",
"(",
"element",
",",
"containerTag",
")",
"{",
"if",
"(",
"element",
"&&",
"element",
".",
"hasChildNodes",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"element",
".",
"childNodes",
".",
"length",
";",
"++",
"i",
")",
"if",
"(... | /* Finds the first element of the given tag type within a parent element.
Used for finding the first LI[ST] within a L[IST]I[TEM]. | [
"/",
"*",
"Finds",
"the",
"first",
"element",
"of",
"the",
"given",
"tag",
"type",
"within",
"a",
"parent",
"element",
".",
"Used",
"for",
"finding",
"the",
"first",
"LI",
"[",
"ST",
"]",
"within",
"a",
"L",
"[",
"IST",
"]",
"I",
"[",
"TEM",
"]",
... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/lib/scriptaculous/dragdrop.js#L795-L802 | train | Returns the first node of the specified container tag | [
30522,
3853,
1006,
5783,
1010,
11661,
15900,
1007,
1063,
2065,
1006,
5783,
1004,
1004,
5783,
1012,
2038,
19339,
3630,
6155,
1007,
2005,
1006,
13075,
30524,
1031,
1045,
1033,
1025,
2709,
19701,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | examples/hello-mui/js/mui.js | function(container, progress, color) {
if (typeof container === 'number') {
color = progress;
progress = container;
container = 'body';
}
container = $(container || 'body');
if (container.length === 0) return;
container = container[0];
var progressbar;
if (container.classList.contains(CLASS_PROGRESSBAR)) {
progressbar = container;
} else {
var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR + ':not(.' + CLASS_PROGRESSBAR_OUT + ')');
if (progressbars) {
for (var i = 0, len = progressbars.length; i < len; i++) {
var _progressbar = progressbars[i];
if (_progressbar.parentNode === container) {
progressbar = _progressbar;
break;
}
}
}
if (!progressbar) {
progressbar = document.createElement('span');
progressbar.className = CLASS_PROGRESSBAR + ' ' + CLASS_PROGRESSBAR_IN + (typeof progress !== 'undefined' ? '' : (' ' + CLASS_PROGRESSBAR_INFINITE)) + (color ? (' ' + CLASS_PROGRESSBAR + '-' + color) : '');
if (typeof progress !== 'undefined') {
progressbar.innerHTML = '<span></span>';
}
container.appendChild(progressbar);
} else {
progressbar.classList.add(CLASS_PROGRESSBAR_IN);
}
}
if (progress) setProgressbar(container, progress);
return progressbar;
} | javascript | function(container, progress, color) {
if (typeof container === 'number') {
color = progress;
progress = container;
container = 'body';
}
container = $(container || 'body');
if (container.length === 0) return;
container = container[0];
var progressbar;
if (container.classList.contains(CLASS_PROGRESSBAR)) {
progressbar = container;
} else {
var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR + ':not(.' + CLASS_PROGRESSBAR_OUT + ')');
if (progressbars) {
for (var i = 0, len = progressbars.length; i < len; i++) {
var _progressbar = progressbars[i];
if (_progressbar.parentNode === container) {
progressbar = _progressbar;
break;
}
}
}
if (!progressbar) {
progressbar = document.createElement('span');
progressbar.className = CLASS_PROGRESSBAR + ' ' + CLASS_PROGRESSBAR_IN + (typeof progress !== 'undefined' ? '' : (' ' + CLASS_PROGRESSBAR_INFINITE)) + (color ? (' ' + CLASS_PROGRESSBAR + '-' + color) : '');
if (typeof progress !== 'undefined') {
progressbar.innerHTML = '<span></span>';
}
container.appendChild(progressbar);
} else {
progressbar.classList.add(CLASS_PROGRESSBAR_IN);
}
}
if (progress) setProgressbar(container, progress);
return progressbar;
} | [
"function",
"(",
"container",
",",
"progress",
",",
"color",
")",
"{",
"if",
"(",
"typeof",
"container",
"===",
"'number'",
")",
"{",
"color",
"=",
"progress",
";",
"progress",
"=",
"container",
";",
"container",
"=",
"'body'",
";",
"}",
"container",
"="... | 创建并显示进度条
@param {Object} container 可选,默认body,支持selector,DOM Node,mui wrapper
@param {Object} progress 可选,undefined表示循环,数字表示具体进度
@param {Object} color 可选,指定颜色样式(目前暂未提供实际样式,可暂时不暴露此参数) | [
"创建并显示进度条"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L7653-L7689 | train | Creates a progress bar element | [
30522,
3853,
1006,
11661,
1010,
5082,
1010,
3609,
1007,
1063,
2065,
1006,
2828,
11253,
11661,
1027,
1027,
1027,
1005,
2193,
1005,
1007,
1063,
3609,
1027,
5082,
1025,
5082,
1027,
11661,
1025,
11661,
1027,
1005,
2303,
1005,
1025,
1065,
11661,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js | function (oRequestor, sUrl, vAnnotationUri, oModel, bSupportReferences) {
MetaModel.call(this);
this.aAnnotationUris = vAnnotationUri && !Array.isArray(vAnnotationUri)
? [vAnnotationUri] : vAnnotationUri;
this.sDefaultBindingMode = BindingMode.OneTime;
this.mETags = {};
this.dLastModified = new Date(0);
this.oMetadataPromise = null;
this.oModel = oModel;
this.mMetadataUrl2Promise = {};
this.oRequestor = oRequestor;
// maps the schema name to a map containing the URL references for the schema as key
// and a boolean value whether the schema has been read already as value; the URL
// reference is used by _MetadataRequestor#read()
// Example:
// mSchema2MetadataUrl = {
// "A." : {"/A/$metadata" : false}, // namespace not yet read
// // multiple references are ok as long as they are not read
// "A.A." : {"/A/$metadata" : false, "/A/V2/$metadata" : false},
// "B." : {"/B/$metadata" : true} // namespace already read
// }
this.mSchema2MetadataUrl = {};
this.mSupportedBindingModes = {"OneTime" : true, "OneWay" : true};
this.bSupportReferences = bSupportReferences !== false; // default is true
// ClientListBinding#filter calls checkFilterOperation on the model; ClientModel does
// not support "All" and "Any" filters
this.mUnsupportedFilterOperators = {"All" : true, "Any" : true};
this.sUrl = sUrl;
} | javascript | function (oRequestor, sUrl, vAnnotationUri, oModel, bSupportReferences) {
MetaModel.call(this);
this.aAnnotationUris = vAnnotationUri && !Array.isArray(vAnnotationUri)
? [vAnnotationUri] : vAnnotationUri;
this.sDefaultBindingMode = BindingMode.OneTime;
this.mETags = {};
this.dLastModified = new Date(0);
this.oMetadataPromise = null;
this.oModel = oModel;
this.mMetadataUrl2Promise = {};
this.oRequestor = oRequestor;
// maps the schema name to a map containing the URL references for the schema as key
// and a boolean value whether the schema has been read already as value; the URL
// reference is used by _MetadataRequestor#read()
// Example:
// mSchema2MetadataUrl = {
// "A." : {"/A/$metadata" : false}, // namespace not yet read
// // multiple references are ok as long as they are not read
// "A.A." : {"/A/$metadata" : false, "/A/V2/$metadata" : false},
// "B." : {"/B/$metadata" : true} // namespace already read
// }
this.mSchema2MetadataUrl = {};
this.mSupportedBindingModes = {"OneTime" : true, "OneWay" : true};
this.bSupportReferences = bSupportReferences !== false; // default is true
// ClientListBinding#filter calls checkFilterOperation on the model; ClientModel does
// not support "All" and "Any" filters
this.mUnsupportedFilterOperators = {"All" : true, "Any" : true};
this.sUrl = sUrl;
} | [
"function",
"(",
"oRequestor",
",",
"sUrl",
",",
"vAnnotationUri",
",",
"oModel",
",",
"bSupportReferences",
")",
"{",
"MetaModel",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"aAnnotationUris",
"=",
"vAnnotationUri",
"&&",
"!",
"Array",
".",
"isArray",... | /*
@param {sap.ui.model.odata.v4.lib._MetadataRequestor} oRequestor | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js#L626-L654 | train | A metadata model that is used to store the metadata for the given schema. | [
30522,
3853,
1006,
10848,
15500,
2953,
1010,
7505,
2140,
1010,
3158,
17048,
3370,
9496,
1010,
18168,
10244,
2140,
1010,
18667,
6279,
6442,
2890,
25523,
2015,
1007,
1063,
18804,
5302,
9247,
1012,
2655,
1006,
2023,
1007,
1025,
2023,
1012,
977... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Dogfalo/materialize | dist/js/materialize.js | destroy | function destroy() {
Modal._count--;
this._removeEventHandlers();
this.el.removeAttribute('style');
this.$overlay.remove();
this.el.M_Modal = undefined;
} | javascript | function destroy() {
Modal._count--;
this._removeEventHandlers();
this.el.removeAttribute('style');
this.$overlay.remove();
this.el.M_Modal = undefined;
} | [
"function",
"destroy",
"(",
")",
"{",
"Modal",
".",
"_count",
"--",
";",
"this",
".",
"_removeEventHandlers",
"(",
")",
";",
"this",
".",
"el",
".",
"removeAttribute",
"(",
"'style'",
")",
";",
"this",
".",
"$overlay",
".",
"remove",
"(",
")",
";",
"... | Teardown component | [
"Teardown",
"component"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L2940-L2946 | train | Destroys the modal | [
30522,
3853,
6033,
1006,
1007,
1063,
16913,
2389,
1012,
1035,
4175,
1011,
1011,
1025,
2023,
1012,
1035,
6366,
18697,
3372,
11774,
12910,
1006,
1007,
1025,
2023,
1012,
3449,
1012,
6366,
19321,
3089,
8569,
2618,
1006,
1005,
2806,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(sServiceRootURI) {
// construct resource path
var sResourcePath = this.getURIToDimensionMemberEntitySet(sServiceRootURI);
// check if request is compliant with filter constraints expressed in
// metadata
this.getFilterExpression().checkValidity();
// construct query options
var sSelectOption = this.getURIQueryOptionValue("$select");
var sFilterOption = this.getURIQueryOptionValue("$filter");
var sSortOption = this.getURIQueryOptionValue("$orderby");
var sTopOption = this.getURIQueryOptionValue("$top");
var sSkipOption = this.getURIQueryOptionValue("$skip");
var sInlineCountOption = this.getURIQueryOptionValue("$inlinecount");
var sURI = sResourcePath;
var bQuestionmark = false;
if (sSelectOption) {
sURI += "?$select=" + sSelectOption;
bQuestionmark = true;
}
if (this._oFilterExpression && sFilterOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$filter=" + sFilterOption;
}
if (this._oSortExpression && sSortOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$orderby=" + sSortOption;
}
if (this._iTopRequestOption && sTopOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$top=" + sTopOption;
}
if (this._iSkipRequestOption && sSkipOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$skip=" + sSkipOption;
}
if (this._bIncludeCount && sInlineCountOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$inlinecount=" + sInlineCountOption;
}
return sURI;
} | javascript | function(sServiceRootURI) {
// construct resource path
var sResourcePath = this.getURIToDimensionMemberEntitySet(sServiceRootURI);
// check if request is compliant with filter constraints expressed in
// metadata
this.getFilterExpression().checkValidity();
// construct query options
var sSelectOption = this.getURIQueryOptionValue("$select");
var sFilterOption = this.getURIQueryOptionValue("$filter");
var sSortOption = this.getURIQueryOptionValue("$orderby");
var sTopOption = this.getURIQueryOptionValue("$top");
var sSkipOption = this.getURIQueryOptionValue("$skip");
var sInlineCountOption = this.getURIQueryOptionValue("$inlinecount");
var sURI = sResourcePath;
var bQuestionmark = false;
if (sSelectOption) {
sURI += "?$select=" + sSelectOption;
bQuestionmark = true;
}
if (this._oFilterExpression && sFilterOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$filter=" + sFilterOption;
}
if (this._oSortExpression && sSortOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$orderby=" + sSortOption;
}
if (this._iTopRequestOption && sTopOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$top=" + sTopOption;
}
if (this._iSkipRequestOption && sSkipOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$skip=" + sSkipOption;
}
if (this._bIncludeCount && sInlineCountOption) {
if (!bQuestionmark) {
sURI += "?";
bQuestionmark = true;
} else {
sURI += "&";
}
sURI += "$inlinecount=" + sInlineCountOption;
}
return sURI;
} | [
"function",
"(",
"sServiceRootURI",
")",
"{",
"// construct resource path",
"var",
"sResourcePath",
"=",
"this",
".",
"getURIToDimensionMemberEntitySet",
"(",
"sServiceRootURI",
")",
";",
"// check if request is compliant with filter constraints expressed in",
"// metadata",
"thi... | Get the unescaped URI to fetch the dimension members, optionally
augmented by text and attributes.
@param {String}
sServiceRootURI (optional) Identifies the root of the OData
service
@returns {String} The unescaped URI that contains the OData resource path
and OData system query options to express the request for the
parameter value set..
@public
@function
@name sap.ui.model.analytics.odata4analytics.DimensionMemberSetRequest#getURIToDimensionMemberEntries | [
"Get",
"the",
"unescaped",
"URI",
"to",
"fetch",
"the",
"dimension",
"members",
"optionally",
"augmented",
"by",
"text",
"and",
"attributes",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L5561-L5631 | train | Construct the URI to the dimension member entity set | [
30522,
3853,
1006,
7020,
2121,
7903,
10624,
4140,
9496,
1007,
1063,
1013,
1013,
9570,
7692,
4130,
13075,
5034,
2229,
8162,
3401,
15069,
1027,
2023,
1012,
2131,
9496,
3406,
22172,
6132,
3258,
4168,
21784,
4765,
3012,
13462,
1006,
7020,
2121,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js | function (oNode) {
var iSelectedNodesCount = 0,
oChildNode;
for (var i = 0; i < oNode.nodes.length; i++) {
oChildNode = oNode.nodes[i];
if (oChildNode.nodes.length) {
oChildNode.selected = this.isNodeSelected(oChildNode);
}
if (oChildNode.selected) {
iSelectedNodesCount++;
}
}
return iSelectedNodesCount === oNode.nodes.length;
} | javascript | function (oNode) {
var iSelectedNodesCount = 0,
oChildNode;
for (var i = 0; i < oNode.nodes.length; i++) {
oChildNode = oNode.nodes[i];
if (oChildNode.nodes.length) {
oChildNode.selected = this.isNodeSelected(oChildNode);
}
if (oChildNode.selected) {
iSelectedNodesCount++;
}
}
return iSelectedNodesCount === oNode.nodes.length;
} | [
"function",
"(",
"oNode",
")",
"{",
"var",
"iSelectedNodesCount",
"=",
"0",
",",
"oChildNode",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"oNode",
".",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"oChildNode",
"=",
"oNode",
".",
... | Checks and update the tree model based on selected child nodes.
@param oNode The tree to be updated
@returns {boolean} The selected of the node. | [
"Checks",
"and",
"update",
"the",
"tree",
"model",
"based",
"on",
"selected",
"child",
"nodes",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js#L193-L208 | train | Determines if the selected nodes are present in the selected nodes array. | [
30522,
3853,
1006,
21058,
3207,
1007,
1063,
13075,
2003,
12260,
10985,
3630,
6155,
3597,
16671,
1027,
1014,
1010,
28166,
4014,
2094,
3630,
3207,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
21058,
3207,
1012,
14164,
1012,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/component/axis/AngleAxisView.js | fixAngleOverlap | function fixAngleOverlap(list) {
var firstItem = list[0];
var lastItem = list[list.length - 1];
if (firstItem
&& lastItem
&& Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4
) {
list.pop();
}
} | javascript | function fixAngleOverlap(list) {
var firstItem = list[0];
var lastItem = list[list.length - 1];
if (firstItem
&& lastItem
&& Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4
) {
list.pop();
}
} | [
"function",
"fixAngleOverlap",
"(",
"list",
")",
"{",
"var",
"firstItem",
"=",
"list",
"[",
"0",
"]",
";",
"var",
"lastItem",
"=",
"list",
"[",
"list",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"firstItem",
"&&",
"lastItem",
"&&",
"Math",
".",
... | Remove the last tick which will overlap the first tick | [
"Remove",
"the",
"last",
"tick",
"which",
"will",
"overlap",
"the",
"first",
"tick"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/axis/AngleAxisView.js#L47-L56 | train | Fix the angle overlap between two nodes | [
30522,
3853,
8081,
5654,
2571,
7840,
2721,
2361,
1006,
2862,
1007,
1063,
13075,
2034,
4221,
2213,
1027,
2862,
1031,
1014,
1033,
1025,
13075,
2197,
4221,
2213,
1027,
2862,
1031,
2862,
1012,
3091,
1011,
1015,
1033,
1025,
2065,
1006,
2034,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RecordRTC | RecordRTC.js | function() {
if (mediaRecorder && typeof mediaRecorder.clearRecordedData === 'function') {
mediaRecorder.clearRecordedData();
}
mediaRecorder = null;
setState('inactive');
self.blob = null;
} | javascript | function() {
if (mediaRecorder && typeof mediaRecorder.clearRecordedData === 'function') {
mediaRecorder.clearRecordedData();
}
mediaRecorder = null;
setState('inactive');
self.blob = null;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"mediaRecorder",
"&&",
"typeof",
"mediaRecorder",
".",
"clearRecordedData",
"===",
"'function'",
")",
"{",
"mediaRecorder",
".",
"clearRecordedData",
"(",
")",
";",
"}",
"mediaRecorder",
"=",
"null",
";",
"setState",
"(",
... | This method resets the recorder. So that you can reuse single recorder instance many times.
@method
@memberof RecordRTC
@instance
@example
recorder.reset();
recorder.startRecording(); | [
"This",
"method",
"resets",
"the",
"recorder",
".",
"So",
"that",
"you",
"can",
"reuse",
"single",
"recorder",
"instance",
"many",
"times",
"."
] | 3c6bad427b9da35c1cf617199ed13dda056c38ba | https://github.com/muaz-khan/RecordRTC/blob/3c6bad427b9da35c1cf617199ed13dda056c38ba/RecordRTC.js#L683-L690 | train | clear the recorder | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2865,
2890,
27108,
4063,
1004,
1004,
2828,
11253,
2865,
2890,
27108,
4063,
1012,
3154,
2890,
27108,
5732,
2850,
2696,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
1063,
2865,
2890,
27108,
4063,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sSkeleton, vGreatestDiff, sCalendarType) {
var oAvailableFormats = this._get(getCLDRCalendarName(sCalendarType), "dateTimeFormats", "intervalFormats");
return this._getFormatPattern(sSkeleton, oAvailableFormats, sCalendarType, vGreatestDiff);
} | javascript | function(sSkeleton, vGreatestDiff, sCalendarType) {
var oAvailableFormats = this._get(getCLDRCalendarName(sCalendarType), "dateTimeFormats", "intervalFormats");
return this._getFormatPattern(sSkeleton, oAvailableFormats, sCalendarType, vGreatestDiff);
} | [
"function",
"(",
"sSkeleton",
",",
"vGreatestDiff",
",",
"sCalendarType",
")",
"{",
"var",
"oAvailableFormats",
"=",
"this",
".",
"_get",
"(",
"getCLDRCalendarName",
"(",
"sCalendarType",
")",
",",
"\"dateTimeFormats\"",
",",
"\"intervalFormats\"",
")",
";",
"retu... | Get interval pattern for a given skeleton format.
The format string does contain pattern symbols (e.g. "yMMMd" or "Hms") and will be converted into the pattern in the used
locale, which matches the wanted symbols best. The symbols must be in canonical order, that is:
Era (G), Year (y/Y), Quarter (q/Q), Month (M/L), Week (w/W), Day-Of-Week (E/e/c), Day (d/D),
Hour (h/H/k/K/), Minute (m), Second (s), Timezone (z/Z/v/V/O/X/x)
See http://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems
@param {string} sSkeleton the wanted skeleton format for the datetime pattern
@param {object|string} vGreatestDiff is either a string which represents the symbol matching the greatest difference in the two dates to format or an object which contains key-value pairs.
The value is always true. The key is one of the date field symbol groups whose value are different between the two dates. The key can only be set with 'Year', 'Quarter', 'Month', 'Week',
'Day', 'DayPeriod', 'Hour', 'Minute', or 'Second'.
@param {sap.ui.core.CalendarType} [sCalendarType] the type of calendar. If it's not set, it falls back to the calendar type either set in configuration or calculated from locale.
@returns {string|string[]} the best matching interval pattern if interval difference is given otherwise an array with all possible interval patterns which match the given skeleton format
@since 1.46
@public | [
"Get",
"interval",
"pattern",
"for",
"a",
"given",
"skeleton",
"format",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L344-L347 | train | Returns the pattern for the given skeleton and interval. | [
30522,
3853,
1006,
7020,
11705,
18903,
2078,
1010,
1058,
17603,
8520,
2102,
4305,
4246,
1010,
4094,
8943,
5339,
18863,
1007,
1063,
13075,
1051,
12462,
11733,
3468,
14192,
11149,
1027,
2023,
1012,
1035,
2131,
1006,
2131,
20464,
13626,
9289,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | write_BrtBeginTableStyles | function write_BrtBeginTableStyles(cnt, defTableStyle, defPivotStyle) {
var o = new_buf(4+256*2*4);
o.write_shift(4, cnt);
write_XLNullableWideString(defTableStyle, o);
write_XLNullableWideString(defPivotStyle, o);
return o.length > o.l ? o.slice(0, o.l) : o;
} | javascript | function write_BrtBeginTableStyles(cnt, defTableStyle, defPivotStyle) {
var o = new_buf(4+256*2*4);
o.write_shift(4, cnt);
write_XLNullableWideString(defTableStyle, o);
write_XLNullableWideString(defPivotStyle, o);
return o.length > o.l ? o.slice(0, o.l) : o;
} | [
"function",
"write_BrtBeginTableStyles",
"(",
"cnt",
",",
"defTableStyle",
",",
"defPivotStyle",
")",
"{",
"var",
"o",
"=",
"new_buf",
"(",
"4",
"+",
"256",
"*",
"2",
"*",
"4",
")",
";",
"o",
".",
"write_shift",
"(",
"4",
",",
"cnt",
")",
";",
"write... | /* [MS-XLSB] 2.4.272 BrtBeginTableStyles | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"272",
"BrtBeginTableStyles"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L9214-L9220 | train | Writes the begin table styles | [
30522,
3853,
4339,
1035,
7987,
2102,
4783,
11528,
10880,
21756,
4244,
1006,
27166,
2102,
1010,
13366,
10880,
21756,
2571,
1010,
13366,
8197,
22994,
21756,
2571,
1007,
1063,
13075,
1051,
1027,
2047,
1035,
20934,
2546,
1006,
1018,
1009,
17273,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/prefer-rest-params.js | checkForArguments | function checkForArguments() {
const argumentsVar = getVariableOfArguments(context.getScope());
if (argumentsVar) {
argumentsVar
.references
.filter(isNotNormalMemberAccess)
.forEach(report);
}
} | javascript | function checkForArguments() {
const argumentsVar = getVariableOfArguments(context.getScope());
if (argumentsVar) {
argumentsVar
.references
.filter(isNotNormalMemberAccess)
.forEach(report);
}
} | [
"function",
"checkForArguments",
"(",
")",
"{",
"const",
"argumentsVar",
"=",
"getVariableOfArguments",
"(",
"context",
".",
"getScope",
"(",
")",
")",
";",
"if",
"(",
"argumentsVar",
")",
"{",
"argumentsVar",
".",
"references",
".",
"filter",
"(",
"isNotNorma... | Reports references of the implicit `arguments` variable if exist.
@returns {void} | [
"Reports",
"references",
"of",
"the",
"implicit",
"arguments",
"variable",
"if",
"exist",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-rest-params.js#L98-L107 | train | Check if the arguments variable is not normal member access | [
30522,
3853,
4638,
29278,
2906,
22850,
11187,
1006,
1007,
1063,
9530,
3367,
9918,
10755,
1027,
2131,
10755,
19210,
11253,
2906,
22850,
11187,
1006,
6123,
1012,
4152,
16186,
1006,
1007,
1007,
1025,
2065,
1006,
9918,
10755,
1007,
1063,
9918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/report/ReportProvider.js | getTechnicalInformation | function getTechnicalInformation(technicalInfo) {
var content = '';
if (!technicalInfo) {
return new Handlebars.SafeString(content);
}
try {
technicalInfo.modules.sort();
var html = ["<div class='sapUiSupportToolbar'>",
"<div><div class='sapUiSupportTechInfoCntnt'>",
"<table border='0' cellpadding='3'>"];
techInfoRenderer.subheader(html, "Support Assistant Information");
techInfoRenderer.line(html, true, true, "Location", technicalInfo.supportAssistant.location);
techInfoRenderer.line(html, true, true, "Version", technicalInfo.supportAssistant.versionAsString);
techInfoRenderer.subheader(html, "Application Information");
techInfoRenderer.line(html, true, true, "SAPUI5 Version", function(buffer){
var sapUI5Version = technicalInfo.sapUi5Version;
if (sapUI5Version && sapUI5Version.version) {
var oVersionInfo = sapUI5Version.version;
var sVersion = jQuery.sap.escapeHTML(oVersionInfo.version || "");
buffer.push(sVersion, " (built at ", jQuery.sap.escapeHTML(oVersionInfo.buildTimestamp || ""), ", last change ", jQuery.sap.escapeHTML(oVersionInfo.scmRevision || ""), ")");
} else {
buffer.push("not available");
}
});
techInfoRenderer.line(html, true, true, "Core Version", function(buffer){
return technicalInfo.version + " (built at " + technicalInfo.build + ", last change " + technicalInfo.change + ")";
});
techInfoRenderer.line(html, true, true, "Loaded jQuery Version", function(buffer){
return technicalInfo.jquery;
});
techInfoRenderer.line(html, true, true, "User Agent", function(buffer){
return technicalInfo.useragent + (technicalInfo.docmode ? ", Document Mode '" + technicalInfo.docmode + "'" : "");
});
techInfoRenderer.line(html, true, true, "Application", technicalInfo.appurl);
techInfoRenderer.multiline(html, true, true, "Configuration (bootstrap)", technicalInfo.bootconfig);
techInfoRenderer.multiline(html, true, true, "Configuration (computed)", technicalInfo.config);
if (!jQuery.isEmptyObject(technicalInfo.libraries)) {
techInfoRenderer.multiline(html, true, true, "Libraries", technicalInfo.libraries);
}
techInfoRenderer.multiline(html, true, true, "Loaded Libraries", technicalInfo.loadedLibraries);
techInfoRenderer.line(html, true, true, "Loaded Modules", function(buffer){
jQuery.each(technicalInfo.modules, function(i,v){
if (v.indexOf("sap.ui.core.support") < 0) {
buffer.push("<span>", jQuery.sap.escapeHTML(v || ""), "</span>");
if (i < technicalInfo.modules.length - 1) {
buffer.push(", ");
}
}
});
});
techInfoRenderer.multiline(html, true, true, "URI Parameters", technicalInfo.uriparams);
html.push("</table></div>");
content = html.join('');
} catch (ex) {
jQuery.sap.log.warning('There was a problem extracting technical info.');
}
return new Handlebars.SafeString(content);
} | javascript | function getTechnicalInformation(technicalInfo) {
var content = '';
if (!technicalInfo) {
return new Handlebars.SafeString(content);
}
try {
technicalInfo.modules.sort();
var html = ["<div class='sapUiSupportToolbar'>",
"<div><div class='sapUiSupportTechInfoCntnt'>",
"<table border='0' cellpadding='3'>"];
techInfoRenderer.subheader(html, "Support Assistant Information");
techInfoRenderer.line(html, true, true, "Location", technicalInfo.supportAssistant.location);
techInfoRenderer.line(html, true, true, "Version", technicalInfo.supportAssistant.versionAsString);
techInfoRenderer.subheader(html, "Application Information");
techInfoRenderer.line(html, true, true, "SAPUI5 Version", function(buffer){
var sapUI5Version = technicalInfo.sapUi5Version;
if (sapUI5Version && sapUI5Version.version) {
var oVersionInfo = sapUI5Version.version;
var sVersion = jQuery.sap.escapeHTML(oVersionInfo.version || "");
buffer.push(sVersion, " (built at ", jQuery.sap.escapeHTML(oVersionInfo.buildTimestamp || ""), ", last change ", jQuery.sap.escapeHTML(oVersionInfo.scmRevision || ""), ")");
} else {
buffer.push("not available");
}
});
techInfoRenderer.line(html, true, true, "Core Version", function(buffer){
return technicalInfo.version + " (built at " + technicalInfo.build + ", last change " + technicalInfo.change + ")";
});
techInfoRenderer.line(html, true, true, "Loaded jQuery Version", function(buffer){
return technicalInfo.jquery;
});
techInfoRenderer.line(html, true, true, "User Agent", function(buffer){
return technicalInfo.useragent + (technicalInfo.docmode ? ", Document Mode '" + technicalInfo.docmode + "'" : "");
});
techInfoRenderer.line(html, true, true, "Application", technicalInfo.appurl);
techInfoRenderer.multiline(html, true, true, "Configuration (bootstrap)", technicalInfo.bootconfig);
techInfoRenderer.multiline(html, true, true, "Configuration (computed)", technicalInfo.config);
if (!jQuery.isEmptyObject(technicalInfo.libraries)) {
techInfoRenderer.multiline(html, true, true, "Libraries", technicalInfo.libraries);
}
techInfoRenderer.multiline(html, true, true, "Loaded Libraries", technicalInfo.loadedLibraries);
techInfoRenderer.line(html, true, true, "Loaded Modules", function(buffer){
jQuery.each(technicalInfo.modules, function(i,v){
if (v.indexOf("sap.ui.core.support") < 0) {
buffer.push("<span>", jQuery.sap.escapeHTML(v || ""), "</span>");
if (i < technicalInfo.modules.length - 1) {
buffer.push(", ");
}
}
});
});
techInfoRenderer.multiline(html, true, true, "URI Parameters", technicalInfo.uriparams);
html.push("</table></div>");
content = html.join('');
} catch (ex) {
jQuery.sap.log.warning('There was a problem extracting technical info.');
}
return new Handlebars.SafeString(content);
} | [
"function",
"getTechnicalInformation",
"(",
"technicalInfo",
")",
"{",
"var",
"content",
"=",
"''",
";",
"if",
"(",
"!",
"technicalInfo",
")",
"{",
"return",
"new",
"Handlebars",
".",
"SafeString",
"(",
"content",
")",
";",
"}",
"try",
"{",
"technicalInfo",
... | /*
Modified version of the function onsapUiSupportTechInfoData from core.support.plugins.TechInfo.js | [
"/",
"*",
"Modified",
"version",
"of",
"the",
"function",
"onsapUiSupportTechInfoData",
"from",
"core",
".",
"support",
".",
"plugins",
".",
"TechInfo",
".",
"js"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/report/ReportProvider.js#L82-L143 | train | Returns technical information | [
30522,
3853,
2131,
15007,
20913,
2378,
14192,
3370,
1006,
4087,
2378,
14876,
1007,
1063,
13075,
4180,
1027,
1005,
1005,
1025,
2065,
1006,
999,
4087,
2378,
14876,
1007,
1063,
2709,
2047,
5047,
8237,
2015,
1012,
3647,
3367,
4892,
1006,
4180,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentManager.js | notifyPathDeleted | function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
} | javascript | function notifyPathDeleted(fullPath) {
// FileSyncManager.syncOpenDocuments() does all the work prompting
// the user to save any unsaved changes and then calls us back
// via notifyFileDeleted
FileSyncManager.syncOpenDocuments(Strings.FILE_DELETED_TITLE);
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
delete encoding[fullPath];
PreferencesManager.setViewState("encoding", encoding, context);
if (!getOpenDocumentForPath(fullPath) &&
!MainViewManager.findInAllWorkingSets(fullPath).length) {
// For images not open in the workingset,
// FileSyncManager.syncOpenDocuments() will
// not tell us to close those views
exports.trigger("pathDeleted", fullPath);
}
} | [
"function",
"notifyPathDeleted",
"(",
"fullPath",
")",
"{",
"// FileSyncManager.syncOpenDocuments() does all the work prompting",
"// the user to save any unsaved changes and then calls us back",
"// via notifyFileDeleted",
"FileSyncManager",
".",
"syncOpenDocuments",
"(",
"Strings",
"... | Called after a file or folder has been deleted. This function is responsible
for updating underlying model data and notifying all views of the change.
@param {string} fullPath The path of the file/folder that has been deleted | [
"Called",
"after",
"a",
"file",
"or",
"folder",
"has",
"been",
"deleted",
".",
"This",
"function",
"is",
"responsible",
"for",
"updating",
"underlying",
"model",
"data",
"and",
"notifying",
"all",
"views",
"of",
"the",
"change",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L497-L522 | train | notifyFileDeleted is called when a file was deleted | [
30522,
3853,
2025,
8757,
15069,
9247,
12870,
2094,
1006,
2440,
15069,
1007,
1063,
1013,
1013,
6764,
6038,
27487,
5162,
4590,
1012,
26351,
26915,
3527,
24894,
11187,
1006,
1007,
2515,
2035,
1996,
2147,
15870,
1013,
1013,
1996,
5310,
2000,
38... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | examples/plugin_example.js | function(settings, updateCallback)
{
// Always a good idea...
var self = this;
// Good idea to create a variable to hold on to our settings, because they might change in the future. See below.
var currentSettings = settings;
/* This is some function where I'll get my data from somewhere */
function getData()
{
var newData = { hello : "world! it's " + new Date().toLocaleTimeString() }; // Just putting some sample data in for fun.
/* Get my data from somewhere and populate newData with it... Probably a JSON API or something. */
/* ... */
// I'm calling updateCallback to tell it I've got new data for it to munch on.
updateCallback(newData);
}
// You'll probably want to implement some sort of timer to refresh your data every so often.
var refreshTimer;
function createRefreshTimer(interval)
{
if(refreshTimer)
{
clearInterval(refreshTimer);
}
refreshTimer = setInterval(function()
{
// Here we call our getData function to update freeboard with new data.
getData();
}, interval);
}
// **onSettingsChanged(newSettings)** (required) : A public function we must implement that will be called when a user makes a change to the settings.
self.onSettingsChanged = function(newSettings)
{
// Here we update our current settings with the variable that is passed in.
currentSettings = newSettings;
}
// **updateNow()** (required) : A public function we must implement that will be called when the user wants to manually refresh the datasource
self.updateNow = function()
{
// Most likely I'll just call getData() here.
getData();
}
// **onDispose()** (required) : A public function we must implement that will be called when this instance of this plugin is no longer needed. Do anything you need to cleanup after yourself here.
self.onDispose = function()
{
// Probably a good idea to get rid of our timer.
clearInterval(refreshTimer);
refreshTimer = undefined;
}
// Here we call createRefreshTimer with our current settings, to kick things off, initially. Notice how we make use of one of the user defined settings that we setup earlier.
createRefreshTimer(currentSettings.refresh_time);
} | javascript | function(settings, updateCallback)
{
// Always a good idea...
var self = this;
// Good idea to create a variable to hold on to our settings, because they might change in the future. See below.
var currentSettings = settings;
/* This is some function where I'll get my data from somewhere */
function getData()
{
var newData = { hello : "world! it's " + new Date().toLocaleTimeString() }; // Just putting some sample data in for fun.
/* Get my data from somewhere and populate newData with it... Probably a JSON API or something. */
/* ... */
// I'm calling updateCallback to tell it I've got new data for it to munch on.
updateCallback(newData);
}
// You'll probably want to implement some sort of timer to refresh your data every so often.
var refreshTimer;
function createRefreshTimer(interval)
{
if(refreshTimer)
{
clearInterval(refreshTimer);
}
refreshTimer = setInterval(function()
{
// Here we call our getData function to update freeboard with new data.
getData();
}, interval);
}
// **onSettingsChanged(newSettings)** (required) : A public function we must implement that will be called when a user makes a change to the settings.
self.onSettingsChanged = function(newSettings)
{
// Here we update our current settings with the variable that is passed in.
currentSettings = newSettings;
}
// **updateNow()** (required) : A public function we must implement that will be called when the user wants to manually refresh the datasource
self.updateNow = function()
{
// Most likely I'll just call getData() here.
getData();
}
// **onDispose()** (required) : A public function we must implement that will be called when this instance of this plugin is no longer needed. Do anything you need to cleanup after yourself here.
self.onDispose = function()
{
// Probably a good idea to get rid of our timer.
clearInterval(refreshTimer);
refreshTimer = undefined;
}
// Here we call createRefreshTimer with our current settings, to kick things off, initially. Notice how we make use of one of the user defined settings that we setup earlier.
createRefreshTimer(currentSettings.refresh_time);
} | [
"function",
"(",
"settings",
",",
"updateCallback",
")",
"{",
"// Always a good idea...",
"var",
"self",
"=",
"this",
";",
"// Good idea to create a variable to hold on to our settings, because they might change in the future. See below.",
"var",
"currentSettings",
"=",
"settings",... | ### Datasource Implementation ------------------- Here we implement the actual datasource plugin. We pass in the settings and updateCallback. | [
"###",
"Datasource",
"Implementation",
"-------------------",
"Here",
"we",
"implement",
"the",
"actual",
"datasource",
"plugin",
".",
"We",
"pass",
"in",
"the",
"settings",
"and",
"updateCallback",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/examples/plugin_example.js#L127-L188 | train | This plugin is a public function that will update the freeboard with the new data. | [
30522,
3853,
1006,
10906,
1010,
10651,
9289,
20850,
8684,
1007,
1063,
1013,
1013,
2467,
1037,
2204,
2801,
1012,
1012,
1012,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
2204,
2801,
2000,
3443,
1037,
8023,
2000,
2907,
2006,
2000,
2256,
10906,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aws/aws-sdk-js | lib/event-stream/parse-message.js | parseHeaders | function parseHeaders(headers) {
var out = {};
var position = 0;
while (position < headers.length) {
var nameLength = headers.readUInt8(position++);
var name = headers.slice(position, position + nameLength).toString();
position += nameLength;
switch (headers.readUInt8(position++)) {
case 0 /* boolTrue */:
out[name] = {
type: BOOLEAN_TAG,
value: true
};
break;
case 1 /* boolFalse */:
out[name] = {
type: BOOLEAN_TAG,
value: false
};
break;
case 2 /* byte */:
out[name] = {
type: BYTE_TAG,
value: headers.readInt8(position++)
};
break;
case 3 /* short */:
out[name] = {
type: SHORT_TAG,
value: headers.readInt16BE(position)
};
position += 2;
break;
case 4 /* integer */:
out[name] = {
type: INT_TAG,
value: headers.readInt32BE(position)
};
position += 4;
break;
case 5 /* long */:
out[name] = {
type: LONG_TAG,
value: new Int64(headers.slice(position, position + 8))
};
position += 8;
break;
case 6 /* byteArray */:
var binaryLength = headers.readUInt16BE(position);
position += 2;
out[name] = {
type: BINARY_TAG,
value: headers.slice(position, position + binaryLength)
};
position += binaryLength;
break;
case 7 /* string */:
var stringLength = headers.readUInt16BE(position);
position += 2;
out[name] = {
type: STRING_TAG,
value: headers.slice(
position,
position + stringLength
).toString()
};
position += stringLength;
break;
case 8 /* timestamp */:
out[name] = {
type: TIMESTAMP_TAG,
value: new Date(
new Int64(headers.slice(position, position + 8))
.valueOf()
)
};
position += 8;
break;
case 9 /* uuid */:
var uuidChars = headers.slice(position, position + 16)
.toString('hex');
position += 16;
out[name] = {
type: UUID_TAG,
value: uuidChars.substr(0, 8) + '-' +
uuidChars.substr(8, 4) + '-' +
uuidChars.substr(12, 4) + '-' +
uuidChars.substr(16, 4) + '-' +
uuidChars.substr(20)
};
break;
default:
throw new Error('Unrecognized header type tag');
}
}
return out;
} | javascript | function parseHeaders(headers) {
var out = {};
var position = 0;
while (position < headers.length) {
var nameLength = headers.readUInt8(position++);
var name = headers.slice(position, position + nameLength).toString();
position += nameLength;
switch (headers.readUInt8(position++)) {
case 0 /* boolTrue */:
out[name] = {
type: BOOLEAN_TAG,
value: true
};
break;
case 1 /* boolFalse */:
out[name] = {
type: BOOLEAN_TAG,
value: false
};
break;
case 2 /* byte */:
out[name] = {
type: BYTE_TAG,
value: headers.readInt8(position++)
};
break;
case 3 /* short */:
out[name] = {
type: SHORT_TAG,
value: headers.readInt16BE(position)
};
position += 2;
break;
case 4 /* integer */:
out[name] = {
type: INT_TAG,
value: headers.readInt32BE(position)
};
position += 4;
break;
case 5 /* long */:
out[name] = {
type: LONG_TAG,
value: new Int64(headers.slice(position, position + 8))
};
position += 8;
break;
case 6 /* byteArray */:
var binaryLength = headers.readUInt16BE(position);
position += 2;
out[name] = {
type: BINARY_TAG,
value: headers.slice(position, position + binaryLength)
};
position += binaryLength;
break;
case 7 /* string */:
var stringLength = headers.readUInt16BE(position);
position += 2;
out[name] = {
type: STRING_TAG,
value: headers.slice(
position,
position + stringLength
).toString()
};
position += stringLength;
break;
case 8 /* timestamp */:
out[name] = {
type: TIMESTAMP_TAG,
value: new Date(
new Int64(headers.slice(position, position + 8))
.valueOf()
)
};
position += 8;
break;
case 9 /* uuid */:
var uuidChars = headers.slice(position, position + 16)
.toString('hex');
position += 16;
out[name] = {
type: UUID_TAG,
value: uuidChars.substr(0, 8) + '-' +
uuidChars.substr(8, 4) + '-' +
uuidChars.substr(12, 4) + '-' +
uuidChars.substr(16, 4) + '-' +
uuidChars.substr(20)
};
break;
default:
throw new Error('Unrecognized header type tag');
}
}
return out;
} | [
"function",
"parseHeaders",
"(",
"headers",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"var",
"position",
"=",
"0",
";",
"while",
"(",
"position",
"<",
"headers",
".",
"length",
")",
"{",
"var",
"nameLength",
"=",
"headers",
".",
"readUInt8",
"(",
"... | @api private
@param {Buffer} headers | [
"@api",
"private"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/event-stream/parse-message.js#L20-L116 | train | Parses the HTTP headers into an object containing the information about the log record. | [
30522,
3853,
11968,
3366,
4974,
2545,
1006,
20346,
2015,
1007,
1063,
13075,
2041,
1027,
1063,
1065,
1025,
13075,
2597,
1027,
1014,
1025,
2096,
1006,
2597,
1026,
20346,
2015,
1012,
3091,
1007,
1063,
13075,
2171,
7770,
13512,
2232,
1027,
2034... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.