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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
google/material-design-lite | src/mdlComponentHandler.js | deconstructComponentInternal | function deconstructComponentInternal(component) {
if (component) {
var componentIndex = createdComponents_.indexOf(component);
createdComponents_.splice(componentIndex, 1);
var upgrades = component.element_.getAttribute('data-upgraded').split(',');
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);
upgrades.splice(componentPlace, 1);
component.element_.setAttribute('data-upgraded', upgrades.join(','));
var ev = createEvent_('mdl-componentdowngraded', true, false);
component.element_.dispatchEvent(ev);
}
} | javascript | function deconstructComponentInternal(component) {
if (component) {
var componentIndex = createdComponents_.indexOf(component);
createdComponents_.splice(componentIndex, 1);
var upgrades = component.element_.getAttribute('data-upgraded').split(',');
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);
upgrades.splice(componentPlace, 1);
component.element_.setAttribute('data-upgraded', upgrades.join(','));
var ev = createEvent_('mdl-componentdowngraded', true, false);
component.element_.dispatchEvent(ev);
}
} | [
"function",
"deconstructComponentInternal",
"(",
"component",
")",
"{",
"if",
"(",
"component",
")",
"{",
"var",
"componentIndex",
"=",
"createdComponents_",
".",
"indexOf",
"(",
"component",
")",
";",
"createdComponents_",
".",
"splice",
"(",
"componentIndex",
",... | Check the component for the downgrade method.
Execute if found.
Remove component from createdComponents list.
@param {?componentHandler.Component} component | [
"Check",
"the",
"component",
"for",
"the",
"downgrade",
"method",
".",
"Execute",
"if",
"found",
".",
"Remove",
"component",
"from",
"createdComponents",
"list",
"."
] | 60f441a22ed98ed2c03f6179adf460d888bf459f | https://github.com/google/material-design-lite/blob/60f441a22ed98ed2c03f6179adf460d888bf459f/src/mdlComponentHandler.js#L370-L383 | train | Deconstructs a component | [
30522,
3853,
21933,
23808,
6820,
6593,
9006,
29513,
16778,
10111,
12789,
2140,
1006,
6922,
1007,
1063,
2065,
1006,
6922,
1007,
1063,
13075,
6922,
22254,
10288,
1027,
2580,
9006,
29513,
7666,
1035,
1012,
5950,
11253,
1006,
6922,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/dom-utils.js | nodeCollector_filter | function nodeCollector_filter(aCallback, aThisObject) {
if (!aCallback)
throw new Error(arguments.callee.name + ": No callback specified");
this.nodes = Array.filter(this.nodes, aCallback, aThisObject);
return this;
} | javascript | function nodeCollector_filter(aCallback, aThisObject) {
if (!aCallback)
throw new Error(arguments.callee.name + ": No callback specified");
this.nodes = Array.filter(this.nodes, aCallback, aThisObject);
return this;
} | [
"function",
"nodeCollector_filter",
"(",
"aCallback",
",",
"aThisObject",
")",
"{",
"if",
"(",
"!",
"aCallback",
")",
"throw",
"new",
"Error",
"(",
"arguments",
".",
"callee",
".",
"name",
"+",
"\": No callback specified\"",
")",
";",
"this",
".",
"nodes",
"... | Filter nodes given by the specified callback function
@param {function} aCallback
Function to test each element of the array.
Elements: node, index (optional) , array (optional)
@param {object} aThisObject
Object to use as 'this' when executing callback.
[optional - default: function scope]
@returns The class instance
@type {object} | [
"Filter",
"nodes",
"given",
"by",
"the",
"specified",
"callback",
"function"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L566-L573 | train | Filter the nodes in the node list | [
30522,
3853,
13045,
26895,
22471,
2953,
1035,
11307,
1006,
9353,
8095,
5963,
1010,
2012,
24158,
16429,
20614,
1007,
1063,
2065,
1006,
999,
9353,
8095,
5963,
1007,
5466,
2047,
7561,
1006,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-eval.js | reportAccessingEvalViaGlobalObject | function reportAccessingEvalViaGlobalObject(globalScope) {
for (let i = 0; i < candidatesOfGlobalObject.length; ++i) {
const name = candidatesOfGlobalObject[i];
const variable = astUtils.getVariableByName(globalScope, name);
if (!variable) {
continue;
}
const references = variable.references;
for (let j = 0; j < references.length; ++j) {
const identifier = references[j].identifier;
let node = identifier.parent;
// To detect code like `window.window.eval`.
while (isMember(node, name)) {
node = node.parent;
}
// Reports.
if (isMember(node, "eval")) {
report(node);
}
}
}
} | javascript | function reportAccessingEvalViaGlobalObject(globalScope) {
for (let i = 0; i < candidatesOfGlobalObject.length; ++i) {
const name = candidatesOfGlobalObject[i];
const variable = astUtils.getVariableByName(globalScope, name);
if (!variable) {
continue;
}
const references = variable.references;
for (let j = 0; j < references.length; ++j) {
const identifier = references[j].identifier;
let node = identifier.parent;
// To detect code like `window.window.eval`.
while (isMember(node, name)) {
node = node.parent;
}
// Reports.
if (isMember(node, "eval")) {
report(node);
}
}
}
} | [
"function",
"reportAccessingEvalViaGlobalObject",
"(",
"globalScope",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"candidatesOfGlobalObject",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"name",
"=",
"candidatesOfGlobalObject",
"[",
"i",
... | Reports accesses of `eval` via the global object.
@param {eslint-scope.Scope} globalScope - The global scope.
@returns {void} | [
"Reports",
"accesses",
"of",
"eval",
"via",
"the",
"global",
"object",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-eval.js#L178-L204 | train | Reports accessing eval via global object | [
30522,
3853,
3189,
6305,
9623,
7741,
13331,
2140,
9035,
23296,
16429,
23067,
2497,
20614,
1006,
3795,
26127,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
5347,
11253,
23296,
16429,
23067,
2497,
20614,
1012,
3091,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(p1, p2)
{
var min = Math.min(p1.length, p2.length);
var comp = 0;
for (var i = 0; i < min; i++)
{
if (p1[i] != p2[i])
{
if (p1[i].length == 0 ||
p2[i].length == 0)
{
comp = (p1[i] == p2[i]) ? 0 : ((p1[i] > p2[i]) ? 1 : -1);
}
else
{
var t1 = parseInt(p1[i]);
var t2 = parseInt(p2[i]);
comp = (t1 == t2) ? 0 : ((t1 > t2) ? 1 : -1);
}
break;
}
}
// Compares path length if both paths are equal to this point
if (comp == 0)
{
var t1 = p1.length;
var t2 = p2.length;
if (t1 != t2)
{
comp = (t1 > t2) ? 1 : -1;
}
}
return comp;
} | javascript | function(p1, p2)
{
var min = Math.min(p1.length, p2.length);
var comp = 0;
for (var i = 0; i < min; i++)
{
if (p1[i] != p2[i])
{
if (p1[i].length == 0 ||
p2[i].length == 0)
{
comp = (p1[i] == p2[i]) ? 0 : ((p1[i] > p2[i]) ? 1 : -1);
}
else
{
var t1 = parseInt(p1[i]);
var t2 = parseInt(p2[i]);
comp = (t1 == t2) ? 0 : ((t1 > t2) ? 1 : -1);
}
break;
}
}
// Compares path length if both paths are equal to this point
if (comp == 0)
{
var t1 = p1.length;
var t2 = p2.length;
if (t1 != t2)
{
comp = (t1 > t2) ? 1 : -1;
}
}
return comp;
} | [
"function",
"(",
"p1",
",",
"p2",
")",
"{",
"var",
"min",
"=",
"Math",
".",
"min",
"(",
"p1",
".",
"length",
",",
"p2",
".",
"length",
")",
";",
"var",
"comp",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"min",
";",
"i... | Function: compare
Compares the given cell paths and returns -1 if p1 is smaller, 0 if
p1 is equal and 1 if p1 is greater than p2. | [
"Function",
":",
"compare"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L43327-L43366 | train | Compares two arrays of points | [
30522,
3853,
1006,
1052,
2487,
1010,
1052,
2475,
1007,
1063,
13075,
8117,
1027,
8785,
1012,
8117,
1006,
1052,
2487,
1012,
3091,
1010,
1052,
2475,
1012,
3091,
1007,
1025,
13075,
4012,
2361,
1027,
1014,
1025,
2005,
1006,
13075,
1045,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | parse_Guts | function parse_Guts(blob) {
blob.l += 4;
var out = [blob.read_shift(2), blob.read_shift(2)];
if(out[0] !== 0) out[0]--;
if(out[1] !== 0) out[1]--;
if(out[0] > 7 || out[1] > 7) throw new Error("Bad Gutters: " + out.join("|"));
return out;
} | javascript | function parse_Guts(blob) {
blob.l += 4;
var out = [blob.read_shift(2), blob.read_shift(2)];
if(out[0] !== 0) out[0]--;
if(out[1] !== 0) out[1]--;
if(out[0] > 7 || out[1] > 7) throw new Error("Bad Gutters: " + out.join("|"));
return out;
} | [
"function",
"parse_Guts",
"(",
"blob",
")",
"{",
"blob",
".",
"l",
"+=",
"4",
";",
"var",
"out",
"=",
"[",
"blob",
".",
"read_shift",
"(",
"2",
")",
",",
"blob",
".",
"read_shift",
"(",
"2",
")",
"]",
";",
"if",
"(",
"out",
"[",
"0",
"]",
"!=... | /* [MS-XLS] 2.4.134 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"134"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6134-L6141 | train | Parse Gutters | [
30522,
3853,
11968,
3366,
1035,
18453,
1006,
1038,
4135,
2497,
1007,
1063,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1018,
1025,
13075,
2041,
1027,
1031,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1016,
1007,
1010,
1038,
4135,
2497,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/angular | .circleci/trigger-webhook.js | _main | function _main(args) {
triggerWebhook(...args).
then(({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
console.log(`Status: ${statusCode}\n${responseText}`) :
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`))).
catch(err => {
console.error(err);
process.exit(1);
});
} | javascript | function _main(args) {
triggerWebhook(...args).
then(({statusCode, responseText}) => (200 <= statusCode && statusCode < 400) ?
console.log(`Status: ${statusCode}\n${responseText}`) :
Promise.reject(new Error(`Request failed (status: ${statusCode}): ${responseText}`))).
catch(err => {
console.error(err);
process.exit(1);
});
} | [
"function",
"_main",
"(",
"args",
")",
"{",
"triggerWebhook",
"(",
"...",
"args",
")",
".",
"then",
"(",
"(",
"{",
"statusCode",
",",
"responseText",
"}",
")",
"=>",
"(",
"200",
"<=",
"statusCode",
"&&",
"statusCode",
"<",
"400",
")",
"?",
"console",
... | Helpers | [
"Helpers"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/.circleci/trigger-webhook.js#L62-L71 | train | Main function. | [
30522,
3853,
1035,
2364,
1006,
12098,
5620,
1007,
1063,
9495,
8545,
23706,
14659,
1006,
1012,
1012,
1012,
12098,
5620,
1007,
1012,
2059,
1006,
1006,
1063,
3570,
16044,
1010,
3433,
18209,
1065,
1007,
1027,
1028,
1006,
3263,
1026,
1027,
3570,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/color.js | fromNamed | function fromNamed(color) {
const el = document.createElement('div');
el.style.color = color;
if (el.style.color !== '') {
document.body.appendChild(el);
const rgb = getComputedStyle(el).color;
document.body.removeChild(el);
return rgb;
} else {
return '';
}
} | javascript | function fromNamed(color) {
const el = document.createElement('div');
el.style.color = color;
if (el.style.color !== '') {
document.body.appendChild(el);
const rgb = getComputedStyle(el).color;
document.body.removeChild(el);
return rgb;
} else {
return '';
}
} | [
"function",
"fromNamed",
"(",
"color",
")",
"{",
"const",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"el",
".",
"style",
".",
"color",
"=",
"color",
";",
"if",
"(",
"el",
".",
"style",
".",
"color",
"!==",
"''",
")",
"{",
... | Return named color as an rgba string.
@param {string} color Named color.
@return {string} Rgb string. | [
"Return",
"named",
"color",
"as",
"an",
"rgba",
"string",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/color.js#L55-L66 | train | Get the named color | [
30522,
3853,
2013,
18442,
2094,
1006,
3609,
1007,
1063,
9530,
3367,
3449,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
3449,
1012,
2806,
1012,
3609,
1027,
3609,
1025,
2065,
1006,
3449,
1012,
2806,
1012,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/data/helper/sourceHelper.js | makeDefaultEncode | function makeDefaultEncode(
seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
) {
var coordSysDefine = getCoordSysDefineBySeries(seriesModel);
var encode = {};
// var encodeTooltip = [];
// var encodeLabel = [];
var encodeItemName = [];
var encodeSeriesName = [];
var seriesType = seriesModel.subType;
// ??? TODO refactor: provide by series itself.
// Consider the case: 'map' series is based on geo coordSys,
// 'graph', 'heatmap' can be based on cartesian. But can not
// give default rule simply here.
var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
var cSeriesMap = createHashMap([
'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
]);
// Usually in this case series will use the first data
// dimension as the "value" dimension, or other default
// processes respectively.
if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
var ecModel = seriesModel.ecModel;
var datasetMap = inner(ecModel).datasetMap;
var key = datasetModel.uid + '_' + seriesLayoutBy;
var datasetRecord = datasetMap.get(key)
|| datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});
// TODO
// Auto detect first time axis and do arrangement.
each(coordSysDefine.coordSysDims, function (coordDim) {
// In value way.
if (coordSysDefine.firstCategoryDimIndex == null) {
var dataDim = datasetRecord.valueWayDim++;
encode[coordDim] = dataDim;
// ??? TODO give a better default series name rule?
// especially when encode x y specified.
// consider: when mutiple series share one dimension
// category axis, series name should better use
// the other dimsion name. On the other hand, use
// both dimensions name.
encodeSeriesName.push(dataDim);
// encodeTooltip.push(dataDim);
// encodeLabel.push(dataDim);
}
// In category way, category axis.
else if (coordSysDefine.categoryAxisMap.get(coordDim)) {
encode[coordDim] = 0;
encodeItemName.push(0);
}
// In category way, non-category axis.
else {
var dataDim = datasetRecord.categoryWayDim++;
encode[coordDim] = dataDim;
// encodeTooltip.push(dataDim);
// encodeLabel.push(dataDim);
encodeSeriesName.push(dataDim);
}
});
}
// Do not make a complex rule! Hard to code maintain and not necessary.
// ??? TODO refactor: provide by series itself.
// [{name: ..., value: ...}, ...] like:
else if (nSeriesMap.get(seriesType) != null) {
// Find the first not ordinal. (5 is an experience value)
var firstNotOrdinal;
for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
if (!doGuessOrdinal(
data, sourceFormat, seriesLayoutBy,
completeResult.dimensionsDefine, completeResult.startIndex, i
)) {
firstNotOrdinal = i;
}
}
if (firstNotOrdinal != null) {
encode.value = firstNotOrdinal;
var nameDimIndex = completeResult.potentialNameDimIndex
|| Math.max(firstNotOrdinal - 1, 0);
// By default, label use itemName in charts.
// So we dont set encodeLabel here.
encodeSeriesName.push(nameDimIndex);
encodeItemName.push(nameDimIndex);
// encodeTooltip.push(firstNotOrdinal);
}
}
// encodeTooltip.length && (encode.tooltip = encodeTooltip);
// encodeLabel.length && (encode.label = encodeLabel);
encodeItemName.length && (encode.itemName = encodeItemName);
encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
return encode;
} | javascript | function makeDefaultEncode(
seriesModel, datasetModel, data, sourceFormat, seriesLayoutBy, completeResult
) {
var coordSysDefine = getCoordSysDefineBySeries(seriesModel);
var encode = {};
// var encodeTooltip = [];
// var encodeLabel = [];
var encodeItemName = [];
var encodeSeriesName = [];
var seriesType = seriesModel.subType;
// ??? TODO refactor: provide by series itself.
// Consider the case: 'map' series is based on geo coordSys,
// 'graph', 'heatmap' can be based on cartesian. But can not
// give default rule simply here.
var nSeriesMap = createHashMap(['pie', 'map', 'funnel']);
var cSeriesMap = createHashMap([
'line', 'bar', 'pictorialBar', 'scatter', 'effectScatter', 'candlestick', 'boxplot'
]);
// Usually in this case series will use the first data
// dimension as the "value" dimension, or other default
// processes respectively.
if (coordSysDefine && cSeriesMap.get(seriesType) != null) {
var ecModel = seriesModel.ecModel;
var datasetMap = inner(ecModel).datasetMap;
var key = datasetModel.uid + '_' + seriesLayoutBy;
var datasetRecord = datasetMap.get(key)
|| datasetMap.set(key, {categoryWayDim: 1, valueWayDim: 0});
// TODO
// Auto detect first time axis and do arrangement.
each(coordSysDefine.coordSysDims, function (coordDim) {
// In value way.
if (coordSysDefine.firstCategoryDimIndex == null) {
var dataDim = datasetRecord.valueWayDim++;
encode[coordDim] = dataDim;
// ??? TODO give a better default series name rule?
// especially when encode x y specified.
// consider: when mutiple series share one dimension
// category axis, series name should better use
// the other dimsion name. On the other hand, use
// both dimensions name.
encodeSeriesName.push(dataDim);
// encodeTooltip.push(dataDim);
// encodeLabel.push(dataDim);
}
// In category way, category axis.
else if (coordSysDefine.categoryAxisMap.get(coordDim)) {
encode[coordDim] = 0;
encodeItemName.push(0);
}
// In category way, non-category axis.
else {
var dataDim = datasetRecord.categoryWayDim++;
encode[coordDim] = dataDim;
// encodeTooltip.push(dataDim);
// encodeLabel.push(dataDim);
encodeSeriesName.push(dataDim);
}
});
}
// Do not make a complex rule! Hard to code maintain and not necessary.
// ??? TODO refactor: provide by series itself.
// [{name: ..., value: ...}, ...] like:
else if (nSeriesMap.get(seriesType) != null) {
// Find the first not ordinal. (5 is an experience value)
var firstNotOrdinal;
for (var i = 0; i < 5 && firstNotOrdinal == null; i++) {
if (!doGuessOrdinal(
data, sourceFormat, seriesLayoutBy,
completeResult.dimensionsDefine, completeResult.startIndex, i
)) {
firstNotOrdinal = i;
}
}
if (firstNotOrdinal != null) {
encode.value = firstNotOrdinal;
var nameDimIndex = completeResult.potentialNameDimIndex
|| Math.max(firstNotOrdinal - 1, 0);
// By default, label use itemName in charts.
// So we dont set encodeLabel here.
encodeSeriesName.push(nameDimIndex);
encodeItemName.push(nameDimIndex);
// encodeTooltip.push(firstNotOrdinal);
}
}
// encodeTooltip.length && (encode.tooltip = encodeTooltip);
// encodeLabel.length && (encode.label = encodeLabel);
encodeItemName.length && (encode.itemName = encodeItemName);
encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
return encode;
} | [
"function",
"makeDefaultEncode",
"(",
"seriesModel",
",",
"datasetModel",
",",
"data",
",",
"sourceFormat",
",",
"seriesLayoutBy",
",",
"completeResult",
")",
"{",
"var",
"coordSysDefine",
"=",
"getCoordSysDefineBySeries",
"(",
"seriesModel",
")",
";",
"var",
"encod... | ??? TODO merge to completedimensions, where also has default encode making logic. And the default rule should depends on series? consider 'map'. | [
"???",
"TODO",
"merge",
"to",
"completedimensions",
"where",
"also",
"has",
"default",
"encode",
"making",
"logic",
".",
"And",
"the",
"default",
"rule",
"should",
"depends",
"on",
"series?",
"consider",
"map",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/helper/sourceHelper.js#L365-L461 | train | This function is called by encodeSeries to create a default encode array for the series. | [
30522,
3853,
2191,
3207,
7011,
11314,
2368,
16044,
1006,
2186,
5302,
9247,
1010,
2951,
13462,
5302,
9247,
1010,
2951,
1010,
3120,
14192,
4017,
1010,
2186,
8485,
5833,
3762,
1010,
3143,
6072,
11314,
1007,
1063,
13075,
2522,
8551,
6508,
16150... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js | destroy | function destroy(oListener) {
for (var n in mTargets) {
var oTargetConfig = mTargets[n];
for (var i = 0; i < oTargetConfig.listeners.length; i++) {
if (oTargetConfig.listeners[i] === oListener) {
oTargetConfig.listeners.splice(i, 1);
oTargetConfig.configurations.splice(i, 1);
}
}
if (oTargetConfig.listeners && oTargetConfig.listeners.length === 0) {
delete mTargets[n];
oTargetConfig.object._observer = undefined;
}
}
} | javascript | function destroy(oListener) {
for (var n in mTargets) {
var oTargetConfig = mTargets[n];
for (var i = 0; i < oTargetConfig.listeners.length; i++) {
if (oTargetConfig.listeners[i] === oListener) {
oTargetConfig.listeners.splice(i, 1);
oTargetConfig.configurations.splice(i, 1);
}
}
if (oTargetConfig.listeners && oTargetConfig.listeners.length === 0) {
delete mTargets[n];
oTargetConfig.object._observer = undefined;
}
}
} | [
"function",
"destroy",
"(",
"oListener",
")",
"{",
"for",
"(",
"var",
"n",
"in",
"mTargets",
")",
"{",
"var",
"oTargetConfig",
"=",
"mTargets",
"[",
"n",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"oTargetConfig",
".",
"listeners",
... | removes a given listener by looking at all registered targets and their listeners. if there are no more listeners to a target, the registered target is removed from the mTargets map. | [
"removes",
"a",
"given",
"listener",
"by",
"looking",
"at",
"all",
"registered",
"targets",
"and",
"their",
"listeners",
".",
"if",
"there",
"are",
"no",
"more",
"listeners",
"to",
"a",
"target",
"the",
"registered",
"target",
"is",
"removed",
"from",
"the",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectObserver.js#L513-L527 | train | Destroys a listener | [
30522,
3853,
6033,
1006,
19330,
27870,
3678,
1007,
1063,
2005,
1006,
13075,
1050,
1999,
11047,
2906,
18150,
2015,
1007,
1063,
13075,
27178,
2906,
18150,
8663,
8873,
2290,
1027,
11047,
2906,
18150,
2015,
1031,
1050,
1033,
1025,
2005,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/core/a-assets.js | inferResponseType | function inferResponseType (src) {
var dotLastIndex = src.lastIndexOf('.');
if (dotLastIndex >= 0) {
var extension = src.slice(dotLastIndex, src.length);
if (extension === '.gltf' || extension === '.glb') {
return 'arraybuffer';
}
}
return 'text';
} | javascript | function inferResponseType (src) {
var dotLastIndex = src.lastIndexOf('.');
if (dotLastIndex >= 0) {
var extension = src.slice(dotLastIndex, src.length);
if (extension === '.gltf' || extension === '.glb') {
return 'arraybuffer';
}
}
return 'text';
} | [
"function",
"inferResponseType",
"(",
"src",
")",
"{",
"var",
"dotLastIndex",
"=",
"src",
".",
"lastIndexOf",
"(",
"'.'",
")",
";",
"if",
"(",
"dotLastIndex",
">=",
"0",
")",
"{",
"var",
"extension",
"=",
"src",
".",
"slice",
"(",
"dotLastIndex",
",",
... | Infer response-type attribute from src.
Default is text(default XMLHttpRequest.responseType)
but we use arraybuffer for .gltf and .glb files
because of THREE.GLTFLoader specification.
@param {string} src
@returns {string} | [
"Infer",
"response",
"-",
"type",
"attribute",
"from",
"src",
".",
"Default",
"is",
"text",
"(",
"default",
"XMLHttpRequest",
".",
"responseType",
")",
"but",
"we",
"use",
"arraybuffer",
"for",
".",
"gltf",
"and",
".",
"glb",
"files",
"because",
"of",
"THR... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-assets.js#L253-L262 | train | infer response type from src | [
30522,
3853,
1999,
7512,
6072,
26029,
13462,
18863,
1006,
5034,
2278,
1007,
1063,
13075,
11089,
8523,
7629,
3207,
2595,
1027,
5034,
2278,
1012,
2197,
22254,
10288,
11253,
1006,
1005,
1012,
1005,
1007,
1025,
2065,
1006,
11089,
8523,
7629,
32... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/BeaconRequest.js | function (option) {
option = option || {};
if (!BeaconRequest.isSupported()) {
throw Error("Beacon API is not supported");
}
if (typeof option.url !== "string") {
throw Error("Beacon url must be valid");
}
this._nMaxBufferLength = option.maxBufferLength || 10;
this._aBuffer = [];
this._sUrl = option.url;
this.attachSendOnUnload();
} | javascript | function (option) {
option = option || {};
if (!BeaconRequest.isSupported()) {
throw Error("Beacon API is not supported");
}
if (typeof option.url !== "string") {
throw Error("Beacon url must be valid");
}
this._nMaxBufferLength = option.maxBufferLength || 10;
this._aBuffer = [];
this._sUrl = option.url;
this.attachSendOnUnload();
} | [
"function",
"(",
"option",
")",
"{",
"option",
"=",
"option",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"BeaconRequest",
".",
"isSupported",
"(",
")",
")",
"{",
"throw",
"Error",
"(",
"\"Beacon API is not supported\"",
")",
";",
"}",
"if",
"(",
"typeof",
"o... | A helper for buffering and sending BeaconRequests to a certain URL
@param {object} option Options for beacon API initialization
@param {string} option.url beacon URL
@param {string} option.maxBufferLength Number of entries in the stack before the beacon is send
@private
@ui5-restricted sap.ui.core | [
"A",
"helper",
"for",
"buffering",
"and",
"sending",
"BeaconRequests",
"to",
"a",
"certain",
"URL"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/BeaconRequest.js#L18-L33 | train | Initialize the beacon | [
30522,
3853,
1006,
5724,
1007,
1063,
5724,
1027,
5724,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
999,
14400,
2890,
15500,
1012,
26354,
6279,
6442,
2098,
1006,
1007,
1007,
1063,
5466,
7561,
1006,
1000,
14400,
17928,
2003,
2025,
3569,
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... | |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | setValue | function setValue ( to, handleNumber ) {
// Setting with null indicates an 'ignore'.
// Inputting 'false' is invalid.
if ( to === null || to === false ) {
return;
}
// If a formatted number was passed, attemt to decode it.
if ( typeof to === 'number' ) {
to = String(to);
}
to = options.format.from(to);
// Request an update for all links if the value was invalid.
// Do so too if setting the handle fails.
if ( to !== false && !isNaN(to) ) {
setHandle(handleNumber, scope_Spectrum.toStepping(to), false, false);
}
} | javascript | function setValue ( to, handleNumber ) {
// Setting with null indicates an 'ignore'.
// Inputting 'false' is invalid.
if ( to === null || to === false ) {
return;
}
// If a formatted number was passed, attemt to decode it.
if ( typeof to === 'number' ) {
to = String(to);
}
to = options.format.from(to);
// Request an update for all links if the value was invalid.
// Do so too if setting the handle fails.
if ( to !== false && !isNaN(to) ) {
setHandle(handleNumber, scope_Spectrum.toStepping(to), false, false);
}
} | [
"function",
"setValue",
"(",
"to",
",",
"handleNumber",
")",
"{",
"// Setting with null indicates an 'ignore'.",
"// Inputting 'false' is invalid.",
"if",
"(",
"to",
"===",
"null",
"||",
"to",
"===",
"false",
")",
"{",
"return",
";",
"}",
"// If a formatted number was... | ... | [
"..."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1855-L1875 | train | Set the value of a link | [
30522,
3853,
2275,
10175,
5657,
1006,
2000,
1010,
5047,
19172,
5677,
1007,
1063,
1013,
1013,
4292,
2007,
19701,
7127,
2019,
1005,
8568,
1005,
1012,
1013,
1013,
7953,
3436,
1005,
6270,
1005,
2003,
19528,
1012,
2065,
1006,
2000,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(cell) {
if (cell.isColspan) {
var colspan = parseInt(api.getAttribute(cell.el, 'colspan') || 1, 10),
cType = cell.el.tagName.toLowerCase();
if (colspan > 1) {
var newCells = this.createCells(cType, colspan -1);
insertAfter(cell.el, newCells);
}
cell.el.removeAttribute('colspan');
}
} | javascript | function(cell) {
if (cell.isColspan) {
var colspan = parseInt(api.getAttribute(cell.el, 'colspan') || 1, 10),
cType = cell.el.tagName.toLowerCase();
if (colspan > 1) {
var newCells = this.createCells(cType, colspan -1);
insertAfter(cell.el, newCells);
}
cell.el.removeAttribute('colspan');
}
} | [
"function",
"(",
"cell",
")",
"{",
"if",
"(",
"cell",
".",
"isColspan",
")",
"{",
"var",
"colspan",
"=",
"parseInt",
"(",
"api",
".",
"getAttribute",
"(",
"cell",
".",
"el",
",",
"'colspan'",
")",
"||",
"1",
",",
"10",
")",
",",
"cType",
"=",
"ce... | Splits merged cell on row to unique cells | [
"Splits",
"merged",
"cell",
"on",
"row",
"to",
"unique",
"cells"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L7615-L7625 | train | create cells if colspan > 1 | [
30522,
3853,
1006,
3526,
1007,
1063,
2065,
1006,
3526,
1012,
2003,
25778,
13102,
2319,
1007,
1063,
13075,
8902,
13102,
2319,
1027,
11968,
20240,
3372,
1006,
17928,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
3526,
1012,
3449,
1010,
1005,
890... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/max-lines-per-function.js | processFunction | function processFunction(funcNode) {
const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
if (!IIFEs && isIIFE(node)) {
return;
}
let lineCount = 0;
for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
const line = lines[i];
if (skipComments) {
if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
continue;
}
}
if (skipBlankLines) {
if (line.match(/^\s*$/u)) {
continue;
}
}
lineCount++;
}
if (lineCount > maxLines) {
const name = astUtils.getFunctionNameWithKind(funcNode);
context.report({
node,
messageId: "exceed",
data: { name, lineCount, maxLines }
});
}
} | javascript | function processFunction(funcNode) {
const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;
if (!IIFEs && isIIFE(node)) {
return;
}
let lineCount = 0;
for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
const line = lines[i];
if (skipComments) {
if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
continue;
}
}
if (skipBlankLines) {
if (line.match(/^\s*$/u)) {
continue;
}
}
lineCount++;
}
if (lineCount > maxLines) {
const name = astUtils.getFunctionNameWithKind(funcNode);
context.report({
node,
messageId: "exceed",
data: { name, lineCount, maxLines }
});
}
} | [
"function",
"processFunction",
"(",
"funcNode",
")",
"{",
"const",
"node",
"=",
"isEmbedded",
"(",
"funcNode",
")",
"?",
"funcNode",
".",
"parent",
":",
"funcNode",
";",
"if",
"(",
"!",
"IIFEs",
"&&",
"isIIFE",
"(",
"node",
")",
")",
"{",
"return",
";"... | Count the lines in the function
@param {ASTNode} funcNode Function AST node
@returns {void}
@private | [
"Count",
"the",
"lines",
"in",
"the",
"function"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-lines-per-function.js#L168-L203 | train | Process function node | [
30522,
3853,
2832,
11263,
27989,
1006,
4569,
2278,
3630,
3207,
1007,
1063,
9530,
3367,
13045,
1027,
2003,
6633,
8270,
5732,
1006,
4569,
2278,
3630,
3207,
1007,
1029,
4569,
2278,
3630,
3207,
1012,
6687,
1024,
4569,
2278,
3630,
3207,
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... |
adobe/brackets | src/utils/Async.js | doSequentiallyInBackground | function doSequentiallyInBackground(items, fnProcessItem, maxBlockingTime, idleTime) {
maxBlockingTime = maxBlockingTime || 15;
idleTime = idleTime || 30;
var sliceStartTime = (new Date()).getTime();
return doSequentially(items, function (item, i) {
var result = new $.Deferred();
// process the next item
fnProcessItem(item, i);
// if we've exhausted our maxBlockingTime
if ((new Date()).getTime() - sliceStartTime >= maxBlockingTime) {
//yield
window.setTimeout(function () {
sliceStartTime = (new Date()).getTime();
result.resolve();
}, idleTime);
} else {
//continue processing
result.resolve();
}
return result;
}, false);
} | javascript | function doSequentiallyInBackground(items, fnProcessItem, maxBlockingTime, idleTime) {
maxBlockingTime = maxBlockingTime || 15;
idleTime = idleTime || 30;
var sliceStartTime = (new Date()).getTime();
return doSequentially(items, function (item, i) {
var result = new $.Deferred();
// process the next item
fnProcessItem(item, i);
// if we've exhausted our maxBlockingTime
if ((new Date()).getTime() - sliceStartTime >= maxBlockingTime) {
//yield
window.setTimeout(function () {
sliceStartTime = (new Date()).getTime();
result.resolve();
}, idleTime);
} else {
//continue processing
result.resolve();
}
return result;
}, false);
} | [
"function",
"doSequentiallyInBackground",
"(",
"items",
",",
"fnProcessItem",
",",
"maxBlockingTime",
",",
"idleTime",
")",
"{",
"maxBlockingTime",
"=",
"maxBlockingTime",
"||",
"15",
";",
"idleTime",
"=",
"idleTime",
"||",
"30",
";",
"var",
"sliceStartTime",
"=",... | Executes a series of synchronous tasks sequentially spread over time-slices less than maxBlockingTime.
Processing yields by idleTime between time-slices.
@param {!Array.<*>} items
@param {!function(*, number)} fnProcessItem Function that synchronously processes one item
@param {number=} maxBlockingTime
@param {number=} idleTime
@return {$.Promise} | [
"Executes",
"a",
"series",
"of",
"synchronous",
"tasks",
"sequentially",
"spread",
"over",
"time",
"-",
"slices",
"less",
"than",
"maxBlockingTime",
".",
"Processing",
"yields",
"by",
"idleTime",
"between",
"time",
"-",
"slices",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/Async.js#L208-L235 | train | This function is a helper function that will iterate over the items in the background and process the next item in the background | [
30522,
3853,
13004,
15417,
4818,
2135,
2378,
5963,
16365,
1006,
5167,
1010,
1042,
16275,
3217,
9623,
28032,
6633,
1010,
4098,
23467,
2075,
7292,
1010,
18373,
7292,
1007,
1063,
4098,
23467,
2075,
7292,
1027,
4098,
23467,
2075,
7292,
1064,
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... |
firebase/firebaseui-web | javascript/widgets/handler/common.js | function(account) {
var app = getApp();
if (!app) {
return;
}
firebaseui.auth.widget.handler.common.handleAcAccountSelectedResponse_(
account, app, container, uiShownCallback);
} | javascript | function(account) {
var app = getApp();
if (!app) {
return;
}
firebaseui.auth.widget.handler.common.handleAcAccountSelectedResponse_(
account, app, container, uiShownCallback);
} | [
"function",
"(",
"account",
")",
"{",
"var",
"app",
"=",
"getApp",
"(",
")",
";",
"if",
"(",
"!",
"app",
")",
"{",
"return",
";",
"}",
"firebaseui",
".",
"auth",
".",
"widget",
".",
"handler",
".",
"common",
".",
"handleAcAccountSelectedResponse_",
"("... | Handle the account returned from accountchooser.com. | [
"Handle",
"the",
"account",
"returned",
"from",
"accountchooser",
".",
"com",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/javascript/widgets/handler/common.js#L381-L388 | train | Handle the account selected response from the auth service. | [
30522,
3853,
1006,
4070,
1007,
1063,
13075,
10439,
1027,
2131,
29098,
1006,
1007,
1025,
2065,
1006,
999,
10439,
1007,
1063,
2709,
1025,
1065,
2543,
15058,
10179,
1012,
8740,
2705,
1012,
15536,
24291,
1012,
28213,
1012,
2691,
1012,
5047,
196... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
zloirock/core-js | packages/core-js/modules/esnext.map.merge.js | merge | function merge(iterable /* ...iterbles */) {
var map = anObject(this);
var setter = aFunction(map.set);
var i = 0;
while (i < arguments.length) {
iterate(arguments[i++], setter, map, true);
}
return map;
} | javascript | function merge(iterable /* ...iterbles */) {
var map = anObject(this);
var setter = aFunction(map.set);
var i = 0;
while (i < arguments.length) {
iterate(arguments[i++], setter, map, true);
}
return map;
} | [
"function",
"merge",
"(",
"iterable",
"/* ...iterbles */",
")",
"{",
"var",
"map",
"=",
"anObject",
"(",
"this",
")",
";",
"var",
"setter",
"=",
"aFunction",
"(",
"map",
".",
"set",
")",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"argu... | eslint-disable-next-line no-unused-vars | [
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"no",
"-",
"unused",
"-",
"vars"
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/modules/esnext.map.merge.js#L10-L18 | train | Merge the given iterable into the current object. | [
30522,
3853,
13590,
1006,
2009,
6906,
3468,
1013,
1008,
1012,
1012,
1012,
2009,
2121,
13510,
1008,
1013,
1007,
1063,
13075,
4949,
1027,
2019,
16429,
20614,
1006,
2023,
1007,
1025,
13075,
2275,
3334,
1027,
21358,
4609,
7542,
1006,
4949,
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... |
graphql/dataloader | resources/watch.js | parseFiles | function parseFiles(filepaths) {
console.log('Checking Syntax');
return Promise.all(filepaths.map(filepath => {
if (isJS(filepath) && !isTest(filepath)) {
return exec('babel', [
'--optional', 'runtime',
'--out-file', '/dev/null',
srcPath(filepath)
]);
}
}));
} | javascript | function parseFiles(filepaths) {
console.log('Checking Syntax');
return Promise.all(filepaths.map(filepath => {
if (isJS(filepath) && !isTest(filepath)) {
return exec('babel', [
'--optional', 'runtime',
'--out-file', '/dev/null',
srcPath(filepath)
]);
}
}));
} | [
"function",
"parseFiles",
"(",
"filepaths",
")",
"{",
"console",
".",
"log",
"(",
"'Checking Syntax'",
")",
";",
"return",
"Promise",
".",
"all",
"(",
"filepaths",
".",
"map",
"(",
"filepath",
"=>",
"{",
"if",
"(",
"isJS",
"(",
"filepath",
")",
"&&",
"... | Checking steps | [
"Checking",
"steps"
] | d6272867e888b6b41e53852cccf0e0158ce60379 | https://github.com/graphql/dataloader/blob/d6272867e888b6b41e53852cccf0e0158ce60379/resources/watch.js#L114-L126 | train | Parse files and return a Promise | [
30522,
3853,
11968,
20106,
9463,
2015,
1006,
5371,
15069,
2015,
1007,
1063,
10122,
1012,
8833,
1006,
1005,
9361,
20231,
1005,
1007,
1025,
2709,
4872,
1012,
2035,
1006,
5371,
15069,
2015,
1012,
4949,
1006,
5371,
15069,
1027,
1028,
1063,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
websockets/ws | lib/websocket-server.js | addListeners | function addListeners(server, map) {
for (const event of Object.keys(map)) server.on(event, map[event]);
return function removeListeners() {
for (const event of Object.keys(map)) {
server.removeListener(event, map[event]);
}
};
} | javascript | function addListeners(server, map) {
for (const event of Object.keys(map)) server.on(event, map[event]);
return function removeListeners() {
for (const event of Object.keys(map)) {
server.removeListener(event, map[event]);
}
};
} | [
"function",
"addListeners",
"(",
"server",
",",
"map",
")",
"{",
"for",
"(",
"const",
"event",
"of",
"Object",
".",
"keys",
"(",
"map",
")",
")",
"server",
".",
"on",
"(",
"event",
",",
"map",
"[",
"event",
"]",
")",
";",
"return",
"function",
"rem... | Add event listeners on an `EventEmitter` using a map of <event, listener>
pairs.
@param {EventEmitter} server The event emitter
@param {Object.<String, Function>} map The listeners to add
@return {Function} A function that will remove the added listeners when called
@private | [
"Add",
"event",
"listeners",
"on",
"an",
"EventEmitter",
"using",
"a",
"map",
"of",
"<event",
"listener",
">",
"pairs",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket-server.js#L336-L344 | train | Adds listener to server | [
30522,
3853,
5587,
9863,
24454,
2015,
1006,
8241,
1010,
4949,
1007,
1063,
2005,
1006,
9530,
3367,
2724,
1997,
4874,
1012,
6309,
1006,
4949,
1007,
1007,
8241,
1012,
2006,
1006,
2724,
1010,
4949,
1031,
2724,
1033,
1007,
1025,
2709,
3853,
63... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/treemap/treemapLayout.js | calculateRootPosition | function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
if (rootRect) {
return {x: rootRect.x, y: rootRect.y};
}
var defaultPosition = {x: 0, y: 0};
if (!targetInfo) {
return defaultPosition;
}
// If targetInfo is fetched by 'retrieveTargetInfo',
// old tree and new tree are the same tree,
// so the node still exists and we can visit it.
var targetNode = targetInfo.node;
var layout = targetNode.getLayout();
if (!layout) {
return defaultPosition;
}
// Transform coord from local to container.
var targetCenter = [layout.width / 2, layout.height / 2];
var node = targetNode;
while (node) {
var nodeLayout = node.getLayout();
targetCenter[0] += nodeLayout.x;
targetCenter[1] += nodeLayout.y;
node = node.parentNode;
}
return {
x: layoutInfo.width / 2 - targetCenter[0],
y: layoutInfo.height / 2 - targetCenter[1]
};
} | javascript | function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
if (rootRect) {
return {x: rootRect.x, y: rootRect.y};
}
var defaultPosition = {x: 0, y: 0};
if (!targetInfo) {
return defaultPosition;
}
// If targetInfo is fetched by 'retrieveTargetInfo',
// old tree and new tree are the same tree,
// so the node still exists and we can visit it.
var targetNode = targetInfo.node;
var layout = targetNode.getLayout();
if (!layout) {
return defaultPosition;
}
// Transform coord from local to container.
var targetCenter = [layout.width / 2, layout.height / 2];
var node = targetNode;
while (node) {
var nodeLayout = node.getLayout();
targetCenter[0] += nodeLayout.x;
targetCenter[1] += nodeLayout.y;
node = node.parentNode;
}
return {
x: layoutInfo.width / 2 - targetCenter[0],
y: layoutInfo.height / 2 - targetCenter[1]
};
} | [
"function",
"calculateRootPosition",
"(",
"layoutInfo",
",",
"rootRect",
",",
"targetInfo",
")",
"{",
"if",
"(",
"rootRect",
")",
"{",
"return",
"{",
"x",
":",
"rootRect",
".",
"x",
",",
"y",
":",
"rootRect",
".",
"y",
"}",
";",
"}",
"var",
"defaultPos... | Root postion base on coord of containerGroup | [
"Root",
"postion",
"base",
"on",
"coord",
"of",
"containerGroup"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L524-L559 | train | Calculate root position | [
30522,
3853,
18422,
3217,
4140,
26994,
1006,
9621,
2378,
14876,
1010,
7117,
2890,
6593,
1010,
4539,
2378,
14876,
1007,
1063,
2065,
1006,
7117,
2890,
6593,
1007,
1063,
2709,
1063,
1060,
1024,
7117,
2890,
6593,
1012,
1060,
1010,
1061,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/strict.js | reportAll | function reportAll(nodes, messageId, fix) {
reportSlice(nodes, 0, nodes.length, messageId, fix);
} | javascript | function reportAll(nodes, messageId, fix) {
reportSlice(nodes, 0, nodes.length, messageId, fix);
} | [
"function",
"reportAll",
"(",
"nodes",
",",
"messageId",
",",
"fix",
")",
"{",
"reportSlice",
"(",
"nodes",
",",
"0",
",",
"nodes",
".",
"length",
",",
"messageId",
",",
"fix",
")",
";",
"}"
] | Report all nodes in an array with a given message.
@param {ASTNode[]} nodes Nodes.
@param {string} messageId Message id to display.
@param {boolean} fix `true` if the directive should be fixed (i.e. removed)
@returns {void} | [
"Report",
"all",
"nodes",
"in",
"an",
"array",
"with",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L153-L155 | train | Report all the nodes in the array | [
30522,
3853,
3189,
8095,
1006,
14164,
1010,
4471,
3593,
1010,
8081,
1007,
1063,
4311,
13231,
1006,
14164,
1010,
1014,
1010,
14164,
1012,
3091,
1010,
4471,
3593,
1010,
8081,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/gridList/grid-list.js | GridLayout | function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
} | javascript | function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
} | [
"function",
"GridLayout",
"(",
"colCount",
",",
"tileSpans",
")",
"{",
"var",
"self",
",",
"layoutInfo",
",",
"gridStyles",
",",
"layoutTime",
",",
"mapTime",
",",
"reflowTime",
";",
"layoutTime",
"=",
"$mdUtil",
".",
"time",
"(",
"function",
"(",
")",
"{"... | Publish layout function | [
"Publish",
"layout",
"function"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L481-L537 | train | GridLayout constructor. | [
30522,
3853,
8370,
8485,
5833,
1006,
8902,
3597,
16671,
1010,
13262,
9739,
2015,
1007,
1063,
13075,
2969,
1010,
9621,
2378,
14876,
1010,
8370,
21756,
4244,
1010,
9621,
7292,
1010,
4949,
7292,
1010,
25416,
8261,
7292,
1025,
9621,
7292,
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... |
dequelabs/axe-core | lib/core/utils/respondable.js | verify | function verify(postedMessage) {
if (
// Check incoming message is valid
typeof postedMessage === 'object' &&
typeof postedMessage.uuid === 'string' &&
postedMessage._respondable === true
) {
var messageSource = _getSource();
return (
// Check the version matches
postedMessage._source === messageSource ||
// Allow free communication with axe test
postedMessage._source === 'axeAPI.x.y.z' ||
messageSource === 'axeAPI.x.y.z'
);
}
return false;
} | javascript | function verify(postedMessage) {
if (
// Check incoming message is valid
typeof postedMessage === 'object' &&
typeof postedMessage.uuid === 'string' &&
postedMessage._respondable === true
) {
var messageSource = _getSource();
return (
// Check the version matches
postedMessage._source === messageSource ||
// Allow free communication with axe test
postedMessage._source === 'axeAPI.x.y.z' ||
messageSource === 'axeAPI.x.y.z'
);
}
return false;
} | [
"function",
"verify",
"(",
"postedMessage",
")",
"{",
"if",
"(",
"// Check incoming message is valid",
"typeof",
"postedMessage",
"===",
"'object'",
"&&",
"typeof",
"postedMessage",
".",
"uuid",
"===",
"'string'",
"&&",
"postedMessage",
".",
"_respondable",
"===",
"... | Verify the received message is from the "respondable" module
@private
@param {Object} postedMessage The message received via postMessage
@return {Boolean} `true` if the message is verified from respondable | [
"Verify",
"the",
"received",
"message",
"is",
"from",
"the",
"respondable",
"module"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/respondable.js#L38-L55 | train | Verify the incoming message is valid | [
30522,
3853,
20410,
1006,
6866,
7834,
3736,
3351,
1007,
1063,
2065,
1006,
1013,
1013,
4638,
14932,
4471,
2003,
9398,
2828,
11253,
6866,
7834,
3736,
3351,
1027,
1027,
1027,
1005,
4874,
1005,
1004,
1004,
2828,
11253,
6866,
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... |
angular/material | gulp/util.js | dedupeCss | function dedupeCss() {
const prefixRegex = /-(webkit|moz|ms|o)-.+/;
return insert.transform(function(contents) {
// Parse the CSS into an AST.
const parsed = postcss.parse(contents);
// Walk through all the rules, skipping comments, media queries etc.
parsed.walk(function(rule) {
// Skip over any comments, media queries and rules that have less than 2 properties.
if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return;
// Walk all of the properties within a rule.
rule.walk(function(prop) {
// Check if there's a similar property that comes after the current one.
const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) {
return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp);
});
// Remove the declaration if it's duplicated.
if (hasDuplicate) {
prop.remove();
gutil.log(gutil.colors.yellow(
'Removed duplicate property: "' +
prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...'
));
}
});
});
// Turn the AST back into CSS.
return parsed.toResult().css;
});
// Checks if a property is a style declaration and that it
// doesn't contain any vendor prefixes.
function validateProp(prop) {
return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) {
return value.indexOf('-') > -1 && prefixRegex.test(value);
});
}
} | javascript | function dedupeCss() {
const prefixRegex = /-(webkit|moz|ms|o)-.+/;
return insert.transform(function(contents) {
// Parse the CSS into an AST.
const parsed = postcss.parse(contents);
// Walk through all the rules, skipping comments, media queries etc.
parsed.walk(function(rule) {
// Skip over any comments, media queries and rules that have less than 2 properties.
if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return;
// Walk all of the properties within a rule.
rule.walk(function(prop) {
// Check if there's a similar property that comes after the current one.
const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) {
return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp);
});
// Remove the declaration if it's duplicated.
if (hasDuplicate) {
prop.remove();
gutil.log(gutil.colors.yellow(
'Removed duplicate property: "' +
prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...'
));
}
});
});
// Turn the AST back into CSS.
return parsed.toResult().css;
});
// Checks if a property is a style declaration and that it
// doesn't contain any vendor prefixes.
function validateProp(prop) {
return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) {
return value.indexOf('-') > -1 && prefixRegex.test(value);
});
}
} | [
"function",
"dedupeCss",
"(",
")",
"{",
"const",
"prefixRegex",
"=",
"/",
"-(webkit|moz|ms|o)-.+",
"/",
";",
"return",
"insert",
".",
"transform",
"(",
"function",
"(",
"contents",
")",
"{",
"// Parse the CSS into an AST.",
"const",
"parsed",
"=",
"postcss",
"."... | Removes duplicated CSS properties. | [
"Removes",
"duplicated",
"CSS",
"properties",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L252-L294 | train | Remove duplicate CSS properties | [
30522,
3853,
2139,
8566,
5051,
6169,
2015,
1006,
1007,
1063,
9530,
3367,
17576,
2890,
3351,
2595,
1027,
1013,
1011,
1006,
4773,
23615,
1064,
9587,
2480,
1064,
5796,
1064,
1051,
1007,
1011,
1012,
1009,
1013,
1025,
2709,
19274,
1012,
10938,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.uxap/src/sap/uxap/component/Component.js | function (vName) {
if (this.oComponentData.mode === ObjectPageConfigurationMode.JsonModel) {
var oController = this._oView.getController();
//some factory requires post-processing once the view and model are created
if (oController && oController.connectToComponent) {
oController.connectToComponent(this.getModel("objectPageLayoutMetadata"));
}
}
return UIComponent.prototype.propagateProperties.apply(this, arguments);
} | javascript | function (vName) {
if (this.oComponentData.mode === ObjectPageConfigurationMode.JsonModel) {
var oController = this._oView.getController();
//some factory requires post-processing once the view and model are created
if (oController && oController.connectToComponent) {
oController.connectToComponent(this.getModel("objectPageLayoutMetadata"));
}
}
return UIComponent.prototype.propagateProperties.apply(this, arguments);
} | [
"function",
"(",
"vName",
")",
"{",
"if",
"(",
"this",
".",
"oComponentData",
".",
"mode",
"===",
"ObjectPageConfigurationMode",
".",
"JsonModel",
")",
"{",
"var",
"oController",
"=",
"this",
".",
"_oView",
".",
"getController",
"(",
")",
";",
"//some factor... | traps propagated properties for postprocessing on useExternalModel cases
@param {*} vName the name of the property
@returns {*} result of the function | [
"traps",
"propagated",
"properties",
"for",
"postprocessing",
"on",
"useExternalModel",
"cases"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/Component.js#L90-L101 | train | propagate properties to the controller | [
30522,
3853,
1006,
1058,
18442,
1007,
1063,
2065,
1006,
2023,
1012,
1051,
9006,
29513,
3372,
2850,
2696,
1012,
5549,
1027,
1027,
1027,
4874,
13704,
8663,
8873,
27390,
3370,
5302,
3207,
1012,
1046,
3385,
5302,
9247,
1007,
1063,
13075,
1051,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/CSSUtils.js | getInfoAtPos | function getInfoAtPos(editor, constPos) {
// We're going to be changing pos a lot, but we don't want to mess up
// the pos the caller passed in so we use extend to make a safe copy of it.
var pos = $.extend({}, constPos),
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
mode = editor.getModeForSelection();
// Check if this is inside a style block or in a css/less document.
if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
return createInfo();
}
// Context from the current editor will have htmlState if we are in css mode
// and in attribute value state of a tag with attribute name style
if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {
// tagInfo is required to aquire the style attr value
var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
// To be used as relative character position
offset = tagInfo.position.offset;
/**
* We will use this CM to cook css context in case of style attribute value
* as CM in htmlmixed mode doesn't yet identify this as css context. We provide
* a no-op display function to run CM without a DOM head.
*/
var _contextCM = new CodeMirror(function () {}, {
value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
mode: "css"
});
ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
}
if (_isInPropName(ctx)) {
return _getPropNameInfo(ctx);
}
if (_isInPropValue(ctx)) {
return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
}
if (_isInAtRule(ctx)) {
return _getImportUrlInfo(ctx, editor);
}
return createInfo();
} | javascript | function getInfoAtPos(editor, constPos) {
// We're going to be changing pos a lot, but we don't want to mess up
// the pos the caller passed in so we use extend to make a safe copy of it.
var pos = $.extend({}, constPos),
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos),
mode = editor.getModeForSelection();
// Check if this is inside a style block or in a css/less document.
if (mode !== "css" && mode !== "text/x-scss" && mode !== "text/x-less") {
return createInfo();
}
// Context from the current editor will have htmlState if we are in css mode
// and in attribute value state of a tag with attribute name style
if (ctx.token.state.htmlState && (!ctx.token.state.localMode || ctx.token.state.localMode.name !== "css")) {
// tagInfo is required to aquire the style attr value
var tagInfo = HTMLUtils.getTagInfo(editor, pos, true),
// To be used as relative character position
offset = tagInfo.position.offset;
/**
* We will use this CM to cook css context in case of style attribute value
* as CM in htmlmixed mode doesn't yet identify this as css context. We provide
* a no-op display function to run CM without a DOM head.
*/
var _contextCM = new CodeMirror(function () {}, {
value: "{" + tagInfo.attr.value.replace(/(^")|("$)/g, ""),
mode: "css"
});
ctx = TokenUtils.getInitialContext(_contextCM, {line: 0, ch: offset + 1});
}
if (_isInPropName(ctx)) {
return _getPropNameInfo(ctx);
}
if (_isInPropValue(ctx)) {
return _getRuleInfoStartingFromPropValue(ctx, ctx.editor);
}
if (_isInAtRule(ctx)) {
return _getImportUrlInfo(ctx, editor);
}
return createInfo();
} | [
"function",
"getInfoAtPos",
"(",
"editor",
",",
"constPos",
")",
"{",
"// We're going to be changing pos a lot, but we don't want to mess up",
"// the pos the caller passed in so we use extend to make a safe copy of it.",
"var",
"pos",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",... | Returns a context info object for the given cursor position
@param {!Editor} editor
@param {{ch: number, line: number}} constPos A CM pos (likely from editor.getCursorPos())
@return {{context: string,
offset: number,
name: string,
index: number,
values: Array.<string>,
isNewItem: boolean,
range: {start: {line: number, ch: number},
end: {line: number, ch: number}}}} A CSS context info object. | [
"Returns",
"a",
"context",
"info",
"object",
"for",
"the",
"given",
"cursor",
"position"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L611-L658 | train | Get info at pos | [
30522,
3853,
2131,
2378,
14876,
4017,
6873,
2015,
1006,
3559,
1010,
9530,
3367,
6873,
2015,
1007,
1063,
1013,
1013,
2057,
1005,
2128,
2183,
2000,
2022,
5278,
13433,
2015,
1037,
2843,
1010,
2021,
2057,
2123,
1005,
1056,
2215,
2000,
6752,
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... |
adobe/brackets | src/project/FileTreeView.js | function () {
if (!this.props.visible) {
return;
}
var node = Preact.findDOMNode(this),
selectedNode = $(node.parentNode).find(this.props.selectedClassName),
selectionViewInfo = this.props.selectionViewInfo;
if (selectedNode.length === 0) {
return;
}
node.style.top = selectedNode.offset().top - selectionViewInfo.get("offsetTop") + selectionViewInfo.get("scrollTop") - selectedNode.position().top + "px";
} | javascript | function () {
if (!this.props.visible) {
return;
}
var node = Preact.findDOMNode(this),
selectedNode = $(node.parentNode).find(this.props.selectedClassName),
selectionViewInfo = this.props.selectionViewInfo;
if (selectedNode.length === 0) {
return;
}
node.style.top = selectedNode.offset().top - selectionViewInfo.get("offsetTop") + selectionViewInfo.get("scrollTop") - selectedNode.position().top + "px";
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"props",
".",
"visible",
")",
"{",
"return",
";",
"}",
"var",
"node",
"=",
"Preact",
".",
"findDOMNode",
"(",
"this",
")",
",",
"selectedNode",
"=",
"$",
"(",
"node",
".",
"parentNode",
")",
... | When the component has updated in the DOM, reposition it to where the currently
selected node is located now. | [
"When",
"the",
"component",
"has",
"updated",
"in",
"the",
"DOM",
"reposition",
"it",
"to",
"where",
"the",
"currently",
"selected",
"node",
"is",
"located",
"now",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L1002-L1016 | train | update selected node top | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
24387,
1012,
5710,
1007,
1063,
2709,
1025,
1065,
13075,
13045,
1027,
3653,
18908,
1012,
2424,
9527,
3630,
3207,
1006,
2023,
1007,
1010,
3479,
3630,
3207,
1027,
1002,
1006,
13045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
lovell/sharp | lib/output.js | _updateFormatOut | function _updateFormatOut (formatOut, options) {
if (!(is.object(options) && options.force === false)) {
this.options.formatOut = formatOut;
}
return this;
} | javascript | function _updateFormatOut (formatOut, options) {
if (!(is.object(options) && options.force === false)) {
this.options.formatOut = formatOut;
}
return this;
} | [
"function",
"_updateFormatOut",
"(",
"formatOut",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"is",
".",
"object",
"(",
"options",
")",
"&&",
"options",
".",
"force",
"===",
"false",
")",
")",
"{",
"this",
".",
"options",
".",
"formatOut",
"=",
"f... | Update the output format unless options.force is false,
in which case revert to input format.
@private
@param {String} formatOut
@param {Object} [options]
@param {Boolean} [options.force=true] - force output format, otherwise attempt to use input format
@returns {Sharp} | [
"Update",
"the",
"output",
"format",
"unless",
"options",
".",
"force",
"is",
"false",
"in",
"which",
"case",
"revert",
"to",
"input",
"format",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/output.js#L575-L580 | train | Update the formatOut option | [
30522,
3853,
1035,
10651,
14192,
10610,
4904,
1006,
4289,
5833,
1010,
7047,
1007,
1063,
2065,
1006,
999,
1006,
2003,
1012,
4874,
1006,
7047,
1007,
1004,
1004,
7047,
1012,
2486,
1027,
1027,
1027,
6270,
1007,
1007,
1063,
2023,
1012,
7047,
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 | javascript/selenium-atoms/inject.js | function() {
new Function(arguments[arguments.length - 3]).apply(null,
(function(args) {
var realCallback = args[args.length - 1];
var unwrapperCallback = args[args.length - 2];
Array.prototype.splice.apply(args, [args.length - 3, 3]);
args.push(function(result) {
unwrapperCallback(result, realCallback);
});
return args;
})(Array.prototype.slice.apply(arguments, [0])));
} | javascript | function() {
new Function(arguments[arguments.length - 3]).apply(null,
(function(args) {
var realCallback = args[args.length - 1];
var unwrapperCallback = args[args.length - 2];
Array.prototype.splice.apply(args, [args.length - 3, 3]);
args.push(function(result) {
unwrapperCallback(result, realCallback);
});
return args;
})(Array.prototype.slice.apply(arguments, [0])));
} | [
"function",
"(",
")",
"{",
"new",
"Function",
"(",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"3",
"]",
")",
".",
"apply",
"(",
"null",
",",
"(",
"function",
"(",
"args",
")",
"{",
"var",
"realCallback",
"=",
"args",
"[",
"args",
".",
"leng... | When running in Firefox chrome mode, any DOM elements in the script result will be wrapped with a XPCNativeWrapper or XrayWrapper. We need to intercept the result and make sure it is "unwrapped" before returning to bot.inject.executeAsyncScript. The function below is in terms of the arguments object only to avoid defining new local values that would be available to the script via closure, but we know the following to be true: let n = arguments.length, then arguments[n - 1] -> The "real" async callback. This is provided by the bot.inject.executeAsyncScript atom. arguments[n - 2] -> Our "unwrapper" callback that we give to the user script. This is injected via an argument because it needs access to variables in this window's scope, while the execution context will be selenium.browserbot.getCurrentWindow(). arguments[n - 3] -> The user script as a string. arguments[0..n - 3] -> The user supplier arguments. | [
"When",
"running",
"in",
"Firefox",
"chrome",
"mode",
"any",
"DOM",
"elements",
"in",
"the",
"script",
"result",
"will",
"be",
"wrapped",
"with",
"a",
"XPCNativeWrapper",
"or",
"XrayWrapper",
".",
"We",
"need",
"to",
"intercept",
"the",
"result",
"and",
"mak... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-atoms/inject.js#L99-L110 | train | This function is a function that will call the callback function | [
30522,
3853,
1006,
1007,
1063,
2047,
3853,
1006,
9918,
1031,
9918,
1012,
3091,
1011,
1017,
1033,
1007,
1012,
6611,
1006,
19701,
1010,
1006,
3853,
1006,
12098,
5620,
1007,
1063,
13075,
2613,
9289,
20850,
8684,
1027,
12098,
5620,
1031,
12098,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/_AnnotationHelperBasics.js | function (oPathValue, sExpectedType) {
var bError,
vValue = oPathValue.value;
if (sExpectedType === "array") {
bError = !Array.isArray(vValue);
} else {
bError = typeof vValue !== sExpectedType
|| vValue === null
|| Array.isArray(vValue);
}
if (bError) {
Basics.error(oPathValue, "Expected " + sExpectedType);
}
} | javascript | function (oPathValue, sExpectedType) {
var bError,
vValue = oPathValue.value;
if (sExpectedType === "array") {
bError = !Array.isArray(vValue);
} else {
bError = typeof vValue !== sExpectedType
|| vValue === null
|| Array.isArray(vValue);
}
if (bError) {
Basics.error(oPathValue, "Expected " + sExpectedType);
}
} | [
"function",
"(",
"oPathValue",
",",
"sExpectedType",
")",
"{",
"var",
"bError",
",",
"vValue",
"=",
"oPathValue",
".",
"value",
";",
"if",
"(",
"sExpectedType",
"===",
"\"array\"",
")",
"{",
"bError",
"=",
"!",
"Array",
".",
"isArray",
"(",
"vValue",
")"... | Logs an error and throws an error if the value is not of the expected type.
@param {object} oPathValue
a path/value pair
@param {string} oPathValue.path
the meta model path to start at
@param {any} oPathValue.value
the value at this path
@param {string} sExpectedType
the expected type (tested w/ typeof) or the special value "array" for an array
@throws {SyntaxError}
if the result is not of the expected type | [
"Logs",
"an",
"error",
"and",
"throws",
"an",
"error",
"if",
"the",
"value",
"is",
"not",
"of",
"the",
"expected",
"type",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L112-L126 | train | Checks if the value of the given path is not an array | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1010,
3348,
5051,
10985,
13874,
1007,
1063,
13075,
2022,
18933,
2099,
1010,
1058,
10175,
5657,
1027,
6728,
8988,
10175,
5657,
1012,
3643,
1025,
2065,
1006,
3348,
5051,
10985,
13874,
1027,
1027,
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... | |
mdn/browser-compat-data | scripts/render.js | getSupportClass | function getSupportClass(supportInfo) {
let cssClass = 'unknown-support';
if (Array.isArray(supportInfo)) {
// the first entry should be the most relevant/recent and will be treated as "the truth"
checkSupport(supportInfo[0].version_added, supportInfo[0].version_removed);
} else if (supportInfo) { // there is just one support statement
checkSupport(supportInfo.version_added, supportInfo.version_removed);
} else { // this browser has no info, it's unknown
return 'unknown-support';
}
function checkSupport(added, removed) {
if (added === null) {
cssClass = 'unknown-support';
} else if (added) {
cssClass = 'full-support';
if (removed) {
cssClass = 'no-support';
}
} else {
cssClass = 'no-support';
}
}
return cssClass;
} | javascript | function getSupportClass(supportInfo) {
let cssClass = 'unknown-support';
if (Array.isArray(supportInfo)) {
// the first entry should be the most relevant/recent and will be treated as "the truth"
checkSupport(supportInfo[0].version_added, supportInfo[0].version_removed);
} else if (supportInfo) { // there is just one support statement
checkSupport(supportInfo.version_added, supportInfo.version_removed);
} else { // this browser has no info, it's unknown
return 'unknown-support';
}
function checkSupport(added, removed) {
if (added === null) {
cssClass = 'unknown-support';
} else if (added) {
cssClass = 'full-support';
if (removed) {
cssClass = 'no-support';
}
} else {
cssClass = 'no-support';
}
}
return cssClass;
} | [
"function",
"getSupportClass",
"(",
"supportInfo",
")",
"{",
"let",
"cssClass",
"=",
"'unknown-support'",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"supportInfo",
")",
")",
"{",
"// the first entry should be the most relevant/recent and will be treated as \"the truth\""... | /*
Given the support information for a browser, this returns
a CSS class to apply to the table cell.
`supportData` is a (or an array of) support_statement(s) | [
"/",
"*",
"Given",
"the",
"support",
"information",
"for",
"a",
"browser",
"this",
"returns",
"a",
"CSS",
"class",
"to",
"apply",
"to",
"the",
"table",
"cell",
"."
] | 6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b | https://github.com/mdn/browser-compat-data/blob/6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b/scripts/render.js#L104-L130 | train | Returns the CSS class for the support statement | [
30522,
3853,
4152,
6279,
6442,
26266,
1006,
2490,
2378,
14876,
1007,
1063,
2292,
20116,
11020,
27102,
1027,
1005,
4242,
1011,
2490,
1005,
1025,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
2490,
2378,
14876,
1007,
1007,
1063,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/UpdateNotification.js | _onRegistryDownloaded | function _onRegistryDownloaded() {
var availableUpdates = ExtensionManager.getAvailableUpdates();
PreferencesManager.setViewState("extensionUpdateInfo", availableUpdates);
PreferencesManager.setViewState("lastExtensionRegistryCheckTime", (new Date()).getTime());
$("#toolbar-extension-manager").toggleClass("updatesAvailable", availableUpdates.length > 0);
} | javascript | function _onRegistryDownloaded() {
var availableUpdates = ExtensionManager.getAvailableUpdates();
PreferencesManager.setViewState("extensionUpdateInfo", availableUpdates);
PreferencesManager.setViewState("lastExtensionRegistryCheckTime", (new Date()).getTime());
$("#toolbar-extension-manager").toggleClass("updatesAvailable", availableUpdates.length > 0);
} | [
"function",
"_onRegistryDownloaded",
"(",
")",
"{",
"var",
"availableUpdates",
"=",
"ExtensionManager",
".",
"getAvailableUpdates",
"(",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"extensionUpdateInfo\"",
",",
"availableUpdates",
")",
";",
"PreferencesM... | Calculate state of notification everytime registries are downloaded - no matter who triggered the download | [
"Calculate",
"state",
"of",
"notification",
"everytime",
"registries",
"are",
"downloaded",
"-",
"no",
"matter",
"who",
"triggered",
"the",
"download"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/UpdateNotification.js#L347-L352 | train | Called when the registry is downloaded | [
30522,
3853,
1035,
2006,
2890,
24063,
2854,
7698,
17468,
1006,
1007,
1063,
13075,
2800,
6279,
27122,
1027,
5331,
24805,
4590,
1012,
2131,
12462,
11733,
3468,
6279,
27122,
1006,
1007,
1025,
18394,
24805,
4590,
1012,
2275,
8584,
9153,
2618,
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... |
zeit/now-cli | src/commands/inspect.js | getEventMetadata | function getEventMetadata({ event, payload }) {
if (event === 'state') {
return chalk.bold(payload.value);
}
if (event === 'instance-start' || event === 'instance-stop') {
if (payload.dc != null) {
return chalk.green(`(${payload.dc})`);
}
}
return '';
} | javascript | function getEventMetadata({ event, payload }) {
if (event === 'state') {
return chalk.bold(payload.value);
}
if (event === 'instance-start' || event === 'instance-stop') {
if (payload.dc != null) {
return chalk.green(`(${payload.dc})`);
}
}
return '';
} | [
"function",
"getEventMetadata",
"(",
"{",
"event",
",",
"payload",
"}",
")",
"{",
"if",
"(",
"event",
"===",
"'state'",
")",
"{",
"return",
"chalk",
".",
"bold",
"(",
"payload",
".",
"value",
")",
";",
"}",
"if",
"(",
"event",
"===",
"'instance-start'"... | gets the metadata that should be printed next to each event | [
"gets",
"the",
"metadata",
"that",
"should",
"be",
"printed",
"next",
"to",
"each",
"event"
] | b53d907b745126113bc3e251ac2451088026a363 | https://github.com/zeit/now-cli/blob/b53d907b745126113bc3e251ac2451088026a363/src/commands/inspect.js#L286-L298 | train | Get metadata for an event | [
30522,
3853,
2131,
18697,
3372,
11368,
8447,
2696,
1006,
1063,
2724,
1010,
18093,
1065,
1007,
1063,
2065,
1006,
2724,
1027,
1027,
1027,
1005,
2110,
1005,
1007,
1063,
2709,
16833,
1012,
7782,
1006,
18093,
1012,
3643,
1007,
1025,
1065,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/Image.js | isSubSet | function isSubSet (aTestArray, aRefArray) {
function isOutsideSet(sTestValue) {
return aRefArray.indexOf(sTestValue) < 0; // value is not part of the reference set
}
return aTestArray && aRefArray && !aTestArray.some(isOutsideSet);
} | javascript | function isSubSet (aTestArray, aRefArray) {
function isOutsideSet(sTestValue) {
return aRefArray.indexOf(sTestValue) < 0; // value is not part of the reference set
}
return aTestArray && aRefArray && !aTestArray.some(isOutsideSet);
} | [
"function",
"isSubSet",
"(",
"aTestArray",
",",
"aRefArray",
")",
"{",
"function",
"isOutsideSet",
"(",
"sTestValue",
")",
"{",
"return",
"aRefArray",
".",
"indexOf",
"(",
"sTestValue",
")",
"<",
"0",
";",
"// value is not part of the reference set",
"}",
"return"... | Utility function that checks if the content of an array
is a subset of the content of a second (reference) array | [
"Utility",
"function",
"that",
"checks",
"if",
"the",
"content",
"of",
"an",
"array",
"is",
"a",
"subset",
"of",
"the",
"content",
"of",
"a",
"second",
"(",
"reference",
")",
"array"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/Image.js#L753-L758 | train | Checks if the given array is a subset of the reference array | [
30522,
3853,
26354,
12083,
13462,
1006,
8823,
14117,
9447,
1010,
2024,
14971,
9447,
1007,
1063,
3853,
11163,
30524,
3367,
10175,
5657,
1007,
1026,
1014,
1025,
1013,
1013,
3643,
2003,
2025,
2112,
1997,
1996,
4431,
2275,
1065,
2709,
8823,
141... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(graph)
{
var cells = null;
if (!mxClipboard.isEmpty())
{
cells = graph.getImportableCells(mxClipboard.getCells());
var delta = mxClipboard.insertCount * mxClipboard.STEPSIZE;
var parent = graph.getDefaultParent();
cells = graph.importCells(cells, delta, delta, parent);
// Increments the counter and selects the inserted cells
mxClipboard.insertCount++;
graph.setSelectionCells(cells);
}
return cells;
} | javascript | function(graph)
{
var cells = null;
if (!mxClipboard.isEmpty())
{
cells = graph.getImportableCells(mxClipboard.getCells());
var delta = mxClipboard.insertCount * mxClipboard.STEPSIZE;
var parent = graph.getDefaultParent();
cells = graph.importCells(cells, delta, delta, parent);
// Increments the counter and selects the inserted cells
mxClipboard.insertCount++;
graph.setSelectionCells(cells);
}
return cells;
} | [
"function",
"(",
"graph",
")",
"{",
"var",
"cells",
"=",
"null",
";",
"if",
"(",
"!",
"mxClipboard",
".",
"isEmpty",
"(",
")",
")",
"{",
"cells",
"=",
"graph",
".",
"getImportableCells",
"(",
"mxClipboard",
".",
"getCells",
"(",
")",
")",
";",
"var",... | Function: paste
Pastes the <cells> into the specified graph restoring
the relation to <parents>, if possible. If the parents
are no longer in the graph or invisible then the
cells are added to the graph's default or into the
swimlane under the cell's new location if one exists.
The cells are added to the graph using <mxGraph.importCells>
and returned.
Parameters:
graph - <mxGraph> to paste the <cells> into. | [
"Function",
":",
"paste"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L11450-L11467 | train | Returns the inserted cells | [
30522,
3853,
1006,
10629,
1007,
1063,
13075,
4442,
1027,
19701,
1025,
2065,
1006,
999,
25630,
20464,
11514,
6277,
1012,
2003,
6633,
13876,
2100,
1006,
1007,
1007,
1063,
4442,
1027,
10629,
1012,
2131,
5714,
6442,
3085,
29109,
4877,
1006,
256... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ui/models/PresetsUtils.js | function (aSelectedRulesPlain) {
// if we persist settings - load any selection presets, else use the default ones
if (this.model.getProperty("/persistingSettings")) {
var aPersistedPresets = Storage.getSelectionPresets();
if (aPersistedPresets) {
this.model.setProperty("/selectionPresets", aPersistedPresets);
}
}
var aPresets = this.model.getProperty("/selectionPresets"),
iLastSystemPresetPosition = 0;
// add System Presets to Rule Presets Popover
this.getSystemPresets().forEach(function (oSystemPreset) {
var isFound = aPresets.some(function (oPreset) {
if (oSystemPreset.id === oPreset.id) {
if (!oPreset.isModified) {
var bIsSelected = oPreset.selected;
oPreset = jQuery.extend({}, oSystemPreset);
oPreset.selected = bIsSelected;
if (bIsSelected) {
SelectionUtils.setSelectedRules(oPreset.selections);
}
}
return true;
}
});
if (!isFound) {
var mSystemPresetConfig = {
disableDelete: true,
isSystemPreset: true
};
aPresets.splice(iLastSystemPresetPosition + 1, 0, jQuery.extend(mSystemPresetConfig, oSystemPreset));
}
iLastSystemPresetPosition++;
});
// find the selected preset
var oSelectedPreset = null;
aPresets.some(function (oCurrent) {
if (oCurrent.selected) {
oSelectedPreset = oCurrent;
return true;
}
});
// sync 'My Selections' with current selections
if (oSelectedPreset.isMySelection) {
oSelectedPreset.selections = aSelectedRulesPlain;
}
// need to init the current preset
this.model.setProperty("/selectionPresetsCurrent", oSelectedPreset);
} | javascript | function (aSelectedRulesPlain) {
// if we persist settings - load any selection presets, else use the default ones
if (this.model.getProperty("/persistingSettings")) {
var aPersistedPresets = Storage.getSelectionPresets();
if (aPersistedPresets) {
this.model.setProperty("/selectionPresets", aPersistedPresets);
}
}
var aPresets = this.model.getProperty("/selectionPresets"),
iLastSystemPresetPosition = 0;
// add System Presets to Rule Presets Popover
this.getSystemPresets().forEach(function (oSystemPreset) {
var isFound = aPresets.some(function (oPreset) {
if (oSystemPreset.id === oPreset.id) {
if (!oPreset.isModified) {
var bIsSelected = oPreset.selected;
oPreset = jQuery.extend({}, oSystemPreset);
oPreset.selected = bIsSelected;
if (bIsSelected) {
SelectionUtils.setSelectedRules(oPreset.selections);
}
}
return true;
}
});
if (!isFound) {
var mSystemPresetConfig = {
disableDelete: true,
isSystemPreset: true
};
aPresets.splice(iLastSystemPresetPosition + 1, 0, jQuery.extend(mSystemPresetConfig, oSystemPreset));
}
iLastSystemPresetPosition++;
});
// find the selected preset
var oSelectedPreset = null;
aPresets.some(function (oCurrent) {
if (oCurrent.selected) {
oSelectedPreset = oCurrent;
return true;
}
});
// sync 'My Selections' with current selections
if (oSelectedPreset.isMySelection) {
oSelectedPreset.selections = aSelectedRulesPlain;
}
// need to init the current preset
this.model.setProperty("/selectionPresetsCurrent", oSelectedPreset);
} | [
"function",
"(",
"aSelectedRulesPlain",
")",
"{",
"// if we persist settings - load any selection presets, else use the default ones",
"if",
"(",
"this",
".",
"model",
".",
"getProperty",
"(",
"\"/persistingSettings\"",
")",
")",
"{",
"var",
"aPersistedPresets",
"=",
"Stora... | Initializes the current selection preset
@param {Array} aSelectedRulesPlain The plain list of selected rules (same format as in the presets json file) | [
"Initializes",
"the",
"current",
"selection",
"preset"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/models/PresetsUtils.js#L34-L89 | train | Updates the selected rules in the selection presets | [
30522,
3853,
1006,
2004,
12260,
10985,
6820,
4244,
24759,
8113,
1007,
1063,
1013,
1013,
2065,
2057,
29486,
10906,
1011,
7170,
2151,
4989,
3653,
13462,
2015,
1010,
2842,
2224,
1996,
12398,
3924,
2065,
1006,
2023,
1012,
2944,
1012,
2131,
2157... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js | function () {
var self = this;
var removed = {},
newStatus,
current;
current = self.stylesheets;
newStatus = related().stylesheets;
Object.keys(current).forEach(function (v, i) {
if (!newStatus[v]) {
removed[v] = current[v];
// remove node created by setStylesheetText if any
self.onStylesheetRemoved(current[v]);
}
});
Object.keys(removed).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetRemoved",
href: v,
roots: [removed[v]]
}));
});
self.stylesheets = newStatus;
} | javascript | function () {
var self = this;
var removed = {},
newStatus,
current;
current = self.stylesheets;
newStatus = related().stylesheets;
Object.keys(current).forEach(function (v, i) {
if (!newStatus[v]) {
removed[v] = current[v];
// remove node created by setStylesheetText if any
self.onStylesheetRemoved(current[v]);
}
});
Object.keys(removed).forEach(function (v, i) {
_transport.send(JSON.stringify({
method: "StylesheetRemoved",
href: v,
roots: [removed[v]]
}));
});
self.stylesheets = newStatus;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"removed",
"=",
"{",
"}",
",",
"newStatus",
",",
"current",
";",
"current",
"=",
"self",
".",
"stylesheets",
";",
"newStatus",
"=",
"related",
"(",
")",
".",
"stylesheets",
";",
"Obje... | Send a notification for the removed stylesheet and
its import-ed styleshets based on document.stylesheets diff
from previous status. It also updates stylesheets status. | [
"Send",
"a",
"notification",
"for",
"the",
"removed",
"stylesheet",
"and",
"its",
"import",
"-",
"ed",
"styleshets",
"based",
"on",
"document",
".",
"stylesheets",
"diff",
"from",
"previous",
"status",
".",
"It",
"also",
"updates",
"stylesheets",
"status",
"."... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/DocumentObserver.js#L199-L226 | train | Remove all stylesheets from the page | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
3718,
1027,
1063,
1065,
1010,
2739,
29336,
2271,
1010,
2783,
1025,
2783,
1027,
2969,
1012,
6782,
21030,
3215,
1025,
2739,
29336,
2271,
1027,
3141,
1006,
1007,
1012,
6782,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-sequences.js | requiresExtraParens | function requiresExtraParens(node) {
return node.parent && parenthesized[node.parent.type] &&
node === node.parent[parenthesized[node.parent.type]];
} | javascript | function requiresExtraParens(node) {
return node.parent && parenthesized[node.parent.type] &&
node === node.parent[parenthesized[node.parent.type]];
} | [
"function",
"requiresExtraParens",
"(",
"node",
")",
"{",
"return",
"node",
".",
"parent",
"&&",
"parenthesized",
"[",
"node",
".",
"parent",
".",
"type",
"]",
"&&",
"node",
"===",
"node",
".",
"parent",
"[",
"parenthesized",
"[",
"node",
".",
"parent",
... | Determines whether a node is required by the grammar to be wrapped in
parens, e.g. the test of an if statement.
@param {ASTNode} node - The AST node
@returns {boolean} True if parens around node belong to parent node. | [
"Determines",
"whether",
"a",
"node",
"is",
"required",
"by",
"the",
"grammar",
"to",
"be",
"wrapped",
"in",
"parens",
"e",
".",
"g",
".",
"the",
"test",
"of",
"an",
"if",
"statement",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-sequences.js#L60-L63 | train | Returns true if the node is not a child of the parent of the node | [
30522,
3853,
5942,
10288,
6494,
19362,
6132,
1006,
13045,
1007,
1063,
2709,
13045,
1012,
6687,
1004,
1004,
6687,
15689,
3550,
1031,
13045,
1012,
6687,
1012,
2828,
1033,
1004,
1004,
13045,
1027,
1027,
1027,
13045,
1012,
6687,
1031,
6687,
156... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Configuration.js | setValue | function setValue(sName, sValue) {
if ( typeof sValue === "undefined" || sValue === null ) {
return;
}
switch (M_SETTINGS[sName].type) {
case "boolean":
if ( typeof sValue === "string" ) {
if (M_SETTINGS[sName].defaultValue) {
config[sName] = sValue.toLowerCase() != "false";
} else {
config[sName] = sValue.toLowerCase() === "true" || sValue.toLowerCase() === "x";
}
} else {
// boolean etc.
config[sName] = !!sValue;
}
break;
case "string":
config[sName] = "" + sValue; // enforce string
break;
case "code":
config[sName] = typeof sValue === "function" ? sValue : String(sValue);
break;
case "function":
if ( typeof sValue !== "function" ) {
throw new Error("unsupported value");
}
config[sName] = sValue;
break;
case "string[]":
if ( Array.isArray(sValue) ) {
config[sName] = sValue;
} else if ( typeof sValue === "string" ) {
config[sName] = sValue.split(/[ ,;]/).map(function(s) {
return s.trim();
});
} else {
throw new Error("unsupported value");
}
break;
case "object":
if ( typeof sValue !== "object" ) {
throw new Error("unsupported value");
}
config[sName] = sValue;
break;
case "Locale":
var oLocale = convertToLocaleOrNull(sValue);
if ( oLocale || M_SETTINGS[sName].defaultValue == null ) {
config[sName] = oLocale;
} else {
throw new Error("unsupported value");
}
break;
default:
// When the type is none of the above types, check if an object as enum is provided to validate the value.
var vType = M_SETTINGS[sName].type;
if (typeof vType === "object") {
checkEnum(vType, sValue, sName);
config[sName] = sValue;
} else {
throw new Error("illegal state");
}
}
} | javascript | function setValue(sName, sValue) {
if ( typeof sValue === "undefined" || sValue === null ) {
return;
}
switch (M_SETTINGS[sName].type) {
case "boolean":
if ( typeof sValue === "string" ) {
if (M_SETTINGS[sName].defaultValue) {
config[sName] = sValue.toLowerCase() != "false";
} else {
config[sName] = sValue.toLowerCase() === "true" || sValue.toLowerCase() === "x";
}
} else {
// boolean etc.
config[sName] = !!sValue;
}
break;
case "string":
config[sName] = "" + sValue; // enforce string
break;
case "code":
config[sName] = typeof sValue === "function" ? sValue : String(sValue);
break;
case "function":
if ( typeof sValue !== "function" ) {
throw new Error("unsupported value");
}
config[sName] = sValue;
break;
case "string[]":
if ( Array.isArray(sValue) ) {
config[sName] = sValue;
} else if ( typeof sValue === "string" ) {
config[sName] = sValue.split(/[ ,;]/).map(function(s) {
return s.trim();
});
} else {
throw new Error("unsupported value");
}
break;
case "object":
if ( typeof sValue !== "object" ) {
throw new Error("unsupported value");
}
config[sName] = sValue;
break;
case "Locale":
var oLocale = convertToLocaleOrNull(sValue);
if ( oLocale || M_SETTINGS[sName].defaultValue == null ) {
config[sName] = oLocale;
} else {
throw new Error("unsupported value");
}
break;
default:
// When the type is none of the above types, check if an object as enum is provided to validate the value.
var vType = M_SETTINGS[sName].type;
if (typeof vType === "object") {
checkEnum(vType, sValue, sName);
config[sName] = sValue;
} else {
throw new Error("illegal state");
}
}
} | [
"function",
"setValue",
"(",
"sName",
",",
"sValue",
")",
"{",
"if",
"(",
"typeof",
"sValue",
"===",
"\"undefined\"",
"||",
"sValue",
"===",
"null",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"M_SETTINGS",
"[",
"sName",
"]",
".",
"type",
")",
"{",
... | /*eslint-enable consistent-this | [
"/",
"*",
"eslint",
"-",
"enable",
"consistent",
"-",
"this"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Configuration.js#L183-L247 | train | Sets the value of a property | [
30522,
3853,
2275,
10175,
5657,
1006,
1055,
18442,
1010,
17917,
2389,
5657,
1007,
1063,
2065,
1006,
2828,
11253,
17917,
2389,
5657,
1027,
1027,
1027,
1000,
6151,
28344,
1000,
1064,
1064,
17917,
2389,
5657,
1027,
1027,
1027,
19701,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/parallel/ParallelView.js | isEmptyValue | function isEmptyValue(val, axisType) {
return axisType === 'category'
? val == null
: (val == null || isNaN(val)); // axisType === 'value'
} | javascript | function isEmptyValue(val, axisType) {
return axisType === 'category'
? val == null
: (val == null || isNaN(val)); // axisType === 'value'
} | [
"function",
"isEmptyValue",
"(",
"val",
",",
"axisType",
")",
"{",
"return",
"axisType",
"===",
"'category'",
"?",
"val",
"==",
"null",
":",
"(",
"val",
"==",
"null",
"||",
"isNaN",
"(",
"val",
")",
")",
";",
"// axisType === 'value'",
"}"
] | FIXME 公用方法? | [
"FIXME",
"公用方法?"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/parallel/ParallelView.js#L262-L266 | train | Check if a value is empty | [
30522,
3853,
2003,
6633,
13876,
2100,
10175,
5657,
1006,
11748,
1010,
8123,
13874,
1007,
1063,
2709,
8123,
13874,
1027,
1027,
1027,
1005,
4696,
1005,
1029,
11748,
1027,
1027,
19701,
1024,
1006,
11748,
1027,
1027,
19701,
1064,
1064,
3475,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableScrollExtension.js | function(oTable) {
var oScrollExtension = oTable._getScrollExtension();
var iVirtualRowCount = oTable._getTotalRowCount() - oTable.getVisibleRowCount();
var iScrollRangeWithoutBuffer;
if (TableUtils.isVariableRowHeightEnabled(oTable)) {
iScrollRangeWithoutBuffer = VerticalScrollingHelper.getScrollRange(oTable) - VerticalScrollingHelper.getScrollRangeBuffer(oTable);
// The last row is part of the buffer. To correctly calculate the fraction of the scroll range allocated to a row, all rows must be
// considered. This is not the case if the scroll range is at its maximum, then the buffer must be excluded from calculation
// completely.
var bScrollRangeMaxedOut = oScrollExtension.getVerticalScrollHeight() === MAX_VERTICAL_SCROLL_HEIGHT;
if (!bScrollRangeMaxedOut) {
iScrollRangeWithoutBuffer += oTable._getDefaultRowHeight();
}
} else {
iScrollRangeWithoutBuffer = VerticalScrollingHelper.getScrollRange(oTable);
}
return iScrollRangeWithoutBuffer / Math.max(1, iVirtualRowCount);
} | javascript | function(oTable) {
var oScrollExtension = oTable._getScrollExtension();
var iVirtualRowCount = oTable._getTotalRowCount() - oTable.getVisibleRowCount();
var iScrollRangeWithoutBuffer;
if (TableUtils.isVariableRowHeightEnabled(oTable)) {
iScrollRangeWithoutBuffer = VerticalScrollingHelper.getScrollRange(oTable) - VerticalScrollingHelper.getScrollRangeBuffer(oTable);
// The last row is part of the buffer. To correctly calculate the fraction of the scroll range allocated to a row, all rows must be
// considered. This is not the case if the scroll range is at its maximum, then the buffer must be excluded from calculation
// completely.
var bScrollRangeMaxedOut = oScrollExtension.getVerticalScrollHeight() === MAX_VERTICAL_SCROLL_HEIGHT;
if (!bScrollRangeMaxedOut) {
iScrollRangeWithoutBuffer += oTable._getDefaultRowHeight();
}
} else {
iScrollRangeWithoutBuffer = VerticalScrollingHelper.getScrollRange(oTable);
}
return iScrollRangeWithoutBuffer / Math.max(1, iVirtualRowCount);
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oScrollExtension",
"=",
"oTable",
".",
"_getScrollExtension",
"(",
")",
";",
"var",
"iVirtualRowCount",
"=",
"oTable",
".",
"_getTotalRowCount",
"(",
")",
"-",
"oTable",
".",
"getVisibleRowCount",
"(",
")",
";",
"... | Gets the fraction of the vertical scroll range which corresponds to a row. This value specifies how many pixels must be scrolled to
scroll one row.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {number} The fraction of the vertical scroll range which corresponds to a row. | [
"Gets",
"the",
"fraction",
"of",
"the",
"vertical",
"scroll",
"range",
"which",
"corresponds",
"to",
"a",
"row",
".",
"This",
"value",
"specifies",
"how",
"many",
"pixels",
"must",
"be",
"scrolled",
"to",
"scroll",
"one",
"row",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableScrollExtension.js#L614-L634 | train | Calculates the fraction of the vertical scroll range. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
9808,
26775,
14511,
10288,
29048,
1027,
27178,
3085,
1012,
1035,
4152,
26775,
14511,
10288,
29048,
1006,
1007,
1025,
13075,
4921,
4313,
26302,
20974,
5004,
3597,
16671,
1027,
27178,
3085,
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... | |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onSetLanguageCode | function onSetLanguageCode() {
var languageCode = $('#language-code').val() || null;
try {
auth.languageCode = languageCode;
alertSuccess('Language code changed to "' + languageCode + '".');
} catch (error) {
alertError('Error: ' + error.code);
}
} | javascript | function onSetLanguageCode() {
var languageCode = $('#language-code').val() || null;
try {
auth.languageCode = languageCode;
alertSuccess('Language code changed to "' + languageCode + '".');
} catch (error) {
alertError('Error: ' + error.code);
}
} | [
"function",
"onSetLanguageCode",
"(",
")",
"{",
"var",
"languageCode",
"=",
"$",
"(",
"'#language-code'",
")",
".",
"val",
"(",
")",
"||",
"null",
";",
"try",
"{",
"auth",
".",
"languageCode",
"=",
"languageCode",
";",
"alertSuccess",
"(",
"'Language code ch... | Saves the new language code provided in the language code input field. | [
"Saves",
"the",
"new",
"language",
"code",
"provided",
"in",
"the",
"language",
"code",
"input",
"field",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L265-L273 | train | Set the language code | [
30522,
3853,
14447,
25023,
6692,
3351,
16044,
1006,
1007,
1063,
13075,
2653,
16044,
1027,
1002,
1006,
1005,
1001,
2653,
1011,
3642,
1005,
30524,
1005,
1000,
1012,
1005,
1007,
1025,
1065,
4608,
1006,
7561,
1007,
1063,
9499,
2121,
29165,
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... |
goldfire/howler.js | examples/3d/js/player.js | function(secs) {
var states = game.controls.states;
if (states.left) this.rotate(-Math.PI * secs);
if (states.right) this.rotate(Math.PI * secs);
if (states.front) this.walk(this.speed * secs);
if (states.back) this.walk(-this.speed * secs);
} | javascript | function(secs) {
var states = game.controls.states;
if (states.left) this.rotate(-Math.PI * secs);
if (states.right) this.rotate(Math.PI * secs);
if (states.front) this.walk(this.speed * secs);
if (states.back) this.walk(-this.speed * secs);
} | [
"function",
"(",
"secs",
")",
"{",
"var",
"states",
"=",
"game",
".",
"controls",
".",
"states",
";",
"if",
"(",
"states",
".",
"left",
")",
"this",
".",
"rotate",
"(",
"-",
"Math",
".",
"PI",
"*",
"secs",
")",
";",
"if",
"(",
"states",
".",
"r... | Update the player position and rotation on each tick.
@param {Number} secs Seconds since last update. | [
"Update",
"the",
"player",
"position",
"and",
"rotation",
"on",
"each",
"tick",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/player.js#L71-L78 | train | Walks the game in a given speed. | [
30522,
3853,
1006,
10819,
2015,
1007,
1063,
13075,
2163,
1027,
2208,
1012,
7711,
1012,
2163,
1025,
2065,
1006,
2163,
1012,
2187,
1007,
2023,
1012,
24357,
1006,
1011,
8785,
1012,
14255,
1008,
10819,
2015,
1007,
1025,
2065,
1006,
2163,
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... | |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | enableAgent | function enableAgent(name) {
if (agents.hasOwnProperty(name) && !_enabledAgentNames.hasOwnProperty(name)) {
_enabledAgentNames[name] = true;
}
} | javascript | function enableAgent(name) {
if (agents.hasOwnProperty(name) && !_enabledAgentNames.hasOwnProperty(name)) {
_enabledAgentNames[name] = true;
}
} | [
"function",
"enableAgent",
"(",
"name",
")",
"{",
"if",
"(",
"agents",
".",
"hasOwnProperty",
"(",
"name",
")",
"&&",
"!",
"_enabledAgentNames",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"_enabledAgentNames",
"[",
"name",
"]",
"=",
"true",
";",
... | Enable an agent. Takes effect next time a connection is made. Does not affect
current live development sessions.
@param {string} name of agent to enable | [
"Enable",
"an",
"agent",
".",
"Takes",
"effect",
"next",
"time",
"a",
"connection",
"is",
"made",
".",
"Does",
"not",
"affect",
"current",
"live",
"development",
"sessions",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L444-L448 | train | Enable an agent | [
30522,
3853,
9585,
4270,
3372,
1006,
2171,
1007,
1063,
2065,
1006,
6074,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
2171,
1007,
1004,
1004,
999,
1035,
9124,
4270,
3372,
18442,
2015,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
2171,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js | function (oModules, oResult) {
var modules = oModules.modules,
vDebugInfo = window["sap-ui-debug"];
// create tree with all modules and empty selection
jQuery.each(modules, function (sName) {
this.set(oResult, sName, false, true);
}.bind(this));
// apply current debug info as tree selection
if (vDebugInfo === true || vDebugInfo === 'x' || vDebugInfo === 'X') {
this.set(oResult, '/', true);
} else if (vDebugInfo && typeof vDebugInfo === 'string') {
vDebugInfo.split(/,/).forEach(function (sPattern) {
if (/\*/.test(sPattern)) {
// if a glob pattern is found, select all modules that are matched by it
var rFilter = new RegExp("^(?:" + this.makeRegExp(sPattern) + ")");
// collect namespaces
var oNamespacesAndModules = {};
Object.keys(modules).forEach(function (sModule) {
var sModulePath = sModule.split("/").slice(0, -1).join("/") + "/";
oNamespacesAndModules[sModulePath] = "";
});
// join namespaces and modules object
for (var sKey in modules) {
oNamespacesAndModules[sKey] = modules[sKey];
}
jQuery.each(oNamespacesAndModules, function (sName) {
if (rFilter.test(sName)) {
this.set(oResult, sName, true);
}
}.bind(this));
} else {
// for simple package / module names, just select the corresponding tree node
this.set(oResult, sPattern, true);
}
}.bind(this));
}
} | javascript | function (oModules, oResult) {
var modules = oModules.modules,
vDebugInfo = window["sap-ui-debug"];
// create tree with all modules and empty selection
jQuery.each(modules, function (sName) {
this.set(oResult, sName, false, true);
}.bind(this));
// apply current debug info as tree selection
if (vDebugInfo === true || vDebugInfo === 'x' || vDebugInfo === 'X') {
this.set(oResult, '/', true);
} else if (vDebugInfo && typeof vDebugInfo === 'string') {
vDebugInfo.split(/,/).forEach(function (sPattern) {
if (/\*/.test(sPattern)) {
// if a glob pattern is found, select all modules that are matched by it
var rFilter = new RegExp("^(?:" + this.makeRegExp(sPattern) + ")");
// collect namespaces
var oNamespacesAndModules = {};
Object.keys(modules).forEach(function (sModule) {
var sModulePath = sModule.split("/").slice(0, -1).join("/") + "/";
oNamespacesAndModules[sModulePath] = "";
});
// join namespaces and modules object
for (var sKey in modules) {
oNamespacesAndModules[sKey] = modules[sKey];
}
jQuery.each(oNamespacesAndModules, function (sName) {
if (rFilter.test(sName)) {
this.set(oResult, sName, true);
}
}.bind(this));
} else {
// for simple package / module names, just select the corresponding tree node
this.set(oResult, sPattern, true);
}
}.bind(this));
}
} | [
"function",
"(",
"oModules",
",",
"oResult",
")",
"{",
"var",
"modules",
"=",
"oModules",
".",
"modules",
",",
"vDebugInfo",
"=",
"window",
"[",
"\"sap-ui-debug\"",
"]",
";",
"// create tree with all modules and empty selection",
"jQuery",
".",
"each",
"(",
"modul... | Converts a module object to a module hierarchy with selections state based on sap-ui-debug
@param {object} oModules Flat object of modules
@param {object} oResult Hierarchical tree of modules including selection state | [
"Converts",
"a",
"module",
"object",
"to",
"a",
"module",
"hierarchy",
"with",
"selections",
"state",
"based",
"on",
"sap",
"-",
"ui",
"-",
"debug"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js#L73-L111 | train | Creates a tree with all modules that match the current debug info | [
30522,
3853,
1006,
18168,
7716,
16308,
1010,
10848,
23722,
2102,
1007,
1063,
13075,
14184,
1027,
18168,
7716,
16308,
1012,
14184,
1010,
1058,
3207,
8569,
11528,
14876,
1027,
3332,
1031,
1000,
20066,
1011,
21318,
1011,
2139,
8569,
2290,
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... | |
GitbookIO/gitbook | lib/output/modifiers/resolveLinks.js | resolveLinks | function resolveLinks(currentFile, resolveFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'a', function($a) {
var href = $a.attr('href');
// Don't change a tag without href
if (!href) {
return;
}
if (LocationUtils.isExternal(href)) {
$a.attr('target', '_blank');
return;
}
// Split anchor
var parsed = url.parse(href);
href = parsed.pathname || '';
if (href) {
// Calcul absolute path for this
href = LocationUtils.toAbsolute(href, currentDirectory, '.');
// Resolve file
href = resolveFile(href);
// Convert back to relative
href = LocationUtils.relative(currentDirectory, href);
}
// Add back anchor
href = href + (parsed.hash || '');
$a.attr('href', href);
});
} | javascript | function resolveLinks(currentFile, resolveFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'a', function($a) {
var href = $a.attr('href');
// Don't change a tag without href
if (!href) {
return;
}
if (LocationUtils.isExternal(href)) {
$a.attr('target', '_blank');
return;
}
// Split anchor
var parsed = url.parse(href);
href = parsed.pathname || '';
if (href) {
// Calcul absolute path for this
href = LocationUtils.toAbsolute(href, currentDirectory, '.');
// Resolve file
href = resolveFile(href);
// Convert back to relative
href = LocationUtils.relative(currentDirectory, href);
}
// Add back anchor
href = href + (parsed.hash || '');
$a.attr('href', href);
});
} | [
"function",
"resolveLinks",
"(",
"currentFile",
",",
"resolveFile",
",",
"$",
")",
"{",
"var",
"currentDirectory",
"=",
"path",
".",
"dirname",
"(",
"currentFile",
")",
";",
"return",
"editHTMLElement",
"(",
"$",
",",
"'a'",
",",
"function",
"(",
"$a",
")"... | Resolve all HTML links:
- /test.md in hello -> ../test.html
@param {String} currentFile
@param {Function(String) -> String} resolveFile
@param {HTMLDom} $ | [
"Resolve",
"all",
"HTML",
"links",
":",
"-",
"/",
"test",
".",
"md",
"in",
"hello",
"-",
">",
"..",
"/",
"test",
".",
"html"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/resolveLinks.js#L15-L51 | train | Resolve links to the current file | [
30522,
3853,
10663,
13767,
2015,
1006,
2783,
8873,
2571,
1010,
10663,
8873,
2571,
1010,
1002,
1007,
1063,
13075,
2783,
4305,
2890,
16761,
2100,
1027,
4130,
1012,
16101,
18442,
1006,
2783,
8873,
2571,
1007,
1025,
2709,
13257,
21246,
2571,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | createCallbackInterface | function createCallbackInterface(oWithControl) {
/**
* Callback interface for visitor functions which provides access to private
* {@link sap.ui.core.util.XMLPreprocessor} functionality using a map of currently
* known variables. Initially, these are the variables known to the XML
* pre-processor when it reaches the visitor's matching element (see
* {@link sap.ui.core.util.XMLPreprocessor.plugIn}). They can be overridden or
* replaced via {@link sap.ui.core.util.XMLPreprocessor.ICallback.with}.
*
* @interface
* @name sap.ui.core.util.XMLPreprocessor.ICallback
* @private
* @see sap.ui.core.util.XMLPreprocessor.plugIn
*/
return /** @lends sap.ui.core.util.XMLPreprocessor.ICallback */ {
/**
* Visits the given elements one-by-one, calls the given callback for each of
* them and stops and waits for each thenable returned by the callback before
* going on to the next element. If a thenable resolves with a truthy value,
* iteration stops and the corresponding element becomes the result of the
* returned thenable.
*
* <b>Note:</b> If the visitor function is used for synchronous XML Templating,
* the callback must return a sync promise; in other cases, any thenable is OK.
*
* @param {any[]} aElements
* Whatever elements we want to visit
* @param {function} fnCallback
* A function to be called with a single element and its index and the array
* (like {@link Array#find} does it), returning a thenable, preferrably a
* {@link sap.ui.base.SyncPromise}
* @returns {sap.ui.base.SyncPromise}
* A sync promise which resolves with the first element where the callback's
* thenable resolved with a truthy value, or resolves with
* <code>undefined</code> as soon as the last callback's thenable has
* resolved, or is rejected with a corresponding error if any callback returns
* a rejected thenable or throws an error
*/
find : function (aElements, fnCallback) {
try {
return SyncPromise.resolve(stopAndGo(aElements, fnCallback));
} catch (e) {
return SyncPromise.reject(e);
}
},
/**
* Returns the model's context which corresponds to the given simple binding
* path. Uses the map of currently known variables.
*
* @param {string} [sPath=""]
* A simple binding path which may include a model name ("a variable"), for
* example "var>some/relative/path", but not a binding ("{...}")
* @returns {sap.ui.model.Context}
* The corresponding context which holds the model and the resolved, absolute
* path
* @throws {Error}
* If a binding is given, if the path refers to an unknown model, or if the
* path cannot be resolved (typically because a relative path was given for a
* model without a binding context)
*/
getContext : function (sPath) {
var oBindingInfo,
oModel,
sResolvedPath;
sPath = sPath || "";
if (sPath[0] === "{") {
throw new Error("Must be a simple path, not a binding: " + sPath);
}
oBindingInfo = BindingParser.simpleParser("{" + sPath + "}");
oModel = oWithControl.getModel(oBindingInfo.model);
if (!oModel) {
throw new Error("Unknown model '" + oBindingInfo.model + "': " + sPath);
}
sResolvedPath = oModel.resolve(oBindingInfo.path,
oWithControl.getBindingContext(oBindingInfo.model));
if (!sResolvedPath) {
throw new Error("Cannot resolve path: " + sPath);
}
return oModel.createBindingContext(sResolvedPath);
},
/**
* Interprets the given XML DOM attribute value as a binding and returns the
* resulting value. Takes care of unescaping and thus also of constant
* expressions; warnings are logged for (formatter) functions which are not
* found. Uses the map of currently known variables.
*
* @param {string} sValue
* An XML DOM attribute value
* @param {Element} [oElement]
* The XML DOM element the attribute value belongs to (needed only for
* warnings which are logged to the console)
* @returns {sap.ui.base.SyncPromise|null}
* A thenable which resolves with the resulting value, or is rejected with a
* corresponding error (for example, an error thrown by a formatter) or
* <code>null</code> in case the binding is not ready (because it refers to a
* model which is not available) (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
getResult : function (sValue, oElement) {
return getResolvedBinding(sValue, oElement, oWithControl, true);
},
/**
* Returns the settings object for XML template processing.
*
* @returns {object}
* settings for the XML preprocessor; might contain the properties
* "bindingContexts" and "models" and maybe others
*
* @function
* @public
* @since 1.41.0
*/
getSettings : function () {
return mSettings;
},
/**
* Returns the view info object for XML template processing.
*
* @returns {object}
* info object of the XML preprocessor's calling instance; might contain the
* string properties "caller", "componentId", "name" and maybe others
*
* @function
* @public
* @since 1.41.0
*/
getViewInfo : function () {
return jQuery.extend(true, {}, oViewInfo);
},
/**
* Inserts the fragment with the given name in place of the given element. Loads
* the fragment, takes care of caching (for the current pre-processor run) and
* visits the fragment's content once it has been imported into the element's
* owner document and put into place.
*
* @param {string} sFragmentName
* The fragment's resolved name
* @param {Element} oElement
* The XML DOM element to be replaced
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as the
* fragment has been inserted, or is rejected with a corresponding error if
* loading or visiting fails (since 1.57.0)
* @throws {Error}
* If a cycle is detected (same <code>sFragmentName</code> and
* {@link sap.ui.core.util.XMLPreprocessor.ICallback})
*
* @function
* @public
* @see #with
* @since 1.39.0
*/
insertFragment : function (sFragmentName, oElement) {
return insertFragment(sFragmentName, oElement, oWithControl);
},
/**
* Visit the given attribute of the given element. If the attribute value
* represents a binding expression that can be resolved, it is replaced with
* the resulting value.
*
* @param {Element} oElement
* The XML DOM element
* @param {Attr} oAttribute
* One of the element's attribute nodes
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as the
* attribute's value has been replaced, or is rejected with a corresponding
* error if getting the binding's value fails (since 1.57.0)
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.visitAttributes
* @since 1.51.0
*/
visitAttribute : function (oElement, oAttribute) {
return visitAttribute(oElement, oAttribute, oWithControl);
},
/**
* Visits all attributes of the given element. If an attribute value represents
* a binding expression that can be resolved, it is replaced with the resulting
* value.
*
* @param {Element} oElement
* The XML DOM element
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as all
* attributes' values have been replaced, or is rejected with a corresponding
* error if getting some binding's value fails (since 1.57.0)
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.getResult
* @since 1.39.0
*/
visitAttributes : function (oElement) {
return visitAttributes(oElement, oWithControl);
},
/**
* Visits all child nodes of the given node via {@link
* sap.ui.core.util.XMLPreprocessor.ICallback.visitNode visitNode}.
*
* @param {Node} oNode
* The XML DOM node
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as visiting
* is done, or is rejected with a corresponding error if visiting fails
* (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
visitChildNodes : function (oNode) {
return visitChildNodes(oNode, oWithControl);
},
/**
* Visits the given node and either processes a template instruction, calls
* a visitor, or simply calls both {@link
* sap.ui.core.util.XMLPreprocessor.ICallback.visitAttributes visitAttributes}
* and {@link sap.ui.core.util.XMLPreprocessor.ICallback.visitChildNodes
* visitChildNodes}.
*
* @param {Node} oNode
* The XML DOM node
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as visiting
* is done, or is rejected with a corresponding error if visiting fails
* (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
visitNode : function (oNode) {
try {
return visitNode(oNode, oWithControl);
} catch (e) {
return SyncPromise.reject(e);
}
},
/**
* Returns a callback interface instance for the given map of variables which
* override currently known variables of the same name in <code>this</code>
* parent interface or replace them altogether. Each variable name becomes a
* named model with a corresponding object binding and can be used inside the
* XML template in the usual way, that is, with a binding expression like
* <code>"{var>some/relative/path}"</code> (see example).
*
* <b>Example:</b> Suppose the XML pre-processor knows a variable named "old"
* and a visitor defines a new variable relative to it as follows.
* Then {@link sap.ui.core.util.XMLPreprocessor.ICallback.getResult getResult}
* for a binding which refers to the new variable using a relative path
* ("{new>relative}") has the same result as for a binding to the old variable
* with a compound path ("{old>prefix/relative}").
*
* <pre>
* oInterface.with({"new" : oInterface.getContext("old>prefix")})
* .getResult("{new>relative}")
* === oInterface.getResult("{old>prefix/relative}"); // true
* </pre>
*
* BEWARE: Previous callback interface instances derived from the same parent
* (<code>this</code>) become invalid (that is, they forget about inherited
* variables) once a new instance is derived.
*
* @param {object} [mVariables={}]
* Map from variable name (string) to value ({@link sap.ui.model.Context})
* @param {boolean} [bReplace=false]
* Whether only the given variables are known in the new callback interface
* instance, no inherited ones
* @returns {sap.ui.core.util.XMLPreprocessor.ICallback}
* A callback interface instance
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.getResult
* @since 1.39.0
*/
"with" : function (mVariables, bReplace) {
var oContext,
bHasVariables = false,
sName,
oNewWithControl = new With();
if (!bReplace) {
oWithControl.setChild(oNewWithControl);
}
for (sName in mVariables) {
oContext = mVariables[sName];
bHasVariables = true;
oNewWithControl.setModel(oContext.getModel(), sName);
oNewWithControl.bindObject({
model : sName,
path : oContext.getPath()
});
}
return bHasVariables || bReplace
? createCallbackInterface(oNewWithControl)
: this;
}
};
} | javascript | function createCallbackInterface(oWithControl) {
/**
* Callback interface for visitor functions which provides access to private
* {@link sap.ui.core.util.XMLPreprocessor} functionality using a map of currently
* known variables. Initially, these are the variables known to the XML
* pre-processor when it reaches the visitor's matching element (see
* {@link sap.ui.core.util.XMLPreprocessor.plugIn}). They can be overridden or
* replaced via {@link sap.ui.core.util.XMLPreprocessor.ICallback.with}.
*
* @interface
* @name sap.ui.core.util.XMLPreprocessor.ICallback
* @private
* @see sap.ui.core.util.XMLPreprocessor.plugIn
*/
return /** @lends sap.ui.core.util.XMLPreprocessor.ICallback */ {
/**
* Visits the given elements one-by-one, calls the given callback for each of
* them and stops and waits for each thenable returned by the callback before
* going on to the next element. If a thenable resolves with a truthy value,
* iteration stops and the corresponding element becomes the result of the
* returned thenable.
*
* <b>Note:</b> If the visitor function is used for synchronous XML Templating,
* the callback must return a sync promise; in other cases, any thenable is OK.
*
* @param {any[]} aElements
* Whatever elements we want to visit
* @param {function} fnCallback
* A function to be called with a single element and its index and the array
* (like {@link Array#find} does it), returning a thenable, preferrably a
* {@link sap.ui.base.SyncPromise}
* @returns {sap.ui.base.SyncPromise}
* A sync promise which resolves with the first element where the callback's
* thenable resolved with a truthy value, or resolves with
* <code>undefined</code> as soon as the last callback's thenable has
* resolved, or is rejected with a corresponding error if any callback returns
* a rejected thenable or throws an error
*/
find : function (aElements, fnCallback) {
try {
return SyncPromise.resolve(stopAndGo(aElements, fnCallback));
} catch (e) {
return SyncPromise.reject(e);
}
},
/**
* Returns the model's context which corresponds to the given simple binding
* path. Uses the map of currently known variables.
*
* @param {string} [sPath=""]
* A simple binding path which may include a model name ("a variable"), for
* example "var>some/relative/path", but not a binding ("{...}")
* @returns {sap.ui.model.Context}
* The corresponding context which holds the model and the resolved, absolute
* path
* @throws {Error}
* If a binding is given, if the path refers to an unknown model, or if the
* path cannot be resolved (typically because a relative path was given for a
* model without a binding context)
*/
getContext : function (sPath) {
var oBindingInfo,
oModel,
sResolvedPath;
sPath = sPath || "";
if (sPath[0] === "{") {
throw new Error("Must be a simple path, not a binding: " + sPath);
}
oBindingInfo = BindingParser.simpleParser("{" + sPath + "}");
oModel = oWithControl.getModel(oBindingInfo.model);
if (!oModel) {
throw new Error("Unknown model '" + oBindingInfo.model + "': " + sPath);
}
sResolvedPath = oModel.resolve(oBindingInfo.path,
oWithControl.getBindingContext(oBindingInfo.model));
if (!sResolvedPath) {
throw new Error("Cannot resolve path: " + sPath);
}
return oModel.createBindingContext(sResolvedPath);
},
/**
* Interprets the given XML DOM attribute value as a binding and returns the
* resulting value. Takes care of unescaping and thus also of constant
* expressions; warnings are logged for (formatter) functions which are not
* found. Uses the map of currently known variables.
*
* @param {string} sValue
* An XML DOM attribute value
* @param {Element} [oElement]
* The XML DOM element the attribute value belongs to (needed only for
* warnings which are logged to the console)
* @returns {sap.ui.base.SyncPromise|null}
* A thenable which resolves with the resulting value, or is rejected with a
* corresponding error (for example, an error thrown by a formatter) or
* <code>null</code> in case the binding is not ready (because it refers to a
* model which is not available) (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
getResult : function (sValue, oElement) {
return getResolvedBinding(sValue, oElement, oWithControl, true);
},
/**
* Returns the settings object for XML template processing.
*
* @returns {object}
* settings for the XML preprocessor; might contain the properties
* "bindingContexts" and "models" and maybe others
*
* @function
* @public
* @since 1.41.0
*/
getSettings : function () {
return mSettings;
},
/**
* Returns the view info object for XML template processing.
*
* @returns {object}
* info object of the XML preprocessor's calling instance; might contain the
* string properties "caller", "componentId", "name" and maybe others
*
* @function
* @public
* @since 1.41.0
*/
getViewInfo : function () {
return jQuery.extend(true, {}, oViewInfo);
},
/**
* Inserts the fragment with the given name in place of the given element. Loads
* the fragment, takes care of caching (for the current pre-processor run) and
* visits the fragment's content once it has been imported into the element's
* owner document and put into place.
*
* @param {string} sFragmentName
* The fragment's resolved name
* @param {Element} oElement
* The XML DOM element to be replaced
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as the
* fragment has been inserted, or is rejected with a corresponding error if
* loading or visiting fails (since 1.57.0)
* @throws {Error}
* If a cycle is detected (same <code>sFragmentName</code> and
* {@link sap.ui.core.util.XMLPreprocessor.ICallback})
*
* @function
* @public
* @see #with
* @since 1.39.0
*/
insertFragment : function (sFragmentName, oElement) {
return insertFragment(sFragmentName, oElement, oWithControl);
},
/**
* Visit the given attribute of the given element. If the attribute value
* represents a binding expression that can be resolved, it is replaced with
* the resulting value.
*
* @param {Element} oElement
* The XML DOM element
* @param {Attr} oAttribute
* One of the element's attribute nodes
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as the
* attribute's value has been replaced, or is rejected with a corresponding
* error if getting the binding's value fails (since 1.57.0)
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.visitAttributes
* @since 1.51.0
*/
visitAttribute : function (oElement, oAttribute) {
return visitAttribute(oElement, oAttribute, oWithControl);
},
/**
* Visits all attributes of the given element. If an attribute value represents
* a binding expression that can be resolved, it is replaced with the resulting
* value.
*
* @param {Element} oElement
* The XML DOM element
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as all
* attributes' values have been replaced, or is rejected with a corresponding
* error if getting some binding's value fails (since 1.57.0)
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.getResult
* @since 1.39.0
*/
visitAttributes : function (oElement) {
return visitAttributes(oElement, oWithControl);
},
/**
* Visits all child nodes of the given node via {@link
* sap.ui.core.util.XMLPreprocessor.ICallback.visitNode visitNode}.
*
* @param {Node} oNode
* The XML DOM node
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as visiting
* is done, or is rejected with a corresponding error if visiting fails
* (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
visitChildNodes : function (oNode) {
return visitChildNodes(oNode, oWithControl);
},
/**
* Visits the given node and either processes a template instruction, calls
* a visitor, or simply calls both {@link
* sap.ui.core.util.XMLPreprocessor.ICallback.visitAttributes visitAttributes}
* and {@link sap.ui.core.util.XMLPreprocessor.ICallback.visitChildNodes
* visitChildNodes}.
*
* @param {Node} oNode
* The XML DOM node
* @returns {sap.ui.base.SyncPromise}
* A thenable which resolves with <code>undefined</code> as soon as visiting
* is done, or is rejected with a corresponding error if visiting fails
* (since 1.57.0)
*
* @function
* @public
* @since 1.39.0
*/
visitNode : function (oNode) {
try {
return visitNode(oNode, oWithControl);
} catch (e) {
return SyncPromise.reject(e);
}
},
/**
* Returns a callback interface instance for the given map of variables which
* override currently known variables of the same name in <code>this</code>
* parent interface or replace them altogether. Each variable name becomes a
* named model with a corresponding object binding and can be used inside the
* XML template in the usual way, that is, with a binding expression like
* <code>"{var>some/relative/path}"</code> (see example).
*
* <b>Example:</b> Suppose the XML pre-processor knows a variable named "old"
* and a visitor defines a new variable relative to it as follows.
* Then {@link sap.ui.core.util.XMLPreprocessor.ICallback.getResult getResult}
* for a binding which refers to the new variable using a relative path
* ("{new>relative}") has the same result as for a binding to the old variable
* with a compound path ("{old>prefix/relative}").
*
* <pre>
* oInterface.with({"new" : oInterface.getContext("old>prefix")})
* .getResult("{new>relative}")
* === oInterface.getResult("{old>prefix/relative}"); // true
* </pre>
*
* BEWARE: Previous callback interface instances derived from the same parent
* (<code>this</code>) become invalid (that is, they forget about inherited
* variables) once a new instance is derived.
*
* @param {object} [mVariables={}]
* Map from variable name (string) to value ({@link sap.ui.model.Context})
* @param {boolean} [bReplace=false]
* Whether only the given variables are known in the new callback interface
* instance, no inherited ones
* @returns {sap.ui.core.util.XMLPreprocessor.ICallback}
* A callback interface instance
*
* @function
* @public
* @see sap.ui.core.util.XMLPreprocessor.ICallback.getResult
* @since 1.39.0
*/
"with" : function (mVariables, bReplace) {
var oContext,
bHasVariables = false,
sName,
oNewWithControl = new With();
if (!bReplace) {
oWithControl.setChild(oNewWithControl);
}
for (sName in mVariables) {
oContext = mVariables[sName];
bHasVariables = true;
oNewWithControl.setModel(oContext.getModel(), sName);
oNewWithControl.bindObject({
model : sName,
path : oContext.getPath()
});
}
return bHasVariables || bReplace
? createCallbackInterface(oNewWithControl)
: this;
}
};
} | [
"function",
"createCallbackInterface",
"(",
"oWithControl",
")",
"{",
"/**\n\t\t\t\t * Callback interface for visitor functions which provides access to private\n\t\t\t\t * {@link sap.ui.core.util.XMLPreprocessor} functionality using a map of currently\n\t\t\t\t * known variables. Initially, these are t... | Returns a callback interface for visitor functions which provides access to private
{@link sap.ui.core.util.XMLPreprocessor} functionality using the given "with"
control.
@param {sap.ui.core.util._with} oWithControl
The "with" control
@returns {sap.ui.core.util.XMLPreprocessor.ICallback}
A callback interface | [
"Returns",
"a",
"callback",
"interface",
"for",
"visitor",
"functions",
"which",
"provides",
"access",
"to",
"private",
"{",
"@link",
"sap",
".",
"ui",
".",
"core",
".",
"util",
".",
"XMLPreprocessor",
"}",
"functionality",
"using",
"the",
"given",
"with",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L606-L923 | train | Creates a callback interface for the XML markup. | [
30522,
3853,
3443,
9289,
20850,
8684,
18447,
2121,
12172,
1006,
27593,
8939,
8663,
13181,
2140,
1007,
1063,
1013,
1008,
1008,
1008,
2655,
5963,
8278,
2005,
10367,
4972,
2029,
3640,
3229,
2000,
2797,
1008,
1063,
1030,
4957,
20066,
1012,
2131... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/hasher.js | function(){
hasher.stop();
hasher.initialized.dispose();
hasher.stopped.dispose();
hasher.changed.dispose();
_frame = hasher = window.hasher = null;
} | javascript | function(){
hasher.stop();
hasher.initialized.dispose();
hasher.stopped.dispose();
hasher.changed.dispose();
_frame = hasher = window.hasher = null;
} | [
"function",
"(",
")",
"{",
"hasher",
".",
"stop",
"(",
")",
";",
"hasher",
".",
"initialized",
".",
"dispose",
"(",
")",
";",
"hasher",
".",
"stopped",
".",
"dispose",
"(",
")",
";",
"hasher",
".",
"changed",
".",
"dispose",
"(",
")",
";",
"_frame"... | Removes all event listeners, stops hasher and destroy hasher object.
- IMPORTANT: hasher won't work after calling this method, hasher Object will be deleted. | [
"Removes",
"all",
"event",
"listeners",
"stops",
"hasher",
"and",
"destroy",
"hasher",
"object",
".",
"-",
"IMPORTANT",
":",
"hasher",
"won",
"t",
"work",
"after",
"calling",
"this",
"method",
"hasher",
"Object",
"will",
"be",
"deleted",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/hasher.js#L425-L431 | train | Stop the hasher and reset the window | [
30522,
3853,
1006,
1007,
1063,
23325,
2121,
1012,
2644,
1006,
1007,
1025,
23325,
2121,
1012,
3988,
3550,
1012,
27764,
1006,
1007,
1025,
23325,
2121,
1012,
3030,
1012,
27764,
1006,
1007,
1025,
23325,
2121,
1012,
2904,
1012,
27764,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsPlugin.js | function (aElementOverlays) {
var bOverlayIsSibling = true;
var sPluginId = "CTX_ADD_ELEMENTS_AS_SIBLING";
var iRank = 20;
var sIcon = "sap-icon://add";
var aMenuItems = [];
for (var i = 0; i < 2; i++){
if (this.isAvailable(bOverlayIsSibling, aElementOverlays)){
var sMenuItemText = this.getContextMenuTitle.bind(this, bOverlayIsSibling);
aMenuItems.push({
id: sPluginId,
text: sMenuItemText,
handler: function (bOverlayIsSibling, aElementOverlays) { // eslint-disable-line no-loop-func
// showAvailableElements has optional parameters, so currying is not possible here
return this.showAvailableElements(bOverlayIsSibling, aElementOverlays);
}.bind(this, bOverlayIsSibling),
enabled: this.isEnabled.bind(this, bOverlayIsSibling),
rank: iRank,
icon: sIcon,
group: "Add"
});
}
bOverlayIsSibling = false;
sPluginId = "CTX_ADD_ELEMENTS_AS_CHILD";
iRank = 30;
}
return aMenuItems;
} | javascript | function (aElementOverlays) {
var bOverlayIsSibling = true;
var sPluginId = "CTX_ADD_ELEMENTS_AS_SIBLING";
var iRank = 20;
var sIcon = "sap-icon://add";
var aMenuItems = [];
for (var i = 0; i < 2; i++){
if (this.isAvailable(bOverlayIsSibling, aElementOverlays)){
var sMenuItemText = this.getContextMenuTitle.bind(this, bOverlayIsSibling);
aMenuItems.push({
id: sPluginId,
text: sMenuItemText,
handler: function (bOverlayIsSibling, aElementOverlays) { // eslint-disable-line no-loop-func
// showAvailableElements has optional parameters, so currying is not possible here
return this.showAvailableElements(bOverlayIsSibling, aElementOverlays);
}.bind(this, bOverlayIsSibling),
enabled: this.isEnabled.bind(this, bOverlayIsSibling),
rank: iRank,
icon: sIcon,
group: "Add"
});
}
bOverlayIsSibling = false;
sPluginId = "CTX_ADD_ELEMENTS_AS_CHILD";
iRank = 30;
}
return aMenuItems;
} | [
"function",
"(",
"aElementOverlays",
")",
"{",
"var",
"bOverlayIsSibling",
"=",
"true",
";",
"var",
"sPluginId",
"=",
"\"CTX_ADD_ELEMENTS_AS_SIBLING\"",
";",
"var",
"iRank",
"=",
"20",
";",
"var",
"sIcon",
"=",
"\"sap-icon://add\"",
";",
"var",
"aMenuItems",
"="... | Retrieve the context menu item for the actions.
Two items are returned here: one for when the overlay is sibling and one for when it is child.
@param {sap.ui.dt.ElementOverlay} oOverlay Overlay for which the context menu was opened
@return {object[]} Returns array containing the items with required data | [
"Retrieve",
"the",
"context",
"menu",
"item",
"for",
"the",
"actions",
".",
"Two",
"items",
"are",
"returned",
"here",
":",
"one",
"for",
"when",
"the",
"overlay",
"is",
"sibling",
"and",
"one",
"for",
"when",
"it",
"is",
"child",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsPlugin.js#L947-L976 | train | Show the available elements | [
30522,
3853,
1006,
29347,
16930,
4765,
7840,
8485,
2015,
1007,
1063,
13075,
8945,
6299,
8485,
14643,
12322,
2989,
1027,
2995,
1025,
13075,
11867,
7630,
11528,
3593,
1027,
1000,
14931,
2595,
1035,
5587,
1035,
3787,
1035,
2004,
1035,
22941,
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... | |
facebook/relay | packages/relay-compiler/language/javascript/RelayFlowBabelFactories.js | importTypes | function importTypes(names: Array<string>, module: string) {
const importDeclaration = t.importDeclaration(
names.map(name =>
t.importSpecifier(t.identifier(name), t.identifier(name)),
),
t.stringLiteral(module),
);
importDeclaration.importKind = 'type';
return importDeclaration;
} | javascript | function importTypes(names: Array<string>, module: string) {
const importDeclaration = t.importDeclaration(
names.map(name =>
t.importSpecifier(t.identifier(name), t.identifier(name)),
),
t.stringLiteral(module),
);
importDeclaration.importKind = 'type';
return importDeclaration;
} | [
"function",
"importTypes",
"(",
"names",
":",
"Array",
"<",
"string",
">",
",",
"module",
":",
"string",
")",
"{",
"const",
"importDeclaration",
"=",
"t",
".",
"importDeclaration",
"(",
"names",
".",
"map",
"(",
"name",
"=>",
"t",
".",
"importSpecifier",
... | import type {NAMES[0], NAMES[1], ...} from 'MODULE'; | [
"import",
"type",
"{",
"NAMES",
"[",
"0",
"]",
"NAMES",
"[",
"1",
"]",
"...",
"}",
"from",
"MODULE",
";"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/language/javascript/RelayFlowBabelFactories.js#L50-L59 | train | Imports types from the specified module | [
30522,
3853,
12324,
13874,
2015,
1006,
3415,
1024,
9140,
1026,
5164,
1028,
1010,
11336,
1024,
5164,
1007,
1063,
9530,
3367,
12324,
3207,
20464,
25879,
3258,
1027,
1056,
1012,
12324,
3207,
20464,
25879,
3258,
1006,
3415,
1012,
4949,
1006,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/flattened-tree.js | virtualDOMfromNode | function virtualDOMfromNode(node, shadowId) {
const vNodeCache = {};
const vNode = {
shadowId: shadowId,
children: [],
actualNode: node,
_isHidden: null, // will be populated by axe.utils.isHidden
get isFocusable() {
if (!vNodeCache._isFocusable) {
vNodeCache._isFocusable = axe.commons.dom.isFocusable(node);
}
return vNodeCache._isFocusable;
},
get tabbableElements() {
if (!vNodeCache._tabbableElements) {
vNodeCache._tabbableElements = axe.commons.dom.getTabbableElements(
this
);
}
return vNodeCache._tabbableElements;
}
};
axe._cache.nodeMap.set(node, vNode);
return vNode;
} | javascript | function virtualDOMfromNode(node, shadowId) {
const vNodeCache = {};
const vNode = {
shadowId: shadowId,
children: [],
actualNode: node,
_isHidden: null, // will be populated by axe.utils.isHidden
get isFocusable() {
if (!vNodeCache._isFocusable) {
vNodeCache._isFocusable = axe.commons.dom.isFocusable(node);
}
return vNodeCache._isFocusable;
},
get tabbableElements() {
if (!vNodeCache._tabbableElements) {
vNodeCache._tabbableElements = axe.commons.dom.getTabbableElements(
this
);
}
return vNodeCache._tabbableElements;
}
};
axe._cache.nodeMap.set(node, vNode);
return vNode;
} | [
"function",
"virtualDOMfromNode",
"(",
"node",
",",
"shadowId",
")",
"{",
"const",
"vNodeCache",
"=",
"{",
"}",
";",
"const",
"vNode",
"=",
"{",
"shadowId",
":",
"shadowId",
",",
"children",
":",
"[",
"]",
",",
"actualNode",
":",
"node",
",",
"_isHidden"... | This implemnts the flatten-tree algorithm specified:
Originally here https://drafts.csswg.org/css-scoping/#flat-tree
Hopefully soon published here: https://www.w3.org/TR/css-scoping-1/#flat-tree
Some notable information:
****** NOTE: as of Chrome 59, this is broken in Chrome so that tests fail completely
****** removed functionality for now
1. <slot> elements do not have boxes by default (i.e. they do not get rendered and
their CSS properties are ignored)
2. <slot> elements can be made to have a box by overriding the display property
which is 'contents' by default
3. Even boxed <slot> elements do not show up in the accessibility tree until
they have a tabindex applied to them OR they have a role applied to them AND
they have a box (this is observed behavior in Safari on OS X, I cannot find
the spec for this)
Wrap the real node and provide list of the flattened children
@param node {Node} - the node in question
@param shadowId {String} - the ID of the shadow DOM to which this node belongs
@return {Object} - the wrapped node | [
"This",
"implemnts",
"the",
"flatten",
"-",
"tree",
"algorithm",
"specified",
":",
"Originally",
"here",
"https",
":",
"//",
"drafts",
".",
"csswg",
".",
"org",
"/",
"css",
"-",
"scoping",
"/",
"#flat",
"-",
"tree",
"Hopefully",
"soon",
"published",
"here"... | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/flattened-tree.js#L29-L53 | train | Returns virtual DOM object from node | [
30522,
3853,
7484,
9527,
19699,
5358,
3630,
3207,
1006,
13045,
1010,
5192,
3593,
1007,
1063,
9530,
3367,
1058,
3630,
3207,
3540,
5403,
1027,
1063,
1065,
1025,
9530,
3367,
1058,
3630,
3207,
1027,
1063,
5192,
3593,
1024,
5192,
3593,
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... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | computeOffsets | function computeOffsets(table, ticks, min, max, options) {
var start = 0;
var end = 0;
var first, last;
if (options.offset && ticks.length) {
if (!options.time.min) {
first = interpolate$1(table, 'time', ticks[0], 'pos');
if (ticks.length === 1) {
start = 1 - first;
} else {
start = (interpolate$1(table, 'time', ticks[1], 'pos') - first) / 2;
}
}
if (!options.time.max) {
last = interpolate$1(table, 'time', ticks[ticks.length - 1], 'pos');
if (ticks.length === 1) {
end = last;
} else {
end = (last - interpolate$1(table, 'time', ticks[ticks.length - 2], 'pos')) / 2;
}
}
}
return {start: start, end: end};
} | javascript | function computeOffsets(table, ticks, min, max, options) {
var start = 0;
var end = 0;
var first, last;
if (options.offset && ticks.length) {
if (!options.time.min) {
first = interpolate$1(table, 'time', ticks[0], 'pos');
if (ticks.length === 1) {
start = 1 - first;
} else {
start = (interpolate$1(table, 'time', ticks[1], 'pos') - first) / 2;
}
}
if (!options.time.max) {
last = interpolate$1(table, 'time', ticks[ticks.length - 1], 'pos');
if (ticks.length === 1) {
end = last;
} else {
end = (last - interpolate$1(table, 'time', ticks[ticks.length - 2], 'pos')) / 2;
}
}
}
return {start: start, end: end};
} | [
"function",
"computeOffsets",
"(",
"table",
",",
"ticks",
",",
"min",
",",
"max",
",",
"options",
")",
"{",
"var",
"start",
"=",
"0",
";",
"var",
"end",
"=",
"0",
";",
"var",
"first",
",",
"last",
";",
"if",
"(",
"options",
".",
"offset",
"&&",
"... | Returns the start and end offsets from edges in the form of {start, end}
where each value is a relative width to the scale and ranges between 0 and 1.
They add extra margins on the both sides by scaling down the original scale.
Offsets are added when the `offset` option is true. | [
"Returns",
"the",
"start",
"and",
"end",
"offsets",
"from",
"edges",
"in",
"the",
"form",
"of",
"{",
"start",
"end",
"}",
"where",
"each",
"value",
"is",
"a",
"relative",
"width",
"to",
"the",
"scale",
"and",
"ranges",
"between",
"0",
"and",
"1",
".",
... | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L12909-L12934 | train | Compute offsets for a given set of ticks | [
30522,
3853,
24134,
27475,
8454,
1006,
2795,
1010,
16356,
2015,
1010,
8117,
1010,
4098,
1010,
7047,
1007,
1063,
13075,
2707,
1027,
1014,
1025,
13075,
2203,
1027,
1014,
1025,
13075,
2034,
1010,
2197,
1025,
2065,
1006,
7047,
1012,
16396,
1004... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | src/ol/format/EsriJSON.js | convertRings | function convertRings(rings, layout) {
const flatRing = [];
const outerRings = [];
const holes = [];
let i, ii;
for (i = 0, ii = rings.length; i < ii; ++i) {
flatRing.length = 0;
deflateCoordinates(flatRing, 0, rings[i], layout.length);
// is this ring an outer ring? is it clockwise?
const clockwise = linearRingIsClockwise(flatRing, 0,
flatRing.length, layout.length);
if (clockwise) {
outerRings.push([rings[i]]);
} else {
holes.push(rings[i]);
}
}
while (holes.length) {
const hole = holes.shift();
let matched = false;
// loop over all outer rings and see if they contain our hole.
for (i = outerRings.length - 1; i >= 0; i--) {
const outerRing = outerRings[i][0];
const containsHole = containsExtent(
new LinearRing(outerRing).getExtent(),
new LinearRing(hole).getExtent()
);
if (containsHole) {
// the hole is contained push it into our polygon
outerRings[i].push(hole);
matched = true;
break;
}
}
if (!matched) {
// no outer rings contain this hole turn it into and outer
// ring (reverse it)
outerRings.push([hole.reverse()]);
}
}
return outerRings;
} | javascript | function convertRings(rings, layout) {
const flatRing = [];
const outerRings = [];
const holes = [];
let i, ii;
for (i = 0, ii = rings.length; i < ii; ++i) {
flatRing.length = 0;
deflateCoordinates(flatRing, 0, rings[i], layout.length);
// is this ring an outer ring? is it clockwise?
const clockwise = linearRingIsClockwise(flatRing, 0,
flatRing.length, layout.length);
if (clockwise) {
outerRings.push([rings[i]]);
} else {
holes.push(rings[i]);
}
}
while (holes.length) {
const hole = holes.shift();
let matched = false;
// loop over all outer rings and see if they contain our hole.
for (i = outerRings.length - 1; i >= 0; i--) {
const outerRing = outerRings[i][0];
const containsHole = containsExtent(
new LinearRing(outerRing).getExtent(),
new LinearRing(hole).getExtent()
);
if (containsHole) {
// the hole is contained push it into our polygon
outerRings[i].push(hole);
matched = true;
break;
}
}
if (!matched) {
// no outer rings contain this hole turn it into and outer
// ring (reverse it)
outerRings.push([hole.reverse()]);
}
}
return outerRings;
} | [
"function",
"convertRings",
"(",
"rings",
",",
"layout",
")",
"{",
"const",
"flatRing",
"=",
"[",
"]",
";",
"const",
"outerRings",
"=",
"[",
"]",
";",
"const",
"holes",
"=",
"[",
"]",
";",
"let",
"i",
",",
"ii",
";",
"for",
"(",
"i",
"=",
"0",
... | Determines inner and outer rings.
Checks if any polygons in this array contain any other polygons in this
array. It is used for checking for holes.
Logic inspired by: https://github.com/Esri/terraformer-arcgis-parser
@param {Array<!Array<!Array<number>>>} rings Rings.
@param {import("../geom/GeometryLayout.js").default} layout Geometry layout.
@return {Array<!Array<!Array<!Array<number>>>>} Transformed rings. | [
"Determines",
"inner",
"and",
"outer",
"rings",
".",
"Checks",
"if",
"any",
"polygons",
"in",
"this",
"array",
"contain",
"any",
"other",
"polygons",
"in",
"this",
"array",
".",
"It",
"is",
"used",
"for",
"checking",
"for",
"holes",
".",
"Logic",
"inspired... | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/EsriJSON.js#L279-L320 | train | Convert a list of rings into a polygon of rings | [
30522,
3853,
10463,
4892,
2015,
1006,
7635,
1010,
9621,
1007,
1063,
9530,
3367,
4257,
4892,
1027,
1031,
1033,
1025,
9530,
3367,
6058,
4892,
2015,
1027,
1031,
1033,
1025,
9530,
3367,
8198,
1027,
1031,
1033,
1025,
2292,
1045,
1010,
2462,
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... |
fullcalendar/fullcalendar | tasks/dts.js | transformModuleName | function transformModuleName(moduleName) {
let parts = moduleName.split('/')
if (parts.length > 1) { // one of our packages
let packageName = dirToPackage[parts[0]]
parts.shift() // remove first item, the dir name
if (parts.length === 1 && parts[0] === 'main') {
parts.shift() // completely empty!
}
parts.unshift(packageName)
}
return parts.join('/')
} | javascript | function transformModuleName(moduleName) {
let parts = moduleName.split('/')
if (parts.length > 1) { // one of our packages
let packageName = dirToPackage[parts[0]]
parts.shift() // remove first item, the dir name
if (parts.length === 1 && parts[0] === 'main') {
parts.shift() // completely empty!
}
parts.unshift(packageName)
}
return parts.join('/')
} | [
"function",
"transformModuleName",
"(",
"moduleName",
")",
"{",
"let",
"parts",
"=",
"moduleName",
".",
"split",
"(",
"'/'",
")",
"if",
"(",
"parts",
".",
"length",
">",
"1",
")",
"{",
"// one of our packages",
"let",
"packageName",
"=",
"dirToPackage",
"[",... | /*
NOTE: this logic is overkill now that modules names are just '@fullcalendar/*' | [
"/",
"*",
"NOTE",
":",
"this",
"logic",
"is",
"overkill",
"now",
"that",
"modules",
"names",
"are",
"just"
] | f827f233581338ceb9723eabb7f895731498fd5b | https://github.com/fullcalendar/fullcalendar/blob/f827f233581338ceb9723eabb7f895731498fd5b/tasks/dts.js#L78-L94 | train | Transform a module name into a module name | [
30522,
3853,
10938,
5302,
8566,
20844,
4168,
1006,
11336,
18442,
1007,
1063,
2292,
3033,
1027,
11336,
18442,
1012,
3975,
1006,
1005,
1013,
1005,
1007,
2065,
1006,
3033,
1012,
3091,
1028,
1015,
1007,
1063,
1013,
1013,
2028,
1997,
2256,
14555... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | dev/param-mixin.js | paramConverterMiddleware | function paramConverterMiddleware(handler, action) {
function convertProperties(obj, schema) {
Object.keys(schema).forEach(key => {
const s = schema[key];
const val = obj[key];
if (val == null)
return;
if (s.type == "string" && typeof val !== "string") {
obj[key] = "" + val;
} else if (s.type == "number" && typeof val !== "number") {
obj[key] = Number(val);
} else if (s.type == "boolean" && typeof val !== "boolean") {
obj[key] = String(val).toLowerCase() === "true";
} else if (s.type == "date" && !(val instanceof Date)) {
obj[key] = new Date(val);
} else if (s.type == "object")
convertProperties(val, s.props);
});
}
// Wrap a param validator
if (action.params && typeof action.params === "object") {
return function convertContextParams(ctx) {
convertProperties(ctx.params, action.params);
return handler(ctx);
};
}
return handler;
} | javascript | function paramConverterMiddleware(handler, action) {
function convertProperties(obj, schema) {
Object.keys(schema).forEach(key => {
const s = schema[key];
const val = obj[key];
if (val == null)
return;
if (s.type == "string" && typeof val !== "string") {
obj[key] = "" + val;
} else if (s.type == "number" && typeof val !== "number") {
obj[key] = Number(val);
} else if (s.type == "boolean" && typeof val !== "boolean") {
obj[key] = String(val).toLowerCase() === "true";
} else if (s.type == "date" && !(val instanceof Date)) {
obj[key] = new Date(val);
} else if (s.type == "object")
convertProperties(val, s.props);
});
}
// Wrap a param validator
if (action.params && typeof action.params === "object") {
return function convertContextParams(ctx) {
convertProperties(ctx.params, action.params);
return handler(ctx);
};
}
return handler;
} | [
"function",
"paramConverterMiddleware",
"(",
"handler",
",",
"action",
")",
"{",
"function",
"convertProperties",
"(",
"obj",
",",
"schema",
")",
"{",
"Object",
".",
"keys",
"(",
"schema",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"const",
"s",
"=",
"s... | Proof-of-Concept middleware to convert context params
@param {Function} handler
@param {Action} action | [
"Proof",
"-",
"of",
"-",
"Concept",
"middleware",
"to",
"convert",
"context",
"params"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/dev/param-mixin.js#L10-L41 | train | Convert params from context to context params | [
30522,
3853,
11498,
12458,
2239,
16874,
2121,
4328,
20338,
8059,
1006,
28213,
1010,
2895,
1007,
1063,
3853,
10463,
21572,
4842,
7368,
1006,
27885,
3501,
1010,
30524,
1031,
3145,
1033,
1025,
9530,
3367,
11748,
1027,
27885,
3501,
1031,
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 | Makefile.js | getFirstVersionOfFile | function getFirstVersionOfFile(filePath) {
const firstCommit = getFirstCommitOfFile(filePath);
let tags = execSilent(`git tag --contains ${firstCommit}`);
tags = splitCommandResultToLines(tags);
return tags.reduce((list, version) => {
const validatedVersion = semver.valid(version.trim());
if (validatedVersion) {
list.push(validatedVersion);
}
return list;
}, []).sort(semver.compare)[0];
} | javascript | function getFirstVersionOfFile(filePath) {
const firstCommit = getFirstCommitOfFile(filePath);
let tags = execSilent(`git tag --contains ${firstCommit}`);
tags = splitCommandResultToLines(tags);
return tags.reduce((list, version) => {
const validatedVersion = semver.valid(version.trim());
if (validatedVersion) {
list.push(validatedVersion);
}
return list;
}, []).sort(semver.compare)[0];
} | [
"function",
"getFirstVersionOfFile",
"(",
"filePath",
")",
"{",
"const",
"firstCommit",
"=",
"getFirstCommitOfFile",
"(",
"filePath",
")",
";",
"let",
"tags",
"=",
"execSilent",
"(",
"`",
"${",
"firstCommit",
"}",
"`",
")",
";",
"tags",
"=",
"splitCommandResul... | Gets the tag name where a given file was introduced first.
@param {string} filePath The file path to check.
@returns {string} The tag name. | [
"Gets",
"the",
"tag",
"name",
"where",
"a",
"given",
"file",
"was",
"introduced",
"first",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L340-L353 | train | Get the first version of a file | [
30522,
3853,
2131,
8873,
12096,
27774,
7245,
9463,
1006,
5371,
15069,
1007,
1063,
9530,
3367,
2034,
9006,
22930,
1027,
2131,
8873,
12096,
9006,
22930,
7245,
9463,
1006,
5371,
15069,
1007,
1025,
2292,
22073,
1027,
4654,
8586,
27572,
4765,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Inspector/Inspector.js | _onError | function _onError(error) {
if (_connectDeferred) {
_connectDeferred.reject();
_connectDeferred = null;
}
exports.trigger("error", error);
} | javascript | function _onError(error) {
if (_connectDeferred) {
_connectDeferred.reject();
_connectDeferred = null;
}
exports.trigger("error", error);
} | [
"function",
"_onError",
"(",
"error",
")",
"{",
"if",
"(",
"_connectDeferred",
")",
"{",
"_connectDeferred",
".",
"reject",
"(",
")",
";",
"_connectDeferred",
"=",
"null",
";",
"}",
"exports",
".",
"trigger",
"(",
"\"error\"",
",",
"error",
")",
";",
"}"... | WebSocket reported an error | [
"WebSocket",
"reported",
"an",
"error"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Inspector/Inspector.js#L186-L192 | train | Called when an error occurs during the connection | [
30522,
3853,
1035,
2028,
18933,
2099,
1006,
7561,
1007,
1063,
2065,
1006,
1035,
7532,
3207,
7512,
5596,
1007,
1063,
1035,
7532,
3207,
7512,
5596,
1012,
15454,
1006,
1007,
1025,
1035,
7532,
3207,
7512,
5596,
1027,
19701,
1025,
1065,
14338,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
elastic/elasticsearch-js | api/api/count.js | buildCount | function buildCount (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request
*
* @param {list} index - A comma-separated list of indices to restrict the results
* @param {list} type - A comma-separated list of types to restrict the results
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {number} min_score - Include only documents with a specific `_score` value in the result
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {list} routing - A comma-separated list of specific routing values
* @param {string} q - Query in the Lucene query string syntax
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early
* @param {object} body - A query to restrict the results specified with the Query DSL (optional)
*/
const acceptedQuerystring = [
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'min_score',
'preference',
'routing',
'q',
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'lenient',
'terminate_after',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
ignoreThrottled: 'ignore_throttled',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
minScore: 'min_score',
analyzeWildcard: 'analyze_wildcard',
defaultOperator: 'default_operator',
terminateAfter: 'terminate_after',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function count (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
} else if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_count'
} else {
path = '/' + '_count'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildCount (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request
*
* @param {list} index - A comma-separated list of indices to restrict the results
* @param {list} type - A comma-separated list of types to restrict the results
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {number} min_score - Include only documents with a specific `_score` value in the result
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {list} routing - A comma-separated list of specific routing values
* @param {string} q - Query in the Lucene query string syntax
* @param {string} analyzer - The analyzer to use for the query string
* @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {enum} default_operator - The default operator for query string query (AND or OR)
* @param {string} df - The field to use as default where no field prefix is given in the query string
* @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early
* @param {object} body - A query to restrict the results specified with the Query DSL (optional)
*/
const acceptedQuerystring = [
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'min_score',
'preference',
'routing',
'q',
'analyzer',
'analyze_wildcard',
'default_operator',
'df',
'lenient',
'terminate_after',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
ignoreThrottled: 'ignore_throttled',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
minScore: 'min_score',
analyzeWildcard: 'analyze_wildcard',
defaultOperator: 'default_operator',
terminateAfter: 'terminate_after',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function count (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count'
} else if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_count'
} else {
path = '/' + '_count'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildCount",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [count](http://www.elastic.co/guide/en/elastic... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/count.js#L25-L143 | train | Build a count query | [
30522,
3853,
3857,
3597,
16671,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
15171,
1011,
13075,
2015,
9530,
3367,
1063,
9338,
2063,
15500,
1010,
9563,
2121,
29165,
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... |
eslint/eslint | lib/rules/radix.js | isValidRadix | function isValidRadix(radix) {
return !(
(radix.type === "Literal" && typeof radix.value !== "number") ||
(radix.type === "Identifier" && radix.name === "undefined")
);
} | javascript | function isValidRadix(radix) {
return !(
(radix.type === "Literal" && typeof radix.value !== "number") ||
(radix.type === "Identifier" && radix.name === "undefined")
);
} | [
"function",
"isValidRadix",
"(",
"radix",
")",
"{",
"return",
"!",
"(",
"(",
"radix",
".",
"type",
"===",
"\"Literal\"",
"&&",
"typeof",
"radix",
".",
"value",
"!==",
"\"number\"",
")",
"||",
"(",
"radix",
".",
"type",
"===",
"\"Identifier\"",
"&&",
"rad... | Checks whether a given node is a valid value of radix or not.
The following values are invalid.
- A literal except numbers.
- undefined.
@param {ASTNode} radix - A node of radix to check.
@returns {boolean} `true` if the node is valid. | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"valid",
"value",
"of",
"radix",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/radix.js#L58-L63 | train | Check if the given radix is valid | [
30522,
3853,
2003,
10175,
3593,
12173,
7646,
1006,
10958,
4305,
2595,
1007,
1063,
2709,
999,
1006,
1006,
10958,
4305,
2595,
1012,
2828,
1027,
1027,
1027,
1000,
18204,
1000,
1004,
1004,
2828,
11253,
10958,
4305,
2595,
1012,
3643,
999,
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... |
angular/material | src/components/sticky/sticky.js | setupAugmentedScrollEvents | function setupAugmentedScrollEvents(element) {
var SCROLL_END_DELAY = 200;
var isScrolling;
var lastScrollTime;
element.on('scroll touchmove', function() {
if (!isScrolling) {
isScrolling = true;
$$rAF.throttle(loopScrollEvent);
element.triggerHandler('$scrollstart');
}
element.triggerHandler('$scroll');
lastScrollTime = +$mdUtil.now();
});
function loopScrollEvent() {
if (+$mdUtil.now() - lastScrollTime > SCROLL_END_DELAY) {
isScrolling = false;
element.triggerHandler('$scrollend');
} else {
element.triggerHandler('$scroll');
$$rAF.throttle(loopScrollEvent);
}
}
} | javascript | function setupAugmentedScrollEvents(element) {
var SCROLL_END_DELAY = 200;
var isScrolling;
var lastScrollTime;
element.on('scroll touchmove', function() {
if (!isScrolling) {
isScrolling = true;
$$rAF.throttle(loopScrollEvent);
element.triggerHandler('$scrollstart');
}
element.triggerHandler('$scroll');
lastScrollTime = +$mdUtil.now();
});
function loopScrollEvent() {
if (+$mdUtil.now() - lastScrollTime > SCROLL_END_DELAY) {
isScrolling = false;
element.triggerHandler('$scrollend');
} else {
element.triggerHandler('$scroll');
$$rAF.throttle(loopScrollEvent);
}
}
} | [
"function",
"setupAugmentedScrollEvents",
"(",
"element",
")",
"{",
"var",
"SCROLL_END_DELAY",
"=",
"200",
";",
"var",
"isScrolling",
";",
"var",
"lastScrollTime",
";",
"element",
".",
"on",
"(",
"'scroll touchmove'",
",",
"function",
"(",
")",
"{",
"if",
"(",... | Android 4.4 don't accurately give scroll events. To fix this problem, we setup a fake scroll event. We say: > If a scroll or touchmove event has happened in the last DELAY milliseconds, then send a `$scroll` event every animationFrame. Additionally, we add $scrollstart and $scrollend events. | [
"Android",
"4",
".",
"4",
"don",
"t",
"accurately",
"give",
"scroll",
"events",
".",
"To",
"fix",
"this",
"problem",
"we",
"setup",
"a",
"fake",
"scroll",
"event",
".",
"We",
"say",
":",
">",
"If",
"a",
"scroll",
"or",
"touchmove",
"event",
"has",
"h... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sticky/sticky.js#L328-L351 | train | Setup event handlers for scroll events | [
30522,
3853,
16437,
4887,
21693,
14088,
11020,
28402,
18697,
7666,
1006,
5783,
1007,
1063,
13075,
17186,
1035,
2203,
1035,
8536,
1027,
3263,
1025,
13075,
26354,
26775,
14511,
2075,
1025,
13075,
16180,
26775,
14511,
7292,
1025,
5783,
1012,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
transloadit/uppy | examples/react-native-expo/FileList.js | FileIcon | function FileIcon () {
return <View style={styles.itemIconContainer}>
<Image
style={styles.itemIcon}
source={require('./assets/file-icon.png')}
/>
</View>
} | javascript | function FileIcon () {
return <View style={styles.itemIconContainer}>
<Image
style={styles.itemIcon}
source={require('./assets/file-icon.png')}
/>
</View>
} | [
"function",
"FileIcon",
"(",
")",
"{",
"return",
"<",
"View",
"style",
"=",
"{",
"styles",
".",
"itemIconContainer",
"}",
">",
"\n ",
"<",
"Image",
"style",
"=",
"{",
"styles",
".",
"itemIcon",
"}",
"source",
"=",
"{",
"require",
"(",
"'./assets/file-... | return str } | [
"return",
"str",
"}"
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/examples/react-native-expo/FileList.js#L18-L25 | train | File Icon | [
30522,
3853,
5371,
28524,
1006,
1007,
1063,
2709,
1026,
3193,
2806,
1027,
1063,
6782,
1012,
8875,
28524,
8663,
18249,
2121,
1065,
1028,
1026,
3746,
2806,
1027,
1063,
6782,
1012,
8875,
28524,
1065,
3120,
1027,
1063,
5478,
1006,
1005,
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... |
adobe/brackets | src/search/node/FindInFilesDomain.js | doSearch | function doSearch(searchObject, nextPages) {
savedSearchObject = searchObject;
if (!files) {
console.log("no file object found");
return {};
}
results = {};
numMatches = 0;
numFiles = 0;
foundMaximum = false;
if (!nextPages) {
exceedsMaximum = false;
evaluatedMatches = 0;
}
var queryObject = parseQueryInfo(searchObject.queryInfo);
if (searchObject.files) {
files = searchObject.files;
}
if (searchObject.getAllResults) {
searchObject.maxResultsToReturn = MAX_TOTAL_RESULTS;
}
doSearchInFiles(files, queryObject.queryExpr, searchObject.startFileIndex, searchObject.maxResultsToReturn);
if (crawlComplete && !nextPages) {
numMatches = getNumMatches(files, queryObject.queryExpr);
}
var send_object = {
"results": results,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!nextPages) {
send_object.numMatches = numMatches;
send_object.numFiles = numFiles;
}
if (searchObject.getAllResults) {
send_object.allResultsAvailable = true;
}
return send_object;
} | javascript | function doSearch(searchObject, nextPages) {
savedSearchObject = searchObject;
if (!files) {
console.log("no file object found");
return {};
}
results = {};
numMatches = 0;
numFiles = 0;
foundMaximum = false;
if (!nextPages) {
exceedsMaximum = false;
evaluatedMatches = 0;
}
var queryObject = parseQueryInfo(searchObject.queryInfo);
if (searchObject.files) {
files = searchObject.files;
}
if (searchObject.getAllResults) {
searchObject.maxResultsToReturn = MAX_TOTAL_RESULTS;
}
doSearchInFiles(files, queryObject.queryExpr, searchObject.startFileIndex, searchObject.maxResultsToReturn);
if (crawlComplete && !nextPages) {
numMatches = getNumMatches(files, queryObject.queryExpr);
}
var send_object = {
"results": results,
"foundMaximum": foundMaximum,
"exceedsMaximum": exceedsMaximum
};
if (!nextPages) {
send_object.numMatches = numMatches;
send_object.numFiles = numFiles;
}
if (searchObject.getAllResults) {
send_object.allResultsAvailable = true;
}
return send_object;
} | [
"function",
"doSearch",
"(",
"searchObject",
",",
"nextPages",
")",
"{",
"savedSearchObject",
"=",
"searchObject",
";",
"if",
"(",
"!",
"files",
")",
"{",
"console",
".",
"log",
"(",
"\"no file object found\"",
")",
";",
"return",
"{",
"}",
";",
"}",
"resu... | Do a search with the searchObject context and return the results
@param {Object} searchObject
@param {boolean} nextPages set to true if to indicate that next page of an existing page is being fetched
@return {Object} search results | [
"Do",
"a",
"search",
"with",
"the",
"searchObject",
"context",
"and",
"return",
"the",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L425-L466 | train | search the files in the current page | [
30522,
3853,
13004,
2906,
2818,
1006,
3945,
16429,
20614,
1010,
2279,
13704,
2015,
1007,
1063,
5552,
17310,
11140,
16429,
20614,
1027,
3945,
16429,
20614,
1025,
2065,
1006,
999,
6764,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
2053,
5371,
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... |
SAP/openui5 | src/sap.m/src/sap/m/FacetFilterList.js | isODataModel | function isODataModel(oModel) {
return oModel instanceof sap.ui.model.odata.ODataModel || oModel instanceof sap.ui.model.odata.v2.ODataModel;
} | javascript | function isODataModel(oModel) {
return oModel instanceof sap.ui.model.odata.ODataModel || oModel instanceof sap.ui.model.odata.v2.ODataModel;
} | [
"function",
"isODataModel",
"(",
"oModel",
")",
"{",
"return",
"oModel",
"instanceof",
"sap",
".",
"ui",
".",
"model",
".",
"odata",
".",
"ODataModel",
"||",
"oModel",
"instanceof",
"sap",
".",
"ui",
".",
"model",
".",
"odata",
".",
"v2",
".",
"ODataMode... | Checks whether given model is one of the OData Model(s) | [
"Checks",
"whether",
"given",
"model",
"is",
"one",
"of",
"the",
"OData",
"Model",
"(",
"s",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/FacetFilterList.js#L566-L568 | train | Returns true if the given model is an OData model | [
30522,
3853,
11163,
2850,
15464,
10244,
2140,
1006,
18168,
10244,
2140,
1007,
1063,
2709,
18168,
10244,
2140,
6013,
11253,
20066,
1012,
21318,
1012,
2944,
1012,
1051,
2850,
2696,
1012,
1051,
2850,
15464,
10244,
2140,
1064,
1064,
18168,
10244,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/config/config-rule.js | combinePropertyObjects | function combinePropertyObjects(objArr1, objArr2) {
const res = [];
if (objArr1.length === 0) {
return objArr2;
}
if (objArr2.length === 0) {
return objArr1;
}
objArr1.forEach(obj1 => {
objArr2.forEach(obj2 => {
const combinedObj = {};
const obj1Props = Object.keys(obj1);
const obj2Props = Object.keys(obj2);
obj1Props.forEach(prop1 => {
combinedObj[prop1] = obj1[prop1];
});
obj2Props.forEach(prop2 => {
combinedObj[prop2] = obj2[prop2];
});
res.push(combinedObj);
});
});
return res;
} | javascript | function combinePropertyObjects(objArr1, objArr2) {
const res = [];
if (objArr1.length === 0) {
return objArr2;
}
if (objArr2.length === 0) {
return objArr1;
}
objArr1.forEach(obj1 => {
objArr2.forEach(obj2 => {
const combinedObj = {};
const obj1Props = Object.keys(obj1);
const obj2Props = Object.keys(obj2);
obj1Props.forEach(prop1 => {
combinedObj[prop1] = obj1[prop1];
});
obj2Props.forEach(prop2 => {
combinedObj[prop2] = obj2[prop2];
});
res.push(combinedObj);
});
});
return res;
} | [
"function",
"combinePropertyObjects",
"(",
"objArr1",
",",
"objArr2",
")",
"{",
"const",
"res",
"=",
"[",
"]",
";",
"if",
"(",
"objArr1",
".",
"length",
"===",
"0",
")",
"{",
"return",
"objArr2",
";",
"}",
"if",
"(",
"objArr2",
".",
"length",
"===",
... | Object whose keys are rule names and values are arrays of valid ruleConfig items
which should be linted against the target source code to determine error counts.
(a ruleConfigSet.ruleConfigs).
e.g. rulesConfig = {
"comma-dangle": [2, [2, "always"], [2, "always-multiline"], [2, "never"]],
"no-console": [2]
}
@typedef rulesConfig
Create valid rule configurations by combining two arrays,
with each array containing multiple objects each with a
single property/value pair and matching properties.
e.g.:
combinePropertyObjects(
[{before: true}, {before: false}],
[{after: true}, {after: false}]
);
will return:
[
{before: true, after: true},
{before: true, after: false},
{before: false, after: true},
{before: false, after: false}
]
@param {Object[]} objArr1 Single key/value objects, all with the same key
@param {Object[]} objArr2 Single key/value objects, all with another key
@returns {Object[]} Combined objects for each combination of input properties and values | [
"Object",
"whose",
"keys",
"are",
"rule",
"names",
"and",
"values",
"are",
"arrays",
"of",
"valid",
"ruleConfig",
"items",
"which",
"should",
"be",
"linted",
"against",
"the",
"target",
"source",
"code",
"to",
"determine",
"error",
"counts",
".",
"(",
"a",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-rule.js#L145-L170 | train | Combine two object arrays | [
30522,
3853,
11506,
21572,
4842,
3723,
16429,
20614,
2015,
1006,
27885,
16084,
2099,
2487,
1010,
27885,
16084,
2099,
2475,
1007,
1063,
9530,
3367,
24501,
1027,
1031,
1033,
1025,
2065,
1006,
27885,
16084,
2099,
2487,
1012,
3091,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/extensions/table/mergedTableRemoveCol.js | _findFocusCell | function _findFocusCell($newTable, rowIndex, colIndex) {
const tableData = dataHandler.createTableData($newTable);
if (tableData[0].length - 1 < colIndex) {
colIndex -= 1;
}
const cellElementIndex = dataHandler.findElementIndex(tableData, rowIndex, colIndex);
return $newTable.find('tr').eq(cellElementIndex.rowIndex).find('td, th')[cellElementIndex.colIndex];
} | javascript | function _findFocusCell($newTable, rowIndex, colIndex) {
const tableData = dataHandler.createTableData($newTable);
if (tableData[0].length - 1 < colIndex) {
colIndex -= 1;
}
const cellElementIndex = dataHandler.findElementIndex(tableData, rowIndex, colIndex);
return $newTable.find('tr').eq(cellElementIndex.rowIndex).find('td, th')[cellElementIndex.colIndex];
} | [
"function",
"_findFocusCell",
"(",
"$newTable",
",",
"rowIndex",
",",
"colIndex",
")",
"{",
"const",
"tableData",
"=",
"dataHandler",
".",
"createTableData",
"(",
"$newTable",
")",
";",
"if",
"(",
"tableData",
"[",
"0",
"]",
".",
"length",
"-",
"1",
"<",
... | Find focus cell element like td or th.
@param {jQuery} $newTable - changed table jQuery element
@param {number} rowIndex - row index of table data
@param {number} colIndex - column index of tabld data
@returns {HTMLElement}
@private | [
"Find",
"focus",
"cell",
"element",
"like",
"td",
"or",
"th",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/mergedTableRemoveCol.js#L136-L146 | train | Find focus cell | [
30522,
3853,
1035,
2424,
14876,
7874,
29109,
2140,
1006,
1002,
25597,
3085,
1010,
5216,
22254,
10288,
1010,
6972,
3207,
2595,
1007,
1063,
9530,
3367,
2795,
2850,
2696,
1027,
2951,
11774,
3917,
1012,
3443,
10880,
2850,
2696,
1006,
1002,
2559... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SinglePlanningCalendarGrid.js | function(oEvent) {
var oDragSession = oEvent.getParameter("dragSession"),
oAppointmentRef = oDragSession.getDragControl().$().get(0),
oDropTarget = oDragSession.getDropControl().getDomRef(),
oAppointmentStartingBoundaries = oDragSession.getComplexData("appointmentStartingBoundaries"),
fnHideIndicator = function() {
var $Indicator = jQuery(oDragSession.getIndicator());
$Indicator.addClass("sapUiDnDIndicatorHide");
},
iTop,
iBottom,
iHeight,
iVariableBoundaryY,
mDraggedControlConfig;
if (!oAppointmentStartingBoundaries) {
oAppointmentStartingBoundaries = {
top: oAppointmentRef.offsetTop,
bottom: oAppointmentRef.offsetTop + oAppointmentRef.getBoundingClientRect().height,
height: oAppointmentRef.getBoundingClientRect().height
};
oDragSession.setComplexData("appointmentStartingBoundaries", oAppointmentStartingBoundaries);
}
iVariableBoundaryY = oDragSession.getData("bottomHandle") ? oAppointmentStartingBoundaries.top : oAppointmentStartingBoundaries.bottom;
iTop = Math.min(iVariableBoundaryY, oDropTarget.offsetTop);
iBottom = Math.max(iVariableBoundaryY, oDropTarget.offsetTop + oDropTarget.getBoundingClientRect().height);
iHeight = iBottom - iTop;
mDraggedControlConfig = {
top: iTop,
height: iHeight,
"z-index": 1,
opacity: 0.8
};
oDragSession.getDragControl().$().css(mDraggedControlConfig);
if (!oDragSession.getIndicator()) {
setTimeout(fnHideIndicator, 0);
} else {
fnHideIndicator();
}
} | javascript | function(oEvent) {
var oDragSession = oEvent.getParameter("dragSession"),
oAppointmentRef = oDragSession.getDragControl().$().get(0),
oDropTarget = oDragSession.getDropControl().getDomRef(),
oAppointmentStartingBoundaries = oDragSession.getComplexData("appointmentStartingBoundaries"),
fnHideIndicator = function() {
var $Indicator = jQuery(oDragSession.getIndicator());
$Indicator.addClass("sapUiDnDIndicatorHide");
},
iTop,
iBottom,
iHeight,
iVariableBoundaryY,
mDraggedControlConfig;
if (!oAppointmentStartingBoundaries) {
oAppointmentStartingBoundaries = {
top: oAppointmentRef.offsetTop,
bottom: oAppointmentRef.offsetTop + oAppointmentRef.getBoundingClientRect().height,
height: oAppointmentRef.getBoundingClientRect().height
};
oDragSession.setComplexData("appointmentStartingBoundaries", oAppointmentStartingBoundaries);
}
iVariableBoundaryY = oDragSession.getData("bottomHandle") ? oAppointmentStartingBoundaries.top : oAppointmentStartingBoundaries.bottom;
iTop = Math.min(iVariableBoundaryY, oDropTarget.offsetTop);
iBottom = Math.max(iVariableBoundaryY, oDropTarget.offsetTop + oDropTarget.getBoundingClientRect().height);
iHeight = iBottom - iTop;
mDraggedControlConfig = {
top: iTop,
height: iHeight,
"z-index": 1,
opacity: 0.8
};
oDragSession.getDragControl().$().css(mDraggedControlConfig);
if (!oDragSession.getIndicator()) {
setTimeout(fnHideIndicator, 0);
} else {
fnHideIndicator();
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oDragSession",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"dragSession\"",
")",
",",
"oAppointmentRef",
"=",
"oDragSession",
".",
"getDragControl",
"(",
")",
".",
"$",
"(",
")",
".",
"get",
"(",
"0",
")",
",",... | Fired when a dragged appointment enters a drop target. | [
"Fired",
"when",
"a",
"dragged",
"appointment",
"enters",
"a",
"drop",
"target",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/SinglePlanningCalendarGrid.js#L597-L641 | train | Dragging of the drop control | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
1051,
7265,
5620,
7971,
3258,
1027,
1051,
18697,
3372,
1012,
2131,
28689,
22828,
1006,
1000,
8011,
8583,
10992,
1000,
1007,
1010,
1051,
29098,
25785,
3672,
2890,
2546,
1027,
1051,
726... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/semi-style.js | check | function check(semiToken, expected) {
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) {
context.report({
loc: semiToken.loc,
message: "Expected this semicolon to be at {{pos}}.",
data: {
pos: (expected === "last")
? "the end of the previous line"
: "the beginning of the next line"
},
fix(fixer) {
if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
return null;
}
const start = prevToken ? prevToken.range[1] : semiToken.range[0];
const end = nextToken ? nextToken.range[0] : semiToken.range[1];
const text = (expected === "last") ? ";\n" : "\n;";
return fixer.replaceTextRange([start, end], text);
}
});
}
} | javascript | function check(semiToken, expected) {
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const prevIsSameLine = !prevToken || astUtils.isTokenOnSameLine(prevToken, semiToken);
const nextIsSameLine = !nextToken || astUtils.isTokenOnSameLine(semiToken, nextToken);
if ((expected === "last" && !prevIsSameLine) || (expected === "first" && !nextIsSameLine)) {
context.report({
loc: semiToken.loc,
message: "Expected this semicolon to be at {{pos}}.",
data: {
pos: (expected === "last")
? "the end of the previous line"
: "the beginning of the next line"
},
fix(fixer) {
if (prevToken && nextToken && sourceCode.commentsExistBetween(prevToken, nextToken)) {
return null;
}
const start = prevToken ? prevToken.range[1] : semiToken.range[0];
const end = nextToken ? nextToken.range[0] : semiToken.range[1];
const text = (expected === "last") ? ";\n" : "\n;";
return fixer.replaceTextRange([start, end], text);
}
});
}
} | [
"function",
"check",
"(",
"semiToken",
",",
"expected",
")",
"{",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"semiToken",
")",
";",
"const",
"nextToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"semiToken",
")",
";",
"const",
... | Check the given semicolon token.
@param {Token} semiToken The semicolon token to check.
@param {"first"|"last"} expected The expected location to check.
@returns {void} | [
"Check",
"the",
"given",
"semicolon",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-style.js#L91-L119 | train | Check if a semicolon is at the end of the line | [
30522,
3853,
4638,
1006,
30524,
4783,
29278,
2063,
1006,
4100,
18715,
2368,
1007,
1025,
9530,
3367,
2279,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
2121,
1006,
4100,
18715,
2368,
1007,
1025,
9530,
3367,
3653,
11365,
215... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/ripple/ripple.js | InkRippleProvider | function InkRippleProvider () {
var isDisabledGlobally = false;
return {
disableInkRipple: disableInkRipple,
$get: function($injector) {
return { attach: attach };
/**
* @ngdoc method
* @name $mdInkRipple#attach
*
* @description
* Attaching given scope, element and options to inkRipple controller
*
* @param {object=} scope Scope within the current context
* @param {object=} element The element the ripple effect should be applied to
* @param {object=} options (Optional) Configuration options to override the defaultRipple configuration
* * `center` - Whether the ripple should start from the center of the container element
* * `dimBackground` - Whether the background should be dimmed with the ripple color
* * `colorElement` - The element the ripple should take its color from, defined by css property `color`
* * `fitRipple` - Whether the ripple should fill the element
*/
function attach (scope, element, options) {
if (isDisabledGlobally || element.controller('mdNoInk')) return angular.noop;
return $injector.instantiate(InkRippleCtrl, {
$scope: scope,
$element: element,
rippleOptions: options
});
}
}
};
/**
* @ngdoc method
* @name $mdInkRippleProvider#disableInkRipple
*
* @description
* A config-time method that, when called, disables ripples globally.
*/
function disableInkRipple () {
isDisabledGlobally = true;
}
} | javascript | function InkRippleProvider () {
var isDisabledGlobally = false;
return {
disableInkRipple: disableInkRipple,
$get: function($injector) {
return { attach: attach };
/**
* @ngdoc method
* @name $mdInkRipple#attach
*
* @description
* Attaching given scope, element and options to inkRipple controller
*
* @param {object=} scope Scope within the current context
* @param {object=} element The element the ripple effect should be applied to
* @param {object=} options (Optional) Configuration options to override the defaultRipple configuration
* * `center` - Whether the ripple should start from the center of the container element
* * `dimBackground` - Whether the background should be dimmed with the ripple color
* * `colorElement` - The element the ripple should take its color from, defined by css property `color`
* * `fitRipple` - Whether the ripple should fill the element
*/
function attach (scope, element, options) {
if (isDisabledGlobally || element.controller('mdNoInk')) return angular.noop;
return $injector.instantiate(InkRippleCtrl, {
$scope: scope,
$element: element,
rippleOptions: options
});
}
}
};
/**
* @ngdoc method
* @name $mdInkRippleProvider#disableInkRipple
*
* @description
* A config-time method that, when called, disables ripples globally.
*/
function disableInkRipple () {
isDisabledGlobally = true;
}
} | [
"function",
"InkRippleProvider",
"(",
")",
"{",
"var",
"isDisabledGlobally",
"=",
"false",
";",
"return",
"{",
"disableInkRipple",
":",
"disableInkRipple",
",",
"$get",
":",
"function",
"(",
"$injector",
")",
"{",
"return",
"{",
"attach",
":",
"attach",
"}",
... | @ngdoc service
@name $mdInkRipple
@module material.core.ripple
@description
`$mdInkRipple` is a service for adding ripples to any element.
@usage
<hljs lang="js">
app.factory('$myElementInkRipple', function($mdInkRipple) {
return {
attach: function (scope, element, options) {
return $mdInkRipple.attach(scope, element, angular.extend({
center: false,
dimBackground: true
}, options));
}
};
});
app.controller('myController', function ($scope, $element, $myElementInkRipple) {
$scope.onClick = function (ev) {
$myElementInkRipple.attach($scope, angular.element(ev.target), { center: true });
}
});
</hljs>
@ngdoc service
@name $mdInkRippleProvider
@module material.core.ripple
@description
If you want to disable ink ripples globally, for all components, you can call the
`disableInkRipple` method in your app's config.
@usage
<hljs lang="js">
app.config(function ($mdInkRippleProvider) {
$mdInkRippleProvider.disableInkRipple();
});
</hljs> | [
"@ngdoc",
"service",
"@name",
"$mdInkRipple",
"@module",
"material",
".",
"core",
".",
"ripple"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/ripple/ripple.js#L108-L152 | train | The InkRippleProvider provides a provider that can be used to configure the ripples. | [
30522,
3853,
10710,
29443,
10814,
21572,
17258,
2121,
1006,
1007,
1063,
13075,
2003,
10521,
3085,
2094,
23296,
16429,
3973,
1027,
6270,
1025,
2709,
1063,
4487,
19150,
19839,
29443,
10814,
1024,
4487,
19150,
19839,
29443,
10814,
1010,
1002,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/filesystem/impls/appshell/AppshellFileSystem.js | showSaveDialog | function showSaveDialog(title, initialPath, proposedNewFilename, callback) {
appshell.fs.showSaveDialog(title, initialPath, proposedNewFilename, _wrap(callback));
} | javascript | function showSaveDialog(title, initialPath, proposedNewFilename, callback) {
appshell.fs.showSaveDialog(title, initialPath, proposedNewFilename, _wrap(callback));
} | [
"function",
"showSaveDialog",
"(",
"title",
",",
"initialPath",
",",
"proposedNewFilename",
",",
"callback",
")",
"{",
"appshell",
".",
"fs",
".",
"showSaveDialog",
"(",
"title",
",",
"initialPath",
",",
"proposedNewFilename",
",",
"_wrap",
"(",
"callback",
")",... | Display a save-file dialog and call back asynchronously with either a
FileSystemError string or the path to which the user has chosen to save
the file. If the dialog is cancelled, the path string will be empty.
@param {string} title
@param {string} initialPath
@param {string} proposedNewFilename
@param {function(?string, string=)} callback | [
"Display",
"a",
"save",
"-",
"file",
"dialog",
"and",
"call",
"back",
"asynchronously",
"with",
"either",
"a",
"FileSystemError",
"string",
"or",
"the",
"path",
"to",
"which",
"the",
"user",
"has",
"chosen",
"to",
"save",
"the",
"file",
".",
"If",
"the",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L215-L217 | train | showSaveDialog - Shows a save dialog | [
30522,
3853,
3065,
10696,
27184,
8649,
1006,
2516,
1010,
3988,
15069,
1010,
3818,
2638,
2860,
8873,
20844,
4168,
1010,
2655,
5963,
1007,
1063,
18726,
18223,
1012,
1042,
2015,
1012,
3065,
10696,
27184,
8649,
1006,
2516,
1010,
3988,
15069,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oControl) {
var sContentDensity;
var aContentDensityStyleClasses = ["sapUiSizeCondensed", "sapUiSizeCompact", "sapUiSizeCozy"];
var fnGetContentDensity = function(sFnName, oObject) {
if (!oObject[sFnName]) {
return;
}
for (var i = 0; i < aContentDensityStyleClasses.length; i++) {
if (oObject[sFnName](aContentDensityStyleClasses[i])) {
return aContentDensityStyleClasses[i];
}
}
};
var $DomRef = oControl.$();
if ($DomRef.length > 0) {
// table was already rendered, check by DOM and return content density class
sContentDensity = fnGetContentDensity("hasClass", $DomRef);
} else {
sContentDensity = fnGetContentDensity("hasStyleClass", oControl);
}
if (sContentDensity) {
return sContentDensity;
}
// since the table was not yet rendered, traverse its parents:
// - to find a content density defined at control level
// - to find the first DOM reference and then check on DOM level
var oParentDomRef = null;
var oParent = oControl.getParent();
// the table might not have a parent at all.
if (oParent) {
// try to get the DOM Ref of the parent. It might be required to traverse the complete parent
// chain to find one parent which has DOM rendered, as it may happen that an element does not have
// a corresponding DOM Ref
do {
// if the content density is defined at control level, we can return it, no matter the control was already
// rendered. By the time it will be rendered, it will have that style class
sContentDensity = fnGetContentDensity("hasStyleClass", oParent);
if (sContentDensity) {
return sContentDensity;
}
// if there was no style class set at control level, we try to find the DOM reference. Using that
// DOM reference, we can easily check for the content density style class via the DOM. This allows us
// to include e.g. the body tag as well.
if (oParent.getDomRef) {
// for Controls and elements
oParentDomRef = oParent.getDomRef();
} else if (oParent.getRootNode) {
// for UIArea
oParentDomRef = oParent.getRootNode();
}
if (!oParentDomRef && oParent.getParent) {
oParent = oParent.getParent();
} else {
// make sure there is not endless loop if oParent has no getParent function
oParent = null;
}
} while (oParent && !oParentDomRef);
}
// if we found a DOM reference, check for content density
$DomRef = jQuery(oParentDomRef || document.body);
sContentDensity = fnGetContentDensity("hasClass", $DomRef.closest("." + aContentDensityStyleClasses.join(",.")));
return sContentDensity;
} | javascript | function(oControl) {
var sContentDensity;
var aContentDensityStyleClasses = ["sapUiSizeCondensed", "sapUiSizeCompact", "sapUiSizeCozy"];
var fnGetContentDensity = function(sFnName, oObject) {
if (!oObject[sFnName]) {
return;
}
for (var i = 0; i < aContentDensityStyleClasses.length; i++) {
if (oObject[sFnName](aContentDensityStyleClasses[i])) {
return aContentDensityStyleClasses[i];
}
}
};
var $DomRef = oControl.$();
if ($DomRef.length > 0) {
// table was already rendered, check by DOM and return content density class
sContentDensity = fnGetContentDensity("hasClass", $DomRef);
} else {
sContentDensity = fnGetContentDensity("hasStyleClass", oControl);
}
if (sContentDensity) {
return sContentDensity;
}
// since the table was not yet rendered, traverse its parents:
// - to find a content density defined at control level
// - to find the first DOM reference and then check on DOM level
var oParentDomRef = null;
var oParent = oControl.getParent();
// the table might not have a parent at all.
if (oParent) {
// try to get the DOM Ref of the parent. It might be required to traverse the complete parent
// chain to find one parent which has DOM rendered, as it may happen that an element does not have
// a corresponding DOM Ref
do {
// if the content density is defined at control level, we can return it, no matter the control was already
// rendered. By the time it will be rendered, it will have that style class
sContentDensity = fnGetContentDensity("hasStyleClass", oParent);
if (sContentDensity) {
return sContentDensity;
}
// if there was no style class set at control level, we try to find the DOM reference. Using that
// DOM reference, we can easily check for the content density style class via the DOM. This allows us
// to include e.g. the body tag as well.
if (oParent.getDomRef) {
// for Controls and elements
oParentDomRef = oParent.getDomRef();
} else if (oParent.getRootNode) {
// for UIArea
oParentDomRef = oParent.getRootNode();
}
if (!oParentDomRef && oParent.getParent) {
oParent = oParent.getParent();
} else {
// make sure there is not endless loop if oParent has no getParent function
oParent = null;
}
} while (oParent && !oParentDomRef);
}
// if we found a DOM reference, check for content density
$DomRef = jQuery(oParentDomRef || document.body);
sContentDensity = fnGetContentDensity("hasClass", $DomRef.closest("." + aContentDensityStyleClasses.join(",.")));
return sContentDensity;
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"sContentDensity",
";",
"var",
"aContentDensityStyleClasses",
"=",
"[",
"\"sapUiSizeCondensed\"",
",",
"\"sapUiSizeCompact\"",
",",
"\"sapUiSizeCozy\"",
"]",
";",
"var",
"fnGetContentDensity",
"=",
"function",
"(",
"sFnNam... | Returns the content density style class which is relevant for the given control. First it tries to find the
definition via the control API. While traversing the controls parents, it's tried to find the closest DOM
reference. If that is found, the check will use the DOM reference to find the closest content density style class
in the parent chain. This approach caters both use cases: content density defined at DOM and/or control level.
If at the same level, several style classes are defined, this is the priority:
sapUiSizeCompact, sapUiSizeCondensed, sapUiSizeCozy
@param {sap.ui.table.Table} oControl Instance of the table.
@returns {String | undefined} name of the content density style class or undefined if none was found. | [
"Returns",
"the",
"content",
"density",
"style",
"class",
"which",
"is",
"relevant",
"for",
"the",
"given",
"control",
".",
"First",
"it",
"tries",
"to",
"find",
"the",
"definition",
"via",
"the",
"control",
"API",
".",
"While",
"traversing",
"the",
"control... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L1030-L1101 | train | Returns the content density of the given control | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
8040,
28040,
3372,
4181,
17759,
1025,
13075,
9353,
28040,
3372,
4181,
17759,
21756,
2571,
26266,
2229,
1027,
1031,
1000,
20066,
27020,
4697,
8663,
4181,
6924,
1000,
1010,
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... | |
SheetJS/js-xlsx | xlsx.js | parse_lpstr | function parse_lpstr(blob, type, pad) {
var start = blob.l;
var str = blob.read_shift(0, 'lpstr-cp');
if(pad) while((blob.l - start) & 3) ++blob.l;
return str;
} | javascript | function parse_lpstr(blob, type, pad) {
var start = blob.l;
var str = blob.read_shift(0, 'lpstr-cp');
if(pad) while((blob.l - start) & 3) ++blob.l;
return str;
} | [
"function",
"parse_lpstr",
"(",
"blob",
",",
"type",
",",
"pad",
")",
"{",
"var",
"start",
"=",
"blob",
".",
"l",
";",
"var",
"str",
"=",
"blob",
".",
"read_shift",
"(",
"0",
",",
"'lpstr-cp'",
")",
";",
"if",
"(",
"pad",
")",
"while",
"(",
"(",
... | /* [MS-OSHARED] 2.3.3.1.4 Lpstr | [
"/",
"*",
"[",
"MS",
"-",
"OSHARED",
"]",
"2",
".",
"3",
".",
"3",
".",
"1",
".",
"4",
"Lpstr"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L4986-L4991 | train | Parse LPSTR | [
30522,
3853,
11968,
3366,
1035,
6948,
3367,
2099,
1006,
1038,
4135,
2497,
1010,
2828,
1010,
11687,
1007,
1063,
13075,
2707,
1027,
1038,
4135,
2497,
1012,
1048,
1025,
13075,
2358,
2099,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
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/PlanningCalendar.js | function (oEvent) {
var oDragSession = oEvent.getParameter("dragSession"),
sTargetElementId = this.getTargetElement(),
fnHideIndicator = function () {
var $Indicator = jQuery(oDragSession.getIndicator());
$Indicator.addClass("sapUiDnDIndicatorHide");
},
oDropRects = oDragSession.getDropControl().getDomRef().getBoundingClientRect(),
oRowRects = sap.ui.getCore().byId(sTargetElementId).getDomRef().getBoundingClientRect(),
mDraggedControlConfig = {
width: oDropRects.left + oDropRects.width - (oDragSession.getDragControl().$().position().left + oRowRects.left),
"min-width": Math.min(oDragSession.getDragControl().$().outerWidth(), oDragSession.getDropControl().$().outerWidth()),
"z-index": 1,
opacity: 0.8
};
oDragSession.getDragControl().$().css(mDraggedControlConfig);
if (!oDragSession.getIndicator()) {
setTimeout(fnHideIndicator, 0);
} else {
fnHideIndicator();
}
} | javascript | function (oEvent) {
var oDragSession = oEvent.getParameter("dragSession"),
sTargetElementId = this.getTargetElement(),
fnHideIndicator = function () {
var $Indicator = jQuery(oDragSession.getIndicator());
$Indicator.addClass("sapUiDnDIndicatorHide");
},
oDropRects = oDragSession.getDropControl().getDomRef().getBoundingClientRect(),
oRowRects = sap.ui.getCore().byId(sTargetElementId).getDomRef().getBoundingClientRect(),
mDraggedControlConfig = {
width: oDropRects.left + oDropRects.width - (oDragSession.getDragControl().$().position().left + oRowRects.left),
"min-width": Math.min(oDragSession.getDragControl().$().outerWidth(), oDragSession.getDropControl().$().outerWidth()),
"z-index": 1,
opacity: 0.8
};
oDragSession.getDragControl().$().css(mDraggedControlConfig);
if (!oDragSession.getIndicator()) {
setTimeout(fnHideIndicator, 0);
} else {
fnHideIndicator();
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oDragSession",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"dragSession\"",
")",
",",
"sTargetElementId",
"=",
"this",
".",
"getTargetElement",
"(",
")",
",",
"fnHideIndicator",
"=",
"function",
"(",
")",
"{",
"var... | Fired when a dragged appointment enters a drop target. | [
"Fired",
"when",
"a",
"dragged",
"appointment",
"enters",
"a",
"drop",
"target",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/PlanningCalendar.js#L3249-L3273 | train | Dragging the control | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
1051,
7265,
5620,
7971,
3258,
1027,
1051,
18697,
3372,
1012,
2131,
28689,
22828,
1006,
1000,
8011,
8583,
10992,
1000,
1007,
1010,
2732,
18150,
12260,
3672,
3593,
1027,
2023,
1012,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/api/v0.1/tags.js | doQuery | function doQuery(options) {
return models.Tag.findOne(options.data, _.omit(options, ['data']))
.then((model) => {
if (!model) {
return Promise.reject(new common.errors.NotFoundError({
message: common.i18n.t('errors.api.tags.tagNotFound')
}));
}
return {
tags: [urlsForTag(model.id, model.toJSON(options), options)]
};
});
} | javascript | function doQuery(options) {
return models.Tag.findOne(options.data, _.omit(options, ['data']))
.then((model) => {
if (!model) {
return Promise.reject(new common.errors.NotFoundError({
message: common.i18n.t('errors.api.tags.tagNotFound')
}));
}
return {
tags: [urlsForTag(model.id, model.toJSON(options), options)]
};
});
} | [
"function",
"doQuery",
"(",
"options",
")",
"{",
"return",
"models",
".",
"Tag",
".",
"findOne",
"(",
"options",
".",
"data",
",",
"_",
".",
"omit",
"(",
"options",
",",
"[",
"'data'",
"]",
")",
")",
".",
"then",
"(",
"(",
"model",
")",
"=>",
"{"... | ### Model Query
Make the call to the Model layer
@param {Object} options
@returns {Object} options | [
"###",
"Model",
"Query",
"Make",
"the",
"call",
"to",
"the",
"Model",
"layer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/tags.js#L74-L87 | train | Query for a tag | [
30522,
3853,
2079,
4226,
2854,
1006,
7047,
1007,
1063,
2709,
4275,
1012,
6415,
1012,
2424,
5643,
1006,
7047,
1012,
2951,
1010,
1035,
1012,
18168,
4183,
1006,
7047,
1010,
1031,
1005,
2951,
1005,
1033,
1007,
1007,
1012,
2059,
1006,
1006,
29... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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() {
var args = arguments;
var sc = args[0], so = args[1], ec = sc, eo = so;
switch (args.length) {
case 3:
eo = args[2];
break;
case 4:
ec = args[2];
eo = args[3];
break;
}
boundaryUpdater(this, sc, so, ec, eo);
} | javascript | function() {
var args = arguments;
var sc = args[0], so = args[1], ec = sc, eo = so;
switch (args.length) {
case 3:
eo = args[2];
break;
case 4:
ec = args[2];
eo = args[3];
break;
}
boundaryUpdater(this, sc, so, ec, eo);
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"var",
"sc",
"=",
"args",
"[",
"0",
"]",
",",
"so",
"=",
"args",
"[",
"1",
"]",
",",
"ec",
"=",
"sc",
",",
"eo",
"=",
"so",
";",
"switch",
"(",
"args",
".",
"length",
")",
"{"... | Convenience method to set a range's start and end boundaries. Overloaded as follows:
- Two parameters (node, offset) creates a collapsed range at that position
- Three parameters (node, startOffset, endOffset) creates a range contained with node starting at
startOffset and ending at endOffset
- Four parameters (startNode, startOffset, endNode, endOffset) creates a range starting at startOffset in
startNode and ending at endOffset in endNode | [
"Convenience",
"method",
"to",
"set",
"a",
"range",
"s",
"start",
"and",
"end",
"boundaries",
".",
"Overloaded",
"as",
"follows",
":",
"-",
"Two",
"parameters",
"(",
"node",
"offset",
")",
"creates",
"a",
"collapsed",
"range",
"at",
"that",
"position",
"-"... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L1968-L1983 | train | Updates the boundary of the connection | [
30522,
3853,
1006,
1007,
1063,
13075,
12098,
5620,
1027,
9918,
1025,
13075,
8040,
1027,
12098,
5620,
1031,
1014,
1033,
1010,
2061,
1027,
12098,
5620,
1031,
1015,
1033,
1010,
14925,
1027,
8040,
1010,
1041,
2080,
1027,
2061,
1025,
6942,
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... | |
moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketRequest | function PacketRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketRequest",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",
... | Properties of a PacketRequest.
@memberof packets
@interface IPacketRequest
@property {string} ver PacketRequest ver
@property {string} sender PacketRequest sender
@property {string} id PacketRequest id
@property {string} action PacketRequest action
@property {Uint8Array|null} [params] PacketRequest params
@property {string} meta PacketRequest meta
@property {number} timeout PacketRequest timeout
@property {number} level PacketRequest level
@property {boolean|null} [metrics] PacketRequest metrics
@property {string|null} [parentID] PacketRequest parentID
@property {string|null} [requestID] PacketRequest requestID
@property {boolean|null} [stream] PacketRequest stream
Constructs a new PacketRequest.
@memberof packets
@classdesc Represents a PacketRequest.
@implements IPacketRequest
@constructor
@param {packets.IPacketRequest=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketRequest",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L365-L370 | train | Properties of a PacketRequest. | [
30522,
3853,
14771,
2890,
15500,
1006,
5144,
1007,
1063,
2065,
1006,
5144,
1007,
2005,
1006,
13075,
6309,
1027,
4874,
1012,
6309,
1006,
5144,
1007,
1010,
1045,
1027,
1014,
1025,
1045,
1026,
6309,
1012,
3091,
1025,
1009,
1009,
1045,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | removeGutters | function removeGutters(editor) {
Editor.unregisterGutter(GUTTER_NAME);
$(editor.getRootElement()).removeClass("folding-enabled");
CodeMirror.defineOption("foldGutter", false, null);
} | javascript | function removeGutters(editor) {
Editor.unregisterGutter(GUTTER_NAME);
$(editor.getRootElement()).removeClass("folding-enabled");
CodeMirror.defineOption("foldGutter", false, null);
} | [
"function",
"removeGutters",
"(",
"editor",
")",
"{",
"Editor",
".",
"unregisterGutter",
"(",
"GUTTER_NAME",
")",
";",
"$",
"(",
"editor",
".",
"getRootElement",
"(",
")",
")",
".",
"removeClass",
"(",
"\"folding-enabled\"",
")",
";",
"CodeMirror",
".",
"def... | Remove the fold gutter for a given CodeMirror instance.
@param {Editor} editor the editor instance whose gutter should be removed | [
"Remove",
"the",
"fold",
"gutter",
"for",
"a",
"given",
"CodeMirror",
"instance",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L315-L319 | train | Removes the fold gutter from the editor | [
30522,
3853,
6366,
27920,
7747,
1006,
3559,
1007,
1063,
3559,
1012,
4895,
2890,
24063,
2121,
27920,
3334,
1006,
9535,
3334,
1035,
2171,
1007,
1025,
1002,
1006,
3559,
1012,
2131,
3217,
12184,
16930,
4765,
1006,
1007,
1007,
1012,
6366,
26266,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-extra-parens.js | hasExcessParensNoLineTerminator | function hasExcessParensNoLineTerminator(token, node) {
if (token.loc.end.line === node.loc.start.line) {
return hasExcessParens(node);
}
return hasDoubleExcessParens(node);
} | javascript | function hasExcessParensNoLineTerminator(token, node) {
if (token.loc.end.line === node.loc.start.line) {
return hasExcessParens(node);
}
return hasDoubleExcessParens(node);
} | [
"function",
"hasExcessParensNoLineTerminator",
"(",
"token",
",",
"node",
")",
"{",
"if",
"(",
"token",
".",
"loc",
".",
"end",
".",
"line",
"===",
"node",
".",
"loc",
".",
"start",
".",
"line",
")",
"{",
"return",
"hasExcessParens",
"(",
"node",
")",
... | Determines if a node following a [no LineTerminator here] restriction is
surrounded by (potentially) invalid extra parentheses.
@param {Token} token - The token preceding the [no LineTerminator here] restriction.
@param {ASTNode} node - The node to be checked.
@returns {boolean} True if the node is incorrectly parenthesised.
@private | [
"Determines",
"if",
"a",
"node",
"following",
"a",
"[",
"no",
"LineTerminator",
"here",
"]",
"restriction",
"is",
"surrounded",
"by",
"(",
"potentially",
")",
"invalid",
"extra",
"parentheses",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L248-L254 | train | Check if the node has excess parentheses | [
30522,
3853,
2038,
10288,
9623,
27694,
6132,
3630,
4179,
3334,
22311,
4263,
1006,
19204,
1010,
13045,
1007,
1063,
2065,
1006,
19204,
1012,
8840,
2278,
1012,
2203,
1012,
2240,
1027,
1027,
1027,
13045,
1012,
8840,
2278,
1012,
2707,
1012,
2240... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/multiline-comment-style.js | isJSDoc | function isJSDoc(commentGroup) {
const lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
return commentGroup[0].type === "Block" &&
/^\*\s*$/u.test(lines[0]) &&
lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&
/^\s*$/u.test(lines[lines.length - 1]);
} | javascript | function isJSDoc(commentGroup) {
const lines = commentGroup[0].value.split(astUtils.LINEBREAK_MATCHER);
return commentGroup[0].type === "Block" &&
/^\*\s*$/u.test(lines[0]) &&
lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&
/^\s*$/u.test(lines[lines.length - 1]);
} | [
"function",
"isJSDoc",
"(",
"commentGroup",
")",
"{",
"const",
"lines",
"=",
"commentGroup",
"[",
"0",
"]",
".",
"value",
".",
"split",
"(",
"astUtils",
".",
"LINEBREAK_MATCHER",
")",
";",
"return",
"commentGroup",
"[",
"0",
"]",
".",
"type",
"===",
"\"B... | Check a comment is JSDoc form
@param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment
@returns {boolean} if commentGroup is JSDoc form, return true | [
"Check",
"a",
"comment",
"is",
"JSDoc",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L102-L109 | train | Check if comment is JSDoc | [
30522,
3853,
2003,
22578,
3527,
2278,
1006,
7615,
17058,
1007,
1063,
9530,
3367,
3210,
1027,
7615,
17058,
1031,
1014,
1033,
1012,
3643,
1012,
3975,
1006,
2004,
8525,
3775,
4877,
1012,
2240,
23890,
1035,
2674,
2121,
1007,
1025,
2709,
7615,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | bindEvent | function bindEvent ( namespacedEvent, callback ) {
scope_Events[namespacedEvent] = scope_Events[namespacedEvent] || [];
scope_Events[namespacedEvent].push(callback);
// If the event bound is 'update,' fire it immediately for all handles.
if ( namespacedEvent.split('.')[0] === 'update' ) {
scope_Handles.forEach(function(a, index){
fireEvent('update', index);
});
}
} | javascript | function bindEvent ( namespacedEvent, callback ) {
scope_Events[namespacedEvent] = scope_Events[namespacedEvent] || [];
scope_Events[namespacedEvent].push(callback);
// If the event bound is 'update,' fire it immediately for all handles.
if ( namespacedEvent.split('.')[0] === 'update' ) {
scope_Handles.forEach(function(a, index){
fireEvent('update', index);
});
}
} | [
"function",
"bindEvent",
"(",
"namespacedEvent",
",",
"callback",
")",
"{",
"scope_Events",
"[",
"namespacedEvent",
"]",
"=",
"scope_Events",
"[",
"namespacedEvent",
"]",
"||",
"[",
"]",
";",
"scope_Events",
"[",
"namespacedEvent",
"]",
".",
"push",
"(",
"call... | Attach an event to this slider, possibly including a namespace | [
"Attach",
"an",
"event",
"to",
"this",
"slider",
"possibly",
"including",
"a",
"namespace"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L2007-L2017 | train | Bind event to all handles | [
30522,
3853,
14187,
18697,
3372,
1006,
3415,
15327,
24844,
4765,
1010,
2655,
5963,
1007,
1063,
9531,
1035,
2824,
1031,
3415,
15327,
24844,
4765,
1033,
1027,
9531,
1035,
2824,
1031,
3415,
15327,
24844,
4765,
1033,
1064,
1064,
1031,
1033,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
radare/radare2 | shlr/www/d3/packages.js | function(nodes) {
var map = {},
imports = [];
// Compute a map from name to node.
nodes.forEach(function(d) {
map[d.name] = d;
});
// For each import, construct a link from the source to target node.
nodes.forEach(function(d) {
if (d.imports) d.imports.forEach(function(i) {
imports.push({source: map[d.name], target: map[i]});
});
});
return imports;
} | javascript | function(nodes) {
var map = {},
imports = [];
// Compute a map from name to node.
nodes.forEach(function(d) {
map[d.name] = d;
});
// For each import, construct a link from the source to target node.
nodes.forEach(function(d) {
if (d.imports) d.imports.forEach(function(i) {
imports.push({source: map[d.name], target: map[i]});
});
});
return imports;
} | [
"function",
"(",
"nodes",
")",
"{",
"var",
"map",
"=",
"{",
"}",
",",
"imports",
"=",
"[",
"]",
";",
"// Compute a map from name to node.",
"nodes",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"map",
"[",
"d",
".",
"name",
"]",
"=",
"d",
"... | Return a list of imports for the given array of nodes. | [
"Return",
"a",
"list",
"of",
"imports",
"for",
"the",
"given",
"array",
"of",
"nodes",
"."
] | bf5e3028810a0ec7c267c6fe4bfad639b4819e35 | https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/d3/packages.js#L29-L46 | train | Returns an array of imports for the given nodes | [
30522,
3853,
1006,
14164,
1007,
1063,
13075,
4949,
1027,
1063,
1065,
1010,
17589,
1027,
1031,
1033,
1025,
1013,
1013,
24134,
1037,
4949,
2013,
2171,
2000,
13045,
1012,
14164,
1012,
18921,
6776,
1006,
3853,
1006,
1040,
1007,
1063,
4949,
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... | |
websockets/ws | lib/buffer-util.js | _unmask | function _unmask(buffer, mask) {
// Required until https://github.com/nodejs/node/issues/9006 is resolved.
const length = buffer.length;
for (let i = 0; i < length; i++) {
buffer[i] ^= mask[i & 3];
}
} | javascript | function _unmask(buffer, mask) {
// Required until https://github.com/nodejs/node/issues/9006 is resolved.
const length = buffer.length;
for (let i = 0; i < length; i++) {
buffer[i] ^= mask[i & 3];
}
} | [
"function",
"_unmask",
"(",
"buffer",
",",
"mask",
")",
"{",
"// Required until https://github.com/nodejs/node/issues/9006 is resolved.",
"const",
"length",
"=",
"buffer",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
... | Unmasks a buffer using the given mask.
@param {Buffer} buffer The buffer to unmask
@param {Buffer} mask The mask to use
@public | [
"Unmasks",
"a",
"buffer",
"using",
"the",
"given",
"mask",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/buffer-util.js#L52-L58 | train | Unmasks a buffer using the given mask. | [
30522,
3853,
1035,
4895,
9335,
2243,
1006,
17698,
1010,
7308,
1007,
1063,
1013,
1013,
3223,
2127,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
13045,
22578,
1013,
13045,
1013,
3314,
1013,
7706,
2575,
2003,
10395,
1012,
953... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-compiler/util/CodeMarker.js | postProcess | function postProcess(json: string, printModule: string => string): string {
return json.replace(
/"@@MODULE_START@@(.*?)@@MODULE_END@@"/g,
(_, moduleName) => printModule(moduleName),
);
} | javascript | function postProcess(json: string, printModule: string => string): string {
return json.replace(
/"@@MODULE_START@@(.*?)@@MODULE_END@@"/g,
(_, moduleName) => printModule(moduleName),
);
} | [
"function",
"postProcess",
"(",
"json",
":",
"string",
",",
"printModule",
":",
"string",
"=",
">",
"string",
")",
":",
"string",
"{",
"return",
"json",
".",
"replace",
"(",
"/",
"\"@@MODULE_START@@(.*?)@@MODULE_END@@\"",
"/",
"g",
",",
"(",
"_",
",",
"mod... | After JSON.stringify'ing some code that contained parts marked with `mark()`,
this post-processes the JSON to convert the marked code strings to raw code.
Example:
CodeMarker.postProcess(
JSON.stringify({code: CodeMarker.mark('alert(1)')})
) | [
"After",
"JSON",
".",
"stringify",
"ing",
"some",
"code",
"that",
"contained",
"parts",
"marked",
"with",
"mark",
"()",
"this",
"post",
"-",
"processes",
"the",
"JSON",
"to",
"convert",
"the",
"marked",
"code",
"strings",
"to",
"raw",
"code",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/util/CodeMarker.js#L29-L34 | train | Post process a json string | [
30522,
3853,
2695,
21572,
9623,
2015,
1006,
1046,
3385,
1024,
5164,
1010,
6140,
5302,
8566,
2571,
1024,
5164,
1027,
1028,
5164,
1007,
1024,
5164,
1063,
2709,
1046,
3385,
1012,
5672,
1006,
1013,
1000,
1030,
1030,
11336,
1035,
2707,
1030,
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... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(textRange) {
var parentEl = textRange.parentElement();
var range = textRange.duplicate();
range.collapse(true);
var startEl = range.parentElement();
range = textRange.duplicate();
range.collapse(false);
var endEl = range.parentElement();
var startEndContainer = (startEl == endEl) ? startEl : dom.getCommonAncestor(startEl, endEl);
return startEndContainer == parentEl ? startEndContainer : dom.getCommonAncestor(parentEl, startEndContainer);
} | javascript | function(textRange) {
var parentEl = textRange.parentElement();
var range = textRange.duplicate();
range.collapse(true);
var startEl = range.parentElement();
range = textRange.duplicate();
range.collapse(false);
var endEl = range.parentElement();
var startEndContainer = (startEl == endEl) ? startEl : dom.getCommonAncestor(startEl, endEl);
return startEndContainer == parentEl ? startEndContainer : dom.getCommonAncestor(parentEl, startEndContainer);
} | [
"function",
"(",
"textRange",
")",
"{",
"var",
"parentEl",
"=",
"textRange",
".",
"parentElement",
"(",
")",
";",
"var",
"range",
"=",
"textRange",
".",
"duplicate",
"(",
")",
";",
"range",
".",
"collapse",
"(",
"true",
")",
";",
"var",
"startEl",
"=",... | /*
This is a workaround for a bug where IE returns the wrong container element from the TextRange's parentElement()
method. For example, in the following (where pipes denote the selection boundaries):
<ul id="ul"><li id="a">| a </li><li id="b"> b |</li></ul>
var range = document.selection.createRange();
alert(range.parentElement().id); // Should alert "ul" but alerts "b"
This method returns the common ancestor node of the following:
- the parentElement() of the textRange
- the parentElement() of the textRange after calling collapse(true)
- the parentElement() of the textRange after calling collapse(false) | [
"/",
"*",
"This",
"is",
"a",
"workaround",
"for",
"a",
"bug",
"where",
"IE",
"returns",
"the",
"wrong",
"container",
"element",
"from",
"the",
"TextRange",
"s",
"parentElement",
"()",
"method",
".",
"For",
"example",
"in",
"the",
"following",
"(",
"where",... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L2461-L2472 | train | Returns the parent element of the text range | [
30522,
3853,
1006,
3793,
24388,
2063,
1007,
1063,
13075,
6687,
2884,
1027,
3793,
24388,
2063,
1012,
6687,
12260,
3672,
1006,
1007,
1025,
13075,
2846,
1027,
3793,
24388,
2063,
1012,
24473,
1006,
1007,
1025,
2846,
1012,
7859,
1006,
2995,
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/base/ManagedObjectMetadata.js | Property | function Property(oClass, name, info) {
info = typeof info !== 'object' ? { type: info } : info;
this.name = name;
this.type = info.type || 'string';
this.group = info.group || 'Misc';
this.defaultValue = info.defaultValue !== null ? info.defaultValue : null;
this.bindable = !!info.bindable;
this.deprecated = !!info.deprecated || false;
this.visibility = info.visibility || 'public';
this.byValue = info.byValue === true; // non-boolean values reserved for the future
this.selector = typeof info.selector === "string" ? info.selector : null;
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = name;
this._iKind = Kind.PROPERTY;
var N = capitalize(name);
this._sMutator = 'set' + N;
this._sGetter = 'get' + N;
if ( this.bindable ) {
this._sBind = 'bind' + N;
this._sUnbind = 'unbind' + N;
} else {
this._sBind =
this._sUnbind = undefined;
}
this._oType = null;
} | javascript | function Property(oClass, name, info) {
info = typeof info !== 'object' ? { type: info } : info;
this.name = name;
this.type = info.type || 'string';
this.group = info.group || 'Misc';
this.defaultValue = info.defaultValue !== null ? info.defaultValue : null;
this.bindable = !!info.bindable;
this.deprecated = !!info.deprecated || false;
this.visibility = info.visibility || 'public';
this.byValue = info.byValue === true; // non-boolean values reserved for the future
this.selector = typeof info.selector === "string" ? info.selector : null;
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = name;
this._iKind = Kind.PROPERTY;
var N = capitalize(name);
this._sMutator = 'set' + N;
this._sGetter = 'get' + N;
if ( this.bindable ) {
this._sBind = 'bind' + N;
this._sUnbind = 'unbind' + N;
} else {
this._sBind =
this._sUnbind = undefined;
}
this._oType = null;
} | [
"function",
"Property",
"(",
"oClass",
",",
"name",
",",
"info",
")",
"{",
"info",
"=",
"typeof",
"info",
"!==",
"'object'",
"?",
"{",
"type",
":",
"info",
"}",
":",
"info",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"type",
"=",
"i... | ---- Property --------------------------------------------------------------------------
Property info object
@private
@since 1.27.1 | [
"----",
"Property",
"--------------------------------------------------------------------------",
"Property",
"info",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js#L169-L195 | train | Constructor for a property | [
30522,
3853,
3200,
1006,
1051,
26266,
1010,
2171,
1010,
18558,
1007,
1063,
18558,
1027,
2828,
11253,
18558,
999,
1027,
1027,
1005,
4874,
1005,
1029,
1063,
2828,
1024,
18558,
1065,
1024,
18558,
1025,
2023,
1012,
2171,
1027,
2171,
1025,
2023,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | _removeFileFromMRU | function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | javascript | function _removeFileFromMRU(paneId, file) {
var index,
compare = function (record) {
return (record.file === file && record.paneId === paneId);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | [
"function",
"_removeFileFromMRU",
"(",
"paneId",
",",
"file",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
"===",
"file",
"&&",
"record",
".",
"paneId",
"===",
"paneId",
")",
... | Removes a file from the global MRU list. Future versions of this
implementation may support the ALL_PANES constant but FOCUS_PANE is not allowed
@param {!string} paneId - Must be a valid paneId (not a shortcut e.g. ALL_PANES)
@ @param {File} file The file object to remove.
@private | [
"Removes",
"a",
"file",
"from",
"the",
"global",
"MRU",
"list",
".",
"Future",
"versions",
"of",
"this",
"implementation",
"may",
"support",
"the",
"ALL_PANES",
"constant",
"but",
"FOCUS_PANE",
"is",
"not",
"allowed"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L781-L794 | train | Remove a file from the MRU | [
30522,
3853,
1035,
6366,
8873,
2571,
19699,
5358,
2213,
6820,
1006,
6090,
7416,
2094,
1010,
5371,
1007,
1063,
13075,
5950,
1010,
12826,
1027,
3853,
1006,
2501,
1007,
1063,
2709,
1006,
2501,
1012,
5371,
1027,
1027,
1027,
5371,
1004,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oEntityType, mChildAnnotations) {
Utils.visitChildren(oEntityType.property, mChildAnnotations, "Property");
Utils.visitChildren(oEntityType.navigationProperty, mChildAnnotations);
Utils.addSapSemantics(oEntityType);
} | javascript | function (oEntityType, mChildAnnotations) {
Utils.visitChildren(oEntityType.property, mChildAnnotations, "Property");
Utils.visitChildren(oEntityType.navigationProperty, mChildAnnotations);
Utils.addSapSemantics(oEntityType);
} | [
"function",
"(",
"oEntityType",
",",
"mChildAnnotations",
")",
"{",
"Utils",
".",
"visitChildren",
"(",
"oEntityType",
".",
"property",
",",
"mChildAnnotations",
",",
"\"Property\"",
")",
";",
"Utils",
".",
"visitChildren",
"(",
"oEntityType",
".",
"navigationProp... | Visits the given entity type and its (structural or navigation) properties.
@param {object} oEntityType
the entity type
@param {object} mChildAnnotations
map from child name (or role) to annotations | [
"Visits",
"the",
"given",
"entity",
"type",
"and",
"its",
"(",
"structural",
"or",
"navigation",
")",
"properties",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L1061-L1065 | train | visit the entity type | [
30522,
3853,
1006,
1051,
4765,
3012,
13874,
1010,
11338,
19466,
7847,
17048,
10708,
1007,
1063,
21183,
12146,
1012,
3942,
19339,
7389,
1006,
1051,
4765,
3012,
13874,
1012,
3200,
1010,
11338,
19466,
7847,
17048,
10708,
1010,
1000,
3200,
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... | |
airyland/vux | src/components/orientation/orientation.js | function (cfg) {
this._cfg = merge({
delay: 400
}, cfg)
// 事件订阅数组
this._subs = {
on: [],
after: []
}
// 当前信息
this.info = this.getInfo()
// 绑定事件回调上下文
this._onWinOrientationChange = bind(this._onWinOrientationChange, this)
// 绑定窗口切换事件
window.addEventListener(EVT_ORIENTATION_CHANGE, this._onWinOrientationChange, false)
} | javascript | function (cfg) {
this._cfg = merge({
delay: 400
}, cfg)
// 事件订阅数组
this._subs = {
on: [],
after: []
}
// 当前信息
this.info = this.getInfo()
// 绑定事件回调上下文
this._onWinOrientationChange = bind(this._onWinOrientationChange, this)
// 绑定窗口切换事件
window.addEventListener(EVT_ORIENTATION_CHANGE, this._onWinOrientationChange, false)
} | [
"function",
"(",
"cfg",
")",
"{",
"this",
".",
"_cfg",
"=",
"merge",
"(",
"{",
"delay",
":",
"400",
"}",
",",
"cfg",
")",
"// 事件订阅数组",
"this",
".",
"_subs",
"=",
"{",
"on",
":",
"[",
"]",
",",
"after",
":",
"[",
"]",
"}",
"// 当前信息",
"this",
"... | 初始化
@method init
@public | [
"初始化"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/orientation/orientation.js#L79-L98 | train | Initialize the
| [
30522,
3853,
1006,
12935,
2290,
1007,
1063,
2023,
1012,
1035,
12935,
2290,
1027,
13590,
1006,
1063,
8536,
1024,
4278,
1065,
1010,
12935,
2290,
1007,
1013,
1013,
30524,
100,
1822,
1751,
100,
100,
100,
1742,
1743,
1861,
2023,
1012,
1035,
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... | |
google/closure-library | closure/goog/html/cssspecificity.js | getSpecificity | function getSpecificity(selector) {
if (userAgentProduct.IE && !userAgent.isVersionOrHigher(9)) {
// IE8 has buggy regex support.
return [0, 0, 0, 0];
}
var specificity = specificityCache.hasOwnProperty(selector) ?
specificityCache[selector] :
null;
if (specificity) {
return specificity;
}
if (Object.keys(specificityCache).length > (1 << 16)) {
// Limit the size of cache to (1 << 16) == 65536. Normally HTML pages don't
// have such numbers of selectors.
specificityCache = {};
}
specificity = calculateSpecificity(selector);
specificityCache[selector] = specificity;
return specificity;
} | javascript | function getSpecificity(selector) {
if (userAgentProduct.IE && !userAgent.isVersionOrHigher(9)) {
// IE8 has buggy regex support.
return [0, 0, 0, 0];
}
var specificity = specificityCache.hasOwnProperty(selector) ?
specificityCache[selector] :
null;
if (specificity) {
return specificity;
}
if (Object.keys(specificityCache).length > (1 << 16)) {
// Limit the size of cache to (1 << 16) == 65536. Normally HTML pages don't
// have such numbers of selectors.
specificityCache = {};
}
specificity = calculateSpecificity(selector);
specificityCache[selector] = specificity;
return specificity;
} | [
"function",
"getSpecificity",
"(",
"selector",
")",
"{",
"if",
"(",
"userAgentProduct",
".",
"IE",
"&&",
"!",
"userAgent",
".",
"isVersionOrHigher",
"(",
"9",
")",
")",
"{",
"// IE8 has buggy regex support.",
"return",
"[",
"0",
",",
"0",
",",
"0",
",",
"0... | Calculates the specificity of CSS selectors, using a global cache if
supported.
@see http://www.w3.org/TR/css3-selectors/#specificity
@see https://specificity.keegan.st/
@param {string} selector The CSS selector.
@return {!Array<number>} The CSS specificity.
@supported IE9+, other browsers. | [
"Calculates",
"the",
"specificity",
"of",
"CSS",
"selectors",
"using",
"a",
"global",
"cache",
"if",
"supported",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/cssspecificity.js#L39-L58 | train | Returns the specificity of a selector. | [
30522,
3853,
4152,
5051,
6895,
8873,
12972,
1006,
27000,
1007,
1063,
2065,
1006,
5310,
4270,
3372,
21572,
8566,
6593,
1012,
29464,
1004,
1004,
999,
5310,
4270,
3372,
1012,
2003,
27774,
2953,
4048,
5603,
2121,
1006,
1023,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | setLayoutScheme | function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
} | javascript | function setLayoutScheme(rows, columns) {
if ((rows < 1) || (rows > 2) || (columns < 1) || (columns > 2) || (columns === 2 && rows === 2)) {
console.error("setLayoutScheme unsupported layout " + rows + ", " + columns);
return false;
}
if (rows === columns) {
_mergePanes();
} else if (rows > columns) {
_doSplit(HORIZONTAL);
} else {
_doSplit(VERTICAL);
}
return true;
} | [
"function",
"setLayoutScheme",
"(",
"rows",
",",
"columns",
")",
"{",
"if",
"(",
"(",
"rows",
"<",
"1",
")",
"||",
"(",
"rows",
">",
"2",
")",
"||",
"(",
"columns",
"<",
"1",
")",
"||",
"(",
"columns",
">",
"2",
")",
"||",
"(",
"columns",
"==="... | Changes the layout scheme
@param {!number} rows (may be 1 or 2)
@param {!number} columns (may be 1 or 2)
@summay Rows or Columns may be 1 or 2 but both cannot be 2. 1x2, 2x1 or 1x1 are the legal values | [
"Changes",
"the",
"layout",
"scheme"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1647-L1661 | train | set layout scheme | [
30522,
3853,
2275,
8485,
12166,
5403,
4168,
1006,
10281,
1010,
7753,
1007,
1063,
2065,
1006,
1006,
10281,
1026,
1015,
1007,
1064,
1064,
1006,
10281,
1028,
1016,
1007,
1064,
1064,
1006,
7753,
1026,
1015,
1007,
1064,
1064,
1006,
7753,
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... |
SeleniumHQ/selenium | javascript/node/optparse.js | OptionParser | function OptionParser() {
/** @type {string} */
var usage = OptionParser.DEFAULT_USAGE;
/** @type {boolean} */
var mustParse = true;
/** @type {!Object.<*>} */
var parsedOptions = {};
/** @type {!Array.<string>} */
var extraArgs = [];
/**
* Sets the usage string. All occurences of "$0" will be replaced with the
* current executable's name.
* @param {string} usageStr The new usage string.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.usage = function(usageStr) {
mustParse = true;
usage = usageStr;
return this;
};
/**
* @type {!Object.<{
* help: string,
* parse: function(string): *,
* required: boolean,
* list: boolean,
* callback: function(*),
* default: *
* }>}
*/
var options = {};
/**
* Adds a new option to this parser.
* @param {string} name The name of the option.
* @param {function(string): *} parseFn The function to use for parsing the
* option. If this function has a "default" property, it will be used as
* the default value for the option if it was not provided on the command
* line. If not specified, the default value will be undefined. The
* default value may be overrideden using the "default" property in the
* option spec.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.addOption = function(name, parseFn, opt_spec) {
checkOptionName(name, options);
var spec = opt_spec || {};
// Quoted notation for "default" to bypass annoying IDE syntax bug.
var defaultValue = spec['default'] ||
(!!spec.list ? [] : parseFn['default']);
options[name] = {
help: spec.help || '',
parse: parseFn,
required: !!spec.required,
list: !!spec.list,
callback: spec.callback || function() {},
'default': defaultValue
};
mustParse = true;
return this;
};
/**
* Defines a boolean option. Option values may be one of {'', 'true', 'false',
* '0', '1'}. In the case of the empty string (''), the option value will be
* set to true.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.boolean = function(name, opt_spec) {
return this.addOption(name, parseBoolean, opt_spec);
};
/**
* Defines a numeric option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.number = function(name, opt_spec) {
return this.addOption(name, parseNumber, opt_spec);
};
/**
* Defines a path option. Each path will be resolved relative to the
* current workin directory, if not absolute.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.path = function(name, opt_spec) {
return this.addOption(name, path.resolve, opt_spec);
};
/**
* Defines a basic string option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.string = function(name, opt_spec) {
return this.addOption(name, parseString, opt_spec);
};
/**
* Defines a regular expression based option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.regex = function(name, opt_spec) {
return this.addOption(name, parseRegex, opt_spec);
};
/**
* Returns the parsed command line options.
*
* <p>The command line arguments will be re-parsed if this parser's
* configuration has changed since the last access.
*
* @return {!Object.<*>} The parsed options.
*/
this.__defineGetter__('options', function() {
parse();
return parsedOptions;
});
/**
* Returns the remaining command line arguments after all options have been
* parsed.
*
* <p>The command line arguments will be re-parsed if this parser's
* configuration has changed since the last access.
*
* @return {!Array.<string>} The remaining command line arguments.
*/
this.__defineGetter__('argv', function() {
parse();
return extraArgs;
});
/**
* Parses a list of arguments. After parsing, the options property of this
* object will contain the value for each parsed flags, and the argv
* property will contain all remaining command line arguments.
* @throws {Error} If the arguments could not be parsed.
*/
this.parse = parse;
/**
* Returns a formatted help message for this parser.
* @return {string} The help message for this parser.
*/
this.getHelpMsg = getHelpMsg;
function getHelpMsg() {
return formatHelpMsg(usage, options);
}
function parse() {
if (!mustParse) {
return;
}
parsedOptions = {};
extraArgs = [];
var args = process.argv.slice(2);
var n = args.length;
try {
for (var i = 0; i < n; ++i) {
var arg = args[i];
if (arg === '--') {
extraArgs = args.slice(i + 1);
break;
}
var match = arg.match(OPTION_FLAG_REGEX);
if (match) {
// Special case --help.
if (match[1] === 'help') {
printHelpAndDie('', 0);
}
parseOption(match);
} else {
extraArgs = args.slice(i + 1);
break;
}
}
} catch (ex) {
printHelpAndDie(ex.message, 1);
}
for (var name in options) {
var option = options[name];
if (!(name in parsedOptions)) {
if (option.required) {
printHelpAndDie('Missing required option: --' + name, 1);
}
parsedOptions[name] = option.list ? [] : option['default'];
}
}
mustParse = false;
}
function printHelpAndDie(errorMessage, exitCode) {
process.stdout.write(errorMessage + '\n');
process.stdout.write(getHelpMsg());
process.exit(exitCode);
}
function parseOption(match) {
var option = options[match[1]];
if (!option) {
throw Error(JSON.stringify('--' + match[1]) + ' is not a valid option');
}
var value = match[2];
if (typeof value !== 'undefined') {
value = parseOptionValue(match[1], option, value);
} else if (option.parse === parseBoolean) {
value = true;
} else {
throw Error('Option ' + JSON.stringify('--' + option.name) +
'requires an operand');
}
option.callback(value);
if (option.list) {
var array = parsedOptions[match[1]] || [];
parsedOptions[match[1]] = array;
array.push(value);
} else {
parsedOptions[match[1]] = value;
}
}
} | javascript | function OptionParser() {
/** @type {string} */
var usage = OptionParser.DEFAULT_USAGE;
/** @type {boolean} */
var mustParse = true;
/** @type {!Object.<*>} */
var parsedOptions = {};
/** @type {!Array.<string>} */
var extraArgs = [];
/**
* Sets the usage string. All occurences of "$0" will be replaced with the
* current executable's name.
* @param {string} usageStr The new usage string.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.usage = function(usageStr) {
mustParse = true;
usage = usageStr;
return this;
};
/**
* @type {!Object.<{
* help: string,
* parse: function(string): *,
* required: boolean,
* list: boolean,
* callback: function(*),
* default: *
* }>}
*/
var options = {};
/**
* Adds a new option to this parser.
* @param {string} name The name of the option.
* @param {function(string): *} parseFn The function to use for parsing the
* option. If this function has a "default" property, it will be used as
* the default value for the option if it was not provided on the command
* line. If not specified, the default value will be undefined. The
* default value may be overrideden using the "default" property in the
* option spec.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.addOption = function(name, parseFn, opt_spec) {
checkOptionName(name, options);
var spec = opt_spec || {};
// Quoted notation for "default" to bypass annoying IDE syntax bug.
var defaultValue = spec['default'] ||
(!!spec.list ? [] : parseFn['default']);
options[name] = {
help: spec.help || '',
parse: parseFn,
required: !!spec.required,
list: !!spec.list,
callback: spec.callback || function() {},
'default': defaultValue
};
mustParse = true;
return this;
};
/**
* Defines a boolean option. Option values may be one of {'', 'true', 'false',
* '0', '1'}. In the case of the empty string (''), the option value will be
* set to true.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.boolean = function(name, opt_spec) {
return this.addOption(name, parseBoolean, opt_spec);
};
/**
* Defines a numeric option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.number = function(name, opt_spec) {
return this.addOption(name, parseNumber, opt_spec);
};
/**
* Defines a path option. Each path will be resolved relative to the
* current workin directory, if not absolute.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.path = function(name, opt_spec) {
return this.addOption(name, path.resolve, opt_spec);
};
/**
* Defines a basic string option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.string = function(name, opt_spec) {
return this.addOption(name, parseString, opt_spec);
};
/**
* Defines a regular expression based option.
* @param {string} name The name of the option.
* @param {Object=} opt_spec The option spec.
* @return {!OptionParser} A self reference.
* @this {OptionParser}
*/
this.regex = function(name, opt_spec) {
return this.addOption(name, parseRegex, opt_spec);
};
/**
* Returns the parsed command line options.
*
* <p>The command line arguments will be re-parsed if this parser's
* configuration has changed since the last access.
*
* @return {!Object.<*>} The parsed options.
*/
this.__defineGetter__('options', function() {
parse();
return parsedOptions;
});
/**
* Returns the remaining command line arguments after all options have been
* parsed.
*
* <p>The command line arguments will be re-parsed if this parser's
* configuration has changed since the last access.
*
* @return {!Array.<string>} The remaining command line arguments.
*/
this.__defineGetter__('argv', function() {
parse();
return extraArgs;
});
/**
* Parses a list of arguments. After parsing, the options property of this
* object will contain the value for each parsed flags, and the argv
* property will contain all remaining command line arguments.
* @throws {Error} If the arguments could not be parsed.
*/
this.parse = parse;
/**
* Returns a formatted help message for this parser.
* @return {string} The help message for this parser.
*/
this.getHelpMsg = getHelpMsg;
function getHelpMsg() {
return formatHelpMsg(usage, options);
}
function parse() {
if (!mustParse) {
return;
}
parsedOptions = {};
extraArgs = [];
var args = process.argv.slice(2);
var n = args.length;
try {
for (var i = 0; i < n; ++i) {
var arg = args[i];
if (arg === '--') {
extraArgs = args.slice(i + 1);
break;
}
var match = arg.match(OPTION_FLAG_REGEX);
if (match) {
// Special case --help.
if (match[1] === 'help') {
printHelpAndDie('', 0);
}
parseOption(match);
} else {
extraArgs = args.slice(i + 1);
break;
}
}
} catch (ex) {
printHelpAndDie(ex.message, 1);
}
for (var name in options) {
var option = options[name];
if (!(name in parsedOptions)) {
if (option.required) {
printHelpAndDie('Missing required option: --' + name, 1);
}
parsedOptions[name] = option.list ? [] : option['default'];
}
}
mustParse = false;
}
function printHelpAndDie(errorMessage, exitCode) {
process.stdout.write(errorMessage + '\n');
process.stdout.write(getHelpMsg());
process.exit(exitCode);
}
function parseOption(match) {
var option = options[match[1]];
if (!option) {
throw Error(JSON.stringify('--' + match[1]) + ' is not a valid option');
}
var value = match[2];
if (typeof value !== 'undefined') {
value = parseOptionValue(match[1], option, value);
} else if (option.parse === parseBoolean) {
value = true;
} else {
throw Error('Option ' + JSON.stringify('--' + option.name) +
'requires an operand');
}
option.callback(value);
if (option.list) {
var array = parsedOptions[match[1]] || [];
parsedOptions[match[1]] = array;
array.push(value);
} else {
parsedOptions[match[1]] = value;
}
}
} | [
"function",
"OptionParser",
"(",
")",
"{",
"/** @type {string} */",
"var",
"usage",
"=",
"OptionParser",
".",
"DEFAULT_USAGE",
";",
"/** @type {boolean} */",
"var",
"mustParse",
"=",
"true",
";",
"/** @type {!Object.<*>} */",
"var",
"parsedOptions",
"=",
"{",
"}",
"... | A command line option parser. Will automatically parse the command line
arguments to this program upon accessing the {@code options} or {@code argv}
properies. The command line will only be re-parsed if this parser's
configuration has changed since the last access.
@constructor | [
"A",
"command",
"line",
"option",
"parser",
".",
"Will",
"automatically",
"parse",
"the",
"command",
"line",
"arguments",
"to",
"this",
"program",
"upon",
"accessing",
"the",
"{"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/optparse.js#L254-L509 | train | The option parser. | [
30522,
3853,
5724,
19362,
8043,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
2828,
1063,
5164,
1065,
1008,
1013,
13075,
8192,
1027,
5724,
19362,
8043,
1012,
12398,
1035,
8192,
1025,
1013,
1008,
1008,
1030,
2828,
1063,
22017,
20898,
1065,
1008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js | sanitize | function sanitize(inputHtml, opt_naiveUriRewriter, opt_nmTokenPolicy) {
var tagPolicy = makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy);
return sanitizeWithPolicy(inputHtml, tagPolicy);
} | javascript | function sanitize(inputHtml, opt_naiveUriRewriter, opt_nmTokenPolicy) {
var tagPolicy = makeTagPolicy(opt_naiveUriRewriter, opt_nmTokenPolicy);
return sanitizeWithPolicy(inputHtml, tagPolicy);
} | [
"function",
"sanitize",
"(",
"inputHtml",
",",
"opt_naiveUriRewriter",
",",
"opt_nmTokenPolicy",
")",
"{",
"var",
"tagPolicy",
"=",
"makeTagPolicy",
"(",
"opt_naiveUriRewriter",
",",
"opt_nmTokenPolicy",
")",
";",
"return",
"sanitizeWithPolicy",
"(",
"inputHtml",
",",... | Strips unsafe tags and attributes from HTML.
@param {string} inputHtml The HTML to sanitize.
@param {?function(?string): ?string} opt_naiveUriRewriter A transform to
apply to URI attributes. If not given, URI attributes are deleted.
@param {function(?string): ?string} opt_nmTokenPolicy A transform to apply
to attributes containing HTML names, element IDs, and space-separated
lists of classes. If not given, such attributes are left unchanged. | [
"Strips",
"unsafe",
"tags",
"and",
"attributes",
"from",
"HTML",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js#L3552-L3555 | train | Sanitize the input html using the given NMTokenRewriter and NMTokenPolicy. | [
30522,
3853,
2624,
25090,
4371,
1006,
7953,
11039,
19968,
1010,
23569,
1035,
15743,
9496,
15603,
17625,
2099,
1010,
23569,
1035,
13221,
18715,
2368,
18155,
2594,
2100,
1007,
1063,
13075,
6415,
18155,
2594,
2100,
1027,
2191,
15900,
18155,
2594... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (oModules) {
var oHierarchy = {},
oTree = {
text: "All"
},
iSelectionDepth;
this.modulesToHierarchy(oModules, oHierarchy);
iSelectionDepth = this.setTreeNode(oHierarchy, oTree, 0, window["sap-ui-debug"] === true);
if (!iSelectionDepth) {
iSelectionDepth = 0;
}
return {
tree: oTree,
depth: iSelectionDepth
};
} | javascript | function (oModules) {
var oHierarchy = {},
oTree = {
text: "All"
},
iSelectionDepth;
this.modulesToHierarchy(oModules, oHierarchy);
iSelectionDepth = this.setTreeNode(oHierarchy, oTree, 0, window["sap-ui-debug"] === true);
if (!iSelectionDepth) {
iSelectionDepth = 0;
}
return {
tree: oTree,
depth: iSelectionDepth
};
} | [
"function",
"(",
"oModules",
")",
"{",
"var",
"oHierarchy",
"=",
"{",
"}",
",",
"oTree",
"=",
"{",
"text",
":",
"\"All\"",
"}",
",",
"iSelectionDepth",
";",
"this",
".",
"modulesToHierarchy",
"(",
"oModules",
",",
"oHierarchy",
")",
";",
"iSelectionDepth",... | Converts a module hierarchy to a bindable tree model structure
The returning object contains the tree structure and depth of the deepest selected node
@param {object} oModules Flat object of modules
@return {{tree: {text: string}, depth: number}} The resulting tree and the depth | [
"Converts",
"a",
"module",
"hierarchy",
"to",
"a",
"bindable",
"tree",
"model",
"structure",
"The",
"returning",
"object",
"contains",
"the",
"tree",
"structure",
"and",
"depth",
"of",
"the",
"deepest",
"selected",
"node"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/techinfo/moduleTreeHelper.js#L119-L137 | train | Creates a tree structure for the modules | [
30522,
3853,
1006,
18168,
7716,
16308,
1007,
1063,
13075,
2821,
3771,
2906,
11714,
1027,
1063,
1065,
1010,
27178,
9910,
1027,
1063,
3793,
1024,
1000,
2035,
1000,
1065,
1010,
2003,
12260,
7542,
3207,
13876,
2232,
1025,
2023,
1012,
14184,
340... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/FileTreeView.js | function (e) {
this.props.actions.setRenameValue(this.props.parentPath + this.refs.name.value.trim());
if (e.keyCode !== KeyEvent.DOM_VK_LEFT &&
e.keyCode !== KeyEvent.DOM_VK_RIGHT) {
// update the width of the input field
var node = this.refs.name,
newWidth = _measureText(node.value);
$(node).width(newWidth);
}
} | javascript | function (e) {
this.props.actions.setRenameValue(this.props.parentPath + this.refs.name.value.trim());
if (e.keyCode !== KeyEvent.DOM_VK_LEFT &&
e.keyCode !== KeyEvent.DOM_VK_RIGHT) {
// update the width of the input field
var node = this.refs.name,
newWidth = _measureText(node.value);
$(node).width(newWidth);
}
} | [
"function",
"(",
"e",
")",
"{",
"this",
".",
"props",
".",
"actions",
".",
"setRenameValue",
"(",
"this",
".",
"props",
".",
"parentPath",
"+",
"this",
".",
"refs",
".",
"name",
".",
"value",
".",
"trim",
"(",
")",
")",
";",
"if",
"(",
"e",
".",
... | The rename or create operation can be completed or canceled by actions outside of
this component, so we keep the model up to date by sending every update via an action. | [
"The",
"rename",
"or",
"create",
"operation",
"can",
"be",
"completed",
"or",
"canceled",
"by",
"actions",
"outside",
"of",
"this",
"component",
"so",
"we",
"keep",
"the",
"model",
"up",
"to",
"date",
"by",
"sending",
"every",
"update",
"via",
"an",
"actio... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L187-L197 | train | on keydown | [
30522,
3853,
1006,
1041,
1007,
1063,
2023,
1012,
24387,
1012,
4506,
1012,
2275,
7389,
14074,
10175,
5657,
1006,
2023,
1012,
24387,
1012,
6687,
15069,
1009,
2023,
1012,
25416,
2015,
1012,
2171,
1012,
3643,
1012,
12241,
1006,
1007,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ReactTraining/react-router | packages/react-router-native/examples/RouteConfig.js | RouteWithSubRoutes | function RouteWithSubRoutes(route) {
return (
<Route
path={route.path}
render={props => (
// pass the sub-routes down to keep nesting
<route.component {...props} routes={route.routes} />
)}
/>
);
} | javascript | function RouteWithSubRoutes(route) {
return (
<Route
path={route.path}
render={props => (
// pass the sub-routes down to keep nesting
<route.component {...props} routes={route.routes} />
)}
/>
);
} | [
"function",
"RouteWithSubRoutes",
"(",
"route",
")",
"{",
"return",
"(",
"<",
"Route",
"path",
"=",
"{",
"route",
".",
"path",
"}",
"render",
"=",
"{",
"props",
"=>",
"(",
"// pass the sub-routes down to keep nesting",
"<",
"route",
".",
"component",
"{",
".... | wrap <Route> and use this everywhere instead, then when sub routes are added to any route it'll work | [
"wrap",
"<Route",
">",
"and",
"use",
"this",
"everywhere",
"instead",
"then",
"when",
"sub",
"routes",
"are",
"added",
"to",
"any",
"route",
"it",
"ll",
"work"
] | 82ce94c3b4e74f71018d104df6dc999801fa9ab2 | https://github.com/ReactTraining/react-router/blob/82ce94c3b4e74f71018d104df6dc999801fa9ab2/packages/react-router-native/examples/RouteConfig.js#L73-L83 | train | RouteWithSubRoutes - returns a Route with sub - routes | [
30522,
3853,
2799,
24415,
6342,
12618,
10421,
2015,
1006,
2799,
1007,
1063,
2709,
1006,
1026,
2799,
4130,
1027,
1063,
2799,
1012,
4130,
1065,
17552,
1027,
1063,
24387,
1027,
1028,
1006,
1013,
1013,
3413,
1996,
4942,
1011,
5847,
2091,
2000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/utils/command.js | spawnCmd | function spawnCmd(command, args, options) {
var d = Promise.defer();
var child = spawn(command, args, options);
child.on('error', function(error) {
return d.reject(error);
});
child.stdout.on('data', function (data) {
d.notify(data);
});
child.stderr.on('data', function (data) {
d.notify(data);
});
child.on('close', function(code) {
if (code === 0) {
d.resolve();
} else {
d.reject(new Error('Error with command "'+command+'"'));
}
});
return d.promise;
} | javascript | function spawnCmd(command, args, options) {
var d = Promise.defer();
var child = spawn(command, args, options);
child.on('error', function(error) {
return d.reject(error);
});
child.stdout.on('data', function (data) {
d.notify(data);
});
child.stderr.on('data', function (data) {
d.notify(data);
});
child.on('close', function(code) {
if (code === 0) {
d.resolve();
} else {
d.reject(new Error('Error with command "'+command+'"'));
}
});
return d.promise;
} | [
"function",
"spawnCmd",
"(",
"command",
",",
"args",
",",
"options",
")",
"{",
"var",
"d",
"=",
"Promise",
".",
"defer",
"(",
")",
";",
"var",
"child",
"=",
"spawn",
"(",
"command",
",",
"args",
",",
"options",
")",
";",
"child",
".",
"on",
"(",
... | Spawn an executable
@param {String} command
@param {Array} args
@param {Object} options
@return {Promise} | [
"Spawn",
"an",
"executable"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/command.js#L44-L69 | train | Spawns a child process | [
30522,
3853,
25645,
27487,
2094,
1006,
3094,
1010,
12098,
5620,
1010,
7047,
1007,
1063,
13075,
1040,
1027,
4872,
1012,
13366,
2121,
1006,
1007,
1025,
13075,
2775,
1027,
25645,
1006,
3094,
1010,
12098,
5620,
1010,
7047,
1007,
1025,
2775,
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... |
jiahaog/nativefier | src/build/buildApp.js | selectAppArgs | function selectAppArgs(options) {
return {
name: options.name,
targetUrl: options.targetUrl,
counter: options.counter,
bounce: options.bounce,
width: options.width,
height: options.height,
minWidth: options.minWidth,
minHeight: options.minHeight,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
x: options.x,
y: options.y,
showMenuBar: options.showMenuBar,
fastQuit: options.fastQuit,
userAgent: options.userAgent,
nativefierVersion: options.nativefierVersion,
ignoreCertificate: options.ignoreCertificate,
disableGpu: options.disableGpu,
ignoreGpuBlacklist: options.ignoreGpuBlacklist,
enableEs3Apis: options.enableEs3Apis,
insecure: options.insecure,
flashPluginDir: options.flashPluginDir,
diskCacheSize: options.diskCacheSize,
fullScreen: options.fullScreen,
hideWindowFrame: options.hideWindowFrame,
maximize: options.maximize,
disableContextMenu: options.disableContextMenu,
disableDevTools: options.disableDevTools,
zoom: options.zoom,
internalUrls: options.internalUrls,
crashReporter: options.crashReporter,
singleInstance: options.singleInstance,
clearCache: options.clearCache,
appCopyright: options.appCopyright,
appVersion: options.appVersion,
buildVersion: options.buildVersion,
win32metadata: options.win32metadata,
versionString: options.versionString,
processEnvs: options.processEnvs,
fileDownloadOptions: options.fileDownloadOptions,
tray: options.tray,
basicAuthUsername: options.basicAuthUsername,
basicAuthPassword: options.basicAuthPassword,
alwaysOnTop: options.alwaysOnTop,
titleBarStyle: options.titleBarStyle,
globalShortcuts: options.globalShortcuts,
};
} | javascript | function selectAppArgs(options) {
return {
name: options.name,
targetUrl: options.targetUrl,
counter: options.counter,
bounce: options.bounce,
width: options.width,
height: options.height,
minWidth: options.minWidth,
minHeight: options.minHeight,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
x: options.x,
y: options.y,
showMenuBar: options.showMenuBar,
fastQuit: options.fastQuit,
userAgent: options.userAgent,
nativefierVersion: options.nativefierVersion,
ignoreCertificate: options.ignoreCertificate,
disableGpu: options.disableGpu,
ignoreGpuBlacklist: options.ignoreGpuBlacklist,
enableEs3Apis: options.enableEs3Apis,
insecure: options.insecure,
flashPluginDir: options.flashPluginDir,
diskCacheSize: options.diskCacheSize,
fullScreen: options.fullScreen,
hideWindowFrame: options.hideWindowFrame,
maximize: options.maximize,
disableContextMenu: options.disableContextMenu,
disableDevTools: options.disableDevTools,
zoom: options.zoom,
internalUrls: options.internalUrls,
crashReporter: options.crashReporter,
singleInstance: options.singleInstance,
clearCache: options.clearCache,
appCopyright: options.appCopyright,
appVersion: options.appVersion,
buildVersion: options.buildVersion,
win32metadata: options.win32metadata,
versionString: options.versionString,
processEnvs: options.processEnvs,
fileDownloadOptions: options.fileDownloadOptions,
tray: options.tray,
basicAuthUsername: options.basicAuthUsername,
basicAuthPassword: options.basicAuthPassword,
alwaysOnTop: options.alwaysOnTop,
titleBarStyle: options.titleBarStyle,
globalShortcuts: options.globalShortcuts,
};
} | [
"function",
"selectAppArgs",
"(",
"options",
")",
"{",
"return",
"{",
"name",
":",
"options",
".",
"name",
",",
"targetUrl",
":",
"options",
".",
"targetUrl",
",",
"counter",
":",
"options",
".",
"counter",
",",
"bounce",
":",
"options",
".",
"bounce",
"... | Only picks certain app args to pass to nativefier.json
@param options | [
"Only",
"picks",
"certain",
"app",
"args",
"to",
"pass",
"to",
"nativefier",
".",
"json"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/src/build/buildApp.js#L13-L62 | train | Select App Arguments | [
30522,
3853,
7276,
29098,
2906,
5620,
1006,
7047,
1007,
1063,
2709,
1063,
2171,
1024,
7047,
1012,
2171,
1010,
4539,
3126,
2140,
1024,
7047,
1012,
4539,
3126,
2140,
1010,
4675,
1024,
7047,
1012,
4675,
1010,
17523,
1024,
7047,
1012,
17523,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | bower_components/Flot/examples/axes-time-zones/date.js | getRule | function getRule(dt, zone, isUTC) {
var date = typeof dt === 'number' ? new Date(dt) : dt;
var ruleset = zone[1];
var basicOffset = zone[0];
//Convert a date to UTC. Depending on the 'type' parameter, the date
// parameter may be:
//
// - `u`, `g`, `z`: already UTC (no adjustment).
//
// - `s`: standard time (adjust for time zone offset but not for DST)
//
// - `w`: wall clock time (adjust for both time zone and DST offset).
//
// DST adjustment is done using the rule given as third argument.
var convertDateToUTC = function (date, type, rule) {
var offset = 0;
if (type === 'u' || type === 'g' || type === 'z') { // UTC
offset = 0;
} else if (type === 's') { // Standard Time
offset = basicOffset;
} else if (type === 'w' || !type) { // Wall Clock Time
offset = getAdjustedOffset(basicOffset, rule);
} else {
throw("unknown type " + type);
}
offset *= 60 * 1000; // to millis
return new Date(date.getTime() + offset);
};
//Step 1: Find applicable rules for this year.
//
//Step 2: Sort the rules by effective date.
//
//Step 3: Check requested date to see if a rule has yet taken effect this year. If not,
//
//Step 4: Get the rules for the previous year. If there isn't an applicable rule for last year, then
// there probably is no current time offset since they seem to explicitly turn off the offset
// when someone stops observing DST.
//
// FIXME if this is not the case and we'll walk all the way back (ugh).
//
//Step 5: Sort the rules by effective date.
//Step 6: Apply the most recent rule before the current time.
var convertRuleToExactDateAndTime = function (yearAndRule, prevRule) {
var year = yearAndRule[0]
, rule = yearAndRule[1];
// Assume that the rule applies to the year of the given date.
var hms = rule[5];
var effectiveDate;
if (!EXACT_DATE_TIME[year])
EXACT_DATE_TIME[year] = {};
// Result for given parameters is already stored
if (EXACT_DATE_TIME[year][rule])
effectiveDate = EXACT_DATE_TIME[year][rule];
else {
//If we have a specific date, use that!
if (!isNaN(rule[4])) {
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]], rule[4], hms[1], hms[2], hms[3], 0));
}
//Let's hunt for the date.
else {
var targetDay
, operator;
//Example: `lastThu`
if (rule[4].substr(0, 4) === "last") {
// Start at the last day of the month and work backward.
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]] + 1, 1, hms[1] - 24, hms[2], hms[3], 0));
targetDay = SHORT_DAYS[rule[4].substr(4, 3)];
operator = "<=";
}
//Example: `Sun>=15`
else {
//Start at the specified date.
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]], rule[4].substr(5), hms[1], hms[2], hms[3], 0));
targetDay = SHORT_DAYS[rule[4].substr(0, 3)];
operator = rule[4].substr(3, 2);
}
var ourDay = effectiveDate.getUTCDay();
//Go forwards.
if (operator === ">=") {
effectiveDate.setUTCDate(effectiveDate.getUTCDate() + (targetDay - ourDay + ((targetDay < ourDay) ? 7 : 0)));
}
//Go backwards. Looking for the last of a certain day, or operator is "<=" (less likely).
else {
effectiveDate.setUTCDate(effectiveDate.getUTCDate() + (targetDay - ourDay - ((targetDay > ourDay) ? 7 : 0)));
}
}
EXACT_DATE_TIME[year][rule] = effectiveDate;
}
//If previous rule is given, correct for the fact that the starting time of the current
// rule may be specified in local time.
if (prevRule) {
effectiveDate = convertDateToUTC(effectiveDate, hms[4], prevRule);
}
return effectiveDate;
};
var findApplicableRules = function (year, ruleset) {
var applicableRules = [];
for (var i = 0; ruleset && i < ruleset.length; i++) {
//Exclude future rules.
if (ruleset[i][0] <= year &&
(
// Date is in a set range.
ruleset[i][1] >= year ||
// Date is in an "only" year.
(ruleset[i][0] === year && ruleset[i][1] === "only") ||
//We're in a range from the start year to infinity.
ruleset[i][1] === "max"
)
) {
//It's completely okay to have any number of matches here.
// Normally we should only see two, but that doesn't preclude other numbers of matches.
// These matches are applicable to this year.
applicableRules.push([year, ruleset[i]]);
}
}
return applicableRules;
};
var compareDates = function (a, b, prev) {
var year, rule;
if (a.constructor !== Date) {
year = a[0];
rule = a[1];
a = (!prev && EXACT_DATE_TIME[year] && EXACT_DATE_TIME[year][rule])
? EXACT_DATE_TIME[year][rule]
: convertRuleToExactDateAndTime(a, prev);
} else if (prev) {
a = convertDateToUTC(a, isUTC ? 'u' : 'w', prev);
}
if (b.constructor !== Date) {
year = b[0];
rule = b[1];
b = (!prev && EXACT_DATE_TIME[year] && EXACT_DATE_TIME[year][rule]) ? EXACT_DATE_TIME[year][rule]
: convertRuleToExactDateAndTime(b, prev);
} else if (prev) {
b = convertDateToUTC(b, isUTC ? 'u' : 'w', prev);
}
a = Number(a);
b = Number(b);
return a - b;
};
var year = date.getUTCFullYear();
var applicableRules;
applicableRules = findApplicableRules(year, _this.rules[ruleset]);
applicableRules.push(date);
//While sorting, the time zone in which the rule starting time is specified
// is ignored. This is ok as long as the timespan between two DST changes is
// larger than the DST offset, which is probably always true.
// As the given date may indeed be close to a DST change, it may get sorted
// to a wrong position (off by one), which is corrected below.
applicableRules.sort(compareDates);
//If there are not enough past DST rules...
if (applicableRules.indexOf(date) < 2) {
applicableRules = applicableRules.concat(findApplicableRules(year-1, _this.rules[ruleset]));
applicableRules.sort(compareDates);
}
var pinpoint = applicableRules.indexOf(date);
if (pinpoint > 1 && compareDates(date, applicableRules[pinpoint-1], applicableRules[pinpoint-2][1]) < 0) {
//The previous rule does not really apply, take the one before that.
return applicableRules[pinpoint - 2][1];
} else if (pinpoint > 0 && pinpoint < applicableRules.length - 1 && compareDates(date, applicableRules[pinpoint+1], applicableRules[pinpoint-1][1]) > 0) {
//The next rule does already apply, take that one.
return applicableRules[pinpoint + 1][1];
} else if (pinpoint === 0) {
//No applicable rule found in this and in previous year.
return null;
}
return applicableRules[pinpoint - 1][1];
} | javascript | function getRule(dt, zone, isUTC) {
var date = typeof dt === 'number' ? new Date(dt) : dt;
var ruleset = zone[1];
var basicOffset = zone[0];
//Convert a date to UTC. Depending on the 'type' parameter, the date
// parameter may be:
//
// - `u`, `g`, `z`: already UTC (no adjustment).
//
// - `s`: standard time (adjust for time zone offset but not for DST)
//
// - `w`: wall clock time (adjust for both time zone and DST offset).
//
// DST adjustment is done using the rule given as third argument.
var convertDateToUTC = function (date, type, rule) {
var offset = 0;
if (type === 'u' || type === 'g' || type === 'z') { // UTC
offset = 0;
} else if (type === 's') { // Standard Time
offset = basicOffset;
} else if (type === 'w' || !type) { // Wall Clock Time
offset = getAdjustedOffset(basicOffset, rule);
} else {
throw("unknown type " + type);
}
offset *= 60 * 1000; // to millis
return new Date(date.getTime() + offset);
};
//Step 1: Find applicable rules for this year.
//
//Step 2: Sort the rules by effective date.
//
//Step 3: Check requested date to see if a rule has yet taken effect this year. If not,
//
//Step 4: Get the rules for the previous year. If there isn't an applicable rule for last year, then
// there probably is no current time offset since they seem to explicitly turn off the offset
// when someone stops observing DST.
//
// FIXME if this is not the case and we'll walk all the way back (ugh).
//
//Step 5: Sort the rules by effective date.
//Step 6: Apply the most recent rule before the current time.
var convertRuleToExactDateAndTime = function (yearAndRule, prevRule) {
var year = yearAndRule[0]
, rule = yearAndRule[1];
// Assume that the rule applies to the year of the given date.
var hms = rule[5];
var effectiveDate;
if (!EXACT_DATE_TIME[year])
EXACT_DATE_TIME[year] = {};
// Result for given parameters is already stored
if (EXACT_DATE_TIME[year][rule])
effectiveDate = EXACT_DATE_TIME[year][rule];
else {
//If we have a specific date, use that!
if (!isNaN(rule[4])) {
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]], rule[4], hms[1], hms[2], hms[3], 0));
}
//Let's hunt for the date.
else {
var targetDay
, operator;
//Example: `lastThu`
if (rule[4].substr(0, 4) === "last") {
// Start at the last day of the month and work backward.
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]] + 1, 1, hms[1] - 24, hms[2], hms[3], 0));
targetDay = SHORT_DAYS[rule[4].substr(4, 3)];
operator = "<=";
}
//Example: `Sun>=15`
else {
//Start at the specified date.
effectiveDate = new Date(Date.UTC(year, SHORT_MONTHS[rule[3]], rule[4].substr(5), hms[1], hms[2], hms[3], 0));
targetDay = SHORT_DAYS[rule[4].substr(0, 3)];
operator = rule[4].substr(3, 2);
}
var ourDay = effectiveDate.getUTCDay();
//Go forwards.
if (operator === ">=") {
effectiveDate.setUTCDate(effectiveDate.getUTCDate() + (targetDay - ourDay + ((targetDay < ourDay) ? 7 : 0)));
}
//Go backwards. Looking for the last of a certain day, or operator is "<=" (less likely).
else {
effectiveDate.setUTCDate(effectiveDate.getUTCDate() + (targetDay - ourDay - ((targetDay > ourDay) ? 7 : 0)));
}
}
EXACT_DATE_TIME[year][rule] = effectiveDate;
}
//If previous rule is given, correct for the fact that the starting time of the current
// rule may be specified in local time.
if (prevRule) {
effectiveDate = convertDateToUTC(effectiveDate, hms[4], prevRule);
}
return effectiveDate;
};
var findApplicableRules = function (year, ruleset) {
var applicableRules = [];
for (var i = 0; ruleset && i < ruleset.length; i++) {
//Exclude future rules.
if (ruleset[i][0] <= year &&
(
// Date is in a set range.
ruleset[i][1] >= year ||
// Date is in an "only" year.
(ruleset[i][0] === year && ruleset[i][1] === "only") ||
//We're in a range from the start year to infinity.
ruleset[i][1] === "max"
)
) {
//It's completely okay to have any number of matches here.
// Normally we should only see two, but that doesn't preclude other numbers of matches.
// These matches are applicable to this year.
applicableRules.push([year, ruleset[i]]);
}
}
return applicableRules;
};
var compareDates = function (a, b, prev) {
var year, rule;
if (a.constructor !== Date) {
year = a[0];
rule = a[1];
a = (!prev && EXACT_DATE_TIME[year] && EXACT_DATE_TIME[year][rule])
? EXACT_DATE_TIME[year][rule]
: convertRuleToExactDateAndTime(a, prev);
} else if (prev) {
a = convertDateToUTC(a, isUTC ? 'u' : 'w', prev);
}
if (b.constructor !== Date) {
year = b[0];
rule = b[1];
b = (!prev && EXACT_DATE_TIME[year] && EXACT_DATE_TIME[year][rule]) ? EXACT_DATE_TIME[year][rule]
: convertRuleToExactDateAndTime(b, prev);
} else if (prev) {
b = convertDateToUTC(b, isUTC ? 'u' : 'w', prev);
}
a = Number(a);
b = Number(b);
return a - b;
};
var year = date.getUTCFullYear();
var applicableRules;
applicableRules = findApplicableRules(year, _this.rules[ruleset]);
applicableRules.push(date);
//While sorting, the time zone in which the rule starting time is specified
// is ignored. This is ok as long as the timespan between two DST changes is
// larger than the DST offset, which is probably always true.
// As the given date may indeed be close to a DST change, it may get sorted
// to a wrong position (off by one), which is corrected below.
applicableRules.sort(compareDates);
//If there are not enough past DST rules...
if (applicableRules.indexOf(date) < 2) {
applicableRules = applicableRules.concat(findApplicableRules(year-1, _this.rules[ruleset]));
applicableRules.sort(compareDates);
}
var pinpoint = applicableRules.indexOf(date);
if (pinpoint > 1 && compareDates(date, applicableRules[pinpoint-1], applicableRules[pinpoint-2][1]) < 0) {
//The previous rule does not really apply, take the one before that.
return applicableRules[pinpoint - 2][1];
} else if (pinpoint > 0 && pinpoint < applicableRules.length - 1 && compareDates(date, applicableRules[pinpoint+1], applicableRules[pinpoint-1][1]) > 0) {
//The next rule does already apply, take that one.
return applicableRules[pinpoint + 1][1];
} else if (pinpoint === 0) {
//No applicable rule found in this and in previous year.
return null;
}
return applicableRules[pinpoint - 1][1];
} | [
"function",
"getRule",
"(",
"dt",
",",
"zone",
",",
"isUTC",
")",
"{",
"var",
"date",
"=",
"typeof",
"dt",
"===",
"'number'",
"?",
"new",
"Date",
"(",
"dt",
")",
":",
"dt",
";",
"var",
"ruleset",
"=",
"zone",
"[",
"1",
"]",
";",
"var",
"basicOffs... | if isUTC is true, date is given in UTC, otherwise it's given in local time (ie. date.getUTC*() returns local time components) | [
"if",
"isUTC",
"is",
"true",
"date",
"is",
"given",
"in",
"UTC",
"otherwise",
"it",
"s",
"given",
"in",
"local",
"time",
"(",
"ie",
".",
"date",
".",
"getUTC",
"*",
"()",
"returns",
"local",
"time",
"components",
")"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/Flot/examples/axes-time-zones/date.js#L519-L701 | train | Returns the rule for the given date and time zone. | [
30522,
3853,
2131,
6820,
2571,
1006,
26718,
1010,
4224,
1010,
2003,
4904,
2278,
1007,
1063,
13075,
3058,
1027,
2828,
11253,
26718,
1027,
1027,
1027,
1005,
2193,
1005,
1029,
2047,
3058,
1006,
26718,
1007,
1024,
26718,
1025,
13075,
3513,
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... |
GoogleChromeLabs/quicklink | demos/network-idle.js | handleMessage | function handleMessage(event) {
if (!event.data) {
return;
}
switch (event.data) {
case 'NETWORK_IDLE_ENQUIRY_RESULT_IDLE':
case 'NETWORK_IDLE_CALLBACK':
networkIdleCallback.__callbacks__.forEach(callback => {
networkIdleCallback.__popCallback__(callback, false);
});
break;
}
} | javascript | function handleMessage(event) {
if (!event.data) {
return;
}
switch (event.data) {
case 'NETWORK_IDLE_ENQUIRY_RESULT_IDLE':
case 'NETWORK_IDLE_CALLBACK':
networkIdleCallback.__callbacks__.forEach(callback => {
networkIdleCallback.__popCallback__(callback, false);
});
break;
}
} | [
"function",
"handleMessage",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"event",
".",
"data",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"event",
".",
"data",
")",
"{",
"case",
"'NETWORK_IDLE_ENQUIRY_RESULT_IDLE'",
":",
"case",
"'NETWORK_IDLE_CALLBACK'",
":",... | Handle message passing
@param {*} event - A valid event | [
"Handle",
"message",
"passing"
] | f91f5c51964fc8e19ce136c52967f7ccd9179726 | https://github.com/GoogleChromeLabs/quicklink/blob/f91f5c51964fc8e19ce136c52967f7ccd9179726/demos/network-idle.js#L93-L106 | train | Handle a message from the network | [
30522,
3853,
5047,
7834,
3736,
3351,
1006,
2724,
1007,
1063,
2065,
1006,
999,
2724,
1012,
2951,
1007,
1063,
2709,
1025,
1065,
6942,
1006,
2724,
1012,
2951,
1007,
1063,
2553,
1005,
2897,
1035,
18373,
1035,
4372,
15549,
2854,
1035,
2765,
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... |
react-bootstrap/react-bootstrap | src/utils/ElementChildren.js | forEach | function forEach(children, func) {
let index = 0;
React.Children.forEach(children, child => {
if (React.isValidElement(child)) func(child, index++);
});
} | javascript | function forEach(children, func) {
let index = 0;
React.Children.forEach(children, child => {
if (React.isValidElement(child)) func(child, index++);
});
} | [
"function",
"forEach",
"(",
"children",
",",
"func",
")",
"{",
"let",
"index",
"=",
"0",
";",
"React",
".",
"Children",
".",
"forEach",
"(",
"children",
",",
"child",
"=>",
"{",
"if",
"(",
"React",
".",
"isValidElement",
"(",
"child",
")",
")",
"func... | Iterates through children that are "valid elements".
The provided forEachFunc(child, index) will be called for each
leaf child with the index reflecting the position relative to "valid components". | [
"Iterates",
"through",
"children",
"that",
"are",
"valid",
"elements",
"."
] | f0dc81f91ae90eb54bd1e4c04fa9419872d347dc | https://github.com/react-bootstrap/react-bootstrap/blob/f0dc81f91ae90eb54bd1e4c04fa9419872d347dc/src/utils/ElementChildren.js#L25-L30 | train | Iterate over children | [
30522,
3853,
18921,
6776,
1006,
2336,
1010,
4569,
2278,
1007,
1063,
2292,
5950,
1027,
1014,
1025,
10509,
1012,
2336,
1012,
18921,
6776,
1006,
2336,
1010,
2775,
1027,
1028,
1063,
2065,
1006,
10509,
1012,
2003,
10175,
5178,
16930,
4765,
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... |
dimsemenov/PhotoSwipe | src/js/gestures.js | function(touch, p) {
p.x = touch.pageX;
p.y = touch.pageY;
p.id = touch.identifier;
return p;
} | javascript | function(touch, p) {
p.x = touch.pageX;
p.y = touch.pageY;
p.id = touch.identifier;
return p;
} | [
"function",
"(",
"touch",
",",
"p",
")",
"{",
"p",
".",
"x",
"=",
"touch",
".",
"pageX",
";",
"p",
".",
"y",
"=",
"touch",
".",
"pageY",
";",
"p",
".",
"id",
"=",
"touch",
".",
"identifier",
";",
"return",
"p",
";",
"}"
] | amount of pixels to drag to determine direction of swipe | [
"amount",
"of",
"pixels",
"to",
"drag",
"to",
"determine",
"direction",
"of",
"swipe"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/gestures.js#L106-L111 | train | touch event handler | [
30522,
3853,
1006,
3543,
1010,
1052,
1007,
1063,
1052,
1012,
1060,
1027,
3543,
1012,
3931,
2595,
1025,
1052,
1012,
1061,
1027,
3543,
1012,
3931,
2100,
1025,
1052,
1012,
8909,
1027,
3543,
1012,
8909,
4765,
18095,
1025,
2709,
1052,
1025,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.