repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
wangfupeng1988/wangEditor | src/js/menus/droplist.js | DropList | function DropList(menu, opt) {
// droplist 所依附的菜单
const editor = menu.editor
this.menu = menu
this.opt = opt
// 容器
const $container = $('<div class="w-e-droplist"></div>')
// 标题
const $title = opt.$title
let titleHtml
if ($title) {
// 替换多语言
titleHtml = $title.html()
titleHtml = replaceLang(editor, titleHtml)
$title.html(titleHtml)
$title.addClass('w-e-dp-title')
$container.append($title)
}
const list = opt.list || []
const type = opt.type || 'list' // 'list' 列表形式(如“标题”菜单) / 'inline-block' 块状形式(如“颜色”菜单)
const onClick = opt.onClick || _emptyFn
// 加入 DOM 并绑定事件
const $list = $('<ul class="' + (type === 'list' ? 'w-e-list' : 'w-e-block') + '"></ul>')
$container.append($list)
list.forEach(item => {
const $elem = item.$elem
// 替换多语言
let elemHtml = $elem.html()
elemHtml = replaceLang(editor, elemHtml)
$elem.html(elemHtml)
const value = item.value
const $li = $('<li class="w-e-item"></li>')
if ($elem) {
$li.append($elem)
$list.append($li)
$li.on('click', e => {
onClick(value)
// 隐藏
this.hideTimeoutId = setTimeout(() => {
this.hide()
}, 0)
})
}
})
// 绑定隐藏事件
$container.on('mouseleave', e => {
this.hideTimeoutId = setTimeout(() => {
this.hide()
}, 0)
})
// 记录属性
this.$container = $container
// 基本属性
this._rendered = false
this._show = false
} | javascript | function DropList(menu, opt) {
// droplist 所依附的菜单
const editor = menu.editor
this.menu = menu
this.opt = opt
// 容器
const $container = $('<div class="w-e-droplist"></div>')
// 标题
const $title = opt.$title
let titleHtml
if ($title) {
// 替换多语言
titleHtml = $title.html()
titleHtml = replaceLang(editor, titleHtml)
$title.html(titleHtml)
$title.addClass('w-e-dp-title')
$container.append($title)
}
const list = opt.list || []
const type = opt.type || 'list' // 'list' 列表形式(如“标题”菜单) / 'inline-block' 块状形式(如“颜色”菜单)
const onClick = opt.onClick || _emptyFn
// 加入 DOM 并绑定事件
const $list = $('<ul class="' + (type === 'list' ? 'w-e-list' : 'w-e-block') + '"></ul>')
$container.append($list)
list.forEach(item => {
const $elem = item.$elem
// 替换多语言
let elemHtml = $elem.html()
elemHtml = replaceLang(editor, elemHtml)
$elem.html(elemHtml)
const value = item.value
const $li = $('<li class="w-e-item"></li>')
if ($elem) {
$li.append($elem)
$list.append($li)
$li.on('click', e => {
onClick(value)
// 隐藏
this.hideTimeoutId = setTimeout(() => {
this.hide()
}, 0)
})
}
})
// 绑定隐藏事件
$container.on('mouseleave', e => {
this.hideTimeoutId = setTimeout(() => {
this.hide()
}, 0)
})
// 记录属性
this.$container = $container
// 基本属性
this._rendered = false
this._show = false
} | [
"function",
"DropList",
"(",
"menu",
",",
"opt",
")",
"{",
"// droplist 所依附的菜单",
"const",
"editor",
"=",
"menu",
".",
"editor",
"this",
".",
"menu",
"=",
"menu",
"this",
".",
"opt",
"=",
"opt",
"// 容器",
"const",
"$container",
"=",
"$",
"(",
"'<div class=... | 构造函数 | [
"构造函数"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/droplist.js#L10-L75 | train | DropList 所依附的菜单 | [
30522,
3853,
4530,
9863,
1006,
12183,
1010,
23569,
1007,
1063,
1013,
1013,
4530,
9863,
100,
100,
100,
1916,
100,
100,
9530,
3367,
3559,
1027,
12183,
1012,
3559,
2023,
1012,
12183,
1027,
12183,
2023,
1012,
23569,
1027,
23569,
1013,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/prefer-object-spread.js | getStartWithSpaces | function getStartWithSpaces(token, sourceCode) {
const text = sourceCode.text;
let start = token.range[0];
// If the previous token is a line comment then skip this step to avoid commenting this token out.
{
const prevToken = sourceCode.getTokenBefore(token, { includeComments: true });
if (prevToken && prevToken.type === "Line") {
return start;
}
}
// Detect spaces before the token.
while (ANY_SPACE.test(text[start - 1] || "")) {
start -= 1;
}
return start;
} | javascript | function getStartWithSpaces(token, sourceCode) {
const text = sourceCode.text;
let start = token.range[0];
// If the previous token is a line comment then skip this step to avoid commenting this token out.
{
const prevToken = sourceCode.getTokenBefore(token, { includeComments: true });
if (prevToken && prevToken.type === "Line") {
return start;
}
}
// Detect spaces before the token.
while (ANY_SPACE.test(text[start - 1] || "")) {
start -= 1;
}
return start;
} | [
"function",
"getStartWithSpaces",
"(",
"token",
",",
"sourceCode",
")",
"{",
"const",
"text",
"=",
"sourceCode",
".",
"text",
";",
"let",
"start",
"=",
"token",
".",
"range",
"[",
"0",
"]",
";",
"// If the previous token is a line comment then skip this step to avoi... | Get the range of a given token and around whitespaces.
@param {Token} token The token to get range.
@param {SourceCode} sourceCode The source code object to get tokens.
@returns {number} The end of the range of the token and around whitespaces. | [
"Get",
"the",
"range",
"of",
"a",
"given",
"token",
"and",
"around",
"whitespaces",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-object-spread.js#L104-L123 | train | Get the start of the token that is at the beginning of the line comment. | [
30522,
3853,
4152,
7559,
2102,
24415,
23058,
2015,
1006,
19204,
1010,
3120,
16044,
1007,
1063,
9530,
3367,
3793,
1027,
3120,
16044,
1012,
3793,
1025,
2292,
2707,
1027,
19204,
1012,
2846,
1031,
1014,
1033,
1025,
1013,
1013,
2065,
1996,
3025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-unmodified-loop-condition.js | toLoopCondition | function toLoopCondition(reference) {
if (reference.init) {
return null;
}
let group = null;
let child = reference.identifier;
let node = child.parent;
while (node) {
if (SENTINEL_PATTERN.test(node.type)) {
if (LOOP_PATTERN.test(node.type) && node.test === child) {
// This reference is inside of a loop condition.
return {
reference,
group,
isInLoop: isInLoop[node.type].bind(null, node),
modified: false
};
}
// This reference is outside of a loop condition.
break;
}
/*
* If it's inside of a group, OK if either operand is modified.
* So stores the group this reference belongs to.
*/
if (GROUP_PATTERN.test(node.type)) {
// If this expression is dynamic, no need to check.
if (hasDynamicExpressions(node)) {
break;
} else {
group = node;
}
}
child = node;
node = node.parent;
}
return null;
} | javascript | function toLoopCondition(reference) {
if (reference.init) {
return null;
}
let group = null;
let child = reference.identifier;
let node = child.parent;
while (node) {
if (SENTINEL_PATTERN.test(node.type)) {
if (LOOP_PATTERN.test(node.type) && node.test === child) {
// This reference is inside of a loop condition.
return {
reference,
group,
isInLoop: isInLoop[node.type].bind(null, node),
modified: false
};
}
// This reference is outside of a loop condition.
break;
}
/*
* If it's inside of a group, OK if either operand is modified.
* So stores the group this reference belongs to.
*/
if (GROUP_PATTERN.test(node.type)) {
// If this expression is dynamic, no need to check.
if (hasDynamicExpressions(node)) {
break;
} else {
group = node;
}
}
child = node;
node = node.parent;
}
return null;
} | [
"function",
"toLoopCondition",
"(",
"reference",
")",
"{",
"if",
"(",
"reference",
".",
"init",
")",
"{",
"return",
"null",
";",
"}",
"let",
"group",
"=",
"null",
";",
"let",
"child",
"=",
"reference",
".",
"identifier",
";",
"let",
"node",
"=",
"child... | Creates the loop condition information from a given reference.
@param {eslint-scope.Reference} reference - A reference to create.
@returns {LoopConditionInfo|null} Created loop condition info, or null. | [
"Creates",
"the",
"loop",
"condition",
"information",
"from",
"a",
"given",
"reference",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L266-L311 | train | To loop condition | [
30522,
3853,
2000,
4135,
7361,
8663,
20562,
1006,
4431,
1007,
1063,
2065,
1006,
4431,
1012,
1999,
4183,
1007,
1063,
2709,
19701,
1025,
1065,
2292,
2177,
1027,
19701,
1025,
2292,
2775,
1027,
4431,
1012,
8909,
4765,
18095,
1025,
2292,
13045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/tabs.js | tabBrowser_getTab | function tabBrowser_getTab(index) {
if (index === undefined)
index = this.selectedIndex;
return this.getElement({type: "tabs_tab", subtype: "index", value: index});
} | javascript | function tabBrowser_getTab(index) {
if (index === undefined)
index = this.selectedIndex;
return this.getElement({type: "tabs_tab", subtype: "index", value: index});
} | [
"function",
"tabBrowser_getTab",
"(",
"index",
")",
"{",
"if",
"(",
"index",
"===",
"undefined",
")",
"index",
"=",
"this",
".",
"selectedIndex",
";",
"return",
"this",
".",
"getElement",
"(",
"{",
"type",
":",
"\"tabs_tab\"",
",",
"subtype",
":",
"\"index... | Get the tab at the specified index
@param {number} index
Index of the tab
@returns The requested tab
@type {ElemBase} | [
"Get",
"the",
"tab",
"at",
"the",
"specified",
"index"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabs.js#L335-L340 | train | Get the tab at the specified index | [
30522,
3853,
21628,
12618,
9333,
2121,
1035,
2131,
2696,
2497,
1006,
5950,
1007,
1063,
2065,
1006,
5950,
1027,
1027,
1027,
6151,
28344,
1007,
5950,
1027,
2023,
1012,
3479,
22254,
10288,
1025,
2709,
2023,
1012,
2131,
12260,
3672,
1006,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/shared-ini/ini-loader.js | loadFrom | function loadFrom(options) {
options = options || {};
var isConfig = options.isConfig === true;
var filename = options.filename || this.getDefaultFilePath(isConfig);
if (!this.resolvedProfiles[filename]) {
var fileContent = this.parseFile(filename, isConfig);
Object.defineProperty(this.resolvedProfiles, filename, { value: fileContent });
}
return this.resolvedProfiles[filename];
} | javascript | function loadFrom(options) {
options = options || {};
var isConfig = options.isConfig === true;
var filename = options.filename || this.getDefaultFilePath(isConfig);
if (!this.resolvedProfiles[filename]) {
var fileContent = this.parseFile(filename, isConfig);
Object.defineProperty(this.resolvedProfiles, filename, { value: fileContent });
}
return this.resolvedProfiles[filename];
} | [
"function",
"loadFrom",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"isConfig",
"=",
"options",
".",
"isConfig",
"===",
"true",
";",
"var",
"filename",
"=",
"options",
".",
"filename",
"||",
"this",
".",
"getDefaultFi... | Load configurations from config/credentials files and cache them
for later use. If no file is specified it will try to load default
files.
@param options [map] information describing the file
@option options filename [String] ('~/.aws/credentials' or defined by
AWS_SHARED_CREDENTIALS_FILE process env var or '~/.aws/config' if
isConfig is set to true)
path to the file to be read.
@option options isConfig [Boolean] (false) True to read config file.
@return [map<String,String>] object containing contents from file in key-value
pairs. | [
"Load",
"configurations",
"from",
"config",
"/",
"credentials",
"files",
"and",
"cache",
"them",
"for",
"later",
"use",
".",
"If",
"no",
"file",
"is",
"specified",
"it",
"will",
"try",
"to",
"load",
"default",
"files",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/shared-ini/ini-loader.js#L51-L60 | train | Load a profile from a file | [
30522,
3853,
7170,
19699,
5358,
1006,
7047,
1007,
1063,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
13075,
2003,
8663,
8873,
2290,
1027,
7047,
1012,
2003,
8663,
8873,
2290,
1027,
1027,
1027,
2995,
1025,
13075,
5371,
18442,
1027,
7047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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()
{
if (mxLog.window == null && document.body != null)
{
var title = mxLog.consoleName + ' - mxGraph ' + mxClient.VERSION;
// Creates a table that maintains the layout
var table = document.createElement('table');
table.setAttribute('width', '100%');
table.setAttribute('height', '100%');
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.style.verticalAlign = 'top';
// Adds the actual console as a textarea
mxLog.textarea = document.createElement('textarea');
mxLog.textarea.setAttribute('wrap', 'off');
mxLog.textarea.setAttribute('readOnly', 'true');
mxLog.textarea.style.height = '100%';
mxLog.textarea.style.resize = 'none';
mxLog.textarea.value = mxLog.buffer;
// Workaround for wrong width in standards mode
if (mxClient.IS_NS && document.compatMode != 'BackCompat')
{
mxLog.textarea.style.width = '99%';
}
else
{
mxLog.textarea.style.width = '100%';
}
td.appendChild(mxLog.textarea);
tr.appendChild(td);
tbody.appendChild(tr);
// Creates the container div
tr = document.createElement('tr');
mxLog.td = document.createElement('td');
mxLog.td.style.verticalAlign = 'top';
mxLog.td.setAttribute('height', '30px');
tr.appendChild(mxLog.td);
tbody.appendChild(tr);
table.appendChild(tbody);
// Adds various debugging buttons
mxLog.addButton('Info', function (evt)
{
mxLog.info();
});
mxLog.addButton('DOM', function (evt)
{
var content = mxUtils.getInnerHtml(document.body);
mxLog.debug(content);
});
mxLog.addButton('Trace', function (evt)
{
mxLog.TRACE = !mxLog.TRACE;
if (mxLog.TRACE)
{
mxLog.debug('Tracing enabled');
}
else
{
mxLog.debug('Tracing disabled');
}
});
mxLog.addButton('Copy', function (evt)
{
try
{
mxUtils.copy(mxLog.textarea.value);
}
catch (err)
{
mxUtils.alert(err);
}
});
mxLog.addButton('Show', function (evt)
{
try
{
mxUtils.popup(mxLog.textarea.value);
}
catch (err)
{
mxUtils.alert(err);
}
});
mxLog.addButton('Clear', function (evt)
{
mxLog.textarea.value = '';
});
// Cross-browser code to get window size
var h = 0;
var w = 0;
if (typeof(window.innerWidth) === 'number')
{
h = window.innerHeight;
w = window.innerWidth;
}
else
{
h = (document.documentElement.clientHeight || document.body.clientHeight);
w = document.body.clientWidth;
}
mxLog.window = new mxWindow(title, table, Math.max(0, w - 320), Math.max(0, h - 210), 300, 160);
mxLog.window.setMaximizable(true);
mxLog.window.setScrollable(false);
mxLog.window.setResizable(true);
mxLog.window.setClosable(true);
mxLog.window.destroyOnClose = false;
// Workaround for ignored textarea height in various setups
if (((mxClient.IS_NS || mxClient.IS_IE) && !mxClient.IS_GC &&
!mxClient.IS_SF && document.compatMode != 'BackCompat') ||
document.documentMode == 11)
{
var elt = mxLog.window.getElement();
var resizeHandler = function(sender, evt)
{
mxLog.textarea.style.height = Math.max(0, elt.offsetHeight - 70) + 'px';
};
mxLog.window.addListener(mxEvent.RESIZE_END, resizeHandler);
mxLog.window.addListener(mxEvent.MAXIMIZE, resizeHandler);
mxLog.window.addListener(mxEvent.NORMALIZE, resizeHandler);
mxLog.textarea.style.height = '92px';
}
}
} | javascript | function()
{
if (mxLog.window == null && document.body != null)
{
var title = mxLog.consoleName + ' - mxGraph ' + mxClient.VERSION;
// Creates a table that maintains the layout
var table = document.createElement('table');
table.setAttribute('width', '100%');
table.setAttribute('height', '100%');
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.style.verticalAlign = 'top';
// Adds the actual console as a textarea
mxLog.textarea = document.createElement('textarea');
mxLog.textarea.setAttribute('wrap', 'off');
mxLog.textarea.setAttribute('readOnly', 'true');
mxLog.textarea.style.height = '100%';
mxLog.textarea.style.resize = 'none';
mxLog.textarea.value = mxLog.buffer;
// Workaround for wrong width in standards mode
if (mxClient.IS_NS && document.compatMode != 'BackCompat')
{
mxLog.textarea.style.width = '99%';
}
else
{
mxLog.textarea.style.width = '100%';
}
td.appendChild(mxLog.textarea);
tr.appendChild(td);
tbody.appendChild(tr);
// Creates the container div
tr = document.createElement('tr');
mxLog.td = document.createElement('td');
mxLog.td.style.verticalAlign = 'top';
mxLog.td.setAttribute('height', '30px');
tr.appendChild(mxLog.td);
tbody.appendChild(tr);
table.appendChild(tbody);
// Adds various debugging buttons
mxLog.addButton('Info', function (evt)
{
mxLog.info();
});
mxLog.addButton('DOM', function (evt)
{
var content = mxUtils.getInnerHtml(document.body);
mxLog.debug(content);
});
mxLog.addButton('Trace', function (evt)
{
mxLog.TRACE = !mxLog.TRACE;
if (mxLog.TRACE)
{
mxLog.debug('Tracing enabled');
}
else
{
mxLog.debug('Tracing disabled');
}
});
mxLog.addButton('Copy', function (evt)
{
try
{
mxUtils.copy(mxLog.textarea.value);
}
catch (err)
{
mxUtils.alert(err);
}
});
mxLog.addButton('Show', function (evt)
{
try
{
mxUtils.popup(mxLog.textarea.value);
}
catch (err)
{
mxUtils.alert(err);
}
});
mxLog.addButton('Clear', function (evt)
{
mxLog.textarea.value = '';
});
// Cross-browser code to get window size
var h = 0;
var w = 0;
if (typeof(window.innerWidth) === 'number')
{
h = window.innerHeight;
w = window.innerWidth;
}
else
{
h = (document.documentElement.clientHeight || document.body.clientHeight);
w = document.body.clientWidth;
}
mxLog.window = new mxWindow(title, table, Math.max(0, w - 320), Math.max(0, h - 210), 300, 160);
mxLog.window.setMaximizable(true);
mxLog.window.setScrollable(false);
mxLog.window.setResizable(true);
mxLog.window.setClosable(true);
mxLog.window.destroyOnClose = false;
// Workaround for ignored textarea height in various setups
if (((mxClient.IS_NS || mxClient.IS_IE) && !mxClient.IS_GC &&
!mxClient.IS_SF && document.compatMode != 'BackCompat') ||
document.documentMode == 11)
{
var elt = mxLog.window.getElement();
var resizeHandler = function(sender, evt)
{
mxLog.textarea.style.height = Math.max(0, elt.offsetHeight - 70) + 'px';
};
mxLog.window.addListener(mxEvent.RESIZE_END, resizeHandler);
mxLog.window.addListener(mxEvent.MAXIMIZE, resizeHandler);
mxLog.window.addListener(mxEvent.NORMALIZE, resizeHandler);
mxLog.textarea.style.height = '92px';
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"mxLog",
".",
"window",
"==",
"null",
"&&",
"document",
".",
"body",
"!=",
"null",
")",
"{",
"var",
"title",
"=",
"mxLog",
".",
"consoleName",
"+",
"' - mxGraph '",
"+",
"mxClient",
".",
"VERSION",
";",
"// Creates... | Function: init
Initializes the DOM node for the console. This requires document.body to
point to a non-null value. This is called from within <setVisible> if the
log has not yet been initialized. | [
"Function",
":",
"init"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L681-L825 | train | Creates the console | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
25630,
21197,
1012,
3332,
1027,
1027,
19701,
1004,
1004,
6254,
1012,
2303,
999,
1027,
19701,
1007,
1063,
13075,
2516,
1027,
25630,
21197,
1012,
10122,
18442,
1009,
1005,
1011,
25630,
14413,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sStyle, iWeekNumber) {
assert(sStyle == "wide" || sStyle == "narrow" , "sStyle must be wide or narrow");
var oMessageBundle = sap.ui.getCore().getLibraryResourceBundle("sap.ui.core", this.oLocale.toString()),
sKey = "date.week.calendarweek." + sStyle;
return oMessageBundle.getText(sKey, iWeekNumber);
} | javascript | function(sStyle, iWeekNumber) {
assert(sStyle == "wide" || sStyle == "narrow" , "sStyle must be wide or narrow");
var oMessageBundle = sap.ui.getCore().getLibraryResourceBundle("sap.ui.core", this.oLocale.toString()),
sKey = "date.week.calendarweek." + sStyle;
return oMessageBundle.getText(sKey, iWeekNumber);
} | [
"function",
"(",
"sStyle",
",",
"iWeekNumber",
")",
"{",
"assert",
"(",
"sStyle",
"==",
"\"wide\"",
"||",
"sStyle",
"==",
"\"narrow\"",
",",
"\"sStyle must be wide or narrow\"",
")",
";",
"var",
"oMessageBundle",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
"... | Returns the defined pattern for representing the calendar week number.
@param {string} sStyle the style of the pattern. It can only be either "wide" or "narrow".
@param {int} iWeekNumber the week number
@return {string} the week number string
@public
@since 1.32.0 | [
"Returns",
"the",
"defined",
"pattern",
"for",
"representing",
"the",
"calendar",
"week",
"number",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L1506-L1513 | train | Returns the text for the given style | [
30522,
3853,
1006,
7020,
27983,
1010,
1045,
28075,
19172,
5677,
1007,
1063,
20865,
1006,
7020,
27983,
1027,
1027,
1000,
2898,
1000,
1064,
1064,
7020,
27983,
1027,
1027,
1000,
4867,
1000,
1010,
1000,
7020,
27983,
2442,
2022,
2898,
2030,
4867... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
thomaspark/bootswatch | docs/_vendor/popper.js/dist/popper.js | getBordersSize | function getBordersSize(styles, axis) {
const sideA = axis === 'x' ? 'Left' : 'Top';
const sideB = sideA === 'Left' ? 'Right' : 'Bottom';
return parseFloat(styles[`border${sideA}Width`], 10) + parseFloat(styles[`border${sideB}Width`], 10);
} | javascript | function getBordersSize(styles, axis) {
const sideA = axis === 'x' ? 'Left' : 'Top';
const sideB = sideA === 'Left' ? 'Right' : 'Bottom';
return parseFloat(styles[`border${sideA}Width`], 10) + parseFloat(styles[`border${sideB}Width`], 10);
} | [
"function",
"getBordersSize",
"(",
"styles",
",",
"axis",
")",
"{",
"const",
"sideA",
"=",
"axis",
"===",
"'x'",
"?",
"'Left'",
":",
"'Top'",
";",
"const",
"sideB",
"=",
"sideA",
"===",
"'Left'",
"?",
"'Right'",
":",
"'Bottom'",
";",
"return",
"parseFloa... | /*
Helper to detect borders of a given element
@method
@memberof Popper.Utils
@param {CSSStyleDeclaration} styles
Result of `getStyleComputedProperty` on the given element
@param {String} axis - `x` or `y`
@return {number} borders - The borders size of the given axis | [
"/",
"*",
"Helper",
"to",
"detect",
"borders",
"of",
"a",
"given",
"element"
] | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/_vendor/popper.js/dist/popper.js#L322-L327 | train | Get the border size of a given axis | [
30522,
3853,
2131,
12821,
13375,
5332,
4371,
1006,
6782,
1010,
8123,
1007,
1063,
9530,
3367,
2217,
2050,
1027,
8123,
1027,
1027,
1027,
1005,
1060,
1005,
1029,
1005,
2187,
1005,
1024,
1005,
2327,
1005,
1025,
9530,
3367,
2217,
2497,
1027,
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 | lib/jsdoc/ui5/template/publish.js | normalizeWhitespace | function normalizeWhitespace(content) {
var compressed = '',
preformatted = 0,
p = 0, m, text;
REGEXP_TAG.lastIndex = 0;
while ( (m = REGEXP_TAG.exec(content)) ) {
if ( m.index > p ) {
text = content.slice(p, m.index);
if ( preformatted ) {
compressed += text;
// debug(' "' + text + '" (preformatted)');
} else {
text = text.replace(/\s+/g,' ');
if ( text.trim() ) {
compressed += text;
}
// debug(' "' + text + '" (trimmed)');
}
}
compressed += m[0];
// debug(' "' + m[0] + '" (tag)');
p = m.index + m[0].length;
if ( /^pre$/i.test(m[1]) ) {
preformatted++;
} else if ( /^\/pre$/i.test(m[1]) && preformatted ) {
preformatted--;
}
}
if ( content.length > p ) {
text = content.slice(p, content.length);
if ( preformatted ) {
compressed += text;
// debug(' "' + text + '" (preformatted)');
} else {
text = text.replace(/\s+/g,' ');
if ( text.trim() ) {
compressed += text;
}
// debug(' "' + text + '" (trimmed)');
}
}
return compressed;
} | javascript | function normalizeWhitespace(content) {
var compressed = '',
preformatted = 0,
p = 0, m, text;
REGEXP_TAG.lastIndex = 0;
while ( (m = REGEXP_TAG.exec(content)) ) {
if ( m.index > p ) {
text = content.slice(p, m.index);
if ( preformatted ) {
compressed += text;
// debug(' "' + text + '" (preformatted)');
} else {
text = text.replace(/\s+/g,' ');
if ( text.trim() ) {
compressed += text;
}
// debug(' "' + text + '" (trimmed)');
}
}
compressed += m[0];
// debug(' "' + m[0] + '" (tag)');
p = m.index + m[0].length;
if ( /^pre$/i.test(m[1]) ) {
preformatted++;
} else if ( /^\/pre$/i.test(m[1]) && preformatted ) {
preformatted--;
}
}
if ( content.length > p ) {
text = content.slice(p, content.length);
if ( preformatted ) {
compressed += text;
// debug(' "' + text + '" (preformatted)');
} else {
text = text.replace(/\s+/g,' ');
if ( text.trim() ) {
compressed += text;
}
// debug(' "' + text + '" (trimmed)');
}
}
return compressed;
} | [
"function",
"normalizeWhitespace",
"(",
"content",
")",
"{",
"var",
"compressed",
"=",
"''",
",",
"preformatted",
"=",
"0",
",",
"p",
"=",
"0",
",",
"m",
",",
"text",
";",
"REGEXP_TAG",
".",
"lastIndex",
"=",
"0",
";",
"while",
"(",
"(",
"m",
"=",
... | Removes unnecessary whitespace from an HTML document:
- if the text between two adjacent HTML tags consists of whitespace only, the whole text is removed
- otherwise, any sequence of whitespace in the text is reduced to a single blank
- inside a <pre> tag, whitespace is preserved
Whitespace inside an element tag is not touched (although it could be normalized as well)
@param {string} content raw HTML file
@returns {string} HTML file with normalized whitespace | [
"Removes",
"unnecessary",
"whitespace",
"from",
"an",
"HTML",
"document",
":",
"-",
"if",
"the",
"text",
"between",
"two",
"adjacent",
"HTML",
"tags",
"consists",
"of",
"whitespace",
"only",
"the",
"whole",
"text",
"is",
"removed",
"-",
"otherwise",
"any",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/template/publish.js#L1388-L1436 | train | Normalize whitespace in content | [
30522,
3853,
3671,
4697,
2860,
16584,
2229,
15327,
1006,
4180,
1007,
1063,
13075,
16620,
1027,
1005,
1005,
1010,
3653,
14192,
19321,
2098,
1027,
1014,
1010,
1052,
1027,
1014,
1010,
1049,
1010,
3793,
1025,
19723,
10288,
2361,
1035,
6415,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/widgets/StatusBar.js | updateIndicator | function updateIndicator(id, visible, style, tooltip) {
if (!_init && !!brackets.test) {
console.error("StatusBar API invoked before status bar created");
return;
}
var $indicator = $("#" + id.replace(_indicatorIDRegexp, "-"));
if ($indicator) {
if (visible) {
$indicator.show();
} else {
$indicator.hide();
}
if (style) {
$indicator.removeClass();
$indicator.addClass(style);
} else {
$indicator.removeClass();
$indicator.addClass("indicator");
}
if (tooltip) {
$indicator.attr("title", tooltip);
}
}
} | javascript | function updateIndicator(id, visible, style, tooltip) {
if (!_init && !!brackets.test) {
console.error("StatusBar API invoked before status bar created");
return;
}
var $indicator = $("#" + id.replace(_indicatorIDRegexp, "-"));
if ($indicator) {
if (visible) {
$indicator.show();
} else {
$indicator.hide();
}
if (style) {
$indicator.removeClass();
$indicator.addClass(style);
} else {
$indicator.removeClass();
$indicator.addClass("indicator");
}
if (tooltip) {
$indicator.attr("title", tooltip);
}
}
} | [
"function",
"updateIndicator",
"(",
"id",
",",
"visible",
",",
"style",
",",
"tooltip",
")",
"{",
"if",
"(",
"!",
"_init",
"&&",
"!",
"!",
"brackets",
".",
"test",
")",
"{",
"console",
".",
"error",
"(",
"\"StatusBar API invoked before status bar created\"",
... | Updates a status indicator
@param {string} id Registration id of the indicator to be updated.
@param {boolean} visible Shows or hides the indicator over the statusbar.
@param {string=} style Sets the attribute "class" of the indicator.
@param {string=} tooltip Sets the attribute "title" of the indicator. | [
"Updates",
"a",
"status",
"indicator"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/StatusBar.js#L144-L172 | train | Update indicator | [
30522,
3853,
10651,
22254,
5555,
4263,
1006,
8909,
1010,
5710,
1010,
2806,
1010,
6994,
25101,
1007,
1063,
2065,
1006,
999,
1035,
1999,
4183,
1004,
1004,
999,
999,
19719,
1012,
3231,
1007,
1063,
10122,
1012,
7561,
1006,
1000,
3570,
8237,
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... |
ecomfe/zrender | src/Painter.js | function (zlevel) {
var layers = this._layers;
var zlevelList = this._zlevelList;
var layer = layers[zlevel];
if (!layer) {
return;
}
layer.dom.parentNode.removeChild(layer.dom);
delete layers[zlevel];
zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
} | javascript | function (zlevel) {
var layers = this._layers;
var zlevelList = this._zlevelList;
var layer = layers[zlevel];
if (!layer) {
return;
}
layer.dom.parentNode.removeChild(layer.dom);
delete layers[zlevel];
zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
} | [
"function",
"(",
"zlevel",
")",
"{",
"var",
"layers",
"=",
"this",
".",
"_layers",
";",
"var",
"zlevelList",
"=",
"this",
".",
"_zlevelList",
";",
"var",
"layer",
"=",
"layers",
"[",
"zlevel",
"]",
";",
"if",
"(",
"!",
"layer",
")",
"{",
"return",
... | 删除指定层
@param {number} zlevel 层所在的zlevel | [
"删除指定层"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/Painter.js#L818-L829 | train | Remove a log file layer | [
30522,
3853,
1006,
1062,
20414,
2884,
1007,
1063,
13075,
9014,
1027,
2023,
1012,
1035,
9014,
1025,
13075,
1062,
20414,
13348,
3367,
1027,
2023,
1012,
1035,
1062,
20414,
13348,
3367,
1025,
13075,
6741,
1027,
9014,
1031,
1062,
20414,
2884,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/command/KeyBindingManager.js | _updateCommandAndKeyMaps | function _updateCommandAndKeyMaps(newBinding) {
if (_allCommands.length === 0) {
return;
}
if (newBinding && newBinding.commandID && _allCommands.indexOf(newBinding.commandID) === -1) {
_defaultKeyMap[newBinding.commandID] = _.cloneDeep(newBinding);
// Process user key map again to catch any reassignment to all new key bindings added from extensions.
_loadUserKeyMap();
}
} | javascript | function _updateCommandAndKeyMaps(newBinding) {
if (_allCommands.length === 0) {
return;
}
if (newBinding && newBinding.commandID && _allCommands.indexOf(newBinding.commandID) === -1) {
_defaultKeyMap[newBinding.commandID] = _.cloneDeep(newBinding);
// Process user key map again to catch any reassignment to all new key bindings added from extensions.
_loadUserKeyMap();
}
} | [
"function",
"_updateCommandAndKeyMaps",
"(",
"newBinding",
")",
"{",
"if",
"(",
"_allCommands",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"newBinding",
"&&",
"newBinding",
".",
"commandID",
"&&",
"_allCommands",
".",
"indexOf",
"(",... | @private
Updates _allCommands array and _defaultKeyMap with the new key binding
if it is not yet in the _allCommands array. _allCommands array is initialized
only in extensionsLoaded event. So any new commands or key bindings added after
that will be updated here.
@param {{commandID: string, key: string, displayKey:string, explicitPlatform: string}} newBinding | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L610-L621 | train | Update command key map | [
30522,
3853,
1035,
10651,
9006,
2386,
7847,
2094,
14839,
2863,
4523,
1006,
2047,
8428,
4667,
1007,
1063,
2065,
1006,
1035,
2035,
9006,
2386,
5104,
1012,
3091,
1027,
1027,
1027,
1014,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2047,
8428,
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... |
airyland/vux | src/components/video/zy.media.js | function() {
var t = this;
var timeline = document.createElement('div');
timeline.className = 'zy_timeline';
timeline.innerHTML = '<div class="zy_timeline_slider">' +
'<div class="zy_timeline_buffering" style="display:none"></div>' +
'<div class="zy_timeline_loaded"></div>' +
'<div class="zy_timeline_current"></div>' +
'<div class="zy_timeline_handle"></div>' +
'</div>';
t.controls.appendChild(timeline);
t.slider = timeline.children[0];
t.buffering = t.slider.children[0];
t.loaded = t.slider.children[1];
t.current = t.slider.children[2];
t.handle = t.slider.children[3];
var isPointerDown = false;
var _X = t.slider.offsetLeft;
var _W = _css(t.slider, 'width');
var pointerMove = function(e) {
var _time = 0;
var x;
if (e.changedTouches) {
x = e.changedTouches[0].pageX
} else {
x = e.pageX
}
if (t.media.duration) {
if (x < _X) {
x = _X
} else if (x > _W + _X) {
x = _W + _X
}
_time = ((x - _X) / _W) * t.media.duration;
if (isPointerDown && _time !== t.media.currentTime) {
t.media.currentTime = _time
}
}
};
// Handle clicks
if (zyMedia.features.hasTouch) {
t.slider.addEventListener('touchstart', function(e) {
isPointerDown = true;
pointerMove(e);
_X = t.slider.offsetLeft;
_W = _css(t.slider, 'width');
t.slider.addEventListener('touchmove', pointerMove);
t.slider.addEventListener('touchend', function(e) {
isPointerDown = false;
t.slider.removeEventListener('touchmove', pointerMove)
});
});
} else {
t.slider.addEventListener('mousedown', function(e) {
isPointerDown = true;
pointerMove(e);
_X = t.slider.offsetLeft;
_W = _css(t.slider, 'width');
t.slider.addEventListener('mousemove', pointerMove);
t.slider.addEventListener('mouseup', function(e) {
isPointerDown = false;
t.slider.addEventListener('mousemove', pointerMove)
});
});
}
t.slider.addEventListener('mouseenter', function(e) {
t.slider.addEventListener('mousemove', pointerMove);
});
t.slider.addEventListener('mouseleave', function(e) {
if (!isPointerDown) {
t.slider.removeEventListener('mousemove', pointerMove)
}
});
//4Hz ~ 66Hz, no longer than 250ms
t.media.addEventListener('timeupdate', function(e) {
t.updateTimeline(e)
});
} | javascript | function() {
var t = this;
var timeline = document.createElement('div');
timeline.className = 'zy_timeline';
timeline.innerHTML = '<div class="zy_timeline_slider">' +
'<div class="zy_timeline_buffering" style="display:none"></div>' +
'<div class="zy_timeline_loaded"></div>' +
'<div class="zy_timeline_current"></div>' +
'<div class="zy_timeline_handle"></div>' +
'</div>';
t.controls.appendChild(timeline);
t.slider = timeline.children[0];
t.buffering = t.slider.children[0];
t.loaded = t.slider.children[1];
t.current = t.slider.children[2];
t.handle = t.slider.children[3];
var isPointerDown = false;
var _X = t.slider.offsetLeft;
var _W = _css(t.slider, 'width');
var pointerMove = function(e) {
var _time = 0;
var x;
if (e.changedTouches) {
x = e.changedTouches[0].pageX
} else {
x = e.pageX
}
if (t.media.duration) {
if (x < _X) {
x = _X
} else if (x > _W + _X) {
x = _W + _X
}
_time = ((x - _X) / _W) * t.media.duration;
if (isPointerDown && _time !== t.media.currentTime) {
t.media.currentTime = _time
}
}
};
// Handle clicks
if (zyMedia.features.hasTouch) {
t.slider.addEventListener('touchstart', function(e) {
isPointerDown = true;
pointerMove(e);
_X = t.slider.offsetLeft;
_W = _css(t.slider, 'width');
t.slider.addEventListener('touchmove', pointerMove);
t.slider.addEventListener('touchend', function(e) {
isPointerDown = false;
t.slider.removeEventListener('touchmove', pointerMove)
});
});
} else {
t.slider.addEventListener('mousedown', function(e) {
isPointerDown = true;
pointerMove(e);
_X = t.slider.offsetLeft;
_W = _css(t.slider, 'width');
t.slider.addEventListener('mousemove', pointerMove);
t.slider.addEventListener('mouseup', function(e) {
isPointerDown = false;
t.slider.addEventListener('mousemove', pointerMove)
});
});
}
t.slider.addEventListener('mouseenter', function(e) {
t.slider.addEventListener('mousemove', pointerMove);
});
t.slider.addEventListener('mouseleave', function(e) {
if (!isPointerDown) {
t.slider.removeEventListener('mousemove', pointerMove)
}
});
//4Hz ~ 66Hz, no longer than 250ms
t.media.addEventListener('timeupdate', function(e) {
t.updateTimeline(e)
});
} | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
";",
"var",
"timeline",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"timeline",
".",
"className",
"=",
"'zy_timeline'",
";",
"timeline",
".",
"innerHTML",
"=",
"'<div class=\"zy_timeline_... | Timeline | [
"Timeline"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/video/zy.media.js#L595-L682 | train | Creates the timeline | [
30522,
3853,
1006,
1007,
1063,
13075,
1056,
1027,
2023,
1025,
13075,
17060,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
17060,
1012,
2465,
18442,
1027,
30524,
1062,
2100,
1035,
17060,
1035,
7358,
2099,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (sPart, bEncodeEquals) {
var sEncoded = encodeURI(sPart)
.replace(rAmpersand, "%26")
.replace(rHash, "%23")
.replace(rPlus, "%2B");
if (bEncodeEquals) {
sEncoded = sEncoded.replace(rEquals, "%3D");
}
return sEncoded;
} | javascript | function (sPart, bEncodeEquals) {
var sEncoded = encodeURI(sPart)
.replace(rAmpersand, "%26")
.replace(rHash, "%23")
.replace(rPlus, "%2B");
if (bEncodeEquals) {
sEncoded = sEncoded.replace(rEquals, "%3D");
}
return sEncoded;
} | [
"function",
"(",
"sPart",
",",
"bEncodeEquals",
")",
"{",
"var",
"sEncoded",
"=",
"encodeURI",
"(",
"sPart",
")",
".",
"replace",
"(",
"rAmpersand",
",",
"\"%26\"",
")",
".",
"replace",
"(",
"rHash",
",",
"\"%23\"",
")",
".",
"replace",
"(",
"rPlus",
"... | Encodes a query part, either a key or a value.
@param {string} sPart
The query part
@param {boolean} bEncodeEquals
If true, "=" is encoded, too
@returns {string}
The encoded query part | [
"Encodes",
"a",
"query",
"part",
"either",
"a",
"key",
"or",
"a",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L363-L372 | train | Encode a URI part | [
30522,
3853,
1006,
12403,
5339,
1010,
3841,
16044,
2063,
26426,
2015,
1007,
1063,
13075,
12411,
16044,
2094,
1027,
4372,
16044,
9496,
30524,
1054,
14949,
2232,
1010,
1000,
1003,
2603,
1000,
1007,
1012,
5672,
1006,
1054,
24759,
2271,
1010,
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/project/FileSyncManager.js | reloadDoc | function reloadDoc(doc) {
var promise = FileUtils.readAsText(doc.file);
promise.done(function (text, readTimestamp) {
doc.refreshText(text, readTimestamp);
});
promise.fail(function (error) {
console.log("Error reloading contents of " + doc.file.fullPath, error);
});
return promise;
} | javascript | function reloadDoc(doc) {
var promise = FileUtils.readAsText(doc.file);
promise.done(function (text, readTimestamp) {
doc.refreshText(text, readTimestamp);
});
promise.fail(function (error) {
console.log("Error reloading contents of " + doc.file.fullPath, error);
});
return promise;
} | [
"function",
"reloadDoc",
"(",
"doc",
")",
"{",
"var",
"promise",
"=",
"FileUtils",
".",
"readAsText",
"(",
"doc",
".",
"file",
")",
";",
"promise",
".",
"done",
"(",
"function",
"(",
"text",
",",
"readTimestamp",
")",
"{",
"doc",
".",
"refreshText",
"(... | Reloads the Document's contents from disk, discarding any unsaved changes in the editor.
@param {!Document} doc
@return {$.Promise} Resolved after editor has been refreshed; rejected if unable to load the
file's new content. Errors are logged but no UI is shown. | [
"Reloads",
"the",
"Document",
"s",
"contents",
"from",
"disk",
"discarding",
"any",
"unsaved",
"changes",
"in",
"the",
"editor",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileSyncManager.js#L218-L229 | train | Reloads the contents of the specified document | [
30522,
3853,
2128,
11066,
3527,
2278,
1006,
9986,
1007,
1063,
13075,
4872,
1027,
5371,
21823,
4877,
1012,
3191,
14083,
10288,
2102,
1006,
9986,
1012,
5371,
1007,
1025,
4872,
1012,
2589,
1006,
3853,
1006,
3793,
1010,
3191,
7292,
9153,
8737,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | examples/3d/js/player.js | function(x, y, dir, speed) {
this.x = x;
this.y = y;
this.dir = dir;
this.speed = speed || 3;
this.steps = 0;
this.hand = new Texture('./assets/gun.png', 512, 360);
// Update the position of the audio listener.
Howler.pos(this.x, this.y, -0.5);
// Update the direction and orientation.
this.rotate(dir);
} | javascript | function(x, y, dir, speed) {
this.x = x;
this.y = y;
this.dir = dir;
this.speed = speed || 3;
this.steps = 0;
this.hand = new Texture('./assets/gun.png', 512, 360);
// Update the position of the audio listener.
Howler.pos(this.x, this.y, -0.5);
// Update the direction and orientation.
this.rotate(dir);
} | [
"function",
"(",
"x",
",",
"y",
",",
"dir",
",",
"speed",
")",
"{",
"this",
".",
"x",
"=",
"x",
";",
"this",
".",
"y",
"=",
"y",
";",
"this",
".",
"dir",
"=",
"dir",
";",
"this",
".",
"speed",
"=",
"speed",
"||",
"3",
";",
"this",
".",
"s... | The player from which we cast the rays.
@param {Number} x Starting x-position.
@param {Number} y Starting y-position.
@param {Number} dir Direction they are facing in radians.
@param {Number} speed Speed they walk at. | [
"The",
"player",
"from",
"which",
"we",
"cast",
"the",
"rays",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/player.js#L20-L33 | train | Initialize a new Knockout object. | [
30522,
3853,
1006,
1060,
1010,
1061,
1010,
16101,
1010,
3177,
1007,
1063,
2023,
1012,
1060,
1027,
1060,
1025,
2023,
1012,
1061,
1027,
1061,
1025,
2023,
1012,
16101,
1027,
16101,
1025,
2023,
1012,
3177,
1027,
3177,
1064,
1064,
1017,
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/main.js | _setupGoLiveMenu | function _setupGoLiveMenu() {
LiveDevImpl.on("statusChange", function statusChange(event, status) {
// Update the checkmark next to 'Live Preview' menu item
// Add checkmark when status is STATUS_ACTIVE; otherwise remove it
CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevImpl.STATUS_ACTIVE);
CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(status === LiveDevImpl.STATUS_ACTIVE);
});
} | javascript | function _setupGoLiveMenu() {
LiveDevImpl.on("statusChange", function statusChange(event, status) {
// Update the checkmark next to 'Live Preview' menu item
// Add checkmark when status is STATUS_ACTIVE; otherwise remove it
CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevImpl.STATUS_ACTIVE);
CommandManager.get(Commands.FILE_LIVE_HIGHLIGHT).setEnabled(status === LiveDevImpl.STATUS_ACTIVE);
});
} | [
"function",
"_setupGoLiveMenu",
"(",
")",
"{",
"LiveDevImpl",
".",
"on",
"(",
"\"statusChange\"",
",",
"function",
"statusChange",
"(",
"event",
",",
"status",
")",
"{",
"// Update the checkmark next to 'Live Preview' menu item",
"// Add checkmark when status is STATUS_ACTIVE... | Maintains state of the Live Preview menu item | [
"Maintains",
"state",
"of",
"the",
"Live",
"Preview",
"menu",
"item"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L250-L257 | train | Setup Live Preview menu | [
30522,
3853,
1035,
16437,
24141,
3512,
3549,
2226,
1006,
1007,
1063,
2973,
6777,
5714,
24759,
1012,
2006,
1006,
1000,
3570,
22305,
2063,
1000,
1010,
3853,
3570,
22305,
2063,
1006,
2724,
1010,
3570,
1007,
1063,
1013,
1013,
10651,
1996,
4638,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeView.js | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.treeData !== nextProps.treeData ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions ||
this.props.selectionViewInfo !== nextProps.selectionViewInfo;
} | javascript | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.treeData !== nextProps.treeData ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions ||
this.props.selectionViewInfo !== nextProps.selectionViewInfo;
} | [
"function",
"(",
"nextProps",
",",
"nextState",
")",
"{",
"return",
"nextProps",
".",
"forceRender",
"||",
"this",
".",
"props",
".",
"treeData",
"!==",
"nextProps",
".",
"treeData",
"||",
"this",
".",
"props",
".",
"sortDirectoriesFirst",
"!==",
"nextProps",
... | Update for any change in the tree data or directory sorting preference. | [
"Update",
"for",
"any",
"change",
"in",
"the",
"tree",
"data",
"or",
"directory",
"sorting",
"preference",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L1127-L1133 | train | Check if the treeData and sortDirectoriesFirst properties are the same as the current treeData and the current sortDirectoriesFirst properties. | [
30522,
3853,
1006,
2279,
21572,
4523,
1010,
2279,
9153,
2618,
1007,
1063,
2709,
2279,
21572,
4523,
1012,
2486,
7389,
4063,
1064,
1064,
2023,
1012,
24387,
1012,
3392,
2850,
2696,
999,
1027,
1027,
2279,
21572,
4523,
1012,
3392,
2850,
2696,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/async/Targets.js | function (vTargets, vData, sTitleTarget, oSequencePromise, fnAfterCreate) {
var that = this,
aViewInfos = [];
if (!Array.isArray(vTargets)) {
vTargets = [vTargets];
}
this._attachTitleChanged(vTargets, sTitleTarget);
return vTargets.reduce(function(oPromise, vTarget) {
var oTargetInfo = vTarget;
if (typeof vTarget === "string") {
oTargetInfo = {
name: vTarget
};
}
var oTargetCreateInfo = {
afterCreate: fnAfterCreate,
prefix: oTargetInfo.prefix
};
// gather view infos while processing Promise chain
return that._displaySingleTarget(oTargetInfo, vData, oPromise, oTargetCreateInfo).then(function(oViewInfo) {
oViewInfo = oViewInfo || {};
oViewInfo.targetInfo = oTargetInfo;
aViewInfos.push(oViewInfo);
});
}, oSequencePromise).then(function() {
return aViewInfos;
});
} | javascript | function (vTargets, vData, sTitleTarget, oSequencePromise, fnAfterCreate) {
var that = this,
aViewInfos = [];
if (!Array.isArray(vTargets)) {
vTargets = [vTargets];
}
this._attachTitleChanged(vTargets, sTitleTarget);
return vTargets.reduce(function(oPromise, vTarget) {
var oTargetInfo = vTarget;
if (typeof vTarget === "string") {
oTargetInfo = {
name: vTarget
};
}
var oTargetCreateInfo = {
afterCreate: fnAfterCreate,
prefix: oTargetInfo.prefix
};
// gather view infos while processing Promise chain
return that._displaySingleTarget(oTargetInfo, vData, oPromise, oTargetCreateInfo).then(function(oViewInfo) {
oViewInfo = oViewInfo || {};
oViewInfo.targetInfo = oTargetInfo;
aViewInfos.push(oViewInfo);
});
}, oSequencePromise).then(function() {
return aViewInfos;
});
} | [
"function",
"(",
"vTargets",
",",
"vData",
",",
"sTitleTarget",
",",
"oSequencePromise",
",",
"fnAfterCreate",
")",
"{",
"var",
"that",
"=",
"this",
",",
"aViewInfos",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"vTargets",
")",
"... | hook to distinguish between the router and an application calling this
@param {array|object} vTargets targets or single target to be displayed
@param {object} vData an object that will be passed to the display event in the data property. If the
target has parents, the data will also be passed to them.
@param {string} sTitleTarget the name of the target from which the title option is taken for firing the {@link sap.ui.core.routing.Targets#event:titleChanged titleChanged} event
@param {Promise} oSequencePromise the promise for chaining
@param {function} [fnAfterCreate] the function which will be called when the Target View/Component is instantiated
@return {Promise} resolving with {{name: *, view: *, control: *}|undefined} for every vTargets, object for single, array for multiple
@private | [
"hook",
"to",
"distinguish",
"between",
"the",
"router",
"and",
"an",
"application",
"calling",
"this",
"@param",
"{",
"array|object",
"}",
"vTargets",
"targets",
"or",
"single",
"target",
"to",
"be",
"displayed",
"@param",
"{",
"object",
"}",
"vData",
"an",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/async/Targets.js#L40-L73 | train | displays a list of targets | [
30522,
3853,
1006,
28879,
2906,
18150,
2015,
1010,
1058,
2850,
2696,
1010,
2358,
4183,
7485,
2906,
18150,
1010,
9808,
2063,
4226,
5897,
21572,
28732,
1010,
1042,
2532,
6199,
2121,
16748,
3686,
1007,
1063,
13075,
2008,
1027,
2023,
1010,
2070... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mrvautin/expressCart | public/javascripts/expressCart.js | showNotification | function showNotification(msg, type, reloadPage){
// defaults to false
reloadPage = reloadPage || false;
$('#notify_message').removeClass();
$('#notify_message').addClass('alert-' + type);
$('#notify_message').html(msg);
$('#notify_message').slideDown(600).delay(2500).slideUp(600, function(){
if(reloadPage === true){
location.reload();
}
});
} | javascript | function showNotification(msg, type, reloadPage){
// defaults to false
reloadPage = reloadPage || false;
$('#notify_message').removeClass();
$('#notify_message').addClass('alert-' + type);
$('#notify_message').html(msg);
$('#notify_message').slideDown(600).delay(2500).slideUp(600, function(){
if(reloadPage === true){
location.reload();
}
});
} | [
"function",
"showNotification",
"(",
"msg",
",",
"type",
",",
"reloadPage",
")",
"{",
"// defaults to false",
"reloadPage",
"=",
"reloadPage",
"||",
"false",
";",
"$",
"(",
"'#notify_message'",
")",
".",
"removeClass",
"(",
")",
";",
"$",
"(",
"'#notify_messag... | show notification popup | [
"show",
"notification",
"popup"
] | 0b6071b6d963d786684fb9cfa7d1ccc499c3ce27 | https://github.com/mrvautin/expressCart/blob/0b6071b6d963d786684fb9cfa7d1ccc499c3ce27/public/javascripts/expressCart.js#L774-L786 | train | show notification | [
30522,
3853,
3491,
4140,
9031,
1006,
5796,
2290,
1010,
2828,
1010,
2128,
11066,
13704,
1007,
1063,
1013,
1013,
12398,
2015,
2000,
6270,
2128,
11066,
13704,
1027,
2128,
11066,
13704,
1064,
1064,
6270,
1025,
1002,
1006,
1005,
1001,
2025,
8757... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.integration/src/sap/ui/integration/util/CardManifest.js | processPlaceholder | function processPlaceholder (sPlaceholder, oParam) {
var sISODate = new Date().toISOString();
var sProcessed = sPlaceholder.replace("{{parameters.NOW_ISO}}", sISODate);
sProcessed = sProcessed.replace("{{parameters.TODAY_ISO}}", sISODate.slice(0, 10));
if (oParam) {
for (var oProperty in oParam) {
sProcessed = sProcessed.replace("{{parameters." + oProperty + "}}", oParam[oProperty].value);
}
}
return sProcessed;
} | javascript | function processPlaceholder (sPlaceholder, oParam) {
var sISODate = new Date().toISOString();
var sProcessed = sPlaceholder.replace("{{parameters.NOW_ISO}}", sISODate);
sProcessed = sProcessed.replace("{{parameters.TODAY_ISO}}", sISODate.slice(0, 10));
if (oParam) {
for (var oProperty in oParam) {
sProcessed = sProcessed.replace("{{parameters." + oProperty + "}}", oParam[oProperty].value);
}
}
return sProcessed;
} | [
"function",
"processPlaceholder",
"(",
"sPlaceholder",
",",
"oParam",
")",
"{",
"var",
"sISODate",
"=",
"new",
"Date",
"(",
")",
".",
"toISOString",
"(",
")",
";",
"var",
"sProcessed",
"=",
"sPlaceholder",
".",
"replace",
"(",
"\"{{parameters.NOW_ISO}}\"",
","... | Replace all placeholders inside the string.
@private
@param {string} sPlaceholder The value to process.
@param {Object} oParam The parameter from the configuration.
@returns {string} The string with replaced placeholders. | [
"Replace",
"all",
"placeholders",
"inside",
"the",
"string",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.integration/src/sap/ui/integration/util/CardManifest.js#L212-L223 | train | Process a placeholder string | [
30522,
3853,
2832,
24759,
10732,
14528,
1006,
11867,
19217,
14528,
1010,
6728,
5400,
2213,
1007,
1063,
13075,
24761,
13390,
2618,
1027,
2047,
3058,
1006,
1007,
1012,
2000,
19565,
3367,
4892,
1006,
1007,
1025,
13075,
11867,
3217,
9623,
6924,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/jszip.js | function(buf, crc) {
var c = (typeof(crc) == "undefined" ? 0 : crc) ^ 0xffffffff;
var bArray = typeof buf !== "string";
var n;
if (bArray) {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf[n]) & 0xff] ^ (c >>> 8);
}
} else {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf.charCodeAt(n)) & 0xff] ^ (c >>> 8);
}
}
return c ^ 0xffffffff;
} | javascript | function(buf, crc) {
var c = (typeof(crc) == "undefined" ? 0 : crc) ^ 0xffffffff;
var bArray = typeof buf !== "string";
var n;
if (bArray) {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf[n]) & 0xff] ^ (c >>> 8);
}
} else {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf.charCodeAt(n)) & 0xff] ^ (c >>> 8);
}
}
return c ^ 0xffffffff;
} | [
"function",
"(",
"buf",
",",
"crc",
")",
"{",
"var",
"c",
"=",
"(",
"typeof",
"(",
"crc",
")",
"==",
"\"undefined\"",
"?",
"0",
":",
"crc",
")",
"^",
"0xffffffff",
";",
"var",
"bArray",
"=",
"typeof",
"buf",
"!==",
"\"string\"",
";",
"var",
"n",
... | ##### BEGIN: MODIFIED BY SAP functions crc32, utf8encode and utf8decode are replaced with implementations by SAP | [
"#####",
"BEGIN",
":",
"MODIFIED",
"BY",
"SAP",
"functions",
"crc32",
"utf8encode",
"and",
"utf8decode",
"are",
"replaced",
"with",
"implementations",
"by",
"SAP"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1121-L1138 | train | Compute the CRC32 of the given buffer | [
30522,
3853,
1006,
20934,
2546,
1010,
13675,
2278,
1007,
1063,
13075,
1039,
1027,
1006,
2828,
11253,
1006,
13675,
2278,
1007,
1027,
1027,
1000,
6151,
28344,
1000,
1029,
1014,
1024,
13675,
2278,
1007,
1034,
1014,
2595,
4246,
4246,
4246,
4246... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-var.js | report | function report(node) {
context.report({
node,
message: "Unexpected var, use let or const instead.",
fix(fixer) {
const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" });
return canFix(node)
? fixer.replaceText(varToken, "let")
: null;
}
});
} | javascript | function report(node) {
context.report({
node,
message: "Unexpected var, use let or const instead.",
fix(fixer) {
const varToken = sourceCode.getFirstToken(node, { filter: t => t.value === "var" });
return canFix(node)
? fixer.replaceText(varToken, "let")
: null;
}
});
} | [
"function",
"report",
"(",
"node",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Unexpected var, use let or const instead.\"",
",",
"fix",
"(",
"fixer",
")",
"{",
"const",
"varToken",
"=",
"sourceCode",
".",
"getFirstToken",
"("... | Reports a given variable declaration node.
@param {ASTNode} node - A variable declaration node to report.
@returns {void} | [
"Reports",
"a",
"given",
"variable",
"declaration",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-var.js#L307-L320 | train | Reports a given variable declaration. | [
30522,
3853,
3189,
1006,
13045,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
4471,
1024,
1000,
9223,
13075,
1010,
2224,
2292,
2030,
9530,
3367,
2612,
1012,
1000,
1010,
8081,
1006,
8081,
2121,
1007,
1063,
9530,
3367,
13075,
18715,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/util/Utils.js | function () {
var sUuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (sPosition) {
var iRandom = Math.random() * 16 | 0;
if (sPosition === 'y') {
iRandom = iRandom & 0x3 | 0x8;
}
return iRandom.toString(16);
});
return sUuid;
} | javascript | function () {
var sUuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (sPosition) {
var iRandom = Math.random() * 16 | 0;
if (sPosition === 'y') {
iRandom = iRandom & 0x3 | 0x8;
}
return iRandom.toString(16);
});
return sUuid;
} | [
"function",
"(",
")",
"{",
"var",
"sUuid",
"=",
"'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'",
".",
"replace",
"(",
"/",
"[xy]",
"/",
"g",
",",
"function",
"(",
"sPosition",
")",
"{",
"var",
"iRandom",
"=",
"Math",
".",
"random",
"(",
")",
"*",
"16",
"|",
"... | Generates v4 uuid (based on random numbers).
@return {string} The generated v4 uuid | [
"Generates",
"v4",
"uuid",
"(",
"based",
"on",
"random",
"numbers",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/util/Utils.js#L101-L113 | train | Generate a uuid | [
30522,
3853,
1006,
1007,
1063,
13075,
10514,
21272,
1027,
1005,
22038,
20348,
20348,
20348,
1011,
22038,
20348,
1011,
1018,
20348,
2595,
1011,
1061,
20348,
2595,
1011,
22038,
20348,
20348,
20348,
20348,
20348,
1005,
1012,
5672,
1006,
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... | |
moment/luxon | src/duration.js | normalizeValues | function normalizeValues(matrix, vals) {
reverseUnits.reduce((previous, current) => {
if (!isUndefined(vals[current])) {
if (previous) {
convert(matrix, vals, previous, vals, current);
}
return current;
} else {
return previous;
}
}, null);
} | javascript | function normalizeValues(matrix, vals) {
reverseUnits.reduce((previous, current) => {
if (!isUndefined(vals[current])) {
if (previous) {
convert(matrix, vals, previous, vals, current);
}
return current;
} else {
return previous;
}
}, null);
} | [
"function",
"normalizeValues",
"(",
"matrix",
",",
"vals",
")",
"{",
"reverseUnits",
".",
"reduce",
"(",
"(",
"previous",
",",
"current",
")",
"=>",
"{",
"if",
"(",
"!",
"isUndefined",
"(",
"vals",
"[",
"current",
"]",
")",
")",
"{",
"if",
"(",
"prev... | NB: mutates parameters | [
"NB",
":",
"mutates",
"parameters"
] | 236f2badea297ee73421aa39a83e06177c1be6d0 | https://github.com/moment/luxon/blob/236f2badea297ee73421aa39a83e06177c1be6d0/src/duration.js#L137-L148 | train | Normalize the values of a given matrix | [
30522,
3853,
3671,
4697,
10175,
15808,
1006,
8185,
1010,
11748,
2015,
1007,
1063,
7901,
19496,
3215,
1012,
5547,
1006,
1006,
3025,
1010,
2783,
1007,
1027,
1028,
1063,
2065,
1006,
999,
2003,
8630,
28344,
1006,
11748,
2015,
1031,
2783,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | dist/howler.js | function(sound) {
var self = this;
// Setup the buffer source for playback.
sound._node.bufferSource = Howler.ctx.createBufferSource();
sound._node.bufferSource.buffer = cache[self._src];
// Connect to the correct node.
if (sound._panner) {
sound._node.bufferSource.connect(sound._panner);
} else {
sound._node.bufferSource.connect(sound._node);
}
// Setup looping and playback rate.
sound._node.bufferSource.loop = sound._loop;
if (sound._loop) {
sound._node.bufferSource.loopStart = sound._start || 0;
sound._node.bufferSource.loopEnd = sound._stop || 0;
}
sound._node.bufferSource.playbackRate.setValueAtTime(sound._rate, Howler.ctx.currentTime);
return self;
} | javascript | function(sound) {
var self = this;
// Setup the buffer source for playback.
sound._node.bufferSource = Howler.ctx.createBufferSource();
sound._node.bufferSource.buffer = cache[self._src];
// Connect to the correct node.
if (sound._panner) {
sound._node.bufferSource.connect(sound._panner);
} else {
sound._node.bufferSource.connect(sound._node);
}
// Setup looping and playback rate.
sound._node.bufferSource.loop = sound._loop;
if (sound._loop) {
sound._node.bufferSource.loopStart = sound._start || 0;
sound._node.bufferSource.loopEnd = sound._stop || 0;
}
sound._node.bufferSource.playbackRate.setValueAtTime(sound._rate, Howler.ctx.currentTime);
return self;
} | [
"function",
"(",
"sound",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Setup the buffer source for playback.",
"sound",
".",
"_node",
".",
"bufferSource",
"=",
"Howler",
".",
"ctx",
".",
"createBufferSource",
"(",
")",
";",
"sound",
".",
"_node",
".",
"buf... | Load the sound back into the buffer source.
@param {Sound} sound The sound object to work with.
@return {Howl} | [
"Load",
"the",
"sound",
"back",
"into",
"the",
"buffer",
"source",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2090-L2113 | train | Setup the buffer source for playback. | [
30522,
3853,
1006,
2614,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
16437,
1996,
17698,
3120,
2005,
18245,
1012,
2614,
1012,
1035,
13045,
1012,
17698,
6499,
3126,
3401,
1027,
22912,
2121,
1012,
14931,
2595,
1012,
3443,
8569,
124... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Agents/GotoAgent.js | _urlWithoutQueryString | function _urlWithoutQueryString(url) {
var index = url.search(/[#\?]/);
if (index >= 0) {
url = url.substr(0, index);
}
return url;
} | javascript | function _urlWithoutQueryString(url) {
var index = url.search(/[#\?]/);
if (index >= 0) {
url = url.substr(0, index);
}
return url;
} | [
"function",
"_urlWithoutQueryString",
"(",
"url",
")",
"{",
"var",
"index",
"=",
"url",
".",
"search",
"(",
"/",
"[#\\?]",
"/",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"url",
"=",
"url",
".",
"substr",
"(",
"0",
",",
"index",
")",
";",... | Return the URL without the query string
@param {string} URL | [
"Return",
"the",
"URL",
"without",
"the",
"query",
"string"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/GotoAgent.js#L47-L53 | train | Remove query string from url | [
30522,
3853,
1035,
24471,
2140,
24415,
5833,
4226,
24769,
18886,
3070,
1006,
24471,
2140,
1007,
1063,
13075,
5950,
1027,
24471,
2140,
1012,
3945,
1006,
1013,
1031,
1001,
1032,
1029,
1033,
1013,
1007,
1025,
2065,
1006,
5950,
1028,
1027,
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... |
Shopify/draggable | src/Draggable/Plugins/Announcement/Announcement.js | createRegion | function createRegion() {
const element = document.createElement('div');
element.setAttribute('id', 'draggable-live-region');
element.setAttribute(ARIA_RELEVANT, 'additions');
element.setAttribute(ARIA_ATOMIC, 'true');
element.setAttribute(ARIA_LIVE, 'assertive');
element.setAttribute(ROLE, 'log');
element.style.position = 'fixed';
element.style.width = '1px';
element.style.height = '1px';
element.style.top = '-1px';
element.style.overflow = 'hidden';
return element;
} | javascript | function createRegion() {
const element = document.createElement('div');
element.setAttribute('id', 'draggable-live-region');
element.setAttribute(ARIA_RELEVANT, 'additions');
element.setAttribute(ARIA_ATOMIC, 'true');
element.setAttribute(ARIA_LIVE, 'assertive');
element.setAttribute(ROLE, 'log');
element.style.position = 'fixed';
element.style.width = '1px';
element.style.height = '1px';
element.style.top = '-1px';
element.style.overflow = 'hidden';
return element;
} | [
"function",
"createRegion",
"(",
")",
"{",
"const",
"element",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"element",
".",
"setAttribute",
"(",
"'id'",
",",
"'draggable-live-region'",
")",
";",
"element",
".",
"setAttribute",
"(",
"ARIA_RELE... | Creates region element
@return {HTMLElement} | [
"Creates",
"region",
"element"
] | ecc04b2cdb8b5009664862472ff8cb237c38cfeb | https://github.com/Shopify/draggable/blob/ecc04b2cdb8b5009664862472ff8cb237c38cfeb/src/Draggable/Plugins/Announcement/Announcement.js#L157-L173 | train | Creates a region | [
30522,
3853,
3443,
23784,
1006,
1007,
1063,
9530,
3367,
5783,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
5783,
1012,
2275,
19321,
3089,
8569,
2618,
1006,
1005,
8909,
1005,
1010,
1005,
8011,
3654,
3468,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-trailing-spaces.js | getCommentLineNumbers | function getCommentLineNumbers(comments) {
const lines = new Set();
comments.forEach(comment => {
for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
lines.add(i);
}
});
return lines;
} | javascript | function getCommentLineNumbers(comments) {
const lines = new Set();
comments.forEach(comment => {
for (let i = comment.loc.start.line; i <= comment.loc.end.line; i++) {
lines.add(i);
}
});
return lines;
} | [
"function",
"getCommentLineNumbers",
"(",
"comments",
")",
"{",
"const",
"lines",
"=",
"new",
"Set",
"(",
")",
";",
"comments",
".",
"forEach",
"(",
"comment",
"=>",
"{",
"for",
"(",
"let",
"i",
"=",
"comment",
".",
"loc",
".",
"start",
".",
"line",
... | Given a list of comment nodes, return the line numbers for those comments.
@param {Array} comments An array of comment nodes.
@returns {number[]} An array of line numbers containing comments. | [
"Given",
"a",
"list",
"of",
"comment",
"nodes",
"return",
"the",
"line",
"numbers",
"for",
"those",
"comments",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-trailing-spaces.js#L89-L99 | train | getCommentLineNumbers - get line numbers from comments | [
30522,
3853,
2131,
9006,
3672,
4179,
19172,
17198,
1006,
7928,
1007,
1063,
9530,
3367,
3210,
1027,
2047,
2275,
1006,
1007,
1025,
7928,
1012,
18921,
6776,
1006,
7615,
1027,
1028,
1063,
2005,
1006,
2292,
1045,
1027,
7615,
1012,
8840,
2278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/bottomSheet/bottom-sheet.js | MdBottomSheetDirective | function MdBottomSheetDirective($mdBottomSheet) {
return {
restrict: 'E',
link : function postLink(scope, element) {
element.addClass('_md'); // private md component indicator for styling
// When navigation force destroys an interimElement, then
// listen and $destroy() that interim instance...
scope.$on('$destroy', function() {
$mdBottomSheet.destroy();
});
}
};
} | javascript | function MdBottomSheetDirective($mdBottomSheet) {
return {
restrict: 'E',
link : function postLink(scope, element) {
element.addClass('_md'); // private md component indicator for styling
// When navigation force destroys an interimElement, then
// listen and $destroy() that interim instance...
scope.$on('$destroy', function() {
$mdBottomSheet.destroy();
});
}
};
} | [
"function",
"MdBottomSheetDirective",
"(",
"$mdBottomSheet",
")",
"{",
"return",
"{",
"restrict",
":",
"'E'",
",",
"link",
":",
"function",
"postLink",
"(",
"scope",
",",
"element",
")",
"{",
"element",
".",
"addClass",
"(",
"'_md'",
")",
";",
"// private md... | /* @ngInject | [
"/",
"*"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/bottomSheet/bottom-sheet.js#L16-L29 | train | Directive to be used to create a md - bottom - sheet. | [
30522,
3853,
9108,
18384,
20389,
4095,
15558,
4305,
2890,
15277,
1006,
1002,
9108,
18384,
20389,
4095,
15558,
1007,
1063,
2709,
1063,
21573,
1024,
1005,
1041,
1005,
1010,
4957,
1024,
3853,
2695,
13767,
1006,
9531,
1010,
5783,
1007,
1063,
57... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/single/Single.js | function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
} | javascript | function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data = seriesModel.getData();
each(data.mapDimension(this.dimension, true), function (dim) {
this._axis.scale.unionExtentFromData(data, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
} | [
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"ecModel",
".",
"eachSeries",
"(",
"function",
"(",
"seriesModel",
")",
"{",
"if",
"(",
"seriesModel",
".",
"coordinateSystem",
"===",
"this",
")",
"{",
"var",
"data",
"=",
"seriesModel",
".",
"getData",
... | Update axis scale after data processed
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api | [
"Update",
"axis",
"scale",
"after",
"data",
"processed"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/single/Single.js#L116-L126 | train | update the extent of the extent | [
30522,
3853,
1006,
14925,
5302,
9247,
1010,
17928,
1007,
1063,
14925,
5302,
9247,
1012,
2169,
8043,
3111,
1006,
3853,
1006,
2186,
5302,
9247,
1007,
1063,
2065,
1006,
2186,
5302,
9247,
1012,
12093,
27268,
6633,
1027,
1027,
1027,
2023,
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... | |
parcel-bundler/parcel | packages/core/parcel-bundler/src/scope-hoisting/mangler.js | mangleScope | function mangleScope(scope) {
let newNames = new Set();
// Sort bindings so that more frequently referenced bindings get shorter names.
let sortedBindings = Object.keys(scope.bindings).sort(
(a, b) =>
scope.bindings[b].referencePaths.length -
scope.bindings[a].referencePaths.length
);
for (let oldName of sortedBindings) {
let i = 0;
let newName = '';
do {
newName = getIdentifier(i++);
} while (
newNames.has(newName) ||
!canRename(scope, scope.bindings[oldName], newName)
);
rename(scope, oldName, newName);
newNames.add(newName);
}
} | javascript | function mangleScope(scope) {
let newNames = new Set();
// Sort bindings so that more frequently referenced bindings get shorter names.
let sortedBindings = Object.keys(scope.bindings).sort(
(a, b) =>
scope.bindings[b].referencePaths.length -
scope.bindings[a].referencePaths.length
);
for (let oldName of sortedBindings) {
let i = 0;
let newName = '';
do {
newName = getIdentifier(i++);
} while (
newNames.has(newName) ||
!canRename(scope, scope.bindings[oldName], newName)
);
rename(scope, oldName, newName);
newNames.add(newName);
}
} | [
"function",
"mangleScope",
"(",
"scope",
")",
"{",
"let",
"newNames",
"=",
"new",
"Set",
"(",
")",
";",
"// Sort bindings so that more frequently referenced bindings get shorter names.",
"let",
"sortedBindings",
"=",
"Object",
".",
"keys",
"(",
"scope",
".",
"bindings... | This is a very specialized mangler designer to mangle only names in the top-level scope.
Mangling of names in other scopes happens at a file level inside workers, but we can't
mangle the top-level scope until scope hoisting is complete in the packager.
Based on code from babel-minify!
https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/charset.js | [
"This",
"is",
"a",
"very",
"specialized",
"mangler",
"designer",
"to",
"mangle",
"only",
"names",
"in",
"the",
"top",
"-",
"level",
"scope",
".",
"Mangling",
"of",
"names",
"in",
"other",
"scopes",
"happens",
"at",
"a",
"file",
"level",
"inside",
"workers"... | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/scope-hoisting/mangler.js#L16-L40 | train | Mangle a scope by renaming all bindings that are not referenced by more frequently referenced bindings. | [
30522,
3853,
2158,
17125,
16186,
1006,
9531,
1007,
1063,
2292,
2047,
18442,
2015,
1027,
2047,
2275,
1006,
1007,
1025,
1013,
1013,
4066,
8031,
2015,
2061,
2008,
2062,
4703,
14964,
8031,
2015,
2131,
7820,
3415,
1012,
2292,
19616,
8428,
4667,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ExpressionParser.js | addInfix | function addInfix(sId, iBindingPower, fnOperator, bLazy) {
// Note: this function is executed at load time only!
mSymbols[sId] = {
lbp: iBindingPower,
led: function (oToken, oParser, fnLeft) {
//lazy evaluation is right associative: performance optimization for guard and
//default operator, e.g. true || A || B || C does not execute the || for B and C
var rbp = bLazy ? this.lbp - 1 : this.lbp;
return INFIX.bind(null, fnLeft, oParser.expression(rbp),
fnOperator, bLazy);
},
nud: unexpected
};
return mSymbols[sId];
} | javascript | function addInfix(sId, iBindingPower, fnOperator, bLazy) {
// Note: this function is executed at load time only!
mSymbols[sId] = {
lbp: iBindingPower,
led: function (oToken, oParser, fnLeft) {
//lazy evaluation is right associative: performance optimization for guard and
//default operator, e.g. true || A || B || C does not execute the || for B and C
var rbp = bLazy ? this.lbp - 1 : this.lbp;
return INFIX.bind(null, fnLeft, oParser.expression(rbp),
fnOperator, bLazy);
},
nud: unexpected
};
return mSymbols[sId];
} | [
"function",
"addInfix",
"(",
"sId",
",",
"iBindingPower",
",",
"fnOperator",
",",
"bLazy",
")",
"{",
"// Note: this function is executed at load time only!",
"mSymbols",
"[",
"sId",
"]",
"=",
"{",
"lbp",
":",
"iBindingPower",
",",
"led",
":",
"function",
"(",
"o... | Adds the infix operator with the given id, binding power and formatter function to the
symbol table.
@param {string} sId - the id of the infix operator
@param {int} iBindingPower - the binding power = precedence of the infix operator
@param {function} fnOperator - the function to evaluate the operator
@param {boolean} [bLazy=false] - whether the right operand is lazily evaluated
@return {object} the newly created symbol for the infix operator | [
"Adds",
"the",
"infix",
"operator",
"with",
"the",
"given",
"id",
"binding",
"power",
"and",
"formatter",
"function",
"to",
"the",
"symbol",
"table",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ExpressionParser.js#L462-L477 | train | Add an infix function to the symbols map | [
30522,
3853,
5587,
2378,
8873,
2595,
1006,
15765,
1010,
21307,
22254,
2075,
11452,
1010,
1042,
3630,
4842,
8844,
1010,
1038,
2721,
9096,
1007,
1063,
1013,
1013,
3602,
1024,
2023,
3853,
2003,
6472,
2012,
7170,
2051,
2069,
999,
5796,
24335,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _createPaneIfNecessary | function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
} | javascript | function _createPaneIfNecessary(paneId) {
var newPane;
if (!_panes.hasOwnProperty(paneId)) {
newPane = new Pane(paneId, _$el);
_panes[paneId] = newPane;
exports.trigger("paneCreate", newPane.id);
newPane.$el.on("click.mainview dragover.mainview", function () {
setActivePaneId(newPane.id);
});
newPane.on("viewListChange.mainview", function () {
_updatePaneHeaders();
exports.trigger("workingSetUpdate", newPane.id);
});
newPane.on("currentViewChange.mainview", function (e, newView, oldView) {
_updatePaneHeaders();
if (_activePaneId === newPane.id) {
exports.trigger("currentFileChange",
newView && newView.getFile(),
newPane.id, oldView && oldView.getFile(),
newPane.id);
}
});
newPane.on("viewDestroy.mainView", function (e, view) {
_removeFileFromMRU(newPane.id, view.getFile());
});
}
return newPane;
} | [
"function",
"_createPaneIfNecessary",
"(",
"paneId",
")",
"{",
"var",
"newPane",
";",
"if",
"(",
"!",
"_panes",
".",
"hasOwnProperty",
"(",
"paneId",
")",
")",
"{",
"newPane",
"=",
"new",
"Pane",
"(",
"paneId",
",",
"_$el",
")",
";",
"_panes",
"[",
"pa... | Creates a pane for paneId if one doesn't already exist
@param {!string} paneId - id of the pane to create
@private
@return {?Pane} - the pane object of the new pane, or undefined if no pane created | [
"Creates",
"a",
"pane",
"for",
"paneId",
"if",
"one",
"doesn",
"t",
"already",
"exist"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1098-L1130 | train | Create a pane if it doesn t exist | [
30522,
30524,
10286,
2100,
1006,
6090,
7416,
2094,
1007,
1063,
13075,
2047,
9739,
2063,
1025,
2065,
1006,
999,
1035,
6090,
2229,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
6090,
7416,
2094,
1007,
1007,
1063,
2047,
9739,
2063,
1027,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/systems/material.js | function (src, data, cb) {
var hash;
var texture;
var textureCache = this.textureCache;
var videoEl;
var videoTextureResult;
function handleVideoTextureLoaded (result) {
result.texture.needsUpdate = true;
cb(result.texture, result.videoEl);
}
// Video element provided.
if (typeof src !== 'string') {
// Check cache before creating texture.
videoEl = src;
hash = this.hashVideo(data, videoEl);
if (textureCache[hash]) {
textureCache[hash].then(handleVideoTextureLoaded);
return;
}
// If not in cache, fix up the attributes then start to create the texture.
fixVideoAttributes(videoEl);
}
// Only URL provided. Use video element to create texture.
videoEl = videoEl || createVideoEl(src, data.width, data.height);
// Generated video element already cached. Use that.
hash = this.hashVideo(data, videoEl);
if (textureCache[hash]) {
textureCache[hash].then(handleVideoTextureLoaded);
return;
}
// Create new video texture.
texture = new THREE.VideoTexture(videoEl);
texture.minFilter = THREE.LinearFilter;
setTextureProperties(texture, data);
// If iOS and video is HLS, do some hacks.
if (this.sceneEl.isIOS &&
isHLS(videoEl.src || videoEl.getAttribute('src'),
videoEl.type || videoEl.getAttribute('type'))) {
// Actually BGRA. Tell shader to correct later.
texture.format = THREE.RGBAFormat;
texture.needsCorrectionBGRA = true;
// Apparently needed for HLS. Tell shader to correct later.
texture.flipY = false;
texture.needsCorrectionFlipY = true;
}
// Cache as promise to be consistent with image texture caching.
videoTextureResult = {texture: texture, videoEl: videoEl};
textureCache[hash] = Promise.resolve(videoTextureResult);
handleVideoTextureLoaded(videoTextureResult);
} | javascript | function (src, data, cb) {
var hash;
var texture;
var textureCache = this.textureCache;
var videoEl;
var videoTextureResult;
function handleVideoTextureLoaded (result) {
result.texture.needsUpdate = true;
cb(result.texture, result.videoEl);
}
// Video element provided.
if (typeof src !== 'string') {
// Check cache before creating texture.
videoEl = src;
hash = this.hashVideo(data, videoEl);
if (textureCache[hash]) {
textureCache[hash].then(handleVideoTextureLoaded);
return;
}
// If not in cache, fix up the attributes then start to create the texture.
fixVideoAttributes(videoEl);
}
// Only URL provided. Use video element to create texture.
videoEl = videoEl || createVideoEl(src, data.width, data.height);
// Generated video element already cached. Use that.
hash = this.hashVideo(data, videoEl);
if (textureCache[hash]) {
textureCache[hash].then(handleVideoTextureLoaded);
return;
}
// Create new video texture.
texture = new THREE.VideoTexture(videoEl);
texture.minFilter = THREE.LinearFilter;
setTextureProperties(texture, data);
// If iOS and video is HLS, do some hacks.
if (this.sceneEl.isIOS &&
isHLS(videoEl.src || videoEl.getAttribute('src'),
videoEl.type || videoEl.getAttribute('type'))) {
// Actually BGRA. Tell shader to correct later.
texture.format = THREE.RGBAFormat;
texture.needsCorrectionBGRA = true;
// Apparently needed for HLS. Tell shader to correct later.
texture.flipY = false;
texture.needsCorrectionFlipY = true;
}
// Cache as promise to be consistent with image texture caching.
videoTextureResult = {texture: texture, videoEl: videoEl};
textureCache[hash] = Promise.resolve(videoTextureResult);
handleVideoTextureLoaded(videoTextureResult);
} | [
"function",
"(",
"src",
",",
"data",
",",
"cb",
")",
"{",
"var",
"hash",
";",
"var",
"texture",
";",
"var",
"textureCache",
"=",
"this",
".",
"textureCache",
";",
"var",
"videoEl",
";",
"var",
"videoTextureResult",
";",
"function",
"handleVideoTextureLoaded"... | Load video texture (THREE.VideoTexture).
Which is just an image texture that RAFs + needsUpdate.
Note that creating a video texture is synchronous unlike loading an image texture.
Made asynchronous to be consistent with image textures.
@param {Element|string} src - Texture source.
@param {object} data - Texture data.
@param {function} cb - Callback to pass texture to. | [
"Load",
"video",
"texture",
"(",
"THREE",
".",
"VideoTexture",
")",
".",
"Which",
"is",
"just",
"an",
"image",
"texture",
"that",
"RAFs",
"+",
"needsUpdate",
".",
"Note",
"that",
"creating",
"a",
"video",
"texture",
"is",
"synchronous",
"unlike",
"loading",
... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L118-L174 | train | Create a texture for a video element. | [
30522,
3853,
1006,
5034,
2278,
1010,
2951,
1010,
17324,
1007,
1063,
30524,
3540,
5403,
1025,
13075,
2678,
2884,
1025,
13075,
2678,
18209,
27595,
2229,
11314,
1025,
3853,
5047,
17258,
8780,
18209,
5397,
17468,
1006,
2765,
1007,
1063,
2765,
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/extensions/default/AutoUpdate/main.js | receiveMessageFromNode | function receiveMessageFromNode(event, msgObj) {
if (functionMap[msgObj.fn]) {
if(domainID === msgObj.requester) {
functionMap[msgObj.fn].apply(null, msgObj.args);
}
}
} | javascript | function receiveMessageFromNode(event, msgObj) {
if (functionMap[msgObj.fn]) {
if(domainID === msgObj.requester) {
functionMap[msgObj.fn].apply(null, msgObj.args);
}
}
} | [
"function",
"receiveMessageFromNode",
"(",
"event",
",",
"msgObj",
")",
"{",
"if",
"(",
"functionMap",
"[",
"msgObj",
".",
"fn",
"]",
")",
"{",
"if",
"(",
"domainID",
"===",
"msgObj",
".",
"requester",
")",
"{",
"functionMap",
"[",
"msgObj",
".",
"fn",
... | Receives messages from node
@param {object} event - event received from node
@param {object} msgObj - json containing - {
fn - function to execute on Brackets side
args - arguments to the above function
requester - ID of the current requester domain | [
"Receives",
"messages",
"from",
"node"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L141-L147 | train | receiveMessageFromNode - receive a message from the node | [
30522,
3853,
4374,
7834,
3736,
3351,
19699,
5358,
3630,
3207,
1006,
2724,
1010,
5796,
3995,
2497,
3501,
1007,
1063,
2065,
1006,
3853,
2863,
2361,
1031,
5796,
3995,
2497,
3501,
1012,
1042,
2078,
1033,
1007,
1063,
2065,
1006,
5884,
3593,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | collapseAll | function collapseAll() {
var editor = EditorManager.getFocusedEditor();
if (editor) {
var cm = editor._codeMirror;
CodeMirror.commands.foldToLevel(cm);
}
} | javascript | function collapseAll() {
var editor = EditorManager.getFocusedEditor();
if (editor) {
var cm = editor._codeMirror;
CodeMirror.commands.foldToLevel(cm);
}
} | [
"function",
"collapseAll",
"(",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getFocusedEditor",
"(",
")",
";",
"if",
"(",
"editor",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
";",
"CodeMirror",
".",
"commands",
".",
"foldToLevel",
... | Collapses all foldable regions in the current document. Folding is done up to a level 'n'
which is defined in the `maxFoldLevel` preference. Levels refer to fold heirarchies e.g., for the following
code fragment, the function is level 1, the if statement is level 2 and the forEach is level 3
function sample() {
if (debug) {
logMessages.forEach(function (m) {
console.debug(m);
});
}
} | [
"Collapses",
"all",
"foldable",
"regions",
"in",
"the",
"current",
"document",
".",
"Folding",
"is",
"done",
"up",
"to",
"a",
"level",
"n",
"which",
"is",
"defined",
"in",
"the",
"maxFoldLevel",
"preference",
".",
"Levels",
"refer",
"to",
"fold",
"heirarchie... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L251-L257 | train | Collapse all code structures | [
30522,
3853,
7859,
8095,
1006,
1007,
1063,
13075,
3559,
1027,
3559,
24805,
4590,
1012,
2131,
14876,
7874,
19082,
15660,
1006,
1007,
1025,
2065,
1006,
3559,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
1035,
3642,
14503,
29165,
1025,
3642,
145... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-cli.js | loginToAws | function loginToAws(region, accountId, username, password) {
const commandLine = `docker login --username AWS --password ${password} https://${accountId}.dkr.ecr.${region}.amazonaws.com`;
return new Promise(
(resolve, reject) =>
command(commandLine, (err, stdout) => {
if (err) {
reject(err);
}
resolve(stdout);
}),
{ silent: true }
);
} | javascript | function loginToAws(region, accountId, username, password) {
const commandLine = `docker login --username AWS --password ${password} https://${accountId}.dkr.ecr.${region}.amazonaws.com`;
return new Promise(
(resolve, reject) =>
command(commandLine, (err, stdout) => {
if (err) {
reject(err);
}
resolve(stdout);
}),
{ silent: true }
);
} | [
"function",
"loginToAws",
"(",
"region",
",",
"accountId",
",",
"username",
",",
"password",
")",
"{",
"const",
"commandLine",
"=",
"`",
"${",
"password",
"}",
"${",
"accountId",
"}",
"${",
"region",
"}",
"`",
";",
"return",
"new",
"Promise",
"(",
"(",
... | Log docker to AWS.
@param region
@param accountId
@param username
@param password
@returns {Promise} | [
"Log",
"docker",
"to",
"AWS",
"."
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-cli.js#L119-L131 | train | Logs to AWS | [
30522,
3853,
8833,
18447,
10441,
9333,
1006,
2555,
1010,
4070,
3593,
1010,
5310,
18442,
1010,
20786,
1007,
1063,
9530,
3367,
3094,
4179,
1027,
1036,
8946,
2121,
8833,
2378,
1011,
1011,
5310,
18442,
22091,
2015,
1011,
1011,
20786,
1002,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/IssueManager.js | function(oRules) {
var index = 0,
innerIndex = 0,
treeTableModel = {},
rulesViewModel,
rule,
rules = [];
rulesViewModel = this.getRulesViewModel(oRules, [], []);
for (var libraryName in rulesViewModel) {
treeTableModel[index] = {
name: libraryName,
id: libraryName + " " + index,
selected: true,
type: "lib",
nodes: rules
};
for (var ruleName in rulesViewModel[libraryName]) {
rule = rulesViewModel[libraryName][ruleName];
rules.push({
name: rule.title,
description: rule.description,
id: rule.id,
audiences: rule.audiences.toString(),
categories: rule.categories.toString(),
minversion: rule.minversion,
resolution: rule.resolution,
title: rule.title,
libName: libraryName,
selected: true
});
innerIndex++;
}
rules = [];
index++;
}
return treeTableModel;
} | javascript | function(oRules) {
var index = 0,
innerIndex = 0,
treeTableModel = {},
rulesViewModel,
rule,
rules = [];
rulesViewModel = this.getRulesViewModel(oRules, [], []);
for (var libraryName in rulesViewModel) {
treeTableModel[index] = {
name: libraryName,
id: libraryName + " " + index,
selected: true,
type: "lib",
nodes: rules
};
for (var ruleName in rulesViewModel[libraryName]) {
rule = rulesViewModel[libraryName][ruleName];
rules.push({
name: rule.title,
description: rule.description,
id: rule.id,
audiences: rule.audiences.toString(),
categories: rule.categories.toString(),
minversion: rule.minversion,
resolution: rule.resolution,
title: rule.title,
libName: libraryName,
selected: true
});
innerIndex++;
}
rules = [];
index++;
}
return treeTableModel;
} | [
"function",
"(",
"oRules",
")",
"{",
"var",
"index",
"=",
"0",
",",
"innerIndex",
"=",
"0",
",",
"treeTableModel",
"=",
"{",
"}",
",",
"rulesViewModel",
",",
"rule",
",",
"rules",
"=",
"[",
"]",
";",
"rulesViewModel",
"=",
"this",
".",
"getRulesViewMod... | Gets rules and converts them into treeTable format.
@public
@method
@name sap.ui.support.IssueManager.getTreeTableViewModel
@param {object} oRules Deserialized rules found within the current state
@returns {object} TreeTableModel Rules in treeTable usable format
The rules are in a TreeTable format. | [
"Gets",
"rules",
"and",
"converts",
"them",
"into",
"treeTable",
"format",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/IssueManager.js#L206-L244 | train | Returns a tree table model for the given rules | [
30522,
3853,
1006,
2030,
16308,
1007,
1063,
13075,
5950,
1027,
1014,
1010,
5110,
22254,
10288,
1027,
1014,
1010,
3392,
10880,
5302,
9247,
1027,
1063,
1065,
1010,
3513,
8584,
5302,
9247,
1010,
3627,
1010,
3513,
1027,
1031,
1033,
1025,
3513,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/EventHandlerResolver.js | parse | function parse(sValue) {
sValue = sValue.trim();
var oTokenizer = new JSTokenizer();
var aResult = [];
var sBuffer = "";
var iParenthesesCounter = 0;
oTokenizer.init(sValue, 0);
for (;;) {
var sSymbol = oTokenizer.next();
if ( sSymbol === '"' || sSymbol === "'" ) {
var pos = oTokenizer.getIndex();
oTokenizer.string();
sBuffer += sValue.slice(pos, oTokenizer.getIndex());
sSymbol = oTokenizer.getCh();
}
if ( !sSymbol ) {
break;
}
switch (sSymbol) {
case "(":
iParenthesesCounter++;
break;
case ")":
iParenthesesCounter--;
break;
}
if (sSymbol === ";" && iParenthesesCounter === 0) {
aResult.push(sBuffer.trim());
sBuffer = "";
} else {
sBuffer += sSymbol;
}
}
if (sBuffer) {
aResult.push(sBuffer.trim());
}
return aResult;
} | javascript | function parse(sValue) {
sValue = sValue.trim();
var oTokenizer = new JSTokenizer();
var aResult = [];
var sBuffer = "";
var iParenthesesCounter = 0;
oTokenizer.init(sValue, 0);
for (;;) {
var sSymbol = oTokenizer.next();
if ( sSymbol === '"' || sSymbol === "'" ) {
var pos = oTokenizer.getIndex();
oTokenizer.string();
sBuffer += sValue.slice(pos, oTokenizer.getIndex());
sSymbol = oTokenizer.getCh();
}
if ( !sSymbol ) {
break;
}
switch (sSymbol) {
case "(":
iParenthesesCounter++;
break;
case ")":
iParenthesesCounter--;
break;
}
if (sSymbol === ";" && iParenthesesCounter === 0) {
aResult.push(sBuffer.trim());
sBuffer = "";
} else {
sBuffer += sSymbol;
}
}
if (sBuffer) {
aResult.push(sBuffer.trim());
}
return aResult;
} | [
"function",
"parse",
"(",
"sValue",
")",
"{",
"sValue",
"=",
"sValue",
".",
"trim",
"(",
")",
";",
"var",
"oTokenizer",
"=",
"new",
"JSTokenizer",
"(",
")",
";",
"var",
"aResult",
"=",
"[",
"]",
";",
"var",
"sBuffer",
"=",
"\"\"",
";",
"var",
"iPar... | Parses and splits the incoming string into meaningful event handler definitions
Examples:
parse(".fnControllerMethod")
=> [".fnControllerMethod"]
parse(".doSomething('Hello World'); .doSomething2('string'); globalFunction")
=> [".doSomething('Hello World')", ".doSomething2('string')", "globalFunction"]
parse(".fnControllerMethod; .fnControllerMethod(${ path:'/someModelProperty', formatter: '.myFormatter', type: 'sap.ui.model.type.String'} ); globalFunction")
=> [".fnControllerMethod", ".fnControllerMethod(${ path:'/someModelProperty', formatter: '.myFormatter', type: 'sap.ui.model.type.String'} )", "globalFunction"]
@param [string] sValue - Incoming string
@return {string[]} - Array of event handler definitions | [
"Parses",
"and",
"splits",
"the",
"incoming",
"string",
"into",
"meaningful",
"event",
"handler",
"definitions"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/EventHandlerResolver.js#L205-L246 | train | Parses the given value into an array of tokens | [
30522,
3853,
11968,
3366,
1006,
17917,
2389,
5657,
1007,
1063,
17917,
2389,
5657,
1027,
17917,
2389,
5657,
1012,
12241,
1006,
1007,
1025,
13075,
27178,
11045,
3490,
6290,
1027,
2047,
1046,
16033,
7520,
17629,
1006,
1007,
1025,
13075,
23631,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | write_XLUnicodeString | function write_XLUnicodeString(str, opts, o) {
if(!o) o = new_buf(3 + 2 * str.length);
o.write_shift(2, str.length);
o.write_shift(1, 1);
o.write_shift(31, str, 'utf16le');
return o;
} | javascript | function write_XLUnicodeString(str, opts, o) {
if(!o) o = new_buf(3 + 2 * str.length);
o.write_shift(2, str.length);
o.write_shift(1, 1);
o.write_shift(31, str, 'utf16le');
return o;
} | [
"function",
"write_XLUnicodeString",
"(",
"str",
",",
"opts",
",",
"o",
")",
"{",
"if",
"(",
"!",
"o",
")",
"o",
"=",
"new_buf",
"(",
"3",
"+",
"2",
"*",
"str",
".",
"length",
")",
";",
"o",
".",
"write_shift",
"(",
"2",
",",
"str",
".",
"lengt... | /* TODO: BIFF5 and lower, codepage awareness | [
"/",
"*",
"TODO",
":",
"BIFF5",
"and",
"lower",
"codepage",
"awareness"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5442-L5448 | train | write a Unicode string | [
30522,
3853,
4339,
1035,
28712,
19496,
23237,
18886,
3070,
1006,
2358,
2099,
1010,
23569,
2015,
1010,
1051,
1007,
1063,
2065,
1006,
999,
1051,
1007,
1051,
1027,
2047,
1035,
20934,
2546,
1006,
1017,
1009,
1016,
1008,
2358,
2099,
1012,
3091,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/path-utils.js | convertPathToPosix | function convertPathToPosix(filepath) {
const normalizedFilepath = path.normalize(filepath);
const posixFilepath = normalizedFilepath.replace(/\\/gu, "/");
return posixFilepath;
} | javascript | function convertPathToPosix(filepath) {
const normalizedFilepath = path.normalize(filepath);
const posixFilepath = normalizedFilepath.replace(/\\/gu, "/");
return posixFilepath;
} | [
"function",
"convertPathToPosix",
"(",
"filepath",
")",
"{",
"const",
"normalizedFilepath",
"=",
"path",
".",
"normalize",
"(",
"filepath",
")",
";",
"const",
"posixFilepath",
"=",
"normalizedFilepath",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"gu",
",",
"\"/\""... | ------------------------------------------------------------------------------ Private ------------------------------------------------------------------------------
Replace Windows with posix style paths
@param {string} filepath Path to convert
@returns {string} Converted filepath | [
"------------------------------------------------------------------------------",
"Private",
"------------------------------------------------------------------------------",
"Replace",
"Windows",
"with",
"posix",
"style",
"paths"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/path-utils.js#L23-L28 | train | Converts a filepath to a posix path | [
30522,
3853,
10463,
15069,
14399,
20049,
2595,
1006,
5371,
15069,
1007,
1063,
9530,
3367,
3671,
3550,
8873,
2571,
15069,
1027,
4130,
1012,
3671,
4697,
1006,
5371,
15069,
1007,
1025,
9530,
3367,
13433,
5332,
2595,
8873,
30524,
102,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebaseui-web | javascript/widgets/handler/common.js | function(providerId, opt_email) {
// If popup flow enabled, this will fail and fallback to redirect.
// TODO: Optimize to force redirect mode only.
// For non-Google providers (not supported yet). This may end up signing the
// user with a provider using different email. Even for Google, a user can
// override the login_hint, but that should be fine as it is the user's
// choice.
firebaseui.auth.widget.handler.common.federatedSignIn(
app, component, providerId, opt_email);
return goog.Promise.resolve(true);
} | javascript | function(providerId, opt_email) {
// If popup flow enabled, this will fail and fallback to redirect.
// TODO: Optimize to force redirect mode only.
// For non-Google providers (not supported yet). This may end up signing the
// user with a provider using different email. Even for Google, a user can
// override the login_hint, but that should be fine as it is the user's
// choice.
firebaseui.auth.widget.handler.common.federatedSignIn(
app, component, providerId, opt_email);
return goog.Promise.resolve(true);
} | [
"function",
"(",
"providerId",
",",
"opt_email",
")",
"{",
"// If popup flow enabled, this will fail and fallback to redirect.",
"// TODO: Optimize to force redirect mode only.",
"// For non-Google providers (not supported yet). This may end up signing the",
"// user with a provider using differ... | Sign in with a provider ID.
@param {string} providerId The Firebase Auth provider ID to sign-in with.
@param {?string=} opt_email The optional email to sign-in with.
@return {!goog.Promise<boolean>} | [
"Sign",
"in",
"with",
"a",
"provider",
"ID",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/javascript/widgets/handler/common.js#L1192-L1202 | train | Signs in the user with a provider. | [
30522,
3853,
1006,
10802,
3593,
1010,
23569,
1035,
10373,
1007,
1063,
1013,
1013,
2065,
3769,
6279,
4834,
9124,
1010,
2023,
2097,
8246,
1998,
2991,
5963,
2000,
2417,
7442,
6593,
1012,
1013,
1013,
28681,
2080,
1024,
23569,
27605,
4371,
2000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
facebook/relay | packages/babel-plugin-relay/compileRelayQLTag.js | compileRelayQLTag | function compileRelayQLTag(
t: $FlowFixMe,
path: Object,
schemaProvider: GraphQLSchemaProvider,
quasi: Object,
documentName: string,
propName: ?string,
tagName: string,
enableValidation: boolean,
state: BabelState,
): Object {
try {
const fileOpts = (state.file && state.file.opts) || {};
const transformer = getClassicTransformer(
schemaProvider,
state.opts || {},
fileOpts,
);
return transformer.transform(t, quasi, {
documentName,
propName,
tagName,
enableValidation,
});
} catch (error) {
throw path.buildCodeFrameError(createTransformError(error), Error);
}
} | javascript | function compileRelayQLTag(
t: $FlowFixMe,
path: Object,
schemaProvider: GraphQLSchemaProvider,
quasi: Object,
documentName: string,
propName: ?string,
tagName: string,
enableValidation: boolean,
state: BabelState,
): Object {
try {
const fileOpts = (state.file && state.file.opts) || {};
const transformer = getClassicTransformer(
schemaProvider,
state.opts || {},
fileOpts,
);
return transformer.transform(t, quasi, {
documentName,
propName,
tagName,
enableValidation,
});
} catch (error) {
throw path.buildCodeFrameError(createTransformError(error), Error);
}
} | [
"function",
"compileRelayQLTag",
"(",
"t",
":",
"$FlowFixMe",
",",
"path",
":",
"Object",
",",
"schemaProvider",
":",
"GraphQLSchemaProvider",
",",
"quasi",
":",
"Object",
",",
"documentName",
":",
"string",
",",
"propName",
":",
"?",
"string",
",",
"tagName",... | Given all the metadata about a found RelayQL tag, compile it and return
the resulting Babel AST. | [
"Given",
"all",
"the",
"metadata",
"about",
"a",
"found",
"RelayQL",
"tag",
"compile",
"it",
"and",
"return",
"the",
"resulting",
"Babel",
"AST",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/babel-plugin-relay/compileRelayQLTag.js#L23-L50 | train | Compile a relayQL tag | [
30522,
3853,
21624,
10581,
2100,
4160,
24458,
2290,
1006,
1056,
1024,
1002,
4834,
8873,
2595,
4168,
1010,
4130,
1024,
4874,
1010,
8040,
28433,
21572,
17258,
2121,
1024,
10629,
4160,
4877,
5403,
2863,
21572,
17258,
2121,
1010,
17982,
1024,
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... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | _getTempElement | function _getTempElement(context) {
var tempElement = context._wysihtml5_tempElement;
if (!tempElement) {
tempElement = context._wysihtml5_tempElement = context.createElement("div");
}
return tempElement;
} | javascript | function _getTempElement(context) {
var tempElement = context._wysihtml5_tempElement;
if (!tempElement) {
tempElement = context._wysihtml5_tempElement = context.createElement("div");
}
return tempElement;
} | [
"function",
"_getTempElement",
"(",
"context",
")",
"{",
"var",
"tempElement",
"=",
"context",
".",
"_wysihtml5_tempElement",
";",
"if",
"(",
"!",
"tempElement",
")",
"{",
"tempElement",
"=",
"context",
".",
"_wysihtml5_tempElement",
"=",
"context",
".",
"create... | Creates or (if already cached) returns a temp element
for the given document object | [
"Creates",
"or",
"(",
"if",
"already",
"cached",
")",
"returns",
"a",
"temp",
"element",
"for",
"the",
"given",
"document",
"object"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L4961-L4967 | train | Returns the temporary element | [
30522,
3853,
1035,
2131,
18532,
11880,
13665,
1006,
6123,
1007,
1063,
13075,
8915,
8737,
12260,
3672,
1027,
6123,
1012,
1035,
1059,
7274,
19190,
21246,
2140,
2629,
1035,
8915,
8737,
12260,
3672,
1025,
2065,
1006,
999,
8915,
8737,
12260,
367... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/hasher.js | function(path){
// ##### BEGIN: MODIFIED BY SAP
var dispatchFunction;
// ##### END: MODIFIED BY SAP
path = _makePath.apply(null, arguments);
if(path !== _hash){
// we should store raw value
// ##### BEGIN: MODIFIED BY SAP
dispatchFunction = _registerChange(path);
if (!hasher.raw) {
path = _encodePath(path);
}
window.location.hash = '#' + path;
dispatchFunction && dispatchFunction();
// ##### END: MODIFIED BY SAP
}
} | javascript | function(path){
// ##### BEGIN: MODIFIED BY SAP
var dispatchFunction;
// ##### END: MODIFIED BY SAP
path = _makePath.apply(null, arguments);
if(path !== _hash){
// we should store raw value
// ##### BEGIN: MODIFIED BY SAP
dispatchFunction = _registerChange(path);
if (!hasher.raw) {
path = _encodePath(path);
}
window.location.hash = '#' + path;
dispatchFunction && dispatchFunction();
// ##### END: MODIFIED BY SAP
}
} | [
"function",
"(",
"path",
")",
"{",
"// ##### BEGIN: MODIFIED BY SAP",
"var",
"dispatchFunction",
";",
"// ##### END: MODIFIED BY SAP",
"path",
"=",
"_makePath",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"if",
"(",
"path",
"!==",
"_hash",
")",
"{",
... | Set Hash value, generating a new history record.
@param {...string} path Hash value without '#'. Hasher will join
path segments using `hasher.separator` and prepend/append hash value
with `hasher.appendHash` and `hasher.prependHash`
@example hasher.setHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor' | [
"Set",
"Hash",
"value",
"generating",
"a",
"new",
"history",
"record",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/hasher.js#L361-L378 | train | This function is called by the hash handler when the hash is changed | [
30522,
3853,
1006,
4130,
1007,
1063,
1013,
1013,
1001,
1001,
1001,
1001,
1001,
4088,
1024,
6310,
2011,
20066,
13075,
18365,
11263,
27989,
1025,
1013,
1013,
1001,
1001,
1001,
1001,
1001,
2203,
1024,
6310,
2011,
20066,
4130,
1027,
1035,
2191,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/input/input.js | calculateInputValueLength | function calculateInputValueLength(value) {
value = ngTrim && !isPasswordInput && angular.isString(value) ? value.trim() : value;
if (value === undefined || value === null) {
value = '';
}
return String(value).length;
} | javascript | function calculateInputValueLength(value) {
value = ngTrim && !isPasswordInput && angular.isString(value) ? value.trim() : value;
if (value === undefined || value === null) {
value = '';
}
return String(value).length;
} | [
"function",
"calculateInputValueLength",
"(",
"value",
")",
"{",
"value",
"=",
"ngTrim",
"&&",
"!",
"isPasswordInput",
"&&",
"angular",
".",
"isString",
"(",
"value",
")",
"?",
"value",
".",
"trim",
"(",
")",
":",
"value",
";",
"if",
"(",
"value",
"===",... | Calculate the input value's length after coercing it to a string
and trimming it if appropriate.
@param value {*} the input's value
@returns {number} calculated length of the input's value | [
"Calculate",
"the",
"input",
"value",
"s",
"length",
"after",
"coercing",
"it",
"to",
"a",
"string",
"and",
"trimming",
"it",
"if",
"appropriate",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/input/input.js#L733-L739 | train | Calculates the length of the input value | [
30522,
3853,
18422,
2378,
18780,
10175,
16284,
13159,
2705,
1006,
3643,
1007,
1063,
3643,
1027,
12835,
18886,
2213,
1004,
1004,
999,
2003,
15194,
18351,
2378,
18780,
1004,
1004,
16108,
1012,
26354,
18886,
3070,
1006,
3643,
1007,
1029,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | services/pypi/pypi-helpers.js | sortDjangoVersions | function sortDjangoVersions(versions) {
return versions.sort((a, b) => {
if (
parseDjangoVersionString(a).major === parseDjangoVersionString(b).major
) {
return (
parseDjangoVersionString(a).minor - parseDjangoVersionString(b).minor
)
} else {
return (
parseDjangoVersionString(a).major - parseDjangoVersionString(b).major
)
}
})
} | javascript | function sortDjangoVersions(versions) {
return versions.sort((a, b) => {
if (
parseDjangoVersionString(a).major === parseDjangoVersionString(b).major
) {
return (
parseDjangoVersionString(a).minor - parseDjangoVersionString(b).minor
)
} else {
return (
parseDjangoVersionString(a).major - parseDjangoVersionString(b).major
)
}
})
} | [
"function",
"sortDjangoVersions",
"(",
"versions",
")",
"{",
"return",
"versions",
".",
"sort",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"{",
"if",
"(",
"parseDjangoVersionString",
"(",
"a",
")",
".",
"major",
"===",
"parseDjangoVersionString",
"(",
"b",
")",
... | Sort an array of django versions low to high. | [
"Sort",
"an",
"array",
"of",
"django",
"versions",
"low",
"to",
"high",
"."
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/pypi/pypi-helpers.js#L25-L39 | train | Sort the list of django versions | [
30522,
3853,
4066,
2094,
8405,
3995,
27774,
2015,
1006,
4617,
1007,
1063,
2709,
4617,
1012,
4066,
1006,
1006,
1037,
1010,
1038,
1007,
1027,
1028,
1063,
2065,
1006,
11968,
6924,
8405,
3995,
27774,
3367,
4892,
1006,
1037,
1007,
1012,
2350,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | addInfixOperator | function addInfixOperator(sId, iLbp) {
// Note: this function is executed at load time only!
mFilterParserSymbols[sId] = {
lbp : iLbp,
led : function (oToken, oLeft) {
oToken.type = "Edm.Boolean"; // Note: currently we only support logical operators
oToken.precedence = iLbp;
oToken.left = oLeft;
oToken.right = this.expression(iLbp);
return oToken;
}
};
} | javascript | function addInfixOperator(sId, iLbp) {
// Note: this function is executed at load time only!
mFilterParserSymbols[sId] = {
lbp : iLbp,
led : function (oToken, oLeft) {
oToken.type = "Edm.Boolean"; // Note: currently we only support logical operators
oToken.precedence = iLbp;
oToken.left = oLeft;
oToken.right = this.expression(iLbp);
return oToken;
}
};
} | [
"function",
"addInfixOperator",
"(",
"sId",
",",
"iLbp",
")",
"{",
"// Note: this function is executed at load time only!",
"mFilterParserSymbols",
"[",
"sId",
"]",
"=",
"{",
"lbp",
":",
"iLbp",
",",
"led",
":",
"function",
"(",
"oToken",
",",
"oLeft",
")",
"{",... | Adds an infix operator to mFilterParserSymbols.
@param {string} sId The token ID
@param {number} iLbp The "left binding power" | [
"Adds",
"an",
"infix",
"operator",
"to",
"mFilterParserSymbols",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Parser.js#L170-L182 | train | Adds an infix operator to the filter parser symbols. | [
30522,
3853,
5587,
2378,
8873,
2595,
25918,
8844,
1006,
15765,
1010,
6335,
2497,
2361,
1007,
1063,
1013,
1013,
3602,
1024,
2023,
3853,
2003,
6472,
2012,
7170,
2051,
2069,
999,
1049,
8873,
21928,
19362,
8043,
6508,
13344,
4877,
1031,
15765,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/node/selenium-webdriver/lib/error.js | checkLegacyResponse | function checkLegacyResponse(responseObj) {
// Handle the legacy Selenium error response format.
if (responseObj
&& typeof responseObj === 'object'
&& typeof responseObj['status'] === 'number'
&& responseObj['status'] !== 0) {
let status = responseObj['status'];
let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError;
let value = responseObj['value'];
if (!value || typeof value !== 'object') {
throw new ctor(value + '');
} else {
let message = value['message'] + '';
if (ctor !== UnexpectedAlertOpenError) {
throw new ctor(message);
}
let text = '';
if (value['alert'] && typeof value['alert']['text'] === 'string') {
text = value['alert']['text'];
}
throw new UnexpectedAlertOpenError(message, text);
}
}
return responseObj;
} | javascript | function checkLegacyResponse(responseObj) {
// Handle the legacy Selenium error response format.
if (responseObj
&& typeof responseObj === 'object'
&& typeof responseObj['status'] === 'number'
&& responseObj['status'] !== 0) {
let status = responseObj['status'];
let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError;
let value = responseObj['value'];
if (!value || typeof value !== 'object') {
throw new ctor(value + '');
} else {
let message = value['message'] + '';
if (ctor !== UnexpectedAlertOpenError) {
throw new ctor(message);
}
let text = '';
if (value['alert'] && typeof value['alert']['text'] === 'string') {
text = value['alert']['text'];
}
throw new UnexpectedAlertOpenError(message, text);
}
}
return responseObj;
} | [
"function",
"checkLegacyResponse",
"(",
"responseObj",
")",
"{",
"// Handle the legacy Selenium error response format.",
"if",
"(",
"responseObj",
"&&",
"typeof",
"responseObj",
"===",
"'object'",
"&&",
"typeof",
"responseObj",
"[",
"'status'",
"]",
"===",
"'number'",
"... | Checks a legacy response from the Selenium 2.0 wire protocol for an error.
@param {*} responseObj the response object to check.
@return {*} responseObj the original response if it does not define an error.
@throws {WebDriverError} if the response object defines an error. | [
"Checks",
"a",
"legacy",
"response",
"from",
"the",
"Selenium",
"2",
".",
"0",
"wire",
"protocol",
"for",
"an",
"error",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/lib/error.js#L569-L596 | train | Check the legacy Selenium error response format. | [
30522,
3853,
4638,
23115,
15719,
6072,
26029,
3366,
1006,
3433,
16429,
3501,
1007,
1063,
1013,
1013,
5047,
1996,
8027,
7367,
7770,
5007,
7561,
3433,
4289,
1012,
2065,
1006,
3433,
16429,
3501,
1004,
1004,
2828,
11253,
3433,
16429,
3501,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js | function () {
var rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
if (!rawLSData) {
return null;
}
return JSON.parse(rawLSData);
} | javascript | function () {
var rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
if (!rawLSData) {
return null;
}
return JSON.parse(rawLSData);
} | [
"function",
"(",
")",
"{",
"var",
"rawLSData",
"=",
"localStorage",
".",
"getItem",
"(",
"constants",
".",
"LOCAL_STORAGE_SELECTED_RULES_KEY",
")",
";",
"if",
"(",
"!",
"rawLSData",
")",
"{",
"return",
"null",
";",
"}",
"return",
"JSON",
".",
"parse",
"(",... | Retrieves the selected rules which are stored in the LocalStorage persistence layer.
@private
@method
@name sap.ui.support.Storage.getSelectedRules
@returns {object[]} All selected rules that are stored in the LocalStorage persistence layer. | [
"Retrieves",
"the",
"selected",
"rules",
"which",
"are",
"stored",
"in",
"the",
"LocalStorage",
"persistence",
"layer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js#L111-L119 | train | Get the selected rules from the local storage | [
30522,
3853,
1006,
1007,
1063,
13075,
6315,
4877,
2850,
2696,
1027,
10575,
4263,
4270,
1012,
2131,
4221,
2213,
1006,
5377,
2015,
1012,
2334,
1035,
5527,
1035,
3479,
1035,
3513,
1035,
3145,
1007,
1025,
2065,
1006,
999,
6315,
4877,
2850,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/languageTools/LanguageClientWrapper.js | validateNotificationParams | function validateNotificationParams(type, params) {
var validatedParams = null;
params = params || {};
//Don't validate if the formatting is done by the caller
if (params.format === MESSAGE_FORMAT.LSP) {
return params;
}
switch (type) {
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_OPENED:
{
if (hasValidProps(params, ["filePath", "fileContent", "languageId"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_CHANGED:
{
if (hasValidProps(params, ["filePath", "fileContent"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_SAVED:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_CLOSED:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.PROJECT_FOLDERS_CHANGED:
{
if (hasValidProps(params, ["foldersAdded", "foldersRemoved"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.LANGUAGE_SERVICE.CUSTOM_NOTIFICATION:
{
validatedParams = params;
}
}
return validatedParams;
} | javascript | function validateNotificationParams(type, params) {
var validatedParams = null;
params = params || {};
//Don't validate if the formatting is done by the caller
if (params.format === MESSAGE_FORMAT.LSP) {
return params;
}
switch (type) {
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_OPENED:
{
if (hasValidProps(params, ["filePath", "fileContent", "languageId"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_CHANGED:
{
if (hasValidProps(params, ["filePath", "fileContent"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_SAVED:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.DOCUMENT_CLOSED:
{
if (hasValidProp(params, "filePath")) {
validatedParams = params;
}
break;
}
case ToolingInfo.SYNCHRONIZE_EVENTS.PROJECT_FOLDERS_CHANGED:
{
if (hasValidProps(params, ["foldersAdded", "foldersRemoved"])) {
validatedParams = params;
}
break;
}
case ToolingInfo.LANGUAGE_SERVICE.CUSTOM_NOTIFICATION:
{
validatedParams = params;
}
}
return validatedParams;
} | [
"function",
"validateNotificationParams",
"(",
"type",
",",
"params",
")",
"{",
"var",
"validatedParams",
"=",
"null",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"//Don't validate if the formatting is done by the caller",
"if",
"(",
"params",
".",
"format",
... | /*
ReponseParams transformer - used by OnNotifications | [
"/",
"*",
"ReponseParams",
"transformer",
"-",
"used",
"by",
"OnNotifications"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/languageTools/LanguageClientWrapper.js#L130-L183 | train | Validates the parameters for a notification | [
30522,
3853,
9398,
3686,
17048,
9031,
28689,
5244,
1006,
2828,
1010,
11498,
5244,
1007,
1063,
13075,
9398,
4383,
28689,
5244,
1027,
19701,
1025,
11498,
5244,
1027,
11498,
5244,
1064,
1064,
1063,
1065,
1025,
1013,
1013,
2123,
1005,
1056,
939... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-runtime/store/RelayModernOperationDescriptor.js | createOperationDescriptor | function createOperationDescriptor(
request: ConcreteRequest,
variables: Variables,
): OperationDescriptor {
const operation = request.operation;
const operationVariables = getOperationVariables(operation, variables);
const dataID = ROOT_ID;
return {
fragment: {
dataID,
node: request.fragment,
variables: operationVariables,
},
node: request,
root: {
dataID,
node: operation,
variables: operationVariables,
},
variables: operationVariables,
};
} | javascript | function createOperationDescriptor(
request: ConcreteRequest,
variables: Variables,
): OperationDescriptor {
const operation = request.operation;
const operationVariables = getOperationVariables(operation, variables);
const dataID = ROOT_ID;
return {
fragment: {
dataID,
node: request.fragment,
variables: operationVariables,
},
node: request,
root: {
dataID,
node: operation,
variables: operationVariables,
},
variables: operationVariables,
};
} | [
"function",
"createOperationDescriptor",
"(",
"request",
":",
"ConcreteRequest",
",",
"variables",
":",
"Variables",
",",
")",
":",
"OperationDescriptor",
"{",
"const",
"operation",
"=",
"request",
".",
"operation",
";",
"const",
"operationVariables",
"=",
"getOpera... | Creates an instance of the `OperationDescriptor` type defined in
`RelayStoreTypes` given an operation and some variables. The input variables
are filtered to exclude variables that do not match defined arguments on the
operation, and default values are populated for null values. | [
"Creates",
"an",
"instance",
"of",
"the",
"OperationDescriptor",
"type",
"defined",
"in",
"RelayStoreTypes",
"given",
"an",
"operation",
"and",
"some",
"variables",
".",
"The",
"input",
"variables",
"are",
"filtered",
"to",
"exclude",
"variables",
"that",
"do",
... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/store/RelayModernOperationDescriptor.js#L26-L47 | train | Creates an OperationDescriptor from a ConcreteRequest and a Cluster | [
30522,
3853,
3443,
25918,
3370,
6155,
23235,
2953,
1006,
5227,
1024,
5509,
2890,
15500,
1010,
10857,
1024,
10857,
1010,
1007,
1024,
3169,
6155,
23235,
2953,
1063,
9530,
3367,
3169,
1027,
5227,
1012,
3169,
1025,
9530,
3367,
3169,
10755,
1921... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | getAllOpenFiles | function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
} | javascript | function getAllOpenFiles() {
var result = getWorkingSet(ALL_PANES);
_.forEach(_panes, function (pane) {
var file = pane.getCurrentlyViewedFile();
if (file) {
result = _.union(result, [file]);
}
});
return result;
} | [
"function",
"getAllOpenFiles",
"(",
")",
"{",
"var",
"result",
"=",
"getWorkingSet",
"(",
"ALL_PANES",
")",
";",
"_",
".",
"forEach",
"(",
"_panes",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"file",
"=",
"pane",
".",
"getCurrentlyViewedFile",
"(",
"... | Retrieves the list of all open files including temporary views
@return {array.<File>} the list of all open files in all open panes | [
"Retrieves",
"the",
"list",
"of",
"all",
"open",
"files",
"including",
"temporary",
"views"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L546-L555 | train | Get all open files | [
30522,
3853,
2131,
8095,
26915,
8873,
4244,
1006,
1007,
1063,
13075,
2765,
1027,
2131,
21398,
13462,
1006,
2035,
1035,
6090,
2229,
1007,
1025,
1035,
1012,
18921,
6776,
1006,
1035,
6090,
2229,
1010,
3853,
1006,
6090,
2063,
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/core/util/util.js | function (scope, key, getter) {
var value = null, args = Array.prototype.slice.call(arguments);
var params = (args.length > 3) ? args.slice(3) : [];
Object.defineProperty(scope, key, {
get: function () {
if (value === null) value = getter.apply(scope, params);
return value;
}
});
} | javascript | function (scope, key, getter) {
var value = null, args = Array.prototype.slice.call(arguments);
var params = (args.length > 3) ? args.slice(3) : [];
Object.defineProperty(scope, key, {
get: function () {
if (value === null) value = getter.apply(scope, params);
return value;
}
});
} | [
"function",
"(",
"scope",
",",
"key",
",",
"getter",
")",
"{",
"var",
"value",
"=",
"null",
",",
"args",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"params",
"=",
"(",
"args",
".",
"length",
">",
... | Create an implicit getter that caches its `getter()`
lookup value | [
"Create",
"an",
"implicit",
"getter",
"that",
"caches",
"its",
"getter",
"()",
"lookup",
"value"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L475-L485 | train | This is a private method that is used to define a property on a scope. | [
30522,
3853,
1006,
9531,
1010,
3145,
1010,
2131,
3334,
1007,
1063,
13075,
3643,
1027,
19701,
1010,
12098,
5620,
1027,
9140,
1012,
8773,
1012,
14704,
1012,
2655,
1006,
9918,
1007,
1025,
13075,
11498,
5244,
1027,
1006,
12098,
5620,
1012,
3091... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/services/layout/layout.js | buildCloakInterceptor | function buildCloakInterceptor(className) {
return ['$timeout', function($timeout){
return {
restrict : 'A',
priority : -10, // run after normal ng-cloak
compile : function(element) {
if (!config.enabled) return angular.noop;
// Re-add the cloak
element.addClass(className);
return function(scope, element) {
// Wait while layout injectors configure, then uncloak
// NOTE: $rAF does not delay enough... and this is a 1x-only event,
// $timeout is acceptable.
$timeout(function(){
element.removeClass(className);
}, 10, false);
};
}
};
}];
} | javascript | function buildCloakInterceptor(className) {
return ['$timeout', function($timeout){
return {
restrict : 'A',
priority : -10, // run after normal ng-cloak
compile : function(element) {
if (!config.enabled) return angular.noop;
// Re-add the cloak
element.addClass(className);
return function(scope, element) {
// Wait while layout injectors configure, then uncloak
// NOTE: $rAF does not delay enough... and this is a 1x-only event,
// $timeout is acceptable.
$timeout(function(){
element.removeClass(className);
}, 10, false);
};
}
};
}];
} | [
"function",
"buildCloakInterceptor",
"(",
"className",
")",
"{",
"return",
"[",
"'$timeout'",
",",
"function",
"(",
"$timeout",
")",
"{",
"return",
"{",
"restrict",
":",
"'A'",
",",
"priority",
":",
"-",
"10",
",",
"// run after normal ng-cloak",
"compile",
":... | Tail-hook ngCloak to delay the uncloaking while Layout transformers
finish processing. Eliminates flicker with Material.Layouts | [
"Tail",
"-",
"hook",
"ngCloak",
"to",
"delay",
"the",
"uncloaking",
"while",
"Layout",
"transformers",
"finish",
"processing",
".",
"Eliminates",
"flicker",
"with",
"Material",
".",
"Layouts"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/layout/layout.js#L215-L237 | train | Build an interceptor to add a cloak class | [
30522,
3853,
3857,
20464,
10441,
4939,
3334,
3401,
13876,
2953,
1006,
2465,
18442,
1007,
1063,
2709,
1031,
1005,
1002,
2051,
5833,
1005,
1010,
3853,
1006,
1002,
2051,
5833,
1007,
1063,
2709,
1063,
21573,
1024,
1005,
1037,
1005,
1010,
9470,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/reporters/progress.js | Progress | function Progress(runner, options) {
Base.call(this, runner, options);
var self = this;
var width = (Base.window.width * 0.5) | 0;
var total = runner.total;
var complete = 0;
var lastN = -1;
// default chars
options = options || {};
var reporterOptions = options.reporterOptions || {};
options.open = reporterOptions.open || '[';
options.complete = reporterOptions.complete || '▬';
options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
options.close = reporterOptions.close || ']';
options.verbose = reporterOptions.verbose || false;
// tests started
runner.on(EVENT_RUN_BEGIN, function() {
console.log();
cursor.hide();
});
// tests complete
runner.on(EVENT_TEST_END, function() {
complete++;
var percent = complete / total;
var n = (width * percent) | 0;
var i = width - n;
if (n === lastN && !options.verbose) {
// Don't re-render the line if it hasn't changed
return;
}
lastN = n;
cursor.CR();
process.stdout.write('\u001b[J');
process.stdout.write(color('progress', ' ' + options.open));
process.stdout.write(Array(n).join(options.complete));
process.stdout.write(Array(i).join(options.incomplete));
process.stdout.write(color('progress', options.close));
if (options.verbose) {
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
}
});
// tests are complete, output some stats
// and the failures if any
runner.once(EVENT_RUN_END, function() {
cursor.show();
console.log();
self.epilogue();
});
} | javascript | function Progress(runner, options) {
Base.call(this, runner, options);
var self = this;
var width = (Base.window.width * 0.5) | 0;
var total = runner.total;
var complete = 0;
var lastN = -1;
// default chars
options = options || {};
var reporterOptions = options.reporterOptions || {};
options.open = reporterOptions.open || '[';
options.complete = reporterOptions.complete || '▬';
options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
options.close = reporterOptions.close || ']';
options.verbose = reporterOptions.verbose || false;
// tests started
runner.on(EVENT_RUN_BEGIN, function() {
console.log();
cursor.hide();
});
// tests complete
runner.on(EVENT_TEST_END, function() {
complete++;
var percent = complete / total;
var n = (width * percent) | 0;
var i = width - n;
if (n === lastN && !options.verbose) {
// Don't re-render the line if it hasn't changed
return;
}
lastN = n;
cursor.CR();
process.stdout.write('\u001b[J');
process.stdout.write(color('progress', ' ' + options.open));
process.stdout.write(Array(n).join(options.complete));
process.stdout.write(Array(i).join(options.incomplete));
process.stdout.write(color('progress', options.close));
if (options.verbose) {
process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
}
});
// tests are complete, output some stats
// and the failures if any
runner.once(EVENT_RUN_END, function() {
cursor.show();
console.log();
self.epilogue();
});
} | [
"function",
"Progress",
"(",
"runner",
",",
"options",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
",",
"options",
")",
";",
"var",
"self",
"=",
"this",
";",
"var",
"width",
"=",
"(",
"Base",
".",
"window",
".",
"width",
"*",
"0.5",
... | Constructs a new `Progress` reporter instance.
@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options | [
"Constructs",
"a",
"new",
"Progress",
"reporter",
"instance",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/progress.js#L40-L97 | train | A progress reporter that displays the progress of the test suite. | [
30522,
3853,
5082,
1006,
5479,
1010,
7047,
1007,
1063,
2918,
1012,
2655,
1006,
2023,
1010,
5479,
1010,
7047,
1007,
1025,
13075,
2969,
1027,
2023,
1025,
13075,
9381,
1027,
1006,
2918,
1012,
3332,
1012,
9381,
1008,
1014,
1012,
1019,
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... |
aws/aws-sdk-js | lib/discover_endpoint.js | marshallCustomIdentifiersHelper | function marshallCustomIdentifiersHelper(result, params, shape) {
if (!shape || params === undefined || params === null) return;
if (shape.type === 'structure' && shape.required && shape.required.length > 0) {
util.arrayEach(shape.required, function(name) {
var memberShape = shape.members[name];
if (memberShape.endpointDiscoveryId === true) {
var locationName = memberShape.isLocationName ? memberShape.name : name;
result[locationName] = String(params[name]);
} else {
marshallCustomIdentifiersHelper(result, params[name], memberShape);
}
});
}
} | javascript | function marshallCustomIdentifiersHelper(result, params, shape) {
if (!shape || params === undefined || params === null) return;
if (shape.type === 'structure' && shape.required && shape.required.length > 0) {
util.arrayEach(shape.required, function(name) {
var memberShape = shape.members[name];
if (memberShape.endpointDiscoveryId === true) {
var locationName = memberShape.isLocationName ? memberShape.name : name;
result[locationName] = String(params[name]);
} else {
marshallCustomIdentifiersHelper(result, params[name], memberShape);
}
});
}
} | [
"function",
"marshallCustomIdentifiersHelper",
"(",
"result",
",",
"params",
",",
"shape",
")",
"{",
"if",
"(",
"!",
"shape",
"||",
"params",
"===",
"undefined",
"||",
"params",
"===",
"null",
")",
"return",
";",
"if",
"(",
"shape",
".",
"type",
"===",
"... | Recursive helper for marshallCustomIdentifiers().
Looks for required string input members that have 'endpointdiscoveryid' trait.
@api private | [
"Recursive",
"helper",
"for",
"marshallCustomIdentifiers",
"()",
".",
"Looks",
"for",
"required",
"string",
"input",
"members",
"that",
"have",
"endpointdiscoveryid",
"trait",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/discover_endpoint.js#L36-L49 | train | Marshalls the custom identifiers for the given shape | [
30522,
3853,
5832,
7874,
20389,
5178,
16778,
8873,
2545,
16001,
4842,
1006,
2765,
1010,
11498,
5244,
1010,
4338,
1007,
1063,
2065,
1006,
999,
4338,
1064,
1064,
11498,
5244,
1027,
1027,
1027,
6151,
28344,
1064,
1064,
11498,
5244,
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... |
angular/material | src/components/autocomplete/js/autocompleteController.js | handleHiddenChange | function handleHiddenChange (hidden, oldHidden) {
if (!hidden && oldHidden) {
positionDropdown();
// Report in polite mode, because the screen reader should finish the default description of
// the input element.
reportMessages(true, ReportType.Count | ReportType.Selected);
if (elements) {
$mdUtil.disableScrollAround(elements.ul);
enableWrapScroll = disableElementScrollEvents(angular.element(elements.wrap));
}
} else if (hidden && !oldHidden) {
$mdUtil.enableScrolling();
if (enableWrapScroll) {
enableWrapScroll();
enableWrapScroll = null;
}
}
} | javascript | function handleHiddenChange (hidden, oldHidden) {
if (!hidden && oldHidden) {
positionDropdown();
// Report in polite mode, because the screen reader should finish the default description of
// the input element.
reportMessages(true, ReportType.Count | ReportType.Selected);
if (elements) {
$mdUtil.disableScrollAround(elements.ul);
enableWrapScroll = disableElementScrollEvents(angular.element(elements.wrap));
}
} else if (hidden && !oldHidden) {
$mdUtil.enableScrolling();
if (enableWrapScroll) {
enableWrapScroll();
enableWrapScroll = null;
}
}
} | [
"function",
"handleHiddenChange",
"(",
"hidden",
",",
"oldHidden",
")",
"{",
"if",
"(",
"!",
"hidden",
"&&",
"oldHidden",
")",
"{",
"positionDropdown",
"(",
")",
";",
"// Report in polite mode, because the screen reader should finish the default description of",
"// the inp... | event/change handlers
Handles changes to the `hidden` property.
@param hidden
@param oldHidden | [
"event",
"/",
"change",
"handlers",
"Handles",
"changes",
"to",
"the",
"hidden",
"property",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L348-L368 | train | Handle hidden change | [
30522,
3853,
5047,
27511,
4181,
22305,
2063,
1006,
5023,
1010,
2214,
27511,
4181,
1007,
1063,
2065,
1006,
999,
5023,
1004,
1004,
2214,
27511,
4181,
1007,
1063,
2597,
25711,
7698,
1006,
1007,
1025,
1013,
1013,
3189,
1999,
13205,
5549,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2Requestor.js | parseAndCheck | function parseAndCheck(oDateFormat, sValue) {
var oDate = oDateFormat.parse(sValue);
if (!oDate) {
throw new Error("Not a valid " + oPropertyMetadata.$Type + " value: " + sValue);
}
return oDate;
} | javascript | function parseAndCheck(oDateFormat, sValue) {
var oDate = oDateFormat.parse(sValue);
if (!oDate) {
throw new Error("Not a valid " + oPropertyMetadata.$Type + " value: " + sValue);
}
return oDate;
} | [
"function",
"parseAndCheck",
"(",
"oDateFormat",
",",
"sValue",
")",
"{",
"var",
"oDate",
"=",
"oDateFormat",
".",
"parse",
"(",
"sValue",
")",
";",
"if",
"(",
"!",
"oDate",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Not a valid \"",
"+",
"oPropertyMetadat... | Parse using the given formatter and check that the result is valid | [
"Parse",
"using",
"the",
"given",
"formatter",
"and",
"check",
"that",
"the",
"result",
"is",
"valid"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_V2Requestor.js#L769-L775 | train | Parses the given value and throws an error if the date is not a valid date | [
30522,
3853,
11968,
17310,
4859,
5403,
3600,
1006,
1051,
13701,
14192,
4017,
1010,
17917,
2389,
5657,
1007,
1063,
13075,
1051,
13701,
1027,
1051,
13701,
14192,
4017,
1012,
11968,
3366,
1006,
17917,
2389,
5657,
1007,
1025,
2065,
1006,
999,
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/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | checkStatement | function checkStatement(ast, start, end, fileText) {
// Do not allow function or class nodes
var notStatement = false;
ASTWalker.simple(getAST(fileText.substr(start, end - start)), {
FunctionDeclaration: function (node) {
notStatement = true;
},
ClassDeclaration: function (node) {
notStatement = true;
}
});
if (notStatement) {
return false;
}
var startStatement = findSurroundASTNode(ast, {start: start}, ["Statement"]);
var endStatement = findSurroundASTNode(ast, {start: end}, ["Statement"]);
return startStatement && endStatement && startStatement.start === start &&
startStatement.end <= end && endStatement.start >= start &&
endStatement.end === end;
} | javascript | function checkStatement(ast, start, end, fileText) {
// Do not allow function or class nodes
var notStatement = false;
ASTWalker.simple(getAST(fileText.substr(start, end - start)), {
FunctionDeclaration: function (node) {
notStatement = true;
},
ClassDeclaration: function (node) {
notStatement = true;
}
});
if (notStatement) {
return false;
}
var startStatement = findSurroundASTNode(ast, {start: start}, ["Statement"]);
var endStatement = findSurroundASTNode(ast, {start: end}, ["Statement"]);
return startStatement && endStatement && startStatement.start === start &&
startStatement.end <= end && endStatement.start >= start &&
endStatement.end === end;
} | [
"function",
"checkStatement",
"(",
"ast",
",",
"start",
",",
"end",
",",
"fileText",
")",
"{",
"// Do not allow function or class nodes",
"var",
"notStatement",
"=",
"false",
";",
"ASTWalker",
".",
"simple",
"(",
"getAST",
"(",
"fileText",
".",
"substr",
"(",
... | /*
Checks whether the text between start and end offsets form a valid set of statements
@param {!ASTNode} ast - the ast of the complete file
@param {!number} start - the start offset
@param {!number} end - the end offset
@param {!string} fileText - the entire file text
@return {boolean} | [
"/",
"*",
"Checks",
"whether",
"the",
"text",
"between",
"start",
"and",
"end",
"offsets",
"form",
"a",
"valid",
"set",
"of",
"statements"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L116-L138 | train | Check if statement is valid | [
30522,
3853,
14148,
12259,
3672,
1006,
2004,
2102,
1010,
2707,
1010,
2203,
1010,
5371,
18209,
1007,
1063,
1013,
1013,
2079,
2025,
3499,
3853,
2030,
2465,
14164,
13075,
2025,
9153,
18532,
4765,
1027,
6270,
1025,
2004,
2102,
26965,
1012,
3722... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/assets/SASSAsset.js | normalizeError | function normalizeError(err) {
let message = 'Unknown error';
if (err) {
if (err instanceof Error) {
return err;
}
message = err.stack || err.message || err;
}
return new Error(message);
} | javascript | function normalizeError(err) {
let message = 'Unknown error';
if (err) {
if (err instanceof Error) {
return err;
}
message = err.stack || err.message || err;
}
return new Error(message);
} | [
"function",
"normalizeError",
"(",
"err",
")",
"{",
"let",
"message",
"=",
"'Unknown error'",
";",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"return",
"err",
";",
"}",
"message",
"=",
"err",
".",
"stack",
"||",
"e... | Ensures an error inherits from Error | [
"Ensures",
"an",
"error",
"inherits",
"from",
"Error"
] | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/assets/SASSAsset.js#L122-L134 | train | Normalize an error to be a problem | [
30522,
3853,
3671,
4697,
2121,
29165,
1006,
9413,
2099,
1007,
1063,
2292,
4471,
1027,
1005,
4242,
7561,
1005,
1025,
2065,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
6013,
11253,
7561,
1007,
1063,
2709,
9413,
2099,
1025,
1065,
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... |
mui-org/material-ui | packages/material-ui/src/utils/focusVisible.js | focusTriggersKeyboardModality | function focusTriggersKeyboardModality(node) {
const { type, tagName } = node;
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) {
return true;
}
if (tagName === 'TEXTAREA' && !node.readOnly) {
return true;
}
if (node.isContentEditable) {
return true;
}
return false;
} | javascript | function focusTriggersKeyboardModality(node) {
const { type, tagName } = node;
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) {
return true;
}
if (tagName === 'TEXTAREA' && !node.readOnly) {
return true;
}
if (node.isContentEditable) {
return true;
}
return false;
} | [
"function",
"focusTriggersKeyboardModality",
"(",
"node",
")",
"{",
"const",
"{",
"type",
",",
"tagName",
"}",
"=",
"node",
";",
"if",
"(",
"tagName",
"===",
"'INPUT'",
"&&",
"inputTypesWhitelist",
"[",
"type",
"]",
"&&",
"!",
"node",
".",
"readOnly",
")",... | Computes whether the given element should automatically trigger the
`focus-visible` class being added, i.e. whether it should always match
`:focus-visible` when focused.
@param {Element} node
@return {boolean} | [
"Computes",
"whether",
"the",
"given",
"element",
"should",
"automatically",
"trigger",
"the",
"focus",
"-",
"visible",
"class",
"being",
"added",
"i",
".",
"e",
".",
"whether",
"it",
"should",
"always",
"match",
":",
"focus",
"-",
"visible",
"when",
"focuse... | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/utils/focusVisible.js#L31-L47 | train | Determines whether the node has focus triggers keyboard modality. | [
30522,
3853,
3579,
18886,
13327,
17140,
2100,
6277,
5302,
9305,
3012,
1006,
13045,
1007,
1063,
9530,
3367,
1063,
2828,
1010,
6415,
18442,
1065,
1027,
13045,
1025,
2065,
1006,
6415,
18442,
1027,
1027,
1027,
1005,
7953,
1005,
1004,
1004,
7953... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-use-before-define.js | isOuterVariable | function isOuterVariable(variable, reference) {
return (
variable.defs[0].type === "Variable" &&
variable.scope.variableScope !== reference.from.variableScope
);
} | javascript | function isOuterVariable(variable, reference) {
return (
variable.defs[0].type === "Variable" &&
variable.scope.variableScope !== reference.from.variableScope
);
} | [
"function",
"isOuterVariable",
"(",
"variable",
",",
"reference",
")",
"{",
"return",
"(",
"variable",
".",
"defs",
"[",
"0",
"]",
".",
"type",
"===",
"\"Variable\"",
"&&",
"variable",
".",
"scope",
".",
"variableScope",
"!==",
"reference",
".",
"from",
".... | Checks whether or not a given variable is a variable declaration in an upper function scope.
@param {eslint-scope.Variable} variable - A variable to check.
@param {eslint-scope.Reference} reference - A reference to check.
@returns {boolean} `true` if the variable is a variable declaration. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"variable",
"is",
"a",
"variable",
"declaration",
"in",
"an",
"upper",
"function",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L67-L72 | train | Returns true if the variable is an outer variable of the given reference | [
30522,
3853,
11163,
19901,
10755,
19210,
1006,
8023,
1010,
4431,
1007,
1063,
2709,
1006,
8023,
1012,
13366,
2015,
1031,
1014,
1033,
1012,
2828,
1027,
1027,
1027,
1000,
8023,
1000,
1004,
1004,
8023,
1012,
9531,
1012,
10857,
16186,
999,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/main.js | attemptToDownload | function attemptToDownload() {
if (checkIfOnline()) {
postMessageToNode(MessageIds.PERFORM_CLEANUP, ['.json'], true);
} else {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
"No Internet connection available."
);
UpdateInfoBar.showUpdateBar({
type: "warning",
title: Strings.DOWNLOAD_FAILED,
description: Strings.INTERNET_UNAVAILABLE
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | javascript | function attemptToDownload() {
if (checkIfOnline()) {
postMessageToNode(MessageIds.PERFORM_CLEANUP, ['.json'], true);
} else {
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
"No Internet connection available."
);
UpdateInfoBar.showUpdateBar({
type: "warning",
title: Strings.DOWNLOAD_FAILED,
description: Strings.INTERNET_UNAVAILABLE
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | [
"function",
"attemptToDownload",
"(",
")",
"{",
"if",
"(",
"checkIfOnline",
"(",
")",
")",
"{",
"postMessageToNode",
"(",
"MessageIds",
".",
"PERFORM_CLEANUP",
",",
"[",
"'.json'",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"enableCheckForUpdateEntry",
"(... | Attempts a download of the latest installer, while cleaning up any existing downloaded installers | [
"Attempts",
"a",
"download",
"of",
"the",
"latest",
"installer",
"while",
"cleaning",
"up",
"any",
"existing",
"downloaded",
"installers"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L705-L726 | train | Attempt to download the file to the server | [
30522,
3853,
3535,
3406,
7698,
11066,
1006,
1007,
1063,
2065,
1006,
4638,
10128,
2239,
4179,
1006,
1007,
1007,
1063,
2695,
7834,
3736,
18150,
17175,
3207,
1006,
4471,
9821,
1012,
4685,
1035,
27686,
1010,
1031,
1005,
1012,
1046,
3385,
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... |
openlayers/openlayers | src/ol/sphere.js | getLengthInternal | function getLengthInternal(coordinates, radius) {
let length = 0;
for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {
length += getDistance(coordinates[i], coordinates[i + 1], radius);
}
return length;
} | javascript | function getLengthInternal(coordinates, radius) {
let length = 0;
for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {
length += getDistance(coordinates[i], coordinates[i + 1], radius);
}
return length;
} | [
"function",
"getLengthInternal",
"(",
"coordinates",
",",
"radius",
")",
"{",
"let",
"length",
"=",
"0",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"ii",
"=",
"coordinates",
".",
"length",
";",
"i",
"<",
"ii",
"-",
"1",
";",
"++",
"i",
")",
"{",... | Get the cumulative great circle length of linestring coordinates (geographic).
@param {Array} coordinates Linestring coordinates.
@param {number} radius The sphere radius to use.
@return {number} The length (in meters). | [
"Get",
"the",
"cumulative",
"great",
"circle",
"length",
"of",
"linestring",
"coordinates",
"(",
"geographic",
")",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/sphere.js#L64-L70 | train | Returns the length of the polygon given a list of coordinates | [
30522,
3853,
2131,
7770,
13512,
10606,
16451,
2389,
1006,
12093,
1010,
12177,
1007,
1063,
2292,
3091,
1027,
1014,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
1010,
2462,
1027,
12093,
1012,
3091,
1025,
1045,
1026,
2462,
1011,
1015,
1025,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js | function(oControl) {
var sControlType = this._getControlTypeInXml(oControl);
jQuery.sap.require(sControlType);
var ControlType = ObjectPath.get(sControlType);
return ControlType.getMetadata();
} | javascript | function(oControl) {
var sControlType = this._getControlTypeInXml(oControl);
jQuery.sap.require(sControlType);
var ControlType = ObjectPath.get(sControlType);
return ControlType.getMetadata();
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"sControlType",
"=",
"this",
".",
"_getControlTypeInXml",
"(",
"oControl",
")",
";",
"jQuery",
".",
"sap",
".",
"require",
"(",
"sControlType",
")",
";",
"var",
"ControlType",
"=",
"ObjectPath",
".",
"get",
"("... | Gets the metadata of am XML control.
@param {Element} oControl - Control in XML
@returns {sap.ui.base.Metadata} Metadata of the control | [
"Gets",
"the",
"metadata",
"of",
"am",
"XML",
"control",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js#L293-L298 | train | Returns the metadata of the control. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
8040,
12162,
13153,
13874,
1027,
2023,
1012,
1035,
2131,
8663,
13181,
24228,
5051,
2378,
2595,
19968,
1006,
1051,
8663,
13181,
2140,
1007,
1025,
1046,
4226,
2854,
1012,
20066,
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/TableAccExtension.js | function(oExtension) {
var oTable = oExtension.getTable();
var oInfo = TableUtils.getFocusedItemInfo(oTable);
return oInfo.cellInRow - (TableUtils.hasRowHeader(oTable) ? 1 : 0);
} | javascript | function(oExtension) {
var oTable = oExtension.getTable();
var oInfo = TableUtils.getFocusedItemInfo(oTable);
return oInfo.cellInRow - (TableUtils.hasRowHeader(oTable) ? 1 : 0);
} | [
"function",
"(",
"oExtension",
")",
"{",
"var",
"oTable",
"=",
"oExtension",
".",
"getTable",
"(",
")",
";",
"var",
"oInfo",
"=",
"TableUtils",
".",
"getFocusedItemInfo",
"(",
"oTable",
")",
";",
"return",
"oInfo",
".",
"cellInRow",
"-",
"(",
"TableUtils",... | /*
Returns the index of the column (in the array of visible columns (see Table._getVisibleColumns())) of the current focused cell
In case the focused cell is a row action the given index equals the length of the visible columns.
This function must not be used if the focus is on a row header.
@returns {int} | [
"/",
"*",
"Returns",
"the",
"index",
"of",
"the",
"column",
"(",
"in",
"the",
"array",
"of",
"visible",
"columns",
"(",
"see",
"Table",
".",
"_getVisibleColumns",
"()",
"))",
"of",
"the",
"current",
"focused",
"cell",
"In",
"case",
"the",
"focused",
"cel... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccExtension.js#L130-L134 | train | Returns the number of cells in the row of the focused item. | [
30522,
3853,
1006,
1051,
10288,
29048,
1007,
1063,
13075,
27178,
3085,
1027,
1051,
10288,
29048,
1012,
2131,
10880,
1006,
1007,
1025,
13075,
1051,
2378,
14876,
1027,
2795,
21823,
4877,
1012,
2131,
14876,
7874,
2098,
4221,
10020,
14876,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (o, oExtension, sTypeClass, sNonDefaultValue, bDeepCopy) {
if (sTypeClass === "EntitySet" && oExtension.value === sNonDefaultValue) {
// potentially nested structure so do deep copy
if (bDeepCopy) {
jQuery.extend(true, o, mV2ToV4[oExtension.name]);
} else {
// Warning: Passing false for the first argument is not supported!
jQuery.extend(o, mV2ToV4[oExtension.name]);
}
}
} | javascript | function (o, oExtension, sTypeClass, sNonDefaultValue, bDeepCopy) {
if (sTypeClass === "EntitySet" && oExtension.value === sNonDefaultValue) {
// potentially nested structure so do deep copy
if (bDeepCopy) {
jQuery.extend(true, o, mV2ToV4[oExtension.name]);
} else {
// Warning: Passing false for the first argument is not supported!
jQuery.extend(o, mV2ToV4[oExtension.name]);
}
}
} | [
"function",
"(",
"o",
",",
"oExtension",
",",
"sTypeClass",
",",
"sNonDefaultValue",
",",
"bDeepCopy",
")",
"{",
"if",
"(",
"sTypeClass",
"===",
"\"EntitySet\"",
"&&",
"oExtension",
".",
"value",
"===",
"sNonDefaultValue",
")",
"{",
"// potentially nested structur... | Adds EntitySet V4 annotation for current extension if extension value is equal to
the given non-default value. Depending on bDeepCopy the annotation will be merged
with deep copy.
@param {object} o
any object
@param {object} oExtension
the SAP Annotation (OData Version 2.0) for which a V4 annotation needs to be added
@param {string} sTypeClass
the type class of the given object; supported type classes are "Property" and
"EntitySet"
@param {string} sNonDefaultValue
if current extension value is equal to this sNonDefaultValue the annotation is
added
@param {boolean} bDeepCopy
if true the annotation is mixed in as deep copy of the entry in mV2ToV4 map | [
"Adds",
"EntitySet",
"V4",
"annotation",
"for",
"current",
"extension",
"if",
"extension",
"value",
"is",
"equal",
"to",
"the",
"given",
"non",
"-",
"default",
"value",
".",
"Depending",
"on",
"bDeepCopy",
"the",
"annotation",
"will",
"be",
"merged",
"with",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L181-L191 | train | This function is called by the extension to determine if the extension is a nested EntitySet | [
30522,
3853,
1006,
1051,
1010,
1051,
10288,
29048,
1010,
2358,
18863,
26266,
1010,
1055,
8540,
3207,
7011,
11314,
10175,
5657,
1010,
1038,
26095,
15042,
7361,
2100,
1007,
1063,
2065,
1006,
2358,
18863,
26266,
1027,
1027,
1027,
1000,
9178,
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... | |
heyui/heyui | src/plugins/popper/index.js | runModifiers | function runModifiers(modifiers, data, ends) {
var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
modifiersToRun.forEach(function (modifier) {
if (modifier['function']) {
// eslint-disable-line dot-notation
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
}
var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
if (modifier.enabled && isFunction(fn)) {
// Add properties to offsets to make them a complete clientRect object
// we do this before each modifier to make sure the previous one doesn't
// mess with these values
data.offsets.popper = getClientRect(data.offsets.popper);
data.offsets.reference = getClientRect(data.offsets.reference);
data = fn(data, modifier);
}
});
return data;
} | javascript | function runModifiers(modifiers, data, ends) {
var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
modifiersToRun.forEach(function (modifier) {
if (modifier['function']) {
// eslint-disable-line dot-notation
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
}
var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
if (modifier.enabled && isFunction(fn)) {
// Add properties to offsets to make them a complete clientRect object
// we do this before each modifier to make sure the previous one doesn't
// mess with these values
data.offsets.popper = getClientRect(data.offsets.popper);
data.offsets.reference = getClientRect(data.offsets.reference);
data = fn(data, modifier);
}
});
return data;
} | [
"function",
"runModifiers",
"(",
"modifiers",
",",
"data",
",",
"ends",
")",
"{",
"var",
"modifiersToRun",
"=",
"ends",
"===",
"undefined",
"?",
"modifiers",
":",
"modifiers",
".",
"slice",
"(",
"0",
",",
"findIndex",
"(",
"modifiers",
",",
"'name'",
",",
... | Loop trough the list of modifiers and run them in order,
each of them will then edit the data object.
@method
@memberof Popper.Utils
@param {dataObject} data
@param {Array} modifiers
@param {String} ends - Optional modifier name used as stopper
@returns {dataObject} | [
"Loop",
"trough",
"the",
"list",
"of",
"modifiers",
"and",
"run",
"them",
"in",
"order",
"each",
"of",
"them",
"will",
"then",
"edit",
"the",
"data",
"object",
"."
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L882-L903 | train | Runs a list of modifiers | [
30522,
3853,
2448,
5302,
4305,
8873,
2545,
1006,
16913,
28295,
1010,
2951,
1010,
4515,
1007,
1063,
13075,
16913,
28295,
4263,
4609,
1027,
30524,
1010,
2424,
22254,
10288,
1006,
16913,
28295,
1010,
1005,
2171,
1005,
1010,
4515,
1007,
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... |
uber/deck.gl | modules/core/src/lifecycle/props.js | diffDataProps | function diffDataProps(props, oldProps) {
if (oldProps === null) {
return 'oldProps is null, initial diff';
}
// Support optional app defined comparison of data
const {dataComparator} = props;
if (dataComparator) {
if (!dataComparator(props.data, oldProps.data)) {
return 'Data comparator detected a change';
}
// Otherwise, do a shallow equal on props
} else if (props.data !== oldProps.data) {
return 'A new data container was supplied';
}
return null;
} | javascript | function diffDataProps(props, oldProps) {
if (oldProps === null) {
return 'oldProps is null, initial diff';
}
// Support optional app defined comparison of data
const {dataComparator} = props;
if (dataComparator) {
if (!dataComparator(props.data, oldProps.data)) {
return 'Data comparator detected a change';
}
// Otherwise, do a shallow equal on props
} else if (props.data !== oldProps.data) {
return 'A new data container was supplied';
}
return null;
} | [
"function",
"diffDataProps",
"(",
"props",
",",
"oldProps",
")",
"{",
"if",
"(",
"oldProps",
"===",
"null",
")",
"{",
"return",
"'oldProps is null, initial diff'",
";",
"}",
"// Support optional app defined comparison of data",
"const",
"{",
"dataComparator",
"}",
"="... | The comparison of the data prop requires special handling the dataComparator should be used if supplied | [
"The",
"comparison",
"of",
"the",
"data",
"prop",
"requires",
"special",
"handling",
"the",
"dataComparator",
"should",
"be",
"used",
"if",
"supplied"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/lifecycle/props.js#L122-L139 | train | diff data container properties | [
30522,
3853,
4487,
4246,
2850,
2696,
21572,
4523,
1006,
24387,
1010,
2214,
21572,
4523,
1007,
1063,
2065,
1006,
2214,
21572,
4523,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
1005,
2214,
21572,
4523,
2003,
19701,
1010,
3988,
4487,
4246,
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... |
aws/aws-sdk-js | lib/services/s3.js | removeVirtualHostedBucketFromPath | function removeVirtualHostedBucketFromPath(req) {
var httpRequest = req.httpRequest;
var bucket = httpRequest.virtualHostedBucket;
if (bucket && httpRequest.path) {
if (req.params && req.params.Key) {
var encodedS3Key = '/' + AWS.util.uriEscapePath(req.params.Key);
if (httpRequest.path.indexOf(encodedS3Key) === 0 && (httpRequest.path.length === encodedS3Key.length || httpRequest.path[encodedS3Key.length] === '?')) {
//path only contains key or path contains only key and querystring
return;
}
}
httpRequest.path = httpRequest.path.replace(new RegExp('/' + bucket), '');
if (httpRequest.path[0] !== '/') {
httpRequest.path = '/' + httpRequest.path;
}
}
} | javascript | function removeVirtualHostedBucketFromPath(req) {
var httpRequest = req.httpRequest;
var bucket = httpRequest.virtualHostedBucket;
if (bucket && httpRequest.path) {
if (req.params && req.params.Key) {
var encodedS3Key = '/' + AWS.util.uriEscapePath(req.params.Key);
if (httpRequest.path.indexOf(encodedS3Key) === 0 && (httpRequest.path.length === encodedS3Key.length || httpRequest.path[encodedS3Key.length] === '?')) {
//path only contains key or path contains only key and querystring
return;
}
}
httpRequest.path = httpRequest.path.replace(new RegExp('/' + bucket), '');
if (httpRequest.path[0] !== '/') {
httpRequest.path = '/' + httpRequest.path;
}
}
} | [
"function",
"removeVirtualHostedBucketFromPath",
"(",
"req",
")",
"{",
"var",
"httpRequest",
"=",
"req",
".",
"httpRequest",
";",
"var",
"bucket",
"=",
"httpRequest",
".",
"virtualHostedBucket",
";",
"if",
"(",
"bucket",
"&&",
"httpRequest",
".",
"path",
")",
... | Takes the bucket name out of the path if bucket is virtual-hosted
@api private | [
"Takes",
"the",
"bucket",
"name",
"out",
"of",
"the",
"path",
"if",
"bucket",
"is",
"virtual",
"-",
"hosted"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L238-L254 | train | Remove virtual hosted bucket from path | [
30522,
3853,
6366,
21663,
26302,
28061,
14701,
24204,
3388,
19699,
25377,
8988,
1006,
2128,
4160,
1007,
1063,
13075,
8299,
2890,
15500,
1027,
2128,
4160,
1012,
8299,
2890,
15500,
1025,
13075,
13610,
1027,
8299,
2890,
15500,
1012,
7484,
15006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-extra-parens.js | isNewExpressionWithParens | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken);
} | javascript | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken);
} | [
"function",
"isNewExpressionWithParens",
"(",
"newExpression",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"newExpression",
")",
";",
"const",
"penultimateToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"lastToken",
")",
";",
... | Determines if a constructor function is newed-up with parens
@param {ASTNode} newExpression - The NewExpression node to be checked.
@returns {boolean} True if the constructor is called with parens.
@private | [
"Determines",
"if",
"a",
"constructor",
"function",
"is",
"newed",
"-",
"up",
"with",
"parens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L190-L195 | train | Check if newExpression has parentheses | [
30522,
3853,
3475,
7974,
10288,
20110,
3258,
24415,
19362,
6132,
1006,
2047,
10288,
20110,
3258,
1007,
1063,
9530,
3367,
2197,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
2047,
10288,
20110,
3258,
1007,
1025,
9530,
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... |
ColorlibHQ/AdminLTE | bower_components/ion.rangeSlider/js/ion.rangeSlider.js | function (options) {
if (!this.input) {
return;
}
this.is_update = true;
this.options.from = this.result.from;
this.options.to = this.result.to;
this.update_check.from = this.result.from;
this.update_check.to = this.result.to;
this.options = $.extend(this.options, options);
this.validate();
this.updateResult(options);
this.toggleInput();
this.remove();
this.init(true);
} | javascript | function (options) {
if (!this.input) {
return;
}
this.is_update = true;
this.options.from = this.result.from;
this.options.to = this.result.to;
this.update_check.from = this.result.from;
this.update_check.to = this.result.to;
this.options = $.extend(this.options, options);
this.validate();
this.updateResult(options);
this.toggleInput();
this.remove();
this.init(true);
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"this",
".",
"input",
")",
"{",
"return",
";",
"}",
"this",
".",
"is_update",
"=",
"true",
";",
"this",
".",
"options",
".",
"from",
"=",
"this",
".",
"result",
".",
"from",
";",
"this",
".",
... | ============================================================================================================= Public methods | [
"=============================================================================================================",
"Public",
"methods"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/ion.rangeSlider/js/ion.rangeSlider.js#L2361-L2380 | train | update the result | [
30522,
3853,
1006,
7047,
1007,
1063,
2065,
1006,
999,
2023,
1012,
7953,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
2003,
1035,
10651,
1027,
2995,
1025,
2023,
1012,
7047,
1012,
2013,
1027,
2023,
1012,
2765,
1012,
2013,
1025,
2023,
1012,
704... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/models/base/index.js | destroy | function destroy(unfilteredOptions) {
const options = this.filterOptions(unfilteredOptions, 'destroy');
if (!options.destroyBy) {
options.destroyBy = {
id: options.id
};
}
// Fetch the object before destroying it, so that the changed data is available to events
return this.forge(options.destroyBy)
.fetch(options)
.then(function then(obj) {
return obj.destroy(options);
});
} | javascript | function destroy(unfilteredOptions) {
const options = this.filterOptions(unfilteredOptions, 'destroy');
if (!options.destroyBy) {
options.destroyBy = {
id: options.id
};
}
// Fetch the object before destroying it, so that the changed data is available to events
return this.forge(options.destroyBy)
.fetch(options)
.then(function then(obj) {
return obj.destroy(options);
});
} | [
"function",
"destroy",
"(",
"unfilteredOptions",
")",
"{",
"const",
"options",
"=",
"this",
".",
"filterOptions",
"(",
"unfilteredOptions",
",",
"'destroy'",
")",
";",
"if",
"(",
"!",
"options",
".",
"destroyBy",
")",
"{",
"options",
".",
"destroyBy",
"=",
... | ### Destroy
Naive destroy
@param {Object} unfilteredOptions (optional)
@return {Promise(ghostBookshelf.Model)} Empty Model | [
"###",
"Destroy",
"Naive",
"destroy"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L1014-L1029 | train | Destroys the object | [
30522,
3853,
6033,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1007,
1063,
9530,
3367,
7047,
1027,
2023,
1012,
11307,
7361,
9285,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1010,
1005,
6033,
1005,
1007,
1025,
2065,
1006,
999,
7047,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/templating/postRender.js | replaceBlocks | function replaceBlocks(content, blocks) {
var newContent = content.replace(/\{\{\-\%([\s\S]+?)\%\-\}\}/g, function(match, key) {
var replacedWith = match;
var block = blocks.get(key);
if (block) {
replacedWith = replaceBlocks(block.get('body'), blocks);
}
return replacedWith;
});
return newContent;
} | javascript | function replaceBlocks(content, blocks) {
var newContent = content.replace(/\{\{\-\%([\s\S]+?)\%\-\}\}/g, function(match, key) {
var replacedWith = match;
var block = blocks.get(key);
if (block) {
replacedWith = replaceBlocks(block.get('body'), blocks);
}
return replacedWith;
});
return newContent;
} | [
"function",
"replaceBlocks",
"(",
"content",
",",
"blocks",
")",
"{",
"var",
"newContent",
"=",
"content",
".",
"replace",
"(",
"/",
"\\{\\{\\-\\%([\\s\\S]+?)\\%\\-\\}\\}",
"/",
"g",
",",
"function",
"(",
"match",
",",
"key",
")",
"{",
"var",
"replacedWith",
... | Replace position markers of blocks by body after processing
This is done to avoid that markdown/asciidoc processer parse the block content
@param {String} content
@return {Object} {blocks: Set, content: String} | [
"Replace",
"position",
"markers",
"of",
"blocks",
"by",
"body",
"after",
"processing",
"This",
"is",
"done",
"to",
"avoid",
"that",
"markdown",
"/",
"asciidoc",
"processer",
"parse",
"the",
"block",
"content"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/templating/postRender.js#L11-L24 | train | Replace all % blocks with the content of the current page | [
30522,
3853,
5672,
23467,
2015,
1006,
4180,
1010,
5991,
1007,
1063,
13075,
2047,
8663,
6528,
2102,
1027,
4180,
1012,
5672,
1006,
1013,
1032,
1063,
1032,
1063,
1032,
1011,
1032,
1003,
1006,
1031,
1032,
1055,
1032,
1055,
1033,
1009,
1029,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-implicit-coercion.js | parseOptions | function parseOptions(options) {
return {
boolean: "boolean" in options ? options.boolean : true,
number: "number" in options ? options.number : true,
string: "string" in options ? options.string : true,
allow: options.allow || []
};
} | javascript | function parseOptions(options) {
return {
boolean: "boolean" in options ? options.boolean : true,
number: "number" in options ? options.number : true,
string: "string" in options ? options.string : true,
allow: options.allow || []
};
} | [
"function",
"parseOptions",
"(",
"options",
")",
"{",
"return",
"{",
"boolean",
":",
"\"boolean\"",
"in",
"options",
"?",
"options",
".",
"boolean",
":",
"true",
",",
"number",
":",
"\"number\"",
"in",
"options",
"?",
"options",
".",
"number",
":",
"true",... | Parses and normalizes an option object.
@param {Object} options - An option object to parse.
@returns {Object} The parsed and normalized option object. | [
"Parses",
"and",
"normalizes",
"an",
"option",
"object",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L22-L29 | train | Parse the options | [
30522,
3853,
11968,
3366,
7361,
9285,
1006,
7047,
1007,
1063,
2709,
1063,
22017,
20898,
30524,
7047,
1029,
7047,
1012,
2193,
1024,
2995,
1010,
5164,
1024,
1000,
5164,
1000,
1999,
7047,
1029,
7047,
1012,
5164,
1024,
2995,
1010,
3499,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/parse/validateConfig.js | validateConfig | function validateConfig(bookJson) {
var v = new jsonschema.Validator();
var result = v.validate(bookJson, schema, {
propertyName: 'config'
});
// Throw error
if (result.errors.length > 0) {
throw new error.ConfigurationError(new Error(result.errors[0].stack));
}
// Insert default values
var defaults = jsonSchemaDefaults(schema);
return mergeDefaults(bookJson, defaults);
} | javascript | function validateConfig(bookJson) {
var v = new jsonschema.Validator();
var result = v.validate(bookJson, schema, {
propertyName: 'config'
});
// Throw error
if (result.errors.length > 0) {
throw new error.ConfigurationError(new Error(result.errors[0].stack));
}
// Insert default values
var defaults = jsonSchemaDefaults(schema);
return mergeDefaults(bookJson, defaults);
} | [
"function",
"validateConfig",
"(",
"bookJson",
")",
"{",
"var",
"v",
"=",
"new",
"jsonschema",
".",
"Validator",
"(",
")",
";",
"var",
"result",
"=",
"v",
".",
"validate",
"(",
"bookJson",
",",
"schema",
",",
"{",
"propertyName",
":",
"'config'",
"}",
... | Validate a book.json content
And return a mix with the default value
@param {Object} bookJson
@return {Object} | [
"Validate",
"a",
"book",
".",
"json",
"content",
"And",
"return",
"a",
"mix",
"with",
"the",
"default",
"value"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/validateConfig.js#L15-L29 | train | Validate the config | [
30522,
3853,
9398,
3686,
8663,
8873,
2290,
1006,
2338,
22578,
2239,
1007,
1063,
13075,
1058,
1027,
2047,
1046,
23345,
5403,
2863,
1012,
9398,
8844,
1006,
1007,
1025,
13075,
2765,
1027,
1058,
1012,
9398,
3686,
1006,
2338,
22578,
2239,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | isInViewStateSelection | function isInViewStateSelection(range, viewState) {
if (!viewState || !viewState.selections) {
return false;
}
return viewState.selections.some(function (selection) {
return rangeEqualsSelection(range, selection);
});
} | javascript | function isInViewStateSelection(range, viewState) {
if (!viewState || !viewState.selections) {
return false;
}
return viewState.selections.some(function (selection) {
return rangeEqualsSelection(range, selection);
});
} | [
"function",
"isInViewStateSelection",
"(",
"range",
",",
"viewState",
")",
"{",
"if",
"(",
"!",
"viewState",
"||",
"!",
"viewState",
".",
"selections",
")",
"{",
"return",
"false",
";",
"}",
"return",
"viewState",
".",
"selections",
".",
"some",
"(",
"func... | Checks if the range is equal to one of the selections in the viewState
@param {Object} range {from, to} where from and to are CodeMirror.Pos objects.
@param {Object} viewState The current editor's ViewState object
@returns {Boolean} true if the range is found in the list of selections or false if not. | [
"Checks",
"if",
"the",
"range",
"is",
"equal",
"to",
"one",
"of",
"the",
"selections",
"in",
"the",
"viewState"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L109-L117 | train | returns true if range is in viewState selection | [
30522,
3853,
2003,
2378,
8584,
9153,
4570,
12260,
7542,
1006,
2846,
1010,
5328,
12259,
1007,
1063,
2065,
1006,
999,
5328,
12259,
1064,
1064,
999,
5328,
12259,
1012,
16310,
1007,
1063,
2709,
6270,
1025,
1065,
2709,
5328,
12259,
1012,
16310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | src/platforms/weex/framework.js | getInstanceTimer | function getInstanceTimer (instanceId, moduleGetter) {
const instance = instances[instanceId]
const timer = moduleGetter('timer')
const timerAPIs = {
setTimeout: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setTimeout(handler, args[1])
return instance.callbackId.toString()
},
setInterval: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setInterval(handler, args[1])
return instance.callbackId.toString()
},
clearTimeout: (n) => {
timer.clearTimeout(n)
},
clearInterval: (n) => {
timer.clearInterval(n)
}
}
return timerAPIs
} | javascript | function getInstanceTimer (instanceId, moduleGetter) {
const instance = instances[instanceId]
const timer = moduleGetter('timer')
const timerAPIs = {
setTimeout: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setTimeout(handler, args[1])
return instance.callbackId.toString()
},
setInterval: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setInterval(handler, args[1])
return instance.callbackId.toString()
},
clearTimeout: (n) => {
timer.clearTimeout(n)
},
clearInterval: (n) => {
timer.clearInterval(n)
}
}
return timerAPIs
} | [
"function",
"getInstanceTimer",
"(",
"instanceId",
",",
"moduleGetter",
")",
"{",
"const",
"instance",
"=",
"instances",
"[",
"instanceId",
"]",
"const",
"timer",
"=",
"moduleGetter",
"(",
"'timer'",
")",
"const",
"timerAPIs",
"=",
"{",
"setTimeout",
":",
"(",... | Generate HTML5 Timer APIs. An important point is that the callback
will be converted into callback id when sent to native. So the
framework can make sure no side effect of the callback happened after
an instance destroyed.
@param {[type]} instanceId [description]
@param {[type]} moduleGetter [description]
@return {[type]} [description] | [
"Generate",
"HTML5",
"Timer",
"APIs",
".",
"An",
"important",
"point",
"is",
"that",
"the",
"callback",
"will",
"be",
"converted",
"into",
"callback",
"id",
"when",
"sent",
"to",
"native",
".",
"So",
"the",
"framework",
"can",
"make",
"sure",
"no",
"side",... | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/src/platforms/weex/framework.js#L323-L349 | train | Get timer APIs for a specific instance | [
30522,
3853,
2131,
7076,
26897,
7292,
2099,
1006,
6013,
3593,
1010,
11336,
18150,
3334,
1007,
1063,
9530,
3367,
6013,
1027,
12107,
1031,
6013,
3593,
1033,
9530,
3367,
25309,
1027,
11336,
18150,
3334,
1006,
1005,
25309,
1005,
1007,
9530,
336... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/sunburst/sunburstLayout.js | sort | function sort(children, sortOrder) {
if (typeof sortOrder === 'function') {
return children.sort(sortOrder);
}
else {
var isAsc = sortOrder === 'asc';
return children.sort(function (a, b) {
var diff = (a.getValue() - b.getValue()) * (isAsc ? 1 : -1);
return diff === 0
? (a.dataIndex - b.dataIndex) * (isAsc ? -1 : 1)
: diff;
});
}
} | javascript | function sort(children, sortOrder) {
if (typeof sortOrder === 'function') {
return children.sort(sortOrder);
}
else {
var isAsc = sortOrder === 'asc';
return children.sort(function (a, b) {
var diff = (a.getValue() - b.getValue()) * (isAsc ? 1 : -1);
return diff === 0
? (a.dataIndex - b.dataIndex) * (isAsc ? -1 : 1)
: diff;
});
}
} | [
"function",
"sort",
"(",
"children",
",",
"sortOrder",
")",
"{",
"if",
"(",
"typeof",
"sortOrder",
"===",
"'function'",
")",
"{",
"return",
"children",
".",
"sort",
"(",
"sortOrder",
")",
";",
"}",
"else",
"{",
"var",
"isAsc",
"=",
"sortOrder",
"===",
... | Sort children nodes
@param {TreeNode[]} children children of node to be sorted
@param {string | function | null} sort sort method
See SunburstSeries.js for details. | [
"Sort",
"children",
"nodes"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/sunburstLayout.js#L195-L208 | train | sorts the children array | [
30522,
3853,
4066,
1006,
2336,
1010,
4066,
8551,
2121,
1007,
1063,
2065,
1006,
2828,
11253,
4066,
8551,
2121,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
1063,
2709,
2336,
1012,
4066,
1006,
4066,
8551,
2121,
1007,
1025,
1065,
2842,
1063,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-runtime/util/isScalarAndEqual.js | isScalarAndEqual | function isScalarAndEqual(valueA: mixed, valueB: mixed): boolean {
return valueA === valueB && (valueA === null || typeof valueA !== 'object');
} | javascript | function isScalarAndEqual(valueA: mixed, valueB: mixed): boolean {
return valueA === valueB && (valueA === null || typeof valueA !== 'object');
} | [
"function",
"isScalarAndEqual",
"(",
"valueA",
":",
"mixed",
",",
"valueB",
":",
"mixed",
")",
":",
"boolean",
"{",
"return",
"valueA",
"===",
"valueB",
"&&",
"(",
"valueA",
"===",
"null",
"||",
"typeof",
"valueA",
"!==",
"'object'",
")",
";",
"}"
] | A fast test to determine if two values are equal scalars:
- compares scalars such as booleans, strings, numbers by value
- compares functions by identity
- returns false for complex values, since these cannot be cheaply tested for
equality (use `areEquals` instead) | [
"A",
"fast",
"test",
"to",
"determine",
"if",
"two",
"values",
"are",
"equal",
"scalars",
":",
"-",
"compares",
"scalars",
"such",
"as",
"booleans",
"strings",
"numbers",
"by",
"value",
"-",
"compares",
"functions",
"by",
"identity",
"-",
"returns",
"false",... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/util/isScalarAndEqual.js#L20-L22 | train | Check if two values are scalar and equal | [
30522,
3853,
26354,
25015,
13033,
2063,
26426,
1006,
3643,
2050,
1024,
3816,
1010,
3643,
2497,
1024,
3816,
1007,
1024,
22017,
20898,
1063,
2709,
3643,
2050,
1027,
1027,
1027,
3643,
2497,
1004,
1004,
1006,
3643,
2050,
1027,
1027,
1027,
19701... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/padding-line-between-statements.js | verifyForAlways | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
let prevToken = getActualLastToken(sourceCode, prevNode);
const nextToken = sourceCode.getFirstTokenBetween(
prevToken,
nextNode,
{
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is not a trailing comment.
* @private
*/
filter(token) {
if (astUtils.isTokenOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}
return true;
}
}
) || nextNode;
const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken)
? "\n\n"
: "\n";
return fixer.insertTextAfter(prevToken, insertText);
}
});
} | javascript | function verifyForAlways(context, prevNode, nextNode, paddingLines) {
if (paddingLines.length > 0) {
return;
}
context.report({
node: nextNode,
message: "Expected blank line before this statement.",
fix(fixer) {
const sourceCode = context.getSourceCode();
let prevToken = getActualLastToken(sourceCode, prevNode);
const nextToken = sourceCode.getFirstTokenBetween(
prevToken,
nextNode,
{
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*
* @param {Token} token The token to check.
* @returns {boolean} `true` if the token is not a trailing comment.
* @private
*/
filter(token) {
if (astUtils.isTokenOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}
return true;
}
}
) || nextNode;
const insertText = astUtils.isTokenOnSameLine(prevToken, nextToken)
? "\n\n"
: "\n";
return fixer.insertTextAfter(prevToken, insertText);
}
});
} | [
"function",
"verifyForAlways",
"(",
"context",
",",
"prevNode",
",",
"nextNode",
",",
"paddingLines",
")",
"{",
"if",
"(",
"paddingLines",
".",
"length",
">",
"0",
")",
"{",
"return",
";",
"}",
"context",
".",
"report",
"(",
"{",
"node",
":",
"nextNode",... | Check and report statements for `always` configuration.
This autofix inserts a blank line between the given 2 statements.
If the `prevNode` has trailing comments, it inserts a blank line after the
trailing comments.
@param {RuleContext} context The rule context to report.
@param {ASTNode} prevNode The previous node to check.
@param {ASTNode} nextNode The next node to check.
@param {Array<Token[]>} paddingLines The array of token pairs that blank
lines exist between the pair.
@returns {void}
@private | [
"Check",
"and",
"report",
"statements",
"for",
"always",
"configuration",
".",
"This",
"autofix",
"inserts",
"a",
"blank",
"line",
"between",
"the",
"given",
"2",
"statements",
".",
"If",
"the",
"prevNode",
"has",
"trailing",
"comments",
"it",
"inserts",
"a",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L288-L342 | train | Verifies that the next node is always. | [
30522,
3853,
20410,
29278,
2389,
14035,
1006,
6123,
1010,
3653,
16022,
10244,
1010,
2279,
3630,
3207,
1010,
11687,
4667,
12735,
1007,
1063,
2065,
1006,
11687,
4667,
12735,
1012,
3091,
1028,
1014,
1007,
1063,
2709,
1025,
1065,
6123,
1012,
31... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | examples/raster.js | summarize | function summarize(value, counts) {
const min = counts.min;
const max = counts.max;
const num = counts.values.length;
if (value < min) {
// do nothing
} else if (value >= max) {
counts.values[num - 1] += 1;
} else {
const index = Math.floor((value - min) / counts.delta);
counts.values[index] += 1;
}
} | javascript | function summarize(value, counts) {
const min = counts.min;
const max = counts.max;
const num = counts.values.length;
if (value < min) {
// do nothing
} else if (value >= max) {
counts.values[num - 1] += 1;
} else {
const index = Math.floor((value - min) / counts.delta);
counts.values[index] += 1;
}
} | [
"function",
"summarize",
"(",
"value",
",",
"counts",
")",
"{",
"const",
"min",
"=",
"counts",
".",
"min",
";",
"const",
"max",
"=",
"counts",
".",
"max",
";",
"const",
"num",
"=",
"counts",
".",
"values",
".",
"length",
";",
"if",
"(",
"value",
"<... | Summarize values for a histogram.
@param {numver} value A VGI value.
@param {Object} counts An object for keeping track of VGI counts. | [
"Summarize",
"values",
"for",
"a",
"histogram",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/raster.js#L31-L43 | train | summarize the value | [
30522,
3853,
7680,
7849,
4697,
1006,
3643,
1010,
9294,
1007,
1063,
9530,
3367,
8117,
1027,
9294,
1012,
8117,
1025,
9530,
3367,
4098,
1027,
9294,
1012,
4098,
1025,
9530,
3367,
16371,
2213,
1027,
9294,
1012,
5300,
1012,
3091,
1025,
2065,
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... |
postcss/autoprefixer | lib/hacks/grid-utils.js | inheritGridGap | function inheritGridGap (decl, gap) {
let rule = decl.parent
let mediaRule = getParentMedia(rule)
let root = rule.root()
// get an array of selector split in 3-deep array
let splitSelectorArr = splitSelector(rule.selector)
// abort if the rule already has gaps
if (Object.keys(gap).length > 0) {
return false
}
// e.g ['min-width']
let [prop] = parseMediaParams(mediaRule.params)
let lastBySpace = splitSelectorArr[0]
// get escaped value from the selector
// if we have '.grid-2.foo.bar' selector, will be '\.grid\-2'
let escaped = escapeRegexp(lastBySpace[lastBySpace.length - 1][0])
let regexp = new RegExp(`(${ escaped }$)|(${ escaped }[,.])`)
// find the closest rule with the same selector
let closestRuleGap
root.walkRules(regexp, r => {
let gridGap
// abort if are checking the same rule
if (rule.toString() === r.toString()) {
return false
}
// find grid-gap values
r.walkDecls('grid-gap', d => (gridGap = getGridGap(d)))
// skip rule without gaps
if (!gridGap || Object.keys(gridGap).length === 0) {
return true
}
// skip rules that should not be inherited from
if (!shouldInheritGap(rule.selector, r.selector)) {
return true
}
let media = getParentMedia(r)
if (media) {
// if we are inside media, we need to check that media props match
// e.g ('min-width' === 'min-width')
let propToCompare = parseMediaParams(media.params)[0]
if (propToCompare === prop) {
closestRuleGap = gridGap
return true
}
} else {
closestRuleGap = gridGap
return true
}
return undefined
})
// if we find the closest gap object
if (closestRuleGap && Object.keys(closestRuleGap).length > 0) {
return closestRuleGap
}
return false
} | javascript | function inheritGridGap (decl, gap) {
let rule = decl.parent
let mediaRule = getParentMedia(rule)
let root = rule.root()
// get an array of selector split in 3-deep array
let splitSelectorArr = splitSelector(rule.selector)
// abort if the rule already has gaps
if (Object.keys(gap).length > 0) {
return false
}
// e.g ['min-width']
let [prop] = parseMediaParams(mediaRule.params)
let lastBySpace = splitSelectorArr[0]
// get escaped value from the selector
// if we have '.grid-2.foo.bar' selector, will be '\.grid\-2'
let escaped = escapeRegexp(lastBySpace[lastBySpace.length - 1][0])
let regexp = new RegExp(`(${ escaped }$)|(${ escaped }[,.])`)
// find the closest rule with the same selector
let closestRuleGap
root.walkRules(regexp, r => {
let gridGap
// abort if are checking the same rule
if (rule.toString() === r.toString()) {
return false
}
// find grid-gap values
r.walkDecls('grid-gap', d => (gridGap = getGridGap(d)))
// skip rule without gaps
if (!gridGap || Object.keys(gridGap).length === 0) {
return true
}
// skip rules that should not be inherited from
if (!shouldInheritGap(rule.selector, r.selector)) {
return true
}
let media = getParentMedia(r)
if (media) {
// if we are inside media, we need to check that media props match
// e.g ('min-width' === 'min-width')
let propToCompare = parseMediaParams(media.params)[0]
if (propToCompare === prop) {
closestRuleGap = gridGap
return true
}
} else {
closestRuleGap = gridGap
return true
}
return undefined
})
// if we find the closest gap object
if (closestRuleGap && Object.keys(closestRuleGap).length > 0) {
return closestRuleGap
}
return false
} | [
"function",
"inheritGridGap",
"(",
"decl",
",",
"gap",
")",
"{",
"let",
"rule",
"=",
"decl",
".",
"parent",
"let",
"mediaRule",
"=",
"getParentMedia",
"(",
"rule",
")",
"let",
"root",
"=",
"rule",
".",
"root",
"(",
")",
"// get an array of selector split in ... | inherit grid gap values from the closest rule above
with the same selector
@param {Declaration} decl
@param {Object} gap gap values
@return {Object | Boolean} return gap values or false (if not found) | [
"inherit",
"grid",
"gap",
"values",
"from",
"the",
"closest",
"rule",
"above",
"with",
"the",
"same",
"selector"
] | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/lib/hacks/grid-utils.js#L871-L940 | train | inherit grid - gap from rule | [
30522,
3853,
22490,
16523,
3593,
3654,
2361,
1006,
11703,
2140,
1010,
6578,
1007,
1063,
2292,
3627,
1027,
11703,
2140,
1012,
6687,
2292,
2865,
6820,
2571,
1027,
2131,
19362,
4765,
16969,
1006,
30524,
3975,
1999,
1017,
1011,
2784,
9140,
2292... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/echarts.js | renderSeries | function renderSeries(ecIns, ecModel, api, payload, dirtyMap) {
// Render all charts
var scheduler = ecIns._scheduler;
var unfinished;
ecModel.eachSeries(function (seriesModel) {
var chartView = ecIns._chartsMap[seriesModel.__viewId];
chartView.__alive = true;
var renderTask = chartView.renderTask;
scheduler.updatePayload(renderTask, payload);
if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
renderTask.dirty();
}
unfinished |= renderTask.perform(scheduler.getPerformArgs(renderTask));
chartView.group.silent = !!seriesModel.get('silent');
updateZ(seriesModel, chartView);
updateBlend(seriesModel, chartView);
});
scheduler.unfinished |= unfinished;
// If use hover layer
updateHoverLayerStatus(ecIns._zr, ecModel);
// Add aria
aria(ecIns._zr.dom, ecModel);
} | javascript | function renderSeries(ecIns, ecModel, api, payload, dirtyMap) {
// Render all charts
var scheduler = ecIns._scheduler;
var unfinished;
ecModel.eachSeries(function (seriesModel) {
var chartView = ecIns._chartsMap[seriesModel.__viewId];
chartView.__alive = true;
var renderTask = chartView.renderTask;
scheduler.updatePayload(renderTask, payload);
if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
renderTask.dirty();
}
unfinished |= renderTask.perform(scheduler.getPerformArgs(renderTask));
chartView.group.silent = !!seriesModel.get('silent');
updateZ(seriesModel, chartView);
updateBlend(seriesModel, chartView);
});
scheduler.unfinished |= unfinished;
// If use hover layer
updateHoverLayerStatus(ecIns._zr, ecModel);
// Add aria
aria(ecIns._zr.dom, ecModel);
} | [
"function",
"renderSeries",
"(",
"ecIns",
",",
"ecModel",
",",
"api",
",",
"payload",
",",
"dirtyMap",
")",
"{",
"// Render all charts",
"var",
"scheduler",
"=",
"ecIns",
".",
"_scheduler",
";",
"var",
"unfinished",
";",
"ecModel",
".",
"eachSeries",
"(",
"f... | Render each chart and component
@private | [
"Render",
"each",
"chart",
"and",
"component"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/echarts.js#L1477-L1507 | train | Render all charts | [
30522,
3853,
17552,
8043,
3111,
1006,
14925,
7076,
1010,
14925,
5302,
9247,
1010,
17928,
1010,
18093,
1010,
6530,
2863,
2361,
1007,
1063,
1013,
1013,
17552,
2035,
6093,
13075,
6134,
2099,
1027,
14925,
7076,
1012,
1035,
6134,
2099,
1025,
130... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/datepicker/js/calendar.spec.js | extractRowText | function extractRowText(tr) {
var cellContents = [];
angular.forEach(tr.children, function(tableElement) {
cellContents.push(tableElement.textContent);
});
return cellContents;
} | javascript | function extractRowText(tr) {
var cellContents = [];
angular.forEach(tr.children, function(tableElement) {
cellContents.push(tableElement.textContent);
});
return cellContents;
} | [
"function",
"extractRowText",
"(",
"tr",
")",
"{",
"var",
"cellContents",
"=",
"[",
"]",
";",
"angular",
".",
"forEach",
"(",
"tr",
".",
"children",
",",
"function",
"(",
"tableElement",
")",
"{",
"cellContents",
".",
"push",
"(",
"tableElement",
".",
"t... | Extracts text as an array (one element per cell) from a tr element. | [
"Extracts",
"text",
"as",
"an",
"array",
"(",
"one",
"element",
"per",
"cell",
")",
"from",
"a",
"tr",
"element",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendar.spec.js#L34-L41 | train | Extract text from a row | [
30522,
3853,
14817,
10524,
18209,
1006,
19817,
1007,
1063,
13075,
3526,
8663,
6528,
3215,
1027,
1031,
1033,
1025,
16108,
1012,
18921,
6776,
1006,
19817,
1012,
2336,
1010,
3853,
1006,
2795,
12260,
3672,
1007,
1063,
3526,
8663,
6528,
3215,
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/ODataModel.js | parseAndValidateSystemQueryOption | function parseAndValidateSystemQueryOption (mOptions, sOptionName, aAllowed) {
var sExpandOptionName,
mExpandOptions,
sExpandPath,
vValue = mOptions[sOptionName];
if (!bSystemQueryOptionsAllowed || aAllowed.indexOf(sOptionName) < 0) {
throw new Error("System query option " + sOptionName + " is not supported");
}
if ((sOptionName === "$expand" || sOptionName === "$select")
&& typeof vValue === "string") {
vValue = _Parser.parseSystemQueryOption(sOptionName + "=" + vValue)[sOptionName];
mOptions[sOptionName] = vValue;
}
if (sOptionName === "$expand") {
for (sExpandPath in vValue) {
mExpandOptions = vValue[sExpandPath];
if (mExpandOptions === null || typeof mExpandOptions !== "object") {
// normalize empty expand options to {}
mExpandOptions = vValue[sExpandPath] = {};
}
for (sExpandOptionName in mExpandOptions) {
parseAndValidateSystemQueryOption(mExpandOptions, sExpandOptionName,
aExpandQueryOptions);
}
}
} else if (sOptionName === "$count") {
if (typeof vValue === "boolean") {
if (!vValue) {
delete mOptions.$count;
}
} else {
switch (typeof vValue === "string" && vValue.toLowerCase()) {
case "false":
delete mOptions.$count;
break;
case "true":
mOptions.$count = true;
break;
default:
throw new Error("Invalid value for $count: " + vValue);
}
}
}
} | javascript | function parseAndValidateSystemQueryOption (mOptions, sOptionName, aAllowed) {
var sExpandOptionName,
mExpandOptions,
sExpandPath,
vValue = mOptions[sOptionName];
if (!bSystemQueryOptionsAllowed || aAllowed.indexOf(sOptionName) < 0) {
throw new Error("System query option " + sOptionName + " is not supported");
}
if ((sOptionName === "$expand" || sOptionName === "$select")
&& typeof vValue === "string") {
vValue = _Parser.parseSystemQueryOption(sOptionName + "=" + vValue)[sOptionName];
mOptions[sOptionName] = vValue;
}
if (sOptionName === "$expand") {
for (sExpandPath in vValue) {
mExpandOptions = vValue[sExpandPath];
if (mExpandOptions === null || typeof mExpandOptions !== "object") {
// normalize empty expand options to {}
mExpandOptions = vValue[sExpandPath] = {};
}
for (sExpandOptionName in mExpandOptions) {
parseAndValidateSystemQueryOption(mExpandOptions, sExpandOptionName,
aExpandQueryOptions);
}
}
} else if (sOptionName === "$count") {
if (typeof vValue === "boolean") {
if (!vValue) {
delete mOptions.$count;
}
} else {
switch (typeof vValue === "string" && vValue.toLowerCase()) {
case "false":
delete mOptions.$count;
break;
case "true":
mOptions.$count = true;
break;
default:
throw new Error("Invalid value for $count: " + vValue);
}
}
}
} | [
"function",
"parseAndValidateSystemQueryOption",
"(",
"mOptions",
",",
"sOptionName",
",",
"aAllowed",
")",
"{",
"var",
"sExpandOptionName",
",",
"mExpandOptions",
",",
"sExpandPath",
",",
"vValue",
"=",
"mOptions",
"[",
"sOptionName",
"]",
";",
"if",
"(",
"!",
... | Parses the query options for the given option name "sOptionName" in the given map of
query options "mOptions" to an object if necessary.
Validates if the given query option name is allowed.
@param {object} mOptions Map of query options by name
@param {string} sOptionName Name of the query option
@param {string[]} aAllowed The allowed system query options
@throws {error} If the given query option name is not allowed | [
"Parses",
"the",
"query",
"options",
"for",
"the",
"given",
"option",
"name",
"sOptionName",
"in",
"the",
"given",
"map",
"of",
"query",
"options",
"mOptions",
"to",
"an",
"object",
"if",
"necessary",
".",
"Validates",
"if",
"the",
"given",
"query",
"option"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataModel.js#L724-L768 | train | Parses the given query options and validates it | [
30522,
3853,
11968,
17310,
4859,
10175,
8524,
4570,
27268,
6633,
4226,
2854,
7361,
3508,
1006,
9587,
16790,
2015,
1010,
2061,
16790,
18442,
1010,
9779,
7174,
15557,
1007,
1063,
13075,
3348,
9739,
3527,
16790,
18442,
1010,
2033,
2595,
9739,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ui/components/codemirror/extensions/autocomplete.js | renderHintMatch | function renderHintMatch(li, self, data) {
// Bold the matched text
const { displayText, segment } = data;
const markedName = replaceWithSurround(displayText, segment, '<strong>', '</strong>');
const { char, title } = ICONS[data.type];
const safeValue = escapeHTML(data.displayValue);
li.className += ` fancy-hint type--${data.type}`;
li.innerHTML = `
<label class="label" title="${title}">${char}</label>
<div class="name">${markedName}</div>
<div class="value" title=${safeValue}>
${safeValue}
</div>
`;
} | javascript | function renderHintMatch(li, self, data) {
// Bold the matched text
const { displayText, segment } = data;
const markedName = replaceWithSurround(displayText, segment, '<strong>', '</strong>');
const { char, title } = ICONS[data.type];
const safeValue = escapeHTML(data.displayValue);
li.className += ` fancy-hint type--${data.type}`;
li.innerHTML = `
<label class="label" title="${title}">${char}</label>
<div class="name">${markedName}</div>
<div class="value" title=${safeValue}>
${safeValue}
</div>
`;
} | [
"function",
"renderHintMatch",
"(",
"li",
",",
"self",
",",
"data",
")",
"{",
"// Bold the matched text",
"const",
"{",
"displayText",
",",
"segment",
"}",
"=",
"data",
";",
"const",
"markedName",
"=",
"replaceWithSurround",
"(",
"displayText",
",",
"segment",
... | Render the autocomplete list entry
@param li
@param self
@param data | [
"Render",
"the",
"autocomplete",
"list",
"entry"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js#L411-L427 | train | Render a hint | [
30522,
3853,
17552,
10606,
29418,
10649,
1006,
5622,
1010,
2969,
1010,
2951,
1007,
1063,
1013,
1013,
7782,
1996,
10349,
3793,
9530,
3367,
1063,
4653,
18209,
1010,
6903,
1065,
1027,
2951,
1025,
9530,
3367,
4417,
18442,
1027,
5672,
24415,
262... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/EditorCommandHandlers.js | _getLineCommentPrefixSuffixEdit | function _getLineCommentPrefixSuffixEdit(editor, prefix, suffix, lineSel, command) {
var sel = lineSel.selectionForEdit;
// For one-line selections, we shrink the selection to exclude the trailing newline.
if (sel.end.line === sel.start.line + 1 && sel.end.ch === 0) {
sel.end = {line: sel.start.line, ch: editor.document.getLine(sel.start.line).length};
}
// Now just run the standard block comment code, but make sure to track any associated selections
// that were subsumed into this line selection.
return _getBlockCommentPrefixSuffixEdit(editor, prefix, suffix, [], sel, lineSel.selectionsToTrack, command);
} | javascript | function _getLineCommentPrefixSuffixEdit(editor, prefix, suffix, lineSel, command) {
var sel = lineSel.selectionForEdit;
// For one-line selections, we shrink the selection to exclude the trailing newline.
if (sel.end.line === sel.start.line + 1 && sel.end.ch === 0) {
sel.end = {line: sel.start.line, ch: editor.document.getLine(sel.start.line).length};
}
// Now just run the standard block comment code, but make sure to track any associated selections
// that were subsumed into this line selection.
return _getBlockCommentPrefixSuffixEdit(editor, prefix, suffix, [], sel, lineSel.selectionsToTrack, command);
} | [
"function",
"_getLineCommentPrefixSuffixEdit",
"(",
"editor",
",",
"prefix",
",",
"suffix",
",",
"lineSel",
",",
"command",
")",
"{",
"var",
"sel",
"=",
"lineSel",
".",
"selectionForEdit",
";",
"// For one-line selections, we shrink the selection to exclude the trailing new... | Generates an edit that adds or removes block-comment tokens to the selection, preserving selection
and cursor position. Applies to the currently focused Editor. The selection must already be a
line selection in the form returned by `Editor.convertToLineSelections()`.
The implementation uses blockCommentPrefixSuffix, with the exception of the case where
there is no selection on a uncommented and not empty line. In this case the whole lines gets
commented in a block-comment.
@param {!Editor} editor
@param {!String} prefix
@param {!String} suffix
@param {!{selectionForEdit: {start:{line:number, ch:number}, end:{line:number, ch:number}, reversed:boolean, primary:boolean},
selectionsToTrack: Array.<{start:{line:number, ch:number}, end:{line:number, ch:number}, reversed:boolean, primary:boolean}>}}
lineSel A line selection as returned from `Editor.convertToLineSelections()`. `selectionForEdit` is the selection to perform
the line comment operation on, and `selectionsToTrack` are a set of selections associated with this line that need to be
tracked through the edit.
@param {String} command The command callee. It cans be "line" or "block".
@return {{edit: {text: string, start:{line: number, ch: number}, end:?{line: number, ch: number}}|Array.<{text: string, start:{line: number, ch: number}, end:?{line: number, ch: number}}>,
selection: {start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean, isBeforeEdit: boolean}>}|
Array.<{start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean, isBeforeEdit: boolean}>}}
An edit description suitable for including in the edits array passed to `Document.doMultipleEdits()`. | [
"Generates",
"an",
"edit",
"that",
"adds",
"or",
"removes",
"block",
"-",
"comment",
"tokens",
"to",
"the",
"selection",
"preserving",
"selection",
"and",
"cursor",
"position",
".",
"Applies",
"to",
"the",
"currently",
"focused",
"Editor",
".",
"The",
"selecti... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L624-L635 | train | This function is called by the lineEdit function to get the comment for a line. | [
30522,
3853,
1035,
2131,
4179,
9006,
3672,
28139,
8873,
2595,
6342,
26989,
19068,
4183,
1006,
3559,
1010,
17576,
1010,
16809,
1010,
3210,
2884,
1010,
3094,
1007,
1063,
13075,
7367,
2140,
1027,
3210,
2884,
1012,
4989,
29278,
2098,
4183,
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... |
uber/deck.gl | modules/json/src/parsers/convert-json.js | enhancedFetch | function enhancedFetch(url) {
/* global fetch */
return fetch(url)
.then(response => response.text())
.then(text => {
try {
return JSON.parse(text);
} catch (error) {
return parseCSV(text);
}
});
} | javascript | function enhancedFetch(url) {
/* global fetch */
return fetch(url)
.then(response => response.text())
.then(text => {
try {
return JSON.parse(text);
} catch (error) {
return parseCSV(text);
}
});
} | [
"function",
"enhancedFetch",
"(",
"url",
")",
"{",
"/* global fetch */",
"return",
"fetch",
"(",
"url",
")",
".",
"then",
"(",
"response",
"=>",
"response",
".",
"text",
"(",
")",
")",
".",
"then",
"(",
"text",
"=>",
"{",
"try",
"{",
"return",
"JSON",
... | HELPERS | [
"HELPERS"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/json/src/parsers/convert-json.js#L149-L160 | train | Enhanced fetch function | [
30522,
3853,
9412,
7959,
10649,
1006,
24471,
2140,
1007,
1063,
1013,
1008,
3795,
18584,
1008,
1013,
2709,
18584,
1006,
24471,
2140,
1007,
1012,
2059,
1006,
3433,
1027,
1028,
3433,
1012,
3793,
1006,
1007,
1007,
1012,
2059,
1006,
3793,
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/project/FileTreeViewModel.js | _deleteAtPath | function _deleteAtPath(treeData, path) {
var objectPath = _filePathToObjectPath(treeData, path);
if (!objectPath) {
return;
}
var originalName = _.last(objectPath);
// Back up to the parent directory
objectPath.pop();
treeData = treeData.updateIn(objectPath, function (directory) {
directory = directory.delete(originalName);
return directory;
});
return treeData;
} | javascript | function _deleteAtPath(treeData, path) {
var objectPath = _filePathToObjectPath(treeData, path);
if (!objectPath) {
return;
}
var originalName = _.last(objectPath);
// Back up to the parent directory
objectPath.pop();
treeData = treeData.updateIn(objectPath, function (directory) {
directory = directory.delete(originalName);
return directory;
});
return treeData;
} | [
"function",
"_deleteAtPath",
"(",
"treeData",
",",
"path",
")",
"{",
"var",
"objectPath",
"=",
"_filePathToObjectPath",
"(",
"treeData",
",",
"path",
")",
";",
"if",
"(",
"!",
"objectPath",
")",
"{",
"return",
";",
"}",
"var",
"originalName",
"=",
"_",
"... | @private
See FileTreeViewModel.deleteAtPath | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeViewModel.js#L936-L954 | train | Delete a file at the given path | [
30522,
3853,
1035,
3972,
12870,
4017,
15069,
1006,
3392,
2850,
2696,
1010,
4130,
1007,
1063,
13075,
4874,
15069,
1027,
1035,
5371,
15069,
3406,
16429,
20614,
15069,
1006,
3392,
2850,
2696,
1010,
4130,
1007,
1025,
2065,
1006,
999,
4874,
1506... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(oQueryResult, oAssociation) {
this._oQueryResult = oQueryResult;
var sQAssocName = this._oEntityType.getSchema().namespace + "." + oAssociation.name;
var aNavProp = this._oEntityType.getTypeDescription().navigationProperty;
if (!aNavProp) {
throw "Invalid consumption model: Parameters entity type lacks navigation property for association to query result entity type";
}
for (var i = -1, oNavProp; (oNavProp = aNavProp[++i]) !== undefined;) {
if (oNavProp.relationship == sQAssocName) {
this._oNavPropToQueryResult = oNavProp.name;
}
}
if (!this._oNavPropToQueryResult) {
throw "Invalid consumption model: Parameters entity type lacks navigation property for association to query result entity type";
}
} | javascript | function(oQueryResult, oAssociation) {
this._oQueryResult = oQueryResult;
var sQAssocName = this._oEntityType.getSchema().namespace + "." + oAssociation.name;
var aNavProp = this._oEntityType.getTypeDescription().navigationProperty;
if (!aNavProp) {
throw "Invalid consumption model: Parameters entity type lacks navigation property for association to query result entity type";
}
for (var i = -1, oNavProp; (oNavProp = aNavProp[++i]) !== undefined;) {
if (oNavProp.relationship == sQAssocName) {
this._oNavPropToQueryResult = oNavProp.name;
}
}
if (!this._oNavPropToQueryResult) {
throw "Invalid consumption model: Parameters entity type lacks navigation property for association to query result entity type";
}
} | [
"function",
"(",
"oQueryResult",
",",
"oAssociation",
")",
"{",
"this",
".",
"_oQueryResult",
"=",
"oQueryResult",
";",
"var",
"sQAssocName",
"=",
"this",
".",
"_oEntityType",
".",
"getSchema",
"(",
")",
".",
"namespace",
"+",
"\".\"",
"+",
"oAssociation",
"... | to be called only by Model objects | [
"to",
"be",
"called",
"only",
"by",
"Model",
"objects"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L1291-L1306 | train | Sets the query result for the given association | [
30522,
3853,
1006,
1051,
4226,
2854,
6072,
11314,
1010,
1051,
12054,
10085,
18963,
1007,
1063,
2023,
1012,
1035,
1051,
4226,
2854,
6072,
11314,
1027,
1051,
4226,
2854,
6072,
11314,
1025,
13075,
5490,
12054,
10085,
18442,
1027,
2023,
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... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable) {
var oInfo = TableUtils.getFocusedItemInfo(oTable);
return oInfo.row - TableUtils.getHeaderRowCount(oTable);
} | javascript | function(oTable) {
var oInfo = TableUtils.getFocusedItemInfo(oTable);
return oInfo.row - TableUtils.getHeaderRowCount(oTable);
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oInfo",
"=",
"TableUtils",
".",
"getFocusedItemInfo",
"(",
"oTable",
")",
";",
"return",
"oInfo",
".",
"row",
"-",
"TableUtils",
".",
"getHeaderRowCount",
"(",
"oTable",
")",
";",
"}"
] | Returns the index of the row (in the rows aggregation) of the current focused cell.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {int} The row index. | [
"Returns",
"the",
"index",
"of",
"the",
"row",
"(",
"in",
"the",
"rows",
"aggregation",
")",
"of",
"the",
"current",
"focused",
"cell",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L653-L656 | train | Returns the index of the last focused item in the table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
1051,
2378,
14876,
1027,
2795,
21823,
4877,
1012,
2131,
14876,
7874,
2098,
4221,
10020,
14876,
1006,
27178,
3085,
1007,
1025,
2709,
1051,
2378,
14876,
1012,
5216,
1011,
2795,
21823,
4877,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/indent-legacy.js | isWrappedInParenthesis | function isWrappedInParenthesis(node) {
const regex = /^return\s*?\(\s*?\);*?/u;
const statementWithoutArgument = sourceCode.getText(node).replace(
sourceCode.getText(node.argument), ""
);
return regex.test(statementWithoutArgument);
} | javascript | function isWrappedInParenthesis(node) {
const regex = /^return\s*?\(\s*?\);*?/u;
const statementWithoutArgument = sourceCode.getText(node).replace(
sourceCode.getText(node.argument), ""
);
return regex.test(statementWithoutArgument);
} | [
"function",
"isWrappedInParenthesis",
"(",
"node",
")",
"{",
"const",
"regex",
"=",
"/",
"^return\\s*?\\(\\s*?\\);*?",
"/",
"u",
";",
"const",
"statementWithoutArgument",
"=",
"sourceCode",
".",
"getText",
"(",
"node",
")",
".",
"replace",
"(",
"sourceCode",
"."... | Checks wether a return statement is wrapped in ()
@param {ASTNode} node node to examine
@returns {boolean} the result | [
"Checks",
"wether",
"a",
"return",
"statement",
"is",
"wrapped",
"in",
"()"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L977-L985 | train | Check if node is wrapped in parentheses | [
30522,
3853,
2003,
13088,
29098,
2098,
2378,
19362,
4765,
24124,
1006,
13045,
1007,
1063,
9530,
3367,
19723,
10288,
1027,
1013,
1034,
2709,
1032,
1055,
1008,
1029,
1032,
1006,
1032,
1055,
1008,
1029,
1032,
1007,
1025,
1008,
1029,
1013,
1057... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/graphic/Displayable.js | function (x, y) {
var coord = this.transformCoordToLocal(x, y);
var rect = this.getBoundingRect();
return rect.contain(coord[0], coord[1]);
} | javascript | function (x, y) {
var coord = this.transformCoordToLocal(x, y);
var rect = this.getBoundingRect();
return rect.contain(coord[0], coord[1]);
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"coord",
"=",
"this",
".",
"transformCoordToLocal",
"(",
"x",
",",
"y",
")",
";",
"var",
"rect",
"=",
"this",
".",
"getBoundingRect",
"(",
")",
";",
"return",
"rect",
".",
"contain",
"(",
"coord",
"[... | 判断坐标 x, y 是否在图形的包围盒上
If bounding rect of element contain coord x, y
@param {number} x
@param {number} y
@return {boolean} | [
"判断坐标",
"x",
"y",
"是否在图形的包围盒上",
"If",
"bounding",
"rect",
"of",
"element",
"contain",
"coord",
"x",
"y"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/graphic/Displayable.js#L200-L204 | train | Returns true if the given coordinates are within the current region of the image | [
30522,
3853,
1006,
1060,
1010,
1061,
1007,
1063,
13075,
2522,
8551,
1027,
2023,
1012,
10938,
3597,
8551,
3406,
4135,
9289,
1006,
1060,
1010,
1061,
1007,
1025,
13075,
28667,
2102,
1027,
2023,
1012,
2131,
15494,
2075,
2890,
6593,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/token-store/index.js | createCursorWithCount | function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
let includeComments = false;
let count = 0;
let countExists = false;
let filter = null;
if (typeof opts === "number") {
count = opts | 0;
countExists = true;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
count = opts.count | 0;
countExists = typeof opts.count === "number";
filter = opts.filter || null;
}
assert(count >= 0, "options.count should be zero or a positive integer.");
assert(!filter || typeof filter === "function", "options.filter should be a function.");
return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
} | javascript | function createCursorWithCount(factory, tokens, comments, indexMap, startLoc, endLoc, opts) {
let includeComments = false;
let count = 0;
let countExists = false;
let filter = null;
if (typeof opts === "number") {
count = opts | 0;
countExists = true;
} else if (typeof opts === "function") {
filter = opts;
} else if (opts) {
includeComments = !!opts.includeComments;
count = opts.count | 0;
countExists = typeof opts.count === "number";
filter = opts.filter || null;
}
assert(count >= 0, "options.count should be zero or a positive integer.");
assert(!filter || typeof filter === "function", "options.filter should be a function.");
return factory.createCursor(tokens, comments, indexMap, startLoc, endLoc, includeComments, filter, 0, countExists ? count : -1);
} | [
"function",
"createCursorWithCount",
"(",
"factory",
",",
"tokens",
",",
"comments",
",",
"indexMap",
",",
"startLoc",
",",
"endLoc",
",",
"opts",
")",
"{",
"let",
"includeComments",
"=",
"false",
";",
"let",
"count",
"=",
"0",
";",
"let",
"countExists",
"... | Creates the cursor iterates tokens with options.
@param {CursorFactory} factory - The cursor factory to initialize cursor.
@param {Token[]} tokens - The array of tokens.
@param {Comment[]} comments - The array of comments.
@param {Object} indexMap - The map from locations to indices in `tokens`.
@param {number} startLoc - The start location of the iteration range.
@param {number} endLoc - The end location of the iteration range.
@param {number|Function|Object} [opts=0] - The option object. If this is a number then it's `opts.count`. If this is a function then it's `opts.filter`.
@param {boolean} [opts.includeComments] - The flag to iterate comments as well.
@param {Function|null} [opts.filter=null] - The predicate function to choose tokens.
@param {number} [opts.count=0] - The maximum count of tokens the cursor iterates. Zero is no iteration for backward compatibility.
@returns {Cursor} The created cursor.
@private | [
"Creates",
"the",
"cursor",
"iterates",
"tokens",
"with",
"options",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/token-store/index.js#L115-L136 | train | Creates a new cursor with a given number of tokens | [
30522,
3853,
3443,
10841,
25301,
2099,
24415,
3597,
16671,
1006,
4713,
1010,
19204,
2015,
1010,
7928,
1010,
5950,
2863,
2361,
1010,
2707,
4135,
2278,
1010,
2203,
4135,
2278,
1010,
23569,
2015,
1007,
1063,
2292,
2421,
9006,
8163,
1027,
6270,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_vertical/event.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_variable",
"name": "BROADCAST_OPTION",
"variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
}
],
"colour": Blockly.Colours.event.secondary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"extensions": ["output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_variable",
"name": "BROADCAST_OPTION",
"variableTypes":[Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE],
"variable": Blockly.Msg.DEFAULT_BROADCAST_MESSAGE_NAME
}
],
"colour": Blockly.Colours.event.secondary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"extensions": ["output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_variable\"",
",",
"\"name\"",
":",
"\"BROADCAST_OPTION\"",
",",
"\"variableTypes\"",
":",
"[",
"Blockly",
... | Broadcast drop-down menu.
@this Blockly.Block | [
"Broadcast",
"drop",
"-",
"down",
"menu",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/event.js#L205-L221 | train | Block for
. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
1000,
1003,
1015,
1000,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
1000,
2828,
1000,
1024,
1000,
2492,
1035,
8023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | get_get_computed_style_function | function get_get_computed_style_function(element) {
// The proper getComputedStyle implementation is the one defined in the element window
if(element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;
// If it is not available, try to get one from the global namespace
if(typeof getComputedStyle === 'function') return getComputedStyle;
return null;
} | javascript | function get_get_computed_style_function(element) {
// The proper getComputedStyle implementation is the one defined in the element window
if(element.ownerDocument.defaultView && typeof element.ownerDocument.defaultView.getComputedStyle === 'function') return element.ownerDocument.defaultView.getComputedStyle;
// If it is not available, try to get one from the global namespace
if(typeof getComputedStyle === 'function') return getComputedStyle;
return null;
} | [
"function",
"get_get_computed_style_function",
"(",
"element",
")",
"{",
"// The proper getComputedStyle implementation is the one defined in the element window",
"if",
"(",
"element",
".",
"ownerDocument",
".",
"defaultView",
"&&",
"typeof",
"element",
".",
"ownerDocument",
".... | /* global getComputedStyle | [
"/",
"*",
"global",
"getComputedStyle"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L19024-L19030 | train | Get computed style function | [
30522,
3853,
2131,
1035,
2131,
1035,
24806,
1035,
2806,
1035,
3853,
1006,
5783,
1007,
1063,
1013,
1013,
1996,
5372,
2131,
9006,
29462,
21756,
2571,
7375,
2003,
1996,
2028,
4225,
1999,
1996,
5783,
3332,
2065,
1006,
5783,
1012,
3954,
3527,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.codeeditor/src/sap/ui/codeeditor/js/ace/ace.js | function(parentId, module, callback) {
if (typeof module === "string") {
var payload = lookup(parentId, module);
if (payload != undefined) {
callback && callback();
return payload;
}
} else if (Object.prototype.toString.call(module) === "[object Array]") {
var params = [];
for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]);
if (dep == undefined && require.original)
return;
params.push(dep);
}
return callback && callback.apply(null, params) || true;
}
} | javascript | function(parentId, module, callback) {
if (typeof module === "string") {
var payload = lookup(parentId, module);
if (payload != undefined) {
callback && callback();
return payload;
}
} else if (Object.prototype.toString.call(module) === "[object Array]") {
var params = [];
for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]);
if (dep == undefined && require.original)
return;
params.push(dep);
}
return callback && callback.apply(null, params) || true;
}
} | [
"function",
"(",
"parentId",
",",
"module",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"module",
"===",
"\"string\"",
")",
"{",
"var",
"payload",
"=",
"lookup",
"(",
"parentId",
",",
"module",
")",
";",
"if",
"(",
"payload",
"!=",
"undefined",
")"... | Get at functionality define()ed using the function above | [
"Get",
"at",
"functionality",
"define",
"()",
"ed",
"using",
"the",
"function",
"above"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.codeeditor/src/sap/ui/codeeditor/js/ace/ace.js#L73-L90 | train | returns the payload of a module | [
30522,
3853,
1006,
6687,
3593,
1010,
11336,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
2828,
11253,
11336,
1027,
1027,
1027,
1000,
5164,
1000,
1007,
1063,
13075,
18093,
1027,
2298,
6279,
1006,
6687,
3593,
1010,
11336,
1007,
1025,
2065,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.