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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
uber/deck.gl | modules/core/src/utils/old-log.js | checkForAssertionErrors | function checkForAssertionErrors(args) {
const isAssertion =
args &&
args.length > 0 &&
typeof args[0] === 'object' &&
args[0] !== null &&
args[0].name === 'AssertionError';
if (isAssertion) {
args = Array.prototype.slice.call(args);
args.unshift(`assert(${args[0].message})`);
}
return args;
} | javascript | function checkForAssertionErrors(args) {
const isAssertion =
args &&
args.length > 0 &&
typeof args[0] === 'object' &&
args[0] !== null &&
args[0].name === 'AssertionError';
if (isAssertion) {
args = Array.prototype.slice.call(args);
args.unshift(`assert(${args[0].message})`);
}
return args;
} | [
"function",
"checkForAssertionErrors",
"(",
"args",
")",
"{",
"const",
"isAssertion",
"=",
"args",
"&&",
"args",
".",
"length",
">",
"0",
"&&",
"typeof",
"args",
"[",
"0",
"]",
"===",
"'object'",
"&&",
"args",
"[",
"0",
"]",
"!==",
"null",
"&&",
"args"... | Assertions don't generate standard exceptions and don't print nicely | [
"Assertions",
"don",
"t",
"generate",
"standard",
"exceptions",
"and",
"don",
"t",
"print",
"nicely"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/utils/old-log.js#L127-L140 | train | Check if an error is thrown | [
30522,
3853,
4638,
29278,
27241,
28228,
5643,
18933,
2869,
1006,
12098,
5620,
1007,
1063,
9530,
3367,
18061,
18116,
3508,
1027,
12098,
5620,
1004,
1004,
12098,
5620,
1012,
3091,
1028,
1014,
1004,
1004,
2828,
11253,
12098,
5620,
1031,
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... |
eslint/eslint | lib/rules/semi-spacing.js | isFirstTokenInCurrentLine | function isFirstTokenInCurrentLine(token) {
const tokenBefore = sourceCode.getTokenBefore(token);
return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
} | javascript | function isFirstTokenInCurrentLine(token) {
const tokenBefore = sourceCode.getTokenBefore(token);
return !(tokenBefore && astUtils.isTokenOnSameLine(token, tokenBefore));
} | [
"function",
"isFirstTokenInCurrentLine",
"(",
"token",
")",
"{",
"const",
"tokenBefore",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"token",
")",
";",
"return",
"!",
"(",
"tokenBefore",
"&&",
"astUtils",
".",
"isTokenOnSameLine",
"(",
"token",
",",
"tokenBef... | Checks if the given token is the first token in its line
@param {Token} token The token to check.
@returns {boolean} Whether or not the token is the first in its line. | [
"Checks",
"if",
"the",
"given",
"token",
"is",
"the",
"first",
"token",
"in",
"its",
"line"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-spacing.js#L95-L99 | train | Check if the given token is the first token in the current line | [
30522,
3853,
2003,
8873,
12096,
18715,
18595,
12273,
29264,
4179,
1006,
19204,
1007,
1063,
9530,
3367,
19204,
4783,
29278,
2063,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
19204,
1007,
1025,
2709,
999,
1006,
19204,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/geometry.js | function (data) {
var cache = this.cache;
var cachedGeometry;
var hash;
// Skip all caching logic.
if (data.skipCache) { return createGeometry(data); }
// Try to retrieve from cache first.
hash = this.hash(data);
cachedGeometry = cache[hash];
incrementCacheCount(this.cacheCount, hash);
if (cachedGeometry) { return cachedGeometry; }
// Create geometry.
cachedGeometry = createGeometry(data);
// Cache and return geometry.
cache[hash] = cachedGeometry;
return cachedGeometry;
} | javascript | function (data) {
var cache = this.cache;
var cachedGeometry;
var hash;
// Skip all caching logic.
if (data.skipCache) { return createGeometry(data); }
// Try to retrieve from cache first.
hash = this.hash(data);
cachedGeometry = cache[hash];
incrementCacheCount(this.cacheCount, hash);
if (cachedGeometry) { return cachedGeometry; }
// Create geometry.
cachedGeometry = createGeometry(data);
// Cache and return geometry.
cache[hash] = cachedGeometry;
return cachedGeometry;
} | [
"function",
"(",
"data",
")",
"{",
"var",
"cache",
"=",
"this",
".",
"cache",
";",
"var",
"cachedGeometry",
";",
"var",
"hash",
";",
"// Skip all caching logic.",
"if",
"(",
"data",
".",
"skipCache",
")",
"{",
"return",
"createGeometry",
"(",
"data",
")",
... | Attempt to retrieve from cache.
@returns {Object|null} A geometry if it exists, else null. | [
"Attempt",
"to",
"retrieve",
"from",
"cache",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/geometry.js#L32-L53 | train | Returns geometry from cache | [
30522,
3853,
1006,
2951,
1007,
1063,
13075,
17053,
1027,
2023,
1012,
17053,
1025,
13075,
17053,
11818,
8462,
11129,
1025,
13075,
23325,
1025,
1013,
1013,
13558,
2035,
6187,
8450,
7961,
1012,
2065,
1006,
2951,
1012,
13558,
3540,
5403,
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... | |
airyland/vux | src/components/video/zy.media.js | function() {
var t = this;
var loading = document.createElement('div');
loading.className = 'dec_loading';
loading.style.display = 'none';
t.container.appendChild(loading);
var error = document.createElement('div');
error.className = 'dec_error';
error.style.display = 'none';
error.innerHTML = '播放异常';
t.container.appendChild(error);
var bigPlay = document.createElement('div');
if (!zyMedia.features.isVendorBigPlay) {
bigPlay.className = 'dec_play';
t.container.appendChild(bigPlay);
bigPlay.addEventListener('click', function() {
// For some device trigger 'play' event
t.media.isUserClick = true;
t.media.play();
// Controls bar auto hide after 3s
if (!t.media.paused && !t.options.alwaysShowControls) {
t.setControlsTimer(3000)
}
});
}
t.media.addEventListener('play', function() {
// Only for user click
if (t.media.isUserClick) {
bigPlay.style.display = 'none';
loading.style.display = '';
t.buffering.style.display = 'none'
}
});
t.media.addEventListener('playing', function() {
bigPlay.style.display = 'none';
loading.style.display = 'none';
t.buffering.style.display = 'none';
error.style.display = 'none';
});
t.media.addEventListener('seeking', function() {
loading.style.display = '';
bigPlay.style.display = 'none';
t.buffering.style.display = '';
});
t.media.addEventListener('seeked', function() {
loading.style.display = 'none';
t.buffering.style.display = 'none';
});
t.media.addEventListener('pause', function() {
bigPlay.style.display = ''
});
t.media.addEventListener('waiting', function() {
loading.style.display = '';
bigPlay.style.display = 'none';
t.buffering.style.display = '';
});
// Don't listen to 'loadeddata' and 'canplay',
// some Android device can't fire 'canplay' or irregular working when use 'createEvent' to trigger 'canplay' (读者i800)
// Error handling
t.media.addEventListener('error', function(e) {
loading.style.display = 'none';
bigPlay.style.display = '';
t.buffering.style.display = 'none';
t.media.pause();
error.style.display = '';
if (typeof t.options.error == 'function') {
t.options.error(e);
}
});
} | javascript | function() {
var t = this;
var loading = document.createElement('div');
loading.className = 'dec_loading';
loading.style.display = 'none';
t.container.appendChild(loading);
var error = document.createElement('div');
error.className = 'dec_error';
error.style.display = 'none';
error.innerHTML = '播放异常';
t.container.appendChild(error);
var bigPlay = document.createElement('div');
if (!zyMedia.features.isVendorBigPlay) {
bigPlay.className = 'dec_play';
t.container.appendChild(bigPlay);
bigPlay.addEventListener('click', function() {
// For some device trigger 'play' event
t.media.isUserClick = true;
t.media.play();
// Controls bar auto hide after 3s
if (!t.media.paused && !t.options.alwaysShowControls) {
t.setControlsTimer(3000)
}
});
}
t.media.addEventListener('play', function() {
// Only for user click
if (t.media.isUserClick) {
bigPlay.style.display = 'none';
loading.style.display = '';
t.buffering.style.display = 'none'
}
});
t.media.addEventListener('playing', function() {
bigPlay.style.display = 'none';
loading.style.display = 'none';
t.buffering.style.display = 'none';
error.style.display = 'none';
});
t.media.addEventListener('seeking', function() {
loading.style.display = '';
bigPlay.style.display = 'none';
t.buffering.style.display = '';
});
t.media.addEventListener('seeked', function() {
loading.style.display = 'none';
t.buffering.style.display = 'none';
});
t.media.addEventListener('pause', function() {
bigPlay.style.display = ''
});
t.media.addEventListener('waiting', function() {
loading.style.display = '';
bigPlay.style.display = 'none';
t.buffering.style.display = '';
});
// Don't listen to 'loadeddata' and 'canplay',
// some Android device can't fire 'canplay' or irregular working when use 'createEvent' to trigger 'canplay' (读者i800)
// Error handling
t.media.addEventListener('error', function(e) {
loading.style.display = 'none';
bigPlay.style.display = '';
t.buffering.style.display = 'none';
t.media.pause();
error.style.display = '';
if (typeof t.options.error == 'function') {
t.options.error(e);
}
});
} | [
"function",
"(",
")",
"{",
"var",
"t",
"=",
"this",
";",
"var",
"loading",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"loading",
".",
"className",
"=",
"'dec_loading'",
";",
"loading",
".",
"style",
".",
"display",
"=",
"'none'",
";... | bigPlay, loading and error info | [
"bigPlay",
"loading",
"and",
"error",
"info"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/video/zy.media.js#L738-L821 | train | Creates the popup | [
30522,
3853,
1006,
1007,
1063,
13075,
1056,
1027,
2023,
1025,
13075,
10578,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
10578,
1012,
2465,
18442,
1027,
1005,
11703,
1035,
10578,
1005,
1025,
10578,
1012,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-implicit-coercion.js | isEmptyString | function isEmptyString(node) {
return astUtils.isStringLiteral(node) && (node.value === "" || (node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === ""));
} | javascript | function isEmptyString(node) {
return astUtils.isStringLiteral(node) && (node.value === "" || (node.type === "TemplateLiteral" && node.quasis.length === 1 && node.quasis[0].value.cooked === ""));
} | [
"function",
"isEmptyString",
"(",
"node",
")",
"{",
"return",
"astUtils",
".",
"isStringLiteral",
"(",
"node",
")",
"&&",
"(",
"node",
".",
"value",
"===",
"\"\"",
"||",
"(",
"node",
".",
"type",
"===",
"\"TemplateLiteral\"",
"&&",
"node",
".",
"quasis",
... | Checks whether a node is an empty string literal or not.
@param {ASTNode} node The node to check.
@returns {boolean} Whether or not the passed in node is an
empty string literal or not. | [
"Checks",
"whether",
"a",
"node",
"is",
"an",
"empty",
"string",
"literal",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L115-L117 | train | Returns true if node is empty string | [
30522,
3853,
2003,
6633,
13876,
27268,
4892,
1006,
13045,
1007,
1063,
2709,
2004,
8525,
3775,
4877,
1012,
26354,
18886,
3070,
22779,
7941,
1006,
13045,
1007,
1004,
1004,
1006,
13045,
1012,
3643,
1027,
1027,
1027,
1000,
1000,
1064,
1064,
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... |
nhn/tui.editor | src/js/wysiwygCommands/tableAddCol.js | focusToNextCell | function focusToNextCell(sq, $cell) {
const range = sq.getSelection();
range.selectNodeContents($cell.next()[0]);
range.collapse(true);
sq.setSelection(range);
} | javascript | function focusToNextCell(sq, $cell) {
const range = sq.getSelection();
range.selectNodeContents($cell.next()[0]);
range.collapse(true);
sq.setSelection(range);
} | [
"function",
"focusToNextCell",
"(",
"sq",
",",
"$cell",
")",
"{",
"const",
"range",
"=",
"sq",
".",
"getSelection",
"(",
")",
";",
"range",
".",
"selectNodeContents",
"(",
"$cell",
".",
"next",
"(",
")",
"[",
"0",
"]",
")",
";",
"range",
".",
"collap... | Focus to next cell
@param {Squire} sq - Squire instance
@param {jQuery} $cell - jQuery wrapped table cell
@ignore | [
"Focus",
"to",
"next",
"cell"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableAddCol.js#L114-L121 | train | Focus to next cell | [
30522,
3853,
3579,
5524,
18413,
29109,
2140,
1006,
5490,
1010,
1002,
3526,
1007,
1063,
9530,
3367,
2846,
1027,
5490,
1012,
4152,
12260,
7542,
1006,
1007,
1025,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-fallthrough.js | hasFallthroughComment | function hasFallthroughComment(node, context, fallthroughCommentPattern) {
const sourceCode = context.getSourceCode();
const comment = lodash.last(sourceCode.getCommentsBefore(node));
return Boolean(comment && fallthroughCommentPattern.test(comment.value));
} | javascript | function hasFallthroughComment(node, context, fallthroughCommentPattern) {
const sourceCode = context.getSourceCode();
const comment = lodash.last(sourceCode.getCommentsBefore(node));
return Boolean(comment && fallthroughCommentPattern.test(comment.value));
} | [
"function",
"hasFallthroughComment",
"(",
"node",
",",
"context",
",",
"fallthroughCommentPattern",
")",
"{",
"const",
"sourceCode",
"=",
"context",
".",
"getSourceCode",
"(",
")",
";",
"const",
"comment",
"=",
"lodash",
".",
"last",
"(",
"sourceCode",
".",
"g... | Checks whether or not a given node has a fallthrough comment.
@param {ASTNode} node - A SwitchCase node to get comments.
@param {RuleContext} context - A rule context which stores comments.
@param {RegExp} fallthroughCommentPattern - A pattern to match comment to.
@returns {boolean} `true` if the node has a valid fallthrough comment. | [
"Checks",
"whether",
"or",
"not",
"a",
"given",
"node",
"has",
"a",
"fallthrough",
"comment",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-fallthrough.js#L26-L31 | train | Checks if a node has a fallthrough comment | [
30522,
3853,
2038,
13976,
2705,
22494,
5603,
9006,
3672,
1006,
13045,
1010,
6123,
1010,
2991,
2705,
22494,
5603,
9006,
3672,
4502,
12079,
2078,
1007,
1063,
9530,
3367,
3120,
16044,
1027,
6123,
1012,
4152,
8162,
3401,
16044,
1006,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
marcuswestin/store.js | plugins/operations.js | push | function push(_, key, val1, val2, val3, etc) {
return _arrayOp.call(this, 'push', arguments)
} | javascript | function push(_, key, val1, val2, val3, etc) {
return _arrayOp.call(this, 'push', arguments)
} | [
"function",
"push",
"(",
"_",
",",
"key",
",",
"val1",
",",
"val2",
",",
"val3",
",",
"etc",
")",
"{",
"return",
"_arrayOp",
".",
"call",
"(",
"this",
",",
"'push'",
",",
"arguments",
")",
"}"
] | array | [
"array"
] | b8e22fea8738fc19da4d9e7dbf1cda6e5185c481 | https://github.com/marcuswestin/store.js/blob/b8e22fea8738fc19da4d9e7dbf1cda6e5185c481/plugins/operations.js#L22-L24 | train | push a value to the end of the array | [
30522,
3853,
5245,
1006,
1035,
1010,
3145,
1010,
11748,
2487,
1010,
11748,
2475,
1010,
11748,
2509,
1010,
4385,
1007,
1063,
2709,
1035,
9140,
7361,
1012,
2655,
1006,
2023,
1010,
1005,
5245,
1005,
1010,
9918,
1007,
1065,
102,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/dialog/dialog.js | getDomElement | function getDomElement(element, defaultElement) {
if (angular.isString(element)) {
element = $document[0].querySelector(element);
}
// If we have a reference to a raw dom element, always wrap it in jqLite
return angular.element(element || defaultElement);
} | javascript | function getDomElement(element, defaultElement) {
if (angular.isString(element)) {
element = $document[0].querySelector(element);
}
// If we have a reference to a raw dom element, always wrap it in jqLite
return angular.element(element || defaultElement);
} | [
"function",
"getDomElement",
"(",
"element",
",",
"defaultElement",
")",
"{",
"if",
"(",
"angular",
".",
"isString",
"(",
"element",
")",
")",
"{",
"element",
"=",
"$document",
"[",
"0",
"]",
".",
"querySelector",
"(",
"element",
")",
";",
"}",
"// If we... | If the specifier is a simple string selector, then query for
the DOM element. | [
"If",
"the",
"specifier",
"is",
"a",
"simple",
"string",
"selector",
"then",
"query",
"for",
"the",
"DOM",
"element",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L935-L942 | train | Get the dom element | [
30522,
3853,
2131,
26173,
16930,
4765,
1006,
5783,
1010,
12398,
12260,
3672,
1007,
1063,
2065,
1006,
16108,
1012,
26354,
18886,
3070,
1006,
5783,
1007,
1007,
1063,
5783,
1027,
1002,
6254,
1031,
1014,
1033,
1012,
23032,
11246,
22471,
2953,
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... |
apache/incubator-echarts | src/chart/tree/layoutHelper.js | executeShifts | function executeShifts(node) {
var children = node.children;
var n = children.length;
var shift = 0;
var change = 0;
while (--n >= 0) {
var child = children[n];
child.hierNode.prelim += shift;
child.hierNode.modifier += shift;
change += child.hierNode.change;
shift += child.hierNode.shift + change;
}
} | javascript | function executeShifts(node) {
var children = node.children;
var n = children.length;
var shift = 0;
var change = 0;
while (--n >= 0) {
var child = children[n];
child.hierNode.prelim += shift;
child.hierNode.modifier += shift;
change += child.hierNode.change;
shift += child.hierNode.shift + change;
}
} | [
"function",
"executeShifts",
"(",
"node",
")",
"{",
"var",
"children",
"=",
"node",
".",
"children",
";",
"var",
"n",
"=",
"children",
".",
"length",
";",
"var",
"shift",
"=",
"0",
";",
"var",
"change",
"=",
"0",
";",
"while",
"(",
"--",
"n",
">=",... | All other shifts, applied to the smaller subtrees between w- and w+, are
performed by this function.
The implementation of this function was originally copied from "d3.js"
<https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
with some modifications made for this program.
See the license statement at the head of this file.
@param {module:echarts/data/Tree~TreeNode} node | [
"All",
"other",
"shifts",
"applied",
"to",
"the",
"smaller",
"subtrees",
"between",
"w",
"-",
"and",
"w",
"+",
"are",
"performed",
"by",
"this",
"function",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/layoutHelper.js#L185-L197 | train | Execute shifts of a node | [
30522,
3853,
15389,
6182,
6199,
2015,
1006,
13045,
1007,
1063,
13075,
2336,
1027,
13045,
1012,
2336,
1025,
13075,
1050,
1027,
2336,
1012,
3091,
1025,
13075,
5670,
1027,
1014,
1025,
13075,
2689,
1027,
1014,
1025,
2096,
1006,
1011,
1011,
1050... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/throttle.js | throttleable | function throttleable(duration, options) {
return function innerDecorator(target, key, descriptor) {
return {
configurable: true,
enumerable: descriptor.enumerable,
get: function getter() {
Object.defineProperty(this, key, {
configurable: true,
enumerable: descriptor.enumerable,
value: throttle(descriptor.value, duration, options)
});
return this[key];
}
};
};
} | javascript | function throttleable(duration, options) {
return function innerDecorator(target, key, descriptor) {
return {
configurable: true,
enumerable: descriptor.enumerable,
get: function getter() {
Object.defineProperty(this, key, {
configurable: true,
enumerable: descriptor.enumerable,
value: throttle(descriptor.value, duration, options)
});
return this[key];
}
};
};
} | [
"function",
"throttleable",
"(",
"duration",
",",
"options",
")",
"{",
"return",
"function",
"innerDecorator",
"(",
"target",
",",
"key",
",",
"descriptor",
")",
"{",
"return",
"{",
"configurable",
":",
"true",
",",
"enumerable",
":",
"descriptor",
".",
"enu... | Throttle decorator
class MyClass {
throttleable(10)
myFn() { ... }
} | [
"Throttle",
"decorator"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/throttle.js#L47-L62 | train | Creates a decorator that throttles the given duration of the resource. | [
30522,
3853,
24420,
3085,
1006,
9367,
1010,
7047,
1007,
1063,
2709,
3853,
5110,
3207,
27108,
8844,
1006,
4539,
1010,
3145,
1010,
4078,
23235,
2953,
1007,
1063,
2709,
1063,
9530,
8873,
27390,
3085,
1024,
2995,
1010,
4372,
17897,
16670,
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... |
zloirock/core-js | packages/core-js/modules/es.promise.js | race | function race(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var reject = capability.reject;
var result = perform(function () {
var $promiseResolve = aFunction(C.resolve);
iterate(iterable, function (promise) {
$promiseResolve.call(C, promise).then(capability.resolve, reject);
});
});
if (result.error) reject(result.value);
return capability.promise;
} | javascript | function race(iterable) {
var C = this;
var capability = newPromiseCapability(C);
var reject = capability.reject;
var result = perform(function () {
var $promiseResolve = aFunction(C.resolve);
iterate(iterable, function (promise) {
$promiseResolve.call(C, promise).then(capability.resolve, reject);
});
});
if (result.error) reject(result.value);
return capability.promise;
} | [
"function",
"race",
"(",
"iterable",
")",
"{",
"var",
"C",
"=",
"this",
";",
"var",
"capability",
"=",
"newPromiseCapability",
"(",
"C",
")",
";",
"var",
"reject",
"=",
"capability",
".",
"reject",
";",
"var",
"result",
"=",
"perform",
"(",
"function",
... | `Promise.race` method https://tc39.github.io/ecma262/#sec-promise.race | [
"Promise",
".",
"race",
"method",
"https",
":",
"//",
"tc39",
".",
"github",
".",
"io",
"/",
"ecma262",
"/",
"#sec",
"-",
"promise",
".",
"race"
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/modules/es.promise.js#L335-L347 | train | Returns a promise that resolves to the first promise in iterable. | [
30522,
3853,
2679,
1006,
2009,
6906,
3468,
1007,
1063,
13075,
1039,
1027,
2023,
1025,
13075,
10673,
1027,
2047,
21572,
28732,
17695,
8010,
1006,
1039,
1007,
1025,
13075,
15454,
1027,
10673,
1012,
15454,
1025,
13075,
2765,
1027,
4685,
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... |
eslint/eslint | lib/rules/multiline-comment-style.js | convertToBlock | function convertToBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const blockLines = commentLinesList.map(line => line.trim());
return `/* ${blockLines.join(`\n${initialOffset} `)} */`;
} | javascript | function convertToBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const blockLines = commentLinesList.map(line => line.trim());
return `/* ${blockLines.join(`\n${initialOffset} `)} */`;
} | [
"function",
"convertToBlock",
"(",
"firstComment",
",",
"commentLinesList",
")",
"{",
"const",
"initialOffset",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"firstComment",
".",
"range",
"[",
"0",
"]",
"-",
"firstComment",
".",
"loc",
".",
"start",
"."... | Converts a comment into bare-block form
@param {Token} firstComment The first comment of the group being converted
@param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
@returns {string} A representation of the comment value in bare-block form | [
"Converts",
"a",
"comment",
"into",
"bare",
"-",
"block",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L90-L95 | train | converts a comment to a block | [
30522,
3853,
10463,
3406,
23467,
1006,
2034,
9006,
3672,
1010,
7615,
12735,
9863,
1007,
1063,
9530,
3367,
3988,
27475,
3388,
1027,
3120,
16044,
1012,
3793,
1012,
14704,
1006,
2034,
9006,
3672,
1012,
2846,
1031,
1014,
1033,
1011,
2034,
9006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (elem)
{
if (elem.getAttribute("type") == "error") {
Strophe.info("SASL binding failed.");
var conflict = elem.getElementsByTagName("conflict"), condition;
if (conflict.length > 0) {
condition = 'conflict';
}
this._changeConnectStatus(Strophe.Status.AUTHFAIL, condition);
return false;
}
// TODO - need to grab errors
var bind = elem.getElementsByTagName("bind");
var jidNode;
if (bind.length > 0) {
// Grab jid
jidNode = bind[0].getElementsByTagName("jid");
if (jidNode.length > 0) {
this.jid = Strophe.getText(jidNode[0]);
if (this.do_session) {
this._addSysHandler(this._sasl_session_cb.bind(this),
null, null, null, "_session_auth_2");
this.send($iq({type: "set", id: "_session_auth_2"})
.c('session', {xmlns: Strophe.NS.SESSION})
.tree());
} else {
this.authenticated = true;
this._changeConnectStatus(Strophe.Status.CONNECTED, null);
}
}
} else {
Strophe.info("SASL binding failed.");
this._changeConnectStatus(Strophe.Status.AUTHFAIL, null);
return false;
}
} | javascript | function (elem)
{
if (elem.getAttribute("type") == "error") {
Strophe.info("SASL binding failed.");
var conflict = elem.getElementsByTagName("conflict"), condition;
if (conflict.length > 0) {
condition = 'conflict';
}
this._changeConnectStatus(Strophe.Status.AUTHFAIL, condition);
return false;
}
// TODO - need to grab errors
var bind = elem.getElementsByTagName("bind");
var jidNode;
if (bind.length > 0) {
// Grab jid
jidNode = bind[0].getElementsByTagName("jid");
if (jidNode.length > 0) {
this.jid = Strophe.getText(jidNode[0]);
if (this.do_session) {
this._addSysHandler(this._sasl_session_cb.bind(this),
null, null, null, "_session_auth_2");
this.send($iq({type: "set", id: "_session_auth_2"})
.c('session', {xmlns: Strophe.NS.SESSION})
.tree());
} else {
this.authenticated = true;
this._changeConnectStatus(Strophe.Status.CONNECTED, null);
}
}
} else {
Strophe.info("SASL binding failed.");
this._changeConnectStatus(Strophe.Status.AUTHFAIL, null);
return false;
}
} | [
"function",
"(",
"elem",
")",
"{",
"if",
"(",
"elem",
".",
"getAttribute",
"(",
"\"type\"",
")",
"==",
"\"error\"",
")",
"{",
"Strophe",
".",
"info",
"(",
"\"SASL binding failed.\"",
")",
";",
"var",
"conflict",
"=",
"elem",
".",
"getElementsByTagName",
"(... | PrivateFunction: _sasl_bind_cb
_Private_ handler for binding result and session start.
Parameters:
(XMLElement) elem - The matching stanza.
Returns:
false to remove the handler. | [
"PrivateFunction",
":",
"_sasl_bind_cb",
"_Private_",
"handler",
"for",
"binding",
"result",
"and",
"session",
"start",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L3252-L3290 | train | End of function
elib | [
30522,
3853,
30524,
12260,
8163,
3762,
15900,
18442,
1006,
1000,
4736,
1000,
1007,
1010,
4650,
1025,
2065,
1006,
4736,
1012,
3091,
1028,
1014,
1007,
1063,
4650,
1027,
1005,
4736,
1005,
1025,
1065,
2023,
1012,
1035,
2689,
8663,
2638,
16649,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/table/mergeCell.js | _initCellData | function _initCellData(targetRows, startColIndex, endColIndex) {
const limitColIndex = endColIndex + 1;
const targetCells = targetRows.map(rowData => rowData.slice(startColIndex, limitColIndex));
[].concat(...targetCells).slice(1).forEach(cellData => {
const {nodeName} = cellData;
util.forEach(cellData, (value, name) => (delete cellData[name]));
cellData.nodeName = nodeName;
});
} | javascript | function _initCellData(targetRows, startColIndex, endColIndex) {
const limitColIndex = endColIndex + 1;
const targetCells = targetRows.map(rowData => rowData.slice(startColIndex, limitColIndex));
[].concat(...targetCells).slice(1).forEach(cellData => {
const {nodeName} = cellData;
util.forEach(cellData, (value, name) => (delete cellData[name]));
cellData.nodeName = nodeName;
});
} | [
"function",
"_initCellData",
"(",
"targetRows",
",",
"startColIndex",
",",
"endColIndex",
")",
"{",
"const",
"limitColIndex",
"=",
"endColIndex",
"+",
"1",
";",
"const",
"targetCells",
"=",
"targetRows",
".",
"map",
"(",
"rowData",
"=>",
"rowData",
".",
"slice... | Initialize cell data of target rows.
@param {Array.<Array.<object>>} targetRows - target rows
@param {number} startColIndex - start column index
@param {number} endColIndex - end column index
@private | [
"Initialize",
"cell",
"data",
"of",
"target",
"rows",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/mergeCell.js#L79-L89 | train | Initialize cell data for the target cells | [
30522,
3853,
1035,
1999,
4183,
29109,
15150,
2696,
1006,
4539,
10524,
2015,
1010,
2707,
25778,
22254,
10288,
1010,
2203,
25778,
22254,
10288,
1007,
1063,
9530,
3367,
5787,
25778,
22254,
10288,
1027,
2203,
25778,
22254,
10288,
1009,
1015,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js | Requestor | function Requestor(sServiceUrl, mHeaders, mQueryParams, oModelInterface) {
this.mBatchQueue = {};
this.mHeaders = mHeaders || {};
this.oModelInterface = oModelInterface;
this.sQueryParams = _Helper.buildQuery(mQueryParams); // Used for $batch and CSRF token only
this.mRunningChangeRequests = {};
this.oSecurityTokenPromise = null; // be nice to Chrome v8
this.iSessionTimer = 0;
this.iSerialNumber = 0;
this.sServiceUrl = sServiceUrl;
} | javascript | function Requestor(sServiceUrl, mHeaders, mQueryParams, oModelInterface) {
this.mBatchQueue = {};
this.mHeaders = mHeaders || {};
this.oModelInterface = oModelInterface;
this.sQueryParams = _Helper.buildQuery(mQueryParams); // Used for $batch and CSRF token only
this.mRunningChangeRequests = {};
this.oSecurityTokenPromise = null; // be nice to Chrome v8
this.iSessionTimer = 0;
this.iSerialNumber = 0;
this.sServiceUrl = sServiceUrl;
} | [
"function",
"Requestor",
"(",
"sServiceUrl",
",",
"mHeaders",
",",
"mQueryParams",
",",
"oModelInterface",
")",
"{",
"this",
".",
"mBatchQueue",
"=",
"{",
"}",
";",
"this",
".",
"mHeaders",
"=",
"mHeaders",
"||",
"{",
"}",
";",
"this",
".",
"oModelInterfac... | Constructor for a new <code>_Requestor</code> instance for the given service URL and default
headers.
@param {string} sServiceUrl
URL of the service document to request the CSRF token from; also used to resolve
relative resource paths (see {@link #request})
@param {object} [mHeaders={}]
Map of default headers; may be overridden with request-specific headers; certain
predefined OData V4 headers are added by default, but may be overridden
@param {object} [mQueryParams={}]
A map of query parameters as described in
{@link sap.ui.model.odata.v4.lib._Helper.buildQuery}; used only to request the CSRF token
@param {object} oModelInterface
A interface allowing to call back to the owning model
@param {function} oModelInterface.fetchEntityContainer
A promise which is resolved with the $metadata "JSON" object as soon as the entity
container is fully available, or rejected with an error.
@param {function} oModelInterface.fetchMetadata
A function that returns a SyncPromise which resolves with the metadata instance for a
given meta path
@param {function} oModelInterface.getGroupProperty
A function called with parameters <code>sGroupId</code> and <code>sPropertyName</code>
returning the property value in question. Only 'submit' is supported for <code>
sPropertyName</code>. Supported property values are: 'API', 'Auto' and 'Direct'.
@param {function} oModelInterface.reportBoundMessages
A function for reporting bound messages; see {@link #reportBoundMessages} for the signature
of this function
@param {function} oModelInterface.reportUnboundMessages
A function called with parameters <code>sResourcePath</code> and <code>sMessages</code>
reporting unbound OData messages to the {@link sap.ui.core.message.MessageManager}.
@param {function (string)} [oModelInterface.onCreateGroup]
A callback function that is called with the group name as parameter when the first
request is added to a group
@private | [
"Constructor",
"for",
"a",
"new",
"<code",
">",
"_Requestor<",
"/",
"code",
">",
"instance",
"for",
"the",
"given",
"service",
"URL",
"and",
"default",
"headers",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L80-L90 | train | Creates a new Requestor instance. | [
30522,
3853,
5227,
2953,
1006,
7020,
2121,
7903,
11236,
2140,
1010,
1049,
4974,
2545,
1010,
1049,
4226,
2854,
28689,
5244,
1010,
18168,
10244,
4115,
3334,
12172,
1007,
1063,
2023,
1012,
15038,
10649,
4226,
5657,
1027,
1063,
1065,
1025,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/docker-cli.js | pushImage | function pushImage(repository) {
const commandLine = `docker push ${repository}`;
return new Promise((resolve, reject) =>
command(commandLine, (err, stdout) => {
if (err) {
reject(err);
}
resolve(stdout);
})
);
} | javascript | function pushImage(repository) {
const commandLine = `docker push ${repository}`;
return new Promise((resolve, reject) =>
command(commandLine, (err, stdout) => {
if (err) {
reject(err);
}
resolve(stdout);
})
);
} | [
"function",
"pushImage",
"(",
"repository",
")",
"{",
"const",
"commandLine",
"=",
"`",
"${",
"repository",
"}",
"`",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"command",
"(",
"commandLine",
",",
"(",
"err",
",",
"... | Pushes the locally constructed Docker image to the supplied respository
@param repository tag, for example: 111111111.dkr.ecr.us-east-1.amazonaws.com/sample
@returns {Promise<any>} | [
"Pushes",
"the",
"locally",
"constructed",
"Docker",
"image",
"to",
"the",
"supplied",
"respository"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-cli.js#L138-L148 | train | Pushes an image to the specified repository | [
30522,
3853,
5245,
9581,
3351,
1006,
22409,
1007,
1063,
9530,
3367,
3094,
4179,
1027,
1036,
8946,
2121,
5245,
1002,
1063,
22409,
1065,
1036,
1025,
2709,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
3094,
1006,
3094,
4179,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | build/babel-plugin-transform-modules-commonjs-ec.js | normalizeModuleAndLoadMetadata | function normalizeModuleAndLoadMetadata(programPath) {
nameAnonymousExports(programPath);
const {local, source} = getModuleMetadata(programPath);
removeModuleDeclarations(programPath);
// Reuse the imported namespace name if there is one.
for (const [, metadata] of source) {
if (metadata.importsNamespace.size > 0) {
// This is kind of gross. If we stop using `loose: true` we should
// just make this destructuring assignment.
metadata.name = metadata.importsNamespace.values().next().value;
}
}
return {
exportName: 'exports',
exportNameListName: null,
local,
source
};
} | javascript | function normalizeModuleAndLoadMetadata(programPath) {
nameAnonymousExports(programPath);
const {local, source} = getModuleMetadata(programPath);
removeModuleDeclarations(programPath);
// Reuse the imported namespace name if there is one.
for (const [, metadata] of source) {
if (metadata.importsNamespace.size > 0) {
// This is kind of gross. If we stop using `loose: true` we should
// just make this destructuring assignment.
metadata.name = metadata.importsNamespace.values().next().value;
}
}
return {
exportName: 'exports',
exportNameListName: null,
local,
source
};
} | [
"function",
"normalizeModuleAndLoadMetadata",
"(",
"programPath",
")",
"{",
"nameAnonymousExports",
"(",
"programPath",
")",
";",
"const",
"{",
"local",
",",
"source",
"}",
"=",
"getModuleMetadata",
"(",
"programPath",
")",
";",
"removeModuleDeclarations",
"(",
"pro... | Remove all imports and exports from the file, and return all metadata
needed to reconstruct the module's behavior.
@return {ModuleMetadata} | [
"Remove",
"all",
"imports",
"and",
"exports",
"from",
"the",
"file",
"and",
"return",
"all",
"metadata",
"needed",
"to",
"reconstruct",
"the",
"module",
"s",
"behavior",
"."
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/build/babel-plugin-transform-modules-commonjs-ec.js#L70-L93 | train | Normalize the module and load the metadata | [
30522,
3853,
3671,
4697,
5302,
8566,
20898,
19422,
10441,
22117,
12928,
2850,
2696,
1006,
2565,
15069,
1007,
1063,
2171,
6761,
4890,
27711,
10288,
25378,
1006,
2565,
15069,
1007,
1025,
9530,
3367,
1063,
2334,
1010,
3120,
1065,
1027,
2131,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/plugin.js | function(e) {
pathPrefixes = env.opts._.reduce(function(result, fileOrDir) {
fileOrDir = path.resolve( path.normalize(fileOrDir) );
if ( fs.statSync(fileOrDir).isDirectory() ) {
// ensure a trailing path separator
if ( fileOrDir.indexOf(path.sep, fileOrDir.length - path.sep.length) < 0 ) {
fileOrDir += path.sep;
}
result.push(fileOrDir);
}
return result;
}, []);
resourceNamePrefixes = pluginConfig.resourceNamePrefixes || [];
if ( !Array.isArray(resourceNamePrefixes) ) {
resourceNamePrefixes = [resourceNamePrefixes];
}
resourceNamePrefixes.forEach(ensureEndingSlash);
while ( resourceNamePrefixes.length < pathPrefixes.length ) {
resourceNamePrefixes.push('');
}
debug("path prefixes " + JSON.stringify(pathPrefixes));
debug("resource name prefixes " + JSON.stringify(resourceNamePrefixes));
} | javascript | function(e) {
pathPrefixes = env.opts._.reduce(function(result, fileOrDir) {
fileOrDir = path.resolve( path.normalize(fileOrDir) );
if ( fs.statSync(fileOrDir).isDirectory() ) {
// ensure a trailing path separator
if ( fileOrDir.indexOf(path.sep, fileOrDir.length - path.sep.length) < 0 ) {
fileOrDir += path.sep;
}
result.push(fileOrDir);
}
return result;
}, []);
resourceNamePrefixes = pluginConfig.resourceNamePrefixes || [];
if ( !Array.isArray(resourceNamePrefixes) ) {
resourceNamePrefixes = [resourceNamePrefixes];
}
resourceNamePrefixes.forEach(ensureEndingSlash);
while ( resourceNamePrefixes.length < pathPrefixes.length ) {
resourceNamePrefixes.push('');
}
debug("path prefixes " + JSON.stringify(pathPrefixes));
debug("resource name prefixes " + JSON.stringify(resourceNamePrefixes));
} | [
"function",
"(",
"e",
")",
"{",
"pathPrefixes",
"=",
"env",
".",
"opts",
".",
"_",
".",
"reduce",
"(",
"function",
"(",
"result",
",",
"fileOrDir",
")",
"{",
"fileOrDir",
"=",
"path",
".",
"resolve",
"(",
"path",
".",
"normalize",
"(",
"fileOrDir",
"... | Before all files are parsed, determine the common path prefix of all filenames
@param {object} e Event info object | [
"Before",
"all",
"files",
"are",
"parsed",
"determine",
"the",
"common",
"path",
"prefix",
"of",
"all",
"filenames"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/plugin.js#L2076-L2100 | train | This function is called when the user clicks on a file or directory | [
30522,
3853,
1006,
1041,
1007,
1063,
4130,
28139,
8873,
20156,
1027,
4372,
2615,
1012,
23569,
2015,
1012,
1035,
1012,
5547,
1006,
3853,
1006,
2765,
1010,
5371,
8551,
4313,
1007,
1063,
5371,
8551,
4313,
1027,
4130,
1012,
10663,
1006,
4130,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/search/FindReplace.js | _getWordAt | function _getWordAt(editor, pos) {
var cm = editor._codeMirror,
start = pos.ch,
end = start,
line = cm.getLine(pos.line);
while (start && CodeMirror.isWordChar(line.charAt(start - 1))) {
--start;
}
while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) {
++end;
}
return {start: {line: pos.line, ch: start}, end: {line: pos.line, ch: end}, text: line.slice(start, end)};
} | javascript | function _getWordAt(editor, pos) {
var cm = editor._codeMirror,
start = pos.ch,
end = start,
line = cm.getLine(pos.line);
while (start && CodeMirror.isWordChar(line.charAt(start - 1))) {
--start;
}
while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) {
++end;
}
return {start: {line: pos.line, ch: start}, end: {line: pos.line, ch: end}, text: line.slice(start, end)};
} | [
"function",
"_getWordAt",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"_codeMirror",
",",
"start",
"=",
"pos",
".",
"ch",
",",
"end",
"=",
"start",
",",
"line",
"=",
"cm",
".",
"getLine",
"(",
"pos",
".",
"line",
")",
";... | Returns the range of the word surrounding the given editor position. Similar to getWordAt() from CodeMirror.
@param {!Editor} editor The editor to search in
@param {!{line: number, ch: number}} pos The position to find a word at.
@return {{start:{line: number, ch: number}, end:{line:number, ch:number}, text:string}} The range and content of the found word. If
there is no word, start will equal end and the text will be the empty string. | [
"Returns",
"the",
"range",
"of",
"the",
"word",
"surrounding",
"the",
"given",
"editor",
"position",
".",
"Similar",
"to",
"getWordAt",
"()",
"from",
"CodeMirror",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L242-L254 | train | Get word at pos | [
30522,
3853,
1035,
2131,
18351,
4017,
1006,
3559,
1010,
13433,
2015,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
1035,
3642,
14503,
29165,
1010,
2707,
1027,
13433,
2015,
1012,
10381,
1010,
2203,
1027,
2707,
1010,
2240,
1027,
4642,
1012,
2131... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | core/server/log.js | date | function date() {
const date = new Date()
return (
pad(date.getUTCMonth() + 1) +
pad(date.getUTCDate()) +
pad(date.getUTCHours()) +
pad(date.getUTCMinutes()) +
pad(date.getUTCSeconds())
)
} | javascript | function date() {
const date = new Date()
return (
pad(date.getUTCMonth() + 1) +
pad(date.getUTCDate()) +
pad(date.getUTCHours()) +
pad(date.getUTCMinutes()) +
pad(date.getUTCSeconds())
)
} | [
"function",
"date",
"(",
")",
"{",
"const",
"date",
"=",
"new",
"Date",
"(",
")",
"return",
"(",
"pad",
"(",
"date",
".",
"getUTCMonth",
"(",
")",
"+",
"1",
")",
"+",
"pad",
"(",
"date",
".",
"getUTCDate",
"(",
")",
")",
"+",
"pad",
"(",
"date"... | Compact date representation. eg. 0611093840 for June 11, 9:38:40 UTC. | [
"Compact",
"date",
"representation",
".",
"eg",
".",
"0611093840",
"for",
"June",
"11",
"9",
":",
"38",
":",
"40",
"UTC",
"."
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/core/server/log.js#L16-L25 | train | Get the date of the current cluster | [
30522,
3853,
3058,
1006,
1007,
1063,
9530,
3367,
3058,
1027,
2047,
3058,
1006,
1007,
2709,
1006,
11687,
1006,
3058,
1012,
2131,
4904,
27487,
12162,
2232,
1006,
1007,
1009,
1015,
1007,
1009,
11687,
1006,
3058,
1012,
2131,
4904,
19797,
3686,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | o2s | function o2s(obj) {
var s = "";
for (key in obj) {
var line = key + "->" + obj[key];
line.replace("\n", " ");
s += line + "\n";
}
return s;
} | javascript | function o2s(obj) {
var s = "";
for (key in obj) {
var line = key + "->" + obj[key];
line.replace("\n", " ");
s += line + "\n";
}
return s;
} | [
"function",
"o2s",
"(",
"obj",
")",
"{",
"var",
"s",
"=",
"\"\"",
";",
"for",
"(",
"key",
"in",
"obj",
")",
"{",
"var",
"line",
"=",
"key",
"+",
"\"->\"",
"+",
"obj",
"[",
"key",
"]",
";",
"line",
".",
"replace",
"(",
"\"\\n\"",
",",
"\" \"",
... | for use from vs.2003 debugger | [
"for",
"use",
"from",
"vs",
".",
"2003",
"debugger"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L821-L829 | train | Convert an object to a string | [
30522,
3853,
1051,
2475,
2015,
1006,
27885,
3501,
1007,
1063,
13075,
1055,
1027,
1000,
1000,
1025,
2005,
1006,
3145,
1999,
27885,
3501,
1007,
1063,
13075,
2240,
1027,
3145,
1009,
1000,
1011,
1028,
1000,
1009,
27885,
3501,
1031,
3145,
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... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js | function (oEvent) {
var sSource = oEvent.getSource();
var sContentBindingPath = sSource.getBindingContextPath().substring(1);
var sContentModelData = this.getView().getModel("content").getData();
var sContent = sContentModelData[sContentBindingPath];
var sContentName = sContent.name;
var sContentFileType = sContentModelData[sContentBindingPath].fileType;
var oRouter = UIComponent.getRouterFor(this);
this.sNamespace = (this.sNamespace ? this.sNamespace : '/');
if (sContentFileType) {
// show details to a file
var mRouteParameters = {
"layer": this.sLayer,
"namespace": encodeURIComponent(this.sNamespace),
"fileName": sContentName,
"fileType": sContentFileType
};
oRouter.navTo("ContentDetails", mRouteParameters);
} else {
// navigation to a namespace
this.sNamespace += sContentName + '/';
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace)});
}
} | javascript | function (oEvent) {
var sSource = oEvent.getSource();
var sContentBindingPath = sSource.getBindingContextPath().substring(1);
var sContentModelData = this.getView().getModel("content").getData();
var sContent = sContentModelData[sContentBindingPath];
var sContentName = sContent.name;
var sContentFileType = sContentModelData[sContentBindingPath].fileType;
var oRouter = UIComponent.getRouterFor(this);
this.sNamespace = (this.sNamespace ? this.sNamespace : '/');
if (sContentFileType) {
// show details to a file
var mRouteParameters = {
"layer": this.sLayer,
"namespace": encodeURIComponent(this.sNamespace),
"fileName": sContentName,
"fileType": sContentFileType
};
oRouter.navTo("ContentDetails", mRouteParameters);
} else {
// navigation to a namespace
this.sNamespace += sContentName + '/';
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace)});
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"sSource",
"=",
"oEvent",
".",
"getSource",
"(",
")",
";",
"var",
"sContentBindingPath",
"=",
"sSource",
".",
"getBindingContextPath",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"var",
"sContentModelData",
"... | Handles the selection of a layer entry in the master page;
Gathers the selected namespace and the current layer, then navigates to the target.
@param {Object} oEvent - press event of master components list
@public | [
"Handles",
"the",
"selection",
"of",
"a",
"layer",
"entry",
"in",
"the",
"master",
"page",
";",
"Gathers",
"the",
"selected",
"namespace",
"and",
"the",
"current",
"layer",
"then",
"navigates",
"to",
"the",
"target",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js#L121-L146 | train | The default event handler for the content navigation | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
7020,
8162,
3401,
1027,
1051,
18697,
3372,
1012,
4152,
8162,
3401,
1006,
1007,
1025,
13075,
8040,
28040,
3372,
8428,
4667,
15069,
1027,
7020,
8162,
3401,
1012,
2131,
8428,
4667,
8663,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/RuleEngineOpaExtension.js | function () {
var bLoaded = sap.ui.getCore().getLoadedLibraries()["sap.ui.support"],
deferred = jQueryDOM.Deferred();
if (!bLoaded) {
sap.ui.require(["sap/ui/support/Bootstrap"], function (bootstrap) {
bootstrap.initSupportRules(["true", "silent"], {
onReady: function () {
deferred.resolve();
}
});
});
} else {
deferred.resolve();
}
return deferred.promise();
} | javascript | function () {
var bLoaded = sap.ui.getCore().getLoadedLibraries()["sap.ui.support"],
deferred = jQueryDOM.Deferred();
if (!bLoaded) {
sap.ui.require(["sap/ui/support/Bootstrap"], function (bootstrap) {
bootstrap.initSupportRules(["true", "silent"], {
onReady: function () {
deferred.resolve();
}
});
});
} else {
deferred.resolve();
}
return deferred.promise();
} | [
"function",
"(",
")",
"{",
"var",
"bLoaded",
"=",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLoadedLibraries",
"(",
")",
"[",
"\"sap.ui.support\"",
"]",
",",
"deferred",
"=",
"jQueryDOM",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"!",
"bLo... | When the application under test is started in a UIComponent container instead of an iframe
the Support Assistant is not loaded because the application doesn't start a separate instance of the Core
to start in Support Mode. In such cases manually start the Support Assistant in the current instance of the Core.
@returns {jQuery.promise} A promise that gets resolved when the Support Assistant is ready. | [
"When",
"the",
"application",
"under",
"test",
"is",
"started",
"in",
"a",
"UIComponent",
"container",
"instead",
"of",
"an",
"iframe",
"the",
"Support",
"Assistant",
"is",
"not",
"loaded",
"because",
"the",
"application",
"doesn",
"t",
"start",
"a",
"separate... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/RuleEngineOpaExtension.js#L45-L62 | train | Initializes the support rules | [
30522,
3853,
1006,
1007,
1063,
13075,
1038,
17468,
1027,
20066,
1012,
21318,
1012,
2131,
17345,
1006,
1007,
1012,
2131,
17468,
29521,
19848,
3111,
1006,
1007,
1031,
1000,
20066,
1012,
21318,
1012,
2490,
1000,
1033,
1010,
13366,
28849,
2094,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxSelectionChange | function mxSelectionChange(selectionModel, added, removed)
{
this.selectionModel = selectionModel;
this.added = (added != null) ? added.slice() : null;
this.removed = (removed != null) ? removed.slice() : null;
} | javascript | function mxSelectionChange(selectionModel, added, removed)
{
this.selectionModel = selectionModel;
this.added = (added != null) ? added.slice() : null;
this.removed = (removed != null) ? removed.slice() : null;
} | [
"function",
"mxSelectionChange",
"(",
"selectionModel",
",",
"added",
",",
"removed",
")",
"{",
"this",
".",
"selectionModel",
"=",
"selectionModel",
";",
"this",
".",
"added",
"=",
"(",
"added",
"!=",
"null",
")",
"?",
"added",
".",
"slice",
"(",
")",
"... | Class: mxSelectionChange
Action to change the current root in a view.
Constructor: mxCurrentRootChange
Constructs a change of the current root in the given view. | [
"Class",
":",
"mxSelectionChange"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L46602-L46607 | train | This function is called when the selection model changes | [
30522,
3853,
25630,
11246,
18491,
22305,
2063,
1006,
4989,
5302,
9247,
1010,
2794,
1010,
3718,
1007,
1063,
2023,
1012,
4989,
5302,
9247,
1027,
4989,
5302,
9247,
1025,
2023,
1012,
2794,
1027,
1006,
2794,
999,
1027,
19701,
1007,
1029,
2794,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Code.controller.js | function () {
this.oModel = new JSONModel();
this.getView().setModel(this.oModel);
this.router = this.getRouter();
this.router.getRoute("code").attachPatternMatched(this.onRouteMatched, this);
this.router.getRoute("codeFile").attachPatternMatched(this.onRouteMatched, this);
this._codeCache = {};
this._aFilesAvailable = [];
this._bFirstLoad = true;
} | javascript | function () {
this.oModel = new JSONModel();
this.getView().setModel(this.oModel);
this.router = this.getRouter();
this.router.getRoute("code").attachPatternMatched(this.onRouteMatched, this);
this.router.getRoute("codeFile").attachPatternMatched(this.onRouteMatched, this);
this._codeCache = {};
this._aFilesAvailable = [];
this._bFirstLoad = true;
} | [
"function",
"(",
")",
"{",
"this",
".",
"oModel",
"=",
"new",
"JSONModel",
"(",
")",
";",
"this",
".",
"getView",
"(",
")",
".",
"setModel",
"(",
"this",
".",
"oModel",
")",
";",
"this",
".",
"router",
"=",
"this",
".",
"getRouter",
"(",
")",
";"... | Called when the controller is instantiated.
@public | [
"Called",
"when",
"the",
"controller",
"is",
"instantiated",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/Code.controller.js#L23-L35 | train | Initializes the model of the data model | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
18168,
10244,
2140,
1027,
2047,
1046,
3385,
5302,
9247,
1006,
1007,
1025,
2023,
1012,
2131,
8584,
1006,
1007,
1012,
2275,
5302,
9247,
1006,
2023,
1012,
18168,
10244,
2140,
1007,
1025,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/FileTreeView.js | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.contents !== nextProps.contents ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions;
} | javascript | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.contents !== nextProps.contents ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions;
} | [
"function",
"(",
"nextProps",
",",
"nextState",
")",
"{",
"return",
"nextProps",
".",
"forceRender",
"||",
"this",
".",
"props",
".",
"contents",
"!==",
"nextProps",
".",
"contents",
"||",
"this",
".",
"props",
".",
"sortDirectoriesFirst",
"!==",
"nextProps",
... | Need to re-render if the sort order or the contents change. | [
"Need",
"to",
"re",
"-",
"render",
"if",
"the",
"sort",
"order",
"or",
"the",
"contents",
"change",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L937-L942 | train | Check if the component is different from the current state | [
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,
8417,
999,
1027,
1027,
2279,
21572,
4523,
1012,
8417,
1064,
1064,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onSendSignInLinkToEmailCurrentUrl | function onSendSignInLinkToEmailCurrentUrl() {
var email = $('#sign-in-with-email-link-email').val();
var actionCodeSettings = {
'url': window.location.href,
'handleCodeInApp': true
};
auth.sendSignInLinkToEmail(email, actionCodeSettings).then(function() {
if ('localStorage' in window && window['localStorage'] !== null) {
window.localStorage.setItem(
'emailForSignIn',
// Save the email and the timestamp.
JSON.stringify({
email: email,
timestamp: new Date().getTime()
}));
}
alertSuccess('Email sent!');
}, onAuthError);
} | javascript | function onSendSignInLinkToEmailCurrentUrl() {
var email = $('#sign-in-with-email-link-email').val();
var actionCodeSettings = {
'url': window.location.href,
'handleCodeInApp': true
};
auth.sendSignInLinkToEmail(email, actionCodeSettings).then(function() {
if ('localStorage' in window && window['localStorage'] !== null) {
window.localStorage.setItem(
'emailForSignIn',
// Save the email and the timestamp.
JSON.stringify({
email: email,
timestamp: new Date().getTime()
}));
}
alertSuccess('Email sent!');
}, onAuthError);
} | [
"function",
"onSendSignInLinkToEmailCurrentUrl",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#sign-in-with-email-link-email'",
")",
".",
"val",
"(",
")",
";",
"var",
"actionCodeSettings",
"=",
"{",
"'url'",
":",
"window",
".",
"location",
".",
"href",
",",... | Sends sign in with email link to the user and pass in current url. | [
"Sends",
"sign",
"in",
"with",
"email",
"link",
"to",
"the",
"user",
"and",
"pass",
"in",
"current",
"url",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L651-L670 | train | Send the sign - in link to the current URL | [
30522,
3853,
2006,
5054,
5104,
23773,
2378,
13767,
3406,
14545,
4014,
10841,
14343,
3372,
3126,
2140,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
3696,
1011,
1999,
1011,
2007,
1011,
10373,
1011,
4957,
1011,
10373,
1005,
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/editor/EditorManager.js | _openInlineWidget | function _openInlineWidget(editor, providers, defaultErrorMsg) {
PerfUtils.markStart(PerfUtils.INLINE_WIDGET_OPEN);
// Run through inline-editor providers until one responds
var pos = editor.getCursorPos(),
inlinePromise,
i,
result = new $.Deferred(),
errorMsg,
providerRet;
// Query each provider in priority order. Provider may return:
// 1. `null` to indicate it does not apply to current cursor position
// 2. promise that should resolve to an InlineWidget
// 3. string which indicates provider does apply to current cursor position,
// but reason it could not create InlineWidget
//
// Keep looping until a provider is found. If a provider is not found,
// display the highest priority error message that was found, otherwise display
// default error message
for (i = 0; i < providers.length && !inlinePromise; i++) {
var provider = providers[i].provider;
providerRet = provider(editor, pos);
if (providerRet) {
if (providerRet.hasOwnProperty("done")) {
inlinePromise = providerRet;
} else if (!errorMsg && typeof (providerRet) === "string") {
errorMsg = providerRet;
}
}
}
// Use default error message if none other provided
errorMsg = errorMsg || defaultErrorMsg;
// If one of them will provide a widget, show it inline once ready
if (inlinePromise) {
inlinePromise.done(function (inlineWidget) {
editor.addInlineWidget(pos, inlineWidget).done(function () {
PerfUtils.addMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
result.resolve();
});
}).fail(function () {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
editor.displayErrorMessageAtCursor(errorMsg);
result.reject();
});
} else {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
editor.displayErrorMessageAtCursor(errorMsg);
result.reject();
}
return result.promise();
} | javascript | function _openInlineWidget(editor, providers, defaultErrorMsg) {
PerfUtils.markStart(PerfUtils.INLINE_WIDGET_OPEN);
// Run through inline-editor providers until one responds
var pos = editor.getCursorPos(),
inlinePromise,
i,
result = new $.Deferred(),
errorMsg,
providerRet;
// Query each provider in priority order. Provider may return:
// 1. `null` to indicate it does not apply to current cursor position
// 2. promise that should resolve to an InlineWidget
// 3. string which indicates provider does apply to current cursor position,
// but reason it could not create InlineWidget
//
// Keep looping until a provider is found. If a provider is not found,
// display the highest priority error message that was found, otherwise display
// default error message
for (i = 0; i < providers.length && !inlinePromise; i++) {
var provider = providers[i].provider;
providerRet = provider(editor, pos);
if (providerRet) {
if (providerRet.hasOwnProperty("done")) {
inlinePromise = providerRet;
} else if (!errorMsg && typeof (providerRet) === "string") {
errorMsg = providerRet;
}
}
}
// Use default error message if none other provided
errorMsg = errorMsg || defaultErrorMsg;
// If one of them will provide a widget, show it inline once ready
if (inlinePromise) {
inlinePromise.done(function (inlineWidget) {
editor.addInlineWidget(pos, inlineWidget).done(function () {
PerfUtils.addMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
result.resolve();
});
}).fail(function () {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
editor.displayErrorMessageAtCursor(errorMsg);
result.reject();
});
} else {
// terminate timer that was started above
PerfUtils.finalizeMeasurement(PerfUtils.INLINE_WIDGET_OPEN);
editor.displayErrorMessageAtCursor(errorMsg);
result.reject();
}
return result.promise();
} | [
"function",
"_openInlineWidget",
"(",
"editor",
",",
"providers",
",",
"defaultErrorMsg",
")",
"{",
"PerfUtils",
".",
"markStart",
"(",
"PerfUtils",
".",
"INLINE_WIDGET_OPEN",
")",
";",
"// Run through inline-editor providers until one responds",
"var",
"pos",
"=",
"edi... | @private
Finds an inline widget provider from the given list that can offer a widget for the current cursor
position, and once the widget has been created inserts it into the editor.
@param {!Editor} editor The host editor
@param {Array.<{priority:number, provider:function(...)}>} providers
prioritized list of providers
@param {string=} defaultErrorMsg Default message to display if no providers return non-null
@return {$.Promise} a promise that will be resolved when an InlineWidget
is created or rejected if no inline providers have offered one. | [
"@private",
"Finds",
"an",
"inline",
"widget",
"provider",
"from",
"the",
"given",
"list",
"that",
"can",
"offer",
"a",
"widget",
"for",
"the",
"current",
"cursor",
"position",
"and",
"once",
"the",
"widget",
"has",
"been",
"created",
"inserts",
"it",
"into"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorManager.js#L213-L269 | train | Open inline widget | [
30522,
3853,
1035,
2330,
2378,
4179,
9148,
24291,
1006,
3559,
1010,
11670,
1010,
12398,
2121,
29165,
5244,
2290,
1007,
1063,
2566,
11263,
3775,
4877,
1012,
6017,
7559,
2102,
1006,
2566,
11263,
3775,
4877,
1012,
23881,
1035,
15536,
24291,
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... |
ecomfe/zrender | src/graphic/States.js | function (state, subPropKey, key, transitionCfg, done) {
var el = this._el;
var stateObj = subPropKey ? state[subPropKey] : state;
var elObj = subPropKey ? el[subPropKey] : el;
var availableProp = stateObj && (key in stateObj)
&& elObj && (key in elObj);
var transitionAnimators = this._transitionAnimators;
if (availableProp) {
var obj = {};
if (stateObj[key] === elObj[key]) {
return 0;
}
obj[key] = stateObj[key];
var animator = el.animate(subPropKey)
.when(transitionCfg.duration, obj)
.delay(transitionCfg.dealy)
.done(function () {
var idx = zrUtil.indexOf(transitionAnimators, 1);
if (idx > 0) {
transitionAnimators.splice(idx, 1);
}
done();
})
.start(transitionCfg.easing);
transitionAnimators.push(animator);
return 1;
}
return 0;
} | javascript | function (state, subPropKey, key, transitionCfg, done) {
var el = this._el;
var stateObj = subPropKey ? state[subPropKey] : state;
var elObj = subPropKey ? el[subPropKey] : el;
var availableProp = stateObj && (key in stateObj)
&& elObj && (key in elObj);
var transitionAnimators = this._transitionAnimators;
if (availableProp) {
var obj = {};
if (stateObj[key] === elObj[key]) {
return 0;
}
obj[key] = stateObj[key];
var animator = el.animate(subPropKey)
.when(transitionCfg.duration, obj)
.delay(transitionCfg.dealy)
.done(function () {
var idx = zrUtil.indexOf(transitionAnimators, 1);
if (idx > 0) {
transitionAnimators.splice(idx, 1);
}
done();
})
.start(transitionCfg.easing);
transitionAnimators.push(animator);
return 1;
}
return 0;
} | [
"function",
"(",
"state",
",",
"subPropKey",
",",
"key",
",",
"transitionCfg",
",",
"done",
")",
"{",
"var",
"el",
"=",
"this",
".",
"_el",
";",
"var",
"stateObj",
"=",
"subPropKey",
"?",
"state",
"[",
"subPropKey",
"]",
":",
"state",
";",
"var",
"el... | Do transition animation of particular property
@param {Object} state
@param {string} subPropKey
@param {string} key
@param {Object} transitionCfg
@param {Function} done
@private | [
"Do",
"transition",
"animation",
"of",
"particular",
"property"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/graphic/States.js#L359-L390 | train | transition to state | [
30522,
3853,
1006,
2110,
1010,
4942,
21572,
2361,
14839,
1010,
3145,
1010,
6653,
2278,
2546,
2290,
1010,
2589,
1007,
1063,
13075,
3449,
1027,
2023,
1012,
1035,
3449,
1025,
13075,
2110,
16429,
3501,
1027,
4942,
21572,
2361,
14839,
1029,
2110... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/aggregation-layers/src/grid-layer/grid-aggregator.js | _pointsToGridHashing | function _pointsToGridHashing(points = [], cellSize, getPosition) {
// find the geometric center of sample points
let latMin = Infinity;
let latMax = -Infinity;
let pLat;
for (const pt of points) {
pLat = getPosition(pt)[1];
if (Number.isFinite(pLat)) {
latMin = pLat < latMin ? pLat : latMin;
latMax = pLat > latMax ? pLat : latMax;
}
}
const centerLat = (latMin + latMax) / 2;
const gridOffset = _calculateGridLatLonOffset(cellSize, centerLat);
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
return {gridHash: {}, gridOffset};
}
// calculate count per cell
const gridHash = {};
for (const pt of points) {
const [lng, lat] = getPosition(pt);
if (Number.isFinite(lat) && Number.isFinite(lng)) {
const latIdx = Math.floor((lat + 90) / gridOffset.yOffset);
const lonIdx = Math.floor((lng + 180) / gridOffset.xOffset);
const key = `${latIdx}-${lonIdx}`;
gridHash[key] = gridHash[key] || {count: 0, points: []};
gridHash[key].count += 1;
gridHash[key].points.push(pt);
}
}
return {gridHash, gridOffset};
} | javascript | function _pointsToGridHashing(points = [], cellSize, getPosition) {
// find the geometric center of sample points
let latMin = Infinity;
let latMax = -Infinity;
let pLat;
for (const pt of points) {
pLat = getPosition(pt)[1];
if (Number.isFinite(pLat)) {
latMin = pLat < latMin ? pLat : latMin;
latMax = pLat > latMax ? pLat : latMax;
}
}
const centerLat = (latMin + latMax) / 2;
const gridOffset = _calculateGridLatLonOffset(cellSize, centerLat);
if (gridOffset.xOffset <= 0 || gridOffset.yOffset <= 0) {
return {gridHash: {}, gridOffset};
}
// calculate count per cell
const gridHash = {};
for (const pt of points) {
const [lng, lat] = getPosition(pt);
if (Number.isFinite(lat) && Number.isFinite(lng)) {
const latIdx = Math.floor((lat + 90) / gridOffset.yOffset);
const lonIdx = Math.floor((lng + 180) / gridOffset.xOffset);
const key = `${latIdx}-${lonIdx}`;
gridHash[key] = gridHash[key] || {count: 0, points: []};
gridHash[key].count += 1;
gridHash[key].points.push(pt);
}
}
return {gridHash, gridOffset};
} | [
"function",
"_pointsToGridHashing",
"(",
"points",
"=",
"[",
"]",
",",
"cellSize",
",",
"getPosition",
")",
"{",
"// find the geometric center of sample points",
"let",
"latMin",
"=",
"Infinity",
";",
"let",
"latMax",
"=",
"-",
"Infinity",
";",
"let",
"pLat",
";... | Project points into each cell, return a hash table of cells
@param {Iterable} points
@param {number} cellSize - unit size in meters
@param {function} getPosition - position accessor
@returns {object} - grid hash and cell dimension | [
"Project",
"points",
"into",
"each",
"cell",
"return",
"a",
"hash",
"table",
"of",
"cells"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/aggregation-layers/src/grid-layer/grid-aggregator.js#L46-L85 | train | Calculates the grid hashing of points | [
30522,
3853,
1035,
2685,
3406,
16523,
3593,
14949,
12053,
1006,
2685,
1027,
1031,
1033,
1010,
4442,
4697,
1010,
2131,
26994,
1007,
1063,
1013,
1013,
2424,
1996,
14965,
2415,
1997,
7099,
2685,
2292,
2474,
21246,
2378,
1027,
15579,
1025,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue) {
// Note: it is safe to modify the caller's object here
oPathValue.asExpression = true;
oPathValue.complexBinding = false;
return Expression.expression(oPathValue).then(function (oParameter) {
return {
result : "expression",
type : "Edm.Boolean",
value : "!"
+ Basics.resultToString(Expression.wrapExpression(oParameter), true, false)
};
});
} | javascript | function (oPathValue) {
// Note: it is safe to modify the caller's object here
oPathValue.asExpression = true;
oPathValue.complexBinding = false;
return Expression.expression(oPathValue).then(function (oParameter) {
return {
result : "expression",
type : "Edm.Boolean",
value : "!"
+ Basics.resultToString(Expression.wrapExpression(oParameter), true, false)
};
});
} | [
"function",
"(",
"oPathValue",
")",
"{",
"// Note: it is safe to modify the caller's object here",
"oPathValue",
".",
"asExpression",
"=",
"true",
";",
"oPathValue",
".",
"complexBinding",
"=",
"false",
";",
"return",
"Expression",
".",
"expression",
"(",
"oPathValue",
... | Handling of "14.5.1 Comparison and Logical Operators": <code>edm:Not</code>.
@param {object} oPathValue
path and value information pointing to the parameter (see Expression object)
@returns {sap.ui.base.SyncPromise}
a sync promise which resolves with the result object or is rejected with an error | [
"Handling",
"of",
"14",
".",
"5",
".",
"1",
"Comparison",
"and",
"Logical",
"Operators",
":",
"<code",
">",
"edm",
":",
"Not<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L600-L613 | train | Returns an object with the type of the expression | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1007,
1063,
1013,
1013,
3602,
1024,
2009,
2003,
3647,
2000,
19933,
1996,
20587,
1005,
1055,
4874,
2182,
6728,
8988,
10175,
5657,
1012,
2004,
10288,
20110,
3258,
1027,
2995,
1025,
6728,
8988,
10175... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
moleculerjs/moleculer | examples/middlewares/index.js | middleware3 | function middleware3() {
return function mw3(handler) {
return async function mw3(ctx) {
broker.logger.info(chalk.cyan("mw3 before", ctx.action.name));
//return broker.Promise.resolve("data from mw3");
const res = await handler(ctx);
broker.logger.info(chalk.cyan("mw3 after", ctx.action.name));
if (res) {
if (ctx.action.name == "users.get")
delete res.gravatar;
if (ctx.action.name == "posts.get")
delete res.content;
}
return res;
};
};
} | javascript | function middleware3() {
return function mw3(handler) {
return async function mw3(ctx) {
broker.logger.info(chalk.cyan("mw3 before", ctx.action.name));
//return broker.Promise.resolve("data from mw3");
const res = await handler(ctx);
broker.logger.info(chalk.cyan("mw3 after", ctx.action.name));
if (res) {
if (ctx.action.name == "users.get")
delete res.gravatar;
if (ctx.action.name == "posts.get")
delete res.content;
}
return res;
};
};
} | [
"function",
"middleware3",
"(",
")",
"{",
"return",
"function",
"mw3",
"(",
"handler",
")",
"{",
"return",
"async",
"function",
"mw3",
"(",
"ctx",
")",
"{",
"broker",
".",
"logger",
".",
"info",
"(",
"chalk",
".",
"cyan",
"(",
"\"mw3 before\"",
",",
"c... | Async/await example | [
"Async",
"/",
"await",
"example"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/examples/middlewares/index.js#L47-L64 | train | Middleware for middleware 3 | [
30522,
3853,
2690,
8059,
2509,
1006,
1007,
1063,
2709,
3853,
12464,
2509,
1006,
28213,
1007,
1063,
2709,
2004,
6038,
2278,
3853,
12464,
2509,
1006,
14931,
2595,
1007,
1063,
20138,
1012,
8833,
4590,
1012,
18558,
1006,
16833,
1012,
22330,
231... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-compiler/core/RelayCompilerError.js | createNonRecoverableUserError | function createNonRecoverableUserError(
message: string,
locations?: ?$ReadOnlyArray<Location>,
nodes?: ?$ReadOnlyArray<ASTNode>,
): NonRecoverableUserError {
let messageWithLocations = message;
if (locations != null) {
const printedLocations = printLocations(locations);
messageWithLocations =
printedLocations.length === 0
? message
: [message, ...printedLocations].join('\n\n') + '\n';
}
const error = new GraphQLError(messageWithLocations, nodes ?? []);
return new Error(error.message);
} | javascript | function createNonRecoverableUserError(
message: string,
locations?: ?$ReadOnlyArray<Location>,
nodes?: ?$ReadOnlyArray<ASTNode>,
): NonRecoverableUserError {
let messageWithLocations = message;
if (locations != null) {
const printedLocations = printLocations(locations);
messageWithLocations =
printedLocations.length === 0
? message
: [message, ...printedLocations].join('\n\n') + '\n';
}
const error = new GraphQLError(messageWithLocations, nodes ?? []);
return new Error(error.message);
} | [
"function",
"createNonRecoverableUserError",
"(",
"message",
":",
"string",
",",
"locations",
"?",
":",
"?",
"$ReadOnlyArray",
"<",
"Location",
">",
",",
"nodes",
"?",
":",
"?",
"$ReadOnlyArray",
"<",
"ASTNode",
">",
",",
")",
":",
"NonRecoverableUserError",
"... | Similar to createUserError but for errors that are *not* recoverable:
the compiler should not continue to process other inputs because their
validity can't be determined. | [
"Similar",
"to",
"createUserError",
"but",
"for",
"errors",
"that",
"are",
"*",
"not",
"*",
"recoverable",
":",
"the",
"compiler",
"should",
"not",
"continue",
"to",
"process",
"other",
"inputs",
"because",
"their",
"validity",
"can",
"t",
"be",
"determined",
... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/RelayCompilerError.js#L59-L74 | train | Creates a non - recoverable user error. | [
30522,
3853,
3443,
8540,
2890,
3597,
26061,
3468,
20330,
2121,
29165,
1006,
4471,
1024,
5164,
1010,
5269,
1029,
1024,
1029,
1002,
3191,
2239,
2135,
2906,
9447,
1026,
3295,
1028,
1010,
14164,
1029,
1024,
1029,
1002,
3191,
2239,
2135,
2906,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/sinon-server.js | extend | function extend(target /*, sources */) {
var sources = Array.prototype.slice.call(arguments, 1),
source, i, prop;
for (i = 0; i < sources.length; i++) {
source = sources[i];
for (prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
// Make sure we copy (own) toString method even when in JScript with DontEnum bug
// See https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
if (hasDontEnumBug && source.hasOwnProperty("toString") && source.toString !== target.toString) {
target.toString = source.toString;
}
}
return target;
} | javascript | function extend(target /*, sources */) {
var sources = Array.prototype.slice.call(arguments, 1),
source, i, prop;
for (i = 0; i < sources.length; i++) {
source = sources[i];
for (prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
// Make sure we copy (own) toString method even when in JScript with DontEnum bug
// See https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
if (hasDontEnumBug && source.hasOwnProperty("toString") && source.toString !== target.toString) {
target.toString = source.toString;
}
}
return target;
} | [
"function",
"extend",
"(",
"target",
"/*, sources */",
")",
"{",
"var",
"sources",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
",",
"source",
",",
"i",
",",
"prop",
";",
"for",
"(",
"i",
"=",
"0",
";"... | /* Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will
override properties in previous sources.
target - The Object to extend
sources - Objects to copy properties from.
Returns the extended target | [
"/",
"*",
"Public",
":",
"Extend",
"target",
"in",
"place",
"with",
"all",
"(",
"own",
")",
"properties",
"from",
"sources",
"in",
"-",
"order",
".",
"Thus",
"last",
"source",
"will",
"override",
"properties",
"in",
"previous",
"sources",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/sinon-server.js#L531-L552 | train | Extend target with sources | [
30522,
3853,
7949,
1006,
4539,
1013,
1008,
1010,
4216,
1008,
1013,
1007,
1063,
13075,
4216,
1027,
9140,
1012,
8773,
1012,
14704,
1012,
2655,
1006,
9918,
1010,
1015,
1007,
1010,
3120,
1010,
1045,
1010,
17678,
1025,
2005,
1006,
1045,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | reconnect | function reconnect() {
if (_loadAgentsPromise) {
// Agents are already loading, so don't unload
return _loadAgentsPromise;
}
unloadAgents();
// Clear any existing related documents before we reload the agents.
// We need to recreate them for the reloaded document due to some
// desirable side-effects (see #7606). Eventually, we should simplify
// the way we get that behavior.
_.forOwn(_relatedDocuments, function (relatedDoc) {
_closeRelatedDocument(relatedDoc);
});
return loadAgents();
} | javascript | function reconnect() {
if (_loadAgentsPromise) {
// Agents are already loading, so don't unload
return _loadAgentsPromise;
}
unloadAgents();
// Clear any existing related documents before we reload the agents.
// We need to recreate them for the reloaded document due to some
// desirable side-effects (see #7606). Eventually, we should simplify
// the way we get that behavior.
_.forOwn(_relatedDocuments, function (relatedDoc) {
_closeRelatedDocument(relatedDoc);
});
return loadAgents();
} | [
"function",
"reconnect",
"(",
")",
"{",
"if",
"(",
"_loadAgentsPromise",
")",
"{",
"// Agents are already loading, so don't unload",
"return",
"_loadAgentsPromise",
";",
"}",
"unloadAgents",
"(",
")",
";",
"// Clear any existing related documents before we reload the agents.",
... | Unload and reload agents
@return {jQuery.Promise} Resolves once the agents are loaded | [
"Unload",
"and",
"reload",
"agents"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L972-L989 | train | Reconnects the agents and reloads the related documents. | [
30522,
3853,
28667,
18256,
6593,
1006,
1007,
1063,
2065,
1006,
1035,
7170,
4270,
7666,
21572,
28732,
1007,
1063,
1013,
1013,
6074,
2024,
2525,
10578,
1010,
2061,
2123,
1005,
1056,
4895,
11066,
2709,
1035,
7170,
4270,
7666,
21572,
28732,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/sessionstore.js | undoClosedTab | function undoClosedTab(controller, event)
{
var count = sessionStoreService.getClosedTabCount(controller.window);
switch (event.type) {
case "menu":
throw new Error("Menu gets build dynamically and cannot be accessed.");
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
}
if (count > 0)
controller.assertJS("subject.newTabCount < subject.oldTabCount",
{
newTabCount : sessionStoreService.getClosedTabCount(controller.window),
oldTabCount : count
});
} | javascript | function undoClosedTab(controller, event)
{
var count = sessionStoreService.getClosedTabCount(controller.window);
switch (event.type) {
case "menu":
throw new Error("Menu gets build dynamically and cannot be accessed.");
break;
case "shortcut":
var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
break;
}
if (count > 0)
controller.assertJS("subject.newTabCount < subject.oldTabCount",
{
newTabCount : sessionStoreService.getClosedTabCount(controller.window),
oldTabCount : count
});
} | [
"function",
"undoClosedTab",
"(",
"controller",
",",
"event",
")",
"{",
"var",
"count",
"=",
"sessionStoreService",
".",
"getClosedTabCount",
"(",
"controller",
".",
"window",
")",
";",
"switch",
"(",
"event",
".",
"type",
")",
"{",
"case",
"\"menu\"",
":",
... | Restores the tab which has been recently closed
@param {MozMillController} controller
MozMillController of the window to operate on
@param {object} event
Specifies the event to use to execute the command | [
"Restores",
"the",
"tab",
"which",
"has",
"been",
"recently",
"closed"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/sessionstore.js#L259-L279 | train | Undo a closed tab | [
30522,
3853,
25672,
20464,
24768,
2696,
2497,
1006,
11486,
1010,
2724,
1007,
1063,
13075,
4175,
1027,
6521,
19277,
8043,
7903,
2063,
1012,
2131,
20464,
24768,
2696,
9818,
21723,
1006,
11486,
1012,
3332,
1007,
1025,
6942,
1006,
2724,
1012,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | getDepth | function getDepth(ancestor, descendant) {
var ret = 0;
while (descendant !== ancestor) {
ret++;
descendant = descendant.parentNode;
if (!descendant)
throw new Error("not a descendant of ancestor!");
}
return ret;
} | javascript | function getDepth(ancestor, descendant) {
var ret = 0;
while (descendant !== ancestor) {
ret++;
descendant = descendant.parentNode;
if (!descendant)
throw new Error("not a descendant of ancestor!");
}
return ret;
} | [
"function",
"getDepth",
"(",
"ancestor",
",",
"descendant",
")",
"{",
"var",
"ret",
"=",
"0",
";",
"while",
"(",
"descendant",
"!==",
"ancestor",
")",
"{",
"ret",
"++",
";",
"descendant",
"=",
"descendant",
".",
"parentNode",
";",
"if",
"(",
"!",
"desc... | Provides the depth of ``descendant`` relative to ``ancestor`` | [
"Provides",
"the",
"depth",
"of",
"descendant",
"relative",
"to",
"ancestor"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L8719-L8728 | train | Get depth of ancestor | [
30522,
3853,
2131,
3207,
13876,
2232,
1006,
13032,
1010,
12608,
1007,
1063,
13075,
2128,
2102,
1027,
1014,
1025,
2096,
1006,
12608,
999,
1027,
1027,
13032,
1007,
1063,
2128,
2102,
1009,
1009,
1025,
12608,
1027,
12608,
1012,
6687,
3630,
3207... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/ui5/plugin.js | collectShortcuts | function collectShortcuts(body) {
function checkAssignment(name, valueNode) {
if ( valueNode.type === Syntax.Literal ) {
currentModule.localNames[name] = {
value: valueNode.value
};
debug("compile time constant found ", name, valueNode.value);
} else if ( valueNode.type === Syntax.MemberExpression ) {
var _import = getLeftmostName(valueNode);
var local = _import && currentModule.localNames[_import];
if ( typeof local === 'object' && local.module ) {
currentModule.localNames[name] = {
module: local.module,
path: getObjectName(valueNode).split('.').slice(1).join('.') // TODO chaining if local has path
};
debug(" found local shortcut: ", name, currentModule.localNames[name]);
}
} else if ( isRequireSyncCall(valueNode) || isProbingRequireCall(valueNode) ) {
if ( valueNode.arguments[0]
&& valueNode.arguments[0].type === Syntax.Literal
&& typeof valueNode.arguments[0].value === 'string' ) {
currentModule.localNames[name] = {
module: valueNode.arguments[0].value
// no (or empty) path
};
debug(" found local import: %s = %s('%s')", name, valueNode.callee.property.name, valueNode.arguments[0].value);
}
} else if ( isExtendCall(valueNode) ) {
currentModule.localNames[name] = {
"class": valueNode.arguments[0].value
// no (or empty) path
};
debug(" found local class definition: %s = .extend('%s', ...)", name, valueNode.arguments[0].value);
}
}
if ( body.type === Syntax.BlockStatement ) {
body.body.forEach(function ( stmt ) {
// console.log(stmt);
if ( stmt.type === Syntax.VariableDeclaration ) {
stmt.declarations.forEach(function(decl) {
if ( decl.init ) {
checkAssignment(decl.id.name, decl.init);
}
});
} else if ( stmt.type === Syntax.ExpressionStatement
&& stmt.expression.type === Syntax.AssignmentExpression
&& stmt.expression.left.type === Syntax.Identifier ) {
checkAssignment(stmt.expression.left.name, stmt.expression.right);
}
});
}
} | javascript | function collectShortcuts(body) {
function checkAssignment(name, valueNode) {
if ( valueNode.type === Syntax.Literal ) {
currentModule.localNames[name] = {
value: valueNode.value
};
debug("compile time constant found ", name, valueNode.value);
} else if ( valueNode.type === Syntax.MemberExpression ) {
var _import = getLeftmostName(valueNode);
var local = _import && currentModule.localNames[_import];
if ( typeof local === 'object' && local.module ) {
currentModule.localNames[name] = {
module: local.module,
path: getObjectName(valueNode).split('.').slice(1).join('.') // TODO chaining if local has path
};
debug(" found local shortcut: ", name, currentModule.localNames[name]);
}
} else if ( isRequireSyncCall(valueNode) || isProbingRequireCall(valueNode) ) {
if ( valueNode.arguments[0]
&& valueNode.arguments[0].type === Syntax.Literal
&& typeof valueNode.arguments[0].value === 'string' ) {
currentModule.localNames[name] = {
module: valueNode.arguments[0].value
// no (or empty) path
};
debug(" found local import: %s = %s('%s')", name, valueNode.callee.property.name, valueNode.arguments[0].value);
}
} else if ( isExtendCall(valueNode) ) {
currentModule.localNames[name] = {
"class": valueNode.arguments[0].value
// no (or empty) path
};
debug(" found local class definition: %s = .extend('%s', ...)", name, valueNode.arguments[0].value);
}
}
if ( body.type === Syntax.BlockStatement ) {
body.body.forEach(function ( stmt ) {
// console.log(stmt);
if ( stmt.type === Syntax.VariableDeclaration ) {
stmt.declarations.forEach(function(decl) {
if ( decl.init ) {
checkAssignment(decl.id.name, decl.init);
}
});
} else if ( stmt.type === Syntax.ExpressionStatement
&& stmt.expression.type === Syntax.AssignmentExpression
&& stmt.expression.left.type === Syntax.Identifier ) {
checkAssignment(stmt.expression.left.name, stmt.expression.right);
}
});
}
} | [
"function",
"collectShortcuts",
"(",
"body",
")",
"{",
"function",
"checkAssignment",
"(",
"name",
",",
"valueNode",
")",
"{",
"if",
"(",
"valueNode",
".",
"type",
"===",
"Syntax",
".",
"Literal",
")",
"{",
"currentModule",
".",
"localNames",
"[",
"name",
... | Searches the given body for variable declarations that can be evaluated statically,
either because they refer to known AMD modukle imports (e.g. shortcut varialbes)
or because they have a (design time) constant value.
@param {ASTNode} body AST node of a function body that shall be searched for shortcuts | [
"Searches",
"the",
"given",
"body",
"for",
"variable",
"declarations",
"that",
"can",
"be",
"evaluated",
"statically",
"either",
"because",
"they",
"refer",
"to",
"known",
"AMD",
"modukle",
"imports",
"(",
"e",
".",
"g",
".",
"shortcut",
"varialbes",
")",
"o... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/plugin.js#L289-L342 | train | collects all the shortcut names | [
30522,
3853,
17427,
27794,
12690,
2015,
1006,
2303,
1007,
1063,
3853,
4638,
12054,
24838,
1006,
2171,
1010,
3643,
3630,
3207,
1007,
1063,
2065,
1006,
3643,
3630,
3207,
1012,
2828,
1027,
1027,
1027,
20231,
1012,
18204,
1007,
1063,
2783,
5302... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(array, key, defaultValue)
{
var value = (array != null) ? array[key] : null;
if (value == null)
{
value = defaultValue;
}
else if (value == mxConstants.NONE)
{
value = null;
}
return value;
} | javascript | function(array, key, defaultValue)
{
var value = (array != null) ? array[key] : null;
if (value == null)
{
value = defaultValue;
}
else if (value == mxConstants.NONE)
{
value = null;
}
return value;
} | [
"function",
"(",
"array",
",",
"key",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"(",
"array",
"!=",
"null",
")",
"?",
"array",
"[",
"key",
"]",
":",
"null",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"defaultValue",
... | Function: getColor
Returns the color value for the given key in the given associative
array or the given default value if the value is null. If the value
is <mxConstants.NONE> then null is returned.
Parameters:
array - Associative array that contains the value for the key.
key - Key whose value should be returned.
defaultValue - Value to be returned if the value for the given
key is null. Default is null. | [
"Function",
":",
"getColor"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3826-L3840 | train | Returns the value of the specified key in the given array. | [
30522,
3853,
1006,
9140,
1010,
3145,
1010,
12398,
10175,
5657,
1007,
1063,
13075,
3643,
1027,
1006,
9140,
999,
1027,
19701,
1007,
1029,
9140,
1031,
3145,
1033,
1024,
19701,
1025,
2065,
1006,
3643,
1027,
1027,
19701,
1007,
1063,
3643,
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/menu/js/menuServiceProvider.js | onMenuKeyDown | function onMenuKeyDown(ev) {
var handled;
switch (ev.keyCode) {
case $mdConstant.KEY_CODE.ESCAPE:
opts.mdMenuCtrl.close(false, { closeAll: true });
handled = true;
break;
case $mdConstant.KEY_CODE.TAB:
opts.mdMenuCtrl.close(false, { closeAll: true });
// Don't prevent default or stop propagation on this event as we want tab
// to move the focus to the next focusable element on the page.
handled = false;
break;
case $mdConstant.KEY_CODE.UP_ARROW:
if (!focusMenuItem(ev, opts.menuContentEl, opts, -1) && !opts.nestLevel) {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.DOWN_ARROW:
if (!focusMenuItem(ev, opts.menuContentEl, opts, 1) && !opts.nestLevel) {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.LEFT_ARROW:
if (opts.nestLevel) {
opts.mdMenuCtrl.close();
} else {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.RIGHT_ARROW:
var parentMenu = $mdUtil.getClosest(ev.target, 'MD-MENU');
if (parentMenu && parentMenu != opts.parent[0]) {
ev.target.click();
} else {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
}
if (handled) {
ev.preventDefault();
ev.stopImmediatePropagation();
}
} | javascript | function onMenuKeyDown(ev) {
var handled;
switch (ev.keyCode) {
case $mdConstant.KEY_CODE.ESCAPE:
opts.mdMenuCtrl.close(false, { closeAll: true });
handled = true;
break;
case $mdConstant.KEY_CODE.TAB:
opts.mdMenuCtrl.close(false, { closeAll: true });
// Don't prevent default or stop propagation on this event as we want tab
// to move the focus to the next focusable element on the page.
handled = false;
break;
case $mdConstant.KEY_CODE.UP_ARROW:
if (!focusMenuItem(ev, opts.menuContentEl, opts, -1) && !opts.nestLevel) {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.DOWN_ARROW:
if (!focusMenuItem(ev, opts.menuContentEl, opts, 1) && !opts.nestLevel) {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.LEFT_ARROW:
if (opts.nestLevel) {
opts.mdMenuCtrl.close();
} else {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
case $mdConstant.KEY_CODE.RIGHT_ARROW:
var parentMenu = $mdUtil.getClosest(ev.target, 'MD-MENU');
if (parentMenu && parentMenu != opts.parent[0]) {
ev.target.click();
} else {
opts.mdMenuCtrl.triggerContainerProxy(ev);
}
handled = true;
break;
}
if (handled) {
ev.preventDefault();
ev.stopImmediatePropagation();
}
} | [
"function",
"onMenuKeyDown",
"(",
"ev",
")",
"{",
"var",
"handled",
";",
"switch",
"(",
"ev",
".",
"keyCode",
")",
"{",
"case",
"$mdConstant",
".",
"KEY_CODE",
".",
"ESCAPE",
":",
"opts",
".",
"mdMenuCtrl",
".",
"close",
"(",
"false",
",",
"{",
"closeA... | ************************************ internal functions ************************************ | [
"************************************",
"internal",
"functions",
"************************************"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/menu/js/menuServiceProvider.js#L288-L335 | train | A keydown event handler for the menu | [
30522,
3853,
2006,
3549,
15851,
25688,
12384,
1006,
23408,
1007,
1063,
13075,
8971,
1025,
6942,
1006,
23408,
1012,
3145,
16044,
1007,
1063,
2553,
1002,
9108,
8663,
12693,
2102,
1012,
3145,
1035,
3642,
1012,
4019,
1024,
23569,
2015,
1012,
91... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/file/FileUtils.js | getFilenameWithoutExtension | function getFilenameWithoutExtension(filename) {
var index = filename.lastIndexOf(".");
return index === -1 ? filename : filename.slice(0, index);
} | javascript | function getFilenameWithoutExtension(filename) {
var index = filename.lastIndexOf(".");
return index === -1 ? filename : filename.slice(0, index);
} | [
"function",
"getFilenameWithoutExtension",
"(",
"filename",
")",
"{",
"var",
"index",
"=",
"filename",
".",
"lastIndexOf",
"(",
"\".\"",
")",
";",
"return",
"index",
"===",
"-",
"1",
"?",
"filename",
":",
"filename",
".",
"slice",
"(",
"0",
",",
"index",
... | Get the file name without the extension. Returns "" if name starts with "."
@param {string} filename File name of a file or directory, without preceding path
@return {string} Returns the file name without the extension | [
"Get",
"the",
"file",
"name",
"without",
"the",
"extension",
".",
"Returns",
"if",
"name",
"starts",
"with",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L428-L431 | train | Returns the filename without the last. | [
30522,
3853,
2131,
8873,
20844,
4168,
24415,
5833,
10288,
29048,
1006,
5371,
18442,
1007,
1063,
13075,
5950,
1027,
5371,
18442,
1012,
2197,
22254,
10288,
11253,
1006,
1000,
1012,
1000,
1007,
1025,
2709,
5950,
1027,
1027,
1027,
1011,
1015,
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... |
vuejs/vue-devtools | src/backend/index.js | processObservables | function processObservables (instance) {
var obs = instance.$observables
if (obs) {
return Object.keys(obs).map(key => {
return {
type: 'observables',
key,
value: instance[key]
}
})
} else {
return []
}
} | javascript | function processObservables (instance) {
var obs = instance.$observables
if (obs) {
return Object.keys(obs).map(key => {
return {
type: 'observables',
key,
value: instance[key]
}
})
} else {
return []
}
} | [
"function",
"processObservables",
"(",
"instance",
")",
"{",
"var",
"obs",
"=",
"instance",
".",
"$observables",
"if",
"(",
"obs",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obs",
")",
".",
"map",
"(",
"key",
"=>",
"{",
"return",
"{",
"type",
"... | Process vue-rx observable bindings.
@param {Vue} instance
@return {Array} | [
"Process",
"vue",
"-",
"rx",
"observable",
"bindings",
"."
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/backend/index.js#L864-L877 | train | Process the observers of an instance | [
30522,
3853,
2832,
16429,
8043,
12423,
2015,
1006,
6013,
1007,
1063,
13075,
27885,
2015,
1027,
6013,
1012,
1002,
27885,
8043,
12423,
2015,
2065,
1006,
27885,
2015,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
27885,
2015,
1007,
1012,
4949,
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... |
Dogfalo/materialize | dist/js/materialize.js | Range | function Range(el, options) {
_classCallCheck(this, Range);
var _this72 = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, Range, el, options));
_this72.el.M_Range = _this72;
/**
* Options for the range
* @member Range#options
*/
_this72.options = $.extend({}, Range.defaults, options);
_this72._mousedown = false;
// Setup
_this72._setupThumb();
_this72._setupEventHandlers();
return _this72;
} | javascript | function Range(el, options) {
_classCallCheck(this, Range);
var _this72 = _possibleConstructorReturn(this, (Range.__proto__ || Object.getPrototypeOf(Range)).call(this, Range, el, options));
_this72.el.M_Range = _this72;
/**
* Options for the range
* @member Range#options
*/
_this72.options = $.extend({}, Range.defaults, options);
_this72._mousedown = false;
// Setup
_this72._setupThumb();
_this72._setupEventHandlers();
return _this72;
} | [
"function",
"Range",
"(",
"el",
",",
"options",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"Range",
")",
";",
"var",
"_this72",
"=",
"_possibleConstructorReturn",
"(",
"this",
",",
"(",
"Range",
".",
"__proto__",
"||",
"Object",
".",
"getPrototypeOf",
... | Construct Range instance
@constructor
@param {Element} el
@param {Object} options | [
"Construct",
"Range",
"instance"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L12094-L12114 | train | Construct a new Range instance | [
30522,
3853,
2846,
1006,
3449,
1010,
7047,
1007,
1063,
1035,
2465,
9289,
29358,
11012,
1006,
2023,
1010,
2846,
1007,
1025,
13075,
1035,
2023,
2581,
2475,
1027,
1035,
2825,
8663,
3367,
6820,
16761,
13465,
14287,
1006,
2023,
1010,
1006,
2846,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/qunit/utils/ControlIterator.js | function(aControls, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback) {
return new Promise(function(resolve, reject){
var iControlCountInLib = 0;
var loop = function(i) {
if (i < aControls.length) {
var sControlName = aControls[i];
handleControl(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(bCountThisControl){
if (bCountThisControl) {
iControlCountInLib++;
}
loop(i + 1);
});
} else {
resolve(iControlCountInLib);
}
};
loop(0);
});
} | javascript | function(aControls, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback) {
return new Promise(function(resolve, reject){
var iControlCountInLib = 0;
var loop = function(i) {
if (i < aControls.length) {
var sControlName = aControls[i];
handleControl(sControlName, aControlsToTest, aExcludedControls, bIncludeNonRenderable, bIncludeNonInstantiable, fnCallback).then(function(bCountThisControl){
if (bCountThisControl) {
iControlCountInLib++;
}
loop(i + 1);
});
} else {
resolve(iControlCountInLib);
}
};
loop(0);
});
} | [
"function",
"(",
"aControls",
",",
"aControlsToTest",
",",
"aExcludedControls",
",",
"bIncludeNonRenderable",
",",
"bIncludeNonInstantiable",
",",
"fnCallback",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
... | Calls the callback function for all controls in the given array, unless they are explicitly excluded | [
"Calls",
"the",
"callback",
"function",
"for",
"all",
"controls",
"in",
"the",
"given",
"array",
"unless",
"they",
"are",
"explicitly",
"excluded"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L380-L401 | train | Handle control names | [
30522,
3853,
1006,
9353,
12162,
13153,
2015,
1010,
9353,
12162,
13153,
16033,
22199,
1010,
29347,
2595,
20464,
13936,
8663,
13181,
4877,
1010,
8026,
20464,
12672,
8540,
7389,
4063,
3085,
1010,
8026,
20464,
12672,
8540,
7076,
5794,
10711,
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... | |
getinsomnia/insomnia | packages/insomnia-importers/src/importers/openapi3.js | importFolderItem | function importFolderItem(item, parentId) {
return {
parentId,
_id: `__GRP_${requestGroupCount++}__`,
_type: 'request_group',
name: item.name || `Folder {requestGroupCount}`,
description: item.description || '',
};
} | javascript | function importFolderItem(item, parentId) {
return {
parentId,
_id: `__GRP_${requestGroupCount++}__`,
_type: 'request_group',
name: item.name || `Folder {requestGroupCount}`,
description: item.description || '',
};
} | [
"function",
"importFolderItem",
"(",
"item",
",",
"parentId",
")",
"{",
"return",
"{",
"parentId",
",",
"_id",
":",
"`",
"${",
"requestGroupCount",
"++",
"}",
"`",
",",
"_type",
":",
"'request_group'",
",",
"name",
":",
"item",
".",
"name",
"||",
"`",
... | Return Insomnia folder / request group
@param {Object} item - OpenAPI 3 endpoint schema
@param {string} parentId - id of parent category
@returns {Object} | [
"Return",
"Insomnia",
"folder",
"/",
"request",
"group"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-importers/src/importers/openapi3.js#L144-L152 | train | Import a folder item into a request group | [
30522,
3853,
12324,
10371,
11124,
18532,
1006,
8875,
1010,
6687,
3593,
1007,
1063,
2709,
1063,
6687,
3593,
1010,
1035,
8909,
1024,
1036,
1035,
1035,
24665,
2361,
1035,
1002,
1063,
5227,
17058,
3597,
16671,
1009,
1009,
1065,
1035,
1035,
1036... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | generateSlug | function generateSlug(Model, base, options) {
var slug,
slugTryCount = 1,
baseName = Model.prototype.tableName.replace(/s$/, ''),
// Look for a matching slug, append an incrementing number if so
checkIfSlugExists, longSlug;
checkIfSlugExists = function checkIfSlugExists(slugToFind) {
var args = {slug: slugToFind};
// status is needed for posts
if (options && options.status) {
args.status = options.status;
}
return Model.findOne(args, options).then(function then(found) {
var trimSpace;
if (!found) {
return slugToFind;
}
slugTryCount += 1;
// If we shortened, go back to the full version and try again
if (slugTryCount === 2 && longSlug) {
slugToFind = longSlug;
longSlug = null;
slugTryCount = 1;
return checkIfSlugExists(slugToFind);
}
// If this is the first time through, add the hyphen
if (slugTryCount === 2) {
slugToFind += '-';
} else {
// Otherwise, trim the number off the end
trimSpace = -(String(slugTryCount - 1).length);
slugToFind = slugToFind.slice(0, trimSpace);
}
slugToFind += slugTryCount;
return checkIfSlugExists(slugToFind);
});
};
slug = security.string.safe(base, options);
// the slug may never be longer than the allowed limit of 191 chars, but should also
// take the counter into count. We reduce a too long slug to 185 so we're always on the
// safe side, also in terms of checking for existing slugs already.
if (slug.length > 185) {
// CASE: don't cut the slug on import
if (!_.has(options, 'importing') || !options.importing) {
slug = slug.slice(0, 185);
}
}
// If it's a user, let's try to cut it down (unless this is a human request)
if (baseName === 'user' && options && options.shortSlug && slugTryCount === 1 && slug !== 'ghost-owner') {
longSlug = slug;
slug = (slug.indexOf('-') > -1) ? slug.substr(0, slug.indexOf('-')) : slug;
}
if (!_.has(options, 'importing') || !options.importing) {
// This checks if the first character of a tag name is a #. If it is, this
// is an internal tag, and as such we should add 'hash' to the beginning of the slug
if (baseName === 'tag' && /^#/.test(base)) {
slug = 'hash-' + slug;
}
}
// Some keywords cannot be changed
const slugList = _.union(config.get('slugs').reserved, urlService.utils.getProtectedSlugs());
slug = _.includes(slugList, slug) ? slug + '-' + baseName : slug;
// if slug is empty after trimming use the model name
if (!slug) {
slug = baseName;
}
// Test for duplicate slugs.
return checkIfSlugExists(slug);
} | javascript | function generateSlug(Model, base, options) {
var slug,
slugTryCount = 1,
baseName = Model.prototype.tableName.replace(/s$/, ''),
// Look for a matching slug, append an incrementing number if so
checkIfSlugExists, longSlug;
checkIfSlugExists = function checkIfSlugExists(slugToFind) {
var args = {slug: slugToFind};
// status is needed for posts
if (options && options.status) {
args.status = options.status;
}
return Model.findOne(args, options).then(function then(found) {
var trimSpace;
if (!found) {
return slugToFind;
}
slugTryCount += 1;
// If we shortened, go back to the full version and try again
if (slugTryCount === 2 && longSlug) {
slugToFind = longSlug;
longSlug = null;
slugTryCount = 1;
return checkIfSlugExists(slugToFind);
}
// If this is the first time through, add the hyphen
if (slugTryCount === 2) {
slugToFind += '-';
} else {
// Otherwise, trim the number off the end
trimSpace = -(String(slugTryCount - 1).length);
slugToFind = slugToFind.slice(0, trimSpace);
}
slugToFind += slugTryCount;
return checkIfSlugExists(slugToFind);
});
};
slug = security.string.safe(base, options);
// the slug may never be longer than the allowed limit of 191 chars, but should also
// take the counter into count. We reduce a too long slug to 185 so we're always on the
// safe side, also in terms of checking for existing slugs already.
if (slug.length > 185) {
// CASE: don't cut the slug on import
if (!_.has(options, 'importing') || !options.importing) {
slug = slug.slice(0, 185);
}
}
// If it's a user, let's try to cut it down (unless this is a human request)
if (baseName === 'user' && options && options.shortSlug && slugTryCount === 1 && slug !== 'ghost-owner') {
longSlug = slug;
slug = (slug.indexOf('-') > -1) ? slug.substr(0, slug.indexOf('-')) : slug;
}
if (!_.has(options, 'importing') || !options.importing) {
// This checks if the first character of a tag name is a #. If it is, this
// is an internal tag, and as such we should add 'hash' to the beginning of the slug
if (baseName === 'tag' && /^#/.test(base)) {
slug = 'hash-' + slug;
}
}
// Some keywords cannot be changed
const slugList = _.union(config.get('slugs').reserved, urlService.utils.getProtectedSlugs());
slug = _.includes(slugList, slug) ? slug + '-' + baseName : slug;
// if slug is empty after trimming use the model name
if (!slug) {
slug = baseName;
}
// Test for duplicate slugs.
return checkIfSlugExists(slug);
} | [
"function",
"generateSlug",
"(",
"Model",
",",
"base",
",",
"options",
")",
"{",
"var",
"slug",
",",
"slugTryCount",
"=",
"1",
",",
"baseName",
"=",
"Model",
".",
"prototype",
".",
"tableName",
".",
"replace",
"(",
"/",
"s$",
"/",
",",
"''",
")",
","... | ### Generate Slug
Create a string to act as the permalink for an object.
@param {ghostBookshelf.Model} Model Model type to generate a slug for
@param {String} base The string for which to generate a slug, usually a title or name
@param {Object} options Options to pass to findOne
@return {Promise(String)} Resolves to a unique slug string | [
"###",
"Generate",
"Slug",
"Create",
"a",
"string",
"to",
"act",
"as",
"the",
"permalink",
"for",
"an",
"object",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L1039-L1123 | train | Generate a slug for a model | [
30522,
3853,
19421,
7630,
2290,
1006,
2944,
1010,
2918,
1010,
7047,
1007,
1063,
13075,
23667,
1010,
23667,
11129,
3597,
16671,
1027,
1015,
1010,
2918,
18442,
1027,
2944,
1012,
8773,
1012,
2795,
18442,
1012,
5672,
1006,
1013,
1055,
1002,
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... |
TryGhost/Ghost | core/server/data/schema/commands.js | createTable | function createTable(table, transaction) {
return (transaction || db.knex).schema.hasTable(table)
.then(function (exists) {
if (exists) {
return;
}
return (transaction || db.knex).schema.createTable(table, function (t) {
var columnKeys = _.keys(schema[table]);
_.each(columnKeys, function (column) {
return addTableColumn(table, t, column);
});
});
});
} | javascript | function createTable(table, transaction) {
return (transaction || db.knex).schema.hasTable(table)
.then(function (exists) {
if (exists) {
return;
}
return (transaction || db.knex).schema.createTable(table, function (t) {
var columnKeys = _.keys(schema[table]);
_.each(columnKeys, function (column) {
return addTableColumn(table, t, column);
});
});
});
} | [
"function",
"createTable",
"(",
"table",
",",
"transaction",
")",
"{",
"return",
"(",
"transaction",
"||",
"db",
".",
"knex",
")",
".",
"schema",
".",
"hasTable",
"(",
"table",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"e... | https://github.com/tgriesser/knex/issues/1303
createTableIfNotExists can throw error if indexes are already in place | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"tgriesser",
"/",
"knex",
"/",
"issues",
"/",
"1303",
"createTableIfNotExists",
"can",
"throw",
"error",
"if",
"indexes",
"are",
"already",
"in",
"place"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/data/schema/commands.js#L79-L93 | train | create table if not exists | [
30522,
3853,
3443,
10880,
1006,
2795,
1010,
12598,
1007,
1063,
2709,
1006,
12598,
1064,
1064,
16962,
1012,
14161,
10288,
1007,
1012,
8040,
28433,
1012,
2038,
10880,
1006,
2795,
1007,
1012,
2059,
1006,
3853,
1006,
6526,
1007,
1063,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ReactiveX/rxjs | .make-helpers.js | createImportTargets | function createImportTargets(importTargets, targetName, targetDirectory) {
const importMap = {};
for (const x in importTargets) {
importMap['rxjs/' + x] = ('rxjs-compat/' + targetName + importTargets[x]).replace(/\.js$/, '');
}
const outputData =
`
"use strict"
var path = require('path');
var dir = path.resolve(__dirname);
module.exports = function() {
return ${JSON.stringify(importMap, null, 4)};
}
`
fs.outputFileSync(targetDirectory + 'path-mapping.js', outputData);
} | javascript | function createImportTargets(importTargets, targetName, targetDirectory) {
const importMap = {};
for (const x in importTargets) {
importMap['rxjs/' + x] = ('rxjs-compat/' + targetName + importTargets[x]).replace(/\.js$/, '');
}
const outputData =
`
"use strict"
var path = require('path');
var dir = path.resolve(__dirname);
module.exports = function() {
return ${JSON.stringify(importMap, null, 4)};
}
`
fs.outputFileSync(targetDirectory + 'path-mapping.js', outputData);
} | [
"function",
"createImportTargets",
"(",
"importTargets",
",",
"targetName",
",",
"targetDirectory",
")",
"{",
"const",
"importMap",
"=",
"{",
"}",
";",
"for",
"(",
"const",
"x",
"in",
"importTargets",
")",
"{",
"importMap",
"[",
"'rxjs/'",
"+",
"x",
"]",
"... | Create a file that exports the importTargets object | [
"Create",
"a",
"file",
"that",
"exports",
"the",
"importTargets",
"object"
] | 1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f | https://github.com/ReactiveX/rxjs/blob/1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f/.make-helpers.js#L40-L59 | train | Creates the importTargets object | [
30522,
3853,
3443,
5714,
6442,
7559,
18150,
2015,
1006,
12324,
7559,
18150,
2015,
1010,
4539,
18442,
1010,
4539,
4305,
2890,
16761,
2100,
1007,
1063,
9530,
3367,
12324,
2863,
2361,
1027,
1063,
1065,
1025,
2005,
1006,
9530,
3367,
1060,
1999,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | data/prefixes.js | f | function f (data, opts, callback) {
data = unpack(data)
if (!callback) {
[callback, opts] = [opts, {}]
}
let match = opts.match || /\sx($|\s)/
let need = []
for (let browser in data.stats) {
let versions = data.stats[browser]
for (let version in versions) {
let support = versions[version]
if (support.match(match)) {
need.push(browser + ' ' + version)
}
}
}
callback(need.sort(browsersSort))
} | javascript | function f (data, opts, callback) {
data = unpack(data)
if (!callback) {
[callback, opts] = [opts, {}]
}
let match = opts.match || /\sx($|\s)/
let need = []
for (let browser in data.stats) {
let versions = data.stats[browser]
for (let version in versions) {
let support = versions[version]
if (support.match(match)) {
need.push(browser + ' ' + version)
}
}
}
callback(need.sort(browsersSort))
} | [
"function",
"f",
"(",
"data",
",",
"opts",
",",
"callback",
")",
"{",
"data",
"=",
"unpack",
"(",
"data",
")",
"if",
"(",
"!",
"callback",
")",
"{",
"[",
"callback",
",",
"opts",
"]",
"=",
"[",
"opts",
",",
"{",
"}",
"]",
"}",
"let",
"match",
... | Convert Can I Use data | [
"Convert",
"Can",
"I",
"Use",
"data"
] | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/data/prefixes.js#L18-L39 | train | returns an array of all the browsers that are not supported by the specified filter | [
30522,
3853,
1042,
1006,
2951,
1010,
23569,
2015,
1010,
2655,
5963,
1007,
1063,
2951,
1027,
4895,
23947,
1006,
2951,
1007,
2065,
1006,
999,
2655,
5963,
1007,
1063,
1031,
2655,
5963,
1010,
23569,
2015,
1033,
1027,
1031,
23569,
2015,
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... |
apache/incubator-echarts | src/component/timeline/SliderTimelineView.js | giveSymbol | function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
var color = itemStyleModel.get('color');
if (!symbol) {
var symbolType = hostModel.get('symbol');
symbol = createSymbol(symbolType, -1, -1, 2, 2, color);
symbol.setStyle('strokeNoScale', true);
group.add(symbol);
callback && callback.onCreate(symbol);
}
else {
symbol.setColor(color);
group.add(symbol); // Group may be new, also need to add.
callback && callback.onUpdate(symbol);
}
// Style
var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
symbol.setStyle(itemStyle);
// Transform and events.
opt = zrUtil.merge({
rectHover: true,
z2: 100
}, opt, true);
var symbolSize = hostModel.get('symbolSize');
symbolSize = symbolSize instanceof Array
? symbolSize.slice()
: [+symbolSize, +symbolSize];
symbolSize[0] /= 2;
symbolSize[1] /= 2;
opt.scale = symbolSize;
var symbolOffset = hostModel.get('symbolOffset');
if (symbolOffset) {
var pos = opt.position = opt.position || [0, 0];
pos[0] += numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
pos[1] += numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
}
var symbolRotate = hostModel.get('symbolRotate');
opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
symbol.attr(opt);
// FIXME
// (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
// getBoundingRect will return wrong result.
// (This is supposed to be resolved in zrender, but it is a little difficult to
// leverage performance and auto updateTransform)
// (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
symbol.updateTransform();
return symbol;
} | javascript | function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
var color = itemStyleModel.get('color');
if (!symbol) {
var symbolType = hostModel.get('symbol');
symbol = createSymbol(symbolType, -1, -1, 2, 2, color);
symbol.setStyle('strokeNoScale', true);
group.add(symbol);
callback && callback.onCreate(symbol);
}
else {
symbol.setColor(color);
group.add(symbol); // Group may be new, also need to add.
callback && callback.onUpdate(symbol);
}
// Style
var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
symbol.setStyle(itemStyle);
// Transform and events.
opt = zrUtil.merge({
rectHover: true,
z2: 100
}, opt, true);
var symbolSize = hostModel.get('symbolSize');
symbolSize = symbolSize instanceof Array
? symbolSize.slice()
: [+symbolSize, +symbolSize];
symbolSize[0] /= 2;
symbolSize[1] /= 2;
opt.scale = symbolSize;
var symbolOffset = hostModel.get('symbolOffset');
if (symbolOffset) {
var pos = opt.position = opt.position || [0, 0];
pos[0] += numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
pos[1] += numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
}
var symbolRotate = hostModel.get('symbolRotate');
opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
symbol.attr(opt);
// FIXME
// (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
// getBoundingRect will return wrong result.
// (This is supposed to be resolved in zrender, but it is a little difficult to
// leverage performance and auto updateTransform)
// (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
symbol.updateTransform();
return symbol;
} | [
"function",
"giveSymbol",
"(",
"hostModel",
",",
"itemStyleModel",
",",
"group",
",",
"opt",
",",
"symbol",
",",
"callback",
")",
"{",
"var",
"color",
"=",
"itemStyleModel",
".",
"get",
"(",
"'color'",
")",
";",
"if",
"(",
"!",
"symbol",
")",
"{",
"var... | Create symbol or update symbol
opt: basic position and event handlers | [
"Create",
"symbol",
"or",
"update",
"symbol",
"opt",
":",
"basic",
"position",
"and",
"event",
"handlers"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/timeline/SliderTimelineView.js#L635-L690 | train | This function is called by the symbol layer when the symbol is not found in the host model. | [
30522,
3853,
3957,
24335,
14956,
1006,
3677,
5302,
9247,
1010,
5167,
27983,
5302,
9247,
1010,
2177,
1010,
23569,
1010,
6454,
1010,
2655,
5963,
1007,
1063,
13075,
3609,
1027,
5167,
27983,
5302,
9247,
1012,
2131,
1006,
1005,
3609,
1005,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/api/v0.1/roles.js | modelQuery | function modelQuery(options) {
return models.Role.findAll(options)
.then((models) => {
let roles = models.map((role) => {
return role.toJSON();
});
if (options.permissions !== 'assign') {
return {roles: roles};
}
return Promise.filter(roles.map((role) => {
return canThis(options.context).assign.role(role)
.return(role)
.catch(() => {});
}), (value) => {
return value && value.name !== 'Owner';
}).then((roles) => {
return {
roles: roles
};
});
});
} | javascript | function modelQuery(options) {
return models.Role.findAll(options)
.then((models) => {
let roles = models.map((role) => {
return role.toJSON();
});
if (options.permissions !== 'assign') {
return {roles: roles};
}
return Promise.filter(roles.map((role) => {
return canThis(options.context).assign.role(role)
.return(role)
.catch(() => {});
}), (value) => {
return value && value.name !== 'Owner';
}).then((roles) => {
return {
roles: roles
};
});
});
} | [
"function",
"modelQuery",
"(",
"options",
")",
"{",
"return",
"models",
".",
"Role",
".",
"findAll",
"(",
"options",
")",
".",
"then",
"(",
"(",
"models",
")",
"=>",
"{",
"let",
"roles",
"=",
"models",
".",
"map",
"(",
"(",
"role",
")",
"=>",
"{",
... | ### Model Query
Make the call to the Model layer
@param {Object} options
@returns {Object} options | [
"###",
"Model",
"Query",
"Make",
"the",
"call",
"to",
"the",
"Model",
"layer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/roles.js#L41-L64 | train | Returns a model query | [
30522,
3853,
2944,
4226,
2854,
1006,
7047,
1007,
1063,
2709,
4275,
1012,
2535,
1012,
2424,
8095,
1006,
7047,
1007,
1012,
2059,
1006,
1006,
4275,
1007,
1027,
1028,
1063,
2292,
4395,
1027,
4275,
1012,
4949,
1006,
1006,
2535,
1007,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oRoadMap){
var iRTLFactor = getRTLFactor();
var jStepArea = oRoadMap.$("steparea");
var iScrollLeft = getScrollLeft(jStepArea);
var jStartDelim = oRoadMap.$("Start");
jStartDelim.removeClass("sapUiRoadMapStartScroll").removeClass("sapUiRoadMapStartFixed");
jStartDelim.addClass(iRTLFactor * iScrollLeft >= oRoadMap.iStepWidth ? "sapUiRoadMapStartScroll" : "sapUiRoadMapStartFixed");
var jEndDelim = oRoadMap.$("End");
jEndDelim.removeClass("sapUiRoadMapEndScroll").removeClass("sapUiRoadMapEndFixed");
var bEndReached = jStepArea.get(0).scrollWidth - iRTLFactor * iScrollLeft - jStepArea.width() < oRoadMap.iStepWidth;
jEndDelim.addClass(bEndReached ? "sapUiRoadMapEndFixed" : "sapUiRoadMapEndScroll");
} | javascript | function(oRoadMap){
var iRTLFactor = getRTLFactor();
var jStepArea = oRoadMap.$("steparea");
var iScrollLeft = getScrollLeft(jStepArea);
var jStartDelim = oRoadMap.$("Start");
jStartDelim.removeClass("sapUiRoadMapStartScroll").removeClass("sapUiRoadMapStartFixed");
jStartDelim.addClass(iRTLFactor * iScrollLeft >= oRoadMap.iStepWidth ? "sapUiRoadMapStartScroll" : "sapUiRoadMapStartFixed");
var jEndDelim = oRoadMap.$("End");
jEndDelim.removeClass("sapUiRoadMapEndScroll").removeClass("sapUiRoadMapEndFixed");
var bEndReached = jStepArea.get(0).scrollWidth - iRTLFactor * iScrollLeft - jStepArea.width() < oRoadMap.iStepWidth;
jEndDelim.addClass(bEndReached ? "sapUiRoadMapEndFixed" : "sapUiRoadMapEndScroll");
} | [
"function",
"(",
"oRoadMap",
")",
"{",
"var",
"iRTLFactor",
"=",
"getRTLFactor",
"(",
")",
";",
"var",
"jStepArea",
"=",
"oRoadMap",
".",
"$",
"(",
"\"steparea\"",
")",
";",
"var",
"iScrollLeft",
"=",
"getScrollLeft",
"(",
"jStepArea",
")",
";",
"var",
"... | Refreshs the delimiters according to the current scroll state | [
"Refreshs",
"the",
"delimiters",
"according",
"to",
"the",
"current",
"scroll",
"state"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L779-L794 | train | Updates the end delimiter class | [
30522,
3853,
1006,
20298,
4215,
2863,
2361,
1007,
1063,
13075,
20868,
19646,
7011,
16761,
1027,
2131,
5339,
10270,
18908,
2953,
1006,
1007,
1025,
13075,
1046,
13473,
19362,
5243,
1027,
20298,
4215,
2863,
2361,
1012,
1002,
1006,
1000,
3357,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/component/marker/markerHelper.js | markerTypeCalculatorWithExtent | function markerTypeCalculatorWithExtent(
mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim /*, otherDataDim*/);
var calcDataDim = stacked
? data.getCalculationInfo('stackResultDimension')
: targetDataDim;
var value = numCalculate(data, calcDataDim, mlType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
// Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return coordArr;
} | javascript | function markerTypeCalculatorWithExtent(
mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim /*, otherDataDim*/);
var calcDataDim = stacked
? data.getCalculationInfo('stackResultDimension')
: targetDataDim;
var value = numCalculate(data, calcDataDim, mlType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex);
// Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return coordArr;
} | [
"function",
"markerTypeCalculatorWithExtent",
"(",
"mlType",
",",
"data",
",",
"otherDataDim",
",",
"targetDataDim",
",",
"otherCoordIndex",
",",
"targetCoordIndex",
")",
"{",
"var",
"coordArr",
"=",
"[",
"]",
";",
"var",
"stacked",
"=",
"isDimensionStacked",
"(",... | return precision; } | [
"return",
"precision",
";",
"}"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/marker/markerHelper.js#L58-L82 | train | Returns an array of coordArr with the data for the given marker type | [
30522,
3853,
12115,
13874,
9289,
19879,
4263,
24415,
10288,
6528,
2102,
1006,
19875,
13874,
1010,
2951,
1010,
2060,
2850,
17713,
5714,
1010,
4539,
2850,
17713,
5714,
1010,
2060,
3597,
8551,
22254,
10288,
1010,
4539,
3597,
8551,
22254,
10288,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | scripts/utopia.js | function (element, contents, where) {
if(contents || contents === 0) {
if (_.type(contents) !== 'array') {
contents = [contents];
}
var firstChild = element.firstChild;
for (var i=0; i<contents.length; i++) {
var content = contents[i], child;
switch(_.type(content)) {
case 'string':
if(content === '') {
continue;
}
// fall through
case 'number':
child = document.createTextNode(content);
break;
case 'object':
child = _.element.create(content);
break;
default:
child = content;
}
if(child) {
if (!where || where === 'end') {
element.appendChild(child);
}
else if (where === 'start') {
element.insertBefore(child, firstChild);
}
}
}
}
return element;
} | javascript | function (element, contents, where) {
if(contents || contents === 0) {
if (_.type(contents) !== 'array') {
contents = [contents];
}
var firstChild = element.firstChild;
for (var i=0; i<contents.length; i++) {
var content = contents[i], child;
switch(_.type(content)) {
case 'string':
if(content === '') {
continue;
}
// fall through
case 'number':
child = document.createTextNode(content);
break;
case 'object':
child = _.element.create(content);
break;
default:
child = content;
}
if(child) {
if (!where || where === 'end') {
element.appendChild(child);
}
else if (where === 'start') {
element.insertBefore(child, firstChild);
}
}
}
}
return element;
} | [
"function",
"(",
"element",
",",
"contents",
",",
"where",
")",
"{",
"if",
"(",
"contents",
"||",
"contents",
"===",
"0",
")",
"{",
"if",
"(",
"_",
".",
"type",
"(",
"contents",
")",
"!==",
"'array'",
")",
"{",
"contents",
"=",
"[",
"contents",
"]"... | Sets an element’s contents
Contents could be: One or multiple (as an array) of the following:
- An object literal that will be passed through Utopia.element.create
- A string or number, which will become a text node
- An existing DOM element | [
"Sets",
"an",
"element’s",
"contents",
"Contents",
"could",
"be",
":",
"One",
"or",
"multiple",
"(",
"as",
"an",
"array",
")",
"of",
"the",
"following",
":",
"-",
"An",
"object",
"literal",
"that",
"will",
"be",
"passed",
"through",
"Utopia",
".",
"eleme... | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L259-L299 | train | Creates an element with contents | [
30522,
3853,
1006,
5783,
1010,
8417,
1010,
2073,
1007,
1063,
2065,
1006,
8417,
1064,
1064,
8417,
1027,
1027,
1027,
1014,
1007,
1063,
2065,
1006,
1035,
1012,
2828,
1006,
8417,
1007,
999,
1027,
1027,
1005,
9140,
1005,
1007,
1063,
8417,
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... | |
chartjs/Chart.js | src/core/core.plugins.js | function(plugins) {
var p = this._plugins;
([]).concat(plugins).forEach(function(plugin) {
if (p.indexOf(plugin) === -1) {
p.push(plugin);
}
});
this._cacheId++;
} | javascript | function(plugins) {
var p = this._plugins;
([]).concat(plugins).forEach(function(plugin) {
if (p.indexOf(plugin) === -1) {
p.push(plugin);
}
});
this._cacheId++;
} | [
"function",
"(",
"plugins",
")",
"{",
"var",
"p",
"=",
"this",
".",
"_plugins",
";",
"(",
"[",
"]",
")",
".",
"concat",
"(",
"plugins",
")",
".",
"forEach",
"(",
"function",
"(",
"plugin",
")",
"{",
"if",
"(",
"p",
".",
"indexOf",
"(",
"plugin",
... | Registers the given plugin(s) if not already registered.
@param {IPlugin[]|IPlugin} plugins plugin instance(s). | [
"Registers",
"the",
"given",
"plugin",
"(",
"s",
")",
"if",
"not",
"already",
"registered",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.plugins.js#L34-L43 | train | Add a list of plugins to the cache | [
30522,
3853,
1006,
13354,
7076,
1007,
1063,
13075,
1052,
1027,
2023,
1012,
1035,
13354,
7076,
1025,
1006,
1031,
1033,
1007,
1012,
9530,
11266,
1006,
13354,
7076,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
13354,
2378,
1007,
1063,
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... | |
SAP/openui5 | src/sap.ui.core/src/ui5loader.js | findMapForContext | function findMapForContext(sContext) {
var p, mMap;
if ( sContext != null ) {
// maps are defined on module IDs, reduce URN to module ID
sContext = urnToIDAndType(sContext).id;
p = sContext.length;
mMap = mMaps[sContext];
while ( p > 0 && mMap == null ) {
p = sContext.lastIndexOf('/');
if ( p > 0 ) { // Note: an empty segment at p = 0 (leading slash) will be ignored
sContext = sContext.slice(0, p);
mMap = mMaps[sContext];
}
}
}
// if none is found, fallback to '*' map
return mMap || mMaps['*'];
} | javascript | function findMapForContext(sContext) {
var p, mMap;
if ( sContext != null ) {
// maps are defined on module IDs, reduce URN to module ID
sContext = urnToIDAndType(sContext).id;
p = sContext.length;
mMap = mMaps[sContext];
while ( p > 0 && mMap == null ) {
p = sContext.lastIndexOf('/');
if ( p > 0 ) { // Note: an empty segment at p = 0 (leading slash) will be ignored
sContext = sContext.slice(0, p);
mMap = mMaps[sContext];
}
}
}
// if none is found, fallback to '*' map
return mMap || mMaps['*'];
} | [
"function",
"findMapForContext",
"(",
"sContext",
")",
"{",
"var",
"p",
",",
"mMap",
";",
"if",
"(",
"sContext",
"!=",
"null",
")",
"{",
"// maps are defined on module IDs, reduce URN to module ID",
"sContext",
"=",
"urnToIDAndType",
"(",
"sContext",
")",
".",
"id... | Find the most specific map config that matches the given context resource
@param {string} sContext Resource name to be used as context
@returns {Object<string,string>|undefined} Most specific map or <code>undefined</code> | [
"Find",
"the",
"most",
"specific",
"map",
"config",
"that",
"matches",
"the",
"given",
"context",
"resource"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/ui5loader.js#L603-L620 | train | Find the map for the given context | [
30522,
3853,
2424,
2863,
14376,
2953,
8663,
18209,
1006,
8040,
28040,
18413,
1007,
1063,
13075,
1052,
1010,
21021,
2361,
1025,
2065,
1006,
8040,
28040,
18413,
999,
1027,
19701,
1007,
1063,
1013,
1013,
7341,
2024,
4225,
2006,
11336,
8909,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/SyncPromise.js | resolve | function resolve(vResult0) {
var fnThen;
if (vResult0 === that) {
reject(new TypeError("A promise cannot be resolved with itself."));
return;
}
if (vResult0 instanceof SyncPromise) {
if (vResult0.isFulfilled()) {
resolve(vResult0.getResult());
return;
} else if (vResult0.isRejected()) {
vResult0.caught(); // might have been uncaught so far
reject(vResult0.getResult());
return;
} else {
vResult0.caught(); // make sure it will never count as uncaught
vResult0 = vResult0.getResult(); // unwrap to access native thenable
}
}
iState = 0;
vResult = vResult0;
if (hasThen(vResult)) {
try {
fnThen = vResult.then;
} catch (e) {
// 2.3.3.2. If retrieving the property x.then results in a thrown exception e,
// reject promise with e as the reason.
reject(e);
return;
}
if (typeof fnThen === "function") {
call(fnThen.bind(vResult), resolve, reject);
return;
}
}
iState = 1;
if (fnResolve) {
fnResolve(vResult);
fnReject = fnResolve = null; // be nice to the garbage collector
}
} | javascript | function resolve(vResult0) {
var fnThen;
if (vResult0 === that) {
reject(new TypeError("A promise cannot be resolved with itself."));
return;
}
if (vResult0 instanceof SyncPromise) {
if (vResult0.isFulfilled()) {
resolve(vResult0.getResult());
return;
} else if (vResult0.isRejected()) {
vResult0.caught(); // might have been uncaught so far
reject(vResult0.getResult());
return;
} else {
vResult0.caught(); // make sure it will never count as uncaught
vResult0 = vResult0.getResult(); // unwrap to access native thenable
}
}
iState = 0;
vResult = vResult0;
if (hasThen(vResult)) {
try {
fnThen = vResult.then;
} catch (e) {
// 2.3.3.2. If retrieving the property x.then results in a thrown exception e,
// reject promise with e as the reason.
reject(e);
return;
}
if (typeof fnThen === "function") {
call(fnThen.bind(vResult), resolve, reject);
return;
}
}
iState = 1;
if (fnResolve) {
fnResolve(vResult);
fnReject = fnResolve = null; // be nice to the garbage collector
}
} | [
"function",
"resolve",
"(",
"vResult0",
")",
"{",
"var",
"fnThen",
";",
"if",
"(",
"vResult0",
"===",
"that",
")",
"{",
"reject",
"(",
"new",
"TypeError",
"(",
"\"A promise cannot be resolved with itself.\"",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"... | /*
@param {any} [vResult0]
The thenable to wrap or the result to synchronously fulfill with | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/SyncPromise.js#L122-L164 | train | Resolve a promise | [
30522,
3853,
10663,
1006,
27830,
2229,
11314,
2692,
1007,
1063,
13075,
1042,
3372,
10222,
1025,
2065,
1006,
27830,
2229,
11314,
2692,
1027,
1027,
1027,
2008,
1007,
1063,
15454,
1006,
2047,
2828,
2121,
29165,
1006,
1000,
1037,
4872,
3685,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
transloadit/uppy | packages/@uppy/companion/src/server/controllers/s3.js | abortMultipartUpload | function abortMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
client.abortMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({})
})
} | javascript | function abortMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
client.abortMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({})
})
} | [
"function",
"abortMultipartUpload",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// @ts-ignore The `uppy` property is added by middleware before reaching here.",
"const",
"client",
"=",
"req",
".",
"uppy",
".",
"s3Client",
"const",
"{",
"uploadId",
"}",
"=",
"req",... | Abort a multipart upload, deleting already uploaded parts.
Expected URL parameters:
- uploadId - The uploadId returned from `createMultipartUpload`.
Expected query parameters:
- key - The object key in the S3 bucket.
Response JSON:
Empty. | [
"Abort",
"a",
"multipart",
"upload",
"deleting",
"already",
"uploaded",
"parts",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L204-L225 | train | Aborts a multipart upload | [
30522,
3853,
11113,
11589,
12274,
7096,
11514,
8445,
6279,
11066,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
1030,
24529,
1011,
8568,
1996,
1036,
2039,
7685,
1036,
3200,
2003,
2794,
2011,
2690,
8059,
2077,
4285,
2182... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
expressjs/express | examples/view-locals/index.js | count2 | function count2(req, res, next) {
User.count(function(err, count){
if (err) return next(err);
res.locals.count = count;
next();
})
} | javascript | function count2(req, res, next) {
User.count(function(err, count){
if (err) return next(err);
res.locals.count = count;
next();
})
} | [
"function",
"count2",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"User",
".",
"count",
"(",
"function",
"(",
"err",
",",
"count",
")",
"{",
"if",
"(",
"err",
")",
"return",
"next",
"(",
"err",
")",
";",
"res",
".",
"locals",
".",
"count",
"... | this approach is much like the last however we're explicitly exposing the locals within each middleware note that this may not always work well, for example here we filter the users in the middleware, which may not be ideal for our application. so in that sense the previous example is more flexible with `req.users`. | [
"this",
"approach",
"is",
"much",
"like",
"the",
"last",
"however",
"we",
"re",
"explicitly",
"exposing",
"the",
"locals",
"within",
"each",
"middleware",
"note",
"that",
"this",
"may",
"not",
"always",
"work",
"well",
"for",
"example",
"here",
"we",
"filter... | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/examples/view-locals/index.js#L84-L90 | train | This is the function that is called when the user is not logged in | [
30522,
3853,
4175,
2475,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
5310,
1012,
4175,
1006,
3853,
1006,
9413,
2099,
1010,
4175,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
2709,
2279,
1006,
9413,
2099,
1007,
1025,
24501,
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... |
jgraph/mxgraph | javascript/mxClient.js | mxPanningHandler | function mxPanningHandler(graph)
{
if (graph != null)
{
this.graph = graph;
this.graph.addMouseListener(this);
// Handles force panning event
this.forcePanningHandler = mxUtils.bind(this, function(sender, evt)
{
var evtName = evt.getProperty('eventName');
var me = evt.getProperty('event');
if (evtName == mxEvent.MOUSE_DOWN && this.isForcePanningEvent(me))
{
this.start(me);
this.active = true;
this.fireEvent(new mxEventObject(mxEvent.PAN_START, 'event', me));
me.consume();
}
});
this.graph.addListener(mxEvent.FIRE_MOUSE_EVENT, this.forcePanningHandler);
// Handles pinch gestures
this.gestureHandler = mxUtils.bind(this, function(sender, eo)
{
if (this.isPinchEnabled())
{
var evt = eo.getProperty('event');
if (!mxEvent.isConsumed(evt) && evt.type == 'gesturestart')
{
this.initialScale = this.graph.view.scale;
// Forces start of panning when pinch gesture starts
if (!this.active && this.mouseDownEvent != null)
{
this.start(this.mouseDownEvent);
this.mouseDownEvent = null;
}
}
else if (evt.type == 'gestureend' && this.initialScale != null)
{
this.initialScale = null;
}
if (this.initialScale != null)
{
var value = Math.round(this.initialScale * evt.scale * 100) / 100;
if (this.minScale != null)
{
value = Math.max(this.minScale, value);
}
if (this.maxScale != null)
{
value = Math.min(this.maxScale, value);
}
if (this.graph.view.scale != value)
{
this.graph.zoomTo(value);
mxEvent.consume(evt);
}
}
}
});
this.graph.addListener(mxEvent.GESTURE, this.gestureHandler);
this.mouseUpListener = mxUtils.bind(this, function()
{
if (this.active)
{
this.reset();
}
});
// Stops scrolling on every mouseup anywhere in the document
mxEvent.addListener(document, 'mouseup', this.mouseUpListener);
}
} | javascript | function mxPanningHandler(graph)
{
if (graph != null)
{
this.graph = graph;
this.graph.addMouseListener(this);
// Handles force panning event
this.forcePanningHandler = mxUtils.bind(this, function(sender, evt)
{
var evtName = evt.getProperty('eventName');
var me = evt.getProperty('event');
if (evtName == mxEvent.MOUSE_DOWN && this.isForcePanningEvent(me))
{
this.start(me);
this.active = true;
this.fireEvent(new mxEventObject(mxEvent.PAN_START, 'event', me));
me.consume();
}
});
this.graph.addListener(mxEvent.FIRE_MOUSE_EVENT, this.forcePanningHandler);
// Handles pinch gestures
this.gestureHandler = mxUtils.bind(this, function(sender, eo)
{
if (this.isPinchEnabled())
{
var evt = eo.getProperty('event');
if (!mxEvent.isConsumed(evt) && evt.type == 'gesturestart')
{
this.initialScale = this.graph.view.scale;
// Forces start of panning when pinch gesture starts
if (!this.active && this.mouseDownEvent != null)
{
this.start(this.mouseDownEvent);
this.mouseDownEvent = null;
}
}
else if (evt.type == 'gestureend' && this.initialScale != null)
{
this.initialScale = null;
}
if (this.initialScale != null)
{
var value = Math.round(this.initialScale * evt.scale * 100) / 100;
if (this.minScale != null)
{
value = Math.max(this.minScale, value);
}
if (this.maxScale != null)
{
value = Math.min(this.maxScale, value);
}
if (this.graph.view.scale != value)
{
this.graph.zoomTo(value);
mxEvent.consume(evt);
}
}
}
});
this.graph.addListener(mxEvent.GESTURE, this.gestureHandler);
this.mouseUpListener = mxUtils.bind(this, function()
{
if (this.active)
{
this.reset();
}
});
// Stops scrolling on every mouseup anywhere in the document
mxEvent.addListener(document, 'mouseup', this.mouseUpListener);
}
} | [
"function",
"mxPanningHandler",
"(",
"graph",
")",
"{",
"if",
"(",
"graph",
"!=",
"null",
")",
"{",
"this",
".",
"graph",
"=",
"graph",
";",
"this",
".",
"graph",
".",
"addMouseListener",
"(",
"this",
")",
";",
"// Handles force panning event",
"this",
"."... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxPanningHandler
Event handler that pans and creates popupmenus. To use the left
mousebutton for panning without interfering with cell moving and
resizing, use <isUseLeftButton> and <isIgnoreCell>. For grid size
steps while panning, use <useGrid>. This handler is built-into
<mxGraph.panningHandler> and enabled using <mxGraph.setPanning>.
Constructor: mxPanningHandler
Constructs an event handler that creates a <mxPopupMenu>
and pans the graph.
Event: mxEvent.PAN_START
Fires when the panning handler changes its <active> state to true. The
<code>event</code> property contains the corresponding <mxMouseEvent>.
Event: mxEvent.PAN
Fires while handle is processing events. The <code>event</code> property contains
the corresponding <mxMouseEvent>.
Event: mxEvent.PAN_END
Fires when the panning handler changes its <active> state to false. The
<code>event</code> property contains the corresponding <mxMouseEvent>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxPanningHandler"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L70611-L70694 | train | Internal function to handle panning events | [
30522,
3853,
25630,
9739,
5582,
11774,
3917,
1006,
10629,
1007,
1063,
2065,
1006,
10629,
999,
1027,
19701,
1007,
1063,
2023,
1012,
10629,
1027,
10629,
1025,
2023,
1012,
10629,
1012,
5587,
27711,
29282,
6528,
2121,
1006,
2023,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/MDNDocs/main.js | getDocs | function getDocs(fileName) {
if (!promiseCache[fileName]) {
var result = new $.Deferred();
var path = ExtensionUtils.getModulePath(module, fileName),
file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file)
.done(function (text) {
var jsonData;
try {
jsonData = JSON.parse(text);
} catch (ex) {
console.error("Malformed documentation database: ", ex);
result.reject();
}
result.resolve(jsonData); // ignored if we already reject()ed above
})
.fail(function (err) {
console.error("Unable to load documentation database: ", err);
result.reject();
});
promiseCache[fileName] = result.promise();
}
return promiseCache[fileName];
} | javascript | function getDocs(fileName) {
if (!promiseCache[fileName]) {
var result = new $.Deferred();
var path = ExtensionUtils.getModulePath(module, fileName),
file = FileSystem.getFileForPath(path);
FileUtils.readAsText(file)
.done(function (text) {
var jsonData;
try {
jsonData = JSON.parse(text);
} catch (ex) {
console.error("Malformed documentation database: ", ex);
result.reject();
}
result.resolve(jsonData); // ignored if we already reject()ed above
})
.fail(function (err) {
console.error("Unable to load documentation database: ", err);
result.reject();
});
promiseCache[fileName] = result.promise();
}
return promiseCache[fileName];
} | [
"function",
"getDocs",
"(",
"fileName",
")",
"{",
"if",
"(",
"!",
"promiseCache",
"[",
"fileName",
"]",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"path",
"=",
"ExtensionUtils",
".",
"getModulePath",
"(",
"module... | Lazily loads JSON docs files. Returns a Promise the is resolved with the parsed Object, or
rejected if the file is missing/corrupt.
@param {string} fileName JSON file to load
@return {!$.Promise} | [
"Lazily",
"loads",
"JSON",
"docs",
"files",
".",
"Returns",
"a",
"Promise",
"the",
"is",
"resolved",
"with",
"the",
"parsed",
"Object",
"or",
"rejected",
"if",
"the",
"file",
"is",
"missing",
"/",
"corrupt",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/MDNDocs/main.js#L52-L79 | train | Get the documentation from the file | [
30522,
3853,
2131,
3527,
6169,
1006,
5371,
18442,
1007,
1063,
2065,
1006,
999,
4872,
3540,
5403,
1031,
5371,
18442,
1033,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
13075,
4130,
1027,
5331,
21823,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/visual/VisualMapping.js | function (option) {
var mappingMethod = option.mappingMethod;
var visualType = option.type;
/**
* @readOnly
* @type {Object}
*/
var thisOption = this.option = zrUtil.clone(option);
/**
* @readOnly
* @type {string}
*/
this.type = visualType;
/**
* @readOnly
* @type {string}
*/
this.mappingMethod = mappingMethod;
/**
* @private
* @type {Function}
*/
this._normalizeData = normalizers[mappingMethod];
var visualHandler = visualHandlers[visualType];
/**
* @public
* @type {Function}
*/
this.applyVisual = visualHandler.applyVisual;
/**
* @public
* @type {Function}
*/
this.getColorMapper = visualHandler.getColorMapper;
/**
* @private
* @type {Function}
*/
this._doMap = visualHandler._doMap[mappingMethod];
if (mappingMethod === 'piecewise') {
normalizeVisualRange(thisOption);
preprocessForPiecewise(thisOption);
}
else if (mappingMethod === 'category') {
thisOption.categories
? preprocessForSpecifiedCategory(thisOption)
// categories is ordinal when thisOption.categories not specified,
// which need no more preprocess except normalize visual.
: normalizeVisualRange(thisOption, true);
}
else { // mappingMethod === 'linear' or 'fixed'
zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
normalizeVisualRange(thisOption);
}
} | javascript | function (option) {
var mappingMethod = option.mappingMethod;
var visualType = option.type;
/**
* @readOnly
* @type {Object}
*/
var thisOption = this.option = zrUtil.clone(option);
/**
* @readOnly
* @type {string}
*/
this.type = visualType;
/**
* @readOnly
* @type {string}
*/
this.mappingMethod = mappingMethod;
/**
* @private
* @type {Function}
*/
this._normalizeData = normalizers[mappingMethod];
var visualHandler = visualHandlers[visualType];
/**
* @public
* @type {Function}
*/
this.applyVisual = visualHandler.applyVisual;
/**
* @public
* @type {Function}
*/
this.getColorMapper = visualHandler.getColorMapper;
/**
* @private
* @type {Function}
*/
this._doMap = visualHandler._doMap[mappingMethod];
if (mappingMethod === 'piecewise') {
normalizeVisualRange(thisOption);
preprocessForPiecewise(thisOption);
}
else if (mappingMethod === 'category') {
thisOption.categories
? preprocessForSpecifiedCategory(thisOption)
// categories is ordinal when thisOption.categories not specified,
// which need no more preprocess except normalize visual.
: normalizeVisualRange(thisOption, true);
}
else { // mappingMethod === 'linear' or 'fixed'
zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
normalizeVisualRange(thisOption);
}
} | [
"function",
"(",
"option",
")",
"{",
"var",
"mappingMethod",
"=",
"option",
".",
"mappingMethod",
";",
"var",
"visualType",
"=",
"option",
".",
"type",
";",
"/**\n * @readOnly\n * @type {Object}\n */",
"var",
"thisOption",
"=",
"this",
".",
"option",
"... | @param {Object} option
@param {string} [option.type] See visualHandlers.
@param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed'
@param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
required when mappingMethod is 'linear'
@param {Array.<Object>=} [option.pieceList] [
{value: someValue},
{interval: [min1, max1], visual: {...}},
{interval: [min2, max2]}
],
required when mappingMethod is 'piecewise'.
Visual for only each piece can be specified.
@param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
required when mappingMethod is 'category'.
If no option.categories, categories is set
as [0, 1, 2, ...].
@param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
@param {(Array|Object|*)} [option.visual] Visual data.
when mappingMethod is 'category',
visual data can be array or object
(like: {cate1: '#222', none: '#fff'})
or primary types (which represents
defualt category visual), otherwise visual
can be array or primary (which will be
normalized to array). | [
"@param",
"{",
"Object",
"}",
"option",
"@param",
"{",
"string",
"}",
"[",
"option",
".",
"type",
"]",
"See",
"visualHandlers",
".",
"@param",
"{",
"string",
"}",
"[",
"option",
".",
"mappingMethod",
"]",
"linear",
"or",
"piecewise",
"or",
"category",
"o... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/visual/VisualMapping.js#L57-L120 | train | A single node of the cluster | [
30522,
3853,
1006,
5724,
1007,
1063,
13075,
12375,
11368,
6806,
2094,
1027,
5724,
1012,
12375,
11368,
6806,
2094,
1025,
13075,
5107,
13874,
1027,
5724,
1012,
2828,
1025,
1013,
1008,
1008,
1008,
1030,
3191,
2239,
2135,
1008,
1030,
2828,
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.core/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js | aggregate | function aggregate(sAlias) {
var oDetails = oAggregation.aggregate[sAlias],
sAggregate = oDetails.name || sAlias,
sGrandTotal = sAlias,
sWith = oDetails.with;
if (sWith) {
if ((sWith === "average" || sWith === "countdistinct")
&& (oDetails.grandTotal || oDetails.subtotals)) {
throw new Error("Cannot aggregate totals with '" + sWith + "'");
}
sAggregate += " with " + sWith + " as " + sAlias;
} else if (oDetails.name) {
sAggregate += " as " + sAlias;
}
if (!bFollowUp) {
if (oDetails.min) {
processMinOrMax(sAlias, "min");
}
if (oDetails.max) {
processMinOrMax(sAlias, "max");
}
}
if (oDetails.grandTotal) {
bHasGrandTotal = true;
if (!mQueryOptions.$skip) {
if (sWith) {
sGrandTotal += " with " + sWith + " as UI5grand__" + sAlias;
}
aConcatAggregate.push(sGrandTotal);
}
}
return sAggregate;
} | javascript | function aggregate(sAlias) {
var oDetails = oAggregation.aggregate[sAlias],
sAggregate = oDetails.name || sAlias,
sGrandTotal = sAlias,
sWith = oDetails.with;
if (sWith) {
if ((sWith === "average" || sWith === "countdistinct")
&& (oDetails.grandTotal || oDetails.subtotals)) {
throw new Error("Cannot aggregate totals with '" + sWith + "'");
}
sAggregate += " with " + sWith + " as " + sAlias;
} else if (oDetails.name) {
sAggregate += " as " + sAlias;
}
if (!bFollowUp) {
if (oDetails.min) {
processMinOrMax(sAlias, "min");
}
if (oDetails.max) {
processMinOrMax(sAlias, "max");
}
}
if (oDetails.grandTotal) {
bHasGrandTotal = true;
if (!mQueryOptions.$skip) {
if (sWith) {
sGrandTotal += " with " + sWith + " as UI5grand__" + sAlias;
}
aConcatAggregate.push(sGrandTotal);
}
}
return sAggregate;
} | [
"function",
"aggregate",
"(",
"sAlias",
")",
"{",
"var",
"oDetails",
"=",
"oAggregation",
".",
"aggregate",
"[",
"sAlias",
"]",
",",
"sAggregate",
"=",
"oDetails",
".",
"name",
"||",
"sAlias",
",",
"sGrandTotal",
"=",
"sAlias",
",",
"sWith",
"=",
"oDetails... | /*
Returns the corresponding part of the "aggregate" term for an aggregatable property,
for example "AggregatableProperty with method as Alias". Processes min/max as a side
effect.
@param {string} sAlias - An aggregatable property name
@returns {string} - Part of the "aggregate" term
@throws {Error} If "average" or "countdistinct" are used together with subtotals or
grand totals | [
"/",
"*",
"Returns",
"the",
"corresponding",
"part",
"of",
"the",
"aggregate",
"term",
"for",
"an",
"aggregatable",
"property",
"for",
"example",
"AggregatableProperty",
"with",
"method",
"as",
"Alias",
".",
"Processes",
"min",
"/",
"max",
"as",
"a",
"side",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js#L192-L225 | train | Adds an aggregate to the aggregation | [
30522,
3853,
9572,
1006,
16183,
7951,
1007,
1063,
13075,
24040,
22081,
1027,
1051,
8490,
17603,
12540,
1012,
9572,
1031,
16183,
7951,
1033,
1010,
7842,
13871,
2890,
5867,
1027,
24040,
22081,
1012,
2171,
1064,
1064,
16183,
7951,
1010,
22214,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/column-prop-getters.js | getterForProp | function getterForProp(prop) {
if (prop == null)
return emptyStringGetter;
if (typeof prop === 'number') {
return numericIndexGetter;
}
else {
// deep or simple
if (prop.indexOf('.') !== -1) {
return deepValueGetter;
}
else {
return shallowValueGetter;
}
}
} | javascript | function getterForProp(prop) {
if (prop == null)
return emptyStringGetter;
if (typeof prop === 'number') {
return numericIndexGetter;
}
else {
// deep or simple
if (prop.indexOf('.') !== -1) {
return deepValueGetter;
}
else {
return shallowValueGetter;
}
}
} | [
"function",
"getterForProp",
"(",
"prop",
")",
"{",
"if",
"(",
"prop",
"==",
"null",
")",
"return",
"emptyStringGetter",
";",
"if",
"(",
"typeof",
"prop",
"===",
"'number'",
")",
"{",
"return",
"numericIndexGetter",
";",
"}",
"else",
"{",
"// deep or simple"... | Returns the appropriate getter function for this kind of prop.
If prop == null, returns the emptyStringGetter. | [
"Returns",
"the",
"appropriate",
"getter",
"function",
"for",
"this",
"kind",
"of",
"prop",
".",
"If",
"prop",
"==",
"null",
"returns",
"the",
"emptyStringGetter",
"."
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/column-prop-getters.js#L16-L31 | train | Returns a getter function for the given property | [
30522,
3853,
2131,
3334,
29278,
21572,
2361,
1006,
17678,
1007,
1063,
2065,
1006,
17678,
1027,
1027,
19701,
1007,
2709,
4064,
3367,
4892,
18150,
3334,
1025,
2065,
1006,
2828,
11253,
17678,
1027,
1027,
1027,
1005,
2193,
1005,
1007,
1063,
270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ODataUtils.js | function (sTimeOfDay) {
var oTimeOfDay;
if (rTimeOfDay.test(sTimeOfDay)) {
if (sTimeOfDay.length > 12) {
// "round" to millis: "HH:mm:ss.SSS"
sTimeOfDay = sTimeOfDay.slice(0, 12);
}
oTimeOfDay = DateFormat.getTimeInstance({
pattern : "HH:mm:ss.SSS",
strictParsing : true,
UTC : true
}).parse(sTimeOfDay);
}
if (!oTimeOfDay) {
throw new Error("Not a valid Edm.TimeOfDay value: " + sTimeOfDay);
}
return oTimeOfDay;
} | javascript | function (sTimeOfDay) {
var oTimeOfDay;
if (rTimeOfDay.test(sTimeOfDay)) {
if (sTimeOfDay.length > 12) {
// "round" to millis: "HH:mm:ss.SSS"
sTimeOfDay = sTimeOfDay.slice(0, 12);
}
oTimeOfDay = DateFormat.getTimeInstance({
pattern : "HH:mm:ss.SSS",
strictParsing : true,
UTC : true
}).parse(sTimeOfDay);
}
if (!oTimeOfDay) {
throw new Error("Not a valid Edm.TimeOfDay value: " + sTimeOfDay);
}
return oTimeOfDay;
} | [
"function",
"(",
"sTimeOfDay",
")",
"{",
"var",
"oTimeOfDay",
";",
"if",
"(",
"rTimeOfDay",
".",
"test",
"(",
"sTimeOfDay",
")",
")",
"{",
"if",
"(",
"sTimeOfDay",
".",
"length",
">",
"12",
")",
"{",
"// \"round\" to millis: \"HH:mm:ss.SSS\"",
"sTimeOfDay",
... | Parses an "Edm.TimeOfDay" value and returns the corresponding JavaScript
<code>Date</code> value (UTC with a date value of "1970-01-01").
@param {string} sTimeOfDay
The "Edm.TimeOfDay" value to parse
@returns {Date}
The JavaScript <code>Date</code> value
@throws {Error}
If the input cannot be parsed
@public
@since 1.43.0 | [
"Parses",
"an",
"Edm",
".",
"TimeOfDay",
"value",
"and",
"returns",
"the",
"corresponding",
"JavaScript",
"<code",
">",
"Date<",
"/",
"code",
">",
"value",
"(",
"UTC",
"with",
"a",
"date",
"value",
"of",
"1970",
"-",
"01",
"-",
"01",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataUtils.js#L173-L191 | train | Converts a Edm. TimeOfDay value to a Date object | [
30522,
3853,
1006,
2358,
14428,
11253,
10259,
1007,
1063,
13075,
27178,
14428,
11253,
10259,
1025,
2065,
1006,
19387,
14428,
11253,
10259,
1012,
3231,
1006,
2358,
14428,
11253,
10259,
1007,
1007,
1063,
2065,
1006,
2358,
14428,
11253,
10259,
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... | |
sass/node-sass | lib/extensions.js | getBinaryName | function getBinaryName() {
var binaryName,
variant,
platform = process.platform;
if (getArgument('--sass-binary-name')) {
binaryName = getArgument('--sass-binary-name');
} else if (process.env.SASS_BINARY_NAME) {
binaryName = process.env.SASS_BINARY_NAME;
} else if (process.env.npm_config_sass_binary_name) {
binaryName = process.env.npm_config_sass_binary_name;
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.binaryName) {
binaryName = pkg.nodeSassConfig.binaryName;
} else {
variant = getPlatformVariant();
if (variant) {
platform += '_' + variant;
}
binaryName = [
platform, '-',
process.arch, '-',
process.versions.modules
].join('');
}
return [binaryName, 'binding.node'].join('_');
} | javascript | function getBinaryName() {
var binaryName,
variant,
platform = process.platform;
if (getArgument('--sass-binary-name')) {
binaryName = getArgument('--sass-binary-name');
} else if (process.env.SASS_BINARY_NAME) {
binaryName = process.env.SASS_BINARY_NAME;
} else if (process.env.npm_config_sass_binary_name) {
binaryName = process.env.npm_config_sass_binary_name;
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.binaryName) {
binaryName = pkg.nodeSassConfig.binaryName;
} else {
variant = getPlatformVariant();
if (variant) {
platform += '_' + variant;
}
binaryName = [
platform, '-',
process.arch, '-',
process.versions.modules
].join('');
}
return [binaryName, 'binding.node'].join('_');
} | [
"function",
"getBinaryName",
"(",
")",
"{",
"var",
"binaryName",
",",
"variant",
",",
"platform",
"=",
"process",
".",
"platform",
";",
"if",
"(",
"getArgument",
"(",
"'--sass-binary-name'",
")",
")",
"{",
"binaryName",
"=",
"getArgument",
"(",
"'--sass-binary... | Get binary name.
If environment variable SASS_BINARY_NAME,
.npmrc variable sass_binary_name or
process argument --binary-name is provided,
return it as is, otherwise make default binary
name: {platform}-{arch}-{v8 version}.node
@api public | [
"Get",
"binary",
"name",
".",
"If",
"environment",
"variable",
"SASS_BINARY_NAME",
".",
"npmrc",
"variable",
"sass_binary_name",
"or",
"process",
"argument",
"--",
"binary",
"-",
"name",
"is",
"provided",
"return",
"it",
"as",
"is",
"otherwise",
"make",
"default... | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L183-L210 | train | Get binary name | [
30522,
3853,
2131,
21114,
18143,
14074,
1006,
1007,
1063,
13075,
12441,
18442,
1010,
8349,
1010,
4132,
1027,
2832,
1012,
4132,
1025,
2065,
1006,
2131,
2906,
22850,
4765,
1006,
1005,
1011,
1011,
21871,
2015,
1011,
12441,
1011,
2171,
1005,
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... |
GitbookIO/gitbook | lib/output/website/prepareResources.js | prepareResources | function prepareResources(output) {
var plugins = output.getPlugins();
var options = output.getOptions();
var type = options.get('prefix');
var state = output.getState();
var context = Api.encodeGlobal(output);
var result = Immutable.Map();
return Promise.forEach(plugins, function(plugin) {
var pluginResources = plugin.getResources(type);
return Promise()
.then(function() {
// Apply resources if is a function
if (is.fn(pluginResources)) {
return Promise()
.then(pluginResources.bind(context));
}
else {
return pluginResources;
}
})
.then(function(resources) {
result = result.set(plugin.getName(), Immutable.Map(resources));
});
})
.then(function() {
// Set output resources
state = state.merge({
resources: result
});
output = output.merge({
state: state
});
return output;
});
} | javascript | function prepareResources(output) {
var plugins = output.getPlugins();
var options = output.getOptions();
var type = options.get('prefix');
var state = output.getState();
var context = Api.encodeGlobal(output);
var result = Immutable.Map();
return Promise.forEach(plugins, function(plugin) {
var pluginResources = plugin.getResources(type);
return Promise()
.then(function() {
// Apply resources if is a function
if (is.fn(pluginResources)) {
return Promise()
.then(pluginResources.bind(context));
}
else {
return pluginResources;
}
})
.then(function(resources) {
result = result.set(plugin.getName(), Immutable.Map(resources));
});
})
.then(function() {
// Set output resources
state = state.merge({
resources: result
});
output = output.merge({
state: state
});
return output;
});
} | [
"function",
"prepareResources",
"(",
"output",
")",
"{",
"var",
"plugins",
"=",
"output",
".",
"getPlugins",
"(",
")",
";",
"var",
"options",
"=",
"output",
".",
"getOptions",
"(",
")",
";",
"var",
"type",
"=",
"options",
".",
"get",
"(",
"'prefix'",
"... | Prepare plugins resources, add all output corresponding type resources
@param {Output}
@return {Promise<Output>} | [
"Prepare",
"plugins",
"resources",
"add",
"all",
"output",
"corresponding",
"type",
"resources"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/prepareResources.js#L13-L52 | train | Prepare resources for a specific type | [
30522,
3853,
7374,
6072,
8162,
9623,
1006,
6434,
1007,
1063,
13075,
13354,
7076,
1027,
6434,
1012,
2131,
24759,
15916,
7076,
1006,
1007,
1025,
13075,
7047,
1027,
6434,
1012,
2131,
7361,
9285,
1006,
1007,
1025,
13075,
2828,
1027,
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... |
angular/protractor | lib/clientsidescripts.js | function() {
if (window.getAngularTestability) {
if (rootSelector) {
var testability = null;
var el = document.querySelector(rootSelector);
try{
testability = window.getAngularTestability(el);
}
catch(e){}
if (testability) {
testability.whenStable(testCallback);
return;
}
}
// Didn't specify root element or testability could not be found
// by rootSelector. This may happen in a hybrid app, which could have
// more than one root.
var testabilities = window.getAllAngularTestabilities();
var count = testabilities.length;
// No angular2 testability, this happens when
// going to a hybrid page and going back to a pure angular1 page
if (count === 0) {
testCallback();
return;
}
var decrement = function() {
count--;
if (count === 0) {
testCallback();
}
};
testabilities.forEach(function(testability) {
testability.whenStable(decrement);
});
}
else {testCallback();} // not an angular2 app
} | javascript | function() {
if (window.getAngularTestability) {
if (rootSelector) {
var testability = null;
var el = document.querySelector(rootSelector);
try{
testability = window.getAngularTestability(el);
}
catch(e){}
if (testability) {
testability.whenStable(testCallback);
return;
}
}
// Didn't specify root element or testability could not be found
// by rootSelector. This may happen in a hybrid app, which could have
// more than one root.
var testabilities = window.getAllAngularTestabilities();
var count = testabilities.length;
// No angular2 testability, this happens when
// going to a hybrid page and going back to a pure angular1 page
if (count === 0) {
testCallback();
return;
}
var decrement = function() {
count--;
if (count === 0) {
testCallback();
}
};
testabilities.forEach(function(testability) {
testability.whenStable(decrement);
});
}
else {testCallback();} // not an angular2 app
} | [
"function",
"(",
")",
"{",
"if",
"(",
"window",
".",
"getAngularTestability",
")",
"{",
"if",
"(",
"rootSelector",
")",
"{",
"var",
"testability",
"=",
"null",
";",
"var",
"el",
"=",
"document",
".",
"querySelector",
"(",
"rootSelector",
")",
";",
"try",... | Wait for Angular2 testability and then run test callback | [
"Wait",
"for",
"Angular2",
"testability",
"and",
"then",
"run",
"test",
"callback"
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/lib/clientsidescripts.js#L171-L211 | train | This function is called when the app is stable | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
3332,
1012,
2131,
5654,
7934,
22199,
8010,
1007,
1063,
2065,
1006,
6147,
12260,
16761,
1007,
1063,
13075,
3231,
8010,
1027,
19701,
1025,
13075,
3449,
1027,
6254,
1012,
23032,
11246,
22471,
2953,
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... | |
zloirock/core-js | packages/core-js/modules/es.string.match.js | function (regexp) {
var res = maybeCallNative(nativeMatch, regexp, this);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
if (!rx.global) return regExpExec(rx, S);
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
var A = [];
var n = 0;
var result;
while ((result = regExpExec(rx, S)) !== null) {
var matchStr = String(result[0]);
A[n] = matchStr;
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
n++;
}
return n === 0 ? null : A;
} | javascript | function (regexp) {
var res = maybeCallNative(nativeMatch, regexp, this);
if (res.done) return res.value;
var rx = anObject(regexp);
var S = String(this);
if (!rx.global) return regExpExec(rx, S);
var fullUnicode = rx.unicode;
rx.lastIndex = 0;
var A = [];
var n = 0;
var result;
while ((result = regExpExec(rx, S)) !== null) {
var matchStr = String(result[0]);
A[n] = matchStr;
if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
n++;
}
return n === 0 ? null : A;
} | [
"function",
"(",
"regexp",
")",
"{",
"var",
"res",
"=",
"maybeCallNative",
"(",
"nativeMatch",
",",
"regexp",
",",
"this",
")",
";",
"if",
"(",
"res",
".",
"done",
")",
"return",
"res",
".",
"value",
";",
"var",
"rx",
"=",
"anObject",
"(",
"regexp",
... | `RegExp.prototype[@@match]` method https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match | [
"RegExp",
".",
"prototype",
"["
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/modules/es.string.match.js#L24-L45 | train | Returns the matches of the given regexp. | [
30522,
3853,
1006,
19723,
10288,
2361,
1007,
1063,
13075,
24501,
1027,
2672,
9289,
19666,
8082,
1006,
3128,
18900,
2818,
1010,
19723,
10288,
2361,
1010,
2023,
1007,
1025,
2065,
1006,
24501,
1012,
2589,
1007,
2709,
24501,
1012,
3643,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
summernote/summernote | src/js/base/core/lists.js | all | function all(array, pred) {
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!pred(array[idx])) {
return false;
}
}
return true;
} | javascript | function all(array, pred) {
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!pred(array[idx])) {
return false;
}
}
return true;
} | [
"function",
"all",
"(",
"array",
",",
"pred",
")",
"{",
"for",
"(",
"let",
"idx",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"idx",
"<",
"len",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"!",
"pred",
"(",
"array",
"[",
"idx",
"]",
... | returns true if all of the values in the array pass the predicate truth test. | [
"returns",
"true",
"if",
"all",
"of",
"the",
"values",
"in",
"the",
"array",
"pass",
"the",
"predicate",
"truth",
"test",
"."
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/lists.js#L54-L61 | train | Returns true if all elements in array are true | [
30522,
3853,
2035,
1006,
9140,
1010,
3653,
2094,
1007,
1063,
2005,
1006,
2292,
8909,
2595,
1027,
1014,
1010,
18798,
1027,
9140,
1012,
3091,
1025,
8909,
2595,
1026,
18798,
1025,
8909,
2595,
1009,
1009,
1007,
1063,
2065,
1006,
999,
3653,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
askmike/gekko | web/vue/public/vendor/humanize-duration.js | humanizer | function humanizer (passedOptions) {
var result = function humanizer (ms, humanizerOptions) {
var options = extend({}, result, humanizerOptions || {})
return doHumanization(ms, options)
}
return extend(result, {
language: 'en',
delimiter: ', ',
spacer: ' ',
conjunction: '',
serialComma: true,
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's'],
languages: {},
round: false,
unitMeasures: {
y: 31557600000,
mo: 2629800000,
w: 604800000,
d: 86400000,
h: 3600000,
m: 60000,
s: 1000,
ms: 1
}
}, passedOptions)
} | javascript | function humanizer (passedOptions) {
var result = function humanizer (ms, humanizerOptions) {
var options = extend({}, result, humanizerOptions || {})
return doHumanization(ms, options)
}
return extend(result, {
language: 'en',
delimiter: ', ',
spacer: ' ',
conjunction: '',
serialComma: true,
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's'],
languages: {},
round: false,
unitMeasures: {
y: 31557600000,
mo: 2629800000,
w: 604800000,
d: 86400000,
h: 3600000,
m: 60000,
s: 1000,
ms: 1
}
}, passedOptions)
} | [
"function",
"humanizer",
"(",
"passedOptions",
")",
"{",
"var",
"result",
"=",
"function",
"humanizer",
"(",
"ms",
",",
"humanizerOptions",
")",
"{",
"var",
"options",
"=",
"extend",
"(",
"{",
"}",
",",
"result",
",",
"humanizerOptions",
"||",
"{",
"}",
... | You can create a humanizer, which returns a function with default parameters. | [
"You",
"can",
"create",
"a",
"humanizer",
"which",
"returns",
"a",
"function",
"with",
"default",
"parameters",
"."
] | 0ce9ddd577fa8a22812c02331a494086758dfadf | https://github.com/askmike/gekko/blob/0ce9ddd577fa8a22812c02331a494086758dfadf/web/vue/public/vendor/humanize-duration.js#L20-L46 | train | Humanization function | [
30522,
3853,
2529,
17629,
1006,
2979,
7361,
9285,
1007,
1063,
13075,
2765,
1027,
3853,
2529,
17629,
1006,
5796,
1010,
2529,
17629,
7361,
9285,
1007,
1063,
13075,
7047,
1027,
7949,
1006,
1063,
1065,
1010,
2765,
1010,
2529,
17629,
7361,
9285,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(node)
{
var ds = mxUtils.getDocumentSize();
var left = parseInt(node.offsetLeft);
var width = parseInt(node.offsetWidth);
var offset = mxUtils.getDocumentScrollOrigin(node.ownerDocument);
var sl = offset.x;
var st = offset.y;
var b = document.body;
var d = document.documentElement;
var right = (sl) + ds.width;
if (left + width > right)
{
node.style.left = Math.max(sl, right - width) + 'px';
}
var top = parseInt(node.offsetTop);
var height = parseInt(node.offsetHeight);
var bottom = st + ds.height;
if (top + height > bottom)
{
node.style.top = Math.max(st, bottom - height) + 'px';
}
} | javascript | function(node)
{
var ds = mxUtils.getDocumentSize();
var left = parseInt(node.offsetLeft);
var width = parseInt(node.offsetWidth);
var offset = mxUtils.getDocumentScrollOrigin(node.ownerDocument);
var sl = offset.x;
var st = offset.y;
var b = document.body;
var d = document.documentElement;
var right = (sl) + ds.width;
if (left + width > right)
{
node.style.left = Math.max(sl, right - width) + 'px';
}
var top = parseInt(node.offsetTop);
var height = parseInt(node.offsetHeight);
var bottom = st + ds.height;
if (top + height > bottom)
{
node.style.top = Math.max(st, bottom - height) + 'px';
}
} | [
"function",
"(",
"node",
")",
"{",
"var",
"ds",
"=",
"mxUtils",
".",
"getDocumentSize",
"(",
")",
";",
"var",
"left",
"=",
"parseInt",
"(",
"node",
".",
"offsetLeft",
")",
";",
"var",
"width",
"=",
"parseInt",
"(",
"node",
".",
"offsetWidth",
")",
";... | Function: fit
Makes sure the given node is inside the visible area of the window. This
is done by setting the left and top in the style. | [
"Function",
":",
"fit"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3499-L3527 | train | Updates the style of a node | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
16233,
1027,
25630,
21823,
4877,
1012,
30524,
1012,
2131,
3527,
24894,
11187,
26775,
14511,
10050,
11528,
1006,
13045,
1012,
3954,
3527,
24894,
4765,
1007,
1025,
13075,
22889,
1027,
16396,
1012,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/datajs.js | function(namespaceURI, qualifiedName) {
var dummy = document.createElement('dummy');
dummy.setAttributeNS(namespaceURI, qualifiedName, '');
var attr = dummy.attributes[0];
dummy.removeAttributeNode(attr);
return attr;
} | javascript | function(namespaceURI, qualifiedName) {
var dummy = document.createElement('dummy');
dummy.setAttributeNS(namespaceURI, qualifiedName, '');
var attr = dummy.attributes[0];
dummy.removeAttributeNode(attr);
return attr;
} | [
"function",
"(",
"namespaceURI",
",",
"qualifiedName",
")",
"{",
"var",
"dummy",
"=",
"document",
".",
"createElement",
"(",
"'dummy'",
")",
";",
"dummy",
".",
"setAttributeNS",
"(",
"namespaceURI",
",",
"qualifiedName",
",",
"''",
")",
";",
"var",
"attr",
... | ##### BEGIN: MODIFIED BY SAP polyfill for document.createAttributeNS which was removed from Chrome 34 but will be added back in, see: http://datajs.codeplex.com/workitem/1272 https://code.google.com/p/chromium/issues/detail?id=347506 https://codereview.chromium.org/243333003 | [
"#####",
"BEGIN",
":",
"MODIFIED",
"BY",
"SAP",
"polyfill",
"for",
"document",
".",
"createAttributeNS",
"which",
"was",
"removed",
"from",
"Chrome",
"34",
"but",
"will",
"be",
"added",
"back",
"in",
"see",
":",
"http",
":",
"//",
"datajs",
".",
"codeplex"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/datajs.js#L970-L976 | train | Get the attribute for a class | [
30522,
3853,
1006,
3415,
15327,
9496,
1010,
4591,
18442,
1007,
1063,
13075,
24369,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
24369,
1005,
1007,
1025,
24369,
1012,
2275,
19321,
3089,
8569,
25808,
1006,
3415,
15327,
9496,
1010,
4591,
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... | |
firebase/firebaseui-web | demo/public/app.js | function() {
document.getElementById('user-signed-in').style.display = 'none';
document.getElementById('user-signed-out').style.display = 'block';
ui.start('#firebaseui-container', getUiConfig());
} | javascript | function() {
document.getElementById('user-signed-in').style.display = 'none';
document.getElementById('user-signed-out').style.display = 'block';
ui.start('#firebaseui-container', getUiConfig());
} | [
"function",
"(",
")",
"{",
"document",
".",
"getElementById",
"(",
"'user-signed-in'",
")",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"document",
".",
"getElementById",
"(",
"'user-signed-out'",
")",
".",
"style",
".",
"display",
"=",
"'block'",
";",... | Displays the UI for a signed out user. | [
"Displays",
"the",
"UI",
"for",
"a",
"signed",
"out",
"user",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/demo/public/app.js#L154-L158 | train | Display the user signed in and out UI | [
30522,
3853,
1006,
1007,
1063,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1005,
5310,
1011,
2772,
1011,
1999,
1005,
1007,
1012,
2806,
1012,
4653,
1027,
1005,
3904,
1005,
1025,
6254,
1012,
2131,
12260,
3672,
3762,
3593,
1006,
1005,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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() {
this.zip64EndOfCentralSize = this.reader.readInt(8);
this.versionMadeBy = this.reader.readString(2);
this.versionNeeded = this.reader.readInt(2);
this.diskNumber = this.reader.readInt(4);
this.diskWithCentralDirStart = this.reader.readInt(4);
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
this.centralDirRecords = this.reader.readInt(8);
this.centralDirSize = this.reader.readInt(8);
this.centralDirOffset = this.reader.readInt(8);
this.zip64ExtensibleData = {};
var extraDataSize = this.zip64EndOfCentralSize - 44,
index = 0,
extraFieldId,
extraFieldLength,
extraFieldValue;
while (index < extraDataSize) {
extraFieldId = this.reader.readInt(2);
extraFieldLength = this.reader.readInt(4);
extraFieldValue = this.reader.readString(extraFieldLength);
this.zip64ExtensibleData[extraFieldId] = {
id: extraFieldId,
length: extraFieldLength,
value: extraFieldValue
};
}
} | javascript | function() {
this.zip64EndOfCentralSize = this.reader.readInt(8);
this.versionMadeBy = this.reader.readString(2);
this.versionNeeded = this.reader.readInt(2);
this.diskNumber = this.reader.readInt(4);
this.diskWithCentralDirStart = this.reader.readInt(4);
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
this.centralDirRecords = this.reader.readInt(8);
this.centralDirSize = this.reader.readInt(8);
this.centralDirOffset = this.reader.readInt(8);
this.zip64ExtensibleData = {};
var extraDataSize = this.zip64EndOfCentralSize - 44,
index = 0,
extraFieldId,
extraFieldLength,
extraFieldValue;
while (index < extraDataSize) {
extraFieldId = this.reader.readInt(2);
extraFieldLength = this.reader.readInt(4);
extraFieldValue = this.reader.readString(extraFieldLength);
this.zip64ExtensibleData[extraFieldId] = {
id: extraFieldId,
length: extraFieldLength,
value: extraFieldValue
};
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"zip64EndOfCentralSize",
"=",
"this",
".",
"reader",
".",
"readInt",
"(",
"8",
")",
";",
"this",
".",
"versionMadeBy",
"=",
"this",
".",
"reader",
".",
"readString",
"(",
"2",
")",
";",
"this",
".",
"versionNeede... | Read the end of the Zip 64 central directory.
Not merged with the method readEndOfCentral :
The end of central can coexist with its Zip64 brother,
I don't want to read the wrong number of bytes ! | [
"Read",
"the",
"end",
"of",
"the",
"Zip",
"64",
"central",
"directory",
".",
"Not",
"merged",
"with",
"the",
"method",
"readEndOfCentral",
":",
"The",
"end",
"of",
"central",
"can",
"coexist",
"with",
"its",
"Zip64",
"brother",
"I",
"don",
"t",
"want",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1739-L1766 | train | Reads the ASN. 1 zip64 extent | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
14101,
21084,
10497,
11253,
13013,
7941,
5332,
4371,
1027,
2023,
1012,
8068,
1012,
3191,
18447,
1006,
1022,
1007,
1025,
2023,
1012,
2544,
21565,
3762,
1027,
2023,
1012,
8068,
1012,
9631,
18886,
307... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/apps/private-blogging/lib/middleware.js | isPrivateSessionAuth | function isPrivateSessionAuth(req, res, next) {
if (!res.isPrivateBlog) {
return res.redirect(urlService.utils.urlFor('home', true));
}
let hash = req.session.token || '',
salt = req.session.salt || '',
isVerified = verifySessionHash(salt, hash);
if (isVerified) {
// redirect to home if user is already authenticated
return res.redirect(urlService.utils.urlFor('home', true));
} else {
return next();
}
} | javascript | function isPrivateSessionAuth(req, res, next) {
if (!res.isPrivateBlog) {
return res.redirect(urlService.utils.urlFor('home', true));
}
let hash = req.session.token || '',
salt = req.session.salt || '',
isVerified = verifySessionHash(salt, hash);
if (isVerified) {
// redirect to home if user is already authenticated
return res.redirect(urlService.utils.urlFor('home', true));
} else {
return next();
}
} | [
"function",
"isPrivateSessionAuth",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"!",
"res",
".",
"isPrivateBlog",
")",
"{",
"return",
"res",
".",
"redirect",
"(",
"urlService",
".",
"utils",
".",
"urlFor",
"(",
"'home'",
",",
"true",
")",... | This is here so a call to /private/ after a session is verified will redirect to home; | [
"This",
"is",
"here",
"so",
"a",
"call",
"to",
"/",
"private",
"/",
"after",
"a",
"session",
"is",
"verified",
"will",
"redirect",
"to",
"home",
";"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/apps/private-blogging/lib/middleware.js#L109-L124 | train | private session auth | [
30522,
3853,
2003,
18098,
21466,
8583,
10992,
4887,
2705,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
2065,
1006,
999,
24501,
1012,
2003,
18098,
21466,
16558,
8649,
1007,
1063,
2709,
24501,
1012,
2417,
7442,
6593,
1006,
24471,
48... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/jvectormap/lib/world-map.js | function(markers){
var i;
for (i = 0; i < markers.length; i++) {
this.markers[ markers[i] ].element.remove();
delete this.markers[ markers[i] ];
};
} | javascript | function(markers){
var i;
for (i = 0; i < markers.length; i++) {
this.markers[ markers[i] ].element.remove();
delete this.markers[ markers[i] ];
};
} | [
"function",
"(",
"markers",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"markers",
".",
"length",
";",
"i",
"++",
")",
"{",
"this",
".",
"markers",
"[",
"markers",
"[",
"i",
"]",
"]",
".",
"element",
".",
"remove",
"(... | Remove some markers from the map.
@param {Array} markers Array of marker codes to be removed. | [
"Remove",
"some",
"markers",
"from",
"the",
"map",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L792-L799 | train | Remove markers from the image | [
30522,
3853,
1006,
16387,
1007,
1063,
13075,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
16387,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2023,
1012,
16387,
1031,
16387,
1031,
1045,
1033,
1033,
1012,
5783,
1012,
6366,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/slider/slider.js | positionToPercent | function positionToPercent(position) {
var offset = vertical ? sliderDimensions.top : sliderDimensions.left;
var size = vertical ? sliderDimensions.height : sliderDimensions.width;
var calc = (position - offset) / size;
if (!vertical && $mdUtil.bidi() === 'rtl') {
calc = 1 - calc;
}
return Math.max(0, Math.min(1, vertical ? 1 - calc : calc));
} | javascript | function positionToPercent(position) {
var offset = vertical ? sliderDimensions.top : sliderDimensions.left;
var size = vertical ? sliderDimensions.height : sliderDimensions.width;
var calc = (position - offset) / size;
if (!vertical && $mdUtil.bidi() === 'rtl') {
calc = 1 - calc;
}
return Math.max(0, Math.min(1, vertical ? 1 - calc : calc));
} | [
"function",
"positionToPercent",
"(",
"position",
")",
"{",
"var",
"offset",
"=",
"vertical",
"?",
"sliderDimensions",
".",
"top",
":",
"sliderDimensions",
".",
"left",
";",
"var",
"size",
"=",
"vertical",
"?",
"sliderDimensions",
".",
"height",
":",
"sliderDi... | Convert position on slider to percentage value of offset from beginning...
@param position
@returns {number} | [
"Convert",
"position",
"on",
"slider",
"to",
"percentage",
"value",
"of",
"offset",
"from",
"beginning",
"..."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/slider/slider.js#L645-L655 | train | Convert a position in pixels to percent | [
30522,
3853,
2597,
14399,
2121,
13013,
1006,
2597,
1007,
1063,
13075,
16396,
1027,
7471,
1029,
7358,
17080,
3549,
27466,
1012,
2327,
1024,
7358,
17080,
3549,
27466,
1012,
2187,
1025,
13075,
2946,
1027,
7471,
1029,
7358,
17080,
3549,
27466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | zIndexSort | function zIndexSort(a, b) {
var cy = a.cy();
var hasCompoundNodes = cy.hasCompoundNodes();
function getDepth(ele) {
var style = ele.pstyle('z-compound-depth');
if (style.value === 'auto') {
return hasCompoundNodes ? ele.zDepth() : 0;
} else if (style.value === 'bottom') {
return -1;
} else if (style.value === 'top') {
return MAX_INT;
} // 'orphan'
return 0;
}
var depthDiff = getDepth(a) - getDepth(b);
if (depthDiff !== 0) {
return depthDiff;
}
function getEleDepth(ele) {
var style = ele.pstyle('z-index-compare');
if (style.value === 'auto') {
return ele.isNode() ? 1 : 0;
} // 'manual'
return 0;
}
var eleDiff = getEleDepth(a) - getEleDepth(b);
if (eleDiff !== 0) {
return eleDiff;
}
var zDiff = a.pstyle('z-index').value - b.pstyle('z-index').value;
if (zDiff !== 0) {
return zDiff;
} // compare indices in the core (order added to graph w/ last on top)
return a.poolIndex() - b.poolIndex();
} | javascript | function zIndexSort(a, b) {
var cy = a.cy();
var hasCompoundNodes = cy.hasCompoundNodes();
function getDepth(ele) {
var style = ele.pstyle('z-compound-depth');
if (style.value === 'auto') {
return hasCompoundNodes ? ele.zDepth() : 0;
} else if (style.value === 'bottom') {
return -1;
} else if (style.value === 'top') {
return MAX_INT;
} // 'orphan'
return 0;
}
var depthDiff = getDepth(a) - getDepth(b);
if (depthDiff !== 0) {
return depthDiff;
}
function getEleDepth(ele) {
var style = ele.pstyle('z-index-compare');
if (style.value === 'auto') {
return ele.isNode() ? 1 : 0;
} // 'manual'
return 0;
}
var eleDiff = getEleDepth(a) - getEleDepth(b);
if (eleDiff !== 0) {
return eleDiff;
}
var zDiff = a.pstyle('z-index').value - b.pstyle('z-index').value;
if (zDiff !== 0) {
return zDiff;
} // compare indices in the core (order added to graph w/ last on top)
return a.poolIndex() - b.poolIndex();
} | [
"function",
"zIndexSort",
"(",
"a",
",",
"b",
")",
"{",
"var",
"cy",
"=",
"a",
".",
"cy",
"(",
")",
";",
"var",
"hasCompoundNodes",
"=",
"cy",
".",
"hasCompoundNodes",
"(",
")",
";",
"function",
"getDepth",
"(",
"ele",
")",
"{",
"var",
"style",
"="... | Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`. | [
"Elements",
"are",
"drawn",
"in",
"a",
"specific",
"order",
"based",
"on",
"compound",
"depth",
"(",
"low",
"to",
"high",
")",
"the",
"element",
"type",
"(",
"nodes",
"above",
"edges",
")",
"and",
"z",
"-",
"index",
"(",
"low",
"to",
"high",
")",
"."... | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L10452-L10502 | train | Sort the nodes in the core by the z - index. | [
30522,
3853,
1062,
22254,
10288,
21748,
2102,
1006,
1037,
1010,
1038,
1007,
1063,
13075,
22330,
1027,
1037,
1012,
22330,
1006,
1007,
1025,
13075,
2038,
9006,
6873,
8630,
3630,
6155,
1027,
22330,
1012,
2038,
9006,
6873,
8630,
3630,
6155,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | traverseToNextViewByMRU | function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
} | javascript | function traverseToNextViewByMRU(direction) {
var file = getCurrentlyViewedFile(),
paneId = getActivePaneId(),
index = _.findIndex(_mruList, function (record) {
return (record.file === file && record.paneId === paneId);
});
return ViewUtils.traverseViewArray(_mruList, index, direction);
} | [
"function",
"traverseToNextViewByMRU",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"paneId",
"=",
"getActivePaneId",
"(",
")",
",",
"index",
"=",
"_",
".",
"findIndex",
"(",
"_mruList",
",",
"function",
"(",
"reco... | Get the next or previous file in the MRU list.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse. | [
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"the",
"MRU",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L933-L941 | train | traverseToNextViewByMRU - traverses the MRU list to the next view | [
30522,
3853,
20811,
5524,
18413,
8584,
3762,
2213,
6820,
1006,
3257,
1007,
1063,
13075,
5371,
1027,
2131,
10841,
14343,
20630,
8584,
2098,
8873,
2571,
1006,
1007,
1010,
6090,
7416,
2094,
1027,
2131,
19620,
9739,
7416,
2094,
1006,
1007,
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... |
mui-org/material-ui | packages/material-ui-icons/builder.js | getComponentName | function getComponentName(destPath) {
const splitregex = new RegExp(`[\\${path.sep}-]+`);
const parts = destPath
.replace('.js', '')
.split(splitregex)
.map(part => part.charAt(0).toUpperCase() + part.substring(1));
return parts.join('');
} | javascript | function getComponentName(destPath) {
const splitregex = new RegExp(`[\\${path.sep}-]+`);
const parts = destPath
.replace('.js', '')
.split(splitregex)
.map(part => part.charAt(0).toUpperCase() + part.substring(1));
return parts.join('');
} | [
"function",
"getComponentName",
"(",
"destPath",
")",
"{",
"const",
"splitregex",
"=",
"new",
"RegExp",
"(",
"`",
"\\\\",
"${",
"path",
".",
"sep",
"}",
"`",
")",
";",
"const",
"parts",
"=",
"destPath",
".",
"replace",
"(",
"'.js'",
",",
"''",
")",
"... | Return Pascal-Cased component name.
@param {string} destPath
@returns {string} class name | [
"Return",
"Pascal",
"-",
"Cased",
"component",
"name",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-icons/builder.js#L70-L79 | train | Get component name from a file path | [
30522,
3853,
2131,
9006,
29513,
3372,
18442,
1006,
4078,
25856,
8988,
1007,
1063,
9530,
3367,
3975,
2890,
3351,
2595,
1027,
2047,
19723,
10288,
2361,
1006,
1036,
1031,
1032,
1032,
1002,
1063,
4130,
1012,
19802,
1065,
1011,
1033,
1009,
1036,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/services/url/utils.js | createUrl | function createUrl(urlPath, absolute, secure, trailingSlash) {
urlPath = urlPath || '/';
absolute = absolute || false;
var base;
// create base of url, always ends without a slash
if (absolute) {
base = getBlogUrl(secure);
} else {
base = getSubdir();
}
if (trailingSlash) {
if (!urlPath.match(/\/$/)) {
urlPath += '/';
}
}
return urlJoin(base, urlPath);
} | javascript | function createUrl(urlPath, absolute, secure, trailingSlash) {
urlPath = urlPath || '/';
absolute = absolute || false;
var base;
// create base of url, always ends without a slash
if (absolute) {
base = getBlogUrl(secure);
} else {
base = getSubdir();
}
if (trailingSlash) {
if (!urlPath.match(/\/$/)) {
urlPath += '/';
}
}
return urlJoin(base, urlPath);
} | [
"function",
"createUrl",
"(",
"urlPath",
",",
"absolute",
",",
"secure",
",",
"trailingSlash",
")",
"{",
"urlPath",
"=",
"urlPath",
"||",
"'/'",
";",
"absolute",
"=",
"absolute",
"||",
"false",
";",
"var",
"base",
";",
"// create base of url, always ends without... | ## createUrl Simple url creation from a given path Ensures that our urls contain the subdirectory if there is one And are correctly formatted as either relative or absolute Usage: createUrl('/', true) -> http://my-ghost-blog.com/ E.g. /blog/ subdir createUrl('/welcome-to-ghost/') -> /blog/welcome-to-ghost/ Parameters: - urlPath - string which must start and end with a slash - absolute (optional, default:false) - boolean whether or not the url should be absolute - secure (optional, default:false) - boolean whether or not to force SSL Returns: - a URL which always ends with a slash | [
"##",
"createUrl",
"Simple",
"url",
"creation",
"from",
"a",
"given",
"path",
"Ensures",
"that",
"our",
"urls",
"contain",
"the",
"subdirectory",
"if",
"there",
"is",
"one",
"And",
"are",
"correctly",
"formatted",
"as",
"either",
"relative",
"or",
"absolute",
... | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/url/utils.js#L180-L199 | train | Creates a url from the given path | [
30522,
3853,
3443,
3126,
2140,
1006,
24471,
14277,
8988,
1010,
7619,
1010,
5851,
1010,
12542,
14540,
11823,
1007,
1063,
24471,
14277,
8988,
1027,
24471,
14277,
8988,
1064,
1064,
1005,
1013,
1005,
1025,
7619,
1027,
7619,
1064,
1064,
6270,
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/AnnotationParser.js | function(oMetadata, oXMLDoc, sSourceUrl) {
var mappingList = {}, schemaNodes, schemaNode,
termNodes, oTerms, termNode, sTermType, annotationNodes, annotationNode,
annotationTarget, annotationNamespace, annotation, propertyAnnotation, propertyAnnotationNodes,
propertyAnnotationNode, sTermValue, targetAnnotation,
expandNodes, expandNode, path, pathValues, expandNodesApplFunc, i, nodeIndex,
annotationsAtArrays = [];
AnnotationParser._parserData.metadataInstance = oMetadata;
AnnotationParser._parserData.serviceMetadata = oMetadata.getServiceMetadata();
AnnotationParser._parserData.xmlDocument = AnnotationParser._oXPath.setNameSpace(oXMLDoc);
AnnotationParser._parserData.schema = {};
AnnotationParser._parserData.aliases = {};
AnnotationParser._parserData.url = sSourceUrl ? sSourceUrl : "metadata document";
AnnotationParser._parserData.annotationsAtArrays = annotationsAtArrays;
// Schema Alias
schemaNodes = AnnotationParser._oXPath.selectNodes("//d:Schema", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < schemaNodes.length; i += 1) {
schemaNode = AnnotationParser._oXPath.nextNode(schemaNodes, i);
AnnotationParser._parserData.schema.Alias = schemaNode.getAttribute("Alias");
AnnotationParser._parserData.schema.Namespace = schemaNode.getAttribute("Namespace");
}
// Fill local alias and reference objects
var oAnnotationReferences = {};
var bFoundReferences = AnnotationParser._parseReferences(oAnnotationReferences);
if (bFoundReferences) {
mappingList.annotationReferences = oAnnotationReferences;
mappingList.aliasDefinitions = AnnotationParser._parserData.aliases;
}
// Term nodes
termNodes = AnnotationParser._oXPath.selectNodes("//d:Term", AnnotationParser._parserData.xmlDocument);
if (termNodes.length > 0) {
oTerms = {};
for (nodeIndex = 0; nodeIndex < termNodes.length; nodeIndex += 1) {
termNode = AnnotationParser._oXPath.nextNode(termNodes, nodeIndex);
sTermType = AnnotationParser.replaceWithAlias(termNode.getAttribute("Type"));
oTerms["@" + AnnotationParser._parserData.schema.Alias + "." + termNode.getAttribute("Name")] = sTermType;
}
mappingList.termDefinitions = oTerms;
}
// Metadata information of all properties
AnnotationParser._parserData.metadataProperties = AnnotationParser.getAllPropertiesMetadata(AnnotationParser._parserData.serviceMetadata);
if (AnnotationParser._parserData.metadataProperties.extensions) {
mappingList.propertyExtensions = AnnotationParser._parserData.metadataProperties.extensions;
}
// Annotations
annotationNodes = AnnotationParser._oXPath.selectNodes("//d:Annotations ", AnnotationParser._parserData.xmlDocument);
for (nodeIndex = 0; nodeIndex < annotationNodes.length; nodeIndex += 1) {
annotationNode = AnnotationParser._oXPath.nextNode(annotationNodes, nodeIndex);
if (annotationNode.hasChildNodes() === false) {
continue;
}
annotationTarget = annotationNode.getAttribute("Target");
annotationNamespace = annotationTarget.split(".")[0];
if (annotationNamespace && AnnotationParser._parserData.aliases[annotationNamespace]) {
annotationTarget = annotationTarget.replace(new RegExp(annotationNamespace, ""), AnnotationParser._parserData.aliases[annotationNamespace]);
}
annotation = annotationTarget;
propertyAnnotation = null;
var sContainerAnnotation = null;
if (annotationTarget.indexOf("/") > 0) {
annotation = annotationTarget.split("/")[0];
// check sAnnotation is EntityContainer: if yes, something in there is annotated - EntitySet, FunctionImport, ..
var bSchemaExists =
AnnotationParser._parserData.serviceMetadata.dataServices &&
AnnotationParser._parserData.serviceMetadata.dataServices.schema &&
AnnotationParser._parserData.serviceMetadata.dataServices.schema.length;
if (bSchemaExists) {
for (var j = AnnotationParser._parserData.serviceMetadata.dataServices.schema.length - 1; j >= 0; j--) {
var oMetadataSchema = AnnotationParser._parserData.serviceMetadata.dataServices.schema[j];
if (oMetadataSchema.entityContainer) {
var aAnnotation = annotation.split('.');
for (var k = oMetadataSchema.entityContainer.length - 1; k >= 0; k--) {
if (oMetadataSchema.entityContainer[k].name === aAnnotation[aAnnotation.length - 1] ) {
sContainerAnnotation = annotationTarget.replace(annotation + "/", "");
break;
}
}
}
}
}
//else - it's a property annotation
if (!sContainerAnnotation) {
propertyAnnotation = annotationTarget.replace(annotation + "/", "");
}
}
// --- Value annotation of complex types. ---
if (propertyAnnotation) {
if (!mappingList.propertyAnnotations) {
mappingList.propertyAnnotations = {};
}
if (!mappingList.propertyAnnotations[annotation]) {
mappingList.propertyAnnotations[annotation] = {};
}
if (!mappingList.propertyAnnotations[annotation][propertyAnnotation]) {
mappingList.propertyAnnotations[annotation][propertyAnnotation] = {};
}
propertyAnnotationNodes = AnnotationParser._oXPath.selectNodes("./d:Annotation", annotationNode);
for (var nodeIndexValue = 0; nodeIndexValue < propertyAnnotationNodes.length; nodeIndexValue += 1) {
propertyAnnotationNode = AnnotationParser._oXPath.nextNode(propertyAnnotationNodes, nodeIndexValue);
sTermValue = AnnotationParser.replaceWithAlias(propertyAnnotationNode.getAttribute("Term"));
var sQualifierValue = getQualifier(propertyAnnotationNode);
if (sQualifierValue) {
sTermValue += "#" + sQualifierValue;
}
if (propertyAnnotationNode.hasChildNodes() === false) {
var o = {};
AnnotationParser.enrichFromPropertyValueAttributes(o, propertyAnnotationNode);
if (jQuery.isEmptyObject(o)) {
// assume DefaultValue="true" for annotation term w/o reading vocabulary
o.Bool = "true";
}
mappingList.propertyAnnotations[annotation][propertyAnnotation][sTermValue] = o;
} else {
mappingList.propertyAnnotations[annotation][propertyAnnotation][sTermValue] = AnnotationParser.getPropertyValue(propertyAnnotationNode);
}
}
// --- Annotations ---
} else {
var mTarget;
if (sContainerAnnotation) {
// Target is an entity container
if (!mappingList["EntityContainer"]) {
mappingList["EntityContainer"] = {};
}
if (!mappingList["EntityContainer"][annotation]) {
mappingList["EntityContainer"][annotation] = {};
}
mTarget = mappingList["EntityContainer"][annotation];
} else {
if (!mappingList[annotation]) {
mappingList[annotation] = {};
}
mTarget = mappingList[annotation];
}
targetAnnotation = annotation.replace(AnnotationParser._parserData.aliases[annotationNamespace], annotationNamespace);
propertyAnnotationNodes = AnnotationParser._oXPath.selectNodes("./d:Annotation", annotationNode);
for (var nodeIndexAnnotation = 0; nodeIndexAnnotation < propertyAnnotationNodes.length; nodeIndexAnnotation += 1) {
propertyAnnotationNode = AnnotationParser._oXPath.nextNode(propertyAnnotationNodes, nodeIndexAnnotation);
var oAnnotationTarget = mTarget;
if (sContainerAnnotation) {
if (!mTarget[sContainerAnnotation]) {
mTarget[sContainerAnnotation] = {};
}
oAnnotationTarget = mTarget[sContainerAnnotation];
}
AnnotationParser._parseAnnotation(annotation, propertyAnnotationNode, oAnnotationTarget);
}
// --- Setup of Expand nodes. ---
expandNodes = AnnotationParser._oXPath.selectNodes("//d:Annotations[contains(@Target, '" + targetAnnotation
+ "')]//d:PropertyValue[contains(@Path, '/')]//@Path", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < expandNodes.length; i += 1) {
expandNode = AnnotationParser._oXPath.nextNode(expandNodes, i);
path = expandNode.value;
if (mappingList.propertyAnnotations) {
if (mappingList.propertyAnnotations[annotation]) {
if (mappingList.propertyAnnotations[annotation][path]) {
continue;
}
}
}
pathValues = path.split('/');
if (AnnotationParser.findNavProperty(annotation, pathValues[0])) {
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
mappingList.expand[annotation][pathValues[0]] = pathValues[0];
}
}
expandNodesApplFunc = AnnotationParser._oXPath.selectNodes("//d:Annotations[contains(@Target, '" + targetAnnotation
+ "')]//d:Path[contains(., '/')]", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < expandNodesApplFunc.length; i += 1) {
expandNode = AnnotationParser._oXPath.nextNode(expandNodesApplFunc, i);
path = AnnotationParser._oXPath.getNodeText(expandNode);
if (
mappingList.propertyAnnotations &&
mappingList.propertyAnnotations[annotation] &&
mappingList.propertyAnnotations[annotation][path]
) {
continue;
}
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
pathValues = path.split('/');
if (AnnotationParser.findNavProperty(annotation, pathValues[0])) {
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
mappingList.expand[annotation][pathValues[0]] = pathValues[0];
}
}
}
}
if (annotationsAtArrays.length) {
// A list of paths (as array of strings or numbers) to annotations at arrays
mappingList.annotationsAtArrays = annotationsAtArrays.map(
function (oAnnotationNode) {
return AnnotationParser.backupAnnotationAtArray(oAnnotationNode, mappingList);
});
}
return mappingList;
} | javascript | function(oMetadata, oXMLDoc, sSourceUrl) {
var mappingList = {}, schemaNodes, schemaNode,
termNodes, oTerms, termNode, sTermType, annotationNodes, annotationNode,
annotationTarget, annotationNamespace, annotation, propertyAnnotation, propertyAnnotationNodes,
propertyAnnotationNode, sTermValue, targetAnnotation,
expandNodes, expandNode, path, pathValues, expandNodesApplFunc, i, nodeIndex,
annotationsAtArrays = [];
AnnotationParser._parserData.metadataInstance = oMetadata;
AnnotationParser._parserData.serviceMetadata = oMetadata.getServiceMetadata();
AnnotationParser._parserData.xmlDocument = AnnotationParser._oXPath.setNameSpace(oXMLDoc);
AnnotationParser._parserData.schema = {};
AnnotationParser._parserData.aliases = {};
AnnotationParser._parserData.url = sSourceUrl ? sSourceUrl : "metadata document";
AnnotationParser._parserData.annotationsAtArrays = annotationsAtArrays;
// Schema Alias
schemaNodes = AnnotationParser._oXPath.selectNodes("//d:Schema", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < schemaNodes.length; i += 1) {
schemaNode = AnnotationParser._oXPath.nextNode(schemaNodes, i);
AnnotationParser._parserData.schema.Alias = schemaNode.getAttribute("Alias");
AnnotationParser._parserData.schema.Namespace = schemaNode.getAttribute("Namespace");
}
// Fill local alias and reference objects
var oAnnotationReferences = {};
var bFoundReferences = AnnotationParser._parseReferences(oAnnotationReferences);
if (bFoundReferences) {
mappingList.annotationReferences = oAnnotationReferences;
mappingList.aliasDefinitions = AnnotationParser._parserData.aliases;
}
// Term nodes
termNodes = AnnotationParser._oXPath.selectNodes("//d:Term", AnnotationParser._parserData.xmlDocument);
if (termNodes.length > 0) {
oTerms = {};
for (nodeIndex = 0; nodeIndex < termNodes.length; nodeIndex += 1) {
termNode = AnnotationParser._oXPath.nextNode(termNodes, nodeIndex);
sTermType = AnnotationParser.replaceWithAlias(termNode.getAttribute("Type"));
oTerms["@" + AnnotationParser._parserData.schema.Alias + "." + termNode.getAttribute("Name")] = sTermType;
}
mappingList.termDefinitions = oTerms;
}
// Metadata information of all properties
AnnotationParser._parserData.metadataProperties = AnnotationParser.getAllPropertiesMetadata(AnnotationParser._parserData.serviceMetadata);
if (AnnotationParser._parserData.metadataProperties.extensions) {
mappingList.propertyExtensions = AnnotationParser._parserData.metadataProperties.extensions;
}
// Annotations
annotationNodes = AnnotationParser._oXPath.selectNodes("//d:Annotations ", AnnotationParser._parserData.xmlDocument);
for (nodeIndex = 0; nodeIndex < annotationNodes.length; nodeIndex += 1) {
annotationNode = AnnotationParser._oXPath.nextNode(annotationNodes, nodeIndex);
if (annotationNode.hasChildNodes() === false) {
continue;
}
annotationTarget = annotationNode.getAttribute("Target");
annotationNamespace = annotationTarget.split(".")[0];
if (annotationNamespace && AnnotationParser._parserData.aliases[annotationNamespace]) {
annotationTarget = annotationTarget.replace(new RegExp(annotationNamespace, ""), AnnotationParser._parserData.aliases[annotationNamespace]);
}
annotation = annotationTarget;
propertyAnnotation = null;
var sContainerAnnotation = null;
if (annotationTarget.indexOf("/") > 0) {
annotation = annotationTarget.split("/")[0];
// check sAnnotation is EntityContainer: if yes, something in there is annotated - EntitySet, FunctionImport, ..
var bSchemaExists =
AnnotationParser._parserData.serviceMetadata.dataServices &&
AnnotationParser._parserData.serviceMetadata.dataServices.schema &&
AnnotationParser._parserData.serviceMetadata.dataServices.schema.length;
if (bSchemaExists) {
for (var j = AnnotationParser._parserData.serviceMetadata.dataServices.schema.length - 1; j >= 0; j--) {
var oMetadataSchema = AnnotationParser._parserData.serviceMetadata.dataServices.schema[j];
if (oMetadataSchema.entityContainer) {
var aAnnotation = annotation.split('.');
for (var k = oMetadataSchema.entityContainer.length - 1; k >= 0; k--) {
if (oMetadataSchema.entityContainer[k].name === aAnnotation[aAnnotation.length - 1] ) {
sContainerAnnotation = annotationTarget.replace(annotation + "/", "");
break;
}
}
}
}
}
//else - it's a property annotation
if (!sContainerAnnotation) {
propertyAnnotation = annotationTarget.replace(annotation + "/", "");
}
}
// --- Value annotation of complex types. ---
if (propertyAnnotation) {
if (!mappingList.propertyAnnotations) {
mappingList.propertyAnnotations = {};
}
if (!mappingList.propertyAnnotations[annotation]) {
mappingList.propertyAnnotations[annotation] = {};
}
if (!mappingList.propertyAnnotations[annotation][propertyAnnotation]) {
mappingList.propertyAnnotations[annotation][propertyAnnotation] = {};
}
propertyAnnotationNodes = AnnotationParser._oXPath.selectNodes("./d:Annotation", annotationNode);
for (var nodeIndexValue = 0; nodeIndexValue < propertyAnnotationNodes.length; nodeIndexValue += 1) {
propertyAnnotationNode = AnnotationParser._oXPath.nextNode(propertyAnnotationNodes, nodeIndexValue);
sTermValue = AnnotationParser.replaceWithAlias(propertyAnnotationNode.getAttribute("Term"));
var sQualifierValue = getQualifier(propertyAnnotationNode);
if (sQualifierValue) {
sTermValue += "#" + sQualifierValue;
}
if (propertyAnnotationNode.hasChildNodes() === false) {
var o = {};
AnnotationParser.enrichFromPropertyValueAttributes(o, propertyAnnotationNode);
if (jQuery.isEmptyObject(o)) {
// assume DefaultValue="true" for annotation term w/o reading vocabulary
o.Bool = "true";
}
mappingList.propertyAnnotations[annotation][propertyAnnotation][sTermValue] = o;
} else {
mappingList.propertyAnnotations[annotation][propertyAnnotation][sTermValue] = AnnotationParser.getPropertyValue(propertyAnnotationNode);
}
}
// --- Annotations ---
} else {
var mTarget;
if (sContainerAnnotation) {
// Target is an entity container
if (!mappingList["EntityContainer"]) {
mappingList["EntityContainer"] = {};
}
if (!mappingList["EntityContainer"][annotation]) {
mappingList["EntityContainer"][annotation] = {};
}
mTarget = mappingList["EntityContainer"][annotation];
} else {
if (!mappingList[annotation]) {
mappingList[annotation] = {};
}
mTarget = mappingList[annotation];
}
targetAnnotation = annotation.replace(AnnotationParser._parserData.aliases[annotationNamespace], annotationNamespace);
propertyAnnotationNodes = AnnotationParser._oXPath.selectNodes("./d:Annotation", annotationNode);
for (var nodeIndexAnnotation = 0; nodeIndexAnnotation < propertyAnnotationNodes.length; nodeIndexAnnotation += 1) {
propertyAnnotationNode = AnnotationParser._oXPath.nextNode(propertyAnnotationNodes, nodeIndexAnnotation);
var oAnnotationTarget = mTarget;
if (sContainerAnnotation) {
if (!mTarget[sContainerAnnotation]) {
mTarget[sContainerAnnotation] = {};
}
oAnnotationTarget = mTarget[sContainerAnnotation];
}
AnnotationParser._parseAnnotation(annotation, propertyAnnotationNode, oAnnotationTarget);
}
// --- Setup of Expand nodes. ---
expandNodes = AnnotationParser._oXPath.selectNodes("//d:Annotations[contains(@Target, '" + targetAnnotation
+ "')]//d:PropertyValue[contains(@Path, '/')]//@Path", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < expandNodes.length; i += 1) {
expandNode = AnnotationParser._oXPath.nextNode(expandNodes, i);
path = expandNode.value;
if (mappingList.propertyAnnotations) {
if (mappingList.propertyAnnotations[annotation]) {
if (mappingList.propertyAnnotations[annotation][path]) {
continue;
}
}
}
pathValues = path.split('/');
if (AnnotationParser.findNavProperty(annotation, pathValues[0])) {
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
mappingList.expand[annotation][pathValues[0]] = pathValues[0];
}
}
expandNodesApplFunc = AnnotationParser._oXPath.selectNodes("//d:Annotations[contains(@Target, '" + targetAnnotation
+ "')]//d:Path[contains(., '/')]", AnnotationParser._parserData.xmlDocument);
for (i = 0; i < expandNodesApplFunc.length; i += 1) {
expandNode = AnnotationParser._oXPath.nextNode(expandNodesApplFunc, i);
path = AnnotationParser._oXPath.getNodeText(expandNode);
if (
mappingList.propertyAnnotations &&
mappingList.propertyAnnotations[annotation] &&
mappingList.propertyAnnotations[annotation][path]
) {
continue;
}
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
pathValues = path.split('/');
if (AnnotationParser.findNavProperty(annotation, pathValues[0])) {
if (!mappingList.expand) {
mappingList.expand = {};
}
if (!mappingList.expand[annotation]) {
mappingList.expand[annotation] = {};
}
mappingList.expand[annotation][pathValues[0]] = pathValues[0];
}
}
}
}
if (annotationsAtArrays.length) {
// A list of paths (as array of strings or numbers) to annotations at arrays
mappingList.annotationsAtArrays = annotationsAtArrays.map(
function (oAnnotationNode) {
return AnnotationParser.backupAnnotationAtArray(oAnnotationNode, mappingList);
});
}
return mappingList;
} | [
"function",
"(",
"oMetadata",
",",
"oXMLDoc",
",",
"sSourceUrl",
")",
"{",
"var",
"mappingList",
"=",
"{",
"}",
",",
"schemaNodes",
",",
"schemaNode",
",",
"termNodes",
",",
"oTerms",
",",
"termNode",
",",
"sTermType",
",",
"annotationNodes",
",",
"annotatio... | Parses the given XML-document using the given ODataMetadata-object and returns a native JavaScript-object
representation of it.
@param {sap.ui.model.odata.ODataMetadata} oMetadata The metadata to be used for interpreting the annotation document
@param {document} oXMLDoc The annotation document
@param {string} [sSourceUrl="metadata document"] The source URL
@returns {object} The parsed annotation object
@static
@private | [
"Parses",
"the",
"given",
"XML",
"-",
"document",
"using",
"the",
"given",
"ODataMetadata",
"-",
"object",
"and",
"returns",
"a",
"native",
"JavaScript",
"-",
"object",
"representation",
"of",
"it",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L192-L417 | train | Parses the XML document and returns a mapping list | [
30522,
3853,
1006,
18168,
12928,
2850,
2696,
1010,
23060,
19968,
3527,
2278,
1010,
7020,
8162,
3401,
3126,
2140,
1007,
1063,
13075,
12375,
9863,
1027,
1063,
1065,
1010,
8040,
28433,
3630,
6155,
1010,
8040,
28433,
3630,
3207,
1010,
2744,
363... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/jsunit/app/xbDebug.js | xbDebugApplyFunction | function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
{
var rv;
if (!funcref)
{
alert('xbDebugApplyFunction: funcref is null');
}
if (typeof(funcref.apply) != 'undefined')
return funcref.apply(thisref, argumentsref);
var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
var i;
for (i = 0; i < argumentsref.length; i++)
{
applyexpr += 'argumentsref[' + i + '],';
}
if (argumentsref.length > 0)
{
applyexpr = applyexpr.substring(0, applyexpr.length - 1);
}
applyexpr += ')';
return eval(applyexpr);
} | javascript | function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
{
var rv;
if (!funcref)
{
alert('xbDebugApplyFunction: funcref is null');
}
if (typeof(funcref.apply) != 'undefined')
return funcref.apply(thisref, argumentsref);
var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
var i;
for (i = 0; i < argumentsref.length; i++)
{
applyexpr += 'argumentsref[' + i + '],';
}
if (argumentsref.length > 0)
{
applyexpr = applyexpr.substring(0, applyexpr.length - 1);
}
applyexpr += ')';
return eval(applyexpr);
} | [
"function",
"xbDebugApplyFunction",
"(",
"funcname",
",",
"funcref",
",",
"thisref",
",",
"argumentsref",
")",
"{",
"var",
"rv",
";",
"if",
"(",
"!",
"funcref",
")",
"{",
"alert",
"(",
"'xbDebugApplyFunction: funcref is null'",
")",
";",
"}",
"if",
"(",
"typ... | emulate functionref.apply for IE mac and IE win < 5.5 | [
"emulate",
"functionref",
".",
"apply",
"for",
"IE",
"mac",
"and",
"IE",
"win",
"<",
"5",
".",
"5"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/jsunit/app/xbDebug.js#L118-L146 | train | This function is called by xbDebugApplyFunction to apply a function to a specific object | [
30522,
3853,
1060,
2497,
3207,
8569,
3654,
9397,
2135,
11263,
27989,
1006,
4569,
2278,
18442,
1010,
4569,
16748,
2546,
1010,
2023,
2890,
2546,
1010,
9918,
2890,
2546,
1007,
1063,
13075,
27634,
1025,
2065,
1006,
999,
4569,
16748,
2546,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | write_cs | function write_cs(data, name, opts, wb, rels) {
return (name.slice(-4)===".bin" ? write_cs_bin : write_cs_xml)(data, opts, wb, rels);
} | javascript | function write_cs(data, name, opts, wb, rels) {
return (name.slice(-4)===".bin" ? write_cs_bin : write_cs_xml)(data, opts, wb, rels);
} | [
"function",
"write_cs",
"(",
"data",
",",
"name",
",",
"opts",
",",
"wb",
",",
"rels",
")",
"{",
"return",
"(",
"name",
".",
"slice",
"(",
"-",
"4",
")",
"===",
"\".bin\"",
"?",
"write_cs_bin",
":",
"write_cs_xml",
")",
"(",
"data",
",",
"opts",
",... | eslint-disable-next-line no-unused-vars | [
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"no",
"-",
"unused",
"-",
"vars"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L15123-L15125 | train | write a single file | [
30522,
3853,
4339,
1035,
20116,
1006,
2951,
1010,
2171,
1010,
23569,
2015,
1010,
25610,
1010,
2128,
4877,
1007,
1063,
2709,
1006,
2171,
1012,
14704,
1006,
1011,
1018,
1007,
1027,
1027,
1027,
1000,
1012,
8026,
1000,
1029,
4339,
1035,
20116,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/ViewUtils.js | getElementClipSize | function getElementClipSize($view, elementRect) {
var delta,
clip = { top: 0, right: 0, bottom: 0, left: 0 },
viewOffset = $view.offset() || { top: 0, left: 0};
// Check if element extends below viewport
delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height());
if (delta > 0) {
clip.bottom = delta;
}
// Check if element extends above viewport
delta = viewOffset.top - elementRect.top;
if (delta > 0) {
clip.top = delta;
}
// Check if element extends to the left of viewport
delta = viewOffset.left - elementRect.left;
if (delta > 0) {
clip.left = delta;
}
// Check if element extends to the right of viewport
delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width());
if (delta > 0) {
clip.right = delta;
}
return clip;
} | javascript | function getElementClipSize($view, elementRect) {
var delta,
clip = { top: 0, right: 0, bottom: 0, left: 0 },
viewOffset = $view.offset() || { top: 0, left: 0};
// Check if element extends below viewport
delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height());
if (delta > 0) {
clip.bottom = delta;
}
// Check if element extends above viewport
delta = viewOffset.top - elementRect.top;
if (delta > 0) {
clip.top = delta;
}
// Check if element extends to the left of viewport
delta = viewOffset.left - elementRect.left;
if (delta > 0) {
clip.left = delta;
}
// Check if element extends to the right of viewport
delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width());
if (delta > 0) {
clip.right = delta;
}
return clip;
} | [
"function",
"getElementClipSize",
"(",
"$view",
",",
"elementRect",
")",
"{",
"var",
"delta",
",",
"clip",
"=",
"{",
"top",
":",
"0",
",",
"right",
":",
"0",
",",
"bottom",
":",
"0",
",",
"left",
":",
"0",
"}",
",",
"viewOffset",
"=",
"$view",
".",... | Determine how much of an element rect is clipped in view.
@param {!DOMElement} $view - A jQuery scrolling container
@param {!{top: number, left: number, height: number, width: number}}
elementRect - rectangle of element's default position/size
@return {{top: number, right: number, bottom: number, left: number}}
amount element rect is clipped in each direction | [
"Determine",
"how",
"much",
"of",
"an",
"element",
"rect",
"is",
"clipped",
"in",
"view",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L313-L343 | train | Get element clip size | [
30522,
3853,
2131,
12260,
3672,
20464,
11514,
5332,
4371,
1006,
1002,
3193,
1010,
5783,
2890,
6593,
1007,
1063,
13075,
7160,
1010,
12528,
1027,
1063,
2327,
1024,
1014,
1010,
2157,
1024,
1014,
1010,
3953,
1024,
1014,
1010,
2187,
1024,
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... |
Dogfalo/materialize | docs/js/init.js | rgb2hex | function rgb2hex(rgb) {
if (/^#[0-9A-F]{6}$/i.test(rgb)) {
return rgb;
}
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (rgb === null) {
return 'N/A';
}
function hex(x) {
return ('0' + parseInt(x).toString(16)).slice(-2);
}
return '#' + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
} | javascript | function rgb2hex(rgb) {
if (/^#[0-9A-F]{6}$/i.test(rgb)) {
return rgb;
}
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (rgb === null) {
return 'N/A';
}
function hex(x) {
return ('0' + parseInt(x).toString(16)).slice(-2);
}
return '#' + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
} | [
"function",
"rgb2hex",
"(",
"rgb",
")",
"{",
"if",
"(",
"/",
"^#[0-9A-F]{6}$",
"/",
"i",
".",
"test",
"(",
"rgb",
")",
")",
"{",
"return",
"rgb",
";",
"}",
"rgb",
"=",
"rgb",
".",
"match",
"(",
"/",
"^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$",
"/",
")",
... | convert rgb to hex value string | [
"convert",
"rgb",
"to",
"hex",
"value",
"string"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/docs/js/init.js#L6-L22 | train | Convert rgb to hex | [
30522,
3853,
1054,
18259,
2475,
5369,
2595,
1006,
1054,
18259,
1007,
1063,
2065,
1006,
1013,
1034,
1001,
1031,
1014,
1011,
1023,
2050,
1011,
1042,
1033,
1063,
1020,
1065,
1002,
1013,
1045,
1012,
3231,
1006,
1054,
18259,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/helpers/helpers.options.js | function(value) {
var t, r, b, l;
if (helpers.isObject(value)) {
t = +value.top || 0;
r = +value.right || 0;
b = +value.bottom || 0;
l = +value.left || 0;
} else {
t = r = b = l = +value || 0;
}
return {
top: t,
right: r,
bottom: b,
left: l,
height: t + b,
width: l + r
};
} | javascript | function(value) {
var t, r, b, l;
if (helpers.isObject(value)) {
t = +value.top || 0;
r = +value.right || 0;
b = +value.bottom || 0;
l = +value.left || 0;
} else {
t = r = b = l = +value || 0;
}
return {
top: t,
right: r,
bottom: b,
left: l,
height: t + b,
width: l + r
};
} | [
"function",
"(",
"value",
")",
"{",
"var",
"t",
",",
"r",
",",
"b",
",",
"l",
";",
"if",
"(",
"helpers",
".",
"isObject",
"(",
"value",
")",
")",
"{",
"t",
"=",
"+",
"value",
".",
"top",
"||",
"0",
";",
"r",
"=",
"+",
"value",
".",
"right",... | Converts the given value into a padding object with pre-computed width/height.
@param {number|object} value - If a number, set the value to all TRBL component,
else, if and object, use defined properties and sets undefined ones to 0.
@returns {object} The padding values (top, right, bottom, left, width, height)
@since 2.7.0 | [
"Converts",
"the",
"given",
"value",
"into",
"a",
"padding",
"object",
"with",
"pre",
"-",
"computed",
"width",
"/",
"height",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/helpers/helpers.options.js#L66-L86 | train | Returns an object with the top right bottom left height and width properties of the specified node. | [
30522,
3853,
1006,
3643,
1007,
1063,
13075,
1056,
1010,
1054,
1010,
1038,
1010,
1048,
1025,
2065,
1006,
2393,
2545,
1012,
11163,
2497,
20614,
1006,
3643,
1007,
1007,
1063,
1056,
1027,
1009,
3643,
1012,
2327,
1064,
1064,
1014,
1025,
1054,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/camera.js | function() {
var x, angle, ray;
ctx.save();
for (var col=0; col<this.resolution; col++) {
x = col / this.resolution - 0.5;
angle = Math.atan2(x, this.focalLen);
ray = game.map.cast(game.player, game.player.dir + angle, this.range);
this.drawCol(col, ray, angle);
}
ctx.restore();
} | javascript | function() {
var x, angle, ray;
ctx.save();
for (var col=0; col<this.resolution; col++) {
x = col / this.resolution - 0.5;
angle = Math.atan2(x, this.focalLen);
ray = game.map.cast(game.player, game.player.dir + angle, this.range);
this.drawCol(col, ray, angle);
}
ctx.restore();
} | [
"function",
"(",
")",
"{",
"var",
"x",
",",
"angle",
",",
"ray",
";",
"ctx",
".",
"save",
"(",
")",
";",
"for",
"(",
"var",
"col",
"=",
"0",
";",
"col",
"<",
"this",
".",
"resolution",
";",
"col",
"++",
")",
"{",
"x",
"=",
"col",
"/",
"this... | Based on the resolution, split the scene up and draw it column by column. | [
"Based",
"on",
"the",
"resolution",
"split",
"the",
"scene",
"up",
"and",
"draw",
"it",
"column",
"by",
"column",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/camera.js#L54-L68 | train | draw the image | [
30522,
3853,
1006,
1007,
1063,
13075,
1060,
1010,
6466,
1010,
4097,
1025,
14931,
2595,
1012,
3828,
1006,
1007,
1025,
2005,
1006,
13075,
8902,
1027,
1014,
1025,
8902,
1026,
2023,
1012,
5813,
1025,
8902,
1009,
1009,
1007,
1063,
1060,
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... | |
aframevr/aframe | src/components/scene/screenshot.js | function (projection) {
var isVREnabled = this.el.renderer.vr.enabled;
var renderer = this.el.renderer;
var params;
// Disable VR.
renderer.vr.enabled = false;
params = this.setCapture(projection);
this.renderCapture(params.camera, params.size, params.projection);
// Trigger file download.
this.saveCapture();
// Restore VR.
renderer.vr.enabled = isVREnabled;
} | javascript | function (projection) {
var isVREnabled = this.el.renderer.vr.enabled;
var renderer = this.el.renderer;
var params;
// Disable VR.
renderer.vr.enabled = false;
params = this.setCapture(projection);
this.renderCapture(params.camera, params.size, params.projection);
// Trigger file download.
this.saveCapture();
// Restore VR.
renderer.vr.enabled = isVREnabled;
} | [
"function",
"(",
"projection",
")",
"{",
"var",
"isVREnabled",
"=",
"this",
".",
"el",
".",
"renderer",
".",
"vr",
".",
"enabled",
";",
"var",
"renderer",
"=",
"this",
".",
"el",
".",
"renderer",
";",
"var",
"params",
";",
"// Disable VR.",
"renderer",
... | Maintained for backwards compatibility. | [
"Maintained",
"for",
"backwards",
"compatibility",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/screenshot.js#L171-L183 | train | Render the camera and size of the camera | [
30522,
3853,
1006,
13996,
1007,
1063,
13075,
2003,
12229,
22966,
2094,
30524,
1025,
13075,
11498,
5244,
1025,
1013,
1013,
4487,
19150,
27830,
1012,
17552,
2121,
1012,
27830,
1012,
9124,
1027,
6270,
1025,
11498,
5244,
1027,
2023,
1012,
2275,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/type/Int.js | setConstraints | function setConstraints(oType, oConstraints) {
var vNullable;
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
if (vNullable === false || vNullable === "false") {
oType.oConstraints = {nullable : false};
} else if (vNullable !== undefined && vNullable !== true && vNullable !== "true") {
Log.warning("Illegal nullable: " + vNullable, null, oType.getName());
}
}
oType._handleLocalizationChange();
} | javascript | function setConstraints(oType, oConstraints) {
var vNullable;
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
if (vNullable === false || vNullable === "false") {
oType.oConstraints = {nullable : false};
} else if (vNullable !== undefined && vNullable !== true && vNullable !== "true") {
Log.warning("Illegal nullable: " + vNullable, null, oType.getName());
}
}
oType._handleLocalizationChange();
} | [
"function",
"setConstraints",
"(",
"oType",
",",
"oConstraints",
")",
"{",
"var",
"vNullable",
";",
"oType",
".",
"oConstraints",
"=",
"undefined",
";",
"if",
"(",
"oConstraints",
")",
"{",
"vNullable",
"=",
"oConstraints",
".",
"nullable",
";",
"if",
"(",
... | Sets the constraints.
@param {sap.ui.model.odata.type.Int} oType
the type instance
@param {object} [oConstraints]
constraints, see {@link #constructor} | [
"Sets",
"the",
"constraints",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Int.js#L56-L69 | train | Sets constraints for the given type | [
30522,
3853,
2275,
8663,
20528,
18447,
2015,
1006,
27178,
18863,
1010,
1051,
8663,
20528,
18447,
2015,
1007,
1063,
13075,
1058,
11231,
4571,
3468,
1025,
27178,
18863,
1012,
1051,
8663,
20528,
18447,
2015,
1027,
6151,
28344,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/downloads.js | getLocalFileFromNativePathOrUrl | function getLocalFileFromNativePathOrUrl(aPathOrUrl) {
if (aPathOrUrl.substring(0,7) == "file://") {
// if this is a URL, get the file from that
let ioSvc = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
// XXX it's possible that using a null char-set here is bad
const fileUrl = ioSvc.newURI(aPathOrUrl, null, null)
.QueryInterface(Ci.nsIFileURL);
return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
} else {
// if it's a pathname, create the nsILocalFile directly
var f = new nsLocalFile(aPathOrUrl);
return f;
}
} | javascript | function getLocalFileFromNativePathOrUrl(aPathOrUrl) {
if (aPathOrUrl.substring(0,7) == "file://") {
// if this is a URL, get the file from that
let ioSvc = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
// XXX it's possible that using a null char-set here is bad
const fileUrl = ioSvc.newURI(aPathOrUrl, null, null)
.QueryInterface(Ci.nsIFileURL);
return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
} else {
// if it's a pathname, create the nsILocalFile directly
var f = new nsLocalFile(aPathOrUrl);
return f;
}
} | [
"function",
"getLocalFileFromNativePathOrUrl",
"(",
"aPathOrUrl",
")",
"{",
"if",
"(",
"aPathOrUrl",
".",
"substring",
"(",
"0",
",",
"7",
")",
"==",
"\"file://\"",
")",
"{",
"// if this is a URL, get the file from that",
"let",
"ioSvc",
"=",
"Cc",
"[",
"\"@mozill... | Get a local file from a native path or URL
@param {string} aPathOrUrl
Native path or URL of the file
@see http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/downloads/content/downloads.js#1309 | [
"Get",
"a",
"local",
"file",
"from",
"a",
"native",
"path",
"or",
"URL"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L386-L401 | train | Get the local file from a native path or a URL | [
30522,
3853,
2131,
4135,
9289,
8873,
2571,
19699,
5358,
19833,
3512,
15069,
2953,
3126,
2140,
1006,
9706,
8988,
2953,
3126,
2140,
1007,
1063,
2065,
1006,
9706,
8988,
2953,
3126,
2140,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
1021,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_themeElements | function parse_themeElements(data, themes, opts) {
themes.themeElements = {};
var t;
[
/* clrScheme CT_ColorScheme */
['clrScheme', clrsregex, parse_clrScheme],
/* fontScheme CT_FontScheme */
['fontScheme', fntsregex, parse_fontScheme],
/* fmtScheme CT_StyleMatrix */
['fmtScheme', fmtsregex, parse_fmtScheme]
].forEach(function(m) {
if(!(t=data.match(m[1]))) throw new Error(m[0] + ' not found in themeElements');
m[2](t, themes, opts);
});
} | javascript | function parse_themeElements(data, themes, opts) {
themes.themeElements = {};
var t;
[
/* clrScheme CT_ColorScheme */
['clrScheme', clrsregex, parse_clrScheme],
/* fontScheme CT_FontScheme */
['fontScheme', fntsregex, parse_fontScheme],
/* fmtScheme CT_StyleMatrix */
['fmtScheme', fmtsregex, parse_fmtScheme]
].forEach(function(m) {
if(!(t=data.match(m[1]))) throw new Error(m[0] + ' not found in themeElements');
m[2](t, themes, opts);
});
} | [
"function",
"parse_themeElements",
"(",
"data",
",",
"themes",
",",
"opts",
")",
"{",
"themes",
".",
"themeElements",
"=",
"{",
"}",
";",
"var",
"t",
";",
"[",
"/* clrScheme CT_ColorScheme */",
"[",
"'clrScheme'",
",",
"clrsregex",
",",
"parse_clrScheme",
"]",... | /* 20.1.6.10 themeElements CT_BaseStyles | [
"/",
"*",
"20",
".",
"1",
".",
"6",
".",
"10",
"themeElements",
"CT_BaseStyles"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L9475-L9491 | train | Parse theme elements | [
30522,
3853,
11968,
3366,
1035,
4323,
12260,
8163,
1006,
30524,
1012,
4323,
12260,
8163,
1027,
1063,
1065,
1025,
13075,
1056,
1025,
1031,
1013,
1008,
18856,
2869,
5403,
4168,
14931,
1035,
6087,
5403,
4168,
1008,
1013,
1031,
1005,
18856,
286... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | handleTernCompletions | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | javascript | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | [
"function",
"handleTernCompletions",
"(",
"response",
")",
"{",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
",",
"completions",
"=",
"response",
".",
"completions",
",",
"properties",
"=",
"response",
".",
"pro... | Handle the response from the tern node domain when
it responds with the list of completions
@param {{file: string, offset: {line: number, ch: number}, completions:Array.<string>,
properties:Array.<string>}} response - the response from node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"list",
"of",
"completions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L690-L712 | train | Handle Tern completions | [
30522,
3853,
5047,
16451,
9006,
10814,
9285,
1006,
3433,
1007,
1063,
13075,
5371,
1027,
3433,
1012,
5371,
1010,
16396,
1027,
3433,
1012,
16396,
1010,
6503,
2015,
1027,
3433,
1012,
6503,
2015,
1010,
5144,
1027,
3433,
1012,
5144,
1010,
1042,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pagekit/vue-resource | dist/vue-resource.esm.js | root | function root (options$$1, next) {
var url = next(options$$1);
if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) {
url = trimEnd(options$$1.root, '/') + '/' + url;
}
return url;
} | javascript | function root (options$$1, next) {
var url = next(options$$1);
if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) {
url = trimEnd(options$$1.root, '/') + '/' + url;
}
return url;
} | [
"function",
"root",
"(",
"options$$1",
",",
"next",
")",
"{",
"var",
"url",
"=",
"next",
"(",
"options$$1",
")",
";",
"if",
"(",
"isString",
"(",
"options$$1",
".",
"root",
")",
"&&",
"!",
"/",
"^(https?:)?\\/",
"/",
".",
"test",
"(",
"url",
")",
"... | Root Prefix Transform. | [
"Root",
"Prefix",
"Transform",
"."
] | fe268fa1d6053ede5f34aef9a11e1a424a70446c | https://github.com/pagekit/vue-resource/blob/fe268fa1d6053ede5f34aef9a11e1a424a70446c/dist/vue-resource.esm.js#L448-L457 | train | Get the root url | [
30522,
3853,
7117,
1006,
7047,
1002,
1002,
1015,
1010,
2279,
1007,
1063,
13075,
24471,
2140,
1027,
2279,
1006,
7047,
1002,
1002,
1015,
1007,
1025,
2065,
1006,
26354,
18886,
3070,
1006,
7047,
1002,
1002,
1015,
1012,
7117,
1007,
1004,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/tooltip/tooltip.js | deregister | function deregister(type, handler, useCapture) {
var handlers = listeners[type];
var index = handlers ? handlers.indexOf(handler) : -1;
if (index > -1) {
handlers.splice(index, 1);
if (handlers.length === 0) {
useCapture ? window.removeEventListener(type, globalEventHandler, true) :
ngWindow.off(type, globalEventHandler);
}
}
} | javascript | function deregister(type, handler, useCapture) {
var handlers = listeners[type];
var index = handlers ? handlers.indexOf(handler) : -1;
if (index > -1) {
handlers.splice(index, 1);
if (handlers.length === 0) {
useCapture ? window.removeEventListener(type, globalEventHandler, true) :
ngWindow.off(type, globalEventHandler);
}
}
} | [
"function",
"deregister",
"(",
"type",
",",
"handler",
",",
"useCapture",
")",
"{",
"var",
"handlers",
"=",
"listeners",
"[",
"type",
"]",
";",
"var",
"index",
"=",
"handlers",
"?",
"handlers",
".",
"indexOf",
"(",
"handler",
")",
":",
"-",
"1",
";",
... | Removes an event handler from the service.
@param {string} type Type of event handler.
@param {!Function} handler The event handler itself.
@param {boolean} useCapture Whether the event handler used event capturing. | [
"Removes",
"an",
"event",
"handler",
"from",
"the",
"service",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tooltip/tooltip.js#L470-L482 | train | Deregisters a listener for a specific event type | [
30522,
3853,
4315,
13910,
12911,
1006,
2828,
1010,
28213,
1010,
2224,
17695,
11244,
1007,
1063,
13075,
28213,
2015,
1027,
13810,
1031,
2828,
1033,
1025,
13075,
5950,
1027,
28213,
2015,
1029,
28213,
2015,
1012,
5950,
11253,
1006,
28213,
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... |
nhn/tui.editor | src/js/wysiwygCommands/tableAddCol.js | getNumberOfCols | function getNumberOfCols(wwe) {
const selectionMgr = wwe.componentManager.getManager('tableSelection');
const $selectedCells = selectionMgr.getSelectedCells();
let length = 1;
if ($selectedCells.length > 0) {
const maxLength = $selectedCells.get(0).parentNode.querySelectorAll('td, th').length;
length = Math.min(maxLength, $selectedCells.length);
}
return length;
} | javascript | function getNumberOfCols(wwe) {
const selectionMgr = wwe.componentManager.getManager('tableSelection');
const $selectedCells = selectionMgr.getSelectedCells();
let length = 1;
if ($selectedCells.length > 0) {
const maxLength = $selectedCells.get(0).parentNode.querySelectorAll('td, th').length;
length = Math.min(maxLength, $selectedCells.length);
}
return length;
} | [
"function",
"getNumberOfCols",
"(",
"wwe",
")",
"{",
"const",
"selectionMgr",
"=",
"wwe",
".",
"componentManager",
".",
"getManager",
"(",
"'tableSelection'",
")",
";",
"const",
"$selectedCells",
"=",
"selectionMgr",
".",
"getSelectedCells",
"(",
")",
";",
"let"... | get number of selected cols
@param {WysiwygEditor} wwe - wysiwyg editor instance
@returns {number} - number of selected cols
@ignore | [
"get",
"number",
"of",
"selected",
"cols"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableAddCol.js#L49-L60 | train | Get number of cols | [
30522,
3853,
2131,
19172,
5677,
11253,
25778,
2015,
1006,
11700,
1007,
1063,
9530,
3367,
4989,
24798,
2099,
1027,
11700,
1012,
6922,
24805,
4590,
1012,
2131,
24805,
4590,
1006,
1005,
7251,
12260,
7542,
1005,
1007,
1025,
9530,
3367,
1002,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | valueSet | function valueSet ( input, fireSetEvent ) {
var values = asArray(input);
var isInit = scope_Locations[0] === undefined;
// Event fires by default
fireSetEvent = (fireSetEvent === undefined ? true : !!fireSetEvent);
values.forEach(setValue);
// Animation is optional.
// Make sure the initial values were set before using animated placement.
if ( options.animate && !isInit ) {
addClassFor(scope_Target, options.cssClasses.tap, options.animationDuration);
}
// Now that all base values are set, apply constraints
scope_HandleNumbers.forEach(function(handleNumber){
setHandle(handleNumber, scope_Locations[handleNumber], true, false);
});
setZindex();
scope_HandleNumbers.forEach(function(handleNumber){
fireEvent('update', handleNumber);
// Fire the event only for handles that received a new value, as per #579
if ( values[handleNumber] !== null && fireSetEvent ) {
fireEvent('set', handleNumber);
}
});
} | javascript | function valueSet ( input, fireSetEvent ) {
var values = asArray(input);
var isInit = scope_Locations[0] === undefined;
// Event fires by default
fireSetEvent = (fireSetEvent === undefined ? true : !!fireSetEvent);
values.forEach(setValue);
// Animation is optional.
// Make sure the initial values were set before using animated placement.
if ( options.animate && !isInit ) {
addClassFor(scope_Target, options.cssClasses.tap, options.animationDuration);
}
// Now that all base values are set, apply constraints
scope_HandleNumbers.forEach(function(handleNumber){
setHandle(handleNumber, scope_Locations[handleNumber], true, false);
});
setZindex();
scope_HandleNumbers.forEach(function(handleNumber){
fireEvent('update', handleNumber);
// Fire the event only for handles that received a new value, as per #579
if ( values[handleNumber] !== null && fireSetEvent ) {
fireEvent('set', handleNumber);
}
});
} | [
"function",
"valueSet",
"(",
"input",
",",
"fireSetEvent",
")",
"{",
"var",
"values",
"=",
"asArray",
"(",
"input",
")",
";",
"var",
"isInit",
"=",
"scope_Locations",
"[",
"0",
"]",
"===",
"undefined",
";",
"// Event fires by default",
"fireSetEvent",
"=",
"... | Set the slider value. | [
"Set",
"the",
"slider",
"value",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1878-L1910 | train | Set the values of the handle | [
30522,
3853,
5300,
3388,
1006,
7953,
1010,
8769,
12870,
15338,
1007,
1063,
13075,
5300,
1027,
17306,
11335,
2100,
1006,
7953,
1007,
1025,
13075,
2003,
5498,
2102,
1027,
9531,
1035,
5269,
1031,
1014,
1033,
1027,
1027,
1027,
6151,
28344,
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/layers/src/solid-polygon-layer/polygon.js | copyFlatRing | function copyFlatRing(target, targetStartIndex, positions, size, srcStartIndex = 0, srcEndIndex) {
srcEndIndex = srcEndIndex || positions.length;
const srcLength = srcEndIndex - srcStartIndex;
if (srcLength <= 0) {
return targetStartIndex;
}
let targetIndex = targetStartIndex;
for (let i = 0; i < srcLength; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
if (!isFlatRingClosed(positions, size, srcStartIndex, srcEndIndex)) {
for (let i = 0; i < size; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
}
return targetIndex;
} | javascript | function copyFlatRing(target, targetStartIndex, positions, size, srcStartIndex = 0, srcEndIndex) {
srcEndIndex = srcEndIndex || positions.length;
const srcLength = srcEndIndex - srcStartIndex;
if (srcLength <= 0) {
return targetStartIndex;
}
let targetIndex = targetStartIndex;
for (let i = 0; i < srcLength; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
if (!isFlatRingClosed(positions, size, srcStartIndex, srcEndIndex)) {
for (let i = 0; i < size; i++) {
target[targetIndex++] = positions[srcStartIndex + i];
}
}
return targetIndex;
} | [
"function",
"copyFlatRing",
"(",
"target",
",",
"targetStartIndex",
",",
"positions",
",",
"size",
",",
"srcStartIndex",
"=",
"0",
",",
"srcEndIndex",
")",
"{",
"srcEndIndex",
"=",
"srcEndIndex",
"||",
"positions",
".",
"length",
";",
"const",
"srcLength",
"="... | Copy a simple flat array into another flat array, closes the ring if needed.
@param {Float64Array} target - destination
@param {Number} targetStartIndex - index in the destination to start copying into
@param {Array} positions - array of numbers
@param {Number} size - size of a position, 2 (xy) or 3 (xyz)
@param {Number} [srcStartIndex] - start index of the path in the positions array
@param {Number} [srcEndIndex] - end index of the path in the positions array
@returns {Number} - the index of the write head in the destination | [
"Copy",
"a",
"simple",
"flat",
"array",
"into",
"another",
"flat",
"array",
"closes",
"the",
"ring",
"if",
"needed",
"."
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/layers/src/solid-polygon-layer/polygon.js#L117-L135 | train | Copy a flat ring to a flat array | [
30522,
3853,
6100,
10258,
4017,
4892,
1006,
4539,
1010,
7889,
7559,
7629,
3207,
2595,
1010,
4460,
1010,
2946,
1010,
5034,
6169,
7559,
7629,
3207,
2595,
1027,
1014,
1010,
5034,
23865,
30524,
5034,
14321,
3070,
2705,
1027,
5034,
23865,
22254,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.