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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eslint/eslint | lib/rules/callback-return.js | isCallbackExpression | function isCallbackExpression(node, parentNode) {
// ensure the parent node exists and is an expression
if (!parentNode || parentNode.type !== "ExpressionStatement") {
return false;
}
// cb()
if (parentNode.expression === node) {
return true;
}
// special case for cb && cb() and similar
if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
if (parentNode.expression.right === node) {
return true;
}
}
return false;
} | javascript | function isCallbackExpression(node, parentNode) {
// ensure the parent node exists and is an expression
if (!parentNode || parentNode.type !== "ExpressionStatement") {
return false;
}
// cb()
if (parentNode.expression === node) {
return true;
}
// special case for cb && cb() and similar
if (parentNode.expression.type === "BinaryExpression" || parentNode.expression.type === "LogicalExpression") {
if (parentNode.expression.right === node) {
return true;
}
}
return false;
} | [
"function",
"isCallbackExpression",
"(",
"node",
",",
"parentNode",
")",
"{",
"// ensure the parent node exists and is an expression",
"if",
"(",
"!",
"parentNode",
"||",
"parentNode",
".",
"type",
"!==",
"\"ExpressionStatement\"",
")",
"{",
"return",
"false",
";",
"}... | Determines whether or not the callback is part of a callback expression.
@param {ASTNode} node The callback node
@param {ASTNode} parentNode The expression node
@returns {boolean} Whether or not this is part of a callback expression | [
"Determines",
"whether",
"or",
"not",
"the",
"callback",
"is",
"part",
"of",
"a",
"callback",
"expression",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/callback-return.js#L94-L114 | train | check if the node is a callback expression | [
30522,
3853,
2003,
9289,
20850,
8684,
10288,
20110,
3258,
1006,
13045,
1010,
6687,
3630,
3207,
1007,
1063,
1013,
1013,
5676,
1996,
6687,
13045,
6526,
1998,
2003,
2019,
3670,
2065,
1006,
999,
6687,
3630,
3207,
1064,
1064,
6687,
3630,
3207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/EditorManager.js | getCurrentFullEditor | function getCurrentFullEditor() {
var currentPath = MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE),
doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath);
return doc && doc._masterEditor;
} | javascript | function getCurrentFullEditor() {
var currentPath = MainViewManager.getCurrentlyViewedPath(MainViewManager.ACTIVE_PANE),
doc = currentPath && DocumentManager.getOpenDocumentForPath(currentPath);
return doc && doc._masterEditor;
} | [
"function",
"getCurrentFullEditor",
"(",
")",
"{",
"var",
"currentPath",
"=",
"MainViewManager",
".",
"getCurrentlyViewedPath",
"(",
"MainViewManager",
".",
"ACTIVE_PANE",
")",
",",
"doc",
"=",
"currentPath",
"&&",
"DocumentManager",
".",
"getOpenDocumentForPath",
"("... | Retrieves the visible full-size Editor for the currently opened file in the ACTIVE_PANE
@return {?Editor} editor of the current view or null | [
"Retrieves",
"the",
"visible",
"full",
"-",
"size",
"Editor",
"for",
"the",
"currently",
"opened",
"file",
"in",
"the",
"ACTIVE_PANE"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorManager.js#L107-L111 | train | Get the full editor for the current page | [
30522,
3853,
2131,
10841,
14343,
3372,
3993,
3709,
15660,
1006,
1007,
1063,
13075,
2783,
15069,
1027,
2364,
8584,
24805,
4590,
1012,
2131,
10841,
14343,
20630,
8584,
2098,
15069,
1006,
2364,
8584,
24805,
4590,
1012,
3161,
1035,
6090,
2063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/preferences/PreferencesManager.js | _setCurrentFile | function _setCurrentFile(newFilename) {
var oldFilename = currentFilename;
if (oldFilename === newFilename) {
return;
}
currentFilename = newFilename;
_toggleProjectScope();
PreferencesImpl.manager.signalContextChanged(_buildContext(oldFilename, currentLanguageId),
_buildContext(newFilename, currentLanguageId));
} | javascript | function _setCurrentFile(newFilename) {
var oldFilename = currentFilename;
if (oldFilename === newFilename) {
return;
}
currentFilename = newFilename;
_toggleProjectScope();
PreferencesImpl.manager.signalContextChanged(_buildContext(oldFilename, currentLanguageId),
_buildContext(newFilename, currentLanguageId));
} | [
"function",
"_setCurrentFile",
"(",
"newFilename",
")",
"{",
"var",
"oldFilename",
"=",
"currentFilename",
";",
"if",
"(",
"oldFilename",
"===",
"newFilename",
")",
"{",
"return",
";",
"}",
"currentFilename",
"=",
"newFilename",
";",
"_toggleProjectScope",
"(",
... | @private
This is used internally within Brackets for the EditorManager to signal
to the preferences what the currently edited file is.
@param {string} newFilename Full path to currently edited file | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesManager.js#L219-L228 | train | Sets the current filename | [
30522,
3853,
1035,
2275,
10841,
14343,
3372,
8873,
2571,
1006,
2047,
8873,
20844,
4168,
1007,
1063,
13075,
2214,
8873,
20844,
4168,
1027,
2783,
8873,
20844,
4168,
1025,
2065,
1006,
2214,
8873,
20844,
4168,
1027,
1027,
1027,
2047,
8873,
2084... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/fs/mock.js | createMockFS | function createMockFS(files) {
files = Immutable.fromJS(files);
var mtime = new Date();
function getFile(filePath) {
var parts = path.normalize(filePath).split(path.sep);
return parts.reduce(function(list, part, i) {
if (!list) return null;
var file;
if (!part || part === '.') file = list;
else file = list.get(part);
if (!file) return null;
if (is.string(file)) {
if (i === (parts.length - 1)) return file;
else return null;
}
return file;
}, files);
}
function fsExists(filePath) {
return Boolean(getFile(filePath) !== null);
}
function fsReadFile(filePath) {
var file = getFile(filePath);
if (!is.string(file)) {
throw error.FileNotFoundError({
filename: filePath
});
}
return new Buffer(file, 'utf8');
}
function fsStatFile(filePath) {
var file = getFile(filePath);
if (!file) {
throw error.FileNotFoundError({
filename: filePath
});
}
return {
mtime: mtime
};
}
function fsReadDir(filePath) {
var dir = getFile(filePath);
if (!dir || is.string(dir)) {
throw error.FileNotFoundError({
filename: filePath
});
}
return dir
.map(function(content, name) {
if (!is.string(content)) {
name = name + '/';
}
return name;
})
.valueSeq();
}
return FS.create({
root: '',
fsExists: fsExists,
fsReadFile: fsReadFile,
fsStatFile: fsStatFile,
fsReadDir: fsReadDir
});
} | javascript | function createMockFS(files) {
files = Immutable.fromJS(files);
var mtime = new Date();
function getFile(filePath) {
var parts = path.normalize(filePath).split(path.sep);
return parts.reduce(function(list, part, i) {
if (!list) return null;
var file;
if (!part || part === '.') file = list;
else file = list.get(part);
if (!file) return null;
if (is.string(file)) {
if (i === (parts.length - 1)) return file;
else return null;
}
return file;
}, files);
}
function fsExists(filePath) {
return Boolean(getFile(filePath) !== null);
}
function fsReadFile(filePath) {
var file = getFile(filePath);
if (!is.string(file)) {
throw error.FileNotFoundError({
filename: filePath
});
}
return new Buffer(file, 'utf8');
}
function fsStatFile(filePath) {
var file = getFile(filePath);
if (!file) {
throw error.FileNotFoundError({
filename: filePath
});
}
return {
mtime: mtime
};
}
function fsReadDir(filePath) {
var dir = getFile(filePath);
if (!dir || is.string(dir)) {
throw error.FileNotFoundError({
filename: filePath
});
}
return dir
.map(function(content, name) {
if (!is.string(content)) {
name = name + '/';
}
return name;
})
.valueSeq();
}
return FS.create({
root: '',
fsExists: fsExists,
fsReadFile: fsReadFile,
fsStatFile: fsStatFile,
fsReadDir: fsReadDir
});
} | [
"function",
"createMockFS",
"(",
"files",
")",
"{",
"files",
"=",
"Immutable",
".",
"fromJS",
"(",
"files",
")",
";",
"var",
"mtime",
"=",
"new",
"Date",
"(",
")",
";",
"function",
"getFile",
"(",
"filePath",
")",
"{",
"var",
"parts",
"=",
"path",
".... | Create a fake filesystem for unit testing GitBook.
@param {Map<String:String|Map>} | [
"Create",
"a",
"fake",
"filesystem",
"for",
"unit",
"testing",
"GitBook",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/fs/mock.js#L14-L93 | train | Creates mock filesystem | [
30522,
3853,
3443,
5302,
3600,
10343,
1006,
6764,
1007,
1063,
6764,
1027,
10047,
28120,
3085,
1012,
2013,
22578,
1006,
6764,
1007,
1025,
13075,
11047,
14428,
1027,
2047,
3058,
1006,
1007,
1025,
3853,
2131,
8873,
2571,
1006,
5371,
15069,
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... |
apache/incubator-echarts | src/chart/tree/layoutHelper.js | nextRight | function nextRight(node) {
var children = node.children;
return children.length && node.isExpand ? children[children.length - 1] : node.hierNode.thread;
} | javascript | function nextRight(node) {
var children = node.children;
return children.length && node.isExpand ? children[children.length - 1] : node.hierNode.thread;
} | [
"function",
"nextRight",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"return",
"children",
".",
"length",
"&&",
"node",
".",
"isExpand",
"?",
"children",
"[",
"children",
".",
"length",
"-",
"1",
"]",
":",
"node",
".",
... | This function is used to traverse the right contour of a subtree.
It returns the rightmost child of node or the thread of node. The function
returns null if and only if node is on the highest depth of its subtree.
@param {module:echarts/data/Tree~TreeNode} node
@return {module:echarts/data/Tree~TreeNode} | [
"This",
"function",
"is",
"used",
"to",
"traverse",
"the",
"right",
"contour",
"of",
"a",
"subtree",
".",
"It",
"returns",
"the",
"rightmost",
"child",
"of",
"node",
"or",
"the",
"thread",
"of",
"node",
".",
"The",
"function",
"returns",
"null",
"if",
"a... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L270-L273 | train | Returns the next node in the tree | [
30522,
3853,
2279,
15950,
1006,
13045,
1007,
1063,
13075,
2336,
1027,
13045,
1012,
2336,
1025,
2709,
2336,
1012,
3091,
1004,
1004,
13045,
1012,
2003,
10288,
9739,
2094,
1029,
2336,
1031,
2336,
1012,
3091,
1011,
1015,
1033,
1024,
13045,
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... |
Shopify/draggable | src/Plugins/SwapAnimation/SwapAnimation.js | resetElementOnTransitionEnd | function resetElementOnTransitionEnd(event) {
event.target.style.transition = '';
event.target.style.pointerEvents = '';
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
} | javascript | function resetElementOnTransitionEnd(event) {
event.target.style.transition = '';
event.target.style.pointerEvents = '';
event.target.removeEventListener('transitionend', resetElementOnTransitionEnd);
} | [
"function",
"resetElementOnTransitionEnd",
"(",
"event",
")",
"{",
"event",
".",
"target",
".",
"style",
".",
"transition",
"=",
"''",
";",
"event",
".",
"target",
".",
"style",
".",
"pointerEvents",
"=",
"''",
";",
"event",
".",
"target",
".",
"removeEven... | Resets animation style properties after animation has completed
@param {Event} event
@private | [
"Resets",
"animation",
"style",
"properties",
"after",
"animation",
"has",
"completed"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Plugins/SwapAnimation/SwapAnimation.js#L138-L142 | train | Reset element transition | [
30522,
3853,
25141,
12260,
23065,
3372,
5521,
28032,
3258,
10497,
1006,
2724,
1007,
1063,
2724,
1012,
4539,
1012,
2806,
1012,
6653,
1027,
1005,
1005,
1025,
2724,
1012,
4539,
1012,
2806,
1012,
20884,
18697,
7666,
1027,
1005,
1005,
1025,
2724... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
postcss/autoprefixer | lib/hacks/grid-utils.js | changeDuplicateAreaSelectors | function changeDuplicateAreaSelectors (ruleSelectors, templateSelectors) {
ruleSelectors = ruleSelectors.map(selector => {
let selectorBySpace = list.space(selector)
let selectorByComma = list.comma(selector)
if (selectorBySpace.length > selectorByComma.length) {
selector = selectorBySpace.slice(-1).join('')
}
return selector
})
return ruleSelectors.map(ruleSelector => {
let newSelector = templateSelectors.map((tplSelector, index) => {
let space = index === 0 ? '' : ' '
return `${ space }${ tplSelector } > ${ ruleSelector }`
})
return newSelector
})
} | javascript | function changeDuplicateAreaSelectors (ruleSelectors, templateSelectors) {
ruleSelectors = ruleSelectors.map(selector => {
let selectorBySpace = list.space(selector)
let selectorByComma = list.comma(selector)
if (selectorBySpace.length > selectorByComma.length) {
selector = selectorBySpace.slice(-1).join('')
}
return selector
})
return ruleSelectors.map(ruleSelector => {
let newSelector = templateSelectors.map((tplSelector, index) => {
let space = index === 0 ? '' : ' '
return `${ space }${ tplSelector } > ${ ruleSelector }`
})
return newSelector
})
} | [
"function",
"changeDuplicateAreaSelectors",
"(",
"ruleSelectors",
",",
"templateSelectors",
")",
"{",
"ruleSelectors",
"=",
"ruleSelectors",
".",
"map",
"(",
"selector",
"=>",
"{",
"let",
"selectorBySpace",
"=",
"list",
".",
"space",
"(",
"selector",
")",
"let",
... | change selectors for rules with duplicate grid-areas.
@param {Array<Rule>} rules
@param {Array<String>} templateSelectors
@return {Array<Rule>} rules with changed selectors | [
"change",
"selectors",
"for",
"rules",
"with",
"duplicate",
"grid",
"-",
"areas",
"."
] | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/lib/hacks/grid-utils.js#L313-L332 | train | Change duplicate area selectors | [
30522,
3853,
2904,
6279,
19341,
27058,
16416,
11246,
22471,
5668,
1006,
3513,
12260,
24817,
1010,
23561,
11246,
22471,
5668,
1007,
1063,
3513,
12260,
24817,
1027,
3513,
12260,
24817,
1012,
4949,
1006,
27000,
1027,
1028,
1063,
2292,
27000,
376... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | tools/internal-rules/consistent-meta-messages.js | getPropertyFromObject | function getPropertyFromObject(property, node) {
const properties = node.properties;
for (let i = 0; i < properties.length; i++) {
if (properties[i].key.name === property) {
return properties[i];
}
}
return null;
} | javascript | function getPropertyFromObject(property, node) {
const properties = node.properties;
for (let i = 0; i < properties.length; i++) {
if (properties[i].key.name === property) {
return properties[i];
}
}
return null;
} | [
"function",
"getPropertyFromObject",
"(",
"property",
",",
"node",
")",
"{",
"const",
"properties",
"=",
"node",
".",
"properties",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"properties",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"("... | ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------
Gets the property of the Object node passed in that has the name specified.
@param {string} property Name of the property to return.
@param {ASTNode} node The ObjectExpression node.
@returns {ASTNode} The Property node or null if not found. | [
"------------------------------------------------------------------------------",
"Helpers",
"------------------------------------------------------------------------------",
"Gets",
"the",
"property",
"of",
"the",
"Object",
"node",
"passed",
"in",
"that",
"has",
"the",
"name",
"spec... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/internal-rules/consistent-meta-messages.js#L19-L29 | train | Get a property from a node | [
30522,
3853,
2131,
21572,
4842,
3723,
19699,
19506,
2497,
20614,
1006,
3200,
1010,
13045,
1007,
1063,
9530,
3367,
5144,
1027,
13045,
1012,
5144,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
5144,
1012,
3091,
1025,
1045,
1009,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/StringUtils.js | prettyPrintBytes | function prettyPrintBytes(bytes, precision) {
var kilobyte = 1024,
megabyte = kilobyte * 1024,
gigabyte = megabyte * 1024,
terabyte = gigabyte * 1024,
returnVal = bytes;
if ((bytes >= 0) && (bytes < kilobyte)) {
returnVal = bytes + " B";
} else if (bytes < megabyte) {
returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
} else if (bytes < gigabyte) {
returnVal = (bytes / megabyte).toFixed(precision) + " MB";
} else if (bytes < terabyte) {
returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + " TB";
}
return returnVal;
} | javascript | function prettyPrintBytes(bytes, precision) {
var kilobyte = 1024,
megabyte = kilobyte * 1024,
gigabyte = megabyte * 1024,
terabyte = gigabyte * 1024,
returnVal = bytes;
if ((bytes >= 0) && (bytes < kilobyte)) {
returnVal = bytes + " B";
} else if (bytes < megabyte) {
returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
} else if (bytes < gigabyte) {
returnVal = (bytes / megabyte).toFixed(precision) + " MB";
} else if (bytes < terabyte) {
returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + " TB";
}
return returnVal;
} | [
"function",
"prettyPrintBytes",
"(",
"bytes",
",",
"precision",
")",
"{",
"var",
"kilobyte",
"=",
"1024",
",",
"megabyte",
"=",
"kilobyte",
"*",
"1024",
",",
"gigabyte",
"=",
"megabyte",
"*",
"1024",
",",
"terabyte",
"=",
"gigabyte",
"*",
"1024",
",",
"r... | Converts number of bytes into human readable format.
If param bytes is negative it returns the number without any changes.
@param {number} bytes Number of bytes to convert
@param {number} precision Number of digits after the decimal separator
@return {string} | [
"Converts",
"number",
"of",
"bytes",
"into",
"human",
"readable",
"format",
".",
"If",
"param",
"bytes",
"is",
"negative",
"it",
"returns",
"the",
"number",
"without",
"any",
"changes",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L185-L205 | train | Pretty print bytes | [
30522,
3853,
3492,
16550,
3762,
4570,
1006,
27507,
1010,
11718,
1007,
1063,
13075,
11382,
4135,
3762,
2618,
1027,
9402,
2549,
1010,
13164,
3762,
2618,
1027,
11382,
4135,
3762,
2618,
1008,
9402,
2549,
1010,
15453,
21275,
2618,
1027,
13164,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/core/scene/a-scene.js | getMaxSize | function getMaxSize (maxSize, isVR) {
var aspectRatio;
var size;
var pixelRatio = window.devicePixelRatio;
size = {height: document.body.offsetHeight, width: document.body.offsetWidth};
if (!maxSize || isVR || (maxSize.width === -1 && maxSize.height === -1)) {
return size;
}
if (size.width * pixelRatio < maxSize.width &&
size.height * pixelRatio < maxSize.height) {
return size;
}
aspectRatio = size.width / size.height;
if ((size.width * pixelRatio) > maxSize.width && maxSize.width !== -1) {
size.width = Math.round(maxSize.width / pixelRatio);
size.height = Math.round(maxSize.width / aspectRatio / pixelRatio);
}
if ((size.height * pixelRatio) > maxSize.height && maxSize.height !== -1) {
size.height = Math.round(maxSize.height / pixelRatio);
size.width = Math.round(maxSize.height * aspectRatio / pixelRatio);
}
return size;
} | javascript | function getMaxSize (maxSize, isVR) {
var aspectRatio;
var size;
var pixelRatio = window.devicePixelRatio;
size = {height: document.body.offsetHeight, width: document.body.offsetWidth};
if (!maxSize || isVR || (maxSize.width === -1 && maxSize.height === -1)) {
return size;
}
if (size.width * pixelRatio < maxSize.width &&
size.height * pixelRatio < maxSize.height) {
return size;
}
aspectRatio = size.width / size.height;
if ((size.width * pixelRatio) > maxSize.width && maxSize.width !== -1) {
size.width = Math.round(maxSize.width / pixelRatio);
size.height = Math.round(maxSize.width / aspectRatio / pixelRatio);
}
if ((size.height * pixelRatio) > maxSize.height && maxSize.height !== -1) {
size.height = Math.round(maxSize.height / pixelRatio);
size.width = Math.round(maxSize.height * aspectRatio / pixelRatio);
}
return size;
} | [
"function",
"getMaxSize",
"(",
"maxSize",
",",
"isVR",
")",
"{",
"var",
"aspectRatio",
";",
"var",
"size",
";",
"var",
"pixelRatio",
"=",
"window",
".",
"devicePixelRatio",
";",
"size",
"=",
"{",
"height",
":",
"document",
".",
"body",
".",
"offsetHeight",... | Return the canvas size. Will be the window size unless that size is greater than the
maximum size (1920x1920 by default). The constrained size will be returned in that case,
maintaining aspect ratio
@param {object} maxSize - Max size parameters (width and height).
@param {boolean} isVR - If in VR.
@returns {object} Width and height. | [
"Return",
"the",
"canvas",
"size",
".",
"Will",
"be",
"the",
"window",
"size",
"unless",
"that",
"size",
"is",
"greater",
"than",
"the",
"maximum",
"size",
"(",
"1920x1920",
"by",
"default",
")",
".",
"The",
"constrained",
"size",
"will",
"be",
"returned",... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/scene/a-scene.js#L770-L798 | train | Get the maximum size of the page | [
30522,
3853,
2131,
17848,
5332,
4371,
1006,
4098,
5332,
4371,
1010,
2003,
19716,
1007,
1063,
13075,
7814,
8609,
3695,
1025,
13075,
2946,
1025,
13075,
22138,
8609,
3695,
1027,
3332,
1012,
5080,
8197,
2595,
2884,
8609,
3695,
1025,
2946,
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... |
mochajs/mocha | lib/utils.js | highlight | function highlight(js) {
return js
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
.replace(/('.*?')/gm, '<span class="string">$1</span>')
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
.replace(/(\d+)/gm, '<span class="number">$1</span>')
.replace(
/\bnew[ \t]+(\w+)/gm,
'<span class="keyword">new</span> <span class="init">$1</span>'
)
.replace(
/\b(function|new|throw|return|var|if|else)\b/gm,
'<span class="keyword">$1</span>'
);
} | javascript | function highlight(js) {
return js
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
.replace(/('.*?')/gm, '<span class="string">$1</span>')
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
.replace(/(\d+)/gm, '<span class="number">$1</span>')
.replace(
/\bnew[ \t]+(\w+)/gm,
'<span class="keyword">new</span> <span class="init">$1</span>'
)
.replace(
/\b(function|new|throw|return|var|if|else)\b/gm,
'<span class="keyword">$1</span>'
);
} | [
"function",
"highlight",
"(",
"js",
")",
"{",
"return",
"js",
".",
"replace",
"(",
"/",
"<",
"/",
"g",
",",
"'<'",
")",
".",
"replace",
"(",
"/",
">",
"/",
"g",
",",
"'>'",
")",
".",
"replace",
"(",
"/",
"\\/\\/(.*)",
"/",
"gm",
",",
"'<s... | Highlight the given string of `js`.
@private
@param {string} js
@return {string} | [
"Highlight",
"the",
"given",
"string",
"of",
"js",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/utils.js#L202-L218 | train | Highlights the given JS code. | [
30522,
3853,
12944,
1006,
1046,
2015,
1007,
1063,
2709,
1046,
2015,
1012,
5672,
1006,
1013,
1026,
1013,
1043,
1010,
1005,
1004,
8318,
1025,
1005,
1007,
1012,
5672,
1006,
1013,
1028,
1013,
1043,
1010,
1005,
1004,
14181,
1025,
1005,
1007,
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... |
chartjs/Chart.js | src/core/core.plugins.js | function(chart, hook, args) {
var descriptors = this.descriptors(chart);
var ilen = descriptors.length;
var i, descriptor, plugin, params, method;
for (i = 0; i < ilen; ++i) {
descriptor = descriptors[i];
plugin = descriptor.plugin;
method = plugin[hook];
if (typeof method === 'function') {
params = [chart].concat(args || []);
params.push(descriptor.options);
if (method.apply(plugin, params) === false) {
return false;
}
}
}
return true;
} | javascript | function(chart, hook, args) {
var descriptors = this.descriptors(chart);
var ilen = descriptors.length;
var i, descriptor, plugin, params, method;
for (i = 0; i < ilen; ++i) {
descriptor = descriptors[i];
plugin = descriptor.plugin;
method = plugin[hook];
if (typeof method === 'function') {
params = [chart].concat(args || []);
params.push(descriptor.options);
if (method.apply(plugin, params) === false) {
return false;
}
}
}
return true;
} | [
"function",
"(",
"chart",
",",
"hook",
",",
"args",
")",
"{",
"var",
"descriptors",
"=",
"this",
".",
"descriptors",
"(",
"chart",
")",
";",
"var",
"ilen",
"=",
"descriptors",
".",
"length",
";",
"var",
"i",
",",
"descriptor",
",",
"plugin",
",",
"pa... | Calls enabled plugins for `chart` on the specified hook and with the given args.
This method immediately returns as soon as a plugin explicitly returns false. The
returned value can be used, for instance, to interrupt the current action.
@param {Chart} chart - The chart instance for which plugins should be called.
@param {string} hook - The name of the plugin method to call (e.g. 'beforeUpdate').
@param {Array} [args] - Extra arguments to apply to the hook call.
@returns {boolean} false if any of the plugins return false, else returns true. | [
"Calls",
"enabled",
"plugins",
"for",
"chart",
"on",
"the",
"specified",
"hook",
"and",
"with",
"the",
"given",
"args",
".",
"This",
"method",
"immediately",
"returns",
"as",
"soon",
"as",
"a",
"plugin",
"explicitly",
"returns",
"false",
".",
"The",
"returne... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.plugins.js#L97-L116 | train | call a method on a chart | [
30522,
3853,
1006,
3673,
1010,
8103,
1010,
12098,
5620,
1007,
1063,
13075,
4078,
23235,
5668,
1027,
2023,
1012,
4078,
23235,
5668,
1006,
3673,
1007,
1025,
13075,
17869,
2078,
1027,
4078,
23235,
5668,
1012,
3091,
1025,
13075,
1045,
1010,
407... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (req, _callback, raw)
{
Strophe.info("_connect_cb was called");
this.connected = true;
var bodyWrap = this._proto._reqToData(req);
if (!bodyWrap) { return; }
if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
if (bodyWrap.nodeName === this._proto.strip && bodyWrap.childNodes.length) {
this.xmlInput(bodyWrap.childNodes[0]);
} else {
this.xmlInput(bodyWrap);
}
}
if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
if (raw) {
this.rawInput(raw);
} else {
this.rawInput(Strophe.serialize(bodyWrap));
}
}
var conncheck = this._proto._connect_cb(bodyWrap);
if (conncheck === Strophe.Status.CONNFAIL) {
return;
}
this._authentication.sasl_scram_sha1 = false;
this._authentication.sasl_plain = false;
this._authentication.sasl_digest_md5 = false;
this._authentication.sasl_anonymous = false;
this._authentication.legacy_auth = false;
// Check for the stream:features tag
var hasFeatures = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "features").length > 0;
var mechanisms = bodyWrap.getElementsByTagName("mechanism");
var matched = [];
var i, mech, found_authentication = false;
if (!hasFeatures) {
this._proto._no_auth_received(_callback);
return;
}
if (mechanisms.length > 0) {
for (i = 0; i < mechanisms.length; i++) {
mech = Strophe.getText(mechanisms[i]);
if (this.mechanisms[mech]) matched.push(this.mechanisms[mech]);
}
}
this._authentication.legacy_auth =
bodyWrap.getElementsByTagName("auth").length > 0;
found_authentication = this._authentication.legacy_auth ||
matched.length > 0;
if (!found_authentication) {
this._proto._no_auth_received(_callback);
return;
}
if (this.do_authentication !== false)
this.authenticate(matched);
} | javascript | function (req, _callback, raw)
{
Strophe.info("_connect_cb was called");
this.connected = true;
var bodyWrap = this._proto._reqToData(req);
if (!bodyWrap) { return; }
if (this.xmlInput !== Strophe.Connection.prototype.xmlInput) {
if (bodyWrap.nodeName === this._proto.strip && bodyWrap.childNodes.length) {
this.xmlInput(bodyWrap.childNodes[0]);
} else {
this.xmlInput(bodyWrap);
}
}
if (this.rawInput !== Strophe.Connection.prototype.rawInput) {
if (raw) {
this.rawInput(raw);
} else {
this.rawInput(Strophe.serialize(bodyWrap));
}
}
var conncheck = this._proto._connect_cb(bodyWrap);
if (conncheck === Strophe.Status.CONNFAIL) {
return;
}
this._authentication.sasl_scram_sha1 = false;
this._authentication.sasl_plain = false;
this._authentication.sasl_digest_md5 = false;
this._authentication.sasl_anonymous = false;
this._authentication.legacy_auth = false;
// Check for the stream:features tag
var hasFeatures = bodyWrap.getElementsByTagNameNS(Strophe.NS.STREAM, "features").length > 0;
var mechanisms = bodyWrap.getElementsByTagName("mechanism");
var matched = [];
var i, mech, found_authentication = false;
if (!hasFeatures) {
this._proto._no_auth_received(_callback);
return;
}
if (mechanisms.length > 0) {
for (i = 0; i < mechanisms.length; i++) {
mech = Strophe.getText(mechanisms[i]);
if (this.mechanisms[mech]) matched.push(this.mechanisms[mech]);
}
}
this._authentication.legacy_auth =
bodyWrap.getElementsByTagName("auth").length > 0;
found_authentication = this._authentication.legacy_auth ||
matched.length > 0;
if (!found_authentication) {
this._proto._no_auth_received(_callback);
return;
}
if (this.do_authentication !== false)
this.authenticate(matched);
} | [
"function",
"(",
"req",
",",
"_callback",
",",
"raw",
")",
"{",
"Strophe",
".",
"info",
"(",
"\"_connect_cb was called\"",
")",
";",
"this",
".",
"connected",
"=",
"true",
";",
"var",
"bodyWrap",
"=",
"this",
".",
"_proto",
".",
"_reqToData",
"(",
"req",... | PrivateFunction: _connect_cb
_Private_ handler for initial connection request.
This handler is used to process the initial connection request
response from the BOSH server. It is used to set up authentication
handlers and start the authentication process.
SASL authentication will be attempted if available, otherwise
the code will fall back to legacy authentication.
Parameters:
(Strophe.Request) req - The current request.
(Function) _callback - low level (xmpp) connect callback function.
Useful for plugins with their own xmpp connect callback (when their)
want to do something special). | [
"PrivateFunction",
":",
"_connect_cb",
"_Private_",
"handler",
"for",
"initial",
"connection",
"request",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L2919-L2980 | train | _connect_cb is called by the Strophe class | [
30522,
3853,
1006,
2128,
4160,
1010,
1035,
2655,
5963,
1010,
6315,
1007,
1063,
2358,
18981,
5369,
1012,
18558,
1006,
1000,
1035,
7532,
1035,
17324,
2001,
2170,
1000,
1007,
1025,
2023,
1012,
4198,
1027,
2995,
1025,
13075,
2303,
13088,
9331,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function(value)
{
for (var key in mxStyleRegistry.values)
{
if (mxStyleRegistry.values[key] == value)
{
return key;
}
}
return null;
} | javascript | function(value)
{
for (var key in mxStyleRegistry.values)
{
if (mxStyleRegistry.values[key] == value)
{
return key;
}
}
return null;
} | [
"function",
"(",
"value",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"mxStyleRegistry",
".",
"values",
")",
"{",
"if",
"(",
"mxStyleRegistry",
".",
"values",
"[",
"key",
"]",
"==",
"value",
")",
"{",
"return",
"key",
";",
"}",
"}",
"return",
"null",
... | Function: getName
Returns the name for the given value. | [
"Function",
":",
"getName"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L51035-L51046 | train | Returns the key of the style registry | [
30522,
3853,
1006,
3643,
1007,
1063,
2005,
1006,
13075,
3145,
1999,
25630,
21756,
3917,
13910,
2923,
2854,
1012,
5300,
1007,
1063,
2065,
1006,
25630,
21756,
3917,
13910,
2923,
2854,
1012,
5300,
1031,
3145,
1033,
1027,
1027,
3643,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/StringMatch.js | _lastSegmentSearch | function _lastSegmentSearch(query, str, originalQuery, originalStr, specials, startingSpecial, lastSegmentStart) {
var queryCounter, matchList;
// It's possible that the query is longer than the last segment.
// If so, we can chop off the bit that we know couldn't possibly be there.
var remainder = "",
originalRemainder = "",
extraCharacters = specials[startingSpecial] + query.length - str.length;
if (extraCharacters > 0) {
remainder = query.substring(0, extraCharacters);
originalRemainder = originalQuery.substring(0, extraCharacters);
query = query.substring(extraCharacters);
originalQuery = originalQuery.substring(extraCharacters);
}
for (queryCounter = 0; queryCounter < query.length; queryCounter++) {
matchList = _generateMatchList(query.substring(queryCounter),
str, originalQuery.substring(queryCounter),
originalStr, specials, startingSpecial);
// if we've got a match *or* there are no segments in this string, we're done
if (matchList || startingSpecial === 0) {
break;
}
}
if (queryCounter === query.length || !matchList) {
return null;
} else {
return {
remainder: remainder + query.substring(0, queryCounter),
originalRemainder: originalRemainder + originalQuery.substring(0, queryCounter),
matchList: matchList
};
}
} | javascript | function _lastSegmentSearch(query, str, originalQuery, originalStr, specials, startingSpecial, lastSegmentStart) {
var queryCounter, matchList;
// It's possible that the query is longer than the last segment.
// If so, we can chop off the bit that we know couldn't possibly be there.
var remainder = "",
originalRemainder = "",
extraCharacters = specials[startingSpecial] + query.length - str.length;
if (extraCharacters > 0) {
remainder = query.substring(0, extraCharacters);
originalRemainder = originalQuery.substring(0, extraCharacters);
query = query.substring(extraCharacters);
originalQuery = originalQuery.substring(extraCharacters);
}
for (queryCounter = 0; queryCounter < query.length; queryCounter++) {
matchList = _generateMatchList(query.substring(queryCounter),
str, originalQuery.substring(queryCounter),
originalStr, specials, startingSpecial);
// if we've got a match *or* there are no segments in this string, we're done
if (matchList || startingSpecial === 0) {
break;
}
}
if (queryCounter === query.length || !matchList) {
return null;
} else {
return {
remainder: remainder + query.substring(0, queryCounter),
originalRemainder: originalRemainder + originalQuery.substring(0, queryCounter),
matchList: matchList
};
}
} | [
"function",
"_lastSegmentSearch",
"(",
"query",
",",
"str",
",",
"originalQuery",
",",
"originalStr",
",",
"specials",
",",
"startingSpecial",
",",
"lastSegmentStart",
")",
"{",
"var",
"queryCounter",
",",
"matchList",
";",
"// It's possible that the query is longer tha... | /*
Seek out the best match in the last segment (generally the filename).
Matches in the filename are preferred, but the query entered could match
any part of the path. So, we find the best match we can get in the filename
and then allow for searching the rest of the string with any characters that
are left from the beginning of the query.
The parameters and return value are the same as for getMatchRanges,
except this function is always working on the last segment and the
result can optionally include a remainder, which is the characters
at the beginning of the query which did not match in the last segment.
@param {string} query the search string (generally lower cased)
@param {string} str the string to compare with (generally lower cased)
@param {string} originalQuery the "non-normalized" query string (used to detect case match priority)
@param {string} originalStr the "non-normalized" string to compare with (used to detect case match priority)
@param {Array} specials list of special indexes in str (from findSpecialCharacters)
@param {int} startingSpecial index into specials array to start scanning with
@param {boolean} lastSegmentStart which character does the last segment start at
@return {{remainder:int, matchList:Array.<SpecialMatch|NormalMatch>}} matched indexes or null if no matches possible | [
"/",
"*",
"Seek",
"out",
"the",
"best",
"match",
"in",
"the",
"last",
"segment",
"(",
"generally",
"the",
"filename",
")",
".",
"Matches",
"in",
"the",
"filename",
"are",
"preferred",
"but",
"the",
"query",
"entered",
"could",
"match",
"any",
"part",
"of... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L411-L447 | train | Search for the last segment in the query | [
30522,
3853,
1035,
16180,
13910,
8163,
14644,
2818,
1006,
23032,
1010,
2358,
2099,
1010,
2434,
4226,
2854,
1010,
23728,
16344,
1010,
19247,
1010,
3225,
13102,
8586,
4818,
1010,
16180,
13910,
8163,
7559,
2102,
1007,
1063,
13075,
23032,
3597,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FileFilters.js | compile | function compile(userFilter) {
// Automatically apply ** prefix/suffix to make writing simple substring-match filters more intuitive
var wrappedGlobs = userFilter.map(function (glob) {
// Automatic "**" prefix if not explicitly present
if (glob.substr(0, 2) !== "**") {
glob = "**" + glob;
}
// Automatic "**" suffix if not explicitly present and no "." in last path segment of filter string
if (glob.substr(-2, 2) !== "**") {
var lastSeg = glob.lastIndexOf("/");
if (glob.indexOf(".", lastSeg + 1) === -1) { // if no "/" present, this treats whole string as 'last segment'
glob += "**";
}
}
return glob;
});
// Convert to regular expression for fast matching
var regexStrings = wrappedGlobs.map(function (glob) {
var reStr = "", i;
for (i = 0; i < glob.length; i++) {
var ch = glob[i];
if (ch === "*") {
// Check for `**`
if (glob[i + 1] === "*") {
// Special case: `/**/` can collapse - that is, it shouldn't require matching both slashes
if (glob[i + 2] === "/" && glob[i - 1] === "/") {
reStr += "(.*/)?";
i += 2; // skip 2nd * and / after it
} else {
reStr += ".*";
i++; // skip 2nd *
}
} else {
// Single `*`
reStr += "[^/]*";
}
} else if (ch === "?") {
reStr += "[^/]"; // unlike '?' in regexp, in globs this requires exactly 1 char
} else {
// Regular char with no special meaning
reStr += StringUtils.regexEscape(ch);
}
}
return "^" + reStr + "$";
});
return regexStrings.join("|");
} | javascript | function compile(userFilter) {
// Automatically apply ** prefix/suffix to make writing simple substring-match filters more intuitive
var wrappedGlobs = userFilter.map(function (glob) {
// Automatic "**" prefix if not explicitly present
if (glob.substr(0, 2) !== "**") {
glob = "**" + glob;
}
// Automatic "**" suffix if not explicitly present and no "." in last path segment of filter string
if (glob.substr(-2, 2) !== "**") {
var lastSeg = glob.lastIndexOf("/");
if (glob.indexOf(".", lastSeg + 1) === -1) { // if no "/" present, this treats whole string as 'last segment'
glob += "**";
}
}
return glob;
});
// Convert to regular expression for fast matching
var regexStrings = wrappedGlobs.map(function (glob) {
var reStr = "", i;
for (i = 0; i < glob.length; i++) {
var ch = glob[i];
if (ch === "*") {
// Check for `**`
if (glob[i + 1] === "*") {
// Special case: `/**/` can collapse - that is, it shouldn't require matching both slashes
if (glob[i + 2] === "/" && glob[i - 1] === "/") {
reStr += "(.*/)?";
i += 2; // skip 2nd * and / after it
} else {
reStr += ".*";
i++; // skip 2nd *
}
} else {
// Single `*`
reStr += "[^/]*";
}
} else if (ch === "?") {
reStr += "[^/]"; // unlike '?' in regexp, in globs this requires exactly 1 char
} else {
// Regular char with no special meaning
reStr += StringUtils.regexEscape(ch);
}
}
return "^" + reStr + "$";
});
return regexStrings.join("|");
} | [
"function",
"compile",
"(",
"userFilter",
")",
"{",
"// Automatically apply ** prefix/suffix to make writing simple substring-match filters more intuitive",
"var",
"wrappedGlobs",
"=",
"userFilter",
".",
"map",
"(",
"function",
"(",
"glob",
")",
"{",
"// Automatic \"**\" prefix... | Converts a user-specified filter object (as chosen in picker or retrieved from getFilters()) to a 'compiled' form
that can be used with filterPath()/filterFileList().
@param {!Array.<string>} userFilter
@return {!string} 'compiled' filter that can be passed to filterPath()/filterFileList(). | [
"Converts",
"a",
"user",
"-",
"specified",
"filter",
"object",
"(",
"as",
"chosen",
"in",
"picker",
"or",
"retrieved",
"from",
"getFilters",
"()",
")",
"to",
"a",
"compiled",
"form",
"that",
"can",
"be",
"used",
"with",
"filterPath",
"()",
"/",
"filterFile... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L210-L257 | train | Compile a glob string to a regular expression | [
30522,
3853,
4012,
22090,
1006,
5310,
8873,
21928,
1007,
1063,
1013,
1013,
8073,
6611,
1008,
1008,
17576,
1013,
16809,
2000,
2191,
3015,
3722,
4942,
3367,
4892,
1011,
2674,
17736,
2062,
29202,
13075,
5058,
23296,
16429,
2015,
1027,
5310,
88... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.commons/src/sap/ui/commons/RoadMap.js | function(oThis, oEvent){
oEvent.stopPropagation();
oEvent.preventDefault();
var jTarget = jQuery(oEvent.target);
var sTargetId = jTarget.attr("id");
if (!sTargetId) {
return;
}
//Handle event for the end of an expandable step
var iIdx = sTargetId.lastIndexOf("-expandend");
if (iIdx != -1) {
var oStep = sap.ui.getCore().byId(sTargetId.substring(0, iIdx));
if (oStep && oThis.indexOfStep(oStep) >= 0) {
oStep.handleSelect(oEvent, true);
return;
}
}
//Handle select on delimiter
if (sTargetId == oThis.getId() + "-Start") {
if (jTarget.hasClass("sapUiRoadMapStartScroll")) {
scrollToNextStep(oThis, "prev", true);
} else {
refreshFocus(oThis);
}
} else if (sTargetId == oThis.getId() + "-End") {
if (jTarget.hasClass("sapUiRoadMapEndScroll")) {
scrollToNextStep(oThis, "next", true);
} else {
refreshFocus(oThis);
}
}
} | javascript | function(oThis, oEvent){
oEvent.stopPropagation();
oEvent.preventDefault();
var jTarget = jQuery(oEvent.target);
var sTargetId = jTarget.attr("id");
if (!sTargetId) {
return;
}
//Handle event for the end of an expandable step
var iIdx = sTargetId.lastIndexOf("-expandend");
if (iIdx != -1) {
var oStep = sap.ui.getCore().byId(sTargetId.substring(0, iIdx));
if (oStep && oThis.indexOfStep(oStep) >= 0) {
oStep.handleSelect(oEvent, true);
return;
}
}
//Handle select on delimiter
if (sTargetId == oThis.getId() + "-Start") {
if (jTarget.hasClass("sapUiRoadMapStartScroll")) {
scrollToNextStep(oThis, "prev", true);
} else {
refreshFocus(oThis);
}
} else if (sTargetId == oThis.getId() + "-End") {
if (jTarget.hasClass("sapUiRoadMapEndScroll")) {
scrollToNextStep(oThis, "next", true);
} else {
refreshFocus(oThis);
}
}
} | [
"function",
"(",
"oThis",
",",
"oEvent",
")",
"{",
"oEvent",
".",
"stopPropagation",
"(",
")",
";",
"oEvent",
".",
"preventDefault",
"(",
")",
";",
"var",
"jTarget",
"=",
"jQuery",
"(",
"oEvent",
".",
"target",
")",
";",
"var",
"sTargetId",
"=",
"jTarg... | ********* Private ********* Called when either the Roadmap is clicked or the space or enter key is pressed | [
"*********",
"Private",
"*********",
"Called",
"when",
"either",
"the",
"Roadmap",
"is",
"clicked",
"or",
"the",
"space",
"or",
"enter",
"key",
"is",
"pressed"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMap.js#L427-L462 | train | Handles the select event on the end of a step | [
30522,
3853,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1007,
1063,
1051,
18697,
3372,
1012,
2644,
21572,
4502,
12540,
1006,
1007,
1025,
1051,
18697,
3372,
1012,
4652,
3207,
7011,
11314,
1006,
1007,
1025,
13075,
1046,
7559,
18150,
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... | |
moleculerjs/moleculer | src/cachers/index.js | resolve | function resolve(opt) {
if (opt instanceof Cachers.Base) {
return opt;
} else if (opt === true) {
return new Cachers.Memory();
} else if (_.isString(opt)) {
let CacherClass = getByName(opt);
if (CacherClass)
return new CacherClass();
if (opt.startsWith("redis://"))
CacherClass = Cachers.Redis;
if (CacherClass)
return new CacherClass(opt);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let CacherClass = getByName(opt.type || "Memory");
if (CacherClass)
return new CacherClass(opt.options);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt.type}'.`, { type: opt.type });
}
return null;
} | javascript | function resolve(opt) {
if (opt instanceof Cachers.Base) {
return opt;
} else if (opt === true) {
return new Cachers.Memory();
} else if (_.isString(opt)) {
let CacherClass = getByName(opt);
if (CacherClass)
return new CacherClass();
if (opt.startsWith("redis://"))
CacherClass = Cachers.Redis;
if (CacherClass)
return new CacherClass(opt);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let CacherClass = getByName(opt.type || "Memory");
if (CacherClass)
return new CacherClass(opt.options);
else
throw new BrokerOptionsError(`Invalid cacher type '${opt.type}'.`, { type: opt.type });
}
return null;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"opt",
"instanceof",
"Cachers",
".",
"Base",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"opt",
"===",
"true",
")",
"{",
"return",
"new",
"Cachers",
".",
"Memory",
"(",
")",
";",
... | Resolve cacher by name
@param {object|string} opt
@returns {Cacher} | [
"Resolve",
"cacher",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/cachers/index.js#L35-L62 | train | Resolve a cacher | [
30522,
3853,
10663,
1006,
23569,
1007,
1063,
2065,
1006,
23569,
6013,
11253,
17053,
2869,
1012,
2918,
1007,
1063,
2709,
23569,
1025,
1065,
2842,
2065,
1006,
23569,
1027,
1027,
1027,
2995,
1007,
1063,
2709,
2047,
17053,
2869,
1012,
3638,
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... |
wangfupeng1988/wangEditor | src/js/menus/index.js | function () {
const editor = this.editor
const $toolbarElem = editor.$toolbarElem
const menus = this.menus
const config = editor.config
// config.zIndex 是配置的编辑区域的 z-index,菜单的 z-index 得在其基础上 +1
const zIndex = config.zIndex + 1
objForEach(menus, (key, menu) => {
const $elem = menu.$elem
if ($elem) {
// 设置 z-index
$elem.css('z-index', zIndex)
$toolbarElem.append($elem)
}
})
} | javascript | function () {
const editor = this.editor
const $toolbarElem = editor.$toolbarElem
const menus = this.menus
const config = editor.config
// config.zIndex 是配置的编辑区域的 z-index,菜单的 z-index 得在其基础上 +1
const zIndex = config.zIndex + 1
objForEach(menus, (key, menu) => {
const $elem = menu.$elem
if ($elem) {
// 设置 z-index
$elem.css('z-index', zIndex)
$toolbarElem.append($elem)
}
})
} | [
"function",
"(",
")",
"{",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"$toolbarElem",
"=",
"editor",
".",
"$toolbarElem",
"const",
"menus",
"=",
"this",
".",
"menus",
"const",
"config",
"=",
"editor",
".",
"config",
"// config.zIndex 是配置的编辑区域的 z-i... | 添加到菜单栏 | [
"添加到菜单栏"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/index.js#L40-L55 | train | Add a new menu element to the toolbar | [
30522,
3853,
1006,
1007,
1063,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
1002,
6994,
8237,
12260,
2213,
1027,
3559,
1012,
1002,
6994,
8237,
12260,
2213,
9530,
3367,
12183,
2015,
1027,
2023,
1012,
12183,
2015,
9530,
3367,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/BarInPageEnabler.js | function (sContext) {
var oOptions = this._getContextOptions(sContext);
if (!oOptions) {
return this;
}
if (!this.setHTMLTag) {
Log.error("The bar control you are using does not implement all the members of the IBar interface", this);
return this;
}
this.setHTMLTag(oOptions.tag);
return this;
} | javascript | function (sContext) {
var oOptions = this._getContextOptions(sContext);
if (!oOptions) {
return this;
}
if (!this.setHTMLTag) {
Log.error("The bar control you are using does not implement all the members of the IBar interface", this);
return this;
}
this.setHTMLTag(oOptions.tag);
return this;
} | [
"function",
"(",
"sContext",
")",
"{",
"var",
"oOptions",
"=",
"this",
".",
"_getContextOptions",
"(",
"sContext",
")",
";",
"if",
"(",
"!",
"oOptions",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"!",
"this",
".",
"setHTMLTag",
")",
"{",
"Log",... | Sets HTML tag according to the context of the page.
Possible contexts are header, footer, subheader.
@param {string} sContext allowed values are header, footer, subheader.
@returns {sap.m.IBar} <code>this</code> for chaining
@sap-restricted
@private | [
"Sets",
"HTML",
"tag",
"according",
"to",
"the",
"context",
"of",
"the",
"page",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/BarInPageEnabler.js#L171-L186 | train | Sets the HTML tag of the bar control | [
30522,
3853,
1006,
8040,
28040,
18413,
1007,
1063,
13075,
1051,
7361,
9285,
1027,
2023,
1012,
1035,
2131,
8663,
18209,
7361,
9285,
1006,
8040,
28040,
18413,
1007,
1025,
2065,
1006,
999,
1051,
7361,
9285,
1007,
1063,
2709,
2023,
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... | |
SAP/openui5 | src/sap.m/src/sap/m/changeHandler/MoveTableColumns.js | _applyChange | function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
var oModifier = mPropertyBag.modifier,
oView = mPropertyBag.view,
oAppComponent = mPropertyBag.appComponent,
oChangeContent = oChange.getContent(),
oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag),
oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag),
aColumns = oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME),
switchCells = function (oRow, iSourceIndex, iTargetIndex) {
var aCells = oModifier.getAggregation(oRow, CELLS_AGGREGATION_NAME);
// ColumnListItem and GroupHeaderListItem are only allowed for the tables items aggregation.
if (!aCells) {
Log.warning("Aggregation cells to move not found");
return;
}
if (iSourceIndex < 0 || iSourceIndex >= aCells.length) {
Log.warning("Move cells in table item called with invalid index: " + iSourceIndex);
return;
}
var oMovedCell = aCells[iSourceIndex];
oModifier.removeAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell);
oModifier.insertAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell, iTargetIndex, oView);
},
moveColumns = function (iSourceIndex, iTargetIndex) {
oModifier.getAggregation(oTable, ITEMS_AGGREGATION_NAME).forEach(function (oItem) {
// We are skipping the GroupHeaderListItems, because they are valid for the whole row and does not have cells to move.
if (oModifier.getControlType(oItem) === "sap.m.GroupHeaderListItem") {
return;
}
switchCells(oItem, iSourceIndex, iTargetIndex);
});
};
if (oTargetSource !== oTable) {
Log.warning("Moving columns between different tables is not yet supported.");
return false;
}
// Fetch the information about the movedElements together with the source and target index.
oChangeContent.movedElements.forEach(function (mMovedElement) {
var oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView),
iSourceIndex, iTargetIndex, iCurrentIndexInAggregation, iStoredSourceIndexInChange, sMovedElementId;
if (!oMovedElement) {
sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
return;
}
iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
iStoredSourceIndexInChange = mMovedElement.sourceIndex;
iTargetIndex = jQuery.isFunction(fnIterator) && fnIterator(iCurrentIndexInAggregation);
iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;
if (iCurrentIndexInAggregation !== iTargetIndex) {
// By default we are getting the index from the aggregation, because it is possible that the order is
// already modified and the column that we want to move is not on the passed source index
iSourceIndex = iCurrentIndexInAggregation;
} else {
// In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action.
// Therefore, we need to use the passed source index
iSourceIndex = iStoredSourceIndexInChange;
}
// move children in `columns` aggregation
oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);
// move children in `items` aggregation (actual content)
var oTemplate = oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);
if (oTemplate) {
switchCells(oTemplate, iSourceIndex, iTargetIndex);
oModifier.updateAggregation(oTable, ITEMS_AGGREGATION_NAME);
} else {
moveColumns(iSourceIndex, iTargetIndex);
}
}, this);
return true;
} | javascript | function _applyChange(oChange, oRelevantContainer, mPropertyBag, fnIterator) {
var oModifier = mPropertyBag.modifier,
oView = mPropertyBag.view,
oAppComponent = mPropertyBag.appComponent,
oChangeContent = oChange.getContent(),
oTargetSource = oChange.getDependentControl(SOURCE_ALIAS, mPropertyBag),
oTable = oChange.getDependentControl(TARGET_ALIAS, mPropertyBag),
aColumns = oModifier.getAggregation(oTable, COLUMNS_AGGREGATION_NAME),
switchCells = function (oRow, iSourceIndex, iTargetIndex) {
var aCells = oModifier.getAggregation(oRow, CELLS_AGGREGATION_NAME);
// ColumnListItem and GroupHeaderListItem are only allowed for the tables items aggregation.
if (!aCells) {
Log.warning("Aggregation cells to move not found");
return;
}
if (iSourceIndex < 0 || iSourceIndex >= aCells.length) {
Log.warning("Move cells in table item called with invalid index: " + iSourceIndex);
return;
}
var oMovedCell = aCells[iSourceIndex];
oModifier.removeAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell);
oModifier.insertAggregation(oRow, CELLS_AGGREGATION_NAME, oMovedCell, iTargetIndex, oView);
},
moveColumns = function (iSourceIndex, iTargetIndex) {
oModifier.getAggregation(oTable, ITEMS_AGGREGATION_NAME).forEach(function (oItem) {
// We are skipping the GroupHeaderListItems, because they are valid for the whole row and does not have cells to move.
if (oModifier.getControlType(oItem) === "sap.m.GroupHeaderListItem") {
return;
}
switchCells(oItem, iSourceIndex, iTargetIndex);
});
};
if (oTargetSource !== oTable) {
Log.warning("Moving columns between different tables is not yet supported.");
return false;
}
// Fetch the information about the movedElements together with the source and target index.
oChangeContent.movedElements.forEach(function (mMovedElement) {
var oMovedElement = oModifier.bySelector(mMovedElement.selector, oAppComponent, oView),
iSourceIndex, iTargetIndex, iCurrentIndexInAggregation, iStoredSourceIndexInChange, sMovedElementId;
if (!oMovedElement) {
sMovedElementId = mMovedElement.selector && mMovedElement.selector.id;
Log.warning("The table column with id: '" + sMovedElementId + "' stored in the change is not found and the move operation cannot be applied");
return;
}
iCurrentIndexInAggregation = aColumns.indexOf(oMovedElement);
iStoredSourceIndexInChange = mMovedElement.sourceIndex;
iTargetIndex = jQuery.isFunction(fnIterator) && fnIterator(iCurrentIndexInAggregation);
iTargetIndex = jQuery.isNumeric(iTargetIndex) ? iTargetIndex : mMovedElement.targetIndex;
if (iCurrentIndexInAggregation !== iTargetIndex) {
// By default we are getting the index from the aggregation, because it is possible that the order is
// already modified and the column that we want to move is not on the passed source index
iSourceIndex = iCurrentIndexInAggregation;
} else {
// In RTA edit mode, the condition will be false, because the aggregation is modified by the drag and drop action.
// Therefore, we need to use the passed source index
iSourceIndex = iStoredSourceIndexInChange;
}
// move children in `columns` aggregation
oModifier.removeAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement);
oModifier.insertAggregation(oTable, COLUMNS_AGGREGATION_NAME, oMovedElement, iTargetIndex, oView);
// move children in `items` aggregation (actual content)
var oTemplate = oModifier.getBindingTemplate(oTable, ITEMS_AGGREGATION_NAME);
if (oTemplate) {
switchCells(oTemplate, iSourceIndex, iTargetIndex);
oModifier.updateAggregation(oTable, ITEMS_AGGREGATION_NAME);
} else {
moveColumns(iSourceIndex, iTargetIndex);
}
}, this);
return true;
} | [
"function",
"_applyChange",
"(",
"oChange",
",",
"oRelevantContainer",
",",
"mPropertyBag",
",",
"fnIterator",
")",
"{",
"var",
"oModifier",
"=",
"mPropertyBag",
".",
"modifier",
",",
"oView",
"=",
"mPropertyBag",
".",
"view",
",",
"oAppComponent",
"=",
"mProper... | Moves a column from one index to another.
@param {sap.ui.fl.Change} oChange Change object with instructions to be applied on the control
@param {sap.ui.core.Control} oRelevantContainer Control that matches the change selector for applying the change, which is the source of the move
@param {object} mPropertyBag Map of properties
@param {object} mPropertyBag.view XML node representing a ui5 view
@param {sap.ui.core.util.reflection.BaseTreeModifier} mPropertyBag.modifier Modifier for the controls
@param {sap.ui.core.UIComponent} mPropertyBag.appComponent AppComponent
@param {function} fnIterator - Iterator function which is called on each movedElement, as an argument it gets CurrentIndex
of the element and may return TargetIndex as a result.
@return {boolean} true Indicates whether the change can be applied | [
"Moves",
"a",
"column",
"from",
"one",
"index",
"to",
"another",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/changeHandler/MoveTableColumns.js#L37-L121 | train | Applies a change to the given container. | [
30522,
3853,
1035,
6611,
22305,
2063,
1006,
28166,
22043,
1010,
10848,
20414,
4630,
8663,
18249,
2121,
1010,
6131,
18981,
15010,
16078,
1010,
1042,
3490,
14621,
4263,
1007,
1063,
13075,
18168,
7716,
18095,
1027,
6131,
18981,
15010,
16078,
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... |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/inspector.js | flushQueueIfAvailable | function flushQueueIfAvailable()
{
if (!isLogAvailable())
return;
clearInterval(WebInspector.log.interval);
delete WebInspector.log.interval;
flushQueue();
} | javascript | function flushQueueIfAvailable()
{
if (!isLogAvailable())
return;
clearInterval(WebInspector.log.interval);
delete WebInspector.log.interval;
flushQueue();
} | [
"function",
"flushQueueIfAvailable",
"(",
")",
"{",
"if",
"(",
"!",
"isLogAvailable",
"(",
")",
")",
"return",
";",
"clearInterval",
"(",
"WebInspector",
".",
"log",
".",
"interval",
")",
";",
"delete",
"WebInspector",
".",
"log",
".",
"interval",
";",
"fl... | flush the queue if it console is available - this function is run on an interval | [
"flush",
"the",
"queue",
"if",
"it",
"console",
"is",
"available",
"-",
"this",
"function",
"is",
"run",
"on",
"an",
"interval"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/inspector.js#L1227-L1236 | train | Flush the queue if log is available | [
30522,
3853,
13862,
4226,
5657,
10128,
12462,
11733,
3468,
1006,
1007,
1063,
2065,
1006,
999,
2003,
21197,
12462,
11733,
3468,
1006,
1007,
1007,
2709,
1025,
3154,
18447,
2121,
10175,
1006,
4773,
7076,
5051,
16761,
1012,
8833,
1012,
13483,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function() {
if (iBaseFontSize == null) {
var oDocumentRootElement = document.documentElement;
if (oDocumentRootElement) {
iBaseFontSize = parseInt(window.getComputedStyle(oDocumentRootElement).fontSize);
}
}
return iBaseFontSize == null ? 16 : iBaseFontSize;
} | javascript | function() {
if (iBaseFontSize == null) {
var oDocumentRootElement = document.documentElement;
if (oDocumentRootElement) {
iBaseFontSize = parseInt(window.getComputedStyle(oDocumentRootElement).fontSize);
}
}
return iBaseFontSize == null ? 16 : iBaseFontSize;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"iBaseFontSize",
"==",
"null",
")",
"{",
"var",
"oDocumentRootElement",
"=",
"document",
".",
"documentElement",
";",
"if",
"(",
"oDocumentRootElement",
")",
"{",
"iBaseFontSize",
"=",
"parseInt",
"(",
"window",
".",
"ge... | Gets the base font size of the document in pixels. If this method is called while the base size cannot be retrieved from the document, a
default font size of 16 (pixels) is returned.
@returns {int} The base font size in pixels. | [
"Gets",
"the",
"base",
"font",
"size",
"of",
"the",
"document",
"in",
"pixels",
".",
"If",
"this",
"method",
"is",
"called",
"while",
"the",
"base",
"size",
"cannot",
"be",
"retrieved",
"from",
"the",
"document",
"a",
"default",
"font",
"size",
"of",
"16... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L1484-L1493 | train | Returns the base font size of the document. | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
21307,
11022,
14876,
7666,
4697,
1027,
1027,
19701,
1007,
1063,
13075,
1051,
3527,
24894,
4765,
3217,
12184,
16930,
4765,
1027,
6254,
1012,
6254,
12260,
3672,
1025,
2065,
1006,
1051,
3527,
24894,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/ODataMessageParser.js | getContentType | function getContentType(oResponse) {
if (oResponse && oResponse.headers) {
for (var sHeader in oResponse.headers) {
if (sHeader.toLowerCase() === "content-type") {
return oResponse.headers[sHeader].replace(/([^;]*);.*/, "$1");
}
}
}
return false;
} | javascript | function getContentType(oResponse) {
if (oResponse && oResponse.headers) {
for (var sHeader in oResponse.headers) {
if (sHeader.toLowerCase() === "content-type") {
return oResponse.headers[sHeader].replace(/([^;]*);.*/, "$1");
}
}
}
return false;
} | [
"function",
"getContentType",
"(",
"oResponse",
")",
"{",
"if",
"(",
"oResponse",
"&&",
"oResponse",
".",
"headers",
")",
"{",
"for",
"(",
"var",
"sHeader",
"in",
"oResponse",
".",
"headers",
")",
"{",
"if",
"(",
"sHeader",
".",
"toLowerCase",
"(",
")",
... | /////////////////////////////////////// Hidden Functions /////////////////////////////////////////
Returns the content-type header of the given response, it searches in a case-insentitive way for
the header
@param {object} oResponse - The response object from which the body property will be used
@return {string|false} Either the content-type header content or false if none is found
@private | [
"///////////////////////////////////////",
"Hidden",
"Functions",
"/////////////////////////////////////////",
"Returns",
"the",
"content",
"-",
"type",
"header",
"of",
"the",
"given",
"response",
"it",
"searches",
"in",
"a",
"case",
"-",
"insentitive",
"way",
"for",
"t... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/ODataMessageParser.js#L800-L809 | train | Returns the content type of the given response | [
30522,
3853,
2131,
8663,
6528,
15353,
5051,
1006,
10848,
13102,
5644,
2063,
1007,
1063,
2065,
1006,
10848,
13102,
5644,
2063,
1004,
1004,
10848,
13102,
5644,
2063,
1012,
20346,
2015,
1007,
1063,
2005,
1006,
13075,
16994,
4063,
1999,
10848,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | dist/js/materialize.js | function () {
_this15.el.style.display = 'none';
_this15.$overlay.remove();
// Call onCloseEnd callback
if (typeof _this15.options.onCloseEnd === 'function') {
_this15.options.onCloseEnd.call(_this15, _this15.el);
}
} | javascript | function () {
_this15.el.style.display = 'none';
_this15.$overlay.remove();
// Call onCloseEnd callback
if (typeof _this15.options.onCloseEnd === 'function') {
_this15.options.onCloseEnd.call(_this15, _this15.el);
}
} | [
"function",
"(",
")",
"{",
"_this15",
".",
"el",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"_this15",
".",
"$overlay",
".",
"remove",
"(",
")",
";",
"// Call onCloseEnd callback",
"if",
"(",
"typeof",
"_this15",
".",
"options",
".",
"onCloseEnd",
... | Handle modal ready callback | [
"Handle",
"modal",
"ready",
"callback"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3135-L3143 | train | Hides the cluster el | [
30522,
3853,
1006,
1007,
1063,
1035,
2023,
16068,
1012,
3449,
1012,
2806,
1012,
4653,
1027,
1005,
3904,
1005,
1025,
1035,
2023,
16068,
1012,
1002,
2058,
8485,
1012,
6366,
1006,
1007,
1025,
1013,
1013,
2655,
2006,
20464,
9232,
10497,
2655,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/scripts/generate-plugin-combinations.js | combine | function combine(a) {
const fn = function(n, src, got, all) {
if (n === 0) {
all.push(got);
return;
}
for (let j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
};
const all = [a];
for (let i = 0; i < a.length; i++) {
fn(i, a, [], all);
}
all.splice(1, 1); // Remove the empty array
return all;
} | javascript | function combine(a) {
const fn = function(n, src, got, all) {
if (n === 0) {
all.push(got);
return;
}
for (let j = 0; j < src.length; j++) {
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all);
}
};
const all = [a];
for (let i = 0; i < a.length; i++) {
fn(i, a, [], all);
}
all.splice(1, 1); // Remove the empty array
return all;
} | [
"function",
"combine",
"(",
"a",
")",
"{",
"const",
"fn",
"=",
"function",
"(",
"n",
",",
"src",
",",
"got",
",",
"all",
")",
"{",
"if",
"(",
"n",
"===",
"0",
")",
"{",
"all",
".",
"push",
"(",
"got",
")",
";",
"return",
";",
"}",
"for",
"(... | 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/scripts/generate-plugin-combinations.js#L17-L38 | train | Combine the array a with the array a | [
30522,
3853,
11506,
1006,
1037,
1007,
1063,
9530,
3367,
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,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataListBinding.js | fetchFilter | function fetchFilter(oFilter, mLambdaVariableToPath, bWithinAnd) {
if (oFilter.aFilters) {
return SyncPromise.all(oFilter.aFilters.map(function (oSubFilter) {
return fetchFilter(oSubFilter, mLambdaVariableToPath, oFilter.bAnd);
})).then(function (aFilterStrings) {
// wrap it if it's an 'or' filter embedded in an 'and'
return wrap(aFilterStrings.join(oFilter.bAnd ? " and " : " or "),
bWithinAnd && !oFilter.bAnd);
});
}
return oMetaModel.fetchObject(
replaceLambdaVariables(oFilter.sPath, mLambdaVariableToPath),
oMetaContext
).then(function (oPropertyMetadata) {
var oCondition, sLambdaVariable, sOperator;
if (!oPropertyMetadata) {
throw new Error("Type cannot be determined, no metadata for path: "
+ oMetaContext.getPath());
}
sOperator = oFilter.sOperator;
if (sOperator === FilterOperator.All || sOperator === FilterOperator.Any) {
oCondition = oFilter.oCondition;
sLambdaVariable = oFilter.sVariable;
if (sOperator === FilterOperator.Any && !oCondition) {
return oFilter.sPath + "/any()";
}
// multifilters are processed in parallel, so clone mLambdaVariableToPath
// to allow same lambda variables in different filters
mLambdaVariableToPath = Object.create(mLambdaVariableToPath);
mLambdaVariableToPath[sLambdaVariable]
= replaceLambdaVariables(oFilter.sPath, mLambdaVariableToPath);
return fetchFilter(
oCondition, mLambdaVariableToPath
).then(function (sFilterValue) {
return oFilter.sPath + "/" + oFilter.sOperator.toLowerCase()
+ "(" + sLambdaVariable + ":" + sFilterValue + ")";
});
}
return getSingleFilterValue(oFilter, oPropertyMetadata.$Type, bWithinAnd);
});
} | javascript | function fetchFilter(oFilter, mLambdaVariableToPath, bWithinAnd) {
if (oFilter.aFilters) {
return SyncPromise.all(oFilter.aFilters.map(function (oSubFilter) {
return fetchFilter(oSubFilter, mLambdaVariableToPath, oFilter.bAnd);
})).then(function (aFilterStrings) {
// wrap it if it's an 'or' filter embedded in an 'and'
return wrap(aFilterStrings.join(oFilter.bAnd ? " and " : " or "),
bWithinAnd && !oFilter.bAnd);
});
}
return oMetaModel.fetchObject(
replaceLambdaVariables(oFilter.sPath, mLambdaVariableToPath),
oMetaContext
).then(function (oPropertyMetadata) {
var oCondition, sLambdaVariable, sOperator;
if (!oPropertyMetadata) {
throw new Error("Type cannot be determined, no metadata for path: "
+ oMetaContext.getPath());
}
sOperator = oFilter.sOperator;
if (sOperator === FilterOperator.All || sOperator === FilterOperator.Any) {
oCondition = oFilter.oCondition;
sLambdaVariable = oFilter.sVariable;
if (sOperator === FilterOperator.Any && !oCondition) {
return oFilter.sPath + "/any()";
}
// multifilters are processed in parallel, so clone mLambdaVariableToPath
// to allow same lambda variables in different filters
mLambdaVariableToPath = Object.create(mLambdaVariableToPath);
mLambdaVariableToPath[sLambdaVariable]
= replaceLambdaVariables(oFilter.sPath, mLambdaVariableToPath);
return fetchFilter(
oCondition, mLambdaVariableToPath
).then(function (sFilterValue) {
return oFilter.sPath + "/" + oFilter.sOperator.toLowerCase()
+ "(" + sLambdaVariable + ":" + sFilterValue + ")";
});
}
return getSingleFilterValue(oFilter, oPropertyMetadata.$Type, bWithinAnd);
});
} | [
"function",
"fetchFilter",
"(",
"oFilter",
",",
"mLambdaVariableToPath",
",",
"bWithinAnd",
")",
"{",
"if",
"(",
"oFilter",
".",
"aFilters",
")",
"{",
"return",
"SyncPromise",
".",
"all",
"(",
"oFilter",
".",
"aFilters",
".",
"map",
"(",
"function",
"(",
"... | Fetches the $filter value for the given filter.
@param {sap.ui.model.Filter} oFilter The filter
@param {object} mLambdaVariableToPath The map from lambda variable to full path
@param {boolean} [bWithinAnd] Whether the embedding filter is an 'and'
@returns {sap.ui.base.SyncPromise} A promise which resolves with the $filter value or
rejects with an error if the filter value uses an unknown operator | [
"Fetches",
"the",
"$filter",
"value",
"for",
"the",
"given",
"filter",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataListBinding.js#L914-L958 | train | Fetch the filter from the database | [
30522,
3853,
18584,
8873,
21928,
1006,
1997,
4014,
3334,
1010,
18619,
14905,
29045,
10980,
3468,
14399,
8988,
1010,
1038,
24415,
3981,
4859,
1007,
1063,
2065,
1006,
1997,
4014,
3334,
1012,
28697,
21928,
2015,
1007,
1063,
2709,
26351,
21572,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | aio/tools/transforms/authors-package/getting-started-package.js | createPackage | function createPackage(tutorialName) {
const tutorialFilePath = `${CONTENTS_PATH}/getting-started/${tutorialName}.md`;
const tutorialFile = readFileSync(tutorialFilePath, 'utf8');
const examples = [];
tutorialFile.replace(/<code-(?:pane|example) [^>]*path="([^"]+)"/g, (_, path) => examples.push('examples/' + path));
if (examples.length) {
console.log('The following example files are referenced in this getting-started:');
console.log(examples.map(example => ' - ' + example).join('\n'));
}
return new Package('author-getting-started', [contentPackage])
.config(function(readFilesProcessor) {
readFilesProcessor.sourceFiles = [
{
basePath: CONTENTS_PATH,
include: tutorialFilePath,
fileReader: 'contentFileReader'
},
{
basePath: CONTENTS_PATH,
include: examples.map(example => resolve(CONTENTS_PATH, example)),
fileReader: 'exampleFileReader'
}
];
});
} | javascript | function createPackage(tutorialName) {
const tutorialFilePath = `${CONTENTS_PATH}/getting-started/${tutorialName}.md`;
const tutorialFile = readFileSync(tutorialFilePath, 'utf8');
const examples = [];
tutorialFile.replace(/<code-(?:pane|example) [^>]*path="([^"]+)"/g, (_, path) => examples.push('examples/' + path));
if (examples.length) {
console.log('The following example files are referenced in this getting-started:');
console.log(examples.map(example => ' - ' + example).join('\n'));
}
return new Package('author-getting-started', [contentPackage])
.config(function(readFilesProcessor) {
readFilesProcessor.sourceFiles = [
{
basePath: CONTENTS_PATH,
include: tutorialFilePath,
fileReader: 'contentFileReader'
},
{
basePath: CONTENTS_PATH,
include: examples.map(example => resolve(CONTENTS_PATH, example)),
fileReader: 'exampleFileReader'
}
];
});
} | [
"function",
"createPackage",
"(",
"tutorialName",
")",
"{",
"const",
"tutorialFilePath",
"=",
"`",
"${",
"CONTENTS_PATH",
"}",
"${",
"tutorialName",
"}",
"`",
";",
"const",
"tutorialFile",
"=",
"readFileSync",
"(",
"tutorialFilePath",
",",
"'utf8'",
")",
";",
... | /* eslint no-console: "off" | [
"/",
"*",
"eslint",
"no",
"-",
"console",
":",
"off"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/aio/tools/transforms/authors-package/getting-started-package.js#L17-L44 | train | Create a package | [
30522,
3853,
3443,
23947,
4270,
1006,
14924,
4818,
18442,
1007,
1063,
9530,
3367,
14924,
4818,
8873,
2571,
15069,
1027,
1036,
1002,
1063,
8417,
1035,
4130,
1065,
1013,
2893,
1011,
2318,
1013,
1002,
1063,
14924,
4818,
18442,
1065,
1012,
9108... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jquery/jquery | build/tasks/build.js | convert | function convert( name, path, contents ) {
var amdName;
// Convert var modules
if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
contents = contents
.replace(
/define\([\w\W]*?return/,
"var " +
( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
" ="
)
.replace( rdefineEnd, "" );
// Sizzle treatment
} else if ( /\/sizzle$/.test( name ) ) {
contents = "var Sizzle =\n" + contents
// Remove EXPOSE lines from Sizzle
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
} else {
contents = contents
.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )
// Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
// Remove define wrappers, closure ends, and empty declarations
contents = contents
.replace( /define\([^{]*?{\s*(?:("|')use strict\1(?:;|))?/, "" )
.replace( rdefineEnd, "" );
// Remove anything wrapped with
// /* ExcludeStart */ /* ExcludeEnd */
// or a single line directly after a // BuildExclude comment
contents = contents
.replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
.replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );
// Remove empty definitions
contents = contents
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
}
// AMD Name
if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
if ( amdName ) {
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
} else {
grunt.log.writeln( "AMD name now anonymous" );
}
// Remove the comma for anonymous defines
contents = contents
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
}
return contents;
} | javascript | function convert( name, path, contents ) {
var amdName;
// Convert var modules
if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
contents = contents
.replace(
/define\([\w\W]*?return/,
"var " +
( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
" ="
)
.replace( rdefineEnd, "" );
// Sizzle treatment
} else if ( /\/sizzle$/.test( name ) ) {
contents = "var Sizzle =\n" + contents
// Remove EXPOSE lines from Sizzle
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
} else {
contents = contents
.replace( /\s*return\s+[^\}]+(\}\s*?\);[^\w\}]*)$/, "$1" )
// Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
// Remove define wrappers, closure ends, and empty declarations
contents = contents
.replace( /define\([^{]*?{\s*(?:("|')use strict\1(?:;|))?/, "" )
.replace( rdefineEnd, "" );
// Remove anything wrapped with
// /* ExcludeStart */ /* ExcludeEnd */
// or a single line directly after a // BuildExclude comment
contents = contents
.replace( /\/\*\s*ExcludeStart\s*\*\/[\w\W]*?\/\*\s*ExcludeEnd\s*\*\//ig, "" )
.replace( /\/\/\s*BuildExclude\n\r?[\w\W]*?\n\r?/ig, "" );
// Remove empty definitions
contents = contents
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
}
// AMD Name
if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
if ( amdName ) {
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
} else {
grunt.log.writeln( "AMD name now anonymous" );
}
// Remove the comma for anonymous defines
contents = contents
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
}
return contents;
} | [
"function",
"convert",
"(",
"name",
",",
"path",
",",
"contents",
")",
"{",
"var",
"amdName",
";",
"// Convert var modules",
"if",
"(",
"/",
".\\/var\\/",
"/",
".",
"test",
"(",
"path",
".",
"replace",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"\"\"",... | Strip all definitions generated by requirejs
Convert "var" modules to var declarations
"var module" means the module only contains a return
statement that should be converted to a var declaration
This is indicated by including the file in any "var" folder
@param {String} name
@param {String} path
@param {String} contents The contents to be written (including their AMD wrappers) | [
"Strip",
"all",
"definitions",
"generated",
"by",
"requirejs",
"Convert",
"var",
"modules",
"to",
"var",
"declarations",
"var",
"module",
"means",
"the",
"module",
"only",
"contains",
"a",
"return",
"statement",
"that",
"should",
"be",
"converted",
"to",
"a",
... | ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3 | https://github.com/jquery/jquery/blob/ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3/build/tasks/build.js#L61-L121 | train | Convert a module name to a module name | [
30522,
3853,
10463,
1006,
2171,
1010,
4130,
1010,
8417,
1007,
1063,
13075,
2572,
28911,
4168,
1025,
1013,
1013,
10463,
13075,
14184,
2065,
1006,
1013,
1012,
1032,
1013,
13075,
1032,
1013,
1013,
1012,
3231,
1006,
30524,
13075,
1032,
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... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ControlsMaster.controller.js | function() {
var oSelectedItem = this._getList().getSelectedItem();
if (oSelectedItem) {
this._toggleListItem(oSelectedItem, false);
setTimeout(this._scrollPageTo.bind(this, 0, 0), 0);
}
} | javascript | function() {
var oSelectedItem = this._getList().getSelectedItem();
if (oSelectedItem) {
this._toggleListItem(oSelectedItem, false);
setTimeout(this._scrollPageTo.bind(this, 0, 0), 0);
}
} | [
"function",
"(",
")",
"{",
"var",
"oSelectedItem",
"=",
"this",
".",
"_getList",
"(",
")",
".",
"getSelectedItem",
"(",
")",
";",
"if",
"(",
"oSelectedItem",
")",
"{",
"this",
".",
"_toggleListItem",
"(",
"oSelectedItem",
",",
"false",
")",
";",
"setTime... | Resets the given <code>List</code> selection
and scrolls to the top. | [
"Resets",
"the",
"given",
"<code",
">",
"List<",
"/",
"code",
">",
"selection",
"and",
"scrolls",
"to",
"the",
"top",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ControlsMaster.controller.js#L415-L422 | train | Toggles the selected item in the list. | [
30522,
3853,
1006,
1007,
1063,
13075,
9808,
12260,
10985,
4221,
2213,
1027,
2023,
1012,
1035,
2131,
9863,
1006,
1007,
1012,
4152,
12260,
10985,
4221,
2213,
1006,
1007,
1025,
2065,
1006,
9808,
12260,
10985,
4221,
2213,
1007,
1063,
2023,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/chart/chart.js | _isFromCodeBlockInCodeMirror | function _isFromCodeBlockInCodeMirror(cm, source, eventData) {
// cursor in codeblock in markdown editor
let fromCodeBlockInCodeMirror = source === 'markdown' && cm.getTokenAt(eventData.from).state.overlay.codeBlock;
// or codeblock editor
fromCodeBlockInCodeMirror = fromCodeBlockInCodeMirror || (source === 'codeblock');
// but not from wysiwyg
fromCodeBlockInCodeMirror = fromCodeBlockInCodeMirror && (source !== 'wysiwyg');
return fromCodeBlockInCodeMirror;
} | javascript | function _isFromCodeBlockInCodeMirror(cm, source, eventData) {
// cursor in codeblock in markdown editor
let fromCodeBlockInCodeMirror = source === 'markdown' && cm.getTokenAt(eventData.from).state.overlay.codeBlock;
// or codeblock editor
fromCodeBlockInCodeMirror = fromCodeBlockInCodeMirror || (source === 'codeblock');
// but not from wysiwyg
fromCodeBlockInCodeMirror = fromCodeBlockInCodeMirror && (source !== 'wysiwyg');
return fromCodeBlockInCodeMirror;
} | [
"function",
"_isFromCodeBlockInCodeMirror",
"(",
"cm",
",",
"source",
",",
"eventData",
")",
"{",
"// cursor in codeblock in markdown editor",
"let",
"fromCodeBlockInCodeMirror",
"=",
"source",
"===",
"'markdown'",
"&&",
"cm",
".",
"getTokenAt",
"(",
"eventData",
".",
... | determine the event is from codeblock in markdown/codeblock editor
@param {CodeMirror} cm - markdown codemirror editor
@param {string} source - event source
@param {Object} eventData - event data
@returns {boolean} - true for the event from codeblock in markdown/codeblock editor
@ignore | [
"determine",
"the",
"event",
"is",
"from",
"codeblock",
"in",
"markdown",
"/",
"codeblock",
"editor"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/chart/chart.js#L465-L474 | train | Check if the cursor is in code block in codeMirror | [
30522,
3853,
1035,
2003,
19699,
5358,
16044,
23467,
2378,
16044,
14503,
29165,
1006,
4642,
1010,
3120,
1010,
2724,
2850,
2696,
1007,
1063,
1013,
1013,
12731,
25301,
2099,
1999,
3642,
23467,
1999,
2928,
7698,
3559,
2292,
2013,
16044,
23467,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/transports/node/NodeSocketTransportDomain.js | _cmdClose | function _cmdClose(clientId) {
var client = _clients[clientId];
if (client) {
client.socket.close();
delete _clients[clientId];
}
} | javascript | function _cmdClose(clientId) {
var client = _clients[clientId];
if (client) {
client.socket.close();
delete _clients[clientId];
}
} | [
"function",
"_cmdClose",
"(",
"clientId",
")",
"{",
"var",
"client",
"=",
"_clients",
"[",
"clientId",
"]",
";",
"if",
"(",
"client",
")",
"{",
"client",
".",
"socket",
".",
"close",
"(",
")",
";",
"delete",
"_clients",
"[",
"clientId",
"]",
";",
"}"... | Closes the connection for a given client ID.
@param {number} clientId | [
"Closes",
"the",
"connection",
"for",
"a",
"given",
"client",
"ID",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/transports/node/NodeSocketTransportDomain.js#L171-L177 | train | Close the client | [
30522,
3853,
1035,
4642,
16409,
10483,
2063,
1006,
7396,
3593,
1007,
1063,
13075,
7396,
1027,
1035,
7846,
1031,
7396,
3593,
1033,
1025,
2065,
1006,
7396,
1007,
1063,
7396,
1012,
22278,
1012,
2485,
1006,
1007,
1025,
3972,
12870,
1035,
7846,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
parcel-bundler/parcel | packages/core/parcel-bundler/src/utils/getTargetEngines.js | getTargetEngines | async function getTargetEngines(asset, isTargetApp) {
let targets = {};
let path = isTargetApp
? Path.join(asset.options.rootDir, 'index')
: asset.name;
let compileTarget =
asset.options.target === 'browser' ? 'browsers' : asset.options.target;
let pkg = await asset.getConfig(['package.json'], {path});
let engines = pkg && pkg.engines;
let nodeVersion = engines && getMinSemver(engines.node);
if (compileTarget === 'node') {
// Use package.engines.node by default if we are compiling for node.
if (typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
} else {
if (
engines &&
(typeof engines.browsers === 'string' || Array.isArray(engines.browsers))
) {
targets.browsers = engines.browsers;
} else if (pkg && pkg.browserslist) {
targets.browsers = pkg.browserslist;
} else {
let browserslist = await loadBrowserslist(asset, path);
if (browserslist) {
targets.browsers = browserslist;
} else {
let babelTargets = await loadBabelrc(asset, path);
if (babelTargets && babelTargets.browsers) {
targets.browsers = babelTargets.browsers;
} else if (babelTargets && babelTargets.node && !nodeVersion) {
nodeVersion = babelTargets.node;
}
}
}
// Fall back to package.engines.node for node_modules without any browser target info.
if (!isTargetApp && !targets.browsers && typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
}
// If we didn't find any targets, set some default engines for the target app.
if (
isTargetApp &&
!targets[compileTarget] &&
DEFAULT_ENGINES[compileTarget]
) {
targets[compileTarget] = DEFAULT_ENGINES[compileTarget];
}
// Parse browser targets
if (targets.browsers) {
if (
typeof targets.browsers === 'object' &&
!Array.isArray(targets.browsers)
) {
let env = asset.options.production
? 'production'
: process.env.NODE_ENV || 'development';
targets.browsers = targets.browsers[env] || targets.browsers.defaults;
}
if (targets.browsers) {
targets.browsers = browserslist(targets.browsers).sort();
}
}
// Dont compile if we couldn't find any targets
if (Object.keys(targets).length === 0) {
return null;
}
return targets;
} | javascript | async function getTargetEngines(asset, isTargetApp) {
let targets = {};
let path = isTargetApp
? Path.join(asset.options.rootDir, 'index')
: asset.name;
let compileTarget =
asset.options.target === 'browser' ? 'browsers' : asset.options.target;
let pkg = await asset.getConfig(['package.json'], {path});
let engines = pkg && pkg.engines;
let nodeVersion = engines && getMinSemver(engines.node);
if (compileTarget === 'node') {
// Use package.engines.node by default if we are compiling for node.
if (typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
} else {
if (
engines &&
(typeof engines.browsers === 'string' || Array.isArray(engines.browsers))
) {
targets.browsers = engines.browsers;
} else if (pkg && pkg.browserslist) {
targets.browsers = pkg.browserslist;
} else {
let browserslist = await loadBrowserslist(asset, path);
if (browserslist) {
targets.browsers = browserslist;
} else {
let babelTargets = await loadBabelrc(asset, path);
if (babelTargets && babelTargets.browsers) {
targets.browsers = babelTargets.browsers;
} else if (babelTargets && babelTargets.node && !nodeVersion) {
nodeVersion = babelTargets.node;
}
}
}
// Fall back to package.engines.node for node_modules without any browser target info.
if (!isTargetApp && !targets.browsers && typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
}
// If we didn't find any targets, set some default engines for the target app.
if (
isTargetApp &&
!targets[compileTarget] &&
DEFAULT_ENGINES[compileTarget]
) {
targets[compileTarget] = DEFAULT_ENGINES[compileTarget];
}
// Parse browser targets
if (targets.browsers) {
if (
typeof targets.browsers === 'object' &&
!Array.isArray(targets.browsers)
) {
let env = asset.options.production
? 'production'
: process.env.NODE_ENV || 'development';
targets.browsers = targets.browsers[env] || targets.browsers.defaults;
}
if (targets.browsers) {
targets.browsers = browserslist(targets.browsers).sort();
}
}
// Dont compile if we couldn't find any targets
if (Object.keys(targets).length === 0) {
return null;
}
return targets;
} | [
"async",
"function",
"getTargetEngines",
"(",
"asset",
",",
"isTargetApp",
")",
"{",
"let",
"targets",
"=",
"{",
"}",
";",
"let",
"path",
"=",
"isTargetApp",
"?",
"Path",
".",
"join",
"(",
"asset",
".",
"options",
".",
"rootDir",
",",
"'index'",
")",
"... | Loads target node and browser versions from the following locations:
- package.json engines field
- package.json browserslist field
- browserslist or .browserslistrc files
- .babelrc or .babelrc.js files with @babel/preset-env | [
"Loads",
"target",
"node",
"and",
"browser",
"versions",
"from",
"the",
"following",
"locations",
":",
"-",
"package",
".",
"json",
"engines",
"field",
"-",
"package",
".",
"json",
"browserslist",
"field",
"-",
"browserslist",
"or",
".",
"browserslistrc",
"fil... | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/utils/getTargetEngines.js#L17-L93 | train | Get target engines | [
30522,
2004,
6038,
2278,
3853,
2131,
7559,
18150,
13159,
10586,
1006,
11412,
1010,
21541,
2906,
18150,
29098,
1007,
1063,
2292,
7889,
1027,
1063,
1065,
1025,
2292,
4130,
1027,
21541,
2906,
18150,
29098,
1029,
4130,
1012,
3693,
1006,
11412,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/LanguageManager.js | getCompoundFileExtension | function getCompoundFileExtension(fullPath) {
var baseName = FileUtils.getBaseName(fullPath),
parts = baseName.split(".");
// get rid of file name
parts.shift();
if (baseName[0] === ".") {
// if starts with a `.`, then still consider it as file name
parts.shift();
}
var extension = [parts.pop()], // last part is always an extension
i = parts.length;
while (i--) {
if (getLanguageForExtension(parts[i])) {
extension.unshift(parts[i]);
} else {
break;
}
}
return extension.join(".");
} | javascript | function getCompoundFileExtension(fullPath) {
var baseName = FileUtils.getBaseName(fullPath),
parts = baseName.split(".");
// get rid of file name
parts.shift();
if (baseName[0] === ".") {
// if starts with a `.`, then still consider it as file name
parts.shift();
}
var extension = [parts.pop()], // last part is always an extension
i = parts.length;
while (i--) {
if (getLanguageForExtension(parts[i])) {
extension.unshift(parts[i]);
} else {
break;
}
}
return extension.join(".");
} | [
"function",
"getCompoundFileExtension",
"(",
"fullPath",
")",
"{",
"var",
"baseName",
"=",
"FileUtils",
".",
"getBaseName",
"(",
"fullPath",
")",
",",
"parts",
"=",
"baseName",
".",
"split",
"(",
"\".\"",
")",
";",
"// get rid of file name",
"parts",
".",
"shi... | Get the file extension (excluding ".") given a path OR a bare filename.
Returns "" for names with no extension.
If the only `.` in the file is the first character,
returns "" as this is not considered an extension.
This method considers known extensions which include `.` in them.
@param {string} fullPath full path to a file or directory
@return {string} Returns the extension of a filename or empty string if
the argument is a directory or a filename with no extension | [
"Get",
"the",
"file",
"extension",
"(",
"excluding",
".",
")",
"given",
"a",
"path",
"OR",
"a",
"bare",
"filename",
".",
"Returns",
"for",
"names",
"with",
"no",
"extension",
".",
"If",
"the",
"only",
".",
"in",
"the",
"file",
"is",
"the",
"first",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/LanguageManager.js#L411-L432 | train | get the extension of a compound file | [
30522,
3853,
2131,
9006,
6873,
8630,
8873,
10559,
18413,
6132,
3258,
1006,
2440,
15069,
1007,
1063,
13075,
2918,
18442,
1027,
5371,
21823,
4877,
1012,
2131,
15058,
18442,
1006,
2440,
15069,
1007,
1010,
3033,
1027,
2918,
18442,
1012,
3975,
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... |
jgraph/mxgraph | javascript/mxClient.js | function(parent, text, editor, functName, arg, pad)
{
return mxUtils.link(parent, text, function()
{
editor[functName](arg);
}, pad);
} | javascript | function(parent, text, editor, functName, arg, pad)
{
return mxUtils.link(parent, text, function()
{
editor[functName](arg);
}, pad);
} | [
"function",
"(",
"parent",
",",
"text",
",",
"editor",
",",
"functName",
",",
"arg",
",",
"pad",
")",
"{",
"return",
"mxUtils",
".",
"link",
"(",
"parent",
",",
"text",
",",
"function",
"(",
")",
"{",
"editor",
"[",
"functName",
"]",
"(",
"arg",
")... | Function: linkInvoke
Adds a hyperlink to the specified parent that invokes the specified
function on the editor passing along the specified argument. The
function name is the name of a function of the editor instance,
not an action name.
Parameters:
parent - DOM node to contain the new link.
text - String that is used as the link label.
editor - <mxEditor> instance to execute the function on.
functName - String that represents the name of the function.
arg - Object that represents the argument to the function.
pad - Optional left-padding for the link. Default is 0. | [
"Function",
":",
"linkInvoke"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3428-L3434 | train | Internal function to link a function to a parent node | [
30522,
3853,
1006,
6687,
1010,
3793,
1010,
3559,
1010,
4569,
6593,
18442,
1010,
12098,
2290,
1010,
11687,
1007,
1063,
2709,
25630,
21823,
4877,
1012,
4957,
1006,
6687,
1010,
3793,
1010,
3853,
1006,
1007,
1063,
3559,
1031,
4569,
6593,
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... | |
adobe/brackets | src/command/CommandManager.js | Command | function Command(name, id, commandFn) {
this._name = name;
this._id = id;
this._commandFn = commandFn;
this._checked = undefined;
this._enabled = true;
} | javascript | function Command(name, id, commandFn) {
this._name = name;
this._id = id;
this._commandFn = commandFn;
this._checked = undefined;
this._enabled = true;
} | [
"function",
"Command",
"(",
"name",
",",
"id",
",",
"commandFn",
")",
"{",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"_id",
"=",
"id",
";",
"this",
".",
"_commandFn",
"=",
"commandFn",
";",
"this",
".",
"_checked",
"=",
"undefined",
";",
... | Events:
- enabledStateChange
- checkedStateChange
- keyBindingAdded
- keyBindingRemoved
@constructor
@private
@param {string} name - text that will be displayed in the UI to represent command
@param {string} id
@param {function} commandFn - the function that is called when the command is executed.
TODO: where should this be triggered, The Command or Exports? | [
"Events",
":",
"-",
"enabledStateChange",
"-",
"checkedStateChange",
"-",
"keyBindingAdded",
"-",
"keyBindingRemoved"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/CommandManager.js#L66-L72 | train | A command is a container for a resource | [
30522,
3853,
3094,
1006,
2171,
1010,
8909,
1010,
3094,
2546,
2078,
1007,
1063,
2023,
1012,
1035,
2171,
1027,
2171,
1025,
2023,
1012,
1035,
8909,
1027,
8909,
1025,
2023,
1012,
1035,
3094,
2546,
2078,
1027,
3094,
2546,
2078,
1025,
2023,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Parser.js | tokenizeSingleQuotedString | function tokenizeSingleQuotedString(sNext, sOption, iAt) {
var i;
function nextChar(bConsume) {
var c = sNext[i];
if (c === "%" && sNext[i + 1] === "2" && sNext[i + 2] === "7") {
c = "'";
if (bConsume) {
i += 2;
}
}
if (bConsume) {
i += 1;
}
return c;
}
for (i = 1; i < sNext.length; ) {
if (nextChar(true) === "'") {
if (nextChar(false) !== "'") {
return sNext.slice(0, i);
}
nextChar(true); // consume 2nd quote
}
}
throw new SyntaxError("Unterminated string at " + iAt + ": " + sOption);
} | javascript | function tokenizeSingleQuotedString(sNext, sOption, iAt) {
var i;
function nextChar(bConsume) {
var c = sNext[i];
if (c === "%" && sNext[i + 1] === "2" && sNext[i + 2] === "7") {
c = "'";
if (bConsume) {
i += 2;
}
}
if (bConsume) {
i += 1;
}
return c;
}
for (i = 1; i < sNext.length; ) {
if (nextChar(true) === "'") {
if (nextChar(false) !== "'") {
return sNext.slice(0, i);
}
nextChar(true); // consume 2nd quote
}
}
throw new SyntaxError("Unterminated string at " + iAt + ": " + sOption);
} | [
"function",
"tokenizeSingleQuotedString",
"(",
"sNext",
",",
"sOption",
",",
"iAt",
")",
"{",
"var",
"i",
";",
"function",
"nextChar",
"(",
"bConsume",
")",
"{",
"var",
"c",
"=",
"sNext",
"[",
"i",
"]",
";",
"if",
"(",
"c",
"===",
"\"%\"",
"&&",
"sNe... | Tokenizes a string starting and ending with a single quote (which may be %-encoded).
A contained single quote is escaped by doubling it.
@param {string} sNext The untokenized input starting with the opening quote
@param {string} sOption The option string (for an error message)
@param {number} iAt The position in the option string (for an error message)
@returns {string} The unconverted string including the quotes. | [
"Tokenizes",
"a",
"string",
"starting",
"and",
"ending",
"with",
"a",
"single",
"quote",
"(",
"which",
"may",
"be",
"%",
"-",
"encoded",
")",
".",
"A",
"contained",
"single",
"quote",
"is",
"escaped",
"by",
"doubling",
"it",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Parser.js#L617-L644 | train | tokenizes a single quoted string | [
30522,
3853,
19204,
10057,
2075,
2571,
28940,
27428,
3367,
4892,
1006,
1055,
2638,
18413,
1010,
2061,
16790,
1010,
24264,
2102,
1007,
1063,
13075,
1045,
1025,
3853,
2279,
7507,
2099,
1006,
4647,
5644,
17897,
1007,
1063,
13075,
1039,
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... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/changeHandler/BaseRename.js | function(oChange, mSpecificChangeInfo, mPropertyBag) {
var oChangeDefinition = oChange.getDefinition();
var sChangePropertyName = mRenameSettings.changePropertyName;
var sTranslationTextType = mRenameSettings.translationTextType;
var oControlToBeRenamed = mPropertyBag.modifier.bySelector(oChange.getSelector(), mPropertyBag.appComponent);
oChangeDefinition.content.originalControlType = mPropertyBag.modifier.getControlType(oControlToBeRenamed);
if (typeof (mSpecificChangeInfo.value) === "string") {
Base.setTextInChange(oChangeDefinition, sChangePropertyName, mSpecificChangeInfo.value, sTranslationTextType);
} else {
throw new Error("oSpecificChangeInfo.value attribute required");
}
} | javascript | function(oChange, mSpecificChangeInfo, mPropertyBag) {
var oChangeDefinition = oChange.getDefinition();
var sChangePropertyName = mRenameSettings.changePropertyName;
var sTranslationTextType = mRenameSettings.translationTextType;
var oControlToBeRenamed = mPropertyBag.modifier.bySelector(oChange.getSelector(), mPropertyBag.appComponent);
oChangeDefinition.content.originalControlType = mPropertyBag.modifier.getControlType(oControlToBeRenamed);
if (typeof (mSpecificChangeInfo.value) === "string") {
Base.setTextInChange(oChangeDefinition, sChangePropertyName, mSpecificChangeInfo.value, sTranslationTextType);
} else {
throw new Error("oSpecificChangeInfo.value attribute required");
}
} | [
"function",
"(",
"oChange",
",",
"mSpecificChangeInfo",
",",
"mPropertyBag",
")",
"{",
"var",
"oChangeDefinition",
"=",
"oChange",
".",
"getDefinition",
"(",
")",
";",
"var",
"sChangePropertyName",
"=",
"mRenameSettings",
".",
"changePropertyName",
";",
"var",
"sT... | Completes the change by adding change handler specific content
@param {sap.ui.fl.Change} oChange change wrapper object to be completed
@param {object} mSpecificChangeInfo with attribute (e.g. textLabel) to be included in the change
@public | [
"Completes",
"the",
"change",
"by",
"adding",
"change",
"handler",
"specific",
"content"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/changeHandler/BaseRename.js#L94-L107 | train | Sets the change s text in the change definition | [
30522,
3853,
1006,
28166,
22043,
1010,
5796,
5051,
6895,
8873,
9468,
18003,
12377,
14876,
1010,
6131,
18981,
15010,
16078,
1007,
1063,
13075,
28166,
22043,
3207,
16294,
22753,
1027,
28166,
22043,
1012,
2131,
3207,
16294,
22753,
1006,
1007,
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... | |
eslint/eslint | lib/rules/no-bitwise.js | isInt32Hint | function isInt32Hint(node) {
return int32Hint && node.operator === "|" && node.right &&
node.right.type === "Literal" && node.right.value === 0;
} | javascript | function isInt32Hint(node) {
return int32Hint && node.operator === "|" && node.right &&
node.right.type === "Literal" && node.right.value === 0;
} | [
"function",
"isInt32Hint",
"(",
"node",
")",
"{",
"return",
"int32Hint",
"&&",
"node",
".",
"operator",
"===",
"\"|\"",
"&&",
"node",
".",
"right",
"&&",
"node",
".",
"right",
".",
"type",
"===",
"\"Literal\"",
"&&",
"node",
".",
"right",
".",
"value",
... | Checks if the given bitwise operator is used for integer typecasting, i.e. "|0"
@param {ASTNode} node The node to check.
@returns {boolean} whether the node is used in integer typecasting. | [
"Checks",
"if",
"the",
"given",
"bitwise",
"operator",
"is",
"used",
"for",
"integer",
"typecasting",
"i",
".",
"e",
".",
"|0"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-bitwise.js#L96-L99 | train | Check if a node is an integer hint | [
30522,
3853,
2003,
18447,
16703,
10606,
2102,
1006,
13045,
1007,
1063,
2709,
20014,
16703,
10606,
2102,
1004,
1004,
13045,
1012,
6872,
1027,
1027,
1027,
1000,
1064,
1000,
1004,
1004,
13045,
1012,
2157,
1004,
1004,
13045,
1012,
2157,
1012,
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.fl/src/sap/ui/fl/Utils.js | function (oControl) {
var sFlexReference = Utils.getComponentClassName(oControl);
var oAppComponent = Utils.getAppComponentForControl(oControl);
var sComponentName = Utils.getComponentName(oAppComponent);
return sFlexReference !== sComponentName;
} | javascript | function (oControl) {
var sFlexReference = Utils.getComponentClassName(oControl);
var oAppComponent = Utils.getAppComponentForControl(oControl);
var sComponentName = Utils.getComponentName(oAppComponent);
return sFlexReference !== sComponentName;
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"sFlexReference",
"=",
"Utils",
".",
"getComponentClassName",
"(",
"oControl",
")",
";",
"var",
"oAppComponent",
"=",
"Utils",
".",
"getAppComponentForControl",
"(",
"oControl",
")",
";",
"var",
"sComponentName",
"="... | Indicates if the current application is a variant of an existing one
@param {sap.ui.core.Control} oControl - SAPUI5 control
@returns {boolean} true if it's an application variant
@public
@function
@name sap.ui.fl.Utils.isApplicationVariant | [
"Indicates",
"if",
"the",
"current",
"application",
"is",
"a",
"variant",
"of",
"an",
"existing",
"one"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L350-L355 | train | Returns true if the control is a component of a Flex component. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
16420,
2571,
2595,
2890,
25523,
1027,
21183,
12146,
1012,
2131,
9006,
29513,
3372,
26266,
18442,
1006,
1051,
8663,
13181,
2140,
1007,
1025,
13075,
1051,
29098,
9006,
29513,
3372,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/api/v0.1/users.js | doQuery | function doQuery(options) {
return models.User.transferOwnership(options.data.owner[0], _.omit(options, ['data']))
.then((models) => {
return {
users: models.toJSON(_.omit(options, ['data']))
};
});
} | javascript | function doQuery(options) {
return models.User.transferOwnership(options.data.owner[0], _.omit(options, ['data']))
.then((models) => {
return {
users: models.toJSON(_.omit(options, ['data']))
};
});
} | [
"function",
"doQuery",
"(",
"options",
")",
"{",
"return",
"models",
".",
"User",
".",
"transferOwnership",
"(",
"options",
".",
"data",
".",
"owner",
"[",
"0",
"]",
",",
"_",
".",
"omit",
"(",
"options",
",",
"[",
"'data'",
"]",
")",
")",
".",
"th... | ### Model Query
Make the call to the Model layer
@param {Object} options
@returns {Object} options | [
"###",
"Model",
"Query",
"Make",
"the",
"call",
"to",
"the",
"Model",
"layer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/users.js#L330-L337 | train | This function is called by the query engine to get the users | [
30522,
3853,
2079,
4226,
2854,
1006,
7047,
1007,
1063,
2709,
4275,
1012,
5310,
1012,
4651,
12384,
2545,
5605,
1006,
7047,
1012,
2951,
1012,
3954,
1031,
1014,
1033,
1010,
1035,
1012,
18168,
4183,
1006,
7047,
1010,
1031,
1005,
2951,
1005,
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... |
adobe/brackets | src/extensibility/ExtensionManager.js | cleanupUpdates | function cleanupUpdates() {
Object.keys(_idsToUpdate).forEach(function (id) {
var installResult = _idsToUpdate[id],
keepFile = installResult.keepFile,
filename = installResult.localPath;
if (filename && !keepFile) {
FileSystem.getFileForPath(filename).unlink();
}
});
_idsToUpdate = {};
} | javascript | function cleanupUpdates() {
Object.keys(_idsToUpdate).forEach(function (id) {
var installResult = _idsToUpdate[id],
keepFile = installResult.keepFile,
filename = installResult.localPath;
if (filename && !keepFile) {
FileSystem.getFileForPath(filename).unlink();
}
});
_idsToUpdate = {};
} | [
"function",
"cleanupUpdates",
"(",
")",
"{",
"Object",
".",
"keys",
"(",
"_idsToUpdate",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"installResult",
"=",
"_idsToUpdate",
"[",
"id",
"]",
",",
"keepFile",
"=",
"installResult",
".",
"... | Deletes any temporary files left behind by extensions that
were marked for update. | [
"Deletes",
"any",
"temporary",
"files",
"left",
"behind",
"by",
"extensions",
"that",
"were",
"marked",
"for",
"update",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L486-L497 | train | Cleanups the update files | [
30522,
3853,
27686,
6279,
27122,
1006,
1007,
1063,
4874,
1012,
6309,
1006,
1035,
8909,
16033,
6279,
13701,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
8909,
1007,
1063,
13075,
16500,
6072,
11314,
1027,
1035,
8909,
16033,
6279,
13701,
1031,
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... |
angular/material | src/core/util/util.js | function(element) {
// For SVG or Symbol elements, innerHTML returns `undefined` in IE.
// Reference: https://stackoverflow.com/q/28129956/633107
// The XMLSerializer API is supported on IE11 and is the recommended workaround.
var serializer = new XMLSerializer();
return Array.prototype.map.call(element.childNodes, function (child) {
return serializer.serializeToString(child);
}).join('');
} | javascript | function(element) {
// For SVG or Symbol elements, innerHTML returns `undefined` in IE.
// Reference: https://stackoverflow.com/q/28129956/633107
// The XMLSerializer API is supported on IE11 and is the recommended workaround.
var serializer = new XMLSerializer();
return Array.prototype.map.call(element.childNodes, function (child) {
return serializer.serializeToString(child);
}).join('');
} | [
"function",
"(",
"element",
")",
"{",
"// For SVG or Symbol elements, innerHTML returns `undefined` in IE.",
"// Reference: https://stackoverflow.com/q/28129956/633107",
"// The XMLSerializer API is supported on IE11 and is the recommended workaround.",
"var",
"serializer",
"=",
"new",
"XMLS... | Gets the inner HTML content of the given HTMLElement.
Only intended for use with SVG or Symbol elements in IE11.
@param {Element} element
@returns {string} the inner HTML of the element passed in | [
"Gets",
"the",
"inner",
"HTML",
"content",
"of",
"the",
"given",
"HTMLElement",
".",
"Only",
"intended",
"for",
"use",
"with",
"SVG",
"or",
"Symbol",
"elements",
"in",
"IE11",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L881-L890 | train | Returns the XML representation of the specified element. | [
30522,
3853,
1006,
5783,
1007,
1063,
1013,
1013,
2005,
17917,
2290,
2030,
6454,
3787,
1010,
5110,
11039,
19968,
5651,
1036,
6151,
28344,
1036,
1999,
29464,
1012,
1013,
1013,
4431,
1024,
16770,
1024,
1013,
1013,
9991,
7840,
12314,
1012,
4012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Graph.js | Edge | function Edge(n1, n2, dataIndex) {
/**
* 节点1,如果是有向图则为源节点
* @type {module:echarts/data/Graph.Node}
*/
this.node1 = n1;
/**
* 节点2,如果是有向图则为目标节点
* @type {module:echarts/data/Graph.Node}
*/
this.node2 = n2;
this.dataIndex = dataIndex == null ? -1 : dataIndex;
} | javascript | function Edge(n1, n2, dataIndex) {
/**
* 节点1,如果是有向图则为源节点
* @type {module:echarts/data/Graph.Node}
*/
this.node1 = n1;
/**
* 节点2,如果是有向图则为目标节点
* @type {module:echarts/data/Graph.Node}
*/
this.node2 = n2;
this.dataIndex = dataIndex == null ? -1 : dataIndex;
} | [
"function",
"Edge",
"(",
"n1",
",",
"n2",
",",
"dataIndex",
")",
"{",
"/**\n * 节点1,如果是有向图则为源节点\n * @type {module:echarts/data/Graph.Node}\n */",
"this",
".",
"node1",
"=",
"n1",
";",
"/**\n * 节点2,如果是有向图则为目标节点\n * @type {module:echarts/data/Graph.Node}\n */",... | 图边
@alias module:echarts/data/Graph.Edge
@param {module:echarts/data/Graph.Node} n1
@param {module:echarts/data/Graph.Node} n2
@param {number} [dataIndex=-1] | [
"图边"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/data/Graph.js#L443-L458 | train | Edge constructor. | [
30522,
3853,
3341,
1006,
1050,
2487,
1010,
1050,
2475,
1010,
2951,
22254,
10288,
1007,
1063,
1013,
1008,
1008,
1008,
100,
100,
1015,
1989,
100,
100,
100,
1873,
100,
100,
100,
100,
100,
100,
100,
1008,
1030,
2828,
1063,
11336,
1024,
1492... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_ColInfo | function parse_ColInfo(blob, length, opts) {
if(!opts.cellStyles) return parsenoop(blob, length);
var w = opts && opts.biff >= 12 ? 4 : 2;
var colFirst = blob.read_shift(w);
var colLast = blob.read_shift(w);
var coldx = blob.read_shift(w);
var ixfe = blob.read_shift(w);
var flags = blob.read_shift(2);
if(w == 2) blob.l += 2;
return {s:colFirst, e:colLast, w:coldx, ixfe:ixfe, flags:flags};
} | javascript | function parse_ColInfo(blob, length, opts) {
if(!opts.cellStyles) return parsenoop(blob, length);
var w = opts && opts.biff >= 12 ? 4 : 2;
var colFirst = blob.read_shift(w);
var colLast = blob.read_shift(w);
var coldx = blob.read_shift(w);
var ixfe = blob.read_shift(w);
var flags = blob.read_shift(2);
if(w == 2) blob.l += 2;
return {s:colFirst, e:colLast, w:coldx, ixfe:ixfe, flags:flags};
} | [
"function",
"parse_ColInfo",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
".",
"cellStyles",
")",
"return",
"parsenoop",
"(",
"blob",
",",
"length",
")",
";",
"var",
"w",
"=",
"opts",
"&&",
"opts",
".",
"biff",
">=",
"... | /* [MS-XLS] 2.4.53 TODO: parse flags /* [MS-XLSB] 2.4.323 TODO: parse flags | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"53",
"TODO",
":",
"parse",
"flags",
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"323",
"TODO",
":",
"parse",
"flags"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6507-L6517 | train | Parse a cellInfo object | [
30522,
3853,
11968,
3366,
1035,
6972,
14876,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
999,
23569,
2015,
1012,
4442,
27983,
2015,
1007,
2709,
11968,
5054,
18589,
1006,
1038,
4135,
2497,
1010,
3091,
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... |
electron/electron | lib/sandboxed_renderer/init.js | runPreloadScript | function runPreloadScript (preloadSrc) {
const preloadWrapperSrc = `(function(require, process, Buffer, global, setImmediate, clearImmediate, exports) {
${preloadSrc}
})`
// eval in window scope
const preloadFn = binding.createPreloadScript(preloadWrapperSrc)
const { setImmediate, clearImmediate } = require('timers')
preloadFn(preloadRequire, preloadProcess, Buffer, global, setImmediate, clearImmediate, {})
} | javascript | function runPreloadScript (preloadSrc) {
const preloadWrapperSrc = `(function(require, process, Buffer, global, setImmediate, clearImmediate, exports) {
${preloadSrc}
})`
// eval in window scope
const preloadFn = binding.createPreloadScript(preloadWrapperSrc)
const { setImmediate, clearImmediate } = require('timers')
preloadFn(preloadRequire, preloadProcess, Buffer, global, setImmediate, clearImmediate, {})
} | [
"function",
"runPreloadScript",
"(",
"preloadSrc",
")",
"{",
"const",
"preloadWrapperSrc",
"=",
"`",
"${",
"preloadSrc",
"}",
"`",
"// eval in window scope",
"const",
"preloadFn",
"=",
"binding",
".",
"createPreloadScript",
"(",
"preloadWrapperSrc",
")",
"const",
"{... | Wrap the script into a function executed in global scope. It won't have access to the current scope, so we'll expose a few objects as arguments: - `require`: The `preloadRequire` function - `process`: The `preloadProcess` object - `Buffer`: Browserify `Buffer` implementation - `global`: The window object, which is aliased to `global` by browserify. Browserify bundles can make use of an external require function as explained in https://github.com/substack/node-browserify#multiple-bundles, so electron apps can use multi-module preload scripts in sandboxed renderers. For example, the user can create a bundle with: $ browserify -x electron preload.js > renderer.js and any `require('electron')` calls in `preload.js` will work as expected since browserify won't try to include `electron` in the bundle, falling back to the `preloadRequire` function above. | [
"Wrap",
"the",
"script",
"into",
"a",
"function",
"executed",
"in",
"global",
"scope",
".",
"It",
"won",
"t",
"have",
"access",
"to",
"the",
"current",
"scope",
"so",
"we",
"ll",
"expose",
"a",
"few",
"objects",
"as",
"arguments",
":",
"-",
"require",
... | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/sandboxed_renderer/init.js#L160-L170 | train | Runs the script in the window scope | [
30522,
3853,
2448,
28139,
11066,
22483,
1006,
3653,
11066,
21338,
2278,
1007,
1063,
9530,
3367,
3653,
11066,
13088,
29098,
2545,
11890,
1027,
1036,
1006,
3853,
1006,
5478,
1010,
2832,
1010,
17698,
1010,
3795,
1010,
2275,
5714,
16969,
2618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/filesystem/impls/appshell/AppshellFileSystem.js | rename | function rename(oldPath, newPath, callback) {
appshell.fs.rename(oldPath, newPath, _wrap(callback));
} | javascript | function rename(oldPath, newPath, callback) {
appshell.fs.rename(oldPath, newPath, _wrap(callback));
} | [
"function",
"rename",
"(",
"oldPath",
",",
"newPath",
",",
"callback",
")",
"{",
"appshell",
".",
"fs",
".",
"rename",
"(",
"oldPath",
",",
"newPath",
",",
"_wrap",
"(",
"callback",
")",
")",
";",
"}"
] | Rename the file or directory at oldPath to newPath, and call back
asynchronously with a possibly null FileSystemError string.
@param {string} oldPath
@param {string} newPath
@param {function(?string)=} callback | [
"Rename",
"the",
"file",
"or",
"directory",
"at",
"oldPath",
"to",
"newPath",
"and",
"call",
"back",
"asynchronously",
"with",
"a",
"possibly",
"null",
"FileSystemError",
"string",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L343-L345 | train | Rename a file or directory | [
30522,
3853,
14916,
14074,
1006,
2214,
15069,
1010,
2047,
15069,
1010,
2655,
5963,
1007,
1063,
18726,
18223,
1012,
1042,
2015,
1012,
14916,
14074,
1006,
2214,
15069,
1010,
2047,
15069,
1010,
1035,
10236,
1006,
2655,
5963,
1007,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/transports/node/NodeSocketTransportDomain.js | _cmdSend | function _cmdSend(idOrArray, msgStr) {
if (!Array.isArray(idOrArray)) {
idOrArray = [idOrArray];
}
idOrArray.forEach(function (id) {
var client = _clients[id];
if (!client) {
console.error("nodeSocketTransport: Couldn't find client ID: " + id);
} else {
client.socket.send(msgStr);
}
});
} | javascript | function _cmdSend(idOrArray, msgStr) {
if (!Array.isArray(idOrArray)) {
idOrArray = [idOrArray];
}
idOrArray.forEach(function (id) {
var client = _clients[id];
if (!client) {
console.error("nodeSocketTransport: Couldn't find client ID: " + id);
} else {
client.socket.send(msgStr);
}
});
} | [
"function",
"_cmdSend",
"(",
"idOrArray",
",",
"msgStr",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"idOrArray",
")",
")",
"{",
"idOrArray",
"=",
"[",
"idOrArray",
"]",
";",
"}",
"idOrArray",
".",
"forEach",
"(",
"function",
"(",
"id",
"... | Sends a transport-layer message over the socket.
@param {number|Array.<number>} idOrArray A client ID or array of client IDs to send the message to.
@param {string} msgStr The message to send as a JSON string. | [
"Sends",
"a",
"transport",
"-",
"layer",
"message",
"over",
"the",
"socket",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/transports/node/NodeSocketTransportDomain.js#L153-L165 | train | send a message to the node socket | [
30522,
3853,
1035,
4642,
5104,
10497,
1006,
8909,
6525,
11335,
2100,
1010,
5796,
5620,
16344,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
8909,
6525,
11335,
2100,
1007,
1007,
1063,
8909,
6525,
11335,
2100,
1027,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/helper/fileToOutput.js | fileToOutput | function fileToOutput(output, filePath) {
var book = output.getBook();
var readme = book.getReadme();
var fileReadme = readme.getFile();
if (
path.basename(filePath, path.extname(filePath)) == 'README' ||
(fileReadme.exists() && filePath == fileReadme.getPath())
) {
filePath = path.join(path.dirname(filePath), 'index' + OUTPUT_EXTENSION);
} else {
filePath = PathUtils.setExtension(filePath, OUTPUT_EXTENSION);
}
return LocationUtils.normalize(filePath);
} | javascript | function fileToOutput(output, filePath) {
var book = output.getBook();
var readme = book.getReadme();
var fileReadme = readme.getFile();
if (
path.basename(filePath, path.extname(filePath)) == 'README' ||
(fileReadme.exists() && filePath == fileReadme.getPath())
) {
filePath = path.join(path.dirname(filePath), 'index' + OUTPUT_EXTENSION);
} else {
filePath = PathUtils.setExtension(filePath, OUTPUT_EXTENSION);
}
return LocationUtils.normalize(filePath);
} | [
"function",
"fileToOutput",
"(",
"output",
",",
"filePath",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"readme",
"=",
"book",
".",
"getReadme",
"(",
")",
";",
"var",
"fileReadme",
"=",
"readme",
".",
"getFile",
"(",
... | Convert a filePath (absolute) to a filename for output
@param {Output} output
@param {String} filePath
@return {String} | [
"Convert",
"a",
"filePath",
"(",
"absolute",
")",
"to",
"a",
"filename",
"for",
"output"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/helper/fileToOutput.js#L15-L30 | train | Get the path to the file to output | [
30522,
3853,
5371,
3406,
5833,
18780,
1006,
6434,
1010,
5371,
15069,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
3191,
4168,
1027,
2338,
1012,
2131,
16416,
22117,
2063,
1006,
1007,
1025,
13075,
5371,
1641... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/dateLocaleProvider.js | defaultFormatDate | function defaultFormatDate(date, timezone) {
if (!date) {
return '';
}
// All of the dates created through ng-material *should* be set to midnight.
// If we encounter a date where the localeTime shows at 11pm instead of midnight,
// we have run into an issue with DST where we need to increment the hour by one:
// var d = new Date(1992, 9, 8, 0, 0, 0);
// d.toLocaleString(); // == "10/7/1992, 11:00:00 PM"
var localeTime = date.toLocaleTimeString();
var formatDate = date;
if (date.getHours() === 0 &&
(localeTime.indexOf('11:') !== -1 || localeTime.indexOf('23:') !== -1)) {
formatDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 1, 0, 0);
}
return $filter('date')(formatDate, 'M/d/yyyy', timezone);
} | javascript | function defaultFormatDate(date, timezone) {
if (!date) {
return '';
}
// All of the dates created through ng-material *should* be set to midnight.
// If we encounter a date where the localeTime shows at 11pm instead of midnight,
// we have run into an issue with DST where we need to increment the hour by one:
// var d = new Date(1992, 9, 8, 0, 0, 0);
// d.toLocaleString(); // == "10/7/1992, 11:00:00 PM"
var localeTime = date.toLocaleTimeString();
var formatDate = date;
if (date.getHours() === 0 &&
(localeTime.indexOf('11:') !== -1 || localeTime.indexOf('23:') !== -1)) {
formatDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 1, 0, 0);
}
return $filter('date')(formatDate, 'M/d/yyyy', timezone);
} | [
"function",
"defaultFormatDate",
"(",
"date",
",",
"timezone",
")",
"{",
"if",
"(",
"!",
"date",
")",
"{",
"return",
"''",
";",
"}",
"// All of the dates created through ng-material *should* be set to midnight.",
"// If we encounter a date where the localeTime shows at 11pm ins... | Default date-to-string formatting function.
@param {!Date} date
@param {string=} timezone
@returns {string} | [
"Default",
"date",
"-",
"to",
"-",
"string",
"formatting",
"function",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/dateLocaleProvider.js#L195-L213 | train | Default date formatter | [
30522,
3853,
12398,
14192,
4017,
13701,
1006,
3058,
1010,
2051,
15975,
1007,
1063,
2065,
1006,
999,
3058,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
1013,
1013,
2035,
1997,
1996,
5246,
2580,
2083,
30524,
2102,
2073,
2057,
2342,
2000,
4297,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/signals.js | function (listener, context) {
validateListener(listener, 'remove');
var i = this._indexOfListener(listener, context);
if (i !== -1) {
this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal
this._bindings.splice(i, 1);
}
return listener;
} | javascript | function (listener, context) {
validateListener(listener, 'remove');
var i = this._indexOfListener(listener, context);
if (i !== -1) {
this._bindings[i]._destroy(); //no reason to a SignalBinding exist if it isn't attached to a signal
this._bindings.splice(i, 1);
}
return listener;
} | [
"function",
"(",
"listener",
",",
"context",
")",
"{",
"validateListener",
"(",
"listener",
",",
"'remove'",
")",
";",
"var",
"i",
"=",
"this",
".",
"_indexOfListener",
"(",
"listener",
",",
"context",
")",
";",
"if",
"(",
"i",
"!==",
"-",
"1",
")",
... | Remove a single listener from the dispatch queue.
@param {Function} listener Handler function that should be removed.
@param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
@return {Function} Listener handler function. | [
"Remove",
"a",
"single",
"listener",
"from",
"the",
"dispatch",
"queue",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/signals.js#L319-L328 | train | Remove a listener from the signal cache | [
30522,
3853,
1006,
19373,
1010,
6123,
1007,
1063,
9398,
3686,
9863,
24454,
1006,
19373,
1010,
1005,
6366,
1005,
1007,
1025,
13075,
1045,
1027,
2023,
1012,
1035,
5950,
11253,
9863,
24454,
1006,
19373,
1010,
6123,
1007,
1025,
2065,
1006,
1045... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/shaders/standard.js | function (data) {
var key;
var material = this.material;
getMaterialData(data, this.materialData);
this.rendererSystem.applyColorCorrection(this.materialData.color);
this.rendererSystem.applyColorCorrection(this.materialData.emissive);
for (key in this.materialData) {
material[key] = this.materialData[key];
}
} | javascript | function (data) {
var key;
var material = this.material;
getMaterialData(data, this.materialData);
this.rendererSystem.applyColorCorrection(this.materialData.color);
this.rendererSystem.applyColorCorrection(this.materialData.emissive);
for (key in this.materialData) {
material[key] = this.materialData[key];
}
} | [
"function",
"(",
"data",
")",
"{",
"var",
"key",
";",
"var",
"material",
"=",
"this",
".",
"material",
";",
"getMaterialData",
"(",
"data",
",",
"this",
".",
"materialData",
")",
";",
"this",
".",
"rendererSystem",
".",
"applyColorCorrection",
"(",
"this",... | Updating existing material.
@param {object} data - Material component data.
@returns {object} Material. | [
"Updating",
"existing",
"material",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/shaders/standard.js#L95-L104 | train | This function is called by the renderer to update the material data | [
30522,
3853,
1006,
2951,
1007,
1063,
13075,
3145,
1025,
13075,
3430,
1027,
2023,
1012,
3430,
1025,
2131,
8585,
14482,
2850,
2696,
1006,
2951,
1010,
2023,
1012,
3430,
2850,
2696,
1007,
1025,
2023,
1012,
17552,
2545,
27268,
6633,
1012,
6611,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
getinsomnia/insomnia | packages/insomnia-app/app/account/crypt.js | _pbkdf2Passphrase | async function _pbkdf2Passphrase(passphrase, salt) {
if (window.crypto && window.crypto.subtle) {
console.log('[crypt] Using native PBKDF2');
const k = await window.crypto.subtle.importKey(
'raw',
Buffer.from(passphrase, 'utf8'),
{ name: 'PBKDF2' },
false,
['deriveBits'],
);
const algo = {
name: 'PBKDF2',
salt: Buffer.from(salt, 'hex'),
iterations: DEFAULT_PBKDF2_ITERATIONS,
hash: 'SHA-256',
};
const derivedKeyRaw = await window.crypto.subtle.deriveBits(algo, k, DEFAULT_BYTE_LENGTH * 8);
return Buffer.from(derivedKeyRaw).toString('hex');
} else {
console.log('[crypt] Using Forge PBKDF2');
const derivedKeyRaw = forge.pkcs5.pbkdf2(
passphrase,
forge.util.hexToBytes(salt),
DEFAULT_PBKDF2_ITERATIONS,
DEFAULT_BYTE_LENGTH,
forge.md.sha256.create(),
);
return forge.util.bytesToHex(derivedKeyRaw);
}
} | javascript | async function _pbkdf2Passphrase(passphrase, salt) {
if (window.crypto && window.crypto.subtle) {
console.log('[crypt] Using native PBKDF2');
const k = await window.crypto.subtle.importKey(
'raw',
Buffer.from(passphrase, 'utf8'),
{ name: 'PBKDF2' },
false,
['deriveBits'],
);
const algo = {
name: 'PBKDF2',
salt: Buffer.from(salt, 'hex'),
iterations: DEFAULT_PBKDF2_ITERATIONS,
hash: 'SHA-256',
};
const derivedKeyRaw = await window.crypto.subtle.deriveBits(algo, k, DEFAULT_BYTE_LENGTH * 8);
return Buffer.from(derivedKeyRaw).toString('hex');
} else {
console.log('[crypt] Using Forge PBKDF2');
const derivedKeyRaw = forge.pkcs5.pbkdf2(
passphrase,
forge.util.hexToBytes(salt),
DEFAULT_PBKDF2_ITERATIONS,
DEFAULT_BYTE_LENGTH,
forge.md.sha256.create(),
);
return forge.util.bytesToHex(derivedKeyRaw);
}
} | [
"async",
"function",
"_pbkdf2Passphrase",
"(",
"passphrase",
",",
"salt",
")",
"{",
"if",
"(",
"window",
".",
"crypto",
"&&",
"window",
".",
"crypto",
".",
"subtle",
")",
"{",
"console",
".",
"log",
"(",
"'[crypt] Using native PBKDF2'",
")",
";",
"const",
... | Derive key from password
@param passphrase
@param salt hex representation of salt | [
"Derive",
"key",
"from",
"password"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-app/app/account/crypt.js#L346-L379 | train | PBKDF2 - based implementation | [
30522,
2004,
6038,
2278,
3853,
1035,
1052,
2497,
2243,
20952,
2475,
15194,
8458,
23797,
1006,
3413,
8458,
23797,
1010,
5474,
1007,
1063,
2065,
1006,
3332,
1012,
19888,
2080,
1004,
1004,
3332,
1012,
19888,
2080,
1012,
11259,
1007,
1063,
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... |
GitbookIO/gitbook | lib/output/prepareAssets.js | prepareAssets | function prepareAssets(output) {
var book = output.getBook();
var pages = output.getPages();
var logger = output.getLogger();
return Parse.listAssets(book, pages)
.then(function(assets) {
logger.info.ln('found', assets.size, 'asset files');
return output.set('assets', assets);
});
} | javascript | function prepareAssets(output) {
var book = output.getBook();
var pages = output.getPages();
var logger = output.getLogger();
return Parse.listAssets(book, pages)
.then(function(assets) {
logger.info.ln('found', assets.size, 'asset files');
return output.set('assets', assets);
});
} | [
"function",
"prepareAssets",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"pages",
"=",
"output",
".",
"getPages",
"(",
")",
";",
"var",
"logger",
"=",
"output",
".",
"getLogger",
"(",
")",
";",
"return... | List all assets in the book
@param {Output}
@return {Promise<Output>} | [
"List",
"all",
"assets",
"in",
"the",
"book"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/prepareAssets.js#L9-L20 | train | prepare assets | [
30522,
3853,
7374,
27241,
3215,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
5530,
1027,
6434,
1012,
2131,
13704,
2015,
1006,
1007,
1025,
13075,
8833,
4590,
1027,
6434,
1012,
2131,
21197,
4590,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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() {
// (a) all properties required in the filter expression have been referenced
var aRequiredFilterPropertyNames = this._oEntityType.getRequiredFilterPropertyNames();
var oPropertiesInFilterExpression = this.getReferencedProperties();
for ( var i = -1, sPropertyName; (sPropertyName = aRequiredFilterPropertyNames[++i]) !== undefined;) {
if (oPropertiesInFilterExpression[sPropertyName] == undefined) {
throw "filter expression does not contain required property " + sPropertyName; // TODO
}
}
// (b) basic filter restrictions have been obeyed
var oPropertyFilterRestrictionSet = this._oEntityType.getPropertiesWithFilterRestrictions();
for ( var sPropertyName2 in oPropertyFilterRestrictionSet) {
var sFilterRestriction = oPropertyFilterRestrictionSet[sPropertyName2];
if (sFilterRestriction == odata4analytics.EntityType.propertyFilterRestriction.SINGLE_VALUE) {
if (oPropertiesInFilterExpression[sPropertyName2] != undefined) {
if (oPropertiesInFilterExpression[sPropertyName2].length > 1) {
// check if all filter instances of the current property have the same single value
var vTheOnlyValue = oPropertiesInFilterExpression[sPropertyName2][0].oValue1;
for (var j = 0; j < oPropertiesInFilterExpression[sPropertyName2].length; j++) {
// check if we have a value change, this means we got another value in one of the filters
if (oPropertiesInFilterExpression[sPropertyName2][j].oValue1 != vTheOnlyValue
|| oPropertiesInFilterExpression[sPropertyName2][j].sOperator != FilterOperator.EQ) {
throw "filter expression may use " + sPropertyName2 + " only with a single EQ condition";
}
}
}
}
}
}
return true;
} | javascript | function() {
// (a) all properties required in the filter expression have been referenced
var aRequiredFilterPropertyNames = this._oEntityType.getRequiredFilterPropertyNames();
var oPropertiesInFilterExpression = this.getReferencedProperties();
for ( var i = -1, sPropertyName; (sPropertyName = aRequiredFilterPropertyNames[++i]) !== undefined;) {
if (oPropertiesInFilterExpression[sPropertyName] == undefined) {
throw "filter expression does not contain required property " + sPropertyName; // TODO
}
}
// (b) basic filter restrictions have been obeyed
var oPropertyFilterRestrictionSet = this._oEntityType.getPropertiesWithFilterRestrictions();
for ( var sPropertyName2 in oPropertyFilterRestrictionSet) {
var sFilterRestriction = oPropertyFilterRestrictionSet[sPropertyName2];
if (sFilterRestriction == odata4analytics.EntityType.propertyFilterRestriction.SINGLE_VALUE) {
if (oPropertiesInFilterExpression[sPropertyName2] != undefined) {
if (oPropertiesInFilterExpression[sPropertyName2].length > 1) {
// check if all filter instances of the current property have the same single value
var vTheOnlyValue = oPropertiesInFilterExpression[sPropertyName2][0].oValue1;
for (var j = 0; j < oPropertiesInFilterExpression[sPropertyName2].length; j++) {
// check if we have a value change, this means we got another value in one of the filters
if (oPropertiesInFilterExpression[sPropertyName2][j].oValue1 != vTheOnlyValue
|| oPropertiesInFilterExpression[sPropertyName2][j].sOperator != FilterOperator.EQ) {
throw "filter expression may use " + sPropertyName2 + " only with a single EQ condition";
}
}
}
}
}
}
return true;
} | [
"function",
"(",
")",
"{",
"// (a) all properties required in the filter expression have been referenced",
"var",
"aRequiredFilterPropertyNames",
"=",
"this",
".",
"_oEntityType",
".",
"getRequiredFilterPropertyNames",
"(",
")",
";",
"var",
"oPropertiesInFilterExpression",
"=",
... | Check if request is compliant with basic filter constraints expressed in metadata:
(a) all properties required in the filter expression have been referenced (b) the single-value filter restrictions have been obeyed
@returns {boolean} The value true. In case the expression violates some of the rules, an exception with some explanatory
message is thrown
@public
@function
@name sap.ui.model.analytics.odata4analytics.FilterExpression#checkValidity | [
"Check",
"if",
"request",
"is",
"compliant",
"with",
"basic",
"filter",
"constraints",
"expressed",
"in",
"metadata",
":"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3503-L3534 | train | Checks if all properties in the filter expression have been referenced and if so checks if they are the same value as the current property | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
1006,
1037,
1007,
2035,
5144,
3223,
1999,
1996,
11307,
3670,
2031,
2042,
14964,
13075,
2024,
15549,
5596,
8873,
21928,
21572,
4842,
25680,
14074,
2015,
1027,
2023,
1012,
1035,
1051,
4765,
3012,
138... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Sample.controller.js | function (event) {
this._sId = event.getParameter("arguments").sampleId;
this._sEntityId = event.getParameter("arguments").entityId;
this.byId("page").setBusy(true);
this.getModel("appView").setProperty("/bHasMaster", false);
ControlsInfo.loadData().then(this._loadSample.bind(this));
} | javascript | function (event) {
this._sId = event.getParameter("arguments").sampleId;
this._sEntityId = event.getParameter("arguments").entityId;
this.byId("page").setBusy(true);
this.getModel("appView").setProperty("/bHasMaster", false);
ControlsInfo.loadData().then(this._loadSample.bind(this));
} | [
"function",
"(",
"event",
")",
"{",
"this",
".",
"_sId",
"=",
"event",
".",
"getParameter",
"(",
"\"arguments\"",
")",
".",
"sampleId",
";",
"this",
".",
"_sEntityId",
"=",
"event",
".",
"getParameter",
"(",
"\"arguments\"",
")",
".",
"entityId",
";",
"t... | /* =========================================================== /* begin: internal methods /* ===========================================================
Navigate handler
@param event
@private | [
"/",
"*",
"===========================================================",
"/",
"*",
"begin",
":",
"internal",
"methods",
"/",
"*",
"===========================================================",
"Navigate",
"handler"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Sample.controller.js#L71-L79 | train | Load sample data | [
30522,
3853,
1006,
2724,
1007,
1063,
2023,
1012,
1035,
15765,
1027,
2724,
1012,
2131,
28689,
22828,
1006,
1000,
9918,
1000,
1007,
1012,
7099,
3593,
1025,
2023,
1012,
1035,
2741,
3012,
3593,
1027,
2724,
1012,
2131,
28689,
22828,
1006,
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... | |
archriss/react-native-snap-carousel | example/src/utils/animations.js | scrollInterpolator1 | function scrollInterpolator1 (index, carouselProps) {
const range = [3, 2, 1, 0, -1];
const inputRange = getInputRangeFromIndexes(range, index, carouselProps);
const outputRange = range;
return { inputRange, outputRange };
} | javascript | function scrollInterpolator1 (index, carouselProps) {
const range = [3, 2, 1, 0, -1];
const inputRange = getInputRangeFromIndexes(range, index, carouselProps);
const outputRange = range;
return { inputRange, outputRange };
} | [
"function",
"scrollInterpolator1",
"(",
"index",
",",
"carouselProps",
")",
"{",
"const",
"range",
"=",
"[",
"3",
",",
"2",
",",
"1",
",",
"0",
",",
"-",
"1",
"]",
";",
"const",
"inputRange",
"=",
"getInputRangeFromIndexes",
"(",
"range",
",",
"index",
... | Photo album effect | [
"Photo",
"album",
"effect"
] | 85980e5177a75d393a1b38480800753282148c50 | https://github.com/archriss/react-native-snap-carousel/blob/85980e5177a75d393a1b38480800753282148c50/example/src/utils/animations.js#L4-L10 | train | scrollInterpolator1 - returns an object with input range and output range | [
30522,
3853,
17186,
18447,
2121,
18155,
8844,
2487,
1006,
5950,
1010,
27628,
21572,
4523,
1007,
1063,
9530,
3367,
2846,
1027,
1031,
1017,
1010,
1016,
1010,
1015,
1010,
1014,
1010,
1011,
1015,
1033,
1025,
9530,
3367,
7953,
24388,
2063,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | bits/70_csheet.js | parse_cs_bin | function parse_cs_bin(data, opts, idx/*:number*/, rels, wb/*::, themes, styles*/)/*:Worksheet*/ {
if(!data) return data;
if(!rels) rels = {'!id':{}};
var s = {'!type':"chart", '!chart':null, '!rel':""};
var state/*:Array<string>*/ = [];
var pass = false;
recordhopper(data, function cs_parse(val, R_n, RT) {
switch(RT) {
case 0x0226: /* 'BrtDrawing' */
s['!rel'] = val; break;
case 0x028B: /* 'BrtCsProp' */
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(val.name) wb.Sheets[idx].CodeName = val.name;
break;
case 0x0232: /* 'BrtBkHim' */
case 0x028C: /* 'BrtCsPageSetup' */
case 0x029D: /* 'BrtCsProtection' */
case 0x02A7: /* 'BrtCsProtectionIso' */
case 0x0227: /* 'BrtLegacyDrawing' */
case 0x0228: /* 'BrtLegacyDrawingHF' */
case 0x01DC: /* 'BrtMargins' */
case 0x0C00: /* 'BrtUid' */
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); break;
default:
if((R_n||"").indexOf("Begin") > 0) state.push(R_n);
else if((R_n||"").indexOf("End") > 0) state.pop();
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
if(rels['!id'][s['!rel']]) s['!chart'] = rels['!id'][s['!rel']];
return s;
} | javascript | function parse_cs_bin(data, opts, idx/*:number*/, rels, wb/*::, themes, styles*/)/*:Worksheet*/ {
if(!data) return data;
if(!rels) rels = {'!id':{}};
var s = {'!type':"chart", '!chart':null, '!rel':""};
var state/*:Array<string>*/ = [];
var pass = false;
recordhopper(data, function cs_parse(val, R_n, RT) {
switch(RT) {
case 0x0226: /* 'BrtDrawing' */
s['!rel'] = val; break;
case 0x028B: /* 'BrtCsProp' */
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(val.name) wb.Sheets[idx].CodeName = val.name;
break;
case 0x0232: /* 'BrtBkHim' */
case 0x028C: /* 'BrtCsPageSetup' */
case 0x029D: /* 'BrtCsProtection' */
case 0x02A7: /* 'BrtCsProtectionIso' */
case 0x0227: /* 'BrtLegacyDrawing' */
case 0x0228: /* 'BrtLegacyDrawingHF' */
case 0x01DC: /* 'BrtMargins' */
case 0x0C00: /* 'BrtUid' */
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); break;
default:
if((R_n||"").indexOf("Begin") > 0) state.push(R_n);
else if((R_n||"").indexOf("End") > 0) state.pop();
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
if(rels['!id'][s['!rel']]) s['!chart'] = rels['!id'][s['!rel']];
return s;
} | [
"function",
"parse_cs_bin",
"(",
"data",
",",
"opts",
",",
"idx",
"/*:number*/",
",",
"rels",
",",
"wb",
"/*::, themes, styles*/",
")",
"/*:Worksheet*/",
"{",
"if",
"(",
"!",
"data",
")",
"return",
"data",
";",
"if",
"(",
"!",
"rels",
")",
"rels",
"=",
... | /* [MS-XLSB] 2.1.7.7 Chart Sheet | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"1",
".",
"7",
".",
"7",
"Chart",
"Sheet"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/70_csheet.js#L42-L87 | train | Parse chart data | [
30522,
3853,
11968,
3366,
1035,
20116,
1035,
8026,
1006,
2951,
1010,
23569,
2015,
1010,
8909,
2595,
1013,
1008,
1024,
2193,
1008,
1013,
1010,
2128,
4877,
1010,
25610,
1013,
1008,
1024,
1024,
1010,
6991,
1010,
6782,
1008,
1013,
1007,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js | function(oTable, iColumnIndex) {
if (!oTable ||
iColumnIndex == null || iColumnIndex < 0) {
return null;
}
var aColumns = oTable.getColumns();
if (iColumnIndex >= aColumns.length) {
return null;
}
var oColumn = aColumns[iColumnIndex];
var sColumnWidth = oColumn.getWidth();
// If the columns width is "auto" or specified in percentage, get the width from the DOM.
if (sColumnWidth === "" || sColumnWidth === "auto" || sColumnWidth.match(/%$/)) {
if (oColumn.getVisible()) {
var oColumnElement = oColumn.getDomRef();
return oColumnElement ? oColumnElement.offsetWidth : 0;
} else {
return 0;
}
} else {
return TableColumnUtils.TableUtils.convertCSSSizeToPixel(sColumnWidth);
}
} | javascript | function(oTable, iColumnIndex) {
if (!oTable ||
iColumnIndex == null || iColumnIndex < 0) {
return null;
}
var aColumns = oTable.getColumns();
if (iColumnIndex >= aColumns.length) {
return null;
}
var oColumn = aColumns[iColumnIndex];
var sColumnWidth = oColumn.getWidth();
// If the columns width is "auto" or specified in percentage, get the width from the DOM.
if (sColumnWidth === "" || sColumnWidth === "auto" || sColumnWidth.match(/%$/)) {
if (oColumn.getVisible()) {
var oColumnElement = oColumn.getDomRef();
return oColumnElement ? oColumnElement.offsetWidth : 0;
} else {
return 0;
}
} else {
return TableColumnUtils.TableUtils.convertCSSSizeToPixel(sColumnWidth);
}
} | [
"function",
"(",
"oTable",
",",
"iColumnIndex",
")",
"{",
"if",
"(",
"!",
"oTable",
"||",
"iColumnIndex",
"==",
"null",
"||",
"iColumnIndex",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"var",
"aColumns",
"=",
"oTable",
".",
"getColumns",
"(",
")",... | Returns the width of a visible column in pixels.
In case the width is set to auto or in percentage, the <code>offsetWidth</code> of the columns DOM element will be returned.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {int} iColumnIndex The index of a column. Must be a visible column.
@returns {int | null} Returns <code>null</code> if <code>iColumnIndex</code> is out of bound.
Returns 0, if the column is not visible, or not yet rendered, and its width is not specified in pixels. | [
"Returns",
"the",
"width",
"of",
"a",
"visible",
"column",
"in",
"pixels",
".",
"In",
"case",
"the",
"width",
"is",
"set",
"to",
"auto",
"or",
"in",
"percentage",
"the",
"<code",
">",
"offsetWidth<",
"/",
"code",
">",
"of",
"the",
"columns",
"DOM",
"el... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js#L691-L716 | train | Returns the width of the column at the given index. | [
30522,
3853,
1006,
27178,
3085,
1010,
24582,
4747,
2819,
11483,
3207,
2595,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1064,
1064,
24582,
4747,
2819,
11483,
3207,
2595,
1027,
1027,
19701,
1064,
1064,
24582,
4747,
2819,
11483,
3207,
2595,
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... | |
ccxt/ccxt | build/transpile.js | transpileJavaScriptToPHP | function transpileJavaScriptToPHP ({ js, variables }) {
// match all local variables (let, const or var)
let localVariablesRegex = /[^a-zA-Z0-9_](?:let|const|var)\s+(?:\[([^\]]+)\]|([a-zA-Z0-9_]+))/g // local variables
let allVariables = (variables || []).map (x => x); // clone the array
// process the variables created in destructuring assignments as well
let localVariablesMatches
while (localVariablesMatches = localVariablesRegex.exec (js)) {
if (localVariablesMatches[1]) {
// this is a destructuring assignment like
// let [ a, b, c ] = 'a-b-c'.split ('-')
let matches = localVariablesMatches[1].trim ().split (', ') // split the destructuring assignment by comma
matches.forEach (x => allVariables.push (x.trim ())) // trim each variable name
} else {
// this is a single variable assignment
allVariables.push (localVariablesMatches[2].trim ()) // add it to the list of local variables
}
}
// match all variables instantiated in the catch()-block of a try-catch clause
let catchClauseRegex = /catch \(([^)]+)\)/g
let catchClauseMatches
while (catchClauseMatches = catchClauseRegex.exec (js)) {
allVariables.push (catchClauseMatches[1])
}
// append $ to all variables in the method (PHP syntax demands $ at the beginning of a variable name)
let phpVariablesRegexes = allVariables.map (x => [ "([^$$a-zA-Z0-9\\.\\>'_/])" + x + "([^a-zA-Z0-9'_/])", '$1$$' + x + '$2' ])
// support for php syntax for object-pointer dereference
// convert all $variable.property to $variable->property
let variablePropertiesRegexes = allVariables.map (x => [ "([^a-zA-Z0-9\\.\\>'_])" + x + '\\.', '$1' + x + '->' ])
// transpile JS → PHP
let phpBody = regexAll (js, phpRegexes.concat (phpVariablesRegexes).concat (variablePropertiesRegexes))
return phpBody
} | javascript | function transpileJavaScriptToPHP ({ js, variables }) {
// match all local variables (let, const or var)
let localVariablesRegex = /[^a-zA-Z0-9_](?:let|const|var)\s+(?:\[([^\]]+)\]|([a-zA-Z0-9_]+))/g // local variables
let allVariables = (variables || []).map (x => x); // clone the array
// process the variables created in destructuring assignments as well
let localVariablesMatches
while (localVariablesMatches = localVariablesRegex.exec (js)) {
if (localVariablesMatches[1]) {
// this is a destructuring assignment like
// let [ a, b, c ] = 'a-b-c'.split ('-')
let matches = localVariablesMatches[1].trim ().split (', ') // split the destructuring assignment by comma
matches.forEach (x => allVariables.push (x.trim ())) // trim each variable name
} else {
// this is a single variable assignment
allVariables.push (localVariablesMatches[2].trim ()) // add it to the list of local variables
}
}
// match all variables instantiated in the catch()-block of a try-catch clause
let catchClauseRegex = /catch \(([^)]+)\)/g
let catchClauseMatches
while (catchClauseMatches = catchClauseRegex.exec (js)) {
allVariables.push (catchClauseMatches[1])
}
// append $ to all variables in the method (PHP syntax demands $ at the beginning of a variable name)
let phpVariablesRegexes = allVariables.map (x => [ "([^$$a-zA-Z0-9\\.\\>'_/])" + x + "([^a-zA-Z0-9'_/])", '$1$$' + x + '$2' ])
// support for php syntax for object-pointer dereference
// convert all $variable.property to $variable->property
let variablePropertiesRegexes = allVariables.map (x => [ "([^a-zA-Z0-9\\.\\>'_])" + x + '\\.', '$1' + x + '->' ])
// transpile JS → PHP
let phpBody = regexAll (js, phpRegexes.concat (phpVariablesRegexes).concat (variablePropertiesRegexes))
return phpBody
} | [
"function",
"transpileJavaScriptToPHP",
"(",
"{",
"js",
",",
"variables",
"}",
")",
"{",
"// match all local variables (let, const or var)",
"let",
"localVariablesRegex",
"=",
"/",
"[^a-zA-Z0-9_](?:let|const|var)\\s+(?:\\[([^\\]]+)\\]|([a-zA-Z0-9_]+))",
"/",
"g",
"// local variab... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/build/transpile.js#L523-L561 | train | transpile JavaScript to PHP | [
30522,
3853,
9099,
22090,
3900,
12044,
23235,
14399,
22269,
1006,
1063,
1046,
2015,
1010,
10857,
1065,
1007,
1063,
1013,
1013,
2674,
2035,
2334,
10857,
1006,
2292,
1010,
9530,
3367,
2030,
30524,
2595,
1027,
1013,
1031,
1034,
1037,
1011,
235... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(parent, text)
{
var p = document.createElement('p');
mxUtils.write(p, text);
if (parent != null)
{
parent.appendChild(p);
}
return p;
} | javascript | function(parent, text)
{
var p = document.createElement('p');
mxUtils.write(p, text);
if (parent != null)
{
parent.appendChild(p);
}
return p;
} | [
"function",
"(",
"parent",
",",
"text",
")",
"{",
"var",
"p",
"=",
"document",
".",
"createElement",
"(",
"'p'",
")",
";",
"mxUtils",
".",
"write",
"(",
"p",
",",
"text",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"parent",
".",
"appe... | Function: para
Appends a new paragraph with the given text to the specified parent and
returns the paragraph.
Parameters:
parent - DOM node to append the text node to.
text - String representing the text for the new paragraph. | [
"Function",
":",
"para"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3363-L3374 | train | Creates a p element and appends it to the parent | [
30522,
3853,
1006,
6687,
1010,
3793,
1007,
1063,
13075,
1052,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
1052,
1005,
1007,
1025,
25630,
21823,
4877,
1012,
4339,
1006,
1052,
1010,
3793,
1007,
1025,
2065,
1006,
6687,
999,
1027,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/AutoUpdate/UpdateInfoBar.js | function () {
if($updateContent.length > 0 && $contentContainer.length > 0 && $updateBar.length > 0) {
var newWidth = $updateBar.outerWidth() - 38;
if($buttonContainer.length > 0) {
newWidth = newWidth- $buttonContainer.outerWidth();
}
if($iconContainer.length > 0) {
newWidth = newWidth - $iconContainer.outerWidth();
}
if($closeIconContainer.length > 0) {
newWidth = newWidth - $closeIconContainer.outerWidth();
}
$contentContainer.css({
"maxWidth": newWidth
});
}
} | javascript | function () {
if($updateContent.length > 0 && $contentContainer.length > 0 && $updateBar.length > 0) {
var newWidth = $updateBar.outerWidth() - 38;
if($buttonContainer.length > 0) {
newWidth = newWidth- $buttonContainer.outerWidth();
}
if($iconContainer.length > 0) {
newWidth = newWidth - $iconContainer.outerWidth();
}
if($closeIconContainer.length > 0) {
newWidth = newWidth - $closeIconContainer.outerWidth();
}
$contentContainer.css({
"maxWidth": newWidth
});
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"$updateContent",
".",
"length",
">",
"0",
"&&",
"$contentContainer",
".",
"length",
">",
"0",
"&&",
"$updateBar",
".",
"length",
">",
"0",
")",
"{",
"var",
"newWidth",
"=",
"$updateBar",
".",
"outerWidth",
"(",
")... | Content Container Width between Icon Container and Button Container or Close Icon Container will be assigned when window will be rezied. | [
"Content",
"Container",
"Width",
"between",
"Icon",
"Container",
"and",
"Button",
"Container",
"or",
"Close",
"Icon",
"Container",
"will",
"be",
"assigned",
"when",
"window",
"will",
"be",
"rezied",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/UpdateInfoBar.js#L123-L140 | train | This function is called when the user clicks on a button or a close icon | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
1002,
10651,
8663,
6528,
2102,
1012,
3091,
1028,
1014,
1004,
1004,
1002,
4180,
8663,
18249,
2121,
1012,
3091,
1028,
1014,
1004,
1004,
1002,
10651,
8237,
1012,
3091,
1028,
1014,
1007,
1063,
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... | |
angular/material | src/components/select/select.js | OptgroupDirective | function OptgroupDirective() {
return {
restrict: 'E',
compile: compile
};
function compile(el, attrs) {
// If we have a select header element, we don't want to add the normal label
// header.
if (!hasSelectHeader()) {
setupLabelElement();
}
function hasSelectHeader() {
return el.parent().find('md-select-header').length;
}
function setupLabelElement() {
var labelElement = el.find('label');
if (!labelElement.length) {
labelElement = angular.element('<label>');
el.prepend(labelElement);
}
labelElement.addClass('md-container-ignore');
labelElement.attr('aria-hidden', 'true');
if (attrs.label) labelElement.text(attrs.label);
}
}
} | javascript | function OptgroupDirective() {
return {
restrict: 'E',
compile: compile
};
function compile(el, attrs) {
// If we have a select header element, we don't want to add the normal label
// header.
if (!hasSelectHeader()) {
setupLabelElement();
}
function hasSelectHeader() {
return el.parent().find('md-select-header').length;
}
function setupLabelElement() {
var labelElement = el.find('label');
if (!labelElement.length) {
labelElement = angular.element('<label>');
el.prepend(labelElement);
}
labelElement.addClass('md-container-ignore');
labelElement.attr('aria-hidden', 'true');
if (attrs.label) labelElement.text(attrs.label);
}
}
} | [
"function",
"OptgroupDirective",
"(",
")",
"{",
"return",
"{",
"restrict",
":",
"'E'",
",",
"compile",
":",
"compile",
"}",
";",
"function",
"compile",
"(",
"el",
",",
"attrs",
")",
"{",
"// If we have a select header element, we don't want to add the normal label",
... | @ngdoc directive
@name mdOptgroup
@restrict E
@module material.components.select
@description Displays a label separating groups of
<a ng-href="/api/directive/mdOption">md-option</a> element directives in a
<a ng-href="/api/directive/mdSelect">md-select</a> box's dropdown menu.
**Note:** When using `md-select-header` element directives within a `md-select`, the labels that
would normally be added to the <a ng-href="/api/directive/mdOptgroup">md-optgroup</a> directives
are omitted, allowing the `md-select-header` to represent the option group label
(and possibly more).
@usage
With label attributes
<hljs lang="html">
<md-select ng-model="currentState" placeholder="Select a state">
<md-optgroup label="Southern">
<md-option ng-value="AL">Alabama</md-option>
<md-option ng-value="FL">Florida</md-option>
</md-optgroup>
<md-optgroup label="Northern">
<md-option ng-value="AK">Alaska</md-option>
<md-option ng-value="MA">Massachusetts</md-option>
</md-optgroup>
</md-select>
</hljs>
With label elements
<hljs lang="html">
<md-select ng-model="currentState" placeholder="Select a state">
<md-optgroup>
<label>Southern</label>
<md-option ng-value="AL">Alabama</md-option>
<md-option ng-value="FL">Florida</md-option>
</md-optgroup>
<md-optgroup>
<label>Northern</label>
<md-option ng-value="AK">Alaska</md-option>
<md-option ng-value="MA">Massachusetts</md-option>
</md-optgroup>
</md-select>
</hljs>
@param {string=} label The option group's label. | [
"@ngdoc",
"directive",
"@name",
"mdOptgroup",
"@restrict",
"E",
"@module",
"material",
".",
"components",
".",
"select"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L1163-L1190 | train | Optgroup directive. | [
30522,
3853,
23569,
17058,
4305,
2890,
15277,
1006,
1007,
1063,
2709,
1063,
21573,
1024,
1005,
1041,
1005,
1010,
4012,
22090,
1024,
4012,
22090,
1065,
1025,
3853,
4012,
22090,
1006,
3449,
1010,
2012,
16344,
2015,
1007,
1063,
1013,
1013,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/docker-prompts.js | askForMonitoring | function askForMonitoring() {
if (this.regenerate) return;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'monitoring',
message: 'Do you want to setup monitoring for your applications ?',
choices: [
{
value: 'no',
name: 'No'
},
{
value: 'elk',
name:
this.deploymentApplicationType === 'monolith'
? 'Yes, for logs and metrics with the JHipster Console (based on ELK)'
: 'Yes, for logs and metrics with the JHipster Console (based on ELK and Zipkin)'
},
{
value: 'prometheus',
name: 'Yes, for metrics only with Prometheus'
}
],
default: this.monitoring ? this.monitoring : 'no'
}
];
this.prompt(prompts).then(props => {
this.monitoring = props.monitoring;
done();
});
} | javascript | function askForMonitoring() {
if (this.regenerate) return;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'monitoring',
message: 'Do you want to setup monitoring for your applications ?',
choices: [
{
value: 'no',
name: 'No'
},
{
value: 'elk',
name:
this.deploymentApplicationType === 'monolith'
? 'Yes, for logs and metrics with the JHipster Console (based on ELK)'
: 'Yes, for logs and metrics with the JHipster Console (based on ELK and Zipkin)'
},
{
value: 'prometheus',
name: 'Yes, for metrics only with Prometheus'
}
],
default: this.monitoring ? this.monitoring : 'no'
}
];
this.prompt(prompts).then(props => {
this.monitoring = props.monitoring;
done();
});
} | [
"function",
"askForMonitoring",
"(",
")",
"{",
"if",
"(",
"this",
".",
"regenerate",
")",
"return",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'list'",
",",
"name",
":",
"'monitori... | Ask For Monitoring | [
"Ask",
"For",
"Monitoring"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-prompts.js#L230-L265 | train | Ask For Monitoring | [
30522,
3853,
3198,
14192,
10698,
29469,
3070,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
19723,
24454,
3686,
1007,
2709,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
25732,
2015,
1027,
1031,
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... |
google/closure-library | closure/goog/net/streams/pbstreamparser.js | finishMessage | function finishMessage() {
if (parser.tag_ < Parser.PADDING_TAG_) {
var message = {};
message[parser.tag_] = parser.messageBuffer_;
parser.result_.push(message);
}
parser.state_ = Parser.State_.INIT;
} | javascript | function finishMessage() {
if (parser.tag_ < Parser.PADDING_TAG_) {
var message = {};
message[parser.tag_] = parser.messageBuffer_;
parser.result_.push(message);
}
parser.state_ = Parser.State_.INIT;
} | [
"function",
"finishMessage",
"(",
")",
"{",
"if",
"(",
"parser",
".",
"tag_",
"<",
"Parser",
".",
"PADDING_TAG_",
")",
"{",
"var",
"message",
"=",
"{",
"}",
";",
"message",
"[",
"parser",
".",
"tag_",
"]",
"=",
"parser",
".",
"messageBuffer_",
";",
"... | Finishes up building the current message and resets parser state | [
"Finishes",
"up",
"building",
"the",
"current",
"message",
"and",
"resets",
"parser",
"state"
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/net/streams/pbstreamparser.js#L289-L296 | train | Finishes the message | [
30522,
3853,
3926,
7834,
3736,
3351,
1006,
1007,
1063,
2065,
1006,
11968,
8043,
1012,
6415,
1035,
1026,
11968,
8043,
1012,
11687,
4667,
1035,
6415,
1035,
1007,
1063,
13075,
4471,
1027,
1063,
1065,
1025,
4471,
1031,
11968,
8043,
1012,
6415,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
serverless/serverless | lib/utils/downloadTemplateFromRepo.js | getPathDirectory | function getPathDirectory(length, parts) {
if (!parts) {
return '';
}
return parts
.slice(length)
.filter(part => part !== '')
.join(path.sep);
} | javascript | function getPathDirectory(length, parts) {
if (!parts) {
return '';
}
return parts
.slice(length)
.filter(part => part !== '')
.join(path.sep);
} | [
"function",
"getPathDirectory",
"(",
"length",
",",
"parts",
")",
"{",
"if",
"(",
"!",
"parts",
")",
"{",
"return",
"''",
";",
"}",
"return",
"parts",
".",
"slice",
"(",
"length",
")",
".",
"filter",
"(",
"part",
"=>",
"part",
"!==",
"''",
")",
"."... | Returns directory path
@param {Number} length
@param {Array} parts
@returns {String} directory path | [
"Returns",
"directory",
"path"
] | 0626d5b5df06e4ed68969e324f1cb6b1b499c443 | https://github.com/serverless/serverless/blob/0626d5b5df06e4ed68969e324f1cb6b1b499c443/lib/utils/downloadTemplateFromRepo.js#L22-L30 | train | Get the path directory of the given path | [
30522,
3853,
2131,
15069,
4305,
2890,
16761,
2100,
1006,
3091,
1010,
3033,
1007,
1063,
2065,
1006,
999,
3033,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
2709,
3033,
1012,
14704,
1006,
3091,
1007,
1012,
11307,
1006,
2112,
1027,
1028,
2112,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mui-org/material-ui | docs/src/modules/components/PageTitle.js | PageTitle | function PageTitle(props) {
const { activePage } = React.useContext(PageContext);
if (!activePage) {
throw new Error('Missing activePage.');
}
const title = pageToTitleI18n(activePage, props.t);
return props.children(title);
} | javascript | function PageTitle(props) {
const { activePage } = React.useContext(PageContext);
if (!activePage) {
throw new Error('Missing activePage.');
}
const title = pageToTitleI18n(activePage, props.t);
return props.children(title);
} | [
"function",
"PageTitle",
"(",
"props",
")",
"{",
"const",
"{",
"activePage",
"}",
"=",
"React",
".",
"useContext",
"(",
"PageContext",
")",
";",
"if",
"(",
"!",
"activePage",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Missing activePage.'",
")",
";",
"}",... | TODO: it really wants to be named useTitle but we're not quite there yet. | [
"TODO",
":",
"it",
"really",
"wants",
"to",
"be",
"named",
"useTitle",
"but",
"we",
"re",
"not",
"quite",
"there",
"yet",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/modules/components/PageTitle.js#L7-L17 | train | Get the title of a page | [
30522,
3853,
3931,
3775,
9286,
1006,
24387,
1007,
1063,
9530,
3367,
1063,
3161,
13704,
1065,
1027,
10509,
1012,
2224,
8663,
18209,
1006,
3931,
8663,
18209,
1007,
1025,
2065,
1006,
999,
3161,
13704,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | _makePaneMostRecent | function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
} | javascript | function _makePaneMostRecent(paneId) {
var pane = _getPane(paneId);
if (pane.getCurrentlyViewedFile()) {
_makeFileMostRecent(paneId, pane.getCurrentlyViewedFile());
}
} | [
"function",
"_makePaneMostRecent",
"(",
"paneId",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"if",
"(",
"pane",
".",
"getCurrentlyViewedFile",
"(",
")",
")",
"{",
"_makeFileMostRecent",
"(",
"paneId",
",",
"pane",
".",
"getCurrentlyVi... | Makes the Pane's current file the most recent
@param {!string} paneId - id of the pane to make the file most recent, or ACTIVE_PANE
@param {!File} file - File object to make most recent
@private | [
"Makes",
"the",
"Pane",
"s",
"current",
"file",
"the",
"most",
"recent"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L369-L375 | train | Make the pane most recent | [
30522,
3853,
1035,
2191,
9739,
6633,
14122,
2890,
13013,
1006,
30524,
1025,
2065,
1006,
6090,
2063,
1012,
2131,
10841,
14343,
20630,
8584,
2098,
8873,
2571,
1006,
1007,
1007,
1063,
1035,
2191,
8873,
16930,
14122,
2890,
13013,
1006,
6090,
74... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ApiDetailIndexDeprecatedExperimental.controller.js | function(oEvent) {
// in our use-case each tab contains a single subSection => only this subSection needs to be processed
var oSubSection = oEvent.getParameter("subSection"),
sId = oSubSection.getId(),
aBlocks;
//attach listeners that prettify the tab content upon its rendering
if (this._aVisitedTabs.indexOf(sId) < 0) { // avoid adding listeners to the same tab twice
aBlocks = oSubSection.getBlocks();
aBlocks.forEach(function(oBlock) {
oBlock.addEventDelegate({"onAfterRendering": this._prettify.bind(this)});
}.bind(this));
this._aVisitedTabs.push(sId);
}
} | javascript | function(oEvent) {
// in our use-case each tab contains a single subSection => only this subSection needs to be processed
var oSubSection = oEvent.getParameter("subSection"),
sId = oSubSection.getId(),
aBlocks;
//attach listeners that prettify the tab content upon its rendering
if (this._aVisitedTabs.indexOf(sId) < 0) { // avoid adding listeners to the same tab twice
aBlocks = oSubSection.getBlocks();
aBlocks.forEach(function(oBlock) {
oBlock.addEventDelegate({"onAfterRendering": this._prettify.bind(this)});
}.bind(this));
this._aVisitedTabs.push(sId);
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"// in our use-case each tab contains a single subSection => only this subSection needs to be processed",
"var",
"oSubSection",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"subSection\"",
")",
",",
"sId",
"=",
"oSubSection",
".",
"getId",
... | Attach listeners that prettify the tab content upon its rendering
@param {oEvent} tab navigate event
@private | [
"Attach",
"listeners",
"that",
"prettify",
"the",
"tab",
"content",
"upon",
"its",
"rendering"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ApiDetailIndexDeprecatedExperimental.controller.js#L74-L89 | train | This function is called when a tab is rendered | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
1013,
1013,
1999,
2256,
2224,
1011,
2553,
2169,
21628,
3397,
1037,
2309,
4942,
29015,
1027,
1028,
2069,
2023,
4942,
29015,
3791,
2000,
2022,
13995,
13075,
9808,
12083,
29015,
1027,
1051,
186... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Shopify/draggable | src/Droppable/Droppable.js | onDroppableReturnedDefaultAnnouncement | function onDroppableReturnedDefaultAnnouncement({dragEvent, dropzone}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
return `Returned ${sourceText} from ${dropzoneText}`;
} | javascript | function onDroppableReturnedDefaultAnnouncement({dragEvent, dropzone}) {
const sourceText = dragEvent.source.textContent.trim() || dragEvent.source.id || 'draggable element';
const dropzoneText = dropzone.textContent.trim() || dropzone.id || 'droppable element';
return `Returned ${sourceText} from ${dropzoneText}`;
} | [
"function",
"onDroppableReturnedDefaultAnnouncement",
"(",
"{",
"dragEvent",
",",
"dropzone",
"}",
")",
"{",
"const",
"sourceText",
"=",
"dragEvent",
".",
"source",
".",
"textContent",
".",
"trim",
"(",
")",
"||",
"dragEvent",
".",
"source",
".",
"id",
"||",
... | Returns an announcement message when the Draggable element has returned to its original dropzone element
@param {DroppableReturnedEvent} droppableEvent
@return {String} | [
"Returns",
"an",
"announcement",
"message",
"when",
"the",
"Draggable",
"element",
"has",
"returned",
"to",
"its",
"original",
"dropzone",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Droppable/Droppable.js#L31-L36 | train | This function is called when a droppable element is returned from a default source. | [
30522,
3853,
2006,
25711,
4502,
16213,
3388,
21737,
14141,
12879,
23505,
11639,
23709,
3401,
3672,
1006,
1063,
8011,
18697,
3372,
1010,
4530,
15975,
1065,
1007,
1063,
9530,
3367,
3120,
18209,
1027,
8011,
18697,
3372,
1012,
3120,
1012,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nodejs/node-gyp | lib/build.js | findSolutionFile | function findSolutionFile () {
glob('build/*.sln', function (err, files) {
if (err) return callback(err)
if (files.length === 0) {
return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
}
guessedSolution = files[0]
log.verbose('found first Solution file', guessedSolution)
doWhich()
})
} | javascript | function findSolutionFile () {
glob('build/*.sln', function (err, files) {
if (err) return callback(err)
if (files.length === 0) {
return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
}
guessedSolution = files[0]
log.verbose('found first Solution file', guessedSolution)
doWhich()
})
} | [
"function",
"findSolutionFile",
"(",
")",
"{",
"glob",
"(",
"'build/*.sln'",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
"if",
"(",
"files",
".",
"length",
"===",
"0",
")",
"{",
... | On Windows, find the first build/*.sln file. | [
"On",
"Windows",
"find",
"the",
"first",
"build",
"/",
"*",
".",
"sln",
"file",
"."
] | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/build.js#L81-L91 | train | Find first. sln file in the project | [
30522,
3853,
4858,
4747,
13700,
8873,
2571,
1006,
1007,
1063,
1043,
4135,
2497,
1006,
1005,
3857,
1013,
1008,
1012,
22889,
2078,
1005,
1010,
3853,
1006,
9413,
2099,
1010,
6764,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
2709,
2655,
5963,
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... |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | drawHorizontalRule | function drawHorizontalRule(editor) {
var cm = editor.codemirror;
var stat = getState(cm);
var options = editor.options;
_replaceSelection(cm, stat.image, options.insertTexts.horizontalRule);
} | javascript | function drawHorizontalRule(editor) {
var cm = editor.codemirror;
var stat = getState(cm);
var options = editor.options;
_replaceSelection(cm, stat.image, options.insertTexts.horizontalRule);
} | [
"function",
"drawHorizontalRule",
"(",
"editor",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"codemirror",
";",
"var",
"stat",
"=",
"getState",
"(",
"cm",
")",
";",
"var",
"options",
"=",
"editor",
".",
"options",
";",
"_replaceSelection",
"(",
"cm",
",",... | Action for drawing a horizontal rule. | [
"Action",
"for",
"drawing",
"a",
"horizontal",
"rule",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L660-L665 | train | Draws the horizontal rule | [
30522,
3853,
4009,
16368,
10993,
12162,
2389,
6820,
2571,
1006,
3559,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
3642,
14503,
29165,
1025,
13075,
28093,
1027,
4152,
12259,
1006,
4642,
1007,
1025,
13075,
7047,
1027,
3559,
1012,
7047,
1025,
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... |
GitbookIO/gitbook | lib/modifiers/summary/mergeAtLevel.js | mergeAtLevel | function mergeAtLevel(summary, level, newValue) {
var levelParts = level.split('.');
var partIndex = Number(levelParts[0]) -1;
var parts = summary.getParts();
var part = parts.get(partIndex);
if (!part) {
return summary;
}
var isEditingPart = levelParts.length < 2;
if (isEditingPart) {
part = part.merge(newValue);
} else {
part = editArticleInPart(part, level, newValue);
}
parts = parts.set(partIndex, part);
return summary.set('parts', parts);
} | javascript | function mergeAtLevel(summary, level, newValue) {
var levelParts = level.split('.');
var partIndex = Number(levelParts[0]) -1;
var parts = summary.getParts();
var part = parts.get(partIndex);
if (!part) {
return summary;
}
var isEditingPart = levelParts.length < 2;
if (isEditingPart) {
part = part.merge(newValue);
} else {
part = editArticleInPart(part, level, newValue);
}
parts = parts.set(partIndex, part);
return summary.set('parts', parts);
} | [
"function",
"mergeAtLevel",
"(",
"summary",
",",
"level",
",",
"newValue",
")",
"{",
"var",
"levelParts",
"=",
"level",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"partIndex",
"=",
"Number",
"(",
"levelParts",
"[",
"0",
"]",
")",
"-",
"1",
";",
"var"... | Edit an article, or a part, in a summary. Does a shallow merge.
@param {Summary} summary
@param {String} level
@param {Article|Part} newValue
@return {Summary} | [
"Edit",
"an",
"article",
"or",
"a",
"part",
"in",
"a",
"summary",
".",
"Does",
"a",
"shallow",
"merge",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/mergeAtLevel.js#L53-L72 | train | Merge an article at a specific level | [
30522,
3853,
13590,
4017,
20414,
2884,
1006,
12654,
1010,
2504,
1010,
2047,
10175,
5657,
1007,
1063,
13075,
2504,
26950,
1027,
2504,
1012,
3975,
1006,
1005,
1012,
1005,
1007,
1025,
13075,
2112,
22254,
10288,
1027,
2193,
1006,
2504,
26950,
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... |
TryGhost/Ghost | core/server/services/url/utils.js | urlJoin | function urlJoin() {
var args = Array.prototype.slice.call(arguments),
prefixDoubleSlash = false,
url;
// Remove empty item at the beginning
if (args[0] === '') {
args.shift();
}
// Handle schemeless protocols
if (args[0].indexOf('//') === 0) {
prefixDoubleSlash = true;
}
// join the elements using a slash
url = args.join('/');
// Fix multiple slashes
url = url.replace(/(^|[^:])\/\/+/g, '$1/');
// Put the double slash back at the beginning if this was a schemeless protocol
if (prefixDoubleSlash) {
url = url.replace(/^\//, '//');
}
url = deduplicateSubDir(url);
return url;
} | javascript | function urlJoin() {
var args = Array.prototype.slice.call(arguments),
prefixDoubleSlash = false,
url;
// Remove empty item at the beginning
if (args[0] === '') {
args.shift();
}
// Handle schemeless protocols
if (args[0].indexOf('//') === 0) {
prefixDoubleSlash = true;
}
// join the elements using a slash
url = args.join('/');
// Fix multiple slashes
url = url.replace(/(^|[^:])\/\/+/g, '$1/');
// Put the double slash back at the beginning if this was a schemeless protocol
if (prefixDoubleSlash) {
url = url.replace(/^\//, '//');
}
url = deduplicateSubDir(url);
return url;
} | [
"function",
"urlJoin",
"(",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"prefixDoubleSlash",
"=",
"false",
",",
"url",
";",
"// Remove empty item at the beginning",
"if",
"(",
"args",
"[",
... | urlJoin
Returns a URL/path for internal use in Ghost.
@param {string} arguments takes arguments and concats those to a valid path/URL.
@return {string} URL concatinated URL/path of arguments. | [
"urlJoin",
"Returns",
"a",
"URL",
"/",
"path",
"for",
"internal",
"use",
"in",
"Ghost",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/url/utils.js#L116-L144 | train | Join the url elements | [
30522,
3853,
24471,
2140,
5558,
2378,
1006,
1007,
1063,
13075,
12098,
5620,
1027,
9140,
1012,
8773,
1012,
14704,
1012,
2655,
1006,
9918,
1007,
1010,
17576,
26797,
13510,
27067,
1027,
6270,
1010,
24471,
2140,
1025,
1013,
1013,
6366,
4064,
88... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/light.js | function (oldData) {
var data = this.data;
var diffData = diff(data, oldData);
var light = this.light;
var rendererSystem = this.rendererSystem;
var self = this;
// Existing light.
if (light && !('type' in diffData)) {
var shadowsLoaded = false;
// Light type has not changed. Update light.
Object.keys(diffData).forEach(function (key) {
var value = data[key];
switch (key) {
case 'color': {
light.color.set(value);
rendererSystem.applyColorCorrection(light.color);
break;
}
case 'groundColor': {
light.groundColor.set(value);
rendererSystem.applyColorCorrection(light.groundColor);
break;
}
case 'angle': {
light.angle = degToRad(value);
break;
}
case 'target': {
// Reset target if selector is null.
if (value === null) {
if (data.type === 'spot' || data.type === 'directional') {
light.target = self.defaultTarget;
}
} else {
// Target specified, set target to entity's `object3D` when it is loaded.
if (value.hasLoaded) {
self.onSetTarget(value, light);
} else {
value.addEventListener('loaded', bind(self.onSetTarget, self, value, light));
}
}
break;
}
case 'castShadow':
case 'shadowBias':
case 'shadowCameraFar':
case 'shadowCameraFov':
case 'shadowCameraNear':
case 'shadowCameraTop':
case 'shadowCameraRight':
case 'shadowCameraBottom':
case 'shadowCameraLeft':
case 'shadowCameraVisible':
case 'shadowMapHeight':
case 'shadowMapWidth':
case 'shadowRadius':
if (!shadowsLoaded) {
self.updateShadow();
shadowsLoaded = true;
}
break;
default: {
light[key] = value;
}
}
});
return;
}
// No light yet or light type has changed. Create and add light.
this.setLight(this.data);
this.updateShadow();
} | javascript | function (oldData) {
var data = this.data;
var diffData = diff(data, oldData);
var light = this.light;
var rendererSystem = this.rendererSystem;
var self = this;
// Existing light.
if (light && !('type' in diffData)) {
var shadowsLoaded = false;
// Light type has not changed. Update light.
Object.keys(diffData).forEach(function (key) {
var value = data[key];
switch (key) {
case 'color': {
light.color.set(value);
rendererSystem.applyColorCorrection(light.color);
break;
}
case 'groundColor': {
light.groundColor.set(value);
rendererSystem.applyColorCorrection(light.groundColor);
break;
}
case 'angle': {
light.angle = degToRad(value);
break;
}
case 'target': {
// Reset target if selector is null.
if (value === null) {
if (data.type === 'spot' || data.type === 'directional') {
light.target = self.defaultTarget;
}
} else {
// Target specified, set target to entity's `object3D` when it is loaded.
if (value.hasLoaded) {
self.onSetTarget(value, light);
} else {
value.addEventListener('loaded', bind(self.onSetTarget, self, value, light));
}
}
break;
}
case 'castShadow':
case 'shadowBias':
case 'shadowCameraFar':
case 'shadowCameraFov':
case 'shadowCameraNear':
case 'shadowCameraTop':
case 'shadowCameraRight':
case 'shadowCameraBottom':
case 'shadowCameraLeft':
case 'shadowCameraVisible':
case 'shadowMapHeight':
case 'shadowMapWidth':
case 'shadowRadius':
if (!shadowsLoaded) {
self.updateShadow();
shadowsLoaded = true;
}
break;
default: {
light[key] = value;
}
}
});
return;
}
// No light yet or light type has changed. Create and add light.
this.setLight(this.data);
this.updateShadow();
} | [
"function",
"(",
"oldData",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"diffData",
"=",
"diff",
"(",
"data",
",",
"oldData",
")",
";",
"var",
"light",
"=",
"this",
".",
"light",
";",
"var",
"rendererSystem",
"=",
"this",
".",
"r... | (Re)create or update light. | [
"(",
"Re",
")",
"create",
"or",
"update",
"light",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/light.js#L59-L138 | train | Updates the light with the new data | [
30522,
3853,
1006,
2214,
2850,
2696,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
4487,
4246,
2850,
2696,
1027,
4487,
4246,
1006,
2951,
1010,
2214,
2850,
2696,
1007,
1025,
13075,
2422,
1027,
2023,
1012,
2422,
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... | |
SeleniumHQ/selenium | javascript/selenium-core/xpath/util.js | reverseInplace | function reverseInplace(array) {
for (var i = 0; i < array.length / 2; ++i) {
var h = array[i];
var ii = array.length - i - 1;
array[i] = array[ii];
array[ii] = h;
}
} | javascript | function reverseInplace(array) {
for (var i = 0; i < array.length / 2; ++i) {
var h = array[i];
var ii = array.length - i - 1;
array[i] = array[ii];
array[ii] = h;
}
} | [
"function",
"reverseInplace",
"(",
"array",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
"/",
"2",
";",
"++",
"i",
")",
"{",
"var",
"h",
"=",
"array",
"[",
"i",
"]",
";",
"var",
"ii",
"=",
"array",
".",
... | Reverses the given array in place. | [
"Reverses",
"the",
"given",
"array",
"in",
"place",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L197-L204 | train | reverse inplace | [
30522,
3853,
7901,
2378,
24759,
10732,
1006,
9140,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
9140,
1012,
3091,
1013,
1016,
1025,
1009,
1009,
1045,
1007,
1063,
13075,
1044,
1027,
9140,
1031,
1045,
1033,
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... |
heyui/heyui | src/plugins/popper/index.js | toValue | function toValue(str, measurement, popperOffsets, referenceOffsets) {
// separate value from unit
var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
var value = +split[1];
var unit = split[2];
// If it's not a number it's an operator, I guess
if (!value) {
return str;
}
if (unit.indexOf('%') === 0) {
var element = void 0;
switch (unit) {
case '%p':
element = popperOffsets;
break;
case '%':
case '%r':
default:
element = referenceOffsets;
}
var rect = getClientRect(element);
return rect[measurement] / 100 * value;
} else if (unit === 'vh' || unit === 'vw') {
// if is a vh or vw, we calculate the size based on the viewport
var size = void 0;
if (unit === 'vh') {
size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
} else {
size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
}
return size / 100 * value;
} else {
// if is an explicit pixel unit, we get rid of the unit and keep the value
// if is an implicit unit, it's px, and we return just the value
return value;
}
} | javascript | function toValue(str, measurement, popperOffsets, referenceOffsets) {
// separate value from unit
var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
var value = +split[1];
var unit = split[2];
// If it's not a number it's an operator, I guess
if (!value) {
return str;
}
if (unit.indexOf('%') === 0) {
var element = void 0;
switch (unit) {
case '%p':
element = popperOffsets;
break;
case '%':
case '%r':
default:
element = referenceOffsets;
}
var rect = getClientRect(element);
return rect[measurement] / 100 * value;
} else if (unit === 'vh' || unit === 'vw') {
// if is a vh or vw, we calculate the size based on the viewport
var size = void 0;
if (unit === 'vh') {
size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
} else {
size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
}
return size / 100 * value;
} else {
// if is an explicit pixel unit, we get rid of the unit and keep the value
// if is an implicit unit, it's px, and we return just the value
return value;
}
} | [
"function",
"toValue",
"(",
"str",
",",
"measurement",
",",
"popperOffsets",
",",
"referenceOffsets",
")",
"{",
"// separate value from unit",
"var",
"split",
"=",
"str",
".",
"match",
"(",
"/",
"((?:\\-|\\+)?\\d*\\.?\\d*)(.*)",
"/",
")",
";",
"var",
"value",
"=... | Converts a string containing value + unit into a px value number
@function
@memberof {modifiers~offset}
@private
@argument {String} str - Value + unit string
@argument {String} measurement - `height` or `width`
@argument {Object} popperOffsets
@argument {Object} referenceOffsets
@returns {Number|String}
Value in pixels, or original string if no values were extracted | [
"Converts",
"a",
"string",
"containing",
"value",
"+",
"unit",
"into",
"a",
"px",
"value",
"number"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1676-L1715 | train | Converts a string to a value in a number of pixels | [
30522,
3853,
2000,
10175,
5657,
1006,
2358,
2099,
1010,
10903,
1010,
3769,
4842,
27475,
8454,
1010,
4431,
27475,
8454,
1007,
1063,
1013,
1013,
3584,
3643,
2013,
3131,
13075,
3975,
1027,
2358,
2099,
1012,
2674,
1006,
1013,
1006,
1006,
1029,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/jquery-mobile-custom.js | validStyle | function validStyle( prop, value, check_vend ) {
var div = document.createElement( 'div' ),
uc = function( txt ) {
return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
},
vend_pref = function( vend ) {
if( vend === "" ) {
return "";
} else {
return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
}
},
check_style = function( vend ) {
var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
uc_vend = uc( vend ),
propStyle = uc_vend + ( uc_vend === "" ? prop : uc( prop ) );
div.setAttribute( "style", vend_prop );
if ( !!div.style[ propStyle ] ) {
ret = true;
}
},
check_vends = check_vend ? check_vend : vendors,
ret;
for( var i = 0; i < check_vends.length; i++ ) {
check_style( check_vends[i] );
}
return !!ret;
} | javascript | function validStyle( prop, value, check_vend ) {
var div = document.createElement( 'div' ),
uc = function( txt ) {
return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
},
vend_pref = function( vend ) {
if( vend === "" ) {
return "";
} else {
return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
}
},
check_style = function( vend ) {
var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
uc_vend = uc( vend ),
propStyle = uc_vend + ( uc_vend === "" ? prop : uc( prop ) );
div.setAttribute( "style", vend_prop );
if ( !!div.style[ propStyle ] ) {
ret = true;
}
},
check_vends = check_vend ? check_vend : vendors,
ret;
for( var i = 0; i < check_vends.length; i++ ) {
check_style( check_vends[i] );
}
return !!ret;
} | [
"function",
"validStyle",
"(",
"prop",
",",
"value",
",",
"check_vend",
")",
"{",
"var",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
",",
"uc",
"=",
"function",
"(",
"txt",
")",
"{",
"return",
"txt",
".",
"charAt",
"(",
"0",
")",... | only used to rule out box shadow, as it's filled opaque on BB 5 and lower | [
"only",
"used",
"to",
"rule",
"out",
"box",
"shadow",
"as",
"it",
"s",
"filled",
"opaque",
"on",
"BB",
"5",
"and",
"lower"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jquery-mobile-custom.js#L746-L776 | train | validStyle - Validates a style property | [
30522,
3853,
9398,
21756,
2571,
1006,
17678,
1010,
3643,
1010,
4638,
1035,
2310,
4859,
1007,
1063,
13075,
4487,
2615,
30524,
1010,
2310,
4859,
1035,
3653,
2546,
1027,
3853,
1006,
2310,
4859,
1007,
1063,
2065,
1006,
2310,
4859,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/glob.js | GlobSync | function GlobSync(pattern, options, shouldIgnore) {
/**
* We don't put this thing to argument `options` to avoid
* further problems, such as `options` validation.
*
* Use `Symbol` as much as possible to avoid confliction.
*/
this[IGNORE] = shouldIgnore;
Sync.call(this, pattern, options);
} | javascript | function GlobSync(pattern, options, shouldIgnore) {
/**
* We don't put this thing to argument `options` to avoid
* further problems, such as `options` validation.
*
* Use `Symbol` as much as possible to avoid confliction.
*/
this[IGNORE] = shouldIgnore;
Sync.call(this, pattern, options);
} | [
"function",
"GlobSync",
"(",
"pattern",
",",
"options",
",",
"shouldIgnore",
")",
"{",
"/**\n * We don't put this thing to argument `options` to avoid\n * further problems, such as `options` validation.\n *\n * Use `Symbol` as much as possible to avoid confliction.\n */",
"... | Subclass of `glob.GlobSync`
@param {string} pattern Pattern to be matched.
@param {Object} options `options` for `glob`
@param {function()} shouldIgnore Method to check whether a directory should be ignored.
@constructor | [
"Subclass",
"of",
"glob",
".",
"GlobSync"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/glob.js#L27-L38 | train | Sync function for globs | [
30522,
3853,
1043,
4135,
5910,
6038,
2278,
1006,
5418,
1010,
7047,
1010,
2323,
23773,
5686,
1007,
1063,
1013,
1008,
1008,
1008,
2057,
2123,
1005,
1056,
2404,
2023,
2518,
2000,
6685,
1036,
7047,
1036,
2000,
4468,
1008,
2582,
3471,
1010,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oResult, bWrapExpression) {
if (oResult.result === "constant") {
switch (oResult.category) {
case "boolean":
case "number":
return String(oResult.value);
// no default
}
}
if (bWrapExpression) {
Expression.wrapExpression(oResult);
}
return Basics.resultToString(oResult, true, false);
} | javascript | function (oResult, bWrapExpression) {
if (oResult.result === "constant") {
switch (oResult.category) {
case "boolean":
case "number":
return String(oResult.value);
// no default
}
}
if (bWrapExpression) {
Expression.wrapExpression(oResult);
}
return Basics.resultToString(oResult, true, false);
} | [
"function",
"(",
"oResult",
",",
"bWrapExpression",
")",
"{",
"if",
"(",
"oResult",
".",
"result",
"===",
"\"constant\"",
")",
"{",
"switch",
"(",
"oResult",
".",
"category",
")",
"{",
"case",
"\"boolean\"",
":",
"case",
"\"number\"",
":",
"return",
"Strin... | Formats the result to be an operand for a logical or comparison operator. Handles
constants accordingly.
@param {object} oResult
a result object with category
@param {boolean} bWrapExpression
if true, wrap an expression in <code>oResult</code> with "()"
@returns {string}
the formatted result | [
"Formats",
"the",
"result",
"to",
"be",
"an",
"operand",
"for",
"a",
"logical",
"or",
"comparison",
"operator",
".",
"Handles",
"constants",
"accordingly",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L540-L553 | train | Converts the given result to a string | [
30522,
3853,
1006,
10848,
23722,
2102,
1010,
1038,
13088,
24065,
2595,
20110,
3258,
1007,
1063,
2065,
1006,
10848,
23722,
2102,
1012,
2765,
1027,
1027,
1027,
1000,
5377,
1000,
1007,
1063,
6942,
1006,
10848,
23722,
2102,
1012,
4696,
1007,
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... | |
moleculerjs/moleculer | src/middlewares/metrics.js | processExtraMetrics | function processExtraMetrics(ctx, payload) {
// extra metrics (params and meta)
if (_.isObject(ctx.action.metrics)) {
// custom metrics def
assignExtraMetrics(ctx, "params", payload);
assignExtraMetrics(ctx, "meta", payload);
}
} | javascript | function processExtraMetrics(ctx, payload) {
// extra metrics (params and meta)
if (_.isObject(ctx.action.metrics)) {
// custom metrics def
assignExtraMetrics(ctx, "params", payload);
assignExtraMetrics(ctx, "meta", payload);
}
} | [
"function",
"processExtraMetrics",
"(",
"ctx",
",",
"payload",
")",
"{",
"// extra metrics (params and meta)",
"if",
"(",
"_",
".",
"isObject",
"(",
"ctx",
".",
"action",
".",
"metrics",
")",
")",
"{",
"// custom metrics def",
"assignExtraMetrics",
"(",
"ctx",
"... | Decide and process extra metrics taking into account action definitions
@param {Context} ctx
@param {any} payload Object for assignment.
@private | [
"Decide",
"and",
"process",
"extra",
"metrics",
"taking",
"into",
"account",
"action",
"definitions"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/metrics.js#L154-L161 | train | process extra metrics | [
30522,
3853,
2832,
10288,
6494,
12589,
2015,
1006,
14931,
2595,
1010,
18093,
1007,
1063,
1013,
1013,
4469,
12046,
2015,
1006,
11498,
5244,
1998,
18804,
1007,
2065,
1006,
1035,
1012,
11163,
2497,
20614,
1006,
14931,
2595,
1012,
2895,
1012,
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... |
LLK/scratch-blocks | blocks_horizontal/wedo.js | function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg',
value: 'mystery', width: 48, height: 48, alt: 'Mystery'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg',
value: 'yellow', width: 48, height: 48, alt: 'Yellow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg',
value: 'orange', width: 48, height: 48, alt: 'Orange'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg',
value: 'coral', width: 48, height: 48, alt: 'Coral'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg',
value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg',
value: 'purple', width: 48, height: 48, alt: 'Purple'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg',
value: 'blue', width: 48, height: 48, alt: 'Blue'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg',
value: 'green', width: 48, height: 48, alt: 'Green'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg',
value: 'white', width: 48, height: 48, alt: 'White'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.looks.primary,
Blockly.Colours.looks.secondary,
Blockly.Colours.looks.tertiary
);
} | javascript | function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_mystery.svg',
value: 'mystery', width: 48, height: 48, alt: 'Mystery'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_yellow.svg',
value: 'yellow', width: 48, height: 48, alt: 'Yellow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_orange.svg',
value: 'orange', width: 48, height: 48, alt: 'Orange'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_coral.svg',
value: 'coral', width: 48, height: 48, alt: 'Coral'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_magenta.svg',
value: 'magenta', width: 48, height: 48, alt: 'Magenta'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_purple.svg',
value: 'purple', width: 48, height: 48, alt: 'Purple'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_blue.svg',
value: 'blue', width: 48, height: 48, alt: 'Blue'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_green.svg',
value: 'green', width: 48, height: 48, alt: 'Green'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/set-led_white.svg',
value: 'white', width: 48, height: 48, alt: 'White'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.looks.primary,
Blockly.Colours.looks.secondary,
Blockly.Colours.looks.tertiary
);
} | [
"function",
"(",
")",
"{",
"this",
".",
"appendDummyInput",
"(",
")",
".",
"appendField",
"(",
"new",
"Blockly",
".",
"FieldIconMenu",
"(",
"[",
"{",
"src",
":",
"Blockly",
".",
"mainWorkspace",
".",
"options",
".",
"pathToMedia",
"+",
"'icons/set-led_myster... | Block for set color drop-down (used for shadow).
@this Blockly.Block | [
"Block",
"for",
"set",
"color",
"drop",
"-",
"down",
"(",
"used",
"for",
"shadow",
")",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_horizontal/wedo.js#L38-L66 | train | Block for the cluster | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
10439,
10497,
8566,
18879,
2378,
18780,
1006,
1007,
1012,
10439,
10497,
3790,
1006,
2047,
3796,
2135,
1012,
2492,
28524,
3549,
2226,
1006,
1031,
1063,
5034,
2278,
1024,
3796,
2135,
1012,
2364,
9316... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/_V2Requestor.js | convertLiteral | function convertLiteral(sPropertyName, sValue) {
var oPropertyMetadata = oEntityType[sPropertyName];
if (oPropertyMetadata.$Type !== "Edm.String") {
sValue = that.formatPropertyAsLiteral(
_Helper.parseLiteral(sValue, oPropertyMetadata.$Type, sPath),
oPropertyMetadata);
}
return encodeURIComponent(sValue);
} | javascript | function convertLiteral(sPropertyName, sValue) {
var oPropertyMetadata = oEntityType[sPropertyName];
if (oPropertyMetadata.$Type !== "Edm.String") {
sValue = that.formatPropertyAsLiteral(
_Helper.parseLiteral(sValue, oPropertyMetadata.$Type, sPath),
oPropertyMetadata);
}
return encodeURIComponent(sValue);
} | [
"function",
"convertLiteral",
"(",
"sPropertyName",
",",
"sValue",
")",
"{",
"var",
"oPropertyMetadata",
"=",
"oEntityType",
"[",
"sPropertyName",
"]",
";",
"if",
"(",
"oPropertyMetadata",
".",
"$Type",
"!==",
"\"Edm.String\"",
")",
"{",
"sValue",
"=",
"that",
... | /*
Converts the literal to V2 syntax.
@param {string} sPropertyName The name of the property in the metadata
@param {string} sValue The value in the key predicate in V4 syntax
@returns {string} The value in V2 syntax | [
"/",
"*",
"Converts",
"the",
"literal",
"to",
"V2",
"syntax",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2Requestor.js#L309-L318 | train | Converts a literal value to a string | [
30522,
3853,
10463,
22779,
7941,
1006,
11867,
18981,
15010,
18442,
1010,
17917,
2389,
5657,
1007,
1063,
13075,
6728,
18981,
15010,
11368,
8447,
2696,
1027,
1051,
4765,
3012,
13874,
1031,
11867,
18981,
15010,
18442,
1033,
1025,
2065,
1006,
672... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/text.js | function () {
var anchor;
var baseline;
var el = this.el;
var data = this.data;
var geometry = this.geometry;
var geometryComponent;
var height;
var layout;
var mesh = this.mesh;
var textRenderWidth;
var textScale;
var width;
var x;
var y;
if (!geometry.layout) { return; }
// Determine width to use (defined width, geometry's width, or default width).
geometryComponent = el.getAttribute('geometry');
width = data.width || (geometryComponent && geometryComponent.width) || DEFAULT_WIDTH;
// Determine wrap pixel count. Either specified or by experimental fudge factor.
// Note that experimental factor will never be correct for variable width fonts.
textRenderWidth = computeWidth(data.wrapPixels, data.wrapCount,
this.currentFont.widthFactor);
textScale = width / textRenderWidth;
// Determine height to use.
layout = geometry.layout;
height = textScale * (layout.height + layout.descender);
// Update geometry dimensions to match text layout if width and height are set to 0.
// For example, scales a plane to fit text.
if (geometryComponent && geometryComponent.primitive === 'plane') {
if (!geometryComponent.width) { el.setAttribute('geometry', 'width', width); }
if (!geometryComponent.height) { el.setAttribute('geometry', 'height', height); }
}
// Calculate X position to anchor text left, center, or right.
anchor = data.anchor === 'align' ? data.align : data.anchor;
if (anchor === 'left') {
x = 0;
} else if (anchor === 'right') {
x = -1 * layout.width;
} else if (anchor === 'center') {
x = -1 * layout.width / 2;
} else {
throw new TypeError('Invalid text.anchor property value', anchor);
}
// Calculate Y position to anchor text top, center, or bottom.
baseline = data.baseline;
if (baseline === 'bottom') {
y = 0;
} else if (baseline === 'top') {
y = -1 * layout.height + layout.ascender;
} else if (baseline === 'center') {
y = -1 * layout.height / 2;
} else {
throw new TypeError('Invalid text.baseline property value', baseline);
}
// Position and scale mesh to apply layout.
mesh.position.x = x * textScale + data.xOffset;
mesh.position.y = y * textScale;
// Place text slightly in front to avoid Z-fighting.
mesh.position.z = data.zOffset;
mesh.scale.set(textScale, -1 * textScale, textScale);
} | javascript | function () {
var anchor;
var baseline;
var el = this.el;
var data = this.data;
var geometry = this.geometry;
var geometryComponent;
var height;
var layout;
var mesh = this.mesh;
var textRenderWidth;
var textScale;
var width;
var x;
var y;
if (!geometry.layout) { return; }
// Determine width to use (defined width, geometry's width, or default width).
geometryComponent = el.getAttribute('geometry');
width = data.width || (geometryComponent && geometryComponent.width) || DEFAULT_WIDTH;
// Determine wrap pixel count. Either specified or by experimental fudge factor.
// Note that experimental factor will never be correct for variable width fonts.
textRenderWidth = computeWidth(data.wrapPixels, data.wrapCount,
this.currentFont.widthFactor);
textScale = width / textRenderWidth;
// Determine height to use.
layout = geometry.layout;
height = textScale * (layout.height + layout.descender);
// Update geometry dimensions to match text layout if width and height are set to 0.
// For example, scales a plane to fit text.
if (geometryComponent && geometryComponent.primitive === 'plane') {
if (!geometryComponent.width) { el.setAttribute('geometry', 'width', width); }
if (!geometryComponent.height) { el.setAttribute('geometry', 'height', height); }
}
// Calculate X position to anchor text left, center, or right.
anchor = data.anchor === 'align' ? data.align : data.anchor;
if (anchor === 'left') {
x = 0;
} else if (anchor === 'right') {
x = -1 * layout.width;
} else if (anchor === 'center') {
x = -1 * layout.width / 2;
} else {
throw new TypeError('Invalid text.anchor property value', anchor);
}
// Calculate Y position to anchor text top, center, or bottom.
baseline = data.baseline;
if (baseline === 'bottom') {
y = 0;
} else if (baseline === 'top') {
y = -1 * layout.height + layout.ascender;
} else if (baseline === 'center') {
y = -1 * layout.height / 2;
} else {
throw new TypeError('Invalid text.baseline property value', baseline);
}
// Position and scale mesh to apply layout.
mesh.position.x = x * textScale + data.xOffset;
mesh.position.y = y * textScale;
// Place text slightly in front to avoid Z-fighting.
mesh.position.z = data.zOffset;
mesh.scale.set(textScale, -1 * textScale, textScale);
} | [
"function",
"(",
")",
"{",
"var",
"anchor",
";",
"var",
"baseline",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"geometry",
"=",
"this",
".",
"geometry",
";",
"var",
"geometryComponent",
";",
... | Update layout with anchor, alignment, baseline, and considering any meshes. | [
"Update",
"layout",
"with",
"anchor",
"alignment",
"baseline",
"and",
"considering",
"any",
"meshes",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L266-L335 | train | Calculate the geometry dimensions and baseline. | [
30522,
3853,
1006,
1007,
1063,
13075,
8133,
1025,
13075,
26163,
1025,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
10988,
1027,
2023,
1012,
10988,
1025,
13075,
10988,
9006,
29513,
3372,
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... | |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function (elem) {
this._forEachNode(this._getAllNodesWithTag(elem, ["br"]), function(br) {
var next = br.nextSibling;
// Whether 2 or more <br> elements have been found and replaced with a
// <p> block.
var replaced = false;
// If we find a <br> chain, remove the <br>s until we hit another element
// or non-whitespace. This leaves behind the first <br> in the chain
// (which will be replaced with a <p> later).
while ((next = this._nextElement(next)) && (next.tagName == "BR")) {
replaced = true;
var brSibling = next.nextSibling;
next.parentNode.removeChild(next);
next = brSibling;
}
// If we removed a <br> chain, replace the remaining <br> with a <p>. Add
// all sibling nodes as children of the <p> until we hit another <br>
// chain.
if (replaced) {
var p = this._doc.createElement("p");
br.parentNode.replaceChild(p, br);
next = p.nextSibling;
while (next) {
// If we've hit another <br><br>, we're done adding children to this <p>.
if (next.tagName == "BR") {
var nextElem = this._nextElement(next.nextSibling);
if (nextElem && nextElem.tagName == "BR")
break;
}
if (!this._isPhrasingContent(next)) break;
// Otherwise, make this node a child of the new <p>.
var sibling = next.nextSibling;
p.appendChild(next);
next = sibling;
}
while (p.lastChild && this._isWhitespace(p.lastChild)) p.removeChild(p.lastChild);
}
});
} | javascript | function (elem) {
this._forEachNode(this._getAllNodesWithTag(elem, ["br"]), function(br) {
var next = br.nextSibling;
// Whether 2 or more <br> elements have been found and replaced with a
// <p> block.
var replaced = false;
// If we find a <br> chain, remove the <br>s until we hit another element
// or non-whitespace. This leaves behind the first <br> in the chain
// (which will be replaced with a <p> later).
while ((next = this._nextElement(next)) && (next.tagName == "BR")) {
replaced = true;
var brSibling = next.nextSibling;
next.parentNode.removeChild(next);
next = brSibling;
}
// If we removed a <br> chain, replace the remaining <br> with a <p>. Add
// all sibling nodes as children of the <p> until we hit another <br>
// chain.
if (replaced) {
var p = this._doc.createElement("p");
br.parentNode.replaceChild(p, br);
next = p.nextSibling;
while (next) {
// If we've hit another <br><br>, we're done adding children to this <p>.
if (next.tagName == "BR") {
var nextElem = this._nextElement(next.nextSibling);
if (nextElem && nextElem.tagName == "BR")
break;
}
if (!this._isPhrasingContent(next)) break;
// Otherwise, make this node a child of the new <p>.
var sibling = next.nextSibling;
p.appendChild(next);
next = sibling;
}
while (p.lastChild && this._isWhitespace(p.lastChild)) p.removeChild(p.lastChild);
}
});
} | [
"function",
"(",
"elem",
")",
"{",
"this",
".",
"_forEachNode",
"(",
"this",
".",
"_getAllNodesWithTag",
"(",
"elem",
",",
"[",
"\"br\"",
"]",
")",
",",
"function",
"(",
"br",
")",
"{",
"var",
"next",
"=",
"br",
".",
"nextSibling",
";",
"// Whether 2 o... | Replaces 2 or more successive <br> elements with a single <p>.
Whitespace between <br> elements are ignored. For example:
<div>foo<br>bar<br> <br><br>abc</div>
will become:
<div>foo<br>bar<p>abc</p></div> | [
"Replaces",
"2",
"or",
"more",
"successive",
"<br",
">",
"elements",
"with",
"a",
"single",
"<p",
">",
".",
"Whitespace",
"between",
"<br",
">",
"elements",
"are",
"ignored",
".",
"For",
"example",
":",
"<div",
">",
"foo<br",
">",
"bar<br",
">",
"<br",
... | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L466-L511 | train | Removes all BR elements in the given element. | [
30522,
3853,
1006,
3449,
6633,
1007,
1063,
2023,
1012,
1035,
18921,
6776,
3630,
3207,
1006,
2023,
1012,
1035,
2131,
8095,
3630,
6155,
24415,
15900,
1006,
3449,
6633,
1010,
1031,
1000,
7987,
1000,
1033,
1007,
1010,
3853,
1006,
7987,
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... | |
SheetJS/js-xlsx | xlsx.js | parse_BIFF2FONTXTRA | function parse_BIFF2FONTXTRA(blob, length) {
blob.l += 6; // unknown
blob.l += 2; // font weight "bls"
blob.l += 1; // charset
blob.l += 3; // unknown
blob.l += 1; // font family
blob.l += length - 13;
} | javascript | function parse_BIFF2FONTXTRA(blob, length) {
blob.l += 6; // unknown
blob.l += 2; // font weight "bls"
blob.l += 1; // charset
blob.l += 3; // unknown
blob.l += 1; // font family
blob.l += length - 13;
} | [
"function",
"parse_BIFF2FONTXTRA",
"(",
"blob",
",",
"length",
")",
"{",
"blob",
".",
"l",
"+=",
"6",
";",
"// unknown",
"blob",
".",
"l",
"+=",
"2",
";",
"// font weight \"bls\"",
"blob",
".",
"l",
"+=",
"1",
";",
"// charset",
"blob",
".",
"l",
"+=",... | /* TODO: convert to BIFF8 font struct | [
"/",
"*",
"TODO",
":",
"convert",
"to",
"BIFF8",
"font",
"struct"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6607-L6614 | train | Parse BIFF2 font tra | [
30522,
3853,
11968,
3366,
1035,
12170,
4246,
2475,
14876,
3372,
18413,
2527,
1006,
1038,
4135,
2497,
1010,
3091,
1007,
1063,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1020,
1025,
1013,
1013,
4242,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/preload-cssom.js | loadCssom | function loadCssom(options) {
const { rootIndex } = options;
const q = axe.utils.queue();
const sheets = getStylesheetsOfRootNode(options);
if (!sheets) {
return q;
}
sheets.forEach((sheet, sheetIndex) => {
const priority = [rootIndex, sheetIndex];
try {
const deferredQ = parseNonCrossOriginStylesheet(sheet, options, priority);
q.defer(deferredQ);
} catch (e) {
// cross-origin stylesheet -> make an XHR and q the response
const deferredQ = parseCrossOriginStylesheet(
sheet.href,
options,
priority
);
q.defer(deferredQ);
}
});
return q;
} | javascript | function loadCssom(options) {
const { rootIndex } = options;
const q = axe.utils.queue();
const sheets = getStylesheetsOfRootNode(options);
if (!sheets) {
return q;
}
sheets.forEach((sheet, sheetIndex) => {
const priority = [rootIndex, sheetIndex];
try {
const deferredQ = parseNonCrossOriginStylesheet(sheet, options, priority);
q.defer(deferredQ);
} catch (e) {
// cross-origin stylesheet -> make an XHR and q the response
const deferredQ = parseCrossOriginStylesheet(
sheet.href,
options,
priority
);
q.defer(deferredQ);
}
});
return q;
} | [
"function",
"loadCssom",
"(",
"options",
")",
"{",
"const",
"{",
"rootIndex",
"}",
"=",
"options",
";",
"const",
"q",
"=",
"axe",
".",
"utils",
".",
"queue",
"(",
")",
";",
"const",
"sheets",
"=",
"getStylesheetsOfRootNode",
"(",
"options",
")",
";",
"... | Returns `axe.utils.queue` of CSSStyleSheet(s) for a given root node
@param {Object} options configuration options
@property {Object} options.rootNode document or document fragment
@property {Number} options.rootIndex a number representing the index of the document or document fragment, used for priority computation
@property {String} options.shadowId an id if undefined denotes that given root is a document fragment/ shadowDOM
@property {Number} options.timeout abort duration for network request
@property {Function} options.convertDataToStylesheet a utility function to generate a style sheet from given data (text)
@return {Object} queue | [
"Returns",
"axe",
".",
"utils",
".",
"queue",
"of",
"CSSStyleSheet",
"(",
"s",
")",
"for",
"a",
"given",
"root",
"node"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/preload-cssom.js#L177-L204 | train | Load CSSOM from the root node | [
30522,
3853,
7170,
6169,
25426,
1006,
7047,
1007,
1063,
9530,
3367,
1063,
7117,
22254,
10288,
1065,
1027,
7047,
1025,
9530,
3367,
1053,
1027,
12946,
1012,
21183,
12146,
1012,
24240,
1006,
1007,
1025,
9530,
3367,
8697,
1027,
4152,
27983,
409... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ExtensionAPI.js | ExtensionAPI | function ExtensionAPI(chartInstance) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(chartInstance[name], chartInstance);
}, this);
} | javascript | function ExtensionAPI(chartInstance) {
zrUtil.each(echartsAPIList, function (name) {
this[name] = zrUtil.bind(chartInstance[name], chartInstance);
}, this);
} | [
"function",
"ExtensionAPI",
"(",
"chartInstance",
")",
"{",
"zrUtil",
".",
"each",
"(",
"echartsAPIList",
",",
"function",
"(",
"name",
")",
"{",
"this",
"[",
"name",
"]",
"=",
"zrUtil",
".",
"bind",
"(",
"chartInstance",
"[",
"name",
"]",
",",
"chartIns... | And `getCoordinateSystems` and `getComponentByElement` will be injected in echarts.js | [
"And",
"getCoordinateSystems",
"and",
"getComponentByElement",
"will",
"be",
"injected",
"in",
"echarts",
".",
"js"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/ExtensionAPI.js#L29-L33 | train | Extension API constructor | [
30522,
3853,
5331,
9331,
2072,
1006,
3673,
7076,
26897,
1007,
1063,
1062,
22134,
4014,
1012,
2169,
1006,
14925,
10686,
3736,
8197,
9863,
1010,
3853,
1006,
2171,
1007,
1063,
2023,
1031,
2171,
1033,
1027,
1062,
22134,
4014,
1012,
14187,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CloseOthers/main.js | prefChangeHandler | function prefChangeHandler() {
var prefs = getPreferences();
if (prefs.closeBelow !== menuEntriesShown.closeBelow) {
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeBelow);
}
}
if (prefs.closeOthers !== menuEntriesShown.closeOthers) {
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeOthers);
}
}
if (prefs.closeAbove !== menuEntriesShown.closeAbove) {
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeAbove);
}
}
menuEntriesShown = prefs;
} | javascript | function prefChangeHandler() {
var prefs = getPreferences();
if (prefs.closeBelow !== menuEntriesShown.closeBelow) {
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeBelow);
}
}
if (prefs.closeOthers !== menuEntriesShown.closeOthers) {
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeOthers);
}
}
if (prefs.closeAbove !== menuEntriesShown.closeAbove) {
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
} else {
workingSetListCmenu.removeMenuItem(closeAbove);
}
}
menuEntriesShown = prefs;
} | [
"function",
"prefChangeHandler",
"(",
")",
"{",
"var",
"prefs",
"=",
"getPreferences",
"(",
")",
";",
"if",
"(",
"prefs",
".",
"closeBelow",
"!==",
"menuEntriesShown",
".",
"closeBelow",
")",
"{",
"if",
"(",
"prefs",
".",
"closeBelow",
")",
"{",
"workingSe... | When the preferences changed, add/remove the required menu items | [
"When",
"the",
"preferences",
"changed",
"add",
"/",
"remove",
"the",
"required",
"menu",
"items"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L124-L152 | train | Change handler for the preferences property | [
30522,
3853,
3653,
11329,
18003,
24660,
21222,
1006,
1007,
1063,
13075,
3653,
10343,
1027,
2131,
28139,
25523,
2015,
1006,
1007,
1025,
2065,
1006,
3653,
10343,
1012,
2485,
8671,
5004,
999,
1027,
1027,
12183,
4765,
5134,
22231,
7962,
1012,
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/JSDOMParser.js | function (quote) {
var str;
var n = this.html.indexOf(quote, this.currentChar);
if (n === -1) {
this.currentChar = this.html.length;
str = null;
} else {
str = this.html.substring(this.currentChar, n);
this.currentChar = n + 1;
}
return str;
} | javascript | function (quote) {
var str;
var n = this.html.indexOf(quote, this.currentChar);
if (n === -1) {
this.currentChar = this.html.length;
str = null;
} else {
str = this.html.substring(this.currentChar, n);
this.currentChar = n + 1;
}
return str;
} | [
"function",
"(",
"quote",
")",
"{",
"var",
"str",
";",
"var",
"n",
"=",
"this",
".",
"html",
".",
"indexOf",
"(",
"quote",
",",
"this",
".",
"currentChar",
")",
";",
"if",
"(",
"n",
"===",
"-",
"1",
")",
"{",
"this",
".",
"currentChar",
"=",
"t... | Called after a quote character is read. This finds the next quote
character and returns the text string in between. | [
"Called",
"after",
"a",
"quote",
"character",
"is",
"read",
".",
"This",
"finds",
"the",
"next",
"quote",
"character",
"and",
"returns",
"the",
"text",
"string",
"in",
"between",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L885-L897 | train | Get the next line of the current line | [
30522,
3853,
1006,
14686,
1007,
1063,
13075,
2358,
2099,
1025,
13075,
1050,
1027,
2023,
1012,
16129,
1012,
5950,
11253,
1006,
14686,
1010,
2023,
1012,
2783,
7507,
2099,
1007,
1025,
2065,
1006,
1050,
1027,
1027,
1027,
1011,
1015,
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... | |
keplergl/kepler.gl | src/reducers/map-state-updaters.js | getMapDimForSplitMap | function getMapDimForSplitMap(isSplit, state) {
// cases:
// 1. state split: true - isSplit: true
// do nothing
// 2. state split: false - isSplit: false
// do nothing
if (state.isSplit === isSplit) {
return {};
}
const width = state.isSplit && !isSplit ?
// 3. state split: true - isSplit: false
// double width
state.width * 2
// 4. state split: false - isSplit: true
// split width
: state.width / 2;
return {
width
};
} | javascript | function getMapDimForSplitMap(isSplit, state) {
// cases:
// 1. state split: true - isSplit: true
// do nothing
// 2. state split: false - isSplit: false
// do nothing
if (state.isSplit === isSplit) {
return {};
}
const width = state.isSplit && !isSplit ?
// 3. state split: true - isSplit: false
// double width
state.width * 2
// 4. state split: false - isSplit: true
// split width
: state.width / 2;
return {
width
};
} | [
"function",
"getMapDimForSplitMap",
"(",
"isSplit",
",",
"state",
")",
"{",
"// cases:",
"// 1. state split: true - isSplit: true",
"// do nothing",
"// 2. state split: false - isSplit: false",
"// do nothing",
"if",
"(",
"state",
".",
"isSplit",
"===",
"isSplit",
")",
"{",... | Helpers | [
"Helpers"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/map-state-updaters.js#L179-L200 | train | get map dim for split map | [
30522,
3853,
2131,
2863,
17299,
5714,
29278,
13102,
15909,
2863,
2361,
1006,
26354,
24759,
4183,
1010,
2110,
1007,
1063,
1013,
1013,
3572,
1024,
1013,
1013,
1015,
1012,
2110,
3975,
1024,
2995,
1011,
26354,
24759,
4183,
1024,
2995,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/publisher/configuration.js | toJSType | function toJSType(config) {
//config.XXX is either undefined or string
var falsyNotations = ['false', '0', undefined];
if (!config.enabled || falsyNotations.indexOf(config.enabled.toLowerCase()) >= 0) {
config.enabled = false;
} else {
config.enabled = true;
}
config.port = config.port ? parseInt(config.port, 10) : undefined;
return config;
} | javascript | function toJSType(config) {
//config.XXX is either undefined or string
var falsyNotations = ['false', '0', undefined];
if (!config.enabled || falsyNotations.indexOf(config.enabled.toLowerCase()) >= 0) {
config.enabled = false;
} else {
config.enabled = true;
}
config.port = config.port ? parseInt(config.port, 10) : undefined;
return config;
} | [
"function",
"toJSType",
"(",
"config",
")",
"{",
"//config.XXX is either undefined or string",
"var",
"falsyNotations",
"=",
"[",
"'false'",
",",
"'0'",
",",
"undefined",
"]",
";",
"if",
"(",
"!",
"config",
".",
"enabled",
"||",
"falsyNotations",
".",
"indexOf",... | Transfer the resolved configuration value to proper types: port as number, enabled
as boolean and clientId as string. The 'enabled' flag is valued to false when set
to 'false' or '0'.
@param {object} resolved client side monitoring config
@api private | [
"Transfer",
"the",
"resolved",
"configuration",
"value",
"to",
"proper",
"types",
":",
"port",
"as",
"number",
"enabled",
"as",
"boolean",
"and",
"clientId",
"as",
"string",
".",
"The",
"enabled",
"flag",
"is",
"valued",
"to",
"false",
"when",
"set",
"to",
... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L67-L77 | train | Convert config to JS type | [
30522,
3853,
2000,
22578,
13874,
1006,
9530,
8873,
2290,
1007,
1063,
1013,
1013,
9530,
8873,
2290,
1012,
22038,
2595,
2003,
2593,
6151,
28344,
2030,
5164,
13075,
6904,
4877,
6038,
17287,
9285,
1027,
1031,
1005,
6270,
1005,
1010,
1005,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.layout/src/sap/ui/layout/form/SimpleForm.js | _applyContainerSize | function _applyContainerSize(){
this._bLayoutDataChangedByMe = true;
var oForm = this.getAggregation("form");
var aContainers = oForm.getFormContainers();
var iLength = aContainers.length;
for (var i = 0; i < iLength; i++) {
var oContainer = aContainers[i];
if ((this.getMaxContainerCols() <= 1) || ((i == iLength - 1) && (iLength % 2 > 0))) {
oContainer.getLayoutData().setHalfGrid(false);
} else if (!oContainer.getLayoutData().getHalfGrid()) {
oContainer.getLayoutData().setHalfGrid(true);
}
}
this._bLayoutDataChangedByMe = false;
} | javascript | function _applyContainerSize(){
this._bLayoutDataChangedByMe = true;
var oForm = this.getAggregation("form");
var aContainers = oForm.getFormContainers();
var iLength = aContainers.length;
for (var i = 0; i < iLength; i++) {
var oContainer = aContainers[i];
if ((this.getMaxContainerCols() <= 1) || ((i == iLength - 1) && (iLength % 2 > 0))) {
oContainer.getLayoutData().setHalfGrid(false);
} else if (!oContainer.getLayoutData().getHalfGrid()) {
oContainer.getLayoutData().setHalfGrid(true);
}
}
this._bLayoutDataChangedByMe = false;
} | [
"function",
"_applyContainerSize",
"(",
")",
"{",
"this",
".",
"_bLayoutDataChangedByMe",
"=",
"true",
";",
"var",
"oForm",
"=",
"this",
".",
"getAggregation",
"(",
"\"form\"",
")",
";",
"var",
"aContainers",
"=",
"oForm",
".",
"getFormContainers",
"(",
")",
... | /*
Applies size of the FormContainers in GridLayout: if only one container is in the last line -> make it full size
adapt all containers because container can be inserted or added later on
@private | [
"/",
"*",
"Applies",
"size",
"of",
"the",
"FormContainers",
"in",
"GridLayout",
":",
"if",
"only",
"one",
"container",
"is",
"in",
"the",
"last",
"line",
"-",
">",
"make",
"it",
"full",
"size",
"adapt",
"all",
"containers",
"because",
"container",
"can",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.layout/src/sap/ui/layout/form/SimpleForm.js#L1802-L1817 | train | Apply the container size to the form | [
30522,
3853,
1035,
6611,
8663,
18249,
2545,
4697,
1006,
1007,
1063,
2023,
1012,
1035,
1038,
8485,
5833,
2850,
2696,
22305,
2098,
3762,
4168,
1027,
2995,
1025,
13075,
1997,
2953,
2213,
1027,
2023,
1012,
2131,
8490,
17603,
12540,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js | function(oTable) {
var i;
var oColumn;
var oColumnMapItem = {};
var oColumnMap = {};
var aColumns = oTable.getColumns();
var iMaxLevel = TableColumnUtils.TableUtils.getHeaderRowCount(oTable);
var oParentReferences = {};
for (var iColumnIndex = 0; iColumnIndex < aColumns.length; iColumnIndex++) {
oColumn = aColumns[iColumnIndex];
oColumnMapItem = {};
oColumnMapItem.id = oColumn.getId();
oColumnMapItem.column = oColumn;
oColumnMapItem.levelInfo = [];
oColumnMapItem.parents = [];
for (var iLevel = 0; iLevel < iMaxLevel; iLevel++) {
oColumnMapItem.levelInfo[iLevel] = {};
oColumnMapItem.levelInfo[iLevel].spannedColumns = [];
var iHeaderSpan = TableColumnUtils.getHeaderSpan(oColumn, iLevel);
// collect columns which are spanned by the current column
for (i = 1; i < iHeaderSpan; i++) {
var oSpannedColumn = aColumns[iColumnIndex + i];
if (oSpannedColumn) {
var sPannedColumnId = oSpannedColumn.getId();
oColumnMapItem.levelInfo[iLevel].spannedColumns.push(aColumns[iColumnIndex + i]);
if (!oParentReferences[sPannedColumnId]) {
oParentReferences[sPannedColumnId] = [];
}
oParentReferences[sPannedColumnId].push({column: oColumn, level: iLevel});
}
}
}
oColumnMap[oColumnMapItem.id] = oColumnMapItem;
}
var aColumnIds = Object.keys(oParentReferences);
for (i = 0; i < aColumnIds.length; i++) {
var sColumnId = aColumnIds[i];
oColumnMap[sColumnId].parents = oParentReferences[sColumnId];
}
return oColumnMap;
} | javascript | function(oTable) {
var i;
var oColumn;
var oColumnMapItem = {};
var oColumnMap = {};
var aColumns = oTable.getColumns();
var iMaxLevel = TableColumnUtils.TableUtils.getHeaderRowCount(oTable);
var oParentReferences = {};
for (var iColumnIndex = 0; iColumnIndex < aColumns.length; iColumnIndex++) {
oColumn = aColumns[iColumnIndex];
oColumnMapItem = {};
oColumnMapItem.id = oColumn.getId();
oColumnMapItem.column = oColumn;
oColumnMapItem.levelInfo = [];
oColumnMapItem.parents = [];
for (var iLevel = 0; iLevel < iMaxLevel; iLevel++) {
oColumnMapItem.levelInfo[iLevel] = {};
oColumnMapItem.levelInfo[iLevel].spannedColumns = [];
var iHeaderSpan = TableColumnUtils.getHeaderSpan(oColumn, iLevel);
// collect columns which are spanned by the current column
for (i = 1; i < iHeaderSpan; i++) {
var oSpannedColumn = aColumns[iColumnIndex + i];
if (oSpannedColumn) {
var sPannedColumnId = oSpannedColumn.getId();
oColumnMapItem.levelInfo[iLevel].spannedColumns.push(aColumns[iColumnIndex + i]);
if (!oParentReferences[sPannedColumnId]) {
oParentReferences[sPannedColumnId] = [];
}
oParentReferences[sPannedColumnId].push({column: oColumn, level: iLevel});
}
}
}
oColumnMap[oColumnMapItem.id] = oColumnMapItem;
}
var aColumnIds = Object.keys(oParentReferences);
for (i = 0; i < aColumnIds.length; i++) {
var sColumnId = aColumnIds[i];
oColumnMap[sColumnId].parents = oParentReferences[sColumnId];
}
return oColumnMap;
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"i",
";",
"var",
"oColumn",
";",
"var",
"oColumnMapItem",
"=",
"{",
"}",
";",
"var",
"oColumnMap",
"=",
"{",
"}",
";",
"var",
"aColumns",
"=",
"oTable",
".",
"getColumns",
"(",
")",
";",
"var",
"iMaxLevel",... | Collects and returns information about the current column configuration of the table.
@param {sap.ui.table.Table} oTable Instance of the table.
@type {Object} ColumnMapItemLevelInfo
@type {sap.ui.table.Column[]} ColumnMapItemLevelInfo.spannedColumns Array of columns which are spanned by the source column
@type {Object} ColumnMapItemParents
@type {sap.ui.table.Column} ColumnMapItemParents.column Column reference
@type {int} ColumnMapItemParents.level Level as which the parent resides
@type {Object} ColumnMapItem
@type {string} oColumnMapItem.id Column ID
@type {sap.ui.table.Column} oColumnManItem.column Column instance
@type {ColumnMapItemLevelInfo[]} oColumnMapItem.levelInfo Array of level information. Each index represents one level of headers
@type {ColumnMapItemParents[]} oColumnMapItem.parents Array of parents of the source column
@type {Object.<string, ColumnMapItem>} ColumnMap
@type {ColumnMapItem} ColumnMap.<columnID> Object with information about column where the column ID is the key
@returns {ColumnMap} Map of column information where the key is the column ID,
@private | [
"Collects",
"and",
"returns",
"information",
"about",
"the",
"current",
"column",
"configuration",
"of",
"the",
"table",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js#L106-L154 | train | Creates a column map for the given table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
1045,
1025,
13075,
1051,
25778,
2819,
2078,
1025,
13075,
1051,
25778,
2819,
2078,
2863,
23270,
6633,
1027,
1063,
1065,
1025,
13075,
1051,
25778,
2819,
2078,
2863,
2361,
1027,
1063,
1065,
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... | |
eslint/eslint | lib/formatters/codeframe.js | formatSummary | function formatSummary(errors, warnings, fixableErrors, fixableWarnings) {
const summaryColor = errors > 0 ? "red" : "yellow";
const summary = [];
const fixablesSummary = [];
if (errors > 0) {
summary.push(`${errors} ${pluralize("error", errors)}`);
}
if (warnings > 0) {
summary.push(`${warnings} ${pluralize("warning", warnings)}`);
}
if (fixableErrors > 0) {
fixablesSummary.push(`${fixableErrors} ${pluralize("error", fixableErrors)}`);
}
if (fixableWarnings > 0) {
fixablesSummary.push(`${fixableWarnings} ${pluralize("warning", fixableWarnings)}`);
}
let output = chalk[summaryColor].bold(`${summary.join(" and ")} found.`);
if (fixableErrors || fixableWarnings) {
output += chalk[summaryColor].bold(`\n${fixablesSummary.join(" and ")} potentially fixable with the \`--fix\` option.`);
}
return output;
} | javascript | function formatSummary(errors, warnings, fixableErrors, fixableWarnings) {
const summaryColor = errors > 0 ? "red" : "yellow";
const summary = [];
const fixablesSummary = [];
if (errors > 0) {
summary.push(`${errors} ${pluralize("error", errors)}`);
}
if (warnings > 0) {
summary.push(`${warnings} ${pluralize("warning", warnings)}`);
}
if (fixableErrors > 0) {
fixablesSummary.push(`${fixableErrors} ${pluralize("error", fixableErrors)}`);
}
if (fixableWarnings > 0) {
fixablesSummary.push(`${fixableWarnings} ${pluralize("warning", fixableWarnings)}`);
}
let output = chalk[summaryColor].bold(`${summary.join(" and ")} found.`);
if (fixableErrors || fixableWarnings) {
output += chalk[summaryColor].bold(`\n${fixablesSummary.join(" and ")} potentially fixable with the \`--fix\` option.`);
}
return output;
} | [
"function",
"formatSummary",
"(",
"errors",
",",
"warnings",
",",
"fixableErrors",
",",
"fixableWarnings",
")",
"{",
"const",
"summaryColor",
"=",
"errors",
">",
"0",
"?",
"\"red\"",
":",
"\"yellow\"",
";",
"const",
"summary",
"=",
"[",
"]",
";",
"const",
... | Gets the formatted output summary for a given number of errors and warnings.
@param {number} errors The number of errors.
@param {number} warnings The number of warnings.
@param {number} fixableErrors The number of fixable errors.
@param {number} fixableWarnings The number of fixable warnings.
@returns {string} The formatted output summary. | [
"Gets",
"the",
"formatted",
"output",
"summary",
"for",
"a",
"given",
"number",
"of",
"errors",
"and",
"warnings",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/formatters/codeframe.js#L81-L109 | train | Returns a string that shows the summary of the errors warnings and fixable errors. | [
30522,
3853,
11630,
2819,
7849,
2100,
1006,
10697,
1010,
16234,
1010,
8081,
3085,
2121,
29165,
2015,
1010,
8081,
3085,
9028,
5582,
2015,
1007,
1063,
9530,
3367,
12654,
18717,
1027,
10697,
1028,
1014,
1029,
1000,
2417,
1000,
1024,
1000,
3756... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_BrtArrFmla | function parse_BrtArrFmla(data, length, opts) {
var end = data.l + length;
var rfx = parse_RfX(data, 16);
var fAlwaysCalc = data.read_shift(1);
var o = [rfx]; o[2] = fAlwaysCalc;
if(opts.cellFormula) {
var formula = parse_XLSBArrayParsedFormula(data, end - data.l, opts);
o[1] = formula;
} else data.l = end;
return o;
} | javascript | function parse_BrtArrFmla(data, length, opts) {
var end = data.l + length;
var rfx = parse_RfX(data, 16);
var fAlwaysCalc = data.read_shift(1);
var o = [rfx]; o[2] = fAlwaysCalc;
if(opts.cellFormula) {
var formula = parse_XLSBArrayParsedFormula(data, end - data.l, opts);
o[1] = formula;
} else data.l = end;
return o;
} | [
"function",
"parse_BrtArrFmla",
"(",
"data",
",",
"length",
",",
"opts",
")",
"{",
"var",
"end",
"=",
"data",
".",
"l",
"+",
"length",
";",
"var",
"rfx",
"=",
"parse_RfX",
"(",
"data",
",",
"16",
")",
";",
"var",
"fAlwaysCalc",
"=",
"data",
".",
"r... | /* [MS-XLSB] 2.4.6 BrtArrFmla | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"6",
"BrtArrFmla"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L13663-L13673 | train | Parse BrtArrFmla | [
30522,
3853,
11968,
3366,
1035,
7987,
7559,
12881,
19968,
2050,
1006,
2951,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2203,
1027,
2951,
1012,
1048,
1009,
3091,
1025,
13075,
21792,
2595,
1027,
11968,
3366,
1035,
21792,
2595,
1006,
29... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
parcel-bundler/parcel | packages/core/parcel-bundler/src/transforms/babel/flow.js | getFlowConfig | function getFlowConfig(asset) {
if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) {
return {
internal: true,
babelVersion: 7,
config: {
plugins: [[require('@babel/plugin-transform-flow-strip-types')]]
}
};
}
return null;
} | javascript | function getFlowConfig(asset) {
if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) {
return {
internal: true,
babelVersion: 7,
config: {
plugins: [[require('@babel/plugin-transform-flow-strip-types')]]
}
};
}
return null;
} | [
"function",
"getFlowConfig",
"(",
"asset",
")",
"{",
"if",
"(",
"/",
"^(\\/{2}|\\/\\*+) *@flow",
"/",
".",
"test",
"(",
"asset",
".",
"contents",
".",
"substring",
"(",
"0",
",",
"20",
")",
")",
")",
"{",
"return",
"{",
"internal",
":",
"true",
",",
... | Generates a babel config for stripping away Flow types. | [
"Generates",
"a",
"babel",
"config",
"for",
"stripping",
"away",
"Flow",
"types",
"."
] | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/transforms/babel/flow.js#L4-L16 | train | Get the flow config for the given asset | [
30522,
3853,
2131,
12314,
8663,
8873,
2290,
1006,
11412,
1007,
1063,
2065,
1006,
1013,
1034,
1006,
1032,
1013,
1063,
1016,
1065,
1064,
1032,
1013,
1032,
1008,
1009,
1007,
1008,
1030,
4834,
1013,
1012,
3231,
1006,
11412,
1012,
8417,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketEvent | function PacketEvent(properties) {
this.groups = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketEvent(properties) {
this.groups = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketEvent",
"(",
"properties",
")",
"{",
"this",
".",
"groups",
"=",
"[",
"]",
";",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"ke... | Properties of a PacketEvent.
@memberof packets
@interface IPacketEvent
@property {string} ver PacketEvent ver
@property {string} sender PacketEvent sender
@property {string} event PacketEvent event
@property {string|null} [data] PacketEvent data
@property {Array.<string>|null} [groups] PacketEvent groups
@property {boolean} broadcast PacketEvent broadcast
Constructs a new PacketEvent.
@memberof packets
@classdesc Represents a PacketEvent.
@implements IPacketEvent
@constructor
@param {packets.IPacketEvent=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketEvent",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L44-L50 | train | Properties of a PacketEvent. | [
30522,
3853,
14771,
18697,
3372,
1006,
5144,
1007,
1063,
2023,
1012,
2967,
1027,
1031,
1033,
1025,
2065,
1006,
5144,
1007,
2005,
1006,
13075,
6309,
1027,
4874,
1012,
6309,
1006,
5144,
1007,
1010,
1045,
1027,
1014,
1025,
1045,
1026,
6309,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/config/config-rule.js | createCoreRuleConfigs | function createCoreRuleConfigs() {
return Object.keys(builtInRules).reduce((accumulator, id) => {
const rule = rules.get(id);
const schema = (typeof rule === "function") ? rule.schema : rule.meta.schema;
accumulator[id] = generateConfigsFromSchema(schema);
return accumulator;
}, {});
} | javascript | function createCoreRuleConfigs() {
return Object.keys(builtInRules).reduce((accumulator, id) => {
const rule = rules.get(id);
const schema = (typeof rule === "function") ? rule.schema : rule.meta.schema;
accumulator[id] = generateConfigsFromSchema(schema);
return accumulator;
}, {});
} | [
"function",
"createCoreRuleConfigs",
"(",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"builtInRules",
")",
".",
"reduce",
"(",
"(",
"accumulator",
",",
"id",
")",
"=>",
"{",
"const",
"rule",
"=",
"rules",
".",
"get",
"(",
"id",
")",
";",
"const",
... | Generate possible rule configurations for all of the core rules
@returns {rulesConfig} Hash of rule names and arrays of possible configurations | [
"Generate",
"possible",
"rule",
"configurations",
"for",
"all",
"of",
"the",
"core",
"rules"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-rule.js#L301-L309 | train | Creates a config object for the core rule | [
30522,
3853,
3443,
17345,
6820,
2571,
8663,
8873,
5620,
1006,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
2328,
2378,
6820,
4244,
1007,
1012,
5547,
1006,
1006,
16222,
2819,
20350,
1010,
8909,
1007,
1027,
1028,
1063,
9530,
3367,
3627,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | checkAnalyticsDataSend | function checkAnalyticsDataSend(event, Eventparams, forceSend) {
var result = new $.Deferred(),
isHDTracking = prefs.get("healthDataTracking"),
isEventDataAlreadySent;
if (isHDTracking) {
isEventDataAlreadySent = HealthLogger.analyticsEventMap.get(Eventparams.eventName);
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
if (!isEventDataAlreadySent || forceSend) {
sendAnalyticsDataToServer(Eventparams)
.done(function () {
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
result.resolve();
}).fail(function () {
HealthLogger.analyticsEventMap.set(Eventparams.eventName, false);
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | javascript | function checkAnalyticsDataSend(event, Eventparams, forceSend) {
var result = new $.Deferred(),
isHDTracking = prefs.get("healthDataTracking"),
isEventDataAlreadySent;
if (isHDTracking) {
isEventDataAlreadySent = HealthLogger.analyticsEventMap.get(Eventparams.eventName);
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
if (!isEventDataAlreadySent || forceSend) {
sendAnalyticsDataToServer(Eventparams)
.done(function () {
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
result.resolve();
}).fail(function () {
HealthLogger.analyticsEventMap.set(Eventparams.eventName, false);
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | [
"function",
"checkAnalyticsDataSend",
"(",
"event",
",",
"Eventparams",
",",
"forceSend",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"isHDTracking",
"=",
"prefs",
".",
"get",
"(",
"\"healthDataTracking\"",
")",
",",
"isEventD... | Check if the Analytic Data is to be sent to the server.
If the user has enabled tracking, Analytic Data will be sent once per session
Send Analytic Data to the server if the Data associated with the given Event is not yet sent in this session.
We are sending the data as soon as the user triggers the event.
The data will be sent to the server only after the notification dialog
for opt-out/in is closed.
@param{Object} event event object
@param{Object} Eventparams Object Containg Data to be sent to Server
@param{boolean} forceSend Flag for sending analytics data for testing purpose | [
"Check",
"if",
"the",
"Analytic",
"Data",
"is",
"to",
"be",
"sent",
"to",
"the",
"server",
".",
"If",
"the",
"user",
"has",
"enabled",
"tracking",
"Analytic",
"Data",
"will",
"be",
"sent",
"once",
"per",
"session",
"Send",
"Analytic",
"Data",
"to",
"the"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L306-L331 | train | Check if analytics data is sent to server | [
30522,
3853,
4638,
27953,
21252,
16150,
6790,
5054,
2094,
1006,
2724,
1010,
2724,
28689,
5244,
1010,
2749,
10497,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2003,
14945,
6494,
23177,
1027,
3653,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.