repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
adobe/brackets | src/language/JSONUtils.js | stripQuotes | function stripQuotes(string) {
if (string) {
if (/^['"]$/.test(string.charAt(0))) {
string = string.substr(1);
}
if (/^['"]$/.test(string.substr(-1, 1))) {
string = string.substr(0, string.length - 1);
}
}
return string;
} | javascript | function stripQuotes(string) {
if (string) {
if (/^['"]$/.test(string.charAt(0))) {
string = string.substr(1);
}
if (/^['"]$/.test(string.substr(-1, 1))) {
string = string.substr(0, string.length - 1);
}
}
return string;
} | [
"function",
"stripQuotes",
"(",
"string",
")",
"{",
"if",
"(",
"string",
")",
"{",
"if",
"(",
"/",
"^['\"]$",
"/",
".",
"test",
"(",
"string",
".",
"charAt",
"(",
"0",
")",
")",
")",
"{",
"string",
"=",
"string",
".",
"substr",
"(",
"1",
")",
"... | Removes the quotes around a string
@param {!String} string
@return {String} | [
"Removes",
"the",
"quotes",
"around",
"a",
"string"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSONUtils.js#L75-L85 | train | strip quotes from string | [
30522,
3853,
6167,
28940,
12184,
2015,
1006,
5164,
1007,
1063,
2065,
1006,
5164,
1007,
1063,
2065,
1006,
1013,
1034,
1031,
1005,
1000,
1033,
1002,
1013,
1012,
3231,
1006,
5164,
1012,
25869,
30524,
1010,
1015,
1007,
1007,
1007,
1063,
5164,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/RenameIdentifier.js | requestFindReferences | function requestFindReferences(session, offset) {
var response = requestFindRefs(session, session.editor.document, offset);
if (response && response.hasOwnProperty("promise")) {
response.promise.done(handleFindRefs).fail(function () {
result.reject();
});
}
} | javascript | function requestFindReferences(session, offset) {
var response = requestFindRefs(session, session.editor.document, offset);
if (response && response.hasOwnProperty("promise")) {
response.promise.done(handleFindRefs).fail(function () {
result.reject();
});
}
} | [
"function",
"requestFindReferences",
"(",
"session",
",",
"offset",
")",
"{",
"var",
"response",
"=",
"requestFindRefs",
"(",
"session",
",",
"session",
".",
"editor",
".",
"document",
",",
"offset",
")",
";",
"if",
"(",
"response",
"&&",
"response",
".",
... | Make a find ref request.
@param {Session} session - the session
@param {number} offset - the offset of where to jump from | [
"Make",
"a",
"find",
"ref",
"request",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RenameIdentifier.js#L169-L177 | train | Request find references | [
30522,
3853,
5227,
16294,
16200,
25523,
2015,
1006,
5219,
1010,
16396,
1007,
1063,
13075,
3433,
1027,
5227,
16294,
16200,
10343,
1006,
5219,
1010,
5219,
1012,
3559,
1012,
6254,
1010,
16396,
1007,
1025,
2065,
1006,
3433,
1004,
1004,
3433,
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... |
semantic-release/semantic-release | lib/git.js | verifyAuth | async function verifyAuth(repositoryUrl, branch, execaOpts) {
try {
await execa('git', ['push', '--dry-run', repositoryUrl, `HEAD:${branch}`], execaOpts);
} catch (error) {
debug(error);
throw error;
}
} | javascript | async function verifyAuth(repositoryUrl, branch, execaOpts) {
try {
await execa('git', ['push', '--dry-run', repositoryUrl, `HEAD:${branch}`], execaOpts);
} catch (error) {
debug(error);
throw error;
}
} | [
"async",
"function",
"verifyAuth",
"(",
"repositoryUrl",
",",
"branch",
",",
"execaOpts",
")",
"{",
"try",
"{",
"await",
"execa",
"(",
"'git'",
",",
"[",
"'push'",
",",
"'--dry-run'",
",",
"repositoryUrl",
",",
"`",
"${",
"branch",
"}",
"`",
"]",
",",
... | Verify the write access authorization to remote repository with push dry-run.
@param {String} repositoryUrl The remote repository URL.
@param {String} branch The repositoru branch for which to verify write access.
@param {Object} [execaOpts] Options to pass to `execa`.
@throws {Error} if not authorized to push. | [
"Verify",
"the",
"write",
"access",
"authorization",
"to",
"remote",
"repository",
"with",
"push",
"dry",
"-",
"run",
"."
] | edf382f88838ed543c0b76cb6c914cca1fc1ddd1 | https://github.com/semantic-release/semantic-release/blob/edf382f88838ed543c0b76cb6c914cca1fc1ddd1/lib/git.js#L121-L128 | train | Verify auth for the branch | [
30522,
2004,
6038,
2278,
3853,
20410,
4887,
2705,
1006,
22409,
3126,
2140,
1010,
3589,
1010,
4654,
19281,
7361,
3215,
1007,
1063,
3046,
1063,
26751,
4654,
19281,
1006,
1005,
21025,
2102,
1005,
1010,
1031,
1005,
5245,
1005,
1010,
1005,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
websockets/ws | lib/buffer-util.js | _mask | function _mask(source, mask, output, offset, length) {
for (let i = 0; i < length; i++) {
output[offset + i] = source[i] ^ mask[i & 3];
}
} | javascript | function _mask(source, mask, output, offset, length) {
for (let i = 0; i < length; i++) {
output[offset + i] = source[i] ^ mask[i & 3];
}
} | [
"function",
"_mask",
"(",
"source",
",",
"mask",
",",
"output",
",",
"offset",
",",
"length",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"output",
"[",
"offset",
"+",
"i",
"]",
"=",
"source",
... | Masks a buffer using the given mask.
@param {Buffer} source The buffer to mask
@param {Buffer} mask The mask to use
@param {Buffer} output The buffer where to store the result
@param {Number} offset The offset at which to start writing
@param {Number} length The number of bytes to mask.
@public | [
"Masks",
"a",
"buffer",
"using",
"the",
"given",
"mask",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/buffer-util.js#L39-L43 | train | Mask the given source array with the given mask. | [
30522,
3853,
1035,
7308,
1006,
3120,
1010,
7308,
1010,
6434,
1010,
16396,
1010,
3091,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
6434,
1031,
16396,
1009,
1045,
1033,
1027,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/StringUtils.js | truncate | function truncate(str, len) {
// Truncate text to specified length
if (str.length > len) {
str = str.substr(0, len);
// To prevent awkwardly truncating in the middle of a word,
// attempt to truncate at the end of the last whole word
var lastSpaceChar = str.lastIndexOf(" ");
if (lastSpaceChar < len && lastSpaceChar > -1) {
str = str.substr(0, lastSpaceChar);
}
return str;
}
} | javascript | function truncate(str, len) {
// Truncate text to specified length
if (str.length > len) {
str = str.substr(0, len);
// To prevent awkwardly truncating in the middle of a word,
// attempt to truncate at the end of the last whole word
var lastSpaceChar = str.lastIndexOf(" ");
if (lastSpaceChar < len && lastSpaceChar > -1) {
str = str.substr(0, lastSpaceChar);
}
return str;
}
} | [
"function",
"truncate",
"(",
"str",
",",
"len",
")",
"{",
"// Truncate text to specified length",
"if",
"(",
"str",
".",
"length",
">",
"len",
")",
"{",
"str",
"=",
"str",
".",
"substr",
"(",
"0",
",",
"len",
")",
";",
"// To prevent awkwardly truncating in ... | Truncate text to specified length.
@param {string} str Text to be truncated.
@param {number} len Length to which text should be truncated
@return {?string} Returns truncated text only if it was changed | [
"Truncate",
"text",
"to",
"specified",
"length",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringUtils.js#L213-L226 | train | Truncate text to specified length | [
30522,
3853,
19817,
4609,
16280,
1006,
2358,
2099,
1010,
18798,
1007,
1063,
1013,
1013,
19817,
4609,
16280,
3793,
2000,
9675,
3091,
2065,
30524,
2203,
1997,
1996,
2197,
2878,
2773,
13075,
16180,
15327,
7507,
2099,
1027,
2358,
2099,
1012,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/icon/js/iconService.js | prepareAndStyle | function prepareAndStyle() {
var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize;
angular.forEach({
'fit': '',
'height': '100%',
'width': '100%',
'preserveAspectRatio': 'xMidYMid meet',
'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize),
'focusable': false // Disable IE11s default behavior to make SVGs focusable
}, function(val, attr) {
this.element.setAttribute(attr, val);
}, this);
} | javascript | function prepareAndStyle() {
var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize;
angular.forEach({
'fit': '',
'height': '100%',
'width': '100%',
'preserveAspectRatio': 'xMidYMid meet',
'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize),
'focusable': false // Disable IE11s default behavior to make SVGs focusable
}, function(val, attr) {
this.element.setAttribute(attr, val);
}, this);
} | [
"function",
"prepareAndStyle",
"(",
")",
"{",
"var",
"viewBoxSize",
"=",
"this",
".",
"config",
"?",
"this",
".",
"config",
".",
"viewBoxSize",
":",
"config",
".",
"defaultViewBoxSize",
";",
"angular",
".",
"forEach",
"(",
"{",
"'fit'",
":",
"''",
",",
"... | Prepare the DOM element that will be cached in the
loaded iconCache store. | [
"Prepare",
"the",
"DOM",
"element",
"that",
"will",
"be",
"cached",
"in",
"the",
"loaded",
"iconCache",
"store",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L712-L724 | train | Prepare and apply the viewBox and viewBox size | [
30522,
3853,
7374,
29560,
27983,
1006,
1007,
1063,
13075,
3193,
8758,
5332,
4371,
1027,
2023,
1012,
9530,
8873,
2290,
1029,
2023,
1012,
9530,
8873,
2290,
1012,
3193,
8758,
5332,
4371,
1024,
9530,
8873,
2290,
1012,
12398,
8584,
8758,
5332,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
electron/electron | spec/api-net-spec.js | randomBuffer | function randomBuffer (size, start, end) {
start = start || 0
end = end || 255
const range = 1 + end - start
const buffer = Buffer.allocUnsafe(size)
for (let i = 0; i < size; ++i) {
buffer[i] = start + Math.floor(Math.random() * range)
}
return buffer
} | javascript | function randomBuffer (size, start, end) {
start = start || 0
end = end || 255
const range = 1 + end - start
const buffer = Buffer.allocUnsafe(size)
for (let i = 0; i < size; ++i) {
buffer[i] = start + Math.floor(Math.random() * range)
}
return buffer
} | [
"function",
"randomBuffer",
"(",
"size",
",",
"start",
",",
"end",
")",
"{",
"start",
"=",
"start",
"||",
"0",
"end",
"=",
"end",
"||",
"255",
"const",
"range",
"=",
"1",
"+",
"end",
"-",
"start",
"const",
"buffer",
"=",
"Buffer",
".",
"allocUnsafe",... | /* The whole net API doesn't use standard callbacks /* eslint-disable standard/no-callback-literal | [
"/",
"*",
"The",
"whole",
"net",
"API",
"doesn",
"t",
"use",
"standard",
"callbacks",
"/",
"*",
"eslint",
"-",
"disable",
"standard",
"/",
"no",
"-",
"callback",
"-",
"literal"
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/spec/api-net-spec.js#L13-L22 | train | Creates a random buffer | [
30522,
3853,
6721,
8569,
12494,
1006,
2946,
1010,
2707,
1010,
2203,
1007,
1063,
2707,
1027,
2707,
1064,
1064,
1014,
2203,
1027,
2203,
1064,
1064,
20637,
9530,
3367,
2846,
1027,
1015,
1009,
2203,
1011,
2707,
9530,
3367,
17698,
1027,
17698,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/collect-results-from-frames.js | collectResultsFromFrames | function collectResultsFromFrames(
context,
options,
command,
parameter,
resolve,
reject
) {
'use strict';
var q = axe.utils.queue();
var frames = context.frames;
// Tell each axe running in each frame to collect results
frames.forEach(function(frame) {
var params = {
options: options,
command: command,
parameter: parameter,
context: {
initiator: false,
page: context.page,
include: frame.include || [],
exclude: frame.exclude || []
}
};
q.defer(function(res, rej) {
var node = frame.node;
axe.utils.sendCommandToFrame(
node,
params,
function(data) {
if (data) {
return res({
results: data,
frameElement: node,
frame: axe.utils.getSelector(node)
});
}
res(null);
},
rej
);
});
});
// Combine results from all frames and give it back
q.then(function(data) {
resolve(axe.utils.mergeResults(data, options));
}).catch(reject);
} | javascript | function collectResultsFromFrames(
context,
options,
command,
parameter,
resolve,
reject
) {
'use strict';
var q = axe.utils.queue();
var frames = context.frames;
// Tell each axe running in each frame to collect results
frames.forEach(function(frame) {
var params = {
options: options,
command: command,
parameter: parameter,
context: {
initiator: false,
page: context.page,
include: frame.include || [],
exclude: frame.exclude || []
}
};
q.defer(function(res, rej) {
var node = frame.node;
axe.utils.sendCommandToFrame(
node,
params,
function(data) {
if (data) {
return res({
results: data,
frameElement: node,
frame: axe.utils.getSelector(node)
});
}
res(null);
},
rej
);
});
});
// Combine results from all frames and give it back
q.then(function(data) {
resolve(axe.utils.mergeResults(data, options));
}).catch(reject);
} | [
"function",
"collectResultsFromFrames",
"(",
"context",
",",
"options",
",",
"command",
",",
"parameter",
",",
"resolve",
",",
"reject",
")",
"{",
"'use strict'",
";",
"var",
"q",
"=",
"axe",
".",
"utils",
".",
"queue",
"(",
")",
";",
"var",
"frames",
"=... | Sends a message to axe running in frames to start analysis and collate results (via `mergeResults`)
@private
@param {Context} context The resolved Context object
@param {Object} options Options object (as passed to `runRules`)
@param {string} command Command sent to all frames
@param {Array} parameter Array of values to be passed along side the command
@param {Function} callback Function to call when results from all frames have returned | [
"Sends",
"a",
"message",
"to",
"axe",
"running",
"in",
"frames",
"to",
"start",
"analysis",
"and",
"collate",
"results",
"(",
"via",
"mergeResults",
")"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/collect-results-from-frames.js#L74-L125 | train | Collect results from all frames | [
30522,
3853,
8145,
6072,
11314,
22747,
21716,
15643,
2015,
1006,
6123,
1010,
7047,
1010,
3094,
1010,
16381,
1010,
10663,
1010,
15454,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
1053,
1027,
12946,
1012,
21183,
12146,
1012,
24240,
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... |
facebook/relay | scripts/rewrite-modules.js | transformJestHelper | function transformJestHelper(path, state) {
var calleePath = path.get('callee');
var args = path.get('arguments');
if (!args.length) {
return;
}
var moduleArg = args[0];
if (
moduleArg.node.type === 'StringLiteral' &&
calleePath.node &&
isJestProperty(t, calleePath.node.property)
) {
var module = mapModule(state, moduleArg.node.value);
if (module) {
moduleArg.replaceWith(t.stringLiteral(module));
}
}
} | javascript | function transformJestHelper(path, state) {
var calleePath = path.get('callee');
var args = path.get('arguments');
if (!args.length) {
return;
}
var moduleArg = args[0];
if (
moduleArg.node.type === 'StringLiteral' &&
calleePath.node &&
isJestProperty(t, calleePath.node.property)
) {
var module = mapModule(state, moduleArg.node.value);
if (module) {
moduleArg.replaceWith(t.stringLiteral(module));
}
}
} | [
"function",
"transformJestHelper",
"(",
"path",
",",
"state",
")",
"{",
"var",
"calleePath",
"=",
"path",
".",
"get",
"(",
"'callee'",
")",
";",
"var",
"args",
"=",
"path",
".",
"get",
"(",
"'arguments'",
")",
";",
"if",
"(",
"!",
"args",
".",
"lengt... | Transforms either individual or chained calls to `jest.dontMock('Foo')`,
`jest.mock('Foo')`, and `jest.genMockFromModule('Foo')`. | [
"Transforms",
"either",
"individual",
"or",
"chained",
"calls",
"to",
"jest",
".",
"dontMock",
"(",
"Foo",
")",
"jest",
".",
"mock",
"(",
"Foo",
")",
"and",
"jest",
".",
"genMockFromModule",
"(",
"Foo",
")",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/scripts/rewrite-modules.js#L98-L115 | train | Transform a Jest function call to a module | [
30522,
3853,
10938,
6460,
3367,
16001,
4842,
1006,
4130,
1010,
2110,
1007,
1063,
13075,
2655,
4402,
15069,
1027,
4130,
1012,
2131,
1006,
1005,
2655,
4402,
1005,
1007,
1025,
13075,
12098,
5620,
1027,
4130,
1012,
2131,
1006,
1005,
9918,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(input) {
var showAnim, duration, postProcess, onClose,
inst = this._curInst;
if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
return;
}
if (this._datepickerShowing) {
showAnim = this._get(inst, "showAnim");
duration = this._get(inst, "duration");
postProcess = function() {
$.datepicker._tidyDialog(inst);
};
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
} else {
inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
(showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
}
if (!showAnim) {
postProcess();
}
this._datepickerShowing = false;
onClose = this._get(inst, "onClose");
if (onClose) {
onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
}
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
if ($.blockUI) {
$.unblockUI();
$("body").append(this.dpDiv);
}
}
this._inDialog = false;
}
} | javascript | function(input) {
var showAnim, duration, postProcess, onClose,
inst = this._curInst;
if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
return;
}
if (this._datepickerShowing) {
showAnim = this._get(inst, "showAnim");
duration = this._get(inst, "duration");
postProcess = function() {
$.datepicker._tidyDialog(inst);
};
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
} else {
inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
(showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
}
if (!showAnim) {
postProcess();
}
this._datepickerShowing = false;
onClose = this._get(inst, "onClose");
if (onClose) {
onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
}
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
if ($.blockUI) {
$.unblockUI();
$("body").append(this.dpDiv);
}
}
this._inDialog = false;
}
} | [
"function",
"(",
"input",
")",
"{",
"var",
"showAnim",
",",
"duration",
",",
"postProcess",
",",
"onClose",
",",
"inst",
"=",
"this",
".",
"_curInst",
";",
"if",
"(",
"!",
"inst",
"||",
"(",
"input",
"&&",
"inst",
"!==",
"$",
".",
"data",
"(",
"inp... | /* Hide the date picker from view.
@param input element - the input field attached to the date picker | [
"/",
"*",
"Hide",
"the",
"date",
"picker",
"from",
"view",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8463-L8506 | train | Hide the datepicker | [
30522,
3853,
1006,
7953,
1007,
1063,
13075,
2265,
7088,
2213,
1010,
9367,
1010,
2695,
21572,
9623,
2015,
1010,
2006,
20464,
9232,
1010,
16021,
2102,
1027,
2023,
1012,
1035,
12731,
6657,
3367,
1025,
2065,
1006,
999,
16021,
2102,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mui-org/material-ui | docs/src/pages/components/grid-list/AdvancedGridList.js | AdvancedGridList | function AdvancedGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={200} spacing={1} className={classes.gridList}>
{tileData.map(tile => (
<GridListTile key={tile.img} cols={tile.featured ? 2 : 1} rows={tile.featured ? 2 : 1}>
<img src={tile.img} alt={tile.title} />
<GridListTileBar
title={tile.title}
titlePosition="top"
actionIcon={
<IconButton className={classes.icon}>
<StarBorderIcon />
</IconButton>
}
actionPosition="left"
className={classes.titleBar}
/>
</GridListTile>
))}
</GridList>
</div>
);
} | javascript | function AdvancedGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={200} spacing={1} className={classes.gridList}>
{tileData.map(tile => (
<GridListTile key={tile.img} cols={tile.featured ? 2 : 1} rows={tile.featured ? 2 : 1}>
<img src={tile.img} alt={tile.title} />
<GridListTileBar
title={tile.title}
titlePosition="top"
actionIcon={
<IconButton className={classes.icon}>
<StarBorderIcon />
</IconButton>
}
actionPosition="left"
className={classes.titleBar}
/>
</GridListTile>
))}
</GridList>
</div>
);
} | [
"function",
"AdvancedGridList",
"(",
")",
"{",
"const",
"classes",
"=",
"useStyles",
"(",
")",
";",
"return",
"(",
"<",
"div",
"className",
"=",
"{",
"classes",
".",
"root",
"}",
">",
"\n ",
"<",
"GridList",
"cellHeight",
"=",
"{",
"200",
"}",
"sp... | The example data is structured as follows:
import image from 'path/to/image.jpg';
[etc...]
const tileData = [
{
img: image,
title: 'Image',
author: 'author',
featured: true,
},
{
[etc...]
},
]; | [
"The",
"example",
"data",
"is",
"structured",
"as",
"follows",
":"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/components/grid-list/AdvancedGridList.js#L52-L77 | train | AdvancedGridList - GridList | [
30522,
3853,
3935,
16523,
3593,
9863,
1006,
1007,
1063,
9530,
3367,
4280,
1027,
3594,
27983,
2015,
1006,
1007,
1025,
2709,
1006,
1026,
4487,
2615,
2465,
18442,
1027,
1063,
4280,
1012,
7117,
1065,
1028,
1026,
8370,
9863,
3526,
26036,
13900,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/selenium-remoterunner.js | requireExtensionJs | function requireExtensionJs(sessionId) {
var src = 'scripts/user-extensions.js[' + sessionId + ']';
if (document.getElementById(src) == null) {
var scriptTag = document.createElement('script');
scriptTag.language = 'JavaScript';
scriptTag.type = 'text/javascript';
scriptTag.src = src;
scriptTag.id = src;
scriptTag.charset = 'UTF-8';
var headTag = document.getElementsByTagName('head')[0];
headTag.appendChild(scriptTag);
}
} | javascript | function requireExtensionJs(sessionId) {
var src = 'scripts/user-extensions.js[' + sessionId + ']';
if (document.getElementById(src) == null) {
var scriptTag = document.createElement('script');
scriptTag.language = 'JavaScript';
scriptTag.type = 'text/javascript';
scriptTag.src = src;
scriptTag.id = src;
scriptTag.charset = 'UTF-8';
var headTag = document.getElementsByTagName('head')[0];
headTag.appendChild(scriptTag);
}
} | [
"function",
"requireExtensionJs",
"(",
"sessionId",
")",
"{",
"var",
"src",
"=",
"'scripts/user-extensions.js['",
"+",
"sessionId",
"+",
"']'",
";",
"if",
"(",
"document",
".",
"getElementById",
"(",
"src",
")",
"==",
"null",
")",
"{",
"var",
"scriptTag",
"=... | Adds a script tag referencing a specially-named user extensions "file". The
resource handler for this special file (which won't actually exist) will use
the session ID embedded in its name to retrieve per-session specified user
extension javascript.
@param sessionId | [
"Adds",
"a",
"script",
"tag",
"referencing",
"a",
"specially",
"-",
"named",
"user",
"extensions",
"file",
".",
"The",
"resource",
"handler",
"for",
"this",
"special",
"file",
"(",
"which",
"won",
"t",
"actually",
"exist",
")",
"will",
"use",
"the",
"sessi... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/selenium-remoterunner.js#L572-L584 | train | Require extension. js | [
30522,
3853,
5478,
10288,
29048,
22578,
1006,
5219,
3593,
1007,
1063,
13075,
5034,
2278,
1027,
1005,
14546,
1013,
5310,
1011,
14305,
1012,
1046,
2015,
1031,
1005,
1009,
5219,
3593,
1009,
1005,
1033,
1005,
1025,
2065,
1006,
6254,
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... |
nhn/tui.editor | src/js/extensions/table/tableRenderer.js | createTableHtml | function createTableHtml(renderData) {
const thead = [renderData[0]];
const tbody = renderData.slice(1);
const theadHtml = _createTheadOrTbodyHtml(thead, 'THEAD');
const tbodyHtml = _createTheadOrTbodyHtml(tbody, 'TBODY');
const className = renderData.className ? ` class="${renderData.className}"` : '';
return `<table${className}>${theadHtml + tbodyHtml}</renderData>`;
} | javascript | function createTableHtml(renderData) {
const thead = [renderData[0]];
const tbody = renderData.slice(1);
const theadHtml = _createTheadOrTbodyHtml(thead, 'THEAD');
const tbodyHtml = _createTheadOrTbodyHtml(tbody, 'TBODY');
const className = renderData.className ? ` class="${renderData.className}"` : '';
return `<table${className}>${theadHtml + tbodyHtml}</renderData>`;
} | [
"function",
"createTableHtml",
"(",
"renderData",
")",
"{",
"const",
"thead",
"=",
"[",
"renderData",
"[",
"0",
"]",
"]",
";",
"const",
"tbody",
"=",
"renderData",
".",
"slice",
"(",
"1",
")",
";",
"const",
"theadHtml",
"=",
"_createTheadOrTbodyHtml",
"(",... | Create table html.
@param {Array.<Array.<object>>} renderData - table data for render
@returns {string}
@private | [
"Create",
"table",
"html",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/tableRenderer.js#L51-L59 | train | Creates html for table | [
30522,
3853,
3443,
10880,
11039,
19968,
1006,
17552,
2850,
2696,
1007,
1063,
9530,
3367,
1996,
4215,
1027,
1031,
17552,
2850,
2696,
1031,
1014,
1033,
1033,
1025,
9530,
3367,
26419,
7716,
2100,
1027,
17552,
2850,
2696,
1012,
14704,
1006,
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... |
expressjs/express | examples/view-constructor/github-view.js | GithubView | function GithubView(name, options){
this.name = name;
options = options || {};
this.engine = options.engines[extname(name)];
// "root" is the app.set('views') setting, however
// in your own implementation you could ignore this
this.path = '/' + options.root + '/master/' + name;
} | javascript | function GithubView(name, options){
this.name = name;
options = options || {};
this.engine = options.engines[extname(name)];
// "root" is the app.set('views') setting, however
// in your own implementation you could ignore this
this.path = '/' + options.root + '/master/' + name;
} | [
"function",
"GithubView",
"(",
"name",
",",
"options",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"engine",
"=",
"options",
".",
"engines",
"[",
"extname",
"(",
"name",
")",
"]",
";... | Custom view that fetches and renders
remove github templates. You could
render templates from a database etc. | [
"Custom",
"view",
"that",
"fetches",
"and",
"renders",
"remove",
"github",
"templates",
".",
"You",
"could",
"render",
"templates",
"from",
"a",
"database",
"etc",
"."
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/examples/view-constructor/github-view.js#L21-L28 | train | GithubView constructor. | [
30522,
3853,
21025,
2705,
12083,
8584,
1006,
2171,
1010,
7047,
1007,
1063,
2023,
1012,
2171,
1027,
2171,
1025,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2023,
1012,
3194,
1027,
7047,
1012,
5209,
1031,
4654,
2102,
18442,
1006,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/dom.js | walkPoint | function walkPoint(startPoint, endPoint, handler, isSkipInnerOffset) {
let point = startPoint;
while (point) {
handler(point);
if (isSamePoint(point, endPoint)) {
break;
}
const isSkipOffset = isSkipInnerOffset &&
startPoint.node !== point.node &&
endPoint.node !== point.node;
point = nextPoint(point, isSkipOffset);
}
} | javascript | function walkPoint(startPoint, endPoint, handler, isSkipInnerOffset) {
let point = startPoint;
while (point) {
handler(point);
if (isSamePoint(point, endPoint)) {
break;
}
const isSkipOffset = isSkipInnerOffset &&
startPoint.node !== point.node &&
endPoint.node !== point.node;
point = nextPoint(point, isSkipOffset);
}
} | [
"function",
"walkPoint",
"(",
"startPoint",
",",
"endPoint",
",",
"handler",
",",
"isSkipInnerOffset",
")",
"{",
"let",
"point",
"=",
"startPoint",
";",
"while",
"(",
"point",
")",
"{",
"handler",
"(",
"point",
")",
";",
"if",
"(",
"isSamePoint",
"(",
"p... | @method walkPoint
@param {BoundaryPoint} startPoint
@param {BoundaryPoint} endPoint
@param {Function} handler
@param {Boolean} isSkipInnerOffset | [
"@method",
"walkPoint"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L677-L692 | train | Walks through the points of a node | [
30522,
3853,
3328,
8400,
1006,
2707,
8400,
1010,
2203,
8400,
1010,
28213,
1010,
26354,
3211,
8091,
3678,
27475,
3388,
1007,
1063,
2292,
2391,
1027,
2707,
8400,
1025,
2096,
1006,
2391,
1007,
1063,
28213,
1006,
2391,
1007,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Agents/RemoteAgent.js | _onAttributeModified | function _onAttributeModified(event, res) {
// res = {nodeId, name, value}
var matches = /^data-ld-(.*)/.exec(res.name);
if (matches) {
exports.trigger(matches[1], res);
}
} | javascript | function _onAttributeModified(event, res) {
// res = {nodeId, name, value}
var matches = /^data-ld-(.*)/.exec(res.name);
if (matches) {
exports.trigger(matches[1], res);
}
} | [
"function",
"_onAttributeModified",
"(",
"event",
",",
"res",
")",
"{",
"// res = {nodeId, name, value}",
"var",
"matches",
"=",
"/",
"^data-ld-(.*)",
"/",
".",
"exec",
"(",
"res",
".",
"name",
")",
";",
"if",
"(",
"matches",
")",
"{",
"exports",
".",
"tri... | interval used to send keepAlive events WebInspector Event: DOM.attributeModified | [
"interval",
"used",
"to",
"send",
"keepAlive",
"events",
"WebInspector",
"Event",
":",
"DOM",
".",
"attributeModified"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteAgent.js#L47-L53 | train | Called when an attribute is modified | [
30522,
3853,
1035,
2006,
19321,
3089,
8569,
18532,
7716,
7810,
1006,
2724,
1010,
24501,
1007,
1063,
1013,
1013,
24501,
1027,
1063,
13045,
3593,
1010,
2171,
1010,
3643,
1065,
13075,
3503,
1027,
1013,
1034,
2951,
1011,
25510,
1011,
1006,
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/command/KeyBindingManager.js | removeGlobalKeydownHook | function removeGlobalKeydownHook(hook) {
var index = _globalKeydownHooks.indexOf(hook);
if (index !== -1) {
_globalKeydownHooks.splice(index, 1);
}
} | javascript | function removeGlobalKeydownHook(hook) {
var index = _globalKeydownHooks.indexOf(hook);
if (index !== -1) {
_globalKeydownHooks.splice(index, 1);
}
} | [
"function",
"removeGlobalKeydownHook",
"(",
"hook",
")",
"{",
"var",
"index",
"=",
"_globalKeydownHooks",
".",
"indexOf",
"(",
"hook",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"_globalKeydownHooks",
".",
"splice",
"(",
"index",
",",
"1",
... | Removes a global keydown hook added by `addGlobalKeydownHook`.
Does not need to be the most recently added hook.
@param {function(Event): boolean} hook The global hook to remove. | [
"Removes",
"a",
"global",
"keydown",
"hook",
"added",
"by",
"addGlobalKeydownHook",
".",
"Does",
"not",
"need",
"to",
"be",
"the",
"most",
"recently",
"added",
"hook",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L964-L969 | train | Remove a global keydown hook | [
30522,
3853,
6366,
23296,
16429,
2389,
14839,
7698,
6806,
6559,
1006,
8103,
1007,
1063,
13075,
5950,
1027,
1035,
3795,
14839,
7698,
6806,
6559,
2015,
1012,
5950,
11253,
1006,
8103,
1007,
1025,
2065,
1006,
5950,
999,
1027,
1027,
1011,
1015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableAccRenderExtension.js | function(oRm, sParentId, sId, sText, aCSSClasses) {
aCSSClasses = aCSSClasses || [];
aCSSClasses.push("sapUiInvisibleText");
oRm.write("<span");
oRm.writeAttribute("id", sParentId + "-" + sId);
oRm.writeAttribute("class", aCSSClasses.join(" "));
oRm.writeAttribute("aria-hidden", "true");
oRm.write(">");
if (sText) {
oRm.writeEscaped(sText);
}
oRm.write("</span>");
} | javascript | function(oRm, sParentId, sId, sText, aCSSClasses) {
aCSSClasses = aCSSClasses || [];
aCSSClasses.push("sapUiInvisibleText");
oRm.write("<span");
oRm.writeAttribute("id", sParentId + "-" + sId);
oRm.writeAttribute("class", aCSSClasses.join(" "));
oRm.writeAttribute("aria-hidden", "true");
oRm.write(">");
if (sText) {
oRm.writeEscaped(sText);
}
oRm.write("</span>");
} | [
"function",
"(",
"oRm",
",",
"sParentId",
",",
"sId",
",",
"sText",
",",
"aCSSClasses",
")",
"{",
"aCSSClasses",
"=",
"aCSSClasses",
"||",
"[",
"]",
";",
"aCSSClasses",
".",
"push",
"(",
"\"sapUiInvisibleText\"",
")",
";",
"oRm",
".",
"write",
"(",
"\"<s... | /*
Renders a hidden element with the given id, text and css classes. | [
"/",
"*",
"Renders",
"a",
"hidden",
"element",
"with",
"the",
"given",
"id",
"text",
"and",
"css",
"classes",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccRenderExtension.js#L15-L28 | train | Renders the invisible text | [
30522,
3853,
1006,
2030,
2213,
1010,
8622,
16778,
2094,
1010,
15765,
1010,
26261,
18413,
1010,
9353,
4757,
26266,
2229,
1007,
1063,
9353,
4757,
26266,
2229,
1027,
9353,
4757,
26266,
2229,
1064,
1064,
1031,
1033,
1025,
9353,
4757,
26266,
222... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | tasks/generate-index.js | getSymbols | async function getSymbols() {
const info = await generateInfo();
return info.symbols.filter(symbol => symbol.kind != 'member');
} | javascript | async function getSymbols() {
const info = await generateInfo();
return info.symbols.filter(symbol => symbol.kind != 'member');
} | [
"async",
"function",
"getSymbols",
"(",
")",
"{",
"const",
"info",
"=",
"await",
"generateInfo",
"(",
")",
";",
"return",
"info",
".",
"symbols",
".",
"filter",
"(",
"symbol",
"=>",
"symbol",
".",
"kind",
"!=",
"'member'",
")",
";",
"}"
] | Read the symbols from info file.
@return {Promise<Array>} Resolves with an array of symbol objects. | [
"Read",
"the",
"symbols",
"from",
"info",
"file",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L10-L13 | train | Get all members of the cluster | [
30522,
2004,
6038,
2278,
3853,
4152,
24335,
14956,
2015,
1006,
1007,
1063,
9530,
3367,
18558,
1027,
26751,
9699,
2378,
14876,
1006,
1007,
1025,
2709,
18558,
1012,
9255,
1012,
11307,
1006,
6454,
1027,
1028,
6454,
1012,
2785,
999,
1027,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/EventDispatcher.js | markDeprecated | function markDeprecated(obj, eventName, insteadStr) {
// Mark event as deprecated - on() will emit warnings when called with this event
if (!obj._deprecatedEvents) {
obj._deprecatedEvents = {};
}
obj._deprecatedEvents[eventName] = insteadStr || true;
} | javascript | function markDeprecated(obj, eventName, insteadStr) {
// Mark event as deprecated - on() will emit warnings when called with this event
if (!obj._deprecatedEvents) {
obj._deprecatedEvents = {};
}
obj._deprecatedEvents[eventName] = insteadStr || true;
} | [
"function",
"markDeprecated",
"(",
"obj",
",",
"eventName",
",",
"insteadStr",
")",
"{",
"// Mark event as deprecated - on() will emit warnings when called with this event",
"if",
"(",
"!",
"obj",
".",
"_deprecatedEvents",
")",
"{",
"obj",
".",
"_deprecatedEvents",
"=",
... | Mark a given event name as deprecated, such that on() will emit warnings when called with it.
May be called before makeEventDispatcher(). May be called on a prototype where makeEventDispatcher()
is called separately per instance (i.e. in the constructor). Should be called before clients have
a chance to start calling on().
@param {!Object} obj Event dispatcher object
@param {string} eventName Name of deprecated event
@param {string=} insteadStr Suggested thing to use instead | [
"Mark",
"a",
"given",
"event",
"name",
"as",
"deprecated",
"such",
"that",
"on",
"()",
"will",
"emit",
"warnings",
"when",
"called",
"with",
"it",
".",
"May",
"be",
"called",
"before",
"makeEventDispatcher",
"()",
".",
"May",
"be",
"called",
"on",
"a",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/EventDispatcher.js#L297-L303 | train | Mark an event as deprecated | [
30522,
3853,
2928,
3207,
28139,
12921,
1006,
27885,
3501,
1010,
2724,
18442,
1010,
2612,
3367,
2099,
1007,
1063,
1013,
1013,
2928,
2724,
2004,
2139,
28139,
12921,
1011,
2006,
1006,
1007,
2097,
12495,
2102,
16234,
2043,
2170,
2007,
2023,
272... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/plugins/TechInfo.js | formatBuildInfo | function formatBuildInfo(timestamp, scmRevision) {
var info = [];
if ( timestamp ) {
var match = /^(\d{4})(\d{2})(\d{2})-?(\d{2})(\d{2})$/.exec(timestamp);
if ( match ) {
timestamp = match[1] + '-' + match[2] + '-' + match[3] + 'T' + match[4] + ":" + match[5];
}
info.push("built at " + encode(timestamp));
}
if ( scmRevision ) {
info.push("last change " + encode(scmRevision));
}
return info.length === 0 ? "" : " (" + info.join(", ") + ")";
} | javascript | function formatBuildInfo(timestamp, scmRevision) {
var info = [];
if ( timestamp ) {
var match = /^(\d{4})(\d{2})(\d{2})-?(\d{2})(\d{2})$/.exec(timestamp);
if ( match ) {
timestamp = match[1] + '-' + match[2] + '-' + match[3] + 'T' + match[4] + ":" + match[5];
}
info.push("built at " + encode(timestamp));
}
if ( scmRevision ) {
info.push("last change " + encode(scmRevision));
}
return info.length === 0 ? "" : " (" + info.join(", ") + ")";
} | [
"function",
"formatBuildInfo",
"(",
"timestamp",
",",
"scmRevision",
")",
"{",
"var",
"info",
"=",
"[",
"]",
";",
"if",
"(",
"timestamp",
")",
"{",
"var",
"match",
"=",
"/",
"^(\\d{4})(\\d{2})(\\d{2})-?(\\d{2})(\\d{2})$",
"/",
".",
"exec",
"(",
"timestamp",
... | version information | [
"version",
"information"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/plugins/TechInfo.js#L64-L77 | train | Format build info | [
30522,
3853,
4289,
8569,
4014,
8718,
14876,
1006,
2335,
15464,
2361,
1010,
8040,
2213,
2890,
17084,
1007,
1063,
13075,
18558,
1027,
1031,
1033,
1025,
2065,
1006,
2335,
15464,
2361,
1007,
1063,
13075,
2674,
1027,
1013,
1034,
1006,
1032,
1040... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | js/mui.jsonp.js | function(url, data, jsonpParam, callbacnName) {
if (jsonpParam) {
url = url.replace(jsonpParam + '=?', jsonpParam + '=' + callbacnName);
} else {
data['callback'] = callbacnName;
}
var buffer = [];
for (var key in data) {
buffer.push(key + '=' + encodeURIComponent(data[key]));
}
return url + (url.indexOf('?') > -1 ? '&' : '?') + buffer.join('&');
} | javascript | function(url, data, jsonpParam, callbacnName) {
if (jsonpParam) {
url = url.replace(jsonpParam + '=?', jsonpParam + '=' + callbacnName);
} else {
data['callback'] = callbacnName;
}
var buffer = [];
for (var key in data) {
buffer.push(key + '=' + encodeURIComponent(data[key]));
}
return url + (url.indexOf('?') > -1 ? '&' : '?') + buffer.join('&');
} | [
"function",
"(",
"url",
",",
"data",
",",
"jsonpParam",
",",
"callbacnName",
")",
"{",
"if",
"(",
"jsonpParam",
")",
"{",
"url",
"=",
"url",
".",
"replace",
"(",
"jsonpParam",
"+",
"'=?'",
",",
"jsonpParam",
"+",
"'='",
"+",
"callbacnName",
")",
";",
... | 转换 URL,JSONP 只支持 get 方式的 queryString ,需将 data 拼入 url | [
"转换",
"URL,JSONP",
"只支持",
"get",
"方式的",
"queryString",
"需将",
"data",
"拼入",
"url"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/js/mui.jsonp.js#L30-L41 | train | Add callback to url | [
30522,
3853,
1006,
24471,
2140,
1010,
2951,
1010,
1046,
3385,
13944,
6444,
1010,
2655,
3676,
2278,
9516,
4168,
1007,
1063,
2065,
1006,
1046,
3385,
13944,
6444,
1007,
1063,
24471,
2140,
1027,
24471,
2140,
1012,
5672,
1006,
1046,
3385,
13944,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxRectangle | function mxRectangle(x, y, width, height)
{
mxPoint.call(this, x, y);
this.width = (width != null) ? width : 0;
this.height = (height != null) ? height : 0;
} | javascript | function mxRectangle(x, y, width, height)
{
mxPoint.call(this, x, y);
this.width = (width != null) ? width : 0;
this.height = (height != null) ? height : 0;
} | [
"function",
"mxRectangle",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"mxPoint",
".",
"call",
"(",
"this",
",",
"x",
",",
"y",
")",
";",
"this",
".",
"width",
"=",
"(",
"width",
"!=",
"null",
")",
"?",
"width",
":",
"0",
";",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxRectangle
Extends <mxPoint> to implement a 2-dimensional rectangle with double
precision coordinates.
Constructor: mxRectangle
Constructs a new rectangle for the optional parameters. If no parameters
are given then the respective default values are used. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxRectangle"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L1760-L1766 | train | A rectangle is a rectangle of the given size | [
30522,
3853,
25630,
2890,
25572,
3070,
2571,
1006,
1060,
1010,
1061,
1010,
9381,
1010,
4578,
1007,
1063,
25630,
8400,
1012,
2655,
1006,
2023,
1010,
1060,
1010,
1061,
1007,
1025,
2023,
1012,
9381,
1027,
1006,
9381,
999,
1027,
19701,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeViewModel.js | _addNewEntries | function _addNewEntries(treeData, added) {
added.forEach(function (filePath) {
var isFolder = _.last(filePath) === "/";
filePath = isFolder ? filePath.substr(0, filePath.length - 1) : filePath;
var parentPath = FileUtils.getDirectoryPath(filePath),
parentObjectPath = _filePathToObjectPath(treeData, parentPath),
basename = FileUtils.getBaseName(filePath);
if (parentObjectPath) {
// Verify that the children are loaded
var childrenPath = _.clone(parentObjectPath);
childrenPath.push("children");
if (treeData.getIn(childrenPath) === null) {
return;
}
treeData = _createPlaceholder(treeData, parentPath, basename, isFolder, {
notInCreateMode: true,
doNotOpen: true
});
}
});
return treeData;
} | javascript | function _addNewEntries(treeData, added) {
added.forEach(function (filePath) {
var isFolder = _.last(filePath) === "/";
filePath = isFolder ? filePath.substr(0, filePath.length - 1) : filePath;
var parentPath = FileUtils.getDirectoryPath(filePath),
parentObjectPath = _filePathToObjectPath(treeData, parentPath),
basename = FileUtils.getBaseName(filePath);
if (parentObjectPath) {
// Verify that the children are loaded
var childrenPath = _.clone(parentObjectPath);
childrenPath.push("children");
if (treeData.getIn(childrenPath) === null) {
return;
}
treeData = _createPlaceholder(treeData, parentPath, basename, isFolder, {
notInCreateMode: true,
doNotOpen: true
});
}
});
return treeData;
} | [
"function",
"_addNewEntries",
"(",
"treeData",
",",
"added",
")",
"{",
"added",
".",
"forEach",
"(",
"function",
"(",
"filePath",
")",
"{",
"var",
"isFolder",
"=",
"_",
".",
"last",
"(",
"filePath",
")",
"===",
"\"/\"",
";",
"filePath",
"=",
"isFolder",
... | @private
Adds entries at the paths listed in the `added` array. Directories should have a trailing slash.
@param {Immutable.Map} treeData
@param {Array.<string>} added list of new project-relative file paths
@return {Immutable.Map} revised treeData | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeViewModel.js#L1006-L1032 | train | Add new entries to the treeData | [
30522,
3853,
1035,
5587,
2638,
12449,
21011,
1006,
3392,
2850,
2696,
1010,
2794,
1007,
1063,
2794,
1012,
18921,
6776,
1006,
3853,
1006,
5371,
15069,
1007,
1063,
13075,
2003,
10371,
2121,
1027,
1035,
1012,
2197,
1006,
5371,
15069,
1007,
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... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | function() {
var me = this;
var opts = me.options;
var labelOpts = opts.labels;
var globalDefaults = core_defaults.global;
var defaultColor = globalDefaults.defaultColor;
var lineDefault = globalDefaults.elements.line;
var legendWidth = me.width;
var lineWidths = me.lineWidths;
if (opts.display) {
var ctx = me.ctx;
var fontColor = valueOrDefault$d(labelOpts.fontColor, globalDefaults.defaultFontColor);
var labelFont = helpers$1.options._parseFont(labelOpts);
var fontSize = labelFont.size;
var cursor;
// Canvas setup
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
ctx.lineWidth = 0.5;
ctx.strokeStyle = fontColor; // for strikethrough effect
ctx.fillStyle = fontColor; // render in correct colour
ctx.font = labelFont.string;
var boxWidth = getBoxWidth(labelOpts, fontSize);
var hitboxes = me.legendHitBoxes;
// current position
var drawLegendBox = function(x, y, legendItem) {
if (isNaN(boxWidth) || boxWidth <= 0) {
return;
}
// Set the ctx for the box
ctx.save();
var lineWidth = valueOrDefault$d(legendItem.lineWidth, lineDefault.borderWidth);
ctx.fillStyle = valueOrDefault$d(legendItem.fillStyle, defaultColor);
ctx.lineCap = valueOrDefault$d(legendItem.lineCap, lineDefault.borderCapStyle);
ctx.lineDashOffset = valueOrDefault$d(legendItem.lineDashOffset, lineDefault.borderDashOffset);
ctx.lineJoin = valueOrDefault$d(legendItem.lineJoin, lineDefault.borderJoinStyle);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = valueOrDefault$d(legendItem.strokeStyle, defaultColor);
if (ctx.setLineDash) {
// IE 9 and 10 do not support line dash
ctx.setLineDash(valueOrDefault$d(legendItem.lineDash, lineDefault.borderDash));
}
if (opts.labels && opts.labels.usePointStyle) {
// Recalculate x and y for drawPoint() because its expecting
// x and y to be center of figure (instead of top left)
var radius = boxWidth * Math.SQRT2 / 2;
var centerX = x + boxWidth / 2;
var centerY = y + fontSize / 2;
// Draw pointStyle as legend symbol
helpers$1.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);
} else {
// Draw box as legend symbol
if (lineWidth !== 0) {
ctx.strokeRect(x, y, boxWidth, fontSize);
}
ctx.fillRect(x, y, boxWidth, fontSize);
}
ctx.restore();
};
var fillText = function(x, y, legendItem, textWidth) {
var halfFontSize = fontSize / 2;
var xLeft = boxWidth + halfFontSize + x;
var yMiddle = y + halfFontSize;
ctx.fillText(legendItem.text, xLeft, yMiddle);
if (legendItem.hidden) {
// Strikethrough the text if hidden
ctx.beginPath();
ctx.lineWidth = 2;
ctx.moveTo(xLeft, yMiddle);
ctx.lineTo(xLeft + textWidth, yMiddle);
ctx.stroke();
}
};
// Horizontal
var isHorizontal = me.isHorizontal();
if (isHorizontal) {
cursor = {
x: me.left + ((legendWidth - lineWidths[0]) / 2) + labelOpts.padding,
y: me.top + labelOpts.padding,
line: 0
};
} else {
cursor = {
x: me.left + labelOpts.padding,
y: me.top + labelOpts.padding,
line: 0
};
}
var itemHeight = fontSize + labelOpts.padding;
helpers$1.each(me.legendItems, function(legendItem, i) {
var textWidth = ctx.measureText(legendItem.text).width;
var width = boxWidth + (fontSize / 2) + textWidth;
var x = cursor.x;
var y = cursor.y;
// Use (me.left + me.minSize.width) and (me.top + me.minSize.height)
// instead of me.right and me.bottom because me.width and me.height
// may have been changed since me.minSize was calculated
if (isHorizontal) {
if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.width) {
y = cursor.y += itemHeight;
cursor.line++;
x = cursor.x = me.left + ((legendWidth - lineWidths[cursor.line]) / 2) + labelOpts.padding;
}
} else if (i > 0 && y + itemHeight > me.top + me.minSize.height) {
x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding;
y = cursor.y = me.top + labelOpts.padding;
cursor.line++;
}
drawLegendBox(x, y, legendItem);
hitboxes[i].left = x;
hitboxes[i].top = y;
// Fill the actual label
fillText(x, y, legendItem, textWidth);
if (isHorizontal) {
cursor.x += width + labelOpts.padding;
} else {
cursor.y += itemHeight;
}
});
}
} | javascript | function() {
var me = this;
var opts = me.options;
var labelOpts = opts.labels;
var globalDefaults = core_defaults.global;
var defaultColor = globalDefaults.defaultColor;
var lineDefault = globalDefaults.elements.line;
var legendWidth = me.width;
var lineWidths = me.lineWidths;
if (opts.display) {
var ctx = me.ctx;
var fontColor = valueOrDefault$d(labelOpts.fontColor, globalDefaults.defaultFontColor);
var labelFont = helpers$1.options._parseFont(labelOpts);
var fontSize = labelFont.size;
var cursor;
// Canvas setup
ctx.textAlign = 'left';
ctx.textBaseline = 'middle';
ctx.lineWidth = 0.5;
ctx.strokeStyle = fontColor; // for strikethrough effect
ctx.fillStyle = fontColor; // render in correct colour
ctx.font = labelFont.string;
var boxWidth = getBoxWidth(labelOpts, fontSize);
var hitboxes = me.legendHitBoxes;
// current position
var drawLegendBox = function(x, y, legendItem) {
if (isNaN(boxWidth) || boxWidth <= 0) {
return;
}
// Set the ctx for the box
ctx.save();
var lineWidth = valueOrDefault$d(legendItem.lineWidth, lineDefault.borderWidth);
ctx.fillStyle = valueOrDefault$d(legendItem.fillStyle, defaultColor);
ctx.lineCap = valueOrDefault$d(legendItem.lineCap, lineDefault.borderCapStyle);
ctx.lineDashOffset = valueOrDefault$d(legendItem.lineDashOffset, lineDefault.borderDashOffset);
ctx.lineJoin = valueOrDefault$d(legendItem.lineJoin, lineDefault.borderJoinStyle);
ctx.lineWidth = lineWidth;
ctx.strokeStyle = valueOrDefault$d(legendItem.strokeStyle, defaultColor);
if (ctx.setLineDash) {
// IE 9 and 10 do not support line dash
ctx.setLineDash(valueOrDefault$d(legendItem.lineDash, lineDefault.borderDash));
}
if (opts.labels && opts.labels.usePointStyle) {
// Recalculate x and y for drawPoint() because its expecting
// x and y to be center of figure (instead of top left)
var radius = boxWidth * Math.SQRT2 / 2;
var centerX = x + boxWidth / 2;
var centerY = y + fontSize / 2;
// Draw pointStyle as legend symbol
helpers$1.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY);
} else {
// Draw box as legend symbol
if (lineWidth !== 0) {
ctx.strokeRect(x, y, boxWidth, fontSize);
}
ctx.fillRect(x, y, boxWidth, fontSize);
}
ctx.restore();
};
var fillText = function(x, y, legendItem, textWidth) {
var halfFontSize = fontSize / 2;
var xLeft = boxWidth + halfFontSize + x;
var yMiddle = y + halfFontSize;
ctx.fillText(legendItem.text, xLeft, yMiddle);
if (legendItem.hidden) {
// Strikethrough the text if hidden
ctx.beginPath();
ctx.lineWidth = 2;
ctx.moveTo(xLeft, yMiddle);
ctx.lineTo(xLeft + textWidth, yMiddle);
ctx.stroke();
}
};
// Horizontal
var isHorizontal = me.isHorizontal();
if (isHorizontal) {
cursor = {
x: me.left + ((legendWidth - lineWidths[0]) / 2) + labelOpts.padding,
y: me.top + labelOpts.padding,
line: 0
};
} else {
cursor = {
x: me.left + labelOpts.padding,
y: me.top + labelOpts.padding,
line: 0
};
}
var itemHeight = fontSize + labelOpts.padding;
helpers$1.each(me.legendItems, function(legendItem, i) {
var textWidth = ctx.measureText(legendItem.text).width;
var width = boxWidth + (fontSize / 2) + textWidth;
var x = cursor.x;
var y = cursor.y;
// Use (me.left + me.minSize.width) and (me.top + me.minSize.height)
// instead of me.right and me.bottom because me.width and me.height
// may have been changed since me.minSize was calculated
if (isHorizontal) {
if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.width) {
y = cursor.y += itemHeight;
cursor.line++;
x = cursor.x = me.left + ((legendWidth - lineWidths[cursor.line]) / 2) + labelOpts.padding;
}
} else if (i > 0 && y + itemHeight > me.top + me.minSize.height) {
x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding;
y = cursor.y = me.top + labelOpts.padding;
cursor.line++;
}
drawLegendBox(x, y, legendItem);
hitboxes[i].left = x;
hitboxes[i].top = y;
// Fill the actual label
fillText(x, y, legendItem, textWidth);
if (isHorizontal) {
cursor.x += width + labelOpts.padding;
} else {
cursor.y += itemHeight;
}
});
}
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"opts",
"=",
"me",
".",
"options",
";",
"var",
"labelOpts",
"=",
"opts",
".",
"labels",
";",
"var",
"globalDefaults",
"=",
"core_defaults",
".",
"global",
";",
"var",
"defaultColor",
"=",... | Actually draw the legend on the canvas | [
"Actually",
"draw",
"the",
"legend",
"on",
"the",
"canvas"
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L14010-L14150 | train | draw the legend box | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
23569,
2015,
1027,
2033,
1012,
7047,
1025,
13075,
3830,
7361,
3215,
1027,
23569,
2015,
1012,
10873,
1025,
13075,
3795,
3207,
7011,
11314,
2015,
1027,
4563,
1035,
12398,
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... | |
GitbookIO/gitbook | lib/output/modifiers/resolveImages.js | resolveImages | function resolveImages(currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
if (LocationUtils.isExternal(src) || LocationUtils.isDataURI(src)) {
return;
}
// Calcul absolute path for this
src = LocationUtils.toAbsolute(src, currentDirectory, '.');
// Convert back to relative
src = LocationUtils.relative(currentDirectory, src);
$img.attr('src', src);
});
} | javascript | function resolveImages(currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
if (LocationUtils.isExternal(src) || LocationUtils.isDataURI(src)) {
return;
}
// Calcul absolute path for this
src = LocationUtils.toAbsolute(src, currentDirectory, '.');
// Convert back to relative
src = LocationUtils.relative(currentDirectory, src);
$img.attr('src', src);
});
} | [
"function",
"resolveImages",
"(",
"currentFile",
",",
"$",
")",
"{",
"var",
"currentDirectory",
"=",
"path",
".",
"dirname",
"(",
"currentFile",
")",
";",
"return",
"editHTMLElement",
"(",
"$",
",",
"'img'",
",",
"function",
"(",
"$img",
")",
"{",
"var",
... | Resolve all HTML images:
- /test.png in hello -> ../test.html
@param {String} currentFile
@param {HTMLDom} $ | [
"Resolve",
"all",
"HTML",
"images",
":",
"-",
"/",
"test",
".",
"png",
"in",
"hello",
"-",
">",
"..",
"/",
"test",
".",
"html"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/resolveImages.js#L13-L31 | train | Resolve images from the current file | [
30522,
3853,
10663,
9581,
8449,
1006,
2783,
8873,
2571,
1010,
1002,
1007,
1063,
13075,
2783,
4305,
2890,
16761,
2100,
1027,
4130,
1012,
16101,
18442,
1006,
2783,
8873,
2571,
1007,
1025,
2709,
13257,
21246,
2571,
16930,
4765,
1006,
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... |
jhipster/generator-jhipster | generators/utils.js | copyWebResource | function copyWebResource(source, dest, regex, type, generator, opt = {}, template) {
if (generator.enableTranslation) {
generator.template(source, dest, generator, opt);
} else {
renderContent(source, generator, generator, opt, body => {
body = body.replace(regex, '');
switch (type) {
case 'html':
body = replacePlaceholders(body, generator);
break;
case 'js':
body = replaceTitle(body, generator);
break;
case 'jsx':
body = replaceTranslation(body, generator);
break;
default:
break;
}
generator.fs.write(dest, body);
});
}
} | javascript | function copyWebResource(source, dest, regex, type, generator, opt = {}, template) {
if (generator.enableTranslation) {
generator.template(source, dest, generator, opt);
} else {
renderContent(source, generator, generator, opt, body => {
body = body.replace(regex, '');
switch (type) {
case 'html':
body = replacePlaceholders(body, generator);
break;
case 'js':
body = replaceTitle(body, generator);
break;
case 'jsx':
body = replaceTranslation(body, generator);
break;
default:
break;
}
generator.fs.write(dest, body);
});
}
} | [
"function",
"copyWebResource",
"(",
"source",
",",
"dest",
",",
"regex",
",",
"type",
",",
"generator",
",",
"opt",
"=",
"{",
"}",
",",
"template",
")",
"{",
"if",
"(",
"generator",
".",
"enableTranslation",
")",
"{",
"generator",
".",
"template",
"(",
... | Copy web resources
@param {string} source source
@param {string} dest destination
@param {regex} regex regex
@param {string} type type of resource (html, js, etc)
@param {object} generator reference to the generator
@param {object} opt options
@param {any} template template | [
"Copy",
"web",
"resources"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/utils.js#L169-L191 | train | Copy a web resource to a destination | [
30522,
3853,
6100,
8545,
13578,
6499,
3126,
3401,
1006,
3120,
1010,
4078,
2102,
1010,
19723,
10288,
1010,
2828,
1010,
13103,
1010,
23569,
1027,
1063,
1065,
1010,
23561,
1007,
1063,
2065,
1006,
13103,
1012,
9585,
6494,
3619,
13490,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/dynamodb/converter.js | unmarshall | function unmarshall(data, options) {
return AWS.DynamoDB.Converter.output({M: data}, options);
} | javascript | function unmarshall(data, options) {
return AWS.DynamoDB.Converter.output({M: data}, options);
} | [
"function",
"unmarshall",
"(",
"data",
",",
"options",
")",
"{",
"return",
"AWS",
".",
"DynamoDB",
".",
"Converter",
".",
"output",
"(",
"{",
"M",
":",
"data",
"}",
",",
"options",
")",
";",
"}"
] | Convert a DynamoDB record into a JavaScript object.
@param data [any] The DynamoDB record
@param options [map]
@option options convertEmptyValues [Boolean] Whether to automatically
convert empty strings, blobs,
and sets to `null`
@option options wrapNumbers [Boolean] Whether to return numbers as a
NumberValue object instead of
converting them to native JavaScript
numbers. This allows for the safe
round-trip transport of numbers of
arbitrary size.
@return [map] An object whose properties have been converted from
DynamoDB's AttributeValue format into their corresponding native
JavaScript types.
@example Convert a record received from a DynamoDB stream
var unmarshalled = AWS.DynamoDB.Converter.unmarshall({
string: {S: 'foo'},
list: {L: [{S: 'fizz'}, {S: 'buzz'}, {S: 'pop'}]},
map: {
M: {
nestedMap: {
M: {
key: {S: 'value'}
}
}
}
},
number: {N: '123'},
nullValue: {NULL: true},
boolValue: {BOOL: true}
}); | [
"Convert",
"a",
"DynamoDB",
"record",
"into",
"a",
"JavaScript",
"object",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/dynamodb/converter.js#L200-L202 | train | Unmarshalls DynamoDB data into a DynamoDB record sequence | [
30522,
3853,
4895,
7849,
7377,
3363,
1006,
2951,
1010,
7047,
1007,
1063,
2709,
22091,
2015,
1012,
17205,
18939,
1012,
10463,
2121,
1012,
6434,
1006,
1063,
1049,
1024,
2951,
1065,
1010,
7047,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _isLineBreakOrBlockElement | function _isLineBreakOrBlockElement(element) {
if (_isLineBreak(element)) {
return true;
}
if (wysihtml5.dom.getStyle("display").from(element) === "block") {
return true;
}
return false;
} | javascript | function _isLineBreakOrBlockElement(element) {
if (_isLineBreak(element)) {
return true;
}
if (wysihtml5.dom.getStyle("display").from(element) === "block") {
return true;
}
return false;
} | [
"function",
"_isLineBreakOrBlockElement",
"(",
"element",
")",
"{",
"if",
"(",
"_isLineBreak",
"(",
"element",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"wysihtml5",
".",
"dom",
".",
"getStyle",
"(",
"\"display\"",
")",
".",
"from",
"(",
"ele... | Checks whether the elment causes a visual line break
(<br> or block elements) | [
"Checks",
"whether",
"the",
"elment",
"causes",
"a",
"visual",
"line",
"break",
"(",
"<br",
">",
"or",
"block",
"elements",
")"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L5710-L5720 | train | Check if the element is a line break or block element | [
30522,
3853,
1035,
2003,
4179,
23890,
2953,
23467,
12260,
3672,
1006,
5783,
1007,
1063,
2065,
1006,
1035,
2003,
4179,
23890,
1006,
5783,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
2065,
1006,
1059,
7274,
19190,
21246,
2140,
2629,
1012,
14383... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/util/DocumentationRouter.js | function (viewName, viewType, master, data) {
var oComponent = this._getOwnerComponent(),
oRootView = oComponent.byId(oComponent.getManifestEntry("/sap.ui5/rootView").id);
oRootView.loaded().then(function (oRootView) {
var oApp = oRootView.byId("splitApp"),
oView = this.getView(viewName, viewType);
oApp.addPage(oView, master);
oApp.toDetail(oView.getId(), "show", data);
}.bind(this));
} | javascript | function (viewName, viewType, master, data) {
var oComponent = this._getOwnerComponent(),
oRootView = oComponent.byId(oComponent.getManifestEntry("/sap.ui5/rootView").id);
oRootView.loaded().then(function (oRootView) {
var oApp = oRootView.byId("splitApp"),
oView = this.getView(viewName, viewType);
oApp.addPage(oView, master);
oApp.toDetail(oView.getId(), "show", data);
}.bind(this));
} | [
"function",
"(",
"viewName",
",",
"viewType",
",",
"master",
",",
"data",
")",
"{",
"var",
"oComponent",
"=",
"this",
".",
"_getOwnerComponent",
"(",
")",
",",
"oRootView",
"=",
"oComponent",
".",
"byId",
"(",
"oComponent",
".",
"getManifestEntry",
"(",
"\... | a nav to method that does not write hashes but load the views properly | [
"a",
"nav",
"to",
"method",
"that",
"does",
"not",
"write",
"hashes",
"but",
"load",
"the",
"views",
"properly"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/util/DocumentationRouter.js#L140-L151 | train | Add a new page to the detail | [
30522,
3853,
1006,
3193,
18442,
1010,
3193,
13874,
1010,
3040,
1010,
2951,
1007,
1063,
13075,
1051,
9006,
29513,
3372,
1027,
2023,
1012,
1035,
2131,
12384,
2121,
9006,
29513,
3372,
1006,
1007,
1010,
20298,
4140,
8584,
1027,
1051,
9006,
2951... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
juliangarnier/anime | src/index.js | normalizePropertyTweens | function normalizePropertyTweens(prop, tweenSettings) {
let settings = cloneObject(tweenSettings);
// Override duration if easing is a spring
if (/^spring/.test(settings.easing)) settings.duration = spring(settings.easing);
if (is.arr(prop)) {
const l = prop.length;
const isFromTo = (l === 2 && !is.obj(prop[0]));
if (!isFromTo) {
// Duration divided by the number of tweens
if (!is.fnc(tweenSettings.duration)) settings.duration = tweenSettings.duration / l;
} else {
// Transform [from, to] values shorthand to a valid tween value
prop = {value: prop};
}
}
const propArray = is.arr(prop) ? prop : [prop];
return propArray.map((v, i) => {
const obj = (is.obj(v) && !is.pth(v)) ? v : {value: v};
// Default delay value should only be applied to the first tween
if (is.und(obj.delay)) obj.delay = !i ? tweenSettings.delay : 0;
// Default endDelay value should only be applied to the last tween
if (is.und(obj.endDelay)) obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0;
return obj;
}).map(k => mergeObjects(k, settings));
} | javascript | function normalizePropertyTweens(prop, tweenSettings) {
let settings = cloneObject(tweenSettings);
// Override duration if easing is a spring
if (/^spring/.test(settings.easing)) settings.duration = spring(settings.easing);
if (is.arr(prop)) {
const l = prop.length;
const isFromTo = (l === 2 && !is.obj(prop[0]));
if (!isFromTo) {
// Duration divided by the number of tweens
if (!is.fnc(tweenSettings.duration)) settings.duration = tweenSettings.duration / l;
} else {
// Transform [from, to] values shorthand to a valid tween value
prop = {value: prop};
}
}
const propArray = is.arr(prop) ? prop : [prop];
return propArray.map((v, i) => {
const obj = (is.obj(v) && !is.pth(v)) ? v : {value: v};
// Default delay value should only be applied to the first tween
if (is.und(obj.delay)) obj.delay = !i ? tweenSettings.delay : 0;
// Default endDelay value should only be applied to the last tween
if (is.und(obj.endDelay)) obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0;
return obj;
}).map(k => mergeObjects(k, settings));
} | [
"function",
"normalizePropertyTweens",
"(",
"prop",
",",
"tweenSettings",
")",
"{",
"let",
"settings",
"=",
"cloneObject",
"(",
"tweenSettings",
")",
";",
"// Override duration if easing is a spring",
"if",
"(",
"/",
"^spring",
"/",
".",
"test",
"(",
"settings",
"... | Properties | [
"Properties"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/src/index.js#L653-L677 | train | Normalizes a property s tween values into a tween object | [
30522,
3853,
3671,
4697,
21572,
4842,
3723,
2102,
28394,
3619,
1006,
17678,
1010,
1056,
28394,
12325,
13027,
2015,
1007,
1063,
2292,
10906,
1027,
17598,
16429,
20614,
1006,
1056,
28394,
12325,
13027,
2015,
1007,
1025,
1013,
1013,
2058,
15637,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | updateAncestorsInDragLayer | function updateAncestorsInDragLayer(node, opts) {
if (opts.inDragLayer == null && opts.addToList == null) {
return;
} // nothing to do
if (!node.cy().hasCompoundNodes()) {
return;
} // find top-level parent
var parent = node.ancestors().orphans(); // no parent node: no nodes to add to the drag layer
if (parent.same(node)) {
return;
}
var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants());
var edges = nodes.connectedEdges();
if (opts.inDragLayer) {
edges.forEach(setInDragLayer);
nodes.forEach(setInDragLayer);
}
if (opts.addToList) {
nodes.forEach(function (ele) {
addToDragList(ele, opts);
});
}
} | javascript | function updateAncestorsInDragLayer(node, opts) {
if (opts.inDragLayer == null && opts.addToList == null) {
return;
} // nothing to do
if (!node.cy().hasCompoundNodes()) {
return;
} // find top-level parent
var parent = node.ancestors().orphans(); // no parent node: no nodes to add to the drag layer
if (parent.same(node)) {
return;
}
var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants());
var edges = nodes.connectedEdges();
if (opts.inDragLayer) {
edges.forEach(setInDragLayer);
nodes.forEach(setInDragLayer);
}
if (opts.addToList) {
nodes.forEach(function (ele) {
addToDragList(ele, opts);
});
}
} | [
"function",
"updateAncestorsInDragLayer",
"(",
"node",
",",
"opts",
")",
"{",
"if",
"(",
"opts",
".",
"inDragLayer",
"==",
"null",
"&&",
"opts",
".",
"addToList",
"==",
"null",
")",
"{",
"return",
";",
"}",
"// nothing to do",
"if",
"(",
"!",
"node",
"."... | helper function to determine which ancestor nodes and edges should go to the drag layer (or should be removed from drag layer). | [
"helper",
"function",
"to",
"determine",
"which",
"ancestor",
"nodes",
"and",
"edges",
"should",
"go",
"to",
"the",
"drag",
"layer",
"(",
"or",
"should",
"be",
"removed",
"from",
"drag",
"layer",
")",
"."
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L23351-L23381 | train | update the ancestors of a node in the drag layer | [
30522,
3853,
10651,
26755,
6591,
22254,
29181,
24314,
1006,
13045,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
23569,
2015,
1012,
27427,
29181,
24314,
1027,
1027,
19701,
1004,
1004,
23569,
2015,
1012,
5587,
3406,
9863,
1027,
1027,
19701,
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... |
GitbookIO/gitbook | lib/output/preparePages.js | preparePages | function preparePages(output) {
var book = output.getBook();
var logger = book.getLogger();
if (book.isMultilingual()) {
return Promise(output);
}
return Parse.parsePagesList(book)
.then(function(pages) {
logger.info.ln('found', pages.size, 'pages');
return output.set('pages', pages);
});
} | javascript | function preparePages(output) {
var book = output.getBook();
var logger = book.getLogger();
if (book.isMultilingual()) {
return Promise(output);
}
return Parse.parsePagesList(book)
.then(function(pages) {
logger.info.ln('found', pages.size, 'pages');
return output.set('pages', pages);
});
} | [
"function",
"preparePages",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"logger",
"=",
"book",
".",
"getLogger",
"(",
")",
";",
"if",
"(",
"book",
".",
"isMultilingual",
"(",
")",
")",
"{",
"return",
... | List and prepare all pages
@param {Output}
@return {Promise<Output>} | [
"List",
"and",
"prepare",
"all",
"pages"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/preparePages.js#L10-L24 | train | Prepare pages for a new language | [
30522,
3853,
7374,
13704,
2015,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
30524,
2059,
1006,
3853,
1006,
5530,
1007,
1063,
8833,
4590,
1012,
18558,
1012,
1048,
2078,
1006,
1005,
2179,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function () {
var oUriParams = this._getUriParameters();
var sDebugParameters = oUriParams.get("sap-ui-debug") || "";
// true if SAPUI5 is in complete debug mode
if (sap.ui.getCore().getConfiguration().getDebug() || sDebugParameters === "true") {
return true;
}
var aDebugParameters = sDebugParameters.split(",");
return aDebugParameters.indexOf("sap/ui/fl") !== -1 || aDebugParameters.indexOf("sap/ui/fl/") !== -1;
} | javascript | function () {
var oUriParams = this._getUriParameters();
var sDebugParameters = oUriParams.get("sap-ui-debug") || "";
// true if SAPUI5 is in complete debug mode
if (sap.ui.getCore().getConfiguration().getDebug() || sDebugParameters === "true") {
return true;
}
var aDebugParameters = sDebugParameters.split(",");
return aDebugParameters.indexOf("sap/ui/fl") !== -1 || aDebugParameters.indexOf("sap/ui/fl/") !== -1;
} | [
"function",
"(",
")",
"{",
"var",
"oUriParams",
"=",
"this",
".",
"_getUriParameters",
"(",
")",
";",
"var",
"sDebugParameters",
"=",
"oUriParams",
".",
"get",
"(",
"\"sap-ui-debug\"",
")",
"||",
"\"\"",
";",
"// true if SAPUI5 is in complete debug mode",
"if",
... | Checks the SAPUI5 debug settings to determine whether all or at least the <code>sap.ui.fl</code> library is debugged.
@returns {boolean} Returns a flag if the flexibility library is debugged
@public | [
"Checks",
"the",
"SAPUI5",
"debug",
"settings",
"to",
"determine",
"whether",
"all",
"or",
"at",
"least",
"the",
"<code",
">",
"sap",
".",
"ui",
".",
"fl<",
"/",
"code",
">",
"library",
"is",
"debugged",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L939-L950 | train | Returns true if the URI parameters are valid | [
30522,
3853,
1006,
1007,
1063,
13075,
2256,
11514,
5400,
5244,
1027,
2023,
1012,
1035,
2131,
9496,
28689,
22828,
2015,
1006,
1007,
1025,
13075,
17371,
15878,
15916,
28689,
22828,
2015,
1027,
2256,
11514,
5400,
5244,
1012,
2131,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/language/CSSUtils.js | _hasStream | function _hasStream() {
while (stream.eol()) {
line++;
if (line >= lineCount) {
return false;
}
if (_hasNonWhitespace(currentSelector)) {
// If we are in a current selector and starting a newline,
// make sure there is whitespace in the selector
currentSelector += " ";
}
stream = new CodeMirror.StringStream(lines[line]);
}
return true;
} | javascript | function _hasStream() {
while (stream.eol()) {
line++;
if (line >= lineCount) {
return false;
}
if (_hasNonWhitespace(currentSelector)) {
// If we are in a current selector and starting a newline,
// make sure there is whitespace in the selector
currentSelector += " ";
}
stream = new CodeMirror.StringStream(lines[line]);
}
return true;
} | [
"function",
"_hasStream",
"(",
")",
"{",
"while",
"(",
"stream",
".",
"eol",
"(",
")",
")",
"{",
"line",
"++",
";",
"if",
"(",
"line",
">=",
"lineCount",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"_hasNonWhitespace",
"(",
"currentSelector",
"... | implement _firstToken()/_nextToken() methods to provide a single stream of tokens | [
"implement",
"_firstToken",
"()",
"/",
"_nextToken",
"()",
"methods",
"to",
"provide",
"a",
"single",
"stream",
"of",
"tokens"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L756-L770 | train | Check if the current selector has a stream | [
30522,
3853,
1035,
2038,
21422,
1006,
1007,
1063,
2096,
1006,
5460,
1012,
1041,
4747,
1006,
1007,
1007,
1063,
2240,
30524,
3597,
16671,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
1035,
8440,
2239,
2860,
16584,
2229,
15327,
1006,
14731,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CloseOthers/main.js | getPreferences | function getPreferences() {
// It's senseless to look prefs up for the current file, instead look them up for
// the current project (or globally)
return {
closeBelow : prefs.get("below", PreferencesManager.CURRENT_PROJECT),
closeOthers : prefs.get("others", PreferencesManager.CURRENT_PROJECT),
closeAbove : prefs.get("above", PreferencesManager.CURRENT_PROJECT)
};
} | javascript | function getPreferences() {
// It's senseless to look prefs up for the current file, instead look them up for
// the current project (or globally)
return {
closeBelow : prefs.get("below", PreferencesManager.CURRENT_PROJECT),
closeOthers : prefs.get("others", PreferencesManager.CURRENT_PROJECT),
closeAbove : prefs.get("above", PreferencesManager.CURRENT_PROJECT)
};
} | [
"function",
"getPreferences",
"(",
")",
"{",
"// It's senseless to look prefs up for the current file, instead look them up for",
"// the current project (or globally)",
"return",
"{",
"closeBelow",
":",
"prefs",
".",
"get",
"(",
"\"below\"",
",",
"PreferencesManager",
".",
"CU... | Returns the preferences used to add/remove the menu items
@return {{closeBelow: boolean, closeOthers: boolean, closeAbove: boolean}} | [
"Returns",
"the",
"preferences",
"used",
"to",
"add",
"/",
"remove",
"the",
"menu",
"items"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L111-L119 | train | Get the preferences for the current project | [
30522,
3853,
2131,
28139,
25523,
2015,
1006,
1007,
1063,
1013,
1013,
2009,
1005,
1055,
3168,
3238,
2000,
2298,
3653,
10343,
2039,
2005,
1996,
2783,
5371,
1010,
2612,
2298,
2068,
2039,
2005,
1013,
1013,
1996,
2783,
2622,
1006,
2030,
16452,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
graphql/graphql-js | resources/benchmark.js | hashForRevision | function hashForRevision(revision) {
const out = execSync(`git rev-parse "${revision}"`, { encoding: 'utf8' });
const match = /[0-9a-f]{8,40}/.exec(out);
if (!match) {
throw new Error(`Bad results for revision ${revision}: ${out}`);
}
return match[0];
} | javascript | function hashForRevision(revision) {
const out = execSync(`git rev-parse "${revision}"`, { encoding: 'utf8' });
const match = /[0-9a-f]{8,40}/.exec(out);
if (!match) {
throw new Error(`Bad results for revision ${revision}: ${out}`);
}
return match[0];
} | [
"function",
"hashForRevision",
"(",
"revision",
")",
"{",
"const",
"out",
"=",
"execSync",
"(",
"`",
"${",
"revision",
"}",
"`",
",",
"{",
"encoding",
":",
"'utf8'",
"}",
")",
";",
"const",
"match",
"=",
"/",
"[0-9a-f]{8,40}",
"/",
".",
"exec",
"(",
... | Returns the complete git hash for a given git revision reference. | [
"Returns",
"the",
"complete",
"git",
"hash",
"for",
"a",
"given",
"git",
"revision",
"reference",
"."
] | b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef | https://github.com/graphql/graphql-js/blob/b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef/resources/benchmark.js#L37-L44 | train | Returns the hash of a given revision | [
30522,
3853,
23325,
29278,
2890,
17084,
1006,
13921,
1007,
1063,
9530,
3367,
2041,
1027,
4654,
8586,
6508,
12273,
1006,
1036,
21025,
2102,
7065,
1011,
11968,
3366,
1000,
1002,
1063,
30524,
1014,
1011,
1023,
2050,
1011,
1042,
1033,
1063,
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... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onLinkWithEmailAndPassword | function onLinkWithEmailAndPassword() {
var email = $('#link-email').val();
var password = $('#link-password').val();
activeUser().linkWithCredential(
firebase.auth.EmailAuthProvider.credential(email, password))
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | function onLinkWithEmailAndPassword() {
var email = $('#link-email').val();
var password = $('#link-password').val();
activeUser().linkWithCredential(
firebase.auth.EmailAuthProvider.credential(email, password))
.then(onAuthUserCredentialSuccess, onAuthError);
} | [
"function",
"onLinkWithEmailAndPassword",
"(",
")",
"{",
"var",
"email",
"=",
"$",
"(",
"'#link-email'",
")",
".",
"val",
"(",
")",
";",
"var",
"password",
"=",
"$",
"(",
"'#link-password'",
")",
".",
"val",
"(",
")",
";",
"activeUser",
"(",
")",
".",
... | Links a signed in user with an email and password account. | [
"Links",
"a",
"signed",
"in",
"user",
"with",
"an",
"email",
"and",
"password",
"account",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L748-L754 | train | Link with email and password | [
30522,
3853,
2006,
13767,
24415,
14545,
11733,
4859,
15194,
18351,
1006,
1007,
1063,
13075,
10373,
1027,
1002,
1006,
1005,
1001,
4957,
1011,
10373,
1005,
1007,
1012,
11748,
1006,
1007,
1025,
13075,
20786,
1027,
1002,
1006,
1005,
1001,
4957,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(path) {
if (path.slice(-1) == '/') {
path = path.substring(0, path.length - 1);
}
var lastSlash = path.lastIndexOf('/');
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
} | javascript | function(path) {
if (path.slice(-1) == '/') {
path = path.substring(0, path.length - 1);
}
var lastSlash = path.lastIndexOf('/');
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
} | [
"function",
"(",
"path",
")",
"{",
"if",
"(",
"path",
".",
"slice",
"(",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"path",
"=",
"path",
".",
"substring",
"(",
"0",
",",
"path",
".",
"length",
"-",
"1",
")",
";",
"}",
"var",
"lastSlash",
"=",
"pat... | Find the parent folder of the path.
@private
@param {string} path the path to use
@return {string} the parent folder, or "" | [
"Find",
"the",
"parent",
"folder",
"of",
"the",
"path",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L612-L618 | train | Get the taxonomy from the path | [
30522,
3853,
1006,
4130,
1007,
1063,
2065,
1006,
4130,
1012,
14704,
1006,
1011,
1015,
1007,
1027,
1027,
1005,
1013,
1005,
1007,
1063,
4130,
1027,
4130,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
4130,
1012,
3091,
1011,
1015,
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... | |
PrismJS/prism | plugins/previewers/prism-previewers.js | function(gradient) {
if (cache[gradient]) {
return cache[gradient];
}
var parts = gradient.match(/^(\b|\B-[a-z]{1,10}-)((?:repeating-)?(?:linear|radial)-gradient)/);
// "", "-moz-", etc.
var prefix = parts && parts[1];
// "linear-gradient", "radial-gradient", etc.
var func = parts && parts[2];
var values = gradient.replace(/^(?:\b|\B-[a-z]{1,10}-)(?:repeating-)?(?:linear|radial)-gradient\(|\)$/g, '').split(/\s*,\s*/);
if (func.indexOf('linear') >= 0) {
return cache[gradient] = convertToW3CLinearGradient(prefix, func, values);
} else if (func.indexOf('radial') >= 0) {
return cache[gradient] = convertToW3CRadialGradient(prefix, func, values);
}
return cache[gradient] = func + '(' + values.join(',') + ')';
} | javascript | function(gradient) {
if (cache[gradient]) {
return cache[gradient];
}
var parts = gradient.match(/^(\b|\B-[a-z]{1,10}-)((?:repeating-)?(?:linear|radial)-gradient)/);
// "", "-moz-", etc.
var prefix = parts && parts[1];
// "linear-gradient", "radial-gradient", etc.
var func = parts && parts[2];
var values = gradient.replace(/^(?:\b|\B-[a-z]{1,10}-)(?:repeating-)?(?:linear|radial)-gradient\(|\)$/g, '').split(/\s*,\s*/);
if (func.indexOf('linear') >= 0) {
return cache[gradient] = convertToW3CLinearGradient(prefix, func, values);
} else if (func.indexOf('radial') >= 0) {
return cache[gradient] = convertToW3CRadialGradient(prefix, func, values);
}
return cache[gradient] = func + '(' + values.join(',') + ')';
} | [
"function",
"(",
"gradient",
")",
"{",
"if",
"(",
"cache",
"[",
"gradient",
"]",
")",
"{",
"return",
"cache",
"[",
"gradient",
"]",
";",
"}",
"var",
"parts",
"=",
"gradient",
".",
"match",
"(",
"/",
"^(\\b|\\B-[a-z]{1,10}-)((?:repeating-)?(?:linear|radial)-gra... | Converts a gradient to a W3C-valid one
Does not support old webkit syntax (-webkit-gradient(linear...) and -webkit-gradient(radial...))
@param {string} gradient The CSS gradient | [
"Converts",
"a",
"gradient",
"to",
"a",
"W3C",
"-",
"valid",
"one",
"Does",
"not",
"support",
"old",
"webkit",
"syntax",
"(",
"-",
"webkit",
"-",
"gradient",
"(",
"linear",
"...",
")",
"and",
"-",
"webkit",
"-",
"gradient",
"(",
"radial",
"...",
"))"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/plugins/previewers/prism-previewers.js#L116-L134 | train | Converts gradient string to W3C gradient function | [
30522,
3853,
1006,
17978,
1007,
1063,
2065,
1006,
17053,
1031,
17978,
1033,
1007,
1063,
2709,
17053,
1031,
17978,
1033,
1025,
1065,
13075,
3033,
1027,
17978,
1012,
2674,
1006,
1013,
1034,
1006,
1032,
1038,
1064,
1032,
1038,
1011,
1031,
1037... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HealthLogger.js | setProjectDetail | function setProjectDetail(projectName, numFiles, cacheSize) {
var projectNameHash = StringUtils.hashCode(projectName),
FIFLog = getHealthDataLog("ProjectDetails");
if (!FIFLog) {
FIFLog = {};
}
FIFLog["prj" + projectNameHash] = {
numFiles : numFiles,
cacheSize : cacheSize
};
setHealthDataLog("ProjectDetails", FIFLog);
} | javascript | function setProjectDetail(projectName, numFiles, cacheSize) {
var projectNameHash = StringUtils.hashCode(projectName),
FIFLog = getHealthDataLog("ProjectDetails");
if (!FIFLog) {
FIFLog = {};
}
FIFLog["prj" + projectNameHash] = {
numFiles : numFiles,
cacheSize : cacheSize
};
setHealthDataLog("ProjectDetails", FIFLog);
} | [
"function",
"setProjectDetail",
"(",
"projectName",
",",
"numFiles",
",",
"cacheSize",
")",
"{",
"var",
"projectNameHash",
"=",
"StringUtils",
".",
"hashCode",
"(",
"projectName",
")",
",",
"FIFLog",
"=",
"getHealthDataLog",
"(",
"\"ProjectDetails\"",
")",
";",
... | Sets the project details(a probably unique prjID, number of files in the project and the node cache size) in the health log
The name of the project is never saved into the health data log, only the hash(name) is for privacy requirements.
@param {string} projectName The name of the project
@param {number} numFiles The number of file in the project
@param {number} cacheSize The node file cache memory consumed by the project | [
"Sets",
"the",
"project",
"details",
"(",
"a",
"probably",
"unique",
"prjID",
"number",
"of",
"files",
"in",
"the",
"project",
"and",
"the",
"node",
"cache",
"size",
")",
"in",
"the",
"health",
"log",
"The",
"name",
"of",
"the",
"project",
"is",
"never",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/HealthLogger.js#L277-L288 | train | Set project details | [
30522,
3853,
2275,
21572,
20614,
3207,
14162,
1006,
2622,
18442,
1010,
16371,
2213,
8873,
4244,
1010,
17053,
5332,
4371,
1007,
1063,
13075,
2622,
18442,
14949,
2232,
1027,
5164,
21823,
4877,
1012,
23325,
16044,
1006,
2622,
18442,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataListBinding.js | getSingleFilterValue | function getSingleFilterValue(oFilter, sEdmType, bWithinAnd) {
var sFilter,
sValue = _Helper.formatLiteral(oFilter.oValue1, sEdmType),
sFilterPath = decodeURIComponent(oFilter.sPath);
switch (oFilter.sOperator) {
case FilterOperator.BT :
sFilter = sFilterPath + " ge " + sValue + " and " + sFilterPath + " le "
+ _Helper.formatLiteral(oFilter.oValue2, sEdmType);
break;
case FilterOperator.NB :
sFilter = wrap(sFilterPath + " lt " + sValue + " or " + sFilterPath + " gt "
+ _Helper.formatLiteral(oFilter.oValue2, sEdmType), bWithinAnd);
break;
case FilterOperator.EQ :
case FilterOperator.GE :
case FilterOperator.GT :
case FilterOperator.LE :
case FilterOperator.LT :
case FilterOperator.NE :
sFilter = sFilterPath + " " + oFilter.sOperator.toLowerCase() + " " + sValue;
break;
case FilterOperator.Contains :
case FilterOperator.EndsWith :
case FilterOperator.NotContains :
case FilterOperator.NotEndsWith :
case FilterOperator.NotStartsWith :
case FilterOperator.StartsWith :
sFilter = oFilter.sOperator.toLowerCase().replace("not", "not ")
+ "(" + sFilterPath + "," + sValue + ")";
break;
default :
throw new Error("Unsupported operator: " + oFilter.sOperator);
}
return sFilter;
} | javascript | function getSingleFilterValue(oFilter, sEdmType, bWithinAnd) {
var sFilter,
sValue = _Helper.formatLiteral(oFilter.oValue1, sEdmType),
sFilterPath = decodeURIComponent(oFilter.sPath);
switch (oFilter.sOperator) {
case FilterOperator.BT :
sFilter = sFilterPath + " ge " + sValue + " and " + sFilterPath + " le "
+ _Helper.formatLiteral(oFilter.oValue2, sEdmType);
break;
case FilterOperator.NB :
sFilter = wrap(sFilterPath + " lt " + sValue + " or " + sFilterPath + " gt "
+ _Helper.formatLiteral(oFilter.oValue2, sEdmType), bWithinAnd);
break;
case FilterOperator.EQ :
case FilterOperator.GE :
case FilterOperator.GT :
case FilterOperator.LE :
case FilterOperator.LT :
case FilterOperator.NE :
sFilter = sFilterPath + " " + oFilter.sOperator.toLowerCase() + " " + sValue;
break;
case FilterOperator.Contains :
case FilterOperator.EndsWith :
case FilterOperator.NotContains :
case FilterOperator.NotEndsWith :
case FilterOperator.NotStartsWith :
case FilterOperator.StartsWith :
sFilter = oFilter.sOperator.toLowerCase().replace("not", "not ")
+ "(" + sFilterPath + "," + sValue + ")";
break;
default :
throw new Error("Unsupported operator: " + oFilter.sOperator);
}
return sFilter;
} | [
"function",
"getSingleFilterValue",
"(",
"oFilter",
",",
"sEdmType",
",",
"bWithinAnd",
")",
"{",
"var",
"sFilter",
",",
"sValue",
"=",
"_Helper",
".",
"formatLiteral",
"(",
"oFilter",
".",
"oValue1",
",",
"sEdmType",
")",
",",
"sFilterPath",
"=",
"decodeURICo... | Returns the $filter value for the given single filter using the given Edm type to
format the filter's operand(s).
@param {sap.ui.model.Filter} oFilter The filter
@param {string} sEdmType The Edm type
@param {boolean} bWithinAnd Whether the embedding filter is an 'and'
@returns {string} The $filter value | [
"Returns",
"the",
"$filter",
"value",
"for",
"the",
"given",
"single",
"filter",
"using",
"the",
"given",
"Edm",
"type",
"to",
"format",
"the",
"filter",
"s",
"operand",
"(",
"s",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataListBinding.js#L869-L904 | train | Get single filter value | [
30522,
3853,
4152,
2075,
2571,
8873,
21928,
10175,
5657,
1006,
1997,
4014,
3334,
1010,
7367,
22117,
13874,
1010,
1038,
24415,
3981,
4859,
1007,
1063,
13075,
16420,
4014,
3334,
1010,
17917,
2389,
5657,
1027,
1035,
2393,
2121,
1012,
4289,
227... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oNavigationProperty, oEntitySet) {
var oNavigationRestrictions =
oEntitySet["Org.OData.Capabilities.V1.NavigationRestrictions"] || {};
oNavigationRestrictions.RestrictedProperties =
oNavigationRestrictions.RestrictedProperties || [];
oNavigationRestrictions.RestrictedProperties.push({
"FilterRestrictions" : {
"Filterable": oBoolFalse
},
"NavigationProperty" : {
"NavigationPropertyPath" : oNavigationProperty.name
}
});
oEntitySet["Org.OData.Capabilities.V1.NavigationRestrictions"] =
oNavigationRestrictions;
} | javascript | function (oNavigationProperty, oEntitySet) {
var oNavigationRestrictions =
oEntitySet["Org.OData.Capabilities.V1.NavigationRestrictions"] || {};
oNavigationRestrictions.RestrictedProperties =
oNavigationRestrictions.RestrictedProperties || [];
oNavigationRestrictions.RestrictedProperties.push({
"FilterRestrictions" : {
"Filterable": oBoolFalse
},
"NavigationProperty" : {
"NavigationPropertyPath" : oNavigationProperty.name
}
});
oEntitySet["Org.OData.Capabilities.V1.NavigationRestrictions"] =
oNavigationRestrictions;
} | [
"function",
"(",
"oNavigationProperty",
",",
"oEntitySet",
")",
"{",
"var",
"oNavigationRestrictions",
"=",
"oEntitySet",
"[",
"\"Org.OData.Capabilities.V1.NavigationRestrictions\"",
"]",
"||",
"{",
"}",
";",
"oNavigationRestrictions",
".",
"RestrictedProperties",
"=",
"o... | Adds a V4 navigation restriction annotation with a filter restriction to the given entity
set for the given navigation property with the V2 annotation
<code>sap:filterable="false"</code>.
@param {object} oNavigationProperty
the navigation property of the entity with the V2 annotation
<code>sap:filterable="false"</code>
@param {object} oEntitySet
the entity set to which the corresponding V4 annotation needs to be added | [
"Adds",
"a",
"V4",
"navigation",
"restriction",
"annotation",
"with",
"a",
"filter",
"restriction",
"to",
"the",
"given",
"entity",
"set",
"for",
"the",
"given",
"navigation",
"property",
"with",
"the",
"V2",
"annotation",
"<code",
">",
"sap",
":",
"filterable... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L240-L258 | train | Adds a restricted property to the entity set | [
30522,
3853,
1006,
2006,
18891,
12540,
21572,
4842,
3723,
1010,
1051,
4765,
3012,
13462,
1007,
1063,
13075,
2006,
18891,
12540,
28533,
7277,
9285,
1027,
1051,
4765,
3012,
13462,
1031,
1000,
8917,
1012,
1051,
2850,
2696,
1012,
9859,
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... | |
adobe/brackets | src/command/KeyBindingManager.js | _handleKey | function _handleKey(key) {
if (_enabled && _keyMap[key]) {
// The execute() function returns a promise because some commands are async.
// Generally, commands decide whether they can run or not synchronously,
// and reject immediately, so we can test for that synchronously.
var promise = CommandManager.execute(_keyMap[key].commandID);
return (promise.state() !== "rejected");
}
return false;
} | javascript | function _handleKey(key) {
if (_enabled && _keyMap[key]) {
// The execute() function returns a promise because some commands are async.
// Generally, commands decide whether they can run or not synchronously,
// and reject immediately, so we can test for that synchronously.
var promise = CommandManager.execute(_keyMap[key].commandID);
return (promise.state() !== "rejected");
}
return false;
} | [
"function",
"_handleKey",
"(",
"key",
")",
"{",
"if",
"(",
"_enabled",
"&&",
"_keyMap",
"[",
"key",
"]",
")",
"{",
"// The execute() function returns a promise because some commands are async.",
"// Generally, commands decide whether they can run or not synchronously,",
"// and r... | Process the keybinding for the current key.
@param {string} A key-description string.
@return {boolean} true if the key was processed, false otherwise | [
"Process",
"the",
"keybinding",
"for",
"the",
"current",
"key",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L811-L820 | train | Handle a key | [
30522,
3853,
1035,
5047,
14839,
1006,
3145,
1007,
1063,
2065,
1006,
1035,
9124,
1004,
1004,
1035,
3145,
2863,
2361,
1031,
3145,
1033,
1007,
1063,
1013,
1013,
1996,
15389,
1006,
1007,
3853,
5651,
1037,
4872,
2138,
2070,
10954,
2024,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RecentProjects/main.js | selectNextItem | function selectNextItem(direction) {
var $links = $dropdown.find("a"),
index = $dropdownItem ? $links.index($dropdownItem) : (direction > 0 ? -1 : 0),
$newItem = $links.eq((index + direction) % $links.length);
if ($dropdownItem) {
$dropdownItem.removeClass("selected");
}
$newItem.addClass("selected");
$dropdownItem = $newItem;
removeDeleteButton();
} | javascript | function selectNextItem(direction) {
var $links = $dropdown.find("a"),
index = $dropdownItem ? $links.index($dropdownItem) : (direction > 0 ? -1 : 0),
$newItem = $links.eq((index + direction) % $links.length);
if ($dropdownItem) {
$dropdownItem.removeClass("selected");
}
$newItem.addClass("selected");
$dropdownItem = $newItem;
removeDeleteButton();
} | [
"function",
"selectNextItem",
"(",
"direction",
")",
"{",
"var",
"$links",
"=",
"$dropdown",
".",
"find",
"(",
"\"a\"",
")",
",",
"index",
"=",
"$dropdownItem",
"?",
"$links",
".",
"index",
"(",
"$dropdownItem",
")",
":",
"(",
"direction",
">",
"0",
"?",... | Selects the next or previous item in the list
@param {number} direction +1 for next, -1 for prev | [
"Selects",
"the",
"next",
"or",
"previous",
"item",
"in",
"the",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RecentProjects/main.js#L162-L174 | train | select next item | [
30522,
3853,
7276,
2638,
18413,
4221,
2213,
1006,
3257,
1007,
1063,
13075,
1002,
6971,
1027,
1002,
4530,
7698,
1012,
2424,
1006,
1000,
1037,
1000,
1007,
1010,
5950,
1027,
1002,
4530,
7698,
4221,
2213,
1029,
1002,
6971,
1012,
5950,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
heyui/heyui | src/plugins/popper/index.js | disableEventListeners | function disableEventListeners() {
if (this.state.eventsEnabled) {
if (window.cancelAnimationFrame) {
cancelAnimationFrame(this.scheduleUpdate);
}
this.state = removeEventListeners(this.reference, this.state);
}
} | javascript | function disableEventListeners() {
if (this.state.eventsEnabled) {
if (window.cancelAnimationFrame) {
cancelAnimationFrame(this.scheduleUpdate);
}
this.state = removeEventListeners(this.reference, this.state);
}
} | [
"function",
"disableEventListeners",
"(",
")",
"{",
"if",
"(",
"this",
".",
"state",
".",
"eventsEnabled",
")",
"{",
"if",
"(",
"window",
".",
"cancelAnimationFrame",
")",
"{",
"cancelAnimationFrame",
"(",
"this",
".",
"scheduleUpdate",
")",
";",
"}",
"this"... | It will remove resize/scroll events and won't recalculate popper position
when they are triggered. It also won't trigger onUpdate callback anymore,
unless you call `update` method manually.
@method
@memberof Popper | [
"It",
"will",
"remove",
"resize",
"/",
"scroll",
"events",
"and",
"won",
"t",
"recalculate",
"popper",
"position",
"when",
"they",
"are",
"triggered",
".",
"It",
"also",
"won",
"t",
"trigger",
"onUpdate",
"callback",
"anymore",
"unless",
"you",
"call",
"upda... | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1145-L1152 | train | Disable event listeners | [
30522,
3853,
4487,
19150,
18697,
3372,
9863,
24454,
2015,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
2110,
1012,
2824,
8189,
23242,
1007,
1063,
2065,
1006,
3332,
1012,
17542,
7088,
28649,
15643,
1007,
1063,
17542,
7088,
28649,
15643,
1006,
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... |
SeleniumHQ/selenium | third_party/closure/goog/i18n/dateintervalformat.js | function(
firstPattern, secondPattern, dateTimeSymbols, useFirstDateOnFirstPattern) {
/**
* Formatter_ to format the first part of the date interval.
* @private {!DateTimeFormat}
*/
this.firstPartFormatter_ = new DateTimeFormat(firstPattern, dateTimeSymbols);
/**
* Formatter_ to format the second part of the date interval.
* @private {!DateTimeFormat}
*/
this.secondPartFormatter_ =
new DateTimeFormat(secondPattern, dateTimeSymbols);
/**
* Specifies if the first or the second date should be formatted by the
* formatter of the first or second part of the date interval.
* @private {boolean}
*/
this.useFirstDateOnFirstPattern_ = useFirstDateOnFirstPattern;
} | javascript | function(
firstPattern, secondPattern, dateTimeSymbols, useFirstDateOnFirstPattern) {
/**
* Formatter_ to format the first part of the date interval.
* @private {!DateTimeFormat}
*/
this.firstPartFormatter_ = new DateTimeFormat(firstPattern, dateTimeSymbols);
/**
* Formatter_ to format the second part of the date interval.
* @private {!DateTimeFormat}
*/
this.secondPartFormatter_ =
new DateTimeFormat(secondPattern, dateTimeSymbols);
/**
* Specifies if the first or the second date should be formatted by the
* formatter of the first or second part of the date interval.
* @private {boolean}
*/
this.useFirstDateOnFirstPattern_ = useFirstDateOnFirstPattern;
} | [
"function",
"(",
"firstPattern",
",",
"secondPattern",
",",
"dateTimeSymbols",
",",
"useFirstDateOnFirstPattern",
")",
"{",
"/**\n * Formatter_ to format the first part of the date interval.\n * @private {!DateTimeFormat}\n */",
"this",
".",
"firstPartFormatter_",
"=",
"new",
... | Constructs an IntervalFormatter_ object which implements the Formatter_
interface.
Internal object to construct and store a goog.i18n.DateTimeFormat for each
part of the date interval pattern.
@param {string} firstPattern First part of the date interval pattern.
@param {string} secondPattern Second part of the date interval pattern.
@param {!DateTimeSymbolsType} dateTimeSymbols Symbols to use with the
datetime formatters.
@param {boolean} useFirstDateOnFirstPattern Indicates if the first or the
second date should be formatted with the first or second part of the date
interval pattern.
@constructor
@implements {Formatter_}
@private | [
"Constructs",
"an",
"IntervalFormatter_",
"object",
"which",
"implements",
"the",
"Formatter_",
"interface",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/i18n/dateintervalformat.js#L556-L577 | train | A formatter for the date interval. | [
30522,
3853,
1006,
2034,
4502,
12079,
2078,
1010,
2117,
4502,
12079,
2078,
1010,
3058,
7292,
6508,
13344,
4877,
1010,
2224,
8873,
12096,
13701,
2239,
8873,
12096,
4502,
12079,
2078,
1007,
1063,
1013,
1008,
1008,
1008,
4289,
3334,
1035,
2000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sNumber) {
var oPlurals = this._get("plurals");
if (typeof sNumber === "number") {
sNumber = sNumber.toString();
}
if (!this._pluralTest) {
this._pluralTest = {};
}
for (var sCategory in oPlurals) {
var fnTest = this._pluralTest[sCategory];
if (!fnTest) {
fnTest = this._parsePluralRule(oPlurals[sCategory]);
this._pluralTest[sCategory] = fnTest;
}
if (fnTest(sNumber)) {
return sCategory;
}
}
return "other";
} | javascript | function(sNumber) {
var oPlurals = this._get("plurals");
if (typeof sNumber === "number") {
sNumber = sNumber.toString();
}
if (!this._pluralTest) {
this._pluralTest = {};
}
for (var sCategory in oPlurals) {
var fnTest = this._pluralTest[sCategory];
if (!fnTest) {
fnTest = this._parsePluralRule(oPlurals[sCategory]);
this._pluralTest[sCategory] = fnTest;
}
if (fnTest(sNumber)) {
return sCategory;
}
}
return "other";
} | [
"function",
"(",
"sNumber",
")",
"{",
"var",
"oPlurals",
"=",
"this",
".",
"_get",
"(",
"\"plurals\"",
")",
";",
"if",
"(",
"typeof",
"sNumber",
"===",
"\"number\"",
")",
"{",
"sNumber",
"=",
"sNumber",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",... | Returns the plural category (zero, one, two, few, many or other) for the given number value.
The number should be passed as a string with dot as decimal separator and the number of decimal/fraction digits
as used in the final output. This is needed in order to preserve trailing zeros which are relevant to
determine the right plural category.
@param {string|number} sNumber The number to find the plural category for
@returns {string} The plural category
@public
@since 1.50 | [
"Returns",
"the",
"plural",
"category",
"(",
"zero",
"one",
"two",
"few",
"many",
"or",
"other",
")",
"for",
"the",
"given",
"number",
"value",
".",
"The",
"number",
"should",
"be",
"passed",
"as",
"a",
"string",
"with",
"dot",
"as",
"decimal",
"separato... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L1576-L1595 | train | Returns the plural test for the given number | [
30522,
3853,
1006,
1055,
19172,
5677,
1007,
1063,
13075,
6728,
7630,
7941,
2015,
1027,
2023,
1012,
1035,
2131,
1006,
1000,
13994,
2015,
1000,
1007,
1025,
2065,
1006,
2828,
11253,
1055,
19172,
5677,
1027,
1027,
1027,
1000,
2193,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/util/clazz.js | superCall | function superCall(context, methodName) {
var args = zrUtil.slice(arguments, 2);
return this.superClass.prototype[methodName].apply(context, args);
} | javascript | function superCall(context, methodName) {
var args = zrUtil.slice(arguments, 2);
return this.superClass.prototype[methodName].apply(context, args);
} | [
"function",
"superCall",
"(",
"context",
",",
"methodName",
")",
"{",
"var",
"args",
"=",
"zrUtil",
".",
"slice",
"(",
"arguments",
",",
"2",
")",
";",
"return",
"this",
".",
"superClass",
".",
"prototype",
"[",
"methodName",
"]",
".",
"apply",
"(",
"c... | superCall should have class info, which can not be fetch from 'this'. Consider this case: class A has method f, class B inherits class A, overrides method f, f call superApply('f'), class C inherits class B, do not overrides method f, then when method of class C is called, dead loop occured. | [
"superCall",
"should",
"have",
"class",
"info",
"which",
"can",
"not",
"be",
"fetch",
"from",
"this",
".",
"Consider",
"this",
"case",
":",
"class",
"A",
"has",
"method",
"f",
"class",
"B",
"inherits",
"class",
"A",
"overrides",
"method",
"f",
"f",
"call... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/util/clazz.js#L117-L120 | train | This method is called by the super class to call the method with the arguments passed to the method. | [
30522,
3853,
3565,
9289,
2140,
1006,
6123,
1010,
4118,
18442,
1007,
1063,
13075,
12098,
5620,
1027,
1062,
22134,
4014,
1012,
14704,
1006,
9918,
1010,
1016,
1007,
1025,
2709,
2023,
1012,
3565,
26266,
1012,
8773,
1031,
4118,
18442,
1033,
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... |
aws/aws-sdk-js | lib/config.js | setPromisesDependency | function setPromisesDependency(dep) {
PromisesDependency = dep;
// if null was passed in, we should try to use native promises
if (dep === null && typeof Promise === 'function') {
PromisesDependency = Promise;
}
var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain];
if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload);
AWS.util.addPromises(constructors, PromisesDependency);
} | javascript | function setPromisesDependency(dep) {
PromisesDependency = dep;
// if null was passed in, we should try to use native promises
if (dep === null && typeof Promise === 'function') {
PromisesDependency = Promise;
}
var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain];
if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload);
AWS.util.addPromises(constructors, PromisesDependency);
} | [
"function",
"setPromisesDependency",
"(",
"dep",
")",
"{",
"PromisesDependency",
"=",
"dep",
";",
"// if null was passed in, we should try to use native promises",
"if",
"(",
"dep",
"===",
"null",
"&&",
"typeof",
"Promise",
"===",
"'function'",
")",
"{",
"PromisesDepend... | Sets the promise dependency the SDK will use wherever Promises are returned.
Passing `null` will force the SDK to use native Promises if they are available.
If native Promises are not available, passing `null` will have no effect.
@param [Constructor] dep A reference to a Promise constructor | [
"Sets",
"the",
"promise",
"dependency",
"the",
"SDK",
"will",
"use",
"wherever",
"Promises",
"are",
"returned",
".",
"Passing",
"null",
"will",
"force",
"the",
"SDK",
"to",
"use",
"native",
"Promises",
"if",
"they",
"are",
"available",
".",
"If",
"native",
... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L550-L559 | train | set the promise dependency | [
30522,
3853,
2275,
21572,
28732,
16150,
13699,
10497,
11916,
1006,
2139,
2361,
1007,
1063,
10659,
3207,
11837,
4181,
5666,
1027,
2139,
2361,
1025,
1013,
1013,
2065,
19701,
2001,
2979,
1999,
1010,
2057,
2323,
3046,
2000,
2224,
3128,
10659,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Decimal.js | setConstraints | function setConstraints(oType, oConstraints) {
var vNullable, iPrecision, vPrecision, iScale, vScale;
function logWarning(vValue, sName) {
Log.warning("Illegal " + sName + ": " + vValue, null, oType.getName());
}
function validateInt(vValue, iDefault, iMinimum, sName) {
var iValue = typeof vValue === "string" ? parseInt(vValue) : vValue;
if (iValue === undefined) {
return iDefault;
}
if (typeof iValue !== "number" || isNaN(iValue) || iValue < iMinimum) {
logWarning(vValue, sName);
return iDefault;
}
return iValue;
}
/*
* Validates whether the given value is a valid Edm.Decimal value.
*
* @param {string} sValue
* the constraint minimum or maximum value
* @param {string} sName
* name for logging
* @returns {string}
* the validated value or undefined
*/
function validateDecimal(sValue, sName) {
if (sValue) {
if (sValue.match(rDecimal)) {
return sValue;
}
logWarning(sValue, sName);
}
}
function validateBoolean(vValue, sName) {
if (vValue === true || vValue === "true") {
return true;
}
if (vValue !== undefined && vValue !== false && vValue !== "false") {
logWarning(vValue, sName);
}
}
function setConstraint(sName, vValue, vDefault) {
if (vValue !== vDefault) {
oType.oConstraints = oType.oConstraints || {};
oType.oConstraints[sName] = vValue;
}
}
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
vPrecision = oConstraints.precision;
vScale = oConstraints.scale;
iScale = vScale === "variable" ? Infinity : validateInt(vScale, 0, 0, "scale");
iPrecision = validateInt(vPrecision, Infinity, 1, "precision");
if (iScale !== Infinity && iPrecision <= iScale) {
Log.warning("Illegal scale: must be less than precision (precision="
+ vPrecision + ", scale=" + vScale + ")", null, oType.getName());
iScale = Infinity; // "variable"
}
setConstraint("precision", iPrecision, Infinity);
setConstraint("scale", iScale, 0);
if (vNullable === false || vNullable === "false") {
setConstraint("nullable", false, true);
} else if (vNullable !== undefined && vNullable !== true && vNullable !== "true") {
logWarning(vNullable, "nullable");
}
setConstraint("minimum", validateDecimal(oConstraints.minimum, "minimum"));
setConstraint("minimumExclusive",
validateBoolean(oConstraints.minimumExclusive, "minimumExclusive"));
setConstraint("maximum", validateDecimal(oConstraints.maximum, "maximum"));
setConstraint("maximumExclusive",
validateBoolean(oConstraints.maximumExclusive, "maximumExclusive"));
}
oType._handleLocalizationChange();
} | javascript | function setConstraints(oType, oConstraints) {
var vNullable, iPrecision, vPrecision, iScale, vScale;
function logWarning(vValue, sName) {
Log.warning("Illegal " + sName + ": " + vValue, null, oType.getName());
}
function validateInt(vValue, iDefault, iMinimum, sName) {
var iValue = typeof vValue === "string" ? parseInt(vValue) : vValue;
if (iValue === undefined) {
return iDefault;
}
if (typeof iValue !== "number" || isNaN(iValue) || iValue < iMinimum) {
logWarning(vValue, sName);
return iDefault;
}
return iValue;
}
/*
* Validates whether the given value is a valid Edm.Decimal value.
*
* @param {string} sValue
* the constraint minimum or maximum value
* @param {string} sName
* name for logging
* @returns {string}
* the validated value or undefined
*/
function validateDecimal(sValue, sName) {
if (sValue) {
if (sValue.match(rDecimal)) {
return sValue;
}
logWarning(sValue, sName);
}
}
function validateBoolean(vValue, sName) {
if (vValue === true || vValue === "true") {
return true;
}
if (vValue !== undefined && vValue !== false && vValue !== "false") {
logWarning(vValue, sName);
}
}
function setConstraint(sName, vValue, vDefault) {
if (vValue !== vDefault) {
oType.oConstraints = oType.oConstraints || {};
oType.oConstraints[sName] = vValue;
}
}
oType.oConstraints = undefined;
if (oConstraints) {
vNullable = oConstraints.nullable;
vPrecision = oConstraints.precision;
vScale = oConstraints.scale;
iScale = vScale === "variable" ? Infinity : validateInt(vScale, 0, 0, "scale");
iPrecision = validateInt(vPrecision, Infinity, 1, "precision");
if (iScale !== Infinity && iPrecision <= iScale) {
Log.warning("Illegal scale: must be less than precision (precision="
+ vPrecision + ", scale=" + vScale + ")", null, oType.getName());
iScale = Infinity; // "variable"
}
setConstraint("precision", iPrecision, Infinity);
setConstraint("scale", iScale, 0);
if (vNullable === false || vNullable === "false") {
setConstraint("nullable", false, true);
} else if (vNullable !== undefined && vNullable !== true && vNullable !== "true") {
logWarning(vNullable, "nullable");
}
setConstraint("minimum", validateDecimal(oConstraints.minimum, "minimum"));
setConstraint("minimumExclusive",
validateBoolean(oConstraints.minimumExclusive, "minimumExclusive"));
setConstraint("maximum", validateDecimal(oConstraints.maximum, "maximum"));
setConstraint("maximumExclusive",
validateBoolean(oConstraints.maximumExclusive, "maximumExclusive"));
}
oType._handleLocalizationChange();
} | [
"function",
"setConstraints",
"(",
"oType",
",",
"oConstraints",
")",
"{",
"var",
"vNullable",
",",
"iPrecision",
",",
"vPrecision",
",",
"iScale",
",",
"vScale",
";",
"function",
"logWarning",
"(",
"vValue",
",",
"sName",
")",
"{",
"Log",
".",
"warning",
... | Sets the constraints.
@param {sap.ui.model.odata.type.Decimal} 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/Decimal.js#L80-L164 | train | Sets constraints for the given Edm. Type | [
30522,
3853,
2275,
8663,
20528,
18447,
2015,
1006,
27178,
18863,
1010,
1051,
8663,
20528,
18447,
2015,
1007,
1063,
13075,
1058,
11231,
4571,
3468,
1010,
12997,
2890,
28472,
1010,
21210,
2890,
28472,
1010,
2003,
9289,
2063,
1010,
5443,
9289,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/Package.js | installFromURL | function installFromURL(url) {
var STATE_DOWNLOADING = 1,
STATE_INSTALLING = 2,
STATE_SUCCEEDED = 3,
STATE_FAILED = 4;
var d = new $.Deferred();
var state = STATE_DOWNLOADING;
var downloadId = (_uniqueId++);
download(url, downloadId)
.done(function (downloadResult) {
state = STATE_INSTALLING;
installFromPath(downloadResult.localPath, downloadResult.filenameHint)
.done(function (result) {
var installationStatus = result.installationStatus;
state = STATE_SUCCEEDED;
result.localPath = downloadResult.localPath;
result.keepFile = false;
if (installationStatus === InstallationStatuses.INSTALLED) {
// Delete temp file
FileSystem.getFileForPath(downloadResult.localPath).unlink();
}
d.resolve(result);
})
.fail(function (err) {
// File IO errors, internal error in install()/validate(), or extension startup crashed
state = STATE_FAILED;
FileSystem.getFileForPath(downloadResult.localPath).unlink();
d.reject(err); // TODO: needs to be err.message ?
});
})
.fail(function (err) {
// Download error (the Node-side download code cleans up any partial ZIP file)
state = STATE_FAILED;
d.reject(err);
});
return {
promise: d.promise(),
cancel: function () {
if (state === STATE_DOWNLOADING) {
// This will trigger download()'s fail() handler with CANCELED as the err code
cancelDownload(downloadId);
}
// Else it's too late to cancel; we'll continue on through the done() chain and emit
// a success result (calling done() handlers) if all else goes well.
}
};
} | javascript | function installFromURL(url) {
var STATE_DOWNLOADING = 1,
STATE_INSTALLING = 2,
STATE_SUCCEEDED = 3,
STATE_FAILED = 4;
var d = new $.Deferred();
var state = STATE_DOWNLOADING;
var downloadId = (_uniqueId++);
download(url, downloadId)
.done(function (downloadResult) {
state = STATE_INSTALLING;
installFromPath(downloadResult.localPath, downloadResult.filenameHint)
.done(function (result) {
var installationStatus = result.installationStatus;
state = STATE_SUCCEEDED;
result.localPath = downloadResult.localPath;
result.keepFile = false;
if (installationStatus === InstallationStatuses.INSTALLED) {
// Delete temp file
FileSystem.getFileForPath(downloadResult.localPath).unlink();
}
d.resolve(result);
})
.fail(function (err) {
// File IO errors, internal error in install()/validate(), or extension startup crashed
state = STATE_FAILED;
FileSystem.getFileForPath(downloadResult.localPath).unlink();
d.reject(err); // TODO: needs to be err.message ?
});
})
.fail(function (err) {
// Download error (the Node-side download code cleans up any partial ZIP file)
state = STATE_FAILED;
d.reject(err);
});
return {
promise: d.promise(),
cancel: function () {
if (state === STATE_DOWNLOADING) {
// This will trigger download()'s fail() handler with CANCELED as the err code
cancelDownload(downloadId);
}
// Else it's too late to cancel; we'll continue on through the done() chain and emit
// a success result (calling done() handlers) if all else goes well.
}
};
} | [
"function",
"installFromURL",
"(",
"url",
")",
"{",
"var",
"STATE_DOWNLOADING",
"=",
"1",
",",
"STATE_INSTALLING",
"=",
"2",
",",
"STATE_SUCCEEDED",
"=",
"3",
",",
"STATE_FAILED",
"=",
"4",
";",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
"... | On success, resolves with an extension metadata object; at that point, the extension has already
started running in Brackets. On failure (including validation errors), rejects with an error object.
An error object consists of either a string error code OR an array where the first entry is the error
code and the remaining entries are further info. The error code string is one of either
ExtensionsDomain.Errors or Package.Errors. Use formatError() to convert an error object to a friendly,
localized error message.
The returned cancel() function will *attempt* to cancel installation, but it is not guaranteed to
succeed. If cancel() succeeds, the Promise is rejected with a CANCELED error code. If we're unable
to cancel, the Promise is resolved or rejected normally, as if cancel() had never been called.
@return {{promise: $.Promise, cancel: function():boolean}} | [
"On",
"success",
"resolves",
"with",
"an",
"extension",
"metadata",
"object",
";",
"at",
"that",
"point",
"the",
"extension",
"has",
"already",
"started",
"running",
"in",
"Brackets",
".",
"On",
"failure",
"(",
"including",
"validation",
"errors",
")",
"reject... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/Package.js#L352-L405 | train | Installs a file from a URL | [
30522,
3853,
16500,
19699,
5358,
3126,
2140,
1006,
24471,
2140,
1007,
1063,
13075,
2110,
1035,
8816,
2075,
1027,
1015,
1010,
2110,
1035,
23658,
1027,
1016,
1010,
2110,
1035,
4594,
1027,
1017,
1010,
2110,
1035,
3478,
1027,
1018,
1025,
13075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onConfirmPasswordReset | function onConfirmPasswordReset() {
var code = $('#password-reset-code').val();
var password = $('#password-reset-password').val();
auth.confirmPasswordReset(code, password).then(function() {
alertSuccess('Password has been changed!');
}, onAuthError);
} | javascript | function onConfirmPasswordReset() {
var code = $('#password-reset-code').val();
var password = $('#password-reset-password').val();
auth.confirmPasswordReset(code, password).then(function() {
alertSuccess('Password has been changed!');
}, onAuthError);
} | [
"function",
"onConfirmPasswordReset",
"(",
")",
"{",
"var",
"code",
"=",
"$",
"(",
"'#password-reset-code'",
")",
".",
"val",
"(",
")",
";",
"var",
"password",
"=",
"$",
"(",
"'#password-reset-password'",
")",
".",
"val",
"(",
")",
";",
"auth",
".",
"con... | Confirms the password reset with the code and password supplied by the user. | [
"Confirms",
"the",
"password",
"reset",
"with",
"the",
"code",
"and",
"password",
"supplied",
"by",
"the",
"user",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L709-L715 | train | Confirm password reset | [
30522,
3853,
2006,
8663,
27972,
15194,
18351,
6072,
3388,
1006,
1007,
1063,
13075,
3642,
1027,
1002,
1006,
1005,
1001,
20786,
1011,
25141,
1011,
3642,
1005,
1007,
1012,
11748,
1006,
1007,
1025,
13075,
20786,
1027,
1002,
1006,
1005,
1001,
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.table/src/sap/ui/table/TableUtils.js | function(oTable) {
var iFixedBottomRowCount = oTable.getFixedBottomRowCount();
var oBinding = oTable.getBinding("rows");
var iFirstFixedBottomIndex = -1;
if (oBinding && iFixedBottomRowCount > 0) {
var iVisibleRowCount = oTable.getVisibleRowCount();
var iFirstVisibleRow = oTable.getFirstVisibleRow();
var iTotalRowCount = oTable._getTotalRowCount();
if (iTotalRowCount >= iVisibleRowCount) {
iFirstFixedBottomIndex = iVisibleRowCount - iFixedBottomRowCount;
} else {
var iIdx = iTotalRowCount - iFixedBottomRowCount - iFirstVisibleRow;
if (iIdx >= 0 && (iFirstVisibleRow + iIdx) < iTotalRowCount) {
iFirstFixedBottomIndex = iIdx;
}
}
}
return iFirstFixedBottomIndex;
} | javascript | function(oTable) {
var iFixedBottomRowCount = oTable.getFixedBottomRowCount();
var oBinding = oTable.getBinding("rows");
var iFirstFixedBottomIndex = -1;
if (oBinding && iFixedBottomRowCount > 0) {
var iVisibleRowCount = oTable.getVisibleRowCount();
var iFirstVisibleRow = oTable.getFirstVisibleRow();
var iTotalRowCount = oTable._getTotalRowCount();
if (iTotalRowCount >= iVisibleRowCount) {
iFirstFixedBottomIndex = iVisibleRowCount - iFixedBottomRowCount;
} else {
var iIdx = iTotalRowCount - iFixedBottomRowCount - iFirstVisibleRow;
if (iIdx >= 0 && (iFirstVisibleRow + iIdx) < iTotalRowCount) {
iFirstFixedBottomIndex = iIdx;
}
}
}
return iFirstFixedBottomIndex;
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"iFixedBottomRowCount",
"=",
"oTable",
".",
"getFixedBottomRowCount",
"(",
")",
";",
"var",
"oBinding",
"=",
"oTable",
".",
"getBinding",
"(",
"\"rows\"",
")",
";",
"var",
"iFirstFixedBottomIndex",
"=",
"-",
"1",
"... | Returns the index of the first fixed bottom row in the <code>rows</code> aggregation.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {int} The index of the first fixed bottom row in the <code>rows</code> aggregation, or <code>-1</code>. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"fixed",
"bottom",
"row",
"in",
"the",
"<code",
">",
"rows<",
"/",
"code",
">",
"aggregation",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L1119-L1140 | train | Returns the index of the bottom row of the table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
2065,
7646,
2098,
18384,
20389,
10524,
3597,
16671,
1027,
27178,
3085,
1012,
2131,
23901,
18384,
20389,
10524,
3597,
16671,
1006,
1007,
1025,
13075,
27885,
22254,
2075,
1027,
30524,
20389,
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... | |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b);
} | javascript | function (q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b);
} | [
"function",
"(",
"q",
",",
"a",
",",
"b",
",",
"x",
",",
"s",
",",
"t",
")",
"{",
"return",
"safe_add",
"(",
"bit_rol",
"(",
"safe_add",
"(",
"safe_add",
"(",
"a",
",",
"q",
")",
",",
"safe_add",
"(",
"x",
",",
"t",
")",
")",
",",
"s",
")",... | /*
These functions implement the four basic operations the algorithm uses. | [
"/",
"*",
"These",
"functions",
"implement",
"the",
"four",
"basic",
"operations",
"the",
"algorithm",
"uses",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L342-L344 | train | A function that adds two terms of the terms | [
30522,
3853,
1006,
1053,
1010,
1037,
1010,
1038,
1010,
1060,
1010,
1055,
1010,
1056,
1007,
1063,
2709,
3647,
1035,
5587,
1006,
2978,
1035,
20996,
2140,
1006,
3647,
1035,
5587,
1006,
3647,
1035,
5587,
1006,
1037,
1010,
1053,
1007,
1010,
36... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
var aSorterObjects = [];
for (var i = -1, oCondition; (oCondition = this._aSortCondition[++i]) !== undefined;) {
aSorterObjects.push(new Sorter(oCondition.property.name,
oCondition.order == odata4analytics.SortOrder.Descending));
}
return aSorterObjects;
} | javascript | function() {
var aSorterObjects = [];
for (var i = -1, oCondition; (oCondition = this._aSortCondition[++i]) !== undefined;) {
aSorterObjects.push(new Sorter(oCondition.property.name,
oCondition.order == odata4analytics.SortOrder.Descending));
}
return aSorterObjects;
} | [
"function",
"(",
")",
"{",
"var",
"aSorterObjects",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"-",
"1",
",",
"oCondition",
";",
"(",
"oCondition",
"=",
"this",
".",
"_aSortCondition",
"[",
"++",
"i",
"]",
")",
"!==",
"undefined",
";",
")",
... | Get an array of SAPUI5 Sorter objects corresponding to this expression.
@returns {sap.ui.model.Sorter[]} List of sorter objects representing
this expression
@public
@function
@name sap.ui.model.analytics.odata4analytics.SortExpression#getExpressionsAsUI5SorterArray | [
"Get",
"an",
"array",
"of",
"SAPUI5",
"Sorter",
"objects",
"corresponding",
"to",
"this",
"expression",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3742-L3751 | train | Returns an array of Sorter objects that can be used to sort the data by the order of the data. | [
30522,
3853,
1006,
1007,
1063,
13075,
2004,
11589,
10624,
2497,
20614,
2015,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
1045,
1027,
1011,
1015,
1010,
1051,
8663,
20562,
1025,
1006,
1051,
8663,
20562,
1027,
2023,
1012,
1035,
2004,
11589,
866... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GeekyAnts/vue-native-core | packages/vue-server-renderer/build.js | optimize | function optimize (root, options) {
if (!root) { return }
isStaticKey = genStaticKeysCached(options.staticKeys || '');
isPlatformReservedTag = options.isReservedTag || no;
// first pass: mark all non-static nodes.
markStatic(root);
// second pass: mark static roots.
markStaticRoots(root, false);
} | javascript | function optimize (root, options) {
if (!root) { return }
isStaticKey = genStaticKeysCached(options.staticKeys || '');
isPlatformReservedTag = options.isReservedTag || no;
// first pass: mark all non-static nodes.
markStatic(root);
// second pass: mark static roots.
markStaticRoots(root, false);
} | [
"function",
"optimize",
"(",
"root",
",",
"options",
")",
"{",
"if",
"(",
"!",
"root",
")",
"{",
"return",
"}",
"isStaticKey",
"=",
"genStaticKeysCached",
"(",
"options",
".",
"staticKeys",
"||",
"''",
")",
";",
"isPlatformReservedTag",
"=",
"options",
"."... | Goal of the optimizer: walk the generated template AST tree
and detect sub-trees that are purely static, i.e. parts of
the DOM that never needs to change.
Once we detect these sub-trees, we can:
1. Hoist them into constants, so that we no longer need to
create fresh nodes for them on each re-render;
2. Completely skip them in the patching process. | [
"Goal",
"of",
"the",
"optimizer",
":",
"walk",
"the",
"generated",
"template",
"AST",
"tree",
"and",
"detect",
"sub",
"-",
"trees",
"that",
"are",
"purely",
"static",
"i",
".",
"e",
".",
"parts",
"of",
"the",
"DOM",
"that",
"never",
"needs",
"to",
"cha... | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/vue-server-renderer/build.js#L3484-L3492 | train | optimize a node | [
30522,
3853,
23569,
27605,
4371,
1006,
7117,
1010,
7047,
1007,
1063,
2065,
1006,
999,
7117,
1007,
1063,
2709,
1065,
26354,
29336,
6799,
3240,
1027,
8991,
16677,
14839,
15782,
7690,
1006,
7047,
30524,
4017,
14192,
6072,
25944,
15900,
1027,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/dom-utils.js | unwrapNode | function unwrapNode(aNode) {
var node = aNode;
if (node) {
// unwrap is not available on older branches (3.5 and 3.6) - Bug 533596
if ("unwrap" in XPCNativeWrapper) {
node = XPCNativeWrapper.unwrap(node);
}
else if ("wrappedJSObject" in node) {
node = node.wrappedJSObject;
}
}
return node;
} | javascript | function unwrapNode(aNode) {
var node = aNode;
if (node) {
// unwrap is not available on older branches (3.5 and 3.6) - Bug 533596
if ("unwrap" in XPCNativeWrapper) {
node = XPCNativeWrapper.unwrap(node);
}
else if ("wrappedJSObject" in node) {
node = node.wrappedJSObject;
}
}
return node;
} | [
"function",
"unwrapNode",
"(",
"aNode",
")",
"{",
"var",
"node",
"=",
"aNode",
";",
"if",
"(",
"node",
")",
"{",
"// unwrap is not available on older branches (3.5 and 3.6) - Bug 533596",
"if",
"(",
"\"unwrap\"",
"in",
"XPCNativeWrapper",
")",
"{",
"node",
"=",
"X... | Unwraps a node which is wrapped into a XPCNativeWrapper or XrayWrapper
@param {DOMnode} Wrapped DOM node
@returns {DOMNode} Unwrapped DOM node | [
"Unwraps",
"a",
"node",
"which",
"is",
"wrapped",
"into",
"a",
"XPCNativeWrapper",
"or",
"XrayWrapper"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L49-L63 | train | Unwraps a node | [
30522,
3853,
4895,
13088,
9331,
3630,
3207,
1006,
2019,
10244,
1007,
1063,
13075,
13045,
1027,
2019,
10244,
1025,
2065,
1006,
13045,
1007,
1063,
1013,
1013,
4895,
13088,
9331,
2003,
2025,
2800,
2006,
3080,
5628,
1006,
1017,
1012,
1019,
1998... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | dist/howler.js | function(event) {
var self = this;
if (self._queue.length > 0) {
var task = self._queue[0];
// Remove this task if a matching event was passed.
if (task.event === event) {
self._queue.shift();
self._loadQueue();
}
// Run the task if no event type is passed.
if (!event) {
task.action();
}
}
return self;
} | javascript | function(event) {
var self = this;
if (self._queue.length > 0) {
var task = self._queue[0];
// Remove this task if a matching event was passed.
if (task.event === event) {
self._queue.shift();
self._loadQueue();
}
// Run the task if no event type is passed.
if (!event) {
task.action();
}
}
return self;
} | [
"function",
"(",
"event",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"_queue",
".",
"length",
">",
"0",
")",
"{",
"var",
"task",
"=",
"self",
".",
"_queue",
"[",
"0",
"]",
";",
"// Remove this task if a matching event was passed."... | Queue of actions initiated before the sound has loaded.
These will be called in sequence, with the next only firing
after the previous has finished executing (even if async like play).
@return {Howl} | [
"Queue",
"of",
"actions",
"initiated",
"before",
"the",
"sound",
"has",
"loaded",
".",
"These",
"will",
"be",
"called",
"in",
"sequence",
"with",
"the",
"next",
"only",
"firing",
"after",
"the",
"previous",
"has",
"finished",
"executing",
"(",
"even",
"if",
... | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1879-L1898 | train | Run the next task in the queue | [
30522,
3853,
1006,
2724,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
2969,
1012,
1035,
24240,
1012,
3091,
1028,
1014,
1007,
1063,
13075,
4708,
1027,
2969,
1012,
1035,
24240,
1031,
1014,
1033,
1025,
1013,
1013,
6366,
2023,
4708,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.m/src/sap/m/library.js | checkAndSetProperty | function checkAndSetProperty(oControl, property, value) {
if (value !== undefined) {
var fSetter = oControl['set' + capitalize(property)];
if (typeof (fSetter) === "function") {
fSetter.call(oControl, value);
return true;
}
}
return false;
} | javascript | function checkAndSetProperty(oControl, property, value) {
if (value !== undefined) {
var fSetter = oControl['set' + capitalize(property)];
if (typeof (fSetter) === "function") {
fSetter.call(oControl, value);
return true;
}
}
return false;
} | [
"function",
"checkAndSetProperty",
"(",
"oControl",
",",
"property",
",",
"value",
")",
"{",
"if",
"(",
"value",
"!==",
"undefined",
")",
"{",
"var",
"fSetter",
"=",
"oControl",
"[",
"'set'",
"+",
"capitalize",
"(",
"property",
")",
"]",
";",
"if",
"(",
... | Checks if value is not undefined, in which case the
setter function for a given property is called.
Returns true if value is set, false otherwise.
@private | [
"Checks",
"if",
"value",
"is",
"not",
"undefined",
"in",
"which",
"case",
"the",
"setter",
"function",
"for",
"a",
"given",
"property",
"is",
"called",
".",
"Returns",
"true",
"if",
"value",
"is",
"set",
"false",
"otherwise",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/library.js#L4289-L4298 | train | Sets the value of a property on the control | [
30522,
3853,
4638,
29560,
3388,
21572,
4842,
3723,
1006,
1051,
8663,
13181,
2140,
1010,
3200,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
999,
1027,
1027,
6151,
28344,
1007,
1063,
13075,
1042,
21678,
2121,
1027,
1051,
8663,
13181,
2140,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/shaders/flat.js | getMaterialData | function getMaterialData (data, materialData) {
materialData.color.set(data.color);
materialData.fog = data.fog;
materialData.wireframe = data.wireframe;
materialData.wireframeLinewidth = data.wireframeLinewidth;
return materialData;
} | javascript | function getMaterialData (data, materialData) {
materialData.color.set(data.color);
materialData.fog = data.fog;
materialData.wireframe = data.wireframe;
materialData.wireframeLinewidth = data.wireframeLinewidth;
return materialData;
} | [
"function",
"getMaterialData",
"(",
"data",
",",
"materialData",
")",
"{",
"materialData",
".",
"color",
".",
"set",
"(",
"data",
".",
"color",
")",
";",
"materialData",
".",
"fog",
"=",
"data",
".",
"fog",
";",
"materialData",
".",
"wireframe",
"=",
"da... | Builds and normalize material data, normalizing stuff along the way.
@param {object} data - Material data.
@param {object} materialData - Object to reuse.
@returns {object} Updated material data. | [
"Builds",
"and",
"normalize",
"material",
"data",
"normalizing",
"stuff",
"along",
"the",
"way",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/shaders/flat.js#L62-L68 | train | Get material data | [
30522,
3853,
2131,
8585,
14482,
2850,
2696,
1006,
2951,
1010,
3430,
2850,
2696,
1007,
1063,
3430,
2850,
2696,
1012,
3609,
1012,
2275,
1006,
2951,
1012,
3609,
1007,
1025,
3430,
2850,
2696,
1012,
9666,
1027,
2951,
1012,
9666,
1025,
3430,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js | _send | function _send(msg, clients) {
var id = _nextMsgId++,
result = new $.Deferred();
// broadcast if there are no specific clients
clients = clients || getConnectionIds();
msg.id = id;
_responseDeferreds[id] = result;
_transport.send(clients, JSON.stringify(msg));
return result.promise();
} | javascript | function _send(msg, clients) {
var id = _nextMsgId++,
result = new $.Deferred();
// broadcast if there are no specific clients
clients = clients || getConnectionIds();
msg.id = id;
_responseDeferreds[id] = result;
_transport.send(clients, JSON.stringify(msg));
return result.promise();
} | [
"function",
"_send",
"(",
"msg",
",",
"clients",
")",
"{",
"var",
"id",
"=",
"_nextMsgId",
"++",
",",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// broadcast if there are no specific clients",
"clients",
"=",
"clients",
"||",
"getConnectionIds... | @private
Dispatches a message to the remote protocol handler via the transport.
@param {Object} msg The message to send.
@param {number|Array.<number>} idOrArray ID or IDs of the client(s) that should
receive the message.
@return {$.Promise} A promise that's fulfilled when the response to the message is received. | [
"@private",
"Dispatches",
"a",
"message",
"to",
"the",
"remote",
"protocol",
"handler",
"via",
"the",
"transport",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js#L137-L147 | train | send a message to a set of clients | [
30522,
3853,
1035,
4604,
1006,
5796,
2290,
1010,
7846,
1007,
1063,
13075,
8909,
1027,
1035,
2279,
5244,
5856,
2094,
1009,
1009,
1010,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
1013,
1013,
3743,
2065,
2045,
2024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(objects) {
var ret = {};
for(var i=0; i<arguments.length; i++) {
var o = arguments[i];
for(var j in o) {
ret[j] = o[j];
}
}
return ret;
} | javascript | function(objects) {
var ret = {};
for(var i=0; i<arguments.length; i++) {
var o = arguments[i];
for(var j in o) {
ret[j] = o[j];
}
}
return ret;
} | [
"function",
"(",
"objects",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"o",
"=",
"arguments",
"[",
"i",
"]",
";",
"for",
"(",
"va... | Copies the properties of one object onto another.
When there is a collision, the later one wins
@return {Object} destination object | [
"Copies",
"the",
"properties",
"of",
"one",
"object",
"onto",
"another",
".",
"When",
"there",
"is",
"a",
"collision",
"the",
"later",
"one",
"wins"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L112-L124 | train | Returns an object containing the properties of the specified objects. | [
30522,
3853,
1006,
5200,
1007,
1063,
13075,
2128,
2102,
1027,
1063,
1065,
1025,
2005,
1006,
13075,
1045,
30524,
1031,
1045,
1033,
1025,
2005,
1006,
13075,
1046,
1999,
1051,
1007,
1063,
2128,
2102,
1031,
1046,
1033,
1027,
1051,
1031,
1046,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
exceljs/exceljs | lib/doc/worksheet.js | addImageToCells | function addImageToCells(imageId, range) {
const model = {
type: 'image',
imageId,
range,
};
this._media.push(new Image(this, model));
} | javascript | function addImageToCells(imageId, range) {
const model = {
type: 'image',
imageId,
range,
};
this._media.push(new Image(this, model));
} | [
"function",
"addImageToCells",
"(",
"imageId",
",",
"range",
")",
"{",
"const",
"model",
"=",
"{",
"type",
":",
"'image'",
",",
"imageId",
",",
"range",
",",
"}",
";",
"this",
".",
"_media",
".",
"push",
"(",
"new",
"Image",
"(",
"this",
",",
"model"... | ========================================================================= Images | [
"=========================================================================",
"Images"
] | c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2 | https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/doc/worksheet.js#L537-L544 | train | Add an image to the cells | [
30522,
3853,
5587,
9581,
18150,
10085,
5349,
2015,
1006,
3746,
3593,
1010,
2846,
1007,
1063,
9530,
3367,
2944,
1027,
1063,
2828,
1024,
1005,
3746,
1005,
1010,
3746,
3593,
1010,
2846,
1010,
1065,
1025,
2023,
1012,
1035,
2865,
1012,
5245,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/dom/jquery/parentByAttribute.js | parentByAttribute | function parentByAttribute(sAttribute, sValue) {
if (this.length > 0) {
if (sValue) {
return this.first().parents("[" + sAttribute + "='" + sValue + "']").get(0);
} else {
return this.first().parents("[" + sAttribute + "]").get(0);
}
}
} | javascript | function parentByAttribute(sAttribute, sValue) {
if (this.length > 0) {
if (sValue) {
return this.first().parents("[" + sAttribute + "='" + sValue + "']").get(0);
} else {
return this.first().parents("[" + sAttribute + "]").get(0);
}
}
} | [
"function",
"parentByAttribute",
"(",
"sAttribute",
",",
"sValue",
")",
"{",
"if",
"(",
"this",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"sValue",
")",
"{",
"return",
"this",
".",
"first",
"(",
")",
".",
"parents",
"(",
"\"[\"",
"+",
"sAttribute... | This module provides the {@link jQuery#parentByAttribute} API.
@namespace
@name module:sap/ui/dom/jquery/parentByAttribute
@public
@since 1.58
Gets the next parent DOM element with a given attribute and attribute value starting above the first given element
@param {string} sAttribute Name of the attribute
@param {string} sValue Value of the attribute (optional)
@return {Element} null or the DOM reference
@public
@name jQuery#parentByAttribute
@author SAP SE
@since 0.9.0
@function
@requires module:sap/ui/dom/jquery/parentByAttribute | [
"This",
"module",
"provides",
"the",
"{",
"@link",
"jQuery#parentByAttribute",
"}",
"API",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/jquery/parentByAttribute.js#L29-L37 | train | Returns the parent of the first node with the given attribute and value | [
30522,
3853,
6687,
3762,
19321,
3089,
8569,
2618,
1006,
2938,
18886,
8569,
30524,
1014,
1007,
1063,
2065,
1006,
17917,
2389,
5657,
1007,
1063,
2709,
2023,
1012,
2034,
1006,
1007,
1012,
3008,
1006,
1000,
1031,
1000,
1009,
2938,
18886,
8569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/watchman | node/index.js | vers_compare | function vers_compare(a, b) {
a = a.split('.');
b = b.split('.');
for (var i = 0; i < 3; i++) {
var d = parseInt(a[i] || '0') - parseInt(b[i] || '0');
if (d != 0) {
return d;
}
}
return 0; // Equal
} | javascript | function vers_compare(a, b) {
a = a.split('.');
b = b.split('.');
for (var i = 0; i < 3; i++) {
var d = parseInt(a[i] || '0') - parseInt(b[i] || '0');
if (d != 0) {
return d;
}
}
return 0; // Equal
} | [
"function",
"vers_compare",
"(",
"a",
",",
"b",
")",
"{",
"a",
"=",
"a",
".",
"split",
"(",
"'.'",
")",
";",
"b",
"=",
"b",
".",
"split",
"(",
"'.'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"... | Compares a vs b, returns < 0 if a < b, > 0 if b > b, 0 if a == b | [
"Compares",
"a",
"vs",
"b",
"returns",
"<",
"0",
"if",
"a",
"<",
"b",
">",
"0",
"if",
"b",
">",
"b",
"0",
"if",
"a",
"==",
"b"
] | 8d576a2d3e1191c977f03f584993da63a3b8e5ec | https://github.com/facebook/watchman/blob/8d576a2d3e1191c977f03f584993da63a3b8e5ec/node/index.js#L249-L259 | train | Compare two vers_list | [
30522,
3853,
2310,
2869,
1035,
12826,
1006,
1037,
1010,
1038,
1007,
1063,
1037,
1027,
1037,
1012,
3975,
1006,
1005,
1012,
1005,
1007,
1025,
1038,
1027,
1038,
1012,
3975,
1006,
1005,
1012,
1005,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | examples/mapbox-vector-tiles-advanced.js | tileUrlFunction | function tileUrlFunction(tileCoord) {
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
.replace('{z}', String(tileCoord[0] * 2 - 1))
.replace('{x}', String(tileCoord[1]))
.replace('{y}', String(tileCoord[2]))
.replace('{a-d}', 'abcd'.substr(
((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1));
} | javascript | function tileUrlFunction(tileCoord) {
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
.replace('{z}', String(tileCoord[0] * 2 - 1))
.replace('{x}', String(tileCoord[1]))
.replace('{y}', String(tileCoord[2]))
.replace('{a-d}', 'abcd'.substr(
((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1));
} | [
"function",
"tileUrlFunction",
"(",
"tileCoord",
")",
"{",
"return",
"(",
"'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/'",
"+",
"'{z}/{x}/{y}.vector.pbf?access_token='",
"+",
"key",
")",
".",
"replace",
"(",
"'{z}'",
",",
"String",
"(",
"tileCoord",
"[",
... | Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15. | [
"Calculation",
"of",
"tile",
"urls",
"for",
"zoom",
"levels",
"1",
"3",
"5",
"7",
"9",
"11",
"13",
"15",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/mapbox-vector-tiles-advanced.js#L19-L27 | train | Returns a url function for a tile | [
30522,
3853,
14090,
3126,
10270,
4609,
7542,
1006,
14090,
3597,
8551,
1007,
1063,
2709,
1006,
1005,
16770,
1024,
1013,
1013,
1063,
1037,
1011,
1040,
1065,
1012,
13262,
1012,
4949,
8758,
1012,
4012,
1013,
1058,
2549,
1013,
4949,
8758,
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... |
apache/incubator-echarts | src/chart/themeRiver/themeRiverLayout.js | computeBaseline | function computeBaseline(data) {
var layerNum = data.length;
var pointNum = data[0].length;
var sums = [];
var y0 = [];
var max = 0;
var temp;
var base = {};
for (var i = 0; i < pointNum; ++i) {
for (var j = 0, temp = 0; j < layerNum; ++j) {
temp += data[j][i][1];
}
if (temp > max) {
max = temp;
}
sums.push(temp);
}
for (var k = 0; k < pointNum; ++k) {
y0[k] = (max - sums[k]) / 2;
}
max = 0;
for (var l = 0; l < pointNum; ++l) {
var sum = sums[l] + y0[l];
if (sum > max) {
max = sum;
}
}
base.y0 = y0;
base.max = max;
return base;
} | javascript | function computeBaseline(data) {
var layerNum = data.length;
var pointNum = data[0].length;
var sums = [];
var y0 = [];
var max = 0;
var temp;
var base = {};
for (var i = 0; i < pointNum; ++i) {
for (var j = 0, temp = 0; j < layerNum; ++j) {
temp += data[j][i][1];
}
if (temp > max) {
max = temp;
}
sums.push(temp);
}
for (var k = 0; k < pointNum; ++k) {
y0[k] = (max - sums[k]) / 2;
}
max = 0;
for (var l = 0; l < pointNum; ++l) {
var sum = sums[l] + y0[l];
if (sum > max) {
max = sum;
}
}
base.y0 = y0;
base.max = max;
return base;
} | [
"function",
"computeBaseline",
"(",
"data",
")",
"{",
"var",
"layerNum",
"=",
"data",
".",
"length",
";",
"var",
"pointNum",
"=",
"data",
"[",
"0",
"]",
".",
"length",
";",
"var",
"sums",
"=",
"[",
"]",
";",
"var",
"y0",
"=",
"[",
"]",
";",
"var"... | Compute the baseLine of the rawdata
Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
@param {Array.<Array>} data the points in each layer
@return {Object} | [
"Compute",
"the",
"baseLine",
"of",
"the",
"rawdata",
"Inspired",
"by",
"Lee",
"Byron",
"s",
"paper",
"Stacked",
"Graphs",
"-",
"Geometry",
"&",
"Aesthetics"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/themeRiver/themeRiverLayout.js#L127-L161 | train | Computes the baseline of the given data | [
30522,
3853,
24134,
15058,
4179,
1006,
2951,
1007,
1063,
13075,
6741,
19172,
1027,
2951,
1012,
3091,
1025,
13075,
2391,
19172,
1027,
2951,
1031,
1014,
1033,
1012,
3091,
1025,
13075,
20571,
1027,
1031,
1033,
1025,
13075,
1061,
2692,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js | function (sQuery) {
// add filter for search
var aFilters = [];
if (sQuery && sQuery.length > 0) {
aFilters = new Filter({
filters: [
new Filter("name", FilterOperator.Contains, sQuery),
new Filter("fileType", FilterOperator.Contains, sQuery)
],
and: false
});
}
// update list binding
var oList = this.byId("masterComponentsList");
var oBinding = oList.getBinding("items");
oBinding.filter(aFilters, "content");
} | javascript | function (sQuery) {
// add filter for search
var aFilters = [];
if (sQuery && sQuery.length > 0) {
aFilters = new Filter({
filters: [
new Filter("name", FilterOperator.Contains, sQuery),
new Filter("fileType", FilterOperator.Contains, sQuery)
],
and: false
});
}
// update list binding
var oList = this.byId("masterComponentsList");
var oBinding = oList.getBinding("items");
oBinding.filter(aFilters, "content");
} | [
"function",
"(",
"sQuery",
")",
"{",
"// add filter for search",
"var",
"aFilters",
"=",
"[",
"]",
";",
"if",
"(",
"sQuery",
"&&",
"sQuery",
".",
"length",
">",
"0",
")",
"{",
"aFilters",
"=",
"new",
"Filter",
"(",
"{",
"filters",
":",
"[",
"new",
"F... | Filters the binding of the master list;
This function is also called once navigation to the page to clear the filters or input search entry.
@param {String} sQuery - entered string within the search field
@public | [
"Filters",
"the",
"binding",
"of",
"the",
"master",
"list",
";",
"This",
"function",
"is",
"also",
"called",
"once",
"navigation",
"to",
"the",
"page",
"to",
"clear",
"the",
"filters",
"or",
"input",
"search",
"entry",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js#L96-L113 | train | search for all items in the master components list | [
30522,
3853,
1006,
5490,
13094,
2100,
1007,
1063,
1013,
1013,
5587,
11307,
2005,
3945,
13075,
28697,
21928,
2015,
1027,
1031,
1033,
1025,
2065,
1006,
5490,
13094,
2100,
1004,
1004,
5490,
13094,
2100,
1012,
3091,
1028,
1014,
1007,
1063,
2869... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | detachElement | function detachElement(element, opts) {
if (!opts.preserveElement) {
if (toNode(element).parentNode === toNode(opts.parent)) {
toNode(opts.parent).removeChild(toNode(element));
}
} else {
toNode(element).style.display = 'none';
}
} | javascript | function detachElement(element, opts) {
if (!opts.preserveElement) {
if (toNode(element).parentNode === toNode(opts.parent)) {
toNode(opts.parent).removeChild(toNode(element));
}
} else {
toNode(element).style.display = 'none';
}
} | [
"function",
"detachElement",
"(",
"element",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"opts",
".",
"preserveElement",
")",
"{",
"if",
"(",
"toNode",
"(",
"element",
")",
".",
"parentNode",
"===",
"toNode",
"(",
"opts",
".",
"parent",
")",
")",
"{",
"to... | Use browser to remove this element without triggering a $destroy event | [
"Use",
"browser",
"to",
"remove",
"this",
"element",
"without",
"triggering",
"a",
"$destroy",
"event"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/menu/js/menuServiceProvider.js#L427-L435 | train | Detach an element from the page | [
30522,
3853,
20010,
15395,
16930,
4765,
1006,
5783,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
999,
23569,
2015,
1012,
7969,
12260,
30524,
10228,
10244,
1006,
5783,
1007,
1012,
6687,
3630,
3207,
1027,
1027,
1027,
10228,
10244,
1006,
23569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
serverless/serverless | lib/utils/config/index.js | set | function set(key, value) {
let config = getGlobalConfig();
if (key && typeof key === 'string' && typeof value !== 'undefined') {
config = _.set(config, key, value);
} else if (_.isObject(key)) {
config = _.merge(config, key);
} else if (typeof value !== 'undefined') {
config = _.merge(config, value);
}
// update config meta
config.meta = config.meta || {};
config.meta.updated_at = Math.round(+new Date() / 1000);
// write to .serverlessrc file
writeFileAtomic.sync(serverlessrcPath, JSON.stringify(config, null, 2));
return config;
} | javascript | function set(key, value) {
let config = getGlobalConfig();
if (key && typeof key === 'string' && typeof value !== 'undefined') {
config = _.set(config, key, value);
} else if (_.isObject(key)) {
config = _.merge(config, key);
} else if (typeof value !== 'undefined') {
config = _.merge(config, value);
}
// update config meta
config.meta = config.meta || {};
config.meta.updated_at = Math.round(+new Date() / 1000);
// write to .serverlessrc file
writeFileAtomic.sync(serverlessrcPath, JSON.stringify(config, null, 2));
return config;
} | [
"function",
"set",
"(",
"key",
",",
"value",
")",
"{",
"let",
"config",
"=",
"getGlobalConfig",
"(",
")",
";",
"if",
"(",
"key",
"&&",
"typeof",
"key",
"===",
"'string'",
"&&",
"typeof",
"value",
"!==",
"'undefined'",
")",
"{",
"config",
"=",
"_",
".... | set global .serverlessrc config value. | [
"set",
"global",
".",
"serverlessrc",
"config",
"value",
"."
] | 0626d5b5df06e4ed68969e324f1cb6b1b499c443 | https://github.com/serverless/serverless/blob/0626d5b5df06e4ed68969e324f1cb6b1b499c443/lib/utils/config/index.js#L66-L81 | train | Set the config | [
30522,
3853,
2275,
1006,
3145,
1010,
3643,
1007,
1063,
2292,
9530,
8873,
2290,
1027,
2131,
23296,
16429,
2389,
8663,
8873,
2290,
1006,
1007,
1025,
2065,
1006,
3145,
1004,
1004,
2828,
11253,
3145,
1027,
1027,
1027,
1005,
5164,
1005,
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... |
goldfire/howler.js | examples/sprite/sprite.js | function() {
var self = this;
// Loop through all active sounds and update their progress bar.
for (var i=0; i<self.sounds.length; i++) {
var id = parseInt(self.sounds[i].id, 10);
var offset = self._sprite[self.sounds[i].dataset.sprite][0];
var seek = (self.sound.seek(id) || 0) - (offset / 1000);
self.sounds[i].style.width = (((seek / self.sound.duration(id)) * 100) || 0) + '%';
}
requestAnimationFrame(self.step.bind(self));
} | javascript | function() {
var self = this;
// Loop through all active sounds and update their progress bar.
for (var i=0; i<self.sounds.length; i++) {
var id = parseInt(self.sounds[i].id, 10);
var offset = self._sprite[self.sounds[i].dataset.sprite][0];
var seek = (self.sound.seek(id) || 0) - (offset / 1000);
self.sounds[i].style.width = (((seek / self.sound.duration(id)) * 100) || 0) + '%';
}
requestAnimationFrame(self.step.bind(self));
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Loop through all active sounds and update their progress bar.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"self",
".",
"sounds",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"id",
... | The step called within requestAnimationFrame to update the playback positions. | [
"The",
"step",
"called",
"within",
"requestAnimationFrame",
"to",
"update",
"the",
"playback",
"positions",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/sprite/sprite.js#L115-L127 | train | Update the progress bar | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
7077,
2083,
2035,
3161,
4165,
1998,
10651,
2037,
5082,
3347,
1012,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2969,
1012,
4165,
1012,
3091,
1025,
1045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | function(sScale, iDiff, bFuture, sStyle) {
var sPattern, oTypes, sKey, sPluralCategory;
if (typeof bFuture === "string") {
sStyle = bFuture;
bFuture = undefined;
}
if (bFuture === undefined) {
bFuture = iDiff > 0;
}
if (sStyle === undefined) {
sStyle = "wide";
}
assert(sStyle === "wide" || sStyle === "short" || sStyle === "narrow", "sStyle is only allowed to be set with 'wide', 'short' or 'narrow'");
sKey = sScale + "-" + sStyle;
if (iDiff === 0 || iDiff === -2 || iDiff === 2) {
sPattern = this._get("dateFields", sKey, "relative-type-" + iDiff);
}
if (!sPattern) {
oTypes = this._get("dateFields", sKey, "relativeTime-type-" + (bFuture ? "future" : "past"));
sPluralCategory = this.getPluralCategory(Math.abs(iDiff).toString());
sPattern = oTypes["relativeTimePattern-count-" + sPluralCategory];
}
return sPattern;
} | javascript | function(sScale, iDiff, bFuture, sStyle) {
var sPattern, oTypes, sKey, sPluralCategory;
if (typeof bFuture === "string") {
sStyle = bFuture;
bFuture = undefined;
}
if (bFuture === undefined) {
bFuture = iDiff > 0;
}
if (sStyle === undefined) {
sStyle = "wide";
}
assert(sStyle === "wide" || sStyle === "short" || sStyle === "narrow", "sStyle is only allowed to be set with 'wide', 'short' or 'narrow'");
sKey = sScale + "-" + sStyle;
if (iDiff === 0 || iDiff === -2 || iDiff === 2) {
sPattern = this._get("dateFields", sKey, "relative-type-" + iDiff);
}
if (!sPattern) {
oTypes = this._get("dateFields", sKey, "relativeTime-type-" + (bFuture ? "future" : "past"));
sPluralCategory = this.getPluralCategory(Math.abs(iDiff).toString());
sPattern = oTypes["relativeTimePattern-count-" + sPluralCategory];
}
return sPattern;
} | [
"function",
"(",
"sScale",
",",
"iDiff",
",",
"bFuture",
",",
"sStyle",
")",
"{",
"var",
"sPattern",
",",
"oTypes",
",",
"sKey",
",",
"sPluralCategory",
";",
"if",
"(",
"typeof",
"bFuture",
"===",
"\"string\"",
")",
"{",
"sStyle",
"=",
"bFuture",
";",
... | Returns the relative format pattern with given scale (year, month, week, ...) and difference value.
@param {string} sScale the scale the relative pattern is needed for
@param {int} iDiff the difference in the given scale unit
@param {boolean} [bFuture] whether a future or past pattern should be used
@param {string} [sStyle="wide"] @since 1.32.10, 1.34.4 the style of the pattern. The valid values are "wide", "short" and "narrow"
@returns {string} the relative format pattern
@public
@since 1.34 | [
"Returns",
"the",
"relative",
"format",
"pattern",
"with",
"given",
"scale",
"(",
"year",
"month",
"week",
"...",
")",
"and",
"difference",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L1140-L1171 | train | Returns the pattern for the given relative time type | [
30522,
3853,
1006,
7020,
9289,
2063,
1010,
8909,
13355,
1010,
28939,
4904,
5397,
1010,
7020,
27983,
1007,
1063,
13075,
14690,
16451,
1010,
27178,
18863,
2015,
1010,
15315,
3240,
1010,
11867,
7630,
7941,
16280,
20255,
2100,
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... | |
openlayers/openlayers | examples/animation.js | elastic | function elastic(t) {
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
} | javascript | function elastic(t) {
return Math.pow(2, -10 * t) * Math.sin((t - 0.075) * (2 * Math.PI) / 0.3) + 1;
} | [
"function",
"elastic",
"(",
"t",
")",
"{",
"return",
"Math",
".",
"pow",
"(",
"2",
",",
"-",
"10",
"*",
"t",
")",
"*",
"Math",
".",
"sin",
"(",
"(",
"t",
"-",
"0.075",
")",
"*",
"(",
"2",
"*",
"Math",
".",
"PI",
")",
"/",
"0.3",
")",
"+",... | An elastic easing method (from https://github.com/DmitryBaranovskiy/raphael). | [
"An",
"elastic",
"easing",
"method",
"(",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"DmitryBaranovskiy",
"/",
"raphael",
")",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/animation.js#L55-L57 | train | returns the elastic distance from t | [
30522,
3853,
21274,
1006,
1056,
1007,
1063,
2709,
8785,
1012,
23776,
1006,
1016,
1010,
1011,
2184,
1008,
1056,
1007,
1008,
8785,
1012,
8254,
1006,
1006,
1056,
1011,
1014,
1012,
5718,
2629,
1007,
1008,
1006,
1016,
1008,
8785,
1012,
14255,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ToolsAPI.js | function (control) {
var properties = control.getMetadata().getAllProperties();
var propertiesBindingData = Object.create(null);
for (var key in properties) {
if (properties.hasOwnProperty(key) && control.getBinding(key)) {
propertiesBindingData[key] = Object.create(null);
propertiesBindingData[key].path = control.getBinding(key).getPath();
propertiesBindingData[key].value = control.getBinding(key).getValue();
propertiesBindingData[key].type = control.getMetadata().getProperty(key).getType().getName ? control.getMetadata().getProperty(key).getType().getName() : '';
propertiesBindingData[key].mode = control.getBinding(key).getBindingMode();
propertiesBindingData[key].model = this._getModelFromContext(control, key);
}
}
return propertiesBindingData;
} | javascript | function (control) {
var properties = control.getMetadata().getAllProperties();
var propertiesBindingData = Object.create(null);
for (var key in properties) {
if (properties.hasOwnProperty(key) && control.getBinding(key)) {
propertiesBindingData[key] = Object.create(null);
propertiesBindingData[key].path = control.getBinding(key).getPath();
propertiesBindingData[key].value = control.getBinding(key).getValue();
propertiesBindingData[key].type = control.getMetadata().getProperty(key).getType().getName ? control.getMetadata().getProperty(key).getType().getName() : '';
propertiesBindingData[key].mode = control.getBinding(key).getBindingMode();
propertiesBindingData[key].model = this._getModelFromContext(control, key);
}
}
return propertiesBindingData;
} | [
"function",
"(",
"control",
")",
"{",
"var",
"properties",
"=",
"control",
".",
"getMetadata",
"(",
")",
".",
"getAllProperties",
"(",
")",
";",
"var",
"propertiesBindingData",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"for",
"(",
"var",
"key"... | Creates an object with the properties bindings of a UI5 control.
@param {Object} control
@returns {Object}
@private | [
"Creates",
"an",
"object",
"with",
"the",
"properties",
"bindings",
"of",
"a",
"UI5",
"control",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/ToolsAPI.js#L317-L333 | train | Returns the binding data for a control | [
30522,
3853,
1006,
2491,
1007,
1063,
13075,
5144,
1027,
2491,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1012,
2131,
8095,
21572,
4842,
7368,
1006,
1007,
1025,
13075,
5144,
8428,
4667,
2850,
2696,
1027,
4874,
1012,
3443,
1006,
19701,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/NodeConnection.js | function () { // failed this attempt, possibly try again
if (attemptCount < CONNECTION_ATTEMPTS) { //try again
// Calculate how long we should wait before trying again
var now = new Date();
var delay = Math.max(
RETRY_DELAY - (now - attemptTimestamp),
1
);
setTimeout(doConnect, delay);
} else { // too many attempts, give up
deferred.reject("Max connection attempts reached");
}
} | javascript | function () { // failed this attempt, possibly try again
if (attemptCount < CONNECTION_ATTEMPTS) { //try again
// Calculate how long we should wait before trying again
var now = new Date();
var delay = Math.max(
RETRY_DELAY - (now - attemptTimestamp),
1
);
setTimeout(doConnect, delay);
} else { // too many attempts, give up
deferred.reject("Max connection attempts reached");
}
} | [
"function",
"(",
")",
"{",
"// failed this attempt, possibly try again",
"if",
"(",
"attemptCount",
"<",
"CONNECTION_ATTEMPTS",
")",
"{",
"//try again",
"// Calculate how long we should wait before trying again",
"var",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"... | succeded | [
"succeded"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/NodeConnection.js#L305-L317 | train | If we have too many attempts to connect then give up | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
3478,
2023,
3535,
1010,
4298,
3046,
2153,
2065,
1006,
3535,
3597,
16671,
1026,
4434,
1035,
4740,
1007,
1063,
1013,
1013,
3046,
2153,
1013,
1013,
18422,
2129,
2146,
2057,
2323,
3524,
2077,
2667,
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... | |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | processLeaves | function processLeaves(leaf) {
/**
* Get an array of the mark types, converted to their MDAST equivalent
* types.
*/
const { marks = [], text } = leaf;
const markTypes = marks.map(mark => markMap[mark.type]);
if (typeof leaf.text === 'string') {
/**
* Code marks must be removed from the marks array, and the presence of a
* code mark changes the text node type that should be used.
*/
const { filteredMarkTypes, textNodeType } = processCodeMark(markTypes);
return { text, marks: filteredMarkTypes, textNodeType };
}
return { node: leaf.node, marks: markTypes };
} | javascript | function processLeaves(leaf) {
/**
* Get an array of the mark types, converted to their MDAST equivalent
* types.
*/
const { marks = [], text } = leaf;
const markTypes = marks.map(mark => markMap[mark.type]);
if (typeof leaf.text === 'string') {
/**
* Code marks must be removed from the marks array, and the presence of a
* code mark changes the text node type that should be used.
*/
const { filteredMarkTypes, textNodeType } = processCodeMark(markTypes);
return { text, marks: filteredMarkTypes, textNodeType };
}
return { node: leaf.node, marks: markTypes };
} | [
"function",
"processLeaves",
"(",
"leaf",
")",
"{",
"/**\n * Get an array of the mark types, converted to their MDAST equivalent\n * types.\n */",
"const",
"{",
"marks",
"=",
"[",
"]",
",",
"text",
"}",
"=",
"leaf",
";",
"const",
"markTypes",
"=",
"marks",
".",
... | Process Slate node leaves in preparation for MDAST transformation. | [
"Process",
"Slate",
"node",
"leaves",
"in",
"preparation",
"for",
"MDAST",
"transformation",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L268-L286 | train | Process a leaf node. | [
30522,
3853,
2832,
19738,
6961,
1006,
7053,
1007,
1063,
1013,
1008,
1008,
1008,
2131,
2019,
9140,
1997,
1996,
2928,
4127,
1010,
4991,
2000,
2037,
9108,
14083,
5662,
1008,
4127,
1012,
1008,
1013,
9530,
3367,
1063,
6017,
1027,
1031,
1033,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (mChangeListeners, sPath, oOldObject, oNewObject) {
if (!oNewObject) {
return;
}
// iterate over all properties in the old object
Object.keys(oOldObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sPath, sProperty),
vOldProperty = oOldObject[sProperty],
vNewProperty;
if (sProperty in oNewObject || sProperty[0] === "#") {
// the property was patched
vNewProperty = oNewObject[sProperty];
if (vNewProperty && typeof vNewProperty === "object") {
if (Array.isArray(vNewProperty)) {
// copy complete collection; no change events as long as
// collection-valued properties are not supported
oOldObject[sProperty] = vNewProperty;
} else if (vOldProperty) {
// a structural property in cache and patch -> recursion
_Helper.updateExisting(mChangeListeners, sPropertyPath, vOldProperty,
vNewProperty);
} else {
// a structural property was added
oOldObject[sProperty] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty,
false);
}
} else if (vOldProperty && typeof vOldProperty === "object") {
// a structural property was removed
oOldObject[sProperty] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vOldProperty, true);
} else {
// a primitive property
oOldObject[sProperty] = vNewProperty;
if (vOldProperty !== vNewProperty) {
_Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty);
}
}
}
});
// iterate over all new advertised actions
Object.keys(oNewObject).filter(function (sProperty) {
return sProperty[0] === "#";
}).filter(function (sAdvertisedAction) {
return !(sAdvertisedAction in oOldObject);
}).forEach(function (sNewAdvertisedAction) {
var vNewProperty = oNewObject[sNewAdvertisedAction],
sPropertyPath = _Helper.buildPath(sPath, sNewAdvertisedAction);
// a structural property was added
oOldObject[sNewAdvertisedAction] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty, false);
});
} | javascript | function (mChangeListeners, sPath, oOldObject, oNewObject) {
if (!oNewObject) {
return;
}
// iterate over all properties in the old object
Object.keys(oOldObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sPath, sProperty),
vOldProperty = oOldObject[sProperty],
vNewProperty;
if (sProperty in oNewObject || sProperty[0] === "#") {
// the property was patched
vNewProperty = oNewObject[sProperty];
if (vNewProperty && typeof vNewProperty === "object") {
if (Array.isArray(vNewProperty)) {
// copy complete collection; no change events as long as
// collection-valued properties are not supported
oOldObject[sProperty] = vNewProperty;
} else if (vOldProperty) {
// a structural property in cache and patch -> recursion
_Helper.updateExisting(mChangeListeners, sPropertyPath, vOldProperty,
vNewProperty);
} else {
// a structural property was added
oOldObject[sProperty] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty,
false);
}
} else if (vOldProperty && typeof vOldProperty === "object") {
// a structural property was removed
oOldObject[sProperty] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vOldProperty, true);
} else {
// a primitive property
oOldObject[sProperty] = vNewProperty;
if (vOldProperty !== vNewProperty) {
_Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty);
}
}
}
});
// iterate over all new advertised actions
Object.keys(oNewObject).filter(function (sProperty) {
return sProperty[0] === "#";
}).filter(function (sAdvertisedAction) {
return !(sAdvertisedAction in oOldObject);
}).forEach(function (sNewAdvertisedAction) {
var vNewProperty = oNewObject[sNewAdvertisedAction],
sPropertyPath = _Helper.buildPath(sPath, sNewAdvertisedAction);
// a structural property was added
oOldObject[sNewAdvertisedAction] = vNewProperty;
_Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty, false);
});
} | [
"function",
"(",
"mChangeListeners",
",",
"sPath",
",",
"oOldObject",
",",
"oNewObject",
")",
"{",
"if",
"(",
"!",
"oNewObject",
")",
"{",
"return",
";",
"}",
"// iterate over all properties in the old object",
"Object",
".",
"keys",
"(",
"oOldObject",
")",
".",... | Updates the old object with the new object. Only existing properties of the old object
are updated. Fires change events for all changed properties. The function recursively
handles modified, added or removed structural properties and fires change events for all
modified/added/removed primitive properties therein. Collection-valued properties are
only updated in the old object, there are no change events for properties therein. Also
fires change events for new advertised actions.
@param {object} mChangeListeners A map of change listeners by path
@param {string} sPath The path of the old object in mChangeListeners
@param {object} oOldObject The old object
@param {object} [oNewObject] The new object | [
"Updates",
"the",
"old",
"object",
"with",
"the",
"new",
"object",
".",
"Only",
"existing",
"properties",
"of",
"the",
"old",
"object",
"are",
"updated",
".",
"Fires",
"change",
"events",
"for",
"all",
"changed",
"properties",
".",
"The",
"function",
"recurs... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L1118-L1174 | train | Updates the properties in the new object | [
30522,
3853,
1006,
11338,
18003,
29282,
6528,
2545,
1010,
14690,
2232,
1010,
1051,
11614,
16429,
20614,
1010,
2028,
12155,
2497,
20614,
1007,
1063,
2065,
1006,
999,
2028,
12155,
2497,
20614,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
2009,
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... | |
wangfupeng1988/wangEditor | src/js/text/index.js | function () {
const editor = this.editor
const $textElem = editor.$textElem
// 保存当前的选区
function saveRange(e) {
// 随时保存选区
editor.selection.saveRange()
// 更新按钮 ative 状态
editor.menus.changeActive()
}
// 按键后保存
$textElem.on('keyup', saveRange)
$textElem.on('mousedown', e => {
// mousedown 状态下,鼠标滑动到编辑区域外面,也需要保存选区
$textElem.on('mouseleave', saveRange)
})
$textElem.on('mouseup', e => {
saveRange()
// 在编辑器区域之内完成点击,取消鼠标滑动到编辑区外面的事件
$textElem.off('mouseleave', saveRange)
})
} | javascript | function () {
const editor = this.editor
const $textElem = editor.$textElem
// 保存当前的选区
function saveRange(e) {
// 随时保存选区
editor.selection.saveRange()
// 更新按钮 ative 状态
editor.menus.changeActive()
}
// 按键后保存
$textElem.on('keyup', saveRange)
$textElem.on('mousedown', e => {
// mousedown 状态下,鼠标滑动到编辑区域外面,也需要保存选区
$textElem.on('mouseleave', saveRange)
})
$textElem.on('mouseup', e => {
saveRange()
// 在编辑器区域之内完成点击,取消鼠标滑动到编辑区外面的事件
$textElem.off('mouseleave', saveRange)
})
} | [
"function",
"(",
")",
"{",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"$textElem",
"=",
"editor",
".",
"$textElem",
"// 保存当前的选区",
"function",
"saveRange",
"(",
"e",
")",
"{",
"// 随时保存选区",
"editor",
".",
"selection",
".",
"saveRange",
"(",
")",... | 实时保存选取 | [
"实时保存选取"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/text/index.js#L148-L170 | train | Initialize the keypress events | [
30522,
3853,
1006,
1007,
1063,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
1002,
3793,
12260,
2213,
1027,
3559,
1012,
1002,
3793,
12260,
2213,
1013,
1013,
1766,
100,
100,
1776,
1916,
100,
1782,
3853,
3828,
24388,
2063,
1006,
104... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
grpc/grpc-node | packages/grpc-native-core/src/server.js | sendUnaryResponse | function sendUnaryResponse(call, value, serialize, metadata, flags) {
var end_batch = {};
var statusMetadata = new Metadata();
var status = {
code: constants.status.OK,
details: 'OK'
};
if (metadata) {
statusMetadata = metadata;
}
var message;
try {
message = serialize(value);
} catch (e) {
e.code = constants.status.INTERNAL;
handleError(call, e);
return;
}
status.metadata = statusMetadata._getCoreRepresentation();
if (!call.metadataSent) {
end_batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
call.metadataSent = true;
}
message.grpcWriteFlags = flags;
end_batch[grpc.opType.SEND_MESSAGE] = message;
end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
call.startBatch(end_batch, function (){});
} | javascript | function sendUnaryResponse(call, value, serialize, metadata, flags) {
var end_batch = {};
var statusMetadata = new Metadata();
var status = {
code: constants.status.OK,
details: 'OK'
};
if (metadata) {
statusMetadata = metadata;
}
var message;
try {
message = serialize(value);
} catch (e) {
e.code = constants.status.INTERNAL;
handleError(call, e);
return;
}
status.metadata = statusMetadata._getCoreRepresentation();
if (!call.metadataSent) {
end_batch[grpc.opType.SEND_INITIAL_METADATA] =
(new Metadata())._getCoreRepresentation();
call.metadataSent = true;
}
message.grpcWriteFlags = flags;
end_batch[grpc.opType.SEND_MESSAGE] = message;
end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
call.startBatch(end_batch, function (){});
} | [
"function",
"sendUnaryResponse",
"(",
"call",
",",
"value",
",",
"serialize",
",",
"metadata",
",",
"flags",
")",
"{",
"var",
"end_batch",
"=",
"{",
"}",
";",
"var",
"statusMetadata",
"=",
"new",
"Metadata",
"(",
")",
";",
"var",
"status",
"=",
"{",
"c... | Send a response to a unary or client streaming call.
@private
@param {grpc.Call} call The call to respond on
@param {*} value The value to respond with
@param {grpc~serialize} serialize Serialization function for the
response
@param {grpc.Metadata=} metadata Optional trailing metadata to send with
status
@param {number=} [flags=0] Flags for modifying how the message is sent. | [
"Send",
"a",
"response",
"to",
"a",
"unary",
"or",
"client",
"streaming",
"call",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L83-L111 | train | Sends an unary response to the specified call. | [
30522,
3853,
4604,
9521,
2854,
6072,
26029,
3366,
1006,
2655,
30524,
3570,
1012,
7929,
1010,
4751,
1024,
1005,
7929,
1005,
1065,
1025,
2065,
1006,
27425,
1007,
1063,
3570,
11368,
8447,
2696,
1027,
27425,
1025,
1065,
13075,
4471,
1025,
3046,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/input/input.js | calculateInputValueLength | function calculateInputValueLength(value) {
value = ngTrim && !isPasswordInput && angular.isString(value) ? value.trim() : value;
if (value === undefined || value === null) {
value = '';
}
return String(value).length;
} | javascript | function calculateInputValueLength(value) {
value = ngTrim && !isPasswordInput && angular.isString(value) ? value.trim() : value;
if (value === undefined || value === null) {
value = '';
}
return String(value).length;
} | [
"function",
"calculateInputValueLength",
"(",
"value",
")",
"{",
"value",
"=",
"ngTrim",
"&&",
"!",
"isPasswordInput",
"&&",
"angular",
".",
"isString",
"(",
"value",
")",
"?",
"value",
".",
"trim",
"(",
")",
":",
"value",
";",
"if",
"(",
"value",
"===",... | Calculate the input value's length after coercing it to a string
and trimming it if appropriate.
@param value {*} the input's value
@returns {number} calculated length of the input's value | [
"Calculate",
"the",
"input",
"value",
"s",
"length",
"after",
"coercing",
"it",
"to",
"a",
"string",
"and",
"trimming",
"it",
"if",
"appropriate",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/input/input.js#L733-L739 | train | Calculates the length of the input value | [
30522,
3853,
18422,
2378,
18780,
10175,
16284,
13159,
2705,
1006,
3643,
1007,
1063,
3643,
1027,
12835,
18886,
2213,
1004,
1004,
999,
2003,
15194,
18351,
2378,
18780,
1004,
1004,
16108,
1012,
26354,
18886,
3070,
1006,
3643,
1007,
1029,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/create-api-index.js | createSymbolSummaryForLib | function createSymbolSummaryForLib(lib) {
let file = path.join(unpackedTestresourcesRoot, lib.replace(/\./g, "/"), "designtime/api.json");
return readJSONFile(file).then(function (apijson) {
if (!apijson.hasOwnProperty("symbols") || !Array.isArray(apijson.symbols)) {
// Ignore libraries with invalid api.json content like empty object or non-array "symbols" property.
return [];
}
return apijson.symbols.map(symbol => {
let oReturn = {
name: symbol.name,
kind: symbol.kind,
visibility: symbol.visibility,
extends: symbol.extends,
implements: symbol.implements,
lib: lib
};
// We add deprecated member only when the control is deprecated to keep file size at check
if (symbol.deprecated) {
oReturn.deprecated = true;
}
collectLists(symbol);
return oReturn;
});
})
} | javascript | function createSymbolSummaryForLib(lib) {
let file = path.join(unpackedTestresourcesRoot, lib.replace(/\./g, "/"), "designtime/api.json");
return readJSONFile(file).then(function (apijson) {
if (!apijson.hasOwnProperty("symbols") || !Array.isArray(apijson.symbols)) {
// Ignore libraries with invalid api.json content like empty object or non-array "symbols" property.
return [];
}
return apijson.symbols.map(symbol => {
let oReturn = {
name: symbol.name,
kind: symbol.kind,
visibility: symbol.visibility,
extends: symbol.extends,
implements: symbol.implements,
lib: lib
};
// We add deprecated member only when the control is deprecated to keep file size at check
if (symbol.deprecated) {
oReturn.deprecated = true;
}
collectLists(symbol);
return oReturn;
});
})
} | [
"function",
"createSymbolSummaryForLib",
"(",
"lib",
")",
"{",
"let",
"file",
"=",
"path",
".",
"join",
"(",
"unpackedTestresourcesRoot",
",",
"lib",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"/\"",
")",
",",
"\"designtime/api.json\"",
")",
";",
"r... | /*
Extracts main symbol information from a library api.json.
Also collects deprecated, experimental and since api's.
Returns a promise that resolves with an array of symbols. | [
"/",
"*",
"Extracts",
"main",
"symbol",
"information",
"from",
"a",
"library",
"api",
".",
"json",
".",
"Also",
"collects",
"deprecated",
"experimental",
"and",
"since",
"api",
"s",
".",
"Returns",
"a",
"promise",
"that",
"resolves",
"with",
"an",
"array",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/create-api-index.js#L104-L129 | train | Create a symbol summary for a specific library | [
30522,
3853,
9005,
24335,
14956,
17421,
7849,
2100,
29278,
29521,
1006,
5622,
2497,
1007,
1063,
2292,
5371,
1027,
4130,
1012,
3693,
1006,
4895,
23947,
2098,
22199,
6072,
8162,
9623,
3217,
4140,
1010,
5622,
2497,
1012,
5672,
1006,
1013,
1032... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/Async.js | waitForAll | function waitForAll(promises, failOnReject, timeout) {
var masterDeferred = new $.Deferred(),
results = [],
count = 0,
sawRejects = false;
if (!promises || promises.length === 0) {
masterDeferred.resolve();
return masterDeferred.promise();
}
// set defaults if needed
failOnReject = (failOnReject === undefined) ? false : true;
if (timeout !== undefined) {
withTimeout(masterDeferred, timeout);
}
promises.forEach(function (promise) {
promise
.fail(function (err) {
sawRejects = true;
})
.done(function (result) {
results.push(result);
})
.always(function () {
count++;
if (count === promises.length) {
if (failOnReject && sawRejects) {
masterDeferred.reject();
} else {
masterDeferred.resolve(results);
}
}
});
});
return masterDeferred.promise();
} | javascript | function waitForAll(promises, failOnReject, timeout) {
var masterDeferred = new $.Deferred(),
results = [],
count = 0,
sawRejects = false;
if (!promises || promises.length === 0) {
masterDeferred.resolve();
return masterDeferred.promise();
}
// set defaults if needed
failOnReject = (failOnReject === undefined) ? false : true;
if (timeout !== undefined) {
withTimeout(masterDeferred, timeout);
}
promises.forEach(function (promise) {
promise
.fail(function (err) {
sawRejects = true;
})
.done(function (result) {
results.push(result);
})
.always(function () {
count++;
if (count === promises.length) {
if (failOnReject && sawRejects) {
masterDeferred.reject();
} else {
masterDeferred.resolve(results);
}
}
});
});
return masterDeferred.promise();
} | [
"function",
"waitForAll",
"(",
"promises",
",",
"failOnReject",
",",
"timeout",
")",
"{",
"var",
"masterDeferred",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"results",
"=",
"[",
"]",
",",
"count",
"=",
"0",
",",
"sawRejects",
"=",
"false",
";",
... | Allows waiting for all the promises to be either resolved or rejected.
Unlike $.when(), it does not call .fail() or .always() handlers on first
reject. The caller should take all the precaution to make sure all the
promises passed to this function are completed to avoid blocking.
If failOnReject is set to true, promise returned by the function will be
rejected if at least one of the promises was rejected. The default value
is false, which will cause the call to this function to be always
successfully resolved.
If timeout is specified, the promise will be rejected on timeout as per
Async.withTimeout.
@param {!Array.<$.Promise>} promises Array of promises to wait for
@param {boolean=} failOnReject Whether to reject or not if one of the promises has been rejected.
@param {number=} timeout Number of milliseconds to wait until rejecting the promise
@return {$.Promise} A Promise which will be resolved once all dependent promises are resolved.
It is resolved with an array of results from the successfully resolved dependent promises.
The resulting array may not be in the same order or contain as many items as there were
promises to wait on and it will contain 'undefined' entries for those promises that resolve
without a result. | [
"Allows",
"waiting",
"for",
"all",
"the",
"promises",
"to",
"be",
"either",
"resolved",
"or",
"rejected",
".",
"Unlike",
"$",
".",
"when",
"()",
"it",
"does",
"not",
"call",
".",
"fail",
"()",
"or",
".",
"always",
"()",
"handlers",
"on",
"first",
"reje... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/Async.js#L374-L413 | train | Wait for all the given promises to resolve or reject | [
30522,
3853,
3524,
29278,
8095,
1006,
10659,
1010,
8246,
2239,
2890,
20614,
1010,
2051,
5833,
1007,
1063,
13075,
3040,
3207,
7512,
5596,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
3463,
1027,
1031,
1033,
1010,
4175,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Locale.js | getDesigntimePropertyAsArray | function getDesigntimePropertyAsArray(sValue) {
var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
return (m && m[2]) ? m[2].split(/,/) : null;
} | javascript | function getDesigntimePropertyAsArray(sValue) {
var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
return (m && m[2]) ? m[2].split(/,/) : null;
} | [
"function",
"getDesigntimePropertyAsArray",
"(",
"sValue",
")",
"{",
"var",
"m",
"=",
"/",
"\\$([-a-z0-9A-Z._]+)(?::([^$]*))?\\$",
"/",
".",
"exec",
"(",
"sValue",
")",
";",
"return",
"(",
"m",
"&&",
"m",
"[",
"2",
"]",
")",
"?",
"m",
"[",
"2",
"]",
".... | Helper to analyze and parse designtime variables
@private | [
"Helper",
"to",
"analyze",
"and",
"parse",
"designtime",
"variables"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Locale.js#L284-L287 | train | Parses the given designtime property value into an array of strings | [
30522,
3853,
2131,
6155,
23773,
7292,
21572,
4842,
21426,
10286,
9447,
1006,
17917,
2389,
5657,
1007,
1063,
13075,
1049,
1027,
1013,
1032,
1002,
1006,
1031,
1011,
1037,
1011,
1062,
2692,
1011,
1023,
2050,
1011,
1062,
1012,
1035,
1033,
1009,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/main.js | setupAutoUpdatePreference | function setupAutoUpdatePreference() {
PreferencesManager.definePreference("autoUpdate.AutoUpdate", "boolean", true, {
description: Strings.DESCRIPTION_AUTO_UPDATE
});
// Set or unset the auto update, based on preference state change
PreferencesManager.on("change", "autoUpdate.AutoUpdate", function () {
if (_isAutoUpdateEnabled()) {
setupAutoUpdate();
UpdateNotification.registerUpdateHandler(_updateProcessHandler);
} else {
unsetAutoUpdate();
UpdateNotification.resetToDefaultUpdateHandler();
}
});
} | javascript | function setupAutoUpdatePreference() {
PreferencesManager.definePreference("autoUpdate.AutoUpdate", "boolean", true, {
description: Strings.DESCRIPTION_AUTO_UPDATE
});
// Set or unset the auto update, based on preference state change
PreferencesManager.on("change", "autoUpdate.AutoUpdate", function () {
if (_isAutoUpdateEnabled()) {
setupAutoUpdate();
UpdateNotification.registerUpdateHandler(_updateProcessHandler);
} else {
unsetAutoUpdate();
UpdateNotification.resetToDefaultUpdateHandler();
}
});
} | [
"function",
"setupAutoUpdatePreference",
"(",
")",
"{",
"PreferencesManager",
".",
"definePreference",
"(",
"\"autoUpdate.AutoUpdate\"",
",",
"\"boolean\"",
",",
"true",
",",
"{",
"description",
":",
"Strings",
".",
"DESCRIPTION_AUTO_UPDATE",
"}",
")",
";",
"// Set or... | Defines preference to enable/disable Auto Update | [
"Defines",
"preference",
"to",
"enable",
"/",
"disable",
"Auto",
"Update"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L513-L528 | train | Setup auto update preference | [
30522,
3853,
16437,
4887,
24826,
17299,
3686,
28139,
25523,
1006,
1007,
1063,
18394,
24805,
4590,
1012,
9375,
28139,
25523,
1006,
1000,
8285,
6279,
13701,
1012,
8285,
6279,
13701,
1000,
1010,
1000,
22017,
20898,
1000,
1010,
2995,
1010,
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... |
GitbookIO/gitbook | lib/plugins/installPlugin.js | installPlugin | function installPlugin(book, plugin) {
var logger = book.getLogger();
var installFolder = book.getRoot();
var name = plugin.getName();
var requirement = plugin.getVersion();
logger.info.ln('');
logger.info.ln('installing plugin "' + name + '"');
// Find a version to install
return resolveVersion(plugin)
.then(function(version) {
if (!version) {
throw new Error('Found no satisfactory version for plugin "' + name + '" with requirement "' + requirement + '"');
}
logger.info.ln('install plugin "' + name +'" (' + requirement + ') from NPM with version', version);
return Promise.nfcall(npmi, {
'name': plugin.getNpmID(),
'version': version,
'path': installFolder,
'npmLoad': {
'loglevel': 'silent',
'loaded': true,
'prefix': installFolder
}
});
})
.then(function() {
logger.info.ok('plugin "' + name + '" installed with success');
});
} | javascript | function installPlugin(book, plugin) {
var logger = book.getLogger();
var installFolder = book.getRoot();
var name = plugin.getName();
var requirement = plugin.getVersion();
logger.info.ln('');
logger.info.ln('installing plugin "' + name + '"');
// Find a version to install
return resolveVersion(plugin)
.then(function(version) {
if (!version) {
throw new Error('Found no satisfactory version for plugin "' + name + '" with requirement "' + requirement + '"');
}
logger.info.ln('install plugin "' + name +'" (' + requirement + ') from NPM with version', version);
return Promise.nfcall(npmi, {
'name': plugin.getNpmID(),
'version': version,
'path': installFolder,
'npmLoad': {
'loglevel': 'silent',
'loaded': true,
'prefix': installFolder
}
});
})
.then(function() {
logger.info.ok('plugin "' + name + '" installed with success');
});
} | [
"function",
"installPlugin",
"(",
"book",
",",
"plugin",
")",
"{",
"var",
"logger",
"=",
"book",
".",
"getLogger",
"(",
")",
";",
"var",
"installFolder",
"=",
"book",
".",
"getRoot",
"(",
")",
";",
"var",
"name",
"=",
"plugin",
".",
"getName",
"(",
"... | Install a plugin for a book
@param {Book}
@param {PluginDependency}
@return {Promise} | [
"Install",
"a",
"plugin",
"for",
"a",
"book"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/installPlugin.js#L13-L45 | train | Install a plugin from NPM | [
30522,
3853,
16500,
24759,
15916,
2378,
1006,
2338,
1010,
13354,
2378,
1007,
1063,
13075,
8833,
4590,
1027,
2338,
1012,
2131,
21197,
4590,
1006,
1007,
1025,
13075,
16500,
10371,
2121,
1027,
2338,
1012,
2131,
3217,
4140,
1006,
1007,
1025,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/signers/v4_credentials.js | getSigningKey | function getSigningKey(
credentials,
date,
region,
service,
shouldCache
) {
var credsIdentifier = AWS.util.crypto
.hmac(credentials.secretAccessKey, credentials.accessKeyId, 'base64');
var cacheKey = [credsIdentifier, date, region, service].join('_');
shouldCache = shouldCache !== false;
if (shouldCache && (cacheKey in cachedSecret)) {
return cachedSecret[cacheKey];
}
var kDate = AWS.util.crypto.hmac(
'AWS4' + credentials.secretAccessKey,
date,
'buffer'
);
var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer');
var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer');
var signingKey = AWS.util.crypto.hmac(kService, v4Identifier, 'buffer');
if (shouldCache) {
cachedSecret[cacheKey] = signingKey;
cacheQueue.push(cacheKey);
if (cacheQueue.length > maxCacheEntries) {
// remove the oldest entry (not the least recently used)
delete cachedSecret[cacheQueue.shift()];
}
}
return signingKey;
} | javascript | function getSigningKey(
credentials,
date,
region,
service,
shouldCache
) {
var credsIdentifier = AWS.util.crypto
.hmac(credentials.secretAccessKey, credentials.accessKeyId, 'base64');
var cacheKey = [credsIdentifier, date, region, service].join('_');
shouldCache = shouldCache !== false;
if (shouldCache && (cacheKey in cachedSecret)) {
return cachedSecret[cacheKey];
}
var kDate = AWS.util.crypto.hmac(
'AWS4' + credentials.secretAccessKey,
date,
'buffer'
);
var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer');
var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer');
var signingKey = AWS.util.crypto.hmac(kService, v4Identifier, 'buffer');
if (shouldCache) {
cachedSecret[cacheKey] = signingKey;
cacheQueue.push(cacheKey);
if (cacheQueue.length > maxCacheEntries) {
// remove the oldest entry (not the least recently used)
delete cachedSecret[cacheQueue.shift()];
}
}
return signingKey;
} | [
"function",
"getSigningKey",
"(",
"credentials",
",",
"date",
",",
"region",
",",
"service",
",",
"shouldCache",
")",
"{",
"var",
"credsIdentifier",
"=",
"AWS",
".",
"util",
".",
"crypto",
".",
"hmac",
"(",
"credentials",
".",
"secretAccessKey",
",",
"creden... | @api private
@param credentials [Credentials]
@param date [String]
@param region [String]
@param service [String]
@param shouldCache [Boolean]
@return [String] | [
"@api",
"private"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/signers/v4_credentials.js#L54-L88 | train | Get the signing key for the given credentials | [
30522,
3853,
4152,
23773,
2075,
14839,
1006,
22496,
1010,
3058,
1010,
2555,
1010,
2326,
1010,
2323,
3540,
5403,
1007,
1063,
13075,
13675,
2098,
7363,
16778,
8873,
2121,
1027,
22091,
2015,
1012,
21183,
4014,
1012,
19888,
2080,
1012,
20287,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _buildDirsFirstComparator | function _buildDirsFirstComparator(contents) {
function _dirsFirstCompare(a, b) {
var aIsFile = FileTreeViewModel.isFile(contents.get(a)),
bIsFile = FileTreeViewModel.isFile(contents.get(b));
if (!aIsFile && bIsFile) {
return -1;
} else if (aIsFile && !bIsFile) {
return 1;
} else {
return FileUtils.compareFilenames(a, b);
}
}
return _dirsFirstCompare;
} | javascript | function _buildDirsFirstComparator(contents) {
function _dirsFirstCompare(a, b) {
var aIsFile = FileTreeViewModel.isFile(contents.get(a)),
bIsFile = FileTreeViewModel.isFile(contents.get(b));
if (!aIsFile && bIsFile) {
return -1;
} else if (aIsFile && !bIsFile) {
return 1;
} else {
return FileUtils.compareFilenames(a, b);
}
}
return _dirsFirstCompare;
} | [
"function",
"_buildDirsFirstComparator",
"(",
"contents",
")",
"{",
"function",
"_dirsFirstCompare",
"(",
"a",
",",
"b",
")",
"{",
"var",
"aIsFile",
"=",
"FileTreeViewModel",
".",
"isFile",
"(",
"contents",
".",
"get",
"(",
"a",
")",
")",
",",
"bIsFile",
"... | @private
Creates a comparison function for sorting a directory's contents with directories
appearing before files.
We're sorting the keys of the directory (the names) based partly on the values,
so we use a closure to capture the map itself so that we can look up the
values as needed.
@param {Immutable.Map} contents The directory's contents
@return {function(string,string)} Comparator that sorts directories first. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L665-L679 | train | Build a comparator function for directories first | [
30522,
3853,
1035,
3857,
4305,
2869,
8873,
12096,
9006,
28689,
4263,
1006,
8417,
1007,
1063,
3853,
1035,
16101,
22747,
18894,
13535,
25377,
12069,
1006,
1037,
1010,
1038,
1007,
1063,
13075,
9932,
22747,
9463,
1027,
5371,
13334,
8584,
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... |
SAP/openui5 | src/sap.ui.layout/src/sap/ui/layout/Splitter.js | _ensureLayoutData | function _ensureLayoutData(oContent) {
var oLd = oContent.getLayoutData();
// Make sure LayoutData is set on the content
// But this approach has the advantage that "compatible" LayoutData can be used.
if (oLd && (!oLd.getResizable || !oLd.getSize || !oLd.getMinSize)) {
Log.warning(
"Content \"" + oContent.getId() + "\" for the Splitter contained wrong LayoutData. " +
"The LayoutData has been replaced with default values."
);
oLd = null;
}
if (!oLd) {
oContent.setLayoutData(new sap.ui.layout.SplitterLayoutData());
}
} | javascript | function _ensureLayoutData(oContent) {
var oLd = oContent.getLayoutData();
// Make sure LayoutData is set on the content
// But this approach has the advantage that "compatible" LayoutData can be used.
if (oLd && (!oLd.getResizable || !oLd.getSize || !oLd.getMinSize)) {
Log.warning(
"Content \"" + oContent.getId() + "\" for the Splitter contained wrong LayoutData. " +
"The LayoutData has been replaced with default values."
);
oLd = null;
}
if (!oLd) {
oContent.setLayoutData(new sap.ui.layout.SplitterLayoutData());
}
} | [
"function",
"_ensureLayoutData",
"(",
"oContent",
")",
"{",
"var",
"oLd",
"=",
"oContent",
".",
"getLayoutData",
"(",
")",
";",
"// Make sure LayoutData is set on the content",
"// But this approach has the advantage that \"compatible\" LayoutData can be used.",
"if",
"(",
"oLd... | Makes sure the LayoutData for the given control is set and compatible. In case nothing is set,
a default sap.ui.layout.SplitterLayoutData is set on the Element
@param {sap.ui.core.Element} [oContent] The Element for which the existance of LayoutData should be ensured
@private | [
"Makes",
"sure",
"the",
"LayoutData",
"for",
"the",
"given",
"control",
"is",
"set",
"and",
"compatible",
".",
"In",
"case",
"nothing",
"is",
"set",
"a",
"default",
"sap",
".",
"ui",
".",
"layout",
".",
"SplitterLayoutData",
"is",
"set",
"on",
"the",
"El... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.layout/src/sap/ui/layout/Splitter.js#L1105-L1119 | train | Ensure that the LayoutData of the Splitter is set on the given content. | [
30522,
3853,
1035,
5676,
8485,
5833,
2850,
2696,
1006,
1051,
8663,
6528,
2102,
1007,
1063,
13075,
2214,
1027,
1051,
8663,
6528,
2102,
1012,
2131,
8485,
5833,
2850,
2696,
1006,
1007,
1025,
1013,
1013,
2191,
2469,
9621,
2850,
2696,
2003,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/modifiers/svgToPng.js | svgToPng | function svgToPng(rootFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
if (path.extname(src) !== '.svg') {
return;
}
// Calcul absolute path for this
src = LocationUtils.toAbsolute(src, currentDirectory, '.');
// We avoid generating twice the same PNG
var hash = crc.crc32(src).toString(16);
var fileName = hash + '.png';
// Input file path
var inputPath = path.join(rootFolder, src);
// Result file path
var filePath = path.join(rootFolder, fileName);
return fs.assertFile(filePath, function() {
return imagesUtil.convertSVGToPNG(inputPath, filePath);
})
.then(function() {
// Convert filename to a relative filename
fileName = LocationUtils.relative(currentDirectory, fileName);
// Replace src
$img.attr('src', fileName);
});
});
} | javascript | function svgToPng(rootFolder, currentFile, $) {
var currentDirectory = path.dirname(currentFile);
return editHTMLElement($, 'img', function($img) {
var src = $img.attr('src');
if (path.extname(src) !== '.svg') {
return;
}
// Calcul absolute path for this
src = LocationUtils.toAbsolute(src, currentDirectory, '.');
// We avoid generating twice the same PNG
var hash = crc.crc32(src).toString(16);
var fileName = hash + '.png';
// Input file path
var inputPath = path.join(rootFolder, src);
// Result file path
var filePath = path.join(rootFolder, fileName);
return fs.assertFile(filePath, function() {
return imagesUtil.convertSVGToPNG(inputPath, filePath);
})
.then(function() {
// Convert filename to a relative filename
fileName = LocationUtils.relative(currentDirectory, fileName);
// Replace src
$img.attr('src', fileName);
});
});
} | [
"function",
"svgToPng",
"(",
"rootFolder",
",",
"currentFile",
",",
"$",
")",
"{",
"var",
"currentDirectory",
"=",
"path",
".",
"dirname",
"(",
"currentFile",
")",
";",
"return",
"editHTMLElement",
"(",
"$",
",",
"'img'",
",",
"function",
"(",
"$img",
")",... | Convert all SVG images to PNG
@param {String} rootFolder
@param {HTMLDom} $
@return {Promise} | [
"Convert",
"all",
"SVG",
"images",
"to",
"PNG"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/svgToPng.js#L17-L50 | train | Convert SVG file to PNG | [
30522,
3853,
17917,
13512,
7361,
3070,
1006,
7117,
10371,
2121,
1010,
2783,
8873,
2571,
1010,
1002,
1007,
1063,
13075,
2783,
4305,
2890,
16761,
2100,
1027,
4130,
1012,
16101,
18442,
1006,
2783,
8873,
2571,
1007,
1025,
2709,
13257,
21246,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/transform-apijson-for-sdk.js | function (oChainObject) {
function isBuiltInType(type) {
return formatters._baseTypes.indexOf(type) >= 0;
}
/**
* Heuristically determining if there is a possibility the given input string
* to be a UI5 symbol
* @param {string} sName
* @returns {boolean}
*/
function possibleUI5Symbol(sName) {
return /^[a-zA-Z][a-zA-Z.]*[a-zA-Z]$/.test(sName);
}
// Function is a copy from: LibraryInfo.js => LibraryInfo.prototype._getActualComponent => "match" inline method
function matchComponent(sModuleName, sPattern) {
sModuleName = sModuleName.toLowerCase();
sPattern = sPattern.toLowerCase();
return (
sModuleName === sPattern
|| sPattern.match(/\*$/) && sModuleName.indexOf(sPattern.slice(0,-1)) === 0 // simple prefix match
|| sPattern.match(/\.\*$/) && sModuleName === sPattern.slice(0,-2) // directory pattern also matches directory itself
);
}
/**
* Pre-processes the symbols list - creating virtual namespace records and attaching children list to namespace
* records.
* @param {object} symbols list
*/
function preProcessSymbols(symbols) {
// Create treeName and modify module names
symbols.forEach(oSymbol => {
let sModuleClearName = oSymbol.name.replace(/^module:/, "");
oSymbol.displayName = sModuleClearName;
oSymbol.treeName = sModuleClearName.replace(/\//g, ".");
});
// Create missing - virtual namespaces
symbols.forEach(oSymbol => {
oSymbol.treeName.split(".").forEach((sPart, i, a) => {
let sName = a.slice(0, (i + 1)).join(".");
if (!symbols.find(o => o.treeName === sName)) {
symbols.push({
name: sName,
displayName: sName,
treeName: sName,
lib: oSymbol.lib,
kind: "namespace"
});
}
});
});
// Discover parents
symbols.forEach(oSymbol => {
let aParent = oSymbol.treeName.split("."),
sParent;
// Extract parent name
aParent.pop();
sParent = aParent.join(".");
// Mark parent
if (symbols.find(({treeName}) => treeName === sParent)) {
oSymbol.parent = sParent;
}
});
// Attach children info
symbols.forEach(oSymbol => {
if (oSymbol.parent) {
let oParent = symbols.find(({treeName}) => treeName === oSymbol.parent);
if (!oParent.nodes) oParent.nodes = [];
oParent.nodes.push({
name: oSymbol.displayName,
description: formatters._preProcessLinksInTextBlock(oSymbol.description),
href: "#/api/" + encodeURIComponent(oSymbol.name)
});
}
});
// Clean list - keep file size down
symbols.forEach(o => {
delete o.treeName;
delete o.parent;
});
}
// Transform to object
let oData = oChainObject.fileData;
// Attach default component for the library if available
if (oChainObject.defaultComponent) {
oData.defaultComponent = oChainObject.defaultComponent;
}
formatters._oOwnLibrary = oData;
// Pre process symbols
preProcessSymbols(oData.symbols);
// Apply formatter's and modify data as needed
oData.symbols.forEach((oSymbol) => {
// when the module name starts with the library name, then we apply the default component
if (oSymbol.name.indexOf(oData.library) === 0) {
oSymbol.component = oChainObject.defaultComponent;
}
// Attach symbol specific component if available (special cases)
// Note: Last hit wins as there may be a more specific component pattern
if (oChainObject.customSymbolComponents) {
Object.keys(oChainObject.customSymbolComponents).forEach(sComponent => {
if (matchComponent(oSymbol.name, sComponent)) {
oSymbol.component = oChainObject.customSymbolComponents[sComponent];
}
});
}
// Attach symbol sample flag if available
if (oChainObject.entitiesWithSamples) {
oSymbol.hasSample = oChainObject.entitiesWithSamples.indexOf(oSymbol.name) >= 0;
}
// Apply settings to formatter object - needed until formatter's are rewritten
formatters._sTopicId = oSymbol.name;
formatters._oTopicData = oSymbol;
// Format Page Title
oSymbol.title = (oSymbol.abstract ? "abstract " : "") + oSymbol.kind + " " + oSymbol.displayName;
oSymbol.subTitle = formatters.formatSubtitle(oSymbol.deprecated);
// Constructor
if (oSymbol.constructor) {
let oConstructor = oSymbol.constructor;
// Description
if (oConstructor.description) {
oConstructor.description = formatters.formatDescription(oConstructor.description);
}
// References
formatters.modifyReferences(oSymbol, true);
// Examples
if (oConstructor.examples) {
oConstructor.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
// Code Example string
oConstructor.codeExample = formatters.formatConstructor(oSymbol.name, oConstructor.parameters);
// Parameters
if (oConstructor.parameters) {
oConstructor.parameters = methods.buildConstructorParameters(oConstructor.parameters);
let aParameters = oConstructor.parameters;
aParameters.forEach(oParameter => {
// Types
oParameter.types = [];
if (oParameter.type) {
let aTypes = oParameter.type.split("|");
for (let i = 0; i < aTypes.length; i++) {
oParameter.types.push({
name: aTypes[i],
linkEnabled: !isBuiltInType(aTypes[i])
});
}
// Keep file size in check
delete oParameter.type;
}
// Default value
oParameter.defaultValue = formatters.formatDefaultValue(oParameter.defaultValue);
// Description
if (oParameter.description) {
oParameter.description = formatters.formatDescription(oParameter.description);
}
})
}
// Throws
if (oConstructor.throws) {
oConstructor.throws.forEach(oThrows => {
// Description
if (oThrows.description) {
oThrows.description = formatters.formatDescription(oThrows.description);
}
// Exception link enabled
if (oThrows.type) {
oThrows.linkEnabled = formatters.formatExceptionLink(oThrows.type);
}
});
}
}
// Description
if (oSymbol.description) {
oSymbol.description = formatters.formatOverviewDescription(oSymbol.description, oSymbol.constructor.references);
}
// Deprecated
if (oSymbol.deprecated) {
oSymbol.deprecatedText = formatters.formatDeprecated(oSymbol.deprecated.since, oSymbol.deprecated.text);
// Keep file size in check
delete oSymbol.deprecated;
}
// Properties
if (oSymbol.properties) {
oSymbol.properties.forEach((oProperty) => {
// Name
oProperty.name = formatters.formatEntityName(oProperty.name, oSymbol.name, oProperty.static);
// Description
if (oProperty.deprecated) {
oProperty.description = formatters.formatDescription(oProperty.description,
oProperty.deprecated.text, oProperty.deprecated.since);
} else {
oProperty.description = formatters.formatDescription(oProperty.description);
}
// Link Enabled
if (oSymbol.kind !== "enum" && !isBuiltInType(oProperty.type) && possibleUI5Symbol(oProperty.type)) {
oProperty.linkEnabled = true;
oProperty.href = "#/api/" + oProperty.type.replace("[]", "");
}
// Keep file size in check
if (oProperty.static) {
delete oProperty.static;
}
if (oSymbol.kind === "enum" || oProperty.type === "undefined") {
delete oProperty.type;
}
});
}
// UI5 Metadata
if (oSymbol["ui5-metadata"]) {
let oMeta = oSymbol["ui5-metadata"];
// Properties
if (oMeta.properties) {
// Sort
oMeta.properties.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.properties.forEach((oProperty) => {
// Name
oProperty.name = formatters.formatEntityName(oProperty.name, oSymbol.name, oProperty.static);
// Description
oProperty.description = formatters.formatDescriptionSince(oProperty.description, oProperty.since);
// Link Enabled
if (!isBuiltInType(oProperty.type)) {
oProperty.linkEnabled = true;
}
// Default value
oProperty.defaultValue = formatters.formatDefaultValue(oProperty.defaultValue);
// Deprecated
if (oProperty.deprecated) {
oProperty.deprecatedText = formatters.formatDeprecated(oProperty.deprecated.since,
oProperty.deprecated.text);
// Keep file size in check
delete oProperty.deprecated;
}
});
}
// Aggregations
if (oMeta.aggregations) {
// Sort
oMeta.aggregations.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.aggregations.forEach((oAggregation) => {
// Link Enabled
if (!isBuiltInType(oAggregation.type)) {
oAggregation.linkEnabled = true;
}
// Description
if (oAggregation.deprecated) {
oAggregation.description = formatters.formatDescription(oAggregation.description,
oAggregation.deprecated.text, oAggregation.deprecated.since);
} else {
oAggregation.description = formatters.formatDescription(oAggregation.description);
}
// Link enabled
oAggregation.linkEnabled = !isBuiltInType(oAggregation.type);
});
}
// Associations
if (oMeta.associations) {
// Sort
oMeta.associations.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.associations.forEach((oAssociation) => {
// Link Enabled
if (!isBuiltInType(oAssociation.type)) {
oAssociation.linkEnabled = true;
}
// Description
if (oAssociation.deprecated) {
oAssociation.description = formatters.formatDescription(oAssociation.description,
oAssociation.deprecated.text, oAssociation.deprecated.since);
} else {
oAssociation.description = formatters.formatDescription(oAssociation.description);
}
});
}
// Events
if (oMeta.events) {
// We don't need event's data from the UI5-metadata for now. Keep file size in check
delete oMeta.events;
}
// Special Settings
if (oMeta.specialSettings) {
oMeta.specialSettings.forEach(oSetting => {
// Link Enabled
if (!isBuiltInType(oSetting.type)) {
oSetting.linkEnabled = true;
}
// Description
if (oSetting.deprecated) {
oSetting.description = formatters.formatDescription(oSetting.description,
oSetting.deprecated.text, oSetting.deprecated.since);
} else {
oSetting.description = formatters.formatDescription(oSetting.description);
}
});
}
// Annotations
if (oMeta.annotations) {
oMeta.annotations.forEach(oAnnotation => {
// Description
oAnnotation.description = formatters.formatAnnotationDescription(oAnnotation.description,
oAnnotation.since);
// Namespace
oAnnotation.namespaceText = oAnnotation.namespace;
oAnnotation.namespace = formatters.formatAnnotationNamespace(oAnnotation.namespace);
// Target
oAnnotation.target = formatters.formatAnnotationTarget(oAnnotation.target);
// Applies to
oAnnotation.appliesTo = formatters.formatAnnotationTarget(oAnnotation.appliesTo);
});
}
}
if (oSymbol.events) {
// Pre-process events
methods.buildEventsModel(oSymbol.events);
oSymbol.events.forEach(oEvent => {
// Description
if (oEvent.description) {
oEvent.description = formatters.formatDescriptionSince(oEvent.description, oEvent.since);
}
// Deprecated
if (oEvent.deprecated) {
oEvent.deprecatedText = formatters.formatEventDeprecated(oEvent.deprecated.since,
oEvent.deprecated.text);
}
// Parameters
if (oEvent.parameters && Array.isArray(oEvent.parameters)) {
oEvent.parameters.forEach(oParameter => {
// Link Enabled
if (!isBuiltInType(oParameter.type)) {
oParameter.linkEnabled = true;
}
// Description
if (oParameter.deprecated) {
oParameter.description = formatters.formatDescription(oParameter.description,
oParameter.deprecated.text, oParameter.deprecated.since);
} else {
oParameter.description = formatters.formatDescription(oParameter.description);
}
});
}
});
}
// Methods
if (oSymbol.methods) {
// Pre-process methods
methods.buildMethodsModel(oSymbol.methods);
oSymbol.methods.forEach(oMethod => {
// Name and link
if (oMethod.name) {
oMethod.name = formatters.formatEntityName(oMethod.name, oSymbol.name, oMethod.static);
// Link
oMethod.href = "#/api/" + encodeURIComponent(oSymbol.name) +
"/methods/" + encodeURIComponent(oMethod.name);
}
formatters.formatReferencesInDescription(oMethod);
// Description
if (oMethod.description) {
oMethod.description = formatters.formatDescription(oMethod.description);
}
// Examples
oMethod.examples && oMethod.examples.forEach(oExample => {
oExample = formatters.formatExample(oExample.caption, oExample.text);
});
// Deprecated
if (oMethod.deprecated) {
oMethod.deprecatedText = formatters.formatEventDeprecated(oMethod.deprecated.since,
oMethod.deprecated.text);
}
// Code example
oMethod.code = formatters.formatMethodCode(oMethod.name, oMethod.parameters, oMethod.returnValue);
// Parameters
if (oMethod.parameters) {
oMethod.parameters.forEach(oParameter => {
// Types
if (oParameter.types) {
oParameter.types.forEach(oType => {
// Link Enabled
if (!isBuiltInType(oType.value) && possibleUI5Symbol(oType.value)) {
oType.linkEnabled = true;
oType.href = "#/api/" + oType.value.replace("[]", "");
}
});
}
// Default value
oParameter.defaultValue = formatters.formatDefaultValue(oParameter.defaultValue);
// Description
if (oParameter.deprecated) {
oParameter.description = formatters.formatDescription(oParameter.description,
oParameter.deprecated.text, oParameter.deprecated.since);
} else {
oParameter.description = formatters.formatDescription(oParameter.description);
}
});
}
// Return value
if (oMethod.returnValue) {
// Description
oMethod.returnValue.description = formatters.formatDescription(oMethod.returnValue.description);
// Types
if (oMethod.returnValue.types) {
oMethod.returnValue.types.forEach(oType => {
// Link Enabled
if (!isBuiltInType(oType.value)) {
oType.href = "#/api/" + encodeURIComponent(oType.value.replace("[]", ""));
oType.linkEnabled = true;
}
});
}
}
// Throws
if (oMethod.throws) {
oMethod.throws.forEach(oThrows => {
// Description
if (oThrows.description) {
oThrows.description = formatters.formatDescription(oThrows.description);
}
// Exception link enabled
if (oThrows.type) {
oThrows.linkEnabled = formatters.formatExceptionLink(oThrows.type);
}
});
}
// Examples
if (oMethod.examples) {
oMethod.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
});
}
// Formatting namespaces, functions and enums, which may contain examples
// or references with links to process them similar to methods and constructors of classes
if (oSymbol.kind !== "class") {
if (oSymbol.examples) {
oSymbol.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
if (oSymbol.references) {
formatters.modifyReferences(oSymbol);
formatters.formatReferencesInDescription(oSymbol);
}
// Description
if (oSymbol.description) {
oSymbol.description = formatters.formatDescription(oSymbol.description);
}
}
});
oChainObject.parsedData = oData;
return oChainObject;
} | javascript | function (oChainObject) {
function isBuiltInType(type) {
return formatters._baseTypes.indexOf(type) >= 0;
}
/**
* Heuristically determining if there is a possibility the given input string
* to be a UI5 symbol
* @param {string} sName
* @returns {boolean}
*/
function possibleUI5Symbol(sName) {
return /^[a-zA-Z][a-zA-Z.]*[a-zA-Z]$/.test(sName);
}
// Function is a copy from: LibraryInfo.js => LibraryInfo.prototype._getActualComponent => "match" inline method
function matchComponent(sModuleName, sPattern) {
sModuleName = sModuleName.toLowerCase();
sPattern = sPattern.toLowerCase();
return (
sModuleName === sPattern
|| sPattern.match(/\*$/) && sModuleName.indexOf(sPattern.slice(0,-1)) === 0 // simple prefix match
|| sPattern.match(/\.\*$/) && sModuleName === sPattern.slice(0,-2) // directory pattern also matches directory itself
);
}
/**
* Pre-processes the symbols list - creating virtual namespace records and attaching children list to namespace
* records.
* @param {object} symbols list
*/
function preProcessSymbols(symbols) {
// Create treeName and modify module names
symbols.forEach(oSymbol => {
let sModuleClearName = oSymbol.name.replace(/^module:/, "");
oSymbol.displayName = sModuleClearName;
oSymbol.treeName = sModuleClearName.replace(/\//g, ".");
});
// Create missing - virtual namespaces
symbols.forEach(oSymbol => {
oSymbol.treeName.split(".").forEach((sPart, i, a) => {
let sName = a.slice(0, (i + 1)).join(".");
if (!symbols.find(o => o.treeName === sName)) {
symbols.push({
name: sName,
displayName: sName,
treeName: sName,
lib: oSymbol.lib,
kind: "namespace"
});
}
});
});
// Discover parents
symbols.forEach(oSymbol => {
let aParent = oSymbol.treeName.split("."),
sParent;
// Extract parent name
aParent.pop();
sParent = aParent.join(".");
// Mark parent
if (symbols.find(({treeName}) => treeName === sParent)) {
oSymbol.parent = sParent;
}
});
// Attach children info
symbols.forEach(oSymbol => {
if (oSymbol.parent) {
let oParent = symbols.find(({treeName}) => treeName === oSymbol.parent);
if (!oParent.nodes) oParent.nodes = [];
oParent.nodes.push({
name: oSymbol.displayName,
description: formatters._preProcessLinksInTextBlock(oSymbol.description),
href: "#/api/" + encodeURIComponent(oSymbol.name)
});
}
});
// Clean list - keep file size down
symbols.forEach(o => {
delete o.treeName;
delete o.parent;
});
}
// Transform to object
let oData = oChainObject.fileData;
// Attach default component for the library if available
if (oChainObject.defaultComponent) {
oData.defaultComponent = oChainObject.defaultComponent;
}
formatters._oOwnLibrary = oData;
// Pre process symbols
preProcessSymbols(oData.symbols);
// Apply formatter's and modify data as needed
oData.symbols.forEach((oSymbol) => {
// when the module name starts with the library name, then we apply the default component
if (oSymbol.name.indexOf(oData.library) === 0) {
oSymbol.component = oChainObject.defaultComponent;
}
// Attach symbol specific component if available (special cases)
// Note: Last hit wins as there may be a more specific component pattern
if (oChainObject.customSymbolComponents) {
Object.keys(oChainObject.customSymbolComponents).forEach(sComponent => {
if (matchComponent(oSymbol.name, sComponent)) {
oSymbol.component = oChainObject.customSymbolComponents[sComponent];
}
});
}
// Attach symbol sample flag if available
if (oChainObject.entitiesWithSamples) {
oSymbol.hasSample = oChainObject.entitiesWithSamples.indexOf(oSymbol.name) >= 0;
}
// Apply settings to formatter object - needed until formatter's are rewritten
formatters._sTopicId = oSymbol.name;
formatters._oTopicData = oSymbol;
// Format Page Title
oSymbol.title = (oSymbol.abstract ? "abstract " : "") + oSymbol.kind + " " + oSymbol.displayName;
oSymbol.subTitle = formatters.formatSubtitle(oSymbol.deprecated);
// Constructor
if (oSymbol.constructor) {
let oConstructor = oSymbol.constructor;
// Description
if (oConstructor.description) {
oConstructor.description = formatters.formatDescription(oConstructor.description);
}
// References
formatters.modifyReferences(oSymbol, true);
// Examples
if (oConstructor.examples) {
oConstructor.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
// Code Example string
oConstructor.codeExample = formatters.formatConstructor(oSymbol.name, oConstructor.parameters);
// Parameters
if (oConstructor.parameters) {
oConstructor.parameters = methods.buildConstructorParameters(oConstructor.parameters);
let aParameters = oConstructor.parameters;
aParameters.forEach(oParameter => {
// Types
oParameter.types = [];
if (oParameter.type) {
let aTypes = oParameter.type.split("|");
for (let i = 0; i < aTypes.length; i++) {
oParameter.types.push({
name: aTypes[i],
linkEnabled: !isBuiltInType(aTypes[i])
});
}
// Keep file size in check
delete oParameter.type;
}
// Default value
oParameter.defaultValue = formatters.formatDefaultValue(oParameter.defaultValue);
// Description
if (oParameter.description) {
oParameter.description = formatters.formatDescription(oParameter.description);
}
})
}
// Throws
if (oConstructor.throws) {
oConstructor.throws.forEach(oThrows => {
// Description
if (oThrows.description) {
oThrows.description = formatters.formatDescription(oThrows.description);
}
// Exception link enabled
if (oThrows.type) {
oThrows.linkEnabled = formatters.formatExceptionLink(oThrows.type);
}
});
}
}
// Description
if (oSymbol.description) {
oSymbol.description = formatters.formatOverviewDescription(oSymbol.description, oSymbol.constructor.references);
}
// Deprecated
if (oSymbol.deprecated) {
oSymbol.deprecatedText = formatters.formatDeprecated(oSymbol.deprecated.since, oSymbol.deprecated.text);
// Keep file size in check
delete oSymbol.deprecated;
}
// Properties
if (oSymbol.properties) {
oSymbol.properties.forEach((oProperty) => {
// Name
oProperty.name = formatters.formatEntityName(oProperty.name, oSymbol.name, oProperty.static);
// Description
if (oProperty.deprecated) {
oProperty.description = formatters.formatDescription(oProperty.description,
oProperty.deprecated.text, oProperty.deprecated.since);
} else {
oProperty.description = formatters.formatDescription(oProperty.description);
}
// Link Enabled
if (oSymbol.kind !== "enum" && !isBuiltInType(oProperty.type) && possibleUI5Symbol(oProperty.type)) {
oProperty.linkEnabled = true;
oProperty.href = "#/api/" + oProperty.type.replace("[]", "");
}
// Keep file size in check
if (oProperty.static) {
delete oProperty.static;
}
if (oSymbol.kind === "enum" || oProperty.type === "undefined") {
delete oProperty.type;
}
});
}
// UI5 Metadata
if (oSymbol["ui5-metadata"]) {
let oMeta = oSymbol["ui5-metadata"];
// Properties
if (oMeta.properties) {
// Sort
oMeta.properties.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.properties.forEach((oProperty) => {
// Name
oProperty.name = formatters.formatEntityName(oProperty.name, oSymbol.name, oProperty.static);
// Description
oProperty.description = formatters.formatDescriptionSince(oProperty.description, oProperty.since);
// Link Enabled
if (!isBuiltInType(oProperty.type)) {
oProperty.linkEnabled = true;
}
// Default value
oProperty.defaultValue = formatters.formatDefaultValue(oProperty.defaultValue);
// Deprecated
if (oProperty.deprecated) {
oProperty.deprecatedText = formatters.formatDeprecated(oProperty.deprecated.since,
oProperty.deprecated.text);
// Keep file size in check
delete oProperty.deprecated;
}
});
}
// Aggregations
if (oMeta.aggregations) {
// Sort
oMeta.aggregations.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.aggregations.forEach((oAggregation) => {
// Link Enabled
if (!isBuiltInType(oAggregation.type)) {
oAggregation.linkEnabled = true;
}
// Description
if (oAggregation.deprecated) {
oAggregation.description = formatters.formatDescription(oAggregation.description,
oAggregation.deprecated.text, oAggregation.deprecated.since);
} else {
oAggregation.description = formatters.formatDescription(oAggregation.description);
}
// Link enabled
oAggregation.linkEnabled = !isBuiltInType(oAggregation.type);
});
}
// Associations
if (oMeta.associations) {
// Sort
oMeta.associations.sort(function (a, b) {
if (a.name < b.name) {
return -1;
} else if (a.name > b.name) {
return 1;
} else {
return 0;
}
});
// Pre-process
oMeta.associations.forEach((oAssociation) => {
// Link Enabled
if (!isBuiltInType(oAssociation.type)) {
oAssociation.linkEnabled = true;
}
// Description
if (oAssociation.deprecated) {
oAssociation.description = formatters.formatDescription(oAssociation.description,
oAssociation.deprecated.text, oAssociation.deprecated.since);
} else {
oAssociation.description = formatters.formatDescription(oAssociation.description);
}
});
}
// Events
if (oMeta.events) {
// We don't need event's data from the UI5-metadata for now. Keep file size in check
delete oMeta.events;
}
// Special Settings
if (oMeta.specialSettings) {
oMeta.specialSettings.forEach(oSetting => {
// Link Enabled
if (!isBuiltInType(oSetting.type)) {
oSetting.linkEnabled = true;
}
// Description
if (oSetting.deprecated) {
oSetting.description = formatters.formatDescription(oSetting.description,
oSetting.deprecated.text, oSetting.deprecated.since);
} else {
oSetting.description = formatters.formatDescription(oSetting.description);
}
});
}
// Annotations
if (oMeta.annotations) {
oMeta.annotations.forEach(oAnnotation => {
// Description
oAnnotation.description = formatters.formatAnnotationDescription(oAnnotation.description,
oAnnotation.since);
// Namespace
oAnnotation.namespaceText = oAnnotation.namespace;
oAnnotation.namespace = formatters.formatAnnotationNamespace(oAnnotation.namespace);
// Target
oAnnotation.target = formatters.formatAnnotationTarget(oAnnotation.target);
// Applies to
oAnnotation.appliesTo = formatters.formatAnnotationTarget(oAnnotation.appliesTo);
});
}
}
if (oSymbol.events) {
// Pre-process events
methods.buildEventsModel(oSymbol.events);
oSymbol.events.forEach(oEvent => {
// Description
if (oEvent.description) {
oEvent.description = formatters.formatDescriptionSince(oEvent.description, oEvent.since);
}
// Deprecated
if (oEvent.deprecated) {
oEvent.deprecatedText = formatters.formatEventDeprecated(oEvent.deprecated.since,
oEvent.deprecated.text);
}
// Parameters
if (oEvent.parameters && Array.isArray(oEvent.parameters)) {
oEvent.parameters.forEach(oParameter => {
// Link Enabled
if (!isBuiltInType(oParameter.type)) {
oParameter.linkEnabled = true;
}
// Description
if (oParameter.deprecated) {
oParameter.description = formatters.formatDescription(oParameter.description,
oParameter.deprecated.text, oParameter.deprecated.since);
} else {
oParameter.description = formatters.formatDescription(oParameter.description);
}
});
}
});
}
// Methods
if (oSymbol.methods) {
// Pre-process methods
methods.buildMethodsModel(oSymbol.methods);
oSymbol.methods.forEach(oMethod => {
// Name and link
if (oMethod.name) {
oMethod.name = formatters.formatEntityName(oMethod.name, oSymbol.name, oMethod.static);
// Link
oMethod.href = "#/api/" + encodeURIComponent(oSymbol.name) +
"/methods/" + encodeURIComponent(oMethod.name);
}
formatters.formatReferencesInDescription(oMethod);
// Description
if (oMethod.description) {
oMethod.description = formatters.formatDescription(oMethod.description);
}
// Examples
oMethod.examples && oMethod.examples.forEach(oExample => {
oExample = formatters.formatExample(oExample.caption, oExample.text);
});
// Deprecated
if (oMethod.deprecated) {
oMethod.deprecatedText = formatters.formatEventDeprecated(oMethod.deprecated.since,
oMethod.deprecated.text);
}
// Code example
oMethod.code = formatters.formatMethodCode(oMethod.name, oMethod.parameters, oMethod.returnValue);
// Parameters
if (oMethod.parameters) {
oMethod.parameters.forEach(oParameter => {
// Types
if (oParameter.types) {
oParameter.types.forEach(oType => {
// Link Enabled
if (!isBuiltInType(oType.value) && possibleUI5Symbol(oType.value)) {
oType.linkEnabled = true;
oType.href = "#/api/" + oType.value.replace("[]", "");
}
});
}
// Default value
oParameter.defaultValue = formatters.formatDefaultValue(oParameter.defaultValue);
// Description
if (oParameter.deprecated) {
oParameter.description = formatters.formatDescription(oParameter.description,
oParameter.deprecated.text, oParameter.deprecated.since);
} else {
oParameter.description = formatters.formatDescription(oParameter.description);
}
});
}
// Return value
if (oMethod.returnValue) {
// Description
oMethod.returnValue.description = formatters.formatDescription(oMethod.returnValue.description);
// Types
if (oMethod.returnValue.types) {
oMethod.returnValue.types.forEach(oType => {
// Link Enabled
if (!isBuiltInType(oType.value)) {
oType.href = "#/api/" + encodeURIComponent(oType.value.replace("[]", ""));
oType.linkEnabled = true;
}
});
}
}
// Throws
if (oMethod.throws) {
oMethod.throws.forEach(oThrows => {
// Description
if (oThrows.description) {
oThrows.description = formatters.formatDescription(oThrows.description);
}
// Exception link enabled
if (oThrows.type) {
oThrows.linkEnabled = formatters.formatExceptionLink(oThrows.type);
}
});
}
// Examples
if (oMethod.examples) {
oMethod.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
});
}
// Formatting namespaces, functions and enums, which may contain examples
// or references with links to process them similar to methods and constructors of classes
if (oSymbol.kind !== "class") {
if (oSymbol.examples) {
oSymbol.examples.forEach((oExample) => {
oExample.data = formatters.formatExample(oExample.caption, oExample.text);
// Keep file size in check
if (oExample.caption) {
delete oExample.caption;
}
if (oExample.text) {
delete oExample.text;
}
});
}
if (oSymbol.references) {
formatters.modifyReferences(oSymbol);
formatters.formatReferencesInDescription(oSymbol);
}
// Description
if (oSymbol.description) {
oSymbol.description = formatters.formatDescription(oSymbol.description);
}
}
});
oChainObject.parsedData = oData;
return oChainObject;
} | [
"function",
"(",
"oChainObject",
")",
"{",
"function",
"isBuiltInType",
"(",
"type",
")",
"{",
"return",
"formatters",
".",
"_baseTypes",
".",
"indexOf",
"(",
"type",
")",
">=",
"0",
";",
"}",
"/**\n\t\t * Heuristically determining if there is a possibility the given ... | Transforms api.json file
@param {object} oChainObject chain object | [
"Transforms",
"api",
".",
"json",
"file"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L61-L683 | train | Checks if the given string is a built - in type of symbol | [
30522,
3853,
1006,
28166,
8113,
16429,
20614,
1007,
1063,
3853,
2003,
8569,
4014,
7629,
13874,
1006,
2828,
1007,
1063,
2709,
4289,
7747,
1012,
1035,
2918,
13874,
2015,
1012,
5950,
11253,
1006,
2828,
1007,
1028,
1027,
1014,
1025,
1065,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js | findAllExpressions | function findAllExpressions(parentBlockStatement, expn, text) {
var doc = session.editor.document,
obj = {},
expns = [];
// find all references of the expression
obj[expn.type] = function(node) {
if (text === doc.getText().substr(node.start, node.end - node.start)) {
expns.push(node);
}
};
ASTWalker.simple(parentBlockStatement, obj);
return expns;
} | javascript | function findAllExpressions(parentBlockStatement, expn, text) {
var doc = session.editor.document,
obj = {},
expns = [];
// find all references of the expression
obj[expn.type] = function(node) {
if (text === doc.getText().substr(node.start, node.end - node.start)) {
expns.push(node);
}
};
ASTWalker.simple(parentBlockStatement, obj);
return expns;
} | [
"function",
"findAllExpressions",
"(",
"parentBlockStatement",
",",
"expn",
",",
"text",
")",
"{",
"var",
"doc",
"=",
"session",
".",
"editor",
".",
"document",
",",
"obj",
"=",
"{",
"}",
",",
"expns",
"=",
"[",
"]",
";",
"// find all references of the expre... | Find all expressions in the parentBlockStatement that are same as expn
@param {!ASTNode} parentBlockStatement
@param {!ASTNode} expn
@param {!string} text - text of the expression
@return {!Array.<ASTNode>} | [
"Find",
"all",
"expressions",
"in",
"the",
"parentBlockStatement",
"that",
"are",
"same",
"as",
"expn"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js#L106-L120 | train | find all expressions in the block | [
30522,
3853,
2424,
24164,
2595,
20110,
8496,
1006,
6687,
23467,
9153,
18532,
4765,
1010,
4654,
2361,
2078,
1010,
3793,
1007,
1063,
13075,
9986,
1027,
5219,
1012,
3559,
1012,
6254,
1010,
27885,
3501,
1027,
1063,
1065,
1010,
4654,
2361,
3619,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mochajs/mocha | lib/runnable.js | multiple | function multiple(err) {
if (emitted) {
return;
}
emitted = true;
var msg = 'done() called multiple times';
if (err && err.message) {
err.message += " (and Mocha's " + msg + ')';
self.emit('error', err);
} else {
self.emit('error', new Error(msg));
}
} | javascript | function multiple(err) {
if (emitted) {
return;
}
emitted = true;
var msg = 'done() called multiple times';
if (err && err.message) {
err.message += " (and Mocha's " + msg + ')';
self.emit('error', err);
} else {
self.emit('error', new Error(msg));
}
} | [
"function",
"multiple",
"(",
"err",
")",
"{",
"if",
"(",
"emitted",
")",
"{",
"return",
";",
"}",
"emitted",
"=",
"true",
";",
"var",
"msg",
"=",
"'done() called multiple times'",
";",
"if",
"(",
"err",
"&&",
"err",
".",
"message",
")",
"{",
"err",
"... | called multiple times | [
"called",
"multiple",
"times"
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/runnable.js#L303-L315 | train | Called when a single task is called | [
30522,
3853,
3674,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
22627,
1007,
1063,
2709,
1025,
1065,
22627,
1027,
2995,
1025,
13075,
5796,
2290,
1027,
1005,
2589,
1006,
1007,
2170,
3674,
2335,
1005,
1025,
2065,
1006,
9413,
2099,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function () {
// Ensure that there is no open WebSocket from a previous Connection.
this._closeSocket();
// Create the new WobSocket
this.socket = new WebSocket(this._conn.service, "xmpp");
this.socket.onopen = this._onOpen.bind(this);
this.socket.onerror = this._onError.bind(this);
this.socket.onclose = this._onClose.bind(this);
this.socket.onmessage = this._connect_cb_wrapper.bind(this);
} | javascript | function () {
// Ensure that there is no open WebSocket from a previous Connection.
this._closeSocket();
// Create the new WobSocket
this.socket = new WebSocket(this._conn.service, "xmpp");
this.socket.onopen = this._onOpen.bind(this);
this.socket.onerror = this._onError.bind(this);
this.socket.onclose = this._onClose.bind(this);
this.socket.onmessage = this._connect_cb_wrapper.bind(this);
} | [
"function",
"(",
")",
"{",
"// Ensure that there is no open WebSocket from a previous Connection.\r",
"this",
".",
"_closeSocket",
"(",
")",
";",
"// Create the new WobSocket\r",
"this",
".",
"socket",
"=",
"new",
"WebSocket",
"(",
"this",
".",
"_conn",
".",
"service",
... | PrivateFunction: _connect
_Private_ function called by Strophe.Connection.connect
Creates a WebSocket for a connection and assigns Callbacks to it.
Does nothing if there already is a WebSocket. | [
"PrivateFunction",
":",
"_connect",
"_Private_",
"function",
"called",
"by",
"Strophe",
".",
"Connection",
".",
"connect"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4862-L4872 | train | Called when the connection is established | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
5676,
2008,
2045,
2003,
2053,
2330,
4773,
6499,
19869,
2102,
2013,
1037,
3025,
4434,
1012,
2023,
1012,
1035,
14572,
7432,
3388,
1006,
1007,
1025,
1013,
1013,
3443,
1996,
2047,
24185,
5910,
7432,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_Ref8U | function parse_Ref8U(blob) {
var rwFirst = blob.read_shift(2);
var rwLast = blob.read_shift(2);
var colFirst = blob.read_shift(2);
var colLast = blob.read_shift(2);
return {s:{c:colFirst, r:rwFirst}, e:{c:colLast,r:rwLast}};
} | javascript | function parse_Ref8U(blob) {
var rwFirst = blob.read_shift(2);
var rwLast = blob.read_shift(2);
var colFirst = blob.read_shift(2);
var colLast = blob.read_shift(2);
return {s:{c:colFirst, r:rwFirst}, e:{c:colLast,r:rwLast}};
} | [
"function",
"parse_Ref8U",
"(",
"blob",
")",
"{",
"var",
"rwFirst",
"=",
"blob",
".",
"read_shift",
"(",
"2",
")",
";",
"var",
"rwLast",
"=",
"blob",
".",
"read_shift",
"(",
"2",
")",
";",
"var",
"colFirst",
"=",
"blob",
".",
"read_shift",
"(",
"2",
... | /* [MS-XLS] 2.5.209 TODO: Check sizes | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"209",
"TODO",
":",
"Check",
"sizes"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5625-L5631 | train | Parse a Ref8U | [
30522,
3853,
11968,
3366,
1035,
25416,
2620,
2226,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
1054,
2860,
8873,
12096,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1016,
1007,
1025,
13075,
1054,
13668,
14083,
1027,
1038,
4135,
2497... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | range | function range(start, end)
{
if (arguments.length == 1) {
var end = start;
start = 0;
}
var r = [];
if (start < end) {
while (start != end)
r.push(start++);
}
else {
while (start != end)
r.push(start--);
}
return r;
} | javascript | function range(start, end)
{
if (arguments.length == 1) {
var end = start;
start = 0;
}
var r = [];
if (start < end) {
while (start != end)
r.push(start++);
}
else {
while (start != end)
r.push(start--);
}
return r;
} | [
"function",
"range",
"(",
"start",
",",
"end",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"{",
"var",
"end",
"=",
"start",
";",
"start",
"=",
"0",
";",
"}",
"var",
"r",
"=",
"[",
"]",
";",
"if",
"(",
"start",
"<",
"end",... | Emulates python's range() built-in. Returns an array of integers, counting
up (or down) from start to end. Note that the range returned is up to, but
NOT INCLUDING, end.
.
@param start integer from which to start counting. If the end parameter is
not provided, this value is considered the end and start will
be zero.
@param end integer to which to count. If omitted, the function will count
up from zero to the value of the start parameter. Note that
the array returned will count up to but will not include this
value.
@return an array of consecutive integers. | [
"Emulates",
"python",
"s",
"range",
"()",
"built",
"-",
"in",
".",
"Returns",
"an",
"array",
"of",
"integers",
"counting",
"up",
"(",
"or",
"down",
")",
"from",
"start",
"to",
"end",
".",
"Note",
"that",
"the",
"range",
"returned",
"is",
"up",
"to",
... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L2455-L2472 | train | returns an array of the ids of the terms | [
30522,
3853,
2846,
1006,
2707,
1010,
2203,
1007,
1063,
2065,
1006,
9918,
1012,
3091,
1027,
1027,
1015,
1007,
1063,
13075,
2203,
1027,
2707,
1025,
2707,
1027,
1014,
1025,
1065,
13075,
1054,
1027,
1031,
1033,
1025,
2065,
1006,
2707,
1026,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | findSurroundASTNode | function findSurroundASTNode(ast, expn, types) {
var foundNode = ASTWalker.findNodeAround(ast, expn.start, function (nodeType, node) {
if (expn.end) {
return types.includes(nodeType) && node.end >= expn.end;
} else {
return types.includes(nodeType);
}
});
return foundNode && _.clone(foundNode.node);
} | javascript | function findSurroundASTNode(ast, expn, types) {
var foundNode = ASTWalker.findNodeAround(ast, expn.start, function (nodeType, node) {
if (expn.end) {
return types.includes(nodeType) && node.end >= expn.end;
} else {
return types.includes(nodeType);
}
});
return foundNode && _.clone(foundNode.node);
} | [
"function",
"findSurroundASTNode",
"(",
"ast",
",",
"expn",
",",
"types",
")",
"{",
"var",
"foundNode",
"=",
"ASTWalker",
".",
"findNodeAround",
"(",
"ast",
",",
"expn",
".",
"start",
",",
"function",
"(",
"nodeType",
",",
"node",
")",
"{",
"if",
"(",
... | Finds the surrounding ast node of the given expression of any of the given types
@param {!ASTNode} ast
@param {!{start: number, end: number}} expn - contains start and end offsets of expn
@param {!Array.<string>} types
@return {?ASTNode} | [
"Finds",
"the",
"surrounding",
"ast",
"node",
"of",
"the",
"given",
"expression",
"of",
"any",
"of",
"the",
"given",
"types"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L322-L331 | train | Find surround AST node | [
30522,
3853,
4858,
3126,
22494,
8943,
3367,
3630,
3207,
1006,
2004,
2102,
1010,
4654,
2361,
2078,
1010,
4127,
1007,
1063,
13075,
2179,
3630,
3207,
1027,
2004,
2102,
26965,
1012,
2424,
3630,
3207,
24490,
1006,
2004,
2102,
1010,
4654,
2361,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws-amplify/amplify-js | packages/amazon-cognito-identity-js/src/BigInteger.js | bnpDRShiftTo | function bnpDRShiftTo(n, r) {
for (var i = n; i < this.t; ++i)
r[i - n] = this[i];
r.t = Math.max(this.t - n, 0);
r.s = this.s;
} | javascript | function bnpDRShiftTo(n, r) {
for (var i = n; i < this.t; ++i)
r[i - n] = this[i];
r.t = Math.max(this.t - n, 0);
r.s = this.s;
} | [
"function",
"bnpDRShiftTo",
"(",
"n",
",",
"r",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"n",
";",
"i",
"<",
"this",
".",
"t",
";",
"++",
"i",
")",
"r",
"[",
"i",
"-",
"n",
"]",
"=",
"this",
"[",
"i",
"]",
";",
"r",
".",
"t",
"=",
"Math",... | (protected) r = this >> n*DB | [
"(",
"protected",
")",
"r",
"=",
"this",
">>",
"n",
"*",
"DB"
] | db55ff3dff31c64a246180f39eb0a04a89fd16e1 | https://github.com/aws-amplify/amplify-js/blob/db55ff3dff31c64a246180f39eb0a04a89fd16e1/packages/amazon-cognito-identity-js/src/BigInteger.js#L327-L332 | train | Shifts the sequence by n to the end of the sequence | [
30522,
3853,
24869,
17299,
2869,
4048,
6199,
3406,
1006,
1050,
1010,
1054,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
30524,
2023,
1012,
1056,
1025,
1009,
1009,
1045,
1007,
1054,
1031,
1045,
1011,
1050,
1033,
1027,
2023,
1031,
1045,
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... |
dequelabs/axe-core | lib/core/utils/get-xpath.js | getXPathArray | function getXPathArray(node, path) {
var sibling, count;
// Gets an XPath for an element which describes its hierarchical location.
if (!node) {
return [];
}
if (!path && node.nodeType === 9) {
// special case for when we are called and give the document itself as the starting node
path = [
{
str: 'html'
}
];
return path;
}
path = path || [];
if (node.parentNode && node.parentNode !== node) {
path = getXPathArray(node.parentNode, path);
}
if (node.previousSibling) {
count = 1;
sibling = node.previousSibling;
do {
if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) {
count++;
}
sibling = sibling.previousSibling;
} while (sibling);
if (count === 1) {
count = null;
}
} else if (node.nextSibling) {
sibling = node.nextSibling;
do {
if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) {
count = 1;
sibling = null;
} else {
count = null;
sibling = sibling.previousSibling;
}
} while (sibling);
}
if (node.nodeType === 1) {
var element = {};
element.str = node.nodeName.toLowerCase();
// add the id and the count so we can construct robust versions of the xpath
var id =
node.getAttribute && axe.utils.escapeSelector(node.getAttribute('id'));
if (id && node.ownerDocument.querySelectorAll('#' + id).length === 1) {
element.id = node.getAttribute('id');
}
if (count > 1) {
element.count = count;
}
path.push(element);
}
return path;
} | javascript | function getXPathArray(node, path) {
var sibling, count;
// Gets an XPath for an element which describes its hierarchical location.
if (!node) {
return [];
}
if (!path && node.nodeType === 9) {
// special case for when we are called and give the document itself as the starting node
path = [
{
str: 'html'
}
];
return path;
}
path = path || [];
if (node.parentNode && node.parentNode !== node) {
path = getXPathArray(node.parentNode, path);
}
if (node.previousSibling) {
count = 1;
sibling = node.previousSibling;
do {
if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) {
count++;
}
sibling = sibling.previousSibling;
} while (sibling);
if (count === 1) {
count = null;
}
} else if (node.nextSibling) {
sibling = node.nextSibling;
do {
if (sibling.nodeType === 1 && sibling.nodeName === node.nodeName) {
count = 1;
sibling = null;
} else {
count = null;
sibling = sibling.previousSibling;
}
} while (sibling);
}
if (node.nodeType === 1) {
var element = {};
element.str = node.nodeName.toLowerCase();
// add the id and the count so we can construct robust versions of the xpath
var id =
node.getAttribute && axe.utils.escapeSelector(node.getAttribute('id'));
if (id && node.ownerDocument.querySelectorAll('#' + id).length === 1) {
element.id = node.getAttribute('id');
}
if (count > 1) {
element.count = count;
}
path.push(element);
}
return path;
} | [
"function",
"getXPathArray",
"(",
"node",
",",
"path",
")",
"{",
"var",
"sibling",
",",
"count",
";",
"// Gets an XPath for an element which describes its hierarchical location.",
"if",
"(",
"!",
"node",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"!",
... | /*global axe | [
"/",
"*",
"global",
"axe"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/get-xpath.js#L3-L63 | train | Returns an array of XPath expression nodes that are closest to the given node. | [
30522,
3853,
2131,
2595,
15069,
2906,
9447,
1006,
13045,
1010,
4130,
1007,
1063,
13075,
22941,
1010,
4175,
1025,
1013,
1013,
4152,
2019,
26726,
8988,
2005,
2019,
5783,
2029,
5577,
2049,
25835,
3295,
1012,
2065,
1006,
999,
13045,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js | chain | function chain(fnAfter, fnBefore) {
if (!fnBefore) {
return fnAfter;
}
function formatter() {
return fnAfter.call(this, fnBefore.apply(this, arguments));
}
return formatter;
} | javascript | function chain(fnAfter, fnBefore) {
if (!fnBefore) {
return fnAfter;
}
function formatter() {
return fnAfter.call(this, fnBefore.apply(this, arguments));
}
return formatter;
} | [
"function",
"chain",
"(",
"fnAfter",
",",
"fnBefore",
")",
"{",
"if",
"(",
"!",
"fnBefore",
")",
"{",
"return",
"fnAfter",
";",
"}",
"function",
"formatter",
"(",
")",
"{",
"return",
"fnAfter",
".",
"call",
"(",
"this",
",",
"fnBefore",
".",
"apply",
... | Returns a function representing the composition <code>fnAfter</code> after
<code>fnBefore</code>.
@param {function} fnAfter
the second function, taking a single argument
@param {function} [fnBefore]
the optional first function, taking multiple arguments
@returns {function}
the composition <code>fnAfter</code> after <code>fnBefore</code> | [
"Returns",
"a",
"function",
"representing",
"the",
"composition",
"<code",
">",
"fnAfter<",
"/",
"code",
">",
"after",
"<code",
">",
"fnBefore<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js#L25-L34 | train | Chain a function to a function | [
30522,
3853,
4677,
1006,
1042,
2532,
6199,
2121,
1010,
1042,
27698,
12879,
5686,
1007,
1063,
2065,
1006,
999,
1042,
27698,
12879,
5686,
1007,
1063,
2709,
1042,
2532,
6199,
2121,
1025,
1065,
3853,
4289,
3334,
1006,
1007,
1063,
2709,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.