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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/localization.js | filterCroppedNodes | function filterCroppedNodes(node) {
if (!node.boxObject) {
return domUtils.DOMWalker.FILTER_SKIP;
} else {
if (!node.disabled && !node.collapsed && !node.hidden) {
// Code specific to the preferences panes to reject out not visible nodes
// in the panes.
if (node.parentNode && (node.parentNode.localName == "prefwindow" &&
node.parentNode.currentPane.id != node.id) ||
((node.parentNode.localName == "tabpanels" ||
node.parentNode.localName == "deck") &&
node.parentNode.selectedPanel.id != node.id)) {
return domUtils.DOMWalker.FILTER_REJECT;
// end of the specific code
} else {
return domUtils.DOMWalker.FILTER_ACCEPT;
}
} else {
// we don't want to test not visible elements
return domUtils.DOMWalker.FILTER_REJECT;
}
}
} | javascript | function filterCroppedNodes(node) {
if (!node.boxObject) {
return domUtils.DOMWalker.FILTER_SKIP;
} else {
if (!node.disabled && !node.collapsed && !node.hidden) {
// Code specific to the preferences panes to reject out not visible nodes
// in the panes.
if (node.parentNode && (node.parentNode.localName == "prefwindow" &&
node.parentNode.currentPane.id != node.id) ||
((node.parentNode.localName == "tabpanels" ||
node.parentNode.localName == "deck") &&
node.parentNode.selectedPanel.id != node.id)) {
return domUtils.DOMWalker.FILTER_REJECT;
// end of the specific code
} else {
return domUtils.DOMWalker.FILTER_ACCEPT;
}
} else {
// we don't want to test not visible elements
return domUtils.DOMWalker.FILTER_REJECT;
}
}
} | [
"function",
"filterCroppedNodes",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"boxObject",
")",
"{",
"return",
"domUtils",
".",
"DOMWalker",
".",
"FILTER_SKIP",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"node",
".",
"disabled",
"&&",
"!",
"node",
... | Filters out nodes which should not be tested because they are not visible
@param {node} node
@returns Filter status of the given node
@type {array of array of int} | [
"Filters",
"out",
"nodes",
"which",
"should",
"not",
"be",
"tested",
"because",
"they",
"are",
"not",
"visible"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L224-L246 | train | filterCroppedNodes - filter out nodes that are not visible in the preferences panes | [
30522,
3853,
11307,
26775,
27288,
3630,
6155,
1006,
13045,
1007,
1063,
2065,
1006,
999,
13045,
1012,
3482,
16429,
20614,
30524,
1012,
9776,
1004,
1004,
999,
13045,
1012,
7798,
1004,
1004,
999,
13045,
1012,
5023,
1007,
1063,
1013,
1013,
3642... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pagekit/vue-resource | dist/vue-resource.esm.js | Client | function Client (context) {
var reqHandlers = [sendRequest], resHandlers = [];
if (!isObject(context)) {
context = null;
}
function Client(request) {
while (reqHandlers.length) {
var handler = reqHandlers.pop();
if (isFunction(handler)) {
var response = (void 0), next = (void 0);
response = handler.call(context, request, function (val) { return next = val; }) || next;
if (isObject(response)) {
return new PromiseObj(function (resolve, reject) {
resHandlers.forEach(function (handler) {
response = when(response, function (response) {
return handler.call(context, response) || response;
}, reject);
});
when(response, resolve, reject);
}, context);
}
if (isFunction(response)) {
resHandlers.unshift(response);
}
} else {
warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
}
}
}
Client.use = function (handler) {
reqHandlers.push(handler);
};
return Client;
} | javascript | function Client (context) {
var reqHandlers = [sendRequest], resHandlers = [];
if (!isObject(context)) {
context = null;
}
function Client(request) {
while (reqHandlers.length) {
var handler = reqHandlers.pop();
if (isFunction(handler)) {
var response = (void 0), next = (void 0);
response = handler.call(context, request, function (val) { return next = val; }) || next;
if (isObject(response)) {
return new PromiseObj(function (resolve, reject) {
resHandlers.forEach(function (handler) {
response = when(response, function (response) {
return handler.call(context, response) || response;
}, reject);
});
when(response, resolve, reject);
}, context);
}
if (isFunction(response)) {
resHandlers.unshift(response);
}
} else {
warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
}
}
}
Client.use = function (handler) {
reqHandlers.push(handler);
};
return Client;
} | [
"function",
"Client",
"(",
"context",
")",
"{",
"var",
"reqHandlers",
"=",
"[",
"sendRequest",
"]",
",",
"resHandlers",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"isObject",
"(",
"context",
")",
")",
"{",
"context",
"=",
"null",
";",
"}",
"function",
"Clie... | Base client. | [
"Base",
"client",
"."
] | fe268fa1d6053ede5f34aef9a11e1a424a70446c | https://github.com/pagekit/vue-resource/blob/fe268fa1d6053ede5f34aef9a11e1a424a70446c/dist/vue-resource.esm.js#L1126-L1174 | train | A client that can be used to send requests to the server | [
30522,
3853,
7396,
1006,
6123,
1007,
1063,
13075,
2128,
4160,
11774,
12910,
1027,
1031,
4604,
2890,
15500,
1033,
1010,
24501,
11774,
12910,
1027,
1031,
1033,
1025,
2065,
1006,
999,
11163,
2497,
20614,
1006,
6123,
1007,
1007,
1063,
6123,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | addConnectedEdges | function addConnectedEdges(node) {
var edges = node._private.edges;
for (var i = 0; i < edges.length; i++) {
add(edges[i]);
}
} | javascript | function addConnectedEdges(node) {
var edges = node._private.edges;
for (var i = 0; i < edges.length; i++) {
add(edges[i]);
}
} | [
"function",
"addConnectedEdges",
"(",
"node",
")",
"{",
"var",
"edges",
"=",
"node",
".",
"_private",
".",
"edges",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"edges",
".",
"length",
";",
"i",
"++",
")",
"{",
"add",
"(",
"edges",
"[",
... | add connected edges | [
"add",
"connected",
"edges"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L12352-L12358 | train | Add connected edges to the node | [
30522,
3853,
5587,
24230,
24225,
2015,
1006,
13045,
1007,
1063,
13075,
7926,
1027,
13045,
1012,
1035,
2797,
1012,
7926,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
7926,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
5587,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CodeInspection.js | inspectFile | function inspectFile(file, providerList) {
var response = new $.Deferred(),
results = [];
providerList = providerList || getProvidersForPath(file.fullPath);
if (!providerList.length) {
response.resolve(null);
return response.promise();
}
DocumentManager.getDocumentText(file)
.done(function (fileText) {
var perfTimerInspector = PerfUtils.markStart("CodeInspection:\t" + file.fullPath),
masterPromise;
masterPromise = Async.doInParallel(providerList, function (provider) {
var perfTimerProvider = PerfUtils.markStart("CodeInspection '" + provider.name + "':\t" + file.fullPath),
runPromise = new $.Deferred();
runPromise.done(function (scanResult) {
results.push({provider: provider, result: scanResult});
});
if (provider.scanFileAsync) {
window.setTimeout(function () {
// timeout error
var errTimeout = {
pos: { line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_TIMED_OUT, provider.name, prefs.get(PREF_ASYNC_TIMEOUT)),
type: Type.ERROR
};
runPromise.resolve({errors: [errTimeout]});
}, prefs.get(PREF_ASYNC_TIMEOUT));
provider.scanFileAsync(fileText, file.fullPath)
.done(function (scanResult) {
PerfUtils.addMeasurement(perfTimerProvider);
runPromise.resolve(scanResult);
})
.fail(function (err) {
PerfUtils.finalizeMeasurement(perfTimerProvider);
var errError = {
pos: {line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_FAILED, provider.name, err),
type: Type.ERROR
};
console.error("[CodeInspection] Provider " + provider.name + " (async) failed: " + err);
runPromise.resolve({errors: [errError]});
});
} else {
try {
var scanResult = provider.scanFile(fileText, file.fullPath);
PerfUtils.addMeasurement(perfTimerProvider);
runPromise.resolve(scanResult);
} catch (err) {
PerfUtils.finalizeMeasurement(perfTimerProvider);
var errError = {
pos: {line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_FAILED, provider.name, err),
type: Type.ERROR
};
console.error("[CodeInspection] Provider " + provider.name + " (sync) threw an error: " + err);
runPromise.resolve({errors: [errError]});
}
}
return runPromise.promise();
}, false);
masterPromise.then(function () {
// sync async may have pushed results in different order, restore the original order
results.sort(function (a, b) {
return providerList.indexOf(a.provider) - providerList.indexOf(b.provider);
});
PerfUtils.addMeasurement(perfTimerInspector);
response.resolve(results);
});
})
.fail(function (err) {
console.error("[CodeInspection] Could not read file for inspection: " + file.fullPath);
response.reject(err);
});
return response.promise();
} | javascript | function inspectFile(file, providerList) {
var response = new $.Deferred(),
results = [];
providerList = providerList || getProvidersForPath(file.fullPath);
if (!providerList.length) {
response.resolve(null);
return response.promise();
}
DocumentManager.getDocumentText(file)
.done(function (fileText) {
var perfTimerInspector = PerfUtils.markStart("CodeInspection:\t" + file.fullPath),
masterPromise;
masterPromise = Async.doInParallel(providerList, function (provider) {
var perfTimerProvider = PerfUtils.markStart("CodeInspection '" + provider.name + "':\t" + file.fullPath),
runPromise = new $.Deferred();
runPromise.done(function (scanResult) {
results.push({provider: provider, result: scanResult});
});
if (provider.scanFileAsync) {
window.setTimeout(function () {
// timeout error
var errTimeout = {
pos: { line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_TIMED_OUT, provider.name, prefs.get(PREF_ASYNC_TIMEOUT)),
type: Type.ERROR
};
runPromise.resolve({errors: [errTimeout]});
}, prefs.get(PREF_ASYNC_TIMEOUT));
provider.scanFileAsync(fileText, file.fullPath)
.done(function (scanResult) {
PerfUtils.addMeasurement(perfTimerProvider);
runPromise.resolve(scanResult);
})
.fail(function (err) {
PerfUtils.finalizeMeasurement(perfTimerProvider);
var errError = {
pos: {line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_FAILED, provider.name, err),
type: Type.ERROR
};
console.error("[CodeInspection] Provider " + provider.name + " (async) failed: " + err);
runPromise.resolve({errors: [errError]});
});
} else {
try {
var scanResult = provider.scanFile(fileText, file.fullPath);
PerfUtils.addMeasurement(perfTimerProvider);
runPromise.resolve(scanResult);
} catch (err) {
PerfUtils.finalizeMeasurement(perfTimerProvider);
var errError = {
pos: {line: -1, col: 0},
message: StringUtils.format(Strings.LINTER_FAILED, provider.name, err),
type: Type.ERROR
};
console.error("[CodeInspection] Provider " + provider.name + " (sync) threw an error: " + err);
runPromise.resolve({errors: [errError]});
}
}
return runPromise.promise();
}, false);
masterPromise.then(function () {
// sync async may have pushed results in different order, restore the original order
results.sort(function (a, b) {
return providerList.indexOf(a.provider) - providerList.indexOf(b.provider);
});
PerfUtils.addMeasurement(perfTimerInspector);
response.resolve(results);
});
})
.fail(function (err) {
console.error("[CodeInspection] Could not read file for inspection: " + file.fullPath);
response.reject(err);
});
return response.promise();
} | [
"function",
"inspectFile",
"(",
"file",
",",
"providerList",
")",
"{",
"var",
"response",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"results",
"=",
"[",
"]",
";",
"providerList",
"=",
"providerList",
"||",
"getProvidersForPath",
"(",
"file",
".",
... | Runs a file inspection over passed file. Uses the given list of providers if specified, otherwise uses
the set of providers that are registered for the file's language.
This method doesn't update the Brackets UI, just provides inspection results.
These results will reflect any unsaved changes present in the file if currently open.
The Promise yields an array of provider-result pair objects (the result is the return value of the
provider's scanFile() - see register() for details). The result object may be null if there were no
errors from that provider.
If there are no providers registered for this file, the Promise yields null instead.
@param {!File} file File that will be inspected for errors.
@param {?Array.<{name:string, scanFileAsync:?function(string, string):!{$.Promise}, scanFile:?function(string, string):?{errors:!Array, aborted:boolean}}>} providerList
@return {$.Promise} a jQuery promise that will be resolved with ?Array.<{provider:Object, result: ?{errors:!Array, aborted:boolean}}> | [
"Runs",
"a",
"file",
"inspection",
"over",
"passed",
"file",
".",
"Uses",
"the",
"given",
"list",
"of",
"providers",
"if",
"specified",
"otherwise",
"uses",
"the",
"set",
"of",
"providers",
"that",
"are",
"registered",
"for",
"the",
"file",
"s",
"language",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L220-L305 | train | Inspects a file using a list of providers | [
30522,
3853,
22459,
8873,
2571,
1006,
5371,
1010,
10802,
9863,
1007,
1063,
13075,
3433,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
3463,
1027,
1031,
1033,
1025,
10802,
9863,
1027,
10802,
9863,
1064,
1064,
2131,
21572,
172... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
lovell/sharp | lib/output.js | toFile | function toFile (fileOut, callback) {
if (!fileOut || fileOut.length === 0) {
const errOutputInvalid = new Error('Missing output file path');
if (is.fn(callback)) {
callback(errOutputInvalid);
} else {
return Promise.reject(errOutputInvalid);
}
} else {
if (this.options.input.file === fileOut) {
const errOutputIsInput = new Error('Cannot use same file for input and output');
if (is.fn(callback)) {
callback(errOutputIsInput);
} else {
return Promise.reject(errOutputIsInput);
}
} else {
this.options.fileOut = fileOut;
return this._pipeline(callback);
}
}
return this;
} | javascript | function toFile (fileOut, callback) {
if (!fileOut || fileOut.length === 0) {
const errOutputInvalid = new Error('Missing output file path');
if (is.fn(callback)) {
callback(errOutputInvalid);
} else {
return Promise.reject(errOutputInvalid);
}
} else {
if (this.options.input.file === fileOut) {
const errOutputIsInput = new Error('Cannot use same file for input and output');
if (is.fn(callback)) {
callback(errOutputIsInput);
} else {
return Promise.reject(errOutputIsInput);
}
} else {
this.options.fileOut = fileOut;
return this._pipeline(callback);
}
}
return this;
} | [
"function",
"toFile",
"(",
"fileOut",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"fileOut",
"||",
"fileOut",
".",
"length",
"===",
"0",
")",
"{",
"const",
"errOutputInvalid",
"=",
"new",
"Error",
"(",
"'Missing output file path'",
")",
";",
"if",
"(",
"i... | Write output image data to a file.
If an explicit output format is not selected, it will be inferred from the extension,
with JPEG, PNG, WebP, TIFF, DZI, and libvips' V format supported.
Note that raw pixel data is only supported for buffer output.
A `Promise` is returned when `callback` is not provided.
@example
sharp(input)
.toFile('output.png', (err, info) => { ... });
@example
sharp(input)
.toFile('output.png')
.then(info => { ... })
.catch(err => { ... });
@param {String} fileOut - the path to write the image data to.
@param {Function} [callback] - called on completion with two arguments `(err, info)`.
`info` contains the output image `format`, `size` (bytes), `width`, `height`,
`channels` and `premultiplied` (indicating if premultiplication was used).
When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.
@returns {Promise<Object>} - when no callback is provided
@throws {Error} Invalid parameters | [
"Write",
"output",
"image",
"data",
"to",
"a",
"file",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/output.js#L33-L55 | train | Create a new file in the current project | [
30522,
3853,
2000,
8873,
2571,
1006,
5371,
5833,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
999,
5371,
5833,
1064,
1064,
5371,
5833,
1012,
3091,
1027,
1027,
1027,
1014,
1007,
1063,
9530,
3367,
9413,
22494,
25856,
21823,
2078,
10175,
3593,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ccxt/ccxt | build/transpile.js | transpileDerivedExchangeFile | function transpileDerivedExchangeFile (folder, filename) {
try {
let contents = fs.readFileSync (folder + filename, 'utf8')
let { python2, python3, php, className, baseClass } = transpileDerivedExchangeClass (contents)
const python2Filename = python2Folder + filename.replace ('.js', '.py')
const python3Filename = python3Folder + filename.replace ('.js', '.py')
const phpFilename = phpFolder + filename.replace ('.js', '.php')
log.cyan ('Transpiling from', filename.yellow)
overwriteFile (python2Filename, python2)
overwriteFile (python3Filename, python3)
overwriteFile (phpFilename, php)
return { className, baseClass }
} catch (e) {
log.red ('\nFailed to transpile source code from', filename.yellow)
log.red ('See https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md on how to build this library properly\n')
throw e // rethrow it
}
} | javascript | function transpileDerivedExchangeFile (folder, filename) {
try {
let contents = fs.readFileSync (folder + filename, 'utf8')
let { python2, python3, php, className, baseClass } = transpileDerivedExchangeClass (contents)
const python2Filename = python2Folder + filename.replace ('.js', '.py')
const python3Filename = python3Folder + filename.replace ('.js', '.py')
const phpFilename = phpFolder + filename.replace ('.js', '.php')
log.cyan ('Transpiling from', filename.yellow)
overwriteFile (python2Filename, python2)
overwriteFile (python3Filename, python3)
overwriteFile (phpFilename, php)
return { className, baseClass }
} catch (e) {
log.red ('\nFailed to transpile source code from', filename.yellow)
log.red ('See https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md on how to build this library properly\n')
throw e // rethrow it
}
} | [
"function",
"transpileDerivedExchangeFile",
"(",
"folder",
",",
"filename",
")",
"{",
"try",
"{",
"let",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"folder",
"+",
"filename",
",",
"'utf8'",
")",
"let",
"{",
"python2",
",",
"python3",
",",
"php",
",",... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/build/transpile.js#L698-L724 | train | transpiles a file from a folder | [
30522,
3853,
9099,
22090,
4063,
3512,
3207,
2595,
22305,
12879,
9463,
1006,
19622,
1010,
5371,
18442,
1007,
1063,
3046,
1063,
2292,
8417,
1027,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
19622,
1009,
5371,
18442,
1010,
1005,
2118... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
summernote/summernote | src/js/base/core/dom.js | listDescendant | function listDescendant(node, pred) {
const descendants = [];
pred = pred || func.ok;
// start DFS(depth first search) with node
(function fnWalk(current) {
if (node !== current && pred(current)) {
descendants.push(current);
}
for (let idx = 0, len = current.childNodes.length; idx < len; idx++) {
fnWalk(current.childNodes[idx]);
}
})(node);
return descendants;
} | javascript | function listDescendant(node, pred) {
const descendants = [];
pred = pred || func.ok;
// start DFS(depth first search) with node
(function fnWalk(current) {
if (node !== current && pred(current)) {
descendants.push(current);
}
for (let idx = 0, len = current.childNodes.length; idx < len; idx++) {
fnWalk(current.childNodes[idx]);
}
})(node);
return descendants;
} | [
"function",
"listDescendant",
"(",
"node",
",",
"pred",
")",
"{",
"const",
"descendants",
"=",
"[",
"]",
";",
"pred",
"=",
"pred",
"||",
"func",
".",
"ok",
";",
"// start DFS(depth first search) with node",
"(",
"function",
"fnWalk",
"(",
"current",
")",
"{"... | listing descendant nodes
@param {Node} node
@param {Function} [pred] - predicate function | [
"listing",
"descendant",
"nodes"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L352-L367 | train | List descendant nodes of node | [
30522,
3853,
2862,
6155,
23865,
4630,
1006,
13045,
1010,
3653,
2094,
1007,
1063,
9530,
3367,
8481,
1027,
1031,
1033,
1025,
3653,
2094,
1027,
3653,
2094,
1064,
1064,
4569,
2278,
1012,
7929,
1025,
1013,
1013,
2707,
1040,
10343,
1006,
5995,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/hyphenation/Hyphenation.js | prepareConfig | function prepareConfig(sLanguage, oConfig) {
//Creating default configuration
var oConfigurationForLanguage = {
"require": [sLanguage],
"hyphen": "\u00AD",
"leftmin": 3, // The minimum of chars to remain on the old line.
"rightmin": 3,// The minimum of chars to go on the new line
"compound": "all", // factory-made -> fac-tory-[ZWSP]made
"path": jQuery.sap.getResourcePath("sap/ui/thirdparty/hyphenopoly")
};
// we are passing only 3 properties to hyphenopoly: hyphen, exceptions and minWordLength
if (oConfig) {
if ("hyphen" in oConfig) {
oConfigurationForLanguage.hyphen = oConfig.hyphen;
}
if ("minWordLength" in oConfig) {
oConfigurationForLanguage.minWordLength = oConfig.minWordLength;
}
if ("exceptions" in oConfig) {
Log.info(
"[UI5 Hyphenation] Add hyphenation exceptions '" + JSON.stringify(oConfig.exceptions) + "' for language " + getLanguageDisplayName(sLanguage),
"sap.ui.core.hyphenation.Hyphenation"
);
// transform "exceptions: {word1: "w-o-r-d-1", word2: "w-o-r-d-2"}" to "exceptions: {en-us: 'w-o-r-d-1,w-o-r-d-2'}"
var aWordsExceptions = [];
Object.keys(oConfig.exceptions).forEach(function(sWord) {
aWordsExceptions.push(oConfig.exceptions[sWord]);
});
if (aWordsExceptions.length > 0) {
oConfigurationForLanguage.exceptions = {};
oConfigurationForLanguage.exceptions[sLanguage] = aWordsExceptions.join(", ");
}
}
}
return oConfigurationForLanguage;
} | javascript | function prepareConfig(sLanguage, oConfig) {
//Creating default configuration
var oConfigurationForLanguage = {
"require": [sLanguage],
"hyphen": "\u00AD",
"leftmin": 3, // The minimum of chars to remain on the old line.
"rightmin": 3,// The minimum of chars to go on the new line
"compound": "all", // factory-made -> fac-tory-[ZWSP]made
"path": jQuery.sap.getResourcePath("sap/ui/thirdparty/hyphenopoly")
};
// we are passing only 3 properties to hyphenopoly: hyphen, exceptions and minWordLength
if (oConfig) {
if ("hyphen" in oConfig) {
oConfigurationForLanguage.hyphen = oConfig.hyphen;
}
if ("minWordLength" in oConfig) {
oConfigurationForLanguage.minWordLength = oConfig.minWordLength;
}
if ("exceptions" in oConfig) {
Log.info(
"[UI5 Hyphenation] Add hyphenation exceptions '" + JSON.stringify(oConfig.exceptions) + "' for language " + getLanguageDisplayName(sLanguage),
"sap.ui.core.hyphenation.Hyphenation"
);
// transform "exceptions: {word1: "w-o-r-d-1", word2: "w-o-r-d-2"}" to "exceptions: {en-us: 'w-o-r-d-1,w-o-r-d-2'}"
var aWordsExceptions = [];
Object.keys(oConfig.exceptions).forEach(function(sWord) {
aWordsExceptions.push(oConfig.exceptions[sWord]);
});
if (aWordsExceptions.length > 0) {
oConfigurationForLanguage.exceptions = {};
oConfigurationForLanguage.exceptions[sLanguage] = aWordsExceptions.join(", ");
}
}
}
return oConfigurationForLanguage;
} | [
"function",
"prepareConfig",
"(",
"sLanguage",
",",
"oConfig",
")",
"{",
"//Creating default configuration",
"var",
"oConfigurationForLanguage",
"=",
"{",
"\"require\"",
":",
"[",
"sLanguage",
"]",
",",
"\"hyphen\"",
":",
"\"\\u00AD\"",
",",
"\"leftmin\"",
":",
"3",... | Transforms the given config so it can be sent to Hyphenopoly.
@param {string} sLanguage The language for which a config is prepared.
@param {map} oConfig Object map with configuration
@returns {Object} {{require: [*], hyphen: string, path: (string|*)}}
@private | [
"Transforms",
"the",
"given",
"config",
"so",
"it",
"can",
"be",
"sent",
"to",
"Hyphenopoly",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/hyphenation/Hyphenation.js#L192-L233 | train | Creates the configuration for the given language. | [
30522,
3853,
7374,
8663,
8873,
2290,
1006,
21435,
6692,
3351,
1010,
1051,
8663,
8873,
2290,
1007,
1063,
1013,
1013,
4526,
12398,
9563,
13075,
1051,
8663,
8873,
27390,
3370,
29278,
25023,
6692,
3351,
1027,
1063,
1000,
5478,
1000,
1024,
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... |
benweet/stackedit | src/libs/pagedown.js | TextareaState | function TextareaState(input) {
// Aliases
var stateObj = this;
var inputArea = input;
this.init = function () {
this.setInputAreaSelectionStartEnd();
this.text = inputArea.getContent();
};
// Sets the selected text in the input box after we've performed an
// operation.
this.setInputAreaSelection = function () {
inputArea.focus();
inputArea.setSelection(stateObj.start, stateObj.end);
};
this.setInputAreaSelectionStartEnd = function () {
stateObj.start = Math.min(
inputArea.selectionMgr.selectionStart,
inputArea.selectionMgr.selectionEnd
);
stateObj.end = Math.max(
inputArea.selectionMgr.selectionStart,
inputArea.selectionMgr.selectionEnd
);
};
// Restore this state into the input area.
this.restore = function () {
if (stateObj.text !== undefined && stateObj.text != inputArea.getContent()) {
inputArea.setContent(stateObj.text);
}
this.setInputAreaSelection();
};
// Gets a collection of HTML chunks from the inptut textarea.
this.getChunks = function () {
var chunk = new Chunks();
chunk.before = util.fixEolChars(stateObj.text.substring(0, stateObj.start));
chunk.startTag = "";
chunk.selection = util.fixEolChars(stateObj.text.substring(stateObj.start, stateObj.end));
chunk.endTag = "";
chunk.after = util.fixEolChars(stateObj.text.substring(stateObj.end));
return chunk;
};
// Sets the TextareaState properties given a chunk of markdown.
this.setChunks = function (chunk) {
chunk.before = chunk.before + chunk.startTag;
chunk.after = chunk.endTag + chunk.after;
this.start = chunk.before.length;
this.end = chunk.before.length + chunk.selection.length;
this.text = chunk.before + chunk.selection + chunk.after;
};
this.init();
} | javascript | function TextareaState(input) {
// Aliases
var stateObj = this;
var inputArea = input;
this.init = function () {
this.setInputAreaSelectionStartEnd();
this.text = inputArea.getContent();
};
// Sets the selected text in the input box after we've performed an
// operation.
this.setInputAreaSelection = function () {
inputArea.focus();
inputArea.setSelection(stateObj.start, stateObj.end);
};
this.setInputAreaSelectionStartEnd = function () {
stateObj.start = Math.min(
inputArea.selectionMgr.selectionStart,
inputArea.selectionMgr.selectionEnd
);
stateObj.end = Math.max(
inputArea.selectionMgr.selectionStart,
inputArea.selectionMgr.selectionEnd
);
};
// Restore this state into the input area.
this.restore = function () {
if (stateObj.text !== undefined && stateObj.text != inputArea.getContent()) {
inputArea.setContent(stateObj.text);
}
this.setInputAreaSelection();
};
// Gets a collection of HTML chunks from the inptut textarea.
this.getChunks = function () {
var chunk = new Chunks();
chunk.before = util.fixEolChars(stateObj.text.substring(0, stateObj.start));
chunk.startTag = "";
chunk.selection = util.fixEolChars(stateObj.text.substring(stateObj.start, stateObj.end));
chunk.endTag = "";
chunk.after = util.fixEolChars(stateObj.text.substring(stateObj.end));
return chunk;
};
// Sets the TextareaState properties given a chunk of markdown.
this.setChunks = function (chunk) {
chunk.before = chunk.before + chunk.startTag;
chunk.after = chunk.endTag + chunk.after;
this.start = chunk.before.length;
this.end = chunk.before.length + chunk.selection.length;
this.text = chunk.before + chunk.selection + chunk.after;
};
this.init();
} | [
"function",
"TextareaState",
"(",
"input",
")",
"{",
"// Aliases",
"var",
"stateObj",
"=",
"this",
";",
"var",
"inputArea",
"=",
"input",
";",
"this",
".",
"init",
"=",
"function",
"(",
")",
"{",
"this",
".",
"setInputAreaSelectionStartEnd",
"(",
")",
";",... | The input textarea state/contents. This is used to implement undo/redo by the undo manager. | [
"The",
"input",
"textarea",
"state",
"/",
"contents",
".",
"This",
"is",
"used",
"to",
"implement",
"undo",
"/",
"redo",
"by",
"the",
"undo",
"manager",
"."
] | 91f8cf3c10b75df65b69f9181cee8151d65a788d | https://github.com/benweet/stackedit/blob/91f8cf3c10b75df65b69f9181cee8151d65a788d/src/libs/pagedown.js#L327-L388 | train | TextareaState constructor. | [
30522,
3853,
3793,
12069,
14083,
3686,
1006,
7953,
1007,
1063,
1013,
1013,
14593,
2229,
13075,
2110,
16429,
3501,
1027,
2023,
1025,
13075,
7953,
12069,
2050,
1027,
7953,
1025,
2023,
1012,
1999,
4183,
1027,
3853,
1006,
1007,
1063,
2023,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FileFilters.js | filterPath | function filterPath(compiledFilter, fullPath) {
if (!compiledFilter) {
return true;
}
var re = new RegExp(compiledFilter);
return !fullPath.match(re);
} | javascript | function filterPath(compiledFilter, fullPath) {
if (!compiledFilter) {
return true;
}
var re = new RegExp(compiledFilter);
return !fullPath.match(re);
} | [
"function",
"filterPath",
"(",
"compiledFilter",
",",
"fullPath",
")",
"{",
"if",
"(",
"!",
"compiledFilter",
")",
"{",
"return",
"true",
";",
"}",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"compiledFilter",
")",
";",
"return",
"!",
"fullPath",
".",
"match... | Returns false if the given path matches any of the exclusion globs in the given filter. Returns true
if the path does not match any of the globs. If filtering many paths at once, use filterFileList()
for much better performance.
@param {?string} compiledFilter 'Compiled' filter object as returned by compile(), or null to no-op
@param {!string} fullPath
@return {boolean} | [
"Returns",
"false",
"if",
"the",
"given",
"path",
"matches",
"any",
"of",
"the",
"exclusion",
"globs",
"in",
"the",
"given",
"filter",
".",
"Returns",
"true",
"if",
"the",
"path",
"does",
"not",
"match",
"any",
"of",
"the",
"globs",
".",
"If",
"filtering... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L269-L276 | train | filter the path based on the filter | [
30522,
3853,
11307,
15069,
1006,
9227,
8873,
21928,
1010,
2440,
15069,
1007,
1063,
2065,
1006,
999,
9227,
8873,
21928,
1007,
1063,
2709,
2995,
1025,
1065,
13075,
2128,
1027,
2047,
19723,
10288,
2361,
1006,
9227,
8873,
21928,
1007,
1025,
270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_vertical/motion.js | function() {
this.jsonInit({
"message0": Blockly.Msg.MOTION_SETROTATIONSTYLE,
"args0": [
{
"type": "field_dropdown",
"name": "STYLE",
"options": [
[Blockly.Msg.MOTION_SETROTATIONSTYLE_LEFTRIGHT, 'left-right'],
[Blockly.Msg.MOTION_SETROTATIONSTYLE_DONTROTATE, 'don\'t rotate'],
[Blockly.Msg.MOTION_SETROTATIONSTYLE_ALLAROUND, 'all around']
]
}
],
"category": Blockly.Categories.motion,
"extensions": ["colours_motion", "shape_statement"]
});
} | javascript | function() {
this.jsonInit({
"message0": Blockly.Msg.MOTION_SETROTATIONSTYLE,
"args0": [
{
"type": "field_dropdown",
"name": "STYLE",
"options": [
[Blockly.Msg.MOTION_SETROTATIONSTYLE_LEFTRIGHT, 'left-right'],
[Blockly.Msg.MOTION_SETROTATIONSTYLE_DONTROTATE, 'don\'t rotate'],
[Blockly.Msg.MOTION_SETROTATIONSTYLE_ALLAROUND, 'all around']
]
}
],
"category": Blockly.Categories.motion,
"extensions": ["colours_motion", "shape_statement"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"Blockly",
".",
"Msg",
".",
"MOTION_SETROTATIONSTYLE",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"STYLE\"",
",",
"\"optio... | Block to set rotation style.
@this Blockly.Block | [
"Block",
"to",
"set",
"rotation",
"style",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/motion.js#L416-L433 | train | Block for the set rotation style. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
3796,
2135,
1012,
5796,
2290,
1012,
4367,
1035,
2275,
21709,
10708,
27983,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | renderedPosition | function renderedPosition(dim, val) {
var ele = this[0];
var cy = this.cy();
var zoom = cy.zoom();
var pan = cy.pan();
var rpos = plainObject(dim) ? dim : undefined;
var setting = rpos !== undefined || val !== undefined && string(dim);
if (ele && ele.isNode()) {
// must have an element and must be a node to return position
if (setting) {
for (var i = 0; i < this.length; i++) {
var _ele = this[i];
if (val !== undefined) {
// set one dimension
_ele.position(dim, (val - pan[dim]) / zoom);
} else if (rpos !== undefined) {
// set whole position
_ele.position(renderedToModelPosition(rpos, zoom, pan));
}
}
} else {
// getting
var pos = ele.position();
rpos = modelToRenderedPosition(pos, zoom, pan);
if (dim === undefined) {
// then return the whole rendered position
return rpos;
} else {
// then return the specified dimension
return rpos[dim];
}
}
} else if (!setting) {
return undefined; // for empty collection case
}
return this; // chaining
} | javascript | function renderedPosition(dim, val) {
var ele = this[0];
var cy = this.cy();
var zoom = cy.zoom();
var pan = cy.pan();
var rpos = plainObject(dim) ? dim : undefined;
var setting = rpos !== undefined || val !== undefined && string(dim);
if (ele && ele.isNode()) {
// must have an element and must be a node to return position
if (setting) {
for (var i = 0; i < this.length; i++) {
var _ele = this[i];
if (val !== undefined) {
// set one dimension
_ele.position(dim, (val - pan[dim]) / zoom);
} else if (rpos !== undefined) {
// set whole position
_ele.position(renderedToModelPosition(rpos, zoom, pan));
}
}
} else {
// getting
var pos = ele.position();
rpos = modelToRenderedPosition(pos, zoom, pan);
if (dim === undefined) {
// then return the whole rendered position
return rpos;
} else {
// then return the specified dimension
return rpos[dim];
}
}
} else if (!setting) {
return undefined; // for empty collection case
}
return this; // chaining
} | [
"function",
"renderedPosition",
"(",
"dim",
",",
"val",
")",
"{",
"var",
"ele",
"=",
"this",
"[",
"0",
"]",
";",
"var",
"cy",
"=",
"this",
".",
"cy",
"(",
")",
";",
"var",
"zoom",
"=",
"cy",
".",
"zoom",
"(",
")",
";",
"var",
"pan",
"=",
"cy"... | get/set the rendered (i.e. on screen) positon of the element | [
"get",
"/",
"set",
"the",
"rendered",
"(",
"i",
".",
"e",
".",
"on",
"screen",
")",
"positon",
"of",
"the",
"element"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L8340-L8380 | train | Returns the rendered position of an element in the specified dimension. | [
30522,
3853,
10155,
26994,
1006,
11737,
1010,
11748,
1007,
1063,
13075,
3449,
2063,
1027,
2023,
1031,
1014,
1033,
1025,
13075,
22330,
1027,
2023,
1012,
22330,
1006,
1007,
1025,
13075,
24095,
1027,
22330,
1012,
24095,
1006,
1007,
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... |
feathericons/feather | bin/process-svg.js | optimize | function optimize(svg) {
const svgo = new Svgo({
plugins: [
{ convertShapeToPath: false },
{ mergePaths: false },
{ removeAttrs: { attrs: '(fill|stroke.*)' } },
{ removeTitle: true },
],
});
return new Promise(resolve => {
svgo.optimize(svg, ({ data }) => resolve(data));
});
} | javascript | function optimize(svg) {
const svgo = new Svgo({
plugins: [
{ convertShapeToPath: false },
{ mergePaths: false },
{ removeAttrs: { attrs: '(fill|stroke.*)' } },
{ removeTitle: true },
],
});
return new Promise(resolve => {
svgo.optimize(svg, ({ data }) => resolve(data));
});
} | [
"function",
"optimize",
"(",
"svg",
")",
"{",
"const",
"svgo",
"=",
"new",
"Svgo",
"(",
"{",
"plugins",
":",
"[",
"{",
"convertShapeToPath",
":",
"false",
"}",
",",
"{",
"mergePaths",
":",
"false",
"}",
",",
"{",
"removeAttrs",
":",
"{",
"attrs",
":"... | Optimize SVG with `svgo`.
@param {string} svg - An SVG string.
@returns {Promise<string>} | [
"Optimize",
"SVG",
"with",
"svgo",
"."
] | 8f658193d25e943b196a2367319b5d9e85ee9f9f | https://github.com/feathericons/feather/blob/8f658193d25e943b196a2367319b5d9e85ee9f9f/bin/process-svg.js#L28-L41 | train | optimize the given SVG | [
30522,
3853,
23569,
27605,
4371,
1006,
17917,
2290,
1007,
1063,
9530,
3367,
17917,
3995,
1027,
2047,
17917,
3995,
1006,
1063,
13354,
7076,
1024,
1031,
1063,
19884,
3270,
22327,
29477,
2705,
1024,
6270,
1065,
1010,
1063,
13590,
15069,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeView.js | function () {
if (!this.props.entry.get("rename")) {
if (this.state.clickTimer !== null) {
this.clearTimer();
}
this.props.actions.selectInWorkingSet(this.myPath());
}
} | javascript | function () {
if (!this.props.entry.get("rename")) {
if (this.state.clickTimer !== null) {
this.clearTimer();
}
this.props.actions.selectInWorkingSet(this.myPath());
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"props",
".",
"entry",
".",
"get",
"(",
"\"rename\"",
")",
")",
"{",
"if",
"(",
"this",
".",
"state",
".",
"clickTimer",
"!==",
"null",
")",
"{",
"this",
".",
"clearTimer",
"(",
")",
";",
... | When the user double clicks, we will select this file and add it to the working
set (via the `selectInWorkingSet` action.) | [
"When",
"the",
"user",
"double",
"clicks",
"we",
"will",
"select",
"this",
"file",
"and",
"add",
"it",
"to",
"the",
"working",
"set",
"(",
"via",
"the",
"selectInWorkingSet",
"action",
".",
")"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L567-L574 | train | select the file in the working set | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
24387,
1012,
4443,
1012,
2131,
1006,
1000,
14916,
14074,
1000,
1007,
1007,
1063,
2065,
1006,
2023,
1012,
2110,
1012,
11562,
7292,
2099,
999,
1027,
1027,
19701,
1007,
1063,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
NervJS/taro | packages/taro-rn-runner/src/index.js | printServerInfo | async function printServerInfo () {
await ProjectSettings.readPackagerInfoAsync(projectDir)
// who knows why qrcode-terminal takes a callback instead of just returning a string
const address = await UrlUtils.constructManifestUrlAsync(projectDir)
let emulatorHelp
if (process.platform === 'darwin') {
emulatorHelp = `Press ${chalk.bold('a')} (Android) or ${chalk.bold('i')} (iOS) to start an emulator.`
} else {
emulatorHelp = `Press ${chalk.bold('a')} to start an Android emulator.`
}
qr.generate(address, qrCode => {
log(`
${indent(qrCode, 2)}
Your app is now running at URL: ${chalk.underline(chalk.cyan(address))}
${chalk.bold('View your app with live reloading:')}
${chalk.underline('Android device:')}
-> Point the Expo app to the QR code above.
(You'll find the QR scanner on the Projects tab of the app.)
${chalk.underline('iOS device:')}
-> Press ${chalk.bold('s')} to email/text the app URL to your phone.
${chalk.underline('Emulator:')}
-> ${emulatorHelp}
Your phone will need to be on the same local network as this computer.
For links to install the Expo app, please visit ${chalk.underline(chalk.cyan('https://expo.io'))}.
Logs from serving your app will appear here. Press Ctrl+C at any time to stop.`
)
printUsage()
})
} | javascript | async function printServerInfo () {
await ProjectSettings.readPackagerInfoAsync(projectDir)
// who knows why qrcode-terminal takes a callback instead of just returning a string
const address = await UrlUtils.constructManifestUrlAsync(projectDir)
let emulatorHelp
if (process.platform === 'darwin') {
emulatorHelp = `Press ${chalk.bold('a')} (Android) or ${chalk.bold('i')} (iOS) to start an emulator.`
} else {
emulatorHelp = `Press ${chalk.bold('a')} to start an Android emulator.`
}
qr.generate(address, qrCode => {
log(`
${indent(qrCode, 2)}
Your app is now running at URL: ${chalk.underline(chalk.cyan(address))}
${chalk.bold('View your app with live reloading:')}
${chalk.underline('Android device:')}
-> Point the Expo app to the QR code above.
(You'll find the QR scanner on the Projects tab of the app.)
${chalk.underline('iOS device:')}
-> Press ${chalk.bold('s')} to email/text the app URL to your phone.
${chalk.underline('Emulator:')}
-> ${emulatorHelp}
Your phone will need to be on the same local network as this computer.
For links to install the Expo app, please visit ${chalk.underline(chalk.cyan('https://expo.io'))}.
Logs from serving your app will appear here. Press Ctrl+C at any time to stop.`
)
printUsage()
})
} | [
"async",
"function",
"printServerInfo",
"(",
")",
"{",
"await",
"ProjectSettings",
".",
"readPackagerInfoAsync",
"(",
"projectDir",
")",
"// who knows why qrcode-terminal takes a callback instead of just returning a string",
"const",
"address",
"=",
"await",
"UrlUtils",
".",
... | print a nicely formatted message with setup information | [
"print",
"a",
"nicely",
"formatted",
"message",
"with",
"setup",
"information"
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro-rn-runner/src/index.js#L58-L86 | train | Print server info | [
30522,
2004,
6038,
2278,
3853,
11204,
2121,
6299,
2378,
14876,
1006,
1007,
1063,
26751,
3934,
18319,
3070,
2015,
1012,
3191,
23947,
17325,
2378,
14876,
3022,
6038,
2278,
1006,
2622,
4305,
2099,
1007,
1013,
1013,
2040,
4282,
2339,
1053,
2956... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Control.js | fnAppendBusyIndicator | function fnAppendBusyIndicator() {
// Only append if busy state is still set
if (!this.getBusy()) {
return;
}
var $this = this.$(this._sBusySection);
//If there is a pending delayed call to append the busy indicator, we can clear it now
if (this._busyIndicatorDelayedCallId) {
clearTimeout(this._busyIndicatorDelayedCallId);
delete this._busyIndicatorDelayedCallId;
}
// if no busy section/control jquery instance could be retrieved -> the control is not part of the dom anymore
// this might happen in certain scenarios when e.g. a dialog is closed faster than the busyIndicatorDelay
if (!$this || $this.length === 0) {
Log.warning("BusyIndicator could not be rendered. The outer control instance is not valid anymore.");
return;
}
if (this._sBlockSection === this._sBusySection) {
if (this._oBlockState) {
BusyIndicatorUtils.addHTML(this._oBlockState, this.getBusyIndicatorSize());
BlockLayerUtils.toggleAnimationStyle(this._oBlockState, true);
this._oBusyBlockState = this._oBlockState;
} else {
// BusyIndicator is the first blocking element created (and )
fnAddStandaloneBusyIndicator.call(this);
}
} else {
// Standalone busy indicator
fnAddStandaloneBusyIndicator.call(this);
}
} | javascript | function fnAppendBusyIndicator() {
// Only append if busy state is still set
if (!this.getBusy()) {
return;
}
var $this = this.$(this._sBusySection);
//If there is a pending delayed call to append the busy indicator, we can clear it now
if (this._busyIndicatorDelayedCallId) {
clearTimeout(this._busyIndicatorDelayedCallId);
delete this._busyIndicatorDelayedCallId;
}
// if no busy section/control jquery instance could be retrieved -> the control is not part of the dom anymore
// this might happen in certain scenarios when e.g. a dialog is closed faster than the busyIndicatorDelay
if (!$this || $this.length === 0) {
Log.warning("BusyIndicator could not be rendered. The outer control instance is not valid anymore.");
return;
}
if (this._sBlockSection === this._sBusySection) {
if (this._oBlockState) {
BusyIndicatorUtils.addHTML(this._oBlockState, this.getBusyIndicatorSize());
BlockLayerUtils.toggleAnimationStyle(this._oBlockState, true);
this._oBusyBlockState = this._oBlockState;
} else {
// BusyIndicator is the first blocking element created (and )
fnAddStandaloneBusyIndicator.call(this);
}
} else {
// Standalone busy indicator
fnAddStandaloneBusyIndicator.call(this);
}
} | [
"function",
"fnAppendBusyIndicator",
"(",
")",
"{",
"// Only append if busy state is still set",
"if",
"(",
"!",
"this",
".",
"getBusy",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"$this",
"=",
"this",
".",
"$",
"(",
"this",
".",
"_sBusySection",
")",
... | Add busy indicator to DOM
@private | [
"Add",
"busy",
"indicator",
"to",
"DOM"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Control.js#L721-L759 | train | Append busy indicator to the DOM | [
30522,
3853,
1042,
2532,
21512,
4859,
8286,
25811,
14808,
8844,
1006,
1007,
1063,
1013,
1013,
2069,
10439,
10497,
2065,
5697,
2110,
2003,
2145,
2275,
2065,
1006,
999,
2023,
1012,
2131,
8286,
2100,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | closenessCentrality | function closenessCentrality(options) {
var _defaults2 = defaults$2(options),
root = _defaults2.root,
weight = _defaults2.weight,
directed = _defaults2.directed,
harmonic = _defaults2.harmonic;
root = this.filter(root)[0]; // we need distance from this node to every other node
var dijkstra = this.dijkstra({
root: root,
weight: weight,
directed: directed
});
var totalDistance = 0;
var nodes = this.nodes();
for (var i = 0; i < nodes.length; i++) {
var n = nodes[i];
if (!n.same(root)) {
var d = dijkstra.distanceTo(n);
if (harmonic) {
totalDistance += 1 / d;
} else {
totalDistance += d;
}
}
}
return harmonic ? totalDistance : 1 / totalDistance;
} | javascript | function closenessCentrality(options) {
var _defaults2 = defaults$2(options),
root = _defaults2.root,
weight = _defaults2.weight,
directed = _defaults2.directed,
harmonic = _defaults2.harmonic;
root = this.filter(root)[0]; // we need distance from this node to every other node
var dijkstra = this.dijkstra({
root: root,
weight: weight,
directed: directed
});
var totalDistance = 0;
var nodes = this.nodes();
for (var i = 0; i < nodes.length; i++) {
var n = nodes[i];
if (!n.same(root)) {
var d = dijkstra.distanceTo(n);
if (harmonic) {
totalDistance += 1 / d;
} else {
totalDistance += d;
}
}
}
return harmonic ? totalDistance : 1 / totalDistance;
} | [
"function",
"closenessCentrality",
"(",
"options",
")",
"{",
"var",
"_defaults2",
"=",
"defaults$2",
"(",
"options",
")",
",",
"root",
"=",
"_defaults2",
".",
"root",
",",
"weight",
"=",
"_defaults2",
".",
"weight",
",",
"directed",
"=",
"_defaults2",
".",
... | Implemented from pseudocode from wikipedia | [
"Implemented",
"from",
"pseudocode",
"from",
"wikipedia"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L3568-L3600 | train | Returns the closeness centrality of the cluster | [
30522,
3853,
28398,
13013,
7941,
3012,
1006,
7047,
1007,
1063,
13075,
1035,
12398,
2015,
2475,
1027,
12398,
2015,
1002,
1016,
1006,
7047,
1007,
1010,
7117,
1027,
1035,
12398,
2015,
2475,
1012,
7117,
1010,
3635,
1027,
1035,
12398,
2015,
2475... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
websockets/ws | lib/websocket.js | receiverOnError | function receiverOnError(err) {
const websocket = this[kWebSocket];
websocket._socket.removeListener('data', socketOnData);
websocket.readyState = WebSocket.CLOSING;
websocket._closeCode = err[kStatusCode];
websocket.emit('error', err);
websocket._socket.destroy();
} | javascript | function receiverOnError(err) {
const websocket = this[kWebSocket];
websocket._socket.removeListener('data', socketOnData);
websocket.readyState = WebSocket.CLOSING;
websocket._closeCode = err[kStatusCode];
websocket.emit('error', err);
websocket._socket.destroy();
} | [
"function",
"receiverOnError",
"(",
"err",
")",
"{",
"const",
"websocket",
"=",
"this",
"[",
"kWebSocket",
"]",
";",
"websocket",
".",
"_socket",
".",
"removeListener",
"(",
"'data'",
",",
"socketOnData",
")",
";",
"websocket",
".",
"readyState",
"=",
"WebSo... | The listener of the `Receiver` `'error'` event.
@param {(RangeError|Error)} err The emitted error
@private | [
"The",
"listener",
"of",
"the",
"Receiver",
"error",
"event",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket.js#L769-L778 | train | receiverOnError - Error handler | [
30522,
3853,
8393,
5643,
18933,
2099,
1006,
9413,
2099,
1007,
1063,
9530,
3367,
4773,
6499,
19869,
2102,
1027,
2023,
1031,
6448,
15878,
6499,
19869,
2102,
1033,
1025,
4773,
6499,
19869,
2102,
1012,
1035,
22278,
1012,
6366,
9863,
24454,
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... |
getinsomnia/insomnia | packages/insomnia-importers/src/importers/openapi3.js | parseEndpoints | function parseEndpoints(document) {
const defaultParent = WORKSPACE_ID;
const paths = Object.keys(document.paths);
const endpointsSchemas = paths
.map(path => {
const schemasPerMethod = document.paths[path];
const methods = Object.keys(schemasPerMethod);
return methods
.filter(method => method !== 'parameters')
.map(method => Object.assign({}, schemasPerMethod[method], { path, method }));
})
.reduce((flat, arr) => flat.concat(arr), []); //flat single array
const tags = document.tags || [];
const folders = tags.map(tag => {
return importFolderItem(tag, defaultParent);
});
const folderLookup = {};
folders.forEach(folder => (folderLookup[folder.name] = folder._id));
const requests = [];
endpointsSchemas.map(endpointSchema => {
let { tags } = endpointSchema;
if (!tags || tags.length == 0) tags = [''];
tags.forEach((tag, index) => {
let id = endpointSchema.operationId
? `${endpointSchema.operationId}${index > 0 ? index : ''}`
: `__REQUEST_${requestCount++}__`;
let parentId = folderLookup[tag] || defaultParent;
requests.push(importRequest(endpointSchema, id, parentId));
});
});
return [...folders, ...requests];
} | javascript | function parseEndpoints(document) {
const defaultParent = WORKSPACE_ID;
const paths = Object.keys(document.paths);
const endpointsSchemas = paths
.map(path => {
const schemasPerMethod = document.paths[path];
const methods = Object.keys(schemasPerMethod);
return methods
.filter(method => method !== 'parameters')
.map(method => Object.assign({}, schemasPerMethod[method], { path, method }));
})
.reduce((flat, arr) => flat.concat(arr), []); //flat single array
const tags = document.tags || [];
const folders = tags.map(tag => {
return importFolderItem(tag, defaultParent);
});
const folderLookup = {};
folders.forEach(folder => (folderLookup[folder.name] = folder._id));
const requests = [];
endpointsSchemas.map(endpointSchema => {
let { tags } = endpointSchema;
if (!tags || tags.length == 0) tags = [''];
tags.forEach((tag, index) => {
let id = endpointSchema.operationId
? `${endpointSchema.operationId}${index > 0 ? index : ''}`
: `__REQUEST_${requestCount++}__`;
let parentId = folderLookup[tag] || defaultParent;
requests.push(importRequest(endpointSchema, id, parentId));
});
});
return [...folders, ...requests];
} | [
"function",
"parseEndpoints",
"(",
"document",
")",
"{",
"const",
"defaultParent",
"=",
"WORKSPACE_ID",
";",
"const",
"paths",
"=",
"Object",
".",
"keys",
"(",
"document",
".",
"paths",
")",
";",
"const",
"endpointsSchemas",
"=",
"paths",
".",
"map",
"(",
... | Create request definitions based on openapi document.
@param {Object} document - OpenAPI 3 valid object (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#oasObject)
@returns {Object[]} array of insomnia endpoints definitions | [
"Create",
"request",
"definitions",
"based",
"on",
"openapi",
"document",
"."
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-importers/src/importers/openapi3.js#L98-L134 | train | Parse a document of endpoints | [
30522,
3853,
11968,
19763,
4859,
26521,
1006,
6254,
1007,
1063,
9530,
3367,
12398,
19362,
4765,
1027,
2573,
15327,
1035,
8909,
1025,
9530,
3367,
10425,
1027,
4874,
1012,
6309,
1006,
6254,
1012,
10425,
1007,
1025,
9530,
3367,
2203,
26521,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | handleTernCompletions | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | javascript | function handleTernCompletions(response) {
var file = response.file,
offset = response.offset,
completions = response.completions,
properties = response.properties,
fnType = response.fnType,
type = response.type,
error = response.error,
$deferredHints = getPendingRequest(file, offset, type);
if ($deferredHints) {
if (error) {
$deferredHints.reject();
} else if (completions) {
$deferredHints.resolveWith(null, [{completions: completions}]);
} else if (properties) {
$deferredHints.resolveWith(null, [{properties: properties}]);
} else if (fnType) {
$deferredHints.resolveWith(null, [fnType]);
}
}
} | [
"function",
"handleTernCompletions",
"(",
"response",
")",
"{",
"var",
"file",
"=",
"response",
".",
"file",
",",
"offset",
"=",
"response",
".",
"offset",
",",
"completions",
"=",
"response",
".",
"completions",
",",
"properties",
"=",
"response",
".",
"pro... | Handle the response from the tern node domain when
it responds with the list of completions
@param {{file: string, offset: {line: number, ch: number}, completions:Array.<string>,
properties:Array.<string>}} response - the response from node domain | [
"Handle",
"the",
"response",
"from",
"the",
"tern",
"node",
"domain",
"when",
"it",
"responds",
"with",
"the",
"list",
"of",
"completions"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L690-L712 | train | Handle Tern completions | [
30522,
3853,
5047,
16451,
9006,
10814,
9285,
1006,
3433,
1007,
1063,
13075,
5371,
1027,
3433,
1012,
5371,
1010,
16396,
1027,
3433,
1012,
16396,
1010,
6503,
2015,
1027,
3433,
1012,
6503,
2015,
1010,
5144,
1027,
3433,
1012,
5144,
1010,
1042,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/markdownItPlugins/markdownitTaskPlugin.js | isChecked | function isChecked(token) {
var checked = false;
if (token.content.indexOf('[x]') === 0 || token.content.indexOf('[X]') === 0) {
checked = true;
}
return checked;
} | javascript | function isChecked(token) {
var checked = false;
if (token.content.indexOf('[x]') === 0 || token.content.indexOf('[X]') === 0) {
checked = true;
}
return checked;
} | [
"function",
"isChecked",
"(",
"token",
")",
"{",
"var",
"checked",
"=",
"false",
";",
"if",
"(",
"token",
".",
"content",
".",
"indexOf",
"(",
"'[x]'",
")",
"===",
"0",
"||",
"token",
".",
"content",
".",
"indexOf",
"(",
"'[X]'",
")",
"===",
"0",
"... | Return boolean value whether task checked or not
@param {object} token Token object
@returns {boolean}
@ignore | [
"Return",
"boolean",
"value",
"whether",
"task",
"checked",
"or",
"not"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/markdownItPlugins/markdownitTaskPlugin.js#L60-L68 | train | Check if the given token is checked | [
30522,
3853,
2003,
5403,
18141,
1006,
19204,
1007,
1063,
13075,
7039,
1027,
6270,
1025,
2065,
1006,
19204,
1012,
4180,
1012,
5950,
11253,
1006,
1005,
1031,
1060,
1033,
1005,
1007,
1027,
1027,
1027,
1014,
1064,
1064,
19204,
1012,
4180,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/QuickOpenHTML/main.js | createIDList | function createIDList() {
var doc = DocumentManager.getCurrentDocument();
if (!doc) {
return;
}
var idList = [];
var docText = doc.getText();
var lines = docText.split("\n");
var regex = new RegExp(/\s+id\s*?=\s*?["'](.*?)["']/gi);
var id, chFrom, chTo, i, line;
for (i = 0; i < lines.length; i++) {
line = lines[i];
var info;
while ((info = regex.exec(line)) !== null) {
id = info[1];
// TODO: this doesn't handle id's that share the
// same portion of a name on the same line or when
// the id and value are on different lines
chFrom = line.indexOf(id);
chTo = chFrom + id.length;
idList.push(new FileLocation(null, i, chFrom, chTo, id));
}
}
return idList;
} | javascript | function createIDList() {
var doc = DocumentManager.getCurrentDocument();
if (!doc) {
return;
}
var idList = [];
var docText = doc.getText();
var lines = docText.split("\n");
var regex = new RegExp(/\s+id\s*?=\s*?["'](.*?)["']/gi);
var id, chFrom, chTo, i, line;
for (i = 0; i < lines.length; i++) {
line = lines[i];
var info;
while ((info = regex.exec(line)) !== null) {
id = info[1];
// TODO: this doesn't handle id's that share the
// same portion of a name on the same line or when
// the id and value are on different lines
chFrom = line.indexOf(id);
chTo = chFrom + id.length;
idList.push(new FileLocation(null, i, chFrom, chTo, id));
}
}
return idList;
} | [
"function",
"createIDList",
"(",
")",
"{",
"var",
"doc",
"=",
"DocumentManager",
".",
"getCurrentDocument",
"(",
")",
";",
"if",
"(",
"!",
"doc",
")",
"{",
"return",
";",
"}",
"var",
"idList",
"=",
"[",
"]",
";",
"var",
"docText",
"=",
"doc",
".",
... | Returns a list of information about ID's for a single document. This array is populated
by createIDList()
@type {?Array.<FileLocation>} | [
"Returns",
"a",
"list",
"of",
"information",
"about",
"ID",
"s",
"for",
"a",
"single",
"document",
".",
"This",
"array",
"is",
"populated",
"by",
"createIDList",
"()"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/QuickOpenHTML/main.js#L58-L84 | train | Create an array of FileLocations | [
30522,
3853,
3443,
3593,
9863,
1006,
1007,
1063,
13075,
9986,
1027,
6254,
24805,
4590,
1012,
2131,
10841,
14343,
3372,
3527,
24894,
4765,
1006,
1007,
1025,
2065,
1006,
999,
9986,
1007,
1063,
2709,
1025,
1065,
13075,
8909,
9863,
1027,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | function() {
var me = this;
if (core_plugins.notify(me, 'beforeLayout') === false) {
return;
}
core_layouts.update(this, this.width, this.height);
/**
* Provided for backward compatibility, use `afterLayout` instead.
* @method IPlugin#afterScaleUpdate
* @deprecated since version 2.5.0
* @todo remove at version 3
* @private
*/
core_plugins.notify(me, 'afterScaleUpdate');
core_plugins.notify(me, 'afterLayout');
} | javascript | function() {
var me = this;
if (core_plugins.notify(me, 'beforeLayout') === false) {
return;
}
core_layouts.update(this, this.width, this.height);
/**
* Provided for backward compatibility, use `afterLayout` instead.
* @method IPlugin#afterScaleUpdate
* @deprecated since version 2.5.0
* @todo remove at version 3
* @private
*/
core_plugins.notify(me, 'afterScaleUpdate');
core_plugins.notify(me, 'afterLayout');
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"core_plugins",
".",
"notify",
"(",
"me",
",",
"'beforeLayout'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"core_layouts",
".",
"update",
"(",
"this",
",",
"this",
".",
"... | Updates the chart layout unless a plugin returns `false` to the `beforeLayout`
hook, in which case, plugins will not be called on `afterLayout`.
@private | [
"Updates",
"the",
"chart",
"layout",
"unless",
"a",
"plugin",
"returns",
"false",
"to",
"the",
"beforeLayout",
"hook",
"in",
"which",
"case",
"plugins",
"will",
"not",
"be",
"called",
"on",
"afterLayout",
"."
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L8771-L8789 | train | Updates the layout of the image. | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
2065,
1006,
4563,
1035,
13354,
7076,
1012,
2025,
8757,
1006,
2033,
1010,
1005,
2077,
8485,
5833,
1005,
1007,
1027,
1027,
1027,
6270,
1007,
1063,
2709,
1025,
1065,
4563,
1035,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
NetEase/pomelo | lib/util/appUtil.js | function(args) {
var argsMap = {};
var mainPos = 1;
while (args[mainPos].indexOf('--') > 0) {
mainPos++;
}
argsMap.main = args[mainPos];
for (var i = (mainPos + 1); i < args.length; i++) {
var arg = args[i];
var sep = arg.indexOf('=');
var key = arg.slice(0, sep);
var value = arg.slice(sep + 1);
if (!isNaN(Number(value)) && (value.indexOf('.') < 0)) {
value = Number(value);
}
argsMap[key] = value;
}
return argsMap;
} | javascript | function(args) {
var argsMap = {};
var mainPos = 1;
while (args[mainPos].indexOf('--') > 0) {
mainPos++;
}
argsMap.main = args[mainPos];
for (var i = (mainPos + 1); i < args.length; i++) {
var arg = args[i];
var sep = arg.indexOf('=');
var key = arg.slice(0, sep);
var value = arg.slice(sep + 1);
if (!isNaN(Number(value)) && (value.indexOf('.') < 0)) {
value = Number(value);
}
argsMap[key] = value;
}
return argsMap;
} | [
"function",
"(",
"args",
")",
"{",
"var",
"argsMap",
"=",
"{",
"}",
";",
"var",
"mainPos",
"=",
"1",
";",
"while",
"(",
"args",
"[",
"mainPos",
"]",
".",
"indexOf",
"(",
"'--'",
")",
">",
"0",
")",
"{",
"mainPos",
"++",
";",
"}",
"argsMap",
"."... | Parse command line arguments.
@param args command line arguments
@return Object argsMap map of arguments | [
"Parse",
"command",
"line",
"arguments",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/util/appUtil.js#L222-L243 | train | Get argsMap from args | [
30522,
3853,
1006,
12098,
5620,
1007,
1063,
13075,
12098,
5620,
2863,
2361,
1027,
1063,
1065,
1025,
13075,
2364,
6873,
2015,
1027,
1015,
1025,
2096,
1006,
12098,
5620,
1031,
2364,
6873,
2015,
1033,
1012,
5950,
11253,
1006,
1005,
1011,
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/LiveDevelopment/main.js | _setupDebugHelpers | function _setupDebugHelpers() {
window.ld = LiveDevelopment;
window.i = Inspector;
window.report = function report(params) { window.params = params; console.info(params); };
} | javascript | function _setupDebugHelpers() {
window.ld = LiveDevelopment;
window.i = Inspector;
window.report = function report(params) { window.params = params; console.info(params); };
} | [
"function",
"_setupDebugHelpers",
"(",
")",
"{",
"window",
".",
"ld",
"=",
"LiveDevelopment",
";",
"window",
".",
"i",
"=",
"Inspector",
";",
"window",
".",
"report",
"=",
"function",
"report",
"(",
"params",
")",
"{",
"window",
".",
"params",
"=",
"para... | Setup window references to useful LiveDevelopment modules | [
"Setup",
"window",
"references",
"to",
"useful",
"LiveDevelopment",
"modules"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L314-L318 | train | Setup debug helpers | [
30522,
3853,
1035,
16437,
3207,
8569,
5603,
2884,
7347,
1006,
1007,
1063,
3332,
1012,
25510,
1027,
2973,
18697,
4135,
24073,
1025,
3332,
1012,
1045,
1027,
7742,
1025,
3332,
1012,
3189,
1027,
3853,
3189,
1006,
11498,
5244,
1007,
1063,
3332,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RequestRecorder.js | function(url, response, method, status, headers) {
if (!_private.isPlayStarted()) {
throw new Error("Start the player first before you add a response.");
}
var sMethod = method || "GET";
var aHeaders = headers || [{
"name": "Content-Type",
"value": "text/plain;charset=utf-8"
}];
var iStatus = status || 200;
var oEntry = {
"startedDateTime": new Date().toISOString(),
"time": 0,
"request": {
"headers": [],
"url": url,
"method": sMethod
},
"response": {
"status": iStatus,
"content": {
"text": response
},
"headers": aHeaders
}
};
var iIndex = _private.mHarFileContent.log.entries.push(oEntry) - 1;
_private.addEntryToMapping(_private.mHarFileContent, _private.mHarFileContent.log.entries, iIndex);
} | javascript | function(url, response, method, status, headers) {
if (!_private.isPlayStarted()) {
throw new Error("Start the player first before you add a response.");
}
var sMethod = method || "GET";
var aHeaders = headers || [{
"name": "Content-Type",
"value": "text/plain;charset=utf-8"
}];
var iStatus = status || 200;
var oEntry = {
"startedDateTime": new Date().toISOString(),
"time": 0,
"request": {
"headers": [],
"url": url,
"method": sMethod
},
"response": {
"status": iStatus,
"content": {
"text": response
},
"headers": aHeaders
}
};
var iIndex = _private.mHarFileContent.log.entries.push(oEntry) - 1;
_private.addEntryToMapping(_private.mHarFileContent, _private.mHarFileContent.log.entries, iIndex);
} | [
"function",
"(",
"url",
",",
"response",
",",
"method",
",",
"status",
",",
"headers",
")",
"{",
"if",
"(",
"!",
"_private",
".",
"isPlayStarted",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Start the player first before you add a response.\"",
")",
... | Adds a response for a request with the provided URL.
@param {string} url The requested URL.
@param {string|function} response The returned response as string or callback.
@param {string} [method] The HTTP method (e.g. GET, POST), default is GET.
@param {int} [status] The desired status, default is 200.
@param {array} [headers] The response Headers, default is text/plain. | [
"Adds",
"a",
"response",
"for",
"a",
"request",
"with",
"the",
"provided",
"URL",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L806-L834 | train | Add a response to the log file | [
30522,
3853,
1006,
24471,
2140,
1010,
3433,
1010,
4118,
1010,
3570,
1010,
20346,
2015,
1007,
1063,
2065,
1006,
999,
1035,
2797,
1012,
2003,
13068,
14117,
3064,
1006,
1007,
1007,
1063,
5466,
2047,
7561,
1006,
1000,
2707,
1996,
2447,
2034,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
chartjs/Chart.js | src/helpers/helpers.core.js | function(loopable, fn, thisArg, reverse) {
var i, len, keys;
if (helpers.isArray(loopable)) {
len = loopable.length;
if (reverse) {
for (i = len - 1; i >= 0; i--) {
fn.call(thisArg, loopable[i], i);
}
} else {
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[i], i);
}
}
} else if (helpers.isObject(loopable)) {
keys = Object.keys(loopable);
len = keys.length;
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[keys[i]], keys[i]);
}
}
} | javascript | function(loopable, fn, thisArg, reverse) {
var i, len, keys;
if (helpers.isArray(loopable)) {
len = loopable.length;
if (reverse) {
for (i = len - 1; i >= 0; i--) {
fn.call(thisArg, loopable[i], i);
}
} else {
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[i], i);
}
}
} else if (helpers.isObject(loopable)) {
keys = Object.keys(loopable);
len = keys.length;
for (i = 0; i < len; i++) {
fn.call(thisArg, loopable[keys[i]], keys[i]);
}
}
} | [
"function",
"(",
"loopable",
",",
"fn",
",",
"thisArg",
",",
"reverse",
")",
"{",
"var",
"i",
",",
"len",
",",
"keys",
";",
"if",
"(",
"helpers",
".",
"isArray",
"(",
"loopable",
")",
")",
"{",
"len",
"=",
"loopable",
".",
"length",
";",
"if",
"(... | Note(SB) for performance sake, this method should only be used when loopable type
is unknown or in none intensive code (not called often and small loopable). Else
it's preferable to use a regular for() loop and save extra function calls.
@param {object|Array} loopable - The object or array to be iterated.
@param {function} fn - The function to call for each item.
@param {object} [thisArg] - The value of `this` provided for the call to `fn`.
@param {boolean} [reverse] - If true, iterates backward on the loopable. | [
"Note",
"(",
"SB",
")",
"for",
"performance",
"sake",
"this",
"method",
"should",
"only",
"be",
"used",
"when",
"loopable",
"type",
"is",
"unknown",
"or",
"in",
"none",
"intensive",
"code",
"(",
"not",
"called",
"often",
"and",
"small",
"loopable",
")",
... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/helpers/helpers.core.js#L114-L134 | train | This function is used to call a function on an object or array. | [
30522,
3853,
1006,
7077,
3085,
1010,
1042,
2078,
1010,
2023,
2906,
2290,
1010,
7901,
1007,
1063,
13075,
1045,
1010,
18798,
1010,
6309,
1025,
2065,
1006,
2393,
2545,
1012,
18061,
11335,
2100,
1006,
7077,
3085,
1007,
1007,
1063,
18798,
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... | |
apache/incubator-echarts | src/echarts.js | prepareView | function prepareView(ecIns, type, ecModel, scheduler) {
var isComponent = type === 'component';
var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
var zr = ecIns._zr;
var api = ecIns._api;
for (var i = 0; i < viewList.length; i++) {
viewList[i].__alive = false;
}
isComponent
? ecModel.eachComponent(function (componentType, model) {
componentType !== 'series' && doPrepare(model);
})
: ecModel.eachSeries(doPrepare);
function doPrepare(model) {
// Consider: id same and type changed.
var viewId = '_ec_' + model.id + '_' + model.type;
var view = viewMap[viewId];
if (!view) {
var classType = parseClassType(model.type);
var Clazz = isComponent
? ComponentView.getClass(classType.main, classType.sub)
: ChartView.getClass(classType.sub);
if (__DEV__) {
assert(Clazz, classType.sub + ' does not exist.');
}
view = new Clazz();
view.init(ecModel, api);
viewMap[viewId] = view;
viewList.push(view);
zr.add(view.group);
}
model.__viewId = view.__id = viewId;
view.__alive = true;
view.__model = model;
view.group.__ecComponentInfo = {
mainType: model.mainType,
index: model.componentIndex
};
!isComponent && scheduler.prepareView(view, model, ecModel, api);
}
for (var i = 0; i < viewList.length;) {
var view = viewList[i];
if (!view.__alive) {
!isComponent && view.renderTask.dispose();
zr.remove(view.group);
view.dispose(ecModel, api);
viewList.splice(i, 1);
delete viewMap[view.__id];
view.__id = view.group.__ecComponentInfo = null;
}
else {
i++;
}
}
} | javascript | function prepareView(ecIns, type, ecModel, scheduler) {
var isComponent = type === 'component';
var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
var zr = ecIns._zr;
var api = ecIns._api;
for (var i = 0; i < viewList.length; i++) {
viewList[i].__alive = false;
}
isComponent
? ecModel.eachComponent(function (componentType, model) {
componentType !== 'series' && doPrepare(model);
})
: ecModel.eachSeries(doPrepare);
function doPrepare(model) {
// Consider: id same and type changed.
var viewId = '_ec_' + model.id + '_' + model.type;
var view = viewMap[viewId];
if (!view) {
var classType = parseClassType(model.type);
var Clazz = isComponent
? ComponentView.getClass(classType.main, classType.sub)
: ChartView.getClass(classType.sub);
if (__DEV__) {
assert(Clazz, classType.sub + ' does not exist.');
}
view = new Clazz();
view.init(ecModel, api);
viewMap[viewId] = view;
viewList.push(view);
zr.add(view.group);
}
model.__viewId = view.__id = viewId;
view.__alive = true;
view.__model = model;
view.group.__ecComponentInfo = {
mainType: model.mainType,
index: model.componentIndex
};
!isComponent && scheduler.prepareView(view, model, ecModel, api);
}
for (var i = 0; i < viewList.length;) {
var view = viewList[i];
if (!view.__alive) {
!isComponent && view.renderTask.dispose();
zr.remove(view.group);
view.dispose(ecModel, api);
viewList.splice(i, 1);
delete viewMap[view.__id];
view.__id = view.group.__ecComponentInfo = null;
}
else {
i++;
}
}
} | [
"function",
"prepareView",
"(",
"ecIns",
",",
"type",
",",
"ecModel",
",",
"scheduler",
")",
"{",
"var",
"isComponent",
"=",
"type",
"===",
"'component'",
";",
"var",
"viewList",
"=",
"isComponent",
"?",
"ecIns",
".",
"_componentsViews",
":",
"ecIns",
".",
... | Prepare view instances of charts and components
@param {module:echarts/model/Global} ecModel
@private | [
"Prepare",
"view",
"instances",
"of",
"charts",
"and",
"components"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/echarts.js#L1352-L1414 | train | prepare view for ecModel | [
30522,
3853,
7374,
8584,
1006,
14925,
7076,
1010,
2828,
1010,
14925,
5302,
9247,
1010,
6134,
2099,
1007,
1063,
13075,
2003,
9006,
29513,
3372,
1027,
2828,
1027,
1027,
1027,
1005,
6922,
1005,
1025,
13075,
30524,
1035,
6177,
2863,
2361,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js | asyncStrategy | function asyncStrategy(node, oAggregation, mAggregations) {
var childNode,
pChain = Promise.resolve(),
aChildPromises = [];
for (childNode = node.firstChild; childNode; childNode = childNode.nextSibling) {
pChain = pChain.then(fnCallback.bind(null, node, oAggregation, mAggregations, childNode));
aChildPromises.push(pChain);
}
return Promise.all(aChildPromises);
} | javascript | function asyncStrategy(node, oAggregation, mAggregations) {
var childNode,
pChain = Promise.resolve(),
aChildPromises = [];
for (childNode = node.firstChild; childNode; childNode = childNode.nextSibling) {
pChain = pChain.then(fnCallback.bind(null, node, oAggregation, mAggregations, childNode));
aChildPromises.push(pChain);
}
return Promise.all(aChildPromises);
} | [
"function",
"asyncStrategy",
"(",
"node",
",",
"oAggregation",
",",
"mAggregations",
")",
"{",
"var",
"childNode",
",",
"pChain",
"=",
"Promise",
".",
"resolve",
"(",
")",
",",
"aChildPromises",
"=",
"[",
"]",
";",
"for",
"(",
"childNode",
"=",
"node",
"... | async strategy ensures processing order by chaining the callbacks | [
"async",
"strategy",
"ensures",
"processing",
"order",
"by",
"chaining",
"the",
"callbacks"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L116-L126 | train | async strategy for async aggregation | [
30522,
3853,
2004,
6038,
6169,
6494,
2618,
6292,
1006,
13045,
1010,
1051,
8490,
17603,
12540,
1010,
23848,
17603,
12540,
2015,
1007,
1063,
13075,
2775,
3630,
3207,
1010,
7473,
10932,
2078,
1027,
4872,
1012,
10663,
1006,
1007,
1010,
9353,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/flow | packages/flow-remove-types/index.js | isLastNodeRemovedFromLine | function isLastNodeRemovedFromLine(context, node) {
var tokens = context.ast.tokens;
var priorTokenIdx = findTokenIndex(tokens, startOf(node)) - 1;
var token = tokens[priorTokenIdx];
var line = node.loc.end.line;
// Find previous token that was not removed on the same line.
while (
priorTokenIdx >= 0 &&
token.loc.end.line === line &&
isRemovedToken(context, token)
) {
token = tokens[--priorTokenIdx];
}
// If there's no prior token (start of file), or the prior token is on another
// line, this line must be fully removed.
return !token || token.loc.end.line !== line;
} | javascript | function isLastNodeRemovedFromLine(context, node) {
var tokens = context.ast.tokens;
var priorTokenIdx = findTokenIndex(tokens, startOf(node)) - 1;
var token = tokens[priorTokenIdx];
var line = node.loc.end.line;
// Find previous token that was not removed on the same line.
while (
priorTokenIdx >= 0 &&
token.loc.end.line === line &&
isRemovedToken(context, token)
) {
token = tokens[--priorTokenIdx];
}
// If there's no prior token (start of file), or the prior token is on another
// line, this line must be fully removed.
return !token || token.loc.end.line !== line;
} | [
"function",
"isLastNodeRemovedFromLine",
"(",
"context",
",",
"node",
")",
"{",
"var",
"tokens",
"=",
"context",
".",
"ast",
".",
"tokens",
";",
"var",
"priorTokenIdx",
"=",
"findTokenIndex",
"(",
"tokens",
",",
"startOf",
"(",
"node",
")",
")",
"-",
"1",
... | Returns true if node is the last to be removed from a line. | [
"Returns",
"true",
"if",
"node",
"is",
"the",
"last",
"to",
"be",
"removed",
"from",
"a",
"line",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-remove-types/index.js#L409-L427 | train | Checks if the node is the last node removed from the line. | [
30522,
3853,
25340,
3367,
3630,
4063,
6633,
21818,
20952,
21716,
4179,
1006,
6123,
1010,
13045,
1007,
1063,
13075,
19204,
2015,
1027,
6123,
1012,
2004,
2102,
1012,
19204,
2015,
1025,
13075,
3188,
18715,
18595,
2094,
2595,
1027,
2424,
18715,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/panel/panel.js | definePreset | function definePreset(name, preset) {
if (!name || !preset) {
throw new Error('mdPanelProvider: The panel preset definition is ' +
'malformed. The name and preset object are required.');
} else if (_presets.hasOwnProperty(name)) {
throw new Error('mdPanelProvider: The panel preset you have requested ' +
'has already been defined.');
}
// Delete any property on the preset that is not allowed.
delete preset.id;
delete preset.position;
delete preset.animation;
_presets[name] = preset;
} | javascript | function definePreset(name, preset) {
if (!name || !preset) {
throw new Error('mdPanelProvider: The panel preset definition is ' +
'malformed. The name and preset object are required.');
} else if (_presets.hasOwnProperty(name)) {
throw new Error('mdPanelProvider: The panel preset you have requested ' +
'has already been defined.');
}
// Delete any property on the preset that is not allowed.
delete preset.id;
delete preset.position;
delete preset.animation;
_presets[name] = preset;
} | [
"function",
"definePreset",
"(",
"name",
",",
"preset",
")",
"{",
"if",
"(",
"!",
"name",
"||",
"!",
"preset",
")",
"{",
"throw",
"new",
"Error",
"(",
"'mdPanelProvider: The panel preset definition is '",
"+",
"'malformed. The name and preset object are required.'",
"... | Takes the passed in panel configuration object and adds it to the `_presets`
object at the specified name.
@param {string} name Name of the preset to set.
@param {!Object} preset Specific configuration object that can contain any
and all of the parameters available within the `$mdPanel.create` method.
However, parameters that pertain to id, position, animation, and user
interaction are not allowed and will be removed from the preset
configuration. | [
"Takes",
"the",
"passed",
"in",
"panel",
"configuration",
"object",
"and",
"adds",
"it",
"to",
"the",
"_presets",
"object",
"at",
"the",
"specified",
"name",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/panel/panel.js#L966-L981 | train | Defines a panel preset | [
30522,
3853,
9375,
28994,
3388,
1006,
2171,
1010,
3653,
13462,
1007,
1063,
2065,
1006,
999,
2171,
1064,
1064,
999,
3653,
13462,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
9108,
9739,
2884,
21572,
17258,
2121,
1024,
1996,
5997,
3653,
13462,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/respondable.js | buildErrorObject | function buildErrorObject(error) {
var msg = error.message || 'Unknown error occurred';
var errorName = errorTypes.includes(error.name) ? error.name : 'Error';
var ErrConstructor = window[errorName] || Error;
if (error.stack) {
msg += '\n' + error.stack.replace(error.message, '');
}
return new ErrConstructor(msg);
} | javascript | function buildErrorObject(error) {
var msg = error.message || 'Unknown error occurred';
var errorName = errorTypes.includes(error.name) ? error.name : 'Error';
var ErrConstructor = window[errorName] || Error;
if (error.stack) {
msg += '\n' + error.stack.replace(error.message, '');
}
return new ErrConstructor(msg);
} | [
"function",
"buildErrorObject",
"(",
"error",
")",
"{",
"var",
"msg",
"=",
"error",
".",
"message",
"||",
"'Unknown error occurred'",
";",
"var",
"errorName",
"=",
"errorTypes",
".",
"includes",
"(",
"error",
".",
"name",
")",
"?",
"error",
".",
"name",
":... | Convert a javascript Error into something that can be stringified
@param {Error} error Any type of error
@return {Object} Processable object | [
"Convert",
"a",
"javascript",
"Error",
"into",
"something",
"that",
"can",
"be",
"stringified"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/respondable.js#L166-L175 | train | Build an error object | [
30522,
3853,
12508,
29165,
16429,
20614,
1006,
7561,
1007,
1063,
13075,
5796,
2290,
1027,
7561,
1012,
4471,
1064,
1064,
1005,
4242,
7561,
4158,
1005,
1025,
13075,
7561,
18442,
1027,
7561,
13874,
2015,
1012,
2950,
1006,
7561,
1012,
2171,
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... |
infinitered/ignite | src/cli/enforce-global.js | defaultVersionMatcher | function defaultVersionMatcher(raw) {
// sanity check
if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null
try {
// look for something that looks like semver
var rx = /([0-9]+\.[0-9]+\.[0-9]+)/
var match = ramda.match(rx, raw)
if (match.length > 0) {
return match[0]
} else {
return null
}
} catch (err) {
// something tragic happened
return false
}
} | javascript | function defaultVersionMatcher(raw) {
// sanity check
if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null
try {
// look for something that looks like semver
var rx = /([0-9]+\.[0-9]+\.[0-9]+)/
var match = ramda.match(rx, raw)
if (match.length > 0) {
return match[0]
} else {
return null
}
} catch (err) {
// something tragic happened
return false
}
} | [
"function",
"defaultVersionMatcher",
"(",
"raw",
")",
"{",
"// sanity check",
"if",
"(",
"ramda",
".",
"isNil",
"(",
"raw",
")",
"||",
"ramda",
".",
"isEmpty",
"(",
"raw",
")",
")",
"return",
"null",
"try",
"{",
"// look for something that looks like semver",
... | Extracts the version number from a somewhere within a string.
This looks for things that look like semver (e.g. 0.0.0) and picks the first one.
@param {string} raw - The raw text which came from running the version command. | [
"Extracts",
"the",
"version",
"number",
"from",
"a",
"somewhere",
"within",
"a",
"string",
"."
] | dca91da22f9ad9bab1eb9f43565689d563bd111d | https://github.com/infinitered/ignite/blob/dca91da22f9ad9bab1eb9f43565689d563bd111d/src/cli/enforce-global.js#L15-L32 | train | default version matcher | [
30522,
3853,
12398,
27774,
18900,
7474,
1006,
6315,
1007,
1063,
1013,
1013,
20039,
4638,
2065,
1006,
8223,
2850,
1012,
3475,
4014,
1006,
6315,
1007,
1064,
1064,
8223,
2850,
1012,
2003,
6633,
13876,
2100,
1006,
6315,
1007,
1007,
2709,
19701,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/ProjectManager.js | createNewItem | function createNewItem(baseDir, initialName, skipRename, isFolder) {
baseDir = model.getDirectoryInProject(baseDir);
if (skipRename) {
if(isFolder) {
return model.createAtPath(baseDir + initialName + "/");
}
return model.createAtPath(baseDir + initialName);
}
return actionCreator.startCreating(baseDir, initialName, isFolder);
} | javascript | function createNewItem(baseDir, initialName, skipRename, isFolder) {
baseDir = model.getDirectoryInProject(baseDir);
if (skipRename) {
if(isFolder) {
return model.createAtPath(baseDir + initialName + "/");
}
return model.createAtPath(baseDir + initialName);
}
return actionCreator.startCreating(baseDir, initialName, isFolder);
} | [
"function",
"createNewItem",
"(",
"baseDir",
",",
"initialName",
",",
"skipRename",
",",
"isFolder",
")",
"{",
"baseDir",
"=",
"model",
".",
"getDirectoryInProject",
"(",
"baseDir",
")",
";",
"if",
"(",
"skipRename",
")",
"{",
"if",
"(",
"isFolder",
")",
"... | Create a new item in the current project.
@param baseDir {string|Directory} Full path of the directory where the item should go.
Defaults to the project root if the entry is not valid or not within the project.
@param initialName {string} Initial name for the item
@param skipRename {boolean} If true, don't allow the user to rename the item
@param isFolder {boolean} If true, create a folder instead of a file
@return {$.Promise} A promise object that will be resolved with the File
of the created object, or rejected if the user cancelled or entered an illegal
filename. | [
"Create",
"a",
"new",
"item",
"in",
"the",
"current",
"project",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L1114-L1124 | train | Create a new item | [
30522,
3853,
3443,
2638,
9148,
18532,
1006,
2241,
4313,
1010,
3988,
18442,
1010,
13558,
7389,
14074,
1010,
2003,
10371,
2121,
1007,
1063,
2241,
4313,
1027,
2944,
1012,
2131,
4305,
2890,
16761,
25811,
21572,
20614,
1006,
2241,
4313,
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... |
mui-org/material-ui | docs/src/pages/components/grid-list/ImageGridList.js | ImageGridList | function ImageGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={160} className={classes.gridList} cols={3}>
{tileData.map(tile => (
<GridListTile key={tile.img} cols={tile.cols || 1}>
<img src={tile.img} alt={tile.title} />
</GridListTile>
))}
</GridList>
</div>
);
} | javascript | function ImageGridList() {
const classes = useStyles();
return (
<div className={classes.root}>
<GridList cellHeight={160} className={classes.gridList} cols={3}>
{tileData.map(tile => (
<GridListTile key={tile.img} cols={tile.cols || 1}>
<img src={tile.img} alt={tile.title} />
</GridListTile>
))}
</GridList>
</div>
);
} | [
"function",
"ImageGridList",
"(",
")",
"{",
"const",
"classes",
"=",
"useStyles",
"(",
")",
";",
"return",
"(",
"<",
"div",
"className",
"=",
"{",
"classes",
".",
"root",
"}",
">",
"\n ",
"<",
"GridList",
"cellHeight",
"=",
"{",
"160",
"}",
"class... | The example data is structured as follows:
import image from 'path/to/image.jpg';
[etc...]
const tileData = [
{
img: image,
title: 'Image',
author: 'author',
cols: 2,
},
{
[etc...]
},
]; | [
"The",
"example",
"data",
"is",
"structured",
"as",
"follows",
":"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/docs/src/pages/components/grid-list/ImageGridList.js#L39-L53 | train | Creates an image grid list | [
30522,
3853,
3746,
16523,
3593,
9863,
1006,
1007,
1063,
9530,
3367,
4280,
1027,
3594,
27983,
2015,
1006,
1007,
1025,
2709,
1006,
1026,
4487,
2615,
2465,
18442,
1027,
1063,
4280,
1012,
7117,
1065,
1028,
1026,
8370,
9863,
3526,
26036,
13900,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/XHRInterceptor.js | createOverride | function createOverride(sXHRMethod) {
mRegistry[sXHRMethod] = Object.create(null);
// backup the original function
mXHRFunctions[sXHRMethod] = window.XMLHttpRequest.prototype[sXHRMethod];
window.XMLHttpRequest.prototype[sXHRMethod] = function() {
var oArgs = arguments;
// call the original function first
mXHRFunctions[sXHRMethod].apply(this, oArgs);
// call the registered callbacks in order of their registration
for (var sName in mRegistry[sXHRMethod]) {
mRegistry[sXHRMethod][sName].apply(this, oArgs);
}
};
} | javascript | function createOverride(sXHRMethod) {
mRegistry[sXHRMethod] = Object.create(null);
// backup the original function
mXHRFunctions[sXHRMethod] = window.XMLHttpRequest.prototype[sXHRMethod];
window.XMLHttpRequest.prototype[sXHRMethod] = function() {
var oArgs = arguments;
// call the original function first
mXHRFunctions[sXHRMethod].apply(this, oArgs);
// call the registered callbacks in order of their registration
for (var sName in mRegistry[sXHRMethod]) {
mRegistry[sXHRMethod][sName].apply(this, oArgs);
}
};
} | [
"function",
"createOverride",
"(",
"sXHRMethod",
")",
"{",
"mRegistry",
"[",
"sXHRMethod",
"]",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"// backup the original function",
"mXHRFunctions",
"[",
"sXHRMethod",
"]",
"=",
"window",
".",
"XMLHttpRequest",
... | Creates the initial override for an original XHR method.
@param {string} sXHRMethod Name of the actual XHR method
@param {function} fnCallback The registered callback function
@private | [
"Creates",
"the",
"initial",
"override",
"for",
"an",
"original",
"XHR",
"method",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/XHRInterceptor.js#L45-L65 | train | Creates a function that will be called when an XHR method is called. | [
30522,
3853,
3443,
7840,
15637,
1006,
1055,
2595,
8093,
11368,
6806,
2094,
1007,
1063,
2720,
13910,
2923,
2854,
1031,
1055,
2595,
8093,
11368,
6806,
2094,
1033,
1027,
4874,
1012,
3443,
1006,
19701,
1007,
1025,
1013,
1013,
10200,
1996,
2434,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CodeInspection.js | getProviderIDsForLanguage | function getProviderIDsForLanguage(languageId) {
if (!_providers[languageId]) {
return [];
}
return _providers[languageId].map(function (provider) {
return provider.name;
});
} | javascript | function getProviderIDsForLanguage(languageId) {
if (!_providers[languageId]) {
return [];
}
return _providers[languageId].map(function (provider) {
return provider.name;
});
} | [
"function",
"getProviderIDsForLanguage",
"(",
"languageId",
")",
"{",
"if",
"(",
"!",
"_providers",
"[",
"languageId",
"]",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"_providers",
"[",
"languageId",
"]",
".",
"map",
"(",
"function",
"(",
"provider"... | Returns an array of the IDs of providers registered for a specific language
@param {!string} languageId
@return {Array.<string>} Names of registered providers. | [
"Returns",
"an",
"array",
"of",
"the",
"IDs",
"of",
"providers",
"registered",
"for",
"a",
"specific",
"language"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L196-L203 | train | Get the provider names for a language | [
30522,
3853,
2131,
21572,
17258,
11124,
5104,
29278,
25023,
6692,
3351,
1006,
2653,
3593,
1007,
1063,
2065,
1006,
999,
1035,
11670,
1031,
2653,
3593,
1033,
1007,
1063,
2709,
1031,
1033,
1025,
1065,
2709,
1035,
11670,
1031,
2653,
3593,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | initGlobalAPI | function initGlobalAPI (Vue) {
// config
var configDef = {};
configDef.get = function () { return config; };
if (process.env.NODE_ENV !== 'production') {
configDef.set = function () {
warn(
'Do not replace the Vue.config object, set individual fields instead.'
);
};
}
Object.defineProperty(Vue, 'config', configDef);
// exposed util methods.
// NOTE: these are not considered part of the public API - avoid relying on
// them unless you are aware of the risk.
Vue.util = {
warn: warn,
extend: extend,
mergeOptions: mergeOptions,
defineReactive: defineReactive$$1
};
Vue.set = set;
Vue.delete = del;
Vue.nextTick = nextTick;
Vue.options = Object.create(null);
ASSET_TYPES.forEach(function (type) {
Vue.options[type + 's'] = Object.create(null);
});
// this is used to identify the "base" constructor to extend all plain-object
// components with in Weex's multi-instance scenarios.
Vue.options._base = Vue;
extend(Vue.options.components, builtInComponents);
initUse(Vue);
initMixin$1(Vue);
initExtend(Vue);
initAssetRegisters(Vue);
} | javascript | function initGlobalAPI (Vue) {
// config
var configDef = {};
configDef.get = function () { return config; };
if (process.env.NODE_ENV !== 'production') {
configDef.set = function () {
warn(
'Do not replace the Vue.config object, set individual fields instead.'
);
};
}
Object.defineProperty(Vue, 'config', configDef);
// exposed util methods.
// NOTE: these are not considered part of the public API - avoid relying on
// them unless you are aware of the risk.
Vue.util = {
warn: warn,
extend: extend,
mergeOptions: mergeOptions,
defineReactive: defineReactive$$1
};
Vue.set = set;
Vue.delete = del;
Vue.nextTick = nextTick;
Vue.options = Object.create(null);
ASSET_TYPES.forEach(function (type) {
Vue.options[type + 's'] = Object.create(null);
});
// this is used to identify the "base" constructor to extend all plain-object
// components with in Weex's multi-instance scenarios.
Vue.options._base = Vue;
extend(Vue.options.components, builtInComponents);
initUse(Vue);
initMixin$1(Vue);
initExtend(Vue);
initAssetRegisters(Vue);
} | [
"function",
"initGlobalAPI",
"(",
"Vue",
")",
"{",
"// config",
"var",
"configDef",
"=",
"{",
"}",
";",
"configDef",
".",
"get",
"=",
"function",
"(",
")",
"{",
"return",
"config",
";",
"}",
";",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"!=... | /* | [
"/",
"*"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L3899-L3941 | train | Initialize the global API. | [
30522,
3853,
1999,
4183,
23296,
16429,
7911,
8197,
1006,
24728,
2063,
1007,
1063,
1013,
1013,
9530,
8873,
2290,
13075,
9530,
8873,
2290,
3207,
2546,
1027,
1063,
1065,
1025,
9530,
8873,
2290,
3207,
2546,
1012,
2131,
1027,
3853,
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... |
dequelabs/axe-core | lib/core/utils/preload-cssom.js | filerStyleAndLinkAttributesInDocumentFragment | function filerStyleAndLinkAttributesInDocumentFragment(node) {
const nodeName = node.nodeName.toUpperCase();
const linkHref = node.getAttribute('href');
const linkRel = node.getAttribute('rel');
const isLink =
nodeName === 'LINK' &&
linkHref &&
linkRel &&
node.rel.toUpperCase().includes('STYLESHEET');
const isStyle = nodeName === 'STYLE';
return isStyle || (isLink && filterMediaIsPrint(node.media));
} | javascript | function filerStyleAndLinkAttributesInDocumentFragment(node) {
const nodeName = node.nodeName.toUpperCase();
const linkHref = node.getAttribute('href');
const linkRel = node.getAttribute('rel');
const isLink =
nodeName === 'LINK' &&
linkHref &&
linkRel &&
node.rel.toUpperCase().includes('STYLESHEET');
const isStyle = nodeName === 'STYLE';
return isStyle || (isLink && filterMediaIsPrint(node.media));
} | [
"function",
"filerStyleAndLinkAttributesInDocumentFragment",
"(",
"node",
")",
"{",
"const",
"nodeName",
"=",
"node",
".",
"nodeName",
".",
"toUpperCase",
"(",
")",
";",
"const",
"linkHref",
"=",
"node",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"const",
"... | Get all `<style></style>` and `<link>` attributes
-> limit to only `style` or `link` attributes with `rel=stylesheet` and `media != print`
@param {Object} node HTMLElement
@returns {Boolean} | [
"Get",
"all",
"<style",
">",
"<",
"/",
"style",
">",
"and",
"<link",
">",
"attributes",
"-",
">",
"limit",
"to",
"only",
"style",
"or",
"link",
"attributes",
"with",
"rel",
"=",
"stylesheet",
"and",
"media",
"!",
"=",
"print"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/preload-cssom.js#L409-L420 | train | Returns true if the node is a style element and the link attribute is a print | [
30522,
3853,
5371,
12096,
12844,
5685,
13767,
19321,
3089,
8569,
4570,
22254,
10085,
27417,
24475,
29181,
3672,
1006,
13045,
1007,
1063,
9530,
3367,
13045,
18442,
1027,
13045,
1012,
13045,
18442,
1012,
2000,
29547,
18992,
3366,
1006,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js | function (oElement, mAction) {
var oDefaultAggregation = oElement.getMetadata().getAggregation();
var sAggregationName = oDefaultAggregation ? oDefaultAggregation.name : mAction.action.aggregation;
var oModel = oElement.getModel();
return Promise.resolve()
.then(function () {
return _getODataPropertiesOfModel(oElement, sAggregationName);
})
.then(function(mData) {
var aODataProperties = mData.property;
var aRelevantElements = _getRelevantElements(oElement, mAction.relevantContainer, sAggregationName);
var aBindings = [];
aRelevantElements.forEach(function(oElement){
aBindings = aBindings.concat(BindingsExtractor.getBindings(oElement, oModel));
});
var fnFilter = mAction.action.filter ? mAction.action.filter : function() {return true;};
aODataProperties = aODataProperties.filter(function(oDataProperty) {
var bHasBindingPath = false;
if (aBindings){
bHasBindingPath = aBindings.some(function(vBinding) {
return (
jQuery.isPlainObject(vBinding)
? vBinding.parts[0].path
: !!vBinding.getPath && vBinding.getPath()
) === oDataProperty.bindingPath;
});
}
return !bHasBindingPath && fnFilter(mAction.relevantContainer, oDataProperty);
});
aODataProperties = _checkForComplexDuplicates(aODataProperties);
return aODataProperties;
})
.then(function(aUnboundODataProperties) {
return aUnboundODataProperties.map(_oDataPropertyToAdditionalElementInfo);
});
} | javascript | function (oElement, mAction) {
var oDefaultAggregation = oElement.getMetadata().getAggregation();
var sAggregationName = oDefaultAggregation ? oDefaultAggregation.name : mAction.action.aggregation;
var oModel = oElement.getModel();
return Promise.resolve()
.then(function () {
return _getODataPropertiesOfModel(oElement, sAggregationName);
})
.then(function(mData) {
var aODataProperties = mData.property;
var aRelevantElements = _getRelevantElements(oElement, mAction.relevantContainer, sAggregationName);
var aBindings = [];
aRelevantElements.forEach(function(oElement){
aBindings = aBindings.concat(BindingsExtractor.getBindings(oElement, oModel));
});
var fnFilter = mAction.action.filter ? mAction.action.filter : function() {return true;};
aODataProperties = aODataProperties.filter(function(oDataProperty) {
var bHasBindingPath = false;
if (aBindings){
bHasBindingPath = aBindings.some(function(vBinding) {
return (
jQuery.isPlainObject(vBinding)
? vBinding.parts[0].path
: !!vBinding.getPath && vBinding.getPath()
) === oDataProperty.bindingPath;
});
}
return !bHasBindingPath && fnFilter(mAction.relevantContainer, oDataProperty);
});
aODataProperties = _checkForComplexDuplicates(aODataProperties);
return aODataProperties;
})
.then(function(aUnboundODataProperties) {
return aUnboundODataProperties.map(_oDataPropertyToAdditionalElementInfo);
});
} | [
"function",
"(",
"oElement",
",",
"mAction",
")",
"{",
"var",
"oDefaultAggregation",
"=",
"oElement",
".",
"getMetadata",
"(",
")",
".",
"getAggregation",
"(",
")",
";",
"var",
"sAggregationName",
"=",
"oDefaultAggregation",
"?",
"oDefaultAggregation",
".",
"nam... | Retrieves available OData properties from the metadata
@param {sap.ui.core.Control} oElement - Source element of which Model we're looking for additional properties
@param {Object} mAction - Action descriptor
@return {Promise} - returns a Promise which resolves with a list of available to display OData properties | [
"Retrieves",
"available",
"OData",
"properties",
"from",
"the",
"metadata"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js#L519-L560 | train | Returns the additional elements of the given element that are not bound to the given aggregation. | [
30522,
3853,
1006,
1051,
12260,
3672,
1010,
6097,
3508,
1007,
1063,
13075,
24040,
7011,
11314,
8490,
17603,
12540,
1027,
1051,
12260,
3672,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1012,
2131,
8490,
17603,
12540,
1006,
1007,
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... | |
SheetJS/js-xlsx | xlsx.js | write_ws_biff8 | function write_ws_biff8(idx, opts, wb) {
var ba = buf_array();
var s = wb.SheetNames[idx], ws = wb.Sheets[s] || {};
var _WB = ((wb||{}).Workbook||{});
var _sheet = ((_WB.Sheets||[])[idx]||{});
var dense = Array.isArray(ws);
var b8 = opts.biff == 8;
var ref, rr = "", cols = [];
var range = safe_decode_range(ws['!ref'] || "A1");
var MAX_ROWS = b8 ? 65536 : 16384;
if(range.e.c > 0xFF || range.e.r >= MAX_ROWS) {
if(opts.WTF) throw new Error("Range " + (ws['!ref'] || "A1") + " exceeds format limit A1:IV16384");
range.e.c = Math.min(range.e.c, 0xFF);
range.e.r = Math.min(range.e.c, MAX_ROWS-1);
}
write_biff_rec(ba, 0x0809, write_BOF(wb, 0x10, opts));
/* ... */
write_biff_rec(ba, "CalcMode", writeuint16(1));
write_biff_rec(ba, "CalcCount", writeuint16(100));
write_biff_rec(ba, "CalcRefMode", writebool(true));
write_biff_rec(ba, "CalcIter", writebool(false));
write_biff_rec(ba, "CalcDelta", write_Xnum(0.001));
write_biff_rec(ba, "CalcSaveRecalc", writebool(true));
write_biff_rec(ba, "PrintRowCol", writebool(false));
write_biff_rec(ba, "PrintGrid", writebool(false));
write_biff_rec(ba, "GridSet", writeuint16(1));
write_biff_rec(ba, "Guts", write_Guts([0,0]));
/* ... */
write_biff_rec(ba, "HCenter", writebool(false));
write_biff_rec(ba, "VCenter", writebool(false));
/* ... */
write_biff_rec(ba, 0x200, write_Dimensions(range, opts));
/* ... */
if(b8) ws['!links'] = [];
for(var R = range.s.r; R <= range.e.r; ++R) {
rr = encode_row(R);
for(var C = range.s.c; C <= range.e.c; ++C) {
if(R === range.s.r) cols[C] = encode_col(C);
ref = cols[C] + rr;
var cell = dense ? (ws[R]||[])[C] : ws[ref];
if(!cell) continue;
/* write cell */
write_ws_biff8_cell(ba, cell, R, C, opts);
if(b8 && cell.l) ws['!links'].push([ref, cell.l]);
}
}
var cname = _sheet.CodeName || _sheet.name || s;
/* ... */
if(b8 && _WB.Views) write_biff_rec(ba, "Window2", write_Window2(_WB.Views[0]));
/* ... */
if(b8 && (ws['!merges']||[]).length) write_biff_rec(ba, "MergeCells", write_MergeCells(ws['!merges']));
/* ... */
if(b8) write_ws_biff8_hlinks(ba, ws);
/* ... */
write_biff_rec(ba, "CodeName", write_XLUnicodeString(cname, opts));
/* ... */
if(b8) write_FEAT(ba, ws);
/* ... */
write_biff_rec(ba, "EOF");
return ba.end();
} | javascript | function write_ws_biff8(idx, opts, wb) {
var ba = buf_array();
var s = wb.SheetNames[idx], ws = wb.Sheets[s] || {};
var _WB = ((wb||{}).Workbook||{});
var _sheet = ((_WB.Sheets||[])[idx]||{});
var dense = Array.isArray(ws);
var b8 = opts.biff == 8;
var ref, rr = "", cols = [];
var range = safe_decode_range(ws['!ref'] || "A1");
var MAX_ROWS = b8 ? 65536 : 16384;
if(range.e.c > 0xFF || range.e.r >= MAX_ROWS) {
if(opts.WTF) throw new Error("Range " + (ws['!ref'] || "A1") + " exceeds format limit A1:IV16384");
range.e.c = Math.min(range.e.c, 0xFF);
range.e.r = Math.min(range.e.c, MAX_ROWS-1);
}
write_biff_rec(ba, 0x0809, write_BOF(wb, 0x10, opts));
/* ... */
write_biff_rec(ba, "CalcMode", writeuint16(1));
write_biff_rec(ba, "CalcCount", writeuint16(100));
write_biff_rec(ba, "CalcRefMode", writebool(true));
write_biff_rec(ba, "CalcIter", writebool(false));
write_biff_rec(ba, "CalcDelta", write_Xnum(0.001));
write_biff_rec(ba, "CalcSaveRecalc", writebool(true));
write_biff_rec(ba, "PrintRowCol", writebool(false));
write_biff_rec(ba, "PrintGrid", writebool(false));
write_biff_rec(ba, "GridSet", writeuint16(1));
write_biff_rec(ba, "Guts", write_Guts([0,0]));
/* ... */
write_biff_rec(ba, "HCenter", writebool(false));
write_biff_rec(ba, "VCenter", writebool(false));
/* ... */
write_biff_rec(ba, 0x200, write_Dimensions(range, opts));
/* ... */
if(b8) ws['!links'] = [];
for(var R = range.s.r; R <= range.e.r; ++R) {
rr = encode_row(R);
for(var C = range.s.c; C <= range.e.c; ++C) {
if(R === range.s.r) cols[C] = encode_col(C);
ref = cols[C] + rr;
var cell = dense ? (ws[R]||[])[C] : ws[ref];
if(!cell) continue;
/* write cell */
write_ws_biff8_cell(ba, cell, R, C, opts);
if(b8 && cell.l) ws['!links'].push([ref, cell.l]);
}
}
var cname = _sheet.CodeName || _sheet.name || s;
/* ... */
if(b8 && _WB.Views) write_biff_rec(ba, "Window2", write_Window2(_WB.Views[0]));
/* ... */
if(b8 && (ws['!merges']||[]).length) write_biff_rec(ba, "MergeCells", write_MergeCells(ws['!merges']));
/* ... */
if(b8) write_ws_biff8_hlinks(ba, ws);
/* ... */
write_biff_rec(ba, "CodeName", write_XLUnicodeString(cname, opts));
/* ... */
if(b8) write_FEAT(ba, ws);
/* ... */
write_biff_rec(ba, "EOF");
return ba.end();
} | [
"function",
"write_ws_biff8",
"(",
"idx",
",",
"opts",
",",
"wb",
")",
"{",
"var",
"ba",
"=",
"buf_array",
"(",
")",
";",
"var",
"s",
"=",
"wb",
".",
"SheetNames",
"[",
"idx",
"]",
",",
"ws",
"=",
"wb",
".",
"Sheets",
"[",
"s",
"]",
"||",
"{",
... | /* [MS-XLS] 2.1.7.20.5 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"1",
".",
"7",
".",
"20",
".",
"5"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L18674-L18736 | train | Write a sheet to a buffer | [
30522,
3853,
4339,
1035,
1059,
2015,
1035,
12170,
4246,
2620,
1006,
8909,
2595,
1010,
23569,
2015,
1010,
25610,
1007,
1063,
13075,
8670,
1027,
20934,
2546,
1035,
9140,
1006,
1007,
1025,
13075,
1055,
1027,
25610,
1012,
7123,
18442,
2015,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function (oManifest) {
var sVersion = "";
if (oManifest){
var oSapApp = (oManifest.getEntry) ? oManifest.getEntry("sap.app") : oManifest["sap.app"];
if (oSapApp && oSapApp.applicationVersion && oSapApp.applicationVersion.version){
sVersion = oSapApp.applicationVersion.version;
}
} else {
this.log.warning("No Manifest received.");
}
return sVersion;
} | javascript | function (oManifest) {
var sVersion = "";
if (oManifest){
var oSapApp = (oManifest.getEntry) ? oManifest.getEntry("sap.app") : oManifest["sap.app"];
if (oSapApp && oSapApp.applicationVersion && oSapApp.applicationVersion.version){
sVersion = oSapApp.applicationVersion.version;
}
} else {
this.log.warning("No Manifest received.");
}
return sVersion;
} | [
"function",
"(",
"oManifest",
")",
"{",
"var",
"sVersion",
"=",
"\"\"",
";",
"if",
"(",
"oManifest",
")",
"{",
"var",
"oSapApp",
"=",
"(",
"oManifest",
".",
"getEntry",
")",
"?",
"oManifest",
".",
"getEntry",
"(",
"\"sap.app\"",
")",
":",
"oManifest",
... | Returns the semantic application version using format: "major.minor.patch".
@param {object} oManifest - Manifest of the component
@returns {string} Version of application if it is available in the manifest, otherwise an empty string
@public | [
"Returns",
"the",
"semantic",
"application",
"version",
"using",
"format",
":",
"major",
".",
"minor",
".",
"patch",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L1152-L1163 | train | Returns the version of the application | [
30522,
3853,
1006,
16640,
29323,
3367,
1007,
1063,
13075,
17917,
2545,
3258,
1027,
1000,
1000,
1025,
2065,
1006,
16640,
29323,
3367,
1007,
1063,
13075,
9808,
22068,
9397,
1027,
1006,
16640,
29323,
3367,
1012,
2131,
4765,
2854,
1007,
1029,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | lib/jsdoc/ui5/template/publish.js | getConstructorDescription | function getConstructorDescription(symbol) {
var description = symbol.description;
var tags = symbol.tags;
if ( tags ) {
for (var i = 0; i < tags.length; i++) {
if ( tags[i].title === "ui5-settings" && tags[i].text) {
description += "\n</p><p>\n" + tags[i].text;
break;
}
}
}
return description;
} | javascript | function getConstructorDescription(symbol) {
var description = symbol.description;
var tags = symbol.tags;
if ( tags ) {
for (var i = 0; i < tags.length; i++) {
if ( tags[i].title === "ui5-settings" && tags[i].text) {
description += "\n</p><p>\n" + tags[i].text;
break;
}
}
}
return description;
} | [
"function",
"getConstructorDescription",
"(",
"symbol",
")",
"{",
"var",
"description",
"=",
"symbol",
".",
"description",
";",
"var",
"tags",
"=",
"symbol",
".",
"tags",
";",
"if",
"(",
"tags",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"... | Description + Settings | [
"Description",
"+",
"Settings"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/template/publish.js#L4094-L4106 | train | Get constructor description | [
30522,
3853,
2131,
8663,
3367,
6820,
16761,
6155,
23235,
3258,
1006,
6454,
1007,
1063,
13075,
6412,
1027,
6454,
1012,
6412,
1025,
13075,
22073,
1027,
6454,
1012,
22073,
1025,
2065,
1006,
22073,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | _onError | function _onError(event, error, msgData) {
var message;
// Sometimes error.message is undefined
if (!error.message) {
console.warn("Expected a non-empty string in error.message, got this instead:", error.message);
message = JSON.stringify(error);
} else {
message = error.message;
}
// Remove "Uncaught" from the beginning to avoid the inspector popping up
if (message && message.substr(0, 8) === "Uncaught") {
message = message.substr(9);
}
// Additional information, like exactly which parameter could not be processed.
var data = error.data;
if (Array.isArray(data)) {
message += "\n" + data.join("\n");
}
// Show the message, but include the error object for further information (e.g. error code)
console.error(message, error, msgData);
} | javascript | function _onError(event, error, msgData) {
var message;
// Sometimes error.message is undefined
if (!error.message) {
console.warn("Expected a non-empty string in error.message, got this instead:", error.message);
message = JSON.stringify(error);
} else {
message = error.message;
}
// Remove "Uncaught" from the beginning to avoid the inspector popping up
if (message && message.substr(0, 8) === "Uncaught") {
message = message.substr(9);
}
// Additional information, like exactly which parameter could not be processed.
var data = error.data;
if (Array.isArray(data)) {
message += "\n" + data.join("\n");
}
// Show the message, but include the error object for further information (e.g. error code)
console.error(message, error, msgData);
} | [
"function",
"_onError",
"(",
"event",
",",
"error",
",",
"msgData",
")",
"{",
"var",
"message",
";",
"// Sometimes error.message is undefined",
"if",
"(",
"!",
"error",
".",
"message",
")",
"{",
"console",
".",
"warn",
"(",
"\"Expected a non-empty string in error.... | Triggered by Inspector.error | [
"Triggered",
"by",
"Inspector",
".",
"error"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L473-L497 | train | Error handler for the error event | [
30522,
3853,
1035,
2028,
18933,
2099,
1006,
2724,
1010,
7561,
1010,
5796,
2290,
2850,
2696,
1007,
1063,
13075,
4471,
1025,
1013,
1013,
2823,
7561,
1012,
4471,
2003,
6151,
28344,
2065,
1006,
999,
7561,
1012,
4471,
1007,
1063,
10122,
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... |
dcloudio/mui | examples/hello-mui/js/mui.js | function(time) {
if (this.pulldown && !this.disablePulldown) {
if (this.y >= this.options.down.height) {
this.pulldownLoading(undefined, time || 0);
return true;
} else {
!this.loading && this.topPocket.classList.remove(CLASS_VISIBILITY);
}
}
return this._super(time);
} | javascript | function(time) {
if (this.pulldown && !this.disablePulldown) {
if (this.y >= this.options.down.height) {
this.pulldownLoading(undefined, time || 0);
return true;
} else {
!this.loading && this.topPocket.classList.remove(CLASS_VISIBILITY);
}
}
return this._super(time);
} | [
"function",
"(",
"time",
")",
"{",
"if",
"(",
"this",
".",
"pulldown",
"&&",
"!",
"this",
".",
"disablePulldown",
")",
"{",
"if",
"(",
"this",
".",
"y",
">=",
"this",
".",
"options",
".",
"down",
".",
"height",
")",
"{",
"this",
".",
"pulldownLoadi... | API | [
"API"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L4625-L4635 | train | Called when the user is trying to pull down | [
30522,
3853,
1006,
2051,
1007,
1063,
2065,
1006,
2023,
1012,
4139,
7698,
1004,
1004,
999,
2023,
1012,
4487,
19150,
14289,
3363,
7698,
1007,
1063,
2065,
1006,
2023,
1012,
1061,
1028,
1027,
2023,
1012,
7047,
1012,
2091,
1012,
4578,
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... | |
GitbookIO/gitbook | lib/api/encodePage.js | encodePage | function encodePage(output, page) {
var book = output.getBook();
var summary = book.getSummary();
var fs = book.getContentFS();
var file = page.getFile();
// JS Page is based on the JSON output
var result = JSONUtils.encodePage(page, summary);
result.type = file.getType();
result.path = file.getPath();
result.rawPath = fs.resolve(result.path);
deprecate.field(output, 'page.progress', result, 'progress', function() {
return encodeProgress(output, page);
}, '"page.progress" property is deprecated');
deprecate.field(output, 'page.sections', result, 'sections', [
{
content: result.content,
type: 'normal'
}
], '"sections" property is deprecated, use page.content instead');
return result;
} | javascript | function encodePage(output, page) {
var book = output.getBook();
var summary = book.getSummary();
var fs = book.getContentFS();
var file = page.getFile();
// JS Page is based on the JSON output
var result = JSONUtils.encodePage(page, summary);
result.type = file.getType();
result.path = file.getPath();
result.rawPath = fs.resolve(result.path);
deprecate.field(output, 'page.progress', result, 'progress', function() {
return encodeProgress(output, page);
}, '"page.progress" property is deprecated');
deprecate.field(output, 'page.sections', result, 'sections', [
{
content: result.content,
type: 'normal'
}
], '"sections" property is deprecated, use page.content instead');
return result;
} | [
"function",
"encodePage",
"(",
"output",
",",
"page",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"summary",
"=",
"book",
".",
"getSummary",
"(",
")",
";",
"var",
"fs",
"=",
"book",
".",
"getContentFS",
"(",
")",
"... | Encode a page in a context to a JS API
@param {Output} output
@param {Page} page
@return {Object} | [
"Encode",
"a",
"page",
"in",
"a",
"context",
"to",
"a",
"JS",
"API"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodePage.js#L12-L37 | train | Encode a page | [
30522,
3853,
4372,
16044,
13704,
1006,
6434,
1010,
3931,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
12654,
1027,
2338,
1012,
4152,
2819,
7849,
2100,
1006,
1007,
1025,
13075,
1042,
2015,
1027,
2338,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Inspector/Inspector.js | _onMessage | function _onMessage(message) {
var response = JSON.parse(message.data),
msgRecord = _messageCallbacks[response.id],
callback = msgRecord && msgRecord.callback,
msgText = (msgRecord && msgRecord.message) || "No message";
if (msgRecord) {
// Messages with an ID are a response to a command, fire callback
callback(response.result, response.error);
delete _messageCallbacks[response.id];
} else if (response.method) {
// Messages with a method are an event, trigger event handlers
var domainAndMethod = response.method.split("."),
domain = domainAndMethod[0],
method = domainAndMethod[1];
EventDispatcher.triggerWithArray(exports[domain], method, response.params);
}
// Always fire event handlers for all messages/errors
exports.trigger("message", response);
if (response.error) {
exports.trigger("error", response.error, msgText);
}
} | javascript | function _onMessage(message) {
var response = JSON.parse(message.data),
msgRecord = _messageCallbacks[response.id],
callback = msgRecord && msgRecord.callback,
msgText = (msgRecord && msgRecord.message) || "No message";
if (msgRecord) {
// Messages with an ID are a response to a command, fire callback
callback(response.result, response.error);
delete _messageCallbacks[response.id];
} else if (response.method) {
// Messages with a method are an event, trigger event handlers
var domainAndMethod = response.method.split("."),
domain = domainAndMethod[0],
method = domainAndMethod[1];
EventDispatcher.triggerWithArray(exports[domain], method, response.params);
}
// Always fire event handlers for all messages/errors
exports.trigger("message", response);
if (response.error) {
exports.trigger("error", response.error, msgText);
}
} | [
"function",
"_onMessage",
"(",
"message",
")",
"{",
"var",
"response",
"=",
"JSON",
".",
"parse",
"(",
"message",
".",
"data",
")",
",",
"msgRecord",
"=",
"_messageCallbacks",
"[",
"response",
".",
"id",
"]",
",",
"callback",
"=",
"msgRecord",
"&&",
"msg... | Received message from the WebSocket
A message can be one of three things:
1. an error -> report it
2. the response to a previous command -> run the stored callback
3. an event -> trigger an event handler method
@param {object} message | [
"Received",
"message",
"from",
"the",
"WebSocket",
"A",
"message",
"can",
"be",
"one",
"of",
"three",
"things",
":",
"1",
".",
"an",
"error",
"-",
">",
"report",
"it",
"2",
".",
"the",
"response",
"to",
"a",
"previous",
"command",
"-",
">",
"run",
"t... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Inspector/Inspector.js#L210-L235 | train | callback function for all messages | [
30522,
3853,
1035,
2006,
7834,
3736,
3351,
1006,
4471,
1007,
1063,
13075,
3433,
1027,
1046,
3385,
1012,
11968,
3366,
1006,
4471,
1012,
2951,
1007,
1010,
5796,
17603,
27108,
2094,
1027,
1035,
4471,
9289,
20850,
8684,
2015,
1031,
3433,
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... |
vuejs/vuepress | packages/@vuepress/core/lib/node/internal-plugins/routes.js | routesCode | function routesCode (pages) {
function genRoute ({
path: pagePath,
key: componentName,
frontmatter: {
layout
},
regularPath,
_meta
}) {
let code = `
{
name: ${JSON.stringify(componentName)},
path: ${JSON.stringify(pagePath)},
component: GlobalLayout,
beforeEnter: (to, from, next) => {
ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)
},${_meta ? `\n meta: ${JSON.stringify(_meta)}` : ''}
}`
const dncodedPath = decodeURIComponent(pagePath)
if (dncodedPath !== pagePath) {
code += `,
{
path: ${JSON.stringify(dncodedPath)},
redirect: ${JSON.stringify(pagePath)}
}`
}
if (/\/$/.test(pagePath)) {
code += `,
{
path: ${JSON.stringify(pagePath + 'index.html')},
redirect: ${JSON.stringify(pagePath)}
}`
}
if (regularPath !== pagePath) {
code += `,
{
path: ${JSON.stringify(regularPath)},
redirect: ${JSON.stringify(pagePath)}
}`
}
return code
}
const notFoundRoute = `,
{
path: '*',
component: GlobalLayout
}`
return (
`export const routes = [${pages.map(genRoute).join(',')}${notFoundRoute}\n]`
)
} | javascript | function routesCode (pages) {
function genRoute ({
path: pagePath,
key: componentName,
frontmatter: {
layout
},
regularPath,
_meta
}) {
let code = `
{
name: ${JSON.stringify(componentName)},
path: ${JSON.stringify(pagePath)},
component: GlobalLayout,
beforeEnter: (to, from, next) => {
ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)
},${_meta ? `\n meta: ${JSON.stringify(_meta)}` : ''}
}`
const dncodedPath = decodeURIComponent(pagePath)
if (dncodedPath !== pagePath) {
code += `,
{
path: ${JSON.stringify(dncodedPath)},
redirect: ${JSON.stringify(pagePath)}
}`
}
if (/\/$/.test(pagePath)) {
code += `,
{
path: ${JSON.stringify(pagePath + 'index.html')},
redirect: ${JSON.stringify(pagePath)}
}`
}
if (regularPath !== pagePath) {
code += `,
{
path: ${JSON.stringify(regularPath)},
redirect: ${JSON.stringify(pagePath)}
}`
}
return code
}
const notFoundRoute = `,
{
path: '*',
component: GlobalLayout
}`
return (
`export const routes = [${pages.map(genRoute).join(',')}${notFoundRoute}\n]`
)
} | [
"function",
"routesCode",
"(",
"pages",
")",
"{",
"function",
"genRoute",
"(",
"{",
"path",
":",
"pagePath",
",",
"key",
":",
"componentName",
",",
"frontmatter",
":",
"{",
"layout",
"}",
",",
"regularPath",
",",
"_meta",
"}",
")",
"{",
"let",
"code",
... | Get Vue routes code.
@param {array} pages
@returns {string} | [
"Get",
"Vue",
"routes",
"code",
"."
] | 15784acc0cf2e87de3c147895b2c3977b0195d78 | https://github.com/vuejs/vuepress/blob/15784acc0cf2e87de3c147895b2c3977b0195d78/packages/@vuepress/core/lib/node/internal-plugins/routes.js#L31-L88 | train | Generate code for all routes | [
30522,
3853,
5847,
16044,
1006,
5530,
1007,
1063,
3853,
8991,
22494,
2618,
1006,
1063,
4130,
1024,
3931,
15069,
1010,
3145,
1024,
6922,
18442,
1010,
2392,
18900,
3334,
1024,
1063,
9621,
1065,
1010,
3180,
15069,
1010,
1035,
18804,
1065,
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... |
SAP/openui5 | src/sap.ui.codeeditor/src/sap/ui/codeeditor/js/ace/worker-javascript.js | each | function each(obj, cb) {
if (!obj)
return;
if (!Array.isArray(obj) && typeof obj === "object")
obj = Object.keys(obj);
obj.forEach(cb);
} | javascript | function each(obj, cb) {
if (!obj)
return;
if (!Array.isArray(obj) && typeof obj === "object")
obj = Object.keys(obj);
obj.forEach(cb);
} | [
"function",
"each",
"(",
"obj",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"return",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"obj",
")",
"&&",
"typeof",
"obj",
"===",
"\"object\"",
")",
"obj",
"=",
"Object",
".",
"keys",
"(",
"... | Variables that live outside the current file | [
"Variables",
"that",
"live",
"outside",
"the",
"current",
"file"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.codeeditor/src/sap/ui/codeeditor/js/ace/worker-javascript.js#L7837-L7845 | train | Iterate over the objects in the cache | [
30522,
3853,
2169,
1006,
27885,
3501,
1010,
17324,
1007,
1063,
2065,
1006,
999,
27885,
3501,
1007,
2709,
1025,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
27885,
3501,
1007,
1004,
1004,
2828,
11253,
27885,
3501,
1027,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jszip.js | function(buf, crc) {
var c = (typeof(crc) == "undefined" ? 0 : crc) ^ 0xffffffff;
var bArray = typeof buf !== "string";
var n;
if (bArray) {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf[n]) & 0xff] ^ (c >>> 8);
}
} else {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf.charCodeAt(n)) & 0xff] ^ (c >>> 8);
}
}
return c ^ 0xffffffff;
} | javascript | function(buf, crc) {
var c = (typeof(crc) == "undefined" ? 0 : crc) ^ 0xffffffff;
var bArray = typeof buf !== "string";
var n;
if (bArray) {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf[n]) & 0xff] ^ (c >>> 8);
}
} else {
for (n = 0; n < buf.length; n++) {
c = SAP_CRC32_TABLE[(c ^ buf.charCodeAt(n)) & 0xff] ^ (c >>> 8);
}
}
return c ^ 0xffffffff;
} | [
"function",
"(",
"buf",
",",
"crc",
")",
"{",
"var",
"c",
"=",
"(",
"typeof",
"(",
"crc",
")",
"==",
"\"undefined\"",
"?",
"0",
":",
"crc",
")",
"^",
"0xffffffff",
";",
"var",
"bArray",
"=",
"typeof",
"buf",
"!==",
"\"string\"",
";",
"var",
"n",
... | ##### BEGIN: MODIFIED BY SAP functions crc32, utf8encode and utf8decode are replaced with implementations by SAP | [
"#####",
"BEGIN",
":",
"MODIFIED",
"BY",
"SAP",
"functions",
"crc32",
"utf8encode",
"and",
"utf8decode",
"are",
"replaced",
"with",
"implementations",
"by",
"SAP"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L1121-L1138 | train | Compute the CRC32 of the given buffer | [
30522,
3853,
1006,
20934,
2546,
1010,
13675,
2278,
1007,
1063,
13075,
1039,
1027,
1006,
2828,
11253,
1006,
13675,
2278,
1007,
1027,
1027,
1000,
6151,
28344,
1000,
1029,
1014,
1024,
13675,
2278,
1007,
1034,
1014,
2595,
4246,
4246,
4246,
4246... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
swimlane/ngx-datatable | release/utils/camel-case.js | camelCase | function camelCase(str) {
// Replace special characters with a space
str = str.replace(/[^a-zA-Z0-9 ]/g, ' ');
// put a space before an uppercase letter
str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');
// Lower case first character and some other stuff
str = str.replace(/([^a-zA-Z0-9 ])|^[0-9]+/g, '').trim().toLowerCase();
// uppercase characters preceded by a space or number
str = str.replace(/([ 0-9]+)([a-zA-Z])/g, function (a, b, c) {
return b.trim() + c.toUpperCase();
});
return str;
} | javascript | function camelCase(str) {
// Replace special characters with a space
str = str.replace(/[^a-zA-Z0-9 ]/g, ' ');
// put a space before an uppercase letter
str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');
// Lower case first character and some other stuff
str = str.replace(/([^a-zA-Z0-9 ])|^[0-9]+/g, '').trim().toLowerCase();
// uppercase characters preceded by a space or number
str = str.replace(/([ 0-9]+)([a-zA-Z])/g, function (a, b, c) {
return b.trim() + c.toUpperCase();
});
return str;
} | [
"function",
"camelCase",
"(",
"str",
")",
"{",
"// Replace special characters with a space",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"[^a-zA-Z0-9 ]",
"/",
"g",
",",
"' '",
")",
";",
"// put a space before an uppercase letter",
"str",
"=",
"str",
".",
"replace... | Converts strings from something to camel case
http://stackoverflow.com/questions/10425287/convert-dash-separated-string-to-camelcase | [
"Converts",
"strings",
"from",
"something",
"to",
"camel",
"case",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"10425287",
"/",
"convert",
"-",
"dash",
"-",
"separated",
"-",
"string",
"-",
"to",
"-",
"camelcase"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/camel-case.js#L7-L19 | train | Convert a string to camelCase | [
30522,
3853,
19130,
18382,
1006,
2358,
2099,
1007,
1063,
1013,
1013,
5672,
2569,
3494,
2007,
1037,
2686,
2358,
2099,
1027,
2358,
2099,
1012,
5672,
1006,
1013,
1031,
1034,
1037,
1011,
23564,
1011,
1062,
2692,
1011,
1023,
1033,
1013,
1043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
airyland/vux | src/components/clocker/clocker.js | pluralize | function pluralize (format, count) {
var plural = 's'
var singular = ''
if (format) {
format = format.replace(/(:||\s)/gi, '').split(/,/)
if (format.length === 1) {
plural = format[0]
} else {
singular = format[0]
plural = format[1]
}
}
if (Math.abs(count) === 1) {
return singular
} else {
return plural
}
} | javascript | function pluralize (format, count) {
var plural = 's'
var singular = ''
if (format) {
format = format.replace(/(:||\s)/gi, '').split(/,/)
if (format.length === 1) {
plural = format[0]
} else {
singular = format[0]
plural = format[1]
}
}
if (Math.abs(count) === 1) {
return singular
} else {
return plural
}
} | [
"function",
"pluralize",
"(",
"format",
",",
"count",
")",
"{",
"var",
"plural",
"=",
"'s'",
"var",
"singular",
"=",
"''",
"if",
"(",
"format",
")",
"{",
"format",
"=",
"format",
".",
"replace",
"(",
"/",
"(:||\\s)",
"/",
"gi",
",",
"''",
")",
".",... | Pluralize | [
"Pluralize"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/clocker/clocker.js#L117-L134 | train | Pluralize the given number of words in a given format | [
30522,
3853,
13994,
4697,
1006,
4289,
1010,
4175,
1007,
1063,
13075,
30524,
1012,
5672,
1006,
1013,
1006,
1024,
1064,
1064,
1032,
1055,
1007,
1013,
21025,
1010,
1005,
1005,
1007,
1012,
3975,
1006,
1013,
1010,
1013,
1007,
2065,
1006,
4289,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
NetEase/pomelo | lib/util/appUtil.js | function(app) {
app.loadConfigBaseApp(Constants.RESERVED.MASTER, Constants.FILEPATH.MASTER);
app.master = app.get(Constants.RESERVED.MASTER);
} | javascript | function(app) {
app.loadConfigBaseApp(Constants.RESERVED.MASTER, Constants.FILEPATH.MASTER);
app.master = app.get(Constants.RESERVED.MASTER);
} | [
"function",
"(",
"app",
")",
"{",
"app",
".",
"loadConfigBaseApp",
"(",
"Constants",
".",
"RESERVED",
".",
"MASTER",
",",
"Constants",
".",
"FILEPATH",
".",
"MASTER",
")",
";",
"app",
".",
"master",
"=",
"app",
".",
"get",
"(",
"Constants",
".",
"RESER... | Load master info from config/master.json. | [
"Load",
"master",
"info",
"from",
"config",
"/",
"master",
".",
"json",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/util/appUtil.js#L155-L158 | train | Load the master config | [
30522,
3853,
1006,
10439,
1007,
1063,
10439,
1012,
7170,
8663,
8873,
18259,
11022,
29098,
1006,
5377,
2015,
1012,
9235,
1012,
3040,
1010,
5377,
2015,
1012,
5371,
15069,
1012,
3040,
1007,
1025,
10439,
1012,
3040,
1027,
10439,
1012,
2131,
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... | |
expressjs/express | lib/router/index.js | gettype | function gettype(obj) {
var type = typeof obj;
if (type !== 'object') {
return type;
}
// inspect [[Class]] for objects
return toString.call(obj)
.replace(objectRegExp, '$1');
} | javascript | function gettype(obj) {
var type = typeof obj;
if (type !== 'object') {
return type;
}
// inspect [[Class]] for objects
return toString.call(obj)
.replace(objectRegExp, '$1');
} | [
"function",
"gettype",
"(",
"obj",
")",
"{",
"var",
"type",
"=",
"typeof",
"obj",
";",
"if",
"(",
"type",
"!==",
"'object'",
")",
"{",
"return",
"type",
";",
"}",
"// inspect [[Class]] for objects",
"return",
"toString",
".",
"call",
"(",
"obj",
")",
"."... | get type for error message | [
"get",
"type",
"for",
"error",
"message"
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/lib/router/index.js#L552-L562 | train | get type of obj | [
30522,
3853,
2131,
13874,
1006,
27885,
3501,
1007,
1063,
13075,
2828,
1027,
2828,
11253,
27885,
3501,
1025,
2065,
1006,
2828,
999,
1027,
1027,
1005,
4874,
1005,
1007,
1063,
2709,
2828,
1025,
1065,
1013,
1013,
22459,
1031,
1031,
2465,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/View.js | function () {
// Must update after view transform updated
var rawTransformMatrix = this._rawTransformable.getLocalTransform();
var roamTransform = this._roamTransformable;
var defaultCenter = this.getDefaultCenter();
var center = this.getCenter();
var zoom = this.getZoom();
center = vector.applyTransform([], center, rawTransformMatrix);
defaultCenter = vector.applyTransform([], defaultCenter, rawTransformMatrix);
roamTransform.origin = center;
roamTransform.position = [
defaultCenter[0] - center[0],
defaultCenter[1] - center[1]
];
roamTransform.scale = [zoom, zoom];
this._updateTransform();
} | javascript | function () {
// Must update after view transform updated
var rawTransformMatrix = this._rawTransformable.getLocalTransform();
var roamTransform = this._roamTransformable;
var defaultCenter = this.getDefaultCenter();
var center = this.getCenter();
var zoom = this.getZoom();
center = vector.applyTransform([], center, rawTransformMatrix);
defaultCenter = vector.applyTransform([], defaultCenter, rawTransformMatrix);
roamTransform.origin = center;
roamTransform.position = [
defaultCenter[0] - center[0],
defaultCenter[1] - center[1]
];
roamTransform.scale = [zoom, zoom];
this._updateTransform();
} | [
"function",
"(",
")",
"{",
"// Must update after view transform updated",
"var",
"rawTransformMatrix",
"=",
"this",
".",
"_rawTransformable",
".",
"getLocalTransform",
"(",
")",
";",
"var",
"roamTransform",
"=",
"this",
".",
"_roamTransformable",
";",
"var",
"defaultC... | Remove roam | [
"Remove",
"roam"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L189-L208 | train | Update view transform | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
2442,
10651,
2044,
3193,
10938,
7172,
13075,
6315,
6494,
3619,
14192,
18900,
17682,
1027,
2023,
1012,
1035,
6315,
6494,
3619,
14192,
3085,
1012,
2131,
4135,
9289,
6494,
3619,
14192,
1006,
1007,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-unused-vars.js | isForInRef | function isForInRef(ref) {
let target = ref.identifier.parent;
// "for (var ...) { return; }"
if (target.type === "VariableDeclarator") {
target = target.parent.parent;
}
if (target.type !== "ForInStatement") {
return false;
}
// "for (...) { return; }"
if (target.body.type === "BlockStatement") {
target = target.body.body[0];
// "for (...) return;"
} else {
target = target.body;
}
// For empty loop body
if (!target) {
return false;
}
return target.type === "ReturnStatement";
} | javascript | function isForInRef(ref) {
let target = ref.identifier.parent;
// "for (var ...) { return; }"
if (target.type === "VariableDeclarator") {
target = target.parent.parent;
}
if (target.type !== "ForInStatement") {
return false;
}
// "for (...) { return; }"
if (target.body.type === "BlockStatement") {
target = target.body.body[0];
// "for (...) return;"
} else {
target = target.body;
}
// For empty loop body
if (!target) {
return false;
}
return target.type === "ReturnStatement";
} | [
"function",
"isForInRef",
"(",
"ref",
")",
"{",
"let",
"target",
"=",
"ref",
".",
"identifier",
".",
"parent",
";",
"// \"for (var ...) { return; }\"",
"if",
"(",
"target",
".",
"type",
"===",
"\"VariableDeclarator\"",
")",
"{",
"target",
"=",
"target",
".",
... | Determine if an identifier is used either in for-in loops.
@param {Reference} ref - The reference to check.
@returns {boolean} whether reference is used in the for-in loops
@private | [
"Determine",
"if",
"an",
"identifier",
"is",
"used",
"either",
"in",
"for",
"-",
"in",
"loops",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unused-vars.js#L424-L452 | train | Is the given reference a for in statement? | [
30522,
3853,
2003,
29278,
2378,
2890,
2546,
1006,
25416,
1007,
1063,
2292,
4539,
1027,
25416,
1012,
8909,
4765,
18095,
1012,
6687,
1025,
1013,
1013,
1000,
2005,
1006,
13075,
1012,
1012,
1012,
1007,
1063,
2709,
1025,
1065,
1000,
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... |
GitbookIO/gitbook | lib/plugins/resolveVersion.js | resolveVersion | function resolveVersion(plugin) {
var npmId = Plugin.nameToNpmID(plugin.getName());
var requiredVersion = plugin.getVersion();
if (plugin.isGitDependency()) {
return Promise.resolve(requiredVersion);
}
return initNPM()
.then(function() {
return Promise.nfcall(npm.commands.view, [npmId + '@' + requiredVersion, 'engines'], true);
})
.then(function(versions) {
versions = Immutable.Map(versions).entrySeq();
var result = versions
.map(function(entry) {
return {
version: entry[0],
gitbook: (entry[1].engines || {}).gitbook
};
})
.filter(function(v) {
return v.gitbook && gitbook.satisfies(v.gitbook);
})
.sort(function(v1, v2) {
return semver.lt(v1.version, v2.version)? 1 : -1;
})
.get(0);
if (!result) {
return undefined;
} else {
return result.version;
}
});
} | javascript | function resolveVersion(plugin) {
var npmId = Plugin.nameToNpmID(plugin.getName());
var requiredVersion = plugin.getVersion();
if (plugin.isGitDependency()) {
return Promise.resolve(requiredVersion);
}
return initNPM()
.then(function() {
return Promise.nfcall(npm.commands.view, [npmId + '@' + requiredVersion, 'engines'], true);
})
.then(function(versions) {
versions = Immutable.Map(versions).entrySeq();
var result = versions
.map(function(entry) {
return {
version: entry[0],
gitbook: (entry[1].engines || {}).gitbook
};
})
.filter(function(v) {
return v.gitbook && gitbook.satisfies(v.gitbook);
})
.sort(function(v1, v2) {
return semver.lt(v1.version, v2.version)? 1 : -1;
})
.get(0);
if (!result) {
return undefined;
} else {
return result.version;
}
});
} | [
"function",
"resolveVersion",
"(",
"plugin",
")",
"{",
"var",
"npmId",
"=",
"Plugin",
".",
"nameToNpmID",
"(",
"plugin",
".",
"getName",
"(",
")",
")",
";",
"var",
"requiredVersion",
"=",
"plugin",
".",
"getVersion",
"(",
")",
";",
"if",
"(",
"plugin",
... | Resolve a plugin dependency to a version
@param {PluginDependency} plugin
@return {Promise<String>} | [
"Resolve",
"a",
"plugin",
"dependency",
"to",
"a",
"version"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/resolveVersion.js#L33-L69 | train | Resolves the version of a plugin | [
30522,
3853,
10663,
27774,
1006,
13354,
2378,
1007,
1063,
13075,
27937,
4328,
2094,
1027,
13354,
2378,
1012,
2171,
2669,
9737,
3593,
1006,
13354,
2378,
1012,
2131,
18442,
1006,
1007,
1007,
1025,
13075,
3223,
27774,
1027,
13354,
2378,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetView.js | _viewFromEl | function _viewFromEl($el) {
if (!$el.hasClass("working-set-view")) {
$el = $el.parents(".working-set-view");
}
var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop();
return _views[id];
} | javascript | function _viewFromEl($el) {
if (!$el.hasClass("working-set-view")) {
$el = $el.parents(".working-set-view");
}
var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop();
return _views[id];
} | [
"function",
"_viewFromEl",
"(",
"$el",
")",
"{",
"if",
"(",
"!",
"$el",
".",
"hasClass",
"(",
"\"working-set-view\"",
")",
")",
"{",
"$el",
"=",
"$el",
".",
"parents",
"(",
"\".working-set-view\"",
")",
";",
"}",
"var",
"id",
"=",
"$el",
".",
"attr",
... | Finds the WorkingSetView object for the specified element
@private
@param {jQuery} $el - the element to find the view for
@return {View} view object | [
"Finds",
"the",
"WorkingSetView",
"object",
"for",
"the",
"specified",
"element"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L226-L233 | train | Get the view from an element | [
30522,
3853,
1035,
3193,
19699,
8462,
2140,
1006,
1002,
3449,
1007,
1063,
2065,
1006,
999,
1002,
3449,
1012,
2038,
26266,
1006,
1000,
2551,
1011,
2275,
1011,
3193,
1000,
1007,
1007,
1063,
1002,
3449,
1027,
1002,
3449,
1012,
3008,
1006,
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.table/src/sap/ui/table/TableAccExtension.js | function(oEvent) {
var oTable = this.getTable();
if (!oTable) {
return;
}
oTable.$("sapUiTableGridCnt").attr("role", ExtensionHelper.getAriaAttributesFor(this, "CONTENT", {}).role);
oTable._mTimeouts._cleanupACCExtension = setTimeout(function() {
var oTable = this.getTable();
if (!oTable) {
return;
}
this._iLastRowNumber = null;
this._iLastColumnNumber = null;
ExtensionHelper.cleanupCellModifications(this);
oTable._mTimeouts._cleanupACCExtension = null;
}.bind(this), 100);
} | javascript | function(oEvent) {
var oTable = this.getTable();
if (!oTable) {
return;
}
oTable.$("sapUiTableGridCnt").attr("role", ExtensionHelper.getAriaAttributesFor(this, "CONTENT", {}).role);
oTable._mTimeouts._cleanupACCExtension = setTimeout(function() {
var oTable = this.getTable();
if (!oTable) {
return;
}
this._iLastRowNumber = null;
this._iLastColumnNumber = null;
ExtensionHelper.cleanupCellModifications(this);
oTable._mTimeouts._cleanupACCExtension = null;
}.bind(this), 100);
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"oTable",
"=",
"this",
".",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"oTable",
")",
"{",
"return",
";",
"}",
"oTable",
".",
"$",
"(",
"\"sapUiTableGridCnt\"",
")",
".",
"attr",
"(",
"\"role\"",
",",
"Ex... | Delegate for the focusout event.
@private
@param {jQuery.Event} oEvent The event object. | [
"Delegate",
"for",
"the",
"focusout",
"event",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccExtension.js#L976-L992 | train | Called when the user clicks on the grid | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
27178,
3085,
1027,
2023,
1012,
2131,
10880,
1006,
1007,
1025,
2065,
1006,
999,
27178,
3085,
1007,
1063,
2709,
1025,
1065,
27178,
3085,
1012,
1002,
1006,
1000,
20066,
14663,
3085,
1652... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/foldhelpers/foldcode.js | doFold | function doFold(cm, pos, options, force) {
options = options || {};
force = force || "fold";
if (typeof pos === "number") {
pos = CodeMirror.Pos(pos, 0);
}
var finder = options.rangeFinder || CodeMirror.fold.auto,
range,
widget,
textRange;
function getRange(allowFolded) {
var range = options.range || finder(cm, pos);
if (!range || range.to.line - range.from.line < prefs.getSetting("minFoldSize")) {
return null;
}
var marks = cm.findMarksAt(range.from),
i,
lastMark,
foldMarks;
for (i = 0; i < marks.length; ++i) {
if (marks[i].__isFold && force !== "fold") {
if (!allowFolded) {
return null;
}
range.cleared = true;
marks[i].clear();
}
}
//check for overlapping folds
if (marks && marks.length) {
foldMarks = marks.filter(function (d) {
return d.__isFold;
});
if (foldMarks && foldMarks.length) {
lastMark = foldMarks[foldMarks.length - 1].find();
if (lastMark && range.from.line <= lastMark.to.line && lastMark.to.line < range.to.line) {
return null;
}
}
}
return range;
}
function makeWidget() {
var widget = window.document.createElement("span");
widget.className = "CodeMirror-foldmarker";
return widget;
}
range = getRange(true);
if (options.scanUp) {
while (!range && pos.line > cm.firstLine()) {
pos = CodeMirror.Pos(pos.line - 1, 0);
range = getRange(false);
}
}
if (!range || range.cleared || force === "unfold" || range.to.line - range.from.line < prefs.getSetting("minFoldSize")) {
if (range) { range.cleared = false; }
return;
}
widget = makeWidget();
textRange = cm.markText(range.from, range.to, {
replacedWith: widget,
clearOnEnter: true,
__isFold: true
});
CodeMirror.on(widget, "mousedown", function (e) {
textRange.clear();
e.preventDefault();
});
textRange.on("clear", function (from, to) {
delete cm._lineFolds[from.line];
CodeMirror.signal(cm, "unfold", cm, from, to);
});
if (force === "fold") {
delete range.cleared;
// In some cases such as in xml style files, the start of line folds can span multiple lines.
// For instance the attributes of an element can span multiple lines. In these cases when folding
// we want to render a gutter marker for both the beginning and end of the opening xml tag.
if (pos.line < range.from.line) {
cm._lineFolds[range.from.line] = range;
} else {
cm._lineFolds[pos.line] = range;
}
} else {
delete cm._lineFolds[pos.line];
}
CodeMirror.signal(cm, force, cm, range.from, range.to);
return range;
} | javascript | function doFold(cm, pos, options, force) {
options = options || {};
force = force || "fold";
if (typeof pos === "number") {
pos = CodeMirror.Pos(pos, 0);
}
var finder = options.rangeFinder || CodeMirror.fold.auto,
range,
widget,
textRange;
function getRange(allowFolded) {
var range = options.range || finder(cm, pos);
if (!range || range.to.line - range.from.line < prefs.getSetting("minFoldSize")) {
return null;
}
var marks = cm.findMarksAt(range.from),
i,
lastMark,
foldMarks;
for (i = 0; i < marks.length; ++i) {
if (marks[i].__isFold && force !== "fold") {
if (!allowFolded) {
return null;
}
range.cleared = true;
marks[i].clear();
}
}
//check for overlapping folds
if (marks && marks.length) {
foldMarks = marks.filter(function (d) {
return d.__isFold;
});
if (foldMarks && foldMarks.length) {
lastMark = foldMarks[foldMarks.length - 1].find();
if (lastMark && range.from.line <= lastMark.to.line && lastMark.to.line < range.to.line) {
return null;
}
}
}
return range;
}
function makeWidget() {
var widget = window.document.createElement("span");
widget.className = "CodeMirror-foldmarker";
return widget;
}
range = getRange(true);
if (options.scanUp) {
while (!range && pos.line > cm.firstLine()) {
pos = CodeMirror.Pos(pos.line - 1, 0);
range = getRange(false);
}
}
if (!range || range.cleared || force === "unfold" || range.to.line - range.from.line < prefs.getSetting("minFoldSize")) {
if (range) { range.cleared = false; }
return;
}
widget = makeWidget();
textRange = cm.markText(range.from, range.to, {
replacedWith: widget,
clearOnEnter: true,
__isFold: true
});
CodeMirror.on(widget, "mousedown", function (e) {
textRange.clear();
e.preventDefault();
});
textRange.on("clear", function (from, to) {
delete cm._lineFolds[from.line];
CodeMirror.signal(cm, "unfold", cm, from, to);
});
if (force === "fold") {
delete range.cleared;
// In some cases such as in xml style files, the start of line folds can span multiple lines.
// For instance the attributes of an element can span multiple lines. In these cases when folding
// we want to render a gutter marker for both the beginning and end of the opening xml tag.
if (pos.line < range.from.line) {
cm._lineFolds[range.from.line] = range;
} else {
cm._lineFolds[pos.line] = range;
}
} else {
delete cm._lineFolds[pos.line];
}
CodeMirror.signal(cm, force, cm, range.from, range.to);
return range;
} | [
"function",
"doFold",
"(",
"cm",
",",
"pos",
",",
"options",
",",
"force",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"force",
"=",
"force",
"||",
"\"fold\"",
";",
"if",
"(",
"typeof",
"pos",
"===",
"\"number\"",
")",
"{",
"pos",
"="... | Performs the folding and unfolding of code regions.
@param {CodeMirror} cm the CodeMirror instance
@param {number| Object} pos | [
"Performs",
"the",
"folding",
"and",
"unfolding",
"of",
"code",
"regions",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldcode.js#L16-L112 | train | Folds the given position in the editor. | [
30522,
3853,
2079,
10371,
1006,
4642,
1010,
13433,
2015,
1010,
7047,
1010,
2486,
1007,
1063,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2486,
1027,
2486,
1064,
1064,
1000,
10671,
1000,
1025,
2065,
1006,
2828,
11253,
13433,
2015,
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... |
ecomfe/zrender | src/dom/HandlerProxy.js | function (event) {
event = normalizeEvent(this.dom, event);
// Mark touch, which is useful in distinguish touch and
// mouse event in upper applicatoin.
event.zrByTouch = true;
this.handler.processGesture(this, event, 'change');
// Mouse move should always be triggered no matter whether
// there is gestrue event, because mouse move and pinch may
// be used at the same time.
domHandlers.mousemove.call(this, event);
setTouchTimer(this);
} | javascript | function (event) {
event = normalizeEvent(this.dom, event);
// Mark touch, which is useful in distinguish touch and
// mouse event in upper applicatoin.
event.zrByTouch = true;
this.handler.processGesture(this, event, 'change');
// Mouse move should always be triggered no matter whether
// there is gestrue event, because mouse move and pinch may
// be used at the same time.
domHandlers.mousemove.call(this, event);
setTouchTimer(this);
} | [
"function",
"(",
"event",
")",
"{",
"event",
"=",
"normalizeEvent",
"(",
"this",
".",
"dom",
",",
"event",
")",
";",
"// Mark touch, which is useful in distinguish touch and",
"// mouse event in upper applicatoin.",
"event",
".",
"zrByTouch",
"=",
"true",
";",
"this",... | Touch移动响应函数
@inner
@param {Event} event | [
"Touch移动响应函数"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/dom/HandlerProxy.js#L131-L147 | train | Handles mouse move and pinch events. | [
30522,
3853,
1006,
2724,
1007,
1063,
30524,
15185,
22123,
7140,
2818,
1027,
2995,
1025,
2023,
1012,
28213,
1012,
2832,
8449,
11244,
1006,
2023,
1010,
2724,
1010,
1005,
2689,
1005,
1007,
1025,
1013,
1013,
8000,
2693,
2323,
2467,
2022,
13330,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-self-assign.js | isSameMember | function isSameMember(left, right) {
if (!isSameProperty(left, right)) {
return false;
}
const lobj = left.object;
const robj = right.object;
if (lobj.type !== robj.type) {
return false;
}
if (lobj.type === "MemberExpression") {
return isSameMember(lobj, robj);
}
return lobj.type === "Identifier" && lobj.name === robj.name;
} | javascript | function isSameMember(left, right) {
if (!isSameProperty(left, right)) {
return false;
}
const lobj = left.object;
const robj = right.object;
if (lobj.type !== robj.type) {
return false;
}
if (lobj.type === "MemberExpression") {
return isSameMember(lobj, robj);
}
return lobj.type === "Identifier" && lobj.name === robj.name;
} | [
"function",
"isSameMember",
"(",
"left",
",",
"right",
")",
"{",
"if",
"(",
"!",
"isSameProperty",
"(",
"left",
",",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"const",
"lobj",
"=",
"left",
".",
"object",
";",
"const",
"robj",
"=",
"right",... | Checks whether 2 given member expression nodes are the reference to the same
property or not.
@param {ASTNode} left - A member expression node to check.
@param {ASTNode} right - Another member expression node to check.
@returns {boolean} `true` if the member expressions are the reference to the
same property or not. | [
"Checks",
"whether",
"2",
"given",
"member",
"expression",
"nodes",
"are",
"the",
"reference",
"to",
"the",
"same",
"property",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-self-assign.js#L52-L67 | train | Returns true if left is the same member of right | [
30522,
3853,
26354,
14074,
4168,
21784,
1006,
2187,
1010,
2157,
1007,
1063,
2065,
1006,
999,
26354,
14074,
21572,
4842,
3723,
1006,
2187,
1010,
2157,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
9530,
3367,
8840,
2497,
3501,
1027,
2187,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js | getOrFetchSchema | function getOrFetchSchema(oMetaModel, mScope, sSchema, fnLog) {
var oPromise, sUrl, aUrls, mUrls;
/**
* Include the schema (and all of its children) with namespace <code>sSchema</code> from
* the given referenced scope.
*
* @param {object} mReferencedScope
* The $metadata "JSON"
*/
function includeSchema(mReferencedScope) {
var oElement,
sKey;
if (!(sSchema in mReferencedScope)) {
fnLog(WARNING, sUrl, " does not contain ", sSchema);
return;
}
fnLog(DEBUG, "Including ", sSchema, " from ", sUrl);
for (sKey in mReferencedScope) {
// $EntityContainer can be ignored; $Reference, $Version is handled above
if (sKey[0] !== "$" && schema(sKey) === sSchema) {
oElement = mReferencedScope[sKey];
mScope[sKey] = oElement;
mergeAnnotations(oElement, mScope.$Annotations);
}
}
}
if (sSchema in mScope) {
return mScope[sSchema];
}
mUrls = oMetaModel.mSchema2MetadataUrl[sSchema];
if (mUrls) {
aUrls = Object.keys(mUrls);
if (aUrls.length > 1) {
reportAndThrowError(oMetaModel, "A schema cannot span more than one document: "
+ "schema is referenced by following URLs: " + aUrls.join(", "), sSchema);
}
sUrl = aUrls[0];
mUrls[sUrl] = true;
fnLog(DEBUG, "Namespace ", sSchema, " found in $Include of ", sUrl);
oPromise = oMetaModel.mMetadataUrl2Promise[sUrl];
if (!oPromise) {
fnLog(DEBUG, "Reading ", sUrl);
oPromise = oMetaModel.mMetadataUrl2Promise[sUrl]
= SyncPromise.resolve(oMetaModel.oRequestor.read(sUrl))
.then(oMetaModel.validate.bind(oMetaModel, sUrl));
}
oPromise = oPromise.then(includeSchema);
// BEWARE: oPromise may already be resolved, then includeSchema() is done now
if (sSchema in mScope) {
return mScope[sSchema];
}
mScope[sSchema] = oPromise;
return oPromise;
}
} | javascript | function getOrFetchSchema(oMetaModel, mScope, sSchema, fnLog) {
var oPromise, sUrl, aUrls, mUrls;
/**
* Include the schema (and all of its children) with namespace <code>sSchema</code> from
* the given referenced scope.
*
* @param {object} mReferencedScope
* The $metadata "JSON"
*/
function includeSchema(mReferencedScope) {
var oElement,
sKey;
if (!(sSchema in mReferencedScope)) {
fnLog(WARNING, sUrl, " does not contain ", sSchema);
return;
}
fnLog(DEBUG, "Including ", sSchema, " from ", sUrl);
for (sKey in mReferencedScope) {
// $EntityContainer can be ignored; $Reference, $Version is handled above
if (sKey[0] !== "$" && schema(sKey) === sSchema) {
oElement = mReferencedScope[sKey];
mScope[sKey] = oElement;
mergeAnnotations(oElement, mScope.$Annotations);
}
}
}
if (sSchema in mScope) {
return mScope[sSchema];
}
mUrls = oMetaModel.mSchema2MetadataUrl[sSchema];
if (mUrls) {
aUrls = Object.keys(mUrls);
if (aUrls.length > 1) {
reportAndThrowError(oMetaModel, "A schema cannot span more than one document: "
+ "schema is referenced by following URLs: " + aUrls.join(", "), sSchema);
}
sUrl = aUrls[0];
mUrls[sUrl] = true;
fnLog(DEBUG, "Namespace ", sSchema, " found in $Include of ", sUrl);
oPromise = oMetaModel.mMetadataUrl2Promise[sUrl];
if (!oPromise) {
fnLog(DEBUG, "Reading ", sUrl);
oPromise = oMetaModel.mMetadataUrl2Promise[sUrl]
= SyncPromise.resolve(oMetaModel.oRequestor.read(sUrl))
.then(oMetaModel.validate.bind(oMetaModel, sUrl));
}
oPromise = oPromise.then(includeSchema);
// BEWARE: oPromise may already be resolved, then includeSchema() is done now
if (sSchema in mScope) {
return mScope[sSchema];
}
mScope[sSchema] = oPromise;
return oPromise;
}
} | [
"function",
"getOrFetchSchema",
"(",
"oMetaModel",
",",
"mScope",
",",
"sSchema",
",",
"fnLog",
")",
"{",
"var",
"oPromise",
",",
"sUrl",
",",
"aUrls",
",",
"mUrls",
";",
"/**\n\t\t * Include the schema (and all of its children) with namespace <code>sSchema</code> from\n\t\... | Returns the schema with the given namespace, or a promise which is resolved as soon as the
schema has been included, or <code>undefined</code> in case the schema is neither present nor
referenced.
@param {sap.ui.model.odata.v4.ODataMetaModel} oMetaModel
The OData metadata model
@param {object} mScope
The $metadata "JSON" of the root service
@param {string} sSchema
A namespace, for example "foo.bar.", of a schema.
@param {function} fnLog
The log function
@returns {object|SyncPromise|undefined}
The schema, or a promise which is resolved without details or rejected with an error, or
<code>undefined</code>.
@throws {Error}
If the schema has already been loaded and read from a different URI | [
"Returns",
"the",
"schema",
"with",
"the",
"given",
"namespace",
"or",
"a",
"promise",
"which",
"is",
"resolved",
"as",
"soon",
"as",
"the",
"schema",
"has",
"been",
"included",
"or",
"<code",
">",
"undefined<",
"/",
"code",
">",
"in",
"case",
"the",
"sc... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js#L149-L209 | train | Returns the schema that is referenced by the given schema. | [
30522,
3853,
2131,
16347,
3388,
18069,
5403,
2863,
1006,
18168,
12928,
5302,
9247,
1010,
23794,
17635,
1010,
7020,
5403,
2863,
1010,
1042,
20554,
8649,
1007,
1063,
13075,
6728,
21716,
5562,
1010,
7505,
2140,
1010,
8740,
12190,
2015,
1010,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | bower_components/Flot/examples/axes-time-zones/date.js | function (date, type, rule) {
var offset = 0;
if (type === 'u' || type === 'g' || type === 'z') { // UTC
offset = 0;
} else if (type === 's') { // Standard Time
offset = basicOffset;
} else if (type === 'w' || !type) { // Wall Clock Time
offset = getAdjustedOffset(basicOffset, rule);
} else {
throw("unknown type " + type);
}
offset *= 60 * 1000; // to millis
return new Date(date.getTime() + offset);
} | javascript | function (date, type, rule) {
var offset = 0;
if (type === 'u' || type === 'g' || type === 'z') { // UTC
offset = 0;
} else if (type === 's') { // Standard Time
offset = basicOffset;
} else if (type === 'w' || !type) { // Wall Clock Time
offset = getAdjustedOffset(basicOffset, rule);
} else {
throw("unknown type " + type);
}
offset *= 60 * 1000; // to millis
return new Date(date.getTime() + offset);
} | [
"function",
"(",
"date",
",",
"type",
",",
"rule",
")",
"{",
"var",
"offset",
"=",
"0",
";",
"if",
"(",
"type",
"===",
"'u'",
"||",
"type",
"===",
"'g'",
"||",
"type",
"===",
"'z'",
")",
"{",
"// UTC",
"offset",
"=",
"0",
";",
"}",
"else",
"if"... | Convert a date to UTC. Depending on the 'type' parameter, the date parameter may be: - `u`, `g`, `z`: already UTC (no adjustment). - `s`: standard time (adjust for time zone offset but not for DST) - `w`: wall clock time (adjust for both time zone and DST offset). DST adjustment is done using the rule given as third argument. | [
"Convert",
"a",
"date",
"to",
"UTC",
".",
"Depending",
"on",
"the",
"type",
"parameter",
"the",
"date",
"parameter",
"may",
"be",
":",
"-",
"u",
"g",
"z",
":",
"already",
"UTC",
"(",
"no",
"adjustment",
")",
".",
"-",
"s",
":",
"standard",
"time",
... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/Flot/examples/axes-time-zones/date.js#L534-L549 | train | Returns the date | [
30522,
3853,
1006,
3058,
1010,
2828,
1010,
3627,
1007,
1063,
13075,
16396,
1027,
1014,
1025,
2065,
1006,
2828,
1027,
1027,
1027,
1005,
1057,
1005,
1064,
1064,
2828,
1027,
1027,
1027,
1005,
1043,
1005,
1064,
1064,
2828,
1027,
1027,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js | index | function index() {
return Array.prototype.filter.call(oElement.parentNode.childNodes, function (oNode) {
return oNode.nodeType === 1;
}).indexOf(oElement);
} | javascript | function index() {
return Array.prototype.filter.call(oElement.parentNode.childNodes, function (oNode) {
return oNode.nodeType === 1;
}).indexOf(oElement);
} | [
"function",
"index",
"(",
")",
"{",
"return",
"Array",
".",
"prototype",
".",
"filter",
".",
"call",
"(",
"oElement",
".",
"parentNode",
".",
"childNodes",
",",
"function",
"(",
"oNode",
")",
"{",
"return",
"oNode",
".",
"nodeType",
"===",
"1",
";",
"}... | returns the current oElement's index in its parentElement's "children" collection (but works in IE as well) | [
"returns",
"the",
"current",
"oElement",
"s",
"index",
"in",
"its",
"parentElement",
"s",
"children",
"collection",
"(",
"but",
"works",
"in",
"IE",
"as",
"well",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationParser.js#L442-L446 | train | Returns the index of the given element in the DOM | [
30522,
3853,
5950,
1006,
1007,
1063,
2709,
9140,
1012,
8773,
1012,
11307,
1012,
2655,
1006,
1051,
12260,
3672,
1012,
6687,
3630,
3207,
1012,
2775,
3630,
6155,
1010,
3853,
1006,
21058,
3207,
1007,
1063,
2709,
21058,
3207,
1012,
13045,
13874,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/ui-element.js | UIArgument | function UIArgument(uiArgumentShorthand, localVars)
{
/**
* @param uiArgumentShorthand
*
* @throws UIArgumentException
*/
this.validate = function(uiArgumentShorthand)
{
var msg = "UIArgument validation error:\n"
+ print_r(uiArgumentShorthand);
// try really hard to throw an exception!
if (!uiArgumentShorthand.name) {
throw new UIArgumentException(msg + 'no name specified!');
}
if (!uiArgumentShorthand.description) {
throw new UIArgumentException(msg + 'no description specified!');
}
if (!uiArgumentShorthand.defaultValues &&
!uiArgumentShorthand.getDefaultValues) {
throw new UIArgumentException(msg + 'no default values specified!');
}
};
/**
* @param uiArgumentShorthand
* @param localVars a list of local variables
*/
this.init = function(uiArgumentShorthand, localVars)
{
this.validate(uiArgumentShorthand);
this.name = uiArgumentShorthand.name;
this.description = uiArgumentShorthand.description;
this.required = uiArgumentShorthand.required || false;
if (uiArgumentShorthand.defaultValues) {
var defaultValues = uiArgumentShorthand.defaultValues;
this.getDefaultValues =
function() { return defaultValues; }
}
else {
this.getDefaultValues = uiArgumentShorthand.getDefaultValues;
}
for (var name in localVars) {
this[name] = localVars[name];
}
}
this.init(uiArgumentShorthand, localVars);
} | javascript | function UIArgument(uiArgumentShorthand, localVars)
{
/**
* @param uiArgumentShorthand
*
* @throws UIArgumentException
*/
this.validate = function(uiArgumentShorthand)
{
var msg = "UIArgument validation error:\n"
+ print_r(uiArgumentShorthand);
// try really hard to throw an exception!
if (!uiArgumentShorthand.name) {
throw new UIArgumentException(msg + 'no name specified!');
}
if (!uiArgumentShorthand.description) {
throw new UIArgumentException(msg + 'no description specified!');
}
if (!uiArgumentShorthand.defaultValues &&
!uiArgumentShorthand.getDefaultValues) {
throw new UIArgumentException(msg + 'no default values specified!');
}
};
/**
* @param uiArgumentShorthand
* @param localVars a list of local variables
*/
this.init = function(uiArgumentShorthand, localVars)
{
this.validate(uiArgumentShorthand);
this.name = uiArgumentShorthand.name;
this.description = uiArgumentShorthand.description;
this.required = uiArgumentShorthand.required || false;
if (uiArgumentShorthand.defaultValues) {
var defaultValues = uiArgumentShorthand.defaultValues;
this.getDefaultValues =
function() { return defaultValues; }
}
else {
this.getDefaultValues = uiArgumentShorthand.getDefaultValues;
}
for (var name in localVars) {
this[name] = localVars[name];
}
}
this.init(uiArgumentShorthand, localVars);
} | [
"function",
"UIArgument",
"(",
"uiArgumentShorthand",
",",
"localVars",
")",
"{",
"/**\n * @param uiArgumentShorthand\n *\n * @throws UIArgumentException\n */",
"this",
".",
"validate",
"=",
"function",
"(",
"uiArgumentShorthand",
")",
"{",
"var",
"msg",
"=",... | Constructs a UIArgument. This is mostly for checking that the values are
valid.
@param uiArgumentShorthand
@param localVars
@throws UIArgumentException | [
"Constructs",
"a",
"UIArgument",
".",
"This",
"is",
"mostly",
"for",
"checking",
"that",
"the",
"values",
"are",
"valid",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L530-L586 | train | UIArgument constructor. | [
30522,
3853,
21318,
2906,
22850,
4765,
1006,
21318,
2906,
22850,
11187,
27794,
11774,
1010,
2334,
10755,
2015,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
11498,
2213,
21318,
2906,
22850,
11187,
27794,
11774,
1008,
1008,
1030,
11618,
21318,
290... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/scene/screenshot.js | function (evt) {
var shortcutPressed = evt.keyCode === 83 && evt.ctrlKey && evt.altKey;
if (!this.data || !shortcutPressed) { return; }
var projection = evt.shiftKey ? 'equirectangular' : 'perspective';
this.capture(projection);
} | javascript | function (evt) {
var shortcutPressed = evt.keyCode === 83 && evt.ctrlKey && evt.altKey;
if (!this.data || !shortcutPressed) { return; }
var projection = evt.shiftKey ? 'equirectangular' : 'perspective';
this.capture(projection);
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"shortcutPressed",
"=",
"evt",
".",
"keyCode",
"===",
"83",
"&&",
"evt",
".",
"ctrlKey",
"&&",
"evt",
".",
"altKey",
";",
"if",
"(",
"!",
"this",
".",
"data",
"||",
"!",
"shortcutPressed",
")",
"{",
"return",
... | <ctrl> + <alt> + s = Regular screenshot.
<ctrl> + <alt> + <shift> + s = Equirectangular screenshot. | [
"<ctrl",
">",
"+",
"<alt",
">",
"+",
"s",
"=",
"Regular",
"screenshot",
".",
"<ctrl",
">",
"+",
"<alt",
">",
"+",
"<shift",
">",
"+",
"s",
"=",
"Equirectangular",
"screenshot",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/scene/screenshot.js#L121-L126 | train | The event handler for the keydown event | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
13075,
2460,
12690,
19811,
1027,
23408,
2102,
1012,
3145,
16044,
1027,
1027,
1027,
6640,
1004,
1004,
23408,
2102,
1012,
14931,
12190,
14839,
1004,
1004,
23408,
2102,
1012,
12456,
14839,
1025,
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... | |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/WrapSelection.js | convertToArrowFunction | function convertToArrowFunction() {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
initializeRefactoringSession(editor);
var funcExprNode = RefactoringUtils.findSurroundASTNode(current.ast, {start: current.startIndex}, ["Function"]);
if (!funcExprNode || funcExprNode.type !== "FunctionExpression" || funcExprNode.id) {
current.editor.displayErrorMessageAtCursor(Strings.ERROR_ARROW_FUNCTION);
return;
}
if (funcExprNode === "FunctionDeclaration") {
current.editor.displayErrorMessageAtCursor(Strings.ERROR_ARROW_FUNCTION);
return;
}
if (!funcExprNode.body) {
return;
}
var noOfStatements = funcExprNode.body.body.length,
selectedText = current.text.substr(funcExprNode.start, funcExprNode.end - funcExprNode.start),
param = [],
dontChangeParam = false,
numberOfParams = funcExprNode.params.length,
treatAsManyParam = false;
funcExprNode.params.forEach(function (item) {
if (item.type === "Identifier") {
param.push(item.name);
} else if (item.type === "AssignmentPattern") {
dontChangeParam = true;
}
});
//In case defaults params keep params as it is
if (dontChangeParam) {
if (numberOfParams >= 1) {
param.splice(0,param.length);
param.push(current.text.substr(funcExprNode.params[0].start, funcExprNode.params[numberOfParams-1].end - funcExprNode.params[0].start));
// In case default param, treat them as many paramater because to use
// one parameter template, That param should be an identifier
if (numberOfParams === 1) {
treatAsManyParam = true;
}
}
dontChangeParam = false;
}
var loc = {
"fullFunctionScope": {
start: funcExprNode.start,
end: funcExprNode.end
},
"functionsDeclOnly": {
start: funcExprNode.start,
end: funcExprNode.body.start
}
},
locPos = {
"fullFunctionScope": {
"start": current.cm.posFromIndex(loc.fullFunctionScope.start),
"end": current.cm.posFromIndex(loc.fullFunctionScope.end)
},
"functionsDeclOnly": {
"start": current.cm.posFromIndex(loc.functionsDeclOnly.start),
"end": current.cm.posFromIndex(loc.functionsDeclOnly.end)
}
},
isReturnStatement = (noOfStatements >= 1 && funcExprNode.body.body[0].type === "ReturnStatement"),
bodyStatements = funcExprNode.body.body[0],
params;
// If there is nothing in function body, then get the text b/w curly braces
// In this case, We will update params only as per Arrow function expression
if (!bodyStatements) {
bodyStatements = funcExprNode.body;
}
params = {
"params": param.join(", "),
"statement": _.trimRight(current.text.substr(bodyStatements.start, bodyStatements.end - bodyStatements.start), ";")
};
if (isReturnStatement) {
params.statement = params.statement.substr(7).trim();
}
if (noOfStatements === 1) {
current.document.batchOperation(function() {
(numberOfParams === 1 && !treatAsManyParam) ? current.replaceTextFromTemplate(ARROW_FUNCTION, params, locPos.fullFunctionScope, "oneParamOneStament") :
current.replaceTextFromTemplate(ARROW_FUNCTION, params, locPos.fullFunctionScope, "manyParamOneStament");
});
} else {
current.document.batchOperation(function() {
(numberOfParams === 1 && !treatAsManyParam) ? current.replaceTextFromTemplate(ARROW_FUNCTION, {params: param},
locPos.functionsDeclOnly, "oneParamManyStament") :
current.replaceTextFromTemplate(ARROW_FUNCTION, {params: param.join(", ")}, locPos.functionsDeclOnly, "manyParamManyStament");
});
}
current.editor.setCursorPos(locPos.functionsDeclOnly.end.line, locPos.functionsDeclOnly.end.ch, false);
} | javascript | function convertToArrowFunction() {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
initializeRefactoringSession(editor);
var funcExprNode = RefactoringUtils.findSurroundASTNode(current.ast, {start: current.startIndex}, ["Function"]);
if (!funcExprNode || funcExprNode.type !== "FunctionExpression" || funcExprNode.id) {
current.editor.displayErrorMessageAtCursor(Strings.ERROR_ARROW_FUNCTION);
return;
}
if (funcExprNode === "FunctionDeclaration") {
current.editor.displayErrorMessageAtCursor(Strings.ERROR_ARROW_FUNCTION);
return;
}
if (!funcExprNode.body) {
return;
}
var noOfStatements = funcExprNode.body.body.length,
selectedText = current.text.substr(funcExprNode.start, funcExprNode.end - funcExprNode.start),
param = [],
dontChangeParam = false,
numberOfParams = funcExprNode.params.length,
treatAsManyParam = false;
funcExprNode.params.forEach(function (item) {
if (item.type === "Identifier") {
param.push(item.name);
} else if (item.type === "AssignmentPattern") {
dontChangeParam = true;
}
});
//In case defaults params keep params as it is
if (dontChangeParam) {
if (numberOfParams >= 1) {
param.splice(0,param.length);
param.push(current.text.substr(funcExprNode.params[0].start, funcExprNode.params[numberOfParams-1].end - funcExprNode.params[0].start));
// In case default param, treat them as many paramater because to use
// one parameter template, That param should be an identifier
if (numberOfParams === 1) {
treatAsManyParam = true;
}
}
dontChangeParam = false;
}
var loc = {
"fullFunctionScope": {
start: funcExprNode.start,
end: funcExprNode.end
},
"functionsDeclOnly": {
start: funcExprNode.start,
end: funcExprNode.body.start
}
},
locPos = {
"fullFunctionScope": {
"start": current.cm.posFromIndex(loc.fullFunctionScope.start),
"end": current.cm.posFromIndex(loc.fullFunctionScope.end)
},
"functionsDeclOnly": {
"start": current.cm.posFromIndex(loc.functionsDeclOnly.start),
"end": current.cm.posFromIndex(loc.functionsDeclOnly.end)
}
},
isReturnStatement = (noOfStatements >= 1 && funcExprNode.body.body[0].type === "ReturnStatement"),
bodyStatements = funcExprNode.body.body[0],
params;
// If there is nothing in function body, then get the text b/w curly braces
// In this case, We will update params only as per Arrow function expression
if (!bodyStatements) {
bodyStatements = funcExprNode.body;
}
params = {
"params": param.join(", "),
"statement": _.trimRight(current.text.substr(bodyStatements.start, bodyStatements.end - bodyStatements.start), ";")
};
if (isReturnStatement) {
params.statement = params.statement.substr(7).trim();
}
if (noOfStatements === 1) {
current.document.batchOperation(function() {
(numberOfParams === 1 && !treatAsManyParam) ? current.replaceTextFromTemplate(ARROW_FUNCTION, params, locPos.fullFunctionScope, "oneParamOneStament") :
current.replaceTextFromTemplate(ARROW_FUNCTION, params, locPos.fullFunctionScope, "manyParamOneStament");
});
} else {
current.document.batchOperation(function() {
(numberOfParams === 1 && !treatAsManyParam) ? current.replaceTextFromTemplate(ARROW_FUNCTION, {params: param},
locPos.functionsDeclOnly, "oneParamManyStament") :
current.replaceTextFromTemplate(ARROW_FUNCTION, {params: param.join(", ")}, locPos.functionsDeclOnly, "manyParamManyStament");
});
}
current.editor.setCursorPos(locPos.functionsDeclOnly.end.line, locPos.functionsDeclOnly.end.ch, false);
} | [
"function",
"convertToArrowFunction",
"(",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"initializeRefactoringSession",
"(",
"editor",
")",
";",
"var",
"funcEx... | Convert function to arrow function | [
"Convert",
"function",
"to",
"arrow",
"function"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/WrapSelection.js#L122-L227 | train | Convert an arrow function to a function | [
30522,
3853,
10463,
3406,
2906,
10524,
11263,
27989,
1006,
1007,
1063,
13075,
3559,
1027,
3559,
24805,
4590,
1012,
2131,
19620,
2098,
15660,
1006,
1007,
1025,
2065,
1006,
999,
3559,
1007,
1063,
2709,
1025,
1065,
3988,
17629,
12879,
18908,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/Async.js | doInParallel_aggregateErrors | function doInParallel_aggregateErrors(items, beginProcessItem) {
var errors = [];
var masterDeferred = new $.Deferred();
var parallelResult = doInParallel(
items,
function (item, i) {
var itemResult = beginProcessItem(item, i);
itemResult.fail(function (error) {
errors.push({ item: item, error: error });
});
return itemResult;
},
false
);
parallelResult
.done(function () {
masterDeferred.resolve();
})
.fail(function () {
masterDeferred.reject(errors);
});
return masterDeferred.promise();
} | javascript | function doInParallel_aggregateErrors(items, beginProcessItem) {
var errors = [];
var masterDeferred = new $.Deferred();
var parallelResult = doInParallel(
items,
function (item, i) {
var itemResult = beginProcessItem(item, i);
itemResult.fail(function (error) {
errors.push({ item: item, error: error });
});
return itemResult;
},
false
);
parallelResult
.done(function () {
masterDeferred.resolve();
})
.fail(function () {
masterDeferred.reject(errors);
});
return masterDeferred.promise();
} | [
"function",
"doInParallel_aggregateErrors",
"(",
"items",
",",
"beginProcessItem",
")",
"{",
"var",
"errors",
"=",
"[",
"]",
";",
"var",
"masterDeferred",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"parallelResult",
"=",
"doInParallel",
"(",
"it... | Executes a series of tasks in parallel, saving up error info from any that fail along the way.
Returns a Promise that is only resolved/rejected once all tasks are complete. This is
essentially a wrapper around doInParallel(..., false).
If one or more tasks failed, the entire "master" promise is rejected at the end - with one
argument: an array objects, one per failed task. Each error object contains:
- item -- the entry in items whose task failed
- error -- the first argument passed to the fail() handler when the task failed
@param {!Array.<*>} items
@param {!function(*, number):Promise} beginProcessItem
@return {$.Promise} | [
"Executes",
"a",
"series",
"of",
"tasks",
"in",
"parallel",
"saving",
"up",
"error",
"info",
"from",
"any",
"that",
"fail",
"along",
"the",
"way",
".",
"Returns",
"a",
"Promise",
"that",
"is",
"only",
"resolved",
"/",
"rejected",
"once",
"all",
"tasks",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/Async.js#L283-L309 | train | Aggregate all errors in parallel | [
30522,
3853,
24341,
28689,
6216,
2140,
1035,
9572,
2121,
29165,
2015,
1006,
5167,
1010,
4088,
21572,
9623,
28032,
6633,
1007,
1063,
13075,
10697,
1027,
1031,
1033,
1025,
13075,
3040,
3207,
7512,
5596,
1027,
2047,
1002,
1012,
13366,
28849,
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... |
firebase/firebaseui-web | demo/public/app.js | getUiConfig | function getUiConfig() {
return {
'callbacks': {
// Called when the user has been successfully signed in.
'signInSuccessWithAuthResult': function(authResult, redirectUrl) {
if (authResult.user) {
handleSignedInUser(authResult.user);
}
if (authResult.additionalUserInfo) {
document.getElementById('is-new-user').textContent =
authResult.additionalUserInfo.isNewUser ?
'New User' : 'Existing User';
}
// Do not redirect.
return false;
}
},
// Opens IDP Providers sign-in flow in a popup.
'signInFlow': 'popup',
'signInOptions': [
// TODO(developer): Remove the providers you don't need for your app.
{
provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
// Required to enable this provider in One-Tap Sign-up.
authMethod: 'https://accounts.google.com',
// Required to enable ID token credentials for this provider.
clientId: CLIENT_ID
},
{
provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
scopes :[
'public_profile',
'email',
'user_likes',
'user_friends'
]
},
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
firebase.auth.GithubAuthProvider.PROVIDER_ID,
{
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
// Whether the display name should be displayed in Sign Up page.
requireDisplayName: true,
signInMethod: getEmailSignInMethod()
},
{
provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
recaptchaParameters: {
size: getRecaptchaMode()
}
},
{
provider: 'microsoft.com',
providerName: 'Microsoft',
buttonColor: '#2F2F2F',
iconUrl: 'https://docs.microsoft.com/en-us/azure/active-directory/develop/media/howto-add-branding-in-azure-ad-apps/ms-symbollockup_mssymbol_19.png',
loginHintKey: 'login_hint'
},
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
],
// Terms of service url.
'tosUrl': 'https://www.google.com',
// Privacy policy url.
'privacyPolicyUrl': 'https://www.google.com',
'credentialHelper': CLIENT_ID && CLIENT_ID != 'YOUR_OAUTH_CLIENT_ID' ?
firebaseui.auth.CredentialHelper.GOOGLE_YOLO :
firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM
};
} | javascript | function getUiConfig() {
return {
'callbacks': {
// Called when the user has been successfully signed in.
'signInSuccessWithAuthResult': function(authResult, redirectUrl) {
if (authResult.user) {
handleSignedInUser(authResult.user);
}
if (authResult.additionalUserInfo) {
document.getElementById('is-new-user').textContent =
authResult.additionalUserInfo.isNewUser ?
'New User' : 'Existing User';
}
// Do not redirect.
return false;
}
},
// Opens IDP Providers sign-in flow in a popup.
'signInFlow': 'popup',
'signInOptions': [
// TODO(developer): Remove the providers you don't need for your app.
{
provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
// Required to enable this provider in One-Tap Sign-up.
authMethod: 'https://accounts.google.com',
// Required to enable ID token credentials for this provider.
clientId: CLIENT_ID
},
{
provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
scopes :[
'public_profile',
'email',
'user_likes',
'user_friends'
]
},
firebase.auth.TwitterAuthProvider.PROVIDER_ID,
firebase.auth.GithubAuthProvider.PROVIDER_ID,
{
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
// Whether the display name should be displayed in Sign Up page.
requireDisplayName: true,
signInMethod: getEmailSignInMethod()
},
{
provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
recaptchaParameters: {
size: getRecaptchaMode()
}
},
{
provider: 'microsoft.com',
providerName: 'Microsoft',
buttonColor: '#2F2F2F',
iconUrl: 'https://docs.microsoft.com/en-us/azure/active-directory/develop/media/howto-add-branding-in-azure-ad-apps/ms-symbollockup_mssymbol_19.png',
loginHintKey: 'login_hint'
},
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID
],
// Terms of service url.
'tosUrl': 'https://www.google.com',
// Privacy policy url.
'privacyPolicyUrl': 'https://www.google.com',
'credentialHelper': CLIENT_ID && CLIENT_ID != 'YOUR_OAUTH_CLIENT_ID' ?
firebaseui.auth.CredentialHelper.GOOGLE_YOLO :
firebaseui.auth.CredentialHelper.ACCOUNT_CHOOSER_COM
};
} | [
"function",
"getUiConfig",
"(",
")",
"{",
"return",
"{",
"'callbacks'",
":",
"{",
"// Called when the user has been successfully signed in.",
"'signInSuccessWithAuthResult'",
":",
"function",
"(",
"authResult",
",",
"redirectUrl",
")",
"{",
"if",
"(",
"authResult",
".",... | FirebaseUI initialization to be used in a Single Page application context.
@return {!Object} The FirebaseUI config. | [
"FirebaseUI",
"initialization",
"to",
"be",
"used",
"in",
"a",
"Single",
"Page",
"application",
"context",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/demo/public/app.js#L22-L90 | train | Returns the UI configuration for the AuthProvider. | [
30522,
3853,
2131,
10179,
8663,
8873,
2290,
1006,
1007,
1063,
2709,
1063,
1005,
2655,
12221,
1005,
1024,
1063,
1013,
1013,
2170,
2043,
1996,
5310,
2038,
2042,
5147,
2772,
1999,
1012,
1005,
3696,
7076,
14194,
9623,
26760,
26054,
14317,
6072,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/docker-prompts.js | askForServiceDiscovery | function askForServiceDiscovery() {
if (this.regenerate) return;
const done = this.async();
const serviceDiscoveryEnabledApps = [];
this.appConfigs.forEach((appConfig, index) => {
if (appConfig.serviceDiscoveryType) {
serviceDiscoveryEnabledApps.push({
baseName: appConfig.baseName,
serviceDiscoveryType: appConfig.serviceDiscoveryType
});
}
});
if (serviceDiscoveryEnabledApps.length === 0) {
this.serviceDiscoveryType = false;
done();
return;
}
if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'consul')) {
this.serviceDiscoveryType = 'consul';
this.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps'));
done();
} else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'eureka')) {
this.serviceDiscoveryType = 'eureka';
this.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps'));
done();
} else {
this.log(chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.'));
this.log('Your service discovery enabled apps:');
serviceDiscoveryEnabledApps.forEach(app => {
this.log(` -${app.baseName} (${app.serviceDiscoveryType})`);
});
const prompts = [
{
type: 'list',
name: 'serviceDiscoveryType',
message: 'Which Service Discovery registry and Configuration server would you like to use ?',
choices: [
{
value: 'eureka',
name: 'JHipster Registry'
},
{
value: 'consul',
name: 'Consul'
},
{
value: false,
name: 'No Service Discovery and Configuration'
}
],
default: 'eureka'
}
];
this.prompt(prompts).then(props => {
this.serviceDiscoveryType = props.serviceDiscoveryType;
done();
});
}
} | javascript | function askForServiceDiscovery() {
if (this.regenerate) return;
const done = this.async();
const serviceDiscoveryEnabledApps = [];
this.appConfigs.forEach((appConfig, index) => {
if (appConfig.serviceDiscoveryType) {
serviceDiscoveryEnabledApps.push({
baseName: appConfig.baseName,
serviceDiscoveryType: appConfig.serviceDiscoveryType
});
}
});
if (serviceDiscoveryEnabledApps.length === 0) {
this.serviceDiscoveryType = false;
done();
return;
}
if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'consul')) {
this.serviceDiscoveryType = 'consul';
this.log(chalk.green('Consul detected as the service discovery and configuration provider used by your apps'));
done();
} else if (serviceDiscoveryEnabledApps.every(app => app.serviceDiscoveryType === 'eureka')) {
this.serviceDiscoveryType = 'eureka';
this.log(chalk.green('JHipster registry detected as the service discovery and configuration provider used by your apps'));
done();
} else {
this.log(chalk.yellow('Unable to determine the service discovery and configuration provider to use from your apps configuration.'));
this.log('Your service discovery enabled apps:');
serviceDiscoveryEnabledApps.forEach(app => {
this.log(` -${app.baseName} (${app.serviceDiscoveryType})`);
});
const prompts = [
{
type: 'list',
name: 'serviceDiscoveryType',
message: 'Which Service Discovery registry and Configuration server would you like to use ?',
choices: [
{
value: 'eureka',
name: 'JHipster Registry'
},
{
value: 'consul',
name: 'Consul'
},
{
value: false,
name: 'No Service Discovery and Configuration'
}
],
default: 'eureka'
}
];
this.prompt(prompts).then(props => {
this.serviceDiscoveryType = props.serviceDiscoveryType;
done();
});
}
} | [
"function",
"askForServiceDiscovery",
"(",
")",
"{",
"if",
"(",
"this",
".",
"regenerate",
")",
"return",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"serviceDiscoveryEnabledApps",
"=",
"[",
"]",
";",
"this",
".",
"appConfigs",... | Ask For Service Discovery | [
"Ask",
"For",
"Service",
"Discovery"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-prompts.js#L307-L371 | train | Ask For Service Discovery | [
30522,
3853,
3198,
29278,
8043,
7903,
2098,
2483,
3597,
27900,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
19723,
24454,
3686,
1007,
2709,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
22858,
2483,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Core.js | preprocessDependencies | function preprocessDependencies(dependencies) {
if (Array.isArray(dependencies)) {
// remove .library-preload suffix from dependencies
return dependencies.map(function (dep) {
return dep.replace(/\.library-preload$/, '');
});
}
return dependencies;
} | javascript | function preprocessDependencies(dependencies) {
if (Array.isArray(dependencies)) {
// remove .library-preload suffix from dependencies
return dependencies.map(function (dep) {
return dep.replace(/\.library-preload$/, '');
});
}
return dependencies;
} | [
"function",
"preprocessDependencies",
"(",
"dependencies",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"dependencies",
")",
")",
"{",
"// remove .library-preload suffix from dependencies",
"return",
"dependencies",
".",
"map",
"(",
"function",
"(",
"dep",
")"... | Preprocessed given dependencies
@param {object} oDependencies - Dependencies to preprocess
@returns {object} oDependencies - Proprocessed dependencies | [
"Preprocessed",
"given",
"dependencies"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Core.js#L1736-L1744 | train | Preprocess the dependencies array | [
30522,
3853,
17463,
3217,
9623,
16150,
13699,
10497,
15266,
1006,
12530,
15266,
1007,
1063,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
12530,
15266,
1007,
1007,
1063,
1013,
1013,
6366,
1012,
3075,
1011,
3653,
11066,
16809,
2013,
12530,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/util.js | function(element, scrollEnd, duration) {
var scrollStart = element.scrollTop;
var scrollChange = scrollEnd - scrollStart;
var scrollingDown = scrollStart < scrollEnd;
var startTime = $mdUtil.now();
$$rAF(scrollChunk);
function scrollChunk() {
var newPosition = calculateNewPosition();
element.scrollTop = newPosition;
if (scrollingDown ? newPosition < scrollEnd : newPosition > scrollEnd) {
$$rAF(scrollChunk);
}
}
function calculateNewPosition() {
var easeDuration = duration || 1000;
var currentTime = $mdUtil.now() - startTime;
return ease(currentTime, scrollStart, scrollChange, easeDuration);
}
function ease(currentTime, start, change, duration) {
// If the duration has passed (which can occur if our app loses focus due to $$rAF), jump
// straight to the proper position
if (currentTime > duration) {
return start + change;
}
var ts = (currentTime /= duration) * currentTime;
var tc = ts * currentTime;
return start + change * (-2 * tc + 3 * ts);
}
} | javascript | function(element, scrollEnd, duration) {
var scrollStart = element.scrollTop;
var scrollChange = scrollEnd - scrollStart;
var scrollingDown = scrollStart < scrollEnd;
var startTime = $mdUtil.now();
$$rAF(scrollChunk);
function scrollChunk() {
var newPosition = calculateNewPosition();
element.scrollTop = newPosition;
if (scrollingDown ? newPosition < scrollEnd : newPosition > scrollEnd) {
$$rAF(scrollChunk);
}
}
function calculateNewPosition() {
var easeDuration = duration || 1000;
var currentTime = $mdUtil.now() - startTime;
return ease(currentTime, scrollStart, scrollChange, easeDuration);
}
function ease(currentTime, start, change, duration) {
// If the duration has passed (which can occur if our app loses focus due to $$rAF), jump
// straight to the proper position
if (currentTime > duration) {
return start + change;
}
var ts = (currentTime /= duration) * currentTime;
var tc = ts * currentTime;
return start + change * (-2 * tc + 3 * ts);
}
} | [
"function",
"(",
"element",
",",
"scrollEnd",
",",
"duration",
")",
"{",
"var",
"scrollStart",
"=",
"element",
".",
"scrollTop",
";",
"var",
"scrollChange",
"=",
"scrollEnd",
"-",
"scrollStart",
";",
"var",
"scrollingDown",
"=",
"scrollStart",
"<",
"scrollEnd"... | Animate the requested element's scrollTop to the requested scrollPosition with basic easing.
@param {!Element} element The element to scroll.
@param {number} scrollEnd The new/final scroll position.
@param {number=} duration Duration of the scroll. Default is 1000ms. | [
"Animate",
"the",
"requested",
"element",
"s",
"scrollTop",
"to",
"the",
"requested",
"scrollPosition",
"with",
"basic",
"easing",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L817-L854 | train | Scrolls the element to the specified position. | [
30522,
3853,
1006,
5783,
1010,
17186,
10497,
1010,
9367,
1007,
1063,
13075,
23074,
7559,
2102,
1027,
5783,
1012,
17186,
14399,
1025,
13075,
17186,
22305,
2063,
1027,
17186,
10497,
1011,
23074,
7559,
2102,
1025,
13075,
28903,
7698,
1027,
23074... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-irregular-whitespace.js | checkForIrregularWhitespace | function checkForIrregularWhitespace(node) {
const sourceLines = sourceCode.lines;
sourceLines.forEach((sourceLine, lineIndex) => {
const lineNumber = lineIndex + 1;
let match;
while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
const location = {
line: lineNumber,
column: match.index
};
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
}
});
} | javascript | function checkForIrregularWhitespace(node) {
const sourceLines = sourceCode.lines;
sourceLines.forEach((sourceLine, lineIndex) => {
const lineNumber = lineIndex + 1;
let match;
while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
const location = {
line: lineNumber,
column: match.index
};
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
}
});
} | [
"function",
"checkForIrregularWhitespace",
"(",
"node",
")",
"{",
"const",
"sourceLines",
"=",
"sourceCode",
".",
"lines",
";",
"sourceLines",
".",
"forEach",
"(",
"(",
"sourceLine",
",",
"lineIndex",
")",
"=>",
"{",
"const",
"lineNumber",
"=",
"lineIndex",
"+... | Checks the program source for irregular whitespace
@param {ASTNode} node The program node
@returns {void}
@private | [
"Checks",
"the",
"program",
"source",
"for",
"irregular",
"whitespace"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L151-L167 | train | Check if node has irregular whitespace | [
30522,
3853,
4638,
29278,
4313,
2890,
24848,
2906,
2860,
16584,
2229,
15327,
1006,
13045,
1007,
1063,
9530,
3367,
3120,
12735,
1027,
3120,
16044,
1012,
3210,
1025,
3120,
12735,
1012,
18921,
6776,
1006,
1006,
3120,
4179,
1010,
2240,
22254,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js | function(oControl) {
var sControlType = this._getControlTypeInXml(oControl);
jQuery.sap.require(sControlType);
var ControlType = ObjectPath.get(sControlType);
return ControlType.getMetadata();
} | javascript | function(oControl) {
var sControlType = this._getControlTypeInXml(oControl);
jQuery.sap.require(sControlType);
var ControlType = ObjectPath.get(sControlType);
return ControlType.getMetadata();
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"sControlType",
"=",
"this",
".",
"_getControlTypeInXml",
"(",
"oControl",
")",
";",
"jQuery",
".",
"sap",
".",
"require",
"(",
"sControlType",
")",
";",
"var",
"ControlType",
"=",
"ObjectPath",
".",
"get",
"("... | Gets the metadata of am XML control.
@param {Element} oControl - Control in XML
@returns {sap.ui.base.Metadata} Metadata of the control | [
"Gets",
"the",
"metadata",
"of",
"am",
"XML",
"control",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/reflection/BaseTreeModifier.js#L293-L298 | train | Returns the metadata of the control. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
8040,
12162,
13153,
13874,
1027,
2023,
1012,
1035,
2131,
8663,
13181,
24228,
5051,
2378,
2595,
19968,
1006,
1051,
8663,
13181,
2140,
1007,
1025,
1046,
4226,
2854,
1012,
20066,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parsePrimaryExpression | function parsePrimaryExpression() {
var type, token, expr, startToken;
if (match('(')) {
return parseGroupExpression();
}
if (match('[')) {
return parseArrayInitialiser();
}
if (match('{')) {
return parseObjectInitialiser();
}
type = lookahead.type;
startToken = lookahead;
if (type === Token.Identifier) {
expr = delegate.createIdentifier(lex().value);
} else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
if (strict && lookahead.octal) {
throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
}
expr = delegate.createLiteral(lex());
} else if (type === Token.Keyword) {
if (matchKeyword('function')) {
return parseFunctionExpression();
}
if (matchKeyword('this')) {
lex();
expr = delegate.createThisExpression();
} else {
throwUnexpected(lex());
}
} else if (type === Token.BooleanLiteral) {
token = lex();
token.value = (token.value === 'true');
expr = delegate.createLiteral(token);
} else if (type === Token.NullLiteral) {
token = lex();
token.value = null;
expr = delegate.createLiteral(token);
} else if (match('/') || match('/=')) {
if (typeof extra.tokens !== 'undefined') {
expr = delegate.createLiteral(collectRegex());
} else {
expr = delegate.createLiteral(scanRegExp());
}
peek();
} else {
throwUnexpected(lex());
}
return delegate.markEnd(expr, startToken);
} | javascript | function parsePrimaryExpression() {
var type, token, expr, startToken;
if (match('(')) {
return parseGroupExpression();
}
if (match('[')) {
return parseArrayInitialiser();
}
if (match('{')) {
return parseObjectInitialiser();
}
type = lookahead.type;
startToken = lookahead;
if (type === Token.Identifier) {
expr = delegate.createIdentifier(lex().value);
} else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
if (strict && lookahead.octal) {
throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
}
expr = delegate.createLiteral(lex());
} else if (type === Token.Keyword) {
if (matchKeyword('function')) {
return parseFunctionExpression();
}
if (matchKeyword('this')) {
lex();
expr = delegate.createThisExpression();
} else {
throwUnexpected(lex());
}
} else if (type === Token.BooleanLiteral) {
token = lex();
token.value = (token.value === 'true');
expr = delegate.createLiteral(token);
} else if (type === Token.NullLiteral) {
token = lex();
token.value = null;
expr = delegate.createLiteral(token);
} else if (match('/') || match('/=')) {
if (typeof extra.tokens !== 'undefined') {
expr = delegate.createLiteral(collectRegex());
} else {
expr = delegate.createLiteral(scanRegExp());
}
peek();
} else {
throwUnexpected(lex());
}
return delegate.markEnd(expr, startToken);
} | [
"function",
"parsePrimaryExpression",
"(",
")",
"{",
"var",
"type",
",",
"token",
",",
"expr",
",",
"startToken",
";",
"if",
"(",
"match",
"(",
"'('",
")",
")",
"{",
"return",
"parseGroupExpression",
"(",
")",
";",
"}",
"if",
"(",
"match",
"(",
"'['",
... | 11.1 Primary Expressions | [
"11",
".",
"1",
"Primary",
"Expressions"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2151-L2206 | train | ECMA - 262 12. 2 Primary Expressions | [
30522,
3853,
11968,
3366,
18098,
9581,
2854,
10288,
20110,
3258,
1006,
1007,
1063,
13075,
2828,
1010,
19204,
1010,
4654,
18098,
1010,
2707,
18715,
2368,
1025,
2065,
1006,
2674,
1006,
1005,
1006,
1005,
1007,
1007,
1063,
2709,
11968,
3366,
17... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(nodeList, filterFn) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
var parentNode = node.parentNode;
if (parentNode) {
if (!filterFn || filterFn.call(this, node, i, nodeList)) {
parentNode.removeChild(node);
}
}
}
} | javascript | function(nodeList, filterFn) {
for (var i = nodeList.length - 1; i >= 0; i--) {
var node = nodeList[i];
var parentNode = node.parentNode;
if (parentNode) {
if (!filterFn || filterFn.call(this, node, i, nodeList)) {
parentNode.removeChild(node);
}
}
}
} | [
"function",
"(",
"nodeList",
",",
"filterFn",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"nodeList",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"node",
"=",
"nodeList",
"[",
"i",
"]",
";",
"var",
"parentNode",
"=... | Iterates over a NodeList, calls `filterFn` for each node and removes node
if function returned `true`.
If function is not passed, removes all the nodes in node list.
@param NodeList nodeList The nodes to operate on
@param Function filterFn the function to use as a filter
@return void | [
"Iterates",
"over",
"a",
"NodeList",
"calls",
"filterFn",
"for",
"each",
"node",
"and",
"removes",
"node",
"if",
"function",
"returned",
"true",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L175-L185 | train | Remove all nodes in the list | [
30522,
3853,
1006,
13045,
9863,
1010,
11307,
2546,
2078,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
13045,
9863,
1012,
3091,
1011,
1015,
1025,
1045,
1028,
1027,
1014,
1025,
1045,
1011,
1011,
1007,
1063,
13075,
13045,
1027,
13045,
9863,
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... | |
nhn/tui.editor | src/js/wwTableManager.js | tableCellGenerator | function tableCellGenerator(amount, tagName) {
const brHTMLString = '<br />';
const cellString = `<${tagName}>${brHTMLString}</${tagName}>`;
let tdString = '';
for (let i = 0; i < amount; i += 1) {
tdString = tdString + cellString;
}
return tdString;
} | javascript | function tableCellGenerator(amount, tagName) {
const brHTMLString = '<br />';
const cellString = `<${tagName}>${brHTMLString}</${tagName}>`;
let tdString = '';
for (let i = 0; i < amount; i += 1) {
tdString = tdString + cellString;
}
return tdString;
} | [
"function",
"tableCellGenerator",
"(",
"amount",
",",
"tagName",
")",
"{",
"const",
"brHTMLString",
"=",
"'<br />'",
";",
"const",
"cellString",
"=",
"`",
"${",
"tagName",
"}",
"${",
"brHTMLString",
"}",
"${",
"tagName",
"}",
"`",
";",
"let",
"tdString",
"... | Generate table cell HTML text
@param {number} amount Amount of cells
@param {string} tagName Tag name of cell 'td' or 'th'
@private
@returns {string} | [
"Generate",
"table",
"cell",
"HTML",
"text"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wwTableManager.js#L1274-L1284 | train | Generate table cell | [
30522,
3853,
2795,
29109,
28875,
3678,
8844,
1006,
3815,
1010,
6415,
18442,
1007,
1063,
9530,
3367,
7987,
11039,
19968,
3367,
4892,
1027,
1005,
1026,
7987,
1013,
1028,
1005,
1025,
9530,
3367,
4442,
18886,
3070,
1027,
1036,
1026,
1002,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
lovell/sharp | lib/resize.js | extend | function extend (extend) {
if (is.integer(extend) && extend > 0) {
this.options.extendTop = extend;
this.options.extendBottom = extend;
this.options.extendLeft = extend;
this.options.extendRight = extend;
} else if (
is.object(extend) &&
is.integer(extend.top) && extend.top >= 0 &&
is.integer(extend.bottom) && extend.bottom >= 0 &&
is.integer(extend.left) && extend.left >= 0 &&
is.integer(extend.right) && extend.right >= 0
) {
this.options.extendTop = extend.top;
this.options.extendBottom = extend.bottom;
this.options.extendLeft = extend.left;
this.options.extendRight = extend.right;
this._setColourOption('extendBackground', extend.background);
} else {
throw new Error('Invalid edge extension ' + extend);
}
return this;
} | javascript | function extend (extend) {
if (is.integer(extend) && extend > 0) {
this.options.extendTop = extend;
this.options.extendBottom = extend;
this.options.extendLeft = extend;
this.options.extendRight = extend;
} else if (
is.object(extend) &&
is.integer(extend.top) && extend.top >= 0 &&
is.integer(extend.bottom) && extend.bottom >= 0 &&
is.integer(extend.left) && extend.left >= 0 &&
is.integer(extend.right) && extend.right >= 0
) {
this.options.extendTop = extend.top;
this.options.extendBottom = extend.bottom;
this.options.extendLeft = extend.left;
this.options.extendRight = extend.right;
this._setColourOption('extendBackground', extend.background);
} else {
throw new Error('Invalid edge extension ' + extend);
}
return this;
} | [
"function",
"extend",
"(",
"extend",
")",
"{",
"if",
"(",
"is",
".",
"integer",
"(",
"extend",
")",
"&&",
"extend",
">",
"0",
")",
"{",
"this",
".",
"options",
".",
"extendTop",
"=",
"extend",
";",
"this",
".",
"options",
".",
"extendBottom",
"=",
... | Extends/pads the edges of the image with the provided background colour.
This operation will always occur after resizing and extraction, if any.
@example
// Resize to 140 pixels wide, then add 10 transparent pixels
// to the top, left and right edges and 20 to the bottom edge
sharp(input)
.resize(140)
.extend({
top: 10,
bottom: 20,
left: 10,
right: 10,
background: { r: 0, g: 0, b: 0, alpha: 0 }
})
...
@param {(Number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts
@param {Number} [extend.top]
@param {Number} [extend.left]
@param {Number} [extend.bottom]
@param {Number} [extend.right]
@param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.
@returns {Sharp}
@throws {Error} Invalid parameters | [
"Extends",
"/",
"pads",
"the",
"edges",
"of",
"the",
"image",
"with",
"the",
"provided",
"background",
"colour",
".",
"This",
"operation",
"will",
"always",
"occur",
"after",
"resizing",
"and",
"extraction",
"if",
"any",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/resize.js#L291-L313 | train | Extend the edge container | [
30522,
3853,
7949,
1006,
7949,
1007,
1063,
2065,
1006,
2003,
1012,
16109,
1006,
7949,
1007,
1004,
1004,
7949,
1028,
1014,
1007,
1063,
2023,
1012,
7047,
1012,
7949,
14399,
1027,
7949,
1025,
2023,
1012,
7047,
1012,
7949,
18384,
20389,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/select/select.js | calculateMenuPositions | function calculateMenuPositions(scope, element, opts) {
var
containerNode = element[0],
targetNode = opts.target[0].children[0], // target the label
parentNode = $document[0].body,
selectNode = opts.selectEl[0],
contentNode = opts.contentEl[0],
parentRect = parentNode.getBoundingClientRect(),
targetRect = targetNode.getBoundingClientRect(),
shouldOpenAroundTarget = false,
bounds = {
left: parentRect.left + SELECT_EDGE_MARGIN,
top: SELECT_EDGE_MARGIN,
bottom: parentRect.height - SELECT_EDGE_MARGIN,
right: parentRect.width - SELECT_EDGE_MARGIN - ($mdUtil.floatingScrollbars() ? 16 : 0)
},
spaceAvailable = {
top: targetRect.top - bounds.top,
left: targetRect.left - bounds.left,
right: bounds.right - (targetRect.left + targetRect.width),
bottom: bounds.bottom - (targetRect.top + targetRect.height)
},
maxWidth = parentRect.width - SELECT_EDGE_MARGIN * 2,
selectedNode = selectNode.querySelector('md-option[selected]'),
optionNodes = selectNode.getElementsByTagName('md-option'),
optgroupNodes = selectNode.getElementsByTagName('md-optgroup'),
isScrollable = calculateScrollable(element, contentNode),
centeredNode;
var loading = isPromiseLike(opts.loadingAsync);
if (!loading) {
// If a selected node, center around that
if (selectedNode) {
centeredNode = selectedNode;
// If there are option groups, center around the first option group
} else if (optgroupNodes.length) {
centeredNode = optgroupNodes[0];
// Otherwise - if we are not loading async - center around the first optionNode
} else if (optionNodes.length) {
centeredNode = optionNodes[0];
// In case there are no options, center on whatever's in there... (eg progress indicator)
} else {
centeredNode = contentNode.firstElementChild || contentNode;
}
} else {
// If loading, center on progress indicator
centeredNode = contentNode.firstElementChild || contentNode;
}
if (contentNode.offsetWidth > maxWidth) {
contentNode.style['max-width'] = maxWidth + 'px';
} else {
contentNode.style.maxWidth = null;
}
if (shouldOpenAroundTarget) {
contentNode.style['min-width'] = targetRect.width + 'px';
}
// Remove padding before we compute the position of the menu
if (isScrollable) {
selectNode.classList.add('md-overflow');
}
var focusedNode = centeredNode;
if ((focusedNode.tagName || '').toUpperCase() === 'MD-OPTGROUP') {
focusedNode = optionNodes[0] || contentNode.firstElementChild || contentNode;
centeredNode = focusedNode;
}
// Cache for autoFocus()
opts.focusedNode = focusedNode;
// Get the selectMenuRect *after* max-width is possibly set above
containerNode.style.display = 'block';
var selectMenuRect = selectNode.getBoundingClientRect();
var centeredRect = getOffsetRect(centeredNode);
if (centeredNode) {
var centeredStyle = $window.getComputedStyle(centeredNode);
centeredRect.paddingLeft = parseInt(centeredStyle.paddingLeft, 10) || 0;
centeredRect.paddingRight = parseInt(centeredStyle.paddingRight, 10) || 0;
}
if (isScrollable) {
var scrollBuffer = contentNode.offsetHeight / 2;
contentNode.scrollTop = centeredRect.top + centeredRect.height / 2 - scrollBuffer;
if (spaceAvailable.top < scrollBuffer) {
contentNode.scrollTop = Math.min(
centeredRect.top,
contentNode.scrollTop + scrollBuffer - spaceAvailable.top
);
} else if (spaceAvailable.bottom < scrollBuffer) {
contentNode.scrollTop = Math.max(
centeredRect.top + centeredRect.height - selectMenuRect.height,
contentNode.scrollTop - scrollBuffer + spaceAvailable.bottom
);
}
}
var left, top, transformOrigin, minWidth, fontSize;
if (shouldOpenAroundTarget) {
left = targetRect.left;
top = targetRect.top + targetRect.height;
transformOrigin = '50% 0';
if (top + selectMenuRect.height > bounds.bottom) {
top = targetRect.top - selectMenuRect.height;
transformOrigin = '50% 100%';
}
} else {
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft) + 2;
top = Math.floor(targetRect.top + targetRect.height / 2 - centeredRect.height / 2 -
centeredRect.top + contentNode.scrollTop) + 2;
transformOrigin = (centeredRect.left + targetRect.width / 2) + 'px ' +
(centeredRect.top + centeredRect.height / 2 - contentNode.scrollTop) + 'px 0px';
minWidth = Math.min(targetRect.width + centeredRect.paddingLeft + centeredRect.paddingRight, maxWidth);
fontSize = window.getComputedStyle(targetNode)['font-size'];
}
// Keep left and top within the window
var containerRect = containerNode.getBoundingClientRect();
var scaleX = Math.round(100 * Math.min(targetRect.width / selectMenuRect.width, 1.0)) / 100;
var scaleY = Math.round(100 * Math.min(targetRect.height / selectMenuRect.height, 1.0)) / 100;
return {
container: {
element: angular.element(containerNode),
styles: {
left: Math.floor(clamp(bounds.left, left, bounds.right - containerRect.width)),
top: Math.floor(clamp(bounds.top, top, bounds.bottom - containerRect.height)),
'min-width': minWidth,
'font-size': fontSize
}
},
dropDown: {
element: angular.element(selectNode),
styles: {
transformOrigin: transformOrigin,
transform: !opts.alreadyOpen ? $mdUtil.supplant('scale({0},{1})', [scaleX, scaleY]) : ""
}
}
};
} | javascript | function calculateMenuPositions(scope, element, opts) {
var
containerNode = element[0],
targetNode = opts.target[0].children[0], // target the label
parentNode = $document[0].body,
selectNode = opts.selectEl[0],
contentNode = opts.contentEl[0],
parentRect = parentNode.getBoundingClientRect(),
targetRect = targetNode.getBoundingClientRect(),
shouldOpenAroundTarget = false,
bounds = {
left: parentRect.left + SELECT_EDGE_MARGIN,
top: SELECT_EDGE_MARGIN,
bottom: parentRect.height - SELECT_EDGE_MARGIN,
right: parentRect.width - SELECT_EDGE_MARGIN - ($mdUtil.floatingScrollbars() ? 16 : 0)
},
spaceAvailable = {
top: targetRect.top - bounds.top,
left: targetRect.left - bounds.left,
right: bounds.right - (targetRect.left + targetRect.width),
bottom: bounds.bottom - (targetRect.top + targetRect.height)
},
maxWidth = parentRect.width - SELECT_EDGE_MARGIN * 2,
selectedNode = selectNode.querySelector('md-option[selected]'),
optionNodes = selectNode.getElementsByTagName('md-option'),
optgroupNodes = selectNode.getElementsByTagName('md-optgroup'),
isScrollable = calculateScrollable(element, contentNode),
centeredNode;
var loading = isPromiseLike(opts.loadingAsync);
if (!loading) {
// If a selected node, center around that
if (selectedNode) {
centeredNode = selectedNode;
// If there are option groups, center around the first option group
} else if (optgroupNodes.length) {
centeredNode = optgroupNodes[0];
// Otherwise - if we are not loading async - center around the first optionNode
} else if (optionNodes.length) {
centeredNode = optionNodes[0];
// In case there are no options, center on whatever's in there... (eg progress indicator)
} else {
centeredNode = contentNode.firstElementChild || contentNode;
}
} else {
// If loading, center on progress indicator
centeredNode = contentNode.firstElementChild || contentNode;
}
if (contentNode.offsetWidth > maxWidth) {
contentNode.style['max-width'] = maxWidth + 'px';
} else {
contentNode.style.maxWidth = null;
}
if (shouldOpenAroundTarget) {
contentNode.style['min-width'] = targetRect.width + 'px';
}
// Remove padding before we compute the position of the menu
if (isScrollable) {
selectNode.classList.add('md-overflow');
}
var focusedNode = centeredNode;
if ((focusedNode.tagName || '').toUpperCase() === 'MD-OPTGROUP') {
focusedNode = optionNodes[0] || contentNode.firstElementChild || contentNode;
centeredNode = focusedNode;
}
// Cache for autoFocus()
opts.focusedNode = focusedNode;
// Get the selectMenuRect *after* max-width is possibly set above
containerNode.style.display = 'block';
var selectMenuRect = selectNode.getBoundingClientRect();
var centeredRect = getOffsetRect(centeredNode);
if (centeredNode) {
var centeredStyle = $window.getComputedStyle(centeredNode);
centeredRect.paddingLeft = parseInt(centeredStyle.paddingLeft, 10) || 0;
centeredRect.paddingRight = parseInt(centeredStyle.paddingRight, 10) || 0;
}
if (isScrollable) {
var scrollBuffer = contentNode.offsetHeight / 2;
contentNode.scrollTop = centeredRect.top + centeredRect.height / 2 - scrollBuffer;
if (spaceAvailable.top < scrollBuffer) {
contentNode.scrollTop = Math.min(
centeredRect.top,
contentNode.scrollTop + scrollBuffer - spaceAvailable.top
);
} else if (spaceAvailable.bottom < scrollBuffer) {
contentNode.scrollTop = Math.max(
centeredRect.top + centeredRect.height - selectMenuRect.height,
contentNode.scrollTop - scrollBuffer + spaceAvailable.bottom
);
}
}
var left, top, transformOrigin, minWidth, fontSize;
if (shouldOpenAroundTarget) {
left = targetRect.left;
top = targetRect.top + targetRect.height;
transformOrigin = '50% 0';
if (top + selectMenuRect.height > bounds.bottom) {
top = targetRect.top - selectMenuRect.height;
transformOrigin = '50% 100%';
}
} else {
left = (targetRect.left + centeredRect.left - centeredRect.paddingLeft) + 2;
top = Math.floor(targetRect.top + targetRect.height / 2 - centeredRect.height / 2 -
centeredRect.top + contentNode.scrollTop) + 2;
transformOrigin = (centeredRect.left + targetRect.width / 2) + 'px ' +
(centeredRect.top + centeredRect.height / 2 - contentNode.scrollTop) + 'px 0px';
minWidth = Math.min(targetRect.width + centeredRect.paddingLeft + centeredRect.paddingRight, maxWidth);
fontSize = window.getComputedStyle(targetNode)['font-size'];
}
// Keep left and top within the window
var containerRect = containerNode.getBoundingClientRect();
var scaleX = Math.round(100 * Math.min(targetRect.width / selectMenuRect.width, 1.0)) / 100;
var scaleY = Math.round(100 * Math.min(targetRect.height / selectMenuRect.height, 1.0)) / 100;
return {
container: {
element: angular.element(containerNode),
styles: {
left: Math.floor(clamp(bounds.left, left, bounds.right - containerRect.width)),
top: Math.floor(clamp(bounds.top, top, bounds.bottom - containerRect.height)),
'min-width': minWidth,
'font-size': fontSize
}
},
dropDown: {
element: angular.element(selectNode),
styles: {
transformOrigin: transformOrigin,
transform: !opts.alreadyOpen ? $mdUtil.supplant('scale({0},{1})', [scaleX, scaleY]) : ""
}
}
};
} | [
"function",
"calculateMenuPositions",
"(",
"scope",
",",
"element",
",",
"opts",
")",
"{",
"var",
"containerNode",
"=",
"element",
"[",
"0",
"]",
",",
"targetNode",
"=",
"opts",
".",
"target",
"[",
"0",
"]",
".",
"children",
"[",
"0",
"]",
",",
"// tar... | Calculate the | [
"Calculate",
"the"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/select/select.js#L1628-L1773 | train | Calculate the position of the menu | [
30522,
3853,
18422,
3549,
6279,
19234,
2015,
1006,
9531,
1010,
5783,
1010,
23569,
2015,
1007,
1063,
13075,
11661,
3630,
3207,
1027,
5783,
1031,
1014,
1033,
1010,
4539,
3630,
3207,
1027,
23569,
2015,
1012,
4539,
1031,
1014,
1033,
1012,
2336,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | toStepping | function toStepping ( xVal, xPct, value ) {
if ( value >= xVal.slice(-1)[0] ){
return 100;
}
var j = getJ( value, xVal ), va, vb, pa, pb;
va = xVal[j-1];
vb = xVal[j];
pa = xPct[j-1];
pb = xPct[j];
return pa + (toPercentage([va, vb], value) / subRangeRatio (pa, pb));
} | javascript | function toStepping ( xVal, xPct, value ) {
if ( value >= xVal.slice(-1)[0] ){
return 100;
}
var j = getJ( value, xVal ), va, vb, pa, pb;
va = xVal[j-1];
vb = xVal[j];
pa = xPct[j-1];
pb = xPct[j];
return pa + (toPercentage([va, vb], value) / subRangeRatio (pa, pb));
} | [
"function",
"toStepping",
"(",
"xVal",
",",
"xPct",
",",
"value",
")",
"{",
"if",
"(",
"value",
">=",
"xVal",
".",
"slice",
"(",
"-",
"1",
")",
"[",
"0",
"]",
")",
"{",
"return",
"100",
";",
"}",
"var",
"j",
"=",
"getJ",
"(",
"value",
",",
"x... | (percentage) Input a value, find where, on a scale of 0-100, it applies. | [
"(",
"percentage",
")",
"Input",
"a",
"value",
"find",
"where",
"on",
"a",
"scale",
"of",
"0",
"-",
"100",
"it",
"applies",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L208-L222 | train | returns the stepping value | [
30522,
3853,
2000,
13473,
14853,
1006,
15566,
2389,
1010,
26726,
6593,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
1028,
1027,
15566,
2389,
1012,
14704,
1006,
1011,
1015,
1007,
1031,
1014,
1033,
1007,
1063,
2709,
2531,
1025,
1065,
13075,
1046... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Target.js | function () {
this._oParent = null;
this._oOptions = null;
this._oCache = null;
if (this._oTitleProvider) {
this._oTitleProvider.destroy();
}
this._oTitleProvider = null;
EventProvider.prototype.destroy.apply(this, arguments);
this.bIsDestroyed = true;
return this;
} | javascript | function () {
this._oParent = null;
this._oOptions = null;
this._oCache = null;
if (this._oTitleProvider) {
this._oTitleProvider.destroy();
}
this._oTitleProvider = null;
EventProvider.prototype.destroy.apply(this, arguments);
this.bIsDestroyed = true;
return this;
} | [
"function",
"(",
")",
"{",
"this",
".",
"_oParent",
"=",
"null",
";",
"this",
".",
"_oOptions",
"=",
"null",
";",
"this",
".",
"_oCache",
"=",
"null",
";",
"if",
"(",
"this",
".",
"_oTitleProvider",
")",
"{",
"this",
".",
"_oTitleProvider",
".",
"des... | Destroys the target, will be called by {@link sap.m.routing.Targets} don't call this directly.
@protected
@returns { sap.ui.core.routing.Target } this for chaining. | [
"Destroys",
"the",
"target",
"will",
"be",
"called",
"by",
"{",
"@link",
"sap",
".",
"m",
".",
"routing",
".",
"Targets",
"}",
"don",
"t",
"call",
"this",
"directly",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Target.js#L91-L103 | train | Destroys the object | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1035,
6728,
12069,
3372,
1027,
19701,
1025,
2023,
1012,
1035,
1051,
7361,
9285,
1027,
19701,
1025,
2023,
1012,
1035,
1051,
3540,
5403,
1027,
19701,
1025,
2065,
1006,
2023,
1012,
1035,
27178,
4183,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/layout/AbsoluteLayoutRenderer.js | function(oPosition) {
var oPos = oPosition.getComputedPosition();
var addStyle = function(oPosition, aBuffer, sPos, sVal){
if (sVal) {
aBuffer.push(sPos + ":" + sVal + ";");
}
};
var aBuffer = [];
addStyle(oPosition, aBuffer, "top", oPos.top);
addStyle(oPosition, aBuffer, "bottom", oPos.bottom);
addStyle(oPosition, aBuffer, "left", oPos.left);
addStyle(oPosition, aBuffer, "right", oPos.right);
addStyle(oPosition, aBuffer, "width", oPos.width);
addStyle(oPosition, aBuffer, "height", oPos.height);
return aBuffer.join("");
} | javascript | function(oPosition) {
var oPos = oPosition.getComputedPosition();
var addStyle = function(oPosition, aBuffer, sPos, sVal){
if (sVal) {
aBuffer.push(sPos + ":" + sVal + ";");
}
};
var aBuffer = [];
addStyle(oPosition, aBuffer, "top", oPos.top);
addStyle(oPosition, aBuffer, "bottom", oPos.bottom);
addStyle(oPosition, aBuffer, "left", oPos.left);
addStyle(oPosition, aBuffer, "right", oPos.right);
addStyle(oPosition, aBuffer, "width", oPos.width);
addStyle(oPosition, aBuffer, "height", oPos.height);
return aBuffer.join("");
} | [
"function",
"(",
"oPosition",
")",
"{",
"var",
"oPos",
"=",
"oPosition",
".",
"getComputedPosition",
"(",
")",
";",
"var",
"addStyle",
"=",
"function",
"(",
"oPosition",
",",
"aBuffer",
",",
"sPos",
",",
"sVal",
")",
"{",
"if",
"(",
"sVal",
")",
"{",
... | Computes and returns the CSS styles for the given position.
@private | [
"Computes",
"and",
"returns",
"the",
"CSS",
"styles",
"for",
"the",
"given",
"position",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/layout/AbsoluteLayoutRenderer.js#L173-L191 | train | Adds the position style to the buffer | [
30522,
3853,
1006,
6728,
19234,
1007,
1063,
13075,
6728,
2891,
1027,
6728,
19234,
1012,
2131,
9006,
29462,
26994,
1006,
1007,
1025,
13075,
9909,
27983,
1027,
3853,
1006,
6728,
19234,
1010,
8273,
12494,
1010,
11867,
2891,
1010,
17917,
2389,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function (x0, y0, x1, y1, x2, y2, x3, y3)
{
var denom = ((y3 - y2) * (x1 - x0)) - ((x3 - x2) * (y1 - y0));
var nume_a = ((x3 - x2) * (y0 - y2)) - ((y3 - y2) * (x0 - x2));
var nume_b = ((x1 - x0) * (y0 - y2)) - ((y1 - y0) * (x0 - x2));
var ua = nume_a / denom;
var ub = nume_b / denom;
if(ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0)
{
// Get the intersection point
var x = x0 + ua * (x1 - x0);
var y = y0 + ua * (y1 - y0);
return new mxPoint(x, y);
}
// No intersection
return null;
} | javascript | function (x0, y0, x1, y1, x2, y2, x3, y3)
{
var denom = ((y3 - y2) * (x1 - x0)) - ((x3 - x2) * (y1 - y0));
var nume_a = ((x3 - x2) * (y0 - y2)) - ((y3 - y2) * (x0 - x2));
var nume_b = ((x1 - x0) * (y0 - y2)) - ((y1 - y0) * (x0 - x2));
var ua = nume_a / denom;
var ub = nume_b / denom;
if(ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0)
{
// Get the intersection point
var x = x0 + ua * (x1 - x0);
var y = y0 + ua * (y1 - y0);
return new mxPoint(x, y);
}
// No intersection
return null;
} | [
"function",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"x3",
",",
"y3",
")",
"{",
"var",
"denom",
"=",
"(",
"(",
"y3",
"-",
"y2",
")",
"*",
"(",
"x1",
"-",
"x0",
")",
")",
"-",
"(",
"(",
"x3",
"-",
"x2",
")... | Function: intersection
Returns the intersection of two lines as an <mxPoint>.
Parameters:
x0 - X-coordinate of the first line's startpoint.
y0 - X-coordinate of the first line's startpoint.
x1 - X-coordinate of the first line's endpoint.
y1 - Y-coordinate of the first line's endpoint.
x2 - X-coordinate of the second line's startpoint.
y2 - Y-coordinate of the second line's startpoint.
x3 - X-coordinate of the second line's endpoint.
y3 - Y-coordinate of the second line's endpoint. | [
"Function",
":",
"intersection"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L5015-L5035 | train | Returns the intersection point of two points | [
30522,
3853,
1006,
1060,
2692,
1010,
1061,
2692,
1010,
1060,
2487,
1010,
1061,
2487,
1010,
1060,
2475,
1010,
1061,
2475,
1010,
1060,
2509,
1010,
1061,
2509,
1007,
1063,
13075,
7939,
5358,
1027,
1006,
1006,
1061,
2509,
1011,
1061,
2475,
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... | |
summernote/summernote | src/js/base/core/lists.js | all | function all(array, pred) {
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!pred(array[idx])) {
return false;
}
}
return true;
} | javascript | function all(array, pred) {
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!pred(array[idx])) {
return false;
}
}
return true;
} | [
"function",
"all",
"(",
"array",
",",
"pred",
")",
"{",
"for",
"(",
"let",
"idx",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"idx",
"<",
"len",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"!",
"pred",
"(",
"array",
"[",
"idx",
"]",
... | returns true if all of the values in the array pass the predicate truth test. | [
"returns",
"true",
"if",
"all",
"of",
"the",
"values",
"in",
"the",
"array",
"pass",
"the",
"predicate",
"truth",
"test",
"."
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/lists.js#L54-L61 | train | Returns true if all elements in array are true | [
30522,
3853,
2035,
1006,
9140,
1010,
3653,
2094,
1007,
1063,
2005,
1006,
2292,
8909,
2595,
1027,
1014,
1010,
18798,
1027,
9140,
1012,
3091,
1025,
8909,
2595,
1026,
18798,
1025,
8909,
2595,
1009,
1009,
1007,
1063,
2065,
1006,
999,
3653,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/CodeHintList.js | _itemsPerPage | function _itemsPerPage() {
var itemsPerPage = 1,
$items = self.$hintMenu.find("li"),
$view = self.$hintMenu.find("ul.dropdown-menu"),
itemHeight;
if ($items.length !== 0) {
itemHeight = $($items[0]).height();
if (itemHeight) {
// round down to integer value
itemsPerPage = Math.floor($view.height() / itemHeight);
itemsPerPage = Math.max(1, Math.min(itemsPerPage, $items.length));
}
}
return itemsPerPage;
} | javascript | function _itemsPerPage() {
var itemsPerPage = 1,
$items = self.$hintMenu.find("li"),
$view = self.$hintMenu.find("ul.dropdown-menu"),
itemHeight;
if ($items.length !== 0) {
itemHeight = $($items[0]).height();
if (itemHeight) {
// round down to integer value
itemsPerPage = Math.floor($view.height() / itemHeight);
itemsPerPage = Math.max(1, Math.min(itemsPerPage, $items.length));
}
}
return itemsPerPage;
} | [
"function",
"_itemsPerPage",
"(",
")",
"{",
"var",
"itemsPerPage",
"=",
"1",
",",
"$items",
"=",
"self",
".",
"$hintMenu",
".",
"find",
"(",
"\"li\"",
")",
",",
"$view",
"=",
"self",
".",
"$hintMenu",
".",
"find",
"(",
"\"ul.dropdown-menu\"",
")",
",",
... | Calculate the number of items per scroll page. | [
"Calculate",
"the",
"number",
"of",
"items",
"per",
"scroll",
"page",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/CodeHintList.js#L389-L405 | train | Get items per page | [
30522,
3853,
1035,
5167,
4842,
13704,
1006,
1007,
1063,
13075,
5167,
4842,
13704,
1027,
1015,
1010,
1002,
5167,
1027,
2969,
1012,
1002,
9374,
3549,
2226,
1012,
2424,
1006,
1000,
5622,
1000,
1007,
1010,
1002,
3193,
1027,
2969,
1012,
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/JSUtils/Session.js | Session | function Session(editor) {
this.editor = editor;
this.path = editor.document.file.fullPath;
this.ternHints = [];
this.ternGuesses = null;
this.fnType = null;
this.builtins = null;
} | javascript | function Session(editor) {
this.editor = editor;
this.path = editor.document.file.fullPath;
this.ternHints = [];
this.ternGuesses = null;
this.fnType = null;
this.builtins = null;
} | [
"function",
"Session",
"(",
"editor",
")",
"{",
"this",
".",
"editor",
"=",
"editor",
";",
"this",
".",
"path",
"=",
"editor",
".",
"document",
".",
"file",
".",
"fullPath",
";",
"this",
".",
"ternHints",
"=",
"[",
"]",
";",
"this",
".",
"ternGuesses... | Session objects encapsulate state associated with a hinting session
and provide methods for updating and querying the session.
@constructor
@param {Editor} editor - the editor context for the session | [
"Session",
"objects",
"encapsulate",
"state",
"associated",
"with",
"a",
"hinting",
"session",
"and",
"provide",
"methods",
"for",
"updating",
"and",
"querying",
"the",
"session",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/Session.js#L45-L52 | train | Session constructor. | [
30522,
3853,
5219,
1006,
3559,
1007,
1063,
2023,
1012,
3559,
1027,
3559,
1025,
2023,
1012,
4130,
1027,
3559,
1012,
6254,
1012,
5371,
1012,
2440,
15069,
1025,
2023,
1012,
28774,
25311,
18447,
2015,
1027,
1031,
1033,
1025,
2023,
1012,
28774,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/xpath/util.js | copyArrayIgnoringAttributesWithoutValue | function copyArrayIgnoringAttributesWithoutValue(dst, src)
{
if (!src) return;
for (var i = src.length - 1; i >= 0; --i) {
// this test will pass so long as the attribute has a non-empty string
// value, even if that value is "false", "0", "undefined", etc.
if (src[i].nodeValue) {
dst.push(src[i]);
}
}
} | javascript | function copyArrayIgnoringAttributesWithoutValue(dst, src)
{
if (!src) return;
for (var i = src.length - 1; i >= 0; --i) {
// this test will pass so long as the attribute has a non-empty string
// value, even if that value is "false", "0", "undefined", etc.
if (src[i].nodeValue) {
dst.push(src[i]);
}
}
} | [
"function",
"copyArrayIgnoringAttributesWithoutValue",
"(",
"dst",
",",
"src",
")",
"{",
"if",
"(",
"!",
"src",
")",
"return",
";",
"for",
"(",
"var",
"i",
"=",
"src",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"// this... | This is an optimization for copying attribute lists in IE. IE includes many
extraneous properties in its DOM attribute lists, which take require
significant extra processing when evaluating attribute steps. With this
function, we ignore any such attributes that has an empty string value. | [
"This",
"is",
"an",
"optimization",
"for",
"copying",
"attribute",
"lists",
"in",
"IE",
".",
"IE",
"includes",
"many",
"extraneous",
"properties",
"in",
"its",
"DOM",
"attribute",
"lists",
"which",
"take",
"require",
"significant",
"extra",
"processing",
"when",... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L235-L245 | train | copy array without value | [
30522,
3853,
6100,
2906,
9447,
23773,
28741,
20697,
18886,
8569,
4570,
24415,
5833,
10175,
5657,
1006,
16233,
2102,
1010,
5034,
2278,
1007,
1063,
2065,
1006,
999,
5034,
2278,
1007,
2709,
1025,
2005,
1006,
13075,
1045,
1027,
5034,
2278,
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... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/FlexController.js | function (sComponentName, sAppVersion) {
this._oChangePersistence = undefined;
this._sComponentName = sComponentName || "";
this._sAppVersion = sAppVersion || Utils.DEFAULT_APP_VERSION;
if (this._sComponentName && this._sAppVersion) {
this._createChangePersistence();
}
} | javascript | function (sComponentName, sAppVersion) {
this._oChangePersistence = undefined;
this._sComponentName = sComponentName || "";
this._sAppVersion = sAppVersion || Utils.DEFAULT_APP_VERSION;
if (this._sComponentName && this._sAppVersion) {
this._createChangePersistence();
}
} | [
"function",
"(",
"sComponentName",
",",
"sAppVersion",
")",
"{",
"this",
".",
"_oChangePersistence",
"=",
"undefined",
";",
"this",
".",
"_sComponentName",
"=",
"sComponentName",
"||",
"\"\"",
";",
"this",
".",
"_sAppVersion",
"=",
"sAppVersion",
"||",
"Utils",
... | Retrieves changes (LabelChange, etc.) for an sap.ui.core.mvc.View and applies these changes
@param {string} sComponentName - Component name the flexibility controller is responsible for
@param {string} sAppVersion - Current version of the application
@constructor
@class
@alias sap.ui.fl.FlexController
@experimental Since 1.27.0
@author SAP SE
@version ${version} | [
"Retrieves",
"changes",
"(",
"LabelChange",
"etc",
".",
")",
"for",
"an",
"sap",
".",
"ui",
".",
"core",
".",
"mvc",
".",
"View",
"and",
"applies",
"these",
"changes"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/FlexController.js#L46-L53 | train | Creates a change persistence instance | [
30522,
3853,
1006,
8040,
25377,
5643,
3372,
18442,
1010,
20066,
2361,
27774,
1007,
1063,
2023,
1012,
1035,
28166,
22043,
7347,
27870,
5897,
1027,
6151,
28344,
1025,
2023,
1012,
1035,
8040,
25377,
5643,
3372,
18442,
1027,
8040,
25377,
5643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Buddhist.js | toGregorian | function toGregorian(oBuddhist) {
var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
iYear = oBuddhist.year + iEraStartYear - 1;
// Before 1941 new year started on 1st of April
if (iYear < 1941 && oBuddhist.month < 3) {
iYear += 1;
}
if (oBuddhist.year === null) {
iYear = undefined;
}
return {
year: iYear,
month: oBuddhist.month,
day: oBuddhist.day
};
} | javascript | function toGregorian(oBuddhist) {
var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
iYear = oBuddhist.year + iEraStartYear - 1;
// Before 1941 new year started on 1st of April
if (iYear < 1941 && oBuddhist.month < 3) {
iYear += 1;
}
if (oBuddhist.year === null) {
iYear = undefined;
}
return {
year: iYear,
month: oBuddhist.month,
day: oBuddhist.day
};
} | [
"function",
"toGregorian",
"(",
"oBuddhist",
")",
"{",
"var",
"iEraStartYear",
"=",
"UniversalDate",
".",
"getEraStartDate",
"(",
"CalendarType",
".",
"Buddhist",
",",
"0",
")",
".",
"year",
",",
"iYear",
"=",
"oBuddhist",
".",
"year",
"+",
"iEraStartYear",
... | Calculate gregorian year from Buddhist year and month
@param {object} oBuddhist
@return {int} | [
"Calculate",
"gregorian",
"year",
"from",
"Buddhist",
"year",
"and",
"month"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/date/Buddhist.js#L71-L86 | train | Converts Buddhist to gregorian | [
30522,
3853,
2000,
17603,
20255,
2937,
1006,
27885,
6784,
19114,
3367,
1007,
1063,
13075,
29464,
8180,
7559,
3723,
14644,
1027,
5415,
13701,
1012,
2131,
24140,
7559,
2102,
13701,
1006,
8094,
13874,
1012,
7992,
1010,
1014,
1007,
1012,
2095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/controllers/controller.doughnut.js | function(datasetIndex) {
var ringWeightOffset = 0;
for (var i = 0; i < datasetIndex; ++i) {
if (this.chart.isDatasetVisible(i)) {
ringWeightOffset += this._getRingWeight(i);
}
}
return ringWeightOffset;
} | javascript | function(datasetIndex) {
var ringWeightOffset = 0;
for (var i = 0; i < datasetIndex; ++i) {
if (this.chart.isDatasetVisible(i)) {
ringWeightOffset += this._getRingWeight(i);
}
}
return ringWeightOffset;
} | [
"function",
"(",
"datasetIndex",
")",
"{",
"var",
"ringWeightOffset",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"datasetIndex",
";",
"++",
"i",
")",
"{",
"if",
"(",
"this",
".",
"chart",
".",
"isDatasetVisible",
"(",
"i",
")",... | Get radius length offset of the dataset in relation to the visible datasets weights. This allows determining the inner and outer radius correctly
@private | [
"Get",
"radius",
"length",
"offset",
"of",
"the",
"dataset",
"in",
"relation",
"to",
"the",
"visible",
"datasets",
"weights",
".",
"This",
"allows",
"determining",
"the",
"inner",
"and",
"outer",
"radius",
"correctly"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/controllers/controller.doughnut.js#L401-L411 | train | Calculate the offset of the ring of the dataset | [
30522,
3853,
1006,
2951,
13462,
22254,
10288,
1007,
1063,
13075,
3614,
11179,
27475,
30524,
3388,
1009,
1027,
2023,
1012,
1035,
2131,
4892,
11179,
1006,
1045,
1007,
1025,
1065,
1065,
2709,
3614,
11179,
27475,
3388,
1025,
1065,
102,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function(state, x, y, hotspot, min, max)
{
hotspot = (hotspot != null) ? hotspot : 1;
min = (min != null) ? min : 0;
max = (max != null) ? max : 0;
if (hotspot > 0)
{
var cx = state.getCenterX();
var cy = state.getCenterY();
var w = state.width;
var h = state.height;
var start = mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE) * state.view.scale;
if (start > 0)
{
if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, true))
{
cy = state.y + start / 2;
h = start;
}
else
{
cx = state.x + start / 2;
w = start;
}
}
w = Math.max(min, w * hotspot);
h = Math.max(min, h * hotspot);
if (max > 0)
{
w = Math.min(w, max);
h = Math.min(h, max);
}
var rect = new mxRectangle(cx - w / 2, cy - h / 2, w, h);
var alpha = mxUtils.toRadians(mxUtils.getValue(state.style, mxConstants.STYLE_ROTATION) || 0);
if (alpha != 0)
{
var cos = Math.cos(-alpha);
var sin = Math.sin(-alpha);
var cx = new mxPoint(state.getCenterX(), state.getCenterY());
var pt = mxUtils.getRotatedPoint(new mxPoint(x, y), cos, sin, cx);
x = pt.x;
y = pt.y;
}
return mxUtils.contains(rect, x, y);
}
return true;
} | javascript | function(state, x, y, hotspot, min, max)
{
hotspot = (hotspot != null) ? hotspot : 1;
min = (min != null) ? min : 0;
max = (max != null) ? max : 0;
if (hotspot > 0)
{
var cx = state.getCenterX();
var cy = state.getCenterY();
var w = state.width;
var h = state.height;
var start = mxUtils.getValue(state.style, mxConstants.STYLE_STARTSIZE) * state.view.scale;
if (start > 0)
{
if (mxUtils.getValue(state.style, mxConstants.STYLE_HORIZONTAL, true))
{
cy = state.y + start / 2;
h = start;
}
else
{
cx = state.x + start / 2;
w = start;
}
}
w = Math.max(min, w * hotspot);
h = Math.max(min, h * hotspot);
if (max > 0)
{
w = Math.min(w, max);
h = Math.min(h, max);
}
var rect = new mxRectangle(cx - w / 2, cy - h / 2, w, h);
var alpha = mxUtils.toRadians(mxUtils.getValue(state.style, mxConstants.STYLE_ROTATION) || 0);
if (alpha != 0)
{
var cos = Math.cos(-alpha);
var sin = Math.sin(-alpha);
var cx = new mxPoint(state.getCenterX(), state.getCenterY());
var pt = mxUtils.getRotatedPoint(new mxPoint(x, y), cos, sin, cx);
x = pt.x;
y = pt.y;
}
return mxUtils.contains(rect, x, y);
}
return true;
} | [
"function",
"(",
"state",
",",
"x",
",",
"y",
",",
"hotspot",
",",
"min",
",",
"max",
")",
"{",
"hotspot",
"=",
"(",
"hotspot",
"!=",
"null",
")",
"?",
"hotspot",
":",
"1",
";",
"min",
"=",
"(",
"min",
"!=",
"null",
")",
"?",
"min",
":",
"0",... | Function: intersects
Returns true if the two rectangles intersect.
Parameters:
a - <mxRectangle> to be checked for intersection.
b - <mxRectangle> to be checked for intersection. | [
"Function",
":",
"intersects"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4684-L4739 | train | Calculates the bounds of the region of the region | [
30522,
3853,
1006,
2110,
1010,
1060,
1010,
1061,
1010,
2980,
13102,
4140,
1010,
8117,
1010,
4098,
1007,
1063,
2980,
13102,
4140,
1027,
1006,
2980,
13102,
4140,
999,
1027,
19701,
1007,
1029,
2980,
13102,
4140,
1024,
1015,
1025,
8117,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/core/a-entity.js | isComponentMixedIn | function isComponentMixedIn (name, mixinEls) {
var i;
var inMixin = false;
for (i = 0; i < mixinEls.length; ++i) {
inMixin = mixinEls[i].hasAttribute(name);
if (inMixin) { break; }
}
return inMixin;
} | javascript | function isComponentMixedIn (name, mixinEls) {
var i;
var inMixin = false;
for (i = 0; i < mixinEls.length; ++i) {
inMixin = mixinEls[i].hasAttribute(name);
if (inMixin) { break; }
}
return inMixin;
} | [
"function",
"isComponentMixedIn",
"(",
"name",
",",
"mixinEls",
")",
"{",
"var",
"i",
";",
"var",
"inMixin",
"=",
"false",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"mixinEls",
".",
"length",
";",
"++",
"i",
")",
"{",
"inMixin",
"=",
"mixinEls... | Check if any mixins contains a component.
@param {string} name - Component name.
@param {array} mixinEls - Array of <a-mixin>s. | [
"Check",
"if",
"any",
"mixins",
"contains",
"a",
"component",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-entity.js#L883-L891 | train | Check if a component is mixed in a mixin | [
30522,
3853,
2003,
9006,
29513,
3372,
4328,
19068,
2378,
1006,
2171,
1010,
4666,
3170,
4877,
1007,
1063,
13075,
1045,
1025,
13075,
1999,
4328,
20303,
1027,
6270,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
4666,
3170,
4877,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js | getUnappliedEditList | function getUnappliedEditList(editor, changeList) {
var cachedValue = _cachedValues[editor.document.file.fullPath];
// We might not have a previous DOM if the document was empty before this edit.
if (!cachedValue || !cachedValue.dom || _cachedValues[editor.document.file.fullPath].invalid) {
// We were in an invalid state, so do a full rebuild.
changeList = null;
}
var result = _updateDOM(cachedValue && cachedValue.dom, editor, changeList);
if (!result.errors) {
_cachedValues[editor.document.file.fullPath] = {
timestamp: editor.document.diskTimestamp,
dom: result.dom,
dirty: false
};
// Since this was an incremental update, we can't rely on the node start/end offsets
// in the dom (because nodes after the updated portion didn't have their offsets
// updated); the marks in the editor are more accurate.
// TODO: should we consider ripping through the dom and fixing up other offsets?
result.dom.fullBuild = false;
return { edits: result.edits };
} else {
if (cachedValue) {
cachedValue.invalid = true;
}
return { errors: result.errors };
}
} | javascript | function getUnappliedEditList(editor, changeList) {
var cachedValue = _cachedValues[editor.document.file.fullPath];
// We might not have a previous DOM if the document was empty before this edit.
if (!cachedValue || !cachedValue.dom || _cachedValues[editor.document.file.fullPath].invalid) {
// We were in an invalid state, so do a full rebuild.
changeList = null;
}
var result = _updateDOM(cachedValue && cachedValue.dom, editor, changeList);
if (!result.errors) {
_cachedValues[editor.document.file.fullPath] = {
timestamp: editor.document.diskTimestamp,
dom: result.dom,
dirty: false
};
// Since this was an incremental update, we can't rely on the node start/end offsets
// in the dom (because nodes after the updated portion didn't have their offsets
// updated); the marks in the editor are more accurate.
// TODO: should we consider ripping through the dom and fixing up other offsets?
result.dom.fullBuild = false;
return { edits: result.edits };
} else {
if (cachedValue) {
cachedValue.invalid = true;
}
return { errors: result.errors };
}
} | [
"function",
"getUnappliedEditList",
"(",
"editor",
",",
"changeList",
")",
"{",
"var",
"cachedValue",
"=",
"_cachedValues",
"[",
"editor",
".",
"document",
".",
"file",
".",
"fullPath",
"]",
";",
"// We might not have a previous DOM if the document was empty before this e... | Calculates the DOM edits that are needed to update the browser from the state the
editor was in the last time that scanDocument(), getInstrumentedHTML(), or
getUnappliedEditList() was called (whichever is most recent). Caches this state so
it can be used as the base state for the next getUnappliedEditList().
For simple text edits, this update is done quickly and incrementally. For structural
edits (edits that change the DOM structure or add/remove attributes), the update
requires a full reparse.
If the document currently contains invalid HTML, no edits will be generated until
getUnappliedEditList() is called when the document is valid, at which point the edits
will reflect all the changes needed to catch the browser up with all the edits
made while the document was invalid.
@param {Editor} editor The editor containing the instrumented HTML
@param {Array} changeList A CodeMirror change list describing the text changes made
in the editor since the last update. If specified, we will attempt to do an
incremental update.
@return {Array} edits A list of edits to apply in the browser. See HTMLDOMDiff for
more information on the format of these edits. | [
"Calculates",
"the",
"DOM",
"edits",
"that",
"are",
"needed",
"to",
"update",
"the",
"browser",
"from",
"the",
"state",
"the",
"editor",
"was",
"in",
"the",
"last",
"time",
"that",
"scanDocument",
"()",
"getInstrumentedHTML",
"()",
"or",
"getUnappliedEditList",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js#L564-L593 | train | Get the unapplied edit list | [
30522,
3853,
2131,
9521,
9397,
8751,
5732,
4183,
9863,
1006,
3559,
1010,
2689,
9863,
1007,
1063,
13075,
17053,
2094,
10175,
5657,
1027,
1035,
17053,
2094,
10175,
15808,
1031,
3559,
1012,
6254,
1012,
5371,
1012,
2440,
15069,
1033,
1025,
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... |
jgraph/mxgraph | javascript/mxClient.js | function(x1, y1, x2, y2, px, py)
{
x2 -= x1;
y2 -= y1;
px -= x1;
py -= y1;
var ccw = px * y2 - py * x2;
if (ccw == 0.0)
{
ccw = px * x2 + py * y2;
if (ccw > 0.0)
{
px -= x2;
py -= y2;
ccw = px * x2 + py * y2;
if (ccw < 0.0)
{
ccw = 0.0;
}
}
}
return (ccw < 0.0) ? -1 : ((ccw > 0.0) ? 1 : 0);
} | javascript | function(x1, y1, x2, y2, px, py)
{
x2 -= x1;
y2 -= y1;
px -= x1;
py -= y1;
var ccw = px * y2 - py * x2;
if (ccw == 0.0)
{
ccw = px * x2 + py * y2;
if (ccw > 0.0)
{
px -= x2;
py -= y2;
ccw = px * x2 + py * y2;
if (ccw < 0.0)
{
ccw = 0.0;
}
}
}
return (ccw < 0.0) ? -1 : ((ccw > 0.0) ? 1 : 0);
} | [
"function",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"px",
",",
"py",
")",
"{",
"x2",
"-=",
"x1",
";",
"y2",
"-=",
"y1",
";",
"px",
"-=",
"x1",
";",
"py",
"-=",
"y1",
";",
"var",
"ccw",
"=",
"px",
"*",
"y2",
"-",
"py",
"*",
"x2"... | Function: relativeCcw
Returns 1 if the given point on the right side of the segment, 0 if its
on the segment, and -1 if the point is on the left side of the segment.
Parameters:
x1 - X-coordinate of the startpoint of the segment.
y1 - Y-coordinate of the startpoint of the segment.
x2 - X-coordinate of the endpoint of the segment.
y2 - Y-coordinate of the endpoint of the segment.
px - X-coordinate of the point.
py - Y-coordinate of the point. | [
"Function",
":",
"relativeCcw"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L5131-L5157 | train | Compute the cCW of a curve | [
30522,
3853,
1006,
1060,
2487,
1010,
1061,
2487,
1010,
1060,
2475,
1010,
1061,
2475,
1010,
1052,
2595,
1010,
1052,
2100,
1007,
1063,
1060,
2475,
1011,
1027,
1060,
2487,
1025,
1061,
2475,
1011,
1027,
1061,
2487,
1025,
1052,
2595,
1011,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/FileTreeView.js | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.treeData !== nextProps.treeData ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions ||
this.props.selectionViewInfo !== nextProps.selectionViewInfo;
} | javascript | function (nextProps, nextState) {
return nextProps.forceRender ||
this.props.treeData !== nextProps.treeData ||
this.props.sortDirectoriesFirst !== nextProps.sortDirectoriesFirst ||
this.props.extensions !== nextProps.extensions ||
this.props.selectionViewInfo !== nextProps.selectionViewInfo;
} | [
"function",
"(",
"nextProps",
",",
"nextState",
")",
"{",
"return",
"nextProps",
".",
"forceRender",
"||",
"this",
".",
"props",
".",
"treeData",
"!==",
"nextProps",
".",
"treeData",
"||",
"this",
".",
"props",
".",
"sortDirectoriesFirst",
"!==",
"nextProps",
... | Update for any change in the tree data or directory sorting preference. | [
"Update",
"for",
"any",
"change",
"in",
"the",
"tree",
"data",
"or",
"directory",
"sorting",
"preference",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L1127-L1133 | train | Check if the treeData and sortDirectoriesFirst properties are the same as the current treeData and the current sortDirectoriesFirst properties. | [
30522,
3853,
1006,
2279,
21572,
4523,
1010,
2279,
9153,
2618,
1007,
1063,
2709,
2279,
21572,
4523,
1012,
2486,
7389,
4063,
1064,
1064,
2023,
1012,
24387,
1012,
3392,
2850,
2696,
999,
1027,
1027,
2279,
21572,
4523,
1012,
3392,
2850,
2696,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/RuleSet.js | function (oSettings) {
oSettings = oSettings || {};
if (!oSettings.name) {
jQuery.sap.log.error("Please provide a name for the RuleSet.");
}
if (mRuleSets[oSettings.name]) {
return mRuleSets[oSettings.name];
}
this._oSettings = oSettings;
this._mRules = {};
mRuleSets[oSettings.name] = this;
} | javascript | function (oSettings) {
oSettings = oSettings || {};
if (!oSettings.name) {
jQuery.sap.log.error("Please provide a name for the RuleSet.");
}
if (mRuleSets[oSettings.name]) {
return mRuleSets[oSettings.name];
}
this._oSettings = oSettings;
this._mRules = {};
mRuleSets[oSettings.name] = this;
} | [
"function",
"(",
"oSettings",
")",
"{",
"oSettings",
"=",
"oSettings",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"oSettings",
".",
"name",
")",
"{",
"jQuery",
".",
"sap",
".",
"log",
".",
"error",
"(",
"\"Please provide a name for the RuleSet.\"",
")",
";",
"... | Creates a RuleSet.
The RuleSet can store multiple rules concerning namespaces.
<h3>Usage</h3>
The RuleSet is an interface used to create, update and delete rulesets.
@class
@public
@constructor
@namespace
@name sap.ui.support.RuleSet
@memberof sap.ui.support
@author SAP SE
@version ${version}
@param {object} oSettings Name of the initiated
@returns {void} | [
"Creates",
"a",
"RuleSet",
".",
"The",
"RuleSet",
"can",
"store",
"multiple",
"rules",
"concerning",
"namespaces",
".",
"<h3",
">",
"Usage<",
"/",
"h3",
">",
"The",
"RuleSet",
"is",
"an",
"interface",
"used",
"to",
"create",
"update",
"and",
"delete",
"rul... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/RuleSet.js#L42-L56 | train | Creates a new RuleSet instance. | [
30522,
3853,
1006,
9808,
18319,
3070,
2015,
1007,
1063,
9808,
18319,
3070,
2015,
1027,
9808,
18319,
3070,
2015,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
999,
9808,
18319,
3070,
2015,
1012,
2171,
1007,
1063,
1046,
4226,
2854,
1012,
20066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/ToolsAPI.js | function (control, inheritedMetadata) {
var inheritedMetadataProperties = inheritedMetadata.getProperties();
var result = Object.create(null);
result.meta = Object.create(null);
result.meta.controlName = inheritedMetadata.getName();
result.properties = Object.create(null);
Object.keys(inheritedMetadataProperties).forEach(function (key) {
result.properties[key] = Object.create(null);
result.properties[key].value = inheritedMetadataProperties[key].get(control);
result.properties[key].type = inheritedMetadataProperties[key].getType().getName ? inheritedMetadataProperties[key].getType().getName() : '';
});
return result;
} | javascript | function (control, inheritedMetadata) {
var inheritedMetadataProperties = inheritedMetadata.getProperties();
var result = Object.create(null);
result.meta = Object.create(null);
result.meta.controlName = inheritedMetadata.getName();
result.properties = Object.create(null);
Object.keys(inheritedMetadataProperties).forEach(function (key) {
result.properties[key] = Object.create(null);
result.properties[key].value = inheritedMetadataProperties[key].get(control);
result.properties[key].type = inheritedMetadataProperties[key].getType().getName ? inheritedMetadataProperties[key].getType().getName() : '';
});
return result;
} | [
"function",
"(",
"control",
",",
"inheritedMetadata",
")",
"{",
"var",
"inheritedMetadataProperties",
"=",
"inheritedMetadata",
".",
"getProperties",
"(",
")",
";",
"var",
"result",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"result",
".",
"meta",
... | Copies the inherited properties of a UI5 control from the metadata.
@param {Object} control - UI5 Control.
@param {Object} inheritedMetadata - UI5 control metadata.
@returns {Object}
@private | [
"Copies",
"the",
"inherited",
"properties",
"of",
"a",
"UI5",
"control",
"from",
"the",
"metadata",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/ToolsAPI.js#L224-L239 | train | Returns a new object with properties and meta properties of the inherited metadata | [
30522,
3853,
1006,
2491,
1010,
7900,
11368,
8447,
2696,
1007,
1063,
13075,
7900,
11368,
8447,
2696,
21572,
4842,
7368,
1027,
7900,
11368,
8447,
2696,
1012,
2131,
21572,
4842,
7368,
1006,
1007,
1025,
13075,
2765,
1027,
4874,
1012,
3443,
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... | |
grpc/grpc-node | packages/grpc-native-core/src/server.js | sendMetadata | function sendMetadata(responseMetadata) {
/* jshint validthis: true */
var self = this;
if (!this.call.metadataSent) {
this.call.metadataSent = true;
var batch = {};
batch[grpc.opType.SEND_INITIAL_METADATA] =
responseMetadata._getCoreRepresentation();
this.call.startBatch(batch, function(err) {
if (err) {
self.emit('error', err);
return;
}
});
}
} | javascript | function sendMetadata(responseMetadata) {
/* jshint validthis: true */
var self = this;
if (!this.call.metadataSent) {
this.call.metadataSent = true;
var batch = {};
batch[grpc.opType.SEND_INITIAL_METADATA] =
responseMetadata._getCoreRepresentation();
this.call.startBatch(batch, function(err) {
if (err) {
self.emit('error', err);
return;
}
});
}
} | [
"function",
"sendMetadata",
"(",
"responseMetadata",
")",
"{",
"/* jshint validthis: true */",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"this",
".",
"call",
".",
"metadataSent",
")",
"{",
"this",
".",
"call",
".",
"metadataSent",
"=",
"true",
";",
... | Send the initial metadata for a writable stream.
@alias grpc~ServerUnaryCall#sendMetadata
@param {grpc.Metadata} responseMetadata Metadata to send | [
"Send",
"the",
"initial",
"metadata",
"for",
"a",
"writable",
"stream",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L473-L488 | train | Send metadata to the cluster | [
30522,
3853,
4604,
11368,
8447,
2696,
1006,
3433,
11368,
8447,
2696,
1007,
1063,
1013,
1008,
1046,
17426,
2102,
9398,
15222,
2015,
1024,
2995,
1008,
1013,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
999,
2023,
1012,
2655,
1012,
27425,
5054,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/EditorStatusBar.js | _formatCountable | function _formatCountable(number, singularStr, pluralStr) {
return StringUtils.format(number > 1 ? pluralStr : singularStr, number);
} | javascript | function _formatCountable(number, singularStr, pluralStr) {
return StringUtils.format(number > 1 ? pluralStr : singularStr, number);
} | [
"function",
"_formatCountable",
"(",
"number",
",",
"singularStr",
",",
"pluralStr",
")",
"{",
"return",
"StringUtils",
".",
"format",
"(",
"number",
">",
"1",
"?",
"pluralStr",
":",
"singularStr",
",",
"number",
")",
";",
"}"
] | Determine string based on count
@param {number} number Count
@param {string} singularStr Singular string
@param {string} pluralStr Plural string
@return {string} Proper string to use for count | [
"Determine",
"string",
"based",
"on",
"count"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorStatusBar.js#L80-L82 | train | Format a countable string | [
30522,
3853,
1035,
4289,
3597,
16671,
3085,
1006,
2193,
1010,
13048,
3367,
2099,
1010,
13994,
3367,
2099,
1007,
1063,
2709,
5164,
21823,
4877,
1012,
4289,
1006,
2193,
1028,
1015,
1029,
13994,
3367,
2099,
1024,
13048,
3367,
2099,
1010,
2193,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.