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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
angular/material | src/core/util/util.js | disableBodyScroll | function disableBodyScroll() {
var documentElement = $document[0].documentElement;
var prevDocumentStyle = documentElement.style.cssText || '';
var prevBodyStyle = body.style.cssText || '';
var viewportTop = $mdUtil.getViewportTop();
$mdUtil.disableScrollAround._viewPortTop = viewportTop;
var clientWidth = body.clientWidth;
var hasVerticalScrollbar = body.scrollHeight > body.clientHeight + 1;
// Scroll may be set on <html> element (for example by overflow-y: scroll)
// but Chrome is reporting the scrollTop position always on <body>.
// scrollElement will allow to restore the scrollTop position to proper target.
var scrollElement = documentElement.scrollTop > 0 ? documentElement : body;
if (hasVerticalScrollbar) {
angular.element(body).css({
position: 'fixed',
width: '100%',
top: -viewportTop + 'px'
});
}
if (body.clientWidth < clientWidth) {
body.style.overflow = 'hidden';
}
return function restoreScroll() {
// Reset the inline style CSS to the previous.
body.style.cssText = prevBodyStyle;
documentElement.style.cssText = prevDocumentStyle;
// The scroll position while being fixed
scrollElement.scrollTop = viewportTop;
};
} | javascript | function disableBodyScroll() {
var documentElement = $document[0].documentElement;
var prevDocumentStyle = documentElement.style.cssText || '';
var prevBodyStyle = body.style.cssText || '';
var viewportTop = $mdUtil.getViewportTop();
$mdUtil.disableScrollAround._viewPortTop = viewportTop;
var clientWidth = body.clientWidth;
var hasVerticalScrollbar = body.scrollHeight > body.clientHeight + 1;
// Scroll may be set on <html> element (for example by overflow-y: scroll)
// but Chrome is reporting the scrollTop position always on <body>.
// scrollElement will allow to restore the scrollTop position to proper target.
var scrollElement = documentElement.scrollTop > 0 ? documentElement : body;
if (hasVerticalScrollbar) {
angular.element(body).css({
position: 'fixed',
width: '100%',
top: -viewportTop + 'px'
});
}
if (body.clientWidth < clientWidth) {
body.style.overflow = 'hidden';
}
return function restoreScroll() {
// Reset the inline style CSS to the previous.
body.style.cssText = prevBodyStyle;
documentElement.style.cssText = prevDocumentStyle;
// The scroll position while being fixed
scrollElement.scrollTop = viewportTop;
};
} | [
"function",
"disableBodyScroll",
"(",
")",
"{",
"var",
"documentElement",
"=",
"$document",
"[",
"0",
"]",
".",
"documentElement",
";",
"var",
"prevDocumentStyle",
"=",
"documentElement",
".",
"style",
".",
"cssText",
"||",
"''",
";",
"var",
"prevBodyStyle",
"... | Converts the body to a position fixed block and translate it to the proper scroll position | [
"Converts",
"the",
"body",
"to",
"a",
"position",
"fixed",
"block",
"and",
"translate",
"it",
"to",
"the",
"proper",
"scroll",
"position"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L285-L321 | train | This function is called when the body is not visible. | [
30522,
3853,
4487,
19150,
23684,
11020,
28402,
30524,
2303,
1012,
2806,
1012,
20116,
13473,
18413,
1064,
1064,
1005,
1005,
1025,
13075,
3193,
6442,
14399,
1027,
1002,
9108,
21823,
2140,
1012,
2131,
8584,
6442,
14399,
1006,
1007,
1025,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HTMLUtils.js | createTagInfo | function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
return { tagName: tagName || "",
attr:
{ name: attrName || "",
value: attrValue || "",
valueAssigned: valueAssigned || false,
quoteChar: quoteChar || "",
hasEndQuote: hasEndQuote || false },
position:
{ tokenType: tokenType || "",
offset: offset || 0 } };
} | javascript | function createTagInfo(tokenType, offset, tagName, attrName, attrValue, valueAssigned, quoteChar, hasEndQuote) {
return { tagName: tagName || "",
attr:
{ name: attrName || "",
value: attrValue || "",
valueAssigned: valueAssigned || false,
quoteChar: quoteChar || "",
hasEndQuote: hasEndQuote || false },
position:
{ tokenType: tokenType || "",
offset: offset || 0 } };
} | [
"function",
"createTagInfo",
"(",
"tokenType",
",",
"offset",
",",
"tagName",
",",
"attrName",
",",
"attrValue",
",",
"valueAssigned",
",",
"quoteChar",
",",
"hasEndQuote",
")",
"{",
"return",
"{",
"tagName",
":",
"tagName",
"||",
"\"\"",
",",
"attr",
":",
... | Creates a tagInfo object and assures all the values are entered or are empty strings
@param {string=} tokenType what is getting edited and should be hinted
@param {number=} offset where the cursor is for the part getting hinted
@param {string=} tagName The name of the tag
@param {string=} attrName The name of the attribute
@param {string=} attrValue The value of the attribute
@return {{tagName:string,
attr:{name:string, value:string, valueAssigned:boolean, quoteChar:string, hasEndQuote:boolean},
position:{tokenType:string, offset:number}
}}
A tagInfo object with some context about the current tag hint. | [
"Creates",
"a",
"tagInfo",
"object",
"and",
"assures",
"all",
"the",
"values",
"are",
"entered",
"or",
"are",
"empty",
"strings"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/HTMLUtils.js#L188-L199 | train | Creates a tag info object | [
30522,
3853,
3443,
15900,
2378,
14876,
1006,
19204,
13874,
1010,
16396,
1010,
6415,
18442,
1010,
2012,
16344,
18442,
1010,
2012,
16344,
10175,
5657,
1010,
3643,
12054,
23773,
2098,
1010,
14686,
7507,
2099,
1010,
2038,
10497,
28940,
12184,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FindUtils.js | _doReplaceInDocument | function _doReplaceInDocument(doc, matchInfo, replaceText, isRegexp) {
// Double-check that the open document's timestamp matches the one we recorded. This
// should normally never go out of sync, because if it did we wouldn't start the
// replace in the first place (due to the fact that we immediately close the search
// results panel whenever we detect a filesystem change that affects the results),
// but we want to double-check in case we don't happen to get the change in time.
// This will *not* handle cases where the document has been edited in memory since
// the matchInfo was generated.
if (doc.diskTimestamp.getTime() !== matchInfo.timestamp.getTime()) {
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Do the replacements in reverse document order so the offsets continue to be correct.
doc.batchOperation(function () {
matchInfo.matches.reverse().forEach(function (match) {
if (match.isChecked) {
doc.replaceRange(isRegexp ? parseDollars(replaceText, match.result) : replaceText, match.start, match.end);
}
});
});
return new $.Deferred().resolve().promise();
} | javascript | function _doReplaceInDocument(doc, matchInfo, replaceText, isRegexp) {
// Double-check that the open document's timestamp matches the one we recorded. This
// should normally never go out of sync, because if it did we wouldn't start the
// replace in the first place (due to the fact that we immediately close the search
// results panel whenever we detect a filesystem change that affects the results),
// but we want to double-check in case we don't happen to get the change in time.
// This will *not* handle cases where the document has been edited in memory since
// the matchInfo was generated.
if (doc.diskTimestamp.getTime() !== matchInfo.timestamp.getTime()) {
return new $.Deferred().reject(exports.ERROR_FILE_CHANGED).promise();
}
// Do the replacements in reverse document order so the offsets continue to be correct.
doc.batchOperation(function () {
matchInfo.matches.reverse().forEach(function (match) {
if (match.isChecked) {
doc.replaceRange(isRegexp ? parseDollars(replaceText, match.result) : replaceText, match.start, match.end);
}
});
});
return new $.Deferred().resolve().promise();
} | [
"function",
"_doReplaceInDocument",
"(",
"doc",
",",
"matchInfo",
",",
"replaceText",
",",
"isRegexp",
")",
"{",
"// Double-check that the open document's timestamp matches the one we recorded. This",
"// should normally never go out of sync, because if it did we wouldn't start the",
"//... | Does a set of replacements in a single document in memory.
@param {!Document} doc The document to do the replacements in.
@param {Object} matchInfo The match info for this file, as returned by `_addSearchMatches()`. Might be mutated.
@param {string} replaceText The text to replace each result with.
@param {boolean=} isRegexp Whether the original query was a regexp.
@return {$.Promise} A promise that's resolved when the replacement is finished or rejected with an error if there were one or more errors. | [
"Does",
"a",
"set",
"of",
"replacements",
"in",
"a",
"single",
"document",
"in",
"memory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L113-L135 | train | Replace the text in the search result set | [
30522,
3853,
1035,
2079,
2890,
24759,
10732,
22254,
10085,
27417,
2102,
1006,
9986,
1010,
2674,
2378,
14876,
1010,
5672,
18209,
1010,
2003,
2890,
3351,
2595,
2361,
1007,
1063,
1013,
1013,
3313,
1011,
4638,
2008,
1996,
2330,
6254,
1005,
1055... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/file-finder.js | normalizeDirectoryEntries | function normalizeDirectoryEntries(entries, directory, supportedConfigs) {
const fileHash = {};
entries.forEach(entry => {
if (supportedConfigs.indexOf(entry) >= 0) {
const resolvedEntry = path.resolve(directory, entry);
if (fs.statSync(resolvedEntry).isFile()) {
fileHash[entry] = resolvedEntry;
}
}
});
return fileHash;
} | javascript | function normalizeDirectoryEntries(entries, directory, supportedConfigs) {
const fileHash = {};
entries.forEach(entry => {
if (supportedConfigs.indexOf(entry) >= 0) {
const resolvedEntry = path.resolve(directory, entry);
if (fs.statSync(resolvedEntry).isFile()) {
fileHash[entry] = resolvedEntry;
}
}
});
return fileHash;
} | [
"function",
"normalizeDirectoryEntries",
"(",
"entries",
",",
"directory",
",",
"supportedConfigs",
")",
"{",
"const",
"fileHash",
"=",
"{",
"}",
";",
"entries",
".",
"forEach",
"(",
"entry",
"=>",
"{",
"if",
"(",
"supportedConfigs",
".",
"indexOf",
"(",
"en... | Create a hash of filenames from a directory listing
@param {string[]} entries Array of directory entries.
@param {string} directory Path to a current directory.
@param {string[]} supportedConfigs List of support filenames.
@returns {Object} Hashmap of filenames | [
"Create",
"a",
"hash",
"of",
"filenames",
"from",
"a",
"directory",
"listing"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/file-finder.js#L42-L55 | train | normalize directory entries | [
30522,
3853,
3671,
3550,
7442,
16761,
20684,
21011,
1006,
10445,
1010,
14176,
1010,
3569,
8663,
8873,
5620,
1007,
1063,
9530,
3367,
5371,
14949,
2232,
1027,
1063,
1065,
1025,
10445,
1012,
18921,
6776,
1006,
4443,
1027,
1028,
1063,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/ViewUtils.js | function (map) {
var didSomething = false;
_.forEach(map, function (arr, key) {
// length > 1 means we have duplicates that need to be resolved
if (arr.length > 1) {
arr.forEach(function (index) {
if (filePaths[index].length !== 0) {
displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index];
didSomething = true;
if (!map[displayPaths[index]]) {
map[displayPaths[index]] = [index];
} else {
map[displayPaths[index]].push(index);
}
}
});
}
delete map[key];
});
return didSomething;
} | javascript | function (map) {
var didSomething = false;
_.forEach(map, function (arr, key) {
// length > 1 means we have duplicates that need to be resolved
if (arr.length > 1) {
arr.forEach(function (index) {
if (filePaths[index].length !== 0) {
displayPaths[index] = filePaths[index].pop() + "/" + displayPaths[index];
didSomething = true;
if (!map[displayPaths[index]]) {
map[displayPaths[index]] = [index];
} else {
map[displayPaths[index]].push(index);
}
}
});
}
delete map[key];
});
return didSomething;
} | [
"function",
"(",
"map",
")",
"{",
"var",
"didSomething",
"=",
"false",
";",
"_",
".",
"forEach",
"(",
"map",
",",
"function",
"(",
"arr",
",",
"key",
")",
"{",
"// length > 1 means we have duplicates that need to be resolved",
"if",
"(",
"arr",
".",
"length",
... | This function is used to loop through map and resolve duplicate names | [
"This",
"function",
"is",
"used",
"to",
"loop",
"through",
"map",
"and",
"resolve",
"duplicate",
"names"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ViewUtils.js#L440-L461 | train | return true if we have duplicates | [
30522,
3853,
1006,
4949,
1007,
1063,
13075,
2106,
14045,
20744,
1027,
6270,
1025,
1035,
1012,
18921,
6776,
1006,
4949,
1010,
3853,
1006,
12098,
2099,
1010,
3145,
1007,
1063,
1013,
1013,
3091,
1028,
1015,
2965,
2057,
2031,
24473,
2015,
2008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js | getScopeBasedDesignTime | function getScopeBasedDesignTime(mMetadata, sScopeKey) {
var mResult = mMetadata;
if ("default" in mMetadata) {
mResult = merge(
{},
mMetadata.default,
sScopeKey !== "default" && mMetadata[sScopeKey] || null
);
}
return mResult;
} | javascript | function getScopeBasedDesignTime(mMetadata, sScopeKey) {
var mResult = mMetadata;
if ("default" in mMetadata) {
mResult = merge(
{},
mMetadata.default,
sScopeKey !== "default" && mMetadata[sScopeKey] || null
);
}
return mResult;
} | [
"function",
"getScopeBasedDesignTime",
"(",
"mMetadata",
",",
"sScopeKey",
")",
"{",
"var",
"mResult",
"=",
"mMetadata",
";",
"if",
"(",
"\"default\"",
"in",
"mMetadata",
")",
"{",
"mResult",
"=",
"merge",
"(",
"{",
"}",
",",
"mMetadata",
".",
"default",
"... | Extracts metadata from metadata map by scope key
@param {object} mMetadata metadata map received from loader
@param {string} sScopeKey scope name to be extracted
@private | [
"Extracts",
"metadata",
"from",
"metadata",
"map",
"by",
"scope",
"key"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js#L1873-L1885 | train | Returns a new object with the default design time as the scope key | [
30522,
3853,
4152,
16186,
15058,
14141,
2229,
23773,
7292,
1006,
3461,
12928,
2850,
2696,
1010,
7020,
16186,
14839,
1007,
1063,
13075,
2720,
2229,
11314,
1027,
3461,
12928,
2850,
2696,
1025,
2065,
1006,
1000,
12398,
1000,
1999,
3461,
12928,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | dist/js/demo.js | setup | function setup() {
var tmp = get('skin')
if (tmp && $.inArray(tmp, mySkins))
changeSkin(tmp)
// Add the change skin listener
$('[data-skin]').on('click', function (e) {
if ($(this).hasClass('knob'))
return
e.preventDefault()
changeSkin($(this).data('skin'))
})
// Add the layout manager
$('[data-layout]').on('click', function () {
changeLayout($(this).data('layout'))
})
$('[data-controlsidebar]').on('click', function () {
changeLayout($(this).data('controlsidebar'))
var slide = !$controlSidebar.options.slide
$controlSidebar.options.slide = slide
if (!slide)
$('.control-sidebar').removeClass('control-sidebar-open')
})
$('[data-sidebarskin="toggle"]').on('click', function () {
var $sidebar = $('.control-sidebar')
if ($sidebar.hasClass('control-sidebar-dark')) {
$sidebar.removeClass('control-sidebar-dark')
$sidebar.addClass('control-sidebar-light')
} else {
$sidebar.removeClass('control-sidebar-light')
$sidebar.addClass('control-sidebar-dark')
}
})
$('[data-enable="expandOnHover"]').on('click', function () {
$(this).attr('disabled', true)
$pushMenu.expandOnHover()
if (!$('body').hasClass('sidebar-collapse'))
$('[data-layout="sidebar-collapse"]').click()
})
// Reset options
if ($('body').hasClass('fixed')) {
$('[data-layout="fixed"]').attr('checked', 'checked')
}
if ($('body').hasClass('layout-boxed')) {
$('[data-layout="layout-boxed"]').attr('checked', 'checked')
}
if ($('body').hasClass('sidebar-collapse')) {
$('[data-layout="sidebar-collapse"]').attr('checked', 'checked')
}
} | javascript | function setup() {
var tmp = get('skin')
if (tmp && $.inArray(tmp, mySkins))
changeSkin(tmp)
// Add the change skin listener
$('[data-skin]').on('click', function (e) {
if ($(this).hasClass('knob'))
return
e.preventDefault()
changeSkin($(this).data('skin'))
})
// Add the layout manager
$('[data-layout]').on('click', function () {
changeLayout($(this).data('layout'))
})
$('[data-controlsidebar]').on('click', function () {
changeLayout($(this).data('controlsidebar'))
var slide = !$controlSidebar.options.slide
$controlSidebar.options.slide = slide
if (!slide)
$('.control-sidebar').removeClass('control-sidebar-open')
})
$('[data-sidebarskin="toggle"]').on('click', function () {
var $sidebar = $('.control-sidebar')
if ($sidebar.hasClass('control-sidebar-dark')) {
$sidebar.removeClass('control-sidebar-dark')
$sidebar.addClass('control-sidebar-light')
} else {
$sidebar.removeClass('control-sidebar-light')
$sidebar.addClass('control-sidebar-dark')
}
})
$('[data-enable="expandOnHover"]').on('click', function () {
$(this).attr('disabled', true)
$pushMenu.expandOnHover()
if (!$('body').hasClass('sidebar-collapse'))
$('[data-layout="sidebar-collapse"]').click()
})
// Reset options
if ($('body').hasClass('fixed')) {
$('[data-layout="fixed"]').attr('checked', 'checked')
}
if ($('body').hasClass('layout-boxed')) {
$('[data-layout="layout-boxed"]').attr('checked', 'checked')
}
if ($('body').hasClass('sidebar-collapse')) {
$('[data-layout="sidebar-collapse"]').attr('checked', 'checked')
}
} | [
"function",
"setup",
"(",
")",
"{",
"var",
"tmp",
"=",
"get",
"(",
"'skin'",
")",
"if",
"(",
"tmp",
"&&",
"$",
".",
"inArray",
"(",
"tmp",
",",
"mySkins",
")",
")",
"changeSkin",
"(",
"tmp",
")",
"// Add the change skin listener",
"$",
"(",
"'[data-ski... | Retrieve default settings and apply them to the template
@returns void | [
"Retrieve",
"default",
"settings",
"and",
"apply",
"them",
"to",
"the",
"template"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/dist/js/demo.js#L111-L167 | train | Setup the calendar | [
30522,
3853,
16437,
1006,
1007,
1063,
13075,
1056,
8737,
1027,
2131,
1006,
1005,
3096,
1005,
1007,
2065,
1006,
1056,
8737,
1004,
1004,
1002,
1012,
27118,
11335,
2100,
1006,
1056,
8737,
1010,
2026,
29334,
2015,
1007,
1007,
3431,
4939,
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/GotoAgent.js | _makeCSSTarget | function _makeCSSTarget(targets, rule) {
if (rule.sourceURL) {
var url = rule.sourceURL;
url += ":" + rule.style.range.start;
var name = rule.selectorList.text;
var file = _fileFromURL(url);
targets.push({"type": "css", "url": url, "name": name, "file": file});
}
} | javascript | function _makeCSSTarget(targets, rule) {
if (rule.sourceURL) {
var url = rule.sourceURL;
url += ":" + rule.style.range.start;
var name = rule.selectorList.text;
var file = _fileFromURL(url);
targets.push({"type": "css", "url": url, "name": name, "file": file});
}
} | [
"function",
"_makeCSSTarget",
"(",
"targets",
",",
"rule",
")",
"{",
"if",
"(",
"rule",
".",
"sourceURL",
")",
"{",
"var",
"url",
"=",
"rule",
".",
"sourceURL",
";",
"url",
"+=",
"\":\"",
"+",
"rule",
".",
"style",
".",
"range",
".",
"start",
";",
... | Make the given css rule a target for goto
@param [] targets array
@param {CSS.Rule} node | [
"Make",
"the",
"given",
"css",
"rule",
"a",
"target",
"for",
"goto"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/GotoAgent.js#L85-L93 | train | makeCSSTarget - make target for CSS rule | [
30522,
3853,
1035,
2191,
6169,
14117,
18150,
1006,
7889,
1010,
3627,
1007,
1063,
2065,
30524,
2140,
1009,
1027,
1000,
1024,
1000,
1009,
3627,
1012,
2806,
1012,
2846,
1012,
2707,
1025,
13075,
2171,
1027,
3627,
1012,
27000,
9863,
1012,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/date/Persian.js | d2g | function d2g(jdn) {
var j, i, gd, gm, gy;
j = 4 * jdn + 139361631;
j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908;
i = div(mod(j, 1461), 4) * 5 + 308;
gd = div(mod(i, 153), 5) + 1;
gm = mod(div(i, 153), 12) + 1;
gy = div(j, 1461) - 100100 + div(8 - gm, 6);
return {
year: gy,
month: gm - 1,
day: gd
};
} | javascript | function d2g(jdn) {
var j, i, gd, gm, gy;
j = 4 * jdn + 139361631;
j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908;
i = div(mod(j, 1461), 4) * 5 + 308;
gd = div(mod(i, 153), 5) + 1;
gm = mod(div(i, 153), 12) + 1;
gy = div(j, 1461) - 100100 + div(8 - gm, 6);
return {
year: gy,
month: gm - 1,
day: gd
};
} | [
"function",
"d2g",
"(",
"jdn",
")",
"{",
"var",
"j",
",",
"i",
",",
"gd",
",",
"gm",
",",
"gy",
";",
"j",
"=",
"4",
"*",
"jdn",
"+",
"139361631",
";",
"j",
"=",
"j",
"+",
"div",
"(",
"div",
"(",
"4",
"*",
"jdn",
"+",
"183187720",
",",
"14... | /*
Calculates Gregorian and Julian calendar dates from the Julian Day number
(jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both
calendars) to some millions years ahead of the present.
@param jdn Julian Day number
@return
gy: Calendar year (years BC numbered 0, -1, -2, ...)
gm: Calendar month (1 to 12)
gd: Calendar day of the month M (1 to 28/29/30/31) | [
"/",
"*",
"Calculates",
"Gregorian",
"and",
"Julian",
"calendar",
"dates",
"from",
"the",
"Julian",
"Day",
"number",
"(",
"jdn",
")",
"for",
"the",
"period",
"since",
"jdn",
"=",
"-",
"34839655",
"(",
"i",
".",
"e",
".",
"the",
"year",
"-",
"100100",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/date/Persian.js#L249-L262 | train | Convert jdn to g | [
30522,
3853,
1040,
2475,
2290,
1006,
26219,
2078,
1007,
1063,
13075,
1046,
1010,
1045,
1010,
1043,
2094,
1010,
13938,
1010,
1043,
2100,
1025,
1046,
1027,
1018,
1008,
26219,
2078,
1009,
16621,
21619,
16048,
21486,
1025,
1046,
1027,
1046,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tailwindcss/tailwindcss | src/cli/commands/build.js | buildToStdout | function buildToStdout(compileOptions) {
return compile(compileOptions).then(result => process.stdout.write(result.css))
} | javascript | function buildToStdout(compileOptions) {
return compile(compileOptions).then(result => process.stdout.write(result.css))
} | [
"function",
"buildToStdout",
"(",
"compileOptions",
")",
"{",
"return",
"compile",
"(",
"compileOptions",
")",
".",
"then",
"(",
"result",
"=>",
"process",
".",
"stdout",
".",
"write",
"(",
"result",
".",
"css",
")",
")",
"}"
] | Compiles CSS file and writes it to stdout.
@param {CompileOptions} compileOptions
@return {Promise} | [
"Compiles",
"CSS",
"file",
"and",
"writes",
"it",
"to",
"stdout",
"."
] | 5066a1e97b3f06b899a4539767ca2bee4bde2da9 | https://github.com/tailwindcss/tailwindcss/blob/5066a1e97b3f06b899a4539767ca2bee4bde2da9/src/cli/commands/build.js#L66-L68 | train | Builds the css file and writes it to stdout | [
30522,
3853,
3857,
13122,
2102,
26797,
2102,
1006,
4012,
22090,
7361,
9285,
1007,
1063,
2709,
4012,
22090,
1006,
4012,
22090,
7361,
9285,
1007,
1012,
2059,
1006,
2765,
1027,
1028,
2832,
1012,
2358,
26797,
2102,
1012,
4339,
1006,
2765,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | getMap | function getMap(options) {
var obj = options.map;
var keys = options.keys;
var l = keys.length;
for (var i = 0; i < l; i++) {
var key = keys[i];
if (plainObject(key)) {
throw Error('Tried to get map with object key');
}
obj = obj[key];
if (obj == null) {
return obj;
}
}
return obj;
} | javascript | function getMap(options) {
var obj = options.map;
var keys = options.keys;
var l = keys.length;
for (var i = 0; i < l; i++) {
var key = keys[i];
if (plainObject(key)) {
throw Error('Tried to get map with object key');
}
obj = obj[key];
if (obj == null) {
return obj;
}
}
return obj;
} | [
"function",
"getMap",
"(",
"options",
")",
"{",
"var",
"obj",
"=",
"options",
".",
"map",
";",
"var",
"keys",
"=",
"options",
".",
"keys",
";",
"var",
"l",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
... | gets the value in a map even if it's not built in places | [
"gets",
"the",
"value",
"in",
"a",
"map",
"even",
"if",
"it",
"s",
"not",
"built",
"in",
"places"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L642-L662 | train | Get the map from the options | [
30522,
3853,
2131,
2863,
2361,
1006,
7047,
1007,
1063,
13075,
27885,
3501,
1027,
7047,
1012,
4949,
1025,
13075,
6309,
1027,
7047,
1012,
6309,
1025,
13075,
1048,
1027,
6309,
1012,
3091,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
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... |
badges/shields | services/nuget/nuget-v3-service-family.js | buildRoute | function buildRoute({ serviceBaseUrl, withTenant, withFeed }) {
let result
if (withTenant) {
result = new RouteBuilder().push(`(?:(.+)\\.)?${serviceBaseUrl}`, 'tenant')
} else {
result = new RouteBuilder({ base: serviceBaseUrl })
}
if (withFeed) {
result.push('([^/]+)', 'feed')
}
return result
} | javascript | function buildRoute({ serviceBaseUrl, withTenant, withFeed }) {
let result
if (withTenant) {
result = new RouteBuilder().push(`(?:(.+)\\.)?${serviceBaseUrl}`, 'tenant')
} else {
result = new RouteBuilder({ base: serviceBaseUrl })
}
if (withFeed) {
result.push('([^/]+)', 'feed')
}
return result
} | [
"function",
"buildRoute",
"(",
"{",
"serviceBaseUrl",
",",
"withTenant",
",",
"withFeed",
"}",
")",
"{",
"let",
"result",
"if",
"(",
"withTenant",
")",
"{",
"result",
"=",
"new",
"RouteBuilder",
"(",
")",
".",
"push",
"(",
"`",
"\\\\",
"${",
"serviceBase... | /*
Build the Shields service URL object for the given service configuration. Return
the RouteBuilder instance to which the service can add the route. | [
"/",
"*",
"Build",
"the",
"Shields",
"service",
"URL",
"object",
"for",
"the",
"given",
"service",
"configuration",
".",
"Return",
"the",
"RouteBuilder",
"instance",
"to",
"which",
"the",
"service",
"can",
"add",
"the",
"route",
"."
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/nuget/nuget-v3-service-family.js#L14-L25 | train | Build a route from a service base url and optional parameters | [
30522,
3853,
3857,
22494,
2618,
1006,
1063,
2326,
15058,
3126,
2140,
1010,
2007,
6528,
4630,
1010,
2007,
7959,
2098,
1065,
1007,
1063,
2292,
2765,
2065,
1006,
2007,
6528,
4630,
1007,
1063,
2765,
1027,
2047,
2799,
8569,
23891,
2099,
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/utils/StringMatch.js | _computeRangesAndScore | function _computeRangesAndScore(matchList, str, lastSegmentStart) {
var matchCounter;
var ranges = [];
var lastMatchIndex = -1;
var lastSegmentScore = 0;
var currentRangeStartedOnSpecial = false;
var score = 0;
var scoreDebug;
if (DEBUG_SCORES) {
scoreDebug = {
special: 0,
match: 0,
upper: 0,
lastSegment: 0,
beginning: 0,
lengthDeduction: 0,
consecutive: 0,
notStartingOnSpecial: 0
};
}
var currentRange = null;
// Records the current range and adds any additional ranges required to
// get to character index c. This function is called before starting a new range
// or returning from the function.
function closeRangeGap(c) {
// Close the current range
if (currentRange) {
currentRange.includesLastSegment = lastMatchIndex >= lastSegmentStart;
if (currentRange.matched && currentRange.includesLastSegment) {
if (DEBUG_SCORES) {
scoreDebug.lastSegment += lastSegmentScore * LAST_SEGMENT_BOOST;
}
score += lastSegmentScore * LAST_SEGMENT_BOOST;
}
if (currentRange.matched && !currentRangeStartedOnSpecial) {
if (DEBUG_SCORES) {
scoreDebug.notStartingOnSpecial -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
score -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
ranges.push(currentRange);
}
// If there was space between the new range and the last,
// add a new unmatched range before the new range can be added.
if (lastMatchIndex + 1 < c) {
ranges.push({
text: str.substring(lastMatchIndex + 1, c),
matched: false,
includesLastSegment: c > lastSegmentStart
});
}
currentRange = null;
lastSegmentScore = 0;
}
// In some cases (see the use of this variable below), we accelerate the
// bonus the more consecutive matches there are.
var numConsecutive = 0;
// Adds a matched character to the appropriate range
function addMatch(match) {
// Pull off the character index
var c = match.index;
var newPoints = 0;
// A match means that we need to do some scoring bookkeeping.
// Start with points added for any match
if (DEBUG_SCORES) {
scoreDebug.match += MATCH_POINTS;
}
newPoints += MATCH_POINTS;
if (match.upper) {
if (DEBUG_SCORES) {
scoreDebug.upper += UPPER_CASE_MATCH;
}
newPoints += UPPER_CASE_MATCH;
}
// A bonus is given for characters that match at the beginning
// of the filename
if (c === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
// If the new character immediately follows the last matched character,
// we award the consecutive matches bonus. The check for score > 0
// handles the initial value of lastMatchIndex which is used for
// constructing ranges but we don't yet have a true match.
if (score > 0 && lastMatchIndex + 1 === c) {
// Continue boosting for each additional match at the beginning
// of the name
if (c - numConsecutive === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
numConsecutive++;
var boost = CONSECUTIVE_MATCHES_POINTS * numConsecutive;
// Consecutive matches that started on a special are a
// good indicator of intent, so we award an added bonus there.
if (currentRangeStartedOnSpecial) {
boost = boost * 2;
}
if (DEBUG_SCORES) {
scoreDebug.consecutive += boost;
}
newPoints += boost;
} else {
numConsecutive = 1;
}
// add points for "special" character matches
if (match instanceof SpecialMatch) {
if (DEBUG_SCORES) {
scoreDebug.special += SPECIAL_POINTS;
}
newPoints += SPECIAL_POINTS;
}
score += newPoints;
// points accumulated in the last segment get an extra bonus
if (c >= lastSegmentStart) {
lastSegmentScore += newPoints;
}
// if the last range wasn't a match or there's a gap, we need to close off
// the range to start a new one.
if ((currentRange && !currentRange.matched) || c > lastMatchIndex + 1) {
closeRangeGap(c);
}
lastMatchIndex = c;
// set up a new match range or add to the current one
if (!currentRange) {
currentRange = {
text: str[c],
matched: true
};
// Check to see if this new matched range is starting on a special
// character. We penalize those ranges that don't, because most
// people will search on the logical boundaries of the name
currentRangeStartedOnSpecial = match instanceof SpecialMatch;
} else {
currentRange.text += str[c];
}
}
// scan through the matches, adding each one in turn
for (matchCounter = 0; matchCounter < matchList.length; matchCounter++) {
var match = matchList[matchCounter];
addMatch(match);
}
// add a range for the last part of the string
closeRangeGap(str.length);
// shorter strings that match are often better than longer ones
var lengthPenalty = -1 * Math.round(str.length * DEDUCTION_FOR_LENGTH);
if (DEBUG_SCORES) {
scoreDebug.lengthDeduction = lengthPenalty;
}
score = score + lengthPenalty;
var result = {
ranges: ranges,
matchGoodness: score
};
if (DEBUG_SCORES) {
result.scoreDebug = scoreDebug;
}
return result;
} | javascript | function _computeRangesAndScore(matchList, str, lastSegmentStart) {
var matchCounter;
var ranges = [];
var lastMatchIndex = -1;
var lastSegmentScore = 0;
var currentRangeStartedOnSpecial = false;
var score = 0;
var scoreDebug;
if (DEBUG_SCORES) {
scoreDebug = {
special: 0,
match: 0,
upper: 0,
lastSegment: 0,
beginning: 0,
lengthDeduction: 0,
consecutive: 0,
notStartingOnSpecial: 0
};
}
var currentRange = null;
// Records the current range and adds any additional ranges required to
// get to character index c. This function is called before starting a new range
// or returning from the function.
function closeRangeGap(c) {
// Close the current range
if (currentRange) {
currentRange.includesLastSegment = lastMatchIndex >= lastSegmentStart;
if (currentRange.matched && currentRange.includesLastSegment) {
if (DEBUG_SCORES) {
scoreDebug.lastSegment += lastSegmentScore * LAST_SEGMENT_BOOST;
}
score += lastSegmentScore * LAST_SEGMENT_BOOST;
}
if (currentRange.matched && !currentRangeStartedOnSpecial) {
if (DEBUG_SCORES) {
scoreDebug.notStartingOnSpecial -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
score -= NOT_STARTING_ON_SPECIAL_PENALTY;
}
ranges.push(currentRange);
}
// If there was space between the new range and the last,
// add a new unmatched range before the new range can be added.
if (lastMatchIndex + 1 < c) {
ranges.push({
text: str.substring(lastMatchIndex + 1, c),
matched: false,
includesLastSegment: c > lastSegmentStart
});
}
currentRange = null;
lastSegmentScore = 0;
}
// In some cases (see the use of this variable below), we accelerate the
// bonus the more consecutive matches there are.
var numConsecutive = 0;
// Adds a matched character to the appropriate range
function addMatch(match) {
// Pull off the character index
var c = match.index;
var newPoints = 0;
// A match means that we need to do some scoring bookkeeping.
// Start with points added for any match
if (DEBUG_SCORES) {
scoreDebug.match += MATCH_POINTS;
}
newPoints += MATCH_POINTS;
if (match.upper) {
if (DEBUG_SCORES) {
scoreDebug.upper += UPPER_CASE_MATCH;
}
newPoints += UPPER_CASE_MATCH;
}
// A bonus is given for characters that match at the beginning
// of the filename
if (c === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
// If the new character immediately follows the last matched character,
// we award the consecutive matches bonus. The check for score > 0
// handles the initial value of lastMatchIndex which is used for
// constructing ranges but we don't yet have a true match.
if (score > 0 && lastMatchIndex + 1 === c) {
// Continue boosting for each additional match at the beginning
// of the name
if (c - numConsecutive === lastSegmentStart) {
if (DEBUG_SCORES) {
scoreDebug.beginning += BEGINNING_OF_NAME_POINTS;
}
newPoints += BEGINNING_OF_NAME_POINTS;
}
numConsecutive++;
var boost = CONSECUTIVE_MATCHES_POINTS * numConsecutive;
// Consecutive matches that started on a special are a
// good indicator of intent, so we award an added bonus there.
if (currentRangeStartedOnSpecial) {
boost = boost * 2;
}
if (DEBUG_SCORES) {
scoreDebug.consecutive += boost;
}
newPoints += boost;
} else {
numConsecutive = 1;
}
// add points for "special" character matches
if (match instanceof SpecialMatch) {
if (DEBUG_SCORES) {
scoreDebug.special += SPECIAL_POINTS;
}
newPoints += SPECIAL_POINTS;
}
score += newPoints;
// points accumulated in the last segment get an extra bonus
if (c >= lastSegmentStart) {
lastSegmentScore += newPoints;
}
// if the last range wasn't a match or there's a gap, we need to close off
// the range to start a new one.
if ((currentRange && !currentRange.matched) || c > lastMatchIndex + 1) {
closeRangeGap(c);
}
lastMatchIndex = c;
// set up a new match range or add to the current one
if (!currentRange) {
currentRange = {
text: str[c],
matched: true
};
// Check to see if this new matched range is starting on a special
// character. We penalize those ranges that don't, because most
// people will search on the logical boundaries of the name
currentRangeStartedOnSpecial = match instanceof SpecialMatch;
} else {
currentRange.text += str[c];
}
}
// scan through the matches, adding each one in turn
for (matchCounter = 0; matchCounter < matchList.length; matchCounter++) {
var match = matchList[matchCounter];
addMatch(match);
}
// add a range for the last part of the string
closeRangeGap(str.length);
// shorter strings that match are often better than longer ones
var lengthPenalty = -1 * Math.round(str.length * DEDUCTION_FOR_LENGTH);
if (DEBUG_SCORES) {
scoreDebug.lengthDeduction = lengthPenalty;
}
score = score + lengthPenalty;
var result = {
ranges: ranges,
matchGoodness: score
};
if (DEBUG_SCORES) {
result.scoreDebug = scoreDebug;
}
return result;
} | [
"function",
"_computeRangesAndScore",
"(",
"matchList",
",",
"str",
",",
"lastSegmentStart",
")",
"{",
"var",
"matchCounter",
";",
"var",
"ranges",
"=",
"[",
"]",
";",
"var",
"lastMatchIndex",
"=",
"-",
"1",
";",
"var",
"lastSegmentScore",
"=",
"0",
";",
"... | Converts a list of matches into a form suitable for returning from stringMatch.
@param {Array.<SpecialMatch|NormalMatch>} matchList to convert
@param {string} original string
@param {int} character index where last segment begins
@return {{ranges:Array.<{text:string, matched:boolean, includesLastSegment:boolean}>, matchGoodness:int, scoreDebug: Object}} matched ranges and score | [
"Converts",
"a",
"list",
"of",
"matches",
"into",
"a",
"form",
"suitable",
"for",
"returning",
"from",
"stringMatch",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/StringMatch.js#L507-L695 | train | Compute the ranges and score of the current range. | [
30522,
3853,
1035,
3274,
22043,
8791,
5104,
17345,
1006,
2674,
9863,
1010,
2358,
2099,
1010,
16180,
13910,
8163,
7559,
2102,
1007,
1063,
13075,
2674,
3597,
16671,
2121,
1025,
13075,
8483,
1027,
1031,
1033,
1025,
13075,
2197,
18900,
17231,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Cache.js | onSubmit | function onSubmit() {
oRequestLock = that.oRequestor.getModelInterface()
.lockGroup(sGroupId, true, that);
if (fnPatchSent) {
fnPatchSent();
}
} | javascript | function onSubmit() {
oRequestLock = that.oRequestor.getModelInterface()
.lockGroup(sGroupId, true, that);
if (fnPatchSent) {
fnPatchSent();
}
} | [
"function",
"onSubmit",
"(",
")",
"{",
"oRequestLock",
"=",
"that",
".",
"oRequestor",
".",
"getModelInterface",
"(",
")",
".",
"lockGroup",
"(",
"sGroupId",
",",
"true",
",",
"that",
")",
";",
"if",
"(",
"fnPatchSent",
")",
"{",
"fnPatchSent",
"(",
")",... | /*
Synchronous callback called when the request is put on the wire. Locks the group
so that further requests created via {@link ODataModel#submitBatch} wait until
this request has returned and its response is applied to the cache. | [
"/",
"*",
"Synchronous",
"callback",
"called",
"when",
"the",
"request",
"is",
"put",
"on",
"the",
"wire",
".",
"Locks",
"the",
"group",
"so",
"that",
"further",
"requests",
"created",
"via",
"{"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Cache.js#L875-L881 | train | Called when the form is submitted | [
30522,
3853,
2006,
6342,
25526,
4183,
1006,
1007,
1063,
10848,
15500,
7878,
1027,
2008,
1012,
10848,
15500,
2953,
1012,
2131,
5302,
9247,
18447,
2121,
12172,
1006,
1007,
1012,
5843,
17058,
1006,
22214,
22107,
3593,
1010,
2995,
1010,
2008,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/parallel/Parallel.js | function (coord, dim) {
var axisLayout = this._axesLayout[dim];
return graphic.applyTransform([coord, 0], axisLayout.transform);
} | javascript | function (coord, dim) {
var axisLayout = this._axesLayout[dim];
return graphic.applyTransform([coord, 0], axisLayout.transform);
} | [
"function",
"(",
"coord",
",",
"dim",
")",
"{",
"var",
"axisLayout",
"=",
"this",
".",
"_axesLayout",
"[",
"dim",
"]",
";",
"return",
"graphic",
".",
"applyTransform",
"(",
"[",
"coord",
",",
"0",
"]",
",",
"axisLayout",
".",
"transform",
")",
";",
"... | Convert coords of each axis to Point.
Return point. For example: [10, 20]
@param {Array.<number>} coords
@param {string} dim
@return {Array.<number>} | [
"Convert",
"coords",
"of",
"each",
"axis",
"to",
"Point",
".",
"Return",
"point",
".",
"For",
"example",
":",
"[",
"10",
"20",
"]"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/parallel/Parallel.js#L423-L426 | train | Returns the graphic for the given coord | [
30522,
3853,
1006,
2522,
8551,
1010,
11737,
1007,
1063,
13075,
8123,
8485,
5833,
1027,
2023,
1012,
1035,
19589,
8485,
5833,
1031,
11737,
1033,
1025,
2709,
8425,
1012,
6611,
6494,
3619,
14192,
1006,
1031,
2522,
8551,
1010,
1014,
1033,
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... | |
eslint/eslint | lib/rules/prefer-object-spread.js | defineFixer | function defineFixer(node, sourceCode) {
return function *(fixer) {
const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
const rightParen = sourceCode.getLastToken(node);
// Remove the callee `Object.assign`
yield fixer.remove(node.callee);
// Replace the parens of argument list to braces.
if (needsParens(node, sourceCode)) {
yield fixer.replaceText(leftParen, "({");
yield fixer.replaceText(rightParen, "})");
} else {
yield fixer.replaceText(leftParen, "{");
yield fixer.replaceText(rightParen, "}");
}
// Process arguments.
for (const argNode of node.arguments) {
const innerParens = getParenTokens(argNode, leftParen, sourceCode);
const left = innerParens.shift();
const right = innerParens.pop();
if (argNode.type === "ObjectExpression") {
const maybeTrailingComma = sourceCode.getLastToken(argNode, 1);
const maybeArgumentComma = sourceCode.getTokenAfter(right);
/*
* Make bare this object literal.
* And remove spaces inside of the braces for better formatting.
*/
for (const innerParen of innerParens) {
yield fixer.remove(innerParen);
}
const leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)];
const rightRange = [
Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap
right.range[1]
];
yield fixer.removeRange(leftRange);
yield fixer.removeRange(rightRange);
// Remove the comma of this argument if it's duplication.
if (
(argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) &&
isCommaToken(maybeArgumentComma)
) {
yield fixer.remove(maybeArgumentComma);
}
} else {
// Make spread.
if (argNeedsParens(argNode, sourceCode)) {
yield fixer.insertTextBefore(left, "...(");
yield fixer.insertTextAfter(right, ")");
} else {
yield fixer.insertTextBefore(left, "...");
}
}
}
};
} | javascript | function defineFixer(node, sourceCode) {
return function *(fixer) {
const leftParen = sourceCode.getTokenAfter(node.callee, isOpeningParenToken);
const rightParen = sourceCode.getLastToken(node);
// Remove the callee `Object.assign`
yield fixer.remove(node.callee);
// Replace the parens of argument list to braces.
if (needsParens(node, sourceCode)) {
yield fixer.replaceText(leftParen, "({");
yield fixer.replaceText(rightParen, "})");
} else {
yield fixer.replaceText(leftParen, "{");
yield fixer.replaceText(rightParen, "}");
}
// Process arguments.
for (const argNode of node.arguments) {
const innerParens = getParenTokens(argNode, leftParen, sourceCode);
const left = innerParens.shift();
const right = innerParens.pop();
if (argNode.type === "ObjectExpression") {
const maybeTrailingComma = sourceCode.getLastToken(argNode, 1);
const maybeArgumentComma = sourceCode.getTokenAfter(right);
/*
* Make bare this object literal.
* And remove spaces inside of the braces for better formatting.
*/
for (const innerParen of innerParens) {
yield fixer.remove(innerParen);
}
const leftRange = [left.range[0], getEndWithSpaces(left, sourceCode)];
const rightRange = [
Math.max(getStartWithSpaces(right, sourceCode), leftRange[1]), // Ensure ranges don't overlap
right.range[1]
];
yield fixer.removeRange(leftRange);
yield fixer.removeRange(rightRange);
// Remove the comma of this argument if it's duplication.
if (
(argNode.properties.length === 0 || isCommaToken(maybeTrailingComma)) &&
isCommaToken(maybeArgumentComma)
) {
yield fixer.remove(maybeArgumentComma);
}
} else {
// Make spread.
if (argNeedsParens(argNode, sourceCode)) {
yield fixer.insertTextBefore(left, "...(");
yield fixer.insertTextAfter(right, ")");
} else {
yield fixer.insertTextBefore(left, "...");
}
}
}
};
} | [
"function",
"defineFixer",
"(",
"node",
",",
"sourceCode",
")",
"{",
"return",
"function",
"*",
"(",
"fixer",
")",
"{",
"const",
"leftParen",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
".",
"callee",
",",
"isOpeningParenToken",
")",
";",
"const",
... | Autofixes the Object.assign call to use an object spread instead.
@param {ASTNode|null} node - The node that the rule warns on, i.e. the Object.assign call
@param {string} sourceCode - sourceCode of the Object.assign call
@returns {Function} autofixer - replaces the Object.assign with a spread object. | [
"Autofixes",
"the",
"Object",
".",
"assign",
"call",
"to",
"use",
"an",
"object",
"spread",
"instead",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-object-spread.js#L149-L211 | train | Defines a fixer function for a given CallExpression. | [
30522,
3853,
9375,
8873,
2595,
2121,
1006,
13045,
1010,
3120,
16044,
1007,
1063,
2709,
3853,
1008,
1006,
8081,
2121,
1007,
1063,
9530,
3367,
2187,
19362,
2368,
1027,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
2121,
1006,
13045,
1012,
2655,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RTCMultiConnection | dev/MediaStreamRecorder.js | StereoAudioRecorderHelper | function StereoAudioRecorderHelper(mediaStream, root) {
// variables
var deviceSampleRate = 44100; // range: 22050 to 96000
if (!ObjectStore.AudioContextConstructor) {
ObjectStore.AudioContextConstructor = new ObjectStore.AudioContext();
}
// check device sample rate
deviceSampleRate = ObjectStore.AudioContextConstructor.sampleRate;
var leftchannel = [];
var rightchannel = [];
var scriptprocessornode;
var recording = false;
var recordingLength = 0;
var volume;
var audioInput;
var sampleRate = root.sampleRate || deviceSampleRate;
var mimeType = root.mimeType || 'audio/wav';
var isPCM = mimeType.indexOf('audio/pcm') > -1;
var context;
var numChannels = root.audioChannels || 2;
this.record = function() {
recording = true;
// reset the buffers for the new recording
leftchannel.length = rightchannel.length = 0;
recordingLength = 0;
};
this.requestData = function() {
if (isPaused) {
return;
}
if (recordingLength === 0) {
requestDataInvoked = false;
return;
}
requestDataInvoked = true;
// clone stuff
var internalLeftChannel = leftchannel.slice(0);
var internalRightChannel = rightchannel.slice(0);
var internalRecordingLength = recordingLength;
// reset the buffers for the new recording
leftchannel.length = rightchannel.length = [];
recordingLength = 0;
requestDataInvoked = false;
// we flat the left and right channels down
var leftBuffer = mergeBuffers(internalLeftChannel, internalRecordingLength);
var interleaved = leftBuffer;
// we interleave both channels together
if (numChannels === 2) {
var rightBuffer = mergeBuffers(internalRightChannel, internalRecordingLength); // bug fixed via #70,#71
interleaved = interleave(leftBuffer, rightBuffer);
}
if (isPCM) {
// our final binary blob
var blob = new Blob([convertoFloat32ToInt16(interleaved)], {
type: 'audio/pcm'
});
console.debug('audio recorded blob size:', bytesToSize(blob.size));
root.ondataavailable(blob);
return;
}
// we create our wav file
var buffer = new ArrayBuffer(44 + interleaved.length * 2);
var view = new DataView(buffer);
// RIFF chunk descriptor
writeUTFBytes(view, 0, 'RIFF');
// -8 (via #97)
view.setUint32(4, 44 + interleaved.length * 2 - 8, true);
writeUTFBytes(view, 8, 'WAVE');
// FMT sub-chunk
writeUTFBytes(view, 12, 'fmt ');
view.setUint32(16, 16, true);
view.setUint16(20, 1, true);
// stereo (2 channels)
view.setUint16(22, numChannels, true);
view.setUint32(24, sampleRate, true);
view.setUint32(28, sampleRate * numChannels * 2, true); // numChannels * 2 (via #71)
view.setUint16(32, numChannels * 2, true);
view.setUint16(34, 16, true);
// data sub-chunk
writeUTFBytes(view, 36, 'data');
view.setUint32(40, interleaved.length * 2, true);
// write the PCM samples
var lng = interleaved.length;
var index = 44;
var volume = 1;
for (var i = 0; i < lng; i++) {
view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);
index += 2;
}
// our final binary blob
var blob = new Blob([view], {
type: 'audio/wav'
});
console.debug('audio recorded blob size:', bytesToSize(blob.size));
root.ondataavailable(blob);
};
this.stop = function() {
// we stop recording
recording = false;
this.requestData();
audioInput.disconnect();
this.onstop();
};
function interleave(leftChannel, rightChannel) {
var length = leftChannel.length + rightChannel.length;
var result = new Float32Array(length);
var inputIndex = 0;
for (var index = 0; index < length;) {
result[index++] = leftChannel[inputIndex];
result[index++] = rightChannel[inputIndex];
inputIndex++;
}
return result;
}
function mergeBuffers(channelBuffer, recordingLength) {
var result = new Float32Array(recordingLength);
var offset = 0;
var lng = channelBuffer.length;
for (var i = 0; i < lng; i++) {
var buffer = channelBuffer[i];
result.set(buffer, offset);
offset += buffer.length;
}
return result;
}
function writeUTFBytes(view, offset, string) {
var lng = string.length;
for (var i = 0; i < lng; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
}
function convertoFloat32ToInt16(buffer) {
var l = buffer.length;
var buf = new Int16Array(l)
while (l--) {
buf[l] = buffer[l] * 0xFFFF; //convert to 16 bit
}
return buf.buffer
}
// creates the audio context
var context = ObjectStore.AudioContextConstructor;
// creates a gain node
ObjectStore.VolumeGainNode = context.createGain();
var volume = ObjectStore.VolumeGainNode;
// creates an audio node from the microphone incoming stream
ObjectStore.AudioInput = context.createMediaStreamSource(mediaStream);
// creates an audio node from the microphone incoming stream
var audioInput = ObjectStore.AudioInput;
// connect the stream to the gain node
audioInput.connect(volume);
/* From the spec: This value controls how frequently the audioprocess event is
dispatched and how many sample-frames need to be processed each call.
Lower values for buffer size will result in a lower (better) latency.
Higher values will be necessary to avoid audio breakup and glitches
Legal values are 256, 512, 1024, 2048, 4096, 8192, and 16384.*/
var bufferSize = root.bufferSize || 2048;
if (root.bufferSize === 0) {
bufferSize = 0;
}
if (context.createJavaScriptNode) {
scriptprocessornode = context.createJavaScriptNode(bufferSize, numChannels, numChannels);
} else if (context.createScriptProcessor) {
scriptprocessornode = context.createScriptProcessor(bufferSize, numChannels, numChannels);
} else {
throw 'WebAudio API has no support on this browser.';
}
bufferSize = scriptprocessornode.bufferSize;
console.debug('using audio buffer-size:', bufferSize);
var requestDataInvoked = false;
// sometimes "scriptprocessornode" disconnects from he destination-node
// and there is no exception thrown in this case.
// and obviously no further "ondataavailable" events will be emitted.
// below global-scope variable is added to debug such unexpected but "rare" cases.
window.scriptprocessornode = scriptprocessornode;
if (numChannels === 1) {
console.debug('All right-channels are skipped.');
}
var isPaused = false;
this.pause = function() {
isPaused = true;
};
this.resume = function() {
isPaused = false;
};
this.onstop = function() {};
// http://webaudio.github.io/web-audio-api/#the-scriptprocessornode-interface
scriptprocessornode.onaudioprocess = function(e) {
if (!recording || requestDataInvoked || isPaused) {
return;
}
var left = e.inputBuffer.getChannelData(0);
leftchannel.push(new Float32Array(left));
if (numChannels === 2) {
var right = e.inputBuffer.getChannelData(1);
rightchannel.push(new Float32Array(right));
}
recordingLength += bufferSize;
};
volume.connect(scriptprocessornode);
scriptprocessornode.connect(context.destination);
} | javascript | function StereoAudioRecorderHelper(mediaStream, root) {
// variables
var deviceSampleRate = 44100; // range: 22050 to 96000
if (!ObjectStore.AudioContextConstructor) {
ObjectStore.AudioContextConstructor = new ObjectStore.AudioContext();
}
// check device sample rate
deviceSampleRate = ObjectStore.AudioContextConstructor.sampleRate;
var leftchannel = [];
var rightchannel = [];
var scriptprocessornode;
var recording = false;
var recordingLength = 0;
var volume;
var audioInput;
var sampleRate = root.sampleRate || deviceSampleRate;
var mimeType = root.mimeType || 'audio/wav';
var isPCM = mimeType.indexOf('audio/pcm') > -1;
var context;
var numChannels = root.audioChannels || 2;
this.record = function() {
recording = true;
// reset the buffers for the new recording
leftchannel.length = rightchannel.length = 0;
recordingLength = 0;
};
this.requestData = function() {
if (isPaused) {
return;
}
if (recordingLength === 0) {
requestDataInvoked = false;
return;
}
requestDataInvoked = true;
// clone stuff
var internalLeftChannel = leftchannel.slice(0);
var internalRightChannel = rightchannel.slice(0);
var internalRecordingLength = recordingLength;
// reset the buffers for the new recording
leftchannel.length = rightchannel.length = [];
recordingLength = 0;
requestDataInvoked = false;
// we flat the left and right channels down
var leftBuffer = mergeBuffers(internalLeftChannel, internalRecordingLength);
var interleaved = leftBuffer;
// we interleave both channels together
if (numChannels === 2) {
var rightBuffer = mergeBuffers(internalRightChannel, internalRecordingLength); // bug fixed via #70,#71
interleaved = interleave(leftBuffer, rightBuffer);
}
if (isPCM) {
// our final binary blob
var blob = new Blob([convertoFloat32ToInt16(interleaved)], {
type: 'audio/pcm'
});
console.debug('audio recorded blob size:', bytesToSize(blob.size));
root.ondataavailable(blob);
return;
}
// we create our wav file
var buffer = new ArrayBuffer(44 + interleaved.length * 2);
var view = new DataView(buffer);
// RIFF chunk descriptor
writeUTFBytes(view, 0, 'RIFF');
// -8 (via #97)
view.setUint32(4, 44 + interleaved.length * 2 - 8, true);
writeUTFBytes(view, 8, 'WAVE');
// FMT sub-chunk
writeUTFBytes(view, 12, 'fmt ');
view.setUint32(16, 16, true);
view.setUint16(20, 1, true);
// stereo (2 channels)
view.setUint16(22, numChannels, true);
view.setUint32(24, sampleRate, true);
view.setUint32(28, sampleRate * numChannels * 2, true); // numChannels * 2 (via #71)
view.setUint16(32, numChannels * 2, true);
view.setUint16(34, 16, true);
// data sub-chunk
writeUTFBytes(view, 36, 'data');
view.setUint32(40, interleaved.length * 2, true);
// write the PCM samples
var lng = interleaved.length;
var index = 44;
var volume = 1;
for (var i = 0; i < lng; i++) {
view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);
index += 2;
}
// our final binary blob
var blob = new Blob([view], {
type: 'audio/wav'
});
console.debug('audio recorded blob size:', bytesToSize(blob.size));
root.ondataavailable(blob);
};
this.stop = function() {
// we stop recording
recording = false;
this.requestData();
audioInput.disconnect();
this.onstop();
};
function interleave(leftChannel, rightChannel) {
var length = leftChannel.length + rightChannel.length;
var result = new Float32Array(length);
var inputIndex = 0;
for (var index = 0; index < length;) {
result[index++] = leftChannel[inputIndex];
result[index++] = rightChannel[inputIndex];
inputIndex++;
}
return result;
}
function mergeBuffers(channelBuffer, recordingLength) {
var result = new Float32Array(recordingLength);
var offset = 0;
var lng = channelBuffer.length;
for (var i = 0; i < lng; i++) {
var buffer = channelBuffer[i];
result.set(buffer, offset);
offset += buffer.length;
}
return result;
}
function writeUTFBytes(view, offset, string) {
var lng = string.length;
for (var i = 0; i < lng; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
}
function convertoFloat32ToInt16(buffer) {
var l = buffer.length;
var buf = new Int16Array(l)
while (l--) {
buf[l] = buffer[l] * 0xFFFF; //convert to 16 bit
}
return buf.buffer
}
// creates the audio context
var context = ObjectStore.AudioContextConstructor;
// creates a gain node
ObjectStore.VolumeGainNode = context.createGain();
var volume = ObjectStore.VolumeGainNode;
// creates an audio node from the microphone incoming stream
ObjectStore.AudioInput = context.createMediaStreamSource(mediaStream);
// creates an audio node from the microphone incoming stream
var audioInput = ObjectStore.AudioInput;
// connect the stream to the gain node
audioInput.connect(volume);
/* From the spec: This value controls how frequently the audioprocess event is
dispatched and how many sample-frames need to be processed each call.
Lower values for buffer size will result in a lower (better) latency.
Higher values will be necessary to avoid audio breakup and glitches
Legal values are 256, 512, 1024, 2048, 4096, 8192, and 16384.*/
var bufferSize = root.bufferSize || 2048;
if (root.bufferSize === 0) {
bufferSize = 0;
}
if (context.createJavaScriptNode) {
scriptprocessornode = context.createJavaScriptNode(bufferSize, numChannels, numChannels);
} else if (context.createScriptProcessor) {
scriptprocessornode = context.createScriptProcessor(bufferSize, numChannels, numChannels);
} else {
throw 'WebAudio API has no support on this browser.';
}
bufferSize = scriptprocessornode.bufferSize;
console.debug('using audio buffer-size:', bufferSize);
var requestDataInvoked = false;
// sometimes "scriptprocessornode" disconnects from he destination-node
// and there is no exception thrown in this case.
// and obviously no further "ondataavailable" events will be emitted.
// below global-scope variable is added to debug such unexpected but "rare" cases.
window.scriptprocessornode = scriptprocessornode;
if (numChannels === 1) {
console.debug('All right-channels are skipped.');
}
var isPaused = false;
this.pause = function() {
isPaused = true;
};
this.resume = function() {
isPaused = false;
};
this.onstop = function() {};
// http://webaudio.github.io/web-audio-api/#the-scriptprocessornode-interface
scriptprocessornode.onaudioprocess = function(e) {
if (!recording || requestDataInvoked || isPaused) {
return;
}
var left = e.inputBuffer.getChannelData(0);
leftchannel.push(new Float32Array(left));
if (numChannels === 2) {
var right = e.inputBuffer.getChannelData(1);
rightchannel.push(new Float32Array(right));
}
recordingLength += bufferSize;
};
volume.connect(scriptprocessornode);
scriptprocessornode.connect(context.destination);
} | [
"function",
"StereoAudioRecorderHelper",
"(",
"mediaStream",
",",
"root",
")",
"{",
"// variables ",
"var",
"deviceSampleRate",
"=",
"44100",
";",
"// range: 22050 to 96000",
"if",
"(",
"!",
"ObjectStore",
".",
"AudioContextConstructor",
")",
"{",
"ObjectStore",
".... | ============================ StereoAudioRecorderHelper.js source code from: http://typedarray.org/wp-content/projects/WebAudioRecorder/script.js | [
"============================",
"StereoAudioRecorderHelper",
".",
"js",
"source",
"code",
"from",
":",
"http",
":",
"//",
"typedarray",
".",
"org",
"/",
"wp",
"-",
"content",
"/",
"projects",
"/",
"WebAudioRecorder",
"/",
"script",
".",
"js"
] | 2032ce949bde30b43a3d2666e0f1e5afbf337f3d | https://github.com/muaz-khan/RTCMultiConnection/blob/2032ce949bde30b43a3d2666e0f1e5afbf337f3d/dev/MediaStreamRecorder.js#L1431-L1686 | train | Stereo Audio recorder helper | [
30522,
3853,
12991,
19513,
25346,
8586,
8551,
2121,
16001,
4842,
1006,
2865,
21422,
1010,
7117,
1007,
1063,
1013,
1013,
10857,
13075,
5733,
16613,
3917,
3686,
1027,
28015,
8889,
1025,
1013,
1013,
2846,
1024,
10545,
12376,
2000,
26637,
8889,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Menus.js | removeMenu | function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
} | javascript | function removeMenu(id) {
var menu,
commandID = "";
if (!id) {
console.error("removeMenu(): missing required parameter: id");
return;
}
if (!menuMap[id]) {
console.error("removeMenu(): menu id not found: %s", id);
return;
}
// Remove all of the menu items in the menu
menu = getMenu(id);
_.forEach(menuItemMap, function (value, key) {
if (_.startsWith(key, id)) {
if (value.isDivider) {
menu.removeMenuDivider(key);
} else {
commandID = value.getCommand();
menu.removeMenuItem(commandID);
}
}
});
if (_isHTMLMenu(id)) {
$(_getHTMLMenu(id)).remove();
} else {
brackets.app.removeMenu(id, function (err) {
if (err) {
console.error("removeMenu() -- id not found: " + id + " (error: " + err + ")");
}
});
}
delete menuMap[id];
} | [
"function",
"removeMenu",
"(",
"id",
")",
"{",
"var",
"menu",
",",
"commandID",
"=",
"\"\"",
";",
"if",
"(",
"!",
"id",
")",
"{",
"console",
".",
"error",
"(",
"\"removeMenu(): missing required parameter: id\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"... | Removes a top-level menu from the application menu bar which may be native or HTML-based.
@param {!string} id - unique identifier for a menu.
Core Menus in Brackets use a simple title as an id, for example "file-menu".
Extensions should use the following format: "author.myextension.mymenuname". | [
"Removes",
"a",
"top",
"-",
"level",
"menu",
"from",
"the",
"application",
"menu",
"bar",
"which",
"may",
"be",
"native",
"or",
"HTML",
"-",
"based",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/Menus.js#L1113-L1152 | train | Remove a menu from the menu map | [
30522,
3853,
6366,
3549,
2226,
1006,
8909,
1007,
1063,
13075,
12183,
1010,
3094,
3593,
1027,
1000,
1000,
1025,
2065,
1006,
999,
8909,
1007,
1063,
10122,
1012,
7561,
1006,
1000,
6366,
3549,
2226,
1006,
1007,
1024,
4394,
3223,
16381,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/commons/color/get-background-color.js | includeMissingElements | function includeMissingElements(elmStack, elm) {
/*eslint max-depth:["error",7]*/
const elementMap = {
TD: ['TR', 'TBODY'],
TH: ['TR', 'THEAD'],
INPUT: ['LABEL']
};
const tagArray = elmStack.map(elm => {
return elm.nodeName;
});
let bgNodes = elmStack;
for (let candidate in elementMap) {
// check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate
if (tagArray.includes(candidate)) {
for (let candidateIndex in elementMap[candidate]) {
if (candidate.hasOwnProperty(candidateIndex)) {
// look up the tree for a matching candidate
let ancestorMatch = axe.commons.dom.findUp(
elm,
elementMap[candidate][candidateIndex]
);
if (ancestorMatch && elmStack.indexOf(ancestorMatch) === -1) {
// found an ancestor not in elmStack, and it overlaps
let overlaps = axe.commons.dom.visuallyOverlaps(
elm.getBoundingClientRect(),
ancestorMatch
);
if (overlaps) {
// if target is in the elementMap, use its position.
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, ancestorMatch);
}
}
// nodeName matches value
// (such as LABEL, when matching itself. It should be in the list, but Phantom skips it)
if (
elm.nodeName === elementMap[candidate][candidateIndex] &&
tagArray.indexOf(elm.nodeName) === -1
) {
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, elm);
}
}
}
}
}
return bgNodes;
} | javascript | function includeMissingElements(elmStack, elm) {
/*eslint max-depth:["error",7]*/
const elementMap = {
TD: ['TR', 'TBODY'],
TH: ['TR', 'THEAD'],
INPUT: ['LABEL']
};
const tagArray = elmStack.map(elm => {
return elm.nodeName;
});
let bgNodes = elmStack;
for (let candidate in elementMap) {
// check that TR or LABEL has paired nodeName from elementMap, but don't expect elm to be that candidate
if (tagArray.includes(candidate)) {
for (let candidateIndex in elementMap[candidate]) {
if (candidate.hasOwnProperty(candidateIndex)) {
// look up the tree for a matching candidate
let ancestorMatch = axe.commons.dom.findUp(
elm,
elementMap[candidate][candidateIndex]
);
if (ancestorMatch && elmStack.indexOf(ancestorMatch) === -1) {
// found an ancestor not in elmStack, and it overlaps
let overlaps = axe.commons.dom.visuallyOverlaps(
elm.getBoundingClientRect(),
ancestorMatch
);
if (overlaps) {
// if target is in the elementMap, use its position.
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, ancestorMatch);
}
}
// nodeName matches value
// (such as LABEL, when matching itself. It should be in the list, but Phantom skips it)
if (
elm.nodeName === elementMap[candidate][candidateIndex] &&
tagArray.indexOf(elm.nodeName) === -1
) {
bgNodes.splice(tagArray.indexOf(candidate) + 1, 0, elm);
}
}
}
}
}
return bgNodes;
} | [
"function",
"includeMissingElements",
"(",
"elmStack",
",",
"elm",
")",
"{",
"/*eslint max-depth:[\"error\",7]*/",
"const",
"elementMap",
"=",
"{",
"TD",
":",
"[",
"'TR'",
",",
"'TBODY'",
"]",
",",
"TH",
":",
"[",
"'TR'",
",",
"'THEAD'",
"]",
",",
"INPUT",
... | Include nodes missing from initial gathering because
document.elementsFromPoint misses some elements we need
i.e. TR is missing from table elementStack and leaves out bgColor
https://github.com/dequelabs/axe-core/issues/273
@private
@param {Array} elmStack
@param {Element} elm
@returns {Array} | [
"Include",
"nodes",
"missing",
"from",
"initial",
"gathering",
"because",
"document",
".",
"elementsFromPoint",
"misses",
"some",
"elements",
"we",
"need",
"i",
".",
"e",
".",
"TR",
"is",
"missing",
"from",
"table",
"elementStack",
"and",
"leaves",
"out",
"bgC... | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/color/get-background-color.js#L239-L284 | train | This function is used to include elements that are not in the elementStack. | [
30522,
3853,
2421,
15630,
7741,
12260,
8163,
1006,
17709,
9153,
3600,
1010,
17709,
1007,
1063,
1013,
1008,
9686,
4115,
2102,
4098,
1011,
5995,
1024,
1031,
1000,
7561,
1000,
1010,
1021,
1033,
1008,
1013,
9530,
3367,
5783,
2863,
2361,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Inspector/Inspector.js | _send | function _send(method, signature, varargs) {
if (!_socket) {
console.log("You must connect to the WebSocket before sending messages.");
// FUTURE: Our current implementation closes and re-opens an inspector connection whenever
// a new HTML file is selected. If done quickly enough, pending requests from the previous
// connection could come in before the new socket connection is established. For now we
// simply ignore this condition.
// This race condition will go away once we support multiple inspector connections and turn
// off auto re-opening when a new HTML file is selected.
return (new $.Deferred()).reject().promise();
}
var id, callback, args, i, params = {}, promise, msg;
// extract the parameters, the callback function, and the message id
args = Array.prototype.slice.call(arguments, 2);
if (typeof args[args.length - 1] === "function") {
callback = args.pop();
} else {
var deferred = new $.Deferred();
promise = deferred.promise();
callback = function (result, error) {
if (error) {
deferred.reject(error);
} else {
deferred.resolve(result);
}
};
}
id = _messageId++;
// verify the parameters against the method signature
// this also constructs the params object of type {name -> value}
if (signature) {
for (i in signature) {
if (_verifySignature(args[i], signature[i])) {
params[signature[i].name] = args[i];
}
}
}
// Store message callback and send message
msg = { method: method, id: id, params: params };
_messageCallbacks[id] = { callback: callback, message: msg };
_socket.send(JSON.stringify(msg));
return promise;
} | javascript | function _send(method, signature, varargs) {
if (!_socket) {
console.log("You must connect to the WebSocket before sending messages.");
// FUTURE: Our current implementation closes and re-opens an inspector connection whenever
// a new HTML file is selected. If done quickly enough, pending requests from the previous
// connection could come in before the new socket connection is established. For now we
// simply ignore this condition.
// This race condition will go away once we support multiple inspector connections and turn
// off auto re-opening when a new HTML file is selected.
return (new $.Deferred()).reject().promise();
}
var id, callback, args, i, params = {}, promise, msg;
// extract the parameters, the callback function, and the message id
args = Array.prototype.slice.call(arguments, 2);
if (typeof args[args.length - 1] === "function") {
callback = args.pop();
} else {
var deferred = new $.Deferred();
promise = deferred.promise();
callback = function (result, error) {
if (error) {
deferred.reject(error);
} else {
deferred.resolve(result);
}
};
}
id = _messageId++;
// verify the parameters against the method signature
// this also constructs the params object of type {name -> value}
if (signature) {
for (i in signature) {
if (_verifySignature(args[i], signature[i])) {
params[signature[i].name] = args[i];
}
}
}
// Store message callback and send message
msg = { method: method, id: id, params: params };
_messageCallbacks[id] = { callback: callback, message: msg };
_socket.send(JSON.stringify(msg));
return promise;
} | [
"function",
"_send",
"(",
"method",
",",
"signature",
",",
"varargs",
")",
"{",
"if",
"(",
"!",
"_socket",
")",
"{",
"console",
".",
"log",
"(",
"\"You must connect to the WebSocket before sending messages.\"",
")",
";",
"// FUTURE: Our current implementation closes and... | Send a message to the remote debugger
All passed arguments after the signature are passed on as parameters.
If the last argument is a function, it is used as the callback function.
@param {string} remote method
@param {object} the method signature | [
"Send",
"a",
"message",
"to",
"the",
"remote",
"debugger",
"All",
"passed",
"arguments",
"after",
"the",
"signature",
"are",
"passed",
"on",
"as",
"parameters",
".",
"If",
"the",
"last",
"argument",
"is",
"a",
"function",
"it",
"is",
"used",
"as",
"the",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Inspector/Inspector.js#L117-L166 | train | send a message to the remote server | [
30522,
3853,
1035,
4604,
1006,
4118,
1010,
30524,
5620,
1007,
1063,
2065,
1006,
999,
1035,
22278,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
2017,
2442,
7532,
2000,
1996,
4773,
6499,
19869,
2102,
2077,
6016,
7696,
1012,
1000,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msg) {
if (msg.params.url) {
// navigate to a new page.
window.location.replace(msg.params.url);
}
} | javascript | function (msg) {
if (msg.params.url) {
// navigate to a new page.
window.location.replace(msg.params.url);
}
} | [
"function",
"(",
"msg",
")",
"{",
"if",
"(",
"msg",
".",
"params",
".",
"url",
")",
"{",
"// navigate to a new page.",
"window",
".",
"location",
".",
"replace",
"(",
"msg",
".",
"params",
".",
"url",
")",
";",
"}",
"}"
] | Navigate to a different page.
@param {Object} msg | [
"Navigate",
"to",
"a",
"different",
"page",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L251-L256 | train | onmessage - > null | [
30522,
3853,
1006,
5796,
2290,
1007,
1063,
2065,
1006,
5796,
2290,
1012,
11498,
5244,
1012,
24471,
2140,
1007,
1063,
1013,
1013,
22149,
2000,
1037,
2047,
3931,
1012,
3332,
1012,
3295,
1012,
5672,
1006,
5796,
2290,
1012,
11498,
5244,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
moleculerjs/moleculer | src/serializers/proto/packets.proto.js | PacketDisconnect | function PacketDisconnect(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | javascript | function PacketDisconnect(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
} | [
"function",
"PacketDisconnect",
"(",
"properties",
")",
"{",
"if",
"(",
"properties",
")",
"for",
"(",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
",",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"++",
"i",
")",... | Properties of a PacketDisconnect.
@memberof packets
@interface IPacketDisconnect
@property {string} ver PacketDisconnect ver
@property {string} sender PacketDisconnect sender
Constructs a new PacketDisconnect.
@memberof packets
@classdesc Represents a PacketDisconnect.
@implements IPacketDisconnect
@constructor
@param {packets.IPacketDisconnect=} [properties] Properties to set | [
"Properties",
"of",
"a",
"PacketDisconnect",
"."
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/serializers/proto/packets.proto.js#L1952-L1957 | train | Properties of a PacketDisconnect. | [
30522,
3853,
14771,
10521,
8663,
2638,
6593,
1006,
5144,
1007,
1063,
2065,
1006,
5144,
1007,
2005,
1006,
13075,
6309,
1027,
4874,
1012,
6309,
1006,
5144,
1007,
1010,
1045,
1027,
1014,
1025,
1045,
1026,
6309,
1012,
3091,
1025,
1009,
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... |
Dogfalo/materialize | dist/js/materialize.js | getWavesEffectElement | function getWavesEffectElement(e) {
if (TouchHandler.allowEvent(e) === false) {
return null;
}
var element = null;
var target = e.target || e.srcElement;
while (target.parentNode !== null) {
if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) {
element = target;
break;
}
target = target.parentNode;
}
return element;
} | javascript | function getWavesEffectElement(e) {
if (TouchHandler.allowEvent(e) === false) {
return null;
}
var element = null;
var target = e.target || e.srcElement;
while (target.parentNode !== null) {
if (!(target instanceof SVGElement) && target.className.indexOf('waves-effect') !== -1) {
element = target;
break;
}
target = target.parentNode;
}
return element;
} | [
"function",
"getWavesEffectElement",
"(",
"e",
")",
"{",
"if",
"(",
"TouchHandler",
".",
"allowEvent",
"(",
"e",
")",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"var",
"element",
"=",
"null",
";",
"var",
"target",
"=",
"e",
".",
"target",
... | Delegated click handler for .waves-effect element.
returns null when .waves-effect element not in "click tree" | [
"Delegated",
"click",
"handler",
"for",
".",
"waves",
"-",
"effect",
"element",
".",
"returns",
"null",
"when",
".",
"waves",
"-",
"effect",
"element",
"not",
"in",
"click",
"tree"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L5025-L5041 | train | Get the element that is the target of the waves - effect | [
30522,
3853,
2131,
16535,
20106,
25969,
12260,
3672,
1006,
1041,
1007,
1063,
2065,
1006,
3543,
11774,
3917,
1012,
3499,
18697,
3372,
1006,
1041,
1007,
1027,
1027,
1027,
6270,
1007,
1063,
2709,
19701,
1025,
1065,
13075,
5783,
1027,
19701,
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/search/node/FindInFilesDomain.js | getSearchMatches | function getSearchMatches(contents, queryExpr) {
if (!contents) {
return;
}
// Quick exit if not found or if we hit the limit
if (foundMaximum || contents.search(queryExpr) === -1) {
return [];
}
var match, lineNum, line, ch, totalMatchLength, matchedLines, numMatchedLines, lastLineLength, endCh,
padding, leftPadding, rightPadding, highlightOffset, highlightEndCh,
lines = contents.split("\n"),
matches = [];
while ((match = queryExpr.exec(contents)) !== null) {
lineNum = offsetToLineNum(lines, match.index);
line = lines[lineNum];
ch = match.index - contents.lastIndexOf("\n", match.index) - 1; // 0-based index
matchedLines = match[0].split("\n");
numMatchedLines = matchedLines.length;
totalMatchLength = match[0].length;
lastLineLength = matchedLines[matchedLines.length - 1].length;
endCh = (numMatchedLines === 1 ? ch + totalMatchLength : lastLineLength);
highlightEndCh = (numMatchedLines === 1 ? endCh : line.length);
highlightOffset = 0;
if (highlightEndCh <= MAX_DISPLAY_LENGTH) {
// Don't store more than 200 chars per line
line = line.substr(0, Math.min(MAX_DISPLAY_LENGTH, line.length));
} else if (totalMatchLength > MAX_DISPLAY_LENGTH) {
// impossible to display the whole match
line = line.substr(ch, ch + MAX_DISPLAY_LENGTH);
highlightOffset = ch;
} else {
// Try to have both beginning and end of match displayed
padding = MAX_DISPLAY_LENGTH - totalMatchLength;
rightPadding = Math.floor(Math.min(padding / 2, line.length - highlightEndCh));
leftPadding = Math.ceil(padding - rightPadding);
highlightOffset = ch - leftPadding;
line = line.substring(highlightOffset, highlightEndCh + rightPadding);
}
matches.push({
start: {line: lineNum, ch: ch},
end: {line: lineNum + numMatchedLines - 1, ch: endCh},
highlightOffset: highlightOffset,
// Note that the following offsets from the beginning of the file are *not* updated if the search
// results change. These are currently only used for multi-file replacement, and we always
// abort the replace (by shutting the results panel) if we detect any result changes, so we don't
// need to keep them up to date. Eventually, we should either get rid of the need for these (by
// doing everything in terms of line/ch offsets, though that will require re-splitting files when
// doing a replace) or properly update them.
startOffset: match.index,
endOffset: match.index + totalMatchLength,
line: line,
result: match,
isChecked: true
});
// We have the max hits in just this 1 file. Stop searching this file.
// This fixed issue #1829 where code hangs on too many hits.
// Adds one over MAX_RESULTS_IN_A_FILE in order to know if the search has exceeded
// or is equal to MAX_RESULTS_IN_A_FILE. Additional result removed in SearchModel
if (matches.length > MAX_RESULTS_IN_A_FILE) {
queryExpr.lastIndex = 0;
break;
}
// Pathological regexps like /^/ return 0-length matches. Ensure we make progress anyway
if (totalMatchLength === 0) {
queryExpr.lastIndex++;
}
}
return matches;
} | javascript | function getSearchMatches(contents, queryExpr) {
if (!contents) {
return;
}
// Quick exit if not found or if we hit the limit
if (foundMaximum || contents.search(queryExpr) === -1) {
return [];
}
var match, lineNum, line, ch, totalMatchLength, matchedLines, numMatchedLines, lastLineLength, endCh,
padding, leftPadding, rightPadding, highlightOffset, highlightEndCh,
lines = contents.split("\n"),
matches = [];
while ((match = queryExpr.exec(contents)) !== null) {
lineNum = offsetToLineNum(lines, match.index);
line = lines[lineNum];
ch = match.index - contents.lastIndexOf("\n", match.index) - 1; // 0-based index
matchedLines = match[0].split("\n");
numMatchedLines = matchedLines.length;
totalMatchLength = match[0].length;
lastLineLength = matchedLines[matchedLines.length - 1].length;
endCh = (numMatchedLines === 1 ? ch + totalMatchLength : lastLineLength);
highlightEndCh = (numMatchedLines === 1 ? endCh : line.length);
highlightOffset = 0;
if (highlightEndCh <= MAX_DISPLAY_LENGTH) {
// Don't store more than 200 chars per line
line = line.substr(0, Math.min(MAX_DISPLAY_LENGTH, line.length));
} else if (totalMatchLength > MAX_DISPLAY_LENGTH) {
// impossible to display the whole match
line = line.substr(ch, ch + MAX_DISPLAY_LENGTH);
highlightOffset = ch;
} else {
// Try to have both beginning and end of match displayed
padding = MAX_DISPLAY_LENGTH - totalMatchLength;
rightPadding = Math.floor(Math.min(padding / 2, line.length - highlightEndCh));
leftPadding = Math.ceil(padding - rightPadding);
highlightOffset = ch - leftPadding;
line = line.substring(highlightOffset, highlightEndCh + rightPadding);
}
matches.push({
start: {line: lineNum, ch: ch},
end: {line: lineNum + numMatchedLines - 1, ch: endCh},
highlightOffset: highlightOffset,
// Note that the following offsets from the beginning of the file are *not* updated if the search
// results change. These are currently only used for multi-file replacement, and we always
// abort the replace (by shutting the results panel) if we detect any result changes, so we don't
// need to keep them up to date. Eventually, we should either get rid of the need for these (by
// doing everything in terms of line/ch offsets, though that will require re-splitting files when
// doing a replace) or properly update them.
startOffset: match.index,
endOffset: match.index + totalMatchLength,
line: line,
result: match,
isChecked: true
});
// We have the max hits in just this 1 file. Stop searching this file.
// This fixed issue #1829 where code hangs on too many hits.
// Adds one over MAX_RESULTS_IN_A_FILE in order to know if the search has exceeded
// or is equal to MAX_RESULTS_IN_A_FILE. Additional result removed in SearchModel
if (matches.length > MAX_RESULTS_IN_A_FILE) {
queryExpr.lastIndex = 0;
break;
}
// Pathological regexps like /^/ return 0-length matches. Ensure we make progress anyway
if (totalMatchLength === 0) {
queryExpr.lastIndex++;
}
}
return matches;
} | [
"function",
"getSearchMatches",
"(",
"contents",
",",
"queryExpr",
")",
"{",
"if",
"(",
"!",
"contents",
")",
"{",
"return",
";",
"}",
"// Quick exit if not found or if we hit the limit",
"if",
"(",
"foundMaximum",
"||",
"contents",
".",
"search",
"(",
"queryExpr"... | Searches through the contents and returns an array of matches
@param {string} contents
@param {RegExp} queryExpr
@return {!Array.<{start: {line:number,ch:number}, end: {line:number,ch:number}, line: string}>} | [
"Searches",
"through",
"the",
"contents",
"and",
"returns",
"an",
"array",
"of",
"matches"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L102-L180 | train | Search matches in the contents of a phrase | [
30522,
3853,
4152,
14644,
2818,
18900,
8376,
1006,
8417,
1010,
23032,
10288,
18098,
1007,
1063,
2065,
1006,
999,
8417,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
4248,
6164,
2065,
2025,
2179,
2030,
2065,
2057,
2718,
1996,
5787,
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... |
postcss/autoprefixer | lib/hacks/grid-utils.js | shouldInheritGap | function shouldInheritGap (selA, selB) {
let result
// get arrays of selector split in 3-deep array
let splitSelectorArrA = splitSelector(selA)
let splitSelectorArrB = splitSelector(selB)
if (splitSelectorArrA[0].length < splitSelectorArrB[0].length) {
// abort if selectorA has lower descendant specificity then selectorB
// (e.g '.grid' and '.hello .world .grid')
return false
} else if (splitSelectorArrA[0].length > splitSelectorArrB[0].length) {
// if selectorA has higher descendant specificity then selectorB
// (e.g '.foo .bar .grid' and '.grid')
let idx = splitSelectorArrA[0].reduce((res, [item], index) => {
let firstSelectorPart = splitSelectorArrB[0][0][0]
if (item === firstSelectorPart) {
return index
}
return false
}, false)
if (idx) {
result = splitSelectorArrB[0].every((arr, index) => {
return arr.every((part, innerIndex) =>
// because selectorA has more space elements, we need to slice
// selectorA array by 'idx' number to compare them
splitSelectorArrA[0].slice(idx)[index][innerIndex] === part)
})
}
} else {
// if selectorA has the same descendant specificity as selectorB
// this condition covers cases such as: '.grid.foo.bar' and '.grid'
result = splitSelectorArrB.some(byCommaArr => {
return byCommaArr.every((bySpaceArr, index) => {
return bySpaceArr.every(
(part, innerIndex) => splitSelectorArrA[0][index][innerIndex] === part
)
})
})
}
return result
} | javascript | function shouldInheritGap (selA, selB) {
let result
// get arrays of selector split in 3-deep array
let splitSelectorArrA = splitSelector(selA)
let splitSelectorArrB = splitSelector(selB)
if (splitSelectorArrA[0].length < splitSelectorArrB[0].length) {
// abort if selectorA has lower descendant specificity then selectorB
// (e.g '.grid' and '.hello .world .grid')
return false
} else if (splitSelectorArrA[0].length > splitSelectorArrB[0].length) {
// if selectorA has higher descendant specificity then selectorB
// (e.g '.foo .bar .grid' and '.grid')
let idx = splitSelectorArrA[0].reduce((res, [item], index) => {
let firstSelectorPart = splitSelectorArrB[0][0][0]
if (item === firstSelectorPart) {
return index
}
return false
}, false)
if (idx) {
result = splitSelectorArrB[0].every((arr, index) => {
return arr.every((part, innerIndex) =>
// because selectorA has more space elements, we need to slice
// selectorA array by 'idx' number to compare them
splitSelectorArrA[0].slice(idx)[index][innerIndex] === part)
})
}
} else {
// if selectorA has the same descendant specificity as selectorB
// this condition covers cases such as: '.grid.foo.bar' and '.grid'
result = splitSelectorArrB.some(byCommaArr => {
return byCommaArr.every((bySpaceArr, index) => {
return bySpaceArr.every(
(part, innerIndex) => splitSelectorArrA[0][index][innerIndex] === part
)
})
})
}
return result
} | [
"function",
"shouldInheritGap",
"(",
"selA",
",",
"selB",
")",
"{",
"let",
"result",
"// get arrays of selector split in 3-deep array",
"let",
"splitSelectorArrA",
"=",
"splitSelector",
"(",
"selA",
")",
"let",
"splitSelectorArrB",
"=",
"splitSelector",
"(",
"selB",
"... | Compare the selectors and decide if we
need to inherit gap from compared selector or not.
@type {String} selA
@type {String} selB
@return {Boolean} | [
"Compare",
"the",
"selectors",
"and",
"decide",
"if",
"we",
"need",
"to",
"inherit",
"gap",
"from",
"compared",
"selector",
"or",
"not",
"."
] | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/lib/hacks/grid-utils.js#L819-L863 | train | Returns true if selectorA is a descendant of selectorB | [
30522,
3853,
2323,
2378,
5886,
4183,
3654,
2361,
1006,
7367,
2721,
1010,
7367,
20850,
1007,
1063,
2292,
2765,
1013,
1013,
2131,
27448,
1997,
27000,
3975,
1999,
1017,
1011,
2784,
9140,
2292,
19584,
12260,
16761,
2906,
2527,
1027,
19584,
1226... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | onActiveEditorChanged | function onActiveEditorChanged(event, current, previous) {
if (current && !current._codeMirror._lineFolds) {
enableFoldingInEditor(current);
}
if (previous) {
saveLineFolds(previous);
}
} | javascript | function onActiveEditorChanged(event, current, previous) {
if (current && !current._codeMirror._lineFolds) {
enableFoldingInEditor(current);
}
if (previous) {
saveLineFolds(previous);
}
} | [
"function",
"onActiveEditorChanged",
"(",
"event",
",",
"current",
",",
"previous",
")",
"{",
"if",
"(",
"current",
"&&",
"!",
"current",
".",
"_codeMirror",
".",
"_lineFolds",
")",
"{",
"enableFoldingInEditor",
"(",
"current",
")",
";",
"}",
"if",
"(",
"p... | When a brand new editor is seen, initialise fold-gutter and restore line folds in it.
Save line folds in departing editor in case it's getting closed.
@param {object} event the event object
@param {Editor} current the current editor
@param {Editor} previous the previous editor | [
"When",
"a",
"brand",
"new",
"editor",
"is",
"seen",
"initialise",
"fold",
"-",
"gutter",
"and",
"restore",
"line",
"folds",
"in",
"it",
".",
"Save",
"line",
"folds",
"in",
"departing",
"editor",
"in",
"case",
"it",
"s",
"getting",
"closed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L338-L345 | train | On active editor change | [
30522,
3853,
2006,
19620,
2098,
15660,
22305,
2098,
1006,
2724,
1010,
2783,
1010,
3025,
1007,
1063,
2065,
1006,
2783,
1004,
1004,
999,
2783,
1012,
1035,
3642,
14503,
29165,
1012,
1035,
2240,
10371,
2015,
1007,
1063,
9585,
21508,
21280,
1566... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LiveDevMultiBrowser.js | open | function open() {
// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
_getInitialDocFromCurrent().done(function (doc) {
var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(),
otherDocumentsInWorkingFiles;
if (doc && !doc._masterEditor) {
otherDocumentsInWorkingFiles = MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file);
if (!otherDocumentsInWorkingFiles) {
CommandManager.execute(Commands.CMD_OPEN, { fullPath: doc.file.fullPath });
}
}
// wait for server (StaticServer, Base URL or file:)
prepareServerPromise
.done(function () {
_setStatus(STATUS_CONNECTING);
_doLaunchAfterServerReady(doc);
})
.fail(function () {
_showWrongDocError();
});
});
} | javascript | function open() {
// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
_getInitialDocFromCurrent().done(function (doc) {
var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(),
otherDocumentsInWorkingFiles;
if (doc && !doc._masterEditor) {
otherDocumentsInWorkingFiles = MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES);
MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file);
if (!otherDocumentsInWorkingFiles) {
CommandManager.execute(Commands.CMD_OPEN, { fullPath: doc.file.fullPath });
}
}
// wait for server (StaticServer, Base URL or file:)
prepareServerPromise
.done(function () {
_setStatus(STATUS_CONNECTING);
_doLaunchAfterServerReady(doc);
})
.fail(function () {
_showWrongDocError();
});
});
} | [
"function",
"open",
"(",
")",
"{",
"// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange",
"// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...",
"_getInitialDocFromCurrent",
"(",
")",
... | Open a live preview on the current docuemnt. | [
"Open",
"a",
"live",
"preview",
"on",
"the",
"current",
"docuemnt",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L691-L717 | train | open the current document | [
30522,
3853,
2330,
1006,
1007,
1063,
1013,
1013,
28681,
2080,
1024,
2342,
2000,
2448,
1035,
2006,
3527,
24894,
4765,
22305,
2063,
1006,
1007,
2044,
7170,
2065,
9986,
999,
1027,
2783,
3527,
24894,
4765,
2182,
1029,
2672,
2025,
1010,
2144,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_MTRSettings | function parse_MTRSettings(blob) {
var fMTREnabled = blob.read_shift(4) !== 0x00;
var fUserSetThreadCount = blob.read_shift(4) !== 0x00;
var cUserThreadCount = blob.read_shift(4);
return [fMTREnabled, fUserSetThreadCount, cUserThreadCount];
} | javascript | function parse_MTRSettings(blob) {
var fMTREnabled = blob.read_shift(4) !== 0x00;
var fUserSetThreadCount = blob.read_shift(4) !== 0x00;
var cUserThreadCount = blob.read_shift(4);
return [fMTREnabled, fUserSetThreadCount, cUserThreadCount];
} | [
"function",
"parse_MTRSettings",
"(",
"blob",
")",
"{",
"var",
"fMTREnabled",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
"!==",
"0x00",
";",
"var",
"fUserSetThreadCount",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
"!==",
"0x00",
";",
"var",
"cUse... | /* [MS-XLS] 2.4.173 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"173"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6306-L6311 | train | Parse MTR settings | [
30522,
3853,
11968,
3366,
1035,
11047,
22573,
13027,
2015,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
4718,
7913,
22966,
2094,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1018,
1007,
999,
1027,
1027,
1014,
2595,
8889,
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... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | offset | function offset ( elem, orientation ) {
var rect = elem.getBoundingClientRect(),
doc = elem.ownerDocument,
docElem = doc.documentElement,
pageOffset = getPageOffset();
// getBoundingClientRect contains left scroll in Chrome on Android.
// I haven't found a feature detection that proves this. Worst case
// scenario on mis-match: the 'tap' feature on horizontal sliders breaks.
if ( /webkit.*Chrome.*Mobile/i.test(navigator.userAgent) ) {
pageOffset.x = 0;
}
return orientation ? (rect.top + pageOffset.y - docElem.clientTop) : (rect.left + pageOffset.x - docElem.clientLeft);
} | javascript | function offset ( elem, orientation ) {
var rect = elem.getBoundingClientRect(),
doc = elem.ownerDocument,
docElem = doc.documentElement,
pageOffset = getPageOffset();
// getBoundingClientRect contains left scroll in Chrome on Android.
// I haven't found a feature detection that proves this. Worst case
// scenario on mis-match: the 'tap' feature on horizontal sliders breaks.
if ( /webkit.*Chrome.*Mobile/i.test(navigator.userAgent) ) {
pageOffset.x = 0;
}
return orientation ? (rect.top + pageOffset.y - docElem.clientTop) : (rect.left + pageOffset.x - docElem.clientLeft);
} | [
"function",
"offset",
"(",
"elem",
",",
"orientation",
")",
"{",
"var",
"rect",
"=",
"elem",
".",
"getBoundingClientRect",
"(",
")",
",",
"doc",
"=",
"elem",
".",
"ownerDocument",
",",
"docElem",
"=",
"doc",
".",
"documentElement",
",",
"pageOffset",
"=",
... | Current position of an element relative to the document. | [
"Current",
"position",
"of",
"an",
"element",
"relative",
"to",
"the",
"document",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L59-L74 | train | Get the offset of an element | [
30522,
3853,
16396,
1006,
3449,
6633,
1010,
10296,
1007,
1063,
13075,
28667,
2102,
1027,
3449,
6633,
1012,
2131,
15494,
2075,
20464,
11638,
2890,
6593,
1006,
1007,
1010,
9986,
1027,
3449,
6633,
1012,
3954,
3527,
24894,
4765,
1010,
9986,
122... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/computed-property-spacing.js | reportNoEndingSpace | function reportNoEndingSpace(node, token, tokenBefore) {
context.report({
node,
loc: token.loc.start,
messageId: "unexpectedSpaceBefore",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
}
});
} | javascript | function reportNoEndingSpace(node, token, tokenBefore) {
context.report({
node,
loc: token.loc.start,
messageId: "unexpectedSpaceBefore",
data: {
tokenValue: token.value
},
fix(fixer) {
return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
}
});
} | [
"function",
"reportNoEndingSpace",
"(",
"node",
",",
"token",
",",
"tokenBefore",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"token",
".",
"loc",
".",
"start",
",",
"messageId",
":",
"\"unexpectedSpaceBefore\"",
",",
"data",
":"... | Reports that there shouldn't be a space before the last token
@param {ASTNode} node - The node to report in the event of an error.
@param {Token} token - The token to use for the report.
@param {Token} tokenBefore - The token before `token`.
@returns {void} | [
"Reports",
"that",
"there",
"shouldn",
"t",
"be",
"a",
"space",
"before",
"the",
"last",
"token"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/computed-property-spacing.js#L77-L89 | train | Reports an unexpected space before the token. | [
30522,
3853,
3189,
3630,
18537,
23058,
1006,
13045,
1010,
19204,
1010,
19204,
4783,
29278,
2063,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
8840,
2278,
1024,
19204,
1012,
8840,
2278,
1012,
2707,
1010,
4471,
3593,
1024,
1000,
922... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/_Batch.js | serializeHeaders | function serializeHeaders(mHeaders) {
var sHeaderName,
aHeaders = [];
for (sHeaderName in mHeaders) {
aHeaders = aHeaders.concat(sHeaderName, ":", mHeaders[sHeaderName], "\r\n");
}
return aHeaders;
} | javascript | function serializeHeaders(mHeaders) {
var sHeaderName,
aHeaders = [];
for (sHeaderName in mHeaders) {
aHeaders = aHeaders.concat(sHeaderName, ":", mHeaders[sHeaderName], "\r\n");
}
return aHeaders;
} | [
"function",
"serializeHeaders",
"(",
"mHeaders",
")",
"{",
"var",
"sHeaderName",
",",
"aHeaders",
"=",
"[",
"]",
";",
"for",
"(",
"sHeaderName",
"in",
"mHeaders",
")",
"{",
"aHeaders",
"=",
"aHeaders",
".",
"concat",
"(",
"sHeaderName",
",",
"\":\"",
",",
... | Serializes a map of request headers to be used in a $batch request.
@param {object} mHeaders
A map of request headers
@returns {object[]} Array representing the serialized headers | [
"Serializes",
"a",
"map",
"of",
"request",
"headers",
"to",
"be",
"used",
"in",
"a",
"$batch",
"request",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js#L218-L227 | train | Serialize headers to a string array | [
30522,
3853,
7642,
4697,
4974,
2545,
1006,
1049,
4974,
2545,
1007,
1063,
13075,
16994,
25888,
14074,
1010,
3805,
2545,
1027,
1031,
1033,
1025,
2005,
1006,
16994,
25888,
14074,
1999,
1049,
4974,
2545,
1007,
1063,
3805,
2545,
1027,
3805,
2545... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js | createElementWithClassName | function createElementWithClassName(type, className) {
var elm = document.createElement(type);
elm.className = className;
return elm;
} | javascript | function createElementWithClassName(type, className) {
var elm = document.createElement(type);
elm.className = className;
return elm;
} | [
"function",
"createElementWithClassName",
"(",
"type",
",",
"className",
")",
"{",
"var",
"elm",
"=",
"document",
".",
"createElement",
"(",
"type",
")",
";",
"elm",
".",
"className",
"=",
"className",
";",
"return",
"elm",
";",
"}"
] | Creates an element of a specified type with a specified class name.
@param {string} type The node type.
@param {string} className The class name to use.
@return {Element} The created element. | [
"Creates",
"an",
"element",
"of",
"a",
"specified",
"type",
"with",
"a",
"specified",
"class",
"name",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js#L264-L268 | train | Creates an element with the given type and class name. | [
30522,
3853,
3443,
12260,
3672,
24415,
26266,
18442,
1006,
2828,
1010,
2465,
18442,
1007,
1063,
13075,
17709,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
2828,
1007,
1025,
17709,
1012,
2465,
18442,
1027,
2465,
18442,
1025,
2709,
17709,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/ExtensionManager.js | markForDisabling | function markForDisabling(id, mark) {
if (mark) {
_idsToDisable[id] = true;
} else {
delete _idsToDisable[id];
}
exports.trigger("statusChange", id);
} | javascript | function markForDisabling(id, mark) {
if (mark) {
_idsToDisable[id] = true;
} else {
delete _idsToDisable[id];
}
exports.trigger("statusChange", id);
} | [
"function",
"markForDisabling",
"(",
"id",
",",
"mark",
")",
"{",
"if",
"(",
"mark",
")",
"{",
"_idsToDisable",
"[",
"id",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"delete",
"_idsToDisable",
"[",
"id",
"]",
";",
"}",
"exports",
".",
"trigger",
"(",
... | Marks an extension for disabling later, or unmarks an extension previously marked.
@param {string} id The id of the extension
@param {boolean} mark Whether to mark or unmark the extension. | [
"Marks",
"an",
"extension",
"for",
"disabling",
"later",
"or",
"unmarks",
"an",
"extension",
"previously",
"marked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L543-L550 | train | Mark a phrase for disabling | [
30522,
3853,
2928,
3877,
14268,
9709,
1006,
8909,
1010,
2928,
1007,
1063,
2065,
1006,
2928,
1007,
1063,
1035,
8909,
16033,
10521,
3085,
1031,
8909,
1033,
1027,
2995,
1025,
1065,
2842,
1063,
3972,
12870,
1035,
8909,
16033,
10521,
3085,
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... |
ipfs/js-ipfs | examples/exchange-files-in-browser/public/app.js | connectToPeer | function connectToPeer (event) {
const multiaddr = $multiaddrInput.value
if (!multiaddr) {
return onError('No multiaddr was inserted.')
}
node.swarm.connect(multiaddr)
.then(() => {
onSuccess(`Successfully connected to peer.`)
$multiaddrInput.value = ''
})
.catch(() => onError('An error occurred when connecting to the peer.'))
} | javascript | function connectToPeer (event) {
const multiaddr = $multiaddrInput.value
if (!multiaddr) {
return onError('No multiaddr was inserted.')
}
node.swarm.connect(multiaddr)
.then(() => {
onSuccess(`Successfully connected to peer.`)
$multiaddrInput.value = ''
})
.catch(() => onError('An error occurred when connecting to the peer.'))
} | [
"function",
"connectToPeer",
"(",
"event",
")",
"{",
"const",
"multiaddr",
"=",
"$multiaddrInput",
".",
"value",
"if",
"(",
"!",
"multiaddr",
")",
"{",
"return",
"onError",
"(",
"'No multiaddr was inserted.'",
")",
"}",
"node",
".",
"swarm",
".",
"connect",
... | /* ===========================================================================
Peers handling
=========================================================================== | [
"/",
"*",
"===========================================================================",
"Peers",
"handling",
"==========================================================================="
] | 97e67601094acda3906549ecb0248fd09f1a8cc3 | https://github.com/ipfs/js-ipfs/blob/97e67601094acda3906549ecb0248fd09f1a8cc3/examples/exchange-files-in-browser/public/app.js#L253-L266 | train | connects to peer | [
30522,
3853,
7532,
14399,
11510,
1006,
2724,
1007,
1063,
9530,
3367,
4800,
4215,
13626,
1027,
1002,
4800,
4215,
13626,
2378,
18780,
1012,
3643,
2065,
1006,
999,
4800,
4215,
13626,
1007,
1063,
2709,
2028,
18933,
2099,
1006,
1005,
2053,
4800,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | components/prism-javadoclike.js | addSupport | function addSupport(languages, docLanguage) {
if (typeof languages === 'string') {
languages = [languages];
}
languages.forEach(function (lang) {
docCommentSupport(lang, function (pattern) {
if (!pattern.inside) {
pattern.inside = {};
}
pattern.inside.rest = docLanguage;
});
});
} | javascript | function addSupport(languages, docLanguage) {
if (typeof languages === 'string') {
languages = [languages];
}
languages.forEach(function (lang) {
docCommentSupport(lang, function (pattern) {
if (!pattern.inside) {
pattern.inside = {};
}
pattern.inside.rest = docLanguage;
});
});
} | [
"function",
"addSupport",
"(",
"languages",
",",
"docLanguage",
")",
"{",
"if",
"(",
"typeof",
"languages",
"===",
"'string'",
")",
"{",
"languages",
"=",
"[",
"languages",
"]",
";",
"}",
"languages",
".",
"forEach",
"(",
"function",
"(",
"lang",
")",
"{... | Adds doc-comment support to the given languages for the given documentation language.
@param {string[]|string} languages
@param {Object} docLanguage | [
"Adds",
"doc",
"-",
"comment",
"support",
"to",
"the",
"given",
"languages",
"for",
"the",
"given",
"documentation",
"language",
"."
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-javadoclike.js#L67-L80 | train | Add support for doc - comment | [
30522,
3853,
9909,
6279,
6442,
1006,
4155,
1010,
9986,
25023,
6692,
3351,
1007,
1063,
2065,
1006,
2828,
11253,
4155,
1027,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
4155,
1027,
1031,
4155,
1033,
1025,
1065,
4155,
1012,
18921,
6776,
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... |
pixijs/pixi.js | packages/prepare/src/Prepare.js | uploadBaseTextures | function uploadBaseTextures(renderer, item)
{
if (item instanceof BaseTexture)
{
// if the texture already has a GL texture, then the texture has been prepared or rendered
// before now. If the texture changed, then the changer should be calling texture.update() which
// reuploads the texture without need for preparing it again
if (!item._glTextures[renderer.CONTEXT_UID])
{
renderer.textureManager.updateTexture(item);
}
return true;
}
return false;
} | javascript | function uploadBaseTextures(renderer, item)
{
if (item instanceof BaseTexture)
{
// if the texture already has a GL texture, then the texture has been prepared or rendered
// before now. If the texture changed, then the changer should be calling texture.update() which
// reuploads the texture without need for preparing it again
if (!item._glTextures[renderer.CONTEXT_UID])
{
renderer.textureManager.updateTexture(item);
}
return true;
}
return false;
} | [
"function",
"uploadBaseTextures",
"(",
"renderer",
",",
"item",
")",
"{",
"if",
"(",
"item",
"instanceof",
"BaseTexture",
")",
"{",
"// if the texture already has a GL texture, then the texture has been prepared or rendered",
"// before now. If the texture changed, then the changer s... | Built-in hook to upload PIXI.Texture objects to the GPU.
@private
@param {PIXI.Renderer} renderer - instance of the webgl renderer
@param {PIXI.DisplayObject} item - Item to check
@return {boolean} If item was uploaded. | [
"Built",
"-",
"in",
"hook",
"to",
"upload",
"PIXI",
".",
"Texture",
"objects",
"to",
"the",
"GPU",
"."
] | 99ae03b7565ae7ca5a6de633b0a277f7128fa4d0 | https://github.com/pixijs/pixi.js/blob/99ae03b7565ae7ca5a6de633b0a277f7128fa4d0/packages/prepare/src/Prepare.js#L39-L55 | train | upload base textures | [
30522,
3853,
2039,
11066,
15058,
18209,
14900,
1006,
17552,
2121,
1010,
8875,
1007,
1063,
2065,
1006,
8875,
6013,
11253,
2918,
18209,
5397,
1007,
1063,
1013,
1013,
2065,
1996,
14902,
2525,
2038,
1037,
1043,
2140,
14902,
1010,
2059,
1996,
14... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/node/AutoUpdateDomain.js | registerNodeFunctions | function registerNodeFunctions() {
functionMap["node.downloadInstaller"] = downloadInstaller;
functionMap["node.performCleanup"] = performCleanup;
functionMap["node.validateInstaller"] = validateChecksum;
functionMap["node.initializeState"] = initializeState;
functionMap["node.checkInstallerStatus"] = checkInstallerStatus;
functionMap["node.removeFromRequesters"] = removeFromRequesters;
} | javascript | function registerNodeFunctions() {
functionMap["node.downloadInstaller"] = downloadInstaller;
functionMap["node.performCleanup"] = performCleanup;
functionMap["node.validateInstaller"] = validateChecksum;
functionMap["node.initializeState"] = initializeState;
functionMap["node.checkInstallerStatus"] = checkInstallerStatus;
functionMap["node.removeFromRequesters"] = removeFromRequesters;
} | [
"function",
"registerNodeFunctions",
"(",
")",
"{",
"functionMap",
"[",
"\"node.downloadInstaller\"",
"]",
"=",
"downloadInstaller",
";",
"functionMap",
"[",
"\"node.performCleanup\"",
"]",
"=",
"performCleanup",
";",
"functionMap",
"[",
"\"node.validateInstaller\"",
"]",... | Generates a map for node side functions | [
"Generates",
"a",
"map",
"for",
"node",
"side",
"functions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L405-L412 | train | Register node functions | [
30522,
3853,
4236,
3630,
3207,
11263,
27989,
2015,
1006,
1007,
1063,
3853,
2863,
2361,
1031,
1000,
13045,
1012,
8816,
7076,
9080,
3917,
1000,
1033,
1027,
8816,
7076,
9080,
3917,
1025,
3853,
2863,
2361,
1031,
1000,
13045,
1012,
4685,
14321,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | ElectronClient/app/main.js | envFromArgs | function envFromArgs(args) {
if (!args) return 'prod';
const envIndex = args.indexOf('--env');
const devIndex = args.indexOf('dev');
if (envIndex === devIndex - 1) return 'dev';
return 'prod';
} | javascript | function envFromArgs(args) {
if (!args) return 'prod';
const envIndex = args.indexOf('--env');
const devIndex = args.indexOf('dev');
if (envIndex === devIndex - 1) return 'dev';
return 'prod';
} | [
"function",
"envFromArgs",
"(",
"args",
")",
"{",
"if",
"(",
"!",
"args",
")",
"return",
"'prod'",
";",
"const",
"envIndex",
"=",
"args",
".",
"indexOf",
"(",
"'--env'",
")",
";",
"const",
"devIndex",
"=",
"args",
".",
"indexOf",
"(",
"'dev'",
")",
"... | Flags are parsed properly in BaseApplication, however it's better to have the env as early as possible to enable debugging capabilities. | [
"Flags",
"are",
"parsed",
"properly",
"in",
"BaseApplication",
"however",
"it",
"s",
"better",
"to",
"have",
"the",
"env",
"as",
"early",
"as",
"possible",
"to",
"enable",
"debugging",
"capabilities",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/ElectronClient/app/main.js#L19-L25 | train | Get the environment from the args | [
30522,
3853,
4372,
2615,
19699,
30524,
1005,
1007,
1025,
9530,
3367,
23601,
3207,
2595,
1027,
12098,
5620,
1012,
5950,
11253,
1006,
1005,
16475,
1005,
1007,
1025,
2065,
1006,
4372,
6371,
3207,
2595,
1027,
1027,
1027,
23601,
3207,
2595,
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... |
adobe/brackets | src/extensibility/node/ExtensionManagerDomain.js | function (error, response, body) {
if (error) {
// Usually means we never got a response - server is down, no DNS entry, etc.
_endDownload(downloadId, Errors.NO_SERVER_RESPONSE);
return;
}
if (response.statusCode !== 200) {
_endDownload(downloadId, [Errors.BAD_HTTP_STATUS, response.statusCode]);
return;
}
var stream = temp.createWriteStream("brackets");
if (!stream) {
_endDownload(downloadId, Errors.CANNOT_WRITE_TEMP);
return;
}
pendingDownloads[downloadId].localPath = stream.path;
pendingDownloads[downloadId].outStream = stream;
stream.write(body);
_endDownload(downloadId);
} | javascript | function (error, response, body) {
if (error) {
// Usually means we never got a response - server is down, no DNS entry, etc.
_endDownload(downloadId, Errors.NO_SERVER_RESPONSE);
return;
}
if (response.statusCode !== 200) {
_endDownload(downloadId, [Errors.BAD_HTTP_STATUS, response.statusCode]);
return;
}
var stream = temp.createWriteStream("brackets");
if (!stream) {
_endDownload(downloadId, Errors.CANNOT_WRITE_TEMP);
return;
}
pendingDownloads[downloadId].localPath = stream.path;
pendingDownloads[downloadId].outStream = stream;
stream.write(body);
_endDownload(downloadId);
} | [
"function",
"(",
"error",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"error",
")",
"{",
"// Usually means we never got a response - server is down, no DNS entry, etc.",
"_endDownload",
"(",
"downloadId",
",",
"Errors",
".",
"NO_SERVER_RESPONSE",
")",
";",
"ret... | Note: we could use the traditional "response"/"data"/"end" events too if we wanted to stream data incrementally, limit download size, etc. - but the simple callback is good enough for our needs. | [
"Note",
":",
"we",
"could",
"use",
"the",
"traditional",
"response",
"/",
"data",
"/",
"end",
"events",
"too",
"if",
"we",
"wanted",
"to",
"stream",
"data",
"incrementally",
"limit",
"download",
"size",
"etc",
".",
"-",
"but",
"the",
"simple",
"callback",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/ExtensionManagerDomain.js#L405-L426 | train | Called when the download is complete | [
30522,
3853,
1006,
7561,
1010,
3433,
1010,
2303,
1007,
1063,
2065,
1006,
7561,
1007,
1063,
1013,
1013,
2788,
2965,
2057,
2196,
2288,
1037,
3433,
1011,
8241,
2003,
2091,
1010,
2053,
1040,
3619,
4443,
1010,
4385,
1012,
1035,
2203,
7698,
110... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_wb_bin | function parse_wb_bin(data, opts) {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state = [];
var pass = false;
if(!opts) opts = {};
opts.biff = 12;
var Names = [];
var supbooks = ([[]]);
supbooks.SheetNames = [];
supbooks.XTI = [];
recordhopper(data, function hopper_wb(val, R_n, RT) {
switch(RT) {
case 0x009C: /* 'BrtBundleSh' */
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
if(val.Sheet != null) opts.SID = val.Sheet;
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete opts.SID;
delete val.Ptg;
Names.push(val);
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
if(!supbooks[0].length) supbooks[0] = [RT, val];
else supbooks.push([RT, val]);
supbooks[supbooks.length - 1].XTI = [];
break;
case 0x016A: /* 'BrtExternSheet' */
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
supbooks.XTI = supbooks.XTI.concat(val);
break;
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
case 0x0C00: /* 'BrtUid' */
case 0x0C01: /* 'BrtRevisionPtr' */
case 0x0817: /* 'BrtAbsPath15' */
case 0x0216: /* 'BrtBookProtection' */
case 0x02A5: /* 'BrtBookProtectionIso' */
case 0x009E: /* 'BrtBookView' */
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
case 0x0080: /* 'BrtFileVersion' */
case 0x0299: /* 'BrtFnGroup' */
case 0x0850: /* 'BrtModelRelationship' */
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
case 0x018D: /* 'BrtUserBookView' */
case 0x009A: /* 'BrtWbFactoid' */
case 0x045D: /* 'BrtWbProp14' */
case 0x0229: /* 'BrtWebOpt' */
case 0x082B: /* 'BrtWorkBookPr15' */
break;
case 0x0023: /* 'BrtFRTBegin' */
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
parse_wb_defaults(wb);
// $FlowIgnore
wb.Names = Names;
(wb).supbooks = supbooks;
return wb;
} | javascript | function parse_wb_bin(data, opts) {
var wb = { AppVersion:{}, WBProps:{}, WBView:[], Sheets:[], CalcPr:{}, xmlns: "" };
var state = [];
var pass = false;
if(!opts) opts = {};
opts.biff = 12;
var Names = [];
var supbooks = ([[]]);
supbooks.SheetNames = [];
supbooks.XTI = [];
recordhopper(data, function hopper_wb(val, R_n, RT) {
switch(RT) {
case 0x009C: /* 'BrtBundleSh' */
supbooks.SheetNames.push(val.name);
wb.Sheets.push(val); break;
case 0x0099: /* 'BrtWbProp' */
wb.WBProps = val; break;
case 0x0027: /* 'BrtName' */
if(val.Sheet != null) opts.SID = val.Sheet;
val.Ref = stringify_formula(val.Ptg, null, null, supbooks, opts);
delete opts.SID;
delete val.Ptg;
Names.push(val);
break;
case 0x040C: /* 'BrtNameExt' */ break;
case 0x0165: /* 'BrtSupSelf' */
case 0x0166: /* 'BrtSupSame' */
case 0x0163: /* 'BrtSupBookSrc' */
case 0x029B: /* 'BrtSupAddin' */
if(!supbooks[0].length) supbooks[0] = [RT, val];
else supbooks.push([RT, val]);
supbooks[supbooks.length - 1].XTI = [];
break;
case 0x016A: /* 'BrtExternSheet' */
if(supbooks.length === 0) { supbooks[0] = []; supbooks[0].XTI = []; }
supbooks[supbooks.length - 1].XTI = supbooks[supbooks.length - 1].XTI.concat(val);
supbooks.XTI = supbooks.XTI.concat(val);
break;
case 0x0169: /* 'BrtPlaceholderName' */
break;
/* case 'BrtModelTimeGroupingCalcCol' */
case 0x0C00: /* 'BrtUid' */
case 0x0C01: /* 'BrtRevisionPtr' */
case 0x0817: /* 'BrtAbsPath15' */
case 0x0216: /* 'BrtBookProtection' */
case 0x02A5: /* 'BrtBookProtectionIso' */
case 0x009E: /* 'BrtBookView' */
case 0x009D: /* 'BrtCalcProp' */
case 0x0262: /* 'BrtCrashRecErr' */
case 0x0802: /* 'BrtDecoupledPivotCacheID' */
case 0x009B: /* 'BrtFileRecover' */
case 0x0224: /* 'BrtFileSharing' */
case 0x02A4: /* 'BrtFileSharingIso' */
case 0x0080: /* 'BrtFileVersion' */
case 0x0299: /* 'BrtFnGroup' */
case 0x0850: /* 'BrtModelRelationship' */
case 0x084D: /* 'BrtModelTable' */
case 0x0225: /* 'BrtOleSize' */
case 0x0805: /* 'BrtPivotTableRef' */
case 0x0254: /* 'BrtSmartTagType' */
case 0x081C: /* 'BrtTableSlicerCacheID' */
case 0x081B: /* 'BrtTableSlicerCacheIDs' */
case 0x0822: /* 'BrtTimelineCachePivotCacheID' */
case 0x018D: /* 'BrtUserBookView' */
case 0x009A: /* 'BrtWbFactoid' */
case 0x045D: /* 'BrtWbProp14' */
case 0x0229: /* 'BrtWebOpt' */
case 0x082B: /* 'BrtWorkBookPr15' */
break;
case 0x0023: /* 'BrtFRTBegin' */
state.push(R_n); pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
state.pop(); pass = false; break;
case 0x0025: /* 'BrtACBegin' */
state.push(R_n); pass = true; break;
case 0x0026: /* 'BrtACEnd' */
state.pop(); pass = false; break;
case 0x0010: /* 'BrtFRTArchID$' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || (opts.WTF && state[state.length-1] != "BrtACBegin" && state[state.length-1] != "BrtFRTBegin")) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
parse_wb_defaults(wb);
// $FlowIgnore
wb.Names = Names;
(wb).supbooks = supbooks;
return wb;
} | [
"function",
"parse_wb_bin",
"(",
"data",
",",
"opts",
")",
"{",
"var",
"wb",
"=",
"{",
"AppVersion",
":",
"{",
"}",
",",
"WBProps",
":",
"{",
"}",
",",
"WBView",
":",
"[",
"]",
",",
"Sheets",
":",
"[",
"]",
",",
"CalcPr",
":",
"{",
"}",
",",
... | /* [MS-XLSB] 2.1.7.61 Workbook | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"1",
".",
"7",
".",
"61",
"Workbook"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L14854-L14956 | train | Parse a binary file. | [
30522,
3853,
11968,
3366,
1035,
25610,
1035,
8026,
1006,
2951,
1010,
23569,
2015,
1007,
1063,
13075,
25610,
1027,
1063,
10439,
27774,
1024,
1063,
1065,
1010,
25610,
21572,
4523,
1024,
1063,
1065,
1010,
25610,
8584,
1024,
1031,
1033,
1010,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/xml/xml-node.js | XmlNode | function XmlNode(name, children) {
if (children === void 0) { children = []; }
this.name = name;
this.children = children;
this.attributes = {};
} | javascript | function XmlNode(name, children) {
if (children === void 0) { children = []; }
this.name = name;
this.children = children;
this.attributes = {};
} | [
"function",
"XmlNode",
"(",
"name",
",",
"children",
")",
"{",
"if",
"(",
"children",
"===",
"void",
"0",
")",
"{",
"children",
"=",
"[",
"]",
";",
"}",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"children",
"=",
"children",
";",
"this",
... | Represents an XML node.
@api private | [
"Represents",
"an",
"XML",
"node",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/xml/xml-node.js#L7-L12 | train | A node in a node tree | [
30522,
3853,
20950,
3630,
3207,
1006,
2171,
1010,
2336,
1007,
1063,
2065,
1006,
2336,
1027,
1027,
1027,
11675,
1014,
1007,
1063,
2336,
1027,
1031,
1033,
1025,
1065,
2023,
1012,
2171,
1027,
2171,
1025,
2023,
1012,
2336,
1027,
2336,
1025,
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.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js | function (component, savedComponents) {
for (var index = 0; index < savedComponents.length; index += 1) {
if (savedComponents[index].text == component.text && savedComponents[index].selected) {
return true;
}
}
return false;
} | javascript | function (component, savedComponents) {
for (var index = 0; index < savedComponents.length; index += 1) {
if (savedComponents[index].text == component.text && savedComponents[index].selected) {
return true;
}
}
return false;
} | [
"function",
"(",
"component",
",",
"savedComponents",
")",
"{",
"for",
"(",
"var",
"index",
"=",
"0",
";",
"index",
"<",
"savedComponents",
".",
"length",
";",
"index",
"+=",
"1",
")",
"{",
"if",
"(",
"savedComponents",
"[",
"index",
"]",
".",
"text",
... | Checks if given execution scope component is selected comparing against an array of settings
@param {Object} component The current component object to be checked
@param {Array} savedComponents The local storage settings for the checked execution scope components
@returns {boolean} If the component is checked or not | [
"Checks",
"if",
"given",
"execution",
"scope",
"component",
"is",
"selected",
"comparing",
"against",
"an",
"array",
"of",
"settings"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L348-L355 | train | Check if a component is selected in the saved list | [
30522,
3853,
1006,
6922,
1010,
5552,
9006,
29513,
7666,
1007,
1063,
2005,
1006,
13075,
5950,
1027,
1014,
1025,
5950,
1026,
5552,
9006,
29513,
7666,
1012,
3091,
1025,
5950,
1009,
1027,
1015,
1007,
1063,
2065,
1006,
5552,
9006,
29513,
7666,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
keplergl/kepler.gl | src/reducers/vis-state-updaters.js | generateLayerMetaForSplitViews | function generateLayerMetaForSplitViews(layer) {
return {
isAvailable: layer.config.isVisible,
isVisible: layer.config.isVisible
};
} | javascript | function generateLayerMetaForSplitViews(layer) {
return {
isAvailable: layer.config.isVisible,
isVisible: layer.config.isVisible
};
} | [
"function",
"generateLayerMetaForSplitViews",
"(",
"layer",
")",
"{",
"return",
"{",
"isAvailable",
":",
"layer",
".",
"config",
".",
"isVisible",
",",
"isVisible",
":",
"layer",
".",
"config",
".",
"isVisible",
"}",
";",
"}"
] | /* eslint-enable max-statements | [
"/",
"*",
"eslint",
"-",
"enable",
"max",
"-",
"statements"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1081-L1086 | train | Generate meta for a layer for split views | [
30522,
3853,
9699,
24314,
11368,
10354,
5668,
24759,
4183,
8584,
2015,
1006,
6741,
1007,
1063,
2709,
1063,
18061,
3567,
11733,
3468,
1024,
6741,
1012,
9530,
8873,
2290,
1012,
2003,
11365,
7028,
1010,
2003,
11365,
7028,
1024,
6741,
1012,
953... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | examples/replace-component/src/components/side-bar.js | CustomSidebarFactory | function CustomSidebarFactory(CloseButton) {
const SideBar = SidebarFactory(CloseButton);
const CustomSidebar = (props) => (
<StyledSideBarContainer>
<SideBar {...props}/>
</StyledSideBarContainer>
);
return CustomSidebar;
} | javascript | function CustomSidebarFactory(CloseButton) {
const SideBar = SidebarFactory(CloseButton);
const CustomSidebar = (props) => (
<StyledSideBarContainer>
<SideBar {...props}/>
</StyledSideBarContainer>
);
return CustomSidebar;
} | [
"function",
"CustomSidebarFactory",
"(",
"CloseButton",
")",
"{",
"const",
"SideBar",
"=",
"SidebarFactory",
"(",
"CloseButton",
")",
";",
"const",
"CustomSidebar",
"=",
"(",
"props",
")",
"=>",
"(",
"<",
"StyledSideBarContainer",
">",
"\n ",
"<",
"SideBar"... | Custom sidebar will render kepler.gl default side bar adding a wrapper component to edit its style | [
"Custom",
"sidebar",
"will",
"render",
"kepler",
".",
"gl",
"default",
"side",
"bar",
"adding",
"a",
"wrapper",
"component",
"to",
"edit",
"its",
"style"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/replace-component/src/components/side-bar.js#L72-L80 | train | Custom Sidebar factory | [
30522,
3853,
8205,
5178,
8237,
21450,
1006,
2485,
8569,
15474,
1007,
1063,
9530,
3367,
2217,
8237,
1027,
30524,
8237,
8663,
18249,
2121,
1028,
1026,
2217,
8237,
1063,
1012,
1012,
1012,
24387,
1065,
1013,
1028,
1026,
1013,
13650,
7363,
8237,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DebugCommands/NodeDebugUtils.js | restartNode | function restartNode() {
try {
_nodeConnection.domains.base.restartNode();
} catch (e) {
window.alert("Failed trying to restart Node: " + e.message);
}
} | javascript | function restartNode() {
try {
_nodeConnection.domains.base.restartNode();
} catch (e) {
window.alert("Failed trying to restart Node: " + e.message);
}
} | [
"function",
"restartNode",
"(",
")",
"{",
"try",
"{",
"_nodeConnection",
".",
"domains",
".",
"base",
".",
"restartNode",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"window",
".",
"alert",
"(",
"\"Failed trying to restart Node: \"",
"+",
"e",
".",
... | Sends a command to node to cause a restart. | [
"Sends",
"a",
"command",
"to",
"node",
"to",
"cause",
"a",
"restart",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/DebugCommands/NodeDebugUtils.js#L64-L70 | train | restart the node | [
30522,
3853,
23818,
3630,
3207,
1006,
1007,
1063,
3046,
1063,
1035,
13045,
8663,
2638,
7542,
1012,
13100,
1012,
2918,
1012,
23818,
3630,
3207,
1006,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
3332,
1012,
9499,
1006,
1000,
3478,
2667,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxCellAttributeChange | function mxCellAttributeChange(cell, attribute, value)
{
this.cell = cell;
this.attribute = attribute;
this.value = value;
this.previous = value;
} | javascript | function mxCellAttributeChange(cell, attribute, value)
{
this.cell = cell;
this.attribute = attribute;
this.value = value;
this.previous = value;
} | [
"function",
"mxCellAttributeChange",
"(",
"cell",
",",
"attribute",
",",
"value",
")",
"{",
"this",
".",
"cell",
"=",
"cell",
";",
"this",
".",
"attribute",
"=",
"attribute",
";",
"this",
".",
"value",
"=",
"value",
";",
"this",
".",
"previous",
"=",
"... | Class: mxCellAttributeChange
Action to change the attribute of a cell's user object.
There is no method on the graph model that uses this
action. To use the action, you can use the code shown
in the example below.
Example:
To change the attributeName in the cell's user object
to attributeValue, use the following code:
(code)
model.beginUpdate();
try
{
var edit = new mxCellAttributeChange(
cell, attributeName, attributeValue);
model.execute(edit);
}
finally
{
model.endUpdate();
}
(end)
Constructor: mxCellAttributeChange
Constructs a change of a attribute of the DOM node
stored as the value of the given <mxCell>. | [
"Class",
":",
"mxCellAttributeChange"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L41934-L41940 | train | This method is called when the attribute of a cell changes | [
30522,
3853,
25630,
29109,
20051,
18886,
8569,
15007,
22043,
1006,
3526,
1010,
17961,
1010,
3643,
1007,
1063,
2023,
1012,
3526,
1027,
3526,
1025,
2023,
1012,
17961,
1027,
17961,
1025,
2023,
1012,
3643,
1027,
3643,
1025,
2023,
1012,
3025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/ast-utils.js | getUpperFunction | function getUpperFunction(node) {
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
if (anyFunctionPattern.test(currentNode.type)) {
return currentNode;
}
}
return null;
} | javascript | function getUpperFunction(node) {
for (let currentNode = node; currentNode; currentNode = currentNode.parent) {
if (anyFunctionPattern.test(currentNode.type)) {
return currentNode;
}
}
return null;
} | [
"function",
"getUpperFunction",
"(",
"node",
")",
"{",
"for",
"(",
"let",
"currentNode",
"=",
"node",
";",
"currentNode",
";",
"currentNode",
"=",
"currentNode",
".",
"parent",
")",
"{",
"if",
"(",
"anyFunctionPattern",
".",
"test",
"(",
"currentNode",
".",
... | Finds a function node from ancestors of a node.
@param {ASTNode} node - A start node to find.
@returns {Node|null} A found function node. | [
"Finds",
"a",
"function",
"node",
"from",
"ancestors",
"of",
"a",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/ast-utils.js#L87-L94 | train | Get the upper function of a node | [
30522,
3853,
2131,
29547,
12881,
4609,
7542,
1006,
13045,
1007,
1063,
2005,
1006,
2292,
2783,
3630,
3207,
1027,
13045,
1025,
2783,
3630,
3207,
1025,
2783,
3630,
3207,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | examples/3d/js/camera.js | function(col, ray, angle) {
var step, drops, rain, texX, wall;
var tex1 = game.map.wall;
var tex2 = game.map.speaker;
var left = Math.floor(col * this.spacing);
var width = Math.ceil(this.spacing);
var hit = -1;
// Find the next wall hit.
while (++hit < ray.length && ray[hit].height <= 0);
// Draw the wall sections and rain drops.
for (var i=ray.length - 1; i>=0; i--) {
step = ray[i];
drops = Math.pow(Math.random(), 100) * i;
rain = (drops > 0) && this.project(0.2, angle, step.dist);
var tex = (step.type === 1) ? tex1 : tex2;
if (i === hit) {
texX = Math.floor(tex.width * step.offset);
wall = this.project(step.height, angle, step.dist);
ctx.globalAlpha = 1;
ctx.drawImage(tex.image, texX, 0, 1, tex.height, left, wall.top, width, wall.height);
ctx.fillStyle = '#000';
ctx.globalAlpha = Math.max((step.dist + step.shading) / this.lightRange - game.map.light, 0);
ctx.fillRect(left, wall.top, width, wall.height);
}
ctx.fillStyle = '#fff';
ctx.globalAlpha = 0.15;
while (--drops > 0) {
ctx.fillRect(left, Math.random() * rain.top, 1, rain.height);
}
}
} | javascript | function(col, ray, angle) {
var step, drops, rain, texX, wall;
var tex1 = game.map.wall;
var tex2 = game.map.speaker;
var left = Math.floor(col * this.spacing);
var width = Math.ceil(this.spacing);
var hit = -1;
// Find the next wall hit.
while (++hit < ray.length && ray[hit].height <= 0);
// Draw the wall sections and rain drops.
for (var i=ray.length - 1; i>=0; i--) {
step = ray[i];
drops = Math.pow(Math.random(), 100) * i;
rain = (drops > 0) && this.project(0.2, angle, step.dist);
var tex = (step.type === 1) ? tex1 : tex2;
if (i === hit) {
texX = Math.floor(tex.width * step.offset);
wall = this.project(step.height, angle, step.dist);
ctx.globalAlpha = 1;
ctx.drawImage(tex.image, texX, 0, 1, tex.height, left, wall.top, width, wall.height);
ctx.fillStyle = '#000';
ctx.globalAlpha = Math.max((step.dist + step.shading) / this.lightRange - game.map.light, 0);
ctx.fillRect(left, wall.top, width, wall.height);
}
ctx.fillStyle = '#fff';
ctx.globalAlpha = 0.15;
while (--drops > 0) {
ctx.fillRect(left, Math.random() * rain.top, 1, rain.height);
}
}
} | [
"function",
"(",
"col",
",",
"ray",
",",
"angle",
")",
"{",
"var",
"step",
",",
"drops",
",",
"rain",
",",
"texX",
",",
"wall",
";",
"var",
"tex1",
"=",
"game",
".",
"map",
".",
"wall",
";",
"var",
"tex2",
"=",
"game",
".",
"map",
".",
"speaker... | Draw a single column of the scene.
@param {Number} col Which column in the sequence.
@param {Array} ray Ray to follow.
@param {Number} angle Angle of the ray. | [
"Draw",
"a",
"single",
"column",
"of",
"the",
"scene",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/camera.js#L76-L113 | train | Draw the ray of the game. map. wall and the speaker. | [
30522,
3853,
1006,
8902,
1010,
4097,
1010,
6466,
1007,
1063,
13075,
3357,
1010,
9010,
1010,
4542,
1010,
16060,
2595,
1010,
2813,
1025,
13075,
16060,
2487,
1027,
2208,
1012,
4949,
1012,
2813,
1025,
13075,
16060,
2475,
1027,
2208,
1012,
4949,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LiveDevMultiBrowser.js | _setStatus | function _setStatus(status, closeReason) {
// Don't send a notification when the status didn't actually change
if (status === exports.status) {
return;
}
exports.status = status;
var reason = status === STATUS_INACTIVE ? closeReason : null;
exports.trigger("statusChange", status, reason);
} | javascript | function _setStatus(status, closeReason) {
// Don't send a notification when the status didn't actually change
if (status === exports.status) {
return;
}
exports.status = status;
var reason = status === STATUS_INACTIVE ? closeReason : null;
exports.trigger("statusChange", status, reason);
} | [
"function",
"_setStatus",
"(",
"status",
",",
"closeReason",
")",
"{",
"// Don't send a notification when the status didn't actually change",
"if",
"(",
"status",
"===",
"exports",
".",
"status",
")",
"{",
"return",
";",
"}",
"exports",
".",
"status",
"=",
"status",... | Update the status. Triggers a statusChange event.
@param {number} status new status
@param {?string} closeReason Optional string key suffix to display to
user when closing the live development connection (see LIVE_DEV_* keys) | [
"Update",
"the",
"status",
".",
"Triggers",
"a",
"statusChange",
"event",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L201-L211 | train | Sets the status of the cluster | [
30522,
3853,
1035,
4520,
29336,
2271,
1006,
3570,
1010,
3553,
5243,
3385,
1007,
1063,
1013,
1013,
2123,
1005,
1056,
4604,
1037,
26828,
2043,
1996,
3570,
2134,
1005,
1056,
2941,
2689,
2065,
1006,
3570,
1027,
1027,
1027,
14338,
1012,
3570,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js | function(oList, oAttribute, iSelectedIndex, bSkipNotify){
oList._lb.removeSelectedIndex(iSelectedIndex);
oAttribute._clearSelection();
if (!bSkipNotify) {
var aSubLists = oList.getSubLists();
for (var i = 0; i < aSubLists.length; i++) {
if (aSubLists[i].getData() === oAttribute.getId()) {
close(aSubLists[i], true);
}
}
}
} | javascript | function(oList, oAttribute, iSelectedIndex, bSkipNotify){
oList._lb.removeSelectedIndex(iSelectedIndex);
oAttribute._clearSelection();
if (!bSkipNotify) {
var aSubLists = oList.getSubLists();
for (var i = 0; i < aSubLists.length; i++) {
if (aSubLists[i].getData() === oAttribute.getId()) {
close(aSubLists[i], true);
}
}
}
} | [
"function",
"(",
"oList",
",",
"oAttribute",
",",
"iSelectedIndex",
",",
"bSkipNotify",
")",
"{",
"oList",
".",
"_lb",
".",
"removeSelectedIndex",
"(",
"iSelectedIndex",
")",
";",
"oAttribute",
".",
"_clearSelection",
"(",
")",
";",
"if",
"(",
"!",
"bSkipNot... | Sets the selection property of the given attribute and all its sub-attributes to false. Additionally the given index in the lists ListBox is unselected. ExactLists which corresponds to the cleared attributes are closed if bSkipNotify is not set. | [
"Sets",
"the",
"selection",
"property",
"of",
"the",
"given",
"attribute",
"and",
"all",
"its",
"sub",
"-",
"attributes",
"to",
"false",
".",
"Additionally",
"the",
"given",
"index",
"in",
"the",
"lists",
"ListBox",
"is",
"unselected",
".",
"ExactLists",
"wh... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L1426-L1437 | train | Removes the selected attribute from the list | [
30522,
3853,
1006,
19330,
2923,
1010,
1051,
19321,
3089,
8569,
2618,
1010,
2003,
12260,
10985,
22254,
10288,
1010,
18667,
3211,
2361,
17048,
8757,
1007,
1063,
19330,
2923,
1012,
1035,
6053,
1012,
20362,
12260,
10985,
22254,
10288,
1006,
2003,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/context/ContextManager.js | function(oContext, aRuntimeContextParameters) {
var that = this;
var bContextActive = true;
var aParameterOfContext = oContext.parameters;
aParameterOfContext.every(function (oParameter) {
bContextActive = bContextActive && that._checkContextParameter(oParameter, aRuntimeContextParameters);
return bContextActive; // breaks loop on false
});
return bContextActive;
} | javascript | function(oContext, aRuntimeContextParameters) {
var that = this;
var bContextActive = true;
var aParameterOfContext = oContext.parameters;
aParameterOfContext.every(function (oParameter) {
bContextActive = bContextActive && that._checkContextParameter(oParameter, aRuntimeContextParameters);
return bContextActive; // breaks loop on false
});
return bContextActive;
} | [
"function",
"(",
"oContext",
",",
"aRuntimeContextParameters",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"bContextActive",
"=",
"true",
";",
"var",
"aParameterOfContext",
"=",
"oContext",
".",
"parameters",
";",
"aParameterOfContext",
".",
"every",
"(",
... | Helper to filter passed context object.
If a passed context is not within the context objects of the given application the context is filtered.
The filtering is done
[At runtime] by comparing the parameters of the context objects with the actual runtime context.
[At designtime] by comparing the id of the context objects with the set url parameter "sap-ui-designTimeContexts"
@param {object} oContext - context object to be validated
@param {object[]} aRuntimeContextParameters - context parameter returned form the context providers
@returns {boolean} bContextActive - determines if the passed context matches the context of the current environment
@private | [
"Helper",
"to",
"filter",
"passed",
"context",
"object",
".",
"If",
"a",
"passed",
"context",
"is",
"not",
"within",
"the",
"context",
"objects",
"of",
"the",
"given",
"application",
"the",
"context",
"is",
"filtered",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/context/ContextManager.js#L147-L158 | train | Checks if the given context has parameters | [
30522,
3853,
1006,
1051,
8663,
18209,
1010,
28217,
7292,
8663,
18209,
28689,
22828,
2015,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
13075,
4647,
28040,
18413,
19620,
1027,
2995,
1025,
13075,
9706,
5400,
22828,
11253,
8663,
18209,
1027,
1051,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_PtgArray | function parse_PtgArray(blob, length, opts) {
var type = (blob[blob.l++] & 0x60) >> 5;
blob.l += opts.biff == 2 ? 6 : opts.biff == 12 ? 14 : 7;
return [type];
} | javascript | function parse_PtgArray(blob, length, opts) {
var type = (blob[blob.l++] & 0x60) >> 5;
blob.l += opts.biff == 2 ? 6 : opts.biff == 12 ? 14 : 7;
return [type];
} | [
"function",
"parse_PtgArray",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
"[",
"blob",
".",
"l",
"++",
"]",
"&",
"0x60",
")",
">>",
"5",
";",
"blob",
".",
"l",
"+=",
"opts",
".",
"biff",
"==",
"2",
"?",
... | /* [MS-XLS] 2.5.198.32 ; [MS-XLSB] 2.5.97.23 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"32",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"23"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10351-L10355 | train | parse_PtgArray - Parse an Array of PTGs | [
30522,
3853,
11968,
3366,
1035,
13866,
6843,
9447,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1031,
1038,
4135,
2497,
1012,
1048,
1009,
1009,
1033,
1004,
1014,
2595,
16086,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/_AnnotationHelperExpression.js | function (oInterface, oPathValue, sEdmType) {
var sValue = oPathValue.value;
Basics.expectType(oPathValue, "string");
if (sEdmType === "String") {
if (rI18n.test(sValue)) { // a simple binding to "@i18n" model
return {
ignoreTypeInPath : true,
result : "binding",
type : "Edm.String",
value : sValue.slice(1, -1) // cut off "{" and "}"
};
} else if (oInterface.getSetting && oInterface.getSetting("bindTexts")) {
// We want a model binding to the path in the metamodel (which is
// oPathValue.path)
// "/##" is prepended because it leads from model to metamodel
return {
result : "binding",
type : "Edm.String",
ignoreTypeInPath : true,
value : "/##" + Expression.replaceIndexes(oInterface.getModel(),
oPathValue.path)
};
}
sEdmType = "Edm.String";
} else if (!mEdmType2RegExp[sEdmType].test(sValue)) {
Basics.error(oPathValue,
"Expected " + sEdmType + " value but instead saw '" + sValue + "'");
} else {
sEdmType = mType2Type[sEdmType];
if (sEdmType === "Edm.Int64"
&& ODataUtils.compare(sValue, sMinSafeInteger, true) >= 0
&& ODataUtils.compare(sValue, sMaxSafeInteger, true) <= 0) {
sEdmType = "Edm.Int32";
}
}
return {
result : "constant",
type : sEdmType,
value : sValue
};
} | javascript | function (oInterface, oPathValue, sEdmType) {
var sValue = oPathValue.value;
Basics.expectType(oPathValue, "string");
if (sEdmType === "String") {
if (rI18n.test(sValue)) { // a simple binding to "@i18n" model
return {
ignoreTypeInPath : true,
result : "binding",
type : "Edm.String",
value : sValue.slice(1, -1) // cut off "{" and "}"
};
} else if (oInterface.getSetting && oInterface.getSetting("bindTexts")) {
// We want a model binding to the path in the metamodel (which is
// oPathValue.path)
// "/##" is prepended because it leads from model to metamodel
return {
result : "binding",
type : "Edm.String",
ignoreTypeInPath : true,
value : "/##" + Expression.replaceIndexes(oInterface.getModel(),
oPathValue.path)
};
}
sEdmType = "Edm.String";
} else if (!mEdmType2RegExp[sEdmType].test(sValue)) {
Basics.error(oPathValue,
"Expected " + sEdmType + " value but instead saw '" + sValue + "'");
} else {
sEdmType = mType2Type[sEdmType];
if (sEdmType === "Edm.Int64"
&& ODataUtils.compare(sValue, sMinSafeInteger, true) >= 0
&& ODataUtils.compare(sValue, sMaxSafeInteger, true) <= 0) {
sEdmType = "Edm.Int32";
}
}
return {
result : "constant",
type : sEdmType,
value : sValue
};
} | [
"function",
"(",
"oInterface",
",",
"oPathValue",
",",
"sEdmType",
")",
"{",
"var",
"sValue",
"=",
"oPathValue",
".",
"value",
";",
"Basics",
".",
"expectType",
"(",
"oPathValue",
",",
"\"string\"",
")",
";",
"if",
"(",
"sEdmType",
"===",
"\"String\"",
")"... | Handling of "14.4 Constant Expressions", i.e.
<ul>
<li>"14.4.2 Expression edm:Bool",</li>
<li>"14.4.3 Expression edm:Date",</li>
<li>"14.4.4 Expression edm:DateTimeOffset",</li>
<li>"14.4.5 Expression edm:Decimal",</li>
<li>"14.4.8 Expression edm:Float",</li>
<li>"14.4.9 Expression edm:Guid",</li>
<li>"14.4.10 Expression edm:Int",</li>
<li>"14.4.11 Expression edm:String",</li>
<li>"14.4.12 Expression edm:TimeOfDay".</li>
</ul>
@param {sap.ui.core.util.XMLPreprocessor.IContext|sap.ui.model.Context} oInterface
the callback interface related to the current formatter call
@param {object} oPathValue
path and value information pointing to the constant (see Expression object)
@param {string} sEdmType
the "edm:*" type of the constant, e.g. "Bool" or "Int"
@returns {object}
the result object | [
"Handling",
"of",
"14",
".",
"4",
"Constant",
"Expressions",
"i",
".",
"e",
".",
"<ul",
">",
"<li",
">",
"14",
".",
"4",
".",
"2",
"Expression",
"edm",
":",
"Bool",
"<",
"/",
"li",
">",
"<li",
">",
"14",
".",
"4",
".",
"3",
"Expression",
"edm",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperExpression.js#L282-L325 | train | Returns an object with the binding type and value | [
30522,
3853,
1006,
1051,
18447,
2121,
12172,
1010,
6728,
8988,
10175,
5657,
1010,
7367,
22117,
13874,
1007,
1063,
13075,
17917,
2389,
5657,
1027,
6728,
8988,
10175,
5657,
1012,
3643,
1025,
24078,
1012,
5987,
13874,
1006,
6728,
8988,
10175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( type ) {
var args, events, allEvents;
if ( !this._events || !type ) {
return this;
}
args = slice.call( arguments, 1 );
events = findHandlers( this._events, type );
allEvents = findHandlers( this._events, 'all' );
return triggerHanders( events, args ) &&
triggerHanders( allEvents, arguments );
} | javascript | function( type ) {
var args, events, allEvents;
if ( !this._events || !type ) {
return this;
}
args = slice.call( arguments, 1 );
events = findHandlers( this._events, type );
allEvents = findHandlers( this._events, 'all' );
return triggerHanders( events, args ) &&
triggerHanders( allEvents, arguments );
} | [
"function",
"(",
"type",
")",
"{",
"var",
"args",
",",
"events",
",",
"allEvents",
";",
"if",
"(",
"!",
"this",
".",
"_events",
"||",
"!",
"type",
")",
"{",
"return",
"this",
";",
"}",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
",",
"1"... | 触发事件
@method trigger
@grammar trigger( name[, args...] ) => self
@param {String} type 事件名
@param {*} [...] 任意参数
@return {Boolean} 如果handler中return false了,则返回false, 否则返回true | [
"触发事件"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L673-L686 | train | Trigger event handlers | [
30522,
3853,
1006,
2828,
1007,
1063,
13075,
12098,
5620,
1010,
2824,
1010,
2035,
18697,
7666,
30524,
2424,
11774,
12910,
1006,
2023,
1012,
1035,
2824,
1010,
1005,
2035,
1005,
1007,
1025,
2709,
9495,
11774,
2545,
1006,
2824,
1010,
12098,
562... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Dogfalo/materialize | dist/js/materialize.js | function () {
if (typeof _this14.options.onOpenEnd === 'function') {
_this14.options.onOpenEnd.call(_this14, _this14.el, _this14._openingTrigger);
}
} | javascript | function () {
if (typeof _this14.options.onOpenEnd === 'function') {
_this14.options.onOpenEnd.call(_this14, _this14.el, _this14._openingTrigger);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"_this14",
".",
"options",
".",
"onOpenEnd",
"===",
"'function'",
")",
"{",
"_this14",
".",
"options",
".",
"onOpenEnd",
".",
"call",
"(",
"_this14",
",",
"_this14",
".",
"el",
",",
"_this14",
".",
"_open... | Handle modal onOpenEnd callback | [
"Handle",
"modal",
"onOpenEnd",
"callback"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3085-L3089 | train | onOpenEnd callback | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2828,
11253,
1035,
2023,
16932,
1012,
7047,
1012,
21058,
11837,
10497,
1027,
1027,
1027,
1005,
3853,
1005,
30524,
1035,
2023,
16932,
1010,
1035,
2023,
16932,
1012,
3449,
1010,
1035,
2023,
16932,
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/preferences/PreferencesManager.js | _setProjectSettingsFile | function _setProjectSettingsFile(settingsFile) {
projectDirectory = FileUtils.getDirectoryPath(settingsFile);
_toggleProjectScope();
PreferencesImpl.projectPathLayer.setPrefFilePath(settingsFile);
PreferencesImpl.projectStorage.setPath(settingsFile);
} | javascript | function _setProjectSettingsFile(settingsFile) {
projectDirectory = FileUtils.getDirectoryPath(settingsFile);
_toggleProjectScope();
PreferencesImpl.projectPathLayer.setPrefFilePath(settingsFile);
PreferencesImpl.projectStorage.setPath(settingsFile);
} | [
"function",
"_setProjectSettingsFile",
"(",
"settingsFile",
")",
"{",
"projectDirectory",
"=",
"FileUtils",
".",
"getDirectoryPath",
"(",
"settingsFile",
")",
";",
"_toggleProjectScope",
"(",
")",
";",
"PreferencesImpl",
".",
"projectPathLayer",
".",
"setPrefFilePath",
... | @private
This is used internally within Brackets for the ProjectManager to signal
which file contains the project-level preferences.
@param {string} settingsFile Full path to the project's settings file | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesManager.js#L101-L106 | train | Set project settings file | [
30522,
3853,
1035,
2275,
21572,
20614,
21678,
8613,
8873,
2571,
1006,
10906,
8873,
2571,
1007,
1063,
2622,
4305,
2890,
16761,
2100,
1027,
5371,
21823,
4877,
1012,
2131,
4305,
2890,
16761,
22571,
8988,
1006,
10906,
8873,
2571,
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... |
SAP/openui5 | src/sap.ui.dt/src/sap/ui/dt/ContextMenuControl.js | function (oContPos, oPopover, oViewport) {
this.getPopover().setShowArrow(true);
var oPos = {};
//Popover should appear at the top (if place available)
this.getPopover().setPlacement(PlacementType.PreferredTopOrFlip);
var iBtnWidth = oPopover.width / this._iButtonsVisible;
oPos.left = oContPos.x + ((this._iButtonsVisible - 1) * iBtnWidth ) / 2 + (this._getBaseFontSize() * 1 / 2);
oPos.top = oContPos.y - (this._getBaseFontSize() * 1 / 2);
// adjust positioning if necessary
oPos.left = (oPos.left < 32) ? 32 : oPos.left;
oPos.top = (oPos.top - oViewport.top < 0) ? oViewport.top : oPos.top;
// check right border positioning
if (oViewport.width - oPos.left < 32) {
oPos.left = oViewport.width - 32;
this.getPopover().addStyleClass("sapUiDtContextMenuRightArrow");
} else {
this.getPopover().removeStyleClass("sapUiDtContextMenuRightArrow");
}
// in Cozy mode the context menu is bigger, therefore we need a higher threshold for the top parameter
var iCozyFactor = this._bCompactMode ? 0 : 15;
if (oPos.top < (100 + iCozyFactor)) {
this.getPopover().setPlacement(PlacementType.Bottom);
oPos.top += 16;
}
return oPos;
} | javascript | function (oContPos, oPopover, oViewport) {
this.getPopover().setShowArrow(true);
var oPos = {};
//Popover should appear at the top (if place available)
this.getPopover().setPlacement(PlacementType.PreferredTopOrFlip);
var iBtnWidth = oPopover.width / this._iButtonsVisible;
oPos.left = oContPos.x + ((this._iButtonsVisible - 1) * iBtnWidth ) / 2 + (this._getBaseFontSize() * 1 / 2);
oPos.top = oContPos.y - (this._getBaseFontSize() * 1 / 2);
// adjust positioning if necessary
oPos.left = (oPos.left < 32) ? 32 : oPos.left;
oPos.top = (oPos.top - oViewport.top < 0) ? oViewport.top : oPos.top;
// check right border positioning
if (oViewport.width - oPos.left < 32) {
oPos.left = oViewport.width - 32;
this.getPopover().addStyleClass("sapUiDtContextMenuRightArrow");
} else {
this.getPopover().removeStyleClass("sapUiDtContextMenuRightArrow");
}
// in Cozy mode the context menu is bigger, therefore we need a higher threshold for the top parameter
var iCozyFactor = this._bCompactMode ? 0 : 15;
if (oPos.top < (100 + iCozyFactor)) {
this.getPopover().setPlacement(PlacementType.Bottom);
oPos.top += 16;
}
return oPos;
} | [
"function",
"(",
"oContPos",
",",
"oPopover",
",",
"oViewport",
")",
"{",
"this",
".",
"getPopover",
"(",
")",
".",
"setShowArrow",
"(",
"true",
")",
";",
"var",
"oPos",
"=",
"{",
"}",
";",
"//Popover should appear at the top (if place available)",
"this",
"."... | Works out how the ContextMenu shall be placed
@param {object} oOverlay the dimensions of the overlay
@param {object} oPopover the dimensions of the popover
@param {object} oViewport the dimensions of the viewport
@return {object} the position of the "fakeDiv" | [
"Works",
"out",
"how",
"the",
"ContextMenu",
"shall",
"be",
"placed"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.dt/src/sap/ui/dt/ContextMenuControl.js#L433-L464 | train | Calculates the position of the popover in the right border of the context menu. | [
30522,
3853,
1006,
1051,
8663,
25856,
2891,
1010,
6728,
7361,
7840,
1010,
1051,
8584,
6442,
1007,
1063,
2023,
1012,
2131,
16340,
7840,
1006,
1007,
1012,
4520,
14406,
2906,
10524,
1006,
2995,
1007,
1025,
13075,
6728,
2891,
1027,
1063,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
elastic/elasticsearch-js | api/index.js | lazyLoad | function lazyLoad (file, opts) {
var fn = null
return function _lazyLoad (params, options, callback) {
if (fn === null) {
fn = require(`./api/${file}.js`)(opts)
}
return fn(params, options, callback)
}
} | javascript | function lazyLoad (file, opts) {
var fn = null
return function _lazyLoad (params, options, callback) {
if (fn === null) {
fn = require(`./api/${file}.js`)(opts)
}
return fn(params, options, callback)
}
} | [
"function",
"lazyLoad",
"(",
"file",
",",
"opts",
")",
"{",
"var",
"fn",
"=",
"null",
"return",
"function",
"_lazyLoad",
"(",
"params",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"fn",
"===",
"null",
")",
"{",
"fn",
"=",
"require",
"(",
... | It's unlikely that a user needs all of our APIs, and since require is a sync operation that takes time (given the amount of APIs we have), let's lazy load them, so a given API file will be required only if the user actually needs that API. The following implementation takes advantage of js closures to have a simple cache with the least overhead. | [
"It",
"s",
"unlikely",
"that",
"a",
"user",
"needs",
"all",
"of",
"our",
"APIs",
"and",
"since",
"require",
"is",
"a",
"sync",
"operation",
"that",
"takes",
"time",
"(",
"given",
"the",
"amount",
"of",
"APIs",
"we",
"have",
")",
"let",
"s",
"lazy",
"... | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/index.js#L547-L555 | train | lazyLoad function | [
30522,
3853,
13971,
11066,
1006,
5371,
1010,
23569,
2015,
1007,
1063,
13075,
1042,
2078,
1027,
19701,
2709,
3853,
1035,
13971,
11066,
1006,
11498,
5244,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
1042,
2078,
1027,
1027,
1027,
197... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.uxap/src/sap/uxap/component/ObjectPageComponentContainer.js | function () {
this._oComponent = sap.ui.component("sap.uxap");
if (!this._oComponent) {
this._oComponent = sap.ui.component({
name: this.getName(),
url: this.getUrl(),
componentData: { //forward configuration to underlying component
jsonConfigurationURL: this.getJsonConfigurationURL(),
mode: this.getMode()
}
});
this.setComponent(this._oComponent, true);
}
// call the parent onBeforeRendering
if (ComponentContainer.prototype.onBeforeRendering) {
ComponentContainer.prototype.onBeforeRendering.call(this);
}
} | javascript | function () {
this._oComponent = sap.ui.component("sap.uxap");
if (!this._oComponent) {
this._oComponent = sap.ui.component({
name: this.getName(),
url: this.getUrl(),
componentData: { //forward configuration to underlying component
jsonConfigurationURL: this.getJsonConfigurationURL(),
mode: this.getMode()
}
});
this.setComponent(this._oComponent, true);
}
// call the parent onBeforeRendering
if (ComponentContainer.prototype.onBeforeRendering) {
ComponentContainer.prototype.onBeforeRendering.call(this);
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"_oComponent",
"=",
"sap",
".",
"ui",
".",
"component",
"(",
"\"sap.uxap\"",
")",
";",
"if",
"(",
"!",
"this",
".",
"_oComponent",
")",
"{",
"this",
".",
"_oComponent",
"=",
"sap",
".",
"ui",
".",
"component",
... | this ComponentContainer is working only with one component: the objectPageLayout
unlike the standard ComponentContainer, this ones exposes properties to the outside world and pass them on to the underlying component | [
"this",
"ComponentContainer",
"is",
"working",
"only",
"with",
"one",
"component",
":",
"the",
"objectPageLayout",
"unlike",
"the",
"standard",
"ComponentContainer",
"this",
"ones",
"exposes",
"properties",
"to",
"the",
"outside",
"world",
"and",
"pass",
"them",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/ObjectPageComponentContainer.js#L34-L53 | train | Creates the component if not exists | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1035,
1051,
9006,
29513,
3372,
1027,
20066,
1012,
21318,
1012,
6922,
1006,
1000,
20066,
1012,
1057,
18684,
2361,
1000,
1007,
1025,
2065,
1006,
999,
2023,
1012,
1035,
1051,
9006,
29513,
3372,
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... | |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | eventMove | function eventMove ( event, data ) {
// Fix #498
// Check value of .buttons in 'start' to work around a bug in IE10 mobile (data.buttonsProperty).
// https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero
// IE9 has .buttons and .which zero on mousemove.
// Firefox breaks the spec MDN defines.
if ( navigator.appVersion.indexOf("MSIE 9") === -1 && event.buttons === 0 && data.buttonsProperty !== 0 ) {
return eventEnd(event, data);
}
// Check if we are moving up or down
var movement = (options.dir ? -1 : 1) * (event.calcPoint - data.startCalcPoint);
// Convert the movement into a percentage of the slider width/height
var proposal = (movement * 100) / data.baseSize;
moveHandles(movement > 0, proposal, data.locations, data.handleNumbers);
} | javascript | function eventMove ( event, data ) {
// Fix #498
// Check value of .buttons in 'start' to work around a bug in IE10 mobile (data.buttonsProperty).
// https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero
// IE9 has .buttons and .which zero on mousemove.
// Firefox breaks the spec MDN defines.
if ( navigator.appVersion.indexOf("MSIE 9") === -1 && event.buttons === 0 && data.buttonsProperty !== 0 ) {
return eventEnd(event, data);
}
// Check if we are moving up or down
var movement = (options.dir ? -1 : 1) * (event.calcPoint - data.startCalcPoint);
// Convert the movement into a percentage of the slider width/height
var proposal = (movement * 100) / data.baseSize;
moveHandles(movement > 0, proposal, data.locations, data.handleNumbers);
} | [
"function",
"eventMove",
"(",
"event",
",",
"data",
")",
"{",
"// Fix #498",
"// Check value of .buttons in 'start' to work around a bug in IE10 mobile (data.buttonsProperty).",
"// https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove... | Handle movement on document for handle and range drag. | [
"Handle",
"movement",
"on",
"document",
"for",
"handle",
"and",
"range",
"drag",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1484-L1502 | train | eventMove eventMove eventMove | [
30522,
3853,
2724,
5302,
3726,
1006,
2724,
1010,
2951,
1007,
1063,
1013,
1013,
8081,
1001,
4749,
2620,
1013,
1013,
4638,
3643,
1997,
1012,
11287,
1999,
1005,
2707,
1005,
2000,
2147,
2105,
1037,
11829,
1999,
29464,
10790,
4684,
1006,
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... |
fex-team/webuploader | dist/webuploader.withoutimage.js | Uploader | function Uploader( opts ) {
this.options = $.extend( true, {}, Uploader.options, opts );
this._init( this.options );
} | javascript | function Uploader( opts ) {
this.options = $.extend( true, {}, Uploader.options, opts );
this._init( this.options );
} | [
"function",
"Uploader",
"(",
"opts",
")",
"{",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"Uploader",
".",
"options",
",",
"opts",
")",
";",
"this",
".",
"_init",
"(",
"this",
".",
"options",
")",
";",
"}"
] | 上传入口类。
@class Uploader
@constructor
@grammar new Uploader( opts ) => Uploader
@example
var uploader = WebUploader.Uploader({
swf: 'path_of_swf/Uploader.swf',
// 开起分片上传。
chunked: true
}); | [
"上传入口类。",
"@class",
"Uploader",
"@constructor",
"@grammar",
"new",
"Uploader",
"(",
"opts",
")",
"=",
">",
"Uploader",
"@example",
"var",
"uploader",
"=",
"WebUploader",
".",
"Uploader",
"(",
"{",
"swf",
":",
"path_of_swf",
"/",
"Uploader",
".",
"swf"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L732-L735 | train | Constructor for Uploader | [
30522,
3853,
2039,
11066,
2121,
1006,
23569,
2015,
1007,
1063,
2023,
1012,
7047,
1027,
1002,
1012,
7949,
1006,
2995,
1010,
1063,
1065,
1010,
2039,
11066,
2121,
1012,
7047,
1010,
23569,
2015,
1007,
1025,
2023,
1012,
1035,
1999,
4183,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/datajs.js | function (dom, namespaceURI, qualifiedName, value) {
/// <summary>Creates a new DOM attribute node.</summary>
/// <param name="dom">DOM document used to create the attribute.</param>
/// <param name="prefix" type="String">Namespace prefix.</param>
/// <param name="namespaceURI" type="String">Namespace URI.</param>
/// <returns>DOM attribute node for the namespace declaration.</returns>
// ##### BEGIN: MODIFIED BY SAP
// added usage of _createAttributeNS as fallback (see function above)
var attribute =
dom.createAttributeNS && dom.createAttributeNS(namespaceURI, qualifiedName) ||
"createNode" in dom && dom.createNode(2, qualifiedName, namespaceURI || undefined) ||
_createAttributeNS(namespaceURI, qualifiedName);
// ##### END: MODIFIED BY SAP
attribute.value = value || "";
return attribute;
} | javascript | function (dom, namespaceURI, qualifiedName, value) {
/// <summary>Creates a new DOM attribute node.</summary>
/// <param name="dom">DOM document used to create the attribute.</param>
/// <param name="prefix" type="String">Namespace prefix.</param>
/// <param name="namespaceURI" type="String">Namespace URI.</param>
/// <returns>DOM attribute node for the namespace declaration.</returns>
// ##### BEGIN: MODIFIED BY SAP
// added usage of _createAttributeNS as fallback (see function above)
var attribute =
dom.createAttributeNS && dom.createAttributeNS(namespaceURI, qualifiedName) ||
"createNode" in dom && dom.createNode(2, qualifiedName, namespaceURI || undefined) ||
_createAttributeNS(namespaceURI, qualifiedName);
// ##### END: MODIFIED BY SAP
attribute.value = value || "";
return attribute;
} | [
"function",
"(",
"dom",
",",
"namespaceURI",
",",
"qualifiedName",
",",
"value",
")",
"{",
"/// <summary>Creates a new DOM attribute node.</summary>",
"/// <param name=\"dom\">DOM document used to create the attribute.</param>",
"/// <param name=\"prefix\" type=\"String\">Namespace prefix.... | ##### END: MODIFIED BY SAP | [
"#####",
"END",
":",
"MODIFIED",
"BY",
"SAP"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/datajs.js#L979-L996 | train | Creates an attribute node for the given namespace declaration. | [
30522,
3853,
1006,
14383,
1010,
3415,
15327,
9496,
1010,
4591,
18442,
1010,
3643,
1007,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
9005,
1037,
2047,
14383,
17961,
13045,
1012,
1026,
1013,
12654,
1028,
1013,
1013,
1013,
1026,
11498,
2213,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js | overrideLunrTokenizer | function overrideLunrTokenizer() {
var origTokenizer = lunr.tokenizer;
var rSeparators = /[-./#_,;\(\)=><|]/g;
lunr.tokenizer = function(str) {
return origTokenizer.call(lunr, str).reduce( function (result, token) {
if ( rSeparators.test(token) ) {
token = token.replace(rSeparators, " ");
result.push.apply(result, token.toLowerCase().split(/ +/));
} else {
result.push(token.toLowerCase());
}
return result;
}, []);
};
Object.keys(origTokenizer).forEach(function (key) {
lunr.tokenizer[key] = origTokenizer[key];
});
} | javascript | function overrideLunrTokenizer() {
var origTokenizer = lunr.tokenizer;
var rSeparators = /[-./#_,;\(\)=><|]/g;
lunr.tokenizer = function(str) {
return origTokenizer.call(lunr, str).reduce( function (result, token) {
if ( rSeparators.test(token) ) {
token = token.replace(rSeparators, " ");
result.push.apply(result, token.toLowerCase().split(/ +/));
} else {
result.push(token.toLowerCase());
}
return result;
}, []);
};
Object.keys(origTokenizer).forEach(function (key) {
lunr.tokenizer[key] = origTokenizer[key];
});
} | [
"function",
"overrideLunrTokenizer",
"(",
")",
"{",
"var",
"origTokenizer",
"=",
"lunr",
".",
"tokenizer",
";",
"var",
"rSeparators",
"=",
"/",
"[-./#_,;\\(\\)=><|]",
"/",
"g",
";",
"lunr",
".",
"tokenizer",
"=",
"function",
"(",
"str",
")",
"{",
"return",
... | overrides the lunr tokenizer in order to define custom token separators | [
"overrides",
"the",
"lunr",
"tokenizer",
"in",
"order",
"to",
"define",
"custom",
"token",
"separators"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L231-L250 | train | Override lunr. tokenizer with lowercased tokens | [
30522,
3853,
2058,
15637,
26896,
5339,
11045,
3490,
6290,
1006,
1007,
1063,
13075,
2030,
8004,
18715,
18595,
6290,
1027,
11320,
16118,
1012,
19204,
17629,
1025,
13075,
12667,
13699,
25879,
5668,
1027,
1013,
1031,
1011,
1012,
1013,
1001,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moleculerjs/moleculer | src/transporters/index.js | resolve | function resolve(opt) {
if (opt instanceof Transporters.Base) {
return opt;
} else if (_.isString(opt)) {
let TransporterClass = getByName(opt);
if (TransporterClass)
return new TransporterClass();
if (opt.startsWith("nats://"))
TransporterClass = Transporters.NATS;
else if (opt.startsWith("mqtt://") || opt.startsWith("mqtts://"))
TransporterClass = Transporters.MQTT;
else if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
TransporterClass = Transporters.Redis;
else if (opt.startsWith("amqp://") || opt.startsWith("amqps://"))
TransporterClass = Transporters.AMQP;
else if (opt.startsWith("kafka://"))
TransporterClass = Transporters.Kafka;
else if (opt.startsWith("stan://"))
TransporterClass = Transporters.STAN;
else if (opt.startsWith("tcp://"))
TransporterClass = Transporters.TCP;
if (TransporterClass)
return new TransporterClass(opt);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let TransporterClass = getByName(opt.type || "NATS");
if (TransporterClass)
return new TransporterClass(opt.options);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt.type}'.`, { type: opt.type });
}
return null;
} | javascript | function resolve(opt) {
if (opt instanceof Transporters.Base) {
return opt;
} else if (_.isString(opt)) {
let TransporterClass = getByName(opt);
if (TransporterClass)
return new TransporterClass();
if (opt.startsWith("nats://"))
TransporterClass = Transporters.NATS;
else if (opt.startsWith("mqtt://") || opt.startsWith("mqtts://"))
TransporterClass = Transporters.MQTT;
else if (opt.startsWith("redis://") || opt.startsWith("rediss://"))
TransporterClass = Transporters.Redis;
else if (opt.startsWith("amqp://") || opt.startsWith("amqps://"))
TransporterClass = Transporters.AMQP;
else if (opt.startsWith("kafka://"))
TransporterClass = Transporters.Kafka;
else if (opt.startsWith("stan://"))
TransporterClass = Transporters.STAN;
else if (opt.startsWith("tcp://"))
TransporterClass = Transporters.TCP;
if (TransporterClass)
return new TransporterClass(opt);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt}'.`, { type: opt });
} else if (_.isObject(opt)) {
let TransporterClass = getByName(opt.type || "NATS");
if (TransporterClass)
return new TransporterClass(opt.options);
else
throw new BrokerOptionsError(`Invalid transporter type '${opt.type}'.`, { type: opt.type });
}
return null;
} | [
"function",
"resolve",
"(",
"opt",
")",
"{",
"if",
"(",
"opt",
"instanceof",
"Transporters",
".",
"Base",
")",
"{",
"return",
"opt",
";",
"}",
"else",
"if",
"(",
"_",
".",
"isString",
"(",
"opt",
")",
")",
"{",
"let",
"TransporterClass",
"=",
"getByN... | Resolve transporter by name
@param {object|string} opt
@returns {Transporter} | [
"Resolve",
"transporter",
"by",
"name"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/transporters/index.js#L40-L78 | train | Resolves a transporter | [
30522,
30524,
1007,
1007,
1063,
2292,
3665,
2121,
26266,
1027,
2131,
3762,
18442,
1006,
23569,
1007,
1025,
2065,
1006,
3665,
2121,
26266,
1007,
2709,
2047,
3665,
2121,
26266,
1006,
1007,
1025,
2065,
1006,
23569,
1012,
4627,
24415,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RecordRTC | WebGL-Recording/view.js | recordCanvasUsingRecordRTC | function recordCanvasUsingRecordRTC(canvas) {
var recorder = RecordRTC(canvas, {
type: 'canvas',
showMousePointer: true
});
recorder.startRecording();
setTimeout(function() {
recorder.stopRecording(function(url) {
var blob = recorder.getBlob();
console.log('blob', blob);
var video = document.createElement('video');
video.src = URL.createObjectURL(blob);
video.setAttribute('style', 'height: 100%; position: absolute; top:0;');
var body = document.querySelector('body');
body.innerHTML = '';
body.appendChild(video);
video.controls = true;
video.play();
});
}, 10 * 1000);
} | javascript | function recordCanvasUsingRecordRTC(canvas) {
var recorder = RecordRTC(canvas, {
type: 'canvas',
showMousePointer: true
});
recorder.startRecording();
setTimeout(function() {
recorder.stopRecording(function(url) {
var blob = recorder.getBlob();
console.log('blob', blob);
var video = document.createElement('video');
video.src = URL.createObjectURL(blob);
video.setAttribute('style', 'height: 100%; position: absolute; top:0;');
var body = document.querySelector('body');
body.innerHTML = '';
body.appendChild(video);
video.controls = true;
video.play();
});
}, 10 * 1000);
} | [
"function",
"recordCanvasUsingRecordRTC",
"(",
"canvas",
")",
"{",
"var",
"recorder",
"=",
"RecordRTC",
"(",
"canvas",
",",
"{",
"type",
":",
"'canvas'",
",",
"showMousePointer",
":",
"true",
"}",
")",
";",
"recorder",
".",
"startRecording",
"(",
")",
";",
... | RecordRTC ========= | [
"RecordRTC",
"========="
] | 3c6bad427b9da35c1cf617199ed13dda056c38ba | https://github.com/muaz-khan/RecordRTC/blob/3c6bad427b9da35c1cf617199ed13dda056c38ba/WebGL-Recording/view.js#L325-L348 | train | record canvas using RecordRTC | [
30522,
3853,
2501,
9336,
12044,
18161,
2890,
27108,
13626,
13535,
1006,
10683,
1007,
1063,
13075,
14520,
1027,
2501,
5339,
2278,
1006,
10683,
1010,
1063,
2828,
1024,
1005,
10683,
1005,
1010,
2265,
27711,
13699,
25785,
2121,
1024,
2995,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | examples/zoomslider.js | createMap | function createMap(divId) {
const source = new OSM();
const layer = new TileLayer({
source: source
});
const map = new Map({
layers: [layer],
target: divId,
view: new View({
center: [0, 0],
zoom: 2
})
});
const zoomslider = new ZoomSlider();
map.addControl(zoomslider);
return map;
} | javascript | function createMap(divId) {
const source = new OSM();
const layer = new TileLayer({
source: source
});
const map = new Map({
layers: [layer],
target: divId,
view: new View({
center: [0, 0],
zoom: 2
})
});
const zoomslider = new ZoomSlider();
map.addControl(zoomslider);
return map;
} | [
"function",
"createMap",
"(",
"divId",
")",
"{",
"const",
"source",
"=",
"new",
"OSM",
"(",
")",
";",
"const",
"layer",
"=",
"new",
"TileLayer",
"(",
"{",
"source",
":",
"source",
"}",
")",
";",
"const",
"map",
"=",
"new",
"Map",
"(",
"{",
"layers"... | Helper method for map-creation.
@param {string} divId The id of the div for the map.
@return {Map} The map instance. | [
"Helper",
"method",
"for",
"map",
"-",
"creation",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/zoomslider.js#L14-L30 | train | Create a map | [
30522,
3853,
3443,
2863,
2361,
1006,
4487,
17258,
1007,
1063,
9530,
3367,
3120,
1027,
2047,
9808,
2213,
1006,
1007,
1025,
9530,
3367,
6741,
1027,
2047,
14090,
24314,
1006,
1063,
3120,
1024,
3120,
1065,
1007,
1025,
9530,
3367,
4949,
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/dom/jquery/Focusable.js | findFocusableDomRef | function findFocusableDomRef(oContainer, bForward) {
var oChild = bForward ? oContainer.firstChild : oContainer.lastChild,
oFocusableDescendant;
while (oChild) {
if ( oChild.nodeType == 1 && !isHidden(oChild) ) {
if ( jQuery(oChild).hasTabIndex() ) {
return oChild;
}
oFocusableDescendant = findFocusableDomRef(oChild, bForward);
if (oFocusableDescendant) {
return oFocusableDescendant;
}
}
oChild = bForward ? oChild.nextSibling : oChild.previousSibling;
}
return null;
} | javascript | function findFocusableDomRef(oContainer, bForward) {
var oChild = bForward ? oContainer.firstChild : oContainer.lastChild,
oFocusableDescendant;
while (oChild) {
if ( oChild.nodeType == 1 && !isHidden(oChild) ) {
if ( jQuery(oChild).hasTabIndex() ) {
return oChild;
}
oFocusableDescendant = findFocusableDomRef(oChild, bForward);
if (oFocusableDescendant) {
return oFocusableDescendant;
}
}
oChild = bForward ? oChild.nextSibling : oChild.previousSibling;
}
return null;
} | [
"function",
"findFocusableDomRef",
"(",
"oContainer",
",",
"bForward",
")",
"{",
"var",
"oChild",
"=",
"bForward",
"?",
"oContainer",
".",
"firstChild",
":",
"oContainer",
".",
"lastChild",
",",
"oFocusableDescendant",
";",
"while",
"(",
"oChild",
")",
"{",
"i... | Searches for a descendant of the given node that is an Element and focusable and visible.
The search is executed 'depth first'.
@param {Node} oContainer Node to search for a focusable descendant
@param {boolean} bForward Whether to search forward (true) or backwards (false)
@returns {Element} Element node that is focusable and visible or null
@private | [
"Searches",
"for",
"a",
"descendant",
"of",
"the",
"given",
"node",
"that",
"is",
"an",
"Element",
"and",
"focusable",
"and",
"visible",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/jquery/Focusable.js#L49-L74 | train | Finds the first child of the given container that has a tabindex attribute. | [
30522,
3853,
2424,
14876,
7874,
3085,
9527,
2890,
2546,
1006,
1051,
8663,
18249,
2121,
1010,
28939,
2953,
7652,
1007,
1063,
13075,
28166,
4014,
2094,
1027,
28939,
2953,
7652,
1029,
1051,
8663,
18249,
2121,
1012,
2034,
19339,
1024,
1051,
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... |
material-components/material-components-web-react | scripts/release/cp-pkgs.js | addTsIgnore | function addTsIgnore(filePath) {
const data = fs.readFileSync(filePath).toString().split('\n');
const lineNumber = data.findIndex((lineText) => lineText.includes('/dist/'));
if (lineNumber <= -1) return;
data.splice(lineNumber, 0, '// @ts-ignore');
const text = data.join('\n');
fs.writeFile(filePath, text, function(err) {
if (err) return console.log(err);
});
} | javascript | function addTsIgnore(filePath) {
const data = fs.readFileSync(filePath).toString().split('\n');
const lineNumber = data.findIndex((lineText) => lineText.includes('/dist/'));
if (lineNumber <= -1) return;
data.splice(lineNumber, 0, '// @ts-ignore');
const text = data.join('\n');
fs.writeFile(filePath, text, function(err) {
if (err) return console.log(err);
});
} | [
"function",
"addTsIgnore",
"(",
"filePath",
")",
"{",
"const",
"data",
"=",
"fs",
".",
"readFileSync",
"(",
"filePath",
")",
".",
"toString",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"const",
"lineNumber",
"=",
"data",
".",
"findIndex",
"(",
"("... | this takes a file path to an index.d.ts file and adds an //@ts-ignore comment above the MDC Web imports (any line that includes `/dist/`). We need to ignore these lines since MDC Web does not have typing files TODO: https://github.com/material-components/material-components-web-react/issues/574 | [
"this",
"takes",
"a",
"file",
"path",
"to",
"an",
"index",
".",
"d",
".",
"ts",
"file",
"and",
"adds",
"an",
"//"
] | 5ee9df0982d6cff893523c3e1e447b0f98bf8611 | https://github.com/material-components/material-components-web-react/blob/5ee9df0982d6cff893523c3e1e447b0f98bf8611/scripts/release/cp-pkgs.js#L82-L92 | train | Add ts - ignore to a file | [
30522,
3853,
5587,
3215,
23773,
5686,
1006,
5371,
15069,
1007,
1063,
9530,
3367,
2951,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
5371,
15069,
1007,
1012,
2000,
3367,
4892,
1006,
1007,
1012,
3975,
1006,
1005,
1032,
1050,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wix/react-native-ui-lib | scripts/utils/propTypesHandler.js | propTypesDocsHandler | function propTypesDocsHandler(documentation, path) {
const propTypesPath = getMemberValuePath(path, 'propTypes');
const docComment = getDocblock(propTypesPath.parent);
const statementPattern = /@.*\:/;
const info = {};
if (docComment) {
const infoRaw = _.split(docComment, '\n');
_.forEach(infoRaw, (statement) => {
if (statement && statementPattern.test(statement)) {
const key = statement.match(statementPattern)[0].slice(1, -1);
info[key] = statement.split(statementPattern)[1].trim();
}
});
}
documentation.set('propsInfo', info);
} | javascript | function propTypesDocsHandler(documentation, path) {
const propTypesPath = getMemberValuePath(path, 'propTypes');
const docComment = getDocblock(propTypesPath.parent);
const statementPattern = /@.*\:/;
const info = {};
if (docComment) {
const infoRaw = _.split(docComment, '\n');
_.forEach(infoRaw, (statement) => {
if (statement && statementPattern.test(statement)) {
const key = statement.match(statementPattern)[0].slice(1, -1);
info[key] = statement.split(statementPattern)[1].trim();
}
});
}
documentation.set('propsInfo', info);
} | [
"function",
"propTypesDocsHandler",
"(",
"documentation",
",",
"path",
")",
"{",
"const",
"propTypesPath",
"=",
"getMemberValuePath",
"(",
"path",
",",
"'propTypes'",
")",
";",
"const",
"docComment",
"=",
"getDocblock",
"(",
"propTypesPath",
".",
"parent",
")",
... | Extract info on the component props | [
"Extract",
"info",
"on",
"the",
"component",
"props"
] | 439d36c7932bc3cfe574320e8f214a03f988c5ac | https://github.com/wix/react-native-ui-lib/blob/439d36c7932bc3cfe574320e8f214a03f988c5ac/scripts/utils/propTypesHandler.js#L10-L26 | train | PropTypes docs handler | [
30522,
3853,
17678,
13874,
16150,
10085,
9688,
21222,
1006,
12653,
1010,
4130,
1007,
1063,
9530,
3367,
17678,
13874,
13102,
8988,
1027,
2131,
4168,
21784,
10175,
5657,
15069,
1006,
4130,
1010,
1005,
17678,
13874,
2015,
1005,
1007,
1025,
9530,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/space-infix-ops.js | checkVar | function checkVar(node) {
const leftNode = (node.id.typeAnnotation) ? node.id.typeAnnotation : node.id;
const rightNode = node.init;
if (rightNode) {
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
if (nonSpacedNode) {
report(node, nonSpacedNode);
}
}
} | javascript | function checkVar(node) {
const leftNode = (node.id.typeAnnotation) ? node.id.typeAnnotation : node.id;
const rightNode = node.init;
if (rightNode) {
const nonSpacedNode = getFirstNonSpacedToken(leftNode, rightNode, "=");
if (nonSpacedNode) {
report(node, nonSpacedNode);
}
}
} | [
"function",
"checkVar",
"(",
"node",
")",
"{",
"const",
"leftNode",
"=",
"(",
"node",
".",
"id",
".",
"typeAnnotation",
")",
"?",
"node",
".",
"id",
".",
"typeAnnotation",
":",
"node",
".",
"id",
";",
"const",
"rightNode",
"=",
"node",
".",
"init",
"... | Check if the node is a variable
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Check",
"if",
"the",
"node",
"is",
"a",
"variable"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-infix-ops.js#L142-L153 | train | Check if variable is valid | [
30522,
3853,
4638,
10755,
1006,
13045,
1007,
1063,
9530,
3367,
2187,
3630,
3207,
1027,
1006,
13045,
1012,
8909,
1012,
2828,
11639,
17287,
3508,
1007,
1029,
13045,
1012,
8909,
1012,
2828,
11639,
17287,
3508,
1024,
13045,
1012,
8909,
1025,
95... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RemoteFileAdapter/RemoteFile.js | RemoteFile | function RemoteFile(protocol, fullPath, fileSystem) {
this._isFile = true;
this._isDirectory = false;
this.readOnly = true;
this._path = fullPath;
this._stat = _getStats(fullPath);
this._id = fullPath;
this._name = _getFileName(fullPath);
this._fileSystem = fileSystem;
this.donotWatch = true;
this.protocol = protocol;
this.encodedPath = fullPath;
} | javascript | function RemoteFile(protocol, fullPath, fileSystem) {
this._isFile = true;
this._isDirectory = false;
this.readOnly = true;
this._path = fullPath;
this._stat = _getStats(fullPath);
this._id = fullPath;
this._name = _getFileName(fullPath);
this._fileSystem = fileSystem;
this.donotWatch = true;
this.protocol = protocol;
this.encodedPath = fullPath;
} | [
"function",
"RemoteFile",
"(",
"protocol",
",",
"fullPath",
",",
"fileSystem",
")",
"{",
"this",
".",
"_isFile",
"=",
"true",
";",
"this",
".",
"_isDirectory",
"=",
"false",
";",
"this",
".",
"readOnly",
"=",
"true",
";",
"this",
".",
"_path",
"=",
"fu... | Model for a RemoteFile.
This class should *not* be instantiated directly. Use FileSystem.getFileForPath
See the FileSystem class for more details.
@constructor
@param {!string} fullPath The full path for this File.
@param {!FileSystem} fileSystem The file system associated with this File. | [
"Model",
"for",
"a",
"RemoteFile",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RemoteFileAdapter/RemoteFile.js#L70-L82 | train | RemoteFile constructor. | [
30522,
3853,
6556,
8873,
2571,
1006,
8778,
1010,
2440,
15069,
1010,
6764,
27268,
6633,
1007,
1063,
2023,
1012,
1035,
2003,
8873,
2571,
1027,
2995,
1025,
2023,
1012,
1035,
2003,
4305,
2890,
16761,
2100,
1027,
6270,
1025,
2023,
1012,
3191,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/XMLUtils.js | _getTagAttributeValue | function _getTagAttributeValue(editor, pos) {
var ctx, tagName, attrName, exclusionList = [], offset, textBefore, textAfter;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
// To support multiple options on the same attribute, we have
// to break the value, these values will not be available then.
if (ctx.token.type === "string" && /\s+/.test(ctx.token.string)) {
textBefore = ctx.token.string.substr(1, offset);
textAfter = ctx.token.string.substr(offset);
// Remove quote from end of the string.
if (/^['"]$/.test(ctx.token.string.substr(-1, 1))) {
textAfter = textAfter.substr(0, textAfter.length - 1);
}
// Split the text before and after the offset, skipping the current query.
exclusionList = exclusionList.concat(textBefore.split(/\s+/).slice(0, -1));
exclusionList = exclusionList.concat(textAfter.split(/\s+/));
// Filter through the list removing empty strings.
exclusionList = exclusionList.filter(function (value) {
if (value.length > 0) {
return true;
}
});
}
// Look-back and find tag and attributes.
while (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket") {
// Disallow hints in closing tags.
if (ctx.token.string === "</") {
return null;
}
// Stop when closing bracket of another tag or opening bracket of its own in encountered.
if (ctx.token.string.indexOf(">") >= 0 || ctx.token.string === "<") {
break;
}
}
// Get the first previous attribute.
if (ctx.token.type === "attribute" && !attrName) {
attrName = ctx.token.string;
}
// Stop if we get a bracket after tag.
if (ctx.token.type === "tag") {
tagName = ctx.token.string;
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
break;
}
return null;
}
}
}
return {
tagName: tagName,
attrName: attrName,
exclusionList: exclusionList
};
} | javascript | function _getTagAttributeValue(editor, pos) {
var ctx, tagName, attrName, exclusionList = [], offset, textBefore, textAfter;
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
offset = TokenUtils.offsetInToken(ctx);
// To support multiple options on the same attribute, we have
// to break the value, these values will not be available then.
if (ctx.token.type === "string" && /\s+/.test(ctx.token.string)) {
textBefore = ctx.token.string.substr(1, offset);
textAfter = ctx.token.string.substr(offset);
// Remove quote from end of the string.
if (/^['"]$/.test(ctx.token.string.substr(-1, 1))) {
textAfter = textAfter.substr(0, textAfter.length - 1);
}
// Split the text before and after the offset, skipping the current query.
exclusionList = exclusionList.concat(textBefore.split(/\s+/).slice(0, -1));
exclusionList = exclusionList.concat(textAfter.split(/\s+/));
// Filter through the list removing empty strings.
exclusionList = exclusionList.filter(function (value) {
if (value.length > 0) {
return true;
}
});
}
// Look-back and find tag and attributes.
while (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket") {
// Disallow hints in closing tags.
if (ctx.token.string === "</") {
return null;
}
// Stop when closing bracket of another tag or opening bracket of its own in encountered.
if (ctx.token.string.indexOf(">") >= 0 || ctx.token.string === "<") {
break;
}
}
// Get the first previous attribute.
if (ctx.token.type === "attribute" && !attrName) {
attrName = ctx.token.string;
}
// Stop if we get a bracket after tag.
if (ctx.token.type === "tag") {
tagName = ctx.token.string;
if (TokenUtils.movePrevToken(ctx)) {
if (ctx.token.type === "tag bracket" && ctx.token.string === "<") {
break;
}
return null;
}
}
}
return {
tagName: tagName,
attrName: attrName,
exclusionList: exclusionList
};
} | [
"function",
"_getTagAttributeValue",
"(",
"editor",
",",
"pos",
")",
"{",
"var",
"ctx",
",",
"tagName",
",",
"attrName",
",",
"exclusionList",
"=",
"[",
"]",
",",
"offset",
",",
"textBefore",
",",
"textAfter",
";",
"ctx",
"=",
"TokenUtils",
".",
"getInitia... | Return the tag name, attribute name and a list of options used by the attribute
@param {!Editor} editor An instance of active editor
@param {!{line: number, ch: number}} pos Position of cursor in the editor
@return {!{tagName: string, attrName: string, exclusionList: Array.<string>}} | [
"Return",
"the",
"tag",
"name",
"attribute",
"name",
"and",
"a",
"list",
"of",
"options",
"used",
"by",
"the",
"attribute"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L156-L220 | train | Get the value of a tag attribute | [
30522,
3853,
1035,
2131,
15900,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
3559,
1010,
13433,
2015,
1007,
1063,
13075,
14931,
2595,
1010,
6415,
18442,
1010,
2012,
16344,
18442,
1010,
15945,
9863,
1027,
1031,
1033,
1010,
16396,
1010,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | togglePreview | function togglePreview(editor) {
var cm = editor.codemirror;
var wrapper = cm.getWrapperElement();
var toolbar_div = wrapper.previousSibling;
var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false;
var preview = wrapper.lastChild;
if(!preview || !/editor-preview/.test(preview.className)) {
preview = document.createElement("div");
preview.className = "editor-preview";
wrapper.appendChild(preview);
}
if(/editor-preview-active/.test(preview.className)) {
preview.className = preview.className.replace(
/\s*editor-preview-active\s*/g, ""
);
if(toolbar) {
toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
}
} else {
// When the preview button is clicked for the first time,
// give some time for the transition from editor.css to fire and the view to slide from right to left,
// instead of just appearing.
setTimeout(function() {
preview.className += " editor-preview-active";
}, 1);
if(toolbar) {
toolbar.className += " active";
toolbar_div.className += " disabled-for-preview";
}
}
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
// Turn off side by side if needed
var sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className))
toggleSideBySide(editor);
} | javascript | function togglePreview(editor) {
var cm = editor.codemirror;
var wrapper = cm.getWrapperElement();
var toolbar_div = wrapper.previousSibling;
var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false;
var preview = wrapper.lastChild;
if(!preview || !/editor-preview/.test(preview.className)) {
preview = document.createElement("div");
preview.className = "editor-preview";
wrapper.appendChild(preview);
}
if(/editor-preview-active/.test(preview.className)) {
preview.className = preview.className.replace(
/\s*editor-preview-active\s*/g, ""
);
if(toolbar) {
toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
}
} else {
// When the preview button is clicked for the first time,
// give some time for the transition from editor.css to fire and the view to slide from right to left,
// instead of just appearing.
setTimeout(function() {
preview.className += " editor-preview-active";
}, 1);
if(toolbar) {
toolbar.className += " active";
toolbar_div.className += " disabled-for-preview";
}
}
preview.innerHTML = editor.options.previewRender(editor.value(), preview);
// Turn off side by side if needed
var sidebyside = cm.getWrapperElement().nextSibling;
if(/editor-preview-active-side/.test(sidebyside.className))
toggleSideBySide(editor);
} | [
"function",
"togglePreview",
"(",
"editor",
")",
"{",
"var",
"cm",
"=",
"editor",
".",
"codemirror",
";",
"var",
"wrapper",
"=",
"cm",
".",
"getWrapperElement",
"(",
")",
";",
"var",
"toolbar_div",
"=",
"wrapper",
".",
"previousSibling",
";",
"var",
"toolb... | Preview action. | [
"Preview",
"action",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L752-L789 | train | Toggle the preview of the editor | [
30522,
3853,
2000,
24679,
28139,
8584,
1006,
3559,
1007,
1063,
13075,
4642,
1027,
3559,
1012,
3642,
14503,
29165,
1025,
13075,
10236,
4842,
30524,
1012,
7047,
1012,
6994,
8237,
1029,
3559,
1012,
6994,
8237,
12260,
8163,
1012,
19236,
1024,
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... |
SAP/openui5 | src/sap.ui.core/src/jquery.sap.history.js | findRouteByIdentifier | function findRouteByIdentifier(sIdf){
var i;
for (i = 0 ; i < routes.length ; i++) {
if (routes[i].sIdentifier === sIdf) {
return routes[i];
}
}
} | javascript | function findRouteByIdentifier(sIdf){
var i;
for (i = 0 ; i < routes.length ; i++) {
if (routes[i].sIdentifier === sIdf) {
return routes[i];
}
}
} | [
"function",
"findRouteByIdentifier",
"(",
"sIdf",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"routes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"routes",
"[",
"i",
"]",
".",
"sIdentifier",
"===",
"sIdf",
")",
... | This function returns the route object matched by the identifier passed as parameter.
@private | [
"This",
"function",
"returns",
"the",
"route",
"object",
"matched",
"by",
"the",
"identifier",
"passed",
"as",
"parameter",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/jquery.sap.history.js#L675-L682 | train | Find a route by its identifier | [
30522,
3853,
2424,
22494,
2618,
3762,
5178,
16778,
8873,
2121,
1006,
15765,
2546,
1007,
1063,
13075,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
5847,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2065,
1006,
5847,
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... |
wuchangming/spy-debugger | buildin_modules/weinre/web/index.js | getTargetBookmarklet | function getTargetBookmarklet() {
var script = targetBookmarkletFunction.toString();
script = script.replace(/\n/g, "")
script = script.replace("targetBookmarkletFunction","")
script = script.replace(/\s*/g, "")
script = script.replace("???", buildHttpURL("target/target-script-min.js#" + weinre_id))
script = "(" + script + ')(document.createElement("script"));void(0);'
return 'javascript:' + script
} | javascript | function getTargetBookmarklet() {
var script = targetBookmarkletFunction.toString();
script = script.replace(/\n/g, "")
script = script.replace("targetBookmarkletFunction","")
script = script.replace(/\s*/g, "")
script = script.replace("???", buildHttpURL("target/target-script-min.js#" + weinre_id))
script = "(" + script + ')(document.createElement("script"));void(0);'
return 'javascript:' + script
} | [
"function",
"getTargetBookmarklet",
"(",
")",
"{",
"var",
"script",
"=",
"targetBookmarkletFunction",
".",
"toString",
"(",
")",
";",
"script",
"=",
"script",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"\"\"",
")",
"script",
"=",
"script",
".",
"rep... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/index.js#L84-L92 | train | Get the target bookmarklet | [
30522,
3853,
2131,
7559,
18150,
8654,
10665,
7485,
1006,
1007,
1063,
13075,
5896,
1027,
4539,
8654,
10665,
7485,
11263,
27989,
1012,
2000,
3367,
4892,
1006,
1007,
1025,
5896,
1027,
5896,
1012,
5672,
1006,
1013,
1032,
1050,
1013,
1043,
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... |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/Panel.js | processChunk | function processChunk()
{
var view = searchableViews[i];
if (++i >= searchableViews.length) {
if (panel._currentSearchChunkIntervalIdentifier === chunkIntervalIdentifier)
delete panel._currentSearchChunkIntervalIdentifier;
clearInterval(chunkIntervalIdentifier);
}
if (!view)
return;
if (view.element.parentNode !== parentElement && view.element.parentNode && parentElement)
view.detach();
view.currentQuery = query;
view.performSearch(query, boundFinishedCallback);
} | javascript | function processChunk()
{
var view = searchableViews[i];
if (++i >= searchableViews.length) {
if (panel._currentSearchChunkIntervalIdentifier === chunkIntervalIdentifier)
delete panel._currentSearchChunkIntervalIdentifier;
clearInterval(chunkIntervalIdentifier);
}
if (!view)
return;
if (view.element.parentNode !== parentElement && view.element.parentNode && parentElement)
view.detach();
view.currentQuery = query;
view.performSearch(query, boundFinishedCallback);
} | [
"function",
"processChunk",
"(",
")",
"{",
"var",
"view",
"=",
"searchableViews",
"[",
"i",
"]",
";",
"if",
"(",
"++",
"i",
">=",
"searchableViews",
".",
"length",
")",
"{",
"if",
"(",
"panel",
".",
"_currentSearchChunkIntervalIdentifier",
"===",
"chunkInter... | Split up the work into chunks so we don't block the UI thread while processing. | [
"Split",
"up",
"the",
"work",
"into",
"chunks",
"so",
"we",
"don",
"t",
"block",
"the",
"UI",
"thread",
"while",
"processing",
"."
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/Panel.js#L204-L222 | train | processChunk - Process a chunk of searchable views | [
30522,
3853,
2832,
20760,
8950,
1006,
1007,
1063,
13075,
3193,
1027,
3945,
3085,
8584,
2015,
1031,
1045,
1033,
1025,
2065,
1006,
1009,
1009,
1045,
1028,
1027,
3945,
3085,
8584,
2015,
1012,
3091,
1007,
1063,
2065,
1006,
5997,
1012,
1035,
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... |
parcel-bundler/parcel | packages/core/parcel-bundler/src/utils/syncPromise.js | syncPromise | function syncPromise(promise) {
let isDone = false;
let res, err;
promise.then(
value => {
res = value;
isDone = true;
},
error => {
err = error;
isDone = true;
}
);
deasync.loopWhile(() => !isDone);
if (err) {
throw err;
}
return res;
} | javascript | function syncPromise(promise) {
let isDone = false;
let res, err;
promise.then(
value => {
res = value;
isDone = true;
},
error => {
err = error;
isDone = true;
}
);
deasync.loopWhile(() => !isDone);
if (err) {
throw err;
}
return res;
} | [
"function",
"syncPromise",
"(",
"promise",
")",
"{",
"let",
"isDone",
"=",
"false",
";",
"let",
"res",
",",
"err",
";",
"promise",
".",
"then",
"(",
"value",
"=>",
"{",
"res",
"=",
"value",
";",
"isDone",
"=",
"true",
";",
"}",
",",
"error",
"=>",
... | Synchronously waits for a promise to return by
yielding to the node event loop as needed. | [
"Synchronously",
"waits",
"for",
"a",
"promise",
"to",
"return",
"by",
"yielding",
"to",
"the",
"node",
"event",
"loop",
"as",
"needed",
"."
] | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/utils/syncPromise.js#L7-L29 | train | Sync a promise | [
30522,
3853,
26351,
21572,
28732,
1006,
4872,
1007,
1063,
2292,
2003,
5280,
2063,
1027,
6270,
1025,
2292,
24501,
1010,
9413,
2099,
1025,
4872,
1012,
2059,
1006,
3643,
1027,
1028,
1063,
24501,
1027,
3643,
1025,
2003,
5280,
2063,
1027,
2995,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/EventHandlerResolver.js | function(sName, oController) {
var fnHandler;
sName = sName.trim();
if (sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) {
// When design mode is enabled, controller code is not loaded. That is why we stub the handler functions.
fnHandler = function() {};
} else {
// check for extended event handler syntax
var iStartBracket = sName.indexOf("("),
sFunctionName = sName;
if (iStartBracket > 0) {
sFunctionName = sName.substring(0, iStartBracket).trim();
} else if (iStartBracket === 0) {
throw new Error("Event handler name starts with a bracket, must start with a function name " +
"(or with a dot followed by controller-local function name): " + sName);
}
switch (sFunctionName.indexOf('.')) {
case 0:
// starts with a dot, must be a controller local handler
// usage of jQuery.sap.getObject to allow addressing functions in properties
fnHandler = oController && ObjectPath.get(sFunctionName.slice(1), oController);
break;
case -1:
// no dot at all: first check for a controller local, then for a global handler
fnHandler = oController && oController[sFunctionName];
if ( fnHandler != null ) {
// If the name can be resolved, don't try to find a global handler (even if it is not a function).
break;
}
// falls through
default:
fnHandler = ObjectPath.get(sFunctionName);
}
// handle extended event handler syntax
if (fnHandler && iStartBracket > 0) {
var iEndBracket = sName.lastIndexOf(")");
if (iEndBracket > iStartBracket) {
if (sName.substring(iStartBracket).indexOf("{=") > -1) {
Log.warning("It looks like an event handler parameter contains a binding expression ({=...}). This is not allowed and will cause an error later on " +
"because the entire event handler is already considered an expression: " + sName);
}
// create a new handler function as wrapper that internally provides the configured values as arguments to the actual handler function
fnHandler = (function(sFunctionName, oController) { // the previous fnHandler is not used because the expression parser resolves and calls the original handler function
return function(oEvent) { // the actual event handler function; soon enriched with more context, then calling the configured fnHandler
var oParametersModel, oSourceModel,
sExpression = sName; // the expression to actually pass to the parser;
// configure the resolver element with additional models
if (sName.indexOf("$parameters") > -1) {
oParametersModel = new JSONModel(oEvent.mParameters);
}
if (sName.indexOf("$source") > -1) {
oSourceModel = new MOM(oEvent.getSource());
}
var mGlobals = {"$controller": oController, $event: oEvent};
if (sFunctionName.indexOf(".") > 0) {
// if function has no leading dot (which would mean it is a Controller method), but has a dot later on, accept the first component as global object
var sGlobal = sFunctionName.split(".")[0];
mGlobals[sGlobal] = window[sGlobal];
} else if (sFunctionName.indexOf(".") === -1) {
if (oController && oController[sFunctionName]) {
// if function has no dot at all, and oController has a member with the same name, this member should be used as function
// (this tells the expression parser to use the same logic as applied above)
sExpression = "$controller." + sExpression;
} else if (window[sFunctionName]) {
mGlobals[sFunctionName] = window[sFunctionName];
}
}
// the following line evaluates the expression
// in case all parameters are constants, it already calls the event handler along with all its arguments, otherwise it returns a binding info
var oExpressionParserResult = BindingParser.parseExpression(sExpression.replace(/^\./, "$controller."), 0, {oContext: oController}, mGlobals);
if (oExpressionParserResult.result) { // a binding info
// we need to trigger evaluation (but we don't need the result, evaluation already calls the event handler)
try {
getBindingValue(oExpressionParserResult.result, oEvent.getSource(), oController, oParametersModel, oSourceModel);
} catch (e) {
e.message = "Error when evaluating event handler '" + sName + "': " + e.message;
throw e;
}
}
if (oParametersModel) {
oParametersModel.destroy();
}
if (oSourceModel) {
oSourceModel.destroy();
}
};
})(sFunctionName, oController);
} else {
Log.error("Syntax error in event handler '" + sName + "': arguments must be enclosed in a pair of brackets");
}
}
}
if ( typeof fnHandler === "function" ) {
// the original handler definition is set as property of the resulting function to keep this information
// e.g. for serializers which convert a control tree back to a serialized format
fnHandler._sapui_handlerName = sName;
// always attach the handler with the controller as context ('this')
return [ fnHandler, oController ];
}
Log.warning("Event handler name '" + sName + "' could not be resolved to an event handler function");
// return undefined
} | javascript | function(sName, oController) {
var fnHandler;
sName = sName.trim();
if (sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) {
// When design mode is enabled, controller code is not loaded. That is why we stub the handler functions.
fnHandler = function() {};
} else {
// check for extended event handler syntax
var iStartBracket = sName.indexOf("("),
sFunctionName = sName;
if (iStartBracket > 0) {
sFunctionName = sName.substring(0, iStartBracket).trim();
} else if (iStartBracket === 0) {
throw new Error("Event handler name starts with a bracket, must start with a function name " +
"(or with a dot followed by controller-local function name): " + sName);
}
switch (sFunctionName.indexOf('.')) {
case 0:
// starts with a dot, must be a controller local handler
// usage of jQuery.sap.getObject to allow addressing functions in properties
fnHandler = oController && ObjectPath.get(sFunctionName.slice(1), oController);
break;
case -1:
// no dot at all: first check for a controller local, then for a global handler
fnHandler = oController && oController[sFunctionName];
if ( fnHandler != null ) {
// If the name can be resolved, don't try to find a global handler (even if it is not a function).
break;
}
// falls through
default:
fnHandler = ObjectPath.get(sFunctionName);
}
// handle extended event handler syntax
if (fnHandler && iStartBracket > 0) {
var iEndBracket = sName.lastIndexOf(")");
if (iEndBracket > iStartBracket) {
if (sName.substring(iStartBracket).indexOf("{=") > -1) {
Log.warning("It looks like an event handler parameter contains a binding expression ({=...}). This is not allowed and will cause an error later on " +
"because the entire event handler is already considered an expression: " + sName);
}
// create a new handler function as wrapper that internally provides the configured values as arguments to the actual handler function
fnHandler = (function(sFunctionName, oController) { // the previous fnHandler is not used because the expression parser resolves and calls the original handler function
return function(oEvent) { // the actual event handler function; soon enriched with more context, then calling the configured fnHandler
var oParametersModel, oSourceModel,
sExpression = sName; // the expression to actually pass to the parser;
// configure the resolver element with additional models
if (sName.indexOf("$parameters") > -1) {
oParametersModel = new JSONModel(oEvent.mParameters);
}
if (sName.indexOf("$source") > -1) {
oSourceModel = new MOM(oEvent.getSource());
}
var mGlobals = {"$controller": oController, $event: oEvent};
if (sFunctionName.indexOf(".") > 0) {
// if function has no leading dot (which would mean it is a Controller method), but has a dot later on, accept the first component as global object
var sGlobal = sFunctionName.split(".")[0];
mGlobals[sGlobal] = window[sGlobal];
} else if (sFunctionName.indexOf(".") === -1) {
if (oController && oController[sFunctionName]) {
// if function has no dot at all, and oController has a member with the same name, this member should be used as function
// (this tells the expression parser to use the same logic as applied above)
sExpression = "$controller." + sExpression;
} else if (window[sFunctionName]) {
mGlobals[sFunctionName] = window[sFunctionName];
}
}
// the following line evaluates the expression
// in case all parameters are constants, it already calls the event handler along with all its arguments, otherwise it returns a binding info
var oExpressionParserResult = BindingParser.parseExpression(sExpression.replace(/^\./, "$controller."), 0, {oContext: oController}, mGlobals);
if (oExpressionParserResult.result) { // a binding info
// we need to trigger evaluation (but we don't need the result, evaluation already calls the event handler)
try {
getBindingValue(oExpressionParserResult.result, oEvent.getSource(), oController, oParametersModel, oSourceModel);
} catch (e) {
e.message = "Error when evaluating event handler '" + sName + "': " + e.message;
throw e;
}
}
if (oParametersModel) {
oParametersModel.destroy();
}
if (oSourceModel) {
oSourceModel.destroy();
}
};
})(sFunctionName, oController);
} else {
Log.error("Syntax error in event handler '" + sName + "': arguments must be enclosed in a pair of brackets");
}
}
}
if ( typeof fnHandler === "function" ) {
// the original handler definition is set as property of the resulting function to keep this information
// e.g. for serializers which convert a control tree back to a serialized format
fnHandler._sapui_handlerName = sName;
// always attach the handler with the controller as context ('this')
return [ fnHandler, oController ];
}
Log.warning("Event handler name '" + sName + "' could not be resolved to an event handler function");
// return undefined
} | [
"function",
"(",
"sName",
",",
"oController",
")",
"{",
"var",
"fnHandler",
";",
"sName",
"=",
"sName",
".",
"trim",
"(",
")",
";",
"if",
"(",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"getControllerCodeDeactiv... | Helper method to resolve an event handler either locally (from a controller) or globally.
Which contexts are checked for the event handler depends on the syntax of the name:
<ul>
<li><i>relative</i>: names starting with a dot ('.') must specify a handler in
the controller (example: <code>".myLocalHandler"</code>)</li>
<li><i>absolute</i>: names that contain, but do not start with a dot ('.') are
always assumed to mean a global handler function. {@link jQuery.sap.getObject}
will be used to retrieve the function (example: <code>"some.global.handler"</code> )</li>
<li><i>legacy</i>: Names that contain no dot at all are first interpreted as a relative name
and then - if nothing is found - as an absolute name. This variant is only supported
for backward compatibility (example: <code>"myHandler"</code>)</li>
</ul>
The returned settings will always use the given <code>oController</code> as context object ('this')
This should allow the implementation of generic global handlers that might need an easy back link
to the controller/view in which they are currently used (e.g. to call createId/byId). It also makes
the development of global event handlers more consistent with controller local event handlers.
The event handler name can either be a pure function name (defined in the controller, or globally,
as explained above), or the function name can be followed by braces containing parameters that
shall be passed to the handler instead of the event object. In case of braces the entire string is
parsed like a binding expression, so in addition to static values also bindings and certain operators
can be used.
<strong>Note</strong>: It is not mandatory but improves readability of declarative views when
legacy names are converted to relative names where appropriate.
@param {string} sName the event handler name to resolve
@param {sap.ui.core.mvc.Controller} oController the controller to use as context
@return {any[]} an array with function and context object, suitable for applySettings.
@private | [
"Helper",
"method",
"to",
"resolve",
"an",
"event",
"handler",
"either",
"locally",
"(",
"from",
"a",
"controller",
")",
"or",
"globally",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/EventHandlerResolver.js#L69-L186 | train | Returns the function that will be called when the event handler is triggered. | [
30522,
3853,
1006,
1055,
18442,
1010,
1051,
8663,
13181,
10820,
1007,
1063,
13075,
1042,
25311,
5685,
3917,
1025,
1055,
18442,
1027,
1055,
18442,
1012,
12241,
1006,
1007,
1025,
2065,
1006,
20066,
1012,
21318,
1012,
2131,
17345,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
getsentry/sentry-javascript | packages/raven-js/src/raven.js | function() {
var self = this;
var wrappedBuiltIns = self._wrappedBuiltIns;
function wrapTimeFn(orig) {
return function(fn, t) {
// preserve arity
// Make a copy of the arguments to prevent deoptimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
var args = new Array(arguments.length);
for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i];
}
var originalCallback = args[0];
if (isFunction(originalCallback)) {
args[0] = self.wrap(
{
mechanism: {
type: 'instrument',
data: {function: orig.name || '<anonymous>'}
}
},
originalCallback
);
}
// IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it
// also supports only two arguments and doesn't care what this is, so we
// can just call the original function directly.
if (orig.apply) {
return orig.apply(this, args);
} else {
return orig(args[0], args[1]);
}
};
}
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs;
function wrapEventTarget(global) {
var proto = _window[global] && _window[global].prototype;
if (proto && proto.hasOwnProperty && proto.hasOwnProperty('addEventListener')) {
fill(
proto,
'addEventListener',
function(orig) {
return function(evtName, fn, capture, secure) {
// preserve arity
try {
if (fn && fn.handleEvent) {
fn.handleEvent = self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'handleEvent',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn.handleEvent
);
}
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
// More breadcrumb DOM capture ... done here and not in `_instrumentBreadcrumbs`
// so that we don't have more than one wrapper function
var before, clickHandler, keypressHandler;
if (
autoBreadcrumbs &&
autoBreadcrumbs.dom &&
(global === 'EventTarget' || global === 'Node')
) {
// NOTE: generating multiple handlers per addEventListener invocation, should
// revisit and verify we can just use one (almost certainly)
clickHandler = self._breadcrumbEventHandler('click');
keypressHandler = self._keypressEventHandler();
before = function(evt) {
// need to intercept every DOM event in `before` argument, in case that
// same wrapped method is re-used for different events (e.g. mousemove THEN click)
// see #724
if (!evt) return;
var eventType;
try {
eventType = evt.type;
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
if (eventType === 'click') return clickHandler(evt);
else if (eventType === 'keypress') return keypressHandler(evt);
};
}
return orig.call(
this,
evtName,
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'addEventListener',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn,
before
),
capture,
secure
);
};
},
wrappedBuiltIns
);
fill(
proto,
'removeEventListener',
function(orig) {
return function(evt, fn, capture, secure) {
try {
fn = fn && (fn.__raven_wrapper__ ? fn.__raven_wrapper__ : fn);
} catch (e) {
// ignore, accessing __raven_wrapper__ will throw in some Selenium environments
}
return orig.call(this, evt, fn, capture, secure);
};
},
wrappedBuiltIns
);
}
}
fill(_window, 'setTimeout', wrapTimeFn, wrappedBuiltIns);
fill(_window, 'setInterval', wrapTimeFn, wrappedBuiltIns);
if (_window.requestAnimationFrame) {
fill(
_window,
'requestAnimationFrame',
function(orig) {
return function(cb) {
return orig(
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
function: 'requestAnimationFrame',
handler: (orig && orig.name) || '<anonymous>'
}
}
},
cb
)
);
};
},
wrappedBuiltIns
);
}
// event targets borrowed from bugsnag-js:
// https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L666
var eventTargets = [
'EventTarget',
'Window',
'Node',
'ApplicationCache',
'AudioTrackList',
'ChannelMergerNode',
'CryptoOperation',
'EventSource',
'FileReader',
'HTMLUnknownElement',
'IDBDatabase',
'IDBRequest',
'IDBTransaction',
'KeyOperation',
'MediaController',
'MessagePort',
'ModalWindow',
'Notification',
'SVGElementInstance',
'Screen',
'TextTrack',
'TextTrackCue',
'TextTrackList',
'WebSocket',
'WebSocketWorker',
'Worker',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload'
];
for (var i = 0; i < eventTargets.length; i++) {
wrapEventTarget(eventTargets[i]);
}
} | javascript | function() {
var self = this;
var wrappedBuiltIns = self._wrappedBuiltIns;
function wrapTimeFn(orig) {
return function(fn, t) {
// preserve arity
// Make a copy of the arguments to prevent deoptimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
var args = new Array(arguments.length);
for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i];
}
var originalCallback = args[0];
if (isFunction(originalCallback)) {
args[0] = self.wrap(
{
mechanism: {
type: 'instrument',
data: {function: orig.name || '<anonymous>'}
}
},
originalCallback
);
}
// IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it
// also supports only two arguments and doesn't care what this is, so we
// can just call the original function directly.
if (orig.apply) {
return orig.apply(this, args);
} else {
return orig(args[0], args[1]);
}
};
}
var autoBreadcrumbs = this._globalOptions.autoBreadcrumbs;
function wrapEventTarget(global) {
var proto = _window[global] && _window[global].prototype;
if (proto && proto.hasOwnProperty && proto.hasOwnProperty('addEventListener')) {
fill(
proto,
'addEventListener',
function(orig) {
return function(evtName, fn, capture, secure) {
// preserve arity
try {
if (fn && fn.handleEvent) {
fn.handleEvent = self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'handleEvent',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn.handleEvent
);
}
} catch (err) {
// can sometimes get 'Permission denied to access property "handle Event'
}
// More breadcrumb DOM capture ... done here and not in `_instrumentBreadcrumbs`
// so that we don't have more than one wrapper function
var before, clickHandler, keypressHandler;
if (
autoBreadcrumbs &&
autoBreadcrumbs.dom &&
(global === 'EventTarget' || global === 'Node')
) {
// NOTE: generating multiple handlers per addEventListener invocation, should
// revisit and verify we can just use one (almost certainly)
clickHandler = self._breadcrumbEventHandler('click');
keypressHandler = self._keypressEventHandler();
before = function(evt) {
// need to intercept every DOM event in `before` argument, in case that
// same wrapped method is re-used for different events (e.g. mousemove THEN click)
// see #724
if (!evt) return;
var eventType;
try {
eventType = evt.type;
} catch (e) {
// just accessing event properties can throw an exception in some rare circumstances
// see: https://github.com/getsentry/raven-js/issues/838
return;
}
if (eventType === 'click') return clickHandler(evt);
else if (eventType === 'keypress') return keypressHandler(evt);
};
}
return orig.call(
this,
evtName,
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
target: global,
function: 'addEventListener',
handler: (fn && fn.name) || '<anonymous>'
}
}
},
fn,
before
),
capture,
secure
);
};
},
wrappedBuiltIns
);
fill(
proto,
'removeEventListener',
function(orig) {
return function(evt, fn, capture, secure) {
try {
fn = fn && (fn.__raven_wrapper__ ? fn.__raven_wrapper__ : fn);
} catch (e) {
// ignore, accessing __raven_wrapper__ will throw in some Selenium environments
}
return orig.call(this, evt, fn, capture, secure);
};
},
wrappedBuiltIns
);
}
}
fill(_window, 'setTimeout', wrapTimeFn, wrappedBuiltIns);
fill(_window, 'setInterval', wrapTimeFn, wrappedBuiltIns);
if (_window.requestAnimationFrame) {
fill(
_window,
'requestAnimationFrame',
function(orig) {
return function(cb) {
return orig(
self.wrap(
{
mechanism: {
type: 'instrument',
data: {
function: 'requestAnimationFrame',
handler: (orig && orig.name) || '<anonymous>'
}
}
},
cb
)
);
};
},
wrappedBuiltIns
);
}
// event targets borrowed from bugsnag-js:
// https://github.com/bugsnag/bugsnag-js/blob/master/src/bugsnag.js#L666
var eventTargets = [
'EventTarget',
'Window',
'Node',
'ApplicationCache',
'AudioTrackList',
'ChannelMergerNode',
'CryptoOperation',
'EventSource',
'FileReader',
'HTMLUnknownElement',
'IDBDatabase',
'IDBRequest',
'IDBTransaction',
'KeyOperation',
'MediaController',
'MessagePort',
'ModalWindow',
'Notification',
'SVGElementInstance',
'Screen',
'TextTrack',
'TextTrackCue',
'TextTrackList',
'WebSocket',
'WebSocketWorker',
'Worker',
'XMLHttpRequest',
'XMLHttpRequestEventTarget',
'XMLHttpRequestUpload'
];
for (var i = 0; i < eventTargets.length; i++) {
wrapEventTarget(eventTargets[i]);
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"wrappedBuiltIns",
"=",
"self",
".",
"_wrappedBuiltIns",
";",
"function",
"wrapTimeFn",
"(",
"orig",
")",
"{",
"return",
"function",
"(",
"fn",
",",
"t",
")",
"{",
"// preserve arity",
"/... | Wrap timer functions and event targets to catch errors and provide
better metadata. | [
"Wrap",
"timer",
"functions",
"and",
"event",
"targets",
"to",
"catch",
"errors",
"and",
"provide",
"better",
"metadata",
"."
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/src/raven.js#L1102-L1308 | train | This function is called by the constructor when the constructor is called. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
5058,
8569,
4014,
7629,
2015,
1027,
2969,
1012,
1035,
5058,
8569,
4014,
7629,
2015,
1025,
3853,
10236,
7292,
2546,
2078,
1006,
2030,
8004,
1007,
1063,
2709,
3853,
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... | |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function() {
var oldRow = api.getParentElement(this.cell, { nodeName: ["TR"] });
if (oldRow) {
this.setTableMap();
this.idx = this.getMapIndex(this.cell);
if (this.idx !== false) {
var modRow = this.map[this.idx.row];
for (var cidx = 0, cmax = modRow.length; cidx < cmax; cidx++) {
if (!modRow[cidx].modified) {
this.setCellAsModified(modRow[cidx]);
this.removeRowCell(modRow[cidx]);
}
}
}
removeElement(oldRow);
}
} | javascript | function() {
var oldRow = api.getParentElement(this.cell, { nodeName: ["TR"] });
if (oldRow) {
this.setTableMap();
this.idx = this.getMapIndex(this.cell);
if (this.idx !== false) {
var modRow = this.map[this.idx.row];
for (var cidx = 0, cmax = modRow.length; cidx < cmax; cidx++) {
if (!modRow[cidx].modified) {
this.setCellAsModified(modRow[cidx]);
this.removeRowCell(modRow[cidx]);
}
}
}
removeElement(oldRow);
}
} | [
"function",
"(",
")",
"{",
"var",
"oldRow",
"=",
"api",
".",
"getParentElement",
"(",
"this",
".",
"cell",
",",
"{",
"nodeName",
":",
"[",
"\"TR\"",
"]",
"}",
")",
";",
"if",
"(",
"oldRow",
")",
"{",
"this",
".",
"setTableMap",
"(",
")",
";",
"th... | Removes the row of selected cell | [
"Removes",
"the",
"row",
"of",
"selected",
"cell"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L7935-L7951 | train | remove the TR element | [
30522,
3853,
1006,
1007,
1063,
13075,
2214,
10524,
1027,
17928,
1012,
2131,
19362,
15781,
16930,
4765,
1006,
2023,
1012,
3526,
1010,
1063,
13045,
18442,
1024,
1031,
1000,
19817,
1000,
1033,
1065,
1007,
1025,
2065,
1006,
2214,
10524,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
codemirror/CodeMirror | src/measurement/position_measurement.js | boxIsAfter | function boxIsAfter(box, x, y, left) {
return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
} | javascript | function boxIsAfter(box, x, y, left) {
return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
} | [
"function",
"boxIsAfter",
"(",
"box",
",",
"x",
",",
"y",
",",
"left",
")",
"{",
"return",
"box",
".",
"bottom",
"<=",
"y",
"?",
"false",
":",
"box",
".",
"top",
">",
"y",
"?",
"true",
":",
"(",
"left",
"?",
"box",
".",
"left",
":",
"box",
".... | Returns true if the given side of a box is after the given coordinates, in top-to-bottom, left-to-right order. | [
"Returns",
"true",
"if",
"the",
"given",
"side",
"of",
"a",
"box",
"is",
"after",
"the",
"given",
"coordinates",
"in",
"top",
"-",
"to",
"-",
"bottom",
"left",
"-",
"to",
"-",
"right",
"order",
"."
] | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/measurement/position_measurement.js#L457-L459 | train | Check if a box is after the given x y | [
30522,
3853,
3482,
14268,
6199,
2121,
1006,
3482,
1010,
1060,
1010,
1061,
1010,
2187,
1007,
1063,
2709,
3482,
1012,
3953,
1026,
1027,
1061,
1029,
6270,
1024,
3482,
1012,
2327,
1028,
1061,
1029,
2995,
1024,
1006,
2187,
1029,
3482,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js | function(oComponent) {
Log.info("CustomizingConfiguration: activateForComponentInstance('" + oComponent.getId() + "')");
var sComponentName = oComponent.getMetadata().getComponentName(),
sKey = sComponentName + "::" + oComponent.getId(),
oCustomizingConfig = oComponent.getManifest()["sap.ui5"] && oComponent.getManifest()["sap.ui5"]["extends"] && oComponent.getManifest()["sap.ui5"]["extends"]["extensions"];
mComponentConfigs[sKey] = oCustomizingConfig;
Log.debug("CustomizingConfiguration: customizing configuration for component '" + sKey + "' loaded: " + JSON.stringify(oCustomizingConfig));
} | javascript | function(oComponent) {
Log.info("CustomizingConfiguration: activateForComponentInstance('" + oComponent.getId() + "')");
var sComponentName = oComponent.getMetadata().getComponentName(),
sKey = sComponentName + "::" + oComponent.getId(),
oCustomizingConfig = oComponent.getManifest()["sap.ui5"] && oComponent.getManifest()["sap.ui5"]["extends"] && oComponent.getManifest()["sap.ui5"]["extends"]["extensions"];
mComponentConfigs[sKey] = oCustomizingConfig;
Log.debug("CustomizingConfiguration: customizing configuration for component '" + sKey + "' loaded: " + JSON.stringify(oCustomizingConfig));
} | [
"function",
"(",
"oComponent",
")",
"{",
"Log",
".",
"info",
"(",
"\"CustomizingConfiguration: activateForComponentInstance('\"",
"+",
"oComponent",
".",
"getId",
"(",
")",
"+",
"\"')\"",
")",
";",
"var",
"sComponentName",
"=",
"oComponent",
".",
"getMetadata",
"(... | Activates the Customizing of a component instance by registering the component
configuration in the central Customizing configuration.
@param {sap.ui.core.Component} oComponent the component instance
@private | [
"Activates",
"the",
"Customizing",
"of",
"a",
"component",
"instance",
"by",
"registering",
"the",
"component",
"configuration",
"in",
"the",
"central",
"Customizing",
"configuration",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js#L127-L135 | train | Activates the customizing configuration for the given component | [
30522,
3853,
1006,
1051,
9006,
29513,
3372,
1007,
1063,
8833,
1012,
18558,
1006,
1000,
7661,
6026,
8663,
8873,
27390,
3370,
1024,
20544,
29278,
9006,
29513,
16778,
23808,
6651,
1006,
1005,
1000,
1009,
1051,
9006,
29513,
3372,
1012,
2131,
35... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ipfs/js-ipfs | src/core/components/files-regular/utils.js | parseRabinString | function parseRabinString (chunker) {
const options = {}
const parts = chunker.split('-')
switch (parts.length) {
case 1:
options.avgChunkSize = 262144
break
case 2:
options.avgChunkSize = parseChunkSize(parts[1], 'avg')
break
case 4:
options.minChunkSize = parseChunkSize(parts[1], 'min')
options.avgChunkSize = parseChunkSize(parts[2], 'avg')
options.maxChunkSize = parseChunkSize(parts[3], 'max')
break
default:
throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')
}
return options
} | javascript | function parseRabinString (chunker) {
const options = {}
const parts = chunker.split('-')
switch (parts.length) {
case 1:
options.avgChunkSize = 262144
break
case 2:
options.avgChunkSize = parseChunkSize(parts[1], 'avg')
break
case 4:
options.minChunkSize = parseChunkSize(parts[1], 'min')
options.avgChunkSize = parseChunkSize(parts[2], 'avg')
options.maxChunkSize = parseChunkSize(parts[3], 'max')
break
default:
throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')
}
return options
} | [
"function",
"parseRabinString",
"(",
"chunker",
")",
"{",
"const",
"options",
"=",
"{",
"}",
"const",
"parts",
"=",
"chunker",
".",
"split",
"(",
"'-'",
")",
"switch",
"(",
"parts",
".",
"length",
")",
"{",
"case",
"1",
":",
"options",
".",
"avgChunkSi... | Parses rabin chunker string
@param {String} chunker Chunker algorithm supported formats:
"rabin"
"rabin-{avg}"
"rabin-{min}-{avg}-{max}"
@return {Object} rabin chunker options | [
"Parses",
"rabin",
"chunker",
"string"
] | 97e67601094acda3906549ecb0248fd09f1a8cc3 | https://github.com/ipfs/js-ipfs/blob/97e67601094acda3906549ecb0248fd09f1a8cc3/src/core/components/files-regular/utils.js#L70-L90 | train | Parse a rabin chunker string | [
30522,
3853,
11968,
8043,
28518,
23808,
4892,
1006,
20000,
2121,
1007,
1063,
9530,
3367,
7047,
1027,
1063,
1065,
9530,
3367,
3033,
1027,
20000,
2121,
1012,
3975,
1006,
1005,
1011,
1005,
1007,
6942,
1006,
3033,
1012,
3091,
1007,
1063,
2553,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | generateExports | function generateExports(symbols) {
const namespaces = {};
const imports = [];
let blocks = [];
symbols.forEach(function(symbol) {
const name = symbol.name;
if (name.indexOf('#') == -1) {
const imp = getImport(symbol);
if (imp) {
imports[getImport(symbol)] = true;
}
const block = formatSymbolExport(symbol, namespaces, imports);
if (block !== blocks[blocks.length - 1]) {
blocks.push(block);
}
}
});
const nsdefs = [];
const ns = Object.keys(namespaces).sort();
for (let i = 0, ii = ns.length; i < ii; ++i) {
if (namespaces[ns[i]]) {
nsdefs.push(`${ns[i]} = {};`);
}
}
blocks = Object.keys(imports).concat('\nvar ol = {};\n', nsdefs.sort()).concat(blocks.sort());
blocks.push('', 'export default ol;');
return blocks.join('\n');
} | javascript | function generateExports(symbols) {
const namespaces = {};
const imports = [];
let blocks = [];
symbols.forEach(function(symbol) {
const name = symbol.name;
if (name.indexOf('#') == -1) {
const imp = getImport(symbol);
if (imp) {
imports[getImport(symbol)] = true;
}
const block = formatSymbolExport(symbol, namespaces, imports);
if (block !== blocks[blocks.length - 1]) {
blocks.push(block);
}
}
});
const nsdefs = [];
const ns = Object.keys(namespaces).sort();
for (let i = 0, ii = ns.length; i < ii; ++i) {
if (namespaces[ns[i]]) {
nsdefs.push(`${ns[i]} = {};`);
}
}
blocks = Object.keys(imports).concat('\nvar ol = {};\n', nsdefs.sort()).concat(blocks.sort());
blocks.push('', 'export default ol;');
return blocks.join('\n');
} | [
"function",
"generateExports",
"(",
"symbols",
")",
"{",
"const",
"namespaces",
"=",
"{",
"}",
";",
"const",
"imports",
"=",
"[",
"]",
";",
"let",
"blocks",
"=",
"[",
"]",
";",
"symbols",
".",
"forEach",
"(",
"function",
"(",
"symbol",
")",
"{",
"con... | Generate export code given a list symbol names.
@param {Array<Object>} symbols List of symbols.
@param {Object<string, string>} namespaces Already defined namespaces.
@param {Array<string>} imports List of all imports.
@return {string} Export code. | [
"Generate",
"export",
"code",
"given",
"a",
"list",
"symbol",
"names",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/tasks/generate-index.js#L70-L97 | train | Generate export blocks for symbols | [
30522,
3853,
9699,
10288,
25378,
1006,
9255,
1007,
1063,
9530,
3367,
3415,
15327,
2015,
1027,
1063,
1065,
1025,
9530,
3367,
17589,
1027,
1031,
1033,
1025,
2292,
5991,
1027,
1031,
1033,
1025,
9255,
1012,
18921,
6776,
1006,
3853,
1006,
6454,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
typeorm/typeorm | extra/typeorm-class-transformer-shim.js | ManyToMany | function ManyToMany(typeFunction, inverseSideOrOptions, options) {
return function (object, propertyName) {
class_transformer_1.Type(typeFunction)(object, propertyName);
};
} | javascript | function ManyToMany(typeFunction, inverseSideOrOptions, options) {
return function (object, propertyName) {
class_transformer_1.Type(typeFunction)(object, propertyName);
};
} | [
"function",
"ManyToMany",
"(",
"typeFunction",
",",
"inverseSideOrOptions",
",",
"options",
")",
"{",
"return",
"function",
"(",
"object",
",",
"propertyName",
")",
"{",
"class_transformer_1",
".",
"Type",
"(",
"typeFunction",
")",
"(",
"object",
",",
"propertyN... | /* export | [
"/",
"*",
"export"
] | 360468b7913db8d988346fba1ee2d3f323498eef | https://github.com/typeorm/typeorm/blob/360468b7913db8d988346fba1ee2d3f323498eef/extra/typeorm-class-transformer-shim.js#L140-L144 | train | Creates a function that takes a typeFunction and returns a function that takes an object and a property name and returns a function that takes an inverse side or options object and returns a function that takes an inverse side or options object and returns a function that takes an inverse side or options object. | [
30522,
3853,
2116,
20389,
19092,
1006,
2828,
11263,
27989,
1010,
19262,
7363,
14604,
16790,
2015,
1010,
7047,
1007,
1063,
2709,
3853,
1006,
4874,
1010,
3200,
18442,
1007,
1063,
2465,
1035,
10938,
2121,
1035,
1015,
1012,
2828,
1006,
2828,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/merge-results.js | spliceNodes | function spliceNodes(target, to) {
'use strict';
var firstFromFrame = to[0].node,
sorterResult,
t;
for (var i = 0, l = target.length; i < l; i++) {
t = target[i].node;
sorterResult = axe.utils.nodeSorter(
{ actualNode: t.element },
{ actualNode: firstFromFrame.element }
);
if (
sorterResult > 0 ||
(sorterResult === 0 && firstFromFrame.selector.length < t.selector.length)
) {
target.splice.apply(target, [i, 0].concat(to));
return;
}
}
target.push.apply(target, to);
} | javascript | function spliceNodes(target, to) {
'use strict';
var firstFromFrame = to[0].node,
sorterResult,
t;
for (var i = 0, l = target.length; i < l; i++) {
t = target[i].node;
sorterResult = axe.utils.nodeSorter(
{ actualNode: t.element },
{ actualNode: firstFromFrame.element }
);
if (
sorterResult > 0 ||
(sorterResult === 0 && firstFromFrame.selector.length < t.selector.length)
) {
target.splice.apply(target, [i, 0].concat(to));
return;
}
}
target.push.apply(target, to);
} | [
"function",
"spliceNodes",
"(",
"target",
",",
"to",
")",
"{",
"'use strict'",
";",
"var",
"firstFromFrame",
"=",
"to",
"[",
"0",
"]",
".",
"node",
",",
"sorterResult",
",",
"t",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"target",
".",
... | Adds `to` to `from` and then re-sorts by DOM order
@private
@param {Array} target `nodes` array on a `RuleResult`
@param {Array} to `nodes` array on a `RuleResult`
@return {Array} The merged and sorted result | [
"Adds",
"to",
"to",
"from",
"and",
"then",
"re",
"-",
"sorts",
"by",
"DOM",
"order"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/merge-results.js#L38-L60 | train | Splice nodes from target to to | [
30522,
3853,
11867,
13231,
3630,
6155,
1006,
4539,
1010,
2000,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
2034,
19699,
5358,
15643,
1027,
2000,
1031,
1014,
1033,
1012,
13045,
1010,
4066,
28849,
23722,
2102,
1010,
1056,
1025,
2005,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | examples/demo-app/src/actions.js | loadRemoteSampleMap | function loadRemoteSampleMap(options) {
return (dispatch) => {
// Load configuration first
const {configUrl, dataUrl} = options;
Promise
.all([loadRemoteConfig(configUrl), loadRemoteData(dataUrl)])
.then(
([config, data]) => {
// TODO: these two actions can be merged
dispatch(loadRemoteResourceSuccess(data, config, options));
dispatch(toggleModal(null));
},
error => {
if (error) {
const {target = {}} = error;
const {status, responseText} = target;
dispatch(loadRemoteResourceError({status, message: `${responseText} - ${LOADING_SAMPLE_ERROR_MESSAGE} ${options.id} (${configUrl})`}, configUrl));
}
}
);
}
} | javascript | function loadRemoteSampleMap(options) {
return (dispatch) => {
// Load configuration first
const {configUrl, dataUrl} = options;
Promise
.all([loadRemoteConfig(configUrl), loadRemoteData(dataUrl)])
.then(
([config, data]) => {
// TODO: these two actions can be merged
dispatch(loadRemoteResourceSuccess(data, config, options));
dispatch(toggleModal(null));
},
error => {
if (error) {
const {target = {}} = error;
const {status, responseText} = target;
dispatch(loadRemoteResourceError({status, message: `${responseText} - ${LOADING_SAMPLE_ERROR_MESSAGE} ${options.id} (${configUrl})`}, configUrl));
}
}
);
}
} | [
"function",
"loadRemoteSampleMap",
"(",
"options",
")",
"{",
"return",
"(",
"dispatch",
")",
"=>",
"{",
"// Load configuration first",
"const",
"{",
"configUrl",
",",
"dataUrl",
"}",
"=",
"options",
";",
"Promise",
".",
"all",
"(",
"[",
"loadRemoteConfig",
"("... | Load remote map with config and data
@param options {configUrl, dataUrl}
@returns {Function} | [
"Load",
"remote",
"map",
"with",
"config",
"and",
"data"
] | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/examples/demo-app/src/actions.js#L223-L245 | train | Load remote sample map | [
30522,
3853,
7170,
28578,
12184,
21559,
10814,
2863,
2361,
1006,
7047,
1007,
1063,
2709,
1006,
18365,
1007,
1027,
1028,
1063,
1013,
1013,
7170,
9563,
2034,
9530,
3367,
1063,
9530,
8873,
27390,
2140,
1010,
2951,
3126,
2140,
1065,
1027,
7047,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _onClick | function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
} | javascript | function _onClick(event) {
var $scope = $(event.delegateTarget).parent();
_openEditorForContext({
path: $scope.data("path"),
paneId: $scope.data("paneId"),
cursor: $scope.data("cursor"),
hideOnOpenFile: true
});
} | [
"function",
"_onClick",
"(",
"event",
")",
"{",
"var",
"$scope",
"=",
"$",
"(",
"event",
".",
"delegateTarget",
")",
".",
"parent",
"(",
")",
";",
"_openEditorForContext",
"(",
"{",
"path",
":",
"$scope",
".",
"data",
"(",
"\"path\"",
")",
",",
"paneId... | Click handler for the link in list item
@private | [
"Click",
"handler",
"for",
"the",
"link",
"in",
"list",
"item"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L427-L435 | train | Click event handler for the neccessary menu item | [
30522,
3853,
1035,
2006,
20464,
6799,
1006,
2724,
1007,
1063,
13075,
1002,
9531,
1027,
1002,
1006,
2724,
1012,
11849,
7559,
18150,
1007,
1012,
6687,
1006,
1007,
1025,
1035,
2441,
15660,
29278,
8663,
18209,
1006,
1063,
4130,
1024,
1002,
9531... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
markdown-it/markdown-it | lib/rules_core/smartquotes.js | replaceAt | function replaceAt(str, index, ch) {
return str.substr(0, index) + ch + str.substr(index + 1);
} | javascript | function replaceAt(str, index, ch) {
return str.substr(0, index) + ch + str.substr(index + 1);
} | [
"function",
"replaceAt",
"(",
"str",
",",
"index",
",",
"ch",
")",
"{",
"return",
"str",
".",
"substr",
"(",
"0",
",",
"index",
")",
"+",
"ch",
"+",
"str",
".",
"substr",
"(",
"index",
"+",
"1",
")",
";",
"}"
] | /* ’ | [
"/",
"*",
"’"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/rules_core/smartquotes.js#L15-L17 | train | Replace a character at a given index in a string | [
30522,
3853,
5672,
4017,
1006,
2358,
2099,
1010,
5950,
1010,
10381,
1007,
1063,
2709,
2358,
2099,
1012,
4942,
3367,
2099,
1006,
1014,
1010,
5950,
1007,
1009,
10381,
1009,
2358,
2099,
1012,
4942,
3367,
2099,
1006,
5950,
1009,
1015,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-compiler/language/javascript/RelayFlowBabelFactories.js | anyTypeAlias | function anyTypeAlias(name: string): BabelAST {
return t.typeAlias(t.identifier(name), null, t.anyTypeAnnotation());
} | javascript | function anyTypeAlias(name: string): BabelAST {
return t.typeAlias(t.identifier(name), null, t.anyTypeAnnotation());
} | [
"function",
"anyTypeAlias",
"(",
"name",
":",
"string",
")",
":",
"BabelAST",
"{",
"return",
"t",
".",
"typeAlias",
"(",
"t",
".",
"identifier",
"(",
"name",
")",
",",
"null",
",",
"t",
".",
"anyTypeAnnotation",
"(",
")",
")",
";",
"}"
] | type NAME = any; | [
"type",
"NAME",
"=",
"any",
";"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/language/javascript/RelayFlowBabelFactories.js#L21-L23 | train | A type alias for any type | [
30522,
3853,
2151,
13874,
22786,
2015,
1006,
2171,
1024,
5164,
1007,
1024,
11561,
8523,
2102,
1063,
2709,
1056,
1012,
2828,
22786,
2015,
1006,
1056,
1012,
8909,
4765,
18095,
1006,
2171,
1007,
1010,
19701,
1010,
1056,
1012,
2151,
13874,
1163... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function (color1, color2, weight) {
if (!weight) {
weight = new(tree.Dimension)(50);
}
var p = weight.value / 100.0;
var w = p * 2 - 1;
var a = color1.toHSL().a - color2.toHSL().a;
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = 1 - w1;
var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
color1.rgb[1] * w1 + color2.rgb[1] * w2,
color1.rgb[2] * w1 + color2.rgb[2] * w2];
var alpha = color1.alpha * p + color2.alpha * (1 - p);
return new(tree.Color)(rgb, alpha);
} | javascript | function (color1, color2, weight) {
if (!weight) {
weight = new(tree.Dimension)(50);
}
var p = weight.value / 100.0;
var w = p * 2 - 1;
var a = color1.toHSL().a - color2.toHSL().a;
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = 1 - w1;
var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
color1.rgb[1] * w1 + color2.rgb[1] * w2,
color1.rgb[2] * w1 + color2.rgb[2] * w2];
var alpha = color1.alpha * p + color2.alpha * (1 - p);
return new(tree.Color)(rgb, alpha);
} | [
"function",
"(",
"color1",
",",
"color2",
",",
"weight",
")",
"{",
"if",
"(",
"!",
"weight",
")",
"{",
"weight",
"=",
"new",
"(",
"tree",
".",
"Dimension",
")",
"(",
"50",
")",
";",
"}",
"var",
"p",
"=",
"weight",
".",
"value",
"/",
"100.0",
";... | Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein http://sass-lang.com | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2009",
"Hampton",
"Catlin",
"Nathan",
"Weizenbaum",
"and",
"Chris",
"Eppstein",
"http",
":",
"//",
"sass",
"-",
"lang",
".",
"com"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L2173-L2191 | train | Returns a new color | [
30522,
3853,
1006,
3609,
2487,
1010,
3609,
2475,
1010,
3635,
1007,
1063,
2065,
1006,
999,
3635,
1007,
1063,
3635,
1027,
2047,
1006,
3392,
30524,
1059,
1027,
1052,
1008,
1016,
1011,
1015,
1025,
13075,
1037,
1027,
3609,
2487,
1012,
2000,
78... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | examples/raster.js | vgi | function vgi(pixel) {
const r = pixel[0] / 255;
const g = pixel[1] / 255;
const b = pixel[2] / 255;
return (2 * g - r - b) / (2 * g + r + b);
} | javascript | function vgi(pixel) {
const r = pixel[0] / 255;
const g = pixel[1] / 255;
const b = pixel[2] / 255;
return (2 * g - r - b) / (2 * g + r + b);
} | [
"function",
"vgi",
"(",
"pixel",
")",
"{",
"const",
"r",
"=",
"pixel",
"[",
"0",
"]",
"/",
"255",
";",
"const",
"g",
"=",
"pixel",
"[",
"1",
"]",
"/",
"255",
";",
"const",
"b",
"=",
"pixel",
"[",
"2",
"]",
"/",
"255",
";",
"return",
"(",
"2... | Calculate the Vegetation Greenness Index (VGI) from an input pixel. This
is a rough estimate assuming that pixel values correspond to reflectance.
@param {Array<number>} pixel An array of [R, G, B, A] values.
@return {number} The VGI value for the given pixel. | [
"Calculate",
"the",
"Vegetation",
"Greenness",
"Index",
"(",
"VGI",
")",
"from",
"an",
"input",
"pixel",
".",
"This",
"is",
"a",
"rough",
"estimate",
"assuming",
"that",
"pixel",
"values",
"correspond",
"to",
"reflectance",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/raster.js#L18-L23 | train | Calculate the vgi color | [
30522,
3853,
1058,
5856,
1006,
22138,
1007,
1063,
9530,
3367,
1054,
1027,
22138,
1031,
1014,
1033,
1013,
20637,
1025,
9530,
3367,
1043,
1027,
22138,
1031,
1015,
1033,
1013,
20637,
1025,
9530,
3367,
1038,
1027,
22138,
1031,
1016,
1033,
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... |
Freeboard/freeboard | js/freeboard.thirdparty.js | Draggable | function Draggable(el, options)
{
this.options = $.extend({}, defaults, options);
this.$body = $(document.body);
this.$container = $(el);
this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
this.player_min_left = 0 + this.options.offset_left;
this.init();
} | javascript | function Draggable(el, options)
{
this.options = $.extend({}, defaults, options);
this.$body = $(document.body);
this.$container = $(el);
this.$dragitems = $(this.options.items, this.$container);
this.is_dragging = false;
this.player_min_left = 0 + this.options.offset_left;
this.init();
} | [
"function",
"Draggable",
"(",
"el",
",",
"options",
")",
"{",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"defaults",
",",
"options",
")",
";",
"this",
".",
"$body",
"=",
"$",
"(",
"document",
".",
"body",
")",
";",
"this... | Basic drag implementation for DOM elements inside a container.
Provide start/stop/drag callbacks.
@class Draggable
@param {HTMLElement} el The HTMLelement that contains all the panes
to be dragged.
@param {Object} [options] An Object with all options you want to
overwrite:
@param {HTMLElement|String} [options.items] Define who will
be the draggable items. Can be a CSS Selector String or a
collection of HTMLElements.
@param {Number} [options.distance] Distance in pixels after mousedown
the mouse must move before dragging should start.
@param {Boolean} [options.limit] Constrains dragging to the width of
the container
@param {offset_left} [options.offset_left] Offset added to the item
that is being dragged.
@param {Number} [options.drag] Executes a callback when the mouse is
moved during the dragging.
@param {Number} [options.start] Executes a callback when the drag
starts.
@param {Number} [options.stop] Executes a callback when the drag stops.
@return {Object} Returns `el`.
@constructor | [
"Basic",
"drag",
"implementation",
"for",
"DOM",
"elements",
"inside",
"a",
"container",
".",
"Provide",
"start",
"/",
"stop",
"/",
"drag",
"callbacks",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L15597-L15606 | train | Draggable constructor. | [
30522,
3853,
8011,
3654,
3468,
1006,
3449,
1010,
7047,
1007,
1063,
2023,
1012,
7047,
1027,
1002,
1012,
7949,
1006,
1063,
1065,
1010,
12398,
2015,
1010,
7047,
1007,
1025,
2023,
1012,
1002,
2303,
1027,
1002,
1006,
6254,
1012,
2303,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/documents/LiveCSSDocument.js | makeUrlsRelativeToCss | function makeUrlsRelativeToCss(match, quotationMark, url) {
if (PathUtils.isRelativeUrl(url)) {
var absUrl = PathUtils.makeUrlAbsolute(url, docUrl);
return "url(" + quotationMark + absUrl + quotationMark + ")";
}
return match;
} | javascript | function makeUrlsRelativeToCss(match, quotationMark, url) {
if (PathUtils.isRelativeUrl(url)) {
var absUrl = PathUtils.makeUrlAbsolute(url, docUrl);
return "url(" + quotationMark + absUrl + quotationMark + ")";
}
return match;
} | [
"function",
"makeUrlsRelativeToCss",
"(",
"match",
",",
"quotationMark",
",",
"url",
")",
"{",
"if",
"(",
"PathUtils",
".",
"isRelativeUrl",
"(",
"url",
")",
")",
"{",
"var",
"absUrl",
"=",
"PathUtils",
".",
"makeUrlAbsolute",
"(",
"url",
",",
"docUrl",
")... | Determines whether an url() line contains a relative or absolute URL, and makes the URL absolute to the CSS file if it is relative | [
"Determines",
"whether",
"an",
"url",
"()",
"line",
"contains",
"a",
"relative",
"or",
"absolute",
"URL",
"and",
"makes",
"the",
"URL",
"absolute",
"to",
"the",
"CSS",
"file",
"if",
"it",
"is",
"relative"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/documents/LiveCSSDocument.js#L104-L110 | train | makeUrlsRelativeToCss - make urls relative to css | [
30522,
3853,
2191,
3126,
4877,
16570,
8082,
3406,
6169,
2015,
1006,
2674,
1010,
20563,
3508,
10665,
1010,
24471,
2140,
1007,
1063,
2065,
1006,
4130,
21823,
4877,
1012,
2003,
16570,
8082,
3126,
2140,
1006,
24471,
2140,
1007,
1007,
1063,
1307... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/base/security/URLWhitelist.js | URLWhitelistEntry | function URLWhitelistEntry(protocol, host, port, path){
if (protocol) {
this.protocol = protocol.toUpperCase();
}
if (host) {
this.host = host.toUpperCase();
}
this.port = port;
this.path = path;
} | javascript | function URLWhitelistEntry(protocol, host, port, path){
if (protocol) {
this.protocol = protocol.toUpperCase();
}
if (host) {
this.host = host.toUpperCase();
}
this.port = port;
this.path = path;
} | [
"function",
"URLWhitelistEntry",
"(",
"protocol",
",",
"host",
",",
"port",
",",
"path",
")",
"{",
"if",
"(",
"protocol",
")",
"{",
"this",
".",
"protocol",
"=",
"protocol",
".",
"toUpperCase",
"(",
")",
";",
"}",
"if",
"(",
"host",
")",
"{",
"this",... | Entry object of the URLWhitelist
@public
@typedef {object} module:sap/base/security/URLWhitelist.Entry
@property {string} protocol The protocol of the URL
@property {string} host The host of the URL
@property {string} port The port of the URL
@property {string} path the path of the URL | [
"Entry",
"object",
"of",
"the",
"URLWhitelist"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/security/URLWhitelist.js#L28-L37 | train | URLWhitelistEntry constructor | [
30522,
3853,
24471,
2140,
2860,
16584,
29282,
6528,
11129,
1006,
8778,
1010,
3677,
1010,
3417,
1010,
4130,
1007,
1063,
2065,
1006,
8778,
1007,
1063,
2023,
1012,
8778,
1027,
8778,
1012,
2000,
29547,
18992,
3366,
1006,
1007,
1025,
1065,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/keyword-spacing.js | checkSpacingForForOfStatement | function checkSpacingForForOfStatement(node) {
if (node.await) {
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
} else {
checkSpacingAroundFirstToken(node);
}
checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
} | javascript | function checkSpacingForForOfStatement(node) {
if (node.await) {
checkSpacingBefore(sourceCode.getFirstToken(node, 0));
checkSpacingAfter(sourceCode.getFirstToken(node, 1));
} else {
checkSpacingAroundFirstToken(node);
}
checkSpacingAround(sourceCode.getTokenBefore(node.right, astUtils.isNotOpeningParenToken));
} | [
"function",
"checkSpacingForForOfStatement",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"await",
")",
"{",
"checkSpacingBefore",
"(",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"0",
")",
")",
";",
"checkSpacingAfter",
"(",
"sourceCode",
".",
"... | Reports `for` and `of` keywords of a given node if usage of spacing
around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"for",
"and",
"of",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L434-L442 | train | Check spacing around for of statement | [
30522,
3853,
14148,
19498,
2075,
29278,
29278,
11253,
9153,
18532,
4765,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
26751,
1007,
1063,
14148,
19498,
2075,
4783,
29278,
2063,
1006,
3120,
16044,
1012,
2131,
8873,
12096,
18715,
2368,
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... |
parcel-bundler/parcel | packages/core/parcel-bundler/src/transforms/babel/babelrc.js | getBabelRc | async function getBabelRc(asset, isSource) {
// Support legacy browserify packages
let pkg = await asset.getPackage();
let browserify = pkg && pkg.browserify;
if (browserify && Array.isArray(browserify.transform)) {
// Look for babelify in the browserify transform list
let babelify = browserify.transform.find(
t => (Array.isArray(t) ? t[0] : t) === 'babelify'
);
// If specified as an array, override the config with the one specified
if (Array.isArray(babelify) && babelify[1]) {
return babelify[1];
}
// Otherwise, return the .babelrc if babelify was found
return babelify ? findBabelRc(asset) : null;
}
// If this asset is not in node_modules, always use the .babelrc
if (isSource) {
return findBabelRc(asset);
}
// Otherwise, don't load .babelrc for node_modules.
// See https://github.com/parcel-bundler/parcel/issues/13.
return null;
} | javascript | async function getBabelRc(asset, isSource) {
// Support legacy browserify packages
let pkg = await asset.getPackage();
let browserify = pkg && pkg.browserify;
if (browserify && Array.isArray(browserify.transform)) {
// Look for babelify in the browserify transform list
let babelify = browserify.transform.find(
t => (Array.isArray(t) ? t[0] : t) === 'babelify'
);
// If specified as an array, override the config with the one specified
if (Array.isArray(babelify) && babelify[1]) {
return babelify[1];
}
// Otherwise, return the .babelrc if babelify was found
return babelify ? findBabelRc(asset) : null;
}
// If this asset is not in node_modules, always use the .babelrc
if (isSource) {
return findBabelRc(asset);
}
// Otherwise, don't load .babelrc for node_modules.
// See https://github.com/parcel-bundler/parcel/issues/13.
return null;
} | [
"async",
"function",
"getBabelRc",
"(",
"asset",
",",
"isSource",
")",
"{",
"// Support legacy browserify packages",
"let",
"pkg",
"=",
"await",
"asset",
".",
"getPackage",
"(",
")",
";",
"let",
"browserify",
"=",
"pkg",
"&&",
"pkg",
".",
"browserify",
";",
... | Finds a .babelrc for an asset. By default, .babelrc files inside node_modules are not used.
However, there are some exceptions:
- if `browserify.transforms` includes "babelify" in package.json (for legacy module compat)
- the `source` field in package.json is used by the resolver | [
"Finds",
"a",
".",
"babelrc",
"for",
"an",
"asset",
".",
"By",
"default",
".",
"babelrc",
"files",
"inside",
"node_modules",
"are",
"not",
"used",
".",
"However",
"there",
"are",
"some",
"exceptions",
":",
"-",
"if",
"browserify",
".",
"transforms",
"inclu... | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/transforms/babel/babelrc.js#L40-L67 | train | Get the. babelrc from the asset | [
30522,
2004,
6038,
2278,
3853,
2131,
3676,
8671,
11890,
1006,
11412,
1010,
26354,
8162,
3401,
1007,
1063,
1013,
1013,
2490,
8027,
16602,
8757,
14555,
2292,
1052,
2243,
2290,
1027,
26751,
11412,
1012,
2131,
23947,
4270,
1006,
1007,
1025,
229... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
transloadit/uppy | website/themes/uppy/source/js/common.js | updateSidebar | function updateSidebar () {
var top = (doc && doc.scrollTop) || body.scrollTop
var headerHeight = header.offsetHeight
if (top > (headerHeight - 25)) {
// main.classList.add('fix-sidebar')
header.classList.add('fix-header')
} else {
// main.classList.remove('fix-sidebar')
header.classList.remove('fix-header')
}
if (animating || !allLinks) return
var last
for (var i = 0; i < allLinks.length; i++) {
var link = allLinks[i]
if (link.offsetTop > top) {
if (!last) last = link
break
} else {
last = link
}
}
if (last) {
setActive(last.id)
}
} | javascript | function updateSidebar () {
var top = (doc && doc.scrollTop) || body.scrollTop
var headerHeight = header.offsetHeight
if (top > (headerHeight - 25)) {
// main.classList.add('fix-sidebar')
header.classList.add('fix-header')
} else {
// main.classList.remove('fix-sidebar')
header.classList.remove('fix-header')
}
if (animating || !allLinks) return
var last
for (var i = 0; i < allLinks.length; i++) {
var link = allLinks[i]
if (link.offsetTop > top) {
if (!last) last = link
break
} else {
last = link
}
}
if (last) {
setActive(last.id)
}
} | [
"function",
"updateSidebar",
"(",
")",
"{",
"var",
"top",
"=",
"(",
"doc",
"&&",
"doc",
".",
"scrollTop",
")",
"||",
"body",
".",
"scrollTop",
"var",
"headerHeight",
"=",
"header",
".",
"offsetHeight",
"if",
"(",
"top",
">",
"(",
"headerHeight",
"-",
"... | // listen for scroll event to do positioning & highlights window.addEventListener('scroll', updateSidebar) window.addEventListener('resize', updateSidebar) | [
"//",
"listen",
"for",
"scroll",
"event",
"to",
"do",
"positioning",
"&",
"highlights",
"window",
".",
"addEventListener",
"(",
"scroll",
"updateSidebar",
")",
"window",
".",
"addEventListener",
"(",
"resize",
"updateSidebar",
")"
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/website/themes/uppy/source/js/common.js#L30-L54 | train | Update sidebar | [
30522,
3853,
14409,
5178,
8237,
1006,
1007,
1063,
13075,
2327,
1027,
1006,
9986,
1004,
1004,
9986,
1012,
17186,
14399,
1007,
1064,
1064,
2303,
1012,
17186,
14399,
13075,
20346,
26036,
13900,
1027,
20346,
1012,
16396,
26036,
13900,
2065,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | templateIf | function templateIf(oIfElement, oWithControl) {
iNestingLevel++;
return stopAndGo(getIfChildren(oIfElement) || [oIfElement], function (oCandidate) {
if (oCandidate.localName === "else") {
return oSyncPromiseResolvedTrue;
}
if (oCandidate.localName === "then") {
oCandidate = oIfElement;
}
return performTest(oCandidate, oWithControl);
}).then(function (oSelectedElement) {
// the selected element: <if>, <then>, <elseif>, <else>, or none at all
return (oSelectedElement
? liftChildNodes(oSelectedElement, oWithControl, oIfElement)
: oSyncPromiseResolved
).then(function () {
oIfElement.parentNode.removeChild(oIfElement);
debugFinished(oIfElement);
iNestingLevel -= 1;
});
});
} | javascript | function templateIf(oIfElement, oWithControl) {
iNestingLevel++;
return stopAndGo(getIfChildren(oIfElement) || [oIfElement], function (oCandidate) {
if (oCandidate.localName === "else") {
return oSyncPromiseResolvedTrue;
}
if (oCandidate.localName === "then") {
oCandidate = oIfElement;
}
return performTest(oCandidate, oWithControl);
}).then(function (oSelectedElement) {
// the selected element: <if>, <then>, <elseif>, <else>, or none at all
return (oSelectedElement
? liftChildNodes(oSelectedElement, oWithControl, oIfElement)
: oSyncPromiseResolved
).then(function () {
oIfElement.parentNode.removeChild(oIfElement);
debugFinished(oIfElement);
iNestingLevel -= 1;
});
});
} | [
"function",
"templateIf",
"(",
"oIfElement",
",",
"oWithControl",
")",
"{",
"iNestingLevel",
"++",
";",
"return",
"stopAndGo",
"(",
"getIfChildren",
"(",
"oIfElement",
")",
"||",
"[",
"oIfElement",
"]",
",",
"function",
"(",
"oCandidate",
")",
"{",
"if",
"("... | Processes a <template:if> instruction.
@param {Element} oIfElement
the <template:if> XML DOM element
@param {sap.ui.core.util._with} oWithControl
the "with" control
@returns {sap.ui.base.SyncPromise}
A sync promise which resolves with <code>undefined</code> as soon as the
<template:if> instruction has been fully processed, or is rejected with a
corresponding error if visiting child nodes fails. | [
"Processes",
"a",
"<template",
":",
"if",
">",
"instruction",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L1499-L1520 | train | templateIf - If - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else - If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - Else If - | [
30522,
3853,
23561,
10128,
1006,
1051,
29323,
16930,
4765,
1010,
27593,
8939,
8663,
13181,
2140,
1007,
1063,
1999,
4355,
2075,
20414,
2884,
1009,
1009,
1025,
2709,
2644,
5685,
3995,
1006,
2131,
10128,
19339,
7389,
1006,
1051,
29323,
16930,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/commons/color/get-background-color.js | calculateObscuringAlpha | function calculateObscuringAlpha(elmIndex, elmStack, originalElm) {
var totalAlpha = 0;
if (elmIndex > 0) {
// there are elements above our element, check if they contribute to the background
for (var i = elmIndex - 1; i >= 0; i--) {
let bgElm = elmStack[i];
let bgElmStyle = window.getComputedStyle(bgElm);
let bgColor = color.getOwnBackgroundColor(bgElmStyle);
if (bgColor.alpha && contentOverlapping(originalElm, bgElm)) {
totalAlpha += bgColor.alpha;
} else {
// remove elements not contributing to the background
elmStack.splice(i, 1);
}
}
}
return totalAlpha;
} | javascript | function calculateObscuringAlpha(elmIndex, elmStack, originalElm) {
var totalAlpha = 0;
if (elmIndex > 0) {
// there are elements above our element, check if they contribute to the background
for (var i = elmIndex - 1; i >= 0; i--) {
let bgElm = elmStack[i];
let bgElmStyle = window.getComputedStyle(bgElm);
let bgColor = color.getOwnBackgroundColor(bgElmStyle);
if (bgColor.alpha && contentOverlapping(originalElm, bgElm)) {
totalAlpha += bgColor.alpha;
} else {
// remove elements not contributing to the background
elmStack.splice(i, 1);
}
}
}
return totalAlpha;
} | [
"function",
"calculateObscuringAlpha",
"(",
"elmIndex",
",",
"elmStack",
",",
"originalElm",
")",
"{",
"var",
"totalAlpha",
"=",
"0",
";",
"if",
"(",
"elmIndex",
">",
"0",
")",
"{",
"// there are elements above our element, check if they contribute to the background",
"... | Calculate alpha transparency of a background element obscuring the current node
@private
@param {Number} elmIndex
@param {Array} elmStack
@param {Element} originalElm
@return {Number|undefined} | [
"Calculate",
"alpha",
"transparency",
"of",
"a",
"background",
"element",
"obscuring",
"the",
"current",
"node"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/commons/color/get-background-color.js#L311-L329 | train | Calculate the alpha value of an element | [
30522,
3853,
18422,
16429,
28817,
4892,
2389,
21890,
1006,
17709,
22254,
10288,
1010,
17709,
9153,
3600,
1010,
2434,
2884,
2213,
1007,
1063,
13075,
2561,
2389,
21890,
1027,
1014,
1025,
2065,
1006,
17709,
22254,
10288,
1028,
1014,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.