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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
transloadit/uppy | packages/@uppy/companion/src/server/controllers/s3.js | signPartUpload | function signPartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId, partNumber } = req.params
const { key } = req.query
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!parseInt(partNumber, 10)) {
return res.status(400).json({ error: 's3: the part number must be a number between 1 and 10000.' })
}
client.getSignedUrl('uploadPart', {
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
PartNumber: partNumber,
Body: '',
Expires: ms('5 minutes') / 1000
}, (err, url) => {
if (err) {
next(err)
return
}
res.json({ url })
})
} | javascript | function signPartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId, partNumber } = req.params
const { key } = req.query
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!parseInt(partNumber, 10)) {
return res.status(400).json({ error: 's3: the part number must be a number between 1 and 10000.' })
}
client.getSignedUrl('uploadPart', {
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
PartNumber: partNumber,
Body: '',
Expires: ms('5 minutes') / 1000
}, (err, url) => {
if (err) {
next(err)
return
}
res.json({ url })
})
} | [
"function",
"signPartUpload",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// @ts-ignore The `uppy` property is added by middleware before reaching here.",
"const",
"client",
"=",
"req",
".",
"uppy",
".",
"s3Client",
"const",
"{",
"uploadId",
",",
"partNumber",
"}"... | Get parameters for uploading one part.
Expected URL parameters:
- uploadId - The uploadId returned from `createMultipartUpload`.
- partNumber - This part's index in the file (1-10000).
Expected query parameters:
- key - The object key in the S3 bucket.
Response JSON:
- url - The URL to upload to, including signed query parameters. | [
"Get",
"parameters",
"for",
"uploading",
"one",
"part",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L165-L192 | train | Signs a part upload | [
30522,
3853,
3696,
19362,
8525,
24759,
10441,
2094,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
1030,
24529,
1011,
8568,
1996,
1036,
2039,
7685,
1036,
3200,
2003,
2794,
2011,
2690,
8059,
2077,
4285,
2182,
1012,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/atoms/dom.js | getOverflowStyles | function getOverflowStyles(e) {
// When the <html> element has an overflow style of 'visible', it assumes
// the overflow style of the body, and the body is really overflow:visible.
var overflowElem = e;
if (htmlOverflowStyle == 'visible') {
// Note: bodyElem will be null/undefined in SVG documents.
if (e == htmlElem && bodyElem) {
overflowElem = bodyElem;
} else if (e == bodyElem) {
return {x: 'visible', y: 'visible'};
}
}
var overflow = {
x: bot.dom.getEffectiveStyle(overflowElem, 'overflow-x'),
y: bot.dom.getEffectiveStyle(overflowElem, 'overflow-y')
};
// The <html> element cannot have a genuine 'visible' overflow style,
// because the viewport can't expand; 'visible' is really 'auto'.
if (e == htmlElem) {
overflow.x = overflow.x == 'visible' ? 'auto' : overflow.x;
overflow.y = overflow.y == 'visible' ? 'auto' : overflow.y;
}
return overflow;
} | javascript | function getOverflowStyles(e) {
// When the <html> element has an overflow style of 'visible', it assumes
// the overflow style of the body, and the body is really overflow:visible.
var overflowElem = e;
if (htmlOverflowStyle == 'visible') {
// Note: bodyElem will be null/undefined in SVG documents.
if (e == htmlElem && bodyElem) {
overflowElem = bodyElem;
} else if (e == bodyElem) {
return {x: 'visible', y: 'visible'};
}
}
var overflow = {
x: bot.dom.getEffectiveStyle(overflowElem, 'overflow-x'),
y: bot.dom.getEffectiveStyle(overflowElem, 'overflow-y')
};
// The <html> element cannot have a genuine 'visible' overflow style,
// because the viewport can't expand; 'visible' is really 'auto'.
if (e == htmlElem) {
overflow.x = overflow.x == 'visible' ? 'auto' : overflow.x;
overflow.y = overflow.y == 'visible' ? 'auto' : overflow.y;
}
return overflow;
} | [
"function",
"getOverflowStyles",
"(",
"e",
")",
"{",
"// When the <html> element has an overflow style of 'visible', it assumes",
"// the overflow style of the body, and the body is really overflow:visible.",
"var",
"overflowElem",
"=",
"e",
";",
"if",
"(",
"htmlOverflowStyle",
"==",... | Return the x and y overflow styles for the given element. | [
"Return",
"the",
"x",
"and",
"y",
"overflow",
"styles",
"for",
"the",
"given",
"element",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/atoms/dom.js#L691-L714 | train | Returns the overflow style of the element. | [
30522,
3853,
2131,
7840,
12314,
21756,
4244,
1006,
1041,
1007,
1063,
1013,
1013,
2043,
1996,
1026,
16129,
1028,
5783,
2038,
2019,
2058,
12314,
2806,
1997,
1005,
5710,
1005,
1010,
2009,
15980,
1013,
1013,
1996,
2058,
12314,
2806,
1997,
1996,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxRectangleShape | function mxRectangleShape(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | javascript | function mxRectangleShape(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | [
"function",
"mxRectangleShape",
"(",
"bounds",
",",
"fill",
",",
"stroke",
",",
"strokewidth",
")",
"{",
"mxShape",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"bounds",
"=",
"bounds",
";",
"this",
".",
"fill",
"=",
"fill",
";",
"this",
".",
"st... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxRectangleShape
Extends <mxShape> to implement a rectangle shape.
This shape is registered under <mxConstants.SHAPE_RECTANGLE>
in <mxCellRenderer>.
Constructor: mxRectangleShape
Constructs a new rectangle shape.
Parameters:
bounds - <mxRectangle> that defines the bounds. This is stored in
<mxShape.bounds>.
fill - String that defines the fill color. This is stored in <fill>.
stroke - String that defines the stroke color. This is stored in <stroke>.
strokewidth - Optional integer that defines the stroke width. Default is
1. This is stored in <strokewidth>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxRectangleShape"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L24977-L24984 | train | A wrapper around mxRectangleShape | [
30522,
3853,
25630,
2890,
25572,
3070,
4244,
3270,
5051,
1006,
19202,
1010,
6039,
1010,
6909,
1010,
6909,
9148,
11927,
2232,
30524,
6039,
1025,
2023,
1012,
6909,
1027,
6909,
1025,
2023,
1012,
6909,
9148,
11927,
2232,
1027,
1006,
6909,
9148,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/examples/grapheditor/www/js/Editor.js | preview | function preview(print)
{
var autoOrigin = onePageCheckBox.checked || pageCountCheckBox.checked;
var printScale = parseInt(pageScaleInput.value) / 100;
if (isNaN(printScale))
{
printScale = 1;
pageScaleInput.value = '100%';
}
// Workaround to match available paper size in actual print output
printScale *= 0.75;
var pf = graph.pageFormat || mxConstants.PAGE_FORMAT_A4_PORTRAIT;
var scale = 1 / graph.pageScale;
if (autoOrigin)
{
var pageCount = (onePageCheckBox.checked) ? 1 : parseInt(pageCountInput.value);
if (!isNaN(pageCount))
{
scale = mxUtils.getScaleForPageCount(pageCount, graph, pf);
}
}
// Negative coordinates are cropped or shifted if page visible
var gb = graph.getGraphBounds();
var border = 0;
var x0 = 0;
var y0 = 0;
// Applies print scale
pf = mxRectangle.fromRectangle(pf);
pf.width = Math.ceil(pf.width * printScale);
pf.height = Math.ceil(pf.height * printScale);
scale *= printScale;
// Starts at first visible page
if (!autoOrigin && graph.pageVisible)
{
var layout = graph.getPageLayout();
x0 -= layout.x * pf.width;
y0 -= layout.y * pf.height;
}
else
{
autoOrigin = true;
}
var preview = PrintDialog.createPrintPreview(graph, scale, pf, border, x0, y0, autoOrigin);
preview.open();
if (print)
{
PrintDialog.printPreview(preview);
}
} | javascript | function preview(print)
{
var autoOrigin = onePageCheckBox.checked || pageCountCheckBox.checked;
var printScale = parseInt(pageScaleInput.value) / 100;
if (isNaN(printScale))
{
printScale = 1;
pageScaleInput.value = '100%';
}
// Workaround to match available paper size in actual print output
printScale *= 0.75;
var pf = graph.pageFormat || mxConstants.PAGE_FORMAT_A4_PORTRAIT;
var scale = 1 / graph.pageScale;
if (autoOrigin)
{
var pageCount = (onePageCheckBox.checked) ? 1 : parseInt(pageCountInput.value);
if (!isNaN(pageCount))
{
scale = mxUtils.getScaleForPageCount(pageCount, graph, pf);
}
}
// Negative coordinates are cropped or shifted if page visible
var gb = graph.getGraphBounds();
var border = 0;
var x0 = 0;
var y0 = 0;
// Applies print scale
pf = mxRectangle.fromRectangle(pf);
pf.width = Math.ceil(pf.width * printScale);
pf.height = Math.ceil(pf.height * printScale);
scale *= printScale;
// Starts at first visible page
if (!autoOrigin && graph.pageVisible)
{
var layout = graph.getPageLayout();
x0 -= layout.x * pf.width;
y0 -= layout.y * pf.height;
}
else
{
autoOrigin = true;
}
var preview = PrintDialog.createPrintPreview(graph, scale, pf, border, x0, y0, autoOrigin);
preview.open();
if (print)
{
PrintDialog.printPreview(preview);
}
} | [
"function",
"preview",
"(",
"print",
")",
"{",
"var",
"autoOrigin",
"=",
"onePageCheckBox",
".",
"checked",
"||",
"pageCountCheckBox",
".",
"checked",
";",
"var",
"printScale",
"=",
"parseInt",
"(",
"pageScaleInput",
".",
"value",
")",
"/",
"100",
";",
"if",... | Overall scale for print-out to account for print borders in dialogs etc | [
"Overall",
"scale",
"for",
"print",
"-",
"out",
"to",
"account",
"for",
"print",
"borders",
"in",
"dialogs",
"etc"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/examples/grapheditor/www/js/Editor.js#L1111-L1169 | train | Creates a print preview | [
30522,
3853,
19236,
1006,
6140,
1007,
1063,
13075,
8285,
10050,
11528,
1027,
2028,
13704,
5403,
3600,
8758,
1012,
7039,
1064,
1064,
3931,
3597,
16671,
5403,
3600,
8758,
1012,
7039,
1025,
13075,
11204,
9289,
2063,
1027,
11968,
20240,
3372,
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... |
dcloudio/mui | examples/hello-mui/js/mui.js | function(start, end) {
var props = ['pageX', 'pageY'];
return getAngle(end[1], end[0], props) - getAngle(start[1], start[0], props);
} | javascript | function(start, end) {
var props = ['pageX', 'pageY'];
return getAngle(end[1], end[0], props) - getAngle(start[1], start[0], props);
} | [
"function",
"(",
"start",
",",
"end",
")",
"{",
"var",
"props",
"=",
"[",
"'pageX'",
",",
"'pageY'",
"]",
";",
"return",
"getAngle",
"(",
"end",
"[",
"1",
"]",
",",
"end",
"[",
"0",
"]",
",",
"props",
")",
"-",
"getAngle",
"(",
"start",
"[",
"1... | rotation
@param {Object} start
@param {Object} end | [
"rotation"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L1234-L1237 | train | Get the angle between two points | [
30522,
3853,
1006,
2707,
1010,
2203,
1007,
1063,
13075,
24387,
1027,
1031,
1005,
3931,
2595,
1005,
1010,
1005,
3931,
2100,
1005,
1033,
1025,
2709,
2131,
5654,
2571,
1006,
2203,
1031,
1015,
1033,
1010,
2203,
1031,
1014,
1033,
1010,
24387,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/sort.js | orderByComparator | function orderByComparator(a, b) {
if (a === null || typeof a === 'undefined')
a = 0;
if (b === null || typeof b === 'undefined')
b = 0;
if (a instanceof Date && b instanceof Date) {
if (a < b)
return -1;
if (a > b)
return 1;
}
else if ((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))) {
// Convert to string in case of a=0 or b=0
a = String(a);
b = String(b);
// Isn't a number so lowercase the string to properly compare
if (a.toLowerCase() < b.toLowerCase())
return -1;
if (a.toLowerCase() > b.toLowerCase())
return 1;
}
else {
// Parse strings as numbers to compare properly
if (parseFloat(a) < parseFloat(b))
return -1;
if (parseFloat(a) > parseFloat(b))
return 1;
}
// equal each other
return 0;
} | javascript | function orderByComparator(a, b) {
if (a === null || typeof a === 'undefined')
a = 0;
if (b === null || typeof b === 'undefined')
b = 0;
if (a instanceof Date && b instanceof Date) {
if (a < b)
return -1;
if (a > b)
return 1;
}
else if ((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))) {
// Convert to string in case of a=0 or b=0
a = String(a);
b = String(b);
// Isn't a number so lowercase the string to properly compare
if (a.toLowerCase() < b.toLowerCase())
return -1;
if (a.toLowerCase() > b.toLowerCase())
return 1;
}
else {
// Parse strings as numbers to compare properly
if (parseFloat(a) < parseFloat(b))
return -1;
if (parseFloat(a) > parseFloat(b))
return 1;
}
// equal each other
return 0;
} | [
"function",
"orderByComparator",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
"===",
"null",
"||",
"typeof",
"a",
"===",
"'undefined'",
")",
"a",
"=",
"0",
";",
"if",
"(",
"b",
"===",
"null",
"||",
"typeof",
"b",
"===",
"'undefined'",
")",
"b",
... | Adapted from fueld-ui on 6/216
https://github.com/FuelInteractive/fuel-ui/tree/master/src/pipes/OrderBy | [
"Adapted",
"from",
"fueld",
"-",
"ui",
"on",
"6",
"/",
"216",
"https",
":",
"//",
"github",
".",
"com",
"/",
"FuelInteractive",
"/",
"fuel",
"-",
"ui",
"/",
"tree",
"/",
"master",
"/",
"src",
"/",
"pipes",
"/",
"OrderBy"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/sort.js#L36-L66 | train | Sort by the date order | [
30522,
3853,
2344,
3762,
9006,
28689,
4263,
1006,
1037,
1010,
1038,
1007,
1063,
2065,
1006,
1037,
1027,
1027,
1027,
19701,
1064,
1064,
2828,
11253,
1037,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1007,
1037,
1027,
1014,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/dialog/dialog.js | configureAria | function configureAria(element, options) {
var role = (options.$type === 'alert') ? 'alertdialog' : 'dialog';
var dialogContent = element.find('md-dialog-content');
var existingDialogId = element.attr('id');
var dialogContentId = 'dialogContent_' + (existingDialogId || $mdUtil.nextUid());
element.attr({
'role': role,
'tabIndex': '-1'
});
if (dialogContent.length === 0) {
dialogContent = element;
// If the dialog element already had an ID, don't clobber it.
if (existingDialogId) {
dialogContentId = existingDialogId;
}
}
dialogContent.attr('id', dialogContentId);
element.attr('aria-describedby', dialogContentId);
if (options.ariaLabel) {
$mdAria.expect(element, 'aria-label', options.ariaLabel);
}
else {
$mdAria.expectAsync(element, 'aria-label', function() {
// If dialog title is specified, set aria-label with it
// See https://github.com/angular/material/issues/10582
if (options.title) {
return options.title;
} else {
var words = dialogContent.text().split(/\s+/);
if (words.length > 3) words = words.slice(0, 3).concat('...');
return words.join(' ');
}
});
}
// Set up elements before and after the dialog content to capture focus and
// redirect back into the dialog.
topFocusTrap = document.createElement('div');
topFocusTrap.classList.add('md-dialog-focus-trap');
topFocusTrap.tabIndex = 0;
bottomFocusTrap = topFocusTrap.cloneNode(false);
// When focus is about to move out of the dialog, we want to intercept it and redirect it
// back to the dialog element.
var focusHandler = function() {
element.focus();
};
topFocusTrap.addEventListener('focus', focusHandler);
bottomFocusTrap.addEventListener('focus', focusHandler);
// The top focus trap inserted immeidately before the md-dialog element (as a sibling).
// The bottom focus trap is inserted at the very end of the md-dialog element (as a child).
element[0].parentNode.insertBefore(topFocusTrap, element[0]);
element.after(bottomFocusTrap);
} | javascript | function configureAria(element, options) {
var role = (options.$type === 'alert') ? 'alertdialog' : 'dialog';
var dialogContent = element.find('md-dialog-content');
var existingDialogId = element.attr('id');
var dialogContentId = 'dialogContent_' + (existingDialogId || $mdUtil.nextUid());
element.attr({
'role': role,
'tabIndex': '-1'
});
if (dialogContent.length === 0) {
dialogContent = element;
// If the dialog element already had an ID, don't clobber it.
if (existingDialogId) {
dialogContentId = existingDialogId;
}
}
dialogContent.attr('id', dialogContentId);
element.attr('aria-describedby', dialogContentId);
if (options.ariaLabel) {
$mdAria.expect(element, 'aria-label', options.ariaLabel);
}
else {
$mdAria.expectAsync(element, 'aria-label', function() {
// If dialog title is specified, set aria-label with it
// See https://github.com/angular/material/issues/10582
if (options.title) {
return options.title;
} else {
var words = dialogContent.text().split(/\s+/);
if (words.length > 3) words = words.slice(0, 3).concat('...');
return words.join(' ');
}
});
}
// Set up elements before and after the dialog content to capture focus and
// redirect back into the dialog.
topFocusTrap = document.createElement('div');
topFocusTrap.classList.add('md-dialog-focus-trap');
topFocusTrap.tabIndex = 0;
bottomFocusTrap = topFocusTrap.cloneNode(false);
// When focus is about to move out of the dialog, we want to intercept it and redirect it
// back to the dialog element.
var focusHandler = function() {
element.focus();
};
topFocusTrap.addEventListener('focus', focusHandler);
bottomFocusTrap.addEventListener('focus', focusHandler);
// The top focus trap inserted immeidately before the md-dialog element (as a sibling).
// The bottom focus trap is inserted at the very end of the md-dialog element (as a child).
element[0].parentNode.insertBefore(topFocusTrap, element[0]);
element.after(bottomFocusTrap);
} | [
"function",
"configureAria",
"(",
"element",
",",
"options",
")",
"{",
"var",
"role",
"=",
"(",
"options",
".",
"$type",
"===",
"'alert'",
")",
"?",
"'alertdialog'",
":",
"'dialog'",
";",
"var",
"dialogContent",
"=",
"element",
".",
"find",
"(",
"'md-dialo... | Inject ARIA-specific attributes appropriate for Dialogs | [
"Inject",
"ARIA",
"-",
"specific",
"attributes",
"appropriate",
"for",
"Dialogs"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L1076-L1136 | train | Configure the aria - label attribute of the given element. | [
30522,
3853,
9530,
8873,
27390,
14644,
2401,
1006,
5783,
1010,
7047,
1007,
1063,
13075,
2535,
1027,
1006,
7047,
1012,
1002,
2828,
1027,
1027,
1027,
1005,
9499,
1005,
1007,
1029,
1005,
9499,
27184,
8649,
1005,
1024,
1005,
13764,
8649,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_PtgMemFunc | function parse_PtgMemFunc(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
return [type, cce];
} | javascript | function parse_PtgMemFunc(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
var cce = blob.read_shift(opts && opts.biff == 2 ? 1 : 2);
return [type, cce];
} | [
"function",
"parse_PtgMemFunc",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
".",
"read_shift",
"(",
"1",
")",
">>>",
"5",
")",
"&",
"0x03",
";",
"var",
"cce",
"=",
"blob",
".",
"read_shift",
"(",
"opts",
"&&"... | /* [MS-XLS] 2.5.198.72 ; [MS-XLSB] 2.5.97.56 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"72",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"56"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10590-L10594 | train | Parse a PTG Mem function | [
30522,
3853,
11968,
3366,
1035,
13866,
21693,
6633,
11263,
12273,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1015,
1007,
1028,
1028,
1028,
1019... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_AggregationCache.js | filter | function filter(mMap, fnFilter) {
return Object.keys(mMap).filter(fnFilter).reduce(copyTo.bind(mMap), {});
} | javascript | function filter(mMap, fnFilter) {
return Object.keys(mMap).filter(fnFilter).reduce(copyTo.bind(mMap), {});
} | [
"function",
"filter",
"(",
"mMap",
",",
"fnFilter",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"mMap",
")",
".",
"filter",
"(",
"fnFilter",
")",
".",
"reduce",
"(",
"copyTo",
".",
"bind",
"(",
"mMap",
")",
",",
"{",
"}",
")",
";",
"}"
] | filters the given map according to the given filter function for keys | [
"filters",
"the",
"given",
"map",
"according",
"to",
"the",
"given",
"filter",
"function",
"for",
"keys"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_AggregationCache.js#L330-L332 | train | Filter the given map by a function. | [
30522,
3853,
11307,
1006,
21021,
2361,
1010,
1042,
2078,
8873,
21928,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
21021,
2361,
1007,
1012,
11307,
1006,
1042,
2078,
8873,
21928,
1007,
1012,
5547,
1006,
6100,
3406,
1012,
14187,
1006,
21021,
236... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TokenUtils.js | getModeAt | function getModeAt(cm, pos, precise) {
precise = precise || true;
var modeData = cm.getMode(),
name;
if (modeData.innerMode) {
modeData = CodeMirror.innerMode(modeData, getTokenAt(cm, pos, precise).state).mode;
}
name = (modeData.name === "xml") ?
modeData.configuration : modeData.name;
return {mode: modeData, name: name};
} | javascript | function getModeAt(cm, pos, precise) {
precise = precise || true;
var modeData = cm.getMode(),
name;
if (modeData.innerMode) {
modeData = CodeMirror.innerMode(modeData, getTokenAt(cm, pos, precise).state).mode;
}
name = (modeData.name === "xml") ?
modeData.configuration : modeData.name;
return {mode: modeData, name: name};
} | [
"function",
"getModeAt",
"(",
"cm",
",",
"pos",
",",
"precise",
")",
"{",
"precise",
"=",
"precise",
"||",
"true",
";",
"var",
"modeData",
"=",
"cm",
".",
"getMode",
"(",
")",
",",
"name",
";",
"if",
"(",
"modeData",
".",
"innerMode",
")",
"{",
"mo... | Returns the mode object and mode name string at a given position
@param {!CodeMirror} cm CodeMirror instance
@param {!{line:number, ch:number}} pos Position to query for mode
@param {boolean} precise If given, results in more current results. Suppresses caching.
@return {mode:{Object}, name:string} | [
"Returns",
"the",
"mode",
"object",
"and",
"mode",
"name",
"string",
"at",
"a",
"given",
"position"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/TokenUtils.js#L210-L223 | train | Get mode at pos | [
30522,
3853,
2131,
5302,
3207,
4017,
1006,
4642,
1010,
13433,
2015,
1010,
10480,
1007,
1063,
10480,
1027,
10480,
1064,
1064,
2995,
1025,
13075,
5549,
2850,
2696,
1027,
4642,
1012,
2131,
5302,
3207,
1006,
1007,
1010,
2171,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/utils.js | getJavadoc | function getJavadoc(text, indentSize) {
if (!text) {
text = '';
}
if (text.includes('"')) {
text = text.replace(/"/g, '\\"');
}
let javadoc = `${_.repeat(' ', indentSize)}/**`;
const rows = text.split('\n');
for (let i = 0; i < rows.length; i++) {
javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} * ${rows[i]}`;
}
javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} */`;
return javadoc;
} | javascript | function getJavadoc(text, indentSize) {
if (!text) {
text = '';
}
if (text.includes('"')) {
text = text.replace(/"/g, '\\"');
}
let javadoc = `${_.repeat(' ', indentSize)}/**`;
const rows = text.split('\n');
for (let i = 0; i < rows.length; i++) {
javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} * ${rows[i]}`;
}
javadoc = `${javadoc}\n${_.repeat(' ', indentSize)} */`;
return javadoc;
} | [
"function",
"getJavadoc",
"(",
"text",
",",
"indentSize",
")",
"{",
"if",
"(",
"!",
"text",
")",
"{",
"text",
"=",
"''",
";",
"}",
"if",
"(",
"text",
".",
"includes",
"(",
"'\"'",
")",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"\... | Convert passed block of string to javadoc formatted string.
@param {string} text text to convert to javadoc format
@param {number} indentSize indent size
@returns javadoc formatted string | [
"Convert",
"passed",
"block",
"of",
"string",
"to",
"javadoc",
"formatted",
"string",
"."
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/utils.js#L356-L370 | train | Get javadoc from text | [
30522,
3853,
2131,
3900,
3567,
3527,
2278,
1006,
3793,
1010,
27427,
11187,
4697,
1007,
1063,
2065,
1006,
999,
3793,
1007,
1063,
3793,
1027,
1005,
1005,
1025,
1065,
2065,
1006,
3793,
1012,
2950,
1006,
1005,
1000,
1005,
1007,
1007,
1063,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(id) {
var date,
target = $(id),
inst = this._getInst(target[0]);
if (this._get(inst, "gotoCurrent") && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
} else {
date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
}
this._notifyChange(inst);
this._adjustDate(target);
} | javascript | function(id) {
var date,
target = $(id),
inst = this._getInst(target[0]);
if (this._get(inst, "gotoCurrent") && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
} else {
date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
}
this._notifyChange(inst);
this._adjustDate(target);
} | [
"function",
"(",
"id",
")",
"{",
"var",
"date",
",",
"target",
"=",
"$",
"(",
"id",
")",
",",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"target",
"[",
"0",
"]",
")",
";",
"if",
"(",
"this",
".",
"_get",
"(",
"inst",
",",
"\"gotoCurrent\"",
")"... | /* Action for current link. | [
"/",
"*",
"Action",
"for",
"current",
"link",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8547-L8564 | train | Set the selected date | [
30522,
3853,
1006,
8909,
1007,
1063,
13075,
3058,
1010,
4539,
1027,
1002,
1006,
8909,
1007,
1010,
16021,
2102,
1027,
2023,
1012,
1035,
2131,
7076,
2102,
1006,
4539,
1031,
1014,
1033,
1007,
1025,
2065,
1006,
2023,
1012,
1035,
2131,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/cursor.js | function (evtName) {
var el = this.el;
var intersectedEl = this.intersectedEl;
var intersection;
intersection = this.el.components.raycaster.getIntersection(intersectedEl);
this.eventDetail.intersectedEl = intersectedEl;
this.eventDetail.intersection = intersection;
el.emit(evtName, this.eventDetail);
if (!intersectedEl) { return; }
this.intersectedEventDetail.intersection = intersection;
intersectedEl.emit(evtName, this.intersectedEventDetail);
} | javascript | function (evtName) {
var el = this.el;
var intersectedEl = this.intersectedEl;
var intersection;
intersection = this.el.components.raycaster.getIntersection(intersectedEl);
this.eventDetail.intersectedEl = intersectedEl;
this.eventDetail.intersection = intersection;
el.emit(evtName, this.eventDetail);
if (!intersectedEl) { return; }
this.intersectedEventDetail.intersection = intersection;
intersectedEl.emit(evtName, this.intersectedEventDetail);
} | [
"function",
"(",
"evtName",
")",
"{",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"intersectedEl",
"=",
"this",
".",
"intersectedEl",
";",
"var",
"intersection",
";",
"intersection",
"=",
"this",
".",
"el",
".",
"components",
".",
"raycaster",
".",
... | Helper to emit on both the cursor and the intersected entity (if exists). | [
"Helper",
"to",
"emit",
"on",
"both",
"the",
"cursor",
"and",
"the",
"intersected",
"entity",
"(",
"if",
"exists",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/cursor.js#L376-L390 | train | emit event to intersected element | [
30522,
3853,
1006,
23408,
2102,
18442,
1007,
1063,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
29261,
14728,
2140,
1027,
2023,
1012,
29261,
14728,
2140,
1025,
13075,
6840,
1025,
6840,
1027,
2023,
1012,
3449,
1012,
6177,
1012,
4097,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/services/ripple/ripple.js | InkRippleCtrl | function InkRippleCtrl ($scope, $element, rippleOptions, $window, $timeout, $mdUtil, $mdColorUtil) {
this.$window = $window;
this.$timeout = $timeout;
this.$mdUtil = $mdUtil;
this.$mdColorUtil = $mdColorUtil;
this.$scope = $scope;
this.$element = $element;
this.options = rippleOptions;
this.mousedown = false;
this.ripples = [];
this.timeout = null; // Stores a reference to the most-recent ripple timeout
this.lastRipple = null;
$mdUtil.valueOnUse(this, 'container', this.createContainer);
this.$element.addClass('md-ink-ripple');
// attach method for unit tests
($element.controller('mdInkRipple') || {}).createRipple = angular.bind(this, this.createRipple);
($element.controller('mdInkRipple') || {}).setColor = angular.bind(this, this.color);
this.bindEvents();
} | javascript | function InkRippleCtrl ($scope, $element, rippleOptions, $window, $timeout, $mdUtil, $mdColorUtil) {
this.$window = $window;
this.$timeout = $timeout;
this.$mdUtil = $mdUtil;
this.$mdColorUtil = $mdColorUtil;
this.$scope = $scope;
this.$element = $element;
this.options = rippleOptions;
this.mousedown = false;
this.ripples = [];
this.timeout = null; // Stores a reference to the most-recent ripple timeout
this.lastRipple = null;
$mdUtil.valueOnUse(this, 'container', this.createContainer);
this.$element.addClass('md-ink-ripple');
// attach method for unit tests
($element.controller('mdInkRipple') || {}).createRipple = angular.bind(this, this.createRipple);
($element.controller('mdInkRipple') || {}).setColor = angular.bind(this, this.color);
this.bindEvents();
} | [
"function",
"InkRippleCtrl",
"(",
"$scope",
",",
"$element",
",",
"rippleOptions",
",",
"$window",
",",
"$timeout",
",",
"$mdUtil",
",",
"$mdColorUtil",
")",
"{",
"this",
".",
"$window",
"=",
"$window",
";",
"this",
".",
"$timeout",
"=",
"$timeout",
";",
"... | Controller used by the ripple service in order to apply ripples
@ngInject | [
"Controller",
"used",
"by",
"the",
"ripple",
"service",
"in",
"order",
"to",
"apply",
"ripples"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/ripple/ripple.js#L158-L180 | train | Controller for ripples | [
30522,
3853,
10710,
29443,
10814,
6593,
12190,
1006,
1002,
9531,
1010,
1002,
5783,
1010,
24644,
7361,
9285,
1010,
1002,
3332,
1010,
1002,
2051,
5833,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
9108,
18717,
21823,
2140,
1007,
1063,
2023,
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... |
catapult-project/catapult | third_party/polymer2/bower_components/web-animations-js/src/dimension-handler.js | calculate | function calculate(expression) {
// In calc expressions, white space is required on both sides of the
// + and - operators. https://drafts.csswg.org/css-values-3/#calc-notation
// Thus any + or - immediately adjacent to . or 0..9 is part of the number,
// e.g. -1.23e+45
// This regular expression matches ( ) * / + - and numbers.
var tokenRegularExpression = /([\+\-\w\.]+|[\(\)\*\/])/g;
var currentToken;
function consume() {
var matchResult = tokenRegularExpression.exec(expression);
if (matchResult)
currentToken = matchResult[0];
else
currentToken = undefined;
}
consume(); // Read the initial token.
function calcNumber() {
// https://drafts.csswg.org/css-values-3/#number-value
var result = Number(currentToken);
consume();
return result;
}
function calcValue() {
// <calc-value> = <number> | <dimension> | <percentage> | ( <calc-sum> )
if (currentToken !== '(')
return calcNumber();
consume();
var result = calcSum();
if (currentToken !== ')')
return NaN;
consume();
return result;
}
function calcProduct() {
// <calc-product> = <calc-value> [ '*' <calc-value> | '/' <calc-number-value> ]*
var left = calcValue();
while (currentToken === '*' || currentToken === '/') {
var operator = currentToken;
consume();
var right = calcValue();
if (operator === '*')
left *= right;
else
left /= right;
}
return left;
}
function calcSum() {
// <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]*
var left = calcProduct();
while (currentToken === '+' || currentToken === '-') {
var operator = currentToken;
consume();
var right = calcProduct();
if (operator === '+')
left += right;
else
left -= right;
}
return left;
}
// <calc()> = calc( <calc-sum> )
return calcSum();
} | javascript | function calculate(expression) {
// In calc expressions, white space is required on both sides of the
// + and - operators. https://drafts.csswg.org/css-values-3/#calc-notation
// Thus any + or - immediately adjacent to . or 0..9 is part of the number,
// e.g. -1.23e+45
// This regular expression matches ( ) * / + - and numbers.
var tokenRegularExpression = /([\+\-\w\.]+|[\(\)\*\/])/g;
var currentToken;
function consume() {
var matchResult = tokenRegularExpression.exec(expression);
if (matchResult)
currentToken = matchResult[0];
else
currentToken = undefined;
}
consume(); // Read the initial token.
function calcNumber() {
// https://drafts.csswg.org/css-values-3/#number-value
var result = Number(currentToken);
consume();
return result;
}
function calcValue() {
// <calc-value> = <number> | <dimension> | <percentage> | ( <calc-sum> )
if (currentToken !== '(')
return calcNumber();
consume();
var result = calcSum();
if (currentToken !== ')')
return NaN;
consume();
return result;
}
function calcProduct() {
// <calc-product> = <calc-value> [ '*' <calc-value> | '/' <calc-number-value> ]*
var left = calcValue();
while (currentToken === '*' || currentToken === '/') {
var operator = currentToken;
consume();
var right = calcValue();
if (operator === '*')
left *= right;
else
left /= right;
}
return left;
}
function calcSum() {
// <calc-sum> = <calc-product> [ [ '+' | '-' ] <calc-product> ]*
var left = calcProduct();
while (currentToken === '+' || currentToken === '-') {
var operator = currentToken;
consume();
var right = calcProduct();
if (operator === '+')
left += right;
else
left -= right;
}
return left;
}
// <calc()> = calc( <calc-sum> )
return calcSum();
} | [
"function",
"calculate",
"(",
"expression",
")",
"{",
"// In calc expressions, white space is required on both sides of the",
"// + and - operators. https://drafts.csswg.org/css-values-3/#calc-notation",
"// Thus any + or - immediately adjacent to . or 0..9 is part of the number,",
"// e.g. -1.23e... | Evaluates a calc expression. https://drafts.csswg.org/css-values-3/#calc-notation | [
"Evaluates",
"a",
"calc",
"expression",
".",
"https",
":",
"//",
"drafts",
".",
"csswg",
".",
"org",
"/",
"css",
"-",
"values",
"-",
"3",
"/",
"#calc",
"-",
"notation"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/polymer2/bower_components/web-animations-js/src/dimension-handler.js#L19-L87 | train | Calculates the formula of an expression. | [
30522,
3853,
18422,
1006,
3670,
1007,
1063,
1013,
1013,
1999,
10250,
2278,
11423,
1010,
2317,
2686,
2003,
3223,
2006,
2119,
3903,
1997,
1996,
1013,
1013,
1009,
1998,
1011,
9224,
1012,
16770,
1024,
1013,
1013,
28967,
1012,
20116,
26760,
2290... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | bits/40_harb.js | sylk_to_aoa | function sylk_to_aoa(d/*:RawData*/, opts)/*:[AOA, Worksheet]*/ {
switch(opts.type) {
case 'base64': return sylk_to_aoa_str(Base64.decode(d), opts);
case 'binary': return sylk_to_aoa_str(d, opts);
case 'buffer': return sylk_to_aoa_str(d.toString('binary'), opts);
case 'array': return sylk_to_aoa_str(cc2str(d), opts);
}
throw new Error("Unrecognized type " + opts.type);
} | javascript | function sylk_to_aoa(d/*:RawData*/, opts)/*:[AOA, Worksheet]*/ {
switch(opts.type) {
case 'base64': return sylk_to_aoa_str(Base64.decode(d), opts);
case 'binary': return sylk_to_aoa_str(d, opts);
case 'buffer': return sylk_to_aoa_str(d.toString('binary'), opts);
case 'array': return sylk_to_aoa_str(cc2str(d), opts);
}
throw new Error("Unrecognized type " + opts.type);
} | [
"function",
"sylk_to_aoa",
"(",
"d",
"/*:RawData*/",
",",
"opts",
")",
"/*:[AOA, Worksheet]*/",
"{",
"switch",
"(",
"opts",
".",
"type",
")",
"{",
"case",
"'base64'",
":",
"return",
"sylk_to_aoa_str",
"(",
"Base64",
".",
"decode",
"(",
"d",
")",
",",
"opts... | /* TODO: find an actual specification | [
"/",
"*",
"TODO",
":",
"find",
"an",
"actual",
"specification"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/40_harb.js#L303-L311 | train | Convert raw data to AIA | [
30522,
3853,
25353,
13687,
1035,
2000,
1035,
20118,
2050,
1006,
1040,
1013,
1008,
1024,
6315,
2850,
2696,
1008,
1013,
1010,
23569,
2015,
1007,
1013,
1008,
1024,
1031,
20118,
2050,
1010,
2573,
21030,
2102,
1033,
1008,
1013,
1063,
6942,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/routing/Router.js | function () {
if (!this._bIsInitialized) {
Log.warning("Router is not initialized. But it got stopped", this);
}
if (this.fnHashChanged) {
this.oHashChanger.detachEvent("hashChanged", this.fnHashChanged);
}
if (this.fnHashReplaced) {
this.oHashChanger.detachEvent("hashReplaced", this.fnHashReplaced);
}
if (this._matchedRoute) {
this._matchedRoute.fireEvent("switched");
this._matchedRoute = null;
}
this._bIsInitialized = false;
return this;
} | javascript | function () {
if (!this._bIsInitialized) {
Log.warning("Router is not initialized. But it got stopped", this);
}
if (this.fnHashChanged) {
this.oHashChanger.detachEvent("hashChanged", this.fnHashChanged);
}
if (this.fnHashReplaced) {
this.oHashChanger.detachEvent("hashReplaced", this.fnHashReplaced);
}
if (this._matchedRoute) {
this._matchedRoute.fireEvent("switched");
this._matchedRoute = null;
}
this._bIsInitialized = false;
return this;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_bIsInitialized",
")",
"{",
"Log",
".",
"warning",
"(",
"\"Router is not initialized. But it got stopped\"",
",",
"this",
")",
";",
"}",
"if",
"(",
"this",
".",
"fnHashChanged",
")",
"{",
"this",
"."... | Stops to listen to the hashChange of the browser.</br>
If you want the router to start again, call initialize again.
@returns { sap.ui.core.routing.Router } this for chaining.
@public | [
"Stops",
"to",
"listen",
"to",
"the",
"hashChange",
"of",
"the",
"browser",
".",
"<",
"/",
"br",
">",
"If",
"you",
"want",
"the",
"router",
"to",
"start",
"again",
"call",
"initialize",
"again",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L392-L414 | train | Removes all listeners and fires the switched event | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
1035,
20377,
5498,
20925,
3550,
1007,
1063,
8833,
1012,
5432,
1006,
1000,
2799,
2099,
2003,
2025,
3988,
3550,
1012,
2021,
2009,
2288,
3030,
1000,
1010,
2023,
1007,
1025,
1065,
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... | |
jgraph/mxgraph | javascript/mxClient.js | function(cells, ascending)
{
ascending = (ascending != null) ? ascending : true;
var lookup = new mxDictionary();
cells.sort(function(o1, o2)
{
var p1 = lookup.get(o1);
if (p1 == null)
{
p1 = mxCellPath.create(o1).split(mxCellPath.PATH_SEPARATOR);
lookup.put(o1, p1);
}
var p2 = lookup.get(o2);
if (p2 == null)
{
p2 = mxCellPath.create(o2).split(mxCellPath.PATH_SEPARATOR);
lookup.put(o2, p2);
}
var comp = mxCellPath.compare(p1, p2);
return (comp == 0) ? 0 : (((comp > 0) == ascending) ? 1 : -1);
});
return cells;
} | javascript | function(cells, ascending)
{
ascending = (ascending != null) ? ascending : true;
var lookup = new mxDictionary();
cells.sort(function(o1, o2)
{
var p1 = lookup.get(o1);
if (p1 == null)
{
p1 = mxCellPath.create(o1).split(mxCellPath.PATH_SEPARATOR);
lookup.put(o1, p1);
}
var p2 = lookup.get(o2);
if (p2 == null)
{
p2 = mxCellPath.create(o2).split(mxCellPath.PATH_SEPARATOR);
lookup.put(o2, p2);
}
var comp = mxCellPath.compare(p1, p2);
return (comp == 0) ? 0 : (((comp > 0) == ascending) ? 1 : -1);
});
return cells;
} | [
"function",
"(",
"cells",
",",
"ascending",
")",
"{",
"ascending",
"=",
"(",
"ascending",
"!=",
"null",
")",
"?",
"ascending",
":",
"true",
";",
"var",
"lookup",
"=",
"new",
"mxDictionary",
"(",
")",
";",
"cells",
".",
"sort",
"(",
"function",
"(",
"... | Function: sortCells
Sorts the given cells according to the order in the cell hierarchy.
Ascending is optional and defaults to true. | [
"Function",
":",
"sortCells"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L5270-L5298 | train | Returns an array of cells sorted by path | [
30522,
3853,
1006,
4442,
1010,
22316,
1007,
1063,
22316,
1027,
1006,
22316,
999,
30524,
1052,
2487,
1027,
2298,
6279,
1012,
2131,
1006,
1051,
2487,
1007,
1025,
2065,
1006,
1052,
2487,
1027,
1027,
19701,
1007,
1063,
1052,
2487,
1027,
25630,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mxCloud | function mxCloud(bounds, fill, stroke, strokewidth)
{
mxActor.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | javascript | function mxCloud(bounds, fill, stroke, strokewidth)
{
mxActor.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | [
"function",
"mxCloud",
"(",
"bounds",
",",
"fill",
",",
"stroke",
",",
"strokewidth",
")",
"{",
"mxActor",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"bounds",
"=",
"bounds",
";",
"this",
".",
"fill",
"=",
"fill",
";",
"this",
".",
"stroke",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxCloud
Extends <mxActor> to implement a cloud shape.
This shape is registered under <mxConstants.SHAPE_CLOUD> in
<mxCellRenderer>.
Constructor: mxCloud
Constructs a new cloud shape.
Parameters:
bounds - <mxRectangle> that defines the bounds. This is stored in
<mxShape.bounds>.
fill - String that defines the fill color. This is stored in <fill>.
stroke - String that defines the stroke color. This is stored in <stroke>.
strokewidth - Optional integer that defines the stroke width. Default is
1. This is stored in <strokewidth>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxCloud"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L24923-L24930 | train | A Cloud Actor | [
30522,
3853,
25630,
20464,
19224,
1006,
19202,
1010,
6039,
1010,
6909,
1010,
6909,
9148,
30524,
11927,
2232,
999,
1027,
19701,
1007,
1029,
6909,
9148,
11927,
2232,
1024,
1015,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/tracked-controls-webvr.js | function () {
var controller = this.controller;
var data = this.data;
var object3D = this.el.object3D;
var pose;
var vrDisplay = this.system.vrDisplay;
var standingMatrix;
if (!controller) { return; }
// Compose pose from Gamepad.
pose = controller.pose;
if (pose.position) {
object3D.position.fromArray(pose.position);
} else {
// Controller not 6DOF, apply arm model.
if (data.armModel) { this.applyArmModel(object3D.position); }
}
if (pose.orientation) {
object3D.quaternion.fromArray(pose.orientation);
}
// Apply transforms, if 6DOF and in VR.
if (vrDisplay && pose.position) {
standingMatrix = this.el.sceneEl.renderer.vr.getStandingMatrix();
object3D.matrix.compose(object3D.position, object3D.quaternion, object3D.scale);
object3D.matrix.multiplyMatrices(standingMatrix, object3D.matrix);
object3D.matrix.decompose(object3D.position, object3D.quaternion, object3D.scale);
}
object3D.rotateX(this.data.orientationOffset.x * THREE.Math.DEG2RAD);
object3D.rotateY(this.data.orientationOffset.y * THREE.Math.DEG2RAD);
object3D.rotateZ(this.data.orientationOffset.z * THREE.Math.DEG2RAD);
} | javascript | function () {
var controller = this.controller;
var data = this.data;
var object3D = this.el.object3D;
var pose;
var vrDisplay = this.system.vrDisplay;
var standingMatrix;
if (!controller) { return; }
// Compose pose from Gamepad.
pose = controller.pose;
if (pose.position) {
object3D.position.fromArray(pose.position);
} else {
// Controller not 6DOF, apply arm model.
if (data.armModel) { this.applyArmModel(object3D.position); }
}
if (pose.orientation) {
object3D.quaternion.fromArray(pose.orientation);
}
// Apply transforms, if 6DOF and in VR.
if (vrDisplay && pose.position) {
standingMatrix = this.el.sceneEl.renderer.vr.getStandingMatrix();
object3D.matrix.compose(object3D.position, object3D.quaternion, object3D.scale);
object3D.matrix.multiplyMatrices(standingMatrix, object3D.matrix);
object3D.matrix.decompose(object3D.position, object3D.quaternion, object3D.scale);
}
object3D.rotateX(this.data.orientationOffset.x * THREE.Math.DEG2RAD);
object3D.rotateY(this.data.orientationOffset.y * THREE.Math.DEG2RAD);
object3D.rotateZ(this.data.orientationOffset.z * THREE.Math.DEG2RAD);
} | [
"function",
"(",
")",
"{",
"var",
"controller",
"=",
"this",
".",
"controller",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"object3D",
"=",
"this",
".",
"el",
".",
"object3D",
";",
"var",
"pose",
";",
"var",
"vrDisplay",
"=",
"this",
... | Read pose from controller (from Gamepad API), apply transforms, apply to entity. | [
"Read",
"pose",
"from",
"controller",
"(",
"from",
"Gamepad",
"API",
")",
"apply",
"transforms",
"apply",
"to",
"entity",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/tracked-controls-webvr.js#L169-L204 | train | Apply object3D | [
30522,
3853,
1006,
1007,
1063,
13075,
11486,
1027,
2023,
1012,
11486,
1025,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
4874,
29097,
1027,
2023,
1012,
3449,
1012,
4874,
29097,
1025,
13075,
13382,
1025,
13075,
27830,
10521,
13068,
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... | |
openlayers/openlayers | src/ol/format/KML.js | setCommonGeometryProperties | function setCommonGeometryProperties(multiGeometry, geometries) {
const ii = geometries.length;
const extrudes = new Array(geometries.length);
const tessellates = new Array(geometries.length);
const altitudeModes = new Array(geometries.length);
let hasExtrude, hasTessellate, hasAltitudeMode;
hasExtrude = hasTessellate = hasAltitudeMode = false;
for (let i = 0; i < ii; ++i) {
const geometry = geometries[i];
extrudes[i] = geometry.get('extrude');
tessellates[i] = geometry.get('tessellate');
altitudeModes[i] = geometry.get('altitudeMode');
hasExtrude = hasExtrude || extrudes[i] !== undefined;
hasTessellate = hasTessellate || tessellates[i] !== undefined;
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
}
if (hasExtrude) {
multiGeometry.set('extrude', extrudes);
}
if (hasTessellate) {
multiGeometry.set('tessellate', tessellates);
}
if (hasAltitudeMode) {
multiGeometry.set('altitudeMode', altitudeModes);
}
} | javascript | function setCommonGeometryProperties(multiGeometry, geometries) {
const ii = geometries.length;
const extrudes = new Array(geometries.length);
const tessellates = new Array(geometries.length);
const altitudeModes = new Array(geometries.length);
let hasExtrude, hasTessellate, hasAltitudeMode;
hasExtrude = hasTessellate = hasAltitudeMode = false;
for (let i = 0; i < ii; ++i) {
const geometry = geometries[i];
extrudes[i] = geometry.get('extrude');
tessellates[i] = geometry.get('tessellate');
altitudeModes[i] = geometry.get('altitudeMode');
hasExtrude = hasExtrude || extrudes[i] !== undefined;
hasTessellate = hasTessellate || tessellates[i] !== undefined;
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
}
if (hasExtrude) {
multiGeometry.set('extrude', extrudes);
}
if (hasTessellate) {
multiGeometry.set('tessellate', tessellates);
}
if (hasAltitudeMode) {
multiGeometry.set('altitudeMode', altitudeModes);
}
} | [
"function",
"setCommonGeometryProperties",
"(",
"multiGeometry",
",",
"geometries",
")",
"{",
"const",
"ii",
"=",
"geometries",
".",
"length",
";",
"const",
"extrudes",
"=",
"new",
"Array",
"(",
"geometries",
".",
"length",
")",
";",
"const",
"tessellates",
"=... | Reads an array of geometries and creates arrays for common geometry
properties. Then sets them to the multi geometry.
@param {MultiPoint|MultiLineString|MultiPolygon} multiGeometry A multi-geometry.
@param {Array<import("../geom/Geometry.js").default>} geometries List of geometries. | [
"Reads",
"an",
"array",
"of",
"geometries",
"and",
"creates",
"arrays",
"for",
"common",
"geometry",
"properties",
".",
"Then",
"sets",
"them",
"to",
"the",
"multi",
"geometry",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/KML.js#L1753-L1778 | train | Sets common geometry properties | [
30522,
3853,
2275,
9006,
8202,
3351,
8462,
11129,
21572,
4842,
7368,
1006,
4800,
3351,
8462,
11129,
1010,
20248,
11368,
5134,
1007,
1063,
9530,
3367,
2462,
1027,
20248,
11368,
5134,
1012,
3091,
1025,
9530,
3367,
4654,
16344,
22087,
1027,
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... |
eslint/eslint | lib/rules/no-extra-label.js | reportIfUnnecessary | function reportIfUnnecessary(node) {
if (!node.label) {
return;
}
const labelNode = node.label;
for (let info = scopeInfo; info !== null; info = info.upper) {
if (info.breakable || info.label && info.label.name === labelNode.name) {
if (info.breakable && info.label && info.label.name === labelNode.name) {
context.report({
node: labelNode,
messageId: "unexpected",
data: labelNode,
fix: fixer => fixer.removeRange([sourceCode.getFirstToken(node).range[1], labelNode.range[1]])
});
}
return;
}
}
} | javascript | function reportIfUnnecessary(node) {
if (!node.label) {
return;
}
const labelNode = node.label;
for (let info = scopeInfo; info !== null; info = info.upper) {
if (info.breakable || info.label && info.label.name === labelNode.name) {
if (info.breakable && info.label && info.label.name === labelNode.name) {
context.report({
node: labelNode,
messageId: "unexpected",
data: labelNode,
fix: fixer => fixer.removeRange([sourceCode.getFirstToken(node).range[1], labelNode.range[1]])
});
}
return;
}
}
} | [
"function",
"reportIfUnnecessary",
"(",
"node",
")",
"{",
"if",
"(",
"!",
"node",
".",
"label",
")",
"{",
"return",
";",
"}",
"const",
"labelNode",
"=",
"node",
".",
"label",
";",
"for",
"(",
"let",
"info",
"=",
"scopeInfo",
";",
"info",
"!==",
"null... | Reports a given control node if it's unnecessary.
@param {ASTNode} node - A node. This is a BreakStatement or a
ContinueStatement.
@returns {void} | [
"Reports",
"a",
"given",
"control",
"node",
"if",
"it",
"s",
"unnecessary",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-label.js#L105-L125 | train | Reports if a node is unnecessary. | [
30522,
3853,
3189,
10128,
4609,
2638,
9623,
10286,
2100,
1006,
13045,
1007,
1063,
2065,
1006,
999,
13045,
1012,
3830,
1007,
1063,
2709,
1025,
1065,
9530,
3367,
3830,
3630,
3207,
1027,
13045,
1012,
3830,
1025,
2005,
1006,
2292,
18558,
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/animation/Animator.js | function (easing, forceAnimate) {
var self = this;
var clipCount = 0;
var oneTrackDone = function () {
clipCount--;
if (!clipCount) {
self._doneCallback();
}
};
var lastClip;
for (var propName in this._tracks) {
if (!this._tracks.hasOwnProperty(propName)) {
continue;
}
var clip = createTrackClip(
this, easing, oneTrackDone,
this._tracks[propName], propName, forceAnimate
);
if (clip) {
this._clipList.push(clip);
clipCount++;
// If start after added to animation
if (this.animation) {
this.animation.addClip(clip);
}
lastClip = clip;
}
}
// Add during callback on the last clip
if (lastClip) {
var oldOnFrame = lastClip.onframe;
lastClip.onframe = function (target, percent) {
oldOnFrame(target, percent);
for (var i = 0; i < self._onframeList.length; i++) {
self._onframeList[i](target, percent);
}
};
}
// This optimization will help the case that in the upper application
// the view may be refreshed frequently, where animation will be
// called repeatly but nothing changed.
if (!clipCount) {
this._doneCallback();
}
return this;
} | javascript | function (easing, forceAnimate) {
var self = this;
var clipCount = 0;
var oneTrackDone = function () {
clipCount--;
if (!clipCount) {
self._doneCallback();
}
};
var lastClip;
for (var propName in this._tracks) {
if (!this._tracks.hasOwnProperty(propName)) {
continue;
}
var clip = createTrackClip(
this, easing, oneTrackDone,
this._tracks[propName], propName, forceAnimate
);
if (clip) {
this._clipList.push(clip);
clipCount++;
// If start after added to animation
if (this.animation) {
this.animation.addClip(clip);
}
lastClip = clip;
}
}
// Add during callback on the last clip
if (lastClip) {
var oldOnFrame = lastClip.onframe;
lastClip.onframe = function (target, percent) {
oldOnFrame(target, percent);
for (var i = 0; i < self._onframeList.length; i++) {
self._onframeList[i](target, percent);
}
};
}
// This optimization will help the case that in the upper application
// the view may be refreshed frequently, where animation will be
// called repeatly but nothing changed.
if (!clipCount) {
this._doneCallback();
}
return this;
} | [
"function",
"(",
"easing",
",",
"forceAnimate",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"clipCount",
"=",
"0",
";",
"var",
"oneTrackDone",
"=",
"function",
"(",
")",
"{",
"clipCount",
"--",
";",
"if",
"(",
"!",
"clipCount",
")",
"{",
"self"... | 开始执行动画
@param {string|Function} [easing]
动画缓动函数,详见{@link module:zrender/animation/easing}
@param {boolean} forceAnimate
@return {module:zrender/animation/Animator} | [
"开始执行动画"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/animation/Animator.js#L552-L605 | train | Creates a new clip for each track | [
30522,
3853,
1006,
24070,
1010,
2486,
7088,
8585,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
12528,
3597,
16671,
1027,
1014,
1025,
13075,
2028,
6494,
3600,
5280,
2063,
1027,
3853,
1006,
1007,
1063,
12528,
3597,
16671,
1011,
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... | |
mdn/browser-compat-data | scripts/render.js | traverseFeatures | function traverseFeatures(obj, depth, identifier) {
depth--;
if (depth >= 0) {
for (let i in obj) {
if (!!obj[i] && typeof(obj[i])=="object" && i !== '__compat') {
if (obj[i].__compat) {
let featureNames = Object.keys(obj[i]);
if (featureNames.length > 1) {
// there are sub features below this node,
// so we need to identify partial support for the main feature
for (let subfeatureName of featureNames) {
// if this is actually a subfeature (i.e. it is not a __compat object)
// and the subfeature has a __compat object
if ((subfeatureName !== '__compat') && (obj[i][subfeatureName].__compat)) {
let browserNames = Object.keys(obj[i].__compat.support);
for (let browser of browserNames) {
if (obj[i].__compat.support[browser].version_added !=
obj[i][subfeatureName].__compat.support[browser].version_added ||
obj[i][subfeatureName].__compat.support[browser].notes) {
obj[i].__compat.support[browser].partial_support = true;
}
}
}
}
}
features.push({[identifier + i]: obj[i].__compat});
}
traverseFeatures(obj[i], depth, i + '.');
}
}
}
} | javascript | function traverseFeatures(obj, depth, identifier) {
depth--;
if (depth >= 0) {
for (let i in obj) {
if (!!obj[i] && typeof(obj[i])=="object" && i !== '__compat') {
if (obj[i].__compat) {
let featureNames = Object.keys(obj[i]);
if (featureNames.length > 1) {
// there are sub features below this node,
// so we need to identify partial support for the main feature
for (let subfeatureName of featureNames) {
// if this is actually a subfeature (i.e. it is not a __compat object)
// and the subfeature has a __compat object
if ((subfeatureName !== '__compat') && (obj[i][subfeatureName].__compat)) {
let browserNames = Object.keys(obj[i].__compat.support);
for (let browser of browserNames) {
if (obj[i].__compat.support[browser].version_added !=
obj[i][subfeatureName].__compat.support[browser].version_added ||
obj[i][subfeatureName].__compat.support[browser].notes) {
obj[i].__compat.support[browser].partial_support = true;
}
}
}
}
}
features.push({[identifier + i]: obj[i].__compat});
}
traverseFeatures(obj[i], depth, i + '.');
}
}
}
} | [
"function",
"traverseFeatures",
"(",
"obj",
",",
"depth",
",",
"identifier",
")",
"{",
"depth",
"--",
";",
"if",
"(",
"depth",
">=",
"0",
")",
"{",
"for",
"(",
"let",
"i",
"in",
"obj",
")",
"{",
"if",
"(",
"!",
"!",
"obj",
"[",
"i",
"]",
"&&",
... | /*
Get features that should be displayed according to the query and the depth setting
Flatten them into a features array | [
"/",
"*",
"Get",
"features",
"that",
"should",
"be",
"displayed",
"according",
"to",
"the",
"query",
"and",
"the",
"depth",
"setting",
"Flatten",
"them",
"into",
"a",
"features",
"array"
] | 6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b | https://github.com/mdn/browser-compat-data/blob/6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b/scripts/render.js#L412-L445 | train | traverseFeatures - traverses the features tree | [
30522,
3853,
20811,
7959,
4017,
14900,
1006,
27885,
3501,
1010,
5995,
1010,
8909,
4765,
18095,
1007,
1063,
5995,
1011,
1011,
1025,
2065,
1006,
5995,
1028,
1027,
1014,
1007,
1063,
2005,
1006,
2292,
1045,
1999,
27885,
3501,
1007,
1063,
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... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js | function (sLayer, sNameSpace, sFileName, sFileType, sData, sTransportId, sPackageName) {
return LRepConnector.saveFile(sLayer, sNameSpace, sFileName, sFileType, sData, sTransportId, sPackageName).then(this._navToDisplayMode.bind(this));
} | javascript | function (sLayer, sNameSpace, sFileName, sFileType, sData, sTransportId, sPackageName) {
return LRepConnector.saveFile(sLayer, sNameSpace, sFileName, sFileType, sData, sTransportId, sPackageName).then(this._navToDisplayMode.bind(this));
} | [
"function",
"(",
"sLayer",
",",
"sNameSpace",
",",
"sFileName",
",",
"sFileType",
",",
"sData",
",",
"sTransportId",
",",
"sPackageName",
")",
"{",
"return",
"LRepConnector",
".",
"saveFile",
"(",
"sLayer",
",",
"sNameSpace",
",",
"sFileName",
",",
"sFileType"... | Send request to back end to saved file.
After the file has been successfully saved, navigates to "Display" mode of the content.
@returns {Promise} - <code>LRepConnector</code> "saveFiles" promise
@private | [
"Send",
"request",
"to",
"back",
"end",
"to",
"saved",
"file",
".",
"After",
"the",
"file",
"has",
"been",
"successfully",
"saved",
"navigates",
"to",
"Display",
"mode",
"of",
"the",
"content",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js#L193-L195 | train | Save file to the server | [
30522,
3853,
1006,
20005,
1010,
1055,
18442,
23058,
1010,
16420,
9463,
18442,
1010,
16420,
9463,
13874,
1010,
17371,
6790,
1010,
2358,
5521,
20205,
3593,
1010,
12403,
3600,
4270,
18442,
1007,
1063,
2709,
1048,
2890,
15042,
18256,
16761,
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... | |
mattdesl/canvas-sketch | examples/experimental/webgl-2d.js | getNormalizedPrimitive3D | function getNormalizedPrimitive3D ({ positions, cells, normals, uvs }, opt = {}) {
return {
positions,
uvs,
normals,
cells
};
} | javascript | function getNormalizedPrimitive3D ({ positions, cells, normals, uvs }, opt = {}) {
return {
positions,
uvs,
normals,
cells
};
} | [
"function",
"getNormalizedPrimitive3D",
"(",
"{",
"positions",
",",
"cells",
",",
"normals",
",",
"uvs",
"}",
",",
"opt",
"=",
"{",
"}",
")",
"{",
"return",
"{",
"positions",
",",
"uvs",
",",
"normals",
",",
"cells",
"}",
";",
"}"
] | A unit 3D sphere, torus, etc | [
"A",
"unit",
"3D",
"sphere",
"torus",
"etc"
] | 4addd0fe3fc053065ca8597ab204e43587c52879 | https://github.com/mattdesl/canvas-sketch/blob/4addd0fe3fc053065ca8597ab204e43587c52879/examples/experimental/webgl-2d.js#L195-L202 | train | Returns a 3D array of normalized 3D coordinates | [
30522,
3853,
2131,
12131,
9067,
3550,
18098,
27605,
6024,
29097,
1006,
1063,
4460,
1010,
4442,
1010,
3671,
2015,
1010,
23068,
2015,
1065,
1010,
23569,
1027,
1063,
1065,
1007,
1063,
2709,
1063,
4460,
1010,
23068,
2015,
1010,
3671,
2015,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/main.js | _toggleLivePreviewMultiBrowser | function _toggleLivePreviewMultiBrowser(value) {
var val = _togglePref(PREF_MULTIBROWSER, value);
CommandManager.get(Commands.TOGGLE_LIVE_PREVIEW_MB_MODE).setChecked(val);
// Issue #10217: multi-browser does not support user server, so disable
// the setting if it is enabled.
CommandManager.get(Commands.FILE_PROJECT_SETTINGS).setEnabled(!val);
} | javascript | function _toggleLivePreviewMultiBrowser(value) {
var val = _togglePref(PREF_MULTIBROWSER, value);
CommandManager.get(Commands.TOGGLE_LIVE_PREVIEW_MB_MODE).setChecked(val);
// Issue #10217: multi-browser does not support user server, so disable
// the setting if it is enabled.
CommandManager.get(Commands.FILE_PROJECT_SETTINGS).setEnabled(!val);
} | [
"function",
"_toggleLivePreviewMultiBrowser",
"(",
"value",
")",
"{",
"var",
"val",
"=",
"_togglePref",
"(",
"PREF_MULTIBROWSER",
",",
"value",
")",
";",
"CommandManager",
".",
"get",
"(",
"Commands",
".",
"TOGGLE_LIVE_PREVIEW_MB_MODE",
")",
".",
"setChecked",
"("... | /* Toggles or sets the "livedev.multibrowser" preference | [
"/",
"*",
"Toggles",
"or",
"sets",
"the",
"livedev",
".",
"multibrowser",
"preference"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L127-L134 | train | Toggle the live preview mode | [
30522,
3853,
1035,
2000,
24679,
3669,
3726,
28139,
8584,
12274,
7096,
12322,
10524,
8043,
1006,
3643,
1007,
1063,
13075,
11748,
1027,
1035,
2000,
24679,
28139,
2546,
1006,
3653,
2546,
1035,
4800,
12618,
9333,
2121,
1010,
3643,
1007,
1025,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/filesystem/impls/appshell/node/FileWatcherManager.js | _unwatchPath | function _unwatchPath(path) {
var watcher = _watcherMap[path];
if (watcher) {
try {
watcher.close();
} catch (err) {
console.warn("Failed to unwatch file " + path + ": " + (err && err.message));
} finally {
delete _watcherMap[path];
}
}
} | javascript | function _unwatchPath(path) {
var watcher = _watcherMap[path];
if (watcher) {
try {
watcher.close();
} catch (err) {
console.warn("Failed to unwatch file " + path + ": " + (err && err.message));
} finally {
delete _watcherMap[path];
}
}
} | [
"function",
"_unwatchPath",
"(",
"path",
")",
"{",
"var",
"watcher",
"=",
"_watcherMap",
"[",
"path",
"]",
";",
"if",
"(",
"watcher",
")",
"{",
"try",
"{",
"watcher",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
... | Un-watch a file or directory.
@private
@param {string} path File or directory to unwatch. | [
"Un",
"-",
"watch",
"a",
"file",
"or",
"directory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/node/FileWatcherManager.js#L70-L82 | train | Unwatch a file | [
30522,
3853,
1035,
4895,
18866,
15069,
1006,
4130,
1007,
1063,
13075,
3422,
2121,
1027,
1035,
3422,
2121,
2863,
2361,
1031,
4130,
1033,
1025,
2065,
1006,
3422,
2121,
1007,
1063,
3046,
1063,
3422,
2121,
1012,
2485,
1006,
1007,
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... |
uber/deck.gl | showcases/ascii/ascii-layer/utils.js | normalizeCharacterBrightness | function normalizeCharacterBrightness(darkPixelsByCharacter) {
let min = Infinity;
let max = 0;
for (const char in darkPixelsByCharacter) {
const b = darkPixelsByCharacter[char];
min = b < min ? b : min;
max = b > max ? b : max;
}
if (max === 0) {
throw Error('Characters are blank');
}
const brightness = {};
for (const char in darkPixelsByCharacter) {
const b = darkPixelsByCharacter[char];
brightness[char] = Math.floor((max - b) / (max - min) * 255);
}
return brightness;
} | javascript | function normalizeCharacterBrightness(darkPixelsByCharacter) {
let min = Infinity;
let max = 0;
for (const char in darkPixelsByCharacter) {
const b = darkPixelsByCharacter[char];
min = b < min ? b : min;
max = b > max ? b : max;
}
if (max === 0) {
throw Error('Characters are blank');
}
const brightness = {};
for (const char in darkPixelsByCharacter) {
const b = darkPixelsByCharacter[char];
brightness[char] = Math.floor((max - b) / (max - min) * 255);
}
return brightness;
} | [
"function",
"normalizeCharacterBrightness",
"(",
"darkPixelsByCharacter",
")",
"{",
"let",
"min",
"=",
"Infinity",
";",
"let",
"max",
"=",
"0",
";",
"for",
"(",
"const",
"char",
"in",
"darkPixelsByCharacter",
")",
"{",
"const",
"b",
"=",
"darkPixelsByCharacter",... | const BRIGHTNESS = {'0': 14, '1': 126, '2': 102, '3': 95, '4': 95, '5': 81, '6': 57, '7': 131, '8': 43, '9': 57, ' ': 255, '!': 176, '"': 198, '#': 69, '$': 57, '%': 43, '&': 31, '\'': 214, '(': 122, ')': 124, '*': 148, '+': 169, ',': 210, '-': 222, '.': 231, '/': 172, ':': 210, ';': 186, '<': 167, '=': 162, '>': 167, '?': 148, '@': 43, 'A': 69, 'B': 45, 'C': 119, 'D': 57, 'E': 93, 'F': 122, 'G': 79, 'H': 64, 'I': 112, 'J': 133, 'K': 69, 'L': 143, 'M': 14, 'N': 33, 'O': 60, 'P': 86, 'Q': 33, 'R': 48, 'S': 98, 'T': 126, 'U': 79, 'V': 91, 'W': 5, 'X': 76, 'Y': 124, 'Z': 88, '[': 112, '\\': 172, ']': 110, '^': 167, '_': 210, '`': 236, 'a': 95, 'b': 71, 'c': 143, 'd': 71, 'e': 107, 'f': 129, 'g': 50, 'h': 98, 'i': 162, 'j': 131, 'k': 95, 'l': 143, 'm': 81, 'n': 119, 'o': 107, 'p': 76, 'q': 76, 'r': 157, 's': 124, 't': 129, 'u': 119, 'v': 141, 'w': 83, 'x': 122, 'y': 112, 'z': 117, '{': 117, '|': 184, '}': 117, '~': 198, '': 255}; | [
"const",
"BRIGHTNESS",
"=",
"{",
"0",
":",
"14",
"1",
":",
"126",
"2",
":",
"102",
"3",
":",
"95",
"4",
":",
"95",
"5",
":",
"81",
"6",
":",
"57",
"7",
":",
"131",
"8",
":",
"43",
"9",
":",
"57",
":",
"255",
"!",
":",
"176",
":",
"198",... | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/showcases/ascii/ascii-layer/utils.js#L3-L22 | train | Normalizes dark pixels by character | [
30522,
3853,
3671,
4697,
7507,
22648,
3334,
26614,
2791,
1006,
2601,
8197,
2595,
9050,
3762,
7507,
22648,
3334,
1007,
1063,
2292,
8117,
1027,
15579,
1025,
2292,
4098,
1027,
1014,
1025,
2005,
1006,
9530,
3367,
25869,
1999,
2601,
8197,
2595,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/protractor | website/js/api-controller.js | function(item) {
var parts = item.displayName.split('.');
for (var i = parts.length - 1; i > 0; i--) {
var name = parts.slice(0, i).join('.');
if (itemsByName[name]) {
return itemsByName[name];
}
}
} | javascript | function(item) {
var parts = item.displayName.split('.');
for (var i = parts.length - 1; i > 0; i--) {
var name = parts.slice(0, i).join('.');
if (itemsByName[name]) {
return itemsByName[name];
}
}
} | [
"function",
"(",
"item",
")",
"{",
"var",
"parts",
"=",
"item",
".",
"displayName",
".",
"split",
"(",
"'.'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"parts",
".",
"length",
"-",
"1",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"var",
"name"... | Try to find a parent by matching the longest substring of the display
name.
@param item | [
"Try",
"to",
"find",
"a",
"parent",
"by",
"matching",
"the",
"longest",
"substring",
"of",
"the",
"display",
"name",
"."
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/website/js/api-controller.js#L161-L169 | train | returns the index of the last item in the list | [
30522,
3853,
1006,
8875,
1007,
1063,
30524,
1027,
3033,
1012,
3091,
1011,
1015,
1025,
1045,
1028,
1014,
1025,
1045,
1011,
1011,
1007,
1063,
13075,
2171,
1027,
3033,
1012,
14704,
1006,
1014,
1010,
1045,
1007,
1012,
3693,
1006,
1005,
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... | |
aframevr/aframe | src/utils/coordinates.js | parse | function parse (value, defaultVec) {
var coordinate;
var defaultVal;
var key;
var i;
var vec;
var x;
var y;
var z;
var w;
if (value && value instanceof Object) {
x = value.x === undefined ? defaultVec && defaultVec.x : value.x;
y = value.y === undefined ? defaultVec && defaultVec.y : value.y;
z = value.z === undefined ? defaultVec && defaultVec.z : value.z;
w = value.w === undefined ? defaultVec && defaultVec.w : value.w;
if (x !== undefined && x !== null) { value.x = parseIfString(x); }
if (y !== undefined && y !== null) { value.y = parseIfString(y); }
if (z !== undefined && z !== null) { value.z = parseIfString(z); }
if (w !== undefined && w !== null) { value.w = parseIfString(w); }
return value;
}
if (value === null || value === undefined) {
return typeof defaultVec === OBJECT ? extend({}, defaultVec) : defaultVec;
}
coordinate = value.trim().split(whitespaceRegex);
vec = {};
for (i = 0; i < COORDINATE_KEYS.length; i++) {
key = COORDINATE_KEYS[i];
if (coordinate[i]) {
vec[key] = parseFloat(coordinate[i], 10);
} else {
defaultVal = defaultVec && defaultVec[key];
if (defaultVal === undefined) { continue; }
vec[key] = parseIfString(defaultVal);
}
}
return vec;
} | javascript | function parse (value, defaultVec) {
var coordinate;
var defaultVal;
var key;
var i;
var vec;
var x;
var y;
var z;
var w;
if (value && value instanceof Object) {
x = value.x === undefined ? defaultVec && defaultVec.x : value.x;
y = value.y === undefined ? defaultVec && defaultVec.y : value.y;
z = value.z === undefined ? defaultVec && defaultVec.z : value.z;
w = value.w === undefined ? defaultVec && defaultVec.w : value.w;
if (x !== undefined && x !== null) { value.x = parseIfString(x); }
if (y !== undefined && y !== null) { value.y = parseIfString(y); }
if (z !== undefined && z !== null) { value.z = parseIfString(z); }
if (w !== undefined && w !== null) { value.w = parseIfString(w); }
return value;
}
if (value === null || value === undefined) {
return typeof defaultVec === OBJECT ? extend({}, defaultVec) : defaultVec;
}
coordinate = value.trim().split(whitespaceRegex);
vec = {};
for (i = 0; i < COORDINATE_KEYS.length; i++) {
key = COORDINATE_KEYS[i];
if (coordinate[i]) {
vec[key] = parseFloat(coordinate[i], 10);
} else {
defaultVal = defaultVec && defaultVec[key];
if (defaultVal === undefined) { continue; }
vec[key] = parseIfString(defaultVal);
}
}
return vec;
} | [
"function",
"parse",
"(",
"value",
",",
"defaultVec",
")",
"{",
"var",
"coordinate",
";",
"var",
"defaultVal",
";",
"var",
"key",
";",
"var",
"i",
";",
"var",
"vec",
";",
"var",
"x",
";",
"var",
"y",
";",
"var",
"z",
";",
"var",
"w",
";",
"if",
... | Parses coordinates from an "x y z" string.
Example: "3 10 -5" to {x: 3, y: 10, z: -5}.
@param {string} val - An "x y z" string.
@param {string} defaults - fallback value.
@returns {object} An object with keys [x, y, z]. | [
"Parses",
"coordinates",
"from",
"an",
"x",
"y",
"z",
"string",
".",
"Example",
":",
"3",
"10",
"-",
"5",
"to",
"{",
"x",
":",
"3",
"y",
":",
"10",
"z",
":",
"-",
"5",
"}",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/coordinates.js#L25-L65 | train | Parses a value into a vec | [
30522,
3853,
11968,
3366,
1006,
3643,
1010,
12398,
3726,
2278,
1007,
1063,
13075,
13530,
1025,
13075,
12398,
10175,
1025,
13075,
3145,
1025,
13075,
1045,
1025,
13075,
2310,
2278,
1025,
13075,
1060,
1025,
13075,
1061,
1025,
13075,
1062,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/editor/upload/upload-img.js | function (files) {
if (!files || !files.length) {
return
}
// ------------------------------ 获取配置信息 ------------------------------
const editor = this.editor
const config = editor.config
let uploadImgServer = config.uploadImgServer
const uploadImgShowBase64 = config.uploadImgShowBase64
const maxSize = config.uploadImgMaxSize
const maxSizeM = maxSize / 1024 / 1024
const maxLength = config.uploadImgMaxLength || 10000
const uploadFileName = config.uploadFileName || ''
const uploadImgParams = config.uploadImgParams || {}
const uploadImgParamsWithUrl = config.uploadImgParamsWithUrl
const uploadImgHeaders = config.uploadImgHeaders || {}
const hooks = config.uploadImgHooks || {}
const timeout = config.uploadImgTimeout || 3000
let withCredentials = config.withCredentials
if (withCredentials == null) {
withCredentials = false
}
const customUploadImg = config.customUploadImg
if (!customUploadImg) {
// 没有 customUploadImg 的情况下,需要如下两个配置才能继续进行图片上传
if (!uploadImgServer && !uploadImgShowBase64) {
return
}
}
// ------------------------------ 验证文件信息 ------------------------------
const resultFiles = []
let errInfo = []
arrForEach(files, file => {
var name = file.name
var size = file.size
// chrome 低版本 name === undefined
if (!name || !size) {
return
}
if (/\.(jpg|jpeg|png|bmp|gif|webp)$/i.test(name) === false) {
// 后缀名不合法,不是图片
errInfo.push(`【${name}】不是图片`)
return
}
if (maxSize < size) {
// 上传图片过大
errInfo.push(`【${name}】大于 ${maxSizeM}M`)
return
}
// 验证通过的加入结果列表
resultFiles.push(file)
})
// 抛出验证信息
if (errInfo.length) {
this._alert('图片验证未通过: \n' + errInfo.join('\n'))
return
}
if (resultFiles.length > maxLength) {
this._alert('一次最多上传' + maxLength + '张图片')
return
}
// ------------------------------ 自定义上传 ------------------------------
if (customUploadImg && typeof customUploadImg === 'function') {
customUploadImg(resultFiles, this.insertLinkImg.bind(this))
// 阻止以下代码执行
return
}
// 添加图片数据
const formdata = new FormData()
arrForEach(resultFiles, file => {
const name = uploadFileName || file.name
formdata.append(name, file)
})
// ------------------------------ 上传图片 ------------------------------
if (uploadImgServer && typeof uploadImgServer === 'string') {
// 添加参数
const uploadImgServerArr = uploadImgServer.split('#')
uploadImgServer = uploadImgServerArr[0]
const uploadImgServerHash = uploadImgServerArr[1] || ''
objForEach(uploadImgParams, (key, val) => {
// 因使用者反应,自定义参数不能默认 encode ,由 v3.1.1 版本开始注释掉
// val = encodeURIComponent(val)
// 第一,将参数拼接到 url 中
if (uploadImgParamsWithUrl) {
if (uploadImgServer.indexOf('?') > 0) {
uploadImgServer += '&'
} else {
uploadImgServer += '?'
}
uploadImgServer = uploadImgServer + key + '=' + val
}
// 第二,将参数添加到 formdata 中
formdata.append(key, val)
})
if (uploadImgServerHash) {
uploadImgServer += '#' + uploadImgServerHash
}
// 定义 xhr
const xhr = new XMLHttpRequest()
xhr.open('POST', uploadImgServer)
// 设置超时
xhr.timeout = timeout
xhr.ontimeout = () => {
// hook - timeout
if (hooks.timeout && typeof hooks.timeout === 'function') {
hooks.timeout(xhr, editor)
}
this._alert('上传图片超时')
}
// 监控 progress
if (xhr.upload) {
xhr.upload.onprogress = e => {
let percent
// 进度条
const progressBar = new Progress(editor)
if (e.lengthComputable) {
percent = e.loaded / e.total
progressBar.show(percent)
}
}
}
// 返回数据
xhr.onreadystatechange = () => {
let result
if (xhr.readyState === 4) {
if (xhr.status < 200 || xhr.status >= 300) {
// hook - error
if (hooks.error && typeof hooks.error === 'function') {
hooks.error(xhr, editor)
}
// xhr 返回状态错误
this._alert('上传图片发生错误', `上传图片发生错误,服务器返回状态是 ${xhr.status}`)
return
}
result = xhr.responseText
if (typeof result !== 'object') {
try {
result = JSON.parse(result)
} catch (ex) {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result)
}
this._alert('上传图片失败', '上传图片返回结果错误,返回结果是: ' + result)
return
}
}
if (!hooks.customInsert && result.errno != '0') {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result)
}
// 数据错误
this._alert('上传图片失败', '上传图片返回结果错误,返回结果 errno=' + result.errno)
} else {
if (hooks.customInsert && typeof hooks.customInsert === 'function') {
// 使用者自定义插入方法
hooks.customInsert(this.insertLinkImg.bind(this), result, editor)
} else {
// 将图片插入编辑器
const data = result.data || []
data.forEach(link => {
this.insertLinkImg(link)
})
}
// hook - success
if (hooks.success && typeof hooks.success === 'function') {
hooks.success(xhr, editor, result)
}
}
}
}
// hook - before
if (hooks.before && typeof hooks.before === 'function') {
const beforeResult = hooks.before(xhr, editor, resultFiles)
if (beforeResult && typeof beforeResult === 'object') {
if (beforeResult.prevent) {
// 如果返回的结果是 {prevent: true, msg: 'xxxx'} 则表示用户放弃上传
this._alert(beforeResult.msg)
return
}
}
}
// 自定义 headers
objForEach(uploadImgHeaders, (key, val) => {
xhr.setRequestHeader(key, val)
})
// 跨域传 cookie
xhr.withCredentials = withCredentials
// 发送请求
xhr.send(formdata)
// 注意,要 return 。不去操作接下来的 base64 显示方式
return
}
// ------------------------------ 显示 base64 格式 ------------------------------
if (uploadImgShowBase64) {
arrForEach(files, file => {
const _this = this
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = function () {
_this.insertLinkImg(this.result)
}
})
}
} | javascript | function (files) {
if (!files || !files.length) {
return
}
// ------------------------------ 获取配置信息 ------------------------------
const editor = this.editor
const config = editor.config
let uploadImgServer = config.uploadImgServer
const uploadImgShowBase64 = config.uploadImgShowBase64
const maxSize = config.uploadImgMaxSize
const maxSizeM = maxSize / 1024 / 1024
const maxLength = config.uploadImgMaxLength || 10000
const uploadFileName = config.uploadFileName || ''
const uploadImgParams = config.uploadImgParams || {}
const uploadImgParamsWithUrl = config.uploadImgParamsWithUrl
const uploadImgHeaders = config.uploadImgHeaders || {}
const hooks = config.uploadImgHooks || {}
const timeout = config.uploadImgTimeout || 3000
let withCredentials = config.withCredentials
if (withCredentials == null) {
withCredentials = false
}
const customUploadImg = config.customUploadImg
if (!customUploadImg) {
// 没有 customUploadImg 的情况下,需要如下两个配置才能继续进行图片上传
if (!uploadImgServer && !uploadImgShowBase64) {
return
}
}
// ------------------------------ 验证文件信息 ------------------------------
const resultFiles = []
let errInfo = []
arrForEach(files, file => {
var name = file.name
var size = file.size
// chrome 低版本 name === undefined
if (!name || !size) {
return
}
if (/\.(jpg|jpeg|png|bmp|gif|webp)$/i.test(name) === false) {
// 后缀名不合法,不是图片
errInfo.push(`【${name}】不是图片`)
return
}
if (maxSize < size) {
// 上传图片过大
errInfo.push(`【${name}】大于 ${maxSizeM}M`)
return
}
// 验证通过的加入结果列表
resultFiles.push(file)
})
// 抛出验证信息
if (errInfo.length) {
this._alert('图片验证未通过: \n' + errInfo.join('\n'))
return
}
if (resultFiles.length > maxLength) {
this._alert('一次最多上传' + maxLength + '张图片')
return
}
// ------------------------------ 自定义上传 ------------------------------
if (customUploadImg && typeof customUploadImg === 'function') {
customUploadImg(resultFiles, this.insertLinkImg.bind(this))
// 阻止以下代码执行
return
}
// 添加图片数据
const formdata = new FormData()
arrForEach(resultFiles, file => {
const name = uploadFileName || file.name
formdata.append(name, file)
})
// ------------------------------ 上传图片 ------------------------------
if (uploadImgServer && typeof uploadImgServer === 'string') {
// 添加参数
const uploadImgServerArr = uploadImgServer.split('#')
uploadImgServer = uploadImgServerArr[0]
const uploadImgServerHash = uploadImgServerArr[1] || ''
objForEach(uploadImgParams, (key, val) => {
// 因使用者反应,自定义参数不能默认 encode ,由 v3.1.1 版本开始注释掉
// val = encodeURIComponent(val)
// 第一,将参数拼接到 url 中
if (uploadImgParamsWithUrl) {
if (uploadImgServer.indexOf('?') > 0) {
uploadImgServer += '&'
} else {
uploadImgServer += '?'
}
uploadImgServer = uploadImgServer + key + '=' + val
}
// 第二,将参数添加到 formdata 中
formdata.append(key, val)
})
if (uploadImgServerHash) {
uploadImgServer += '#' + uploadImgServerHash
}
// 定义 xhr
const xhr = new XMLHttpRequest()
xhr.open('POST', uploadImgServer)
// 设置超时
xhr.timeout = timeout
xhr.ontimeout = () => {
// hook - timeout
if (hooks.timeout && typeof hooks.timeout === 'function') {
hooks.timeout(xhr, editor)
}
this._alert('上传图片超时')
}
// 监控 progress
if (xhr.upload) {
xhr.upload.onprogress = e => {
let percent
// 进度条
const progressBar = new Progress(editor)
if (e.lengthComputable) {
percent = e.loaded / e.total
progressBar.show(percent)
}
}
}
// 返回数据
xhr.onreadystatechange = () => {
let result
if (xhr.readyState === 4) {
if (xhr.status < 200 || xhr.status >= 300) {
// hook - error
if (hooks.error && typeof hooks.error === 'function') {
hooks.error(xhr, editor)
}
// xhr 返回状态错误
this._alert('上传图片发生错误', `上传图片发生错误,服务器返回状态是 ${xhr.status}`)
return
}
result = xhr.responseText
if (typeof result !== 'object') {
try {
result = JSON.parse(result)
} catch (ex) {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result)
}
this._alert('上传图片失败', '上传图片返回结果错误,返回结果是: ' + result)
return
}
}
if (!hooks.customInsert && result.errno != '0') {
// hook - fail
if (hooks.fail && typeof hooks.fail === 'function') {
hooks.fail(xhr, editor, result)
}
// 数据错误
this._alert('上传图片失败', '上传图片返回结果错误,返回结果 errno=' + result.errno)
} else {
if (hooks.customInsert && typeof hooks.customInsert === 'function') {
// 使用者自定义插入方法
hooks.customInsert(this.insertLinkImg.bind(this), result, editor)
} else {
// 将图片插入编辑器
const data = result.data || []
data.forEach(link => {
this.insertLinkImg(link)
})
}
// hook - success
if (hooks.success && typeof hooks.success === 'function') {
hooks.success(xhr, editor, result)
}
}
}
}
// hook - before
if (hooks.before && typeof hooks.before === 'function') {
const beforeResult = hooks.before(xhr, editor, resultFiles)
if (beforeResult && typeof beforeResult === 'object') {
if (beforeResult.prevent) {
// 如果返回的结果是 {prevent: true, msg: 'xxxx'} 则表示用户放弃上传
this._alert(beforeResult.msg)
return
}
}
}
// 自定义 headers
objForEach(uploadImgHeaders, (key, val) => {
xhr.setRequestHeader(key, val)
})
// 跨域传 cookie
xhr.withCredentials = withCredentials
// 发送请求
xhr.send(formdata)
// 注意,要 return 。不去操作接下来的 base64 显示方式
return
}
// ------------------------------ 显示 base64 格式 ------------------------------
if (uploadImgShowBase64) {
arrForEach(files, file => {
const _this = this
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = function () {
_this.insertLinkImg(this.result)
}
})
}
} | [
"function",
"(",
"files",
")",
"{",
"if",
"(",
"!",
"files",
"||",
"!",
"files",
".",
"length",
")",
"{",
"return",
"}",
"// ------------------------------ 获取配置信息 ------------------------------",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"config",
... | 上传图片 | [
"上传图片"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/editor/upload/upload-img.js#L80-L314 | train | get the file list | [
30522,
3853,
1006,
6764,
1007,
1063,
2065,
1006,
999,
6764,
1064,
1064,
999,
6764,
1012,
3091,
1007,
1063,
2709,
1065,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
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... | |
heyui/heyui | src/plugins/popper/index.js | getClientRect | function getClientRect(offsets) {
return _extends({}, offsets, {
right: offsets.left + offsets.width,
bottom: offsets.top + offsets.height
});
} | javascript | function getClientRect(offsets) {
return _extends({}, offsets, {
right: offsets.left + offsets.width,
bottom: offsets.top + offsets.height
});
} | [
"function",
"getClientRect",
"(",
"offsets",
")",
"{",
"return",
"_extends",
"(",
"{",
"}",
",",
"offsets",
",",
"{",
"right",
":",
"offsets",
".",
"left",
"+",
"offsets",
".",
"width",
",",
"bottom",
":",
"offsets",
".",
"top",
"+",
"offsets",
".",
... | Given element offsets, generate an output similar to getBoundingClientRect
@method
@memberof Popper.Utils
@argument {Object} offsets
@returns {Object} ClientRect like output | [
"Given",
"element",
"offsets",
"generate",
"an",
"output",
"similar",
"to",
"getBoundingClientRect"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L432-L437 | train | Get the client rect of the node | [
30522,
3853,
2131,
20464,
11638,
2890,
6593,
1006,
16396,
2015,
1007,
1063,
2709,
1035,
8908,
1006,
1063,
1065,
1010,
16396,
2015,
1010,
1063,
2157,
1024,
16396,
2015,
1012,
2187,
1009,
16396,
2015,
1012,
9381,
1010,
3953,
1024,
16396,
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/language/CSSUtils.js | _parseSelector | function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
} | javascript | function _parseSelector(ctx) {
var selector = "";
// Skip over {
TokenUtils.movePrevToken(ctx);
while (true) {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
}
// Stop once we've reached a <style ...> tag
if (ctx.token.string === "style" && ctx.token.type === "tag") {
// Remove everything up to end-of-tag from selector
var eotIndex = selector.indexOf(">");
if (eotIndex !== -1) {
selector = selector.substring(eotIndex + 1);
}
break;
}
selector = ctx.token.string + selector;
}
if (!TokenUtils.movePrevToken(ctx)) {
break;
}
}
return selector;
} | [
"function",
"_parseSelector",
"(",
"ctx",
")",
"{",
"var",
"selector",
"=",
"\"\"",
";",
"// Skip over {",
"TokenUtils",
".",
"movePrevToken",
"(",
"ctx",
")",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"ctx",
".",
"token",
".",
"type",
"!==",
"\"... | Parse a selector. Assumes ctx is pointing at the opening { that is after the selector name. | [
"Parse",
"a",
"selector",
".",
"Assumes",
"ctx",
"is",
"pointing",
"at",
"the",
"opening",
"{",
"that",
"is",
"after",
"the",
"selector",
"name",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1563-L1594 | train | Parse selector | [
30522,
3853,
1035,
11968,
8583,
12260,
16761,
1006,
14931,
2595,
1007,
1063,
13075,
27000,
1027,
1000,
1000,
1025,
1013,
1013,
13558,
2058,
1063,
19204,
21823,
4877,
1012,
2693,
28139,
2615,
18715,
2368,
1006,
14931,
2595,
1007,
1025,
2096,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | fnAddStandaloneBusyIndicator | function fnAddStandaloneBusyIndicator () {
this._oBusyBlockState = BlockLayerUtils.block(this, this.getId() + "-busyIndicator", this._sBusySection);
BusyIndicatorUtils.addHTML(this._oBusyBlockState, this.getBusyIndicatorSize());
} | javascript | function fnAddStandaloneBusyIndicator () {
this._oBusyBlockState = BlockLayerUtils.block(this, this.getId() + "-busyIndicator", this._sBusySection);
BusyIndicatorUtils.addHTML(this._oBusyBlockState, this.getBusyIndicatorSize());
} | [
"function",
"fnAddStandaloneBusyIndicator",
"(",
")",
"{",
"this",
".",
"_oBusyBlockState",
"=",
"BlockLayerUtils",
".",
"block",
"(",
"this",
",",
"this",
".",
"getId",
"(",
")",
"+",
"\"-busyIndicator\"",
",",
"this",
".",
"_sBusySection",
")",
";",
"BusyInd... | Adds a standalone BusyIndicator.
The block-layer code is able to recognize that a new block-layer is not needed. | [
"Adds",
"a",
"standalone",
"BusyIndicator",
".",
"The",
"block",
"-",
"layer",
"code",
"is",
"able",
"to",
"recognize",
"that",
"a",
"new",
"block",
"-",
"layer",
"is",
"not",
"needed",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Control.js#L773-L776 | train | Adds the standalone busy indicator to the container | [
30522,
3853,
1042,
25389,
5104,
5794,
9305,
5643,
8286,
25811,
14808,
8844,
1006,
1007,
1063,
2023,
1012,
1035,
27885,
2271,
2100,
23467,
9153,
2618,
1027,
3796,
24314,
21823,
4877,
1012,
3796,
1006,
2023,
1010,
2023,
1012,
2131,
3593,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | examples/measure.js | createHelpTooltip | function createHelpTooltip() {
if (helpTooltipElement) {
helpTooltipElement.parentNode.removeChild(helpTooltipElement);
}
helpTooltipElement = document.createElement('div');
helpTooltipElement.className = 'ol-tooltip hidden';
helpTooltip = new Overlay({
element: helpTooltipElement,
offset: [15, 0],
positioning: 'center-left'
});
map.addOverlay(helpTooltip);
} | javascript | function createHelpTooltip() {
if (helpTooltipElement) {
helpTooltipElement.parentNode.removeChild(helpTooltipElement);
}
helpTooltipElement = document.createElement('div');
helpTooltipElement.className = 'ol-tooltip hidden';
helpTooltip = new Overlay({
element: helpTooltipElement,
offset: [15, 0],
positioning: 'center-left'
});
map.addOverlay(helpTooltip);
} | [
"function",
"createHelpTooltip",
"(",
")",
"{",
"if",
"(",
"helpTooltipElement",
")",
"{",
"helpTooltipElement",
".",
"parentNode",
".",
"removeChild",
"(",
"helpTooltipElement",
")",
";",
"}",
"helpTooltipElement",
"=",
"document",
".",
"createElement",
"(",
"'di... | Creates a new help tooltip | [
"Creates",
"a",
"new",
"help",
"tooltip"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L243-L255 | train | Creates a new help tooltip element | [
30522,
3853,
3443,
16001,
13876,
13669,
25101,
1006,
1007,
1063,
2065,
1006,
2393,
3406,
27914,
15457,
16930,
4765,
1007,
1063,
2393,
3406,
27914,
15457,
16930,
4765,
1012,
6687,
3630,
3207,
1012,
6366,
19339,
1006,
2393,
3406,
27914,
15457,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(node, from, remove, step, delay, isEnabled)
{
mxEffects.fadeOut.apply(this, arguments);
} | javascript | function(node, from, remove, step, delay, isEnabled)
{
mxEffects.fadeOut.apply(this, arguments);
} | [
"function",
"(",
"node",
",",
"from",
",",
"remove",
",",
"step",
",",
"delay",
",",
"isEnabled",
")",
"{",
"mxEffects",
".",
"fadeOut",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}"
] | Function: fadeOut
See <mxEffects.fadeOut>. This is for backwards compatibility and
will be removed later. | [
"Function",
":",
"fadeOut"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L5188-L5191 | train | Fade out the node | [
30522,
3853,
1006,
13045,
1010,
2013,
1010,
6366,
1010,
3357,
1010,
8536,
1010,
2003,
8189,
23242,
1007,
1063,
25630,
12879,
25969,
2015,
1012,
12985,
5833,
1012,
6611,
1006,
2023,
1010,
9918,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | src/ol/pointer/MsSource.js | msPointerDown | function msPointerDown(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
const e = this.prepareEvent_(inEvent);
this.dispatcher.down(e, inEvent);
} | javascript | function msPointerDown(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
const e = this.prepareEvent_(inEvent);
this.dispatcher.down(e, inEvent);
} | [
"function",
"msPointerDown",
"(",
"inEvent",
")",
"{",
"this",
".",
"pointerMap",
"[",
"inEvent",
".",
"pointerId",
".",
"toString",
"(",
")",
"]",
"=",
"inEvent",
";",
"const",
"e",
"=",
"this",
".",
"prepareEvent_",
"(",
"inEvent",
")",
";",
"this",
... | Handler for `msPointerDown`.
@this {MsSource}
@param {MSPointerEvent} inEvent The in event. | [
"Handler",
"for",
"msPointerDown",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L55-L59 | train | Handler for msPointerDown. | [
30522,
3853,
5796,
8400,
2121,
7698,
1006,
1999,
18697,
3372,
1007,
1063,
2023,
1012,
20884,
2863,
2361,
1031,
1999,
18697,
3372,
1012,
20884,
3593,
1012,
2000,
3367,
4892,
1006,
1007,
1033,
1027,
1999,
18697,
3372,
1025,
9530,
3367,
1041,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | commitPicker | function commitPicker(picker) {
var filter = getActiveFilter();
return (filter && filter.patterns.length) ? compile(filter.patterns) : "";
} | javascript | function commitPicker(picker) {
var filter = getActiveFilter();
return (filter && filter.patterns.length) ? compile(filter.patterns) : "";
} | [
"function",
"commitPicker",
"(",
"picker",
")",
"{",
"var",
"filter",
"=",
"getActiveFilter",
"(",
")",
";",
"return",
"(",
"filter",
"&&",
"filter",
".",
"patterns",
".",
"length",
")",
"?",
"compile",
"(",
"filter",
".",
"patterns",
")",
":",
"\"\"",
... | Marks the filter picker's currently selected item as most-recently used, and returns the corresponding
'compiled' filter object ready for use with filterPath().
@param {!jQueryObject} picker UI returned from createFilterPicker()
@return {!string} 'compiled' filter that can be passed to filterPath()/filterFileList(). | [
"Marks",
"the",
"filter",
"picker",
"s",
"currently",
"selected",
"item",
"as",
"most",
"-",
"recently",
"used",
"and",
"returns",
"the",
"corresponding",
"compiled",
"filter",
"object",
"ready",
"for",
"use",
"with",
"filterPath",
"()",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L424-L427 | train | commit the picker | [
30522,
3853,
10797,
24330,
5484,
1006,
4060,
2121,
1007,
1063,
13075,
11307,
1027,
2131,
19620,
8873,
21928,
1006,
1007,
1025,
2709,
1006,
11307,
1004,
1004,
11307,
1012,
7060,
1012,
3091,
1007,
1029,
4012,
22090,
1006,
11307,
1012,
7060,
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.documentation/src/sap/ui/documentation/sdk/controller/util/SearchUtil.js | init | function init() {
if (!oInitPromise) {
oInitPromise = new Promise(function(resolve, reject) {
oWorker = new window.Worker(WORKER.URL);
// listen for confirmation from worker
oWorker.addEventListener('message', function(oEvent) {
var oData = oEvent.data;
resolve(oData && oData[WORKER.RESPONSE_FIELDS.DONE] === true);
}, false);
// instruct the worker to fetch the index data
oWorker.postMessage({
"cmd": WORKER.COMMANDS.INIT,
"bIsMsieBrowser": !!Device.browser.msie
});
});
}
return oInitPromise;
} | javascript | function init() {
if (!oInitPromise) {
oInitPromise = new Promise(function(resolve, reject) {
oWorker = new window.Worker(WORKER.URL);
// listen for confirmation from worker
oWorker.addEventListener('message', function(oEvent) {
var oData = oEvent.data;
resolve(oData && oData[WORKER.RESPONSE_FIELDS.DONE] === true);
}, false);
// instruct the worker to fetch the index data
oWorker.postMessage({
"cmd": WORKER.COMMANDS.INIT,
"bIsMsieBrowser": !!Device.browser.msie
});
});
}
return oInitPromise;
} | [
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"oInitPromise",
")",
"{",
"oInitPromise",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"oWorker",
"=",
"new",
"window",
".",
"Worker",
"(",
"WORKER",
".",
"URL",
"... | Initializes the setup for client-search
@returns {*} | [
"Initializes",
"the",
"setup",
"for",
"client",
"-",
"search"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/SearchUtil.js#L29-L50 | train | Initializes the index data | [
30522,
3853,
1999,
4183,
1006,
1007,
1063,
2065,
1006,
999,
1051,
5498,
25856,
21716,
5562,
1007,
1063,
1051,
5498,
25856,
21716,
5562,
1027,
2047,
4872,
1006,
3853,
1006,
10663,
1010,
15454,
1007,
1063,
27593,
2953,
5484,
1027,
2047,
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... |
facebook/flow | packages/flow-remove-types/index.js | visit | function visit(ast, context, visitor) {
var stack;
var parent;
var keys = [];
var index = -1;
do {
index++;
if (stack && index === keys.length) {
parent = stack.parent;
keys = stack.keys;
index = stack.index;
stack = stack.prev;
} else {
var node = parent ? parent[keys[index]] : getProgram(ast);
if (node && typeof node === 'object' && (node.type || node.length)) {
if (node.type) {
var visitFn = visitor[node.type];
if (visitFn && visitFn(context, node, ast) === false) {
continue;
}
}
stack = {parent: parent, keys: keys, index: index, prev: stack};
parent = node;
keys = Object.keys(node);
index = -1;
}
}
} while (stack);
} | javascript | function visit(ast, context, visitor) {
var stack;
var parent;
var keys = [];
var index = -1;
do {
index++;
if (stack && index === keys.length) {
parent = stack.parent;
keys = stack.keys;
index = stack.index;
stack = stack.prev;
} else {
var node = parent ? parent[keys[index]] : getProgram(ast);
if (node && typeof node === 'object' && (node.type || node.length)) {
if (node.type) {
var visitFn = visitor[node.type];
if (visitFn && visitFn(context, node, ast) === false) {
continue;
}
}
stack = {parent: parent, keys: keys, index: index, prev: stack};
parent = node;
keys = Object.keys(node);
index = -1;
}
}
} while (stack);
} | [
"function",
"visit",
"(",
"ast",
",",
"context",
",",
"visitor",
")",
"{",
"var",
"stack",
";",
"var",
"parent",
";",
"var",
"keys",
"=",
"[",
"]",
";",
"var",
"index",
"=",
"-",
"1",
";",
"do",
"{",
"index",
"++",
";",
"if",
"(",
"stack",
"&&"... | Given the AST output from the parser, walk through in a depth-first order, calling methods on the given visitor, providing context as the first argument. | [
"Given",
"the",
"AST",
"output",
"from",
"the",
"parser",
"walk",
"through",
"in",
"a",
"depth",
"-",
"first",
"order",
"calling",
"methods",
"on",
"the",
"given",
"visitor",
"providing",
"context",
"as",
"the",
"first",
"argument",
"."
] | 25bc6aba258658eaf21ccc4722ef7124724a1d2b | https://github.com/facebook/flow/blob/25bc6aba258658eaf21ccc4722ef7124724a1d2b/packages/flow-remove-types/index.js#L461-L490 | train | Visit the given AST. | [
30522,
3853,
3942,
1006,
2004,
2102,
1010,
6123,
1010,
10367,
1007,
1063,
13075,
9991,
1025,
13075,
6687,
1025,
13075,
6309,
1027,
1031,
1033,
1025,
13075,
5950,
1027,
1011,
1015,
1025,
2079,
1063,
5950,
1009,
1009,
1025,
2065,
1006,
9991,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/models/base/index.js | fixDates | function fixDates(attrs) {
var self = this;
_.each(attrs, function each(value, key) {
if (value !== null
&& schema.tables[self.tableName].hasOwnProperty(key)
&& schema.tables[self.tableName][key].type === 'dateTime') {
attrs[key] = moment(value).format('YYYY-MM-DD HH:mm:ss');
}
});
return attrs;
} | javascript | function fixDates(attrs) {
var self = this;
_.each(attrs, function each(value, key) {
if (value !== null
&& schema.tables[self.tableName].hasOwnProperty(key)
&& schema.tables[self.tableName][key].type === 'dateTime') {
attrs[key] = moment(value).format('YYYY-MM-DD HH:mm:ss');
}
});
return attrs;
} | [
"function",
"fixDates",
"(",
"attrs",
")",
"{",
"var",
"self",
"=",
"this",
";",
"_",
".",
"each",
"(",
"attrs",
",",
"function",
"each",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"value",
"!==",
"null",
"&&",
"schema",
".",
"tables",
"[",
"... | before we insert dates into the database, we have to normalize
date format is now in each db the same | [
"before",
"we",
"insert",
"dates",
"into",
"the",
"database",
"we",
"have",
"to",
"normalize",
"date",
"format",
"is",
"now",
"in",
"each",
"db",
"the",
"same"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L443-L455 | train | Fix dates in the schema | [
30522,
3853,
8081,
27122,
1006,
2012,
16344,
2015,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1035,
1012,
2169,
1006,
2012,
16344,
2015,
1010,
3853,
2169,
1006,
3643,
1010,
3145,
1007,
1063,
2065,
1006,
3643,
999,
1027,
1027,
19701,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/NotificationBar.js | function(oThis) {
var aNotifiers = oThis.getNotifiers();
for (var i = 0; i < aNotifiers.length; i++) {
var iCount = aNotifiers[i].getMessages().length;
var sKey = "NOTIBAR_NOTIFIER_COUNT_TEXT_" + (iCount === 1 ? "SING" : "PL");
fnSetNotifierDescription(oThis, aNotifiers[i], sKey, iCount);
}
} | javascript | function(oThis) {
var aNotifiers = oThis.getNotifiers();
for (var i = 0; i < aNotifiers.length; i++) {
var iCount = aNotifiers[i].getMessages().length;
var sKey = "NOTIBAR_NOTIFIER_COUNT_TEXT_" + (iCount === 1 ? "SING" : "PL");
fnSetNotifierDescription(oThis, aNotifiers[i], sKey, iCount);
}
} | [
"function",
"(",
"oThis",
")",
"{",
"var",
"aNotifiers",
"=",
"oThis",
".",
"getNotifiers",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aNotifiers",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"iCount",
"=",
"aNotifiers",
... | Sets all description of all notifiers
@private | [
"Sets",
"all",
"description",
"of",
"all",
"notifiers"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/NotificationBar.js#L1018-L1027 | train | Set the notifier description | [
30522,
3853,
1006,
27178,
24158,
1007,
1063,
13075,
2019,
4140,
28295,
1027,
27178,
24158,
1012,
2131,
17048,
28295,
1006,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2019,
4140,
28295,
1012,
3091,
1025,
1045,
1009,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable) {
var oBinding = oTable ? oTable.getBinding("rows") : null;
if (TableUtils.isA(oBinding, "sap.ui.model.analytics.AnalyticalBinding")) {
return oBinding.bUseBatchRequests;
} else if (TableUtils.isA(oBinding, "sap.ui.model.TreeBinding")) {
return false;
}
return true;
} | javascript | function(oTable) {
var oBinding = oTable ? oTable.getBinding("rows") : null;
if (TableUtils.isA(oBinding, "sap.ui.model.analytics.AnalyticalBinding")) {
return oBinding.bUseBatchRequests;
} else if (TableUtils.isA(oBinding, "sap.ui.model.TreeBinding")) {
return false;
}
return true;
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oBinding",
"=",
"oTable",
"?",
"oTable",
".",
"getBinding",
"(",
"\"rows\"",
")",
":",
"null",
";",
"if",
"(",
"TableUtils",
".",
"isA",
"(",
"oBinding",
",",
"\"sap.ui.model.analytics.AnalyticalBinding\"",
")",
"... | A counter to determine whether there are pending requests can be used if exactly one dataReceived event is fired for every
dataRequested event. If this is not the case and there can be an imbalance between dataReceived and dataRequested events, a more limited
method using a boolean flag must be used.
It is not always possible to correctly determine whether there is a pending request, because the table must use a flag instead of a
counter. A flag is necessary under the following conditions:
If the AnalyticalBinding is created with the parameter "useBatchRequest" set to false, an imbalance between dataRequested and
dataReceived events can occur. There will be one dataRequested event for every request that would otherwise be part of a batch
request. But still only one dataReceived event is fired after all responses are received.
If the ODataTreeBindingFlat adapter is applied to the TreeBinding, the adapter fires a dataRequested event on every call of getNodes,
even if no request is sent. This can happen if the adapter ignores the request, because it finds out there is a pending request which
covers it. When a request is ignored no dataReceived event is fired.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {boolean} Returns <code>true</code>, if the table can use a counter for pending request detection. | [
"A",
"counter",
"to",
"determine",
"whether",
"there",
"are",
"pending",
"requests",
"can",
"be",
"used",
"if",
"exactly",
"one",
"dataReceived",
"event",
"is",
"fired",
"for",
"every",
"dataRequested",
"event",
".",
"If",
"this",
"is",
"not",
"the",
"case",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L422-L432 | train | Returns true if the table is using batch requests | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
27885,
22254,
2075,
1027,
27178,
3085,
1029,
27178,
3085,
1012,
2131,
8428,
4667,
1006,
1000,
10281,
1000,
1007,
1024,
19701,
1025,
2065,
1006,
2795,
21823,
4877,
1012,
18061,
1006,
27885,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | receiverOnPing | function receiverOnPing(data) {
const websocket = this[kWebSocket];
websocket.pong(data, !websocket._isServer, NOOP);
websocket.emit('ping', data);
} | javascript | function receiverOnPing(data) {
const websocket = this[kWebSocket];
websocket.pong(data, !websocket._isServer, NOOP);
websocket.emit('ping', data);
} | [
"function",
"receiverOnPing",
"(",
"data",
")",
"{",
"const",
"websocket",
"=",
"this",
"[",
"kWebSocket",
"]",
";",
"websocket",
".",
"pong",
"(",
"data",
",",
"!",
"websocket",
".",
"_isServer",
",",
"NOOP",
")",
";",
"websocket",
".",
"emit",
"(",
"... | The listener of the `Receiver` `'ping'` event.
@param {Buffer} data The data included in the ping frame
@private | [
"The",
"listener",
"of",
"the",
"Receiver",
"ping",
"event",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket.js#L805-L810 | train | receiverOnPing - Sends ping to the remote | [
30522,
3853,
8393,
2239,
4691,
1006,
2951,
1007,
1063,
9530,
3367,
4773,
6499,
19869,
2102,
1027,
2023,
1031,
6448,
15878,
6499,
19869,
2102,
1033,
1025,
4773,
6499,
19869,
2102,
1012,
13433,
3070,
1006,
2951,
1010,
999,
4773,
6499,
19869,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/babel-plugin-relay/getValidRelayQLTag.js | getValidRelayQLTag | function getValidRelayQLTag(path: any): [any, ?string, ?string] {
const {node} = path;
const tag = path.get('tag');
const tagName = tag.matchesPattern('Relay.QL')
? 'Relay.QL'
: tag.matchesPattern('RelayClassic_DEPRECATED.QL')
? 'RelayClassic_DEPRECATED.QL'
: tag.matchesPattern('RelayClassic.QL')
? 'RelayClassic.QL'
: tag.isIdentifier({name: 'RelayQL'})
? 'RelayQL'
: null;
if (!tagName) {
return [null, null, null];
}
let p = path;
let propName = null;
while (!propName && (p = p.parentPath)) {
if (p.isProperty()) {
propName = p.node.key.name;
}
}
return [node.quasi, tagName, propName];
} | javascript | function getValidRelayQLTag(path: any): [any, ?string, ?string] {
const {node} = path;
const tag = path.get('tag');
const tagName = tag.matchesPattern('Relay.QL')
? 'Relay.QL'
: tag.matchesPattern('RelayClassic_DEPRECATED.QL')
? 'RelayClassic_DEPRECATED.QL'
: tag.matchesPattern('RelayClassic.QL')
? 'RelayClassic.QL'
: tag.isIdentifier({name: 'RelayQL'})
? 'RelayQL'
: null;
if (!tagName) {
return [null, null, null];
}
let p = path;
let propName = null;
while (!propName && (p = p.parentPath)) {
if (p.isProperty()) {
propName = p.node.key.name;
}
}
return [node.quasi, tagName, propName];
} | [
"function",
"getValidRelayQLTag",
"(",
"path",
":",
"any",
")",
":",
"[",
"any",
",",
"?",
"string",
",",
"?",
"string",
"]",
"{",
"const",
"{",
"node",
"}",
"=",
"path",
";",
"const",
"tag",
"=",
"path",
".",
"get",
"(",
"'tag'",
")",
";",
"cons... | Given a TemplateLiteral path, return the metadata about a RelayQL tag
if one exists. | [
"Given",
"a",
"TemplateLiteral",
"path",
"return",
"the",
"metadata",
"about",
"a",
"RelayQL",
"tag",
"if",
"one",
"exists",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/babel-plugin-relay/getValidRelayQLTag.js#L17-L43 | train | Returns the valid tag name and property name of the node | [
30522,
3853,
2131,
10175,
3593,
16570,
4710,
4160,
24458,
2290,
1006,
4130,
1024,
2151,
1007,
1024,
1031,
2151,
1010,
1029,
5164,
1010,
1029,
5164,
1033,
1063,
9530,
3367,
1063,
13045,
1065,
1027,
4130,
1025,
9530,
3367,
6415,
1027,
4130,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/DataType.js | function(sValue, _oOptions) {
if ( sValue === "" ) {
return undefined;
}
if ( !/^\.?[A-Z_\$][A-Z0-9_\$]*(\.[A-Z_\$][A-Z0-9_\$]*)*$/i.test(sValue) ) {
throw new Error(
"Function references must consist of dot separated " +
"simple identifiers (A-Z, 0-9, _ or $) only, but was '" + sValue + "'");
}
// TODO implementation should be moved to / shared with EventHandlerResolver
var fnResult,
bLocal,
contextObj = _oOptions && _oOptions.context;
if ( sValue[0] === '.' ) {
// starts with a dot, must be a controller local function
// usage of ObjectPath.get to allow addressing functions in properties
if ( contextObj ) {
fnResult = ObjectPath.get(sValue.slice(1), contextObj);
bLocal = true;
}
} else {
fnResult = ObjectPath.get(sValue);
}
if ( fnResult && this.isValid(fnResult) ) {
return bLocal ? fnResult.bind(contextObj) : fnResult;
}
throw new TypeError("The string '" + sValue + "' couldn't be resolved to a function");
} | javascript | function(sValue, _oOptions) {
if ( sValue === "" ) {
return undefined;
}
if ( !/^\.?[A-Z_\$][A-Z0-9_\$]*(\.[A-Z_\$][A-Z0-9_\$]*)*$/i.test(sValue) ) {
throw new Error(
"Function references must consist of dot separated " +
"simple identifiers (A-Z, 0-9, _ or $) only, but was '" + sValue + "'");
}
// TODO implementation should be moved to / shared with EventHandlerResolver
var fnResult,
bLocal,
contextObj = _oOptions && _oOptions.context;
if ( sValue[0] === '.' ) {
// starts with a dot, must be a controller local function
// usage of ObjectPath.get to allow addressing functions in properties
if ( contextObj ) {
fnResult = ObjectPath.get(sValue.slice(1), contextObj);
bLocal = true;
}
} else {
fnResult = ObjectPath.get(sValue);
}
if ( fnResult && this.isValid(fnResult) ) {
return bLocal ? fnResult.bind(contextObj) : fnResult;
}
throw new TypeError("The string '" + sValue + "' couldn't be resolved to a function");
} | [
"function",
"(",
"sValue",
",",
"_oOptions",
")",
"{",
"if",
"(",
"sValue",
"===",
"\"\"",
")",
"{",
"return",
"undefined",
";",
"}",
"if",
"(",
"!",
"/",
"^\\.?[A-Z_\\$][A-Z0-9_\\$]*(\\.[A-Z_\\$][A-Z0-9_\\$]*)*$",
"/",
"i",
".",
"test",
"(",
"sValue",
")",
... | /*
Note: the second parameter <code>_oOptions</code> is a hidden feature for internal use only.
Its structure is subject to change. No code other than the XMLTemplateProcessor must use it. | [
"/",
"*",
"Note",
":",
"the",
"second",
"parameter",
"<code",
">",
"_oOptions<",
"/",
"code",
">",
"is",
"a",
"hidden",
"feature",
"for",
"internal",
"use",
"only",
".",
"Its",
"structure",
"is",
"subject",
"to",
"change",
".",
"No",
"code",
"other",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/DataType.js#L439-L471 | train | Returns the function that is bound to the given value | [
30522,
3853,
1006,
17917,
2389,
5657,
1010,
1035,
1051,
7361,
9285,
1007,
1063,
2065,
1006,
17917,
2389,
5657,
1027,
1027,
1027,
1000,
1000,
1007,
1063,
2709,
6151,
28344,
1025,
1065,
2065,
1006,
999,
1013,
1034,
1032,
1012,
1029,
1031,
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... | |
transloadit/uppy | website/build-examples.js | bundle | function bundle (ids = []) {
ids.forEach((id) => {
if (!muted.has(id)) {
console.info(chalk.cyan('change:'), path.relative(process.cwd(), id))
muted.add(id)
}
})
const exampleName = path.basename(path.dirname(file))
const output = dstPattern.replace('**', exampleName)
const parentDir = path.dirname(output)
mkdirp.sync(parentDir)
console.info(chalk.grey(`⏳ building: ${path.relative(process.cwd(), file)}`))
b
.bundle()
.on('error', onError)
.pipe(createStream(output))
.on('finish', () => {
console.info(chalk.green(`✓ built: ${path.relative(process.cwd(), file)}`))
})
} | javascript | function bundle (ids = []) {
ids.forEach((id) => {
if (!muted.has(id)) {
console.info(chalk.cyan('change:'), path.relative(process.cwd(), id))
muted.add(id)
}
})
const exampleName = path.basename(path.dirname(file))
const output = dstPattern.replace('**', exampleName)
const parentDir = path.dirname(output)
mkdirp.sync(parentDir)
console.info(chalk.grey(`⏳ building: ${path.relative(process.cwd(), file)}`))
b
.bundle()
.on('error', onError)
.pipe(createStream(output))
.on('finish', () => {
console.info(chalk.green(`✓ built: ${path.relative(process.cwd(), file)}`))
})
} | [
"function",
"bundle",
"(",
"ids",
"=",
"[",
"]",
")",
"{",
"ids",
".",
"forEach",
"(",
"(",
"id",
")",
"=>",
"{",
"if",
"(",
"!",
"muted",
".",
"has",
"(",
"id",
")",
")",
"{",
"console",
".",
"info",
"(",
"chalk",
".",
"cyan",
"(",
"'change:... | Creates bundle and writes it to static and public folders.
Changes to
@param {[type]} ids [description]
@return {[type]} [description] | [
"Creates",
"bundle",
"and",
"writes",
"it",
"to",
"static",
"and",
"public",
"folders",
".",
"Changes",
"to"
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/website/build-examples.js#L115-L138 | train | Bundle a file | [
30522,
3853,
14012,
1006,
8909,
2015,
1027,
1031,
1033,
1007,
1063,
8909,
2015,
1012,
18921,
6776,
1006,
1006,
8909,
1007,
1027,
1028,
1063,
2065,
1006,
999,
22124,
1012,
2038,
1006,
8909,
1007,
1007,
1063,
10122,
1012,
18558,
1006,
16833,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | socketOnClose | function socketOnClose() {
const websocket = this[kWebSocket];
this.removeListener('close', socketOnClose);
this.removeListener('end', socketOnEnd);
websocket.readyState = WebSocket.CLOSING;
//
// The close frame might not have been received or the `'end'` event emitted,
// for example, if the socket was destroyed due to an error. Ensure that the
// `receiver` stream is closed after writing any remaining buffered data to
// it. If the readable side of the socket is in flowing mode then there is no
// buffered data as everything has been already written and `readable.read()`
// will return `null`. If instead, the socket is paused, any possible buffered
// data will be read as a single chunk and emitted synchronously in a single
// `'data'` event.
//
websocket._socket.read();
websocket._receiver.end();
this.removeListener('data', socketOnData);
this[kWebSocket] = undefined;
clearTimeout(websocket._closeTimer);
if (
websocket._receiver._writableState.finished ||
websocket._receiver._writableState.errorEmitted
) {
websocket.emitClose();
} else {
websocket._receiver.on('error', receiverOnFinish);
websocket._receiver.on('finish', receiverOnFinish);
}
} | javascript | function socketOnClose() {
const websocket = this[kWebSocket];
this.removeListener('close', socketOnClose);
this.removeListener('end', socketOnEnd);
websocket.readyState = WebSocket.CLOSING;
//
// The close frame might not have been received or the `'end'` event emitted,
// for example, if the socket was destroyed due to an error. Ensure that the
// `receiver` stream is closed after writing any remaining buffered data to
// it. If the readable side of the socket is in flowing mode then there is no
// buffered data as everything has been already written and `readable.read()`
// will return `null`. If instead, the socket is paused, any possible buffered
// data will be read as a single chunk and emitted synchronously in a single
// `'data'` event.
//
websocket._socket.read();
websocket._receiver.end();
this.removeListener('data', socketOnData);
this[kWebSocket] = undefined;
clearTimeout(websocket._closeTimer);
if (
websocket._receiver._writableState.finished ||
websocket._receiver._writableState.errorEmitted
) {
websocket.emitClose();
} else {
websocket._receiver.on('error', receiverOnFinish);
websocket._receiver.on('finish', receiverOnFinish);
}
} | [
"function",
"socketOnClose",
"(",
")",
"{",
"const",
"websocket",
"=",
"this",
"[",
"kWebSocket",
"]",
";",
"this",
".",
"removeListener",
"(",
"'close'",
",",
"socketOnClose",
")",
";",
"this",
".",
"removeListener",
"(",
"'end'",
",",
"socketOnEnd",
")",
... | The listener of the `net.Socket` `'close'` event.
@private | [
"The",
"listener",
"of",
"the",
"net",
".",
"Socket",
"close",
"event",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket.js#L827-L862 | train | The close event is fired when the socket closes. | [
30522,
3853,
22278,
2239,
20464,
9232,
1006,
1007,
1063,
9530,
3367,
4773,
6499,
19869,
2102,
1027,
2023,
1031,
6448,
15878,
6499,
19869,
2102,
1033,
1025,
2023,
1012,
6366,
9863,
24454,
1006,
1005,
2485,
1005,
1010,
22278,
2239,
20464,
923... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(evt)
{
// Special case for mousemove and mousedown we check the buttons
// if it exists because which is 0 even if no button is pressed
if ('buttons' in evt && (evt.type == 'mousedown' || evt.type == 'mousemove'))
{
return evt.buttons == 1;
}
else if ('which' in evt)
{
return evt.which === 1;
}
else
{
return evt.button === 1;
}
} | javascript | function(evt)
{
// Special case for mousemove and mousedown we check the buttons
// if it exists because which is 0 even if no button is pressed
if ('buttons' in evt && (evt.type == 'mousedown' || evt.type == 'mousemove'))
{
return evt.buttons == 1;
}
else if ('which' in evt)
{
return evt.which === 1;
}
else
{
return evt.button === 1;
}
} | [
"function",
"(",
"evt",
")",
"{",
"// Special case for mousemove and mousedown we check the buttons",
"// if it exists because which is 0 even if no button is pressed",
"if",
"(",
"'buttons'",
"in",
"evt",
"&&",
"(",
"evt",
".",
"type",
"==",
"'mousedown'",
"||",
"evt",
"."... | Function: isLeftMouseButton
Returns true if the left mouse button is pressed for the given event.
To check if a button is pressed during a mouseMove you should use the
<mxGraph.isMouseDown> property. Note that this returns true in Firefox
for control+left-click on the Mac. | [
"Function",
":",
"isLeftMouseButton"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L9872-L9888 | train | Check if the event is a mousemove or mousedown | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
1013,
1013,
2569,
2553,
2005,
8000,
5302,
3726,
1998,
8000,
7698,
2057,
4638,
1996,
11287,
1013,
1013,
2065,
2009,
6526,
2138,
2029,
2003,
1014,
2130,
2065,
2053,
6462,
2003,
4508,
2065,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/Agents/RemoteAgent.js | _onFrameNavigated | function _onFrameNavigated(event, res) {
// res = {frame}
// Re-inject RemoteFunctions when navigating to a new page, but not if an iframe was loaded
if (res.frame.parentId) {
return;
}
_stopKeepAliveInterval();
// inject RemoteFunctions
var command = "window._LD=" + RemoteFunctions + "(" + JSON.stringify(LiveDevelopment.config) + "," + PreferencesManager.get("livedev.wsPort") + ");";
Inspector.Runtime.evaluate(command, function onEvaluate(response) {
if (response.error || response.wasThrown) {
_load.reject(response.error);
} else {
_objectId = response.result.objectId;
_load.resolve();
_startKeepAliveInterval();
}
});
} | javascript | function _onFrameNavigated(event, res) {
// res = {frame}
// Re-inject RemoteFunctions when navigating to a new page, but not if an iframe was loaded
if (res.frame.parentId) {
return;
}
_stopKeepAliveInterval();
// inject RemoteFunctions
var command = "window._LD=" + RemoteFunctions + "(" + JSON.stringify(LiveDevelopment.config) + "," + PreferencesManager.get("livedev.wsPort") + ");";
Inspector.Runtime.evaluate(command, function onEvaluate(response) {
if (response.error || response.wasThrown) {
_load.reject(response.error);
} else {
_objectId = response.result.objectId;
_load.resolve();
_startKeepAliveInterval();
}
});
} | [
"function",
"_onFrameNavigated",
"(",
"event",
",",
"res",
")",
"{",
"// res = {frame}",
"// Re-inject RemoteFunctions when navigating to a new page, but not if an iframe was loaded",
"if",
"(",
"res",
".",
"frame",
".",
"parentId",
")",
"{",
"return",
";",
"}",
"_stopKee... | WebInspector Event: Page.frameNavigated | [
"WebInspector",
"Event",
":",
"Page",
".",
"frameNavigated"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteAgent.js#L124-L146 | train | Called when a frame is navigated to a new page | [
30522,
3853,
1035,
2006,
15643,
2532,
5737,
11644,
1006,
2724,
1010,
24501,
1007,
1063,
1013,
1013,
24501,
1027,
1063,
4853,
1065,
1013,
1013,
2128,
1011,
1999,
20614,
6556,
11263,
27989,
2015,
2043,
6583,
5737,
16961,
2000,
1037,
2047,
393... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/select.js | pushNode | function pushNode(result, nodes) {
'use strict';
var temp;
if (result.length === 0) {
return nodes;
}
if (result.length < nodes.length) {
// switch so the comparison is shortest
temp = result;
result = nodes;
nodes = temp;
}
for (var i = 0, l = nodes.length; i < l; i++) {
if (!result.includes(nodes[i])) {
result.push(nodes[i]);
}
}
return result;
} | javascript | function pushNode(result, nodes) {
'use strict';
var temp;
if (result.length === 0) {
return nodes;
}
if (result.length < nodes.length) {
// switch so the comparison is shortest
temp = result;
result = nodes;
nodes = temp;
}
for (var i = 0, l = nodes.length; i < l; i++) {
if (!result.includes(nodes[i])) {
result.push(nodes[i]);
}
}
return result;
} | [
"function",
"pushNode",
"(",
"result",
",",
"nodes",
")",
"{",
"'use strict'",
";",
"var",
"temp",
";",
"if",
"(",
"result",
".",
"length",
"===",
"0",
")",
"{",
"return",
"nodes",
";",
"}",
"if",
"(",
"result",
".",
"length",
"<",
"nodes",
".",
"l... | Pushes unique nodes that are in context to an array
@private
@param {Array} result The array to push to
@param {Array} nodes The list of nodes to push
@param {Object} context The "resolved" context object, @see resolveContext | [
"Pushes",
"unique",
"nodes",
"that",
"are",
"in",
"context",
"to",
"an",
"array"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/select.js#L58-L78 | train | push nodes to result | [
30522,
3853,
5245,
3630,
3207,
1006,
2765,
1010,
14164,
1007,
1063,
1005,
2224,
9384,
1005,
1025,
13075,
8915,
8737,
1025,
2065,
1006,
2765,
1012,
3091,
1027,
1027,
1027,
1014,
1007,
1063,
2709,
14164,
1025,
1065,
2065,
1006,
2765,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ErrorHandler.js | function (sDetails) {
MessageBox.error(
this._sErrorText,
{
id : "metadataErrorMessageBox",
details : sDetails,
styleClass : this._oComponent.getContentDensityClass(),
actions : [MessageBox.Action.RETRY, MessageBox.Action.CLOSE],
onClose : function (sAction) {
if (sAction === MessageBox.Action.RETRY) {
this._oModel.refreshMetadata();
}
}.bind(this)
}
);
} | javascript | function (sDetails) {
MessageBox.error(
this._sErrorText,
{
id : "metadataErrorMessageBox",
details : sDetails,
styleClass : this._oComponent.getContentDensityClass(),
actions : [MessageBox.Action.RETRY, MessageBox.Action.CLOSE],
onClose : function (sAction) {
if (sAction === MessageBox.Action.RETRY) {
this._oModel.refreshMetadata();
}
}.bind(this)
}
);
} | [
"function",
"(",
"sDetails",
")",
"{",
"MessageBox",
".",
"error",
"(",
"this",
".",
"_sErrorText",
",",
"{",
"id",
":",
"\"metadataErrorMessageBox\"",
",",
"details",
":",
"sDetails",
",",
"styleClass",
":",
"this",
".",
"_oComponent",
".",
"getContentDensity... | Shows a {@link sap.m.MessageBox} when the metadata call has failed.
The user can try to refresh the metadata.
@param {string} sDetails a technical error to be displayed on request
@private | [
"Shows",
"a",
"{"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ErrorHandler.js#L33-L48 | train | Show error message box | [
30522,
3853,
1006,
17371,
12928,
12146,
1007,
1063,
4471,
8758,
1012,
7561,
1006,
2023,
1012,
1035,
14262,
29165,
18209,
1010,
1063,
8909,
1024,
1000,
27425,
2121,
29165,
7834,
3736,
3351,
8758,
1000,
1010,
4751,
1024,
17371,
12928,
12146,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
askmike/gekko | core/prepareDateRange.js | function(from, to) {
config.backtest.daterange = {
from: moment.unix(from).utc().format(),
to: moment.unix(to).utc().format(),
};
util.setConfig(config);
} | javascript | function(from, to) {
config.backtest.daterange = {
from: moment.unix(from).utc().format(),
to: moment.unix(to).utc().format(),
};
util.setConfig(config);
} | [
"function",
"(",
"from",
",",
"to",
")",
"{",
"config",
".",
"backtest",
".",
"daterange",
"=",
"{",
"from",
":",
"moment",
".",
"unix",
"(",
"from",
")",
".",
"utc",
"(",
")",
".",
"format",
"(",
")",
",",
"to",
":",
"moment",
".",
"unix",
"("... | helper to store the evenutally detected daterange. | [
"helper",
"to",
"store",
"the",
"evenutally",
"detected",
"daterange",
"."
] | 0ce9ddd577fa8a22812c02331a494086758dfadf | https://github.com/askmike/gekko/blob/0ce9ddd577fa8a22812c02331a494086758dfadf/core/prepareDateRange.js#L14-L20 | train | Set the daterange of the cluster | [
30522,
3853,
1006,
2013,
1010,
2000,
1007,
1063,
9530,
8873,
2290,
1012,
2067,
22199,
1012,
3058,
24388,
2063,
1027,
1063,
2013,
1024,
2617,
1012,
19998,
1006,
2013,
1007,
1012,
11396,
1006,
1007,
1012,
4289,
1006,
1007,
1010,
2000,
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... | |
jgraph/mxgraph | javascript/mxClient.js | mxActor | function mxActor(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | javascript | function mxActor(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | [
"function",
"mxActor",
"(",
"bounds",
",",
"fill",
",",
"stroke",
",",
"strokewidth",
")",
"{",
"mxShape",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"bounds",
"=",
"bounds",
";",
"this",
".",
"fill",
"=",
"fill",
";",
"this",
".",
"stroke",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxActor
Extends <mxShape> to implement an actor shape. If a custom shape with one
filled area is needed, then this shape's <redrawPath> should be overridden.
Example:
(code)
function SampleShape() { }
SampleShape.prototype = new mxActor();
SampleShape.prototype.constructor = vsAseShape;
mxCellRenderer.registerShape('sample', SampleShape);
SampleShape.prototype.redrawPath = function(path, x, y, w, h)
{
path.moveTo(0, 0);
path.lineTo(w, h);
// ...
path.close();
}
(end)
This shape is registered under <mxConstants.SHAPE_ACTOR> in
<mxCellRenderer>.
Constructor: mxActor
Constructs a new actor shape.
Parameters:
bounds - <mxRectangle> that defines the bounds. This is stored in
<mxShape.bounds>.
fill - String that defines the fill color. This is stored in <fill>.
stroke - String that defines the stroke color. This is stored in <stroke>.
strokewidth - Optional integer that defines the stroke width. Default is
1. This is stored in <strokewidth>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxActor"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L24856-L24863 | train | A mxActor is a base class for all actors | [
30522,
3853,
25630,
18908,
2953,
1006,
19202,
1010,
6039,
1010,
6909,
1010,
6909,
9148,
11927,
2232,
1007,
1063,
25630,
7377,
5051,
1012,
2655,
1006,
2023,
1007,
1025,
2023,
1012,
19202,
1027,
19202,
1025,
2023,
1012,
6039,
1027,
6039,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js | function(oTable) {
return {
columnCount: oTable.getColumns().length,
visibleColumnCount: TableColumnUtils.TableUtils.getVisibleColumnCount(oTable),
columnMap: TableColumnUtils.getColumnMap(oTable)
};
} | javascript | function(oTable) {
return {
columnCount: oTable.getColumns().length,
visibleColumnCount: TableColumnUtils.TableUtils.getVisibleColumnCount(oTable),
columnMap: TableColumnUtils.getColumnMap(oTable)
};
} | [
"function",
"(",
"oTable",
")",
"{",
"return",
"{",
"columnCount",
":",
"oTable",
".",
"getColumns",
"(",
")",
".",
"length",
",",
"visibleColumnCount",
":",
"TableColumnUtils",
".",
"TableUtils",
".",
"getVisibleColumnCount",
"(",
"oTable",
")",
",",
"columnM... | Collects and returns column info.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {ColumnInfo} Map of detailed column information.
@private | [
"Collects",
"and",
"returns",
"column",
"info",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableColumnUtils.js#L74-L80 | train | Returns an object with the properties of the table | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
2709,
1063,
5930,
3597,
16671,
1024,
27178,
3085,
1012,
2131,
25778,
2819,
3619,
1006,
1007,
1012,
3091,
1010,
5710,
25778,
2819,
15305,
16671,
1024,
2795,
25778,
2819,
24072,
12146,
1012,
2795,
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... | |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | cleanNum | function cleanNum(val) {
return -128 < val && val < 128 && Math.floor(val) !== val ? -(val * 1024 | 0) : val;
} | javascript | function cleanNum(val) {
return -128 < val && val < 128 && Math.floor(val) !== val ? -(val * 1024 | 0) : val;
} | [
"function",
"cleanNum",
"(",
"val",
")",
"{",
"return",
"-",
"128",
"<",
"val",
"&&",
"val",
"<",
"128",
"&&",
"Math",
".",
"floor",
"(",
"val",
")",
"!==",
"val",
"?",
"-",
"(",
"val",
"*",
"1024",
"|",
"0",
")",
":",
"val",
";",
"}"
] | - hashing works on 32 bit ints b/c we use bitwise ops - small numbers get cut off (e.g. 0.123 is seen as 0 by the hashing function) - raise up small numbers so more significant digits are seen by hashing - make small numbers negative to avoid collisions -- most style values are positive numbers - works in practice and it's relatively cheap | [
"-",
"hashing",
"works",
"on",
"32",
"bit",
"ints",
"b",
"/",
"c",
"we",
"use",
"bitwise",
"ops",
"-",
"small",
"numbers",
"get",
"cut",
"off",
"(",
"e",
".",
"g",
".",
"0",
".",
"123",
"is",
"seen",
"as",
"0",
"by",
"the",
"hashing",
"function",... | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L14042-L14044 | train | clean a number | [
30522,
3853,
4550,
19172,
1006,
11748,
1007,
1063,
2709,
1011,
30524,
1024,
11748,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/languageTools/ClientLoader.js | sendLanguageClientInfo | function sendLanguageClientInfo() {
//Init node with Information required by Language Client
clientInfoLoadedPromise = clientInfoDomain.exec("initialize", _bracketsPath, ToolingInfo);
function logInitializationError() {
console.error("Failed to Initialize LanguageClient Module Information.");
}
//Attach success and failure function for the clientInfoLoadedPromise
clientInfoLoadedPromise.then(function (success) {
if (!success) {
logInitializationError();
return;
}
if (Array.isArray(pendingClientsToBeLoaded)) {
pendingClientsToBeLoaded.forEach(function (pendingClient) {
pendingClient.load();
});
} else {
exports.trigger("languageClientModuleInitialized");
}
pendingClientsToBeLoaded = null;
}, function () {
logInitializationError();
});
} | javascript | function sendLanguageClientInfo() {
//Init node with Information required by Language Client
clientInfoLoadedPromise = clientInfoDomain.exec("initialize", _bracketsPath, ToolingInfo);
function logInitializationError() {
console.error("Failed to Initialize LanguageClient Module Information.");
}
//Attach success and failure function for the clientInfoLoadedPromise
clientInfoLoadedPromise.then(function (success) {
if (!success) {
logInitializationError();
return;
}
if (Array.isArray(pendingClientsToBeLoaded)) {
pendingClientsToBeLoaded.forEach(function (pendingClient) {
pendingClient.load();
});
} else {
exports.trigger("languageClientModuleInitialized");
}
pendingClientsToBeLoaded = null;
}, function () {
logInitializationError();
});
} | [
"function",
"sendLanguageClientInfo",
"(",
")",
"{",
"//Init node with Information required by Language Client",
"clientInfoLoadedPromise",
"=",
"clientInfoDomain",
".",
"exec",
"(",
"\"initialize\"",
",",
"_bracketsPath",
",",
"ToolingInfo",
")",
";",
"function",
"logInitial... | This function passes Brackets's native directory path as well as the tooling commands
required by the LanguageClient node module. This information is then maintained in memory
in the node process server for succesfully loading and functioning of all language clients
since it is a direct dependency. | [
"This",
"function",
"passes",
"Brackets",
"s",
"native",
"directory",
"path",
"as",
"well",
"as",
"the",
"tooling",
"commands",
"required",
"by",
"the",
"LanguageClient",
"node",
"module",
".",
"This",
"information",
"is",
"then",
"maintained",
"in",
"memory",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/languageTools/ClientLoader.js#L124-L150 | train | Send LanguageClient Module Information | [
30522,
3853,
4604,
25023,
6692,
3351,
20464,
11638,
2378,
14876,
1006,
1007,
1063,
1013,
1013,
1999,
4183,
13045,
2007,
2592,
3223,
2011,
2653,
7396,
7396,
2378,
14876,
17468,
21572,
28732,
1027,
7396,
2378,
14876,
9527,
8113,
1012,
4654,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/draco | javascript/example/DRACOLoader.js | function(rawBuffer, callback, attributeUniqueIdMap,
attributeTypeMap) {
var scope = this;
THREE.DRACOLoader.getDecoderModule()
.then( function ( module ) {
scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback,
attributeUniqueIdMap || {}, attributeTypeMap || {});
});
} | javascript | function(rawBuffer, callback, attributeUniqueIdMap,
attributeTypeMap) {
var scope = this;
THREE.DRACOLoader.getDecoderModule()
.then( function ( module ) {
scope.decodeDracoFileInternal( rawBuffer, module.decoder, callback,
attributeUniqueIdMap || {}, attributeTypeMap || {});
});
} | [
"function",
"(",
"rawBuffer",
",",
"callback",
",",
"attributeUniqueIdMap",
",",
"attributeTypeMap",
")",
"{",
"var",
"scope",
"=",
"this",
";",
"THREE",
".",
"DRACOLoader",
".",
"getDecoderModule",
"(",
")",
".",
"then",
"(",
"function",
"(",
"module",
")",... | |attributeUniqueIdMap| specifies attribute unique id for an attribute in
the geometry to be decoded. The name of the attribute must be one of the
supported attribute type in Three.JS, including:
'position',
'color',
'normal',
'uv',
'uv2',
'skinIndex',
'skinWeight'.
The format is:
attributeUniqueIdMap[attributeName] = attributeId | [
"|attributeUniqueIdMap|",
"specifies",
"attribute",
"unique",
"id",
"for",
"an",
"attribute",
"in",
"the",
"geometry",
"to",
"be",
"decoded",
".",
"The",
"name",
"of",
"the",
"attribute",
"must",
"be",
"one",
"of",
"the",
"supported",
"attribute",
"type",
"in"... | 785c9c4aa2b952236c29ad639901dbbaf216da38 | https://github.com/google/draco/blob/785c9c4aa2b952236c29ad639901dbbaf216da38/javascript/example/DRACOLoader.js#L103-L111 | train | Decode a DRACO file | [
30522,
3853,
1006,
6315,
8569,
12494,
1010,
2655,
5963,
1010,
17961,
19496,
4226,
3593,
2863,
2361,
1010,
17961,
13874,
2863,
2361,
1007,
1063,
13075,
9531,
1027,
2023,
1025,
2093,
1012,
2852,
22684,
11066,
2121,
1012,
2131,
3207,
16044,
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... | |
electron/electron | lib/browser/rpc-server.js | function (sender, contextId, value, optimizeSimpleObject = false) {
// Determine the type of value.
const meta = { type: typeof value }
if (meta.type === 'object') {
// Recognize certain types of objects.
if (value === null) {
meta.type = 'value'
} else if (bufferUtils.isBuffer(value)) {
meta.type = 'buffer'
} else if (Array.isArray(value)) {
meta.type = 'array'
} else if (value instanceof Error) {
meta.type = 'error'
} else if (value instanceof Date) {
meta.type = 'date'
} else if (isPromise(value)) {
meta.type = 'promise'
} else if (hasProp.call(value, 'callee') && value.length != null) {
// Treat the arguments object as array.
meta.type = 'array'
} else if (optimizeSimpleObject && v8Util.getHiddenValue(value, 'simple')) {
// Treat simple objects as value.
meta.type = 'value'
}
}
// Fill the meta object according to value's type.
if (meta.type === 'array') {
meta.members = value.map((el) => valueToMeta(sender, contextId, el, optimizeSimpleObject))
} else if (meta.type === 'object' || meta.type === 'function') {
meta.name = value.constructor ? value.constructor.name : ''
// Reference the original value if it's an object, because when it's
// passed to renderer we would assume the renderer keeps a reference of
// it.
meta.id = objectsRegistry.add(sender, contextId, value)
meta.members = getObjectMembers(value)
meta.proto = getObjectPrototype(value)
} else if (meta.type === 'buffer') {
meta.value = bufferUtils.bufferToMeta(value)
} else if (meta.type === 'promise') {
// Add default handler to prevent unhandled rejections in main process
// Instead they should appear in the renderer process
value.then(function () {}, function () {})
meta.then = valueToMeta(sender, contextId, function (onFulfilled, onRejected) {
value.then(onFulfilled, onRejected)
})
} else if (meta.type === 'error') {
meta.members = plainObjectToMeta(value)
// Error.name is not part of own properties.
meta.members.push({
name: 'name',
value: value.name
})
} else if (meta.type === 'date') {
meta.value = value.getTime()
} else {
meta.type = 'value'
meta.value = value
}
return meta
} | javascript | function (sender, contextId, value, optimizeSimpleObject = false) {
// Determine the type of value.
const meta = { type: typeof value }
if (meta.type === 'object') {
// Recognize certain types of objects.
if (value === null) {
meta.type = 'value'
} else if (bufferUtils.isBuffer(value)) {
meta.type = 'buffer'
} else if (Array.isArray(value)) {
meta.type = 'array'
} else if (value instanceof Error) {
meta.type = 'error'
} else if (value instanceof Date) {
meta.type = 'date'
} else if (isPromise(value)) {
meta.type = 'promise'
} else if (hasProp.call(value, 'callee') && value.length != null) {
// Treat the arguments object as array.
meta.type = 'array'
} else if (optimizeSimpleObject && v8Util.getHiddenValue(value, 'simple')) {
// Treat simple objects as value.
meta.type = 'value'
}
}
// Fill the meta object according to value's type.
if (meta.type === 'array') {
meta.members = value.map((el) => valueToMeta(sender, contextId, el, optimizeSimpleObject))
} else if (meta.type === 'object' || meta.type === 'function') {
meta.name = value.constructor ? value.constructor.name : ''
// Reference the original value if it's an object, because when it's
// passed to renderer we would assume the renderer keeps a reference of
// it.
meta.id = objectsRegistry.add(sender, contextId, value)
meta.members = getObjectMembers(value)
meta.proto = getObjectPrototype(value)
} else if (meta.type === 'buffer') {
meta.value = bufferUtils.bufferToMeta(value)
} else if (meta.type === 'promise') {
// Add default handler to prevent unhandled rejections in main process
// Instead they should appear in the renderer process
value.then(function () {}, function () {})
meta.then = valueToMeta(sender, contextId, function (onFulfilled, onRejected) {
value.then(onFulfilled, onRejected)
})
} else if (meta.type === 'error') {
meta.members = plainObjectToMeta(value)
// Error.name is not part of own properties.
meta.members.push({
name: 'name',
value: value.name
})
} else if (meta.type === 'date') {
meta.value = value.getTime()
} else {
meta.type = 'value'
meta.value = value
}
return meta
} | [
"function",
"(",
"sender",
",",
"contextId",
",",
"value",
",",
"optimizeSimpleObject",
"=",
"false",
")",
"{",
"// Determine the type of value.",
"const",
"meta",
"=",
"{",
"type",
":",
"typeof",
"value",
"}",
"if",
"(",
"meta",
".",
"type",
"===",
"'object... | Convert a real value into meta data. | [
"Convert",
"a",
"real",
"value",
"into",
"meta",
"data",
"."
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/browser/rpc-server.js#L71-L134 | train | Converts value to meta object | [
30522,
3853,
1006,
4604,
2121,
1010,
6123,
3593,
1010,
3643,
1010,
23569,
27605,
11254,
5714,
10814,
16429,
20614,
1027,
6270,
1007,
1063,
1013,
1013,
5646,
1996,
2828,
1997,
3643,
1012,
9530,
3367,
18804,
1027,
1063,
2828,
1024,
2828,
1125... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | unique | function unique(array) {
const results = [];
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!contains(results, array[idx])) {
results.push(array[idx]);
}
}
return results;
} | javascript | function unique(array) {
const results = [];
for (let idx = 0, len = array.length; idx < len; idx++) {
if (!contains(results, array[idx])) {
results.push(array[idx]);
}
}
return results;
} | [
"function",
"unique",
"(",
"array",
")",
"{",
"const",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"idx",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"idx",
"<",
"len",
";",
"idx",
"++",
")",
"{",
"if",
"(",
"!",
"contains",
... | produces a duplicate-free version of the array
@param {Array} array | [
"produces",
"a",
"duplicate",
"-",
"free",
"version",
"of",
"the",
"array"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/lists.js#L147-L157 | train | Returns an array of unique elements | [
30522,
3853,
4310,
1006,
9140,
1007,
1063,
9530,
3367,
3463,
1027,
1031,
1033,
1025,
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,
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... |
ReactiveX/rxjs | docs_app/src/app/search/search-worker.js | makeRequest | function makeRequest(url, callback) {
// The JSON file that is loaded should be an array of PageInfo:
var searchDataRequest = new XMLHttpRequest();
searchDataRequest.onload = function() {
callback(JSON.parse(this.responseText));
};
searchDataRequest.open('GET', url);
searchDataRequest.send();
} | javascript | function makeRequest(url, callback) {
// The JSON file that is loaded should be an array of PageInfo:
var searchDataRequest = new XMLHttpRequest();
searchDataRequest.onload = function() {
callback(JSON.parse(this.responseText));
};
searchDataRequest.open('GET', url);
searchDataRequest.send();
} | [
"function",
"makeRequest",
"(",
"url",
",",
"callback",
")",
"{",
"// The JSON file that is loaded should be an array of PageInfo:",
"var",
"searchDataRequest",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"searchDataRequest",
".",
"onload",
"=",
"function",
"(",
")",
... | Use XHR to make a request to the server | [
"Use",
"XHR",
"to",
"make",
"a",
"request",
"to",
"the",
"server"
] | 1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f | https://github.com/ReactiveX/rxjs/blob/1037a1d1e6b80c7218e7ffdf8c0d96a612653a4f/docs_app/src/app/search/search-worker.js#L62-L71 | train | Make a request to the specified URL | [
30522,
3853,
9338,
2063,
15500,
1006,
24471,
2140,
1010,
2655,
5963,
1007,
1063,
1013,
1013,
1996,
1046,
3385,
5371,
2008,
2003,
8209,
2323,
2022,
2019,
9140,
1997,
3931,
2378,
14876,
1024,
13075,
3945,
2850,
7559,
2063,
15500,
1027,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/config.js | extractCredentials | function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
} | javascript | function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
} | [
"function",
"extractCredentials",
"(",
"options",
")",
"{",
"if",
"(",
"options",
".",
"accessKeyId",
"&&",
"options",
".",
"secretAccessKey",
")",
"{",
"options",
"=",
"AWS",
".",
"util",
".",
"copy",
"(",
"options",
")",
";",
"options",
".",
"credentials... | Extracts accessKeyId, secretAccessKey and sessionToken
from a configuration hash.
@api private | [
"Extracts",
"accessKeyId",
"secretAccessKey",
"and",
"sessionToken",
"from",
"a",
"configuration",
"hash",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L536-L542 | train | Extract credentials from options | [
30522,
3853,
14817,
16748,
16454,
26340,
1006,
7047,
1007,
1063,
2065,
1006,
7047,
1012,
3229,
14839,
3593,
1004,
1004,
7047,
1012,
3595,
6305,
9623,
17140,
2100,
1007,
1063,
7047,
1027,
22091,
2015,
1012,
21183,
4014,
1012,
6100,
1006,
704... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/WrapSelection.js | _wrapSelectedStatements | function _wrapSelectedStatements (wrapperName, err) {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
initializeRefactoringSession(editor);
var startIndex = current.startIndex,
endIndex = current.endIndex,
selectedText = current.selectedText,
pos;
if (selectedText.length === 0) {
var statementNode = RefactoringUtils.findSurroundASTNode(current.ast, {start: startIndex}, ["Statement"]);
if (!statementNode) {
current.editor.displayErrorMessageAtCursor(err);
return;
}
selectedText = current.text.substr(statementNode.start, statementNode.end - statementNode.start);
startIndex = statementNode.start;
endIndex = statementNode.end;
} else {
var selectionDetails = RefactoringUtils.normalizeText(selectedText, startIndex, endIndex);
selectedText = selectionDetails.text;
startIndex = selectionDetails.start;
endIndex = selectionDetails.end;
}
if (!RefactoringUtils.checkStatement(current.ast, startIndex, endIndex, selectedText)) {
current.editor.displayErrorMessageAtCursor(err);
return;
}
pos = {
"start": current.cm.posFromIndex(startIndex),
"end": current.cm.posFromIndex(endIndex)
};
current.document.batchOperation(function() {
current.replaceTextFromTemplate(wrapperName, {body: selectedText}, pos);
});
if (wrapperName === TRY_CATCH) {
var cursorLine = current.editor.getSelection().end.line - 1,
startCursorCh = current.document.getLine(cursorLine).indexOf("\/\/"),
endCursorCh = current.document.getLine(cursorLine).length;
current.editor.setSelection({"line": cursorLine, "ch": startCursorCh}, {"line": cursorLine, "ch": endCursorCh});
} else if (wrapperName === WRAP_IN_CONDITION) {
current.editor.setSelection({"line": pos.start.line, "ch": pos.start.ch + 4}, {"line": pos.start.line, "ch": pos.start.ch + 13});
}
} | javascript | function _wrapSelectedStatements (wrapperName, err) {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
initializeRefactoringSession(editor);
var startIndex = current.startIndex,
endIndex = current.endIndex,
selectedText = current.selectedText,
pos;
if (selectedText.length === 0) {
var statementNode = RefactoringUtils.findSurroundASTNode(current.ast, {start: startIndex}, ["Statement"]);
if (!statementNode) {
current.editor.displayErrorMessageAtCursor(err);
return;
}
selectedText = current.text.substr(statementNode.start, statementNode.end - statementNode.start);
startIndex = statementNode.start;
endIndex = statementNode.end;
} else {
var selectionDetails = RefactoringUtils.normalizeText(selectedText, startIndex, endIndex);
selectedText = selectionDetails.text;
startIndex = selectionDetails.start;
endIndex = selectionDetails.end;
}
if (!RefactoringUtils.checkStatement(current.ast, startIndex, endIndex, selectedText)) {
current.editor.displayErrorMessageAtCursor(err);
return;
}
pos = {
"start": current.cm.posFromIndex(startIndex),
"end": current.cm.posFromIndex(endIndex)
};
current.document.batchOperation(function() {
current.replaceTextFromTemplate(wrapperName, {body: selectedText}, pos);
});
if (wrapperName === TRY_CATCH) {
var cursorLine = current.editor.getSelection().end.line - 1,
startCursorCh = current.document.getLine(cursorLine).indexOf("\/\/"),
endCursorCh = current.document.getLine(cursorLine).length;
current.editor.setSelection({"line": cursorLine, "ch": startCursorCh}, {"line": cursorLine, "ch": endCursorCh});
} else if (wrapperName === WRAP_IN_CONDITION) {
current.editor.setSelection({"line": pos.start.line, "ch": pos.start.ch + 4}, {"line": pos.start.line, "ch": pos.start.ch + 13});
}
} | [
"function",
"_wrapSelectedStatements",
"(",
"wrapperName",
",",
"err",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"initializeRefactoringSession",
"(",
"editor"... | Wrap selected statements
@param {string} wrapperName - template name where we want wrap selected statements
@param {string} err- error message if we can't wrap selected code | [
"Wrap",
"selected",
"statements"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/WrapSelection.js#L57-L108 | train | Wrap selected statements | [
30522,
3853,
1035,
19735,
12260,
10985,
9153,
18532,
11187,
1006,
10236,
4842,
18442,
1010,
9413,
2099,
1007,
1063,
13075,
3559,
1027,
3559,
24805,
4590,
1012,
2131,
19620,
2098,
15660,
1006,
1007,
1025,
2065,
1006,
999,
3559,
1007,
1063,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | function (aElements, fnCallback) {
try {
return SyncPromise.resolve(stopAndGo(aElements, fnCallback));
} catch (e) {
return SyncPromise.reject(e);
}
} | javascript | function (aElements, fnCallback) {
try {
return SyncPromise.resolve(stopAndGo(aElements, fnCallback));
} catch (e) {
return SyncPromise.reject(e);
}
} | [
"function",
"(",
"aElements",
",",
"fnCallback",
")",
"{",
"try",
"{",
"return",
"SyncPromise",
".",
"resolve",
"(",
"stopAndGo",
"(",
"aElements",
",",
"fnCallback",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"SyncPromise",
".",
"reject"... | Visits the given elements one-by-one, calls the given callback for each of
them and stops and waits for each thenable returned by the callback before
going on to the next element. If a thenable resolves with a truthy value,
iteration stops and the corresponding element becomes the result of the
returned thenable.
<b>Note:</b> If the visitor function is used for synchronous XML Templating,
the callback must return a sync promise; in other cases, any thenable is OK.
@param {any[]} aElements
Whatever elements we want to visit
@param {function} fnCallback
A function to be called with a single element and its index and the array
(like {@link Array#find} does it), returning a thenable, preferrably a
{@link sap.ui.base.SyncPromise}
@returns {sap.ui.base.SyncPromise}
A sync promise which resolves with the first element where the callback's
thenable resolved with a truthy value, or resolves with
<code>undefined</code> as soon as the last callback's thenable has
resolved, or is rejected with a corresponding error if any callback returns
a rejected thenable or throws an error | [
"Visits",
"the",
"given",
"elements",
"one",
"-",
"by",
"-",
"one",
"calls",
"the",
"given",
"callback",
"for",
"each",
"of",
"them",
"and",
"stops",
"and",
"waits",
"for",
"each",
"thenable",
"returned",
"by",
"the",
"callback",
"before",
"going",
"on",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L644-L650 | train | stop and go | [
30522,
3853,
1006,
29347,
16930,
11187,
1010,
1042,
20909,
3363,
5963,
1007,
1063,
3046,
1063,
2709,
26351,
21572,
28732,
1012,
10663,
1006,
2644,
5685,
3995,
1006,
29347,
16930,
11187,
1010,
1042,
20909,
3363,
5963,
1007,
1007,
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... | |
socketio/socket.io | examples/whiteboard/public/main.js | throttle | function throttle(callback, delay) {
var previousCall = new Date().getTime();
return function() {
var time = new Date().getTime();
if ((time - previousCall) >= delay) {
previousCall = time;
callback.apply(null, arguments);
}
};
} | javascript | function throttle(callback, delay) {
var previousCall = new Date().getTime();
return function() {
var time = new Date().getTime();
if ((time - previousCall) >= delay) {
previousCall = time;
callback.apply(null, arguments);
}
};
} | [
"function",
"throttle",
"(",
"callback",
",",
"delay",
")",
"{",
"var",
"previousCall",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"return",
"function",
"(",
")",
"{",
"var",
"time",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"... | limit the number of events per second | [
"limit",
"the",
"number",
"of",
"events",
"per",
"second"
] | 9c1e73c752aec63f48b511330a506d037783d897 | https://github.com/socketio/socket.io/blob/9c1e73c752aec63f48b511330a506d037783d897/examples/whiteboard/public/main.js#L82-L92 | train | Throttles a function to be called every delay milliseconds | [
30522,
3853,
24420,
1006,
2655,
5963,
1010,
8536,
1007,
1063,
13075,
3025,
9289,
2140,
1027,
2047,
3058,
1006,
1007,
1012,
2131,
7292,
1006,
1007,
1025,
2709,
3853,
1006,
1007,
1063,
13075,
2051,
1027,
2047,
3058,
1006,
1007,
1012,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/jszip.js | function(dec, bytes) {
var hex = "",
i;
for (i = 0; i < bytes; i++) {
hex += String.fromCharCode(dec & 0xff);
dec = dec >>> 8;
}
return hex;
} | javascript | function(dec, bytes) {
var hex = "",
i;
for (i = 0; i < bytes; i++) {
hex += String.fromCharCode(dec & 0xff);
dec = dec >>> 8;
}
return hex;
} | [
"function",
"(",
"dec",
",",
"bytes",
")",
"{",
"var",
"hex",
"=",
"\"\"",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
";",
"i",
"++",
")",
"{",
"hex",
"+=",
"String",
".",
"fromCharCode",
"(",
"dec",
"&",
"0xff",
")",
... | Transform an integer into a string in hexadecimal.
@private
@param {number} dec the number to convert.
@param {number} bytes the number of bytes to generate.
@returns {string} the result. | [
"Transform",
"an",
"integer",
"into",
"a",
"string",
"in",
"hexadecimal",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/jszip.js#L506-L514 | train | Convert a binary number to a hex string | [
30522,
3853,
1006,
11703,
1010,
27507,
1007,
1063,
13075,
2002,
2595,
1027,
1000,
1000,
1010,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
27507,
1025,
1045,
1009,
1009,
1007,
1063,
2002,
2595,
1009,
1027,
5164,
1012,
2013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-useless-escape.js | validateString | function validateString(node, match) {
const isTemplateElement = node.type === "TemplateElement";
const escapedChar = match[0][1];
let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
let isQuoteEscape;
if (isTemplateElement) {
isQuoteEscape = escapedChar === "`";
if (escapedChar === "$") {
// Warn if `\$` is not followed by `{`
isUnnecessaryEscape = match.input[match.index + 2] !== "{";
} else if (escapedChar === "{") {
/*
* Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
* is necessary and the rule should not warn. If preceded by `/$`, the rule
* will warn for the `/$` instead, as it is the first unnecessarily escaped character.
*/
isUnnecessaryEscape = match.input[match.index - 1] !== "$";
}
} else {
isQuoteEscape = escapedChar === node.raw[0];
}
if (isUnnecessaryEscape && !isQuoteEscape) {
report(node, match.index + 1, match[0].slice(1));
}
} | javascript | function validateString(node, match) {
const isTemplateElement = node.type === "TemplateElement";
const escapedChar = match[0][1];
let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
let isQuoteEscape;
if (isTemplateElement) {
isQuoteEscape = escapedChar === "`";
if (escapedChar === "$") {
// Warn if `\$` is not followed by `{`
isUnnecessaryEscape = match.input[match.index + 2] !== "{";
} else if (escapedChar === "{") {
/*
* Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
* is necessary and the rule should not warn. If preceded by `/$`, the rule
* will warn for the `/$` instead, as it is the first unnecessarily escaped character.
*/
isUnnecessaryEscape = match.input[match.index - 1] !== "$";
}
} else {
isQuoteEscape = escapedChar === node.raw[0];
}
if (isUnnecessaryEscape && !isQuoteEscape) {
report(node, match.index + 1, match[0].slice(1));
}
} | [
"function",
"validateString",
"(",
"node",
",",
"match",
")",
"{",
"const",
"isTemplateElement",
"=",
"node",
".",
"type",
"===",
"\"TemplateElement\"",
";",
"const",
"escapedChar",
"=",
"match",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"let",
"isUnnecessaryEscape... | Checks if the escape character in given string slice is unnecessary.
@private
@param {ASTNode} node - node to validate.
@param {string} match - string slice to validate.
@returns {void} | [
"Checks",
"if",
"the",
"escape",
"character",
"in",
"given",
"string",
"slice",
"is",
"unnecessary",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L121-L150 | train | Validate a string | [
30522,
3853,
9398,
8520,
18886,
3070,
1006,
13045,
1010,
2674,
1007,
1063,
9530,
3367,
21541,
30524,
1027,
1027,
1027,
1000,
23561,
12260,
3672,
1000,
1025,
9530,
3367,
6376,
7507,
2099,
1027,
2674,
1031,
1014,
1033,
1031,
1015,
1033,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/systems/material.js | function (src, data, cb) {
var self = this;
// Canvas.
if (src.tagName === 'CANVAS') {
this.loadCanvas(src, data, cb);
return;
}
// Video element.
if (src.tagName === 'VIDEO') {
if (!src.src && !src.srcObject && !src.childElementCount) {
warn('Video element was defined with neither `source` elements nor `src` / `srcObject` attributes.');
}
this.loadVideo(src, data, cb);
return;
}
utils.srcLoader.validateSrc(src, loadImageCb, loadVideoCb);
function loadImageCb (src) { self.loadImage(src, data, cb); }
function loadVideoCb (src) { self.loadVideo(src, data, cb); }
} | javascript | function (src, data, cb) {
var self = this;
// Canvas.
if (src.tagName === 'CANVAS') {
this.loadCanvas(src, data, cb);
return;
}
// Video element.
if (src.tagName === 'VIDEO') {
if (!src.src && !src.srcObject && !src.childElementCount) {
warn('Video element was defined with neither `source` elements nor `src` / `srcObject` attributes.');
}
this.loadVideo(src, data, cb);
return;
}
utils.srcLoader.validateSrc(src, loadImageCb, loadVideoCb);
function loadImageCb (src) { self.loadImage(src, data, cb); }
function loadVideoCb (src) { self.loadVideo(src, data, cb); }
} | [
"function",
"(",
"src",
",",
"data",
",",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Canvas.",
"if",
"(",
"src",
".",
"tagName",
"===",
"'CANVAS'",
")",
"{",
"this",
".",
"loadCanvas",
"(",
"src",
",",
"data",
",",
"cb",
")",
";",
"retu... | Determine whether `src` is a image or video. Then try to load the asset, then call back.
@param {string, or element} src - Texture URL or element.
@param {string} data - Relevant texture data used for caching.
@param {function} cb - Callback to pass texture to. | [
"Determine",
"whether",
"src",
"is",
"a",
"image",
"or",
"video",
".",
"Then",
"try",
"to",
"load",
"the",
"asset",
"then",
"call",
"back",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L49-L70 | train | Load a video image element | [
30522,
3853,
1006,
5034,
2278,
1010,
2951,
1010,
17324,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
10683,
1012,
2065,
1006,
5034,
2278,
1012,
6415,
18442,
1027,
1027,
1027,
1005,
10683,
1005,
1007,
1063,
2023,
1012,
7170,
9336,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
google/material-design-lite | src/mdlComponentHandler.js | registerInternal | function registerInternal(config) {
// In order to support both Closure-compiled and uncompiled code accessing
// this method, we need to allow for both the dot and array syntax for
// property access. You'll therefore see the `foo.bar || foo['bar']`
// pattern repeated across this method.
var widgetMissing = (typeof config.widget === 'undefined' &&
typeof config['widget'] === 'undefined');
var widget = true;
if (!widgetMissing) {
widget = config.widget || config['widget'];
}
var newConfig = /** @type {componentHandler.ComponentConfig} */ ({
classConstructor: config.constructor || config['constructor'],
className: config.classAsString || config['classAsString'],
cssClass: config.cssClass || config['cssClass'],
widget: widget,
callbacks: []
});
registeredComponents_.forEach(function(item) {
if (item.cssClass === newConfig.cssClass) {
throw new Error('The provided cssClass has already been registered: ' + item.cssClass);
}
if (item.className === newConfig.className) {
throw new Error('The provided className has already been registered');
}
});
if (config.constructor.prototype
.hasOwnProperty(componentConfigProperty_)) {
throw new Error(
'MDL component classes must not have ' + componentConfigProperty_ +
' defined as a property.');
}
var found = findRegisteredClass_(config.classAsString, newConfig);
if (!found) {
registeredComponents_.push(newConfig);
}
} | javascript | function registerInternal(config) {
// In order to support both Closure-compiled and uncompiled code accessing
// this method, we need to allow for both the dot and array syntax for
// property access. You'll therefore see the `foo.bar || foo['bar']`
// pattern repeated across this method.
var widgetMissing = (typeof config.widget === 'undefined' &&
typeof config['widget'] === 'undefined');
var widget = true;
if (!widgetMissing) {
widget = config.widget || config['widget'];
}
var newConfig = /** @type {componentHandler.ComponentConfig} */ ({
classConstructor: config.constructor || config['constructor'],
className: config.classAsString || config['classAsString'],
cssClass: config.cssClass || config['cssClass'],
widget: widget,
callbacks: []
});
registeredComponents_.forEach(function(item) {
if (item.cssClass === newConfig.cssClass) {
throw new Error('The provided cssClass has already been registered: ' + item.cssClass);
}
if (item.className === newConfig.className) {
throw new Error('The provided className has already been registered');
}
});
if (config.constructor.prototype
.hasOwnProperty(componentConfigProperty_)) {
throw new Error(
'MDL component classes must not have ' + componentConfigProperty_ +
' defined as a property.');
}
var found = findRegisteredClass_(config.classAsString, newConfig);
if (!found) {
registeredComponents_.push(newConfig);
}
} | [
"function",
"registerInternal",
"(",
"config",
")",
"{",
"// In order to support both Closure-compiled and uncompiled code accessing",
"// this method, we need to allow for both the dot and array syntax for",
"// property access. You'll therefore see the `foo.bar || foo['bar']`",
"// pattern repea... | Registers a class for future use and attempts to upgrade existing DOM.
@param {componentHandler.ComponentConfigPublic} config | [
"Registers",
"a",
"class",
"for",
"future",
"use",
"and",
"attempts",
"to",
"upgrade",
"existing",
"DOM",
"."
] | 60f441a22ed98ed2c03f6179adf460d888bf459f | https://github.com/google/material-design-lite/blob/60f441a22ed98ed2c03f6179adf460d888bf459f/src/mdlComponentHandler.js#L292-L334 | train | Register a component with the kernel. | [
30522,
3853,
4236,
18447,
11795,
2389,
1006,
9530,
8873,
2290,
1007,
1063,
1013,
1013,
1999,
2344,
2000,
2490,
2119,
8503,
1011,
9227,
1998,
4895,
9006,
22090,
2094,
3642,
3229,
2075,
1013,
1013,
2023,
4118,
1010,
2057,
2342,
2000,
3499,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/EditorManager.js | _createUnattachedMasterEditor | function _createUnattachedMasterEditor(doc) {
// attach to the hidden containers DOM node if necessary
if (!_$hiddenEditorsContainer) {
_$hiddenEditorsContainer = $("#hidden-editors");
}
// Create an editor
var editor = _createEditorForDocument(doc, true, _$hiddenEditorsContainer);
// and hide it
editor.setVisible(false);
} | javascript | function _createUnattachedMasterEditor(doc) {
// attach to the hidden containers DOM node if necessary
if (!_$hiddenEditorsContainer) {
_$hiddenEditorsContainer = $("#hidden-editors");
}
// Create an editor
var editor = _createEditorForDocument(doc, true, _$hiddenEditorsContainer);
// and hide it
editor.setVisible(false);
} | [
"function",
"_createUnattachedMasterEditor",
"(",
"doc",
")",
"{",
"// attach to the hidden containers DOM node if necessary",
"if",
"(",
"!",
"_$hiddenEditorsContainer",
")",
"{",
"_$hiddenEditorsContainer",
"=",
"$",
"(",
"\"#hidden-editors\"",
")",
";",
"}",
"// Create a... | Creates a hidden, unattached master editor that is needed when a document is created for the
sole purpose of creating an inline editor so operations that require a master editor can be performed
Only called from Document._ensureMasterEditor()
The editor view is placed in a hidden part of the DOM but can later be moved to a visible pane
when the document is opened using pane.addView()
@param {!Document} doc - document to create a hidden editor for | [
"Creates",
"a",
"hidden",
"unattached",
"master",
"editor",
"that",
"is",
"needed",
"when",
"a",
"document",
"is",
"created",
"for",
"the",
"sole",
"purpose",
"of",
"creating",
"an",
"inline",
"editor",
"so",
"operations",
"that",
"require",
"a",
"master",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorManager.js#L346-L355 | train | Create an unattached master editor for the given document | [
30522,
3853,
1035,
3443,
9521,
5946,
7690,
8706,
2098,
15660,
1006,
9986,
1007,
1063,
1013,
1013,
22476,
2000,
1996,
5023,
16143,
14383,
13045,
2065,
4072,
2065,
1006,
999,
1035,
1002,
5023,
2098,
27287,
8663,
18249,
2121,
1007,
1063,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js | function(oTable, oEvent) {
if (oTable._bIsColumnResizerMoving) {
return;
}
oTable._bIsColumnResizerMoving = true;
oTable.$().toggleClass("sapUiTableResizing", true);
var $Document = jQuery(document),
bTouch = oTable._isTouchEvent(oEvent);
oTable._$colResize = oTable.$("rsz");
oTable._iColumnResizeStart = ExtensionHelper._getEventPosition(oEvent, oTable).x;
$Document.bind((bTouch ? "touchend" : "mouseup") + ".sapUiTableColumnResize",
ColumnResizeHelper.exitColumnResizing.bind(oTable));
$Document.bind((bTouch ? "touchmove" : "mousemove") + ".sapUiTableColumnResize",
ColumnResizeHelper.onMouseMoveWhileColumnResizing.bind(oTable));
oTable._disableTextSelection();
} | javascript | function(oTable, oEvent) {
if (oTable._bIsColumnResizerMoving) {
return;
}
oTable._bIsColumnResizerMoving = true;
oTable.$().toggleClass("sapUiTableResizing", true);
var $Document = jQuery(document),
bTouch = oTable._isTouchEvent(oEvent);
oTable._$colResize = oTable.$("rsz");
oTable._iColumnResizeStart = ExtensionHelper._getEventPosition(oEvent, oTable).x;
$Document.bind((bTouch ? "touchend" : "mouseup") + ".sapUiTableColumnResize",
ColumnResizeHelper.exitColumnResizing.bind(oTable));
$Document.bind((bTouch ? "touchmove" : "mousemove") + ".sapUiTableColumnResize",
ColumnResizeHelper.onMouseMoveWhileColumnResizing.bind(oTable));
oTable._disableTextSelection();
} | [
"function",
"(",
"oTable",
",",
"oEvent",
")",
"{",
"if",
"(",
"oTable",
".",
"_bIsColumnResizerMoving",
")",
"{",
"return",
";",
"}",
"oTable",
".",
"_bIsColumnResizerMoving",
"=",
"true",
";",
"oTable",
".",
"$",
"(",
")",
".",
"toggleClass",
"(",
"\"s... | /*
Initializes the drag&drop for resizing | [
"/",
"*",
"Initializes",
"the",
"drag&drop",
"for",
"resizing"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L162-L182 | train | Handles the mouse move event on the column resizer. | [
30522,
3853,
1006,
27178,
3085,
1010,
1051,
18697,
3372,
1007,
1063,
2065,
1006,
27178,
3085,
1012,
1035,
20377,
25778,
2819,
16118,
2229,
17629,
5302,
6455,
1007,
1063,
2709,
1025,
1065,
27178,
3085,
1012,
1035,
20377,
25778,
2819,
16118,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensibility/node/package-validator.js | extractAndValidateFiles | function extractAndValidateFiles(zipPath, extractDir, options, callback) {
var unzipper = new DecompressZip(zipPath);
unzipper.on("error", function (err) {
// General error to report for problems reading the file
callback(null, {
errors: [[Errors.INVALID_ZIP_FILE, zipPath, err]]
});
return;
});
unzipper.on("extract", function (log) {
findCommonPrefix(extractDir, function (err, commonPrefix) {
if (err) {
callback(err, null);
return;
}
var packageJSON = path.join(extractDir, commonPrefix, "package.json");
validatePackageJSON(zipPath, packageJSON, options, function (err, errors, metadata) {
if (err) {
callback(err, null);
return;
}
var mainJS = path.join(extractDir, commonPrefix, "main.js"),
isTheme = metadata && metadata.theme;
// Throw missing main.js file only for non-theme extensions
if (!isTheme && !fs.existsSync(mainJS)) {
errors.push([Errors.MISSING_MAIN, zipPath, mainJS]);
}
var npmOptions = ['--production'];
if (options.proxy) {
npmOptions.push('--proxy ' + options.proxy);
}
if (process.platform.startsWith('win')) {
// On Windows force a 32 bit build until nodejs 64 bit is supported.
npmOptions.push('--arch=ia32');
npmOptions.push('--npm_config_arch=ia32');
npmOptions.push('--npm_config_target_arch=ia32');
}
performNpmInstallIfRequired(npmOptions, {
errors: errors,
metadata: metadata,
commonPrefix: commonPrefix,
extractDir: extractDir
}, callback);
});
});
});
unzipper.extract({
path: extractDir,
filter: function (file) {
return file.type !== "SymbolicLink";
}
});
} | javascript | function extractAndValidateFiles(zipPath, extractDir, options, callback) {
var unzipper = new DecompressZip(zipPath);
unzipper.on("error", function (err) {
// General error to report for problems reading the file
callback(null, {
errors: [[Errors.INVALID_ZIP_FILE, zipPath, err]]
});
return;
});
unzipper.on("extract", function (log) {
findCommonPrefix(extractDir, function (err, commonPrefix) {
if (err) {
callback(err, null);
return;
}
var packageJSON = path.join(extractDir, commonPrefix, "package.json");
validatePackageJSON(zipPath, packageJSON, options, function (err, errors, metadata) {
if (err) {
callback(err, null);
return;
}
var mainJS = path.join(extractDir, commonPrefix, "main.js"),
isTheme = metadata && metadata.theme;
// Throw missing main.js file only for non-theme extensions
if (!isTheme && !fs.existsSync(mainJS)) {
errors.push([Errors.MISSING_MAIN, zipPath, mainJS]);
}
var npmOptions = ['--production'];
if (options.proxy) {
npmOptions.push('--proxy ' + options.proxy);
}
if (process.platform.startsWith('win')) {
// On Windows force a 32 bit build until nodejs 64 bit is supported.
npmOptions.push('--arch=ia32');
npmOptions.push('--npm_config_arch=ia32');
npmOptions.push('--npm_config_target_arch=ia32');
}
performNpmInstallIfRequired(npmOptions, {
errors: errors,
metadata: metadata,
commonPrefix: commonPrefix,
extractDir: extractDir
}, callback);
});
});
});
unzipper.extract({
path: extractDir,
filter: function (file) {
return file.type !== "SymbolicLink";
}
});
} | [
"function",
"extractAndValidateFiles",
"(",
"zipPath",
",",
"extractDir",
",",
"options",
",",
"callback",
")",
"{",
"var",
"unzipper",
"=",
"new",
"DecompressZip",
"(",
"zipPath",
")",
";",
"unzipper",
".",
"on",
"(",
"\"error\"",
",",
"function",
"(",
"err... | Extracts the package into the given directory and then validates it.
@param {string} zipPath path to package zip file
@param {string} extractDir directory to extract package into
@param {Object} options validation options
@param {function(Error, {errors: Array, metadata: Object, commonPrefix: string, extractDir: string})} callback function to call with the result | [
"Extracts",
"the",
"package",
"into",
"the",
"given",
"directory",
"and",
"then",
"validates",
"it",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/node/package-validator.js#L268-L327 | train | Extract and validate files from zip | [
30522,
3853,
14817,
5685,
10175,
8524,
2618,
8873,
4244,
1006,
14101,
15069,
1010,
14817,
4305,
2099,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
13075,
4895,
5831,
18620,
1027,
2047,
21933,
8737,
8303,
5831,
2361,
1006,
14101,
15069,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/config/config-validator.js | validateRuleSeverity | function validateRuleSeverity(options) {
const severity = Array.isArray(options) ? options[0] : options;
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
return normSeverity;
}
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
} | javascript | function validateRuleSeverity(options) {
const severity = Array.isArray(options) ? options[0] : options;
const normSeverity = typeof severity === "string" ? severityMap[severity.toLowerCase()] : severity;
if (normSeverity === 0 || normSeverity === 1 || normSeverity === 2) {
return normSeverity;
}
throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/gu, "\"").replace(/\n/gu, "")}').\n`);
} | [
"function",
"validateRuleSeverity",
"(",
"options",
")",
"{",
"const",
"severity",
"=",
"Array",
".",
"isArray",
"(",
"options",
")",
"?",
"options",
"[",
"0",
"]",
":",
"options",
";",
"const",
"normSeverity",
"=",
"typeof",
"severity",
"===",
"\"string\"",... | Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
@param {options} options The given options for the rule.
@returns {number|string} The rule's severity value | [
"Validates",
"a",
"rule",
"s",
"severity",
"and",
"returns",
"the",
"severity",
"value",
".",
"Throws",
"an",
"error",
"if",
"the",
"severity",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-validator.js#L72-L82 | train | Validate the severity of a rule | [
30522,
3853,
9398,
24932,
16308,
22507,
3012,
1006,
7047,
1007,
1063,
9530,
3367,
18976,
1027,
9140,
1012,
18061,
11335,
2100,
1006,
7047,
1007,
1029,
7047,
1031,
1014,
1033,
1024,
7047,
1025,
9530,
3367,
17606,
22507,
3012,
1027,
2828,
112... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | restoreLineFolds | function restoreLineFolds(editor) {
/**
* Checks if the range from and to Pos is the same as the selection start and end Pos
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects
* @param {Object} selection {start, end} where start and end are CodeMirror.Pos objects
* @returns {Boolean} true if the range and selection span the same region and false otherwise
*/
function rangeEqualsSelection(range, selection) {
return range.from.line === selection.start.line && range.from.ch === selection.start.ch &&
range.to.line === selection.end.line && range.to.ch === selection.end.ch;
}
/**
* Checks if the range is equal to one of the selections in the viewState
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects.
* @param {Object} viewState The current editor's ViewState object
* @returns {Boolean} true if the range is found in the list of selections or false if not.
*/
function isInViewStateSelection(range, viewState) {
if (!viewState || !viewState.selections) {
return false;
}
return viewState.selections.some(function (selection) {
return rangeEqualsSelection(range, selection);
});
}
var saveFolds = prefs.getSetting("saveFoldStates");
if (!editor || !saveFolds) {
if (editor) {
editor._codeMirror._lineFolds = editor._codeMirror._lineFolds || {};
}
return;
}
var cm = editor._codeMirror;
var viewState = ViewStateManager.getViewState(editor.document.file);
var path = editor.document.file.fullPath;
var folds = cm._lineFolds || prefs.getFolds(path) || {};
//separate out selection folds from non-selection folds
var nonSelectionFolds = {}, selectionFolds = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
if (isInViewStateSelection(range, viewState)) {
selectionFolds[line] = range;
} else {
nonSelectionFolds[line] = range;
}
});
nonSelectionFolds = cm.getValidFolds(nonSelectionFolds);
//add the selection folds
Object.keys(selectionFolds).forEach(function (line) {
nonSelectionFolds[line] = selectionFolds[line];
});
cm._lineFolds = nonSelectionFolds;
prefs.setFolds(path, cm._lineFolds);
Object.keys(cm._lineFolds).forEach(function (line) {
cm.foldCode(Number(line), {range: cm._lineFolds[line]});
});
} | javascript | function restoreLineFolds(editor) {
/**
* Checks if the range from and to Pos is the same as the selection start and end Pos
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects
* @param {Object} selection {start, end} where start and end are CodeMirror.Pos objects
* @returns {Boolean} true if the range and selection span the same region and false otherwise
*/
function rangeEqualsSelection(range, selection) {
return range.from.line === selection.start.line && range.from.ch === selection.start.ch &&
range.to.line === selection.end.line && range.to.ch === selection.end.ch;
}
/**
* Checks if the range is equal to one of the selections in the viewState
* @param {Object} range {from, to} where from and to are CodeMirror.Pos objects.
* @param {Object} viewState The current editor's ViewState object
* @returns {Boolean} true if the range is found in the list of selections or false if not.
*/
function isInViewStateSelection(range, viewState) {
if (!viewState || !viewState.selections) {
return false;
}
return viewState.selections.some(function (selection) {
return rangeEqualsSelection(range, selection);
});
}
var saveFolds = prefs.getSetting("saveFoldStates");
if (!editor || !saveFolds) {
if (editor) {
editor._codeMirror._lineFolds = editor._codeMirror._lineFolds || {};
}
return;
}
var cm = editor._codeMirror;
var viewState = ViewStateManager.getViewState(editor.document.file);
var path = editor.document.file.fullPath;
var folds = cm._lineFolds || prefs.getFolds(path) || {};
//separate out selection folds from non-selection folds
var nonSelectionFolds = {}, selectionFolds = {}, range;
Object.keys(folds).forEach(function (line) {
range = folds[line];
if (isInViewStateSelection(range, viewState)) {
selectionFolds[line] = range;
} else {
nonSelectionFolds[line] = range;
}
});
nonSelectionFolds = cm.getValidFolds(nonSelectionFolds);
//add the selection folds
Object.keys(selectionFolds).forEach(function (line) {
nonSelectionFolds[line] = selectionFolds[line];
});
cm._lineFolds = nonSelectionFolds;
prefs.setFolds(path, cm._lineFolds);
Object.keys(cm._lineFolds).forEach(function (line) {
cm.foldCode(Number(line), {range: cm._lineFolds[line]});
});
} | [
"function",
"restoreLineFolds",
"(",
"editor",
")",
"{",
"/**\n * Checks if the range from and to Pos is the same as the selection start and end Pos\n * @param {Object} range {from, to} where from and to are CodeMirror.Pos objects\n * @param {Object} selection {start, e... | Used to keep track of files for which line folds have been restored.
Restores the linefolds in the editor using values fetched from the preference store
Checks the document to ensure that changes have not been made (e.g., in a different editor)
to invalidate the saved line folds.
Selection Folds are found by comparing the line folds in the preference store with the
selection ranges in the viewState of the current document. Any selection range in the view state
that is folded in the prefs will be folded. Unlike other fold range finder, the only validation
on selection folds is to check that they satisfy the minimum fold range.
@param {Editor} editor the editor whose saved line folds should be restored | [
"Used",
"to",
"keep",
"track",
"of",
"files",
"for",
"which",
"line",
"folds",
"have",
"been",
"restored",
".",
"Restores",
"the",
"linefolds",
"in",
"the",
"editor",
"using",
"values",
"fetched",
"from",
"the",
"preference",
"store",
"Checks",
"the",
"docum... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L91-L153 | train | Restore line folds from editor s editor s viewState | [
30522,
3853,
9239,
4179,
10371,
2015,
1006,
3559,
1007,
1063,
1013,
1008,
1008,
1008,
14148,
2065,
1996,
2846,
2013,
1998,
2000,
13433,
2015,
2003,
1996,
2168,
2004,
1996,
4989,
2707,
1998,
2203,
13433,
2015,
1008,
1030,
11498,
2213,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Parser.js | tokenize | function tokenize(sOption) {
var iAt = 1, // The token's position for error messages; we count starting with 1
sId,
aMatches,
sNext = sOption,
iOffset,
oToken,
aTokens = [],
sValue;
while (sNext.length) {
aMatches = rToken.exec(sNext);
iOffset = 0;
if (aMatches) {
sValue = aMatches[0];
if (aMatches[7]) {
sId = "OPTION";
} else if (aMatches[6] || aMatches[4]) {
sId = "VALUE";
} else if (aMatches[5]) {
sId = "PATH";
if (sValue === "false" || sValue === "true" || sValue === "null") {
sId = "VALUE";
} else if (sValue === "not") {
sId = "not";
aMatches = rNot.exec(sNext);
if (aMatches) {
sValue = aMatches[0];
}
}
} else if (aMatches[3]) { // a %-escaped delimiter
sId = unescape(aMatches[3]);
} else if (aMatches[2]) { // an operator
sId = aMatches[2];
iOffset = aMatches[1].length;
} else { // a delimiter
sId = aMatches[0];
}
if (sId === '"') {
sId = "VALUE";
sValue = tokenizeDoubleQuotedString(sNext, sOption, iAt);
} else if (sId === "'") {
sId = "VALUE";
sValue = tokenizeSingleQuotedString(sNext, sOption, iAt);
}
oToken = {
at : iAt + iOffset,
id : sId,
value : sValue
};
} else {
throw new SyntaxError("Unknown character '" + sNext[0] + "' at " + iAt + ": "
+ sOption);
}
sNext = sNext.slice(sValue.length);
iAt += sValue.length;
aTokens.push(oToken);
}
return aTokens;
} | javascript | function tokenize(sOption) {
var iAt = 1, // The token's position for error messages; we count starting with 1
sId,
aMatches,
sNext = sOption,
iOffset,
oToken,
aTokens = [],
sValue;
while (sNext.length) {
aMatches = rToken.exec(sNext);
iOffset = 0;
if (aMatches) {
sValue = aMatches[0];
if (aMatches[7]) {
sId = "OPTION";
} else if (aMatches[6] || aMatches[4]) {
sId = "VALUE";
} else if (aMatches[5]) {
sId = "PATH";
if (sValue === "false" || sValue === "true" || sValue === "null") {
sId = "VALUE";
} else if (sValue === "not") {
sId = "not";
aMatches = rNot.exec(sNext);
if (aMatches) {
sValue = aMatches[0];
}
}
} else if (aMatches[3]) { // a %-escaped delimiter
sId = unescape(aMatches[3]);
} else if (aMatches[2]) { // an operator
sId = aMatches[2];
iOffset = aMatches[1].length;
} else { // a delimiter
sId = aMatches[0];
}
if (sId === '"') {
sId = "VALUE";
sValue = tokenizeDoubleQuotedString(sNext, sOption, iAt);
} else if (sId === "'") {
sId = "VALUE";
sValue = tokenizeSingleQuotedString(sNext, sOption, iAt);
}
oToken = {
at : iAt + iOffset,
id : sId,
value : sValue
};
} else {
throw new SyntaxError("Unknown character '" + sNext[0] + "' at " + iAt + ": "
+ sOption);
}
sNext = sNext.slice(sValue.length);
iAt += sValue.length;
aTokens.push(oToken);
}
return aTokens;
} | [
"function",
"tokenize",
"(",
"sOption",
")",
"{",
"var",
"iAt",
"=",
"1",
",",
"// The token's position for error messages; we count starting with 1",
"sId",
",",
"aMatches",
",",
"sNext",
"=",
"sOption",
",",
"iOffset",
",",
"oToken",
",",
"aTokens",
"=",
"[",
... | Splits the option string into an array of tokens.
@param {string} sOption The option string
@returns {object[]} The array of tokens. | [
"Splits",
"the",
"option",
"string",
"into",
"an",
"array",
"of",
"tokens",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Parser.js#L688-L748 | train | Parses the given string into an array of tokens | [
30522,
3853,
19204,
4697,
1006,
2061,
16790,
1007,
1063,
13075,
24264,
2102,
1027,
1015,
1010,
1013,
1013,
1996,
19204,
1005,
1055,
2597,
2005,
7561,
7696,
1025,
2057,
4175,
3225,
2007,
1015,
15765,
1010,
25933,
10649,
2229,
1010,
1055,
263... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | _draft/music/webuploader.js | function( key, blob, filename ) {
var me = this,
opts = me.options;
if ( me.getRuid() ) {
me.disconnectRuntime();
}
// 连接到blob归属的同一个runtime.
me.connectRuntime( blob.ruid, function() {
me.exec('init');
});
me._blob = blob;
opts.fileVar = key || opts.fileVar;
opts.filename = filename || opts.filename;
} | javascript | function( key, blob, filename ) {
var me = this,
opts = me.options;
if ( me.getRuid() ) {
me.disconnectRuntime();
}
// 连接到blob归属的同一个runtime.
me.connectRuntime( blob.ruid, function() {
me.exec('init');
});
me._blob = blob;
opts.fileVar = key || opts.fileVar;
opts.filename = filename || opts.filename;
} | [
"function",
"(",
"key",
",",
"blob",
",",
"filename",
")",
"{",
"var",
"me",
"=",
"this",
",",
"opts",
"=",
"me",
".",
"options",
";",
"if",
"(",
"me",
".",
"getRuid",
"(",
")",
")",
"{",
"me",
".",
"disconnectRuntime",
"(",
")",
";",
"}",
"// ... | 添加Blob, 只能添加一次,最后一次有效。 | [
"添加Blob",
"只能添加一次,最后一次有效。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/_draft/music/webuploader.js#L1938-L1954 | train | Initialize the file cache | [
30522,
3853,
1006,
3145,
1010,
1038,
4135,
2497,
1010,
5371,
18442,
1007,
1063,
13075,
2033,
1027,
2023,
1010,
23569,
2015,
1027,
2033,
1012,
7047,
1025,
2065,
1006,
2033,
1012,
2131,
6820,
3593,
1006,
1007,
1007,
1063,
2033,
1012,
12532,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dequelabs/axe-core | lib/core/utils/get-xpath.js | xpathToString | function xpathToString(xpathArray) {
return xpathArray.reduce((str, elm) => {
if (elm.id) {
return `/${elm.str}[@id='${elm.id}']`;
} else {
return str + `/${elm.str}` + (elm.count > 0 ? `[${elm.count}]` : '');
}
}, '');
} | javascript | function xpathToString(xpathArray) {
return xpathArray.reduce((str, elm) => {
if (elm.id) {
return `/${elm.str}[@id='${elm.id}']`;
} else {
return str + `/${elm.str}` + (elm.count > 0 ? `[${elm.count}]` : '');
}
}, '');
} | [
"function",
"xpathToString",
"(",
"xpathArray",
")",
"{",
"return",
"xpathArray",
".",
"reduce",
"(",
"(",
"str",
",",
"elm",
")",
"=>",
"{",
"if",
"(",
"elm",
".",
"id",
")",
"{",
"return",
"`",
"${",
"elm",
".",
"str",
"}",
"${",
"elm",
".",
"i... | Robust is intended to allow xpaths to be robust to changes in the HTML structure of the page This means always use the id when present Non robust means always use the count (i.e. the exact position of the element) Ironically this is a bit of a misnomer because in very, very dynamic pages (e.g. where ids are generated on the fly) the non-ribust Xpaths will work whereas the robust ones will not work | [
"Robust",
"is",
"intended",
"to",
"allow",
"xpaths",
"to",
"be",
"robust",
"to",
"changes",
"in",
"the",
"HTML",
"structure",
"of",
"the",
"page",
"This",
"means",
"always",
"use",
"the",
"id",
"when",
"present",
"Non",
"robust",
"means",
"always",
"use",
... | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/get-xpath.js#L70-L78 | train | Converts an array of XPath nodes to a string | [
30522,
3853,
26726,
8988,
13122,
18886,
3070,
1006,
26726,
8988,
2906,
9447,
1007,
1063,
2709,
26726,
8988,
2906,
9447,
1012,
5547,
1006,
1006,
2358,
2099,
1010,
17709,
1007,
1027,
1028,
1063,
2065,
1006,
17709,
1012,
8909,
1007,
1063,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/NoDistractions/main.js | initializeCommands | function initializeCommands() {
CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode);
CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels);
Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PANELS, "", Menus.AFTER, Commands.VIEW_HIDE_SIDEBAR);
Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PURE_CODE, "", Menus.AFTER, CMD_TOGGLE_PANELS);
KeyBindingManager.addBinding(CMD_TOGGLE_PURE_CODE, [ {key: togglePureCodeKey}, {key: togglePureCodeKeyMac, platform: "mac"} ]);
//default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt
//from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]);
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]);
} | javascript | function initializeCommands() {
CommandManager.register(Strings.CMD_TOGGLE_PURE_CODE, CMD_TOGGLE_PURE_CODE, _togglePureCode);
CommandManager.register(Strings.CMD_TOGGLE_PANELS, CMD_TOGGLE_PANELS, _togglePanels);
Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PANELS, "", Menus.AFTER, Commands.VIEW_HIDE_SIDEBAR);
Menus.getMenu(Menus.AppMenuBar.VIEW_MENU).addMenuItem(CMD_TOGGLE_PURE_CODE, "", Menus.AFTER, CMD_TOGGLE_PANELS);
KeyBindingManager.addBinding(CMD_TOGGLE_PURE_CODE, [ {key: togglePureCodeKey}, {key: togglePureCodeKeyMac, platform: "mac"} ]);
//default toggle panel shortcut was ctrl+shift+` as it is present in one vertical line in the keyboard. However, we later learnt
//from IQE team than non-English keyboards does not have the ` char. So added one more shortcut ctrl+shift+1 which will be preferred
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey}, {key: togglePanelsKeyMac, platform: "mac"} ]);
KeyBindingManager.addBinding(CMD_TOGGLE_PANELS, [ {key: togglePanelsKey_EN}, {key: togglePanelsKeyMac_EN, platform: "mac"} ]);
} | [
"function",
"initializeCommands",
"(",
")",
"{",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_TOGGLE_PURE_CODE",
",",
"CMD_TOGGLE_PURE_CODE",
",",
"_togglePureCode",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_TOGGLE_PANELS",... | Register the Commands , add the Menu Items and key bindings | [
"Register",
"the",
"Commands",
"add",
"the",
"Menu",
"Items",
"and",
"key",
"bindings"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NoDistractions/main.js#L154-L167 | train | Initializes the commands | [
30522,
3853,
3988,
4697,
9006,
2386,
5104,
1006,
1007,
1063,
3094,
24805,
4590,
1012,
4236,
1006,
7817,
1012,
4642,
2094,
1035,
2000,
24679,
1035,
5760,
1035,
3642,
1010,
4642,
2094,
1035,
2000,
24679,
1035,
5760,
1035,
3642,
1010,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/AnimationUtils.js | animateUsingClass | function animateUsingClass(target, animClass, timeoutDuration) {
var result = new $.Deferred(),
$target = $(target);
timeoutDuration = timeoutDuration || 400;
function finish(e) {
if (e.target === target) {
result.resolve();
}
}
function cleanup() {
$target
.removeClass(animClass)
.off(_transitionEvent, finish);
}
if ($target.is(":hidden")) {
// Don't do anything if the element is hidden because transitionEnd wouldn't fire
result.resolve();
} else {
// Note that we can't just use $.one() here because we only want to remove
// the handler when we get the transition end event for the correct target (not
// a child).
$target
.addClass(animClass)
.on(_transitionEvent, finish);
}
// Use timeout in case transition end event is not sent
return Async.withTimeout(result.promise(), timeoutDuration, true)
.done(cleanup);
} | javascript | function animateUsingClass(target, animClass, timeoutDuration) {
var result = new $.Deferred(),
$target = $(target);
timeoutDuration = timeoutDuration || 400;
function finish(e) {
if (e.target === target) {
result.resolve();
}
}
function cleanup() {
$target
.removeClass(animClass)
.off(_transitionEvent, finish);
}
if ($target.is(":hidden")) {
// Don't do anything if the element is hidden because transitionEnd wouldn't fire
result.resolve();
} else {
// Note that we can't just use $.one() here because we only want to remove
// the handler when we get the transition end event for the correct target (not
// a child).
$target
.addClass(animClass)
.on(_transitionEvent, finish);
}
// Use timeout in case transition end event is not sent
return Async.withTimeout(result.promise(), timeoutDuration, true)
.done(cleanup);
} | [
"function",
"animateUsingClass",
"(",
"target",
",",
"animClass",
",",
"timeoutDuration",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"$target",
"=",
"$",
"(",
"target",
")",
";",
"timeoutDuration",
"=",
"timeoutDuration",
"... | Start an animation by adding the given class to the given target. When the
animation is complete, removes the class, clears the event handler we attach
to watch for the animation to finish, and resolves the returned promise.
@param {Element} target The DOM node to animate.
@param {string} animClass The class that applies the animation/transition to the target.
@param {number=} timeoutDuration Time to wait in ms before rejecting promise. Default is 400.
@return {$.Promise} A promise that is resolved when the animation completes. Never rejected. | [
"Start",
"an",
"animation",
"by",
"adding",
"the",
"given",
"class",
"to",
"the",
"given",
"target",
".",
"When",
"the",
"animation",
"is",
"complete",
"removes",
"the",
"class",
"clears",
"the",
"event",
"handler",
"we",
"attach",
"to",
"watch",
"for",
"t... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/AnimationUtils.js#L68-L101 | train | Animate the target element using the specified CSS class | [
30522,
3853,
2019,
21499,
18161,
26266,
1006,
4539,
1010,
2019,
5714,
26266,
1010,
2051,
5833,
24979,
3370,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
1002,
4539,
1027,
1002,
1006,
4539,
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... |
blueimp/jQuery-File-Upload | js/jquery.fileupload-ui.js | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var progress = Math.floor(data.loaded / data.total * 100);
if (data.context) {
data.context.each(function () {
$(this).find('.progress')
.attr('aria-valuenow', progress)
.children().first().css(
'width',
progress + '%'
);
});
}
} | javascript | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var progress = Math.floor(data.loaded / data.total * 100);
if (data.context) {
data.context.each(function () {
$(this).find('.progress')
.attr('aria-valuenow', progress)
.children().first().css(
'width',
progress + '%'
);
});
}
} | [
"function",
"(",
"e",
",",
"data",
")",
"{",
"if",
"(",
"e",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"progress",
"=",
"Math",
".",
"floor",
"(",
"data",
".",
"loaded",
"/",
"data",
".",
"total",
"*",
"10... | Callback for upload progress events: | [
"Callback",
"for",
"upload",
"progress",
"events",
":"
] | 4586771d65482dc9678c7e48d245a1501bf96ff5 | https://github.com/blueimp/jQuery-File-Upload/blob/4586771d65482dc9678c7e48d245a1501bf96ff5/js/jquery.fileupload-ui.js#L282-L297 | train | onProgress event | [
30522,
3853,
1006,
1041,
1010,
2951,
1007,
1063,
2065,
1006,
1041,
1012,
2003,
3207,
7011,
11314,
28139,
15338,
2098,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
13075,
5082,
1027,
8785,
1012,
2723,
1006,
2951,
1012,
8209,
1013,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function (state, source, target, points, result)
{
var pts = state.absolutePoints;
var p0 = pts[0];
var pe = pts[pts.length-1];
if (p0 != null && pe != null)
{
if (points != null && points.length > 0)
{
for (var i = 0; i < points.length; i++)
{
var pt = points[i];
pt = state.view.transformControlPoint(state, pt);
result.push(new mxPoint(pt.x, pt.y));
}
}
return;
}
if (source != null)
{
var view = state.view;
var graph = view.graph;
var pt = (points != null && points.length > 0) ? points[0] : null;
if (pt != null)
{
pt = view.transformControlPoint(state, pt);
if (mxUtils.contains(source, pt.x, pt.y))
{
pt = null;
}
}
var x = 0;
var dx = 0;
var y = 0;
var dy = 0;
var seg = mxUtils.getValue(state.style, mxConstants.STYLE_SEGMENT,
graph.gridSize) * view.scale;
var dir = mxUtils.getValue(state.style, mxConstants.STYLE_DIRECTION,
mxConstants.DIRECTION_WEST);
if (dir == mxConstants.DIRECTION_NORTH ||
dir == mxConstants.DIRECTION_SOUTH)
{
x = view.getRoutingCenterX(source);
dx = seg;
}
else
{
y = view.getRoutingCenterY(source);
dy = seg;
}
if (pt == null ||
pt.x < source.x ||
pt.x > source.x + source.width)
{
if (pt != null)
{
x = pt.x;
dy = Math.max(Math.abs(y - pt.y), dy);
}
else
{
if (dir == mxConstants.DIRECTION_NORTH)
{
y = source.y - 2 * dx;
}
else if (dir == mxConstants.DIRECTION_SOUTH)
{
y = source.y + source.height + 2 * dx;
}
else if (dir == mxConstants.DIRECTION_EAST)
{
x = source.x - 2 * dy;
}
else
{
x = source.x + source.width + 2 * dy;
}
}
}
else if (pt != null)
{
x = view.getRoutingCenterX(source);
dx = Math.max(Math.abs(x - pt.x), dy);
y = pt.y;
dy = 0;
}
result.push(new mxPoint(x - dx, y - dy));
result.push(new mxPoint(x + dx, y + dy));
}
} | javascript | function (state, source, target, points, result)
{
var pts = state.absolutePoints;
var p0 = pts[0];
var pe = pts[pts.length-1];
if (p0 != null && pe != null)
{
if (points != null && points.length > 0)
{
for (var i = 0; i < points.length; i++)
{
var pt = points[i];
pt = state.view.transformControlPoint(state, pt);
result.push(new mxPoint(pt.x, pt.y));
}
}
return;
}
if (source != null)
{
var view = state.view;
var graph = view.graph;
var pt = (points != null && points.length > 0) ? points[0] : null;
if (pt != null)
{
pt = view.transformControlPoint(state, pt);
if (mxUtils.contains(source, pt.x, pt.y))
{
pt = null;
}
}
var x = 0;
var dx = 0;
var y = 0;
var dy = 0;
var seg = mxUtils.getValue(state.style, mxConstants.STYLE_SEGMENT,
graph.gridSize) * view.scale;
var dir = mxUtils.getValue(state.style, mxConstants.STYLE_DIRECTION,
mxConstants.DIRECTION_WEST);
if (dir == mxConstants.DIRECTION_NORTH ||
dir == mxConstants.DIRECTION_SOUTH)
{
x = view.getRoutingCenterX(source);
dx = seg;
}
else
{
y = view.getRoutingCenterY(source);
dy = seg;
}
if (pt == null ||
pt.x < source.x ||
pt.x > source.x + source.width)
{
if (pt != null)
{
x = pt.x;
dy = Math.max(Math.abs(y - pt.y), dy);
}
else
{
if (dir == mxConstants.DIRECTION_NORTH)
{
y = source.y - 2 * dx;
}
else if (dir == mxConstants.DIRECTION_SOUTH)
{
y = source.y + source.height + 2 * dx;
}
else if (dir == mxConstants.DIRECTION_EAST)
{
x = source.x - 2 * dy;
}
else
{
x = source.x + source.width + 2 * dy;
}
}
}
else if (pt != null)
{
x = view.getRoutingCenterX(source);
dx = Math.max(Math.abs(x - pt.x), dy);
y = pt.y;
dy = 0;
}
result.push(new mxPoint(x - dx, y - dy));
result.push(new mxPoint(x + dx, y + dy));
}
} | [
"function",
"(",
"state",
",",
"source",
",",
"target",
",",
"points",
",",
"result",
")",
"{",
"var",
"pts",
"=",
"state",
".",
"absolutePoints",
";",
"var",
"p0",
"=",
"pts",
"[",
"0",
"]",
";",
"var",
"pe",
"=",
"pts",
"[",
"pts",
".",
"length... | Function: Loop
Implements a self-reference, aka. loop. | [
"Function",
":",
"Loop"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L49648-L49748 | train | Returns the point at which the point is closest to the target point | [
30522,
3853,
1006,
2110,
1010,
3120,
1010,
4539,
1010,
2685,
1010,
2765,
1007,
1063,
13075,
19637,
1027,
2110,
1012,
7619,
26521,
1025,
13075,
1052,
2692,
1027,
19637,
1031,
1014,
1033,
1025,
13075,
21877,
1027,
19637,
1031,
19637,
1012,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/table/toMarkRenderer.js | _makeTableHeadAlignText | function _makeTableHeadAlignText(thElement) {
const {align} = thElement;
const textContent = (thElement.textContent || thElement.innerText).replace(RX_COLS, '');
let textLength = textContent.length;
let leftAlignValue = '';
let rightAlignValue = '';
if (align) {
if (align === 'left') {
leftAlignValue = ':';
textLength -= 1;
} else if (align === 'right') {
rightAlignValue = ':';
textLength -= 1;
} else if (align === 'center') {
rightAlignValue = ':';
leftAlignValue = ':';
textLength -= 2;
}
}
textLength = Math.max(textLength, 3);
return leftAlignValue + _createRepeatString('-', textLength) + rightAlignValue;
} | javascript | function _makeTableHeadAlignText(thElement) {
const {align} = thElement;
const textContent = (thElement.textContent || thElement.innerText).replace(RX_COLS, '');
let textLength = textContent.length;
let leftAlignValue = '';
let rightAlignValue = '';
if (align) {
if (align === 'left') {
leftAlignValue = ':';
textLength -= 1;
} else if (align === 'right') {
rightAlignValue = ':';
textLength -= 1;
} else if (align === 'center') {
rightAlignValue = ':';
leftAlignValue = ':';
textLength -= 2;
}
}
textLength = Math.max(textLength, 3);
return leftAlignValue + _createRepeatString('-', textLength) + rightAlignValue;
} | [
"function",
"_makeTableHeadAlignText",
"(",
"thElement",
")",
"{",
"const",
"{",
"align",
"}",
"=",
"thElement",
";",
"const",
"textContent",
"=",
"(",
"thElement",
".",
"textContent",
"||",
"thElement",
".",
"innerText",
")",
".",
"replace",
"(",
"RX_COLS",
... | Make table head align text.
Copy from https://github.com/nhn/to-mark/blob/develop/src/renderer.gfm.js
@param {HTMLElement} thElement - Table head cell element
@returns {string}
@private | [
"Make",
"table",
"head",
"align",
"text",
".",
"Copy",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"nhn",
"/",
"to",
"-",
"mark",
"/",
"blob",
"/",
"develop",
"/",
"src",
"/",
"renderer",
".",
"gfm",
".",
"js"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/toMarkRenderer.js#L29-L53 | train | Creates a string that can be used to align the table head. | [
30522,
3853,
1035,
2191,
10880,
4974,
11475,
16206,
18209,
1006,
1996,
16930,
4765,
1007,
1063,
9530,
3367,
1063,
25705,
1065,
1027,
1996,
16930,
4765,
1025,
9530,
3367,
3793,
8663,
6528,
2102,
1027,
1006,
1996,
16930,
4765,
1012,
3793,
866... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/sessionstore.js | aboutSessionRestore_getRestoreState | function aboutSessionRestore_getRestoreState(element) {
var tree = this.tabList.getNode();
return tree.view.getCellValue(element.listIndex, tree.columns.getColumnAt(0));
} | javascript | function aboutSessionRestore_getRestoreState(element) {
var tree = this.tabList.getNode();
return tree.view.getCellValue(element.listIndex, tree.columns.getColumnAt(0));
} | [
"function",
"aboutSessionRestore_getRestoreState",
"(",
"element",
")",
"{",
"var",
"tree",
"=",
"this",
".",
"tabList",
".",
"getNode",
"(",
")",
";",
"return",
"tree",
".",
"view",
".",
"getCellValue",
"(",
"element",
".",
"listIndex",
",",
"tree",
".",
... | Returns the current restore state of the given element
@param {object} element
Element which restore state should be retrieved
@returns True if the element should be restored
@type {boolean} | [
"Returns",
"the",
"current",
"restore",
"state",
"of",
"the",
"given",
"element"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/sessionstore.js#L155-L159 | train | Get the restore state of the given element | [
30522,
3853,
2055,
8583,
10992,
28533,
5686,
1035,
2131,
28533,
16610,
12259,
1006,
5783,
1007,
1063,
13075,
3392,
1027,
2023,
1012,
21628,
9863,
1012,
2131,
3630,
3207,
1006,
1007,
1025,
2709,
3392,
1012,
3193,
1012,
2131,
29109,
22144,
76... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/qunit.js | toolbarChanged | function toolbarChanged() {
var updatedUrl, value,
field = this,
params = {};
// Detect if field is a select menu or a checkbox
if ( "selectedIndex" in field ) {
value = field.options[ field.selectedIndex ].value || undefined;
} else {
value = field.checked ? ( field.defaultValue || true ) : undefined;
}
params[ field.name ] = value;
updatedUrl = setUrl( params );
if ( "hidepassed" === field.name && "replaceState" in window.history ) {
config[ field.name ] = value || false;
if ( value ) {
addClass( id( "qunit-tests" ), "hidepass" );
} else {
removeClass( id( "qunit-tests" ), "hidepass" );
}
// It is not necessary to refresh the whole page
window.history.replaceState( null, "", updatedUrl );
} else {
window.location = updatedUrl;
}
} | javascript | function toolbarChanged() {
var updatedUrl, value,
field = this,
params = {};
// Detect if field is a select menu or a checkbox
if ( "selectedIndex" in field ) {
value = field.options[ field.selectedIndex ].value || undefined;
} else {
value = field.checked ? ( field.defaultValue || true ) : undefined;
}
params[ field.name ] = value;
updatedUrl = setUrl( params );
if ( "hidepassed" === field.name && "replaceState" in window.history ) {
config[ field.name ] = value || false;
if ( value ) {
addClass( id( "qunit-tests" ), "hidepass" );
} else {
removeClass( id( "qunit-tests" ), "hidepass" );
}
// It is not necessary to refresh the whole page
window.history.replaceState( null, "", updatedUrl );
} else {
window.location = updatedUrl;
}
} | [
"function",
"toolbarChanged",
"(",
")",
"{",
"var",
"updatedUrl",
",",
"value",
",",
"field",
"=",
"this",
",",
"params",
"=",
"{",
"}",
";",
"// Detect if field is a select menu or a checkbox",
"if",
"(",
"\"selectedIndex\"",
"in",
"field",
")",
"{",
"value",
... | Handle "click" events on toolbar checkboxes and "change" for select menus. Updates the URL with the new state of `config.urlConfig` values. | [
"Handle",
"click",
"events",
"on",
"toolbar",
"checkboxes",
"and",
"change",
"for",
"select",
"menus",
".",
"Updates",
"the",
"URL",
"with",
"the",
"new",
"state",
"of",
"config",
".",
"urlConfig",
"values",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/qunit.js#L3323-L3351 | train | This function is called when the toolbar is changed | [
30522,
3853,
6994,
8237,
22305,
2098,
1006,
1007,
1063,
13075,
7172,
3126,
2140,
1010,
3643,
1010,
2492,
1027,
2023,
1010,
11498,
5244,
1027,
1063,
1065,
1025,
1013,
1013,
11487,
2065,
2492,
2003,
1037,
7276,
12183,
2030,
1037,
4638,
8758,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uikit/uikit | src/js/components/parallax.js | getOffsetElement | function getOffsetElement(el) {
return el
? 'offsetTop' in el
? el
: getOffsetElement(el.parentNode)
: document.body;
} | javascript | function getOffsetElement(el) {
return el
? 'offsetTop' in el
? el
: getOffsetElement(el.parentNode)
: document.body;
} | [
"function",
"getOffsetElement",
"(",
"el",
")",
"{",
"return",
"el",
"?",
"'offsetTop'",
"in",
"el",
"?",
"el",
":",
"getOffsetElement",
"(",
"el",
".",
"parentNode",
")",
":",
"document",
".",
"body",
";",
"}"
] | SVG elements do not inherit from HTMLElement | [
"SVG",
"elements",
"do",
"not",
"inherit",
"from",
"HTMLElement"
] | b7760008135313b6a81f645c750db6f285a89488 | https://github.com/uikit/uikit/blob/b7760008135313b6a81f645c750db6f285a89488/src/js/components/parallax.js#L70-L76 | train | Get offset element | [
30522,
3853,
2131,
27475,
12870,
16930,
4765,
1006,
3449,
1007,
1063,
2709,
3449,
1029,
1005,
16396,
14399,
1005,
1999,
3449,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/extensions/chart/chart.js | _onMDPasteBefore | function _onMDPasteBefore(cm, {source, data: eventData}) {
if (!_isFromCodeBlockInCodeMirror(cm, source, eventData)) {
return;
}
const code = eventData.text.join('\n');
const delta = calcDSVDelta(code, '\t');
if (delta === 0) {
csv.COLUMN_SEPARATOR = '\t';
const parsed = _reduceToTSV(csv.parse(code));
eventData.update(eventData.from, eventData.to, parsed);
}
} | javascript | function _onMDPasteBefore(cm, {source, data: eventData}) {
if (!_isFromCodeBlockInCodeMirror(cm, source, eventData)) {
return;
}
const code = eventData.text.join('\n');
const delta = calcDSVDelta(code, '\t');
if (delta === 0) {
csv.COLUMN_SEPARATOR = '\t';
const parsed = _reduceToTSV(csv.parse(code));
eventData.update(eventData.from, eventData.to, parsed);
}
} | [
"function",
"_onMDPasteBefore",
"(",
"cm",
",",
"{",
"source",
",",
"data",
":",
"eventData",
"}",
")",
"{",
"if",
"(",
"!",
"_isFromCodeBlockInCodeMirror",
"(",
"cm",
",",
"source",
",",
"eventData",
")",
")",
"{",
"return",
";",
"}",
"const",
"code",
... | enclose pasting data strings from markdown in quotes
wysiwyg event should be treated separately.
because pasteBefore event from wysiwyg has been already processed table data to string,
on the other hand we need a table element
@param {CodeMirror} cm - markdown codemirror editor
@param {string} source - event source
@param {Object} data - event data
@ignore | [
"enclose",
"pasting",
"data",
"strings",
"from",
"markdown",
"in",
"quotes",
"wysiwyg",
"event",
"should",
"be",
"treated",
"separately",
".",
"because",
"pasteBefore",
"event",
"from",
"wysiwyg",
"has",
"been",
"already",
"processed",
"table",
"data",
"to",
"st... | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/chart/chart.js#L486-L499 | train | When a paste is before a new line | [
30522,
3853,
1035,
2006,
26876,
19707,
2618,
4783,
29278,
2063,
1006,
4642,
1010,
1063,
3120,
1010,
2951,
1024,
2724,
2850,
2696,
1065,
1007,
1063,
2065,
1006,
999,
1035,
2003,
19699,
5358,
16044,
23467,
2378,
16044,
14503,
29165,
1006,
464... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
shipshapecode/shepherd | src/js/utils/general.js | _makeTippyInstance | function _makeTippyInstance(attachToOptions) {
if (!attachToOptions.element) {
return _makeCenteredTippy.call(this);
}
const tippyOptions = _makeAttachedTippyOptions.call(this, attachToOptions);
return tippy(attachToOptions.element, tippyOptions);
} | javascript | function _makeTippyInstance(attachToOptions) {
if (!attachToOptions.element) {
return _makeCenteredTippy.call(this);
}
const tippyOptions = _makeAttachedTippyOptions.call(this, attachToOptions);
return tippy(attachToOptions.element, tippyOptions);
} | [
"function",
"_makeTippyInstance",
"(",
"attachToOptions",
")",
"{",
"if",
"(",
"!",
"attachToOptions",
".",
"element",
")",
"{",
"return",
"_makeCenteredTippy",
".",
"call",
"(",
"this",
")",
";",
"}",
"const",
"tippyOptions",
"=",
"_makeAttachedTippyOptions",
"... | Generates a `Tippy` instance from a set of base `attachTo` options
@return {tippy} The final tippy instance
@private | [
"Generates",
"a",
"Tippy",
"instance",
"from",
"a",
"set",
"of",
"base",
"attachTo",
"options"
] | 0cb1c63fb07b58796358f6d33da5f6405e2b05f4 | https://github.com/shipshapecode/shepherd/blob/0cb1c63fb07b58796358f6d33da5f6405e2b05f4/src/js/utils/general.js#L192-L200 | train | Create a new instance of Tippy with the given options | [
30522,
3853,
1035,
2191,
25101,
7685,
7076,
26897,
1006,
22476,
3406,
7361,
9285,
1007,
1063,
2065,
1006,
999,
22476,
3406,
7361,
9285,
1012,
5783,
1007,
1063,
2709,
1035,
2191,
13013,
6850,
25101,
7685,
1012,
2655,
1006,
2023,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc | examples/node/static_codegen/route_guide/route_guide_client.js | runListFeatures | function runListFeatures(callback) {
var rect = new messages.Rectangle();
var lo = new messages.Point();
lo.setLatitude(400000000);
lo.setLongitude(-750000000);
rect.setLo(lo);
var hi = new messages.Point();
hi.setLatitude(420000000);
hi.setLongitude(-730000000);
rect.setHi(hi);
console.log('Looking for features between 40, -75 and 42, -73');
var call = client.listFeatures(rect);
call.on('data', function(feature) {
console.log('Found feature called "' + feature.getName() + '" at ' +
feature.getLocation().getLatitude()/COORD_FACTOR + ', ' +
feature.getLocation().getLongitude()/COORD_FACTOR);
});
call.on('end', callback);
} | javascript | function runListFeatures(callback) {
var rect = new messages.Rectangle();
var lo = new messages.Point();
lo.setLatitude(400000000);
lo.setLongitude(-750000000);
rect.setLo(lo);
var hi = new messages.Point();
hi.setLatitude(420000000);
hi.setLongitude(-730000000);
rect.setHi(hi);
console.log('Looking for features between 40, -75 and 42, -73');
var call = client.listFeatures(rect);
call.on('data', function(feature) {
console.log('Found feature called "' + feature.getName() + '" at ' +
feature.getLocation().getLatitude()/COORD_FACTOR + ', ' +
feature.getLocation().getLongitude()/COORD_FACTOR);
});
call.on('end', callback);
} | [
"function",
"runListFeatures",
"(",
"callback",
")",
"{",
"var",
"rect",
"=",
"new",
"messages",
".",
"Rectangle",
"(",
")",
";",
"var",
"lo",
"=",
"new",
"messages",
".",
"Point",
"(",
")",
";",
"lo",
".",
"setLatitude",
"(",
"400000000",
")",
";",
... | Run the listFeatures demo. Calls listFeatures with a rectangle containing all
of the features in the pre-generated database. Prints each response as it
comes in.
@param {function} callback Called when this demo is complete | [
"Run",
"the",
"listFeatures",
"demo",
".",
"Calls",
"listFeatures",
"with",
"a",
"rectangle",
"containing",
"all",
"of",
"the",
"features",
"in",
"the",
"pre",
"-",
"generated",
"database",
".",
"Prints",
"each",
"response",
"as",
"it",
"comes",
"in",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/static_codegen/route_guide/route_guide_client.js#L73-L91 | train | List features in the cluster | [
30522,
3853,
2448,
9863,
7959,
4017,
14900,
1006,
2655,
5963,
1007,
1063,
13075,
28667,
2102,
1027,
2047,
7696,
1012,
28667,
23395,
1006,
1007,
1025,
13075,
8840,
1027,
2047,
7696,
1012,
2391,
1006,
1007,
1025,
8840,
1012,
2275,
20051,
1867... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | find | function find(cfb, path) {
var UCFullPaths = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k = false;
if(path.charCodeAt(0) === 47 /* "/" */) { k = true; path = UCFullPaths[0].slice(0, -1) + path; }
else k = path.indexOf("/") !== -1;
var UCPath = path.toUpperCase();
var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
} | javascript | function find(cfb, path) {
var UCFullPaths = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
var UCPaths = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
var k = false;
if(path.charCodeAt(0) === 47 /* "/" */) { k = true; path = UCFullPaths[0].slice(0, -1) + path; }
else k = path.indexOf("/") !== -1;
var UCPath = path.toUpperCase();
var w = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
if(w !== -1) return cfb.FileIndex[w];
var m = !UCPath.match(chr1);
UCPath = UCPath.replace(chr0,'');
if(m) UCPath = UCPath.replace(chr1,'!');
for(w = 0; w < UCFullPaths.length; ++w) {
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
}
return null;
} | [
"function",
"find",
"(",
"cfb",
",",
"path",
")",
"{",
"var",
"UCFullPaths",
"=",
"cfb",
".",
"FullPaths",
".",
"map",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"x",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"var",
"UCPaths",
"=",
"U... | /* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) | [
"/",
"*",
"[",
"MS",
"-",
"CFB",
"]",
"2",
".",
"6",
".",
"4",
"(",
"Unicode",
"3",
".",
"0",
".",
"1",
"case",
"conversion",
")"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L1886-L1904 | train | Find the file in the CFB | [
30522,
3853,
2424,
1006,
12935,
2497,
1010,
4130,
1007,
1063,
13075,
15384,
3993,
14277,
8988,
2015,
1027,
12935,
2497,
1012,
2440,
15069,
2015,
1012,
4949,
1006,
3853,
1006,
1060,
1007,
1063,
2709,
1060,
1012,
2000,
29547,
18992,
3366,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/main.js | watchPrefsForChanges | function watchPrefsForChanges() {
prefs.prefsObject.on("change", function (e, data) {
if (data.ids.indexOf("enabled") > -1) {
// Check if enabled state mismatches whether code-folding is actually initialized (can't assume
// since preference change events can occur when the value hasn't really changed)
var isEnabled = prefs.getSetting("enabled");
if (isEnabled && !_isInitialized) {
init();
} else if (!isEnabled && _isInitialized) {
deinit();
}
}
});
} | javascript | function watchPrefsForChanges() {
prefs.prefsObject.on("change", function (e, data) {
if (data.ids.indexOf("enabled") > -1) {
// Check if enabled state mismatches whether code-folding is actually initialized (can't assume
// since preference change events can occur when the value hasn't really changed)
var isEnabled = prefs.getSetting("enabled");
if (isEnabled && !_isInitialized) {
init();
} else if (!isEnabled && _isInitialized) {
deinit();
}
}
});
} | [
"function",
"watchPrefsForChanges",
"(",
")",
"{",
"prefs",
".",
"prefsObject",
".",
"on",
"(",
"\"change\"",
",",
"function",
"(",
"e",
",",
"data",
")",
"{",
"if",
"(",
"data",
".",
"ids",
".",
"indexOf",
"(",
"\"enabled\"",
")",
">",
"-",
"1",
")"... | Register change listener for the preferences file. | [
"Register",
"change",
"listener",
"for",
"the",
"preferences",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/main.js#L440-L453 | train | Watch for changes in preferences | [
30522,
3853,
3422,
28139,
10343,
29278,
22305,
2229,
1006,
1007,
1063,
3653,
10343,
1012,
3653,
10343,
16429,
20614,
1012,
2006,
1006,
1000,
2689,
1000,
1010,
3853,
1006,
1041,
30524,
1012,
5950,
11253,
1006,
1000,
9124,
1000,
1007,
1028,
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... |
SheetJS/js-xlsx | bits/78_writebiff.js | write_BIFF2LABEL | function write_BIFF2LABEL(r/*:number*/, c/*:number*/, val) {
var out = new_buf(8 + 2*val.length);
write_BIFF2Cell(out, r, c);
out.write_shift(1, val.length);
out.write_shift(val.length, val, 'sbcs');
return out.l < out.length ? out.slice(0, out.l) : out;
} | javascript | function write_BIFF2LABEL(r/*:number*/, c/*:number*/, val) {
var out = new_buf(8 + 2*val.length);
write_BIFF2Cell(out, r, c);
out.write_shift(1, val.length);
out.write_shift(val.length, val, 'sbcs');
return out.l < out.length ? out.slice(0, out.l) : out;
} | [
"function",
"write_BIFF2LABEL",
"(",
"r",
"/*:number*/",
",",
"c",
"/*:number*/",
",",
"val",
")",
"{",
"var",
"out",
"=",
"new_buf",
"(",
"8",
"+",
"2",
"*",
"val",
".",
"length",
")",
";",
"write_BIFF2Cell",
"(",
"out",
",",
"r",
",",
"c",
")",
"... | /* TODO: codepage, large strings | [
"/",
"*",
"TODO",
":",
"codepage",
"large",
"strings"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/78_writebiff.js#L29-L35 | train | write BIFF2 label | [
30522,
3853,
4339,
1035,
12170,
4246,
2475,
20470,
2884,
1006,
1054,
1013,
1008,
1024,
2193,
1008,
1013,
1010,
1039,
1013,
1008,
1024,
2193,
1008,
1013,
1010,
11748,
1007,
1063,
13075,
2041,
1027,
2047,
1035,
20934,
2546,
1006,
1022,
1009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-unmodified-loop-condition.js | getEncloseFunctionDeclaration | function getEncloseFunctionDeclaration(reference) {
let node = reference.identifier;
while (node) {
if (node.type === "FunctionDeclaration") {
return node.id ? node : null;
}
node = node.parent;
}
return null;
} | javascript | function getEncloseFunctionDeclaration(reference) {
let node = reference.identifier;
while (node) {
if (node.type === "FunctionDeclaration") {
return node.id ? node : null;
}
node = node.parent;
}
return null;
} | [
"function",
"getEncloseFunctionDeclaration",
"(",
"reference",
")",
"{",
"let",
"node",
"=",
"reference",
".",
"identifier",
";",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"\"FunctionDeclaration\"",
")",
"{",
"return",
"node",
".... | Gets the function which encloses a given reference.
This supports only FunctionDeclaration.
@param {eslint-scope.Reference} reference - A reference to get.
@returns {ASTNode|null} The function node or null. | [
"Gets",
"the",
"function",
"which",
"encloses",
"a",
"given",
"reference",
".",
"This",
"supports",
"only",
"FunctionDeclaration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unmodified-loop-condition.js#L115-L127 | train | Get the EnloseFunctionDeclaration node of a given reference | [
30522,
3853,
2131,
2368,
20464,
9232,
11263,
27989,
3207,
20464,
25879,
3258,
1006,
4431,
1007,
1063,
2292,
13045,
1027,
4431,
1012,
8909,
4765,
18095,
1025,
2096,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
2828,
1027,
1027,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_BLOB | function parse_BLOB(blob) {
var size = blob.read_shift(4);
var bytes = blob.slice(blob.l,blob.l+size);
blob.l += size;
if((size & 3) > 0) blob.l += (4 - (size & 3)) & 3;
return bytes;
} | javascript | function parse_BLOB(blob) {
var size = blob.read_shift(4);
var bytes = blob.slice(blob.l,blob.l+size);
blob.l += size;
if((size & 3) > 0) blob.l += (4 - (size & 3)) & 3;
return bytes;
} | [
"function",
"parse_BLOB",
"(",
"blob",
")",
"{",
"var",
"size",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"var",
"bytes",
"=",
"blob",
".",
"slice",
"(",
"blob",
".",
"l",
",",
"blob",
".",
"l",
"+",
"size",
")",
";",
"blob",
".",
"l"... | /* [MS-OLEPS] 2.9 BLOB | [
"/",
"*",
"[",
"MS",
"-",
"OLEPS",
"]",
"2",
".",
"9",
"BLOB"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5060-L5066 | train | Parse a BLOB | [
30522,
3853,
11968,
3366,
1035,
1038,
4135,
2497,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
2946,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1018,
1007,
1025,
13075,
27507,
1027,
1038,
4135,
2497,
1012,
14704,
1006,
1038,
4135,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/extensions/mark/mark.js | getHelper | function getHelper() {
let helper;
if (editor.isViewer()) {
helper = vmh;
} else if (editor.isWysiwygMode()) {
helper = wmh;
} else {
helper = mmh;
}
return helper;
} | javascript | function getHelper() {
let helper;
if (editor.isViewer()) {
helper = vmh;
} else if (editor.isWysiwygMode()) {
helper = wmh;
} else {
helper = mmh;
}
return helper;
} | [
"function",
"getHelper",
"(",
")",
"{",
"let",
"helper",
";",
"if",
"(",
"editor",
".",
"isViewer",
"(",
")",
")",
"{",
"helper",
"=",
"vmh",
";",
"}",
"else",
"if",
"(",
"editor",
".",
"isWysiwygMode",
"(",
")",
")",
"{",
"helper",
"=",
"wmh",
"... | getHelper
Get helper for current situation
@returns {object} helper | [
"getHelper",
"Get",
"helper",
"for",
"current",
"situation"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/mark/mark.js#L42-L54 | train | Get helper function | [
30522,
3853,
2131,
16001,
4842,
1006,
1007,
1063,
2292,
2393,
2121,
1025,
2065,
1006,
3559,
1012,
2003,
8584,
2121,
1006,
1007,
1007,
1063,
2393,
2121,
1027,
1058,
2213,
2232,
1025,
1065,
2842,
2065,
1006,
3559,
1012,
2003,
18418,
5332,
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... |
TryGhost/Ghost | core/server/models/plugins/collision.js | save | function save(data) {
this.clientData = _.cloneDeep(data) || {};
this.serverData = _.cloneDeep(this.attributes);
return ParentModel.prototype.save.apply(this, arguments);
} | javascript | function save(data) {
this.clientData = _.cloneDeep(data) || {};
this.serverData = _.cloneDeep(this.attributes);
return ParentModel.prototype.save.apply(this, arguments);
} | [
"function",
"save",
"(",
"data",
")",
"{",
"this",
".",
"clientData",
"=",
"_",
".",
"cloneDeep",
"(",
"data",
")",
"||",
"{",
"}",
";",
"this",
".",
"serverData",
"=",
"_",
".",
"cloneDeep",
"(",
"this",
".",
"attributes",
")",
";",
"return",
"Par... | We have to remember current server data and client data.
The `sync` method has no access to it.
`updated_at` is already set to "Date.now" when the overridden `sync.update` is called.
See https://github.com/tgriesser/bookshelf/blob/79c526870e618748caf94e7476a0bc796ee090a6/src/model.js#L955 | [
"We",
"have",
"to",
"remember",
"current",
"server",
"data",
"and",
"client",
"data",
".",
"The",
"sync",
"method",
"has",
"no",
"access",
"to",
"it",
".",
"updated_at",
"is",
"already",
"set",
"to",
"Date",
".",
"now",
"when",
"the",
"overridden",
"sync... | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/plugins/collision.js#L87-L92 | train | Save the client data and server data | [
30522,
3853,
3828,
1006,
2951,
1007,
1063,
2023,
1012,
7396,
2850,
2696,
1027,
1035,
1012,
17598,
26095,
2361,
1006,
2951,
1007,
1064,
1064,
1063,
1065,
1025,
2023,
1012,
8241,
2850,
2696,
1027,
1035,
1012,
17598,
26095,
2361,
1006,
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... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(options) {
var doc = node.ownerDocument,
nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {
wysihtml5.dom.insert(doc.createElement("br")).after(node);
}
if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {
wysihtml5.dom.insert(doc.createElement("br")).before(node);
}
} | javascript | function(options) {
var doc = node.ownerDocument,
nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {
wysihtml5.dom.insert(doc.createElement("br")).after(node);
}
if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {
wysihtml5.dom.insert(doc.createElement("br")).before(node);
}
} | [
"function",
"(",
"options",
")",
"{",
"var",
"doc",
"=",
"node",
".",
"ownerDocument",
",",
"nextSibling",
"=",
"wysihtml5",
".",
"dom",
".",
"domNode",
"(",
"node",
")",
".",
"next",
"(",
"{",
"ignoreBlankTexts",
":",
"true",
"}",
")",
",",
"previousS... | /* wysihtml5.dom.lineBreaks(element).add();
Adds line breaks before and after the given node if the previous and next siblings
aren't already causing a visual line break (block element or <br>) | [
"/",
"*",
"wysihtml5",
".",
"dom",
".",
"lineBreaks",
"(",
"element",
")",
".",
"add",
"()",
";"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L5729-L5740 | train | This function is called by the dom. dom to create a new element | [
30522,
3853,
1006,
7047,
1007,
1063,
13075,
9986,
1027,
13045,
1012,
3954,
3527,
24894,
4765,
1010,
2279,
5332,
9709,
1027,
1059,
7274,
19190,
21246,
2140,
2629,
1012,
14383,
1012,
14383,
3630,
3207,
1006,
13045,
1007,
1012,
2279,
1006,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | docs/guides/component/_name_/_name_.js | _name_listDirective | function _name_listDirective() {
return {
scope: {},
require: [],
controller: _name_listController,
link: postLink
};
function postLink(scope, element, attr, ctrls) {
}
} | javascript | function _name_listDirective() {
return {
scope: {},
require: [],
controller: _name_listController,
link: postLink
};
function postLink(scope, element, attr, ctrls) {
}
} | [
"function",
"_name_listDirective",
"(",
")",
"{",
"return",
"{",
"scope",
":",
"{",
"}",
",",
"require",
":",
"[",
"]",
",",
"controller",
":",
"_name_listController",
",",
"link",
":",
"postLink",
"}",
";",
"function",
"postLink",
"(",
"scope",
",",
"el... | @ngdoc directive
@name md_name_list
@module material.components._name_list
@restrict E
@description
@usage | [
"@ngdoc",
"directive",
"@name",
"md_name_list",
"@module",
"material",
".",
"components",
".",
"_name_list",
"@restrict",
"E",
"@description"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/guides/component/_name_/_name_.js#L21-L32 | train | The name list directive | [
30522,
3853,
1035,
2171,
1035,
2862,
4305,
2890,
15277,
1006,
1007,
1063,
2709,
1063,
9531,
1024,
1063,
1065,
1010,
5478,
1024,
1031,
1033,
1010,
11486,
1024,
1035,
2171,
1035,
2862,
8663,
13181,
10820,
1010,
4957,
1024,
2695,
13767,
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... |
angular/material | src/components/dialog/dialog.js | onShow | function onShow(scope, element, options, controller) {
angular.element($document[0].body).addClass('md-dialog-is-showing');
var dialogElement = element.find('md-dialog');
// Once a dialog has `ng-cloak` applied on his template the dialog animation will not work properly.
// This is a very common problem, so we have to notify the developer about this.
if (dialogElement.hasClass('ng-cloak')) {
var message = '$mdDialog: using `<md-dialog ng-cloak>` will affect the dialog opening animations.';
$log.warn(message, element[0]);
}
captureParentAndFromToElements(options);
configureAria(dialogElement, options);
showBackdrop(scope, element, options);
activateListeners(element, options);
return dialogPopIn(element, options)
.then(function() {
lockScreenReader(element, options);
warnDeprecatedActions();
focusOnOpen();
});
/**
* Check to see if they used the deprecated .md-actions class and log a warning
*/
function warnDeprecatedActions() {
if (element[0].querySelector('.md-actions')) {
$log.warn('Using a class of md-actions is deprecated, please use <md-dialog-actions>.');
}
}
/**
* For alerts, focus on content... otherwise focus on
* the close button (or equivalent)
*/
function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
}
} | javascript | function onShow(scope, element, options, controller) {
angular.element($document[0].body).addClass('md-dialog-is-showing');
var dialogElement = element.find('md-dialog');
// Once a dialog has `ng-cloak` applied on his template the dialog animation will not work properly.
// This is a very common problem, so we have to notify the developer about this.
if (dialogElement.hasClass('ng-cloak')) {
var message = '$mdDialog: using `<md-dialog ng-cloak>` will affect the dialog opening animations.';
$log.warn(message, element[0]);
}
captureParentAndFromToElements(options);
configureAria(dialogElement, options);
showBackdrop(scope, element, options);
activateListeners(element, options);
return dialogPopIn(element, options)
.then(function() {
lockScreenReader(element, options);
warnDeprecatedActions();
focusOnOpen();
});
/**
* Check to see if they used the deprecated .md-actions class and log a warning
*/
function warnDeprecatedActions() {
if (element[0].querySelector('.md-actions')) {
$log.warn('Using a class of md-actions is deprecated, please use <md-dialog-actions>.');
}
}
/**
* For alerts, focus on content... otherwise focus on
* the close button (or equivalent)
*/
function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
}
} | [
"function",
"onShow",
"(",
"scope",
",",
"element",
",",
"options",
",",
"controller",
")",
"{",
"angular",
".",
"element",
"(",
"$document",
"[",
"0",
"]",
".",
"body",
")",
".",
"addClass",
"(",
"'md-dialog-is-showing'",
")",
";",
"var",
"dialogElement",... | Show method for dialogs | [
"Show",
"method",
"for",
"dialogs"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L748-L801 | train | Show the dialog. | [
30522,
3853,
2006,
22231,
2860,
1006,
9531,
1010,
5783,
1010,
7047,
1010,
11486,
1007,
1063,
16108,
1012,
5783,
1006,
1002,
6254,
1031,
1014,
1033,
1012,
2303,
1007,
1012,
5587,
26266,
1006,
1005,
9108,
1011,
13764,
8649,
1011,
2003,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObject.js | addAllToAggregation | function addAllToAggregation(aObjects) {
for (var i = 0, len = aObjects.length; i < len; i++) {
var vObject = aObjects[i];
if ( Array.isArray(vObject) ) {
addAllToAggregation(vObject);
} else {
that[oKeyInfo._sMutator](makeObject(vObject, oKeyInfo, oScope));
}
}
} | javascript | function addAllToAggregation(aObjects) {
for (var i = 0, len = aObjects.length; i < len; i++) {
var vObject = aObjects[i];
if ( Array.isArray(vObject) ) {
addAllToAggregation(vObject);
} else {
that[oKeyInfo._sMutator](makeObject(vObject, oKeyInfo, oScope));
}
}
} | [
"function",
"addAllToAggregation",
"(",
"aObjects",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"aObjects",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"vObject",
"=",
"aObjects",
"[",
"i",
"]",
";",
"if... | add all given objects to the given aggregation. nested arrays are flattened (might occur e.g. in case of content from an extension point) | [
"add",
"all",
"given",
"objects",
"to",
"the",
"given",
"aggregation",
".",
"nested",
"arrays",
"are",
"flattened",
"(",
"might",
"occur",
"e",
".",
"g",
".",
"in",
"case",
"of",
"content",
"from",
"an",
"extension",
"point",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObject.js#L1082-L1091 | train | Adds all objects to the aggregation | [
30522,
3853,
5587,
8095,
3406,
8490,
17603,
12540,
1006,
20118,
2497,
20614,
2015,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
18798,
1027,
20118,
2497,
20614,
2015,
1012,
3091,
1025,
1045,
1026,
18798,
1025,
1045,
1009,
1009,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.