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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/prefs.js | openPreferencesDialog | function openPreferencesDialog(controller, callback, launcher) {
if(!controller)
throw new Error("No controller given for Preferences Dialog");
if(typeof callback != "function")
throw new Error("No callback given for Preferences Dialog");
if (mozmill.isWindows) {
// Preference dialog is modal on windows, set up our callback
var prefModal = new modalDialog.modalDialog(controller.window);
prefModal.start(callback);
}
// Launch the preference dialog
if (launcher) {
launcher();
} else {
mozmill.getPreferencesController();
}
if (mozmill.isWindows) {
prefModal.waitForDialog();
} else {
// Get the window type of the preferences window depending on the application
var prefWindowType = null;
switch (mozmill.Application) {
case "Thunderbird":
prefWindowType = "Mail:Preferences";
break;
default:
prefWindowType = "Browser:Preferences";
}
utils.handleWindow("type", prefWindowType, callback);
}
} | javascript | function openPreferencesDialog(controller, callback, launcher) {
if(!controller)
throw new Error("No controller given for Preferences Dialog");
if(typeof callback != "function")
throw new Error("No callback given for Preferences Dialog");
if (mozmill.isWindows) {
// Preference dialog is modal on windows, set up our callback
var prefModal = new modalDialog.modalDialog(controller.window);
prefModal.start(callback);
}
// Launch the preference dialog
if (launcher) {
launcher();
} else {
mozmill.getPreferencesController();
}
if (mozmill.isWindows) {
prefModal.waitForDialog();
} else {
// Get the window type of the preferences window depending on the application
var prefWindowType = null;
switch (mozmill.Application) {
case "Thunderbird":
prefWindowType = "Mail:Preferences";
break;
default:
prefWindowType = "Browser:Preferences";
}
utils.handleWindow("type", prefWindowType, callback);
}
} | [
"function",
"openPreferencesDialog",
"(",
"controller",
",",
"callback",
",",
"launcher",
")",
"{",
"if",
"(",
"!",
"controller",
")",
"throw",
"new",
"Error",
"(",
"\"No controller given for Preferences Dialog\"",
")",
";",
"if",
"(",
"typeof",
"callback",
"!=",
... | Open the preferences dialog and call the given handler
@param {MozMillController} controller
MozMillController which is the opener of the preferences dialog
@param {function} callback
The callback handler to use to interact with the preference dialog
@param {function} launcher
(Optional) A callback handler to launch the preference dialog | [
"Open",
"the",
"preferences",
"dialog",
"and",
"call",
"the",
"given",
"handler"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/prefs.js#L341-L375 | train | Open the preferences dialog | [
30522,
3853,
2330,
28139,
25523,
16150,
4818,
8649,
1006,
11486,
1010,
2655,
5963,
1010,
22742,
1007,
1063,
2065,
1006,
999,
11486,
1007,
5466,
2047,
7561,
1006,
1000,
2053,
11486,
2445,
2005,
18394,
13764,
8649,
1000,
1007,
1025,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | consumeWhitespace | function consumeWhitespace(remaining) {
var match = remaining.match(/^\s+/);
if (match) {
var consumed = match[0];
remaining = remaining.substring(consumed.length);
}
return remaining;
} | javascript | function consumeWhitespace(remaining) {
var match = remaining.match(/^\s+/);
if (match) {
var consumed = match[0];
remaining = remaining.substring(consumed.length);
}
return remaining;
} | [
"function",
"consumeWhitespace",
"(",
"remaining",
")",
"{",
"var",
"match",
"=",
"remaining",
".",
"match",
"(",
"/",
"^\\s+",
"/",
")",
";",
"if",
"(",
"match",
")",
"{",
"var",
"consumed",
"=",
"match",
"[",
"0",
"]",
";",
"remaining",
"=",
"remai... | Consume all the leading whitespace
@param {string} remaining The text to consume
@returns The text with the leading whitespace removed | [
"Consume",
"all",
"the",
"leading",
"whitespace"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L7135-L7144 | train | Consumes whitespace from remaining string | [
30522,
3853,
16678,
2860,
16584,
2229,
15327,
1006,
3588,
1007,
1063,
13075,
2674,
1027,
3588,
1012,
2674,
1006,
1013,
1034,
1032,
1055,
1009,
1013,
1007,
1025,
2065,
1006,
2674,
1007,
1063,
13075,
10202,
1027,
2674,
1031,
1014,
1033,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
babel/babel | packages/babel-helpers/src/index.js | getHelperMetadata | function getHelperMetadata(file) {
const globals = new Set();
const localBindingNames = new Set();
// Maps imported identifier -> helper name
const dependencies = new Map();
let exportName;
let exportPath;
const exportBindingAssignments = [];
const importPaths = [];
const importBindingsReferences = [];
traverse(file, {
ImportDeclaration(child) {
const name = child.node.source.value;
if (!helpers[name]) {
throw child.buildCodeFrameError(`Unknown helper ${name}`);
}
if (
child.get("specifiers").length !== 1 ||
!child.get("specifiers.0").isImportDefaultSpecifier()
) {
throw child.buildCodeFrameError(
"Helpers can only import a default value",
);
}
const bindingIdentifier = child.node.specifiers[0].local;
dependencies.set(bindingIdentifier, name);
importPaths.push(makePath(child));
},
ExportDefaultDeclaration(child) {
const decl = child.get("declaration");
if (decl.isFunctionDeclaration()) {
if (!decl.node.id) {
throw decl.buildCodeFrameError(
"Helpers should give names to their exported func declaration",
);
}
exportName = decl.node.id.name;
}
exportPath = makePath(child);
},
ExportAllDeclaration(child) {
throw child.buildCodeFrameError("Helpers can only export default");
},
ExportNamedDeclaration(child) {
throw child.buildCodeFrameError("Helpers can only export default");
},
Statement(child) {
if (child.isModuleDeclaration()) return;
child.skip();
},
});
traverse(file, {
Program(path) {
const bindings = path.scope.getAllBindings();
Object.keys(bindings).forEach(name => {
if (name === exportName) return;
if (dependencies.has(bindings[name].identifier)) return;
localBindingNames.add(name);
});
},
ReferencedIdentifier(child) {
const name = child.node.name;
const binding = child.scope.getBinding(name, /* noGlobal */ true);
if (!binding) {
globals.add(name);
} else if (dependencies.has(binding.identifier)) {
importBindingsReferences.push(makePath(child));
}
},
AssignmentExpression(child) {
const left = child.get("left");
if (!(exportName in left.getBindingIdentifiers())) return;
if (!left.isIdentifier()) {
throw left.buildCodeFrameError(
"Only simple assignments to exports are allowed in helpers",
);
}
const binding = child.scope.getBinding(exportName);
if (binding && binding.scope.path.isProgram()) {
exportBindingAssignments.push(makePath(child));
}
},
});
if (!exportPath) throw new Error("Helpers must default-export something.");
// Process these in reverse so that mutating the references does not invalidate any later paths in
// the list.
exportBindingAssignments.reverse();
return {
globals: Array.from(globals),
localBindingNames: Array.from(localBindingNames),
dependencies,
exportBindingAssignments,
exportPath,
exportName,
importBindingsReferences,
importPaths,
};
} | javascript | function getHelperMetadata(file) {
const globals = new Set();
const localBindingNames = new Set();
// Maps imported identifier -> helper name
const dependencies = new Map();
let exportName;
let exportPath;
const exportBindingAssignments = [];
const importPaths = [];
const importBindingsReferences = [];
traverse(file, {
ImportDeclaration(child) {
const name = child.node.source.value;
if (!helpers[name]) {
throw child.buildCodeFrameError(`Unknown helper ${name}`);
}
if (
child.get("specifiers").length !== 1 ||
!child.get("specifiers.0").isImportDefaultSpecifier()
) {
throw child.buildCodeFrameError(
"Helpers can only import a default value",
);
}
const bindingIdentifier = child.node.specifiers[0].local;
dependencies.set(bindingIdentifier, name);
importPaths.push(makePath(child));
},
ExportDefaultDeclaration(child) {
const decl = child.get("declaration");
if (decl.isFunctionDeclaration()) {
if (!decl.node.id) {
throw decl.buildCodeFrameError(
"Helpers should give names to their exported func declaration",
);
}
exportName = decl.node.id.name;
}
exportPath = makePath(child);
},
ExportAllDeclaration(child) {
throw child.buildCodeFrameError("Helpers can only export default");
},
ExportNamedDeclaration(child) {
throw child.buildCodeFrameError("Helpers can only export default");
},
Statement(child) {
if (child.isModuleDeclaration()) return;
child.skip();
},
});
traverse(file, {
Program(path) {
const bindings = path.scope.getAllBindings();
Object.keys(bindings).forEach(name => {
if (name === exportName) return;
if (dependencies.has(bindings[name].identifier)) return;
localBindingNames.add(name);
});
},
ReferencedIdentifier(child) {
const name = child.node.name;
const binding = child.scope.getBinding(name, /* noGlobal */ true);
if (!binding) {
globals.add(name);
} else if (dependencies.has(binding.identifier)) {
importBindingsReferences.push(makePath(child));
}
},
AssignmentExpression(child) {
const left = child.get("left");
if (!(exportName in left.getBindingIdentifiers())) return;
if (!left.isIdentifier()) {
throw left.buildCodeFrameError(
"Only simple assignments to exports are allowed in helpers",
);
}
const binding = child.scope.getBinding(exportName);
if (binding && binding.scope.path.isProgram()) {
exportBindingAssignments.push(makePath(child));
}
},
});
if (!exportPath) throw new Error("Helpers must default-export something.");
// Process these in reverse so that mutating the references does not invalidate any later paths in
// the list.
exportBindingAssignments.reverse();
return {
globals: Array.from(globals),
localBindingNames: Array.from(localBindingNames),
dependencies,
exportBindingAssignments,
exportPath,
exportName,
importBindingsReferences,
importPaths,
};
} | [
"function",
"getHelperMetadata",
"(",
"file",
")",
"{",
"const",
"globals",
"=",
"new",
"Set",
"(",
")",
";",
"const",
"localBindingNames",
"=",
"new",
"Set",
"(",
")",
";",
"// Maps imported identifier -> helper name",
"const",
"dependencies",
"=",
"new",
"Map"... | Given a file AST for a given helper, get a bunch of metadata about it so that Babel can quickly render
the helper is whatever context it is needed in. | [
"Given",
"a",
"file",
"AST",
"for",
"a",
"given",
"helper",
"get",
"a",
"bunch",
"of",
"metadata",
"about",
"it",
"so",
"that",
"Babel",
"can",
"quickly",
"render",
"the",
"helper",
"is",
"whatever",
"context",
"it",
"is",
"needed",
"in",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-helpers/src/index.js#L20-L132 | train | Get the metadata for the helper | [
30522,
3853,
2131,
16001,
4842,
11368,
8447,
2696,
1006,
5371,
1007,
1063,
9530,
3367,
3795,
2015,
1027,
2047,
2275,
1006,
1007,
1025,
9530,
3367,
2334,
8428,
4667,
18442,
2015,
1027,
2047,
2275,
1006,
1007,
1025,
1013,
1013,
7341,
10964,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/less.js | function () {
var c = input.charAt(i);
if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
i++;
if (input.charAt(i) === '^') {
c = '^^';
i++;
}
while (isWhitespace(input, i)) { i++; }
return new(tree.Combinator)(c);
} else if (isWhitespace(input, i - 1)) {
return new(tree.Combinator)(" ");
} else {
return new(tree.Combinator)(null);
}
} | javascript | function () {
var c = input.charAt(i);
if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {
i++;
if (input.charAt(i) === '^') {
c = '^^';
i++;
}
while (isWhitespace(input, i)) { i++; }
return new(tree.Combinator)(c);
} else if (isWhitespace(input, i - 1)) {
return new(tree.Combinator)(" ");
} else {
return new(tree.Combinator)(null);
}
} | [
"function",
"(",
")",
"{",
"var",
"c",
"=",
"input",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"===",
"'>'",
"||",
"c",
"===",
"'+'",
"||",
"c",
"===",
"'~'",
"||",
"c",
"===",
"'|'",
"||",
"c",
"===",
"'^'",
")",
"{",
"i",
"++",
... | Combinators combine elements together, in a Selector. Because our parser isn't white-space sensitive, special care has to be taken, when parsing the descendant combinator, ` `, as it's an empty space. We have to check the previous character in the input, to see if it's a ` ` character. More info on how we deal with this in *combinator.js*. | [
"Combinators",
"combine",
"elements",
"together",
"in",
"a",
"Selector",
".",
"Because",
"our",
"parser",
"isn",
"t",
"white",
"-",
"space",
"sensitive",
"special",
"care",
"has",
"to",
"be",
"taken",
"when",
"parsing",
"the",
"descendant",
"combinator",
"as",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1385-L1401 | train | returns a combinator | [
30522,
3853,
1006,
1007,
1063,
13075,
1039,
1027,
7953,
1012,
25869,
4017,
1006,
1045,
1007,
1025,
2065,
1006,
1039,
1027,
1027,
1027,
1005,
1028,
1005,
1064,
1064,
1039,
1027,
1027,
1027,
1005,
1009,
1005,
1064,
1064,
1039,
1027,
1027,
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... | |
eslint/eslint | lib/rules/vars-on-top.js | isVariableDeclaration | function isVariableDeclaration(node) {
return (
node.type === "VariableDeclaration" ||
(
node.type === "ExportNamedDeclaration" &&
node.declaration &&
node.declaration.type === "VariableDeclaration"
)
);
} | javascript | function isVariableDeclaration(node) {
return (
node.type === "VariableDeclaration" ||
(
node.type === "ExportNamedDeclaration" &&
node.declaration &&
node.declaration.type === "VariableDeclaration"
)
);
} | [
"function",
"isVariableDeclaration",
"(",
"node",
")",
"{",
"return",
"(",
"node",
".",
"type",
"===",
"\"VariableDeclaration\"",
"||",
"(",
"node",
".",
"type",
"===",
"\"ExportNamedDeclaration\"",
"&&",
"node",
".",
"declaration",
"&&",
"node",
".",
"declarati... | Checks whether a given node is a variable declaration or not.
@param {ASTNode} node - any node
@returns {boolean} `true` if the node is a variable declaration. | [
"Checks",
"whether",
"a",
"given",
"node",
"is",
"a",
"variable",
"declaration",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/vars-on-top.js#L60-L69 | train | Check if a node is a variable declaration | [
30522,
3853,
2003,
10755,
19210,
3207,
20464,
25879,
3258,
1006,
13045,
1007,
1063,
2709,
1006,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
8023,
3207,
20464,
25879,
3258,
1000,
1064,
1064,
1006,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
91... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | examples/measure.js | function(line) {
const length = getLength(line);
let output;
if (length > 100) {
output = (Math.round(length / 1000 * 100) / 100) +
' ' + 'km';
} else {
output = (Math.round(length * 100) / 100) +
' ' + 'm';
}
return output;
} | javascript | function(line) {
const length = getLength(line);
let output;
if (length > 100) {
output = (Math.round(length / 1000 * 100) / 100) +
' ' + 'km';
} else {
output = (Math.round(length * 100) / 100) +
' ' + 'm';
}
return output;
} | [
"function",
"(",
"line",
")",
"{",
"const",
"length",
"=",
"getLength",
"(",
"line",
")",
";",
"let",
"output",
";",
"if",
"(",
"length",
">",
"100",
")",
"{",
"output",
"=",
"(",
"Math",
".",
"round",
"(",
"length",
"/",
"1000",
"*",
"100",
")",... | global so we can remove it later
Format length output.
@param {LineString} line The line.
@return {string} The formatted length. | [
"global",
"so",
"we",
"can",
"remove",
"it",
"later",
"Format",
"length",
"output",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L140-L151 | train | get the term length of a term | [
30522,
3853,
1006,
2240,
1007,
1063,
9530,
3367,
3091,
1027,
2131,
7770,
13512,
2232,
1006,
2240,
1007,
1025,
2292,
6434,
1025,
2065,
1006,
3091,
1028,
2531,
1007,
1063,
6434,
1027,
1006,
8785,
1012,
2461,
1006,
3091,
1013,
6694,
1008,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
websockets/ws | lib/buffer-util.js | viewToBuffer | function viewToBuffer(view) {
const buf = Buffer.from(view.buffer);
if (view.byteLength !== view.buffer.byteLength) {
return buf.slice(view.byteOffset, view.byteOffset + view.byteLength);
}
return buf;
} | javascript | function viewToBuffer(view) {
const buf = Buffer.from(view.buffer);
if (view.byteLength !== view.buffer.byteLength) {
return buf.slice(view.byteOffset, view.byteOffset + view.byteLength);
}
return buf;
} | [
"function",
"viewToBuffer",
"(",
"view",
")",
"{",
"const",
"buf",
"=",
"Buffer",
".",
"from",
"(",
"view",
".",
"buffer",
")",
";",
"if",
"(",
"view",
".",
"byteLength",
"!==",
"view",
".",
"buffer",
".",
"byteLength",
")",
"{",
"return",
"buf",
"."... | Converts an `ArrayBuffer` view into a buffer.
@param {(DataView|TypedArray)} view The view to convert
@return {Buffer} Converted view
@private | [
"Converts",
"an",
"ArrayBuffer",
"view",
"into",
"a",
"buffer",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/buffer-util.js#L109-L117 | train | Convert a view to a buffer | [
30522,
3853,
3193,
3406,
8569,
12494,
1006,
3193,
1007,
1063,
9530,
3367,
20934,
2546,
1027,
17698,
1012,
2013,
1006,
3193,
1012,
17698,
1007,
1025,
2065,
1006,
3193,
1012,
24880,
7770,
13512,
2232,
999,
1027,
1027,
3193,
1012,
17698,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js | includeSchema | function includeSchema(mReferencedScope) {
var oElement,
sKey;
if (!(sSchema in mReferencedScope)) {
fnLog(WARNING, sUrl, " does not contain ", sSchema);
return;
}
fnLog(DEBUG, "Including ", sSchema, " from ", sUrl);
for (sKey in mReferencedScope) {
// $EntityContainer can be ignored; $Reference, $Version is handled above
if (sKey[0] !== "$" && schema(sKey) === sSchema) {
oElement = mReferencedScope[sKey];
mScope[sKey] = oElement;
mergeAnnotations(oElement, mScope.$Annotations);
}
}
} | javascript | function includeSchema(mReferencedScope) {
var oElement,
sKey;
if (!(sSchema in mReferencedScope)) {
fnLog(WARNING, sUrl, " does not contain ", sSchema);
return;
}
fnLog(DEBUG, "Including ", sSchema, " from ", sUrl);
for (sKey in mReferencedScope) {
// $EntityContainer can be ignored; $Reference, $Version is handled above
if (sKey[0] !== "$" && schema(sKey) === sSchema) {
oElement = mReferencedScope[sKey];
mScope[sKey] = oElement;
mergeAnnotations(oElement, mScope.$Annotations);
}
}
} | [
"function",
"includeSchema",
"(",
"mReferencedScope",
")",
"{",
"var",
"oElement",
",",
"sKey",
";",
"if",
"(",
"!",
"(",
"sSchema",
"in",
"mReferencedScope",
")",
")",
"{",
"fnLog",
"(",
"WARNING",
",",
"sUrl",
",",
"\" does not contain \"",
",",
"sSchema",... | Include the schema (and all of its children) with namespace <code>sSchema</code> from
the given referenced scope.
@param {object} mReferencedScope
The $metadata "JSON" | [
"Include",
"the",
"schema",
"(",
"and",
"all",
"of",
"its",
"children",
")",
"with",
"namespace",
"<code",
">",
"sSchema<",
"/",
"code",
">",
"from",
"the",
"given",
"referenced",
"scope",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js#L159-L177 | train | Include the given schema from the scope | [
30522,
3853,
2950,
5403,
2863,
1006,
2720,
27235,
24413,
5104,
16186,
1007,
1063,
13075,
1051,
12260,
3672,
1010,
15315,
3240,
1025,
2065,
1006,
999,
1006,
7020,
5403,
2863,
1999,
2720,
27235,
24413,
5104,
16186,
1007,
1007,
1063,
1042,
205... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/AnalyticalBinding.js | trimAndCheckForDuplicates | function trimAndCheckForDuplicates(aSelect, sPath) {
var sCurrentProperty,
bError = false,
i,
n;
// replace all white-spaces before and after the value
for (i = 0, n = aSelect.length; i < n; i++) {
aSelect[i] = aSelect[i].trim();
}
// check for duplicate entries and remove from list
for (i = aSelect.length - 1; i >= 0; i--) {
sCurrentProperty = aSelect[i];
if (aSelect.indexOf(sCurrentProperty) !== i) {
// found duplicate
oLogger.warning("Ignored the 'select' binding parameter, because it"
+ " contains the property '" + sCurrentProperty + "' multiple times",
sPath);
aSelect.splice(i, 1);
bError = true;
}
}
return bError;
} | javascript | function trimAndCheckForDuplicates(aSelect, sPath) {
var sCurrentProperty,
bError = false,
i,
n;
// replace all white-spaces before and after the value
for (i = 0, n = aSelect.length; i < n; i++) {
aSelect[i] = aSelect[i].trim();
}
// check for duplicate entries and remove from list
for (i = aSelect.length - 1; i >= 0; i--) {
sCurrentProperty = aSelect[i];
if (aSelect.indexOf(sCurrentProperty) !== i) {
// found duplicate
oLogger.warning("Ignored the 'select' binding parameter, because it"
+ " contains the property '" + sCurrentProperty + "' multiple times",
sPath);
aSelect.splice(i, 1);
bError = true;
}
}
return bError;
} | [
"function",
"trimAndCheckForDuplicates",
"(",
"aSelect",
",",
"sPath",
")",
"{",
"var",
"sCurrentProperty",
",",
"bError",
"=",
"false",
",",
"i",
",",
"n",
";",
"// replace all white-spaces before and after the value",
"for",
"(",
"i",
"=",
"0",
",",
"n",
"=",
... | Iterate over the given array, trim each value and check whether there are duplicate entries
in the array. If there are duplicate entries a warning is logged and the duplicate is removed
from the array.
@param {string[]} aSelect An array of strings
@param {string} sPath The binding path
@returns {boolean} <code>true</code> if there is at least one duplicate entry in the array. | [
"Iterate",
"over",
"the",
"given",
"array",
"trim",
"each",
"value",
"and",
"check",
"whether",
"there",
"are",
"duplicate",
"entries",
"in",
"the",
"array",
".",
"If",
"there",
"are",
"duplicate",
"entries",
"a",
"warning",
"is",
"logged",
"and",
"the",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/AnalyticalBinding.js#L188-L211 | train | trim the given array of values | [
30522,
3853,
12241,
5685,
5403,
3600,
3877,
6279,
19341,
4570,
1006,
2004,
12260,
6593,
1010,
14690,
2232,
1007,
1063,
13075,
8040,
29264,
21572,
4842,
3723,
1010,
2022,
18933,
2099,
1027,
6270,
1010,
1045,
1010,
1050,
1025,
1013,
1013,
567... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_vertical/sensing.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "KEY_OPTION",
"options": [
[Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'],
['a', 'a'],
['b', 'b'],
['c', 'c'],
['d', 'd'],
['e', 'e'],
['f', 'f'],
['g', 'g'],
['h', 'h'],
['i', 'i'],
['j', 'j'],
['k', 'k'],
['l', 'l'],
['m', 'm'],
['n', 'n'],
['o', 'o'],
['p', 'p'],
['q', 'q'],
['r', 'r'],
['s', 's'],
['t', 't'],
['u', 'u'],
['v', 'v'],
['w', 'w'],
['x', 'x'],
['y', 'y'],
['z', 'z'],
['0', '0'],
['1', '1'],
['2', '2'],
['3', '3'],
['4', '4'],
['5', '5'],
['6', '6'],
['7', '7'],
['8', '8'],
['9', '9']
]
}
],
"extensions": ["colours_sensing", "output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "KEY_OPTION",
"options": [
[Blockly.Msg.EVENT_WHENKEYPRESSED_SPACE, 'space'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_UP, 'up arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_DOWN, 'down arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_RIGHT, 'right arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_LEFT, 'left arrow'],
[Blockly.Msg.EVENT_WHENKEYPRESSED_ANY, 'any'],
['a', 'a'],
['b', 'b'],
['c', 'c'],
['d', 'd'],
['e', 'e'],
['f', 'f'],
['g', 'g'],
['h', 'h'],
['i', 'i'],
['j', 'j'],
['k', 'k'],
['l', 'l'],
['m', 'm'],
['n', 'n'],
['o', 'o'],
['p', 'p'],
['q', 'q'],
['r', 'r'],
['s', 's'],
['t', 't'],
['u', 'u'],
['v', 'v'],
['w', 'w'],
['x', 'x'],
['y', 'y'],
['z', 'z'],
['0', '0'],
['1', '1'],
['2', '2'],
['3', '3'],
['4', '4'],
['5', '5'],
['6', '6'],
['7', '7'],
['8', '8'],
['9', '9']
]
}
],
"extensions": ["colours_sensing", "output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"KEY_OPTION\"",
",",
"\"options\"",
":",
"[",
"[",
"Blockly",
".",
... | Options for Keys
@this Blockly.Block | [
"Options",
"for",
"Keys"
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/sensing.js#L220-L275 | train | Construct the keydropdown | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
1000,
1003,
1015,
1000,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
1000,
2828,
1000,
1024,
1000,
2492,
1035,
4530,
76... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/progressCircular/js/progressCircularDirective.js | getDashLength | function getDashLength(diameter, strokeWidth, value, limit) {
return (diameter - strokeWidth) * $window.Math.PI * ((3 * (limit || 100) / 100) - (value/100));
} | javascript | function getDashLength(diameter, strokeWidth, value, limit) {
return (diameter - strokeWidth) * $window.Math.PI * ((3 * (limit || 100) / 100) - (value/100));
} | [
"function",
"getDashLength",
"(",
"diameter",
",",
"strokeWidth",
",",
"value",
",",
"limit",
")",
"{",
"return",
"(",
"diameter",
"-",
"strokeWidth",
")",
"*",
"$window",
".",
"Math",
".",
"PI",
"*",
"(",
"(",
"3",
"*",
"(",
"limit",
"||",
"100",
")... | Return stroke length for progress circle
@param {number} diameter Diameter of the container.
@param {number} strokeWidth Stroke width to be used when drawing circle
@param {number} value Percentage of circle (between 0 and 100)
@param {number} limit Max percentage for circle
@returns {number} Stroke length for progres circle | [
"Return",
"stroke",
"length",
"for",
"progress",
"circle"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/progressCircular/js/progressCircularDirective.js#L337-L339 | train | Calculate the length of a dash | [
30522,
3853,
2131,
8883,
7317,
13159,
2705,
1006,
6705,
1010,
6909,
9148,
11927,
2232,
1010,
3643,
1010,
5787,
1007,
1063,
2709,
1006,
6705,
1011,
6909,
9148,
11927,
2232,
1007,
1008,
1002,
3332,
1012,
8785,
1012,
14255,
1008,
1006,
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... |
MoePlayer/DPlayer | demo/modernizr.js | domToCSS | function domToCSS(name) {
return name.replace(/([A-Z])/g, function(str, m1) {
return '-' + m1.toLowerCase();
}).replace(/^ms-/, '-ms-');
} | javascript | function domToCSS(name) {
return name.replace(/([A-Z])/g, function(str, m1) {
return '-' + m1.toLowerCase();
}).replace(/^ms-/, '-ms-');
} | [
"function",
"domToCSS",
"(",
"name",
")",
"{",
"return",
"name",
".",
"replace",
"(",
"/",
"([A-Z])",
"/",
"g",
",",
"function",
"(",
"str",
",",
"m1",
")",
"{",
"return",
"'-'",
"+",
"m1",
".",
"toLowerCase",
"(",
")",
";",
"}",
")",
".",
"repla... | domToCSS takes a camelCase string and converts it to kebab-case
e.g. boxSizing -> box-sizing
@access private
@function domToCSS
@param {string} name - String name of camelCase prop we want to convert
@returns {string} The kebab-case version of the supplied name | [
"domToCSS",
"takes",
"a",
"camelCase",
"string",
"and",
"converts",
"it",
"to",
"kebab",
"-",
"case",
"e",
".",
"g",
".",
"boxSizing",
"-",
">",
"box",
"-",
"sizing"
] | f5c53f082634a6e5af56cfc72978ad7bad49b989 | https://github.com/MoePlayer/DPlayer/blob/f5c53f082634a6e5af56cfc72978ad7bad49b989/demo/modernizr.js#L798-L802 | train | Converts a dom element name to a CSS element name | [
30522,
3853,
14383,
3406,
6169,
2015,
1006,
2171,
1007,
1063,
2709,
2171,
1012,
5672,
1006,
1013,
1006,
1031,
1037,
1011,
1062,
1033,
1007,
1013,
1043,
1010,
3853,
1006,
2358,
2099,
1010,
23290,
1007,
1063,
2709,
1005,
1011,
1005,
1009,
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... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(e, tag) {
var isEmbed = ["object", "embed", "iframe"].indexOf(tag) !== -1;
this._removeNodes(e.getElementsByTagName(tag), function(element) {
// Allow youtube and vimeo videos through as people usually want to see those.
if (isEmbed) {
var attributeValues = [].map.call(element.attributes, function(attr) {
return attr.value;
}).join("|");
// First, check the elements attributes to see if any of them contain youtube or vimeo
if (this.REGEXPS.videos.test(attributeValues))
return false;
// Then check the elements inside this element for the same.
if (this.REGEXPS.videos.test(element.innerHTML))
return false;
}
return true;
});
} | javascript | function(e, tag) {
var isEmbed = ["object", "embed", "iframe"].indexOf(tag) !== -1;
this._removeNodes(e.getElementsByTagName(tag), function(element) {
// Allow youtube and vimeo videos through as people usually want to see those.
if (isEmbed) {
var attributeValues = [].map.call(element.attributes, function(attr) {
return attr.value;
}).join("|");
// First, check the elements attributes to see if any of them contain youtube or vimeo
if (this.REGEXPS.videos.test(attributeValues))
return false;
// Then check the elements inside this element for the same.
if (this.REGEXPS.videos.test(element.innerHTML))
return false;
}
return true;
});
} | [
"function",
"(",
"e",
",",
"tag",
")",
"{",
"var",
"isEmbed",
"=",
"[",
"\"object\"",
",",
"\"embed\"",
",",
"\"iframe\"",
"]",
".",
"indexOf",
"(",
"tag",
")",
"!==",
"-",
"1",
";",
"this",
".",
"_removeNodes",
"(",
"e",
".",
"getElementsByTagName",
... | Clean a node of all elements of type "tag".
(Unless it's a youtube/vimeo video. People love movies.)
@param Element
@param string tag to clean
@return void | [
"Clean",
"a",
"node",
"of",
"all",
"elements",
"of",
"type",
"tag",
".",
"(",
"Unless",
"it",
"s",
"a",
"youtube",
"/",
"vimeo",
"video",
".",
"People",
"love",
"movies",
".",
")"
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L1453-L1474 | train | Remove all elements with the same tag | [
30522,
3853,
1006,
1041,
1010,
6415,
1007,
1063,
13075,
2003,
6633,
8270,
1027,
1031,
1000,
4874,
1000,
1010,
1000,
7861,
8270,
1000,
1010,
1000,
2065,
6444,
2063,
1000,
1033,
1012,
5950,
11253,
1006,
6415,
1007,
999,
1027,
1027,
1011,
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... | |
angular/material | gulp/util.js | deployMaterialMocks | function deployMaterialMocks() {
return gulp.src(config.mockFiles)
.pipe(gulp.dest(config.outputDir));
} | javascript | function deployMaterialMocks() {
return gulp.src(config.mockFiles)
.pipe(gulp.dest(config.outputDir));
} | [
"function",
"deployMaterialMocks",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"config",
".",
"mockFiles",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"config",
".",
"outputDir",
")",
")",
";",
"}"
] | Deploy the `angular-material-mocks.js` file to the `dist` directory | [
"Deploy",
"the",
"angular",
"-",
"material",
"-",
"mocks",
".",
"js",
"file",
"to",
"the",
"dist",
"directory"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/gulp/util.js#L72-L75 | train | Deploy the material mock files to the output directory | [
30522,
3853,
21296,
8585,
14482,
5302,
10603,
1006,
1007,
1063,
2709,
26546,
1012,
5034,
2278,
1006,
9530,
8873,
2290,
1012,
12934,
8873,
4244,
1007,
1012,
8667,
1006,
26546,
1012,
4078,
2102,
1006,
9530,
8873,
2290,
1012,
6434,
4305,
2099,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_waitForCategory | function addonsManager_waitForCategory(aSpec) {
var spec = aSpec || { };
var category = spec.category;
var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
// TODO: restore after 1.5.1 has landed
// var self = this;
// mozmill.utils.waitFor(function () {
// return self.selectedCategory.getNode() == category.getNode();
// }, timeout, 100, "Category '" + category.getNode().id + "' has been set");
mozmill.utils.waitForEval("subject.self.selectedCategory.getNode() == subject.aCategory.getNode()",
timeout, 100,
{self: this, aCategory: category});
} | javascript | function addonsManager_waitForCategory(aSpec) {
var spec = aSpec || { };
var category = spec.category;
var timeout = (spec.timeout == undefined) ? TIMEOUT : spec.timeout;
if (!category)
throw new Error(arguments.callee.name + ": Category not specified.");
// TODO: restore after 1.5.1 has landed
// var self = this;
// mozmill.utils.waitFor(function () {
// return self.selectedCategory.getNode() == category.getNode();
// }, timeout, 100, "Category '" + category.getNode().id + "' has been set");
mozmill.utils.waitForEval("subject.self.selectedCategory.getNode() == subject.aCategory.getNode()",
timeout, 100,
{self: this, aCategory: category});
} | [
"function",
"addonsManager_waitForCategory",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"category",
"=",
"spec",
".",
"category",
";",
"var",
"timeout",
"=",
"(",
"spec",
".",
"timeout",
"==",
"undefined",
")",
"?",
... | Wait until the specified category has been selected
@param {object} aSpec
Object with parameters for customization
Elements: category - Category element to wait for
timeout - Duration to wait for the target state
[optional - default: 5s] | [
"Wait",
"until",
"the",
"specified",
"category",
"has",
"been",
"selected"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L748-L765 | train | Wait until the specified category has been set | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
3524,
29278,
16280,
20255,
2100,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
4696,
1027,
28699,
1012,
4696,
1025,
13075,
2051,
58... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/chips/chips.spec.js | updateInputCursor | function updateInputCursor() {
if (isValidInput) {
var inputLength = input[0].value.length;
try {
input[0].selectionStart = input[0].selectionEnd = inputLength;
} catch (e) {
// Chrome does not allow setting a selection for number inputs and just throws
// a DOMException as soon as something tries to set a selection programmatically.
// Faking the selection properties for the ChipsController works for our tests.
var selectionDescriptor = { writable: true, value: inputLength };
Object.defineProperty(input[0], 'selectionStart', selectionDescriptor);
Object.defineProperty(input[0], 'selectionEnd', selectionDescriptor);
}
}
} | javascript | function updateInputCursor() {
if (isValidInput) {
var inputLength = input[0].value.length;
try {
input[0].selectionStart = input[0].selectionEnd = inputLength;
} catch (e) {
// Chrome does not allow setting a selection for number inputs and just throws
// a DOMException as soon as something tries to set a selection programmatically.
// Faking the selection properties for the ChipsController works for our tests.
var selectionDescriptor = { writable: true, value: inputLength };
Object.defineProperty(input[0], 'selectionStart', selectionDescriptor);
Object.defineProperty(input[0], 'selectionEnd', selectionDescriptor);
}
}
} | [
"function",
"updateInputCursor",
"(",
")",
"{",
"if",
"(",
"isValidInput",
")",
"{",
"var",
"inputLength",
"=",
"input",
"[",
"0",
"]",
".",
"value",
".",
"length",
";",
"try",
"{",
"input",
"[",
"0",
"]",
".",
"selectionStart",
"=",
"input",
"[",
"0... | Updates the cursor position of the input.
This is necessary to test the cursor position. | [
"Updates",
"the",
"cursor",
"position",
"of",
"the",
"input",
".",
"This",
"is",
"necessary",
"to",
"test",
"the",
"cursor",
"position",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/chips.spec.js#L814-L829 | train | Updates the cursor of the input element. | [
30522,
3853,
10651,
2378,
18780,
10841,
25301,
2099,
1006,
1007,
1063,
2065,
1006,
2003,
10175,
28173,
16275,
4904,
1007,
1063,
13075,
7953,
7770,
13512,
2232,
1027,
7953,
1031,
1014,
1033,
1012,
3643,
1012,
3091,
1025,
3046,
1063,
7953,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js | statement | function statement(toks, i, n, handler) {
if (i < n) {
var tok = toks[i];
if (tok.charAt(0) === '@') {
return atrule(toks, i, n, handler, true);
} else {
return ruleset(toks, i, n, handler);
}
} else {
return i;
}
} | javascript | function statement(toks, i, n, handler) {
if (i < n) {
var tok = toks[i];
if (tok.charAt(0) === '@') {
return atrule(toks, i, n, handler, true);
} else {
return ruleset(toks, i, n, handler);
}
} else {
return i;
}
} | [
"function",
"statement",
"(",
"toks",
",",
"i",
",",
"n",
",",
"handler",
")",
"{",
"if",
"(",
"i",
"<",
"n",
")",
"{",
"var",
"tok",
"=",
"toks",
"[",
"i",
"]",
";",
"if",
"(",
"tok",
".",
"charAt",
"(",
"0",
")",
"===",
"'@'",
")",
"{",
... | statement : ruleset | at-rule; | [
"statement",
":",
"ruleset",
"|",
"at",
"-",
"rule",
";"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js#L1763-L1774 | train | statement function | [
30522,
3853,
4861,
1006,
2000,
5705,
1010,
1045,
1010,
1050,
1010,
28213,
1007,
1063,
2065,
1006,
1045,
1026,
1050,
1007,
1063,
13075,
2000,
2243,
1027,
2000,
5705,
1031,
1045,
1033,
1025,
2065,
1006,
2000,
2243,
1012,
25869,
4017,
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... |
ecomfe/zrender | src/Storage.js | function (cb, context) {
for (var i = 0; i < this._roots.length; i++) {
this._roots[i].traverse(cb, context);
}
} | javascript | function (cb, context) {
for (var i = 0; i < this._roots.length; i++) {
this._roots[i].traverse(cb, context);
}
} | [
"function",
"(",
"cb",
",",
"context",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_roots",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"_roots",
"[",
"i",
"]",
".",
"traverse",
"(",
"cb",
",",
"context"... | @param {Function} cb | [
"@param",
"{",
"Function",
"}",
"cb"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/Storage.js#L45-L49 | train | Traverse the tree | [
30522,
3853,
1006,
17324,
1010,
6123,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2023,
1012,
1035,
6147,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2023,
1012,
1035,
6147,
1031,
1045,
1033,
1012,
20811,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/utils.js | checkSearchField | function checkSearchField(controller, searchField,
searchTerm, submitButton,
timeout) {
controller.waitThenClick(searchField, timeout);
controller.type(searchField, searchTerm);
if (submitButton != undefined) {
controller.waitThenClick(submitButton, timeout);
}
} | javascript | function checkSearchField(controller, searchField,
searchTerm, submitButton,
timeout) {
controller.waitThenClick(searchField, timeout);
controller.type(searchField, searchTerm);
if (submitButton != undefined) {
controller.waitThenClick(submitButton, timeout);
}
} | [
"function",
"checkSearchField",
"(",
"controller",
",",
"searchField",
",",
"searchTerm",
",",
"submitButton",
",",
"timeout",
")",
"{",
"controller",
".",
"waitThenClick",
"(",
"searchField",
",",
"timeout",
")",
";",
"controller",
".",
"type",
"(",
"searchFiel... | Run tests against a given search form
@param {MozMillController} controller
MozMillController of the window to operate on
@param {ElemBase} searchField
The HTML input form element to test
@param {string} searchTerm
The search term for the test
@param {ElemBase} submitButton
(Optional) The forms submit button
@param {number} timeout
The timeout value for the single tests | [
"Run",
"tests",
"against",
"a",
"given",
"search",
"form"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L232-L241 | train | Checks if a search field is valid and if so checks if it is valid | [
30522,
3853,
14148,
14644,
22693,
1006,
11486,
1010,
3945,
3790,
1010,
3945,
3334,
2213,
1010,
12040,
8569,
15474,
1010,
2051,
5833,
1007,
1063,
11486,
1012,
3524,
10760,
12273,
25230,
1006,
3945,
3790,
1010,
2051,
5833,
1007,
1025,
11486,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
airbnb/enzyme | packages/enzyme/src/ShallowWrapper.js | updatePrimaryRootContext | function updatePrimaryRootContext(wrappingComponent) {
const adapter = getAdapter(wrappingComponent[OPTIONS]);
const primaryWrapper = wrappingComponent[PRIMARY_WRAPPER];
const primaryRenderer = primaryWrapper[RENDERER];
const primaryNode = primaryRenderer.getNode();
const {
legacyContext,
providerValues,
} = getContextFromWrappingComponent(wrappingComponent, adapter);
const prevProviderValues = primaryWrapper[PROVIDER_VALUES];
primaryWrapper.setContext({
...wrappingComponent[PRIMARY_WRAPPER][OPTIONS].context,
...legacyContext,
});
primaryWrapper[PROVIDER_VALUES] = new Map([...prevProviderValues, ...providerValues]);
if (typeof adapter.isContextConsumer === 'function' && adapter.isContextConsumer(primaryNode.type)) {
const Consumer = primaryNode.type;
// Adapters with an `isContextConsumer` method will definitely have a `getProviderFromConsumer`
// method.
const Provider = adapter.getProviderFromConsumer(Consumer);
const newValue = providerValues.get(Provider);
const oldValue = prevProviderValues.get(Provider);
// Use referential comparison like React
if (newValue !== oldValue) {
primaryWrapper.rerender();
}
}
} | javascript | function updatePrimaryRootContext(wrappingComponent) {
const adapter = getAdapter(wrappingComponent[OPTIONS]);
const primaryWrapper = wrappingComponent[PRIMARY_WRAPPER];
const primaryRenderer = primaryWrapper[RENDERER];
const primaryNode = primaryRenderer.getNode();
const {
legacyContext,
providerValues,
} = getContextFromWrappingComponent(wrappingComponent, adapter);
const prevProviderValues = primaryWrapper[PROVIDER_VALUES];
primaryWrapper.setContext({
...wrappingComponent[PRIMARY_WRAPPER][OPTIONS].context,
...legacyContext,
});
primaryWrapper[PROVIDER_VALUES] = new Map([...prevProviderValues, ...providerValues]);
if (typeof adapter.isContextConsumer === 'function' && adapter.isContextConsumer(primaryNode.type)) {
const Consumer = primaryNode.type;
// Adapters with an `isContextConsumer` method will definitely have a `getProviderFromConsumer`
// method.
const Provider = adapter.getProviderFromConsumer(Consumer);
const newValue = providerValues.get(Provider);
const oldValue = prevProviderValues.get(Provider);
// Use referential comparison like React
if (newValue !== oldValue) {
primaryWrapper.rerender();
}
}
} | [
"function",
"updatePrimaryRootContext",
"(",
"wrappingComponent",
")",
"{",
"const",
"adapter",
"=",
"getAdapter",
"(",
"wrappingComponent",
"[",
"OPTIONS",
"]",
")",
";",
"const",
"primaryWrapper",
"=",
"wrappingComponent",
"[",
"PRIMARY_WRAPPER",
"]",
";",
"const"... | Updates the context of the primary wrapper when the
`wrappingComponent` re-renders. | [
"Updates",
"the",
"context",
"of",
"the",
"primary",
"wrapper",
"when",
"the",
"wrappingComponent",
"re",
"-",
"renders",
"."
] | cd430eae95eba151f17e970ee77c18f09476de0e | https://github.com/airbnb/enzyme/blob/cd430eae95eba151f17e970ee77c18f09476de0e/packages/enzyme/src/ShallowWrapper.js#L1724-L1754 | train | Updates the context of the primary root wrapper. | [
30522,
3853,
10651,
18098,
9581,
2854,
3217,
4140,
8663,
18209,
1006,
12252,
9006,
29513,
3372,
1007,
1063,
9530,
3367,
15581,
2121,
1027,
2131,
8447,
13876,
2121,
1006,
12252,
9006,
29513,
3372,
1031,
7047,
1033,
1007,
1025,
9530,
3367,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/PlanningCalendar.js | function (oEvent) {
var fnHandleAppsOverlay = function () {
var $CalendarRowAppsOverlay = jQuery(".sapUiCalendarRowAppsOverlay");
setTimeout(function () {
$CalendarRowAppsOverlay.addClass("sapUiCalendarRowAppsOverlayDragging");
}, 0);
jQuery(document).one("dragend", function () {
$CalendarRowAppsOverlay.removeClass("sapUiCalendarRowAppsOverlayDragging");
});
};
if (oTargetTimeline._isOneMonthIntervalOnSmallSizes() || !oTargetTimeline._isDraggingPerformed()) {
oEvent.preventDefault();
return;
}
fnHandleAppsOverlay();
} | javascript | function (oEvent) {
var fnHandleAppsOverlay = function () {
var $CalendarRowAppsOverlay = jQuery(".sapUiCalendarRowAppsOverlay");
setTimeout(function () {
$CalendarRowAppsOverlay.addClass("sapUiCalendarRowAppsOverlayDragging");
}, 0);
jQuery(document).one("dragend", function () {
$CalendarRowAppsOverlay.removeClass("sapUiCalendarRowAppsOverlayDragging");
});
};
if (oTargetTimeline._isOneMonthIntervalOnSmallSizes() || !oTargetTimeline._isDraggingPerformed()) {
oEvent.preventDefault();
return;
}
fnHandleAppsOverlay();
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"fnHandleAppsOverlay",
"=",
"function",
"(",
")",
"{",
"var",
"$CalendarRowAppsOverlay",
"=",
"jQuery",
"(",
"\".sapUiCalendarRowAppsOverlay\"",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"$CalendarRowAppsOv... | Fired when the user starts dragging an appointment. | [
"Fired",
"when",
"the",
"user",
"starts",
"dragging",
"an",
"appointment",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/PlanningCalendar.js#L3034-L3052 | train | Handles the dragend event on the apps overlay | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
1042,
25311,
5685,
19738,
28281,
7840,
8485,
1027,
3853,
1006,
1007,
1063,
13075,
1002,
8094,
10524,
29098,
23230,
2121,
8485,
1027,
1046,
4226,
2854,
1006,
1000,
1012,
20066,
10179,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
grpc/grpc-node | packages/grpc-native-core/src/server.js | handleError | function handleError(call, error) {
var statusMetadata = new Metadata();
var status = {
code: constants.status.UNKNOWN,
details: 'Unknown Error'
};
if (error.hasOwnProperty('message')) {
status.details = error.message;
}
if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
status.code = error.code;
if (error.hasOwnProperty('details')) {
status.details = error.details;
}
}
if (error.hasOwnProperty('metadata')) {
statusMetadata = error.metadata;
}
status.metadata = statusMetadata._getCoreRepresentation();
var error_batch = {};
if (!call.metadataSent) {
error_batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
}
error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
call.startBatch(error_batch, function(){});
} | javascript | function handleError(call, error) {
var statusMetadata = new Metadata();
var status = {
code: constants.status.UNKNOWN,
details: 'Unknown Error'
};
if (error.hasOwnProperty('message')) {
status.details = error.message;
}
if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
status.code = error.code;
if (error.hasOwnProperty('details')) {
status.details = error.details;
}
}
if (error.hasOwnProperty('metadata')) {
statusMetadata = error.metadata;
}
status.metadata = statusMetadata._getCoreRepresentation();
var error_batch = {};
if (!call.metadataSent) {
error_batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
}
error_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
call.startBatch(error_batch, function(){});
} | [
"function",
"handleError",
"(",
"call",
",",
"error",
")",
"{",
"var",
"statusMetadata",
"=",
"new",
"Metadata",
"(",
")",
";",
"var",
"status",
"=",
"{",
"code",
":",
"constants",
".",
"status",
".",
"UNKNOWN",
",",
"details",
":",
"'Unknown Error'",
"}... | Handle an error on a call by sending it as a status
@private
@param {grpc.internal~Call} call The call to send the error on
@param {(Object|Error)} error The error object | [
"Handle",
"an",
"error",
"on",
"a",
"call",
"by",
"sending",
"it",
"as",
"a",
"status"
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L44-L70 | train | Handle an error from the server | [
30522,
3853,
5047,
2121,
29165,
1006,
2655,
1010,
7561,
1007,
1063,
13075,
3570,
11368,
8447,
2696,
1027,
2047,
27425,
1006,
1007,
1025,
13075,
3570,
1027,
1063,
3642,
1024,
5377,
2015,
1012,
3570,
1012,
4242,
1010,
4751,
1024,
1005,
4242,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/library.js | function(rm, sBgColor, sBgImgUrl, sCustomBGClass) {
rm.addClass(sCustomBGClass || "sapUiGlobalBackgroundColor");
if (sBgColor && !DataType.getType("sap.ui.core.CSSColor").isValid(sBgColor)) {
Log.warning(sBgColor + " is not a valid sap.ui.core.CSSColor type");
sBgColor = "";
}
if (sBgColor || sBgImgUrl) { // when an image or color is configured, the gradient needs to be removed, so the color can be seen behind the image
rm.addStyle("background-image", "none");
rm.addStyle("filter", "none");
}
if (sBgColor) {
rm.addStyle("background-color", sBgColor);
}
} | javascript | function(rm, sBgColor, sBgImgUrl, sCustomBGClass) {
rm.addClass(sCustomBGClass || "sapUiGlobalBackgroundColor");
if (sBgColor && !DataType.getType("sap.ui.core.CSSColor").isValid(sBgColor)) {
Log.warning(sBgColor + " is not a valid sap.ui.core.CSSColor type");
sBgColor = "";
}
if (sBgColor || sBgImgUrl) { // when an image or color is configured, the gradient needs to be removed, so the color can be seen behind the image
rm.addStyle("background-image", "none");
rm.addStyle("filter", "none");
}
if (sBgColor) {
rm.addStyle("background-color", sBgColor);
}
} | [
"function",
"(",
"rm",
",",
"sBgColor",
",",
"sBgImgUrl",
",",
"sCustomBGClass",
")",
"{",
"rm",
".",
"addClass",
"(",
"sCustomBGClass",
"||",
"\"sapUiGlobalBackgroundColor\"",
")",
";",
"if",
"(",
"sBgColor",
"&&",
"!",
"DataType",
".",
"getType",
"(",
"\"s... | Adds CSS classes and styles to the given RenderManager, depending on the given configuration for background color and background image.
To be called by control renderers supporting the global themable background image within their root tag, before they call writeClasses() and writeStyles().
@param {sap.ui.core.RenderManager} rm The RenderManager
@param {sap.ui.core.CSSColor} [sBgColor] A configured custom background color for the control, if any
@param {sap.ui.core.URI} [sBgImgUrl] The configured custom background image for the control, if any
@protected | [
"Adds",
"CSS",
"classes",
"and",
"styles",
"to",
"the",
"given",
"RenderManager",
"depending",
"on",
"the",
"given",
"configuration",
"for",
"background",
"color",
"and",
"background",
"image",
".",
"To",
"be",
"called",
"by",
"control",
"renderers",
"supporting... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/library.js#L4181-L4195 | train | Adds background background | [
30522,
3853,
1006,
28549,
1010,
24829,
18195,
12898,
2099,
1010,
24829,
5856,
24798,
3126,
2140,
1010,
8040,
19966,
5358,
2497,
18195,
27102,
1007,
1063,
28549,
1012,
5587,
26266,
1006,
8040,
19966,
5358,
2497,
18195,
27102,
1064,
1064,
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... | |
jgraph/mxgraph | javascript/mxClient.js | mxConnectionHandler | function mxConnectionHandler(graph, factoryMethod)
{
mxEventSource.call(this);
if (graph != null)
{
this.graph = graph;
this.factoryMethod = factoryMethod;
this.init();
// Handles escape keystrokes
this.escapeHandler = mxUtils.bind(this, function(sender, evt)
{
this.reset();
});
this.graph.addListener(mxEvent.ESCAPE, this.escapeHandler);
}
} | javascript | function mxConnectionHandler(graph, factoryMethod)
{
mxEventSource.call(this);
if (graph != null)
{
this.graph = graph;
this.factoryMethod = factoryMethod;
this.init();
// Handles escape keystrokes
this.escapeHandler = mxUtils.bind(this, function(sender, evt)
{
this.reset();
});
this.graph.addListener(mxEvent.ESCAPE, this.escapeHandler);
}
} | [
"function",
"mxConnectionHandler",
"(",
"graph",
",",
"factoryMethod",
")",
"{",
"mxEventSource",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"graph",
"!=",
"null",
")",
"{",
"this",
".",
"graph",
"=",
"graph",
";",
"this",
".",
"factoryMethod",
"=",
... | Copyright (c) 2006-2016, JGraph Ltd
Copyright (c) 2006-2016, Gaudenz Alder
Class: mxConnectionHandler
Graph event handler that creates new connections. Uses <mxTerminalMarker>
for finding and highlighting the source and target vertices and
<factoryMethod> to create the edge instance. This handler is built-into
<mxGraph.connectionHandler> and enabled using <mxGraph.setConnectable>.
Example:
(code)
new mxConnectionHandler(graph, function(source, target, style)
{
edge = new mxCell('', new mxGeometry());
edge.setEdge(true);
edge.setStyle(style);
edge.geometry.relative = true;
return edge;
});
(end)
Here is an alternative solution that just sets a specific user object for
new edges by overriding <insertEdge>.
(code)
mxConnectionHandlerInsertEdge = mxConnectionHandler.prototype.insertEdge;
mxConnectionHandler.prototype.insertEdge = function(parent, id, value, source, target, style)
{
value = 'Test';
return mxConnectionHandlerInsertEdge.apply(this, arguments);
};
(end)
Using images to trigger connections:
This handler uses mxTerminalMarker to find the source and target cell for
the new connection and creates a new edge using <connect>. The new edge is
created using <createEdge> which in turn uses <factoryMethod> or creates a
new default edge.
The handler uses a "highlight-paradigm" for indicating if a cell is being
used as a source or target terminal, as seen in other diagramming products.
In order to allow both, moving and connecting cells at the same time,
<mxConstants.DEFAULT_HOTSPOT> is used in the handler to determine the hotspot
of a cell, that is, the region of the cell which is used to trigger a new
connection. The constant is a value between 0 and 1 that specifies the
amount of the width and height around the center to be used for the hotspot
of a cell and its default value is 0.5. In addition,
<mxConstants.MIN_HOTSPOT_SIZE> defines the minimum number of pixels for the
width and height of the hotspot.
This solution, while standards compliant, may be somewhat confusing because
there is no visual indicator for the hotspot and the highlight is seen to
switch on and off while the mouse is being moved in and out. Furthermore,
this paradigm does not allow to create different connections depending on
the highlighted hotspot as there is only one hotspot per cell and it
normally does not allow cells to be moved and connected at the same time as
there is no clear indication of the connectable area of the cell.
To come across these issues, the handle has an additional <createIcons> hook
with a default implementation that allows to create one icon to be used to
trigger new connections. If this icon is specified, then new connections can
only be created if the image is clicked while the cell is being highlighted.
The <createIcons> hook may be overridden to create more than one
<mxImageShape> for creating new connections, but the default implementation
supports one image and is used as follows:
In order to display the "connect image" whenever the mouse is over the cell,
an DEFAULT_HOTSPOT of 1 should be used:
(code)
mxConstants.DEFAULT_HOTSPOT = 1;
(end)
In order to avoid confusion with the highlighting, the highlight color
should not be used with a connect image:
(code)
mxConstants.HIGHLIGHT_COLOR = null;
(end)
To install the image, the connectImage field of the mxConnectionHandler must
be assigned a new <mxImage> instance:
(code)
mxConnectionHandler.prototype.connectImage = new mxImage('images/green-dot.gif', 14, 14);
(end)
This will use the green-dot.gif with a width and height of 14 pixels as the
image to trigger new connections. In createIcons the icon field of the
handler will be set in order to remember the icon that has been clicked for
creating the new connection. This field will be available under selectedIcon
in the connect method, which may be overridden to take the icon that
triggered the new connection into account. This is useful if more than one
icon may be used to create a connection.
Group: Events
Event: mxEvent.START
Fires when a new connection is being created by the user. The <code>state</code>
property contains the state of the source cell.
Event: mxEvent.CONNECT
Fires between begin- and endUpdate in <connect>. The <code>cell</code>
property contains the inserted edge, the <code>event</code> and <code>target</code>
properties contain the respective arguments that were passed to <connect> (where
target corresponds to the dropTarget argument). Finally, the <code>terminal</code>
property corresponds to the target argument in <connect> or the clone of the source
terminal if <createTarget> is enabled.
Note that the target is the cell under the mouse where the mouse button was released.
Depending on the logic in the handler, this doesn't necessarily have to be the target
of the inserted edge. To print the source, target or any optional ports IDs that the
edge is connected to, the following code can be used. To get more details about the
actual connection point, <mxGraph.getConnectionConstraint> can be used. To resolve
the port IDs, use <mxGraphModel.getCell>.
(code)
graph.connectionHandler.addListener(mxEvent.CONNECT, function(sender, evt)
{
var edge = evt.getProperty('cell');
var source = graph.getModel().getTerminal(edge, true);
var target = graph.getModel().getTerminal(edge, false);
var style = graph.getCellStyle(edge);
var sourcePortId = style[mxConstants.STYLE_SOURCE_PORT];
var targetPortId = style[mxConstants.STYLE_TARGET_PORT];
mxLog.show();
mxLog.debug('connect', edge, source.id, target.id, sourcePortId, targetPortId);
});
(end)
Event: mxEvent.RESET
Fires when the <reset> method is invoked.
Constructor: mxConnectionHandler
Constructs an event handler that connects vertices using the specified
factory method to create the new edges. Modify
<mxConstants.ACTIVE_REGION> to setup the region on a cell which triggers
the creation of a new connection or use connect icons as explained
above.
Parameters:
graph - Reference to the enclosing <mxGraph>.
factoryMethod - Optional function to create the edge. The function takes
the source and target <mxCell> as the first and second argument and an
optional cell style from the preview as the third argument. It returns
the <mxCell> that represents the new edge. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2016",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2016",
"Gaudenz",
"Alder",
"Class",
":",
"mxConnectionHandler"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L72168-L72186 | train | This is the base class for all connection events | [
30522,
3853,
25630,
8663,
2638,
7542,
11774,
3917,
1006,
10629,
1010,
4713,
11368,
6806,
2094,
1007,
1063,
25630,
18697,
7666,
8162,
3401,
1012,
2655,
1006,
2023,
1007,
1025,
2065,
1006,
10629,
999,
1027,
19701,
1007,
1063,
2023,
1012,
1062... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/util.js | processQueue | function processQueue() {
var queue = nextTick.queue;
var digest = nextTick.digest;
nextTick.queue = [];
nextTick.timeout = null;
nextTick.digest = false;
queue.forEach(function(queueItem) {
var skip = queueItem.scope && queueItem.scope.$$destroyed;
if (!skip) {
queueItem.callback();
}
});
if (digest) $rootScope.$digest();
} | javascript | function processQueue() {
var queue = nextTick.queue;
var digest = nextTick.digest;
nextTick.queue = [];
nextTick.timeout = null;
nextTick.digest = false;
queue.forEach(function(queueItem) {
var skip = queueItem.scope && queueItem.scope.$$destroyed;
if (!skip) {
queueItem.callback();
}
});
if (digest) $rootScope.$digest();
} | [
"function",
"processQueue",
"(",
")",
"{",
"var",
"queue",
"=",
"nextTick",
".",
"queue",
";",
"var",
"digest",
"=",
"nextTick",
".",
"digest",
";",
"nextTick",
".",
"queue",
"=",
"[",
"]",
";",
"nextTick",
".",
"timeout",
"=",
"null",
";",
"nextTick",... | Grab a copy of the current queue
Clear the queue for future use
Process the existing queue
Trigger digest if necessary | [
"Grab",
"a",
"copy",
"of",
"the",
"current",
"queue",
"Clear",
"the",
"queue",
"for",
"future",
"use",
"Process",
"the",
"existing",
"queue",
"Trigger",
"digest",
"if",
"necessary"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L695-L711 | train | Process the queue | [
30522,
3853,
2832,
4226,
5657,
1006,
1007,
1063,
13075,
24240,
1027,
2279,
26348,
1012,
24240,
1025,
13075,
17886,
1027,
2279,
26348,
1012,
17886,
1025,
2279,
26348,
1012,
24240,
1027,
1031,
1033,
1025,
2279,
26348,
1012,
2051,
5833,
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... |
jgraph/mxgraph | javascript/examples/grapheditor/www/js/Graph.js | createHint | function createHint()
{
var hint = document.createElement('div');
hint.className = 'geHint';
hint.style.whiteSpace = 'nowrap';
hint.style.position = 'absolute';
return hint;
} | javascript | function createHint()
{
var hint = document.createElement('div');
hint.className = 'geHint';
hint.style.whiteSpace = 'nowrap';
hint.style.position = 'absolute';
return hint;
} | [
"function",
"createHint",
"(",
")",
"{",
"var",
"hint",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"hint",
".",
"className",
"=",
"'geHint'",
";",
"hint",
".",
"style",
".",
"whiteSpace",
"=",
"'nowrap'",
";",
"hint",
".",
"style",
... | Hints on handlers | [
"Hints",
"on",
"handlers"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/examples/grapheditor/www/js/Graph.js#L7566-L7574 | train | Creates a hint element | [
30522,
3853,
3443,
10606,
2102,
1006,
1007,
1063,
13075,
9374,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
9374,
1012,
2465,
18442,
1027,
1005,
16216,
10606,
2102,
1005,
1025,
9374,
1012,
2806,
1012,
12461... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/addons.js | addonsManager_getAddonButton | function addonsManager_getAddonButton(aSpec) {
var spec = aSpec || { };
var addon = spec.addon;
var button = spec.button;
if (!button)
throw new Error(arguments.callee.name + ": Button not specified.");
return this.getAddonChildElement({addon: addon, type: button + "Button"});
} | javascript | function addonsManager_getAddonButton(aSpec) {
var spec = aSpec || { };
var addon = spec.addon;
var button = spec.button;
if (!button)
throw new Error(arguments.callee.name + ": Button not specified.");
return this.getAddonChildElement({addon: addon, type: button + "Button"});
} | [
"function",
"addonsManager_getAddonButton",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"addon",
"=",
"spec",
".",
"addon",
";",
"var",
"button",
"=",
"spec",
".",
"button",
";",
"if",
"(",
"!",
"button",
")",
"th... | Returns the element of the specified add-ons button
@param {object} aSpec
Information on which add-on to operate on
Elements: addon - Add-on element
button - Button (disable, enable, preferences, remove)
@returns Add-on button
@type {ElemBase} | [
"Returns",
"the",
"element",
"of",
"the",
"specified",
"add",
"-",
"ons",
"button"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L460-L469 | train | Get the button element for the specified add - ons | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2131,
4215,
5280,
8569,
15474,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
1063,
1065,
1025,
13075,
5587,
2239,
1027,
28699,
1012,
5587,
2239,
1025,
13075... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/one-var.js | splitDeclarations | function splitDeclarations(declaration) {
return fixer => declaration.declarations.map(declarator => {
const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
if (tokenAfterDeclarator === null) {
return null;
}
const afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, { includeComments: true });
if (tokenAfterDeclarator.value !== ",") {
return null;
}
/*
* `var x,y`
* tokenAfterDeclarator ^^ afterComma
*/
if (afterComma.range[0] === tokenAfterDeclarator.range[1]) {
return fixer.replaceText(tokenAfterDeclarator, `; ${declaration.kind} `);
}
/*
* `var x,
* tokenAfterDeclarator ^
* y`
* ^ afterComma
*/
if (
afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line ||
afterComma.type === "Line" ||
afterComma.type === "Block"
) {
let lastComment = afterComma;
while (lastComment.type === "Line" || lastComment.type === "Block") {
lastComment = sourceCode.getTokenAfter(lastComment, { includeComments: true });
}
return fixer.replaceTextRange(
[tokenAfterDeclarator.range[0], lastComment.range[0]],
`;${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}${declaration.kind} `
);
}
return fixer.replaceText(tokenAfterDeclarator, `; ${declaration.kind}`);
}).filter(x => x);
} | javascript | function splitDeclarations(declaration) {
return fixer => declaration.declarations.map(declarator => {
const tokenAfterDeclarator = sourceCode.getTokenAfter(declarator);
if (tokenAfterDeclarator === null) {
return null;
}
const afterComma = sourceCode.getTokenAfter(tokenAfterDeclarator, { includeComments: true });
if (tokenAfterDeclarator.value !== ",") {
return null;
}
/*
* `var x,y`
* tokenAfterDeclarator ^^ afterComma
*/
if (afterComma.range[0] === tokenAfterDeclarator.range[1]) {
return fixer.replaceText(tokenAfterDeclarator, `; ${declaration.kind} `);
}
/*
* `var x,
* tokenAfterDeclarator ^
* y`
* ^ afterComma
*/
if (
afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line ||
afterComma.type === "Line" ||
afterComma.type === "Block"
) {
let lastComment = afterComma;
while (lastComment.type === "Line" || lastComment.type === "Block") {
lastComment = sourceCode.getTokenAfter(lastComment, { includeComments: true });
}
return fixer.replaceTextRange(
[tokenAfterDeclarator.range[0], lastComment.range[0]],
`;${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}${declaration.kind} `
);
}
return fixer.replaceText(tokenAfterDeclarator, `; ${declaration.kind}`);
}).filter(x => x);
} | [
"function",
"splitDeclarations",
"(",
"declaration",
")",
"{",
"return",
"fixer",
"=>",
"declaration",
".",
"declarations",
".",
"map",
"(",
"declarator",
"=>",
"{",
"const",
"tokenAfterDeclarator",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"declarator",
")",
... | Fixer to split a VariableDeclaration into individual declarations
@param {VariableDeclaration} declaration The `VariableDeclaration` to split
@returns {Function} The fixer function | [
"Fixer",
"to",
"split",
"a",
"VariableDeclaration",
"into",
"individual",
"declarations"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L293-L340 | train | Split declarations into two | [
30522,
3853,
3975,
3207,
20464,
25879,
8496,
1006,
8170,
1007,
1063,
2709,
8081,
2121,
1027,
1028,
8170,
1012,
8170,
2015,
1012,
4949,
1006,
11703,
8017,
8844,
1027,
1028,
1063,
9530,
3367,
19204,
10354,
3334,
3207,
20464,
25879,
2953,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/SearchUtil.js | search | function search(sQuery) {
return new Promise(function(resolve, reject) {
init().then(function() {
oWorker.addEventListener('message', function(oEvent) {
var oData = oEvent.data;
resolve(oData && oData[WORKER.RESPONSE_FIELDS.SEARCH_RESULT]);
}, false);
oWorker.postMessage({
"cmd": WORKER.COMMANDS.SEARCH,
"sQuery": sQuery
});
});
});
} | javascript | function search(sQuery) {
return new Promise(function(resolve, reject) {
init().then(function() {
oWorker.addEventListener('message', function(oEvent) {
var oData = oEvent.data;
resolve(oData && oData[WORKER.RESPONSE_FIELDS.SEARCH_RESULT]);
}, false);
oWorker.postMessage({
"cmd": WORKER.COMMANDS.SEARCH,
"sQuery": sQuery
});
});
});
} | [
"function",
"search",
"(",
"sQuery",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"init",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"oWorker",
".",
"addEventListener",
"(",
"'message'",
",... | Initiates search and return a promise with the search result
@param sQuery the search string
@returns {Promise<any>} | [
"Initiates",
"search",
"and",
"return",
"a",
"promise",
"with",
"the",
"search",
"result"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/SearchUtil.js#L59-L75 | train | Search for a query in the cluster | [
30522,
3853,
3945,
1006,
5490,
13094,
2100,
1007,
1063,
2709,
2047,
4872,
1006,
3853,
1006,
10663,
1010,
15454,
1007,
1063,
1999,
4183,
1006,
1007,
1012,
2059,
1006,
3853,
1006,
1007,
1063,
27593,
2953,
5484,
1012,
5587,
18697,
3372,
9863,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/extensibility/ExtensionManager.js | getCompatibilityInfoForVersion | function getCompatibilityInfoForVersion(extVersion, apiVersion) {
var requiredVersion = (extVersion.brackets || (extVersion.engines && extVersion.engines.brackets)),
result = {};
result.isCompatible = !requiredVersion || semver.satisfies(apiVersion, requiredVersion);
if (result.isCompatible) {
result.compatibleVersion = extVersion.version;
} else {
// Find out reason for incompatibility
if (requiredVersion.charAt(0) === '<') {
result.requiresNewer = false;
} else if (requiredVersion.charAt(0) === '>') {
result.requiresNewer = true;
} else if (requiredVersion.charAt(0) === "~") {
var compareVersion = requiredVersion.slice(1);
// Need to add .0s to this style of range in order to compare (since valid version
// numbers must have major/minor/patch).
if (compareVersion.match(/^[0-9]+$/)) {
compareVersion += ".0.0";
} else if (compareVersion.match(/^[0-9]+\.[0-9]+$/)) {
compareVersion += ".0";
}
result.requiresNewer = semver.lt(apiVersion, compareVersion);
}
}
return result;
} | javascript | function getCompatibilityInfoForVersion(extVersion, apiVersion) {
var requiredVersion = (extVersion.brackets || (extVersion.engines && extVersion.engines.brackets)),
result = {};
result.isCompatible = !requiredVersion || semver.satisfies(apiVersion, requiredVersion);
if (result.isCompatible) {
result.compatibleVersion = extVersion.version;
} else {
// Find out reason for incompatibility
if (requiredVersion.charAt(0) === '<') {
result.requiresNewer = false;
} else if (requiredVersion.charAt(0) === '>') {
result.requiresNewer = true;
} else if (requiredVersion.charAt(0) === "~") {
var compareVersion = requiredVersion.slice(1);
// Need to add .0s to this style of range in order to compare (since valid version
// numbers must have major/minor/patch).
if (compareVersion.match(/^[0-9]+$/)) {
compareVersion += ".0.0";
} else if (compareVersion.match(/^[0-9]+\.[0-9]+$/)) {
compareVersion += ".0";
}
result.requiresNewer = semver.lt(apiVersion, compareVersion);
}
}
return result;
} | [
"function",
"getCompatibilityInfoForVersion",
"(",
"extVersion",
",",
"apiVersion",
")",
"{",
"var",
"requiredVersion",
"=",
"(",
"extVersion",
".",
"brackets",
"||",
"(",
"extVersion",
".",
"engines",
"&&",
"extVersion",
".",
"engines",
".",
"brackets",
")",
")... | Determines if the given versions[] entry is compatible with the given Brackets API version, and if not
specifies why.
@param {Object} extVersion
@param {string} apiVersion
@return {{isCompatible: boolean, requiresNewer: ?boolean, compatibleVersion: ?string}} | [
"Determines",
"if",
"the",
"given",
"versions",
"[]",
"entry",
"is",
"compatible",
"with",
"the",
"given",
"Brackets",
"API",
"version",
"and",
"if",
"not",
"specifies",
"why",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L311-L336 | train | Get compatibility info for a version | [
30522,
3853,
2131,
9006,
24952,
8553,
2378,
14876,
29278,
27774,
1006,
4654,
9189,
2545,
3258,
1010,
17928,
27774,
1007,
1063,
13075,
3223,
27774,
1027,
1006,
4654,
9189,
2545,
3258,
1012,
19719,
1064,
1064,
1006,
4654,
9189,
2545,
3258,
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... |
angular/material | src/components/datepicker/js/dateUtil.js | createDateAtMidnight | function createDateAtMidnight(opt_value) {
var date;
if (angular.isUndefined(opt_value)) {
date = new Date();
} else {
date = new Date(opt_value);
}
setDateTimeToMidnight(date);
return date;
} | javascript | function createDateAtMidnight(opt_value) {
var date;
if (angular.isUndefined(opt_value)) {
date = new Date();
} else {
date = new Date(opt_value);
}
setDateTimeToMidnight(date);
return date;
} | [
"function",
"createDateAtMidnight",
"(",
"opt_value",
")",
"{",
"var",
"date",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"opt_value",
")",
")",
"{",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"}",
"else",
"{",
"date",
"=",
"new",
"Date",
"(... | Creates a date with the time set to midnight.
Drop-in replacement for two forms of the Date constructor:
1. No argument for Date representing now.
2. Single-argument value representing number of seconds since Unix Epoch
or a Date object.
@param {number|Date=} opt_value
@return {Date} New date with time set to midnight. | [
"Creates",
"a",
"date",
"with",
"the",
"time",
"set",
"to",
"midnight",
".",
"Drop",
"-",
"in",
"replacement",
"for",
"two",
"forms",
"of",
"the",
"Date",
"constructor",
":",
"1",
".",
"No",
"argument",
"for",
"Date",
"representing",
"now",
".",
"2",
"... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateUtil.js#L217-L226 | train | Creates a date at midnight | [
30522,
3853,
2580,
3686,
4017,
4328,
2094,
15864,
1006,
23569,
1035,
3643,
1007,
1063,
13075,
3058,
1025,
2065,
1006,
16108,
1012,
2003,
8630,
28344,
1006,
23569,
1035,
3643,
1007,
1007,
1063,
3058,
1027,
2047,
3058,
1006,
1007,
1025,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | website/src/static/workers/util.js | decodePolyline | function decodePolyline(str, precision) {
let index = 0,
lat = 0,
lng = 0,
coordinates = [],
shift = 0,
result = 0,
byte = null,
latitude_change,
longitude_change,
factor = Math.pow(10, precision || 5);
// Coordinates have variable length when encoded, so just keep
// track of whether we've hit the end of the string. In each
// loop iteration, a single coordinate is decoded.
while (index < str.length) {
// Reset shift, result, and byte
byte = null;
shift = 0;
result = 0;
do {
byte = str.charCodeAt(index++) - 63;
result |= (byte & 0x1f) << shift;
shift += 5;
} while (byte >= 0x20);
latitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1));
shift = result = 0;
do {
byte = str.charCodeAt(index++) - 63;
result |= (byte & 0x1f) << shift;
shift += 5;
} while (byte >= 0x20);
longitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += latitude_change;
lng += longitude_change;
coordinates.push([lng / factor, lat / factor]);
}
return coordinates;
} | javascript | function decodePolyline(str, precision) {
let index = 0,
lat = 0,
lng = 0,
coordinates = [],
shift = 0,
result = 0,
byte = null,
latitude_change,
longitude_change,
factor = Math.pow(10, precision || 5);
// Coordinates have variable length when encoded, so just keep
// track of whether we've hit the end of the string. In each
// loop iteration, a single coordinate is decoded.
while (index < str.length) {
// Reset shift, result, and byte
byte = null;
shift = 0;
result = 0;
do {
byte = str.charCodeAt(index++) - 63;
result |= (byte & 0x1f) << shift;
shift += 5;
} while (byte >= 0x20);
latitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1));
shift = result = 0;
do {
byte = str.charCodeAt(index++) - 63;
result |= (byte & 0x1f) << shift;
shift += 5;
} while (byte >= 0x20);
longitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += latitude_change;
lng += longitude_change;
coordinates.push([lng / factor, lat / factor]);
}
return coordinates;
} | [
"function",
"decodePolyline",
"(",
"str",
",",
"precision",
")",
"{",
"let",
"index",
"=",
"0",
",",
"lat",
"=",
"0",
",",
"lng",
"=",
"0",
",",
"coordinates",
"=",
"[",
"]",
",",
"shift",
"=",
"0",
",",
"result",
"=",
"0",
",",
"byte",
"=",
"n... | https://github.com/mapbox/polyline
Decodes to a [longitude, latitude] coordinates array.
This is adapted from the implementation in Project-OSRM.
@param {String} str
@param {Number} precision
@returns {Array}
@see https://github.com/Project-OSRM/osrm-frontend/blob/master/WebContent/routing/OSRM.RoutingGeometry.js | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"mapbox",
"/",
"polyline"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/website/src/static/workers/util.js#L33-L80 | train | Decode a polyline from a string | [
30522,
3853,
21933,
3207,
18155,
8516,
3170,
1006,
2358,
2099,
1010,
11718,
1007,
1063,
2292,
5950,
1027,
1014,
1010,
2474,
2102,
1027,
1014,
1010,
1048,
3070,
1027,
1014,
1010,
12093,
1027,
1031,
1033,
1010,
5670,
1027,
1014,
1010,
2765,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/registry/componentRegistry.js | function(handle) {
if (!isValidID(handle)) return null;
var i, j, instance;
for (i = 0, j = instances.length; i < j; i++) {
instance = instances[i];
if (instance.$$mdHandle === handle) {
return instance;
}
}
return null;
} | javascript | function(handle) {
if (!isValidID(handle)) return null;
var i, j, instance;
for (i = 0, j = instances.length; i < j; i++) {
instance = instances[i];
if (instance.$$mdHandle === handle) {
return instance;
}
}
return null;
} | [
"function",
"(",
"handle",
")",
"{",
"if",
"(",
"!",
"isValidID",
"(",
"handle",
")",
")",
"return",
"null",
";",
"var",
"i",
",",
"j",
",",
"instance",
";",
"for",
"(",
"i",
"=",
"0",
",",
"j",
"=",
"instances",
".",
"length",
";",
"i",
"<",
... | Get a registered instance.
@param handle the String handle to look up for a registered instance. | [
"Get",
"a",
"registered",
"instance",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L43-L54 | train | Returns the instance of the given handle | [
30522,
3853,
1006,
5047,
1007,
1063,
2065,
1006,
999,
2003,
10175,
28173,
2094,
1006,
5047,
1007,
1007,
2709,
19701,
1025,
13075,
1045,
1010,
1046,
1010,
6013,
1025,
2005,
1006,
1045,
1027,
1014,
1010,
1046,
1027,
12107,
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... | |
vuejs/vue-devtools | src/backend/index.js | findQualifiedChildren | function findQualifiedChildren (instance) {
return isQualified(instance)
? capture(instance)
: findQualifiedChildrenFromList(instance.$children).concat(
instance._vnode && instance._vnode.children
// Find functional components in recursively in non-functional vnodes.
? flatten(instance._vnode.children.filter(child => !child.componentInstance).map(captureChild))
// Filter qualified children.
.filter(instance => isQualified(instance))
: []
)
} | javascript | function findQualifiedChildren (instance) {
return isQualified(instance)
? capture(instance)
: findQualifiedChildrenFromList(instance.$children).concat(
instance._vnode && instance._vnode.children
// Find functional components in recursively in non-functional vnodes.
? flatten(instance._vnode.children.filter(child => !child.componentInstance).map(captureChild))
// Filter qualified children.
.filter(instance => isQualified(instance))
: []
)
} | [
"function",
"findQualifiedChildren",
"(",
"instance",
")",
"{",
"return",
"isQualified",
"(",
"instance",
")",
"?",
"capture",
"(",
"instance",
")",
":",
"findQualifiedChildrenFromList",
"(",
"instance",
".",
"$children",
")",
".",
"concat",
"(",
"instance",
"."... | Find qualified children from a single instance.
If the instance itself is qualified, just return itself.
This is ok because [].concat works in both cases.
@param {Vue|Vnode} instance
@return {Vue|Array} | [
"Find",
"qualified",
"children",
"from",
"a",
"single",
"instance",
".",
"If",
"the",
"instance",
"itself",
"is",
"qualified",
"just",
"return",
"itself",
".",
"This",
"is",
"ok",
"because",
"[]",
".",
"concat",
"works",
"in",
"both",
"cases",
"."
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/backend/index.js#L320-L331 | train | Find all qualified children of a component | [
30522,
3853,
2424,
26426,
7810,
19339,
7389,
1006,
6013,
1007,
1063,
2709,
2003,
26426,
7810,
1006,
6013,
1007,
1029,
5425,
1006,
6013,
1007,
1024,
2424,
26426,
7810,
19339,
7389,
19699,
5358,
9863,
1006,
6013,
1012,
1002,
2336,
1007,
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... |
eslint/eslint | lib/util/npm-utils.js | findPackageJson | function findPackageJson(startDir) {
let dir = path.resolve(startDir || process.cwd());
do {
const pkgFile = path.join(dir, "package.json");
if (!fs.existsSync(pkgFile) || !fs.statSync(pkgFile).isFile()) {
dir = path.join(dir, "..");
continue;
}
return pkgFile;
} while (dir !== path.resolve(dir, ".."));
return null;
} | javascript | function findPackageJson(startDir) {
let dir = path.resolve(startDir || process.cwd());
do {
const pkgFile = path.join(dir, "package.json");
if (!fs.existsSync(pkgFile) || !fs.statSync(pkgFile).isFile()) {
dir = path.join(dir, "..");
continue;
}
return pkgFile;
} while (dir !== path.resolve(dir, ".."));
return null;
} | [
"function",
"findPackageJson",
"(",
"startDir",
")",
"{",
"let",
"dir",
"=",
"path",
".",
"resolve",
"(",
"startDir",
"||",
"process",
".",
"cwd",
"(",
")",
")",
";",
"do",
"{",
"const",
"pkgFile",
"=",
"path",
".",
"join",
"(",
"dir",
",",
"\"packag... | ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------
Find the closest package.json file, starting at process.cwd (by default),
and working up to root.
@param {string} [startDir=process.cwd()] Starting directory
@returns {string} Absolute path to closest package.json file | [
"------------------------------------------------------------------------------",
"Helpers",
"------------------------------------------------------------------------------",
"Find",
"the",
"closest",
"package",
".",
"json",
"file",
"starting",
"at",
"process",
".",
"cwd",
"(",
"by",... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/npm-utils.js#L28-L41 | train | Find the package. json file in the specified directory | [
30522,
3853,
2424,
23947,
4270,
22578,
2239,
1006,
2707,
4305,
2099,
1007,
1063,
2292,
16101,
1027,
4130,
1012,
10663,
1006,
2707,
4305,
2099,
1064,
1064,
2832,
1012,
19296,
2094,
1006,
1007,
1007,
1025,
2079,
1063,
9530,
3367,
1052,
2243,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/calendar/Calendar.js | function () {
var range = this._model.get('range');
var rg = range;
if (zrUtil.isArray(rg) && rg.length === 1) {
rg = rg[0];
}
if (/^\d{4}$/.test(rg)) {
range = [rg + '-01-01', rg + '-12-31'];
}
if (/^\d{4}[\/|-]\d{1,2}$/.test(rg)) {
var start = this.getDateInfo(rg);
var firstDay = start.date;
firstDay.setMonth(firstDay.getMonth() + 1);
var end = this.getNextNDay(firstDay, -1);
range = [start.formatedDate, end.formatedDate];
}
if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rg)) {
range = [rg, rg];
}
var tmp = this._getRangeInfo(range);
if (tmp.start.time > tmp.end.time) {
range.reverse();
}
return range;
} | javascript | function () {
var range = this._model.get('range');
var rg = range;
if (zrUtil.isArray(rg) && rg.length === 1) {
rg = rg[0];
}
if (/^\d{4}$/.test(rg)) {
range = [rg + '-01-01', rg + '-12-31'];
}
if (/^\d{4}[\/|-]\d{1,2}$/.test(rg)) {
var start = this.getDateInfo(rg);
var firstDay = start.date;
firstDay.setMonth(firstDay.getMonth() + 1);
var end = this.getNextNDay(firstDay, -1);
range = [start.formatedDate, end.formatedDate];
}
if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rg)) {
range = [rg, rg];
}
var tmp = this._getRangeInfo(range);
if (tmp.start.time > tmp.end.time) {
range.reverse();
}
return range;
} | [
"function",
"(",
")",
"{",
"var",
"range",
"=",
"this",
".",
"_model",
".",
"get",
"(",
"'range'",
")",
";",
"var",
"rg",
"=",
"range",
";",
"if",
"(",
"zrUtil",
".",
"isArray",
"(",
"rg",
")",
"&&",
"rg",
".",
"length",
"===",
"1",
")",
"{",
... | initRange
@private
@return {Array} [start, end] | [
"initRange"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/calendar/Calendar.js#L319-L353 | train | Get the range of the log | [
30522,
3853,
1006,
1007,
1063,
13075,
2846,
1027,
2023,
1012,
1035,
2944,
1012,
2131,
1006,
1005,
2846,
1005,
1007,
1025,
13075,
1054,
2290,
1027,
2846,
1025,
2065,
1006,
1062,
22134,
4014,
1012,
18061,
11335,
2100,
1006,
1054,
2290,
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... | |
ReactTraining/react-router | packages/react-router/modules/Prompt.js | Prompt | function Prompt({ message, when = true }) {
return (
<RouterContext.Consumer>
{context => {
invariant(context, "You should not use <Prompt> outside a <Router>");
if (!when || context.staticContext) return null;
const method = context.history.block;
return (
<Lifecycle
onMount={self => {
self.release = method(message);
}}
onUpdate={(self, prevProps) => {
if (prevProps.message !== message) {
self.release();
self.release = method(message);
}
}}
onUnmount={self => {
self.release();
}}
message={message}
/>
);
}}
</RouterContext.Consumer>
);
} | javascript | function Prompt({ message, when = true }) {
return (
<RouterContext.Consumer>
{context => {
invariant(context, "You should not use <Prompt> outside a <Router>");
if (!when || context.staticContext) return null;
const method = context.history.block;
return (
<Lifecycle
onMount={self => {
self.release = method(message);
}}
onUpdate={(self, prevProps) => {
if (prevProps.message !== message) {
self.release();
self.release = method(message);
}
}}
onUnmount={self => {
self.release();
}}
message={message}
/>
);
}}
</RouterContext.Consumer>
);
} | [
"function",
"Prompt",
"(",
"{",
"message",
",",
"when",
"=",
"true",
"}",
")",
"{",
"return",
"(",
"<",
"RouterContext",
".",
"Consumer",
">",
"\n ",
"{",
"context",
"=>",
"{",
"invariant",
"(",
"context",
",",
"\"You should not use <Prompt> outside a <Ro... | The public API for prompting the user before navigating away from a screen. | [
"The",
"public",
"API",
"for",
"prompting",
"the",
"user",
"before",
"navigating",
"away",
"from",
"a",
"screen",
"."
] | 82ce94c3b4e74f71018d104df6dc999801fa9ab2 | https://github.com/ReactTraining/react-router/blob/82ce94c3b4e74f71018d104df6dc999801fa9ab2/packages/react-router/modules/Prompt.js#L11-L41 | train | Prompt a user to enter a new message | [
30522,
3853,
25732,
1006,
1063,
4471,
1010,
2043,
1027,
2995,
1065,
1007,
1063,
2709,
1006,
1026,
2799,
29566,
10111,
18413,
1012,
7325,
1028,
1063,
6123,
1027,
1028,
1063,
23915,
1006,
6123,
1010,
1000,
2017,
2323,
2025,
2224,
1026,
25732,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RTCMultiConnection | dev/getUserMedia.js | setStreamType | function setStreamType(constraints, stream) {
if (constraints.mandatory && constraints.mandatory.chromeMediaSource) {
stream.isScreen = true;
} else if (constraints.mozMediaSource || constraints.mediaSource) {
stream.isScreen = true;
} else if (constraints.video) {
stream.isVideo = true;
} else if (constraints.audio) {
stream.isAudio = true;
}
} | javascript | function setStreamType(constraints, stream) {
if (constraints.mandatory && constraints.mandatory.chromeMediaSource) {
stream.isScreen = true;
} else if (constraints.mozMediaSource || constraints.mediaSource) {
stream.isScreen = true;
} else if (constraints.video) {
stream.isVideo = true;
} else if (constraints.audio) {
stream.isAudio = true;
}
} | [
"function",
"setStreamType",
"(",
"constraints",
",",
"stream",
")",
"{",
"if",
"(",
"constraints",
".",
"mandatory",
"&&",
"constraints",
".",
"mandatory",
".",
"chromeMediaSource",
")",
"{",
"stream",
".",
"isScreen",
"=",
"true",
";",
"}",
"else",
"if",
... | getUserMediaHandler.js | [
"getUserMediaHandler",
".",
"js"
] | 2032ce949bde30b43a3d2666e0f1e5afbf337f3d | https://github.com/muaz-khan/RTCMultiConnection/blob/2032ce949bde30b43a3d2666e0f1e5afbf337f3d/dev/getUserMedia.js#L3-L13 | train | Sets the type of the given stream based on the constraints | [
30522,
3853,
4520,
25379,
13874,
1006,
14679,
1010,
5460,
1007,
1063,
2065,
1006,
14679,
1012,
10915,
1004,
1004,
14679,
1012,
10915,
1012,
18546,
16969,
6499,
3126,
3401,
1007,
1063,
5460,
1012,
26354,
24410,
1027,
2995,
1025,
1065,
2842,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
expressjs/express | lib/utils.js | createETagGenerator | function createETagGenerator (options) {
return function generateETag (body, encoding) {
var buf = !Buffer.isBuffer(body)
? Buffer.from(body, encoding)
: body
return etag(buf, options)
}
} | javascript | function createETagGenerator (options) {
return function generateETag (body, encoding) {
var buf = !Buffer.isBuffer(body)
? Buffer.from(body, encoding)
: body
return etag(buf, options)
}
} | [
"function",
"createETagGenerator",
"(",
"options",
")",
"{",
"return",
"function",
"generateETag",
"(",
"body",
",",
"encoding",
")",
"{",
"var",
"buf",
"=",
"!",
"Buffer",
".",
"isBuffer",
"(",
"body",
")",
"?",
"Buffer",
".",
"from",
"(",
"body",
",",
... | Create an ETag generator function, generating ETags with
the given options.
@param {object} options
@return {function}
@private | [
"Create",
"an",
"ETag",
"generator",
"function",
"generating",
"ETags",
"with",
"the",
"given",
"options",
"."
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/lib/utils.js#L274-L282 | train | Creates a function that returns an ETag generator that will generate the ETag for the given body. | [
30522,
3853,
3443,
12928,
13871,
24454,
8844,
1006,
7047,
1007,
1063,
2709,
3853,
9699,
12928,
2290,
1006,
2303,
1010,
17181,
1007,
1063,
13075,
20934,
2546,
1027,
999,
17698,
1012,
2003,
8569,
12494,
1006,
2303,
1007,
1029,
17698,
1012,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function () {
var aAllMeasureNames,
oCondition,
sOrderByOptionString = null,
aSortConditions = this._oSortExpression
? this._oSortExpression._aSortCondition
: [],
i,
n = aSortConditions.length;
if (n) {
aAllMeasureNames = this._oQueryResult.getAllMeasureNames();
for (i = 0; i < n; i += 1) {
oCondition = aSortConditions[i];
if (!this._oSelectedPropertyNames[oCondition.property.name]
&& aAllMeasureNames.indexOf(oCondition.property.name) < 0) {
// sorting of aggregated entities is meaningful only if the sorted property
// is also selected or is a measure
continue;
}
sOrderByOptionString = (sOrderByOptionString ? sOrderByOptionString + "," : "")
+ oCondition.property.name + " " + oCondition.order;
}
}
return sOrderByOptionString;
} | javascript | function () {
var aAllMeasureNames,
oCondition,
sOrderByOptionString = null,
aSortConditions = this._oSortExpression
? this._oSortExpression._aSortCondition
: [],
i,
n = aSortConditions.length;
if (n) {
aAllMeasureNames = this._oQueryResult.getAllMeasureNames();
for (i = 0; i < n; i += 1) {
oCondition = aSortConditions[i];
if (!this._oSelectedPropertyNames[oCondition.property.name]
&& aAllMeasureNames.indexOf(oCondition.property.name) < 0) {
// sorting of aggregated entities is meaningful only if the sorted property
// is also selected or is a measure
continue;
}
sOrderByOptionString = (sOrderByOptionString ? sOrderByOptionString + "," : "")
+ oCondition.property.name + " " + oCondition.order;
}
}
return sOrderByOptionString;
} | [
"function",
"(",
")",
"{",
"var",
"aAllMeasureNames",
",",
"oCondition",
",",
"sOrderByOptionString",
"=",
"null",
",",
"aSortConditions",
"=",
"this",
".",
"_oSortExpression",
"?",
"this",
".",
"_oSortExpression",
".",
"_aSortCondition",
":",
"[",
"]",
",",
"... | Get the value for the OData system query option $orderby corresponding to
the sort expression.
@returns {string} The $orderby value for the sort expression or <code>null</code> | [
"Get",
"the",
"value",
"for",
"the",
"OData",
"system",
"query",
"option",
"$orderby",
"corresponding",
"to",
"the",
"sort",
"expression",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L4647-L4674 | train | Returns the order by option string for the order by clause | [
30522,
3853,
1006,
1007,
1063,
13075,
9779,
3363,
4168,
3022,
5397,
18442,
2015,
1010,
1051,
8663,
20562,
1010,
2061,
26764,
3762,
7361,
9285,
18886,
3070,
1027,
19701,
1010,
2004,
11589,
8663,
20562,
2015,
1027,
2023,
1012,
1035,
9808,
115... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Cache.js | setCount | function setCount(mChangeListeners, sPath, aCollection, vCount) {
// Note: @odata.count is of type Edm.Int64, represented as a string in OData responses;
// $count should be a number and the loss of precision is acceptable
if (typeof vCount === "string") {
vCount = parseInt(vCount);
}
// Note: this relies on $count being present as an own property of aCollection
_Helper.updateExisting(mChangeListeners, sPath, aCollection, {$count : vCount});
} | javascript | function setCount(mChangeListeners, sPath, aCollection, vCount) {
// Note: @odata.count is of type Edm.Int64, represented as a string in OData responses;
// $count should be a number and the loss of precision is acceptable
if (typeof vCount === "string") {
vCount = parseInt(vCount);
}
// Note: this relies on $count being present as an own property of aCollection
_Helper.updateExisting(mChangeListeners, sPath, aCollection, {$count : vCount});
} | [
"function",
"setCount",
"(",
"mChangeListeners",
",",
"sPath",
",",
"aCollection",
",",
"vCount",
")",
"{",
"// Note: @odata.count is of type Edm.Int64, represented as a string in OData responses;",
"// $count should be a number and the loss of precision is acceptable",
"if",
"(",
"t... | Sets the collection's $count: a number representing the sum of the element count on
server-side and the number of transient elements created on the client. It may be
<code>undefined</code>, but not <code>Infinity</code>.
@param {object} mChangeListeners A map of change listeners by path
@param {string} sPath The path of the collection in the cache (as used by change listeners)
@param {array} aCollection The collection
@param {string|number} vCount The count | [
"Sets",
"the",
"collection",
"s",
"$count",
":",
"a",
"number",
"representing",
"the",
"sum",
"of",
"the",
"element",
"count",
"on",
"server",
"-",
"side",
"and",
"the",
"number",
"of",
"transient",
"elements",
"created",
"on",
"the",
"client",
".",
"It",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Cache.js#L62-L70 | train | Sets the count of the items in the given collection. | [
30522,
3853,
2275,
3597,
16671,
1006,
11338,
18003,
29282,
6528,
2545,
1010,
14690,
2232,
1010,
9353,
14511,
18491,
1010,
18315,
21723,
1007,
1063,
1013,
1013,
3602,
1024,
1030,
1051,
2850,
2696,
1012,
4175,
2003,
1997,
2828,
3968,
2213,
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.dt/src/sap/ui/dt/ElementOverlay.js | function(oChild1, oChild2) {
var oGeometry1 = DOMUtil.getGeometry(oChild1);
var oGeometry2 = DOMUtil.getGeometry(oChild2);
var oPosition1 = oGeometry1 && oGeometry1.position;
var oPosition2 = oGeometry2 && oGeometry2.position;
if (oPosition1 && oPosition2) {
var iBottom1 = oPosition1.top + oGeometry1.size.height;
var iBottom2 = oPosition2.top + oGeometry2.size.height;
if (oPosition1.top < oPosition2.top) {
if (iBottom1 >= iBottom2 && oPosition2.left < oPosition1.left) {
/* Example:
+--------------+
+------+ | |
| 2 | | 1 |
+------+ | |
+--------------+
Despites 1st overlay's top is above 2nd element,
the order should be switched, since 2nd element
is shorter and is more to the left
*/
return 1;
} else {
return -1; // do not switch order
}
} else if (oPosition1.top === oPosition2.top) {
if (oPosition1.left === oPosition2.left) {
// Give priority to smaller block by height or width
if (
oGeometry1.size.height < oGeometry2.size.height
|| oGeometry1.size.width < oGeometry2.size.width
) {
return -1;
} else if (
oGeometry1.size.height > oGeometry2.size.height
|| oGeometry1.size.width > oGeometry2.size.width
) {
return 1;
} else {
return 0;
}
} else if (oPosition1.left < oPosition2.left) {
return -1; // order is correct
} else {
return 1; // switch order
}
} else if (iBottom1 <= iBottom2 && oPosition2.left > oPosition1.left) { // if (oPosition1.top > oPosition2.top)
/* see picture above, but switch 1 and 2 - order is correct */
return -1;
} else {
/* Example:
+--------------+
+------+ | 2 |
| 1 | +--------------+
| |
+------+
Since 1st overlay's both top and bottom coordinates are
bellow in dom, then top and bottom of 2nd, they should be switched
*/
return 1;
}
}
return 0;
} | javascript | function(oChild1, oChild2) {
var oGeometry1 = DOMUtil.getGeometry(oChild1);
var oGeometry2 = DOMUtil.getGeometry(oChild2);
var oPosition1 = oGeometry1 && oGeometry1.position;
var oPosition2 = oGeometry2 && oGeometry2.position;
if (oPosition1 && oPosition2) {
var iBottom1 = oPosition1.top + oGeometry1.size.height;
var iBottom2 = oPosition2.top + oGeometry2.size.height;
if (oPosition1.top < oPosition2.top) {
if (iBottom1 >= iBottom2 && oPosition2.left < oPosition1.left) {
/* Example:
+--------------+
+------+ | |
| 2 | | 1 |
+------+ | |
+--------------+
Despites 1st overlay's top is above 2nd element,
the order should be switched, since 2nd element
is shorter and is more to the left
*/
return 1;
} else {
return -1; // do not switch order
}
} else if (oPosition1.top === oPosition2.top) {
if (oPosition1.left === oPosition2.left) {
// Give priority to smaller block by height or width
if (
oGeometry1.size.height < oGeometry2.size.height
|| oGeometry1.size.width < oGeometry2.size.width
) {
return -1;
} else if (
oGeometry1.size.height > oGeometry2.size.height
|| oGeometry1.size.width > oGeometry2.size.width
) {
return 1;
} else {
return 0;
}
} else if (oPosition1.left < oPosition2.left) {
return -1; // order is correct
} else {
return 1; // switch order
}
} else if (iBottom1 <= iBottom2 && oPosition2.left > oPosition1.left) { // if (oPosition1.top > oPosition2.top)
/* see picture above, but switch 1 and 2 - order is correct */
return -1;
} else {
/* Example:
+--------------+
+------+ | 2 |
| 1 | +--------------+
| |
+------+
Since 1st overlay's both top and bottom coordinates are
bellow in dom, then top and bottom of 2nd, they should be switched
*/
return 1;
}
}
return 0;
} | [
"function",
"(",
"oChild1",
",",
"oChild2",
")",
"{",
"var",
"oGeometry1",
"=",
"DOMUtil",
".",
"getGeometry",
"(",
"oChild1",
")",
";",
"var",
"oGeometry2",
"=",
"DOMUtil",
".",
"getGeometry",
"(",
"oChild2",
")",
";",
"var",
"oPosition1",
"=",
"oGeometry... | compares two DOM Nodes and returns 1, if first child should be bellow in dom order | [
"compares",
"two",
"DOM",
"Nodes",
"and",
"returns",
"1",
"if",
"first",
"child",
"should",
"be",
"bellow",
"in",
"dom",
"order"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.dt/src/sap/ui/dt/ElementOverlay.js#L388-L453 | train | Returns - 1 if the two nodes are equal or 1 if the two nodes are equal or 0 if the two nodes are equal | [
30522,
3853,
1006,
28166,
4014,
2094,
2487,
1010,
28166,
4014,
2094,
2475,
1007,
1063,
13075,
13958,
8780,
24327,
2487,
1027,
14383,
21823,
2140,
1012,
2131,
3351,
8462,
11129,
1006,
28166,
4014,
2094,
2487,
1007,
1025,
13075,
13958,
8780,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
pixijs/pixi.js | packages/prepare/src/BasePrepare.js | drawText | function drawText(helper, item)
{
if (item instanceof Text)
{
// updating text will return early if it is not dirty
item.updateText(true);
return true;
}
return false;
} | javascript | function drawText(helper, item)
{
if (item instanceof Text)
{
// updating text will return early if it is not dirty
item.updateText(true);
return true;
}
return false;
} | [
"function",
"drawText",
"(",
"helper",
",",
"item",
")",
"{",
"if",
"(",
"item",
"instanceof",
"Text",
")",
"{",
"// updating text will return early if it is not dirty",
"item",
".",
"updateText",
"(",
"true",
")",
";",
"return",
"true",
";",
"}",
"return",
"f... | Built-in hook to draw PIXI.Text to its texture.
@private
@param {PIXI.Renderer|PIXI.CanvasPrepare} helper - Not used by this upload handler
@param {PIXI.DisplayObject} item - Item to check
@return {boolean} If item was uploaded. | [
"Built",
"-",
"in",
"hook",
"to",
"draw",
"PIXI",
".",
"Text",
"to",
"its",
"texture",
"."
] | 99ae03b7565ae7ca5a6de633b0a277f7128fa4d0 | https://github.com/pixijs/pixi.js/blob/99ae03b7565ae7ca5a6de633b0a277f7128fa4d0/packages/prepare/src/BasePrepare.js#L405-L416 | train | draw text from a node | [
30522,
3853,
4009,
18209,
1006,
2393,
2121,
1010,
8875,
1007,
1063,
2065,
1006,
8875,
6013,
11253,
3793,
1007,
1063,
1013,
1013,
2039,
16616,
3793,
2097,
2709,
2220,
2065,
2009,
2003,
2025,
6530,
8875,
1012,
10651,
18209,
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... |
NetEase/pomelo | lib/util/appUtil.js | function(app, args) {
app.set(Constants.RESERVED.ENV, args.env || process.env.NODE_ENV || Constants.RESERVED.ENV_DEV, true);
} | javascript | function(app, args) {
app.set(Constants.RESERVED.ENV, args.env || process.env.NODE_ENV || Constants.RESERVED.ENV_DEV, true);
} | [
"function",
"(",
"app",
",",
"args",
")",
"{",
"app",
".",
"set",
"(",
"Constants",
".",
"RESERVED",
".",
"ENV",
",",
"args",
".",
"env",
"||",
"process",
".",
"env",
".",
"NODE_ENV",
"||",
"Constants",
".",
"RESERVED",
".",
"ENV_DEV",
",",
"true",
... | Setup enviroment. | [
"Setup",
"enviroment",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/util/appUtil.js#L193-L195 | train | Set the environment variable | [
30522,
3853,
1006,
10439,
1010,
12098,
5620,
1007,
1063,
10439,
1012,
2275,
1006,
5377,
2015,
1012,
9235,
1012,
4372,
2615,
1010,
12098,
5620,
1012,
4372,
2615,
1064,
1064,
2832,
1012,
4372,
2615,
1012,
13045,
1035,
4372,
2615,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/AnalyticalBinding.js | logUnsupportedPropertyInSelect | function logUnsupportedPropertyInSelect(sPath, sSelectedProperty, oDimensionOrMeasure) {
var sDimensionOrMeasure = oDimensionOrMeasure
instanceof sap.ui.model.analytics.odata4analytics.Dimension
? "dimension" : "measure";
if (oDimensionOrMeasure.getName() === sSelectedProperty) {
oLogger.warning("Ignored the 'select' binding parameter, because it contains"
+ " the " + sDimensionOrMeasure + " property '"
+ sSelectedProperty
+ "' which is not contained in the analytical info (see updateAnalyticalInfo)",
sPath);
} else {
oLogger.warning("Ignored the 'select' binding parameter, because the property '"
+ sSelectedProperty + "' is associated with the "
+ sDimensionOrMeasure + " property '"
+ oDimensionOrMeasure.getName() + "' which is not contained in the analytical"
+ " info (see updateAnalyticalInfo)",
sPath);
}
} | javascript | function logUnsupportedPropertyInSelect(sPath, sSelectedProperty, oDimensionOrMeasure) {
var sDimensionOrMeasure = oDimensionOrMeasure
instanceof sap.ui.model.analytics.odata4analytics.Dimension
? "dimension" : "measure";
if (oDimensionOrMeasure.getName() === sSelectedProperty) {
oLogger.warning("Ignored the 'select' binding parameter, because it contains"
+ " the " + sDimensionOrMeasure + " property '"
+ sSelectedProperty
+ "' which is not contained in the analytical info (see updateAnalyticalInfo)",
sPath);
} else {
oLogger.warning("Ignored the 'select' binding parameter, because the property '"
+ sSelectedProperty + "' is associated with the "
+ sDimensionOrMeasure + " property '"
+ oDimensionOrMeasure.getName() + "' which is not contained in the analytical"
+ " info (see updateAnalyticalInfo)",
sPath);
}
} | [
"function",
"logUnsupportedPropertyInSelect",
"(",
"sPath",
",",
"sSelectedProperty",
",",
"oDimensionOrMeasure",
")",
"{",
"var",
"sDimensionOrMeasure",
"=",
"oDimensionOrMeasure",
"instanceof",
"sap",
".",
"ui",
".",
"model",
".",
"analytics",
".",
"odata4analytics",
... | Logs a warning that the given select property is not supported. Either it is a dimension or
a measure or it is associated with a dimension or a measure which is not part of the
analytical info.
@param {string} sPath The binding path
@param {string} sSelectedProperty The name of the selected property
@param {sap.ui.model.analytics.odata4analytics.Dimension
|sap.ui.model.analytics.odata4analytics.Measure} oDimensionOrMeasure
The dimension or measure that causes the issue | [
"Logs",
"a",
"warning",
"that",
"the",
"given",
"select",
"property",
"is",
"not",
"supported",
".",
"Either",
"it",
"is",
"a",
"dimension",
"or",
"a",
"measure",
"or",
"it",
"is",
"associated",
"with",
"a",
"dimension",
"or",
"a",
"measure",
"which",
"i... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/AnalyticalBinding.js#L157-L177 | train | Logs an unsupported property in the select binding | [
30522,
3853,
8833,
4609,
6342,
9397,
15613,
21572,
4842,
3723,
7076,
12260,
6593,
1006,
14690,
2232,
1010,
7020,
12260,
10985,
21572,
4842,
3723,
1010,
21045,
3549,
10992,
2953,
4168,
3022,
5397,
1007,
1063,
13075,
17371,
14428,
3619,
3258,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | getClosestHandle | function getClosestHandle ( proposal ) {
var closest = 100;
var handleNumber = false;
scope_Handles.forEach(function(handle, index){
// Disabled handles are ignored
if ( handle.hasAttribute('disabled') ) {
return;
}
var pos = Math.abs(scope_Locations[index] - proposal);
if ( pos < closest ) {
handleNumber = index;
closest = pos;
}
});
return handleNumber;
} | javascript | function getClosestHandle ( proposal ) {
var closest = 100;
var handleNumber = false;
scope_Handles.forEach(function(handle, index){
// Disabled handles are ignored
if ( handle.hasAttribute('disabled') ) {
return;
}
var pos = Math.abs(scope_Locations[index] - proposal);
if ( pos < closest ) {
handleNumber = index;
closest = pos;
}
});
return handleNumber;
} | [
"function",
"getClosestHandle",
"(",
"proposal",
")",
"{",
"var",
"closest",
"=",
"100",
";",
"var",
"handleNumber",
"=",
"false",
";",
"scope_Handles",
".",
"forEach",
"(",
"function",
"(",
"handle",
",",
"index",
")",
"{",
"// Disabled handles are ignored",
... | Find handle closest to a certain percentage on the slider | [
"Find",
"handle",
"closest",
"to",
"a",
"certain",
"percentage",
"on",
"the",
"slider"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1367-L1388 | train | Get closest handle to proposal | [
30522,
3853,
2131,
20464,
27465,
21604,
10362,
1006,
6378,
1007,
1063,
13075,
7541,
1027,
2531,
1025,
13075,
5047,
19172,
5677,
1027,
6270,
1025,
9531,
1035,
16024,
1012,
18921,
6776,
1006,
3853,
1006,
5047,
1010,
5950,
1007,
1063,
1013,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/angular | tools/gulp-tasks/cldr/extract.js | getDateTimeTranslations | function getDateTimeTranslations(localeData) {
const dayNames = localeData.main(`dates/calendars/gregorian/days`);
const monthNames = localeData.main(`dates/calendars/gregorian/months`);
const erasNames = localeData.main(`dates/calendars/gregorian/eras`);
const dayPeriods = getDayPeriodsAmPm(localeData);
const dayPeriodsFormat = removeDuplicates([
objectValues(dayPeriods.format.narrow),
objectValues(dayPeriods.format.abbreviated),
objectValues(dayPeriods.format.wide)
]);
const dayPeriodsStandalone = removeDuplicates([
objectValues(dayPeriods['stand-alone'].narrow),
objectValues(dayPeriods['stand-alone'].abbreviated),
objectValues(dayPeriods['stand-alone'].wide)
]);
const daysFormat = removeDuplicates([
objectValues(dayNames.format.narrow),
objectValues(dayNames.format.abbreviated),
objectValues(dayNames.format.wide),
objectValues(dayNames.format.short)
]);
const daysStandalone = removeDuplicates([
objectValues(dayNames['stand-alone'].narrow),
objectValues(dayNames['stand-alone'].abbreviated),
objectValues(dayNames['stand-alone'].wide),
objectValues(dayNames['stand-alone'].short)
]);
const monthsFormat = removeDuplicates([
objectValues(monthNames.format.narrow),
objectValues(monthNames.format.abbreviated),
objectValues(monthNames.format.wide)
]);
const monthsStandalone = removeDuplicates([
objectValues(monthNames['stand-alone'].narrow),
objectValues(monthNames['stand-alone'].abbreviated),
objectValues(monthNames['stand-alone'].wide)
]);
const eras = removeDuplicates([
[erasNames.eraNarrow['0'], erasNames.eraNarrow['1']],
[erasNames.eraAbbr['0'], erasNames.eraAbbr['1']],
[erasNames.eraNames['0'], erasNames.eraNames['1']]
]);
const dateTimeTranslations = [
...removeDuplicates([dayPeriodsFormat, dayPeriodsStandalone]),
...removeDuplicates([daysFormat, daysStandalone]),
...removeDuplicates([monthsFormat, monthsStandalone]),
eras
];
return dateTimeTranslations;
} | javascript | function getDateTimeTranslations(localeData) {
const dayNames = localeData.main(`dates/calendars/gregorian/days`);
const monthNames = localeData.main(`dates/calendars/gregorian/months`);
const erasNames = localeData.main(`dates/calendars/gregorian/eras`);
const dayPeriods = getDayPeriodsAmPm(localeData);
const dayPeriodsFormat = removeDuplicates([
objectValues(dayPeriods.format.narrow),
objectValues(dayPeriods.format.abbreviated),
objectValues(dayPeriods.format.wide)
]);
const dayPeriodsStandalone = removeDuplicates([
objectValues(dayPeriods['stand-alone'].narrow),
objectValues(dayPeriods['stand-alone'].abbreviated),
objectValues(dayPeriods['stand-alone'].wide)
]);
const daysFormat = removeDuplicates([
objectValues(dayNames.format.narrow),
objectValues(dayNames.format.abbreviated),
objectValues(dayNames.format.wide),
objectValues(dayNames.format.short)
]);
const daysStandalone = removeDuplicates([
objectValues(dayNames['stand-alone'].narrow),
objectValues(dayNames['stand-alone'].abbreviated),
objectValues(dayNames['stand-alone'].wide),
objectValues(dayNames['stand-alone'].short)
]);
const monthsFormat = removeDuplicates([
objectValues(monthNames.format.narrow),
objectValues(monthNames.format.abbreviated),
objectValues(monthNames.format.wide)
]);
const monthsStandalone = removeDuplicates([
objectValues(monthNames['stand-alone'].narrow),
objectValues(monthNames['stand-alone'].abbreviated),
objectValues(monthNames['stand-alone'].wide)
]);
const eras = removeDuplicates([
[erasNames.eraNarrow['0'], erasNames.eraNarrow['1']],
[erasNames.eraAbbr['0'], erasNames.eraAbbr['1']],
[erasNames.eraNames['0'], erasNames.eraNames['1']]
]);
const dateTimeTranslations = [
...removeDuplicates([dayPeriodsFormat, dayPeriodsStandalone]),
...removeDuplicates([daysFormat, daysStandalone]),
...removeDuplicates([monthsFormat, monthsStandalone]),
eras
];
return dateTimeTranslations;
} | [
"function",
"getDateTimeTranslations",
"(",
"localeData",
")",
"{",
"const",
"dayNames",
"=",
"localeData",
".",
"main",
"(",
"`",
"`",
")",
";",
"const",
"monthNames",
"=",
"localeData",
".",
"main",
"(",
"`",
"`",
")",
";",
"const",
"erasNames",
"=",
"... | Returns date-related translations for a locale
@returns [ dayPeriodsFormat, dayPeriodsStandalone, daysFormat, dayStandalone, monthsFormat, monthsStandalone, eras ]
each value: [ narrow, abbreviated, wide, short? ] | [
"Returns",
"date",
"-",
"related",
"translations",
"for",
"a",
"locale"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/cldr/extract.js#L284-L342 | train | Get the translations for the given locale | [
30522,
3853,
2131,
13701,
7292,
6494,
3619,
13490,
2015,
1006,
2334,
30524,
1006,
1036,
5246,
1013,
8094,
2015,
1013,
25847,
1013,
2706,
1036,
1007,
1025,
9530,
3367,
28500,
18442,
2015,
1027,
2334,
11960,
2696,
1012,
2364,
1006,
1036,
5246... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/video/zy.media.js | function() {
var t = this;
// Native events
if (zyMedia.features.nativeFullscreenPrefix != '-') {
// Chrome doesn't alays fire this in an iframe
var func = function(e) {
if (t.isFullScreen) {
if (!isInFullScreenMode()) {
t.exitFullScreen()
}
}
};
document.addEventListener(zyMedia.features.nativeFullscreenPrefix + 'fullscreenchange', func)
}
t.fullscreenBtn = document.createElement('div');
t.fullscreenBtn.className = 'zy_fullscreen_btn';
t.controls.appendChild(t.fullscreenBtn);
t.fullscreenBtn.addEventListener('click', function() {
if ((zyMedia.features.nativeFullscreenPrefix != '-' && isInFullScreenMode()) || t.isFullScreen) {
t.exitFullScreen()
} else {
t.enterFullScreen()
}
});
} | javascript | function() {
var t = this;
// Native events
if (zyMedia.features.nativeFullscreenPrefix != '-') {
// Chrome doesn't alays fire this in an iframe
var func = function(e) {
if (t.isFullScreen) {
if (!isInFullScreenMode()) {
t.exitFullScreen()
}
}
};
document.addEventListener(zyMedia.features.nativeFullscreenPrefix + 'fullscreenchange', func)
}
t.fullscreenBtn = document.createElement('div');
t.fullscreenBtn.className = 'zy_fullscreen_btn';
t.controls.appendChild(t.fullscreenBtn);
t.fullscreenBtn.addEventListener('click', function() {
if ((zyMedia.features.nativeFullscreenPrefix != '-' && isInFullScreenMode()) || t.isFullScreen) {
t.exitFullScreen()
} else {
t.enterFullScreen()
}
});
} | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
";",
"// Native events",
"if",
"(",
"zyMedia",
".",
"features",
".",
"nativeFullscreenPrefix",
"!=",
"'-'",
")",
"{",
"// Chrome doesn't alays fire this in an iframe",
"var",
"func",
"=",
"function",
"(",
"e",
... | Fullscreen button | [
"Fullscreen",
"button"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/video/zy.media.js#L708-L735 | train | Add fullscreen event | [
30522,
3853,
1006,
1007,
1063,
13075,
1056,
1027,
2023,
1025,
1013,
1013,
3128,
2824,
2065,
1006,
1062,
25219,
9032,
1012,
2838,
1012,
3128,
3993,
4877,
24410,
28139,
8873,
2595,
999,
1027,
1005,
1011,
1005,
1007,
1063,
1013,
1013,
18546,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/api/deprecate.js | deprecateRenamedMethod | function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) {
msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead');
var fn = objectPath.get(instance, newName);
instance[oldName] = deprecateMethod(book, key, fn, msg);
} | javascript | function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) {
msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead');
var fn = objectPath.get(instance, newName);
instance[oldName] = deprecateMethod(book, key, fn, msg);
} | [
"function",
"deprecateRenamedMethod",
"(",
"book",
",",
"key",
",",
"instance",
",",
"oldName",
",",
"newName",
",",
"msg",
")",
"{",
"msg",
"=",
"msg",
"||",
"(",
"'\"'",
"+",
"oldName",
"+",
"'\" is deprecated, use \"'",
"+",
"newName",
"+",
"'()\" instead... | Deprecate a method in favor of another one
@param {Book} book
@param {String} key
@param {Object} instance
@param {String} oldName
@param {String} newName | [
"Deprecate",
"a",
"method",
"in",
"favor",
"of",
"another",
"one"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L109-L114 | train | Deprecate a method in a node. | [
30522,
3853,
30524,
2003,
2139,
28139,
12921,
1010,
2224,
1000,
1005,
1009,
2047,
18442,
1009,
1005,
1006,
1007,
1000,
2612,
1005,
1007,
1025,
13075,
1042,
2078,
1027,
4874,
15069,
1012,
2131,
1006,
6013,
1010,
2047,
18442,
1007,
1025,
6013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/sidenav/sidenav.js | SidenavDirective | function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInteraction, $animate,
$compile, $parse, $log, $q, $document, $window, $$rAF) {
return {
restrict: 'E',
scope: {
isOpen: '=?mdIsOpen'
},
controller: '$mdSidenavController',
compile: function(element) {
element.addClass('md-closed').attr('tabIndex', '-1');
return postLink;
}
};
/**
* Directive Post Link function...
*/
function postLink(scope, element, attr, sidenavCtrl) {
var lastParentOverFlow;
var backdrop;
var disableScrollTarget = null;
var disableCloseEvents;
var triggeringInteractionType;
var triggeringElement = null;
var previousContainerStyles;
var promise = $q.when(true);
var isLockedOpenParsed = $parse(attr.mdIsLockedOpen);
var ngWindow = angular.element($window);
var isLocked = function() {
return isLockedOpenParsed(scope.$parent, {
$media: function(arg) {
$log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead.");
return $mdMedia(arg);
},
$mdMedia: $mdMedia
});
};
if (attr.mdDisableScrollTarget) {
disableScrollTarget = $document[0].querySelector(attr.mdDisableScrollTarget);
if (disableScrollTarget) {
disableScrollTarget = angular.element(disableScrollTarget);
} else {
$log.warn($mdUtil.supplant('mdSidenav: couldn\'t find element matching ' +
'selector "{selector}". Falling back to parent.',
{ selector: attr.mdDisableScrollTarget }));
}
}
if (!disableScrollTarget) {
disableScrollTarget = element.parent();
}
// Only create the backdrop if the backdrop isn't disabled.
if (!attr.hasOwnProperty('mdDisableBackdrop')) {
backdrop = $mdUtil.createBackdrop(scope, "md-sidenav-backdrop md-opaque ng-enter");
}
// If md-disable-close-events is set on the sidenav we will disable
// backdrop click and Escape key events
if (attr.hasOwnProperty('mdDisableCloseEvents')) {
disableCloseEvents = true;
}
element.addClass('_md'); // private md component indicator for styling
$mdTheming(element);
// The backdrop should inherit the sidenavs theme,
// because the backdrop will take its parent theme by default.
if (backdrop) $mdTheming.inherit(backdrop, element);
element.on('$destroy', function() {
backdrop && backdrop.remove();
sidenavCtrl.destroy();
});
scope.$on('$destroy', function(){
backdrop && backdrop.remove();
});
scope.$watch(isLocked, updateIsLocked);
scope.$watch('isOpen', updateIsOpen);
// Publish special accessor for the Controller instance
sidenavCtrl.$toggleOpen = toggleOpen;
/**
* Toggle the DOM classes to indicate `locked`
* @param isLocked
* @param oldValue
*/
function updateIsLocked(isLocked, oldValue) {
scope.isLockedOpen = isLocked;
if (isLocked === oldValue) {
element.toggleClass('md-locked-open', !!isLocked);
} else {
$animate[isLocked ? 'addClass' : 'removeClass'](element, 'md-locked-open');
}
if (backdrop) {
backdrop.toggleClass('md-locked-open', !!isLocked);
}
}
/**
* Toggle the SideNav view and attach/detach listeners
* @param isOpen
*/
function updateIsOpen(isOpen) {
// Support deprecated md-sidenav-focus attribute as fallback
var focusEl = $mdUtil.findFocusTarget(element) ||
$mdUtil.findFocusTarget(element,'[md-sidenav-focus]') || element;
var parent = element.parent();
var restorePositioning;
// If the user hasn't set the disable close events property we are adding
// click and escape events to close the sidenav
if (!disableCloseEvents) {
parent[isOpen ? 'on' : 'off']('keydown', onKeyDown);
if (backdrop) backdrop[isOpen ? 'on' : 'off']('click', close);
}
restorePositioning = updateContainerPositions(parent, isOpen);
if (isOpen) {
// Capture upon opening..
triggeringElement = $document[0].activeElement;
triggeringInteractionType = $mdInteraction.getLastInteractionType();
}
disableParentScroll(isOpen);
return promise = $q.all([
isOpen && backdrop ? $animate.enter(backdrop, parent) : backdrop ?
$animate.leave(backdrop) : $q.when(true),
$animate[isOpen ? 'removeClass' : 'addClass'](element, 'md-closed')
]).then(function() {
// Perform focus when animations are ALL done...
if (scope.isOpen) {
$$rAF(function() {
// Notifies child components that the sidenav was opened. Should wait
// a frame in order to allow for the element height to be computed.
ngWindow.triggerHandler('resize');
});
focusEl && focusEl.focus();
}
// Restores the positioning on the sidenav and backdrop.
restorePositioning && restorePositioning();
});
}
function updateContainerPositions(parent, willOpen) {
var drawerEl = element[0];
var scrollTop = parent[0].scrollTop;
if (willOpen && scrollTop) {
previousContainerStyles = {
top: drawerEl.style.top,
bottom: drawerEl.style.bottom,
height: drawerEl.style.height
};
// When the parent is scrolled down, then we want to be able to show the sidenav at the
// current scroll position. We're moving the sidenav down to the correct scroll position
// and apply the height of the parent, to increase the performance. Using 100% as height,
// will impact the performance heavily.
var positionStyle = {
top: scrollTop + 'px',
bottom: 'auto',
height: parent[0].clientHeight + 'px'
};
// Apply the new position styles to the sidenav and backdrop.
element.css(positionStyle);
backdrop.css(positionStyle);
}
// When the sidenav is closing and we have previous defined container styles,
// then we return a restore function, which resets the sidenav and backdrop.
if (!willOpen && previousContainerStyles) {
return function() {
drawerEl.style.top = previousContainerStyles.top;
drawerEl.style.bottom = previousContainerStyles.bottom;
drawerEl.style.height = previousContainerStyles.height;
backdrop[0].style.top = null;
backdrop[0].style.bottom = null;
backdrop[0].style.height = null;
previousContainerStyles = null;
};
}
}
/**
* Prevent parent scrolling (when the SideNav is open)
*/
function disableParentScroll(disabled) {
if (disabled && !lastParentOverFlow) {
lastParentOverFlow = disableScrollTarget.css('overflow');
disableScrollTarget.css('overflow', 'hidden');
} else if (angular.isDefined(lastParentOverFlow)) {
disableScrollTarget.css('overflow', lastParentOverFlow);
lastParentOverFlow = undefined;
}
}
/**
* Toggle the sideNav view and publish a promise to be resolved when
* the view animation finishes.
* @param {boolean} isOpen true to open the sidenav, false to close it
* @returns {*} promise to be resolved when the view animation finishes
*/
function toggleOpen(isOpen) {
if (scope.isOpen === isOpen) {
return $q.when(true);
} else {
if (scope.isOpen && sidenavCtrl.onCloseCb) sidenavCtrl.onCloseCb();
return $q(function(resolve) {
// Toggle value to force an async `updateIsOpen()` to run
scope.isOpen = isOpen;
$mdUtil.nextTick(function() {
// When the current `updateIsOpen()` animation finishes
promise.then(function(result) {
if (!scope.isOpen && triggeringElement && triggeringInteractionType === 'keyboard') {
// reset focus to originating element (if available) upon close
triggeringElement.focus();
triggeringElement = null;
}
resolve(result);
});
});
});
}
}
/**
* Auto-close sideNav when the `escape` key is pressed.
* @param {KeyboardEvent} ev keydown event
*/
function onKeyDown(ev) {
var isEscape = (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE);
return isEscape ? close(ev) : $q.when(true);
}
/**
* With backdrop `clicks` or `escape` key-press, immediately apply the CSS close transition...
* Then notify the controller to close() and perform its own actions.
* @param {Event} ev
* @returns {*}
*/
function close(ev) {
ev.preventDefault();
return sidenavCtrl.close();
}
}
} | javascript | function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInteraction, $animate,
$compile, $parse, $log, $q, $document, $window, $$rAF) {
return {
restrict: 'E',
scope: {
isOpen: '=?mdIsOpen'
},
controller: '$mdSidenavController',
compile: function(element) {
element.addClass('md-closed').attr('tabIndex', '-1');
return postLink;
}
};
/**
* Directive Post Link function...
*/
function postLink(scope, element, attr, sidenavCtrl) {
var lastParentOverFlow;
var backdrop;
var disableScrollTarget = null;
var disableCloseEvents;
var triggeringInteractionType;
var triggeringElement = null;
var previousContainerStyles;
var promise = $q.when(true);
var isLockedOpenParsed = $parse(attr.mdIsLockedOpen);
var ngWindow = angular.element($window);
var isLocked = function() {
return isLockedOpenParsed(scope.$parent, {
$media: function(arg) {
$log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead.");
return $mdMedia(arg);
},
$mdMedia: $mdMedia
});
};
if (attr.mdDisableScrollTarget) {
disableScrollTarget = $document[0].querySelector(attr.mdDisableScrollTarget);
if (disableScrollTarget) {
disableScrollTarget = angular.element(disableScrollTarget);
} else {
$log.warn($mdUtil.supplant('mdSidenav: couldn\'t find element matching ' +
'selector "{selector}". Falling back to parent.',
{ selector: attr.mdDisableScrollTarget }));
}
}
if (!disableScrollTarget) {
disableScrollTarget = element.parent();
}
// Only create the backdrop if the backdrop isn't disabled.
if (!attr.hasOwnProperty('mdDisableBackdrop')) {
backdrop = $mdUtil.createBackdrop(scope, "md-sidenav-backdrop md-opaque ng-enter");
}
// If md-disable-close-events is set on the sidenav we will disable
// backdrop click and Escape key events
if (attr.hasOwnProperty('mdDisableCloseEvents')) {
disableCloseEvents = true;
}
element.addClass('_md'); // private md component indicator for styling
$mdTheming(element);
// The backdrop should inherit the sidenavs theme,
// because the backdrop will take its parent theme by default.
if (backdrop) $mdTheming.inherit(backdrop, element);
element.on('$destroy', function() {
backdrop && backdrop.remove();
sidenavCtrl.destroy();
});
scope.$on('$destroy', function(){
backdrop && backdrop.remove();
});
scope.$watch(isLocked, updateIsLocked);
scope.$watch('isOpen', updateIsOpen);
// Publish special accessor for the Controller instance
sidenavCtrl.$toggleOpen = toggleOpen;
/**
* Toggle the DOM classes to indicate `locked`
* @param isLocked
* @param oldValue
*/
function updateIsLocked(isLocked, oldValue) {
scope.isLockedOpen = isLocked;
if (isLocked === oldValue) {
element.toggleClass('md-locked-open', !!isLocked);
} else {
$animate[isLocked ? 'addClass' : 'removeClass'](element, 'md-locked-open');
}
if (backdrop) {
backdrop.toggleClass('md-locked-open', !!isLocked);
}
}
/**
* Toggle the SideNav view and attach/detach listeners
* @param isOpen
*/
function updateIsOpen(isOpen) {
// Support deprecated md-sidenav-focus attribute as fallback
var focusEl = $mdUtil.findFocusTarget(element) ||
$mdUtil.findFocusTarget(element,'[md-sidenav-focus]') || element;
var parent = element.parent();
var restorePositioning;
// If the user hasn't set the disable close events property we are adding
// click and escape events to close the sidenav
if (!disableCloseEvents) {
parent[isOpen ? 'on' : 'off']('keydown', onKeyDown);
if (backdrop) backdrop[isOpen ? 'on' : 'off']('click', close);
}
restorePositioning = updateContainerPositions(parent, isOpen);
if (isOpen) {
// Capture upon opening..
triggeringElement = $document[0].activeElement;
triggeringInteractionType = $mdInteraction.getLastInteractionType();
}
disableParentScroll(isOpen);
return promise = $q.all([
isOpen && backdrop ? $animate.enter(backdrop, parent) : backdrop ?
$animate.leave(backdrop) : $q.when(true),
$animate[isOpen ? 'removeClass' : 'addClass'](element, 'md-closed')
]).then(function() {
// Perform focus when animations are ALL done...
if (scope.isOpen) {
$$rAF(function() {
// Notifies child components that the sidenav was opened. Should wait
// a frame in order to allow for the element height to be computed.
ngWindow.triggerHandler('resize');
});
focusEl && focusEl.focus();
}
// Restores the positioning on the sidenav and backdrop.
restorePositioning && restorePositioning();
});
}
function updateContainerPositions(parent, willOpen) {
var drawerEl = element[0];
var scrollTop = parent[0].scrollTop;
if (willOpen && scrollTop) {
previousContainerStyles = {
top: drawerEl.style.top,
bottom: drawerEl.style.bottom,
height: drawerEl.style.height
};
// When the parent is scrolled down, then we want to be able to show the sidenav at the
// current scroll position. We're moving the sidenav down to the correct scroll position
// and apply the height of the parent, to increase the performance. Using 100% as height,
// will impact the performance heavily.
var positionStyle = {
top: scrollTop + 'px',
bottom: 'auto',
height: parent[0].clientHeight + 'px'
};
// Apply the new position styles to the sidenav and backdrop.
element.css(positionStyle);
backdrop.css(positionStyle);
}
// When the sidenav is closing and we have previous defined container styles,
// then we return a restore function, which resets the sidenav and backdrop.
if (!willOpen && previousContainerStyles) {
return function() {
drawerEl.style.top = previousContainerStyles.top;
drawerEl.style.bottom = previousContainerStyles.bottom;
drawerEl.style.height = previousContainerStyles.height;
backdrop[0].style.top = null;
backdrop[0].style.bottom = null;
backdrop[0].style.height = null;
previousContainerStyles = null;
};
}
}
/**
* Prevent parent scrolling (when the SideNav is open)
*/
function disableParentScroll(disabled) {
if (disabled && !lastParentOverFlow) {
lastParentOverFlow = disableScrollTarget.css('overflow');
disableScrollTarget.css('overflow', 'hidden');
} else if (angular.isDefined(lastParentOverFlow)) {
disableScrollTarget.css('overflow', lastParentOverFlow);
lastParentOverFlow = undefined;
}
}
/**
* Toggle the sideNav view and publish a promise to be resolved when
* the view animation finishes.
* @param {boolean} isOpen true to open the sidenav, false to close it
* @returns {*} promise to be resolved when the view animation finishes
*/
function toggleOpen(isOpen) {
if (scope.isOpen === isOpen) {
return $q.when(true);
} else {
if (scope.isOpen && sidenavCtrl.onCloseCb) sidenavCtrl.onCloseCb();
return $q(function(resolve) {
// Toggle value to force an async `updateIsOpen()` to run
scope.isOpen = isOpen;
$mdUtil.nextTick(function() {
// When the current `updateIsOpen()` animation finishes
promise.then(function(result) {
if (!scope.isOpen && triggeringElement && triggeringInteractionType === 'keyboard') {
// reset focus to originating element (if available) upon close
triggeringElement.focus();
triggeringElement = null;
}
resolve(result);
});
});
});
}
}
/**
* Auto-close sideNav when the `escape` key is pressed.
* @param {KeyboardEvent} ev keydown event
*/
function onKeyDown(ev) {
var isEscape = (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE);
return isEscape ? close(ev) : $q.when(true);
}
/**
* With backdrop `clicks` or `escape` key-press, immediately apply the CSS close transition...
* Then notify the controller to close() and perform its own actions.
* @param {Event} ev
* @returns {*}
*/
function close(ev) {
ev.preventDefault();
return sidenavCtrl.close();
}
}
} | [
"function",
"SidenavDirective",
"(",
"$mdMedia",
",",
"$mdUtil",
",",
"$mdConstant",
",",
"$mdTheming",
",",
"$mdInteraction",
",",
"$animate",
",",
"$compile",
",",
"$parse",
",",
"$log",
",",
"$q",
",",
"$document",
",",
"$window",
",",
"$$rAF",
")",
"{",
... | @ngdoc directive
@name mdSidenav
@module material.components.sidenav
@restrict E
@description
A Sidenav component that can be opened and closed programmatically.
By default, upon opening it will slide out on top of the main content area.
For keyboard and screen reader accessibility, focus is sent to the sidenav wrapper by default.
It can be overridden with the `md-autofocus` directive on the child element you want focused.
@usage
<hljs lang="html">
<div layout="row" ng-controller="MyController">
<md-sidenav md-component-id="left" class="md-sidenav-left">
Left Nav!
</md-sidenav>
<md-content>
Center Content
<md-button ng-click="openLeftMenu()">
Open Left Menu
</md-button>
</md-content>
<md-sidenav md-component-id="right"
md-is-locked-open="$mdMedia('min-width: 333px')"
class="md-sidenav-right">
<form>
<md-input-container>
<label for="testInput">Test input</label>
<input id="testInput" type="text"
ng-model="data" md-autofocus>
</md-input-container>
</form>
</md-sidenav>
</div>
</hljs>
<hljs lang="js">
var app = angular.module('myApp', ['ngMaterial']);
app.controller('MyController', function($scope, $mdSidenav) {
$scope.openLeftMenu = function() {
$mdSidenav('left').toggle();
};
});
</hljs>
@param {expression=} md-is-open A model bound to whether the sidenav is opened.
@param {boolean=} md-disable-backdrop When present in the markup, the sidenav will not show a
backdrop.
@param {boolean=} md-disable-close-events When present in the markup, clicking the backdrop or
pressing the 'Escape' key will not close the sidenav.
@param {string=} md-component-id componentId to use with $mdSidenav service.
@param {expression=} md-is-locked-open When this expression evaluates to true,
the sidenav 'locks open': it falls into the content's flow instead
of appearing over it. This overrides the `md-is-open` attribute.
@param {string=} md-disable-scroll-target Selector, pointing to an element, whose scrolling will
be disabled when the sidenav is opened. By default this is the sidenav's direct parent.
The $mdMedia() service is exposed to the is-locked-open attribute, which
can be given a media query or one of the `sm`, `gt-sm`, `md`, `gt-md`, `lg` or `gt-lg` presets.
Examples:
- `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
- `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
- `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>` (locks open on small screens) | [
"@ngdoc",
"directive",
"@name",
"mdSidenav",
"@module",
"material",
".",
"components",
".",
"sidenav",
"@restrict",
"E"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L258-L522 | train | The Sidenav directive | [
30522,
3853,
2217,
2532,
16872,
7442,
15277,
1006,
1002,
9108,
16969,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
9108,
8663,
12693,
2102,
1010,
1002,
9108,
10760,
6562,
1010,
1002,
9108,
18447,
6906,
7542,
1010,
1002,
2019,
21499,
1010,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | mxForm | function mxForm(className)
{
this.table = document.createElement('table');
this.table.className = className;
this.body = document.createElement('tbody');
this.table.appendChild(this.body);
} | javascript | function mxForm(className)
{
this.table = document.createElement('table');
this.table.className = className;
this.body = document.createElement('tbody');
this.table.appendChild(this.body);
} | [
"function",
"mxForm",
"(",
"className",
")",
"{",
"this",
".",
"table",
"=",
"document",
".",
"createElement",
"(",
"'table'",
")",
";",
"this",
".",
"table",
".",
"className",
"=",
"className",
";",
"this",
".",
"body",
"=",
"document",
".",
"createElem... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxForm
A simple class for creating HTML forms.
Constructor: mxForm
Creates a HTML table using the specified classname. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxForm"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L12614-L12621 | train | This is the main function of the mxForm class. It is the main function of the mxForm class. It is the main function of the mxForm class. It is the main function of the mxForm class. It is the main function of the mxForm class. It is the main function of the mxForm class. | [
30522,
3853,
25630,
14192,
1006,
2465,
18442,
1007,
1063,
2023,
1012,
2795,
1027,
30524,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
26419,
7716,
2100,
1005,
1007,
1025,
2023,
1012,
2795,
1012,
10439,
10497,
19339,
1006,
2023,
1012,
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... |
angular/material | src/components/radioButton/radio-button.js | changeSelectedButton | function changeSelectedButton(parent, increment) {
// Coerce all child radio buttons into an array, then wrap then in an iterator
var buttons = $mdUtil.iterator(parent[0].querySelectorAll('md-radio-button'), true);
if (buttons.count()) {
var validate = function (button) {
// If disabled, then NOT valid
return !angular.element(button).attr("disabled");
};
var selected = parent[0].querySelector('md-radio-button.md-checked');
var target = buttons[increment < 0 ? 'previous' : 'next'](selected, validate) || buttons.first();
// Activate radioButton's click listener (triggerHandler won't create a real click event)
angular.element(target).triggerHandler('click');
}
} | javascript | function changeSelectedButton(parent, increment) {
// Coerce all child radio buttons into an array, then wrap then in an iterator
var buttons = $mdUtil.iterator(parent[0].querySelectorAll('md-radio-button'), true);
if (buttons.count()) {
var validate = function (button) {
// If disabled, then NOT valid
return !angular.element(button).attr("disabled");
};
var selected = parent[0].querySelector('md-radio-button.md-checked');
var target = buttons[increment < 0 ? 'previous' : 'next'](selected, validate) || buttons.first();
// Activate radioButton's click listener (triggerHandler won't create a real click event)
angular.element(target).triggerHandler('click');
}
} | [
"function",
"changeSelectedButton",
"(",
"parent",
",",
"increment",
")",
"{",
"// Coerce all child radio buttons into an array, then wrap then in an iterator",
"var",
"buttons",
"=",
"$mdUtil",
".",
"iterator",
"(",
"parent",
"[",
"0",
"]",
".",
"querySelectorAll",
"(",
... | Change the radio group's selected button by a given increment.
If no button is selected, select the first button. | [
"Change",
"the",
"radio",
"group",
"s",
"selected",
"button",
"by",
"a",
"given",
"increment",
".",
"If",
"no",
"button",
"is",
"selected",
"select",
"the",
"first",
"button",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L188-L204 | train | Change the selected button | [
30522,
3853,
3431,
12260,
10985,
8569,
15474,
1006,
6687,
1010,
4297,
28578,
4765,
1007,
1063,
1013,
1013,
24873,
19170,
2035,
2775,
2557,
11287,
2046,
2019,
9140,
1010,
2059,
10236,
2059,
1999,
2019,
2009,
6906,
4263,
13075,
11287,
1027,
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... |
SheetJS/js-xlsx | xlsx.js | parse_FilePassHeader | function parse_FilePassHeader(blob, length, oo) {
var o = oo || {}; o.Info = blob.read_shift(2); blob.l -= 2;
if(o.Info === 1) o.Data = parse_RC4Header(blob, length);
else o.Data = parse_RC4CryptoHeader(blob, length);
return o;
} | javascript | function parse_FilePassHeader(blob, length, oo) {
var o = oo || {}; o.Info = blob.read_shift(2); blob.l -= 2;
if(o.Info === 1) o.Data = parse_RC4Header(blob, length);
else o.Data = parse_RC4CryptoHeader(blob, length);
return o;
} | [
"function",
"parse_FilePassHeader",
"(",
"blob",
",",
"length",
",",
"oo",
")",
"{",
"var",
"o",
"=",
"oo",
"||",
"{",
"}",
";",
"o",
".",
"Info",
"=",
"blob",
".",
"read_shift",
"(",
"2",
")",
";",
"blob",
".",
"l",
"-=",
"2",
";",
"if",
"(",
... | /* 2.4.117 | [
"/",
"*",
"2",
".",
"4",
".",
"117"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L8415-L8420 | train | Parse the file pass header | [
30522,
3853,
11968,
3366,
1035,
5371,
15194,
4974,
2121,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
1051,
2080,
1007,
1063,
13075,
1051,
1027,
1051,
2080,
1064,
1064,
1063,
1065,
1025,
1051,
1012,
18558,
1027,
1038,
4135,
2497,
1012,
3191,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | DOMWalker_prepareTargetWindows | function DOMWalker_prepareTargetWindows(ids) {
var doc = this._controller.window.document;
// Go through all the provided ids
for (var i = 0; i < ids.length; i++) {
var node = this._getNode(ids[i]);
// Go further only, if the needed element exists
if (node) {
var idSet = ids[i];
// Decide if what we want to open is a new normal/modal window or if it
// will be opened in the current window.
switch (idSet.target) {
case DOMWalker.WINDOW_CURRENT:
this._processNode(node, idSet);
break;
case DOMWalker.WINDOW_MODAL:
// Modal windows have to be able to access that informations
var modalInfos = {ids : idSet.subContent,
callbackFilter : this._callbackFilter,
callbackNodeTest : this._callbackNodeTest,
callbackResults : this._callbackResults,
waitFunction : idSet.waitFunction}
persisted.modalInfos = modalInfos;
var md = new modalDialog.modalDialog(this._controller.window);
md.start(this._modalWindowHelper);
this._processNode(node, idSet);
md.waitForDialog();
break;
case DOMWalker.WINDOW_NEW:
this._processNode(node, idSet);
// Get the new non-modal window controller
var controller = utils.handleWindow('title', idSet.title,
false, true);
// Start a new DOMWalker instance
let domWalker = new DOMWalker(controller, this._callbackFilter,
this._callbackNodeTest,
this._callbackResults);
domWalker.walk(idSet.subContent,
controller.window.document.documentElement,
idSet.waitFunction);
// Close the window
controller.window.close();
break;
default:
throw new Error("Node does not exist: " + ids[i][ids[i].getBy]);
}
}
}
} | javascript | function DOMWalker_prepareTargetWindows(ids) {
var doc = this._controller.window.document;
// Go through all the provided ids
for (var i = 0; i < ids.length; i++) {
var node = this._getNode(ids[i]);
// Go further only, if the needed element exists
if (node) {
var idSet = ids[i];
// Decide if what we want to open is a new normal/modal window or if it
// will be opened in the current window.
switch (idSet.target) {
case DOMWalker.WINDOW_CURRENT:
this._processNode(node, idSet);
break;
case DOMWalker.WINDOW_MODAL:
// Modal windows have to be able to access that informations
var modalInfos = {ids : idSet.subContent,
callbackFilter : this._callbackFilter,
callbackNodeTest : this._callbackNodeTest,
callbackResults : this._callbackResults,
waitFunction : idSet.waitFunction}
persisted.modalInfos = modalInfos;
var md = new modalDialog.modalDialog(this._controller.window);
md.start(this._modalWindowHelper);
this._processNode(node, idSet);
md.waitForDialog();
break;
case DOMWalker.WINDOW_NEW:
this._processNode(node, idSet);
// Get the new non-modal window controller
var controller = utils.handleWindow('title', idSet.title,
false, true);
// Start a new DOMWalker instance
let domWalker = new DOMWalker(controller, this._callbackFilter,
this._callbackNodeTest,
this._callbackResults);
domWalker.walk(idSet.subContent,
controller.window.document.documentElement,
idSet.waitFunction);
// Close the window
controller.window.close();
break;
default:
throw new Error("Node does not exist: " + ids[i][ids[i].getBy]);
}
}
}
} | [
"function",
"DOMWalker_prepareTargetWindows",
"(",
"ids",
")",
"{",
"var",
"doc",
"=",
"this",
".",
"_controller",
".",
"window",
".",
"document",
";",
"// Go through all the provided ids",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ids",
".",
"length... | Main entry point to open new elements like windows, tabpanels, prefpanes,
dialogs
@param {array of objects} ids
Contains informations on the elements to open while
Object-elements: getBy - attribute-name of the attribute
containing the identification
information for the opener-element
subContent - array of ids of the opener-elements
in the window with the value of
the above getBy-attribute
target - information, where the new
elements will be opened
[1|2|4]
title - title of the opened dialog/window
waitFunction - The function used as an argument
for MozmillController.waitFor to
wait before starting the walk.
[optional - default: no waiting]
windowHandler - Window instance
[only needed for some tests] | [
"Main",
"entry",
"point",
"to",
"open",
"new",
"elements",
"like",
"windows",
"tabpanels",
"prefpanes",
"dialogs"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L251-L306 | train | Prepare target windows | [
30522,
3853,
14383,
26965,
1035,
7374,
7559,
18150,
11101,
15568,
1006,
8909,
2015,
1007,
1063,
13075,
9986,
1027,
2023,
1012,
1035,
11486,
1012,
3332,
1012,
6254,
1025,
1013,
1013,
2175,
2083,
2035,
1996,
3024,
8909,
2015,
2005,
1006,
1307... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/datepicker/js/calendar.js | CalendarCtrl | function CalendarCtrl($element, $scope, $$mdDateUtil, $mdUtil,
$mdConstant, $mdTheming, $$rAF, $attrs, $mdDateLocale) {
$mdTheming($element);
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final {!angular.Scope} */
this.$scope = $scope;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.$mdUtil = $mdUtil;
/** @final */
this.keyCode = $mdConstant.KEY_CODE;
/** @final */
this.$$rAF = $$rAF;
/** @final */
this.$mdDateLocale = $mdDateLocale;
/** @final {Date} */
this.today = this.dateUtil.createDateAtMidnight();
/** @type {!angular.NgModelController} */
this.ngModelCtrl = null;
/** @type {String} Class applied to the selected date cell. */
this.SELECTED_DATE_CLASS = 'md-calendar-selected-date';
/** @type {String} Class applied to the cell for today. */
this.TODAY_CLASS = 'md-calendar-date-today';
/** @type {String} Class applied to the focused cell. */
this.FOCUSED_DATE_CLASS = 'md-focus';
/** @final {number} Unique ID for this calendar instance. */
this.id = nextUniqueId++;
/**
* The date that is currently focused or showing in the calendar. This will initially be set
* to the ng-model value if set, otherwise to today. It will be updated as the user navigates
* to other months. The cell corresponding to the displayDate does not necesarily always have
* focus in the document (such as for cases when the user is scrolling the calendar).
* @type {Date}
*/
this.displayDate = null;
/**
* The selected date. Keep track of this separately from the ng-model value so that we
* can know, when the ng-model value changes, what the previous value was before it's updated
* in the component's UI.
*
* @type {Date}
*/
this.selectedDate = null;
/**
* The first date that can be rendered by the calendar. The default is taken
* from the mdDateLocale provider and is limited by the mdMinDate.
* @type {Date}
*/
this.firstRenderableDate = null;
/**
* The last date that can be rendered by the calendar. The default comes
* from the mdDateLocale provider and is limited by the maxDate.
* @type {Date}
*/
this.lastRenderableDate = null;
/**
* Used to toggle initialize the root element in the next digest.
* @type {Boolean}
*/
this.isInitialized = false;
/**
* Cache for the width of the element without a scrollbar. Used to hide the scrollbar later on
* and to avoid extra reflows when switching between views.
* @type {Number}
*/
this.width = 0;
/**
* Caches the width of the scrollbar in order to be used when hiding it and to avoid extra reflows.
* @type {Number}
*/
this.scrollbarWidth = 0;
// Unless the user specifies so, the calendar should not be a tab stop.
// This is necessary because ngAria might add a tabindex to anything with an ng-model
// (based on whether or not the user has turned that particular feature on/off).
if (!$attrs.tabindex) {
$element.attr('tabindex', '-1');
}
var boundKeyHandler = angular.bind(this, this.handleKeyEvent);
// If use the md-calendar directly in the body without datepicker,
// handleKeyEvent will disable other inputs on the page.
// So only apply the handleKeyEvent on the body when the md-calendar inside datepicker,
// otherwise apply on the calendar element only.
var handleKeyElement;
if ($element.parent().hasClass('md-datepicker-calendar')) {
handleKeyElement = angular.element(document.body);
} else {
handleKeyElement = $element;
}
// Bind the keydown handler to the body, in order to handle cases where the focused
// element gets removed from the DOM and stops propagating click events.
handleKeyElement.on('keydown', boundKeyHandler);
$scope.$on('$destroy', function() {
handleKeyElement.off('keydown', boundKeyHandler);
});
// For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are pre-assigned,
// manually call the $onInit hook.
if (angular.version.major === 1 && angular.version.minor <= 4) {
this.$onInit();
}
} | javascript | function CalendarCtrl($element, $scope, $$mdDateUtil, $mdUtil,
$mdConstant, $mdTheming, $$rAF, $attrs, $mdDateLocale) {
$mdTheming($element);
/** @final {!angular.JQLite} */
this.$element = $element;
/** @final {!angular.Scope} */
this.$scope = $scope;
/** @final */
this.dateUtil = $$mdDateUtil;
/** @final */
this.$mdUtil = $mdUtil;
/** @final */
this.keyCode = $mdConstant.KEY_CODE;
/** @final */
this.$$rAF = $$rAF;
/** @final */
this.$mdDateLocale = $mdDateLocale;
/** @final {Date} */
this.today = this.dateUtil.createDateAtMidnight();
/** @type {!angular.NgModelController} */
this.ngModelCtrl = null;
/** @type {String} Class applied to the selected date cell. */
this.SELECTED_DATE_CLASS = 'md-calendar-selected-date';
/** @type {String} Class applied to the cell for today. */
this.TODAY_CLASS = 'md-calendar-date-today';
/** @type {String} Class applied to the focused cell. */
this.FOCUSED_DATE_CLASS = 'md-focus';
/** @final {number} Unique ID for this calendar instance. */
this.id = nextUniqueId++;
/**
* The date that is currently focused or showing in the calendar. This will initially be set
* to the ng-model value if set, otherwise to today. It will be updated as the user navigates
* to other months. The cell corresponding to the displayDate does not necesarily always have
* focus in the document (such as for cases when the user is scrolling the calendar).
* @type {Date}
*/
this.displayDate = null;
/**
* The selected date. Keep track of this separately from the ng-model value so that we
* can know, when the ng-model value changes, what the previous value was before it's updated
* in the component's UI.
*
* @type {Date}
*/
this.selectedDate = null;
/**
* The first date that can be rendered by the calendar. The default is taken
* from the mdDateLocale provider and is limited by the mdMinDate.
* @type {Date}
*/
this.firstRenderableDate = null;
/**
* The last date that can be rendered by the calendar. The default comes
* from the mdDateLocale provider and is limited by the maxDate.
* @type {Date}
*/
this.lastRenderableDate = null;
/**
* Used to toggle initialize the root element in the next digest.
* @type {Boolean}
*/
this.isInitialized = false;
/**
* Cache for the width of the element without a scrollbar. Used to hide the scrollbar later on
* and to avoid extra reflows when switching between views.
* @type {Number}
*/
this.width = 0;
/**
* Caches the width of the scrollbar in order to be used when hiding it and to avoid extra reflows.
* @type {Number}
*/
this.scrollbarWidth = 0;
// Unless the user specifies so, the calendar should not be a tab stop.
// This is necessary because ngAria might add a tabindex to anything with an ng-model
// (based on whether or not the user has turned that particular feature on/off).
if (!$attrs.tabindex) {
$element.attr('tabindex', '-1');
}
var boundKeyHandler = angular.bind(this, this.handleKeyEvent);
// If use the md-calendar directly in the body without datepicker,
// handleKeyEvent will disable other inputs on the page.
// So only apply the handleKeyEvent on the body when the md-calendar inside datepicker,
// otherwise apply on the calendar element only.
var handleKeyElement;
if ($element.parent().hasClass('md-datepicker-calendar')) {
handleKeyElement = angular.element(document.body);
} else {
handleKeyElement = $element;
}
// Bind the keydown handler to the body, in order to handle cases where the focused
// element gets removed from the DOM and stops propagating click events.
handleKeyElement.on('keydown', boundKeyHandler);
$scope.$on('$destroy', function() {
handleKeyElement.off('keydown', boundKeyHandler);
});
// For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are pre-assigned,
// manually call the $onInit hook.
if (angular.version.major === 1 && angular.version.minor <= 4) {
this.$onInit();
}
} | [
"function",
"CalendarCtrl",
"(",
"$element",
",",
"$scope",
",",
"$$mdDateUtil",
",",
"$mdUtil",
",",
"$mdConstant",
",",
"$mdTheming",
",",
"$$rAF",
",",
"$attrs",
",",
"$mdDateLocale",
")",
"{",
"$mdTheming",
"(",
"$element",
")",
";",
"/** @final {!angular.JQ... | Controller for the mdCalendar component.
@ngInject @constructor | [
"Controller",
"for",
"the",
"mdCalendar",
"component",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendar.js#L107-L237 | train | A controller for the calendar. | [
30522,
3853,
8094,
6593,
12190,
1006,
1002,
5783,
1010,
1002,
9531,
1010,
1002,
1002,
9108,
13701,
21823,
2140,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
9108,
8663,
12693,
2102,
1010,
1002,
9108,
10760,
6562,
1010,
1002,
1002,
7148,
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... |
adobe/brackets | src/JSUtils/ScopeManager.js | handleGetGuesses | function handleGetGuesses(response) {
var path = response.file,
type = response.type,
offset = response.offset,
$deferredHints = getPendingRequest(path, offset, type);
if ($deferredHints) {
$deferredHints.resolveWith(null, [response.properties]);
}
} | javascript | function handleGetGuesses(response) {
var path = response.file,
type = response.type,
offset = response.offset,
$deferredHints = getPendingRequest(path, offset, type);
if ($deferredHints) {
$deferredHints.resolveWith(null, [response.properties]);
}
} | [
"function",
"handleGetGuesses",
"(",
"response",
")",
"{",
"var",
"path",
"=",
"response",
".",
"file",
",",
"type",
"=",
"response",
".",
"type",
",",
"offset",
"=",
"response",
".",
"offset",
",",
"$deferredHints",
"=",
"getPendingRequest",
"(",
"path",
... | Handle the response from the tern node domain when
it responds to the get guesses message.
@param {{file: string, type: string, offset: {line: number, ch: number},
properties: Array.<string>}} response -
the response from node domain contains the guesses for a
property lookup. | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"to",
"the",
"get",
"guesses",
"message",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L723-L732 | train | Handle the get guesses request | [
30522,
3853,
5047,
18150,
22967,
8583,
1006,
3433,
1007,
1063,
13075,
4130,
1027,
3433,
1012,
5371,
1010,
2828,
1027,
3433,
1012,
2828,
1010,
16396,
1027,
3433,
1012,
16396,
1010,
1002,
13366,
28849,
19114,
7666,
1027,
2131,
11837,
4667,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/StringMatch.js | stringMatch | function stringMatch(str, query, options, special) {
var result;
options = options || {};
// No query? Short circuit the normal work done and just
// return a single range that covers the whole string.
if (!query) {
result = new SearchResult(str);
result.matchGoodness = 0;
if (DEBUG_SCORES) {
result.scoreDebug = {};
}
result.stringRanges = [{
text: str,
matched: false,
includesLastSegment: true
}];
return result;
}
// comparisons are case insensitive, so switch to lower case here
var queryLower = query.toLowerCase();
var compareLower = str.toLowerCase();
if (options.preferPrefixMatches) {
options.segmentedSearch = false;
}
if (options.preferPrefixMatches && compareLower.substr(0, queryLower.length) === queryLower) {
// NOTE: we compare against the case insensitive match
// above but we pass the case-sensitive version in
// because we want to weight the match to give case-matches
// a higher score
return _prefixMatchResult(str, query);
}
// Locate the special characters and then use orderedCompare to do the real
// work.
if (!special) {
special = findSpecialCharacters(str);
}
var lastSegmentStart, matchList;
// For strings that are not broken into multiple segments, we can potentially
// avoid some extra work
if (options.segmentedSearch) {
lastSegmentStart = special.specials[special.lastSegmentSpecialsIndex];
matchList = _wholeStringSearch(queryLower, compareLower, query, str, special.specials,
special.lastSegmentSpecialsIndex);
} else {
lastSegmentStart = 0;
matchList = _generateMatchList(queryLower, compareLower, query, str, special.specials, 0);
}
// If we get a match, turn this into a SearchResult as expected by the consumers
// of this API.
if (matchList) {
var compareData = _computeRangesAndScore(matchList, str, lastSegmentStart);
result = new SearchResult(str);
result.stringRanges = compareData.ranges;
result.matchGoodness = -1 * compareData.matchGoodness;
if (DEBUG_SCORES) {
result.scoreDebug = compareData.scoreDebug;
}
}
return result;
} | javascript | function stringMatch(str, query, options, special) {
var result;
options = options || {};
// No query? Short circuit the normal work done and just
// return a single range that covers the whole string.
if (!query) {
result = new SearchResult(str);
result.matchGoodness = 0;
if (DEBUG_SCORES) {
result.scoreDebug = {};
}
result.stringRanges = [{
text: str,
matched: false,
includesLastSegment: true
}];
return result;
}
// comparisons are case insensitive, so switch to lower case here
var queryLower = query.toLowerCase();
var compareLower = str.toLowerCase();
if (options.preferPrefixMatches) {
options.segmentedSearch = false;
}
if (options.preferPrefixMatches && compareLower.substr(0, queryLower.length) === queryLower) {
// NOTE: we compare against the case insensitive match
// above but we pass the case-sensitive version in
// because we want to weight the match to give case-matches
// a higher score
return _prefixMatchResult(str, query);
}
// Locate the special characters and then use orderedCompare to do the real
// work.
if (!special) {
special = findSpecialCharacters(str);
}
var lastSegmentStart, matchList;
// For strings that are not broken into multiple segments, we can potentially
// avoid some extra work
if (options.segmentedSearch) {
lastSegmentStart = special.specials[special.lastSegmentSpecialsIndex];
matchList = _wholeStringSearch(queryLower, compareLower, query, str, special.specials,
special.lastSegmentSpecialsIndex);
} else {
lastSegmentStart = 0;
matchList = _generateMatchList(queryLower, compareLower, query, str, special.specials, 0);
}
// If we get a match, turn this into a SearchResult as expected by the consumers
// of this API.
if (matchList) {
var compareData = _computeRangesAndScore(matchList, str, lastSegmentStart);
result = new SearchResult(str);
result.stringRanges = compareData.ranges;
result.matchGoodness = -1 * compareData.matchGoodness;
if (DEBUG_SCORES) {
result.scoreDebug = compareData.scoreDebug;
}
}
return result;
} | [
"function",
"stringMatch",
"(",
"str",
",",
"query",
",",
"options",
",",
"special",
")",
"{",
"var",
"result",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// No query? Short circuit the normal work done and just",
"// return a single range that covers the who... | /*
Match str against the query using the QuickOpen algorithm provided by
the functions above. The general idea is to prefer matches of "special" characters and,
optionally, matches that occur in the "last segment" (generally, the filename). stringMatch
will try to provide the best match and produces a "matchGoodness" score
to allow for relative ranking.
The result object returned includes "stringRanges" which can be used to highlight
the matched portions of the string, in addition to the "matchGoodness"
mentioned above. If DEBUG_SCORES is true, scoreDebug is set on the result
to provide insight into the score.
The matching is done in a case-insensitive manner.
@param {string} str The string to search
@param {string} query The query string to find in string
@param {{preferPrefixMatches:?boolean, segmentedSearch:?boolean}} options to control search behavior.
preferPrefixMatches puts an exact case-insensitive prefix match ahead of all other matches,
even short-circuiting the match logic. This option implies segmentedSearch=false.
When segmentedSearch is true, the string is broken into segments by "/" characters
and the last segment is searched first and matches there are scored higher.
@param {?Object} special (optional) the specials data from findSpecialCharacters, if already known
This is generally just used by StringMatcher for optimization.
@return {{ranges:Array.<{text:string, matched:boolean, includesLastSegment:boolean}>, matchGoodness:int, scoreDebug: Object}} matched ranges and score | [
"/",
"*",
"Match",
"str",
"against",
"the",
"query",
"using",
"the",
"QuickOpen",
"algorithm",
"provided",
"by",
"the",
"functions",
"above",
".",
"The",
"general",
"idea",
"is",
"to",
"prefer",
"matches",
"of",
"special",
"characters",
"and",
"optionally",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L766-L833 | train | Match a string against a query | [
30522,
3853,
5164,
18900,
2818,
1006,
2358,
2099,
1010,
23032,
1010,
7047,
1010,
2569,
1007,
1063,
13075,
2765,
1025,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
1013,
1013,
2053,
23032,
1029,
2460,
4984,
1996,
3671,
2147,
2589,
1998,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/src/autheventmanager.js | function() {
if (!self.initialized_) {
self.initialized_ = true;
// Listen to Auth events on iframe.
self.oauthSignInHandler_.addAuthEventListener(self.authEventHandler_);
}
} | javascript | function() {
if (!self.initialized_) {
self.initialized_ = true;
// Listen to Auth events on iframe.
self.oauthSignInHandler_.addAuthEventListener(self.authEventHandler_);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"self",
".",
"initialized_",
")",
"{",
"self",
".",
"initialized_",
"=",
"true",
";",
"// Listen to Auth events on iframe.",
"self",
".",
"oauthSignInHandler_",
".",
"addAuthEventListener",
"(",
"self",
".",
"authEventH... | On initialization, add Auth event listener if not already added. | [
"On",
"initialization",
"add",
"Auth",
"event",
"listener",
"if",
"not",
"already",
"added",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/src/autheventmanager.js#L501-L507 | train | Initialize the auth handler | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2969,
1012,
3988,
3550,
1035,
1007,
1063,
2969,
1012,
3988,
3550,
1035,
1027,
2995,
1025,
1013,
1013,
4952,
2000,
8740,
2705,
2824,
2006,
2065,
6444,
2063,
1012,
2969,
1012,
1051,
4887,
2683... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (elem)
{
// build plaintext auth iq
var iq = $iq({type: "set", id: "_auth_2"})
.c('query', {xmlns: Strophe.NS.AUTH})
.c('username', {}).t(Strophe.getNodeFromJid(this.jid))
.up()
.c('password').t(this.pass);
if (!Strophe.getResourceFromJid(this.jid)) {
// since the user has not supplied a resource, we pick
// a default one here. unlike other auth methods, the server
// cannot do this for us.
this.jid = Strophe.getBareJidFromJid(this.jid) + '/strophe';
}
iq.up().c('resource', {}).t(Strophe.getResourceFromJid(this.jid));
this._addSysHandler(this._auth2_cb.bind(this), null,
null, null, "_auth_2");
this.send(iq.tree());
return false;
} | javascript | function (elem)
{
// build plaintext auth iq
var iq = $iq({type: "set", id: "_auth_2"})
.c('query', {xmlns: Strophe.NS.AUTH})
.c('username', {}).t(Strophe.getNodeFromJid(this.jid))
.up()
.c('password').t(this.pass);
if (!Strophe.getResourceFromJid(this.jid)) {
// since the user has not supplied a resource, we pick
// a default one here. unlike other auth methods, the server
// cannot do this for us.
this.jid = Strophe.getBareJidFromJid(this.jid) + '/strophe';
}
iq.up().c('resource', {}).t(Strophe.getResourceFromJid(this.jid));
this._addSysHandler(this._auth2_cb.bind(this), null,
null, null, "_auth_2");
this.send(iq.tree());
return false;
} | [
"function",
"(",
"elem",
")",
"{",
"// build plaintext auth iq\r",
"var",
"iq",
"=",
"$iq",
"(",
"{",
"type",
":",
"\"set\"",
",",
"id",
":",
"\"_auth_2\"",
"}",
")",
".",
"c",
"(",
"'query'",
",",
"{",
"xmlns",
":",
"Strophe",
".",
"NS",
".",
"AUTH"... | PrivateFunction: _auth1_cb
_Private_ handler for legacy authentication.
This handler is called in response to the initial <iq type='get'/>
for legacy authentication. It builds an authentication <iq/> and
sends it, creating a handler (calling back to _auth2_cb()) to
handle the result
Parameters:
(XMLElement) elem - The stanza that triggered the callback.
Returns:
false to remove the handler.
/* jshint unused:false | [
"PrivateFunction",
":",
"_auth1_cb",
"_Private_",
"handler",
"for",
"legacy",
"authentication",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L3100-L3123 | train | auth 2 | [
30522,
3853,
1006,
3449,
6633,
1007,
1063,
1013,
1013,
3857,
5810,
18209,
8740,
2705,
26264,
13075,
26264,
1027,
1002,
26264,
1006,
1063,
2828,
1024,
1000,
2275,
1000,
1010,
8909,
1024,
1000,
1035,
8740,
2705,
1035,
1016,
1000,
1065,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/code-path-analysis/code-path-state.js | removeConnection | function removeConnection(prevSegments, nextSegments) {
for (let i = 0; i < prevSegments.length; ++i) {
const prevSegment = prevSegments[i];
const nextSegment = nextSegments[i];
remove(prevSegment.nextSegments, nextSegment);
remove(prevSegment.allNextSegments, nextSegment);
remove(nextSegment.prevSegments, prevSegment);
remove(nextSegment.allPrevSegments, prevSegment);
}
} | javascript | function removeConnection(prevSegments, nextSegments) {
for (let i = 0; i < prevSegments.length; ++i) {
const prevSegment = prevSegments[i];
const nextSegment = nextSegments[i];
remove(prevSegment.nextSegments, nextSegment);
remove(prevSegment.allNextSegments, nextSegment);
remove(nextSegment.prevSegments, prevSegment);
remove(nextSegment.allPrevSegments, prevSegment);
}
} | [
"function",
"removeConnection",
"(",
"prevSegments",
",",
"nextSegments",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"prevSegments",
".",
"length",
";",
"++",
"i",
")",
"{",
"const",
"prevSegment",
"=",
"prevSegments",
"[",
"i",
"]",
";... | Disconnect given segments.
This is used in a process for switch statements.
If there is the "default" chunk before other cases, the order is different
between node's and running's.
@param {CodePathSegment[]} prevSegments - Forward segments to disconnect.
@param {CodePathSegment[]} nextSegments - Backward segments to disconnect.
@returns {void} | [
"Disconnect",
"given",
"segments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/code-path-state.js#L151-L161 | train | Remove connection from the network | [
30522,
3853,
6366,
8663,
2638,
7542,
1006,
3653,
15088,
13910,
8163,
1010,
2279,
3366,
21693,
11187,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
3653,
15088,
13910,
8163,
1012,
3091,
1025,
1009,
1009,
1045,
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... |
shipshapecode/shepherd | src/js/utils/modal.js | _createMaskConsumer | function _createMaskConsumer() {
const element = document.createElementNS(svgNS, 'rect');
_setAttributes(element, {
height: '100%',
width: '100%',
x: '0',
y: '0'
});
element.setAttribute('mask', `url(#${elementIds.modalOverlayMask})`);
return element;
} | javascript | function _createMaskConsumer() {
const element = document.createElementNS(svgNS, 'rect');
_setAttributes(element, {
height: '100%',
width: '100%',
x: '0',
y: '0'
});
element.setAttribute('mask', `url(#${elementIds.modalOverlayMask})`);
return element;
} | [
"function",
"_createMaskConsumer",
"(",
")",
"{",
"const",
"element",
"=",
"document",
".",
"createElementNS",
"(",
"svgNS",
",",
"'rect'",
")",
";",
"_setAttributes",
"(",
"element",
",",
"{",
"height",
":",
"'100%'",
",",
"width",
":",
"'100%'",
",",
"x"... | <rect x="0" y="0" width="100%" height="100%" mask="url(#shepherdModalMask)"/> | [
"<rect",
"x",
"=",
"0",
"y",
"=",
"0",
"width",
"=",
"100%",
"height",
"=",
"100%",
"mask",
"=",
"url",
"(",
"#shepherdModalMask",
")",
"/",
">"
] | 0cb1c63fb07b58796358f6d33da5f6405e2b05f4 | https://github.com/shipshapecode/shepherd/blob/0cb1c63fb07b58796358f6d33da5f6405e2b05f4/src/js/utils/modal.js#L78-L90 | train | Creates an element that can be used to display the modal overlay | [
30522,
3853,
1035,
3443,
9335,
2243,
8663,
23545,
2099,
1006,
1007,
1063,
9530,
3367,
5783,
1027,
6254,
1012,
3443,
12260,
3672,
3619,
1006,
17917,
16206,
2015,
1010,
1005,
28667,
2102,
1005,
1007,
1025,
1035,
2275,
19321,
3089,
8569,
4570,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/autocomplete/js/autocompleteController.js | gatherSnapWrap | function gatherSnapWrap() {
var element;
var value;
for (element = $element; element.length; element = element.parent()) {
value = element.attr('md-autocomplete-snap');
if (angular.isDefined(value)) break;
}
if (element.length) {
return {
snap: element[0],
wrap: (value.toLowerCase() === 'width') ? element[0] : $element.find('md-autocomplete-wrap')[0]
};
}
var wrap = $element.find('md-autocomplete-wrap')[0];
return {
snap: wrap,
wrap: wrap
};
} | javascript | function gatherSnapWrap() {
var element;
var value;
for (element = $element; element.length; element = element.parent()) {
value = element.attr('md-autocomplete-snap');
if (angular.isDefined(value)) break;
}
if (element.length) {
return {
snap: element[0],
wrap: (value.toLowerCase() === 'width') ? element[0] : $element.find('md-autocomplete-wrap')[0]
};
}
var wrap = $element.find('md-autocomplete-wrap')[0];
return {
snap: wrap,
wrap: wrap
};
} | [
"function",
"gatherSnapWrap",
"(",
")",
"{",
"var",
"element",
";",
"var",
"value",
";",
"for",
"(",
"element",
"=",
"$element",
";",
"element",
".",
"length",
";",
"element",
"=",
"element",
".",
"parent",
"(",
")",
")",
"{",
"value",
"=",
"element",
... | Gathers the snap and wrap elements | [
"Gathers",
"the",
"snap",
"and",
"wrap",
"elements"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L306-L326 | train | gather snap wrap | [
30522,
3853,
29438,
2532,
28400,
2527,
2361,
1006,
1007,
1063,
13075,
5783,
1025,
13075,
3643,
1025,
2005,
1006,
5783,
1027,
1002,
5783,
1025,
5783,
1012,
3091,
1025,
5783,
1027,
5783,
1012,
6687,
1006,
1007,
1007,
1063,
3643,
1027,
5783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Filter.js | function() {
// covert the values array into an array of filter objects
var aFilters = [];
for (var i = 0, l = this.aValues && this.aValues.length || 0; i < l; i++) {
aFilters.push(new Filter({
path: this.sPath,
operator: this.aValues[i].operator,
value1: this.aValues[i].value1,
value2: this.aValues[i].value2
}));
}
// create the new filter object based on the filters
if (aFilters.length > 1) {
var oFilter = new Filter({
filters: aFilters,
and: this.bAND
});
return oFilter;
} else {
return aFilters[0];
}
} | javascript | function() {
// covert the values array into an array of filter objects
var aFilters = [];
for (var i = 0, l = this.aValues && this.aValues.length || 0; i < l; i++) {
aFilters.push(new Filter({
path: this.sPath,
operator: this.aValues[i].operator,
value1: this.aValues[i].value1,
value2: this.aValues[i].value2
}));
}
// create the new filter object based on the filters
if (aFilters.length > 1) {
var oFilter = new Filter({
filters: aFilters,
and: this.bAND
});
return oFilter;
} else {
return aFilters[0];
}
} | [
"function",
"(",
")",
"{",
"// covert the values array into an array of filter objects",
"var",
"aFilters",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"aValues",
"&&",
"this",
".",
"aValues",
".",
"length",
"||",
"0",... | Converts the <code>sap.ui.model.odata.Filter</code> into a
<code>sap.ui.model.Filter</code>.
@return {sap.ui.model.Filter} a <code>sap.ui.model.Filter</code> object
@public | [
"Converts",
"the",
"<code",
">",
"sap",
".",
"ui",
".",
"model",
".",
"odata",
".",
"Filter<",
"/",
"code",
">",
"into",
"a",
"<code",
">",
"sap",
".",
"ui",
".",
"model",
".",
"Filter<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/Filter.js#L47-L72 | train | Returns a filter object based on the values array | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
19813,
1996,
5300,
9140,
2046,
2019,
9140,
1997,
11307,
5200,
13075,
28697,
21928,
2015,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
1048,
1027,
2023,
1012,
10927,
7630,
2229... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-useless-escape.js | parseRegExp | function parseRegExp(regExpText) {
const charList = [];
regExpText.split("").reduce((state, char, index) => {
if (!state.escapeNextChar) {
if (char === "\\") {
return Object.assign(state, { escapeNextChar: true });
}
if (char === "[" && !state.inCharClass) {
return Object.assign(state, { inCharClass: true, startingCharClass: true });
}
if (char === "]" && state.inCharClass) {
if (charList.length && charList[charList.length - 1].inCharClass) {
charList[charList.length - 1].endsCharClass = true;
}
return Object.assign(state, { inCharClass: false, startingCharClass: false });
}
}
charList.push({
text: char,
index,
escaped: state.escapeNextChar,
inCharClass: state.inCharClass,
startsCharClass: state.startingCharClass,
endsCharClass: false
});
return Object.assign(state, { escapeNextChar: false, startingCharClass: false });
}, { escapeNextChar: false, inCharClass: false, startingCharClass: false });
return charList;
} | javascript | function parseRegExp(regExpText) {
const charList = [];
regExpText.split("").reduce((state, char, index) => {
if (!state.escapeNextChar) {
if (char === "\\") {
return Object.assign(state, { escapeNextChar: true });
}
if (char === "[" && !state.inCharClass) {
return Object.assign(state, { inCharClass: true, startingCharClass: true });
}
if (char === "]" && state.inCharClass) {
if (charList.length && charList[charList.length - 1].inCharClass) {
charList[charList.length - 1].endsCharClass = true;
}
return Object.assign(state, { inCharClass: false, startingCharClass: false });
}
}
charList.push({
text: char,
index,
escaped: state.escapeNextChar,
inCharClass: state.inCharClass,
startsCharClass: state.startingCharClass,
endsCharClass: false
});
return Object.assign(state, { escapeNextChar: false, startingCharClass: false });
}, { escapeNextChar: false, inCharClass: false, startingCharClass: false });
return charList;
} | [
"function",
"parseRegExp",
"(",
"regExpText",
")",
"{",
"const",
"charList",
"=",
"[",
"]",
";",
"regExpText",
".",
"split",
"(",
"\"\"",
")",
".",
"reduce",
"(",
"(",
"state",
",",
"char",
",",
"index",
")",
"=>",
"{",
"if",
"(",
"!",
"state",
"."... | Parses a regular expression into a list of characters with character class info.
@param {string} regExpText The raw text used to create the regular expression
@returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class.
@example
parseRegExp('a\\b[cd-]')
returns:
[
{text: 'a', index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false},
{text: 'b', index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false},
{text: 'c', index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false},
{text: 'd', index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false},
{text: '-', index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false}
] | [
"Parses",
"a",
"regular",
"expression",
"into",
"a",
"list",
"of",
"characters",
"with",
"character",
"class",
"info",
".",
"@param",
"{",
"string",
"}",
"regExpText",
"The",
"raw",
"text",
"used",
"to",
"create",
"the",
"regular",
"expression",
"@returns",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L48-L78 | train | Parses a regular expression into an array of tokens | [
30522,
3853,
11968,
8043,
24746,
2595,
2361,
1006,
19723,
10288,
13876,
10288,
2102,
1007,
1063,
9530,
3367,
25869,
9863,
1027,
1031,
1033,
1025,
19723,
10288,
13876,
10288,
2102,
1012,
3975,
1006,
1000,
1000,
1007,
1012,
5547,
1006,
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.ui.table/src/sap/ui/table/TableUtils.js | function(oTable, vRowIndicator, bSelect, fnDoSelect) {
if (!oTable ||
!oTable.getBinding("rows") ||
oTable.getSelectionMode() === SelectionMode.None ||
vRowIndicator == null) {
return false;
}
function setSelectionState(iAbsoluteRowIndex) {
if (!oTable._isRowSelectable(iAbsoluteRowIndex)) {
return false;
}
oTable._iSourceRowIndex = iAbsoluteRowIndex; // To indicate that the selection was changed by user interaction.
var bSelectionChanged = false;
if (fnDoSelect) {
bSelectionChanged = fnDoSelect(iAbsoluteRowIndex, bSelect);
} else if (oTable.isIndexSelected(iAbsoluteRowIndex)) {
if (bSelect !== true) {
bSelectionChanged = true;
oTable.removeSelectionInterval(iAbsoluteRowIndex, iAbsoluteRowIndex);
}
} else if (bSelect !== false) {
bSelectionChanged = true;
oTable.addSelectionInterval(iAbsoluteRowIndex, iAbsoluteRowIndex);
}
delete oTable._iSourceRowIndex;
return bSelectionChanged;
}
// Variable vRowIndicator is a row index value.
if (typeof vRowIndicator === "number") {
if (vRowIndicator < 0 || vRowIndicator >= oTable._getTotalRowCount()) {
return false;
}
return setSelectionState(vRowIndicator);
// Variable vRowIndicator is a jQuery object or DOM element.
} else {
var $Cell = jQuery(vRowIndicator);
var oCellInfo = TableUtils.getCellInfo($Cell[0]);
var bIsRowSelectionAllowed = TableUtils.isRowSelectionAllowed(oTable);
if (!TableUtils.Grouping.isInGroupingRow($Cell[0])
&& ((oCellInfo.isOfType(TableUtils.CELLTYPE.DATACELL | TableUtils.CELLTYPE.ROWACTION) && bIsRowSelectionAllowed)
|| (oCellInfo.isOfType(TableUtils.CELLTYPE.ROWHEADER) && TableUtils.isRowSelectorSelectionAllowed(oTable)))) {
var iAbsoluteRowIndex;
if (oCellInfo.isOfType(TableUtils.CELLTYPE.DATACELL)) {
iAbsoluteRowIndex = oTable
.getRows()[parseInt($Cell.closest("tr", oTable.getDomRef()).attr("data-sap-ui-rowindex"))]
.getIndex();
} else { // CELLTYPES.ROWHEADER, CELLTYPES.ROWACTION
iAbsoluteRowIndex = oTable.getRows()[parseInt($Cell.attr("data-sap-ui-rowindex"))].getIndex();
}
return setSelectionState(iAbsoluteRowIndex);
}
return false;
}
} | javascript | function(oTable, vRowIndicator, bSelect, fnDoSelect) {
if (!oTable ||
!oTable.getBinding("rows") ||
oTable.getSelectionMode() === SelectionMode.None ||
vRowIndicator == null) {
return false;
}
function setSelectionState(iAbsoluteRowIndex) {
if (!oTable._isRowSelectable(iAbsoluteRowIndex)) {
return false;
}
oTable._iSourceRowIndex = iAbsoluteRowIndex; // To indicate that the selection was changed by user interaction.
var bSelectionChanged = false;
if (fnDoSelect) {
bSelectionChanged = fnDoSelect(iAbsoluteRowIndex, bSelect);
} else if (oTable.isIndexSelected(iAbsoluteRowIndex)) {
if (bSelect !== true) {
bSelectionChanged = true;
oTable.removeSelectionInterval(iAbsoluteRowIndex, iAbsoluteRowIndex);
}
} else if (bSelect !== false) {
bSelectionChanged = true;
oTable.addSelectionInterval(iAbsoluteRowIndex, iAbsoluteRowIndex);
}
delete oTable._iSourceRowIndex;
return bSelectionChanged;
}
// Variable vRowIndicator is a row index value.
if (typeof vRowIndicator === "number") {
if (vRowIndicator < 0 || vRowIndicator >= oTable._getTotalRowCount()) {
return false;
}
return setSelectionState(vRowIndicator);
// Variable vRowIndicator is a jQuery object or DOM element.
} else {
var $Cell = jQuery(vRowIndicator);
var oCellInfo = TableUtils.getCellInfo($Cell[0]);
var bIsRowSelectionAllowed = TableUtils.isRowSelectionAllowed(oTable);
if (!TableUtils.Grouping.isInGroupingRow($Cell[0])
&& ((oCellInfo.isOfType(TableUtils.CELLTYPE.DATACELL | TableUtils.CELLTYPE.ROWACTION) && bIsRowSelectionAllowed)
|| (oCellInfo.isOfType(TableUtils.CELLTYPE.ROWHEADER) && TableUtils.isRowSelectorSelectionAllowed(oTable)))) {
var iAbsoluteRowIndex;
if (oCellInfo.isOfType(TableUtils.CELLTYPE.DATACELL)) {
iAbsoluteRowIndex = oTable
.getRows()[parseInt($Cell.closest("tr", oTable.getDomRef()).attr("data-sap-ui-rowindex"))]
.getIndex();
} else { // CELLTYPES.ROWHEADER, CELLTYPES.ROWACTION
iAbsoluteRowIndex = oTable.getRows()[parseInt($Cell.attr("data-sap-ui-rowindex"))].getIndex();
}
return setSelectionState(iAbsoluteRowIndex);
}
return false;
}
} | [
"function",
"(",
"oTable",
",",
"vRowIndicator",
",",
"bSelect",
",",
"fnDoSelect",
")",
"{",
"if",
"(",
"!",
"oTable",
"||",
"!",
"oTable",
".",
"getBinding",
"(",
"\"rows\"",
")",
"||",
"oTable",
".",
"getSelectionMode",
"(",
")",
"===",
"SelectionMode",... | Toggles the selection state of the row which contains the given cell DOM element.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {jQuery | HTMLElement | int} vRowIndicator The data cell in the row, or the data row index of the row,
where the selection state should be toggled.
@param {boolean} [bSelect] If defined, then instead of toggling the desired state is set.
@param {Function} [fnDoSelect] If defined, then instead of the default selection code, this custom callback is used.
@returns {boolean} Returns <code>true</code> if the selection state of the row has been changed. | [
"Toggles",
"the",
"selection",
"state",
"of",
"the",
"row",
"which",
"contains",
"the",
"given",
"cell",
"DOM",
"element",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L457-L522 | train | Sets the selection state of a row. | [
30522,
3853,
1006,
27178,
3085,
1010,
27830,
5004,
22254,
5555,
4263,
1010,
18667,
12260,
6593,
1010,
1042,
15482,
11246,
22471,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1064,
1064,
999,
27178,
3085,
1012,
2131,
8428,
4667,
1006,
1000,
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... | |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js | function (oThis) {
if (!oThis.getOpener()) {
var sId = "";
if (oThis.oPopup) {
if (oThis.oPopup._oPosition.of instanceof sap.ui.core.Element) {
sId = oThis.oPopup._oPosition.of.getId();
} else {
if (oThis.oPopup._oPosition.of.length > 0) {
sId = oThis.oPopup._oPosition.of[0].id;
} else {
sId = oThis.oPopup._oPosition.of.id;
}
}
}
if (sId !== "") {
oThis.setAssociation("opener", sId, true);
} else {
Log.error("Neither an opener was set properly nor a corresponding one can be distinguished", "", "sap.ui.ux3.ToolPopup");
}
}
} | javascript | function (oThis) {
if (!oThis.getOpener()) {
var sId = "";
if (oThis.oPopup) {
if (oThis.oPopup._oPosition.of instanceof sap.ui.core.Element) {
sId = oThis.oPopup._oPosition.of.getId();
} else {
if (oThis.oPopup._oPosition.of.length > 0) {
sId = oThis.oPopup._oPosition.of[0].id;
} else {
sId = oThis.oPopup._oPosition.of.id;
}
}
}
if (sId !== "") {
oThis.setAssociation("opener", sId, true);
} else {
Log.error("Neither an opener was set properly nor a corresponding one can be distinguished", "", "sap.ui.ux3.ToolPopup");
}
}
} | [
"function",
"(",
"oThis",
")",
"{",
"if",
"(",
"!",
"oThis",
".",
"getOpener",
"(",
")",
")",
"{",
"var",
"sId",
"=",
"\"\"",
";",
"if",
"(",
"oThis",
".",
"oPopup",
")",
"{",
"if",
"(",
"oThis",
".",
"oPopup",
".",
"_oPosition",
".",
"of",
"in... | Checks if an opener was set. If not, this functions tries to get the opener from the Popup.
@private | [
"Checks",
"if",
"an",
"opener",
"was",
"set",
".",
"If",
"not",
"this",
"functions",
"tries",
"to",
"get",
"the",
"opener",
"from",
"the",
"Popup",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ToolPopup.js#L729-L750 | train | Sets the opener association | [
30522,
3853,
1006,
27178,
24158,
1007,
1063,
2065,
1006,
999,
27178,
24158,
1012,
2131,
26915,
2121,
1006,
1007,
1007,
1063,
13075,
15765,
1027,
1000,
1000,
1025,
2065,
1006,
27178,
24158,
1012,
6728,
7361,
6279,
1007,
1063,
2065,
1006,
271... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/controllers/Analysis.controller.js | function (sRule, bAsync) {
var sCheckFunction = this.model.getProperty(sRule + "/check");
if (!sCheckFunction) {
return;
}
// Check if a function is found
var oMatch = sCheckFunction.match(/function[^(]*\(([^)]*)\)/);
if (!oMatch) {
return;
}
// Get the parameters of the function found and trim, then split by word.
var aParams = oMatch[1].trim().split(/\W+/);
// Add missing parameters to ensure the resolve function is passed on the correct position.
aParams[0] = aParams[0] || "oIssueManager";
aParams[1] = aParams[1] || "oCoreFacade";
aParams[2] = aParams[2] || "oScope";
// If async add a fnResolve to the template else remove it.
if (bAsync) {
aParams[3] = aParams[3] || "fnResolve";
} else {
aParams = aParams.slice(0, 3);
}
// Replace the current parameters with the new ones.
var sNewCheckFunction = sCheckFunction.replace(/function[^(]*\(([^)]*)\)/, "function (" + aParams.join(", ") + ")");
this.model.setProperty(sRule + "/check", sNewCheckFunction);
} | javascript | function (sRule, bAsync) {
var sCheckFunction = this.model.getProperty(sRule + "/check");
if (!sCheckFunction) {
return;
}
// Check if a function is found
var oMatch = sCheckFunction.match(/function[^(]*\(([^)]*)\)/);
if (!oMatch) {
return;
}
// Get the parameters of the function found and trim, then split by word.
var aParams = oMatch[1].trim().split(/\W+/);
// Add missing parameters to ensure the resolve function is passed on the correct position.
aParams[0] = aParams[0] || "oIssueManager";
aParams[1] = aParams[1] || "oCoreFacade";
aParams[2] = aParams[2] || "oScope";
// If async add a fnResolve to the template else remove it.
if (bAsync) {
aParams[3] = aParams[3] || "fnResolve";
} else {
aParams = aParams.slice(0, 3);
}
// Replace the current parameters with the new ones.
var sNewCheckFunction = sCheckFunction.replace(/function[^(]*\(([^)]*)\)/, "function (" + aParams.join(", ") + ")");
this.model.setProperty(sRule + "/check", sNewCheckFunction);
} | [
"function",
"(",
"sRule",
",",
"bAsync",
")",
"{",
"var",
"sCheckFunction",
"=",
"this",
".",
"model",
".",
"getProperty",
"(",
"sRule",
"+",
"\"/check\"",
")",
";",
"if",
"(",
"!",
"sCheckFunction",
")",
"{",
"return",
";",
"}",
"// Check if a function is... | Add fnResolve to the check function when async is set to true otherwise removes it.
@private
@param {string} sRule the model path to edit or new rule
@param {bAsync} bAsync the async property of the rule | [
"Add",
"fnResolve",
"to",
"the",
"check",
"function",
"when",
"async",
"is",
"set",
"to",
"true",
"otherwise",
"removes",
"it",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L123-L155 | train | Checks if a rule has a function that is not found in the model. | [
30522,
3853,
1006,
5034,
9307,
1010,
19021,
6038,
2278,
1007,
1063,
13075,
8040,
5369,
3600,
11263,
27989,
1027,
2023,
1012,
2944,
1012,
2131,
21572,
4842,
3723,
1006,
5034,
9307,
1009,
1000,
1013,
4638,
1000,
1007,
1025,
2065,
1006,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/look-controls.js | function (enabled) {
var sceneEl = this.el.sceneEl;
function enableGrabCursor () { sceneEl.canvas.classList.add('a-grab-cursor'); }
function disableGrabCursor () { sceneEl.canvas.classList.remove('a-grab-cursor'); }
if (!sceneEl.canvas) {
if (enabled) {
sceneEl.addEventListener('render-target-loaded', enableGrabCursor);
} else {
sceneEl.addEventListener('render-target-loaded', disableGrabCursor);
}
return;
}
if (enabled) {
enableGrabCursor();
return;
}
disableGrabCursor();
} | javascript | function (enabled) {
var sceneEl = this.el.sceneEl;
function enableGrabCursor () { sceneEl.canvas.classList.add('a-grab-cursor'); }
function disableGrabCursor () { sceneEl.canvas.classList.remove('a-grab-cursor'); }
if (!sceneEl.canvas) {
if (enabled) {
sceneEl.addEventListener('render-target-loaded', enableGrabCursor);
} else {
sceneEl.addEventListener('render-target-loaded', disableGrabCursor);
}
return;
}
if (enabled) {
enableGrabCursor();
return;
}
disableGrabCursor();
} | [
"function",
"(",
"enabled",
")",
"{",
"var",
"sceneEl",
"=",
"this",
".",
"el",
".",
"sceneEl",
";",
"function",
"enableGrabCursor",
"(",
")",
"{",
"sceneEl",
".",
"canvas",
".",
"classList",
".",
"add",
"(",
"'a-grab-cursor'",
")",
";",
"}",
"function",... | Toggle the feature of showing/hiding the grab cursor. | [
"Toggle",
"the",
"feature",
"of",
"showing",
"/",
"hiding",
"the",
"grab",
"cursor",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L384-L404 | train | Enable or disable grabbing cursor | [
30522,
3853,
1006,
9124,
1007,
1063,
13075,
3496,
2884,
1027,
2023,
1012,
3449,
1012,
3496,
2884,
1025,
3853,
9585,
17643,
9818,
9236,
2953,
1006,
1007,
1063,
3496,
2884,
1012,
10683,
1012,
2465,
9863,
1012,
5587,
1006,
1005,
1037,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | DOMWalker_processNode | function DOMWalker_processNode(activeNode, idSet) {
var doc = this._controller.window.document;
var nodeToProcess = this._getNode(idSet);
// Opens a new window/dialog through a menulist and runs DOMWalker.walk()
// for it.
// If the wanted window/dialog is already selected, just run this function
// recursively for it's descendants.
if (activeNode.localName == "menulist") {
if (nodeToProcess.label != idSet.title) {
var dropDown = new elementslib.Elem(nodeToProcess);
this._controller.waitForElement(dropDown);
this._controller.select(dropDown, null, idSet.title);
this._controller.waitFor(function() {
return nodeToProcess.label == idSet.title;
}, "The menu item did not load in time: " + idSet.title);
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (nodeToProcess.selected && idSet.subContent &&
idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Opens a new prefpane using a provided windowHandler object
// and runs DOMWalker.walk() for it.
// If the wanted prefpane is already selected, just run this function
// recursively for it's descendants.
else if (activeNode.localName == "prefpane") {
var windowHandler = idSet.windowHandler;
if (windowHandler.paneId != idSet.id) {
windowHandler.paneId = idSet.id;
// Wait for the pane's content to load and to be fully displayed
this._controller.waitFor(function() {
return (nodeToProcess.loaded &&
(!mozmill.isMac ||
nodeToProcess.style.opacity == 1 ||
nodeToProcess.style.opacity == null));
}, "The pane did not load in time: " + idSet.id);
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (windowHandler.paneId == idSet.id && idSet.subContent &&
idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Switches to another tab and runs DOMWalker.walk() for it.
// If the wanted tabpanel is already selected, just run this function
// recursively for it's descendants.
else if (activeNode.localName == "tab") {
if (nodeToProcess.selected != true) {
this._controller.click(new elementslib.Elem(nodeToProcess));
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (nodeToProcess.selected && idSet.subContent
&& idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Opens a new dialog/window by clicking on an object and runs
// DOMWalker.walk() for it.
else {
this._controller.click(new elementslib.Elem(nodeToProcess));
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
}
} | javascript | function DOMWalker_processNode(activeNode, idSet) {
var doc = this._controller.window.document;
var nodeToProcess = this._getNode(idSet);
// Opens a new window/dialog through a menulist and runs DOMWalker.walk()
// for it.
// If the wanted window/dialog is already selected, just run this function
// recursively for it's descendants.
if (activeNode.localName == "menulist") {
if (nodeToProcess.label != idSet.title) {
var dropDown = new elementslib.Elem(nodeToProcess);
this._controller.waitForElement(dropDown);
this._controller.select(dropDown, null, idSet.title);
this._controller.waitFor(function() {
return nodeToProcess.label == idSet.title;
}, "The menu item did not load in time: " + idSet.title);
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (nodeToProcess.selected && idSet.subContent &&
idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Opens a new prefpane using a provided windowHandler object
// and runs DOMWalker.walk() for it.
// If the wanted prefpane is already selected, just run this function
// recursively for it's descendants.
else if (activeNode.localName == "prefpane") {
var windowHandler = idSet.windowHandler;
if (windowHandler.paneId != idSet.id) {
windowHandler.paneId = idSet.id;
// Wait for the pane's content to load and to be fully displayed
this._controller.waitFor(function() {
return (nodeToProcess.loaded &&
(!mozmill.isMac ||
nodeToProcess.style.opacity == 1 ||
nodeToProcess.style.opacity == null));
}, "The pane did not load in time: " + idSet.id);
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (windowHandler.paneId == idSet.id && idSet.subContent &&
idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Switches to another tab and runs DOMWalker.walk() for it.
// If the wanted tabpanel is already selected, just run this function
// recursively for it's descendants.
else if (activeNode.localName == "tab") {
if (nodeToProcess.selected != true) {
this._controller.click(new elementslib.Elem(nodeToProcess));
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
} else if (nodeToProcess.selected && idSet.subContent
&& idSet.subContent.length > 0) {
this._prepareTargetWindows(idSet.subContent);
}
}
// Opens a new dialog/window by clicking on an object and runs
// DOMWalker.walk() for it.
else {
this._controller.click(new elementslib.Elem(nodeToProcess));
// If the target is a new modal/non-modal window, this.walk() has to be
// started by the method opening that window. If not, we do it here.
if (idSet.target == DOMWalker.WINDOW_CURRENT)
this.walk(idSet.subContent, null, idSet.waitFunction);
}
} | [
"function",
"DOMWalker_processNode",
"(",
"activeNode",
",",
"idSet",
")",
"{",
"var",
"doc",
"=",
"this",
".",
"_controller",
".",
"window",
".",
"document",
";",
"var",
"nodeToProcess",
"=",
"this",
".",
"_getNode",
"(",
"idSet",
")",
";",
"// Opens a new ... | Opens new windows/dialog and starts the DOMWalker.walk() in case of dialogs
in existing windows.
@param {Node} activeNode
Node that holds the information which way
to open the new window/dialog
@param {object} idSet
ID set for the element to open | [
"Opens",
"new",
"windows",
"/",
"dialog",
"and",
"starts",
"the",
"DOMWalker",
".",
"walk",
"()",
"in",
"case",
"of",
"dialogs",
"in",
"existing",
"windows",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L318-L402 | train | Process a node | [
30522,
3853,
14383,
26965,
1035,
2832,
3630,
3207,
1006,
3161,
3630,
3207,
1010,
8909,
13462,
1007,
1063,
13075,
9986,
1027,
2023,
1012,
1035,
11486,
1012,
3332,
1012,
6254,
1025,
13075,
13045,
14399,
3217,
9623,
2015,
1027,
2023,
1012,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/meta/meta.js | setMeta | function setMeta(name, content) {
mapExistingElement(name);
if (!metaElements[name]) {
var newMeta = angular.element('<meta name="' + name + '" content="' + content + '"/>');
head.append(newMeta);
metaElements[name] = newMeta;
}
else {
metaElements[name].attr('content', content);
}
return function () {
metaElements[name].attr('content', '');
metaElements[name].remove();
delete metaElements[name];
};
} | javascript | function setMeta(name, content) {
mapExistingElement(name);
if (!metaElements[name]) {
var newMeta = angular.element('<meta name="' + name + '" content="' + content + '"/>');
head.append(newMeta);
metaElements[name] = newMeta;
}
else {
metaElements[name].attr('content', content);
}
return function () {
metaElements[name].attr('content', '');
metaElements[name].remove();
delete metaElements[name];
};
} | [
"function",
"setMeta",
"(",
"name",
",",
"content",
")",
"{",
"mapExistingElement",
"(",
"name",
")",
";",
"if",
"(",
"!",
"metaElements",
"[",
"name",
"]",
")",
"{",
"var",
"newMeta",
"=",
"angular",
".",
"element",
"(",
"'<meta name=\"'",
"+",
"name",
... | @ngdoc method
@name $$mdMeta#setMeta
@description
Creates meta element with the 'name' and 'content' attributes,
if the meta tag is already created than we replace the 'content' value
@param {string} name meta tag 'name' attribute value
@param {string} content meta tag 'content' attribute value
@returns {function} remove function | [
"@ngdoc",
"method",
"@name",
"$$mdMeta#setMeta"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/meta/meta.js#L73-L90 | train | Sets the meta element | [
30522,
3853,
2275,
11368,
2050,
1006,
2171,
1010,
4180,
1007,
1063,
4949,
10288,
2923,
23496,
16930,
4765,
1006,
2171,
1007,
1025,
2065,
1006,
999,
18804,
12260,
8163,
1031,
2171,
1033,
1007,
1063,
13075,
2047,
11368,
2050,
1027,
16108,
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... |
grpc/grpc | examples/node/dynamic_codegen/route_guide/route_guide_server.js | getDistance | function getDistance(start, end) {
function toRadians(num) {
return num * Math.PI / 180;
}
var R = 6371000; // earth radius in metres
var lat1 = toRadians(start.latitude / COORD_FACTOR);
var lat2 = toRadians(end.latitude / COORD_FACTOR);
var lon1 = toRadians(start.longitude / COORD_FACTOR);
var lon2 = toRadians(end.longitude / COORD_FACTOR);
var deltalat = lat2-lat1;
var deltalon = lon2-lon1;
var a = Math.sin(deltalat/2) * Math.sin(deltalat/2) +
Math.cos(lat1) * Math.cos(lat2) *
Math.sin(deltalon/2) * Math.sin(deltalon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
} | javascript | function getDistance(start, end) {
function toRadians(num) {
return num * Math.PI / 180;
}
var R = 6371000; // earth radius in metres
var lat1 = toRadians(start.latitude / COORD_FACTOR);
var lat2 = toRadians(end.latitude / COORD_FACTOR);
var lon1 = toRadians(start.longitude / COORD_FACTOR);
var lon2 = toRadians(end.longitude / COORD_FACTOR);
var deltalat = lat2-lat1;
var deltalon = lon2-lon1;
var a = Math.sin(deltalat/2) * Math.sin(deltalat/2) +
Math.cos(lat1) * Math.cos(lat2) *
Math.sin(deltalon/2) * Math.sin(deltalon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
} | [
"function",
"getDistance",
"(",
"start",
",",
"end",
")",
"{",
"function",
"toRadians",
"(",
"num",
")",
"{",
"return",
"num",
"*",
"Math",
".",
"PI",
"/",
"180",
";",
"}",
"var",
"R",
"=",
"6371000",
";",
"// earth radius in metres",
"var",
"lat1",
"=... | Calculate the distance between two points using the "haversine" formula.
The formula is based on http://mathforum.org/library/drmath/view/51879.html.
@param start The starting point
@param end The end point
@return The distance between the points in meters | [
"Calculate",
"the",
"distance",
"between",
"two",
"points",
"using",
"the",
"haversine",
"formula",
".",
"The",
"formula",
"is",
"based",
"on",
"http",
":",
"//",
"mathforum",
".",
"org",
"/",
"library",
"/",
"drmath",
"/",
"view",
"/",
"51879",
".",
"ht... | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/dynamic_codegen/route_guide/route_guide_server.js#L120-L137 | train | Get distance between two points | [
30522,
3853,
2131,
10521,
26897,
1006,
2707,
1010,
2203,
1007,
1063,
3853,
17153,
25205,
3619,
1006,
16371,
2213,
1007,
1063,
2709,
16371,
2213,
1008,
8785,
1012,
14255,
1013,
8380,
1025,
1065,
13075,
1054,
1027,
6191,
2581,
18613,
2692,
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... |
SheetJS/js-xlsx | xlsx.js | parse_PtgSheet | function parse_PtgSheet(blob, length, opts) {
blob.l += 5;
blob.l += 2;
blob.l += (opts.biff == 2 ? 1 : 4);
return ["PTGSHEET"];
} | javascript | function parse_PtgSheet(blob, length, opts) {
blob.l += 5;
blob.l += 2;
blob.l += (opts.biff == 2 ? 1 : 4);
return ["PTGSHEET"];
} | [
"function",
"parse_PtgSheet",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"blob",
".",
"l",
"+=",
"5",
";",
"blob",
".",
"l",
"+=",
"2",
";",
"blob",
".",
"l",
"+=",
"(",
"opts",
".",
"biff",
"==",
"2",
"?",
"1",
":",
"4",
")",
";",
... | /* [XLS] old spec | [
"/",
"*",
"[",
"XLS",
"]",
"old",
"spec"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10695-L10700 | train | Parse a PTGSHEET | [
30522,
3853,
11968,
3366,
1035,
13866,
5620,
21030,
2102,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1019,
1025,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1016,
1025,
1038,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js | _validateStepsParams | function _validateStepsParams(match) {
var count = _convertToNumber(match[1]);
if (!count.isNumber || count.value < 1 || Math.floor(count.value) !== count.value) {
return false;
}
if (match[2] && match[2] !== "start" && match[2] !== "end") {
return false;
}
return true;
} | javascript | function _validateStepsParams(match) {
var count = _convertToNumber(match[1]);
if (!count.isNumber || count.value < 1 || Math.floor(count.value) !== count.value) {
return false;
}
if (match[2] && match[2] !== "start" && match[2] !== "end") {
return false;
}
return true;
} | [
"function",
"_validateStepsParams",
"(",
"match",
")",
"{",
"var",
"count",
"=",
"_convertToNumber",
"(",
"match",
"[",
"1",
"]",
")",
";",
"if",
"(",
"!",
"count",
".",
"isNumber",
"||",
"count",
".",
"value",
"<",
"1",
"||",
"Math",
".",
"floor",
"... | Validate steps function parameters that are not already validated by regex:
@param {RegExp.match} match RegExp Match object with steps function parameters
in array position 1 (and optionally 2).
@return {boolean} true if all parameters are valid, otherwise, false | [
"Validate",
"steps",
"function",
"parameters",
"that",
"are",
"not",
"already",
"validated",
"by",
"regex",
":"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js#L232-L244 | train | Validate step params | [
30522,
3853,
1035,
9398,
8520,
2618,
4523,
28689,
5244,
1006,
2674,
1007,
1063,
13075,
4175,
1027,
1035,
10463,
2669,
29440,
1006,
2674,
1031,
1015,
1033,
1007,
1025,
2065,
1006,
999,
4175,
1012,
3475,
29440,
1064,
1064,
4175,
1012,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/theming/theming.js | function() {
return angular.extend({ }, themeConfig, {
defaultTheme : defaultTheme,
alwaysWatchTheme : alwaysWatchTheme,
registeredStyles : [].concat(themeConfig.registeredStyles)
});
} | javascript | function() {
return angular.extend({ }, themeConfig, {
defaultTheme : defaultTheme,
alwaysWatchTheme : alwaysWatchTheme,
registeredStyles : [].concat(themeConfig.registeredStyles)
});
} | [
"function",
"(",
")",
"{",
"return",
"angular",
".",
"extend",
"(",
"{",
"}",
",",
"themeConfig",
",",
"{",
"defaultTheme",
":",
"defaultTheme",
",",
"alwaysWatchTheme",
":",
"alwaysWatchTheme",
",",
"registeredStyles",
":",
"[",
"]",
".",
"concat",
"(",
"... | return a read-only clone of the current theme configuration | [
"return",
"a",
"read",
"-",
"only",
"clone",
"of",
"the",
"current",
"theme",
"configuration"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L297-L303 | train | Returns the configuration for the current theme | [
30522,
3853,
1006,
1007,
1063,
2709,
16108,
1012,
7949,
1006,
1063,
1065,
1010,
4323,
8663,
8873,
2290,
1010,
1063,
12398,
10760,
4168,
1024,
12398,
10760,
4168,
1010,
30524,
10760,
4168,
1010,
5068,
21756,
4244,
1024,
1031,
1033,
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... | |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
console.log("Runtime.evaluate");
var result = eval(msg.params.expression);
MessageBroker.respond(msg, {
result: JSON.stringify(result) // TODO: in original protocol this is an object handle
});
} | javascript | function (msg) {
console.log("Runtime.evaluate");
var result = eval(msg.params.expression);
MessageBroker.respond(msg, {
result: JSON.stringify(result) // TODO: in original protocol this is an object handle
});
} | [
"function",
"(",
"msg",
")",
"{",
"console",
".",
"log",
"(",
"\"Runtime.evaluate\"",
")",
";",
"var",
"result",
"=",
"eval",
"(",
"msg",
".",
"params",
".",
"expression",
")",
";",
"MessageBroker",
".",
"respond",
"(",
"msg",
",",
"{",
"result",
":",
... | Evaluate an expresion and return its result. | [
"Evaluate",
"an",
"expresion",
"and",
"return",
"its",
"result",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L141-L147 | train | evaluate the expression | [
30522,
3853,
1006,
5796,
2290,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
2448,
7292,
1012,
16157,
1000,
1007,
1025,
13075,
2765,
1027,
9345,
2140,
1006,
5796,
2290,
1012,
11498,
5244,
1012,
3670,
1007,
1025,
4471,
12618,
5484,
1012,
6869,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | function(sName, mAnnotations, mTarget) {
// Everything in here must be on Term level, so we overwrite the target with the data from the source
if (Array.isArray(mAnnotations[sName])) {
// This is a collection - make sure it stays one
mTarget[sName] = mAnnotations[sName].slice(0);
} else {
// Make sure the map exists in the target
mTarget[sName] = mTarget[sName] || {};
for (var sKey in mAnnotations[sName]) {
mTarget[sName][sKey] = mAnnotations[sName][sKey];
}
}
} | javascript | function(sName, mAnnotations, mTarget) {
// Everything in here must be on Term level, so we overwrite the target with the data from the source
if (Array.isArray(mAnnotations[sName])) {
// This is a collection - make sure it stays one
mTarget[sName] = mAnnotations[sName].slice(0);
} else {
// Make sure the map exists in the target
mTarget[sName] = mTarget[sName] || {};
for (var sKey in mAnnotations[sName]) {
mTarget[sName][sKey] = mAnnotations[sName][sKey];
}
}
} | [
"function",
"(",
"sName",
",",
"mAnnotations",
",",
"mTarget",
")",
"{",
"// Everything in here must be on Term level, so we overwrite the target with the data from the source",
"if",
"(",
"Array",
".",
"isArray",
"(",
"mAnnotations",
"[",
"sName",
"]",
")",
")",
"{",
"... | /*
@static
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L140-L154 | train | This function is called by the annotation processor to create a new map of the target object | [
30522,
3853,
1006,
1055,
18442,
1010,
10856,
17287,
9285,
1010,
11047,
2906,
18150,
1007,
1063,
1013,
1013,
2673,
1999,
2182,
2442,
2022,
2006,
2744,
2504,
1010,
2061,
2057,
2058,
26373,
1996,
4539,
2007,
1996,
2951,
2013,
1996,
3120,
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... | |
angular/material | src/core/services/theming/theming.js | checkPaletteValid | function checkPaletteValid(name, map) {
var missingColors = VALID_HUE_VALUES.filter(function(field) {
return !map[field];
});
if (missingColors.length) {
throw new Error("Missing colors %1 in palette %2!"
.replace('%1', missingColors.join(', '))
.replace('%2', name));
}
return map;
} | javascript | function checkPaletteValid(name, map) {
var missingColors = VALID_HUE_VALUES.filter(function(field) {
return !map[field];
});
if (missingColors.length) {
throw new Error("Missing colors %1 in palette %2!"
.replace('%1', missingColors.join(', '))
.replace('%2', name));
}
return map;
} | [
"function",
"checkPaletteValid",
"(",
"name",
",",
"map",
")",
"{",
"var",
"missingColors",
"=",
"VALID_HUE_VALUES",
".",
"filter",
"(",
"function",
"(",
"field",
")",
"{",
"return",
"!",
"map",
"[",
"field",
"]",
";",
"}",
")",
";",
"if",
"(",
"missin... | Make sure that palette has all required hues | [
"Make",
"sure",
"that",
"palette",
"has",
"all",
"required",
"hues"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/theming/theming.js#L441-L452 | train | Check if the palette is valid | [
30522,
3853,
4638,
12952,
7585,
10175,
3593,
1006,
2171,
1010,
4949,
1007,
1063,
13075,
4394,
18717,
2015,
1027,
9398,
1035,
20639,
1035,
5300,
1012,
11307,
1006,
3853,
1006,
2492,
1007,
1063,
2709,
999,
4949,
1031,
2492,
1033,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/source-code-fixer.js | compareMessagesByFixRange | function compareMessagesByFixRange(a, b) {
return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
} | javascript | function compareMessagesByFixRange(a, b) {
return a.fix.range[0] - b.fix.range[0] || a.fix.range[1] - b.fix.range[1];
} | [
"function",
"compareMessagesByFixRange",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"fix",
".",
"range",
"[",
"0",
"]",
"-",
"b",
".",
"fix",
".",
"range",
"[",
"0",
"]",
"||",
"a",
".",
"fix",
".",
"range",
"[",
"1",
"]",
"-",
"b",
".... | Compares items in a messages array by range.
@param {Message} a The first message.
@param {Message} b The second message.
@returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
@private | [
"Compares",
"items",
"in",
"a",
"messages",
"array",
"by",
"range",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/source-code-fixer.js#L26-L28 | train | Compare messages by fix range | [
30522,
3853,
12826,
7834,
3736,
8449,
3762,
8873,
2595,
24388,
2063,
1006,
1037,
1010,
1038,
1007,
1063,
2709,
1037,
1012,
8081,
1012,
2846,
1031,
1014,
1033,
1011,
1038,
1012,
8081,
1012,
2846,
1031,
1014,
1033,
1064,
1064,
1037,
1012,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentManager.js | createUntitledDocument | function createUntitledDocument(counter, fileExt) {
var filename = Strings.UNTITLED + "-" + counter + fileExt,
fullPath = _untitledDocumentPath + "/" + filename,
now = new Date(),
file = new InMemoryFile(fullPath, FileSystem);
FileSystem.addEntryForPathIfRequired(file, fullPath);
return new DocumentModule.Document(file, now, "");
} | javascript | function createUntitledDocument(counter, fileExt) {
var filename = Strings.UNTITLED + "-" + counter + fileExt,
fullPath = _untitledDocumentPath + "/" + filename,
now = new Date(),
file = new InMemoryFile(fullPath, FileSystem);
FileSystem.addEntryForPathIfRequired(file, fullPath);
return new DocumentModule.Document(file, now, "");
} | [
"function",
"createUntitledDocument",
"(",
"counter",
",",
"fileExt",
")",
"{",
"var",
"filename",
"=",
"Strings",
".",
"UNTITLED",
"+",
"\"-\"",
"+",
"counter",
"+",
"fileExt",
",",
"fullPath",
"=",
"_untitledDocumentPath",
"+",
"\"/\"",
"+",
"filename",
",",... | Creates an untitled document. The associated File has a fullPath that
looks like /some-random-string/Untitled-counter.fileExt.
@param {number} counter - used in the name of the new Document's File
@param {string} fileExt - file extension of the new Document's File, including "."
@return {Document} - a new untitled Document | [
"Creates",
"an",
"untitled",
"document",
".",
"The",
"associated",
"File",
"has",
"a",
"fullPath",
"that",
"looks",
"like",
"/",
"some",
"-",
"random",
"-",
"string",
"/",
"Untitled",
"-",
"counter",
".",
"fileExt",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L448-L457 | train | Create a new unntitled document | [
30522,
3853,
3443,
16671,
4183,
3709,
3527,
24894,
4765,
1006,
4675,
1010,
5371,
10288,
2102,
1007,
1063,
13075,
5371,
18442,
1027,
7817,
1012,
24819,
1009,
1000,
1011,
1000,
1009,
4675,
1009,
5371,
10288,
2102,
1010,
2440,
15069,
1027,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/EditorCommandHandlers.js | duplicateText | function duplicateText(editor) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
var selections = editor.getSelections(),
delimiter = "",
edits = [],
rangeSels = [],
cursorSels = [],
doc = editor.document;
// When there are multiple selections, we want to handle all the cursors first (duplicating
// their lines), then all the ranges (duplicating the ranges).
_.each(selections, function (sel) {
if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
cursorSels.push(sel);
} else {
rangeSels.push(sel);
}
});
var cursorLineSels = editor.convertToLineSelections(cursorSels);
_.each(cursorLineSels, function (lineSel, index) {
var sel = lineSel.selectionForEdit;
if (sel.end.line === editor.lineCount()) {
delimiter = "\n";
}
// Don't need to explicitly track selections since we are doing the edits in such a way that
// the existing selections will get appropriately updated.
edits.push({edit: {text: doc.getRange(sel.start, sel.end) + delimiter, start: sel.start }});
});
_.each(rangeSels, function (sel) {
edits.push({edit: {text: doc.getRange(sel.start, sel.end), start: sel.start }});
});
doc.doMultipleEdits(edits);
} | javascript | function duplicateText(editor) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
var selections = editor.getSelections(),
delimiter = "",
edits = [],
rangeSels = [],
cursorSels = [],
doc = editor.document;
// When there are multiple selections, we want to handle all the cursors first (duplicating
// their lines), then all the ranges (duplicating the ranges).
_.each(selections, function (sel) {
if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
cursorSels.push(sel);
} else {
rangeSels.push(sel);
}
});
var cursorLineSels = editor.convertToLineSelections(cursorSels);
_.each(cursorLineSels, function (lineSel, index) {
var sel = lineSel.selectionForEdit;
if (sel.end.line === editor.lineCount()) {
delimiter = "\n";
}
// Don't need to explicitly track selections since we are doing the edits in such a way that
// the existing selections will get appropriately updated.
edits.push({edit: {text: doc.getRange(sel.start, sel.end) + delimiter, start: sel.start }});
});
_.each(rangeSels, function (sel) {
edits.push({edit: {text: doc.getRange(sel.start, sel.end), start: sel.start }});
});
doc.doMultipleEdits(edits);
} | [
"function",
"duplicateText",
"(",
"editor",
")",
"{",
"editor",
"=",
"editor",
"||",
"EditorManager",
".",
"getFocusedEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"var",
"selections",
"=",
"editor",
".",
"getSelections",
... | Duplicates the selected text, or current line if no selection. The cursor/selection is left
on the second copy. | [
"Duplicates",
"the",
"selected",
"text",
"or",
"current",
"line",
"if",
"no",
"selection",
".",
"The",
"cursor",
"/",
"selection",
"is",
"left",
"on",
"the",
"second",
"copy",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L737-L775 | train | Duplicate text from the editor | [
30522,
3853,
24473,
18209,
1006,
3559,
1007,
1063,
3559,
1027,
3559,
1064,
1064,
3559,
24805,
4590,
1012,
2131,
14876,
7874,
19082,
15660,
1006,
1007,
1025,
2065,
1006,
999,
3559,
1007,
1063,
2709,
1025,
1065,
13075,
16310,
1027,
3559,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | getAny | function getAny(oWithControl, oBindingInfo, mSettings, oScope, bAsync) {
var bValueAsPromise = false;
/*
* Prepares the given binding info or part of it; makes it "one time" and binds its
* formatter function (if opted in) to an interface object.
*
* @param {object} oInfo
* a binding info or a part of it
* @param {number} i
* index of binding info's part (if applicable)
*/
function prepare(oInfo, i) {
var fnFormatter = oInfo.formatter,
oModel,
sModelName = oInfo.model;
if (oInfo.path && oInfo.path.indexOf(">") > 0) {
sModelName = oInfo.path.slice(0, oInfo.path.indexOf(">"));
}
oModel = oWithControl.getModel(sModelName);
if (fnFormatter && fnFormatter.requiresIContext === true) {
fnFormatter = oInfo.formatter
= fnFormatter.bind(null, createContextInterface(oWithControl, mSettings, i));
}
// wrap formatter only if there is a formatter and async is allowed and either
// - we use $$valueAsPromise ourselves, or
// - we are top-level and at least one child has used $$valueAsPromise
if (fnFormatter && bAsync
&& (oModel && oModel.$$valueAsPromise || i === undefined && bValueAsPromise)) {
oInfo.formatter = function () {
var that = this;
return SyncPromise.all(arguments).then(function (aArguments) {
return fnFormatter.apply(that, aArguments);
});
};
oInfo.formatter.textFragments = fnFormatter.textFragments;
}
oInfo.mode = BindingMode.OneTime;
oInfo.parameters = oInfo.parameters || {};
oInfo.parameters.scope = oScope;
if (bAsync && oModel && oModel.$$valueAsPromise) { // opt-in to async behavior
bValueAsPromise = oInfo.parameters.$$valueAsPromise = true;
}
}
try {
if (oBindingInfo.parts) {
oBindingInfo.parts.forEach(prepare);
}
prepare(oBindingInfo);
oWithControl.bindProperty("any", oBindingInfo);
return oWithControl.getBinding("any")
? SyncPromise.resolve(oWithControl.getAny())
: null;
} catch (e) {
return SyncPromise.reject(e);
} finally {
oWithControl.unbindProperty("any", true);
}
} | javascript | function getAny(oWithControl, oBindingInfo, mSettings, oScope, bAsync) {
var bValueAsPromise = false;
/*
* Prepares the given binding info or part of it; makes it "one time" and binds its
* formatter function (if opted in) to an interface object.
*
* @param {object} oInfo
* a binding info or a part of it
* @param {number} i
* index of binding info's part (if applicable)
*/
function prepare(oInfo, i) {
var fnFormatter = oInfo.formatter,
oModel,
sModelName = oInfo.model;
if (oInfo.path && oInfo.path.indexOf(">") > 0) {
sModelName = oInfo.path.slice(0, oInfo.path.indexOf(">"));
}
oModel = oWithControl.getModel(sModelName);
if (fnFormatter && fnFormatter.requiresIContext === true) {
fnFormatter = oInfo.formatter
= fnFormatter.bind(null, createContextInterface(oWithControl, mSettings, i));
}
// wrap formatter only if there is a formatter and async is allowed and either
// - we use $$valueAsPromise ourselves, or
// - we are top-level and at least one child has used $$valueAsPromise
if (fnFormatter && bAsync
&& (oModel && oModel.$$valueAsPromise || i === undefined && bValueAsPromise)) {
oInfo.formatter = function () {
var that = this;
return SyncPromise.all(arguments).then(function (aArguments) {
return fnFormatter.apply(that, aArguments);
});
};
oInfo.formatter.textFragments = fnFormatter.textFragments;
}
oInfo.mode = BindingMode.OneTime;
oInfo.parameters = oInfo.parameters || {};
oInfo.parameters.scope = oScope;
if (bAsync && oModel && oModel.$$valueAsPromise) { // opt-in to async behavior
bValueAsPromise = oInfo.parameters.$$valueAsPromise = true;
}
}
try {
if (oBindingInfo.parts) {
oBindingInfo.parts.forEach(prepare);
}
prepare(oBindingInfo);
oWithControl.bindProperty("any", oBindingInfo);
return oWithControl.getBinding("any")
? SyncPromise.resolve(oWithControl.getAny())
: null;
} catch (e) {
return SyncPromise.reject(e);
} finally {
oWithControl.unbindProperty("any", true);
}
} | [
"function",
"getAny",
"(",
"oWithControl",
",",
"oBindingInfo",
",",
"mSettings",
",",
"oScope",
",",
"bAsync",
")",
"{",
"var",
"bValueAsPromise",
"=",
"false",
";",
"/*\n\t\t * Prepares the given binding info or part of it; makes it \"one time\" and binds its\n\t\t * formatte... | Gets the value of the control's "any" property via the given binding info.
@param {sap.ui.core.util._with} oWithControl
the "with" control
@param {object} oBindingInfo
the binding info
@param {object} mSettings
map/JSON-object with initial property values, etc.
@param {object} oScope
map of currently known aliases
@param {boolean} bAsync
whether async processing is allowed
@returns {sap.ui.base.SyncPromise|null}
a sync promise which resolves with the property 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) | [
"Gets",
"the",
"value",
"of",
"the",
"control",
"s",
"any",
"property",
"via",
"the",
"given",
"binding",
"info",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L346-L408 | train | Returns the first binding that is not a part of it. | [
30522,
3853,
2131,
19092,
1006,
27593,
8939,
8663,
13181,
2140,
1010,
27885,
22254,
2075,
2378,
14876,
1010,
5796,
18319,
3070,
2015,
1010,
9808,
16186,
1010,
19021,
6038,
2278,
1007,
1063,
13075,
1038,
10175,
5657,
3022,
21572,
28732,
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... |
swimlane/ngx-datatable | release/utils/math.js | adjustColumnWidths | function adjustColumnWidths(allColumns, expectedWidth) {
var columnsWidth = column_1.columnsTotalWidth(allColumns);
var totalFlexGrow = getTotalFlexGrow(allColumns);
var colsByGroup = column_1.columnsByPin(allColumns);
if (columnsWidth !== expectedWidth) {
scaleColumns(colsByGroup, expectedWidth, totalFlexGrow);
}
} | javascript | function adjustColumnWidths(allColumns, expectedWidth) {
var columnsWidth = column_1.columnsTotalWidth(allColumns);
var totalFlexGrow = getTotalFlexGrow(allColumns);
var colsByGroup = column_1.columnsByPin(allColumns);
if (columnsWidth !== expectedWidth) {
scaleColumns(colsByGroup, expectedWidth, totalFlexGrow);
}
} | [
"function",
"adjustColumnWidths",
"(",
"allColumns",
",",
"expectedWidth",
")",
"{",
"var",
"columnsWidth",
"=",
"column_1",
".",
"columnsTotalWidth",
"(",
"allColumns",
")",
";",
"var",
"totalFlexGrow",
"=",
"getTotalFlexGrow",
"(",
"allColumns",
")",
";",
"var",... | Adjusts the column widths.
Inspired by: https://github.com/facebook/fixed-data-table/blob/master/src/FixedDataTableWidthHelper.js | [
"Adjusts",
"the",
"column",
"widths",
".",
"Inspired",
"by",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"facebook",
"/",
"fixed",
"-",
"data",
"-",
"table",
"/",
"blob",
"/",
"master",
"/",
"src",
"/",
"FixedDataTableWidthHelper",
".",
"js"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/math.js#L20-L27 | train | Adjusts the widths of all columns to match the expected width | [
30522,
3853,
14171,
25778,
2819,
2078,
9148,
11927,
7898,
1006,
2035,
25778,
2819,
3619,
1010,
3517,
9148,
11927,
2232,
1007,
1063,
13075,
7753,
9148,
11927,
2232,
1027,
5930,
1035,
1015,
1012,
7753,
3406,
9080,
9148,
11927,
2232,
1006,
203... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Source.js | Source | function Source(fields) {
/**
* @type {boolean}
*/
this.fromDataset = fields.fromDataset;
/**
* Not null/undefined.
* @type {Array|Object}
*/
this.data = fields.data || (
fields.sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ? {} : []
);
/**
* See also "detectSourceFormat".
* Not null/undefined.
* @type {string}
*/
this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN;
/**
* 'row' or 'column'
* Not null/undefined.
* @type {string} seriesLayoutBy
*/
this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
/**
* dimensions definition in option.
* can be null/undefined.
* @type {Array.<Object|string>}
*/
this.dimensionsDefine = fields.dimensionsDefine;
/**
* encode definition in option.
* can be null/undefined.
* @type {Objet|HashMap}
*/
this.encodeDefine = fields.encodeDefine && createHashMap(fields.encodeDefine);
/**
* Not null/undefined, uint.
* @type {number}
*/
this.startIndex = fields.startIndex || 0;
/**
* Can be null/undefined (when unknown), uint.
* @type {number}
*/
this.dimensionsDetectCount = fields.dimensionsDetectCount;
} | javascript | function Source(fields) {
/**
* @type {boolean}
*/
this.fromDataset = fields.fromDataset;
/**
* Not null/undefined.
* @type {Array|Object}
*/
this.data = fields.data || (
fields.sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ? {} : []
);
/**
* See also "detectSourceFormat".
* Not null/undefined.
* @type {string}
*/
this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN;
/**
* 'row' or 'column'
* Not null/undefined.
* @type {string} seriesLayoutBy
*/
this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
/**
* dimensions definition in option.
* can be null/undefined.
* @type {Array.<Object|string>}
*/
this.dimensionsDefine = fields.dimensionsDefine;
/**
* encode definition in option.
* can be null/undefined.
* @type {Objet|HashMap}
*/
this.encodeDefine = fields.encodeDefine && createHashMap(fields.encodeDefine);
/**
* Not null/undefined, uint.
* @type {number}
*/
this.startIndex = fields.startIndex || 0;
/**
* Can be null/undefined (when unknown), uint.
* @type {number}
*/
this.dimensionsDetectCount = fields.dimensionsDetectCount;
} | [
"function",
"Source",
"(",
"fields",
")",
"{",
"/**\n * @type {boolean}\n */",
"this",
".",
"fromDataset",
"=",
"fields",
".",
"fromDataset",
";",
"/**\n * Not null/undefined.\n * @type {Array|Object}\n */",
"this",
".",
"data",
"=",
"fields",
".",
"da... | [sourceFormat]
+ "original":
This format is only used in series.data, where
itemStyle can be specified in data item.
+ "arrayRows":
[
['product', 'score', 'amount'],
['Matcha Latte', 89.3, 95.8],
['Milk Tea', 92.1, 89.4],
['Cheese Cocoa', 94.4, 91.2],
['Walnut Brownie', 85.4, 76.9]
]
+ "objectRows":
[
{product: 'Matcha Latte', score: 89.3, amount: 95.8},
{product: 'Milk Tea', score: 92.1, amount: 89.4},
{product: 'Cheese Cocoa', score: 94.4, amount: 91.2},
{product: 'Walnut Brownie', score: 85.4, amount: 76.9}
]
+ "keyedColumns":
{
'product': ['Matcha Latte', 'Milk Tea', 'Cheese Cocoa', 'Walnut Brownie'],
'count': [823, 235, 1042, 988],
'score': [95.8, 81.4, 91.2, 76.9]
}
+ "typedArray"
+ "unknown"
@constructor
@param {Object} fields
@param {string} fields.sourceFormat
@param {Array|Object} fields.fromDataset
@param {Array|Object} [fields.data]
@param {string} [seriesLayoutBy='column']
@param {Array.<Object|string>} [dimensionsDefine]
@param {Objet|HashMap} [encodeDefine]
@param {number} [startIndex=0]
@param {number} [dimensionsDetectCount] | [
"[",
"sourceFormat",
"]"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Source.js#L78-L132 | train | A source object. | [
30522,
3853,
3120,
1006,
4249,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2828,
1063,
22017,
20898,
1065,
1008,
1013,
2023,
1012,
2013,
2850,
18260,
2102,
1027,
4249,
1012,
2013,
2850,
18260,
2102,
1025,
1013,
1008,
1008,
1008,
2025,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/App.controller.js | function() {
var data = {};
if (this._oFeedbackDialog.contextCheckBox.getSelected()) {
data = {
"texts": {
"t1": this._oFeedbackDialog.textInput.getValue()
},
"ratings":{
"r1": {"value" : this._oFeedbackDialog.ratingStatus.value}
},
"context": {"page": this._getCurrentPageRelativeURL(), "attr1": this._getUI5Distribution() + ":" + sap.ui.version}
};
} else {
data = {
"texts": {
"t1": this._oFeedbackDialog.textInput.getValue()
},
"ratings":{
"r1": {"value" : this._oFeedbackDialog.ratingStatus.value}
},
"context": {"attr1": this._getUI5Distribution() + ":" + sap.ui.version}
};
}
// send feedback
this._oFeedbackDialog.setBusyIndicatorDelay(0);
this._oFeedbackDialog.setBusy(true);
jQuery.ajax({
url: this.FEEDBACK_SERVICE_URL,
type: "POST",
contentType: "application/json",
data: JSON.stringify(data)
}).
done(
function () {
MessageBox.success("Your feedback has been sent.", {title: "Thank you!"});
this._oFeedbackDialog.reset();
this._oFeedbackDialog.close();
this._oFeedbackDialog.setBusy(false);
}.bind(this)
).
fail(
function (oRequest, sStatus, sError) {
var sErrorDetails = sError; // + "\n" + oRequest.responseText;
MessageBox.error("An error occurred sending your feedback:\n" + sErrorDetails, {title: "Sorry!"});
this._oFeedbackDialog.setBusy(false);
}.bind(this)
);
} | javascript | function() {
var data = {};
if (this._oFeedbackDialog.contextCheckBox.getSelected()) {
data = {
"texts": {
"t1": this._oFeedbackDialog.textInput.getValue()
},
"ratings":{
"r1": {"value" : this._oFeedbackDialog.ratingStatus.value}
},
"context": {"page": this._getCurrentPageRelativeURL(), "attr1": this._getUI5Distribution() + ":" + sap.ui.version}
};
} else {
data = {
"texts": {
"t1": this._oFeedbackDialog.textInput.getValue()
},
"ratings":{
"r1": {"value" : this._oFeedbackDialog.ratingStatus.value}
},
"context": {"attr1": this._getUI5Distribution() + ":" + sap.ui.version}
};
}
// send feedback
this._oFeedbackDialog.setBusyIndicatorDelay(0);
this._oFeedbackDialog.setBusy(true);
jQuery.ajax({
url: this.FEEDBACK_SERVICE_URL,
type: "POST",
contentType: "application/json",
data: JSON.stringify(data)
}).
done(
function () {
MessageBox.success("Your feedback has been sent.", {title: "Thank you!"});
this._oFeedbackDialog.reset();
this._oFeedbackDialog.close();
this._oFeedbackDialog.setBusy(false);
}.bind(this)
).
fail(
function (oRequest, sStatus, sError) {
var sErrorDetails = sError; // + "\n" + oRequest.responseText;
MessageBox.error("An error occurred sending your feedback:\n" + sErrorDetails, {title: "Sorry!"});
this._oFeedbackDialog.setBusy(false);
}.bind(this)
);
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"{",
"}",
";",
"if",
"(",
"this",
".",
"_oFeedbackDialog",
".",
"contextCheckBox",
".",
"getSelected",
"(",
")",
")",
"{",
"data",
"=",
"{",
"\"texts\"",
":",
"{",
"\"t1\"",
":",
"this",
".",
"_oFeedback... | Event handler for the send feedback button | [
"Event",
"handler",
"for",
"the",
"send",
"feedback",
"button"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/App.controller.js#L513-L564 | train | Send the feedback | [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
1063,
1065,
1025,
2065,
1006,
2023,
1012,
1035,
1997,
13089,
5963,
27184,
8649,
1012,
6123,
5403,
3600,
8758,
1012,
4152,
12260,
10985,
1006,
1007,
1007,
1063,
2951,
1027,
1063,
1000,
6981,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
getsentry/sentry-javascript | packages/raven-js/Gruntfile.js | function(a) {
var fn = function(n, src, got, all) {
if (n === 0) {
all.push(got);
return;
}
for (var j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
};
var excluded = excludedPlugins.map(function(plugin) {
return 'plugins/' + plugin + '.js';
});
// Remove the plugins that we don't want to build
a = a.filter(function(n) {
return excluded.indexOf(n) === -1;
});
var all = [a];
for (var i = 0; i < a.length; i++) {
fn(i, a, [], all);
}
return all;
} | javascript | function(a) {
var fn = function(n, src, got, all) {
if (n === 0) {
all.push(got);
return;
}
for (var j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
};
var excluded = excludedPlugins.map(function(plugin) {
return 'plugins/' + plugin + '.js';
});
// Remove the plugins that we don't want to build
a = a.filter(function(n) {
return excluded.indexOf(n) === -1;
});
var all = [a];
for (var i = 0; i < a.length; i++) {
fn(i, a, [], all);
}
return all;
} | [
"function",
"(",
"a",
")",
"{",
"var",
"fn",
"=",
"function",
"(",
"n",
",",
"src",
",",
"got",
",",
"all",
")",
"{",
"if",
"(",
"n",
"===",
"0",
")",
"{",
"all",
".",
"push",
"(",
"got",
")",
";",
"return",
";",
"}",
"for",
"(",
"var",
"... | Taken from http://dzone.com/snippets/calculate-all-combinations | [
"Taken",
"from",
"http",
":",
"//",
"dzone",
".",
"com",
"/",
"snippets",
"/",
"calculate",
"-",
"all",
"-",
"combinations"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/Gruntfile.js#L39-L67 | train | Build the xsd | [
30522,
3853,
1006,
1037,
1007,
1063,
13075,
1042,
2078,
1027,
3853,
1006,
1050,
1010,
5034,
2278,
1010,
2288,
1010,
2035,
1007,
1063,
2065,
1006,
1050,
1027,
1027,
1027,
1014,
1007,
1063,
2035,
1012,
5245,
1006,
2288,
1007,
1025,
2709,
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... | |
mescroll/mescroll | mescroll-uni/dist/mescroll-uni.js | function() {
me.downHight = 0;
me.isDownScrolling = false;
me.optDown.endDownScroll && me.optDown.endDownScroll(me);
} | javascript | function() {
me.downHight = 0;
me.isDownScrolling = false;
me.optDown.endDownScroll && me.optDown.endDownScroll(me);
} | [
"function",
"(",
")",
"{",
"me",
".",
"downHight",
"=",
"0",
";",
"me",
".",
"isDownScrolling",
"=",
"false",
";",
"me",
".",
"optDown",
".",
"endDownScroll",
"&&",
"me",
".",
"optDown",
".",
"endDownScroll",
"(",
"me",
")",
";",
"}"
] | 结束下拉刷新的方法 | [
"结束下拉刷新的方法"
] | 43d3dcf3062da0fe95995ddcb5e93f5725792c98 | https://github.com/mescroll/mescroll/blob/43d3dcf3062da0fe95995ddcb5e93f5725792c98/mescroll-uni/dist/mescroll-uni.js#L264-L268 | train | end down scroll | [
30522,
3853,
1006,
1007,
1063,
2033,
1012,
2091,
4048,
13900,
1027,
1014,
1025,
2033,
1012,
2003,
7698,
11020,
28402,
2075,
1027,
6270,
1025,
2033,
1012,
23569,
7698,
1012,
2203,
7698,
11020,
28402,
1004,
1004,
2033,
1012,
23569,
7698,
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... | |
babel/babel | packages/babel-helper-module-transforms/src/index.js | buildESModuleHeader | function buildESModuleHeader(
metadata: ModuleMetadata,
enumerable: boolean = false,
) {
return (enumerable
? template.statement`
EXPORTS.__esModule = true;
`
: template.statement`
Object.defineProperty(EXPORTS, "__esModule", {
value: true,
});
`)({ EXPORTS: metadata.exportName });
} | javascript | function buildESModuleHeader(
metadata: ModuleMetadata,
enumerable: boolean = false,
) {
return (enumerable
? template.statement`
EXPORTS.__esModule = true;
`
: template.statement`
Object.defineProperty(EXPORTS, "__esModule", {
value: true,
});
`)({ EXPORTS: metadata.exportName });
} | [
"function",
"buildESModuleHeader",
"(",
"metadata",
":",
"ModuleMetadata",
",",
"enumerable",
":",
"boolean",
"=",
"false",
",",
")",
"{",
"return",
"(",
"enumerable",
"?",
"template",
".",
"statement",
"`",
"`",
":",
"template",
".",
"statement",
"`",
"`",
... | Build an "__esModule" header statement setting the property on a given object. | [
"Build",
"an",
"__esModule",
"header",
"statement",
"setting",
"the",
"property",
"on",
"a",
"given",
"object",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-helper-module-transforms/src/index.js#L213-L226 | train | Build the header for the module | [
30522,
3853,
3857,
2229,
5302,
8566,
2571,
4974,
2121,
1006,
27425,
1024,
11336,
11368,
8447,
2696,
1010,
4372,
17897,
16670,
1024,
22017,
20898,
1027,
6270,
1010,
1007,
1063,
2709,
1006,
4372,
17897,
16670,
1029,
23561,
1012,
4861,
1036,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/MockServer.js | function(data, select, currentPath) {
var result = {};
// traversed path to get to data:
currentPath = currentPath || '';
if (typeof data !== 'object') {
return data;
}
if (typeof data.slice === 'function') {
return data.map(function(el, index) {
return fnMultiSelect(el, select, currentPath); // on same path
});
}
// If Object:
// Handle "__metadata" property
if (data.__metadata !== undefined && currentPath.length === 0) {
result.__metadata = data.__metadata;
}
// Take the relevant paths only.
select.filter(function(path) {
return (path + '/').indexOf(currentPath) === 0;
}).forEach(function(path, _, innerSelect) {
// then get the next property in given path
var propertyKey = path.substr(currentPath.length).split('/')[0];
// Check if we have that propertyKey on the current object
if (data[propertyKey] !== undefined) {
// in this case recurse again while adding this to the current path
result[propertyKey] = fnMultiSelect(data[propertyKey], innerSelect, currentPath + propertyKey + '/');
}
});
// Add specific results case handling
if (data.results !== undefined) { // recurse with same path
result.results = fnMultiSelect(data.results, select, currentPath);
}
return result;
} | javascript | function(data, select, currentPath) {
var result = {};
// traversed path to get to data:
currentPath = currentPath || '';
if (typeof data !== 'object') {
return data;
}
if (typeof data.slice === 'function') {
return data.map(function(el, index) {
return fnMultiSelect(el, select, currentPath); // on same path
});
}
// If Object:
// Handle "__metadata" property
if (data.__metadata !== undefined && currentPath.length === 0) {
result.__metadata = data.__metadata;
}
// Take the relevant paths only.
select.filter(function(path) {
return (path + '/').indexOf(currentPath) === 0;
}).forEach(function(path, _, innerSelect) {
// then get the next property in given path
var propertyKey = path.substr(currentPath.length).split('/')[0];
// Check if we have that propertyKey on the current object
if (data[propertyKey] !== undefined) {
// in this case recurse again while adding this to the current path
result[propertyKey] = fnMultiSelect(data[propertyKey], innerSelect, currentPath + propertyKey + '/');
}
});
// Add specific results case handling
if (data.results !== undefined) { // recurse with same path
result.results = fnMultiSelect(data.results, select, currentPath);
}
return result;
} | [
"function",
"(",
"data",
",",
"select",
",",
"currentPath",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"// traversed path to get to data:",
"currentPath",
"=",
"currentPath",
"||",
"''",
";",
"if",
"(",
"typeof",
"data",
"!==",
"'object'",
")",
"{",
"r... | Add Support for multiple select return 1...n | [
"Add",
"Support",
"for",
"multiple",
"select",
"return",
"1",
"...",
"n"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/MockServer.js#L976-L1010 | train | Recursively select the given data object. | [
30522,
3853,
1006,
2951,
1010,
7276,
1010,
2783,
15069,
1007,
1063,
13075,
2765,
1027,
1063,
1065,
1025,
1013,
1013,
27797,
4130,
2000,
2131,
2000,
2951,
1024,
2783,
15069,
1027,
2783,
15069,
1064,
1064,
1005,
1005,
1025,
2065,
1006,
2828,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
electron/electron | lib/renderer/api/remote.js | setObjectMembers | function setObjectMembers (ref, object, metaId, members) {
if (!Array.isArray(members)) return
for (const member of members) {
if (object.hasOwnProperty(member.name)) continue
const descriptor = { enumerable: member.enumerable }
if (member.type === 'method') {
const remoteMemberFunction = function (...args) {
let command
if (this && this.constructor === remoteMemberFunction) {
command = 'ELECTRON_BROWSER_MEMBER_CONSTRUCTOR'
} else {
command = 'ELECTRON_BROWSER_MEMBER_CALL'
}
const ret = ipcRendererInternal.sendSync(command, contextId, metaId, member.name, wrapArgs(args))
return metaToValue(ret)
}
let descriptorFunction = proxyFunctionProperties(remoteMemberFunction, metaId, member.name)
descriptor.get = () => {
descriptorFunction.ref = ref // The member should reference its object.
return descriptorFunction
}
// Enable monkey-patch the method
descriptor.set = (value) => {
descriptorFunction = value
return value
}
descriptor.configurable = true
} else if (member.type === 'get') {
descriptor.get = () => {
const command = 'ELECTRON_BROWSER_MEMBER_GET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, member.name)
return metaToValue(meta)
}
if (member.writable) {
descriptor.set = (value) => {
const args = wrapArgs([value])
const command = 'ELECTRON_BROWSER_MEMBER_SET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, member.name, args)
if (meta != null) metaToValue(meta)
return value
}
}
}
Object.defineProperty(object, member.name, descriptor)
}
} | javascript | function setObjectMembers (ref, object, metaId, members) {
if (!Array.isArray(members)) return
for (const member of members) {
if (object.hasOwnProperty(member.name)) continue
const descriptor = { enumerable: member.enumerable }
if (member.type === 'method') {
const remoteMemberFunction = function (...args) {
let command
if (this && this.constructor === remoteMemberFunction) {
command = 'ELECTRON_BROWSER_MEMBER_CONSTRUCTOR'
} else {
command = 'ELECTRON_BROWSER_MEMBER_CALL'
}
const ret = ipcRendererInternal.sendSync(command, contextId, metaId, member.name, wrapArgs(args))
return metaToValue(ret)
}
let descriptorFunction = proxyFunctionProperties(remoteMemberFunction, metaId, member.name)
descriptor.get = () => {
descriptorFunction.ref = ref // The member should reference its object.
return descriptorFunction
}
// Enable monkey-patch the method
descriptor.set = (value) => {
descriptorFunction = value
return value
}
descriptor.configurable = true
} else if (member.type === 'get') {
descriptor.get = () => {
const command = 'ELECTRON_BROWSER_MEMBER_GET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, member.name)
return metaToValue(meta)
}
if (member.writable) {
descriptor.set = (value) => {
const args = wrapArgs([value])
const command = 'ELECTRON_BROWSER_MEMBER_SET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, member.name, args)
if (meta != null) metaToValue(meta)
return value
}
}
}
Object.defineProperty(object, member.name, descriptor)
}
} | [
"function",
"setObjectMembers",
"(",
"ref",
",",
"object",
",",
"metaId",
",",
"members",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"members",
")",
")",
"return",
"for",
"(",
"const",
"member",
"of",
"members",
")",
"{",
"if",
"(",
"obj... | Populate object's members from descriptors. The |ref| will be kept referenced by |members|. This matches |getObjectMemebers| in rpc-server. | [
"Populate",
"object",
"s",
"members",
"from",
"descriptors",
".",
"The",
"|ref|",
"will",
"be",
"kept",
"referenced",
"by",
"|members|",
".",
"This",
"matches",
"|getObjectMemebers|",
"in",
"rpc",
"-",
"server",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/renderer/api/remote.js#L110-L161 | train | Set the members of an object | [
30522,
3853,
2275,
16429,
20614,
4168,
21784,
2015,
1006,
25416,
1010,
4874,
1010,
18804,
3593,
1010,
2372,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
2372,
1007,
1007,
2709,
2005,
1006,
9530,
3367,
2266,
1997,
2372,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/api/encodeGlobal.js | function(fileName, content) {
return Promise()
.then(function() {
var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
return fs.exists(filePath);
});
} | javascript | function(fileName, content) {
return Promise()
.then(function() {
var filePath = PathUtils.resolveInRoot(outputFolder, fileName);
return fs.exists(filePath);
});
} | [
"function",
"(",
"fileName",
",",
"content",
")",
"{",
"return",
"Promise",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"var",
"filePath",
"=",
"PathUtils",
".",
"resolveInRoot",
"(",
"outputFolder",
",",
"fileName",
")",
";",
"return",
"fs",
... | Check that a file exists.
@param {String} fileName
@return {Promise} | [
"Check",
"that",
"a",
"file",
"exists",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeGlobal.js#L180-L187 | train | Check if file exists in output folder | [
30522,
3853,
1006,
5371,
18442,
1010,
4180,
1007,
1063,
2709,
4872,
1006,
1007,
1012,
2059,
1006,
3853,
1006,
1007,
1063,
13075,
5371,
15069,
1027,
4130,
21823,
4877,
1012,
10663,
2378,
3217,
4140,
1006,
6434,
10371,
2121,
1010,
5371,
18442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dequelabs/axe-core | lib/commons/aria/roles.js | function(roles, ariaAttributes) {
var getScore = function(role) {
var allowedAriaAttributes = aria.allowedAttr(role);
return allowedAriaAttributes.reduce(function(score, attribute) {
return score + (ariaAttributes.indexOf(attribute) > -1 ? 1 : 0);
}, 0);
};
var scored = roles.map(function(role) {
return { score: getScore(role), name: role };
});
var sorted = scored.sort(function(scoredRoleA, scoredRoleB) {
return scoredRoleB.score - scoredRoleA.score;
});
return sorted.map(function(sortedRole) {
return sortedRole.name;
});
} | javascript | function(roles, ariaAttributes) {
var getScore = function(role) {
var allowedAriaAttributes = aria.allowedAttr(role);
return allowedAriaAttributes.reduce(function(score, attribute) {
return score + (ariaAttributes.indexOf(attribute) > -1 ? 1 : 0);
}, 0);
};
var scored = roles.map(function(role) {
return { score: getScore(role), name: role };
});
var sorted = scored.sort(function(scoredRoleA, scoredRoleB) {
return scoredRoleB.score - scoredRoleA.score;
});
return sorted.map(function(sortedRole) {
return sortedRole.name;
});
} | [
"function",
"(",
"roles",
",",
"ariaAttributes",
")",
"{",
"var",
"getScore",
"=",
"function",
"(",
"role",
")",
"{",
"var",
"allowedAriaAttributes",
"=",
"aria",
".",
"allowedAttr",
"(",
"role",
")",
";",
"return",
"allowedAriaAttributes",
".",
"reduce",
"(... | /*
Score a set of roles and aria-attributes by its optimal score
E.g. [{score: 2, name: button}, {score: 1, name: main}] | [
"/",
"*",
"Score",
"a",
"set",
"of",
"roles",
"and",
"aria",
"-",
"attributes",
"by",
"its",
"optimal",
"score",
"E",
".",
"g",
".",
"[",
"{",
"score",
":",
"2",
"name",
":",
"button",
"}",
"{",
"score",
":",
"1",
"name",
":",
"main",
"}",
"]"
... | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/aria/roles.js#L155-L174 | train | Returns an array of roles sorted by score | [
30522,
3853,
1006,
4395,
1010,
9342,
19321,
3089,
8569,
4570,
1007,
1063,
13075,
4152,
17345,
1027,
3853,
1006,
2535,
1007,
1063,
13075,
3039,
10980,
19321,
3089,
8569,
4570,
1027,
9342,
1012,
3039,
19321,
2099,
1006,
2535,
1007,
1025,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/space-unary-ops.js | isFirstBangInBangBangExpression | function isFirstBangInBangBangExpression(node) {
return node && node.type === "UnaryExpression" && node.argument.operator === "!" &&
node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
} | javascript | function isFirstBangInBangBangExpression(node) {
return node && node.type === "UnaryExpression" && node.argument.operator === "!" &&
node.argument && node.argument.type === "UnaryExpression" && node.argument.operator === "!";
} | [
"function",
"isFirstBangInBangBangExpression",
"(",
"node",
")",
"{",
"return",
"node",
"&&",
"node",
".",
"type",
"===",
"\"UnaryExpression\"",
"&&",
"node",
".",
"argument",
".",
"operator",
"===",
"\"!\"",
"&&",
"node",
".",
"argument",
"&&",
"node",
".",
... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Check if the node is the first "!" in a "!!" convert to Boolean expression
@param {ASTnode} node AST node
@returns {boolean} Whether or not the node is first "!" in "!!" | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Check",
"if",
"the",
"node",
"is",
"the",
"first",
"!",
"in",
"a",
"!!",
"convert",
"to",
"Boolean",
"expression"
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L76-L79 | train | Check if the node is a first bang in a bang expression | [
30522,
3853,
2003,
8873,
12096,
25153,
2378,
25153,
25153,
10288,
20110,
3258,
1006,
13045,
1007,
1063,
2709,
13045,
1004,
1004,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
14477,
2854,
10288,
20110,
3258,
1000,
1004,
1004,
13045,
1012,
6685,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc-node | packages/grpc-native-core/src/server.js | setUpWritable | function setUpWritable(stream, serialize) {
stream.finished = false;
stream.status = {
code : constants.status.OK,
details : 'OK',
metadata : new Metadata()
};
stream.serialize = common.wrapIgnoreNull(serialize);
function sendStatus() {
var batch = {};
if (!stream.call.metadataSent) {
stream.call.metadataSent = true;
batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
}
if (stream.status.metadata) {
stream.status.metadata = stream.status.metadata._getCoreRepresentation();
}
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = stream.status;
stream.call.startBatch(batch, function(){});
}
stream.on('finish', sendStatus);
/**
* Set the pending status to a given error status. If the error does not have
* code or details properties, the code will be set to grpc.status.UNKNOWN
* and the details will be set to 'Unknown Error'.
* @param {Error} err The error object
*/
function setStatus(err) {
var code = constants.status.UNKNOWN;
var details = 'Unknown Error';
var metadata = new Metadata();
if (err.hasOwnProperty('message')) {
details = err.message;
}
if (err.hasOwnProperty('code')) {
code = err.code;
if (err.hasOwnProperty('details')) {
details = err.details;
}
}
if (err.hasOwnProperty('metadata')) {
metadata = err.metadata;
}
stream.status = {code: code, details: details, metadata: metadata};
}
/**
* Terminate the call. This includes indicating that reads are done, draining
* all pending writes, and sending the given error as a status
* @param {Error} err The error object
* @this GrpcServerStream
*/
function terminateCall(err) {
// Drain readable data
setStatus(err);
stream.end();
}
stream.on('error', terminateCall);
/**
* Override of Writable#end method that allows for sending metadata with a
* success status.
* @param {Metadata=} metadata Metadata to send with the status
*/
stream.end = function(metadata) {
if (metadata) {
stream.status.metadata = metadata;
}
Writable.prototype.end.call(this);
};
} | javascript | function setUpWritable(stream, serialize) {
stream.finished = false;
stream.status = {
code : constants.status.OK,
details : 'OK',
metadata : new Metadata()
};
stream.serialize = common.wrapIgnoreNull(serialize);
function sendStatus() {
var batch = {};
if (!stream.call.metadataSent) {
stream.call.metadataSent = true;
batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
}
if (stream.status.metadata) {
stream.status.metadata = stream.status.metadata._getCoreRepresentation();
}
batch[grpc.opType.SEND_STATUS_FROM_SERVER] = stream.status;
stream.call.startBatch(batch, function(){});
}
stream.on('finish', sendStatus);
/**
* Set the pending status to a given error status. If the error does not have
* code or details properties, the code will be set to grpc.status.UNKNOWN
* and the details will be set to 'Unknown Error'.
* @param {Error} err The error object
*/
function setStatus(err) {
var code = constants.status.UNKNOWN;
var details = 'Unknown Error';
var metadata = new Metadata();
if (err.hasOwnProperty('message')) {
details = err.message;
}
if (err.hasOwnProperty('code')) {
code = err.code;
if (err.hasOwnProperty('details')) {
details = err.details;
}
}
if (err.hasOwnProperty('metadata')) {
metadata = err.metadata;
}
stream.status = {code: code, details: details, metadata: metadata};
}
/**
* Terminate the call. This includes indicating that reads are done, draining
* all pending writes, and sending the given error as a status
* @param {Error} err The error object
* @this GrpcServerStream
*/
function terminateCall(err) {
// Drain readable data
setStatus(err);
stream.end();
}
stream.on('error', terminateCall);
/**
* Override of Writable#end method that allows for sending metadata with a
* success status.
* @param {Metadata=} metadata Metadata to send with the status
*/
stream.end = function(metadata) {
if (metadata) {
stream.status.metadata = metadata;
}
Writable.prototype.end.call(this);
};
} | [
"function",
"setUpWritable",
"(",
"stream",
",",
"serialize",
")",
"{",
"stream",
".",
"finished",
"=",
"false",
";",
"stream",
".",
"status",
"=",
"{",
"code",
":",
"constants",
".",
"status",
".",
"OK",
",",
"details",
":",
"'OK'",
",",
"metadata",
"... | Initialize a writable stream. This is used for both the writable and duplex
stream constructors.
@private
@param {Writable} stream The stream to set up
@param {function(*):Buffer=} Serialization function for responses | [
"Initialize",
"a",
"writable",
"stream",
".",
"This",
"is",
"used",
"for",
"both",
"the",
"writable",
"and",
"duplex",
"stream",
"constructors",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L120-L190 | train | Set up writable stream | [
30522,
3853,
16437,
13088,
6590,
3468,
1006,
5460,
1010,
7642,
4697,
1007,
1063,
5460,
1012,
2736,
1027,
6270,
1025,
5460,
1012,
3570,
1027,
1063,
3642,
1024,
5377,
2015,
1012,
3570,
1012,
7929,
1010,
4751,
1024,
1005,
7929,
1005,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseArrayInitialiser | function parseArrayInitialiser() {
var elements = [], startToken;
startToken = lookahead;
expect('[');
while (!match(']')) {
if (match(',')) {
lex();
elements.push(null);
} else {
elements.push(parseAssignmentExpression());
if (!match(']')) {
expect(',');
}
}
}
lex();
return delegate.markEnd(delegate.createArrayExpression(elements), startToken);
} | javascript | function parseArrayInitialiser() {
var elements = [], startToken;
startToken = lookahead;
expect('[');
while (!match(']')) {
if (match(',')) {
lex();
elements.push(null);
} else {
elements.push(parseAssignmentExpression());
if (!match(']')) {
expect(',');
}
}
}
lex();
return delegate.markEnd(delegate.createArrayExpression(elements), startToken);
} | [
"function",
"parseArrayInitialiser",
"(",
")",
"{",
"var",
"elements",
"=",
"[",
"]",
",",
"startToken",
";",
"startToken",
"=",
"lookahead",
";",
"expect",
"(",
"'['",
")",
";",
"while",
"(",
"!",
"match",
"(",
"']'",
")",
")",
"{",
"if",
"(",
"matc... | 11.1.4 Array Initialiser | [
"11",
".",
"1",
".",
"4",
"Array",
"Initialiser"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L1979-L2001 | train | ECMA - 262 12. 2 Array Initialiser | [
30522,
3853,
11968,
17310,
11335,
25811,
29050,
6856,
2121,
1006,
1007,
1063,
13075,
3787,
1027,
1031,
1033,
1010,
2707,
18715,
2368,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
1025,
5987,
1006,
1005,
1031,
1005,
1007,
1025,
2096,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/DraftEnabledMockServer.js | function(mEntitySets) {
var that = this;
var oMockdata = this._oMockdata;
var aDraftRoot = oMockdata[this._oDraftMetadata.draftRootName];
var fnGrep = function(aContains, aContained) {
return aContains.filter(function(x) {
return aContained.indexOf(x) < 0;
})[0];
};
if (aDraftRoot.length === 100) {
for (var i = 0; i < aDraftRoot.length; i++) {
var oEntity = aDraftRoot[i];
// active documents without a draft (0-24)
if (i < 25) {
oEntity.IsActiveEntity = true; // true for active documents
oEntity.HasActiveEntity = false; // false for new drafts and active documents
oEntity.HasDraftEntity = false; // false for active document without a draft
oEntity[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
if (oEntity[this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID]) {
oEntity[this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID] = null;
}
var aDraftNodes = [];
var aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = true;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = false;
aDraftNodes[i][this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
if (aDraftNodes[i][this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID]) {
aDraftNodes[i][this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID] = null;
}
var sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
aDraftNodes[i][sDraftKey] = this._oConstants.EMPTY_GUID;
}
// new drafts without corresponding active documents (25-49)
} else if (i < 50) {
oEntity.IsActiveEntity = false;
oEntity.HasActiveEntity = false;
oEntity.HasDraftEntity = false;
aDraftNodes = [];
aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = false;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = false;
sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
}
// active documents with a corresponding draft document, a.k.a edit drafts (50-74)
} else if (i < 75) {
var oSiblingEntity = jQuery.extend(true, {}, oEntity);
oEntity.IsActiveEntity = true; // true for active documents
oEntity.HasActiveEntity = false; // false for new drafts and active documents
oEntity.HasDraftEntity = true; // false for active document without a draft
oEntity[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
aDraftNodes = [];
aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = true;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = true;
sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
aDraftNodes[i][sDraftKey] = this._oConstants.EMPTY_GUID;
}
oSiblingEntity.IsActiveEntity = false;
oSiblingEntity.HasActiveEntity = true;
oSiblingEntity.HasDraftEntity = false;
aDraftRoot[i + 25] = oSiblingEntity;
}
}
}
var sRootUri = this._getRootUri();
jQuery.each(mEntitySets, function(sEntitySetName, oEntitySet) {
jQuery.each(oMockdata[sEntitySetName], function(iIndex, oEntry) {
// add the metadata for the entry
oEntry.__metadata = oEntry.__metadata || {};
oEntry.__metadata.uri = sRootUri + sEntitySetName + "(" + that._createKeysString(oEntitySet, oEntry) + ")";
oEntry.__metadata.type = oEntitySet.schema + "." + oEntitySet.type;
// add the navigation properties
jQuery.each(oEntitySet.navprops, function(sKey) {
oEntry[sKey] = {
__deferred: {
uri: sRootUri + sEntitySetName + "(" + that._createKeysString(oEntitySet, oEntry) + ")/" + sKey
}
};
});
});
});
} | javascript | function(mEntitySets) {
var that = this;
var oMockdata = this._oMockdata;
var aDraftRoot = oMockdata[this._oDraftMetadata.draftRootName];
var fnGrep = function(aContains, aContained) {
return aContains.filter(function(x) {
return aContained.indexOf(x) < 0;
})[0];
};
if (aDraftRoot.length === 100) {
for (var i = 0; i < aDraftRoot.length; i++) {
var oEntity = aDraftRoot[i];
// active documents without a draft (0-24)
if (i < 25) {
oEntity.IsActiveEntity = true; // true for active documents
oEntity.HasActiveEntity = false; // false for new drafts and active documents
oEntity.HasDraftEntity = false; // false for active document without a draft
oEntity[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
if (oEntity[this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID]) {
oEntity[this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID] = null;
}
var aDraftNodes = [];
var aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = true;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = false;
aDraftNodes[i][this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
if (aDraftNodes[i][this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID]) {
aDraftNodes[i][this._oConstants.DRAFT_ADMINISTRATIVE_DATA_UUID] = null;
}
var sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
aDraftNodes[i][sDraftKey] = this._oConstants.EMPTY_GUID;
}
// new drafts without corresponding active documents (25-49)
} else if (i < 50) {
oEntity.IsActiveEntity = false;
oEntity.HasActiveEntity = false;
oEntity.HasDraftEntity = false;
aDraftNodes = [];
aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = false;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = false;
sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
}
// active documents with a corresponding draft document, a.k.a edit drafts (50-74)
} else if (i < 75) {
var oSiblingEntity = jQuery.extend(true, {}, oEntity);
oEntity.IsActiveEntity = true; // true for active documents
oEntity.HasActiveEntity = false; // false for new drafts and active documents
oEntity.HasDraftEntity = true; // false for active document without a draft
oEntity[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
aDraftNodes = [];
aSemanticDraftNodeKeys = [];
for (var j = 0; j < this._oDraftMetadata.draftNodes.length; j++) {
aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[j], mEntitySets);
aDraftNodes = oMockdata[this._oDraftMetadata.draftNodes[j]];
// changing the values if there is a referential constraint
var oEntitySet = mEntitySets[this._oDraftMetadata.draftRootName];
for (var navprop in oEntitySet.navprops) {
var oNavProp = oEntitySet.navprops[navprop];
if (oNavProp.to.entitySet === this._oDraftMetadata.draftNodes[j]) {
var iPropRefLength = oNavProp.from.propRef.length;
for (var k = 0; k < iPropRefLength; k++) {
// copy the value from the principle to the dependant;
aDraftNodes[i][oNavProp.to.propRef[k]] = oEntity[oNavProp.from.propRef[k]];
}
}
}
aDraftNodes[i].IsActiveEntity = true;
aDraftNodes[i].HasActiveEntity = false;
aDraftNodes[i].HasDraftEntity = true;
sDraftKey = fnGrep(mEntitySets[this._oDraftMetadata.draftNodes[j]].keys, aSemanticDraftNodeKeys);
aDraftNodes[i][sDraftKey] = this._oConstants.EMPTY_GUID;
}
oSiblingEntity.IsActiveEntity = false;
oSiblingEntity.HasActiveEntity = true;
oSiblingEntity.HasDraftEntity = false;
aDraftRoot[i + 25] = oSiblingEntity;
}
}
}
var sRootUri = this._getRootUri();
jQuery.each(mEntitySets, function(sEntitySetName, oEntitySet) {
jQuery.each(oMockdata[sEntitySetName], function(iIndex, oEntry) {
// add the metadata for the entry
oEntry.__metadata = oEntry.__metadata || {};
oEntry.__metadata.uri = sRootUri + sEntitySetName + "(" + that._createKeysString(oEntitySet, oEntry) + ")";
oEntry.__metadata.type = oEntitySet.schema + "." + oEntitySet.type;
// add the navigation properties
jQuery.each(oEntitySet.navprops, function(sKey) {
oEntry[sKey] = {
__deferred: {
uri: sRootUri + sEntitySetName + "(" + that._createKeysString(oEntitySet, oEntry) + ")/" + sKey
}
};
});
});
});
} | [
"function",
"(",
"mEntitySets",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"oMockdata",
"=",
"this",
".",
"_oMockdata",
";",
"var",
"aDraftRoot",
"=",
"oMockdata",
"[",
"this",
".",
"_oDraftMetadata",
".",
"draftRootName",
"]",
";",
"var",
"fnGrep",... | Handles draft mock data generation
@param {object} mEntitySets | [
"Handles",
"draft",
"mock",
"data",
"generation"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/DraftEnabledMockServer.js#L208-L337 | train | Sets the drafts and active documents to the given entity sets. | [
30522,
3853,
1006,
2273,
3775,
3723,
13462,
2015,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
13075,
18168,
7432,
2850,
2696,
1027,
2023,
1012,
1035,
18168,
7432,
2850,
2696,
1025,
13075,
4748,
27528,
13181,
4140,
1027,
18168,
7432,
2850,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/linter.js | findEslintEnv | function findEslintEnv(text) {
let match, retv;
eslintEnvPattern.lastIndex = 0;
while ((match = eslintEnvPattern.exec(text))) {
retv = Object.assign(retv || {}, commentParser.parseListConfig(match[1]));
}
return retv;
} | javascript | function findEslintEnv(text) {
let match, retv;
eslintEnvPattern.lastIndex = 0;
while ((match = eslintEnvPattern.exec(text))) {
retv = Object.assign(retv || {}, commentParser.parseListConfig(match[1]));
}
return retv;
} | [
"function",
"findEslintEnv",
"(",
"text",
")",
"{",
"let",
"match",
",",
"retv",
";",
"eslintEnvPattern",
".",
"lastIndex",
"=",
"0",
";",
"while",
"(",
"(",
"match",
"=",
"eslintEnvPattern",
".",
"exec",
"(",
"text",
")",
")",
")",
"{",
"retv",
"=",
... | Checks whether or not there is a comment which has "eslint-env *" in a given text.
@param {string} text - A source code text to check.
@returns {Object|null} A result of parseListConfig() with "eslint-env *" comment. | [
"Checks",
"whether",
"or",
"not",
"there",
"is",
"a",
"comment",
"which",
"has",
"eslint",
"-",
"env",
"*",
"in",
"a",
"given",
"text",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/linter.js#L321-L331 | train | Find the eslint environment variable in the given text | [
30522,
3853,
2424,
2229,
4115,
6528,
2615,
1006,
3793,
1007,
1063,
2292,
2674,
1010,
2128,
9189,
1025,
9686,
4115,
6528,
2615,
4502,
12079,
2078,
1012,
2197,
22254,
10288,
1027,
1014,
1025,
2096,
1006,
1006,
2674,
1027,
9686,
4115,
6528,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
NervJS/taro-ui | src/components/input-number/index.js | addNum | function addNum (num1, num2) {
let sq1, sq2
try {
sq1 = _toString(num1).split('.')[1].length
} catch (e) {
sq1 = 0
}
try {
sq2 = _toString(num2).split('.')[1].length
} catch (e) {
sq2 = 0
}
const m = Math.pow(10, Math.max(sq1, sq2))
return (Math.round(num1 * m) + Math.round(num2 * m)) / m
} | javascript | function addNum (num1, num2) {
let sq1, sq2
try {
sq1 = _toString(num1).split('.')[1].length
} catch (e) {
sq1 = 0
}
try {
sq2 = _toString(num2).split('.')[1].length
} catch (e) {
sq2 = 0
}
const m = Math.pow(10, Math.max(sq1, sq2))
return (Math.round(num1 * m) + Math.round(num2 * m)) / m
} | [
"function",
"addNum",
"(",
"num1",
",",
"num2",
")",
"{",
"let",
"sq1",
",",
"sq2",
"try",
"{",
"sq1",
"=",
"_toString",
"(",
"num1",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
"]",
".",
"length",
"}",
"catch",
"(",
"e",
")",
"{",
"sq1",
"... | 实现两数相加并保留小数点后最短尾数 | [
"实现两数相加并保留小数点后最短尾数"
] | 9a761032b3663abf82dd4514ac29deec2eb13d2a | https://github.com/NervJS/taro-ui/blob/9a761032b3663abf82dd4514ac29deec2eb13d2a/src/components/input-number/index.js#L11-L25 | train | Add two numbers | [
30522,
3853,
5587,
19172,
1006,
16371,
2213,
2487,
1010,
16371,
2213,
2475,
1007,
1063,
2292,
5490,
2487,
1010,
5490,
2475,
3046,
1063,
5490,
2487,
1027,
1035,
2000,
3367,
4892,
1006,
16371,
2213,
2487,
1007,
1012,
3975,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/dom/jquery/getSelectedText.js | function() {
var oDomRef = this.get(0);
try {
if (typeof oDomRef.selectionStart === "number") {
return oDomRef.value.substring(oDomRef.selectionStart, oDomRef.selectionEnd);
}
} catch (e) {
// note: some browsers fail to read the "selectionStart" and "selectionEnd" properties from HTMLInputElement, e.g.: The input element's type "number" does not support selection.
}
return "";
} | javascript | function() {
var oDomRef = this.get(0);
try {
if (typeof oDomRef.selectionStart === "number") {
return oDomRef.value.substring(oDomRef.selectionStart, oDomRef.selectionEnd);
}
} catch (e) {
// note: some browsers fail to read the "selectionStart" and "selectionEnd" properties from HTMLInputElement, e.g.: The input element's type "number" does not support selection.
}
return "";
} | [
"function",
"(",
")",
"{",
"var",
"oDomRef",
"=",
"this",
".",
"get",
"(",
"0",
")",
";",
"try",
"{",
"if",
"(",
"typeof",
"oDomRef",
".",
"selectionStart",
"===",
"\"number\"",
")",
"{",
"return",
"oDomRef",
".",
"value",
".",
"substring",
"(",
"oDo... | This module provides the {@link jQuery#getSelectedText} API.
@namespace
@name module:sap/ui/dom/jquery/getSelectedText
@public
@since 1.58
Retrieve the selected text in the first element of the collection.
<b>Note</b>: This feature is only supported for input element’s type of text, search, url, tel and password.
@return {string} The selected text.
@public
@name jQuery#getSelectedText
@author SAP SE
@since 1.26.0
@function
@requires module:sap/ui/dom/jquery/getSelectedText | [
"This",
"module",
"provides",
"the",
"{",
"@link",
"jQuery#getSelectedText",
"}",
"API",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/jquery/getSelectedText.js#L29-L41 | train | Returns the selection string from the DOM | [
30522,
3853,
1006,
1007,
1063,
13075,
1051,
9527,
2890,
2546,
1027,
2023,
1012,
2131,
1006,
1014,
1007,
1025,
3046,
1063,
2065,
1006,
2828,
11253,
1051,
9527,
2890,
2546,
1012,
16310,
7559,
2102,
1027,
1027,
1027,
1000,
2193,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
goldfire/howler.js | dist/howler.js | function(node) {
var self = this;
var isIOS = Howler._navigator && Howler._navigator.vendor.indexOf('Apple') >= 0;
if (Howler._scratchBuffer && node.bufferSource) {
node.bufferSource.onended = null;
node.bufferSource.disconnect(0);
if (isIOS) {
try { node.bufferSource.buffer = Howler._scratchBuffer; } catch(e) {}
}
}
node.bufferSource = null;
return self;
} | javascript | function(node) {
var self = this;
var isIOS = Howler._navigator && Howler._navigator.vendor.indexOf('Apple') >= 0;
if (Howler._scratchBuffer && node.bufferSource) {
node.bufferSource.onended = null;
node.bufferSource.disconnect(0);
if (isIOS) {
try { node.bufferSource.buffer = Howler._scratchBuffer; } catch(e) {}
}
}
node.bufferSource = null;
return self;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"isIOS",
"=",
"Howler",
".",
"_navigator",
"&&",
"Howler",
".",
"_navigator",
".",
"vendor",
".",
"indexOf",
"(",
"'Apple'",
")",
">=",
"0",
";",
"if",
"(",
"Howler",
".",
"... | Prevent memory leaks by cleaning up the buffer source after playback.
@param {Object} node Sound's audio node containing the buffer source.
@return {Howl} | [
"Prevent",
"memory",
"leaks",
"by",
"cleaning",
"up",
"the",
"buffer",
"source",
"after",
"playback",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2120-L2134 | train | This function is called by the bufferSource constructor when the buffer is ready | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
2003,
10735,
1027,
22912,
2121,
1012,
1035,
20532,
1004,
1004,
22912,
2121,
1012,
1035,
20532,
1012,
21431,
1012,
5950,
11253,
1006,
1005,
6207,
1005,
1007,
1028,
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... | |
eslint/eslint | lib/rules/semi-style.js | isLastChild | function isLastChild(node) {
const t = node.parent.type;
if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { // before `else` keyword.
return true;
}
if (t === "DoWhileStatement") { // before `while` keyword.
return true;
}
const nodeList = getChildren(node.parent);
return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
} | javascript | function isLastChild(node) {
const t = node.parent.type;
if (t === "IfStatement" && node.parent.consequent === node && node.parent.alternate) { // before `else` keyword.
return true;
}
if (t === "DoWhileStatement") { // before `while` keyword.
return true;
}
const nodeList = getChildren(node.parent);
return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
} | [
"function",
"isLastChild",
"(",
"node",
")",
"{",
"const",
"t",
"=",
"node",
".",
"parent",
".",
"type",
";",
"if",
"(",
"t",
"===",
"\"IfStatement\"",
"&&",
"node",
".",
"parent",
".",
"consequent",
"===",
"node",
"&&",
"node",
".",
"parent",
".",
"... | Check whether a given node is the last statement in the parent block.
@param {Node} node A node to check.
@returns {boolean} `true` if the node is the last statement in the parent block. | [
"Check",
"whether",
"a",
"given",
"node",
"is",
"the",
"last",
"statement",
"in",
"the",
"parent",
"block",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-style.js#L52-L64 | train | Returns true if node is the last child of the last statement in the list of children | [
30522,
3853,
25340,
3367,
19339,
1006,
13045,
1007,
1063,
9530,
3367,
1056,
1027,
13045,
1012,
6687,
1012,
2828,
1025,
2065,
1006,
1056,
1027,
1027,
1027,
1000,
2065,
9153,
18532,
4765,
1000,
1004,
1004,
13045,
1012,
6687,
1012,
9530,
3366,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.