repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function(elem, callback, errback, timeout) {
var timeoutHandler = null;
var that = this;
if (typeof(elem.tree) === "function") {
elem = elem.tree();
}
var id = elem.getAttribute('id');
// inject id if not found
if (!id) {
id = this.getUniqueId("sendIQ");
elem.setAttribute("id", id);
}
var expectedFrom = elem.getAttribute("to");
var fulljid = this.jid;
var handler = this.addHandler(function (stanza) {
// remove timeout handler if there is one
if (timeoutHandler) {
that.deleteTimedHandler(timeoutHandler);
}
var acceptable = false;
var from = stanza.getAttribute("from");
if (from === expectedFrom ||
(expectedFrom === null &&
(from === Strophe.getBareJidFromJid(fulljid) ||
from === Strophe.getDomainFromJid(fulljid) ||
from === fulljid))) {
acceptable = true;
}
if (!acceptable) {
throw {
name: "StropheError",
message: "Got answer to IQ from wrong jid:" + from +
"\nExpected jid: " + expectedFrom
};
}
var iqtype = stanza.getAttribute('type');
if (iqtype == 'result') {
if (callback) {
callback(stanza);
}
} else if (iqtype == 'error') {
if (errback) {
errback(stanza);
}
} else {
throw {
name: "StropheError",
message: "Got bad IQ type of " + iqtype
};
}
}, null, 'iq', ['error', 'result'], id);
// if timeout specified, setup timeout handler.
if (timeout) {
timeoutHandler = this.addTimedHandler(timeout, function () {
// get rid of normal handler
that.deleteHandler(handler);
// call errback on timeout with null stanza
if (errback) {
errback(null);
}
return false;
});
}
this.send(elem);
return id;
} | javascript | function(elem, callback, errback, timeout) {
var timeoutHandler = null;
var that = this;
if (typeof(elem.tree) === "function") {
elem = elem.tree();
}
var id = elem.getAttribute('id');
// inject id if not found
if (!id) {
id = this.getUniqueId("sendIQ");
elem.setAttribute("id", id);
}
var expectedFrom = elem.getAttribute("to");
var fulljid = this.jid;
var handler = this.addHandler(function (stanza) {
// remove timeout handler if there is one
if (timeoutHandler) {
that.deleteTimedHandler(timeoutHandler);
}
var acceptable = false;
var from = stanza.getAttribute("from");
if (from === expectedFrom ||
(expectedFrom === null &&
(from === Strophe.getBareJidFromJid(fulljid) ||
from === Strophe.getDomainFromJid(fulljid) ||
from === fulljid))) {
acceptable = true;
}
if (!acceptable) {
throw {
name: "StropheError",
message: "Got answer to IQ from wrong jid:" + from +
"\nExpected jid: " + expectedFrom
};
}
var iqtype = stanza.getAttribute('type');
if (iqtype == 'result') {
if (callback) {
callback(stanza);
}
} else if (iqtype == 'error') {
if (errback) {
errback(stanza);
}
} else {
throw {
name: "StropheError",
message: "Got bad IQ type of " + iqtype
};
}
}, null, 'iq', ['error', 'result'], id);
// if timeout specified, setup timeout handler.
if (timeout) {
timeoutHandler = this.addTimedHandler(timeout, function () {
// get rid of normal handler
that.deleteHandler(handler);
// call errback on timeout with null stanza
if (errback) {
errback(null);
}
return false;
});
}
this.send(elem);
return id;
} | [
"function",
"(",
"elem",
",",
"callback",
",",
"errback",
",",
"timeout",
")",
"{",
"var",
"timeoutHandler",
"=",
"null",
";",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"typeof",
"(",
"elem",
".",
"tree",
")",
"===",
"\"function\"",
")",
"{",
"elem... | Function: sendIQ
Helper function to send IQ stanzas.
Parameters:
(XMLElement) elem - The stanza to send.
(Function) callback - The callback function for a successful request.
(Function) errback - The callback function for a failed or timed
out request. On timeout, the stanza will be null.
(Integer) timeout - The time specified in milliseconds for a
timeout to occur.
Returns:
The id used to send the IQ. | [
"Function",
":",
"sendIQ",
"Helper",
"function",
"to",
"send",
"IQ",
"stanzas",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L2460-L2533 | train | Send an IQ | [
30522,
3853,
1006,
3449,
6633,
1010,
2655,
5963,
1010,
30524,
2051,
17167,
5685,
3917,
1027,
19701,
1025,
13075,
2008,
1027,
2023,
1025,
2065,
1006,
2828,
11253,
1006,
3449,
6633,
1012,
3392,
1007,
1027,
1027,
1027,
1000,
3853,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/services/registry/componentRegistry.js | resolveWhen | function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
} | javascript | function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
} | [
"function",
"resolveWhen",
"(",
")",
"{",
"var",
"dfd",
"=",
"pendings",
"[",
"handle",
"]",
";",
"if",
"(",
"dfd",
")",
"{",
"dfd",
".",
"forEach",
"(",
"function",
"(",
"promise",
")",
"{",
"promise",
".",
"resolve",
"(",
"instance",
")",
";",
"}... | Resolve any pending promises for this instance | [
"Resolve",
"any",
"pending",
"promises",
"for",
"this",
"instance"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L83-L91 | train | resolve when the handle is not in pendings | [
30522,
3853,
10663,
2860,
10222,
1006,
1007,
1063,
13075,
1040,
2546,
2094,
1027,
14223,
2015,
1031,
5047,
1033,
1025,
2065,
1006,
1040,
2546,
2094,
1007,
1063,
1040,
2546,
2094,
1012,
18921,
6776,
1006,
3853,
1006,
4872,
1007,
1063,
4872,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/transform-apijson-for-sdk.js | function (target) {
var result = "";
if (target) {
target.forEach(function (element) {
result += element + '<br>';
});
}
result = this._preProcessLinksInTextBlock(result);
return result;
} | javascript | function (target) {
var result = "";
if (target) {
target.forEach(function (element) {
result += element + '<br>';
});
}
result = this._preProcessLinksInTextBlock(result);
return result;
} | [
"function",
"(",
"target",
")",
"{",
"var",
"result",
"=",
"\"\"",
";",
"if",
"(",
"target",
")",
"{",
"target",
".",
"forEach",
"(",
"function",
"(",
"element",
")",
"{",
"result",
"+=",
"element",
"+",
"'<br>'",
";",
"}",
")",
";",
"}",
"result",... | Formats the target and applies to texts of annotations
@param target - the array of texts to be formatted
@returns string - the formatted text | [
"Formats",
"the",
"target",
"and",
"applies",
"to",
"texts",
"of",
"annotations"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L968-L979 | train | Returns a string containing the links in the target text block | [
30522,
3853,
1006,
4539,
1007,
1063,
13075,
2765,
1027,
1000,
1000,
1025,
2065,
1006,
4539,
1007,
1063,
4539,
1012,
18921,
6776,
1006,
3853,
1006,
5783,
1007,
1063,
2765,
1009,
1027,
5783,
1009,
1005,
1026,
7987,
1028,
1005,
1025,
1065,
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/animation.js | function () {
this.updateConfig();
this.animation.began = true;
this.time = 0;
this.animationIsPlaying = true;
this.stopRelatedAnimations();
this.el.emit('animationbegin', this.eventDetail, false);
} | javascript | function () {
this.updateConfig();
this.animation.began = true;
this.time = 0;
this.animationIsPlaying = true;
this.stopRelatedAnimations();
this.el.emit('animationbegin', this.eventDetail, false);
} | [
"function",
"(",
")",
"{",
"this",
".",
"updateConfig",
"(",
")",
";",
"this",
".",
"animation",
".",
"began",
"=",
"true",
";",
"this",
".",
"time",
"=",
"0",
";",
"this",
".",
"animationIsPlaying",
"=",
"true",
";",
"this",
".",
"stopRelatedAnimation... | This is before animation start (including from startEvents).
Set to initial state (config.from, time = 0, seekTime = 0). | [
"This",
"is",
"before",
"animation",
"start",
"(",
"including",
"from",
"startEvents",
")",
".",
"Set",
"to",
"initial",
"state",
"(",
"config",
".",
"from",
"time",
"=",
"0",
"seekTime",
"=",
"0",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L190-L197 | train | Animation begin | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
10651,
8663,
8873,
2290,
1006,
1007,
1025,
2023,
1012,
7284,
1012,
2211,
1027,
2995,
1025,
2023,
1012,
2051,
1027,
1014,
1025,
2023,
1012,
7284,
2483,
13068,
2075,
1027,
2995,
1025,
2023,
1012,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | mxWindow | function mxWindow(title, content, x, y, width, height, minimizable, movable, replaceNode, style)
{
if (content != null)
{
minimizable = (minimizable != null) ? minimizable : true;
this.content = content;
this.init(x, y, width, height, style);
this.installMaximizeHandler();
this.installMinimizeHandler();
this.installCloseHandler();
this.setMinimizable(minimizable);
this.setTitle(title);
if (movable == null || movable)
{
this.installMoveHandler();
}
if (replaceNode != null && replaceNode.parentNode != null)
{
replaceNode.parentNode.replaceChild(this.div, replaceNode);
}
else
{
document.body.appendChild(this.div);
}
}
} | javascript | function mxWindow(title, content, x, y, width, height, minimizable, movable, replaceNode, style)
{
if (content != null)
{
minimizable = (minimizable != null) ? minimizable : true;
this.content = content;
this.init(x, y, width, height, style);
this.installMaximizeHandler();
this.installMinimizeHandler();
this.installCloseHandler();
this.setMinimizable(minimizable);
this.setTitle(title);
if (movable == null || movable)
{
this.installMoveHandler();
}
if (replaceNode != null && replaceNode.parentNode != null)
{
replaceNode.parentNode.replaceChild(this.div, replaceNode);
}
else
{
document.body.appendChild(this.div);
}
}
} | [
"function",
"mxWindow",
"(",
"title",
",",
"content",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"minimizable",
",",
"movable",
",",
"replaceNode",
",",
"style",
")",
"{",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"minimizable",
"=",
"... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxWindow
Basic window inside a document.
Examples:
Creating a simple window.
(code)
var tb = document.createElement('div');
var wnd = new mxWindow('Title', tb, 100, 100, 200, 200, true, true);
wnd.setVisible(true);
(end)
Creating a window that contains an iframe.
(code)
var frame = document.createElement('iframe');
frame.setAttribute('width', '192px');
frame.setAttribute('height', '172px');
frame.setAttribute('src', 'http://www.example.com/');
frame.style.backgroundColor = 'white';
var w = document.body.clientWidth;
var h = (document.body.clientHeight || document.documentElement.clientHeight);
var wnd = new mxWindow('Title', frame, (w-200)/2, (h-200)/3, 200, 200);
wnd.setVisible(true);
(end)
To limit the movement of a window, eg. to keep it from being moved beyond
the top, left corner the following method can be overridden (recommended):
(code)
wnd.setLocation = function(x, y)
{
x = Math.max(0, x);
y = Math.max(0, y);
mxWindow.prototype.setLocation.apply(this, arguments);
};
(end)
Or the following event handler can be used:
(code)
wnd.addListener(mxEvent.MOVE, function(e)
{
wnd.setLocation(Math.max(0, wnd.getX()), Math.max(0, wnd.getY()));
});
(end)
To keep a window inside the current window:
(code)
mxEvent.addListener(window, 'resize', mxUtils.bind(this, function()
{
var iw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var ih = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var x = this.window.getX();
var y = this.window.getY();
if (x + this.window.table.clientWidth > iw)
{
x = Math.max(0, iw - this.window.table.clientWidth);
}
if (y + this.window.table.clientHeight > ih)
{
y = Math.max(0, ih - this.window.table.clientHeight);
}
if (this.window.getX() != x || this.window.getY() != y)
{
this.window.setLocation(x, y);
}
}));
(end)
Event: mxEvent.MOVE_START
Fires before the window is moved. The <code>event</code> property contains
the corresponding mouse event.
Event: mxEvent.MOVE
Fires while the window is being moved. The <code>event</code> property
contains the corresponding mouse event.
Event: mxEvent.MOVE_END
Fires after the window is moved. The <code>event</code> property contains
the corresponding mouse event.
Event: mxEvent.RESIZE_START
Fires before the window is resized. The <code>event</code> property contains
the corresponding mouse event.
Event: mxEvent.RESIZE
Fires while the window is being resized. The <code>event</code> property
contains the corresponding mouse event.
Event: mxEvent.RESIZE_END
Fires after the window is resized. The <code>event</code> property contains
the corresponding mouse event.
Event: mxEvent.MAXIMIZE
Fires after the window is maximized. The <code>event</code> property
contains the corresponding mouse event.
Event: mxEvent.MINIMIZE
Fires after the window is minimized. The <code>event</code> property
contains the corresponding mouse event.
Event: mxEvent.NORMALIZE
Fires after the window is normalized, that is, it returned from
maximized or minimized state. The <code>event</code> property contains the
corresponding mouse event.
Event: mxEvent.ACTIVATE
Fires after a window is activated. The <code>previousWindow</code> property
contains the previous window. The event sender is the active window.
Event: mxEvent.SHOW
Fires after the window is shown. This event has no properties.
Event: mxEvent.HIDE
Fires after the window is hidden. This event has no properties.
Event: mxEvent.CLOSE
Fires before the window is closed. The <code>event</code> property contains
the corresponding mouse event.
Event: mxEvent.DESTROY
Fires before the window is destroyed. This event has no properties.
Constructor: mxWindow
Constructs a new window with the given dimension and title to display
the specified content. The window elements use the given style as a
prefix for the classnames of the respective window elements, namely,
the window title and window pane. The respective postfixes are appended
to the given stylename as follows:
style - Base style for the window.
style+Title - Style for the window title.
style+Pane - Style for the window pane.
The default value for style is mxWindow, resulting in the following
classnames for the window elements: mxWindow, mxWindowTitle and
mxWindowPane.
If replaceNode is given then the window replaces the given DOM node in
the document.
Parameters:
title - String that represents the title of the new window.
content - DOM node that is used as the window content.
x - X-coordinate of the window location.
y - Y-coordinate of the window location.
width - Width of the window.
height - Optional height of the window. Default is to match the height
of the content at the specified width.
minimizable - Optional boolean indicating if the window is minimizable.
Default is true.
movable - Optional boolean indicating if the window is movable. Default
is true.
replaceNode - Optional DOM node that the window should replace.
style - Optional base classname for the window elements. Default is
mxWindow. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxWindow"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L11657-L11685 | train | A wrapper around the window constructor. | [
30522,
3853,
25630,
11101,
5004,
1006,
2516,
1010,
4180,
1010,
1060,
1010,
1061,
1010,
9381,
1010,
4578,
1010,
7163,
4328,
4143,
3468,
1010,
9587,
12423,
1010,
5672,
3630,
3207,
1010,
2806,
1007,
1063,
2065,
1006,
4180,
999,
1027,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/UnitMixin.js | parseValue | function parseValue(vValue, sSourceType, aCurrentValues) {
var iDecimals, iFractionDigits, aMatches, sUnit, aValues;
if (this.mCustomUnits === undefined) {
throw new ParseException("Cannot parse value without customizing");
}
aValues = fnBaseType.prototype.parseValue.apply(this, arguments);
sUnit = aValues[1] || aCurrentValues[1];
// remove trailing decimal zeroes and separator
if (aValues[0].includes(".")) {
aValues[0] = aValues[0].replace(rTrailingZeros, "").replace(rSeparator, "");
}
if (sUnit && this.mCustomUnits) {
aMatches = rDecimals.exec(aValues[0]);
iFractionDigits = aMatches ? aMatches[1].length : 0;
// If the unit is not in mCustomUnits, the base class throws a ParseException.
iDecimals = this.mCustomUnits[sUnit].decimals;
if (iFractionDigits > iDecimals) {
throw new ParseException(iDecimals
? getText("EnterNumberFraction", [iDecimals])
: getText("EnterInt"));
}
}
if (!this.bParseAsString) {
aValues[0] = Number(aValues[0]);
}
return aValues;
} | javascript | function parseValue(vValue, sSourceType, aCurrentValues) {
var iDecimals, iFractionDigits, aMatches, sUnit, aValues;
if (this.mCustomUnits === undefined) {
throw new ParseException("Cannot parse value without customizing");
}
aValues = fnBaseType.prototype.parseValue.apply(this, arguments);
sUnit = aValues[1] || aCurrentValues[1];
// remove trailing decimal zeroes and separator
if (aValues[0].includes(".")) {
aValues[0] = aValues[0].replace(rTrailingZeros, "").replace(rSeparator, "");
}
if (sUnit && this.mCustomUnits) {
aMatches = rDecimals.exec(aValues[0]);
iFractionDigits = aMatches ? aMatches[1].length : 0;
// If the unit is not in mCustomUnits, the base class throws a ParseException.
iDecimals = this.mCustomUnits[sUnit].decimals;
if (iFractionDigits > iDecimals) {
throw new ParseException(iDecimals
? getText("EnterNumberFraction", [iDecimals])
: getText("EnterInt"));
}
}
if (!this.bParseAsString) {
aValues[0] = Number(aValues[0]);
}
return aValues;
} | [
"function",
"parseValue",
"(",
"vValue",
",",
"sSourceType",
",",
"aCurrentValues",
")",
"{",
"var",
"iDecimals",
",",
"iFractionDigits",
",",
"aMatches",
",",
"sUnit",
",",
"aValues",
";",
"if",
"(",
"this",
".",
"mCustomUnits",
"===",
"undefined",
")",
"{"... | Parses the given string value to an array containing measure or amount, and unit or
currency.
@param {string} vValue
The value to be parsed
@param {string} sSourceType
The source type (the expected type of <code>vValue</code>); must be "string", or a type
with "string" as its
{@link sap.ui.base.DataType#getPrimitiveType primitive type}.
See {@link sap.ui.model.odata.type} for more information.
@param {any[]} aCurrentValues
The current values of all binding parts
@returns {any[]}
An array containing measure or amount, and unit or currency in this order. Measure or
amount, and unit or currency, are string values unless the format option
<code>parseAsString</code> is <code>false</code>; in this case, the measure or amount
is a number.
@throws {sap.ui.model.ParseException}
If {@link #formatValue} has not yet been called with a customizing part or
if <code>sSourceType</code> is unsupported or if the given string cannot be parsed
@function
@name sap.ui.model.odata.type.UnitMixin#parseValue
@public
@see sap.ui.model.type.Unit#parseValue
@since 1.63.0 | [
"Parses",
"the",
"given",
"string",
"value",
"to",
"an",
"array",
"containing",
"measure",
"or",
"amount",
"and",
"unit",
"or",
"currency",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/UnitMixin.js#L181-L210 | train | Parse a value | [
30522,
3853,
11968,
3366,
10175,
5657,
1006,
1058,
10175,
5657,
1010,
7020,
8162,
3401,
13874,
1010,
9353,
29264,
10175,
15808,
1007,
1063,
13075,
8909,
8586,
9581,
4877,
1010,
2065,
25533,
4305,
23806,
2015,
1010,
25933,
10649,
2229,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oType) {
if (oType.property) {
oType.property.forEach(function (oProperty) {
var aAnnotationParts,
bIsCollection,
aMatches,
sSubStructure,
vTmp,
sV2Semantics = oProperty["sap:semantics"],
sV4Annotation,
sV4AnnotationPath,
oV4Annotation,
oV4TypeInfo,
sV4TypeList;
if (!sV2Semantics) {
return;
}
if (sV2Semantics === "url") {
oProperty["Org.OData.Core.V1.IsURL"] = oBoolTrue;
return;
}
if (sV2Semantics in mDatePartSemantics2CommonTerm) {
sV4Annotation = "com.sap.vocabularies.Common.v1."
+ mDatePartSemantics2CommonTerm[sV2Semantics];
oProperty[sV4Annotation] = oBoolTrue;
return;
}
aMatches = rSemanticsWithTypes.exec(sV2Semantics);
if (!aMatches) {
if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Unsupported sap:semantics: " + sV2Semantics,
oType.name + "." + oProperty.name, sLoggingModule);
}
return;
}
if (aMatches[2]) {
sV2Semantics = aMatches[1];
sV4TypeList = Utils.getV4TypesForV2Semantics(sV2Semantics, aMatches[2],
oProperty, oType);
}
oV4TypeInfo = mV2SemanticsToV4TypeInfo[sV2Semantics];
bIsCollection = sV2Semantics === "tel" || sV2Semantics === "email";
sV4AnnotationPath = mSemanticsToV4AnnotationPath[sV2Semantics];
if (sV4AnnotationPath) {
aAnnotationParts = sV4AnnotationPath.split("/");
sV4Annotation = "com.sap.vocabularies.Communication.v1."
+ aAnnotationParts[0];
oType[sV4Annotation] = oType[sV4Annotation] || {};
oV4Annotation = oType[sV4Annotation];
sSubStructure = aAnnotationParts[1];
if (sSubStructure) {
oV4Annotation[sSubStructure] = oV4Annotation[sSubStructure] ||
(bIsCollection ? [] : {});
if (bIsCollection) {
vTmp = {};
oV4Annotation[sSubStructure].push(vTmp);
oV4Annotation = vTmp;
} else {
oV4Annotation = oV4Annotation[sSubStructure];
}
}
oV4Annotation[mV2ToV4Attribute[sV2Semantics] || sV2Semantics]
= { "Path" : oProperty.name };
if (sV4TypeList) {
// set also type attribute
oV4Annotation.type = { "EnumMember" : sV4TypeList };
}
}
// Additional annotation at the property with sap:semantics "tel" or "email";
// ensure not to overwrite existing V4 annotations
if (oV4TypeInfo) {
oProperty[oV4TypeInfo.v4PropertyAnnotation] =
oProperty[oV4TypeInfo.v4PropertyAnnotation] || oBoolTrue;
}
});
}
} | javascript | function (oType) {
if (oType.property) {
oType.property.forEach(function (oProperty) {
var aAnnotationParts,
bIsCollection,
aMatches,
sSubStructure,
vTmp,
sV2Semantics = oProperty["sap:semantics"],
sV4Annotation,
sV4AnnotationPath,
oV4Annotation,
oV4TypeInfo,
sV4TypeList;
if (!sV2Semantics) {
return;
}
if (sV2Semantics === "url") {
oProperty["Org.OData.Core.V1.IsURL"] = oBoolTrue;
return;
}
if (sV2Semantics in mDatePartSemantics2CommonTerm) {
sV4Annotation = "com.sap.vocabularies.Common.v1."
+ mDatePartSemantics2CommonTerm[sV2Semantics];
oProperty[sV4Annotation] = oBoolTrue;
return;
}
aMatches = rSemanticsWithTypes.exec(sV2Semantics);
if (!aMatches) {
if (Log.isLoggable(iWARNING, sLoggingModule)) {
Log.warning("Unsupported sap:semantics: " + sV2Semantics,
oType.name + "." + oProperty.name, sLoggingModule);
}
return;
}
if (aMatches[2]) {
sV2Semantics = aMatches[1];
sV4TypeList = Utils.getV4TypesForV2Semantics(sV2Semantics, aMatches[2],
oProperty, oType);
}
oV4TypeInfo = mV2SemanticsToV4TypeInfo[sV2Semantics];
bIsCollection = sV2Semantics === "tel" || sV2Semantics === "email";
sV4AnnotationPath = mSemanticsToV4AnnotationPath[sV2Semantics];
if (sV4AnnotationPath) {
aAnnotationParts = sV4AnnotationPath.split("/");
sV4Annotation = "com.sap.vocabularies.Communication.v1."
+ aAnnotationParts[0];
oType[sV4Annotation] = oType[sV4Annotation] || {};
oV4Annotation = oType[sV4Annotation];
sSubStructure = aAnnotationParts[1];
if (sSubStructure) {
oV4Annotation[sSubStructure] = oV4Annotation[sSubStructure] ||
(bIsCollection ? [] : {});
if (bIsCollection) {
vTmp = {};
oV4Annotation[sSubStructure].push(vTmp);
oV4Annotation = vTmp;
} else {
oV4Annotation = oV4Annotation[sSubStructure];
}
}
oV4Annotation[mV2ToV4Attribute[sV2Semantics] || sV2Semantics]
= { "Path" : oProperty.name };
if (sV4TypeList) {
// set also type attribute
oV4Annotation.type = { "EnumMember" : sV4TypeList };
}
}
// Additional annotation at the property with sap:semantics "tel" or "email";
// ensure not to overwrite existing V4 annotations
if (oV4TypeInfo) {
oProperty[oV4TypeInfo.v4PropertyAnnotation] =
oProperty[oV4TypeInfo.v4PropertyAnnotation] || oBoolTrue;
}
});
}
} | [
"function",
"(",
"oType",
")",
"{",
"if",
"(",
"oType",
".",
"property",
")",
"{",
"oType",
".",
"property",
".",
"forEach",
"(",
"function",
"(",
"oProperty",
")",
"{",
"var",
"aAnnotationParts",
",",
"bIsCollection",
",",
"aMatches",
",",
"sSubStructure"... | Collects sap:semantics annotations of the given type's properties at the type.
@param {object} oType
the entity type or the complex type for which sap:semantics needs to be added | [
"Collects",
"sap",
":",
"semantics",
"annotations",
"of",
"the",
"given",
"type",
"s",
"properties",
"at",
"the",
"type",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L288-L369 | train | This function is called by the constructor to determine if the type is a valid Semantic Type | [
30522,
3853,
1006,
27178,
18863,
1007,
1063,
2065,
1006,
27178,
18863,
1012,
3200,
1007,
1063,
27178,
18863,
1012,
3200,
1012,
18921,
6776,
1006,
3853,
1006,
6728,
18981,
15010,
1007,
1063,
13075,
9779,
10695,
17287,
3508,
26950,
1010,
20377,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | watchPath | function watchPath(path, ignored) {
if (_watcherMap.hasOwnProperty(path)) {
return;
}
return _watcherImpl.watchPath(path, ignored, _watcherMap, _domainManager);
} | javascript | function watchPath(path, ignored) {
if (_watcherMap.hasOwnProperty(path)) {
return;
}
return _watcherImpl.watchPath(path, ignored, _watcherMap, _domainManager);
} | [
"function",
"watchPath",
"(",
"path",
",",
"ignored",
")",
"{",
"if",
"(",
"_watcherMap",
".",
"hasOwnProperty",
"(",
"path",
")",
")",
"{",
"return",
";",
"}",
"return",
"_watcherImpl",
".",
"watchPath",
"(",
"path",
",",
"ignored",
",",
"_watcherMap",
... | Watch a file or directory.
@param {string} path File or directory to watch.
@param {Array<string>} ignored List of entries to ignore during watching. | [
"Watch",
"a",
"file",
"or",
"directory",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/node/FileWatcherManager.js#L101-L106 | train | Watches a path | [
30522,
3853,
3422,
15069,
1006,
4130,
1010,
6439,
1007,
1063,
2065,
1006,
1035,
3422,
2121,
2863,
2361,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
4130,
1007,
1007,
1063,
2709,
1025,
1065,
2709,
1035,
3422,
11124,
8737,
2140,
1012,
3422,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js | createSearchConfig | function createSearchConfig(sFieldToSearch) {
var oConfig = {
fields: {},
expand: true
};
oConfig.fields[sFieldToSearch] = {};
return oConfig;
} | javascript | function createSearchConfig(sFieldToSearch) {
var oConfig = {
fields: {},
expand: true
};
oConfig.fields[sFieldToSearch] = {};
return oConfig;
} | [
"function",
"createSearchConfig",
"(",
"sFieldToSearch",
")",
"{",
"var",
"oConfig",
"=",
"{",
"fields",
":",
"{",
"}",
",",
"expand",
":",
"true",
"}",
";",
"oConfig",
".",
"fields",
"[",
"sFieldToSearch",
"]",
"=",
"{",
"}",
";",
"return",
"oConfig",
... | Create config for search of the lunr index
in the expected (by lunr lib) format
@param sFieldToSearch
@returns {{fields: {}, expand: boolean}} | [
"Create",
"config",
"for",
"search",
"of",
"the",
"lunr",
"index",
"in",
"the",
"expected",
"(",
"by",
"lunr",
"lib",
")",
"format"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L450-L458 | train | Creates a configuration object for a search query. | [
30522,
3853,
9005,
14644,
2818,
8663,
8873,
2290,
1006,
16420,
12891,
22282,
2906,
2818,
1007,
1063,
13075,
1051,
8663,
8873,
2290,
1027,
1063,
4249,
1024,
1063,
1065,
1010,
7818,
1024,
2995,
1065,
1025,
1051,
8663,
8873,
2290,
1012,
4249,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | bower_components/jquery/src/css.js | finalPropName | function finalPropName( name ) {
var ret = jQuery.cssProps[ name ];
if ( !ret ) {
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
}
return ret;
} | javascript | function finalPropName( name ) {
var ret = jQuery.cssProps[ name ];
if ( !ret ) {
ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name;
}
return ret;
} | [
"function",
"finalPropName",
"(",
"name",
")",
"{",
"var",
"ret",
"=",
"jQuery",
".",
"cssProps",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"ret",
"=",
"jQuery",
".",
"cssProps",
"[",
"name",
"]",
"=",
"vendorPropName",
"(",
"name",
"... | Return a property mapped along what jQuery.cssProps suggests or to a vendor prefixed property. | [
"Return",
"a",
"property",
"mapped",
"along",
"what",
"jQuery",
".",
"cssProps",
"suggests",
"or",
"to",
"a",
"vendor",
"prefixed",
"property",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery/src/css.js#L63-L69 | train | Returns the final CSS property name | [
30522,
3853,
2345,
21572,
2361,
18442,
1006,
2171,
1007,
1063,
13075,
2128,
2102,
1027,
1046,
4226,
2854,
1012,
20116,
13102,
18981,
2015,
1031,
2171,
1033,
1025,
2065,
1006,
999,
2128,
2102,
1007,
1063,
2128,
2102,
1027,
1046,
4226,
2854,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FocusHandler.js | function(sControlId, sRelatedControlId, oCore){
var oControl = sControlId ? oCore && oCore.byId(sControlId) : null;
if (oControl) {
var oRelatedControl = sRelatedControlId ? oCore.byId(sRelatedControlId) : null;
var oEvent = jQuery.Event("sapfocusleave");
oEvent.target = oControl.getDomRef();
oEvent.relatedControlId = oRelatedControl ? oRelatedControl.getId() : null;
oEvent.relatedControlFocusInfo = oRelatedControl ? oRelatedControl.getFocusInfo() : null;
//TODO: Cleanup the popup! The following is shit
var oControlUIArea = oControl.getUIArea();
var oUiArea = null;
if (oControlUIArea) {
oUiArea = oCore.getUIArea(oControlUIArea.getId());
} else {
var oPopupUIAreaDomRef = oCore.getStaticAreaRef();
if (containsOrEquals(oPopupUIAreaDomRef, oEvent.target)) {
oUiArea = oCore.getUIArea(oPopupUIAreaDomRef.id);
}
}
if (oUiArea) {
oUiArea._handleEvent(oEvent);
}
}
} | javascript | function(sControlId, sRelatedControlId, oCore){
var oControl = sControlId ? oCore && oCore.byId(sControlId) : null;
if (oControl) {
var oRelatedControl = sRelatedControlId ? oCore.byId(sRelatedControlId) : null;
var oEvent = jQuery.Event("sapfocusleave");
oEvent.target = oControl.getDomRef();
oEvent.relatedControlId = oRelatedControl ? oRelatedControl.getId() : null;
oEvent.relatedControlFocusInfo = oRelatedControl ? oRelatedControl.getFocusInfo() : null;
//TODO: Cleanup the popup! The following is shit
var oControlUIArea = oControl.getUIArea();
var oUiArea = null;
if (oControlUIArea) {
oUiArea = oCore.getUIArea(oControlUIArea.getId());
} else {
var oPopupUIAreaDomRef = oCore.getStaticAreaRef();
if (containsOrEquals(oPopupUIAreaDomRef, oEvent.target)) {
oUiArea = oCore.getUIArea(oPopupUIAreaDomRef.id);
}
}
if (oUiArea) {
oUiArea._handleEvent(oEvent);
}
}
} | [
"function",
"(",
"sControlId",
",",
"sRelatedControlId",
",",
"oCore",
")",
"{",
"var",
"oControl",
"=",
"sControlId",
"?",
"oCore",
"&&",
"oCore",
".",
"byId",
"(",
"sControlId",
")",
":",
"null",
";",
"if",
"(",
"oControl",
")",
"{",
"var",
"oRelatedCo... | Calls the onsapfocusleave function on the control with id sControlId
with the information about the given related control.
@param {string} sControlId
@param {string} sRelatedControlId
@private | [
"Calls",
"the",
"onsapfocusleave",
"function",
"on",
"the",
"control",
"with",
"id",
"sControlId",
"with",
"the",
"information",
"about",
"the",
"given",
"related",
"control",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/FocusHandler.js#L302-L325 | train | Handles the sapfocusleave event. | [
30522,
3853,
1006,
8040,
12162,
13153,
3593,
1010,
5034,
10581,
3064,
8663,
13181,
21273,
1010,
1051,
17345,
1007,
1063,
13075,
1051,
8663,
13181,
2140,
1027,
8040,
12162,
13153,
3593,
1029,
1051,
17345,
1004,
1004,
1051,
17345,
1012,
2011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
vuejs/vue-cli | scripts/buildEditorConfig.js | convertRules | function convertRules (config) {
const result = {}
const eslintRules = new CLIEngine({
useEslintrc: false,
baseConfig: {
extends: [require.resolve(`@vue/eslint-config-${config}`)]
}
}).getConfigForFile().rules
const getRuleOptions = (ruleName, defaultOptions = []) => {
const ruleConfig = eslintRules[ruleName]
if (!ruleConfig || ruleConfig === 0 || ruleConfig === 'off') {
return
}
if (Array.isArray(ruleConfig) && (ruleConfig[0] === 0 || ruleConfig[0] === 'off')) {
return
}
if (Array.isArray(ruleConfig) && ruleConfig.length > 1) {
return ruleConfig.slice(1)
}
return defaultOptions
}
// https://eslint.org/docs/rules/indent
const indent = getRuleOptions('indent', [4])
if (indent) {
result.indent_style = indent[0] === 'tab' ? 'tab' : 'space'
if (typeof indent[0] === 'number') {
result.indent_size = indent[0]
}
}
// https://eslint.org/docs/rules/linebreak-style
const linebreakStyle = getRuleOptions('linebreak-style', ['unix'])
if (linebreakStyle) {
result.end_of_line = linebreakStyle[0] === 'unix' ? 'lf' : 'crlf'
}
// https://eslint.org/docs/rules/no-trailing-spaces
const noTrailingSpaces = getRuleOptions('no-trailing-spaces', [{ skipBlankLines: false, ignoreComments: false }])
if (noTrailingSpaces) {
if (!noTrailingSpaces[0].skipBlankLines && !noTrailingSpaces[0].ignoreComments) {
result.trim_trailing_whitespace = true
}
}
// https://eslint.org/docs/rules/eol-last
const eolLast = getRuleOptions('eol-last', ['always'])
if (eolLast) {
result.insert_final_newline = eolLast[0] !== 'never'
}
// https://eslint.org/docs/rules/max-len
const maxLen = getRuleOptions('max-len', [{ code: 80 }])
if (maxLen) {
// To simplify the implementation logic, we only read from the `code` option.
// `max-len` has an undocumented array-style configuration,
// where max code length specified directly as integers
// (used by `eslint-config-airbnb`).
if (typeof maxLen[0] === 'number') {
result.max_line_length = maxLen[0]
} else {
result.max_line_length = maxLen[0].code
}
}
return result
} | javascript | function convertRules (config) {
const result = {}
const eslintRules = new CLIEngine({
useEslintrc: false,
baseConfig: {
extends: [require.resolve(`@vue/eslint-config-${config}`)]
}
}).getConfigForFile().rules
const getRuleOptions = (ruleName, defaultOptions = []) => {
const ruleConfig = eslintRules[ruleName]
if (!ruleConfig || ruleConfig === 0 || ruleConfig === 'off') {
return
}
if (Array.isArray(ruleConfig) && (ruleConfig[0] === 0 || ruleConfig[0] === 'off')) {
return
}
if (Array.isArray(ruleConfig) && ruleConfig.length > 1) {
return ruleConfig.slice(1)
}
return defaultOptions
}
// https://eslint.org/docs/rules/indent
const indent = getRuleOptions('indent', [4])
if (indent) {
result.indent_style = indent[0] === 'tab' ? 'tab' : 'space'
if (typeof indent[0] === 'number') {
result.indent_size = indent[0]
}
}
// https://eslint.org/docs/rules/linebreak-style
const linebreakStyle = getRuleOptions('linebreak-style', ['unix'])
if (linebreakStyle) {
result.end_of_line = linebreakStyle[0] === 'unix' ? 'lf' : 'crlf'
}
// https://eslint.org/docs/rules/no-trailing-spaces
const noTrailingSpaces = getRuleOptions('no-trailing-spaces', [{ skipBlankLines: false, ignoreComments: false }])
if (noTrailingSpaces) {
if (!noTrailingSpaces[0].skipBlankLines && !noTrailingSpaces[0].ignoreComments) {
result.trim_trailing_whitespace = true
}
}
// https://eslint.org/docs/rules/eol-last
const eolLast = getRuleOptions('eol-last', ['always'])
if (eolLast) {
result.insert_final_newline = eolLast[0] !== 'never'
}
// https://eslint.org/docs/rules/max-len
const maxLen = getRuleOptions('max-len', [{ code: 80 }])
if (maxLen) {
// To simplify the implementation logic, we only read from the `code` option.
// `max-len` has an undocumented array-style configuration,
// where max code length specified directly as integers
// (used by `eslint-config-airbnb`).
if (typeof maxLen[0] === 'number') {
result.max_line_length = maxLen[0]
} else {
result.max_line_length = maxLen[0].code
}
}
return result
} | [
"function",
"convertRules",
"(",
"config",
")",
"{",
"const",
"result",
"=",
"{",
"}",
"const",
"eslintRules",
"=",
"new",
"CLIEngine",
"(",
"{",
"useEslintrc",
":",
"false",
",",
"baseConfig",
":",
"{",
"extends",
":",
"[",
"require",
".",
"resolve",
"(... | Convert eslint rules to editorconfig rules. | [
"Convert",
"eslint",
"rules",
"to",
"editorconfig",
"rules",
"."
] | 206803cbefefdfbc7d8ed12440b0b751688b77b2 | https://github.com/vuejs/vue-cli/blob/206803cbefefdfbc7d8ed12440b0b751688b77b2/scripts/buildEditorConfig.js#L16-L91 | train | Convert eslint rules to a spec | [
30522,
3853,
10463,
6820,
4244,
1006,
9530,
8873,
2290,
1007,
1063,
9530,
3367,
2765,
1027,
1063,
1065,
9530,
3367,
9686,
4115,
16344,
16308,
1027,
2047,
18856,
9013,
11528,
2063,
1006,
1063,
2224,
2229,
4115,
16344,
2278,
1024,
6270,
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... |
aframevr/aframe | src/core/a-entity.js | checkComponentDefined | function checkComponentDefined (el, name) {
// Check if element contains the component.
if (el.components[name] && el.components[name].attrValue) { return true; }
return isComponentMixedIn(name, el.mixinEls);
} | javascript | function checkComponentDefined (el, name) {
// Check if element contains the component.
if (el.components[name] && el.components[name].attrValue) { return true; }
return isComponentMixedIn(name, el.mixinEls);
} | [
"function",
"checkComponentDefined",
"(",
"el",
",",
"name",
")",
"{",
"// Check if element contains the component.",
"if",
"(",
"el",
".",
"components",
"[",
"name",
"]",
"&&",
"el",
".",
"components",
"[",
"name",
"]",
".",
"attrValue",
")",
"{",
"return",
... | Check if a component is *defined* for an entity, including defaults and mixins.
Does not check whether the component has been *initialized* for an entity.
@param {string} el - Entity.
@param {string} name - Component name.
@returns {boolean} | [
"Check",
"if",
"a",
"component",
"is",
"*",
"defined",
"*",
"for",
"an",
"entity",
"including",
"defaults",
"and",
"mixins",
".",
"Does",
"not",
"check",
"whether",
"the",
"component",
"has",
"been",
"*",
"initialized",
"*",
"for",
"an",
"entity",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-entity.js#L870-L875 | train | Check if component defined | [
30522,
3853,
4638,
9006,
29513,
3372,
3207,
23460,
2094,
1006,
3449,
1010,
2171,
1007,
1063,
1013,
1013,
4638,
2065,
5783,
3397,
1996,
6922,
1012,
2065,
1006,
3449,
1012,
6177,
1031,
2171,
1033,
1004,
1004,
3449,
1012,
6177,
1031,
2171,
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... |
cytoscape/cytoscape.js | documentation/docmaker.js | md2html | function md2html( file ){
file = file.substr( file.length - 3 ) === '.md' ? file : file + '.md'; // add extension if need be
let md;
try{
md = fs.readFileSync( path.join(__dirname, './md', file) , 'utf8');
} catch(e){
throw 'A markdown file named `' + file + '` was referenced but could not be read';
}
// let html = converter.makeHtml( md );
//let html = mdConvertor( md );
let html = marked( md, {
highlight: function(code, lang){
let ret;
if( lang ){
ret = hljs.highlight(lang, code).value;
} else {
ret = hljs.highlightAuto(code).value;
}
return ret;
},
smartypants: true,
renderer: mdRend,
gfm: true
} );
return html;
} | javascript | function md2html( file ){
file = file.substr( file.length - 3 ) === '.md' ? file : file + '.md'; // add extension if need be
let md;
try{
md = fs.readFileSync( path.join(__dirname, './md', file) , 'utf8');
} catch(e){
throw 'A markdown file named `' + file + '` was referenced but could not be read';
}
// let html = converter.makeHtml( md );
//let html = mdConvertor( md );
let html = marked( md, {
highlight: function(code, lang){
let ret;
if( lang ){
ret = hljs.highlight(lang, code).value;
} else {
ret = hljs.highlightAuto(code).value;
}
return ret;
},
smartypants: true,
renderer: mdRend,
gfm: true
} );
return html;
} | [
"function",
"md2html",
"(",
"file",
")",
"{",
"file",
"=",
"file",
".",
"substr",
"(",
"file",
".",
"length",
"-",
"3",
")",
"===",
"'.md'",
"?",
"file",
":",
"file",
"+",
"'.md'",
";",
"// add extension if need be",
"let",
"md",
";",
"try",
"{",
"md... | let html = converter.makeHtml("**I am bold!**"); let html = Handlebars.compile(); | [
"let",
"html",
"=",
"converter",
".",
"makeHtml",
"(",
"**",
"I",
"am",
"bold!",
"**",
")",
";",
"let",
"html",
"=",
"Handlebars",
".",
"compile",
"()",
";"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/documentation/docmaker.js#L48-L83 | train | converts a markdown file to html | [
30522,
3853,
9108,
2475,
11039,
19968,
1006,
5371,
1007,
1063,
5371,
1027,
5371,
1012,
4942,
3367,
2099,
1006,
5371,
1012,
3091,
1011,
1017,
1007,
1027,
1027,
1027,
1005,
1012,
9108,
1005,
1029,
5371,
1024,
5371,
1009,
1005,
1012,
9108,
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... |
GeekyAnts/vue-native-core | packages/vue-server-renderer/build.js | mergeHook | function mergeHook (
parentVal,
childVal
) {
return childVal
? parentVal
? parentVal.concat(childVal)
: Array.isArray(childVal)
? childVal
: [childVal]
: parentVal
} | javascript | function mergeHook (
parentVal,
childVal
) {
return childVal
? parentVal
? parentVal.concat(childVal)
: Array.isArray(childVal)
? childVal
: [childVal]
: parentVal
} | [
"function",
"mergeHook",
"(",
"parentVal",
",",
"childVal",
")",
"{",
"return",
"childVal",
"?",
"parentVal",
"?",
"parentVal",
".",
"concat",
"(",
"childVal",
")",
":",
"Array",
".",
"isArray",
"(",
"childVal",
")",
"?",
"childVal",
":",
"[",
"childVal",
... | Hooks and props are merged as arrays. | [
"Hooks",
"and",
"props",
"are",
"merged",
"as",
"arrays",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/vue-server-renderer/build.js#L1251-L1262 | train | Merge the two values | [
30522,
3853,
13590,
6806,
6559,
1006,
6687,
10175,
1010,
2775,
10175,
1007,
1063,
2709,
2775,
10175,
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,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-compiler/util/dedupeJSONStringify.js | printJSCode | function printJSCode(isDupedVar, depth, value) {
if (value == null || typeof value !== 'object') {
return JSON.stringify(value);
}
// Only use variable references at depth beyond the top level.
if (depth !== '') {
const metadata = metadataForVal.get(value);
if (metadata && metadata.isDuplicate) {
if (!metadata.varName) {
const refCode = printJSCode(true, '', value);
metadata.varName = 'v' + varDefs.length;
varDefs.push(metadata.varName + ' = ' + refCode);
}
return '(' + metadata.varName + '/*: any*/)';
}
}
let str;
let isEmpty = true;
const depth2 = depth + ' ';
if (Array.isArray(value)) {
// Empty arrays can only have one inferred flow type and then conflict if
// used in different places, this is unsound if we would write to them but
// this whole module is based on the idea of a read only JSON tree.
if (isDupedVar && value.length === 0) {
return '([]/*: any*/)';
}
str = '[';
for (let i = 0; i < value.length; i++) {
str +=
(isEmpty ? '\n' : ',\n') +
depth2 +
printJSCode(isDupedVar, depth2, value[i]);
isEmpty = false;
}
str += isEmpty ? ']' : `\n${depth}]`;
} else {
str = '{';
for (const k in value) {
if (value.hasOwnProperty(k) && value[k] !== undefined) {
str +=
(isEmpty ? '\n' : ',\n') +
depth2 +
JSON.stringify(k) +
': ' +
printJSCode(isDupedVar, depth2, value[k]);
isEmpty = false;
}
}
str += isEmpty ? '}' : `\n${depth}}`;
}
return str;
} | javascript | function printJSCode(isDupedVar, depth, value) {
if (value == null || typeof value !== 'object') {
return JSON.stringify(value);
}
// Only use variable references at depth beyond the top level.
if (depth !== '') {
const metadata = metadataForVal.get(value);
if (metadata && metadata.isDuplicate) {
if (!metadata.varName) {
const refCode = printJSCode(true, '', value);
metadata.varName = 'v' + varDefs.length;
varDefs.push(metadata.varName + ' = ' + refCode);
}
return '(' + metadata.varName + '/*: any*/)';
}
}
let str;
let isEmpty = true;
const depth2 = depth + ' ';
if (Array.isArray(value)) {
// Empty arrays can only have one inferred flow type and then conflict if
// used in different places, this is unsound if we would write to them but
// this whole module is based on the idea of a read only JSON tree.
if (isDupedVar && value.length === 0) {
return '([]/*: any*/)';
}
str = '[';
for (let i = 0; i < value.length; i++) {
str +=
(isEmpty ? '\n' : ',\n') +
depth2 +
printJSCode(isDupedVar, depth2, value[i]);
isEmpty = false;
}
str += isEmpty ? ']' : `\n${depth}]`;
} else {
str = '{';
for (const k in value) {
if (value.hasOwnProperty(k) && value[k] !== undefined) {
str +=
(isEmpty ? '\n' : ',\n') +
depth2 +
JSON.stringify(k) +
': ' +
printJSCode(isDupedVar, depth2, value[k]);
isEmpty = false;
}
}
str += isEmpty ? '}' : `\n${depth}}`;
}
return str;
} | [
"function",
"printJSCode",
"(",
"isDupedVar",
",",
"depth",
",",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
"||",
"typeof",
"value",
"!==",
"'object'",
")",
"{",
"return",
"JSON",
".",
"stringify",
"(",
"value",
")",
";",
"}",
"// Only use vari... | Stringify JS, replacing duplicates with variable references. | [
"Stringify",
"JS",
"replacing",
"duplicates",
"with",
"variable",
"references",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/util/dedupeJSONStringify.js#L90-L141 | train | Print JS code for a variable or array of variables. | [
30522,
3853,
6140,
22578,
16044,
1006,
2003,
8566,
5669,
10755,
1010,
5995,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
1027,
1027,
19701,
1064,
1064,
2828,
11253,
3643,
999,
1027,
1027,
1005,
4874,
1005,
1007,
1063,
2709,
1046,
3385,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | handleDocumentOpen | function handleDocumentOpen(commandData) {
var result = new $.Deferred();
handleFileOpen(commandData)
.done(function (file) {
// if we succeeded with an open file
// then we need to resolve that to a document.
// getOpenDocumentForPath will return null if there isn't a
// supporting document for that file (e.g. an image)
var doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
result.resolve(doc);
})
.fail(function (err) {
result.reject(err);
});
return result.promise();
} | javascript | function handleDocumentOpen(commandData) {
var result = new $.Deferred();
handleFileOpen(commandData)
.done(function (file) {
// if we succeeded with an open file
// then we need to resolve that to a document.
// getOpenDocumentForPath will return null if there isn't a
// supporting document for that file (e.g. an image)
var doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
result.resolve(doc);
})
.fail(function (err) {
result.reject(err);
});
return result.promise();
} | [
"function",
"handleDocumentOpen",
"(",
"commandData",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"handleFileOpen",
"(",
"commandData",
")",
".",
"done",
"(",
"function",
"(",
"file",
")",
"{",
"// if we succeeded with an open f... | Opens the given file, makes it the current file, does NOT add it to the workingset
@param {FileCommandData} commandData
fullPath: File to open;
silent: optional flag to suppress error messages;
paneId: optional PaneId (defaults to active pane)
@return {$.Promise} a jQuery promise that will be resolved with @type {Document} | [
"Opens",
"the",
"given",
"file",
"makes",
"it",
"the",
"current",
"file",
"does",
"NOT",
"add",
"it",
"to",
"the",
"workingset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L525-L542 | train | Handle a document open command | [
30522,
3853,
8971,
10085,
27417,
14399,
2368,
1006,
3094,
2850,
2696,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
5047,
8873,
2571,
26915,
1006,
3094,
2850,
2696,
1007,
1012,
2589,
1006,
3853,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | _removeDeletedFileFromMRU | function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | javascript | function _removeDeletedFileFromMRU(e, fullPath) {
var index,
compare = function (record) {
return (record.file.fullPath === fullPath);
};
// find and remove all instances
do {
index = _.findIndex(_mruList, compare);
if (index !== -1) {
_mruList.splice(index, 1);
}
} while (index !== -1);
} | [
"function",
"_removeDeletedFileFromMRU",
"(",
"e",
",",
"fullPath",
")",
"{",
"var",
"index",
",",
"compare",
"=",
"function",
"(",
"record",
")",
"{",
"return",
"(",
"record",
".",
"file",
".",
"fullPath",
"===",
"fullPath",
")",
";",
"}",
";",
"// find... | DocumentManager.pathDeleted Event handler to remove a file
from the MRU list
@param {!jQuery.event} e -
@param {!string} fullPath - path of the file to remove
@private | [
"DocumentManager",
".",
"pathDeleted",
"Event",
"handler",
"to",
"remove",
"a",
"file",
"from",
"the",
"MRU",
"list"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L866-L879 | train | Remove a deleted file from the MRU | [
30522,
3853,
1035,
3718,
12260,
3064,
8873,
2571,
19699,
5358,
2213,
6820,
1006,
1041,
1010,
2440,
15069,
1007,
1063,
13075,
5950,
1010,
12826,
1027,
3853,
1006,
2501,
1007,
1063,
2709,
1006,
2501,
1012,
5371,
1012,
2440,
15069,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/models/relations/authors.js | destroyByAuthor | function destroyByAuthor(unfilteredOptions) {
let options = this.filterOptions(unfilteredOptions, 'destroyByAuthor', {extraAllowedProperties: ['id']}),
postCollection = Posts.forge(),
authorId = options.id;
if (!authorId) {
return Promise.reject(new common.errors.NotFoundError({
message: common.i18n.t('errors.models.post.noUserFound')
}));
}
// CASE: if you are the primary author of a post, the whole post and it's relations get's deleted.
// `posts_authors` are automatically removed (bookshelf-relations)
// CASE: if you are the secondary author of a post, you are just deleted as author.
// must happen manually
const destroyPost = (() => {
return postCollection
.query('where', 'author_id', '=', authorId)
.fetch(options)
.call('invokeThen', 'destroy', options)
.then(function (response) {
return (options.transacting || ghostBookshelf.knex)('posts_authors')
.where('author_id', authorId)
.del()
.return(response);
})
.catch((err) => {
throw new common.errors.GhostError({err: err});
});
});
if (!options.transacting) {
return ghostBookshelf.transaction((transacting) => {
options.transacting = transacting;
return destroyPost();
});
}
return destroyPost();
} | javascript | function destroyByAuthor(unfilteredOptions) {
let options = this.filterOptions(unfilteredOptions, 'destroyByAuthor', {extraAllowedProperties: ['id']}),
postCollection = Posts.forge(),
authorId = options.id;
if (!authorId) {
return Promise.reject(new common.errors.NotFoundError({
message: common.i18n.t('errors.models.post.noUserFound')
}));
}
// CASE: if you are the primary author of a post, the whole post and it's relations get's deleted.
// `posts_authors` are automatically removed (bookshelf-relations)
// CASE: if you are the secondary author of a post, you are just deleted as author.
// must happen manually
const destroyPost = (() => {
return postCollection
.query('where', 'author_id', '=', authorId)
.fetch(options)
.call('invokeThen', 'destroy', options)
.then(function (response) {
return (options.transacting || ghostBookshelf.knex)('posts_authors')
.where('author_id', authorId)
.del()
.return(response);
})
.catch((err) => {
throw new common.errors.GhostError({err: err});
});
});
if (!options.transacting) {
return ghostBookshelf.transaction((transacting) => {
options.transacting = transacting;
return destroyPost();
});
}
return destroyPost();
} | [
"function",
"destroyByAuthor",
"(",
"unfilteredOptions",
")",
"{",
"let",
"options",
"=",
"this",
".",
"filterOptions",
"(",
"unfilteredOptions",
",",
"'destroyByAuthor'",
",",
"{",
"extraAllowedProperties",
":",
"[",
"'id'",
"]",
"}",
")",
",",
"postCollection",
... | ### destroyByAuthor
@param {[type]} options has context and id. Context is the user doing the destroy, id is the user to destroy | [
"###",
"destroyByAuthor"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/relations/authors.js#L293-L332 | train | Destroys a post by its author | [
30522,
3853,
6033,
3762,
4887,
27844,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1007,
1063,
2292,
7047,
1027,
2023,
1012,
11307,
7361,
9285,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1010,
1005,
6033,
3762,
4887,
27844,
1005,
1010,
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... |
goldfire/howler.js | dist/howler.js | function() {
var self = this || Howler;
for (var i=self._howls.length-1; i>=0; i--) {
self._howls[i].unload();
}
// Create a new AudioContext to make sure it is fully reset.
if (self.usingWebAudio && self.ctx && typeof self.ctx.close !== 'undefined') {
self.ctx.close();
self.ctx = null;
setupAudioContext();
}
return self;
} | javascript | function() {
var self = this || Howler;
for (var i=self._howls.length-1; i>=0; i--) {
self._howls[i].unload();
}
// Create a new AudioContext to make sure it is fully reset.
if (self.usingWebAudio && self.ctx && typeof self.ctx.close !== 'undefined') {
self.ctx.close();
self.ctx = null;
setupAudioContext();
}
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
"||",
"Howler",
";",
"for",
"(",
"var",
"i",
"=",
"self",
".",
"_howls",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"self",
".",
"_howls",
"[",
"i",
"]",
".... | Unload and destroy all currently loaded Howl objects.
@return {Howler} | [
"Unload",
"and",
"destroy",
"all",
"currently",
"loaded",
"Howl",
"objects",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L157-L172 | train | Unload all the Howl objects | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1064,
1064,
22912,
2121,
1025,
2005,
1006,
13075,
1045,
1027,
2969,
1012,
1035,
22912,
2015,
1012,
3091,
1011,
1015,
1025,
1045,
1028,
1027,
1014,
1025,
1045,
1011,
1011,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/Agents/ScriptAgent.js | load | function load() {
_reset();
_load = new $.Deferred();
var enableResult = new $.Deferred();
Inspector.Debugger.enable().done(function () {
Inspector.Debugger.setPauseOnExceptions("uncaught").done(function () {
enableResult.resolve();
});
});
Inspector.Page.on("frameNavigated.ScriptAgent", _onFrameNavigated);
DOMAgent.on("getDocument.ScriptAgent", _onGetDocument);
Inspector.Debugger
.on("scriptParsed.ScriptAgent", _onScriptParsed)
.on("scriptFailedToParse.ScriptAgent", _onScriptFailedToParse)
.on("paused.ScriptAgent", _onPaused);
Inspector.DOM.on("childNodeInserted.ScriptAgent", _onChildNodeInserted);
return $.when(_load.promise(), enableResult.promise());
} | javascript | function load() {
_reset();
_load = new $.Deferred();
var enableResult = new $.Deferred();
Inspector.Debugger.enable().done(function () {
Inspector.Debugger.setPauseOnExceptions("uncaught").done(function () {
enableResult.resolve();
});
});
Inspector.Page.on("frameNavigated.ScriptAgent", _onFrameNavigated);
DOMAgent.on("getDocument.ScriptAgent", _onGetDocument);
Inspector.Debugger
.on("scriptParsed.ScriptAgent", _onScriptParsed)
.on("scriptFailedToParse.ScriptAgent", _onScriptFailedToParse)
.on("paused.ScriptAgent", _onPaused);
Inspector.DOM.on("childNodeInserted.ScriptAgent", _onChildNodeInserted);
return $.when(_load.promise(), enableResult.promise());
} | [
"function",
"load",
"(",
")",
"{",
"_reset",
"(",
")",
";",
"_load",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"enableResult",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"Inspector",
".",
"Debugger",
".",
"enable",
"(",
")",
"... | Initialize the agent | [
"Initialize",
"the",
"agent"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/ScriptAgent.js#L126-L147 | train | Load the script | [
30522,
3853,
7170,
1006,
1007,
1063,
1035,
25141,
1006,
1007,
1025,
1035,
7170,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
13075,
9585,
6072,
11314,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
7742,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/sankey/sankeyLayout.js | computeEdgeDepths | function computeEdgeDepths(nodes, orient) {
var keyAttr = orient === 'vertical' ? 'x' : 'y';
zrUtil.each(nodes, function (node) {
node.outEdges.sort(function (a, b) {
return a.node2.getLayout()[keyAttr] - b.node2.getLayout()[keyAttr];
});
node.inEdges.sort(function (a, b) {
return a.node1.getLayout()[keyAttr] - b.node1.getLayout()[keyAttr];
});
});
zrUtil.each(nodes, function (node) {
var sy = 0;
var ty = 0;
zrUtil.each(node.outEdges, function (edge) {
edge.setLayout({sy: sy}, true);
sy += edge.getLayout().dy;
});
zrUtil.each(node.inEdges, function (edge) {
edge.setLayout({ty: ty}, true);
ty += edge.getLayout().dy;
});
});
} | javascript | function computeEdgeDepths(nodes, orient) {
var keyAttr = orient === 'vertical' ? 'x' : 'y';
zrUtil.each(nodes, function (node) {
node.outEdges.sort(function (a, b) {
return a.node2.getLayout()[keyAttr] - b.node2.getLayout()[keyAttr];
});
node.inEdges.sort(function (a, b) {
return a.node1.getLayout()[keyAttr] - b.node1.getLayout()[keyAttr];
});
});
zrUtil.each(nodes, function (node) {
var sy = 0;
var ty = 0;
zrUtil.each(node.outEdges, function (edge) {
edge.setLayout({sy: sy}, true);
sy += edge.getLayout().dy;
});
zrUtil.each(node.inEdges, function (edge) {
edge.setLayout({ty: ty}, true);
ty += edge.getLayout().dy;
});
});
} | [
"function",
"computeEdgeDepths",
"(",
"nodes",
",",
"orient",
")",
"{",
"var",
"keyAttr",
"=",
"orient",
"===",
"'vertical'",
"?",
"'x'",
":",
"'y'",
";",
"zrUtil",
".",
"each",
"(",
"nodes",
",",
"function",
"(",
"node",
")",
"{",
"node",
".",
"outEdg... | Compute the depth(y-position) of each edge
@param {module:echarts/data/Graph~Node} nodes node of sankey view | [
"Compute",
"the",
"depth",
"(",
"y",
"-",
"position",
")",
"of",
"each",
"edge"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sankey/sankeyLayout.js#L483-L505 | train | Compute edge depths | [
30522,
3853,
24134,
24225,
3207,
13876,
7898,
1006,
14164,
1010,
16865,
1007,
1063,
13075,
3145,
19321,
2099,
1027,
16865,
1027,
1027,
1027,
1005,
7471,
1005,
1029,
1005,
1060,
1005,
1024,
1005,
1061,
1005,
1025,
1062,
22134,
4014,
1012,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js | function(oEvent) {
if (bInteractionActive) {
// notify for a newly started interaction, but not more often than every 250ms.
if (!iScrollEventDelayId) {
Interaction.notifyEventStart(oEvent);
} else {
clearTimeout(iScrollEventDelayId);
}
iScrollEventDelayId = setTimeout(function(){
Interaction.notifyStepStart();
iScrollEventDelayId = 0;
}, 250);
}
} | javascript | function(oEvent) {
if (bInteractionActive) {
// notify for a newly started interaction, but not more often than every 250ms.
if (!iScrollEventDelayId) {
Interaction.notifyEventStart(oEvent);
} else {
clearTimeout(iScrollEventDelayId);
}
iScrollEventDelayId = setTimeout(function(){
Interaction.notifyStepStart();
iScrollEventDelayId = 0;
}, 250);
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"if",
"(",
"bInteractionActive",
")",
"{",
"// notify for a newly started interaction, but not more often than every 250ms.",
"if",
"(",
"!",
"iScrollEventDelayId",
")",
"{",
"Interaction",
".",
"notifyEventStart",
"(",
"oEvent",
")",
... | This method notifies if a scroll event has been triggered. Some controls require this special treatment,
as the generic detection process via notifyEventStart is not sufficient.
@param {Event} oEvent Scroll event whose processing has started
@static
@private | [
"This",
"method",
"notifies",
"if",
"a",
"scroll",
"event",
"has",
"been",
"triggered",
".",
"Some",
"controls",
"require",
"this",
"special",
"treatment",
"as",
"the",
"generic",
"detection",
"process",
"via",
"notifyEventStart",
"is",
"not",
"sufficient",
"."
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/performance/trace/Interaction.js#L493-L506 | train | Called when the user scrolls in the page | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
2065,
1006,
8026,
14621,
7542,
19620,
1007,
1063,
1013,
1013,
2025,
8757,
2005,
1037,
4397,
2318,
8290,
1010,
2021,
2025,
2062,
2411,
2084,
2296,
5539,
5244,
1012,
2065,
1006,
999,
2003,
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... | |
juliangarnier/anime | lib/anime.js | steps | function steps(steps) {
if ( steps === void 0 ) steps = 10;
return function (t) { return Math.round(t * steps) * (1 / steps); };
} | javascript | function steps(steps) {
if ( steps === void 0 ) steps = 10;
return function (t) { return Math.round(t * steps) * (1 / steps); };
} | [
"function",
"steps",
"(",
"steps",
")",
"{",
"if",
"(",
"steps",
"===",
"void",
"0",
")",
"steps",
"=",
"10",
";",
"return",
"function",
"(",
"t",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"t",
"*",
"steps",
")",
"*",
"(",
"1",
"/",
"steps... | Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function | [
"Basic",
"steps",
"easing",
"implementation",
"https",
":",
"//",
"developer",
".",
"mozilla",
".",
"org",
"/",
"fr",
"/",
"docs",
"/",
"Web",
"/",
"CSS",
"/",
"transition",
"-",
"timing",
"-",
"function"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/lib/anime.js#L148-L152 | train | Returns a function that will return a function that will return a number of steps | [
30522,
3853,
4084,
1006,
4084,
1007,
1063,
2065,
1006,
4084,
1027,
1027,
1027,
11675,
1014,
1007,
4084,
1027,
2184,
1025,
2709,
3853,
1006,
1056,
1007,
1063,
2709,
8785,
1012,
2461,
1006,
1056,
1008,
4084,
1007,
1008,
1006,
1015,
1013,
40... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/icon/js/iconService.js | MdIconService | function MdIconService(config, $templateRequest, $q, $log, $mdUtil, $sce) {
var iconCache = {};
var svgCache = {};
var urlRegex = /[-\w@:%+.~#?&//=]{2,}\.[a-z]{2,4}\b(\/[-\w@:%+.~#?&//=]*)?/i;
var dataUrlRegex = /^data:image\/svg\+xml[\s*;\w\-=]*?(base64)?,(.*)$/i;
Icon.prototype = {clone: cloneSVG, prepare: prepareAndStyle};
getIcon.fontSet = findRegisteredFontSet;
// Publish service...
return getIcon;
/**
* Actual $mdIcon service is essentially a lookup function
* @param {*} id $sce trust wrapper over a URL string, URL, icon registry id, or icon set id
* @returns {angular.$q.Promise}
*/
function getIcon(id) {
id = id || '';
// If the "id" provided is not a string, the only other valid value is a $sce trust wrapper
// over a URL string. If the value is not trusted, this will intentionally throw an error
// because the user is attempted to use an unsafe URL, potentially opening themselves up
// to an XSS attack.
if (!angular.isString(id)) {
id = $sce.getTrustedUrl(id);
}
// If already loaded and cached, use a clone of the cached icon.
// Otherwise either load by URL, or lookup in the registry and then load by URL, and cache.
if (iconCache[id]) {
return $q.when(transformClone(iconCache[id]));
}
if (urlRegex.test(id) || dataUrlRegex.test(id)) {
return loadByURL(id).then(cacheIcon(id));
}
if (id.indexOf(':') === -1) {
id = '$default:' + id;
}
var load = config[id] ? loadByID : loadFromIconSet;
return load(id)
.then(cacheIcon(id));
}
/**
* Lookup a registered fontSet style using its alias.
* @param {string} alias used to lookup the alias in the array of fontSets
* @returns {*} matching fontSet or the defaultFontSet if that alias does not match
*/
function findRegisteredFontSet(alias) {
var useDefault = angular.isUndefined(alias) || !(alias && alias.length);
if (useDefault) {
return config.defaultFontSet;
}
var result = alias;
angular.forEach(config.fontSets, function(fontSet) {
if (fontSet.alias === alias) {
result = fontSet.fontSet || result;
}
});
return result;
}
/**
* @param {!Icon} cacheElement cached icon from the iconCache
* @returns {Icon} cloned Icon element with unique ids
*/
function transformClone(cacheElement) {
var clone = cacheElement.clone();
var newUid = $mdUtil.nextUid();
var cacheSuffix, svgUrlQuerySelector, i, xlinkHrefValue;
// These are SVG attributes that can reference element ids.
var svgUrlAttributes = [
'clip-path', 'color-profile', 'cursor', 'fill', 'filter', 'href', 'marker-start',
'marker-mid', 'marker-end', 'mask', 'stroke', 'style', 'vector-effect'
];
var isIeSvg = clone.innerHTML === undefined;
// Verify that the newUid only contains a number and not some XSS content.
if (!isFinite(Number(newUid))) {
throw new Error('Unsafe and unexpected non-number result from $mdUtil.nextUid().');
}
cacheSuffix = '_cache' + newUid;
// For each cached icon, we need to modify the id attributes and references.
// This is needed because SVG ids are treated as normal DOM ids and should not be duplicated on
// the page.
if (clone.id) {
clone.id += cacheSuffix;
}
// Do as much as possible with querySelectorAll as it provides much greater performance
// than RegEx against serialized DOM.
angular.forEach(clone.querySelectorAll('[id]'), function(descendantElem) {
svgUrlQuerySelector = '';
for (i = 0; i < svgUrlAttributes.length; i++) {
svgUrlQuerySelector += '[' + svgUrlAttributes[i] + '="url(#' + descendantElem.id + ')"]';
if (i + 1 < svgUrlAttributes.length) {
svgUrlQuerySelector += ', ';
}
}
// Append the cacheSuffix to references of the element's id within url(#id) calls.
angular.forEach(clone.querySelectorAll(svgUrlQuerySelector), function(refItem) {
updateSvgIdReferences(descendantElem, refItem, isIeSvg, newUid);
});
// Handle usages of url(#id) in the SVG's stylesheets
angular.forEach(clone.querySelectorAll('style'), function(refItem) {
updateSvgIdReferences(descendantElem, refItem, isIeSvg, newUid);
});
// Update ids referenced by the deprecated (in SVG v2) xlink:href XML attribute. The now
// preferred href attribute is handled above. However, this non-standard XML namespaced
// attribute cannot be handled in the same way. Explanation of this query selector here:
// https://stackoverflow.com/q/23034283/633107.
angular.forEach(clone.querySelectorAll('[*|href]:not([href])'), function(refItem) {
xlinkHrefValue = refItem.getAttribute('xlink:href');
if (xlinkHrefValue) {
xlinkHrefValue = xlinkHrefValue.replace("#" + descendantElem.id, "#" + descendantElem.id + cacheSuffix);
refItem.setAttribute('xlink:href', xlinkHrefValue);
}
});
descendantElem.id += cacheSuffix;
});
return clone;
}
/**
* @param {Element} referencedElement element w/ id that needs to be updated
* @param {Element} referencingElement element that references the original id
* @param {boolean} isIeSvg true if we're dealing with an SVG in IE11, false otherwise
* @param {string} newUid the cache id to add as part of the cache suffix
*/
function updateSvgIdReferences(referencedElement, referencingElement, isIeSvg, newUid) {
var svgElement, cacheSuffix;
// Verify that the newUid only contains a number and not some XSS content.
if (!isFinite(Number(newUid))) {
throw new Error('Unsafe and unexpected non-number result for newUid.');
}
cacheSuffix = '_cache' + newUid;
// outerHTML of SVG elements is not supported by IE11
if (isIeSvg) {
svgElement = $mdUtil.getOuterHTML(referencingElement);
svgElement = svgElement.replace("url(#" + referencedElement.id + ")",
"url(#" + referencedElement.id + cacheSuffix + ")");
referencingElement.textContent = angular.element(svgElement)[0].innerHTML;
} else {
// This use of outerHTML should be safe from XSS attack since we are only injecting the
// cacheSuffix with content from $mdUtil.nextUid which we verify is a finite number above.
referencingElement.outerHTML = referencingElement.outerHTML.replace(
"url(#" + referencedElement.id + ")",
"url(#" + referencedElement.id + cacheSuffix + ")");
}
}
/**
* Prepare and cache the loaded icon for the specified `id`.
* @param {string} id icon cache id
* @returns {function(*=): *}
*/
function cacheIcon(id) {
return function updateCache(icon) {
iconCache[id] = isIcon(icon) ? icon : new Icon(icon, config[id]);
return transformClone(iconCache[id]);
};
}
/**
* Lookup the configuration in the registry, if !registered throw an error
* otherwise load the icon [on-demand] using the registered URL.
* @param {string} id icon registry id
* @returns {angular.$q.Promise}
*/
function loadByID(id) {
var iconConfig = config[id];
return loadByURL(iconConfig.url).then(function(icon) {
return new Icon(icon, iconConfig);
});
}
/**
* Loads the file as XML and uses querySelector( <id> ) to find the desired node...
* @param {string} id icon id in icon set
* @returns {angular.$q.Promise}
*/
function loadFromIconSet(id) {
var setName = id.substring(0, id.lastIndexOf(':')) || '$default';
var iconSetConfig = config[setName];
return !iconSetConfig ? announceIdNotFound(id) : loadByURL(iconSetConfig.url).then(extractFromSet);
function extractFromSet(set) {
var iconName = id.slice(id.lastIndexOf(':') + 1);
var icon = set.querySelector('#' + iconName);
return icon ? new Icon(icon, iconSetConfig) : announceIdNotFound(id);
}
function announceIdNotFound(id) {
var msg = 'icon ' + id + ' not found';
$log.warn(msg);
return $q.reject(msg || id);
}
}
/**
* Load the icon by URL (may use the $templateCache).
* Extract the data for later conversion to Icon
* @param {string} url icon URL
* @returns {angular.$q.Promise}
*/
function loadByURL(url) {
/* Load the icon from embedded data URL. */
function loadByDataUrl(url) {
var results = dataUrlRegex.exec(url);
var isBase64 = /base64/i.test(url);
var data = isBase64 ? window.atob(results[2]) : results[2];
return $q.when(angular.element(data)[0]);
}
/* Load the icon by URL using HTTP. */
function loadByHttpUrl(url) {
return $q(function(resolve, reject) {
// Catch HTTP or generic errors not related to incorrect icon IDs.
var announceAndReject = function(err) {
var msg = angular.isString(err) ? err : (err.message || err.data || err.statusText);
$log.warn(msg);
reject(err);
},
extractSvg = function(response) {
if (!svgCache[url]) {
svgCache[url] = angular.element('<div>').append(response)[0].querySelector('svg');
}
resolve(svgCache[url]);
};
$templateRequest(url, true).then(extractSvg, announceAndReject);
});
}
return dataUrlRegex.test(url)
? loadByDataUrl(url)
: loadByHttpUrl(url);
}
/**
* Check target signature to see if it is an Icon instance.
* @param {Icon|Element} target
* @returns {boolean} true if the specified target is an Icon object, false otherwise.
*/
function isIcon(target) {
return angular.isDefined(target.element) && angular.isDefined(target.config);
}
/**
* Define the Icon class
* @param {Element} el
* @param {=ConfigurationItem} config
* @constructor
*/
function Icon(el, config) {
// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>.
if (el && el.tagName.toLowerCase() === 'symbol') {
var viewbox = el.getAttribute('viewBox');
// // Check if innerHTML is supported as IE11 does not support innerHTML on SVG elements.
if (el.innerHTML) {
el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">')
.html(el.innerHTML)[0];
} else {
el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">')
.append($mdUtil.getInnerHTML(el))[0];
}
if (viewbox) el.setAttribute('viewBox', viewbox);
}
if (el && el.tagName.toLowerCase() !== 'svg') {
el = angular.element(
'<svg xmlns="http://www.w3.org/2000/svg">').append(el.cloneNode(true))[0];
}
// Inject the namespace if not available...
if (!el.getAttribute('xmlns')) {
el.setAttribute('xmlns', "http://www.w3.org/2000/svg");
}
this.element = el;
this.config = config;
this.prepare();
}
/**
* Prepare the DOM element that will be cached in the
* loaded iconCache store.
*/
function prepareAndStyle() {
var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize;
angular.forEach({
'fit': '',
'height': '100%',
'width': '100%',
'preserveAspectRatio': 'xMidYMid meet',
'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize),
'focusable': false // Disable IE11s default behavior to make SVGs focusable
}, function(val, attr) {
this.element.setAttribute(attr, val);
}, this);
}
/**
* Clone the Icon DOM element.
*/
function cloneSVG() {
// If the element or any of its children have a style attribute, then a CSP policy without
// 'unsafe-inline' in the style-src directive, will result in a violation.
return this.element.cloneNode(true);
}
} | javascript | function MdIconService(config, $templateRequest, $q, $log, $mdUtil, $sce) {
var iconCache = {};
var svgCache = {};
var urlRegex = /[-\w@:%+.~#?&//=]{2,}\.[a-z]{2,4}\b(\/[-\w@:%+.~#?&//=]*)?/i;
var dataUrlRegex = /^data:image\/svg\+xml[\s*;\w\-=]*?(base64)?,(.*)$/i;
Icon.prototype = {clone: cloneSVG, prepare: prepareAndStyle};
getIcon.fontSet = findRegisteredFontSet;
// Publish service...
return getIcon;
/**
* Actual $mdIcon service is essentially a lookup function
* @param {*} id $sce trust wrapper over a URL string, URL, icon registry id, or icon set id
* @returns {angular.$q.Promise}
*/
function getIcon(id) {
id = id || '';
// If the "id" provided is not a string, the only other valid value is a $sce trust wrapper
// over a URL string. If the value is not trusted, this will intentionally throw an error
// because the user is attempted to use an unsafe URL, potentially opening themselves up
// to an XSS attack.
if (!angular.isString(id)) {
id = $sce.getTrustedUrl(id);
}
// If already loaded and cached, use a clone of the cached icon.
// Otherwise either load by URL, or lookup in the registry and then load by URL, and cache.
if (iconCache[id]) {
return $q.when(transformClone(iconCache[id]));
}
if (urlRegex.test(id) || dataUrlRegex.test(id)) {
return loadByURL(id).then(cacheIcon(id));
}
if (id.indexOf(':') === -1) {
id = '$default:' + id;
}
var load = config[id] ? loadByID : loadFromIconSet;
return load(id)
.then(cacheIcon(id));
}
/**
* Lookup a registered fontSet style using its alias.
* @param {string} alias used to lookup the alias in the array of fontSets
* @returns {*} matching fontSet or the defaultFontSet if that alias does not match
*/
function findRegisteredFontSet(alias) {
var useDefault = angular.isUndefined(alias) || !(alias && alias.length);
if (useDefault) {
return config.defaultFontSet;
}
var result = alias;
angular.forEach(config.fontSets, function(fontSet) {
if (fontSet.alias === alias) {
result = fontSet.fontSet || result;
}
});
return result;
}
/**
* @param {!Icon} cacheElement cached icon from the iconCache
* @returns {Icon} cloned Icon element with unique ids
*/
function transformClone(cacheElement) {
var clone = cacheElement.clone();
var newUid = $mdUtil.nextUid();
var cacheSuffix, svgUrlQuerySelector, i, xlinkHrefValue;
// These are SVG attributes that can reference element ids.
var svgUrlAttributes = [
'clip-path', 'color-profile', 'cursor', 'fill', 'filter', 'href', 'marker-start',
'marker-mid', 'marker-end', 'mask', 'stroke', 'style', 'vector-effect'
];
var isIeSvg = clone.innerHTML === undefined;
// Verify that the newUid only contains a number and not some XSS content.
if (!isFinite(Number(newUid))) {
throw new Error('Unsafe and unexpected non-number result from $mdUtil.nextUid().');
}
cacheSuffix = '_cache' + newUid;
// For each cached icon, we need to modify the id attributes and references.
// This is needed because SVG ids are treated as normal DOM ids and should not be duplicated on
// the page.
if (clone.id) {
clone.id += cacheSuffix;
}
// Do as much as possible with querySelectorAll as it provides much greater performance
// than RegEx against serialized DOM.
angular.forEach(clone.querySelectorAll('[id]'), function(descendantElem) {
svgUrlQuerySelector = '';
for (i = 0; i < svgUrlAttributes.length; i++) {
svgUrlQuerySelector += '[' + svgUrlAttributes[i] + '="url(#' + descendantElem.id + ')"]';
if (i + 1 < svgUrlAttributes.length) {
svgUrlQuerySelector += ', ';
}
}
// Append the cacheSuffix to references of the element's id within url(#id) calls.
angular.forEach(clone.querySelectorAll(svgUrlQuerySelector), function(refItem) {
updateSvgIdReferences(descendantElem, refItem, isIeSvg, newUid);
});
// Handle usages of url(#id) in the SVG's stylesheets
angular.forEach(clone.querySelectorAll('style'), function(refItem) {
updateSvgIdReferences(descendantElem, refItem, isIeSvg, newUid);
});
// Update ids referenced by the deprecated (in SVG v2) xlink:href XML attribute. The now
// preferred href attribute is handled above. However, this non-standard XML namespaced
// attribute cannot be handled in the same way. Explanation of this query selector here:
// https://stackoverflow.com/q/23034283/633107.
angular.forEach(clone.querySelectorAll('[*|href]:not([href])'), function(refItem) {
xlinkHrefValue = refItem.getAttribute('xlink:href');
if (xlinkHrefValue) {
xlinkHrefValue = xlinkHrefValue.replace("#" + descendantElem.id, "#" + descendantElem.id + cacheSuffix);
refItem.setAttribute('xlink:href', xlinkHrefValue);
}
});
descendantElem.id += cacheSuffix;
});
return clone;
}
/**
* @param {Element} referencedElement element w/ id that needs to be updated
* @param {Element} referencingElement element that references the original id
* @param {boolean} isIeSvg true if we're dealing with an SVG in IE11, false otherwise
* @param {string} newUid the cache id to add as part of the cache suffix
*/
function updateSvgIdReferences(referencedElement, referencingElement, isIeSvg, newUid) {
var svgElement, cacheSuffix;
// Verify that the newUid only contains a number and not some XSS content.
if (!isFinite(Number(newUid))) {
throw new Error('Unsafe and unexpected non-number result for newUid.');
}
cacheSuffix = '_cache' + newUid;
// outerHTML of SVG elements is not supported by IE11
if (isIeSvg) {
svgElement = $mdUtil.getOuterHTML(referencingElement);
svgElement = svgElement.replace("url(#" + referencedElement.id + ")",
"url(#" + referencedElement.id + cacheSuffix + ")");
referencingElement.textContent = angular.element(svgElement)[0].innerHTML;
} else {
// This use of outerHTML should be safe from XSS attack since we are only injecting the
// cacheSuffix with content from $mdUtil.nextUid which we verify is a finite number above.
referencingElement.outerHTML = referencingElement.outerHTML.replace(
"url(#" + referencedElement.id + ")",
"url(#" + referencedElement.id + cacheSuffix + ")");
}
}
/**
* Prepare and cache the loaded icon for the specified `id`.
* @param {string} id icon cache id
* @returns {function(*=): *}
*/
function cacheIcon(id) {
return function updateCache(icon) {
iconCache[id] = isIcon(icon) ? icon : new Icon(icon, config[id]);
return transformClone(iconCache[id]);
};
}
/**
* Lookup the configuration in the registry, if !registered throw an error
* otherwise load the icon [on-demand] using the registered URL.
* @param {string} id icon registry id
* @returns {angular.$q.Promise}
*/
function loadByID(id) {
var iconConfig = config[id];
return loadByURL(iconConfig.url).then(function(icon) {
return new Icon(icon, iconConfig);
});
}
/**
* Loads the file as XML and uses querySelector( <id> ) to find the desired node...
* @param {string} id icon id in icon set
* @returns {angular.$q.Promise}
*/
function loadFromIconSet(id) {
var setName = id.substring(0, id.lastIndexOf(':')) || '$default';
var iconSetConfig = config[setName];
return !iconSetConfig ? announceIdNotFound(id) : loadByURL(iconSetConfig.url).then(extractFromSet);
function extractFromSet(set) {
var iconName = id.slice(id.lastIndexOf(':') + 1);
var icon = set.querySelector('#' + iconName);
return icon ? new Icon(icon, iconSetConfig) : announceIdNotFound(id);
}
function announceIdNotFound(id) {
var msg = 'icon ' + id + ' not found';
$log.warn(msg);
return $q.reject(msg || id);
}
}
/**
* Load the icon by URL (may use the $templateCache).
* Extract the data for later conversion to Icon
* @param {string} url icon URL
* @returns {angular.$q.Promise}
*/
function loadByURL(url) {
/* Load the icon from embedded data URL. */
function loadByDataUrl(url) {
var results = dataUrlRegex.exec(url);
var isBase64 = /base64/i.test(url);
var data = isBase64 ? window.atob(results[2]) : results[2];
return $q.when(angular.element(data)[0]);
}
/* Load the icon by URL using HTTP. */
function loadByHttpUrl(url) {
return $q(function(resolve, reject) {
// Catch HTTP or generic errors not related to incorrect icon IDs.
var announceAndReject = function(err) {
var msg = angular.isString(err) ? err : (err.message || err.data || err.statusText);
$log.warn(msg);
reject(err);
},
extractSvg = function(response) {
if (!svgCache[url]) {
svgCache[url] = angular.element('<div>').append(response)[0].querySelector('svg');
}
resolve(svgCache[url]);
};
$templateRequest(url, true).then(extractSvg, announceAndReject);
});
}
return dataUrlRegex.test(url)
? loadByDataUrl(url)
: loadByHttpUrl(url);
}
/**
* Check target signature to see if it is an Icon instance.
* @param {Icon|Element} target
* @returns {boolean} true if the specified target is an Icon object, false otherwise.
*/
function isIcon(target) {
return angular.isDefined(target.element) && angular.isDefined(target.config);
}
/**
* Define the Icon class
* @param {Element} el
* @param {=ConfigurationItem} config
* @constructor
*/
function Icon(el, config) {
// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>.
if (el && el.tagName.toLowerCase() === 'symbol') {
var viewbox = el.getAttribute('viewBox');
// // Check if innerHTML is supported as IE11 does not support innerHTML on SVG elements.
if (el.innerHTML) {
el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">')
.html(el.innerHTML)[0];
} else {
el = angular.element('<svg xmlns="http://www.w3.org/2000/svg">')
.append($mdUtil.getInnerHTML(el))[0];
}
if (viewbox) el.setAttribute('viewBox', viewbox);
}
if (el && el.tagName.toLowerCase() !== 'svg') {
el = angular.element(
'<svg xmlns="http://www.w3.org/2000/svg">').append(el.cloneNode(true))[0];
}
// Inject the namespace if not available...
if (!el.getAttribute('xmlns')) {
el.setAttribute('xmlns', "http://www.w3.org/2000/svg");
}
this.element = el;
this.config = config;
this.prepare();
}
/**
* Prepare the DOM element that will be cached in the
* loaded iconCache store.
*/
function prepareAndStyle() {
var viewBoxSize = this.config ? this.config.viewBoxSize : config.defaultViewBoxSize;
angular.forEach({
'fit': '',
'height': '100%',
'width': '100%',
'preserveAspectRatio': 'xMidYMid meet',
'viewBox': this.element.getAttribute('viewBox') || ('0 0 ' + viewBoxSize + ' ' + viewBoxSize),
'focusable': false // Disable IE11s default behavior to make SVGs focusable
}, function(val, attr) {
this.element.setAttribute(attr, val);
}, this);
}
/**
* Clone the Icon DOM element.
*/
function cloneSVG() {
// If the element or any of its children have a style attribute, then a CSP policy without
// 'unsafe-inline' in the style-src directive, will result in a violation.
return this.element.cloneNode(true);
}
} | [
"function",
"MdIconService",
"(",
"config",
",",
"$templateRequest",
",",
"$q",
",",
"$log",
",",
"$mdUtil",
",",
"$sce",
")",
"{",
"var",
"iconCache",
"=",
"{",
"}",
";",
"var",
"svgCache",
"=",
"{",
"}",
";",
"var",
"urlRegex",
"=",
"/",
"[-\\w@:%+.~... | @ngdoc service
@name $mdIcon
@module material.components.icon
@description
The `$mdIcon` service is a function used to lookup SVG icons.
@param {string} id Query value for a unique Id or URL. If the argument is a URL, then the service will retrieve the icon element
from its internal cache or load the icon and cache it first. If the value is not a URL-type string, then an ID lookup is
performed. The Id may be a unique icon ID or may include an iconSet ID prefix.
For the **id** query to work properly, this means that all id-to-URL mappings must have been previously configured
using the `$mdIconProvider`.
@returns {angular.$q.Promise} A promise that gets resolved to a clone of the initial SVG DOM element; which was
created from the SVG markup in the SVG data file. If an error occurs (e.g. the icon cannot be found) the promise
will get rejected.
@usage
<hljs lang="js">
function SomeDirective($mdIcon) {
// See if the icon has already been loaded, if not
// then lookup the icon from the registry cache, load and cache
// it for future requests.
// NOTE: ID queries require configuration with $mdIconProvider
$mdIcon('android').then(function(iconEl) { element.append(iconEl); });
$mdIcon('work:chair').then(function(iconEl) { element.append(iconEl); });
// Load and cache the external SVG using a URL
$mdIcon('img/icons/android.svg').then(function(iconEl) {
element.append(iconEl);
});
};
</hljs>
> <b>Note:</b> The `<md-icon>` directive internally uses the `$mdIcon` service to query, load,
and instantiate SVG DOM elements.
/* @ngInject | [
"@ngdoc",
"service",
"@name",
"$mdIcon",
"@module",
"material",
".",
"components",
".",
"icon"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/icon/js/iconService.js#L406-L735 | train | The MdIconService constructor. | [
30522,
3853,
9108,
28524,
8043,
7903,
2063,
1006,
9530,
8873,
2290,
1010,
1002,
23561,
2890,
15500,
1010,
1002,
1053,
1010,
1002,
8833,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
8040,
2063,
1007,
1063,
13075,
12696,
3540,
5403,
1027,
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... |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | _getInitialDocFromCurrent | function _getInitialDocFromCurrent() {
var doc = _getCurrentDocument(),
refPath,
i;
// Is the currently opened document already a file we can use for Live Development?
if (doc) {
refPath = doc.file.fullPath;
if (LiveDevelopmentUtils.isStaticHtmlFileExt(refPath) || LiveDevelopmentUtils.isServerHtmlFileExt(refPath)) {
return new $.Deferred().resolve(doc);
}
}
var result = new $.Deferred();
var baseUrl = ProjectManager.getBaseUrl(),
hasOwnServerForLiveDevelopment = (baseUrl && baseUrl.length);
ProjectManager.getAllFiles().done(function (allFiles) {
var projectRoot = ProjectManager.getProjectRoot().fullPath,
containingFolder,
indexFileFound = false,
stillInProjectTree = true;
if (refPath) {
containingFolder = FileUtils.getDirectoryPath(refPath);
} else {
containingFolder = projectRoot;
}
var filteredFiltered = allFiles.filter(function (item) {
var parent = FileUtils.getParentPath(item.fullPath);
return (containingFolder.indexOf(parent) === 0);
});
var filterIndexFile = function (fileInfo) {
if (fileInfo.fullPath.indexOf(containingFolder) === 0) {
if (FileUtils.getFilenameWithoutExtension(fileInfo.name) === "index") {
if (hasOwnServerForLiveDevelopment) {
if ((LiveDevelopmentUtils.isServerHtmlFileExt(fileInfo.name)) ||
(LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name))) {
return true;
}
} else if (LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name)) {
return true;
}
} else {
return false;
}
}
};
while (!indexFileFound && stillInProjectTree) {
i = _.findIndex(filteredFiltered, filterIndexFile);
// We found no good match
if (i === -1) {
// traverse the directory tree up one level
containingFolder = FileUtils.getParentPath(containingFolder);
// Are we still inside the project?
if (containingFolder.indexOf(projectRoot) === -1) {
stillInProjectTree = false;
}
} else {
indexFileFound = true;
}
}
if (i !== -1) {
DocumentManager.getDocumentForPath(filteredFiltered[i].fullPath).then(result.resolve, result.resolve);
return;
}
result.resolve(null);
});
return result.promise();
} | javascript | function _getInitialDocFromCurrent() {
var doc = _getCurrentDocument(),
refPath,
i;
// Is the currently opened document already a file we can use for Live Development?
if (doc) {
refPath = doc.file.fullPath;
if (LiveDevelopmentUtils.isStaticHtmlFileExt(refPath) || LiveDevelopmentUtils.isServerHtmlFileExt(refPath)) {
return new $.Deferred().resolve(doc);
}
}
var result = new $.Deferred();
var baseUrl = ProjectManager.getBaseUrl(),
hasOwnServerForLiveDevelopment = (baseUrl && baseUrl.length);
ProjectManager.getAllFiles().done(function (allFiles) {
var projectRoot = ProjectManager.getProjectRoot().fullPath,
containingFolder,
indexFileFound = false,
stillInProjectTree = true;
if (refPath) {
containingFolder = FileUtils.getDirectoryPath(refPath);
} else {
containingFolder = projectRoot;
}
var filteredFiltered = allFiles.filter(function (item) {
var parent = FileUtils.getParentPath(item.fullPath);
return (containingFolder.indexOf(parent) === 0);
});
var filterIndexFile = function (fileInfo) {
if (fileInfo.fullPath.indexOf(containingFolder) === 0) {
if (FileUtils.getFilenameWithoutExtension(fileInfo.name) === "index") {
if (hasOwnServerForLiveDevelopment) {
if ((LiveDevelopmentUtils.isServerHtmlFileExt(fileInfo.name)) ||
(LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name))) {
return true;
}
} else if (LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name)) {
return true;
}
} else {
return false;
}
}
};
while (!indexFileFound && stillInProjectTree) {
i = _.findIndex(filteredFiltered, filterIndexFile);
// We found no good match
if (i === -1) {
// traverse the directory tree up one level
containingFolder = FileUtils.getParentPath(containingFolder);
// Are we still inside the project?
if (containingFolder.indexOf(projectRoot) === -1) {
stillInProjectTree = false;
}
} else {
indexFileFound = true;
}
}
if (i !== -1) {
DocumentManager.getDocumentForPath(filteredFiltered[i].fullPath).then(result.resolve, result.resolve);
return;
}
result.resolve(null);
});
return result.promise();
} | [
"function",
"_getInitialDocFromCurrent",
"(",
")",
"{",
"var",
"doc",
"=",
"_getCurrentDocument",
"(",
")",
",",
"refPath",
",",
"i",
";",
"// Is the currently opened document already a file we can use for Live Development?",
"if",
"(",
"doc",
")",
"{",
"refPath",
"=",
... | @private
Determine an index file that can be used to start Live Development.
This function will inspect all files in a project to find the closest index file
available for currently opened document. We are searching for these files:
- index.html
- index.htm
If the project is configured with a custom base url for live development, then
the list of possible index files is extended to contain these index files too:
- index.php
- index.php3
- index.php4
- index.php5
- index.phtm
- index.phtml
- index.cfm
- index.cfml
- index.asp
- index.aspx
- index.jsp
- index.jspx
- index.shm
- index.shml
If a file was found, the promise will be resolved with the full path to this file. If no file
was found in the whole project tree, the promise will be resolved with null.
@return {jQuery.Promise} A promise that is resolved with a full path
to a file if one could been determined, or null if there was no suitable index
file. | [
"@private",
"Determine",
"an",
"index",
"file",
"that",
"can",
"be",
"used",
"to",
"start",
"Live",
"Development",
".",
"This",
"function",
"will",
"inspect",
"all",
"files",
"in",
"a",
"project",
"to",
"find",
"the",
"closest",
"index",
"file",
"available",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L691-L769 | train | Get the initial document from the current file | [
30522,
3853,
1035,
2131,
5498,
20925,
3527,
2278,
19699,
5358,
10841,
14343,
3372,
1006,
1007,
1063,
13075,
9986,
1027,
1035,
2131,
10841,
14343,
3372,
3527,
24894,
4765,
1006,
1007,
1010,
25416,
15069,
1010,
1045,
1025,
1013,
1013,
2003,
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... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | function(options) {
var globalDefaults = core_defaults.global;
var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
var font = {
family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily),
lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeight, globalDefaults.defaultLineHeight), size),
size: size,
style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle),
weight: null,
string: ''
};
font.string = toFontString(font);
return font;
} | javascript | function(options) {
var globalDefaults = core_defaults.global;
var size = valueOrDefault(options.fontSize, globalDefaults.defaultFontSize);
var font = {
family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFamily),
lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.lineHeight, globalDefaults.defaultLineHeight), size),
size: size,
style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyle),
weight: null,
string: ''
};
font.string = toFontString(font);
return font;
} | [
"function",
"(",
"options",
")",
"{",
"var",
"globalDefaults",
"=",
"core_defaults",
".",
"global",
";",
"var",
"size",
"=",
"valueOrDefault",
"(",
"options",
".",
"fontSize",
",",
"globalDefaults",
".",
"defaultFontSize",
")",
";",
"var",
"font",
"=",
"{",
... | Parses font options and returns the font object.
@param {object} options - A object that contains font options to be parsed.
@return {object} The font object.
@todo Support font.* options and renamed to toFont().
@private | [
"Parses",
"font",
"options",
"and",
"returns",
"the",
"font",
"object",
"."
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L2642-L2656 | train | Creates a font object from the given options | [
30522,
3853,
1006,
7047,
1007,
1063,
13075,
3795,
3207,
7011,
11314,
2015,
1027,
4563,
1035,
12398,
2015,
1012,
3795,
1025,
13075,
2946,
1027,
3643,
8551,
12879,
23505,
1006,
7047,
1012,
15489,
5332,
4371,
1010,
3795,
3207,
7011,
11314,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
facebook/relay | packages/relay-compiler/transforms/RelayMaskTransform.js | relayMaskTransform | function relayMaskTransform(context: CompilerContext): CompilerContext {
return IRTransformer.transform(
context,
{
FragmentSpread: visitFragmentSpread,
Fragment: visitFragment,
},
() => ({
reachableArguments: [],
}),
);
} | javascript | function relayMaskTransform(context: CompilerContext): CompilerContext {
return IRTransformer.transform(
context,
{
FragmentSpread: visitFragmentSpread,
Fragment: visitFragment,
},
() => ({
reachableArguments: [],
}),
);
} | [
"function",
"relayMaskTransform",
"(",
"context",
":",
"CompilerContext",
")",
":",
"CompilerContext",
"{",
"return",
"IRTransformer",
".",
"transform",
"(",
"context",
",",
"{",
"FragmentSpread",
":",
"visitFragmentSpread",
",",
"Fragment",
":",
"visitFragment",
",... | A transform that inlines fragment spreads with the @relay(mask: false)
directive. | [
"A",
"transform",
"that",
"inlines",
"fragment",
"spreads",
"with",
"the"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/transforms/RelayMaskTransform.js#L40-L51 | train | relay mask transform | [
30522,
3853,
8846,
9335,
25509,
5521,
22747,
2953,
2213,
1006,
6123,
1024,
21624,
8663,
18209,
1007,
1024,
21624,
8663,
18209,
1063,
2709,
20868,
6494,
3619,
14192,
2121,
1012,
10938,
1006,
6123,
1010,
1063,
10341,
28139,
4215,
1024,
3942,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | unmergeOne | function unmergeOne(ele) {
ele = ele[0];
var _p = this._private;
var id = ele._private.data.id;
var map = _p.map;
var entry = map.get(id);
if (!entry) {
return this; // no need to remove
}
var i = entry.index;
this.unmergeAt(i);
return this;
} | javascript | function unmergeOne(ele) {
ele = ele[0];
var _p = this._private;
var id = ele._private.data.id;
var map = _p.map;
var entry = map.get(id);
if (!entry) {
return this; // no need to remove
}
var i = entry.index;
this.unmergeAt(i);
return this;
} | [
"function",
"unmergeOne",
"(",
"ele",
")",
"{",
"ele",
"=",
"ele",
"[",
"0",
"]",
";",
"var",
"_p",
"=",
"this",
".",
"_private",
";",
"var",
"id",
"=",
"ele",
".",
"_private",
".",
"data",
".",
"id",
";",
"var",
"map",
"=",
"_p",
".",
"map",
... | remove single ele in place in calling collection | [
"remove",
"single",
"ele",
"in",
"place",
"in",
"calling",
"collection"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L10300-L10314 | train | remove one node from the node | [
30522,
3853,
4895,
5017,
3351,
5643,
1006,
3449,
2063,
1007,
1063,
3449,
2063,
1027,
3449,
2063,
1031,
1014,
1033,
1025,
13075,
1035,
1052,
1027,
2023,
1012,
1035,
2797,
1025,
13075,
8909,
1027,
3449,
2063,
1012,
1035,
2797,
1012,
2951,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/transform-apijson-for-sdk.js | getAPIJSONPromise | function getAPIJSONPromise(oChainObject) {
return new Promise(function(oResolve, oReject) {
fs.readFile(sInputFile, 'utf8', (oError, sFileData) => {
if (oError) {
oReject(oError);
} else {
oChainObject.fileData = JSON.parse(sFileData);
oResolve(oChainObject);
}
});
});
} | javascript | function getAPIJSONPromise(oChainObject) {
return new Promise(function(oResolve, oReject) {
fs.readFile(sInputFile, 'utf8', (oError, sFileData) => {
if (oError) {
oReject(oError);
} else {
oChainObject.fileData = JSON.parse(sFileData);
oResolve(oChainObject);
}
});
});
} | [
"function",
"getAPIJSONPromise",
"(",
"oChainObject",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"oResolve",
",",
"oReject",
")",
"{",
"fs",
".",
"readFile",
"(",
"sInputFile",
",",
"'utf8'",
",",
"(",
"oError",
",",
"sFileData",
")",
"=>"... | Load api.json file
@param {object} oChainObject chain object
@returns {object} chain object | [
"Load",
"api",
".",
"json",
"file"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L880-L891 | train | Reads the API JSON file and parses it into an object | [
30522,
3853,
2131,
9331,
28418,
3385,
21572,
28732,
1006,
28166,
8113,
16429,
20614,
1007,
1063,
2709,
2047,
4872,
1006,
3853,
1006,
10848,
19454,
3726,
1010,
10848,
20614,
1007,
1063,
1042,
2015,
1012,
3191,
8873,
2571,
1006,
8254,
18780,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetView.js | _viewFromEl | function _viewFromEl($el) {
if (!$el.hasClass("working-set-view")) {
$el = $el.parents(".working-set-view");
}
var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop();
return _views[id];
} | javascript | function _viewFromEl($el) {
if (!$el.hasClass("working-set-view")) {
$el = $el.parents(".working-set-view");
}
var id = $el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop();
return _views[id];
} | [
"function",
"_viewFromEl",
"(",
"$el",
")",
"{",
"if",
"(",
"!",
"$el",
".",
"hasClass",
"(",
"\"working-set-view\"",
")",
")",
"{",
"$el",
"=",
"$el",
".",
"parents",
"(",
"\".working-set-view\"",
")",
";",
"}",
"var",
"id",
"=",
"$el",
".",
"attr",
... | Finds the WorkingSetView object for the specified element
@private
@param {jQuery} $el - the element to find the view for
@return {View} view object | [
"Finds",
"the",
"WorkingSetView",
"object",
"for",
"the",
"specified",
"element"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L226-L233 | train | Get the view from an element | [
30522,
3853,
1035,
3193,
19699,
8462,
2140,
1006,
1002,
3449,
1007,
1063,
2065,
1006,
999,
1002,
3449,
1012,
2038,
26266,
1006,
1000,
2551,
1011,
2275,
1011,
3193,
1000,
1007,
1007,
1063,
1002,
3449,
1027,
1002,
3449,
1012,
3008,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/CodeFolding/Prefs.js | setFolds | function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
} | javascript | function setFolds(path, folds) {
var context = getViewStateContext();
var allFolds = PreferencesManager.getViewState(FOLDS_PREF_KEY, context);
allFolds[path] = simplify(folds);
PreferencesManager.setViewState(FOLDS_PREF_KEY, allFolds, context);
} | [
"function",
"setFolds",
"(",
"path",
",",
"folds",
")",
"{",
"var",
"context",
"=",
"getViewStateContext",
"(",
")",
";",
"var",
"allFolds",
"=",
"PreferencesManager",
".",
"getViewState",
"(",
"FOLDS_PREF_KEY",
",",
"context",
")",
";",
"allFolds",
"[",
"pa... | Saves the line folds for the specified path
@param {!string} path the path to the document
@param {Object} folds the fold ranges to save for the current document | [
"Saves",
"the",
"line",
"folds",
"for",
"the",
"specified",
"path"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/Prefs.js#L108-L113 | train | Set the folds for a path | [
30522,
3853,
2275,
10371,
2015,
1006,
4130,
1010,
15439,
1007,
1063,
13075,
6123,
1027,
2131,
8584,
9153,
26557,
28040,
18413,
1006,
1007,
1025,
13075,
2035,
10371,
2015,
1027,
18394,
24805,
4590,
1012,
2131,
8584,
9153,
2618,
1006,
15439,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AppCacheBuster.js | function() {
// activate the session (do not create the session for compatibility reasons with mIndex previously)
oSession.active = true;
// store the original function / property description to intercept
fnValidateProperty = ManagedObject.prototype.validateProperty;
descScriptSrc = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src");
descLinkHref = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href");
// function shortcuts (better performance when used frequently!)
var fnConvertUrl = AppCacheBuster.convertURL;
var fnNormalizeUrl = AppCacheBuster.normalizeURL;
// resources URL's will be handled via standard
// UI5 cachebuster mechanism (so we simply ignore them)
var fnIsACBUrl = function(sUrl) {
if (this.active === true && sUrl && typeof (sUrl) === "string") {
sUrl = fnNormalizeUrl(sUrl);
return !sUrl.match(oFilter);
}
return false;
}.bind(oSession);
// enhance xhr with appCacheBuster functionality
fnXhrOpenOrig = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(sMethod, sUrl) {
if (sUrl && fnIsACBUrl(sUrl)) {
arguments[1] = fnConvertUrl(sUrl);
}
fnXhrOpenOrig.apply(this, arguments);
};
fnEnhancedXhrOpen = XMLHttpRequest.prototype.open;
// enhance the validateProperty function to intercept URI types
// test via: new sap.ui.commons.Image({src: "acctest/img/Employee.png"}).getSrc()
// new sap.ui.commons.Image({src: "./acctest/../acctest/img/Employee.png"}).getSrc()
ManagedObject.prototype.validateProperty = function(sPropertyName, oValue) {
var oMetadata = this.getMetadata(),
oProperty = oMetadata.getProperty(sPropertyName),
oArgs;
if (oProperty && oProperty.type === "sap.ui.core.URI") {
oArgs = Array.prototype.slice.apply(arguments);
try {
if (fnIsACBUrl(oArgs[1] /* oValue */)) {
oArgs[1] = fnConvertUrl(oArgs[1] /* oValue */);
}
} catch (e) {
// URI normalization or conversion failed, fall back to normal processing
}
}
// either forward the modified or the original arguments
return fnValidateProperty.apply(this, oArgs || arguments);
};
// create an interceptor description which validates the value
// of the setter whether to rewrite the URL or not
var fnCreateInterceptorDescriptor = function(descriptor) {
var newDescriptor = {
get: descriptor.get,
set: function(val) {
if (fnIsACBUrl(val)) {
val = fnConvertUrl(val);
}
descriptor.set.call(this, val);
},
enumerable: descriptor.enumerable,
configurable: descriptor.configurable
};
newDescriptor.set._sapUiCoreACB = true;
return newDescriptor;
};
// try to setup the property descriptor interceptors (not supported on all browsers, e.g. iOS9)
var bError = false;
try {
Object.defineProperty(HTMLScriptElement.prototype, "src", fnCreateInterceptorDescriptor(descScriptSrc));
} catch (ex) {
Log.error("Your browser doesn't support redefining the src property of the script tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex);
bError = true;
}
try {
Object.defineProperty(HTMLLinkElement.prototype, "href", fnCreateInterceptorDescriptor(descLinkHref));
} catch (ex) {
Log.error("Your browser doesn't support redefining the href property of the link tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex);
bError = true;
}
// in case of setup issues we stop the AppCacheBuster support
if (bError) {
this.exit();
}
} | javascript | function() {
// activate the session (do not create the session for compatibility reasons with mIndex previously)
oSession.active = true;
// store the original function / property description to intercept
fnValidateProperty = ManagedObject.prototype.validateProperty;
descScriptSrc = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src");
descLinkHref = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href");
// function shortcuts (better performance when used frequently!)
var fnConvertUrl = AppCacheBuster.convertURL;
var fnNormalizeUrl = AppCacheBuster.normalizeURL;
// resources URL's will be handled via standard
// UI5 cachebuster mechanism (so we simply ignore them)
var fnIsACBUrl = function(sUrl) {
if (this.active === true && sUrl && typeof (sUrl) === "string") {
sUrl = fnNormalizeUrl(sUrl);
return !sUrl.match(oFilter);
}
return false;
}.bind(oSession);
// enhance xhr with appCacheBuster functionality
fnXhrOpenOrig = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(sMethod, sUrl) {
if (sUrl && fnIsACBUrl(sUrl)) {
arguments[1] = fnConvertUrl(sUrl);
}
fnXhrOpenOrig.apply(this, arguments);
};
fnEnhancedXhrOpen = XMLHttpRequest.prototype.open;
// enhance the validateProperty function to intercept URI types
// test via: new sap.ui.commons.Image({src: "acctest/img/Employee.png"}).getSrc()
// new sap.ui.commons.Image({src: "./acctest/../acctest/img/Employee.png"}).getSrc()
ManagedObject.prototype.validateProperty = function(sPropertyName, oValue) {
var oMetadata = this.getMetadata(),
oProperty = oMetadata.getProperty(sPropertyName),
oArgs;
if (oProperty && oProperty.type === "sap.ui.core.URI") {
oArgs = Array.prototype.slice.apply(arguments);
try {
if (fnIsACBUrl(oArgs[1] /* oValue */)) {
oArgs[1] = fnConvertUrl(oArgs[1] /* oValue */);
}
} catch (e) {
// URI normalization or conversion failed, fall back to normal processing
}
}
// either forward the modified or the original arguments
return fnValidateProperty.apply(this, oArgs || arguments);
};
// create an interceptor description which validates the value
// of the setter whether to rewrite the URL or not
var fnCreateInterceptorDescriptor = function(descriptor) {
var newDescriptor = {
get: descriptor.get,
set: function(val) {
if (fnIsACBUrl(val)) {
val = fnConvertUrl(val);
}
descriptor.set.call(this, val);
},
enumerable: descriptor.enumerable,
configurable: descriptor.configurable
};
newDescriptor.set._sapUiCoreACB = true;
return newDescriptor;
};
// try to setup the property descriptor interceptors (not supported on all browsers, e.g. iOS9)
var bError = false;
try {
Object.defineProperty(HTMLScriptElement.prototype, "src", fnCreateInterceptorDescriptor(descScriptSrc));
} catch (ex) {
Log.error("Your browser doesn't support redefining the src property of the script tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex);
bError = true;
}
try {
Object.defineProperty(HTMLLinkElement.prototype, "href", fnCreateInterceptorDescriptor(descLinkHref));
} catch (ex) {
Log.error("Your browser doesn't support redefining the href property of the link tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex);
bError = true;
}
// in case of setup issues we stop the AppCacheBuster support
if (bError) {
this.exit();
}
} | [
"function",
"(",
")",
"{",
"// activate the session (do not create the session for compatibility reasons with mIndex previously)",
"oSession",
".",
"active",
"=",
"true",
";",
"// store the original function / property description to intercept",
"fnValidateProperty",
"=",
"ManagedObject"... | Initializes the AppCacheBuster. Hooks into the relevant functions
in the Core to intercept the code which are dealing with URLs and
converts those URLs into cachebuster URLs.
The intercepted functions are:
<ul>
<li><code>XMLHttpRequest.prototype.open</code></li>
<li><code>HTMLScriptElement.prototype.src</code></li>
<li><code>HTMLLinkElement.prototype.href</code></li>
<li><code>sap.ui.base.ManagedObject.prototype.validateProperty</code></li>
</ul>
@private | [
"Initializes",
"the",
"AppCacheBuster",
".",
"Hooks",
"into",
"the",
"relevant",
"functions",
"in",
"the",
"Core",
"to",
"intercept",
"the",
"code",
"which",
"are",
"dealing",
"with",
"URLs",
"and",
"converts",
"those",
"URLs",
"into",
"cachebuster",
"URLs",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/AppCacheBuster.js#L332-L425 | train | This function is called by the sap. ui. core. ObjectRegistry to create a new instance of the object | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
20544,
1996,
5219,
1006,
2079,
2025,
3443,
1996,
5219,
2005,
21778,
4436,
2007,
2568,
10288,
3130,
1007,
9808,
7971,
3258,
1012,
3161,
1027,
2995,
1025,
1013,
1013,
3573,
1996,
2434,
3853,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
goldfire/howler.js | dist/howler.js | function() {
// If we have already detected that Web Audio isn't supported, don't run this step again.
if (!Howler.usingWebAudio) {
return;
}
// Check if we are using Web Audio and setup the AudioContext if we are.
try {
if (typeof AudioContext !== 'undefined') {
Howler.ctx = new AudioContext();
} else if (typeof webkitAudioContext !== 'undefined') {
Howler.ctx = new webkitAudioContext();
} else {
Howler.usingWebAudio = false;
}
} catch(e) {
Howler.usingWebAudio = false;
}
// If the audio context creation still failed, set using web audio to false.
if (!Howler.ctx) {
Howler.usingWebAudio = false;
}
// Check if a webview is being used on iOS8 or earlier (rather than the browser).
// If it is, disable Web Audio as it causes crashing.
var iOS = (/iP(hone|od|ad)/.test(Howler._navigator && Howler._navigator.platform));
var appVersion = Howler._navigator && Howler._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
var version = appVersion ? parseInt(appVersion[1], 10) : null;
if (iOS && version && version < 9) {
var safari = /safari/.test(Howler._navigator && Howler._navigator.userAgent.toLowerCase());
if (Howler._navigator && Howler._navigator.standalone && !safari || Howler._navigator && !Howler._navigator.standalone && !safari) {
Howler.usingWebAudio = false;
}
}
// Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage).
if (Howler.usingWebAudio) {
Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain();
Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : 1, Howler.ctx.currentTime);
Howler.masterGain.connect(Howler.ctx.destination);
}
// Re-run the setup on Howler.
Howler._setup();
} | javascript | function() {
// If we have already detected that Web Audio isn't supported, don't run this step again.
if (!Howler.usingWebAudio) {
return;
}
// Check if we are using Web Audio and setup the AudioContext if we are.
try {
if (typeof AudioContext !== 'undefined') {
Howler.ctx = new AudioContext();
} else if (typeof webkitAudioContext !== 'undefined') {
Howler.ctx = new webkitAudioContext();
} else {
Howler.usingWebAudio = false;
}
} catch(e) {
Howler.usingWebAudio = false;
}
// If the audio context creation still failed, set using web audio to false.
if (!Howler.ctx) {
Howler.usingWebAudio = false;
}
// Check if a webview is being used on iOS8 or earlier (rather than the browser).
// If it is, disable Web Audio as it causes crashing.
var iOS = (/iP(hone|od|ad)/.test(Howler._navigator && Howler._navigator.platform));
var appVersion = Howler._navigator && Howler._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
var version = appVersion ? parseInt(appVersion[1], 10) : null;
if (iOS && version && version < 9) {
var safari = /safari/.test(Howler._navigator && Howler._navigator.userAgent.toLowerCase());
if (Howler._navigator && Howler._navigator.standalone && !safari || Howler._navigator && !Howler._navigator.standalone && !safari) {
Howler.usingWebAudio = false;
}
}
// Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage).
if (Howler.usingWebAudio) {
Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain();
Howler.masterGain.gain.setValueAtTime(Howler._muted ? 0 : 1, Howler.ctx.currentTime);
Howler.masterGain.connect(Howler.ctx.destination);
}
// Re-run the setup on Howler.
Howler._setup();
} | [
"function",
"(",
")",
"{",
"// If we have already detected that Web Audio isn't supported, don't run this step again.",
"if",
"(",
"!",
"Howler",
".",
"usingWebAudio",
")",
"{",
"return",
";",
"}",
"// Check if we are using Web Audio and setup the AudioContext if we are.",
"try",
... | Setup the audio context when available, or switch to HTML5 Audio mode. | [
"Setup",
"the",
"audio",
"context",
"when",
"available",
"or",
"switch",
"to",
"HTML5",
"Audio",
"mode",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2423-L2468 | train | This function is called by the initialization of the module. It is called by the initialization of the module and the module is not called directly. | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
2065,
2057,
2031,
2525,
11156,
2008,
4773,
5746,
3475,
1005,
1056,
3569,
1010,
2123,
1005,
1056,
2448,
2023,
3357,
2153,
1012,
2065,
1006,
999,
22912,
2121,
1012,
2478,
8545,
27773,
20617,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function () {
var e, c, v, index = i;
c = this.combinator();
e = $re(/^(?:\d+\.\d+|\d+)%/) || $re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
$char('*') || $char('&') || this.attribute() || $re(/^\([^()@]+\)/) || $re(/^[\.#](?=@)/) ||
this.entities.variableCurly();
if (! e) {
if ($char('(')) {
if ((v = this.selector()) && $char(')')) {
e = new(tree.Paren)(v);
}
}
}
if (e) { return new(tree.Element)(c, e, index, env.currentFileInfo); }
} | javascript | function () {
var e, c, v, index = i;
c = this.combinator();
e = $re(/^(?:\d+\.\d+|\d+)%/) || $re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||
$char('*') || $char('&') || this.attribute() || $re(/^\([^()@]+\)/) || $re(/^[\.#](?=@)/) ||
this.entities.variableCurly();
if (! e) {
if ($char('(')) {
if ((v = this.selector()) && $char(')')) {
e = new(tree.Paren)(v);
}
}
}
if (e) { return new(tree.Element)(c, e, index, env.currentFileInfo); }
} | [
"function",
"(",
")",
"{",
"var",
"e",
",",
"c",
",",
"v",
",",
"index",
"=",
"i",
";",
"c",
"=",
"this",
".",
"combinator",
"(",
")",
";",
"e",
"=",
"$re",
"(",
"/",
"^(?:\\d+\\.\\d+|\\d+)%",
"/",
")",
"||",
"$re",
"(",
"/",
"^(?:[.#]?|:*)(?:[\\... | A Selector Element div + h1 #socks input[type="text"] Elements are the building blocks for Selectors, they are made out of a `Combinator` (see combinator rule), and an element name, such as a tag a class, or `*`. | [
"A",
"Selector",
"Element",
"div",
"+",
"h1",
"#socks",
"input",
"[",
"type",
"=",
"text",
"]",
"Elements",
"are",
"the",
"building",
"blocks",
"for",
"Selectors",
"they",
"are",
"made",
"out",
"of",
"a",
"Combinator",
"(",
"see",
"combinator",
"rule",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1356-L1374 | train | returns a node if it is an element | [
30522,
3853,
1006,
1007,
1063,
13075,
1041,
1010,
1039,
1010,
1058,
1010,
5950,
1027,
1045,
1025,
1039,
1027,
2023,
1012,
22863,
23207,
1006,
1007,
1025,
1041,
1027,
1002,
2128,
1006,
1013,
1034,
1006,
1029,
1024,
1032,
1040,
1009,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/Agents/CSSAgent.js | load | function load() {
Inspector.Page.on("frameNavigated.CSSAgent", _onFrameNavigated);
Inspector.CSS.on("styleSheetAdded.CSSAgent", _styleSheetAdded);
Inspector.CSS.on("styleSheetRemoved.CSSAgent", _styleSheetRemoved);
// getAllStyleSheets was deleted beginning with Chrome 34
if (!_getAllStyleSheetsNotFound) {
Inspector.Page.on("frameStoppedLoading.CSSAgent", _onFrameStoppedLoading);
}
} | javascript | function load() {
Inspector.Page.on("frameNavigated.CSSAgent", _onFrameNavigated);
Inspector.CSS.on("styleSheetAdded.CSSAgent", _styleSheetAdded);
Inspector.CSS.on("styleSheetRemoved.CSSAgent", _styleSheetRemoved);
// getAllStyleSheets was deleted beginning with Chrome 34
if (!_getAllStyleSheetsNotFound) {
Inspector.Page.on("frameStoppedLoading.CSSAgent", _onFrameStoppedLoading);
}
} | [
"function",
"load",
"(",
")",
"{",
"Inspector",
".",
"Page",
".",
"on",
"(",
"\"frameNavigated.CSSAgent\"",
",",
"_onFrameNavigated",
")",
";",
"Inspector",
".",
"CSS",
".",
"on",
"(",
"\"styleSheetAdded.CSSAgent\"",
",",
"_styleSheetAdded",
")",
";",
"Inspector... | Initialize the agent | [
"Initialize",
"the",
"agent"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/CSSAgent.js#L210-L219 | train | Load all the styles | [
30522,
3853,
7170,
1006,
1007,
1063,
7742,
1012,
3931,
1012,
2006,
1006,
1000,
4853,
2532,
5737,
11644,
1012,
20116,
3736,
11461,
1000,
1010,
1035,
2006,
15643,
2532,
5737,
11644,
1007,
1025,
7742,
1012,
20116,
2015,
1012,
2006,
1006,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/dom-utils.js | DOMWalker__walk | function DOMWalker__walk(root) {
if (!root.childNodes)
throw new Error("root.childNodes does not exist");
var collectedResults = [];
for (var i = 0; i < root.childNodes.length; i++) {
var nodeStatus = this._callbackFilter(root.childNodes[i]);
var nodeTestResults = [];
switch (nodeStatus) {
case DOMWalker.FILTER_ACCEPT:
nodeTestResults = this._callbackNodeTest(root.childNodes[i]);
collectedResults = collectedResults.concat(nodeTestResults);
// no break here as we have to perform the _walk below too
case DOMWalker.FILTER_SKIP:
nodeTestResults = this._walk(root.childNodes[i]);
break;
default:
break;
}
collectedResults = collectedResults.concat(nodeTestResults);
}
return collectedResults;
} | javascript | function DOMWalker__walk(root) {
if (!root.childNodes)
throw new Error("root.childNodes does not exist");
var collectedResults = [];
for (var i = 0; i < root.childNodes.length; i++) {
var nodeStatus = this._callbackFilter(root.childNodes[i]);
var nodeTestResults = [];
switch (nodeStatus) {
case DOMWalker.FILTER_ACCEPT:
nodeTestResults = this._callbackNodeTest(root.childNodes[i]);
collectedResults = collectedResults.concat(nodeTestResults);
// no break here as we have to perform the _walk below too
case DOMWalker.FILTER_SKIP:
nodeTestResults = this._walk(root.childNodes[i]);
break;
default:
break;
}
collectedResults = collectedResults.concat(nodeTestResults);
}
return collectedResults;
} | [
"function",
"DOMWalker__walk",
"(",
"root",
")",
"{",
"if",
"(",
"!",
"root",
".",
"childNodes",
")",
"throw",
"new",
"Error",
"(",
"\"root.childNodes does not exist\"",
")",
";",
"var",
"collectedResults",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
... | DOMWalker_walk goes recursively through the DOM, starting with a provided
root-node.
First, it filters nodes by submitting each node to the this._callbackFilter
method to decide, if a node should be submitted to a provided
this._callbackNodeTest method to test (that hapens in case of
FILTER_ACCEPT).
In case of FILTER_ACCEPT and FILTER_SKIP, the children of such a node
will be filtered recursively.
Nodes with the nodeStatus "FILTER_REJECT" and their descendants will be
completetly ignored.
@param {Node} root
Node to start testing from
[optional - default: this._controller.window.document.documentElement]
@returns An array with gathered all results from testing a given element
@type {array of elements} | [
"DOMWalker_walk",
"goes",
"recursively",
"through",
"the",
"DOM",
"starting",
"with",
"a",
"provided",
"root",
"-",
"node",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L423-L449 | train | Walks the DOM tree and returns an array of results | [
30522,
3853,
14383,
26965,
1035,
1035,
3328,
1006,
7117,
1007,
1063,
2065,
1006,
999,
7117,
1012,
2775,
3630,
6155,
1007,
5466,
2047,
7561,
1006,
1000,
7117,
1012,
2775,
3630,
6155,
2515,
2025,
4839,
1000,
1007,
1025,
13075,
5067,
6072,
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... |
angular/material | src/components/panel/panel.spec.js | attachToBody | function attachToBody(el) {
var element = angular.element(el);
angular.element(document.body).append(element);
attachedElements.push(element);
} | javascript | function attachToBody(el) {
var element = angular.element(el);
angular.element(document.body).append(element);
attachedElements.push(element);
} | [
"function",
"attachToBody",
"(",
"el",
")",
"{",
"var",
"element",
"=",
"angular",
".",
"element",
"(",
"el",
")",
";",
"angular",
".",
"element",
"(",
"document",
".",
"body",
")",
".",
"append",
"(",
"element",
")",
";",
"attachedElements",
".",
"pus... | Attached an element to document.body. Keeps track of attached elements
so that they can be removed in an afterEach.
@param el | [
"Attached",
"an",
"element",
"to",
"document",
".",
"body",
".",
"Keeps",
"track",
"of",
"attached",
"elements",
"so",
"that",
"they",
"can",
"be",
"removed",
"in",
"an",
"afterEach",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/panel/panel.spec.js#L3366-L3370 | train | Attaches an element to the body | [
30522,
3853,
22476,
3406,
23684,
1006,
3449,
1007,
1063,
13075,
5783,
1027,
16108,
1012,
5783,
1006,
3449,
1007,
1025,
16108,
1012,
5783,
1006,
6254,
1012,
2303,
1007,
1012,
10439,
10497,
1006,
5783,
1007,
1025,
4987,
12260,
8163,
1012,
524... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/lines-around-directive.js | hasNewlineAfter | function hasNewlineAfter(node) {
const lastToken = getLastTokenOnLine(node);
const tokenAfter = sourceCode.getTokenAfter(lastToken, { includeComments: true });
return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
} | javascript | function hasNewlineAfter(node) {
const lastToken = getLastTokenOnLine(node);
const tokenAfter = sourceCode.getTokenAfter(lastToken, { includeComments: true });
return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
} | [
"function",
"hasNewlineAfter",
"(",
"node",
")",
"{",
"const",
"lastToken",
"=",
"getLastTokenOnLine",
"(",
"node",
")",
";",
"const",
"tokenAfter",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"lastToken",
",",
"{",
"includeComments",
":",
"true",
"}",
")",
... | Check if node is followed by a blank newline.
@param {ASTNode} node Node to check.
@returns {boolean} Whether or not the passed in node is followed by a blank newline. | [
"Check",
"if",
"node",
"is",
"followed",
"by",
"a",
"blank",
"newline",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-directive.js#L99-L104 | train | Check if node has a newline after the last token | [
30522,
3853,
8440,
7974,
4179,
10354,
3334,
1006,
13045,
1007,
1063,
9530,
3367,
2197,
18715,
2368,
1027,
2131,
8523,
9284,
7520,
2239,
4179,
1006,
13045,
1007,
1025,
9530,
3367,
19204,
10354,
3334,
1027,
3120,
16044,
1012,
2131,
18715,
818... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _setupGoLiveButton | function _setupGoLiveButton() {
if (!_$btnGoLive) {
_$btnGoLive = $("#toolbar-go-live");
_$btnGoLive.click(function onGoLive() {
_handleGoLiveCommand();
});
}
LiveDevImpl.on("statusChange", function statusChange(event, status, reason) {
// status starts at -1 (error), so add one when looking up name and style
// See the comments at the top of LiveDevelopment.js for details on the
// various status codes.
_setLabel(_$btnGoLive, null, _status[status + 1].style, _status[status + 1].tooltip);
_showStatusChangeReason(reason);
if (config.autoconnect) {
window.sessionStorage.setItem("live.enabled", status === 3);
}
});
// Initialize tooltip for 'not connected' state
_setLabel(_$btnGoLive, null, _status[1].style, _status[1].tooltip);
} | javascript | function _setupGoLiveButton() {
if (!_$btnGoLive) {
_$btnGoLive = $("#toolbar-go-live");
_$btnGoLive.click(function onGoLive() {
_handleGoLiveCommand();
});
}
LiveDevImpl.on("statusChange", function statusChange(event, status, reason) {
// status starts at -1 (error), so add one when looking up name and style
// See the comments at the top of LiveDevelopment.js for details on the
// various status codes.
_setLabel(_$btnGoLive, null, _status[status + 1].style, _status[status + 1].tooltip);
_showStatusChangeReason(reason);
if (config.autoconnect) {
window.sessionStorage.setItem("live.enabled", status === 3);
}
});
// Initialize tooltip for 'not connected' state
_setLabel(_$btnGoLive, null, _status[1].style, _status[1].tooltip);
} | [
"function",
"_setupGoLiveButton",
"(",
")",
"{",
"if",
"(",
"!",
"_$btnGoLive",
")",
"{",
"_$btnGoLive",
"=",
"$",
"(",
"\"#toolbar-go-live\"",
")",
";",
"_$btnGoLive",
".",
"click",
"(",
"function",
"onGoLive",
"(",
")",
"{",
"_handleGoLiveCommand",
"(",
")... | Create the menu item "Go Live" | [
"Create",
"the",
"menu",
"item",
"Go",
"Live"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L227-L247 | train | Setup the button that will go live | [
30522,
3853,
1035,
16437,
24141,
3512,
8569,
15474,
1006,
1007,
1063,
2065,
1006,
999,
1035,
1002,
18411,
16656,
3669,
3726,
1007,
1063,
1035,
1002,
18411,
16656,
3669,
3726,
1027,
1002,
1006,
1000,
1001,
6994,
8237,
1011,
2175,
1011,
2444,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getBinding("rows");
var iTotalRowCount = oTable._getTotalRowCount();
var bHasData = iTotalRowCount > 0;
if (oBinding && oBinding.providesGrandTotal) { // Analytical Binding
var bHasTotal = oBinding.providesGrandTotal() && oBinding.hasTotaledMeasures();
bHasData = (bHasTotal && iTotalRowCount > 1) || (!bHasTotal && iTotalRowCount > 0);
}
return bHasData;
} | javascript | function(oTable) {
var oBinding = oTable.getBinding("rows");
var iTotalRowCount = oTable._getTotalRowCount();
var bHasData = iTotalRowCount > 0;
if (oBinding && oBinding.providesGrandTotal) { // Analytical Binding
var bHasTotal = oBinding.providesGrandTotal() && oBinding.hasTotaledMeasures();
bHasData = (bHasTotal && iTotalRowCount > 1) || (!bHasTotal && iTotalRowCount > 0);
}
return bHasData;
} | [
"function",
"(",
"oTable",
")",
"{",
"var",
"oBinding",
"=",
"oTable",
".",
"getBinding",
"(",
"\"rows\"",
")",
";",
"var",
"iTotalRowCount",
"=",
"oTable",
".",
"_getTotalRowCount",
"(",
")",
";",
"var",
"bHasData",
"=",
"iTotalRowCount",
">",
"0",
";",
... | Returns whether the table currently has data.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {boolean} Whether the table has data. | [
"Returns",
"whether",
"the",
"table",
"currently",
"has",
"data",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L357-L368 | train | Returns true if the table has data. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
13075,
27885,
22254,
2075,
1027,
27178,
3085,
1012,
2131,
8428,
4667,
1006,
1000,
10281,
1000,
1007,
1025,
13075,
23333,
9080,
10524,
3597,
16671,
1027,
27178,
3085,
1012,
1035,
2131,
3406,
9080,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/19_fsutils.js | write_dl | function write_dl(fname/*:string*/, payload/*:any*/, enc/*:?string*/) {
/*global IE_SaveFile, Blob, navigator, saveAs, URL, document, File, chrome */
if(typeof _fs !== 'undefined' && _fs.writeFileSync) return enc ? _fs.writeFileSync(fname, payload, enc) : _fs.writeFileSync(fname, payload);
var data = (enc == "utf8") ? utf8write(payload) : payload;
/*:: declare var IE_SaveFile: any; */
if(typeof IE_SaveFile !== 'undefined') return IE_SaveFile(data, fname);
if(typeof Blob !== 'undefined') {
var blob = new Blob([blobify(data)], {type:"application/octet-stream"});
/*:: declare var navigator: any; */
if(typeof navigator !== 'undefined' && navigator.msSaveBlob) return navigator.msSaveBlob(blob, fname);
/*:: declare var saveAs: any; */
if(typeof saveAs !== 'undefined') return saveAs(blob, fname);
if(typeof URL !== 'undefined' && typeof document !== 'undefined' && document.createElement && URL.createObjectURL) {
var url = URL.createObjectURL(blob);
/*:: declare var chrome: any; */
if(typeof chrome === 'object' && typeof (chrome.downloads||{}).download == "function") {
if(URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function() { URL.revokeObjectURL(url); }, 60000);
return chrome.downloads.download({ url: url, filename: fname, saveAs: true});
}
var a = document.createElement("a");
if(a.download != null) {
/*:: if(document.body == null) throw new Error("unreachable"); */
a.download = fname; a.href = url; document.body.appendChild(a); a.click();
/*:: if(document.body == null) throw new Error("unreachable"); */ document.body.removeChild(a);
if(URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function() { URL.revokeObjectURL(url); }, 60000);
return url;
}
}
}
// $FlowIgnore
if(typeof $ !== 'undefined' && typeof File !== 'undefined' && typeof Folder !== 'undefined') try { // extendscript
// $FlowIgnore
var out = File(fname); out.open("w"); out.encoding = "binary";
if(Array.isArray(payload)) payload = a2s(payload);
out.write(payload); out.close(); return payload;
} catch(e) { if(!e.message || !e.message.match(/onstruct/)) throw e; }
throw new Error("cannot save file " + fname);
} | javascript | function write_dl(fname/*:string*/, payload/*:any*/, enc/*:?string*/) {
/*global IE_SaveFile, Blob, navigator, saveAs, URL, document, File, chrome */
if(typeof _fs !== 'undefined' && _fs.writeFileSync) return enc ? _fs.writeFileSync(fname, payload, enc) : _fs.writeFileSync(fname, payload);
var data = (enc == "utf8") ? utf8write(payload) : payload;
/*:: declare var IE_SaveFile: any; */
if(typeof IE_SaveFile !== 'undefined') return IE_SaveFile(data, fname);
if(typeof Blob !== 'undefined') {
var blob = new Blob([blobify(data)], {type:"application/octet-stream"});
/*:: declare var navigator: any; */
if(typeof navigator !== 'undefined' && navigator.msSaveBlob) return navigator.msSaveBlob(blob, fname);
/*:: declare var saveAs: any; */
if(typeof saveAs !== 'undefined') return saveAs(blob, fname);
if(typeof URL !== 'undefined' && typeof document !== 'undefined' && document.createElement && URL.createObjectURL) {
var url = URL.createObjectURL(blob);
/*:: declare var chrome: any; */
if(typeof chrome === 'object' && typeof (chrome.downloads||{}).download == "function") {
if(URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function() { URL.revokeObjectURL(url); }, 60000);
return chrome.downloads.download({ url: url, filename: fname, saveAs: true});
}
var a = document.createElement("a");
if(a.download != null) {
/*:: if(document.body == null) throw new Error("unreachable"); */
a.download = fname; a.href = url; document.body.appendChild(a); a.click();
/*:: if(document.body == null) throw new Error("unreachable"); */ document.body.removeChild(a);
if(URL.revokeObjectURL && typeof setTimeout !== 'undefined') setTimeout(function() { URL.revokeObjectURL(url); }, 60000);
return url;
}
}
}
// $FlowIgnore
if(typeof $ !== 'undefined' && typeof File !== 'undefined' && typeof Folder !== 'undefined') try { // extendscript
// $FlowIgnore
var out = File(fname); out.open("w"); out.encoding = "binary";
if(Array.isArray(payload)) payload = a2s(payload);
out.write(payload); out.close(); return payload;
} catch(e) { if(!e.message || !e.message.match(/onstruct/)) throw e; }
throw new Error("cannot save file " + fname);
} | [
"function",
"write_dl",
"(",
"fname",
"/*:string*/",
",",
"payload",
"/*:any*/",
",",
"enc",
"/*:?string*/",
")",
"{",
"/*global IE_SaveFile, Blob, navigator, saveAs, URL, document, File, chrome */",
"if",
"(",
"typeof",
"_fs",
"!==",
"'undefined'",
"&&",
"_fs",
".",
"w... | /* write or download file | [
"/",
"*",
"write",
"or",
"download",
"file"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/19_fsutils.js#L11-L48 | train | Writes a file to a local filesystem | [
30522,
3853,
4339,
1035,
21469,
1006,
1042,
18442,
1013,
1008,
1024,
5164,
1008,
1013,
1010,
18093,
1013,
1008,
1024,
2151,
1008,
1013,
1010,
4372,
2278,
1013,
1008,
1024,
1029,
5164,
1008,
1013,
1007,
1063,
1013,
1008,
3795,
29464,
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... |
nhn/tui.editor | src/js/wysiwygCommands/table.js | focusToFirstTh | function focusToFirstTh(sq, $table) {
const range = sq.getSelection();
range.selectNodeContents($table.find('th')[0]);
range.collapse(true);
sq.setSelection(range);
} | javascript | function focusToFirstTh(sq, $table) {
const range = sq.getSelection();
range.selectNodeContents($table.find('th')[0]);
range.collapse(true);
sq.setSelection(range);
} | [
"function",
"focusToFirstTh",
"(",
"sq",
",",
"$table",
")",
"{",
"const",
"range",
"=",
"sq",
".",
"getSelection",
"(",
")",
";",
"range",
".",
"selectNodeContents",
"(",
"$table",
".",
"find",
"(",
"'th'",
")",
"[",
"0",
"]",
")",
";",
"range",
"."... | Focus to first th
@param {Squire} sq Squire instance
@param {jQuery} $table jQuery wrapped table element | [
"Focus",
"to",
"first",
"th"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/table.js#L54-L60 | train | Focus to first th in table | [
30522,
3853,
3579,
3406,
8873,
12096,
2705,
1006,
5490,
1010,
1002,
2795,
1007,
1063,
9530,
3367,
2846,
1027,
5490,
1012,
4152,
12260,
7542,
1006,
1007,
1025,
2846,
1012,
7276,
3630,
3207,
8663,
6528,
3215,
1006,
1002,
2795,
1012,
2424,
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/filesystem/impls/appshell/AppshellFileSystem.js | readFile | function readFile(path, options, callback) {
var encoding = options.encoding || "utf8";
// callback to be executed when the call to stat completes
// or immediately if a stat object was passed as an argument
function doReadFile(stat) {
if (stat.size > (FileUtils.MAX_FILE_SIZE)) {
callback(FileSystemError.EXCEEDS_MAX_FILE_SIZE);
} else {
appshell.fs.readFile(path, encoding, function (_err, _data, encoding, preserveBOM) {
if (_err) {
callback(_mapError(_err));
} else {
callback(null, _data, encoding, preserveBOM, stat);
}
});
}
}
if (options.stat) {
doReadFile(options.stat);
} else {
exports.stat(path, function (_err, _stat) {
if (_err) {
callback(_err);
} else {
doReadFile(_stat);
}
});
}
} | javascript | function readFile(path, options, callback) {
var encoding = options.encoding || "utf8";
// callback to be executed when the call to stat completes
// or immediately if a stat object was passed as an argument
function doReadFile(stat) {
if (stat.size > (FileUtils.MAX_FILE_SIZE)) {
callback(FileSystemError.EXCEEDS_MAX_FILE_SIZE);
} else {
appshell.fs.readFile(path, encoding, function (_err, _data, encoding, preserveBOM) {
if (_err) {
callback(_mapError(_err));
} else {
callback(null, _data, encoding, preserveBOM, stat);
}
});
}
}
if (options.stat) {
doReadFile(options.stat);
} else {
exports.stat(path, function (_err, _stat) {
if (_err) {
callback(_err);
} else {
doReadFile(_stat);
}
});
}
} | [
"function",
"readFile",
"(",
"path",
",",
"options",
",",
"callback",
")",
"{",
"var",
"encoding",
"=",
"options",
".",
"encoding",
"||",
"\"utf8\"",
";",
"// callback to be executed when the call to stat completes",
"// or immediately if a stat object was passed as an argum... | Read the contents of the file at the given path, calling back
asynchronously with either a FileSystemError string, or with the data and
the FileSystemStats object associated with the read file. The options
parameter can be used to specify an encoding (default "utf8"), and also
a cached stats object that the implementation is free to use in order
to avoid an additional stat call.
Note: if either the read or the stat call fails then neither the read data
nor stat will be passed back, and the call should be considered to have failed.
If both calls fail, the error from the read call is passed back.
@param {string} path
@param {{encoding: string=, stat: FileSystemStats=}} options
@param {function(?string, string=, FileSystemStats=)} callback | [
"Read",
"the",
"contents",
"of",
"the",
"file",
"at",
"the",
"given",
"path",
"calling",
"back",
"asynchronously",
"with",
"either",
"a",
"FileSystemError",
"string",
"or",
"with",
"the",
"data",
"and",
"the",
"FileSystemStats",
"object",
"associated",
"with",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L363-L393 | train | readFile - Reads a file | [
30522,
3853,
3191,
8873,
2571,
1006,
4130,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
13075,
17181,
1027,
7047,
1012,
17181,
1064,
1064,
1000,
21183,
2546,
2620,
1000,
1025,
1013,
1013,
2655,
5963,
2000,
2022,
6472,
2043,
1996,
2655,
2000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/App.controller.js | function() {
var oViewModel = this.getModel("appView"),
bPhoneSize = oViewModel.getProperty("/bPhoneSize");
// Version switch should not be shown on phone sizes or when no versions are found
oViewModel.setProperty("/bShowVersionSwitchInHeader", !bPhoneSize && !!this._aNeoAppVersions);
oViewModel.setProperty("/bShowVersionSwitchInMenu", bPhoneSize && !!this._aNeoAppVersions);
} | javascript | function() {
var oViewModel = this.getModel("appView"),
bPhoneSize = oViewModel.getProperty("/bPhoneSize");
// Version switch should not be shown on phone sizes or when no versions are found
oViewModel.setProperty("/bShowVersionSwitchInHeader", !bPhoneSize && !!this._aNeoAppVersions);
oViewModel.setProperty("/bShowVersionSwitchInMenu", bPhoneSize && !!this._aNeoAppVersions);
} | [
"function",
"(",
")",
"{",
"var",
"oViewModel",
"=",
"this",
".",
"getModel",
"(",
"\"appView\"",
")",
",",
"bPhoneSize",
"=",
"oViewModel",
".",
"getProperty",
"(",
"\"/bPhoneSize\"",
")",
";",
"// Version switch should not be shown on phone sizes or when no versions a... | Determines whether or not to show the version change button.
@private | [
"Determines",
"whether",
"or",
"not",
"to",
"show",
"the",
"version",
"change",
"button",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/App.controller.js#L414-L421 | train | Sets the version switch in header or menu depending on the phone size | [
30522,
3853,
1006,
1007,
1063,
13075,
1051,
8584,
5302,
9247,
1027,
2023,
1012,
2131,
5302,
9247,
1006,
1000,
10439,
8584,
1000,
1007,
1010,
17531,
27406,
5332,
4371,
1027,
1051,
8584,
5302,
9247,
1012,
2131,
21572,
4842,
3723,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/editor/InlineWidget.js | InlineWidget | function InlineWidget() {
var self = this;
// create the outer wrapper div
this.htmlContent = window.document.createElement("div");
this.$htmlContent = $(this.htmlContent).addClass("inline-widget").attr("tabindex", "-1");
this.$htmlContent.append("<div class='shadow top' />")
.append("<div class='shadow bottom' />")
.append("<a href='#' class='close no-focus'>×</a>");
// create the close button
this.$closeBtn = this.$htmlContent.find(".close");
this.$closeBtn.click(function (e) {
self.close();
e.stopImmediatePropagation();
});
this.$htmlContent.on("keydown", function (e) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
self.close();
e.stopImmediatePropagation();
}
});
} | javascript | function InlineWidget() {
var self = this;
// create the outer wrapper div
this.htmlContent = window.document.createElement("div");
this.$htmlContent = $(this.htmlContent).addClass("inline-widget").attr("tabindex", "-1");
this.$htmlContent.append("<div class='shadow top' />")
.append("<div class='shadow bottom' />")
.append("<a href='#' class='close no-focus'>×</a>");
// create the close button
this.$closeBtn = this.$htmlContent.find(".close");
this.$closeBtn.click(function (e) {
self.close();
e.stopImmediatePropagation();
});
this.$htmlContent.on("keydown", function (e) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
self.close();
e.stopImmediatePropagation();
}
});
} | [
"function",
"InlineWidget",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// create the outer wrapper div",
"this",
".",
"htmlContent",
"=",
"window",
".",
"document",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"this",
".",
"$htmlContent",
"=",
"$",
... | @constructor | [
"@constructor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/InlineWidget.js#L36-L59 | train | Inline widget | [
30522,
3853,
23881,
9148,
24291,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
1013,
1013,
3443,
1996,
6058,
10236,
4842,
4487,
2615,
2023,
1012,
16129,
8663,
6528,
2102,
1027,
3332,
1012,
6254,
1012,
3443,
12260,
3672,
1006,
1000,
4487,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/tabs/js/tabsController.js | removeTab | function removeTab (tabData) {
if (destroyed) return;
var selectedIndex = ctrl.selectedIndex,
tab = ctrl.tabs.splice(tabData.getIndex(), 1)[ 0 ];
refreshIndex();
// when removing a tab, if the selected index did not change, we have to manually trigger the
// tab select/deselect events
if (ctrl.selectedIndex === selectedIndex) {
tab.scope.deselect();
ctrl.tabs[ ctrl.selectedIndex ] && ctrl.tabs[ ctrl.selectedIndex ].scope.select();
}
$mdUtil.nextTick(function () {
updatePagination();
ctrl.offsetLeft = fixOffset(ctrl.offsetLeft);
});
} | javascript | function removeTab (tabData) {
if (destroyed) return;
var selectedIndex = ctrl.selectedIndex,
tab = ctrl.tabs.splice(tabData.getIndex(), 1)[ 0 ];
refreshIndex();
// when removing a tab, if the selected index did not change, we have to manually trigger the
// tab select/deselect events
if (ctrl.selectedIndex === selectedIndex) {
tab.scope.deselect();
ctrl.tabs[ ctrl.selectedIndex ] && ctrl.tabs[ ctrl.selectedIndex ].scope.select();
}
$mdUtil.nextTick(function () {
updatePagination();
ctrl.offsetLeft = fixOffset(ctrl.offsetLeft);
});
} | [
"function",
"removeTab",
"(",
"tabData",
")",
"{",
"if",
"(",
"destroyed",
")",
"return",
";",
"var",
"selectedIndex",
"=",
"ctrl",
".",
"selectedIndex",
",",
"tab",
"=",
"ctrl",
".",
"tabs",
".",
"splice",
"(",
"tabData",
".",
"getIndex",
"(",
")",
",... | Remove a tab from the data and select the nearest valid tab.
@param {Object} tabData tab to remove | [
"Remove",
"a",
"tab",
"from",
"the",
"data",
"and",
"select",
"the",
"nearest",
"valid",
"tab",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L421-L436 | train | Removes a tab from the page | [
30522,
3853,
6366,
2696,
2497,
1006,
21628,
2850,
2696,
1007,
1063,
2065,
1006,
3908,
1007,
2709,
1025,
13075,
3479,
22254,
10288,
1027,
14931,
12190,
1012,
3479,
22254,
10288,
1010,
21628,
1027,
14931,
12190,
1012,
21628,
2015,
1012,
11867,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | bower_components/jvectormap/lib/world-map.js | function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
} | javascript | function(markers, seriesData){
var i;
seriesData = seriesData || [];
this.createMarkers(markers);
for (i = 0; i < seriesData.length; i++) {
this.series.markers[i].setValues(seriesData[i] || {});
};
} | [
"function",
"(",
"markers",
",",
"seriesData",
")",
"{",
"var",
"i",
";",
"seriesData",
"=",
"seriesData",
"||",
"[",
"]",
";",
"this",
".",
"createMarkers",
"(",
"markers",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"seriesData",
".",
"le... | Add set of marker to the map.
@param {Object|Array} markers Markers to add to the map. In case of array is provided, codes of markers will be set as string representations of array indexes.
@param {Array} seriesData Values to add to the data series. | [
"Add",
"set",
"of",
"marker",
"to",
"the",
"map",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L777-L786 | train | set markers and series data | [
30522,
3853,
1006,
16387,
1010,
2186,
2850,
2696,
1007,
1063,
13075,
1045,
1025,
2186,
2850,
2696,
1027,
2186,
2850,
2696,
1064,
1064,
1031,
1033,
1025,
2023,
1012,
3443,
10665,
2545,
1006,
16387,
1007,
1025,
2005,
1006,
1045,
1027,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/services/gesture/gesture.js | addHandler | function addHandler(name, definition) {
var handler = new $$MdGestureHandler(name);
angular.extend(handler, definition);
HANDLERS[name] = handler;
return self;
} | javascript | function addHandler(name, definition) {
var handler = new $$MdGestureHandler(name);
angular.extend(handler, definition);
HANDLERS[name] = handler;
return self;
} | [
"function",
"addHandler",
"(",
"name",
",",
"definition",
")",
"{",
"var",
"handler",
"=",
"new",
"$$MdGestureHandler",
"(",
"name",
")",
";",
"angular",
".",
"extend",
"(",
"handler",
",",
"definition",
")",
";",
"HANDLERS",
"[",
"name",
"]",
"=",
"hand... | /*
add a handler to $mdGesture. see below. | [
"/",
"*",
"add",
"a",
"handler",
"to",
"$mdGesture",
".",
"see",
"below",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L191-L197 | train | Adds a new gesture handler to the current container. | [
30522,
3853,
5587,
11774,
3917,
1006,
2171,
1010,
6210,
1007,
1063,
13075,
28213,
1027,
2047,
1002,
1002,
9108,
8449,
11244,
11774,
3917,
1006,
2171,
1007,
1025,
16108,
1012,
7949,
1006,
28213,
1010,
6210,
1007,
1025,
28213,
2015,
1031,
217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | examples/animation.js | bounce | function bounce(t) {
const s = 7.5625;
const p = 2.75;
let l;
if (t < (1 / p)) {
l = s * t * t;
} else {
if (t < (2 / p)) {
t -= (1.5 / p);
l = s * t * t + 0.75;
} else {
if (t < (2.5 / p)) {
t -= (2.25 / p);
l = s * t * t + 0.9375;
} else {
t -= (2.625 / p);
l = s * t * t + 0.984375;
}
}
}
return l;
} | javascript | function bounce(t) {
const s = 7.5625;
const p = 2.75;
let l;
if (t < (1 / p)) {
l = s * t * t;
} else {
if (t < (2 / p)) {
t -= (1.5 / p);
l = s * t * t + 0.75;
} else {
if (t < (2.5 / p)) {
t -= (2.25 / p);
l = s * t * t + 0.9375;
} else {
t -= (2.625 / p);
l = s * t * t + 0.984375;
}
}
}
return l;
} | [
"function",
"bounce",
"(",
"t",
")",
"{",
"const",
"s",
"=",
"7.5625",
";",
"const",
"p",
"=",
"2.75",
";",
"let",
"l",
";",
"if",
"(",
"t",
"<",
"(",
"1",
"/",
"p",
")",
")",
"{",
"l",
"=",
"s",
"*",
"t",
"*",
"t",
";",
"}",
"else",
"{... | A bounce easing method (from https://github.com/DmitryBaranovskiy/raphael). | [
"A",
"bounce",
"easing",
"method",
"(",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"DmitryBaranovskiy",
"/",
"raphael",
")",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/animation.js#L31-L52 | train | bounce t | [
30522,
3853,
17523,
1006,
1056,
1007,
1063,
9530,
3367,
1055,
1027,
1021,
1012,
5179,
17788,
1025,
9530,
3367,
1052,
1027,
1016,
1012,
4293,
1025,
2292,
1048,
1025,
2065,
1006,
1056,
1026,
1006,
1015,
1013,
1052,
1007,
1007,
1063,
1048,
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/project/ProjectManager.js | setBaseUrl | function setBaseUrl(projectBaseUrl) {
var context = _getProjectViewStateContext();
projectBaseUrl = model.setBaseUrl(projectBaseUrl);
PreferencesManager.setViewState("project.baseUrl", projectBaseUrl, context);
} | javascript | function setBaseUrl(projectBaseUrl) {
var context = _getProjectViewStateContext();
projectBaseUrl = model.setBaseUrl(projectBaseUrl);
PreferencesManager.setViewState("project.baseUrl", projectBaseUrl, context);
} | [
"function",
"setBaseUrl",
"(",
"projectBaseUrl",
")",
"{",
"var",
"context",
"=",
"_getProjectViewStateContext",
"(",
")",
";",
"projectBaseUrl",
"=",
"model",
".",
"setBaseUrl",
"(",
"projectBaseUrl",
")",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"p... | Sets the encoded Base URL of the currently loaded project.
@param {String} | [
"Sets",
"the",
"encoded",
"Base",
"URL",
"of",
"the",
"currently",
"loaded",
"project",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L514-L520 | train | Sets the base URL of the project | [
30522,
3853,
2275,
15058,
3126,
2140,
1006,
2622,
15058,
3126,
2140,
1007,
1063,
13075,
6123,
1027,
1035,
2131,
21572,
20614,
8584,
9153,
26557,
28040,
18413,
1006,
1007,
1025,
2622,
15058,
3126,
2140,
1027,
2944,
1012,
2275,
15058,
3126,
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... |
getinsomnia/insomnia | packages/insomnia-app/app/account/crypt.js | _hkdfSalt | async function _hkdfSalt(rawSalt, rawEmail) {
return new Promise(resolve => {
const hkdf = new HKDF('sha256', rawSalt, rawEmail);
hkdf.derive('', DEFAULT_BYTE_LENGTH, buffer => resolve(buffer.toString('hex')));
});
} | javascript | async function _hkdfSalt(rawSalt, rawEmail) {
return new Promise(resolve => {
const hkdf = new HKDF('sha256', rawSalt, rawEmail);
hkdf.derive('', DEFAULT_BYTE_LENGTH, buffer => resolve(buffer.toString('hex')));
});
} | [
"async",
"function",
"_hkdfSalt",
"(",
"rawSalt",
",",
"rawEmail",
")",
"{",
"return",
"new",
"Promise",
"(",
"resolve",
"=>",
"{",
"const",
"hkdf",
"=",
"new",
"HKDF",
"(",
"'sha256'",
",",
"rawSalt",
",",
"rawEmail",
")",
";",
"hkdf",
".",
"derive",
... | ~~~~~~~~~~~~~~~~ // Helper Functions // ~~~~~~~~~~~~~~~~ //
Combine email and raw salt into usable salt
@param rawSalt
@param rawEmail
@returns {Promise} | [
"~~~~~~~~~~~~~~~~",
"//",
"Helper",
"Functions",
"//",
"~~~~~~~~~~~~~~~~",
"//",
"Combine",
"email",
"and",
"raw",
"salt",
"into",
"usable",
"salt"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-app/app/account/crypt.js#L304-L309 | train | HKDF the salt and email | [
30522,
2004,
6038,
2278,
3853,
1035,
22563,
20952,
12002,
2102,
1006,
6315,
12002,
2102,
1010,
6315,
14545,
4014,
1007,
1063,
2709,
2047,
4872,
1006,
10663,
1027,
1028,
1063,
9530,
3367,
22563,
20952,
1027,
2047,
22563,
20952,
1006,
1005,
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 | getObject | function getObject(sName) {
// Note: ObjectPath.get("", ...) === undefined
return sName && sName.charAt(0) === "."
? ObjectPath.get(sName.slice(1), oScope)
: ObjectPath.get(sName || "", oScope) || ObjectPath.get(sName || "");
} | javascript | function getObject(sName) {
// Note: ObjectPath.get("", ...) === undefined
return sName && sName.charAt(0) === "."
? ObjectPath.get(sName.slice(1), oScope)
: ObjectPath.get(sName || "", oScope) || ObjectPath.get(sName || "");
} | [
"function",
"getObject",
"(",
"sName",
")",
"{",
"// Note: ObjectPath.get(\"\", ...) === undefined",
"return",
"sName",
"&&",
"sName",
".",
"charAt",
"(",
"0",
")",
"===",
"\".\"",
"?",
"ObjectPath",
".",
"get",
"(",
"sName",
".",
"slice",
"(",
"1",
")",
","... | Returns a JavaScript object which is identified by a dot-separated sequence of names.
If the given compound name starts with a dot, it is interpreted relative to
<code>oScope</code>.
@param {string} sName
a dot-separated sequence of names that identify the required object
@returns {object}
a JavaScript object which is identified by a sequence of names | [
"Returns",
"a",
"JavaScript",
"object",
"which",
"is",
"identified",
"by",
"a",
"dot",
"-",
"separated",
"sequence",
"of",
"names",
".",
"If",
"the",
"given",
"compound",
"name",
"starts",
"with",
"a",
"dot",
"it",
"is",
"interpreted",
"relative",
"to",
"<... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L1053-L1058 | train | Get the object from the ObjectPath | [
30522,
3853,
2131,
16429,
20614,
1006,
1055,
18442,
1007,
1063,
1013,
1013,
3602,
1024,
4874,
15069,
1012,
2131,
1006,
1000,
1000,
1010,
1012,
1012,
1012,
1007,
1027,
1027,
1027,
6151,
28344,
2709,
1055,
18442,
1004,
1004,
1055,
18442,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | dist/extension/dataTool.js | map | function map(obj, cb, context) {
if (!(obj && cb)) {
return;
}
if (obj.map && obj.map === nativeMap) {
return obj.map(cb, context);
}
else {
var result = [];
for (var i = 0, len = obj.length; i < len; i++) {
result.push(cb.call(context, obj[i], i, obj));
}
return result;
}
} | javascript | function map(obj, cb, context) {
if (!(obj && cb)) {
return;
}
if (obj.map && obj.map === nativeMap) {
return obj.map(cb, context);
}
else {
var result = [];
for (var i = 0, len = obj.length; i < len; i++) {
result.push(cb.call(context, obj[i], i, obj));
}
return result;
}
} | [
"function",
"map",
"(",
"obj",
",",
"cb",
",",
"context",
")",
"{",
"if",
"(",
"!",
"(",
"obj",
"&&",
"cb",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"obj",
".",
"map",
"&&",
"obj",
".",
"map",
"===",
"nativeMap",
")",
"{",
"return",
"obj... | 数组或对象遍历
@memberOf module:zrender/core/util
@param {Object|Array} obj
@param {Function} cb
@param {*} [context]
数组映射
@memberOf module:zrender/core/util
@param {Array} obj
@param {Function} cb
@param {*} [context]
@return {Array} | [
"数组或对象遍历"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/dist/extension/dataTool.js#L134-L148 | train | A function that returns an array of the result of calling a callback for each entry in the array. | [
30522,
3853,
4949,
1006,
27885,
3501,
1010,
17324,
1010,
6123,
1007,
1063,
2065,
1006,
999,
1006,
27885,
3501,
1004,
1004,
17324,
1007,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
27885,
3501,
1012,
4949,
1004,
1004,
27885,
3501,
1012,
4949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | endTraversal | function endTraversal() {
var pane = _getPane(ACTIVE_PANE);
if (_traversingFileList) {
_traversingFileList = false;
_makeFileMostRecent(pane.id, pane.getCurrentlyViewedFile());
}
} | javascript | function endTraversal() {
var pane = _getPane(ACTIVE_PANE);
if (_traversingFileList) {
_traversingFileList = false;
_makeFileMostRecent(pane.id, pane.getCurrentlyViewedFile());
}
} | [
"function",
"endTraversal",
"(",
")",
"{",
"var",
"pane",
"=",
"_getPane",
"(",
"ACTIVE_PANE",
")",
";",
"if",
"(",
"_traversingFileList",
")",
"{",
"_traversingFileList",
"=",
"false",
";",
"_makeFileMostRecent",
"(",
"pane",
".",
"id",
",",
"pane",
".",
... | Un-freezes the MRU list after one or more beginTraversal() calls.
Whatever file is current is bumped to the front of the MRU list. | [
"Un",
"-",
"freezes",
"the",
"MRU",
"list",
"after",
"one",
"or",
"more",
"beginTraversal",
"()",
"calls",
".",
"Whatever",
"file",
"is",
"current",
"is",
"bumped",
"to",
"the",
"front",
"of",
"the",
"MRU",
"list",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L981-L989 | train | End traversal | [
30522,
30524,
9739,
2063,
1006,
3161,
1035,
6090,
2063,
1007,
1025,
2065,
1006,
1035,
29053,
2075,
8873,
2571,
9863,
1007,
1063,
1035,
29053,
2075,
8873,
2571,
9863,
1027,
6270,
1025,
1035,
2191,
8873,
16930,
14122,
2890,
13013,
1006,
6090,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/document/DocumentCommandHandlers.js | detectDocumentNavEnd | function detectDocumentNavEnd(event) {
if (event.keyCode === KeyEvent.DOM_VK_CONTROL) { // Ctrl key
MainViewManager.endTraversal();
_addedNavKeyHandler = false;
$(window.document.body).off("keyup", detectDocumentNavEnd);
}
} | javascript | function detectDocumentNavEnd(event) {
if (event.keyCode === KeyEvent.DOM_VK_CONTROL) { // Ctrl key
MainViewManager.endTraversal();
_addedNavKeyHandler = false;
$(window.document.body).off("keyup", detectDocumentNavEnd);
}
} | [
"function",
"detectDocumentNavEnd",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"keyCode",
"===",
"KeyEvent",
".",
"DOM_VK_CONTROL",
")",
"{",
"// Ctrl key",
"MainViewManager",
".",
"endTraversal",
"(",
")",
";",
"_addedNavKeyHandler",
"=",
"false",
";",
... | When the Ctrl key is released, if we were in the middle of a next/prev document navigation
sequence, now is the time to end it and update the MRU order. If we allowed the order to update
on every next/prev increment, the 1st & 2nd entries would just switch places forever and we'd
never get further down the list.
@param {jQueryEvent} event Key-up event | [
"When",
"the",
"Ctrl",
"key",
"is",
"released",
"if",
"we",
"were",
"in",
"the",
"middle",
"of",
"a",
"next",
"/",
"prev",
"document",
"navigation",
"sequence",
"now",
"is",
"the",
"time",
"to",
"end",
"it",
"and",
"update",
"the",
"MRU",
"order",
".",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L1531-L1537 | train | detect document navigation end | [
30522,
3853,
11487,
3527,
24894,
4765,
2532,
8159,
2094,
1006,
30524,
12190,
3145,
2364,
8584,
24805,
4590,
1012,
2203,
6494,
14028,
2389,
1006,
1007,
1025,
1035,
2794,
2532,
2615,
14839,
11774,
3917,
1027,
6270,
1025,
1002,
1006,
3332,
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... |
angular/material | release.js | writeScript | function writeScript (name, cmds) {
fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + cmds.join('\n'));
exec('chmod +x ' + name);
} | javascript | function writeScript (name, cmds) {
fs.writeFileSync(name, '#!/usr/bin/env bash\n\n' + cmds.join('\n'));
exec('chmod +x ' + name);
} | [
"function",
"writeScript",
"(",
"name",
",",
"cmds",
")",
"{",
"fs",
".",
"writeFileSync",
"(",
"name",
",",
"'#!/usr/bin/env bash\\n\\n'",
"+",
"cmds",
".",
"join",
"(",
"'\\n'",
")",
")",
";",
"exec",
"(",
"'chmod +x '",
"+",
"name",
")",
";",
"}"
] | writes an array of commands to a bash script | [
"writes",
"an",
"array",
"of",
"commands",
"to",
"a",
"bash",
"script"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/release.js#L208-L211 | train | Write a script to the file system | [
30522,
3853,
7009,
23235,
1006,
2171,
1010,
4642,
5104,
1007,
1063,
1042,
2015,
1012,
4339,
8873,
4244,
6038,
2278,
1006,
2171,
1010,
1005,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
24234,
1032,
1050,
1032,
1050,
1005,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/key-spacing.js | verifyListSpacing | function verifyListSpacing(properties) {
const length = properties.length;
for (let i = 0; i < length; i++) {
verifySpacing(properties[i], singleLineOptions);
}
} | javascript | function verifyListSpacing(properties) {
const length = properties.length;
for (let i = 0; i < length; i++) {
verifySpacing(properties[i], singleLineOptions);
}
} | [
"function",
"verifyListSpacing",
"(",
"properties",
")",
"{",
"const",
"length",
"=",
"properties",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"verifySpacing",
"(",
"properties",
"[",
"i",
... | Verifies spacing of each property in a list.
@param {ASTNode[]} properties List of Property AST nodes.
@returns {void} | [
"Verifies",
"spacing",
"of",
"each",
"property",
"in",
"a",
"list",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/key-spacing.js#L617-L623 | train | verify spacing of list | [
30522,
3853,
20410,
27103,
19498,
2075,
1006,
5144,
1007,
1063,
9530,
3367,
3091,
1027,
5144,
1012,
3091,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
20410,
13102,
26217,
1006,
5144,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/core/core.controller.js | mergeScaleConfig | function mergeScaleConfig(/* config objects ... */) {
return helpers.merge({}, [].slice.call(arguments), {
merger: function(key, target, source, options) {
if (key === 'xAxes' || key === 'yAxes') {
var slen = source[key].length;
var i, type, scale;
if (!target[key]) {
target[key] = [];
}
for (i = 0; i < slen; ++i) {
scale = source[key][i];
type = valueOrDefault(scale.type, key === 'xAxes' ? 'category' : 'linear');
if (i >= target[key].length) {
target[key].push({});
}
if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
// new/untyped scale or type changed: let's apply the new defaults
// then merge source scale to correctly overwrite the defaults.
helpers.merge(target[key][i], [scaleService.getScaleDefaults(type), scale]);
} else {
// scales type are the same
helpers.merge(target[key][i], scale);
}
}
} else {
helpers._merger(key, target, source, options);
}
}
});
} | javascript | function mergeScaleConfig(/* config objects ... */) {
return helpers.merge({}, [].slice.call(arguments), {
merger: function(key, target, source, options) {
if (key === 'xAxes' || key === 'yAxes') {
var slen = source[key].length;
var i, type, scale;
if (!target[key]) {
target[key] = [];
}
for (i = 0; i < slen; ++i) {
scale = source[key][i];
type = valueOrDefault(scale.type, key === 'xAxes' ? 'category' : 'linear');
if (i >= target[key].length) {
target[key].push({});
}
if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
// new/untyped scale or type changed: let's apply the new defaults
// then merge source scale to correctly overwrite the defaults.
helpers.merge(target[key][i], [scaleService.getScaleDefaults(type), scale]);
} else {
// scales type are the same
helpers.merge(target[key][i], scale);
}
}
} else {
helpers._merger(key, target, source, options);
}
}
});
} | [
"function",
"mergeScaleConfig",
"(",
"/* config objects ... */",
")",
"{",
"return",
"helpers",
".",
"merge",
"(",
"{",
"}",
",",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"{",
"merger",
":",
"function",
"(",
"key",
",",
"target",
... | Recursively merge the given config objects representing the `scales` option
by incorporating scale defaults in `xAxes` and `yAxes` array items, then
returns a deep copy of the result, thus doesn't alter inputs. | [
"Recursively",
"merge",
"the",
"given",
"config",
"objects",
"representing",
"the",
"scales",
"option",
"by",
"incorporating",
"scale",
"defaults",
"in",
"xAxes",
"and",
"yAxes",
"array",
"items",
"then",
"returns",
"a",
"deep",
"copy",
"of",
"the",
"result",
... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.controller.js#L43-L76 | train | Merge scale config objects into target config object | [
30522,
3853,
13590,
15782,
2571,
8663,
8873,
2290,
1006,
1013,
1008,
9530,
8873,
2290,
5200,
1012,
1012,
1012,
1008,
1013,
1007,
1063,
2709,
2393,
2545,
1012,
13590,
1006,
1063,
1065,
1010,
1031,
1033,
1012,
14704,
1012,
2655,
1006,
9918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-ide | packages/side-runtime/src/webdriver.js | async function(...args) {
try {
return await Executor.prototype[assertion].call(this, ...args)
} catch (err) {
if (err instanceof AssertionError) {
throw new VerificationError(err.message)
}
throw err
}
} | javascript | async function(...args) {
try {
return await Executor.prototype[assertion].call(this, ...args)
} catch (err) {
if (err instanceof AssertionError) {
throw new VerificationError(err.message)
}
throw err
}
} | [
"async",
"function",
"(",
"...",
"args",
")",
"{",
"try",
"{",
"return",
"await",
"Executor",
".",
"prototype",
"[",
"assertion",
"]",
".",
"call",
"(",
"this",
",",
"...",
"args",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"instanc... | creating the function inside an object since function declared in an object are named after the property, thus creating dyanmic named funcs also in order to be able to call(this) the function has to be normal declaration rather than arrow, as arrow will be bound to createVerifyCommands context which is undefined | [
"creating",
"the",
"function",
"inside",
"an",
"object",
"since",
"function",
"declared",
"in",
"an",
"object",
"are",
"named",
"after",
"the",
"property",
"thus",
"creating",
"dyanmic",
"named",
"funcs",
"also",
"in",
"order",
"to",
"be",
"able",
"to",
"cal... | 2b7852d2bb0d19cf285bae30e7dce2d250bc54ae | https://github.com/SeleniumHQ/selenium-ide/blob/2b7852d2bb0d19cf285bae30e7dce2d250bc54ae/packages/side-runtime/src/webdriver.js#L1384-L1393 | train | Alerta Komponente | [
30522,
2004,
6038,
2278,
3853,
1006,
1012,
1012,
1012,
12098,
5620,
1007,
1063,
3046,
1063,
2709,
26751,
4654,
8586,
16161,
2099,
1012,
8773,
1031,
23617,
1033,
1012,
2655,
1006,
2023,
1010,
1012,
1012,
1012,
12098,
5620,
1007,
1065,
4608,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | Makefile.js | lintMarkdown | function lintMarkdown(files) {
const config = yaml.safeLoad(fs.readFileSync(path.join(__dirname, "./.markdownlint.yml"), "utf8")),
result = markdownlint.sync({
files,
config,
resultVersion: 1
}),
resultString = result.toString(),
returnCode = resultString ? 1 : 0;
if (resultString) {
console.error(resultString);
}
return { code: returnCode };
} | javascript | function lintMarkdown(files) {
const config = yaml.safeLoad(fs.readFileSync(path.join(__dirname, "./.markdownlint.yml"), "utf8")),
result = markdownlint.sync({
files,
config,
resultVersion: 1
}),
resultString = result.toString(),
returnCode = resultString ? 1 : 0;
if (resultString) {
console.error(resultString);
}
return { code: returnCode };
} | [
"function",
"lintMarkdown",
"(",
"files",
")",
"{",
"const",
"config",
"=",
"yaml",
".",
"safeLoad",
"(",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"\"./.markdownlint.yml\"",
")",
",",
"\"utf8\"",
")",
")",
",",
"result",
... | Lints Markdown files.
@param {Array} files Array of file names to lint.
@returns {Object} exec-style exit code object.
@private | [
"Lints",
"Markdown",
"files",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/Makefile.js#L387-L401 | train | Lint Markdown files | [
30522,
3853,
11409,
29418,
8024,
7698,
1006,
6764,
1007,
1063,
9530,
3367,
9530,
8873,
2290,
1027,
8038,
19968,
1012,
3647,
11066,
1006,
1042,
2015,
1012,
3191,
8873,
4244,
6038,
2278,
1006,
4130,
1012,
3693,
1006,
1035,
1035,
16101,
18442,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/polar/polarCreator.js | updatePolarScale | function updatePolarScale(ecModel, api) {
var polar = this;
var angleAxis = polar.getAngleAxis();
var radiusAxis = polar.getRadiusAxis();
// Reset scale
angleAxis.scale.setExtent(Infinity, -Infinity);
radiusAxis.scale.setExtent(Infinity, -Infinity);
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === polar) {
var data = seriesModel.getData();
zrUtil.each(data.mapDimension('radius', true), function (dim) {
radiusAxis.scale.unionExtentFromData(
data, getStackedDimension(data, dim)
);
});
zrUtil.each(data.mapDimension('angle', true), function (dim) {
angleAxis.scale.unionExtentFromData(
data, getStackedDimension(data, dim)
);
});
}
});
niceScaleExtent(angleAxis.scale, angleAxis.model);
niceScaleExtent(radiusAxis.scale, radiusAxis.model);
// Fix extent of category angle axis
if (angleAxis.type === 'category' && !angleAxis.onBand) {
var extent = angleAxis.getExtent();
var diff = 360 / angleAxis.scale.count();
angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
angleAxis.setExtent(extent[0], extent[1]);
}
} | javascript | function updatePolarScale(ecModel, api) {
var polar = this;
var angleAxis = polar.getAngleAxis();
var radiusAxis = polar.getRadiusAxis();
// Reset scale
angleAxis.scale.setExtent(Infinity, -Infinity);
radiusAxis.scale.setExtent(Infinity, -Infinity);
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === polar) {
var data = seriesModel.getData();
zrUtil.each(data.mapDimension('radius', true), function (dim) {
radiusAxis.scale.unionExtentFromData(
data, getStackedDimension(data, dim)
);
});
zrUtil.each(data.mapDimension('angle', true), function (dim) {
angleAxis.scale.unionExtentFromData(
data, getStackedDimension(data, dim)
);
});
}
});
niceScaleExtent(angleAxis.scale, angleAxis.model);
niceScaleExtent(radiusAxis.scale, radiusAxis.model);
// Fix extent of category angle axis
if (angleAxis.type === 'category' && !angleAxis.onBand) {
var extent = angleAxis.getExtent();
var diff = 360 / angleAxis.scale.count();
angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
angleAxis.setExtent(extent[0], extent[1]);
}
} | [
"function",
"updatePolarScale",
"(",
"ecModel",
",",
"api",
")",
"{",
"var",
"polar",
"=",
"this",
";",
"var",
"angleAxis",
"=",
"polar",
".",
"getAngleAxis",
"(",
")",
";",
"var",
"radiusAxis",
"=",
"polar",
".",
"getRadiusAxis",
"(",
")",
";",
"// Rese... | Update polar | [
"Update",
"polar"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/polar/polarCreator.js#L59-L93 | train | Update polar scale | [
30522,
3853,
10651,
18155,
11650,
9289,
2063,
1006,
14925,
5302,
9247,
1010,
17928,
1007,
1063,
13075,
11508,
1027,
2023,
1025,
13075,
6466,
8528,
2483,
1027,
11508,
1012,
2131,
5654,
19738,
9048,
2015,
1006,
1007,
1025,
30524,
1011,
15579,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(inst) {
var altFormat, date, dateStr,
altField = this._get(inst, "altField");
if (altField) { // update alternate field too
altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
date = this._getDate(inst);
dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
$(altField).each(function() { $(this).val(dateStr); });
}
} | javascript | function(inst) {
var altFormat, date, dateStr,
altField = this._get(inst, "altField");
if (altField) { // update alternate field too
altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
date = this._getDate(inst);
dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
$(altField).each(function() { $(this).val(dateStr); });
}
} | [
"function",
"(",
"inst",
")",
"{",
"var",
"altFormat",
",",
"date",
",",
"dateStr",
",",
"altField",
"=",
"this",
".",
"_get",
"(",
"inst",
",",
"\"altField\"",
")",
";",
"if",
"(",
"altField",
")",
"{",
"// update alternate field too",
"altFormat",
"=",
... | /* Update any alternate field to synchronise with the main field. | [
"/",
"*",
"Update",
"any",
"alternate",
"field",
"to",
"synchronise",
"with",
"the",
"main",
"field",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8634-L8644 | train | update the date field | [
30522,
3853,
1006,
16021,
2102,
1007,
1063,
13075,
12456,
14192,
4017,
1010,
3058,
1010,
5246,
16344,
1010,
12456,
3790,
1027,
2023,
1012,
1035,
2131,
1006,
16021,
2102,
1010,
1000,
12456,
3790,
1000,
1007,
1025,
2065,
1006,
12456,
3790,
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... | |
parcel-bundler/parcel | packages/core/parcel-bundler/src/transforms/babel/env.js | getEnvConfig | async function getEnvConfig(asset, isSourceModule) {
// Load the target engines for the app and generate a @babel/preset-env config
let targetEngines = await getTargetEngines(asset, true);
let targetEnv = await getEnvPlugins(targetEngines, true);
if (!targetEnv) {
return null;
}
// If this is the app module, the source and target will be the same, so just compile everything.
// Otherwise, load the source engines and generate a babel-present-env config.
if (!isSourceModule) {
let sourceEngines = await getTargetEngines(asset, false);
let sourceEnv = (await getEnvPlugins(sourceEngines, false)) || targetEnv;
// Do a diff of the returned plugins. We only need to process the remaining plugins to get to the app target.
let sourcePlugins = new Set(sourceEnv.map(p => p[0]));
targetEnv = targetEnv.filter(plugin => {
return !sourcePlugins.has(plugin[0]);
});
}
return {
internal: true,
babelVersion: 7,
config: {
plugins: targetEnv
}
};
} | javascript | async function getEnvConfig(asset, isSourceModule) {
// Load the target engines for the app and generate a @babel/preset-env config
let targetEngines = await getTargetEngines(asset, true);
let targetEnv = await getEnvPlugins(targetEngines, true);
if (!targetEnv) {
return null;
}
// If this is the app module, the source and target will be the same, so just compile everything.
// Otherwise, load the source engines and generate a babel-present-env config.
if (!isSourceModule) {
let sourceEngines = await getTargetEngines(asset, false);
let sourceEnv = (await getEnvPlugins(sourceEngines, false)) || targetEnv;
// Do a diff of the returned plugins. We only need to process the remaining plugins to get to the app target.
let sourcePlugins = new Set(sourceEnv.map(p => p[0]));
targetEnv = targetEnv.filter(plugin => {
return !sourcePlugins.has(plugin[0]);
});
}
return {
internal: true,
babelVersion: 7,
config: {
plugins: targetEnv
}
};
} | [
"async",
"function",
"getEnvConfig",
"(",
"asset",
",",
"isSourceModule",
")",
"{",
"// Load the target engines for the app and generate a @babel/preset-env config",
"let",
"targetEngines",
"=",
"await",
"getTargetEngines",
"(",
"asset",
",",
"true",
")",
";",
"let",
"tar... | Generates a @babel/preset-env config for an asset.
This is done by finding the source module's target engines, and the app's
target engines, and doing a diff to include only the necessary plugins. | [
"Generates",
"a"
] | 84b308511f87d4b69da62bcd352f0ff2f7bd4f1b | https://github.com/parcel-bundler/parcel/blob/84b308511f87d4b69da62bcd352f0ff2f7bd4f1b/packages/core/parcel-bundler/src/transforms/babel/env.js#L9-L37 | train | Get the env config for the app. | [
30522,
2004,
6038,
2278,
3853,
2131,
2368,
25465,
2239,
8873,
2290,
1006,
11412,
1010,
26354,
8162,
3401,
5302,
8566,
2571,
1007,
1063,
1013,
1013,
7170,
1996,
4539,
5209,
2005,
1996,
10439,
1998,
9699,
1037,
1030,
11561,
2140,
1013,
3653,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-js/scripts/generate-plugin-combinations.js | generate | function generate(plugins, dest) {
const pluginNames = plugins.map((plugin) => {
return path.basename(plugin, '.js');
});
const pluginCombinations = combine(pluginNames);
pluginCombinations.forEach((pluginCombination) => {
fs.writeFileSync(
path.resolve(dest, `${pluginCombination.join(',')}.js`),
template(pluginCombination),
);
});
} | javascript | function generate(plugins, dest) {
const pluginNames = plugins.map((plugin) => {
return path.basename(plugin, '.js');
});
const pluginCombinations = combine(pluginNames);
pluginCombinations.forEach((pluginCombination) => {
fs.writeFileSync(
path.resolve(dest, `${pluginCombination.join(',')}.js`),
template(pluginCombination),
);
});
} | [
"function",
"generate",
"(",
"plugins",
",",
"dest",
")",
"{",
"const",
"pluginNames",
"=",
"plugins",
".",
"map",
"(",
"(",
"plugin",
")",
"=>",
"{",
"return",
"path",
".",
"basename",
"(",
"plugin",
",",
"'.js'",
")",
";",
"}",
")",
";",
"const",
... | Generate all plugin combinations.
@param {array} plugins
@param {string} dest | [
"Generate",
"all",
"plugin",
"combinations",
"."
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/scripts/generate-plugin-combinations.js#L46-L59 | train | Generate a bunch of plugin combinations | [
30522,
3853,
9699,
1006,
13354,
7076,
1010,
4078,
2102,
1007,
1063,
9530,
3367,
13354,
23111,
14074,
2015,
1027,
13354,
7076,
1012,
4949,
1006,
1006,
13354,
2378,
1007,
1027,
1028,
1063,
2709,
4130,
1012,
2918,
18442,
1006,
13354,
2378,
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... |
tensorflow/tfjs-models | knn-classifier/demo/camera.js | setupGui | function setupGui() {
// Create training buttons and info texts
for (let i = 0; i < NUM_CLASSES; i++) {
const div = document.createElement('div');
document.body.appendChild(div);
div.style.marginBottom = '10px';
// Create training button
const button = document.createElement('button');
button.innerText = 'Train ' + i;
div.appendChild(button);
// Listen for mouse events when clicking the button
button.addEventListener('click', () => {
training = i;
requestAnimationFrame(() => training = -1);
});
// Create info text
const infoText = document.createElement('span');
infoText.innerText = ' No examples added';
div.appendChild(infoText);
infoTexts.push(infoText);
}
} | javascript | function setupGui() {
// Create training buttons and info texts
for (let i = 0; i < NUM_CLASSES; i++) {
const div = document.createElement('div');
document.body.appendChild(div);
div.style.marginBottom = '10px';
// Create training button
const button = document.createElement('button');
button.innerText = 'Train ' + i;
div.appendChild(button);
// Listen for mouse events when clicking the button
button.addEventListener('click', () => {
training = i;
requestAnimationFrame(() => training = -1);
});
// Create info text
const infoText = document.createElement('span');
infoText.innerText = ' No examples added';
div.appendChild(infoText);
infoTexts.push(infoText);
}
} | [
"function",
"setupGui",
"(",
")",
"{",
"// Create training buttons and info texts",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"NUM_CLASSES",
";",
"i",
"++",
")",
"{",
"const",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"... | Setup training GUI. Adds a training button for each class,
and sets up mouse events. | [
"Setup",
"training",
"GUI",
".",
"Adds",
"a",
"training",
"button",
"for",
"each",
"class",
"and",
"sets",
"up",
"mouse",
"events",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/knn-classifier/demo/camera.js#L87-L111 | train | Creates the GUI for the training buttons | [
30522,
3853,
16437,
25698,
1006,
1007,
1063,
1013,
1013,
3443,
2731,
11287,
1998,
18558,
6981,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
16371,
2213,
1035,
4280,
1025,
1045,
1009,
1009,
1007,
1063,
9530,
3367,
4487,
2615,
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... |
serverless/serverless | lib/plugins/aws/package/compile/events/apiGateway/lib/resources.js | applyResource | function applyResource(resource, isMethod) {
let root;
let parent;
let currentPath;
const path = resource.path.replace(/^\//, '').replace(/\/$/, '');
const pathParts = path.split('/');
function applyNodeResource(node, parts, index) {
const n = node;
if (index === parts.length - 1) {
n.name = resource.name;
if (resource.resourceId) {
n.resourceId = resource.resourceId;
if (_.every(predefinedResourceNodes, (iter) => iter.path !== n.path)) {
predefinedResourceNodes.push(node);
}
}
if (isMethod && !node.hasMethod) {
n.hasMethod = true;
if (_.every(methodNodes, (iter) => iter.path !== n.path)) {
methodNodes.push(node);
}
}
}
parent = node;
}
pathParts.forEach((pathPart, index) => {
currentPath = currentPath ? `${currentPath}/${pathPart}` : pathPart;
root = root || _.find(trees, (node) => node.path === currentPath);
parent = parent || root;
let node;
if (parent) {
if (parent.path === currentPath) {
applyNodeResource(parent, pathParts, index);
return;
} else if (parent.children.length > 0) {
node = _.find(parent.children, (n) => n.path === currentPath);
if (node) {
applyNodeResource(node, pathParts, index);
return;
}
}
}
node = {
path: currentPath,
pathPart,
parent,
level: index,
children: [],
};
if (parent) {
parent.children.push(node);
}
if (!root) {
root = node;
trees.push(root);
}
applyNodeResource(node, pathParts, index);
});
} | javascript | function applyResource(resource, isMethod) {
let root;
let parent;
let currentPath;
const path = resource.path.replace(/^\//, '').replace(/\/$/, '');
const pathParts = path.split('/');
function applyNodeResource(node, parts, index) {
const n = node;
if (index === parts.length - 1) {
n.name = resource.name;
if (resource.resourceId) {
n.resourceId = resource.resourceId;
if (_.every(predefinedResourceNodes, (iter) => iter.path !== n.path)) {
predefinedResourceNodes.push(node);
}
}
if (isMethod && !node.hasMethod) {
n.hasMethod = true;
if (_.every(methodNodes, (iter) => iter.path !== n.path)) {
methodNodes.push(node);
}
}
}
parent = node;
}
pathParts.forEach((pathPart, index) => {
currentPath = currentPath ? `${currentPath}/${pathPart}` : pathPart;
root = root || _.find(trees, (node) => node.path === currentPath);
parent = parent || root;
let node;
if (parent) {
if (parent.path === currentPath) {
applyNodeResource(parent, pathParts, index);
return;
} else if (parent.children.length > 0) {
node = _.find(parent.children, (n) => n.path === currentPath);
if (node) {
applyNodeResource(node, pathParts, index);
return;
}
}
}
node = {
path: currentPath,
pathPart,
parent,
level: index,
children: [],
};
if (parent) {
parent.children.push(node);
}
if (!root) {
root = node;
trees.push(root);
}
applyNodeResource(node, pathParts, index);
});
} | [
"function",
"applyResource",
"(",
"resource",
",",
"isMethod",
")",
"{",
"let",
"root",
";",
"let",
"parent",
";",
"let",
"currentPath",
";",
"const",
"path",
"=",
"resource",
".",
"path",
".",
"replace",
"(",
"/",
"^\\/",
"/",
",",
"''",
")",
".",
"... | organize all resource paths into N-ary tree | [
"organize",
"all",
"resource",
"paths",
"into",
"N",
"-",
"ary",
"tree"
] | 0626d5b5df06e4ed68969e324f1cb6b1b499c443 | https://github.com/serverless/serverless/blob/0626d5b5df06e4ed68969e324f1cb6b1b499c443/lib/plugins/aws/package/compile/events/apiGateway/lib/resources.js#L81-L148 | train | Apply a resource to the tree | [
30522,
3853,
6611,
6072,
8162,
3401,
1006,
7692,
1010,
2003,
11368,
6806,
2094,
1007,
1063,
2292,
7117,
1025,
2292,
6687,
1025,
2292,
2783,
15069,
1025,
9530,
3367,
4130,
1027,
7692,
1012,
4130,
1012,
5672,
1006,
1013,
1034,
1032,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js | getResponseHeader | function getResponseHeader(sHeaderName) {
var sResponseHeader;
sHeaderName = sHeaderName.toLowerCase();
for (sResponseHeader in this.headers) {
if (sResponseHeader.toLowerCase() === sHeaderName) {
return this.headers[sResponseHeader];
}
}
} | javascript | function getResponseHeader(sHeaderName) {
var sResponseHeader;
sHeaderName = sHeaderName.toLowerCase();
for (sResponseHeader in this.headers) {
if (sResponseHeader.toLowerCase() === sHeaderName) {
return this.headers[sResponseHeader];
}
}
} | [
"function",
"getResponseHeader",
"(",
"sHeaderName",
")",
"{",
"var",
"sResponseHeader",
";",
"sHeaderName",
"=",
"sHeaderName",
".",
"toLowerCase",
"(",
")",
";",
"for",
"(",
"sResponseHeader",
"in",
"this",
".",
"headers",
")",
"{",
"if",
"(",
"sResponseHead... | The getResponseHeader() method imitates the jqXHR.getResponseHeader() method for a $batch
error response.
@param {string} sHeaderName The header name
@returns {string} The response header value | [
"The",
"getResponseHeader",
"()",
"method",
"imitates",
"the",
"jqXHR",
".",
"getResponseHeader",
"()",
"method",
"for",
"a",
"$batch",
"error",
"response",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L31-L41 | train | Returns the response header by name. | [
30522,
3853,
2131,
6072,
26029,
3366,
4974,
2121,
1006,
16994,
25888,
14074,
1007,
1063,
13075,
5034,
2229,
26029,
3366,
4974,
2121,
1025,
16994,
25888,
14074,
1027,
16994,
25888,
14074,
1012,
2000,
27663,
18992,
3366,
1006,
1007,
1025,
2005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
moleculerjs/moleculer | src/middlewares/circuit-breaker.js | halfOpen | function halfOpen(item) {
item.state = C.CIRCUIT_HALF_OPEN;
item.ep.state = true;
logger.debug(`Circuit breaker has been half-opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name });
broker.broadcast("$circuit-breaker.half-opened", { nodeID: item.ep.id, action: item.ep.action.name });
if (item.cbTimer) {
clearTimeout(item.cbTimer);
item.cbTimer = null;
}
} | javascript | function halfOpen(item) {
item.state = C.CIRCUIT_HALF_OPEN;
item.ep.state = true;
logger.debug(`Circuit breaker has been half-opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name });
broker.broadcast("$circuit-breaker.half-opened", { nodeID: item.ep.id, action: item.ep.action.name });
if (item.cbTimer) {
clearTimeout(item.cbTimer);
item.cbTimer = null;
}
} | [
"function",
"halfOpen",
"(",
"item",
")",
"{",
"item",
".",
"state",
"=",
"C",
".",
"CIRCUIT_HALF_OPEN",
";",
"item",
".",
"ep",
".",
"state",
"=",
"true",
";",
"logger",
".",
"debug",
"(",
"`",
"${",
"item",
".",
"ep",
".",
"name",
"}",
"`",
","... | Change circuit-breaker status to half-open
@param {Object} item
@param {Context} ctx | [
"Change",
"circuit",
"-",
"breaker",
"status",
"to",
"half",
"-",
"open"
] | f95aadc2d61b0d0e3c643a43c3ed28bca6425cde | https://github.com/moleculerjs/moleculer/blob/f95aadc2d61b0d0e3c643a43c3ed28bca6425cde/src/middlewares/circuit-breaker.js#L145-L157 | train | Handle half - open circuit breaker | [
30522,
3853,
2431,
26915,
1006,
8875,
1007,
1063,
8875,
1012,
2110,
1027,
1039,
1012,
4984,
1035,
2431,
1035,
2330,
1025,
8875,
1012,
4958,
1012,
2110,
1027,
2995,
1025,
8833,
4590,
1012,
2139,
30524,
1012,
4958,
1012,
2171,
1065,
1005,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js | getRemoteFunctionsScript | function getRemoteFunctionsScript() {
var script = "";
// Inject DocumentObserver into the browser (tracks related documents)
script += DocumentObserver;
// Inject remote functions into the browser.
script += "window._LD=(" + RemoteFunctions + "(" + JSON.stringify(LiveDevMultiBrowser.config) + "))";
return "<script>\n" + script + "</script>\n";
} | javascript | function getRemoteFunctionsScript() {
var script = "";
// Inject DocumentObserver into the browser (tracks related documents)
script += DocumentObserver;
// Inject remote functions into the browser.
script += "window._LD=(" + RemoteFunctions + "(" + JSON.stringify(LiveDevMultiBrowser.config) + "))";
return "<script>\n" + script + "</script>\n";
} | [
"function",
"getRemoteFunctionsScript",
"(",
")",
"{",
"var",
"script",
"=",
"\"\"",
";",
"// Inject DocumentObserver into the browser (tracks related documents)",
"script",
"+=",
"DocumentObserver",
";",
"// Inject remote functions into the browser.",
"script",
"+=",
"\"window._... | Returns a script that should be injected into the HTML that's launched in the
browser in order to implement remote commands that handle protocol requests.
Includes the <script> tags.
@return {string} | [
"Returns",
"a",
"script",
"that",
"should",
"be",
"injected",
"into",
"the",
"HTML",
"that",
"s",
"launched",
"in",
"the",
"browser",
"in",
"order",
"to",
"implement",
"remote",
"commands",
"that",
"handle",
"protocol",
"requests",
".",
"Includes",
"the",
"<... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js#L212-L219 | train | Get the script to be used to inject remote functions into the browser | [
30522,
3853,
2131,
28578,
12184,
11263,
27989,
4757,
23235,
1006,
1007,
1063,
13075,
5896,
1027,
1000,
1000,
1025,
1013,
1013,
1999,
20614,
6254,
16429,
8043,
6299,
2046,
1996,
16602,
1006,
3162,
3141,
5491,
1007,
5896,
1009,
1027,
6254,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/json/encodeOutput.js | encodeOutputToJson | function encodeOutputToJson(output) {
var book = output.getBook();
var generator = output.getGenerator();
var options = output.getOptions();
var result = encodeBook(book);
result.output = {
name: generator
};
result.options = options.toJS();
return result;
} | javascript | function encodeOutputToJson(output) {
var book = output.getBook();
var generator = output.getGenerator();
var options = output.getOptions();
var result = encodeBook(book);
result.output = {
name: generator
};
result.options = options.toJS();
return result;
} | [
"function",
"encodeOutputToJson",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"generator",
"=",
"output",
".",
"getGenerator",
"(",
")",
";",
"var",
"options",
"=",
"output",
".",
"getOptions",
"(",
")",
... | Encode an output to JSON
@param {Output}
@return {Object} | [
"Encode",
"an",
"output",
"to",
"JSON"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeOutput.js#L9-L23 | train | Encode the output to JSON | [
30522,
3853,
4372,
16044,
5833,
18780,
3406,
22578,
2239,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
13103,
1027,
6434,
1012,
2131,
6914,
6906,
4263,
1006,
1007,
1025,
13075,
7047,
1027,
6434... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ExtractToFunction.js | handleExtractToFunction | function handleExtractToFunction() {
var editor = EditorManager.getActiveEditor();
var result = new $.Deferred(); // used only for testing purpose
if (editor.getSelections().length > 1) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
return;
}
initializeSession(editor);
var selection = editor.getSelection(),
doc = editor.document,
retObj = RefactoringUtils.normalizeText(editor.getSelectedText(), editor.indexFromPos(selection.start), editor.indexFromPos(selection.end)),
text = retObj.text,
start = retObj.start,
end = retObj.end,
ast,
scopes,
expns,
inlineMenu;
RefactoringUtils.getScopeData(session, editor.posFromIndex(start)).done(function(scope) {
ast = RefactoringUtils.getAST(doc.getText());
var isExpression = false;
if (!RefactoringUtils.checkStatement(ast, start, end, doc.getText())) {
isExpression = RefactoringUtils.getExpression(ast, start, end, doc.getText());
if (!isExpression) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
return;
}
}
scopes = RefactoringUtils.getAllScopes(ast, scope, doc.getText());
// if only one scope, extract without menu
if (scopes.length === 1) {
extract(ast, text, scopes, scopes[0], scopes[0], start, end, isExpression);
result.resolve();
return;
}
inlineMenu = new InlineMenu(editor, Strings.EXTRACTTO_FUNCTION_SELECT_SCOPE);
inlineMenu.open(scopes.filter(RefactoringUtils.isFnScope));
result.resolve(inlineMenu);
inlineMenu.onSelect(function (scopeId) {
extract(ast, text, scopes, scopes[0], scopes[scopeId], start, end, isExpression);
inlineMenu.close();
});
inlineMenu.onClose(function(){
inlineMenu.close();
});
}).fail(function() {
editor.displayErrorMessageAtCursor(Strings.ERROR_TERN_FAILED);
result.resolve(Strings.ERROR_TERN_FAILED);
});
return result.promise();
} | javascript | function handleExtractToFunction() {
var editor = EditorManager.getActiveEditor();
var result = new $.Deferred(); // used only for testing purpose
if (editor.getSelections().length > 1) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_MULTICURSORS);
return;
}
initializeSession(editor);
var selection = editor.getSelection(),
doc = editor.document,
retObj = RefactoringUtils.normalizeText(editor.getSelectedText(), editor.indexFromPos(selection.start), editor.indexFromPos(selection.end)),
text = retObj.text,
start = retObj.start,
end = retObj.end,
ast,
scopes,
expns,
inlineMenu;
RefactoringUtils.getScopeData(session, editor.posFromIndex(start)).done(function(scope) {
ast = RefactoringUtils.getAST(doc.getText());
var isExpression = false;
if (!RefactoringUtils.checkStatement(ast, start, end, doc.getText())) {
isExpression = RefactoringUtils.getExpression(ast, start, end, doc.getText());
if (!isExpression) {
editor.displayErrorMessageAtCursor(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
result.resolve(Strings.ERROR_EXTRACTTO_FUNCTION_NOT_VALID);
return;
}
}
scopes = RefactoringUtils.getAllScopes(ast, scope, doc.getText());
// if only one scope, extract without menu
if (scopes.length === 1) {
extract(ast, text, scopes, scopes[0], scopes[0], start, end, isExpression);
result.resolve();
return;
}
inlineMenu = new InlineMenu(editor, Strings.EXTRACTTO_FUNCTION_SELECT_SCOPE);
inlineMenu.open(scopes.filter(RefactoringUtils.isFnScope));
result.resolve(inlineMenu);
inlineMenu.onSelect(function (scopeId) {
extract(ast, text, scopes, scopes[0], scopes[scopeId], start, end, isExpression);
inlineMenu.close();
});
inlineMenu.onClose(function(){
inlineMenu.close();
});
}).fail(function() {
editor.displayErrorMessageAtCursor(Strings.ERROR_TERN_FAILED);
result.resolve(Strings.ERROR_TERN_FAILED);
});
return result.promise();
} | [
"function",
"handleExtractToFunction",
"(",
")",
"{",
"var",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// used only for testing purpose",
"if",
"(",
"editor",
".",
... | Main function that handles extract to function | [
"Main",
"function",
"that",
"handles",
"extract",
"to",
"function"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/ExtractToFunction.js#L265-L328 | train | handleExtractToFunction - Extracts to function | [
30522,
3853,
5047,
10288,
6494,
6593,
3406,
11263,
27989,
1006,
1007,
1063,
13075,
3559,
1027,
3559,
24805,
4590,
1012,
2131,
19620,
2098,
15660,
1006,
1007,
1025,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/ExtensionLoader.js | loadExtensionModule | function loadExtensionModule(name, config, entryPoint) {
var extensionConfig = {
context: name,
baseUrl: config.baseUrl,
paths: globalPaths,
locale: brackets.getLocale()
};
// Read optional requirejs-config.json
var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) {
// Create new RequireJS context and load extension entry point
var extensionRequire = brackets.libRequire.config(mergedConfig),
extensionRequireDeferred = new $.Deferred();
contexts[name] = extensionRequire;
extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject);
return extensionRequireDeferred.promise();
}).then(function (module) {
// Extension loaded normally
var initPromise;
_extensions[name] = module;
// Optional sync/async initExtension
if (module && module.initExtension && (typeof module.initExtension === "function")) {
// optional async extension init
try {
initPromise = Async.withTimeout(module.initExtension(), _getInitExtensionTimeout());
} catch (err) {
// Synchronous error while initializing extension
console.error("[Extension] Error -- error thrown during initExtension for " + name + ": " + err);
return new $.Deferred().reject(err).promise();
}
// initExtension may be synchronous and may not return a promise
if (initPromise) {
// WARNING: These calls to initPromise.fail() and initPromise.then(),
// could also result in a runtime error if initPromise is not a valid
// promise. Currently, the promise is wrapped via Async.withTimeout(),
// so the call is safe as-is.
initPromise.fail(function (err) {
if (err === Async.ERROR_TIMEOUT) {
console.error("[Extension] Error -- timeout during initExtension for " + name);
} else {
console.error("[Extension] Error -- failed initExtension for " + name + (err ? ": " + err : ""));
}
});
return initPromise;
}
}
}, function errback(err) {
// Extension failed to load during the initial require() call
var additionalInfo = String(err);
if (err.requireType === "scripterror" && err.originalError) {
// This type has a misleading error message - replace it with something clearer (URL of require() call that got a 404 result)
additionalInfo = "Module does not exist: " + err.originalError.target.src;
}
console.error("[Extension] failed to load " + config.baseUrl + " - " + additionalInfo);
if (err.requireType === "define") {
// This type has a useful stack (exception thrown by ext code or info on bad getModule() call)
console.log(err.stack);
}
});
return promise;
} | javascript | function loadExtensionModule(name, config, entryPoint) {
var extensionConfig = {
context: name,
baseUrl: config.baseUrl,
paths: globalPaths,
locale: brackets.getLocale()
};
// Read optional requirejs-config.json
var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) {
// Create new RequireJS context and load extension entry point
var extensionRequire = brackets.libRequire.config(mergedConfig),
extensionRequireDeferred = new $.Deferred();
contexts[name] = extensionRequire;
extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject);
return extensionRequireDeferred.promise();
}).then(function (module) {
// Extension loaded normally
var initPromise;
_extensions[name] = module;
// Optional sync/async initExtension
if (module && module.initExtension && (typeof module.initExtension === "function")) {
// optional async extension init
try {
initPromise = Async.withTimeout(module.initExtension(), _getInitExtensionTimeout());
} catch (err) {
// Synchronous error while initializing extension
console.error("[Extension] Error -- error thrown during initExtension for " + name + ": " + err);
return new $.Deferred().reject(err).promise();
}
// initExtension may be synchronous and may not return a promise
if (initPromise) {
// WARNING: These calls to initPromise.fail() and initPromise.then(),
// could also result in a runtime error if initPromise is not a valid
// promise. Currently, the promise is wrapped via Async.withTimeout(),
// so the call is safe as-is.
initPromise.fail(function (err) {
if (err === Async.ERROR_TIMEOUT) {
console.error("[Extension] Error -- timeout during initExtension for " + name);
} else {
console.error("[Extension] Error -- failed initExtension for " + name + (err ? ": " + err : ""));
}
});
return initPromise;
}
}
}, function errback(err) {
// Extension failed to load during the initial require() call
var additionalInfo = String(err);
if (err.requireType === "scripterror" && err.originalError) {
// This type has a misleading error message - replace it with something clearer (URL of require() call that got a 404 result)
additionalInfo = "Module does not exist: " + err.originalError.target.src;
}
console.error("[Extension] failed to load " + config.baseUrl + " - " + additionalInfo);
if (err.requireType === "define") {
// This type has a useful stack (exception thrown by ext code or info on bad getModule() call)
console.log(err.stack);
}
});
return promise;
} | [
"function",
"loadExtensionModule",
"(",
"name",
",",
"config",
",",
"entryPoint",
")",
"{",
"var",
"extensionConfig",
"=",
"{",
"context",
":",
"name",
",",
"baseUrl",
":",
"config",
".",
"baseUrl",
",",
"paths",
":",
"globalPaths",
",",
"locale",
":",
"br... | Loads the extension module that lives at baseUrl into its own Require.js context
@param {!string} name, used to identify the extension
@param {!{baseUrl: string}} config object with baseUrl property containing absolute path of extension
@param {!string} entryPoint, name of the main js file to load
@return {!$.Promise} A promise object that is resolved when the extension is loaded, or rejected
if the extension fails to load or throws an exception immediately when loaded.
(Note: if extension contains a JS syntax error, promise is resolved not rejected). | [
"Loads",
"the",
"extension",
"module",
"that",
"lives",
"at",
"baseUrl",
"into",
"its",
"own",
"Require",
".",
"js",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L168-L236 | train | Load extension module | [
30522,
3853,
7170,
10288,
29048,
5302,
8566,
2571,
1006,
2171,
1010,
9530,
8873,
2290,
1010,
4443,
8400,
1007,
1063,
13075,
5331,
8663,
8873,
2290,
1027,
1063,
6123,
1024,
2171,
1010,
2918,
3126,
2140,
1024,
9530,
8873,
2290,
1012,
2918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/curly.js | isCollapsedOneLiner | function isCollapsedOneLiner(node) {
const before = sourceCode.getTokenBefore(node);
const last = sourceCode.getLastToken(node);
const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
return before.loc.start.line === lastExcludingSemicolon.loc.end.line;
} | javascript | function isCollapsedOneLiner(node) {
const before = sourceCode.getTokenBefore(node);
const last = sourceCode.getLastToken(node);
const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
return before.loc.start.line === lastExcludingSemicolon.loc.end.line;
} | [
"function",
"isCollapsedOneLiner",
"(",
"node",
")",
"{",
"const",
"before",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
")",
";",
"const",
"last",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"lastExcludingSemicolon",
"="... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Determines if a given node is a one-liner that's on the same line as it's preceding code.
@param {ASTNode} node The node to check.
@returns {boolean} True if the node is a one-liner that's on the same line as it's preceding code.
@private | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Determines",
"if",
"a",
"given",
"node",
"is",
"a",
"one",
"-",
"liner",
"that",
"s",
"on",
"the",
"same",
"line... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L85-L91 | train | Check if node is collapsed by one liner | [
30522,
3853,
2003,
26895,
9331,
6924,
5643,
20660,
1006,
13045,
1007,
1063,
9530,
3367,
2077,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
13045,
1007,
1025,
9530,
3367,
2197,
1027,
3120,
16044,
1012,
2131,
8523,
928... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/TileContainer.js | handleAriaPositionInSet | function handleAriaPositionInSet(iStartIndex, iEndIndex, aVisibleTiles) {
var i,
oTile = null;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
for (i = iStartIndex; i < iEndIndex; i++) {
oTile = aVisibleTiles[i];
if (oTile) {
oTile.$().attr('aria-posinset', this._indexOfVisibleTile(oTile, aVisibleTiles) + 1);
}
}
} | javascript | function handleAriaPositionInSet(iStartIndex, iEndIndex, aVisibleTiles) {
var i,
oTile = null;
aVisibleTiles = aVisibleTiles || this._getVisibleTiles();
for (i = iStartIndex; i < iEndIndex; i++) {
oTile = aVisibleTiles[i];
if (oTile) {
oTile.$().attr('aria-posinset', this._indexOfVisibleTile(oTile, aVisibleTiles) + 1);
}
}
} | [
"function",
"handleAriaPositionInSet",
"(",
"iStartIndex",
",",
"iEndIndex",
",",
"aVisibleTiles",
")",
"{",
"var",
"i",
",",
"oTile",
"=",
"null",
";",
"aVisibleTiles",
"=",
"aVisibleTiles",
"||",
"this",
".",
"_getVisibleTiles",
"(",
")",
";",
"for",
"(",
... | Handles the WAI ARIA property aria-posinset after a change in the TileContainer.
@param {int} iStartIndex The index of the Tile to start with
@param {int} iEndIndex The index of the Tile to complete with
@param {sap.m.Tile[]} [aVisibleTiles] optional list of visible tiles in order to avoid filtering them again.
@private | [
"Handles",
"the",
"WAI",
"ARIA",
"property",
"aria",
"-",
"posinset",
"after",
"a",
"change",
"in",
"the",
"TileContainer",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/TileContainer.js#L2163-L2175 | train | Handle ARIA position in set | [
30522,
3853,
5047,
10980,
26994,
7076,
3388,
1006,
21541,
8445,
22254,
10288,
1010,
29464,
16089,
13629,
2595,
1010,
20704,
17417,
3468,
15286,
2015,
1007,
1063,
13075,
1045,
1010,
27178,
9463,
1027,
19701,
1025,
20704,
17417,
3468,
15286,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseSwitchCase | function parseSwitchCase() {
var test, consequent = [], statement, startToken;
startToken = lookahead;
if (matchKeyword('default')) {
lex();
test = null;
} else {
expectKeyword('case');
test = parseExpression();
}
expect(':');
while (index < length) {
if (match('}') || matchKeyword('default') || matchKeyword('case')) {
break;
}
statement = parseStatement();
consequent.push(statement);
}
return delegate.markEnd(delegate.createSwitchCase(test, consequent), startToken);
} | javascript | function parseSwitchCase() {
var test, consequent = [], statement, startToken;
startToken = lookahead;
if (matchKeyword('default')) {
lex();
test = null;
} else {
expectKeyword('case');
test = parseExpression();
}
expect(':');
while (index < length) {
if (match('}') || matchKeyword('default') || matchKeyword('case')) {
break;
}
statement = parseStatement();
consequent.push(statement);
}
return delegate.markEnd(delegate.createSwitchCase(test, consequent), startToken);
} | [
"function",
"parseSwitchCase",
"(",
")",
"{",
"var",
"test",
",",
"consequent",
"=",
"[",
"]",
",",
"statement",
",",
"startToken",
";",
"startToken",
"=",
"lookahead",
";",
"if",
"(",
"matchKeyword",
"(",
"'default'",
")",
")",
"{",
"lex",
"(",
")",
"... | 12.10 The swith statement | [
"12",
".",
"10",
"The",
"swith",
"statement"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L3043-L3065 | train | ECMA - 262 13. 2 Switch Case | [
30522,
3853,
11968,
8583,
9148,
10649,
18382,
1006,
1007,
1063,
13075,
3231,
1010,
9530,
3366,
15417,
1027,
1031,
1033,
1010,
4861,
1010,
2707,
18715,
2368,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
1025,
2065,
1006,
2674,
14839,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-irregular-whitespace.js | removeWhitespaceError | function removeWhitespaceError(node) {
const locStart = node.loc.start;
const locEnd = node.loc.end;
errors = errors.filter(({ loc: errorLoc }) => {
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
return false;
}
}
return true;
});
} | javascript | function removeWhitespaceError(node) {
const locStart = node.loc.start;
const locEnd = node.loc.end;
errors = errors.filter(({ loc: errorLoc }) => {
if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) {
if (errorLoc.column >= locStart.column && (errorLoc.column <= locEnd.column || errorLoc.line < locEnd.line)) {
return false;
}
}
return true;
});
} | [
"function",
"removeWhitespaceError",
"(",
"node",
")",
"{",
"const",
"locStart",
"=",
"node",
".",
"loc",
".",
"start",
";",
"const",
"locEnd",
"=",
"node",
".",
"loc",
".",
"end",
";",
"errors",
"=",
"errors",
".",
"filter",
"(",
"(",
"{",
"loc",
":... | Removes errors that occur inside a string node
@param {ASTNode} node to check for matching errors.
@returns {void}
@private | [
"Removes",
"errors",
"that",
"occur",
"inside",
"a",
"string",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L86-L98 | train | Remove whitespace errors from the node | [
30522,
3853,
6366,
2860,
16584,
2229,
15327,
2121,
29165,
1006,
13045,
1007,
1063,
9530,
3367,
8840,
6169,
7559,
2102,
1027,
13045,
1012,
8840,
2278,
1012,
2707,
1025,
9530,
3367,
8840,
23865,
1027,
13045,
1012,
8840,
2278,
1012,
2203,
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... |
NervJS/taro | packages/taro/src/internal/_common.js | assocIndexOf | function assocIndexOf(array, key) {
var length = array.length
while (length--) {
if (eq(array[length][0], key)) {
return length
}
}
return -1
} | javascript | function assocIndexOf(array, key) {
var length = array.length
while (length--) {
if (eq(array[length][0], key)) {
return length
}
}
return -1
} | [
"function",
"assocIndexOf",
"(",
"array",
",",
"key",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
"while",
"(",
"length",
"--",
")",
"{",
"if",
"(",
"eq",
"(",
"array",
"[",
"length",
"]",
"[",
"0",
"]",
",",
"key",
")",
")",
"{",
"... | Gets the index at which the `key` is found in `array` of key-value pairs.
@private
@param {Array} array The array to inspect.
@param {*} key The key to search for.
@returns {number} Returns the index of the matched value, else `-1`. | [
"Gets",
"the",
"index",
"at",
"which",
"the",
"key",
"is",
"found",
"in",
"array",
"of",
"key",
"-",
"value",
"pairs",
"."
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L449-L457 | train | Find index of key in array | [
30522,
3853,
4632,
10085,
22254,
10288,
11253,
1006,
9140,
1010,
3145,
1007,
1063,
13075,
3091,
1027,
9140,
1012,
3091,
2096,
1006,
3091,
1011,
1011,
1007,
1063,
2065,
1006,
1041,
4160,
1006,
9140,
1031,
3091,
1033,
1031,
1014,
1033,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/utils/mergeDefaults.js | mergeDefaults | function mergeDefaults(obj, src) {
var objValue = Immutable.fromJS(obj);
var srcValue = Immutable.fromJS(src);
return srcValue.mergeDeep(objValue).toJS();
} | javascript | function mergeDefaults(obj, src) {
var objValue = Immutable.fromJS(obj);
var srcValue = Immutable.fromJS(src);
return srcValue.mergeDeep(objValue).toJS();
} | [
"function",
"mergeDefaults",
"(",
"obj",
",",
"src",
")",
"{",
"var",
"objValue",
"=",
"Immutable",
".",
"fromJS",
"(",
"obj",
")",
";",
"var",
"srcValue",
"=",
"Immutable",
".",
"fromJS",
"(",
"src",
")",
";",
"return",
"srcValue",
".",
"mergeDeep",
"... | Merge
@param {Object|Map} obj
@param {Object|Map} src
@return {Object} | [
"Merge"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/mergeDefaults.js#L9-L14 | train | Merge the default values of obj and src | [
30522,
3853,
5314,
12879,
23505,
2015,
1006,
27885,
3501,
1010,
5034,
2278,
1007,
1063,
13075,
27885,
3501,
10175,
5657,
1027,
10047,
28120,
3085,
1012,
2013,
22578,
1006,
27885,
3501,
1007,
1025,
13075,
5034,
2278,
10175,
5657,
1027,
10047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ImageViewer.js | _createImageView | function _createImageView(file, pane) {
var view = pane.getViewForPath(file.fullPath);
if (view) {
pane.showView(view);
} else {
view = new ImageView(file, pane.$content);
pane.addView(view, true);
}
return new $.Deferred().resolve().promise();
} | javascript | function _createImageView(file, pane) {
var view = pane.getViewForPath(file.fullPath);
if (view) {
pane.showView(view);
} else {
view = new ImageView(file, pane.$content);
pane.addView(view, true);
}
return new $.Deferred().resolve().promise();
} | [
"function",
"_createImageView",
"(",
"file",
",",
"pane",
")",
"{",
"var",
"view",
"=",
"pane",
".",
"getViewForPath",
"(",
"file",
".",
"fullPath",
")",
";",
"if",
"(",
"view",
")",
"{",
"pane",
".",
"showView",
"(",
"view",
")",
";",
"}",
"else",
... | /*
Creates an image view object and adds it to the specified pane
@param {!File} file - the file to create an image of
@param {!Pane} pane - the pane in which to host the view
@return {jQuery.Promise} | [
"/",
"*",
"Creates",
"an",
"image",
"view",
"object",
"and",
"adds",
"it",
"to",
"the",
"specified",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/ImageViewer.js#L417-L427 | train | Create ImageView | [
30522,
3853,
1035,
3443,
9581,
3351,
8584,
1006,
5371,
1010,
6090,
2063,
1007,
1063,
13075,
3193,
1027,
6090,
2063,
1012,
2131,
8584,
29278,
15069,
1006,
5371,
1012,
2440,
15069,
1007,
1025,
2065,
1006,
3193,
1007,
1063,
6090,
2063,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | getOrCreateHierarchy | function getOrCreateHierarchy(sKey) {
var oResult = oRecursiveHierarchies[sKey];
if (!oResult) {
oResult = oRecursiveHierarchies[sKey] = {};
}
return oResult;
} | javascript | function getOrCreateHierarchy(sKey) {
var oResult = oRecursiveHierarchies[sKey];
if (!oResult) {
oResult = oRecursiveHierarchies[sKey] = {};
}
return oResult;
} | [
"function",
"getOrCreateHierarchy",
"(",
"sKey",
")",
"{",
"var",
"oResult",
"=",
"oRecursiveHierarchies",
"[",
"sKey",
"]",
";",
"if",
"(",
"!",
"oResult",
")",
"{",
"oResult",
"=",
"oRecursiveHierarchies",
"[",
"sKey",
"]",
"=",
"{",
"}",
";",
"}",
"re... | temp for collecting all properties participating in hierarchies | [
"temp",
"for",
"collecting",
"all",
"properties",
"participating",
"in",
"hierarchies"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L2449-L2456 | train | Returns the hierarchy for the given key. | [
30522,
3853,
2131,
2953,
16748,
3686,
4048,
6906,
29389,
1006,
15315,
3240,
1007,
1063,
13075,
10848,
23722,
2102,
1027,
30524,
23722,
2102,
1027,
10848,
10841,
2869,
3512,
4048,
6906,
11140,
3111,
1031,
15315,
3240,
1033,
1027,
1063,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc-node | packages/grpc-native-core/src/client_interceptors.js | _getLastInterceptor | function _getLastInterceptor(method_definition, channel, responder) {
var callback = (responder instanceof Function) ? responder : function() {};
var emitter = (responder instanceof EventEmitter) ? responder :
new EventEmitter();
var method_type = common.getMethodType(method_definition);
var generator = interceptorGenerators[method_type];
return generator(method_definition, channel, emitter, callback);
} | javascript | function _getLastInterceptor(method_definition, channel, responder) {
var callback = (responder instanceof Function) ? responder : function() {};
var emitter = (responder instanceof EventEmitter) ? responder :
new EventEmitter();
var method_type = common.getMethodType(method_definition);
var generator = interceptorGenerators[method_type];
return generator(method_definition, channel, emitter, callback);
} | [
"function",
"_getLastInterceptor",
"(",
"method_definition",
",",
"channel",
",",
"responder",
")",
"{",
"var",
"callback",
"=",
"(",
"responder",
"instanceof",
"Function",
")",
"?",
"responder",
":",
"function",
"(",
")",
"{",
"}",
";",
"var",
"emitter",
"=... | Creates the last interceptor in an interceptor stack.
@private
@param {grpc~MethodDefinition} method_definition
@param {grpc.Channel} channel
@param {function|EventEmitter} responder
@return {Interceptor} | [
"Creates",
"the",
"last",
"interceptor",
"in",
"an",
"interceptor",
"stack",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1373-L1380 | train | Get last interceptor | [
30522,
3853,
1035,
2131,
8523,
7629,
3334,
3401,
13876,
2953,
1006,
4118,
1035,
6210,
1010,
3149,
1010,
6869,
2121,
1007,
1063,
13075,
2655,
5963,
1027,
1006,
6869,
2121,
6013,
11253,
3853,
1007,
1029,
6869,
2121,
1024,
3853,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | lib/jsdoc/create-api-index.js | collectLists | function collectLists(oSymbol) {
function addData(oDataType, oEntityObject, sObjectType, sSymbolName) {
let sSince = oDataType !== "since" ? oEntityObject[oDataType].since : oEntityObject.since,
oData = {
control: sSymbolName,
text: oEntityObject[oDataType].text || oEntityObject.description,
type: sObjectType,
"static": !!oEntityObject.static,
visibility: oEntityObject.visibility
};
// For class we skip entityName
if (sObjectType !== "class") {
oData.entityName = oEntityObject.name;
}
if (sSince && sSince !== "undefined" /* Sometimes sSince comes as string "undefined" */) {
// take only major and minor versions
let sVersion = sSince.split(".").slice(0, 2).join(".");
oData.since = sSince;
if (!oListCollection[oDataType][sVersion]) {
oListCollection[oDataType][sVersion] = {
name: sVersion,
apis: []
};
}
oListCollection[oDataType][sVersion].apis.push(oData);
} else if (oDataType !== "since" /* noVersion does not make sense for since and will fail */) {
oListCollection[oDataType].noVersion.apis.push(oData);
}
}
// Classes
if (oSymbol.deprecated) {
addData("deprecated", oSymbol, "class", oSymbol.name);
}
if (oSymbol.experimental) {
addData("experimental", oSymbol, "class", oSymbol.name);
}
if (oSymbol.since && oSymbol.since !== "undefined" /* Sometimes sSince comes as string "undefined" */) {
addData("since", oSymbol, "class", oSymbol.name);
}
// Methods
oSymbol.methods && oSymbol.methods.forEach(oMethod => {
if (oMethod.deprecated) {
addData("deprecated", oMethod, "methods", oSymbol.name);
}
if (oMethod.experimental) {
addData("experimental", oMethod, "methods", oSymbol.name);
}
if (oMethod.since) {
addData("since", oMethod, "methods", oSymbol.name);
}
});
// Events
oSymbol.events && oSymbol.events.forEach(oEvent => {
if (oEvent.deprecated) {
addData("deprecated", oEvent, "events", oSymbol.name);
}
if (oEvent.experimental) {
addData("experimental", oEvent, "events", oSymbol.name);
}
if (oEvent.since) {
addData("since", oEvent, "events", oSymbol.name);
}
});
} | javascript | function collectLists(oSymbol) {
function addData(oDataType, oEntityObject, sObjectType, sSymbolName) {
let sSince = oDataType !== "since" ? oEntityObject[oDataType].since : oEntityObject.since,
oData = {
control: sSymbolName,
text: oEntityObject[oDataType].text || oEntityObject.description,
type: sObjectType,
"static": !!oEntityObject.static,
visibility: oEntityObject.visibility
};
// For class we skip entityName
if (sObjectType !== "class") {
oData.entityName = oEntityObject.name;
}
if (sSince && sSince !== "undefined" /* Sometimes sSince comes as string "undefined" */) {
// take only major and minor versions
let sVersion = sSince.split(".").slice(0, 2).join(".");
oData.since = sSince;
if (!oListCollection[oDataType][sVersion]) {
oListCollection[oDataType][sVersion] = {
name: sVersion,
apis: []
};
}
oListCollection[oDataType][sVersion].apis.push(oData);
} else if (oDataType !== "since" /* noVersion does not make sense for since and will fail */) {
oListCollection[oDataType].noVersion.apis.push(oData);
}
}
// Classes
if (oSymbol.deprecated) {
addData("deprecated", oSymbol, "class", oSymbol.name);
}
if (oSymbol.experimental) {
addData("experimental", oSymbol, "class", oSymbol.name);
}
if (oSymbol.since && oSymbol.since !== "undefined" /* Sometimes sSince comes as string "undefined" */) {
addData("since", oSymbol, "class", oSymbol.name);
}
// Methods
oSymbol.methods && oSymbol.methods.forEach(oMethod => {
if (oMethod.deprecated) {
addData("deprecated", oMethod, "methods", oSymbol.name);
}
if (oMethod.experimental) {
addData("experimental", oMethod, "methods", oSymbol.name);
}
if (oMethod.since) {
addData("since", oMethod, "methods", oSymbol.name);
}
});
// Events
oSymbol.events && oSymbol.events.forEach(oEvent => {
if (oEvent.deprecated) {
addData("deprecated", oEvent, "events", oSymbol.name);
}
if (oEvent.experimental) {
addData("experimental", oEvent, "events", oSymbol.name);
}
if (oEvent.since) {
addData("since", oEvent, "events", oSymbol.name);
}
});
} | [
"function",
"collectLists",
"(",
"oSymbol",
")",
"{",
"function",
"addData",
"(",
"oDataType",
",",
"oEntityObject",
",",
"sObjectType",
",",
"sSymbolName",
")",
"{",
"let",
"sSince",
"=",
"oDataType",
"!==",
"\"since\"",
"?",
"oEntityObject",
"[",
"oDataType",
... | /*
Collects Deprecated, Experimental and Since data from passed symbol
including symbol itself, methods and events. | [
"/",
"*",
"Collects",
"Deprecated",
"Experimental",
"and",
"Since",
"data",
"from",
"passed",
"symbol",
"including",
"symbol",
"itself",
"methods",
"and",
"events",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/create-api-index.js#L135-L214 | train | collects all the lists | [
30522,
3853,
8145,
27103,
1006,
9808,
24335,
14956,
1007,
1063,
3853,
5587,
2850,
2696,
1006,
1051,
2850,
29336,
18863,
1010,
1051,
4765,
3012,
16429,
20614,
1010,
17540,
20614,
13874,
1010,
7020,
24335,
14956,
18442,
1007,
1063,
2292,
7020,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HealthData/HealthDataManager.js | sendAnalyticsDataToServer | function sendAnalyticsDataToServer(eventParams) {
var result = new $.Deferred();
var analyticsData = getAnalyticsData(eventParams);
$.ajax({
url: brackets.config.analyticsDataServerURL,
type: "POST",
data: JSON.stringify({events: [analyticsData]}),
headers: {
"Content-Type": "application/json",
"x-api-key": brackets.config.serviceKey
}
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Adobe Analytics Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
return result.promise();
} | javascript | function sendAnalyticsDataToServer(eventParams) {
var result = new $.Deferred();
var analyticsData = getAnalyticsData(eventParams);
$.ajax({
url: brackets.config.analyticsDataServerURL,
type: "POST",
data: JSON.stringify({events: [analyticsData]}),
headers: {
"Content-Type": "application/json",
"x-api-key": brackets.config.serviceKey
}
})
.done(function () {
result.resolve();
})
.fail(function (jqXHR, status, errorThrown) {
console.error("Error in sending Adobe Analytics Data. Response : " + jqXHR.responseText + ". Status : " + status + ". Error : " + errorThrown);
result.reject();
});
return result.promise();
} | [
"function",
"sendAnalyticsDataToServer",
"(",
"eventParams",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"analyticsData",
"=",
"getAnalyticsData",
"(",
"eventParams",
")",
";",
"$",
".",
"ajax",
"(",
"{",
"url",
":",
... | Send Analytics data to Server | [
"Send",
"Analytics",
"data",
"to",
"Server"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L215-L237 | train | Send Adobe Analytics Data to the server | [
30522,
3853,
4604,
27953,
21252,
16150,
6790,
22282,
2099,
6299,
1006,
2724,
28689,
5244,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
13075,
25095,
2850,
2696,
1027,
2131,
27953,
21252,
16150,
6790,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/indent-legacy.js | checkLastNodeLineIndent | function checkLastNodeLineIndent(node, lastLineIndent) {
const lastToken = sourceCode.getLastToken(node);
const endIndent = getNodeIndent(lastToken, true);
if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
report(
node,
lastLineIndent,
endIndent.space,
endIndent.tab,
{ line: lastToken.loc.start.line, column: lastToken.loc.start.column },
true
);
}
} | javascript | function checkLastNodeLineIndent(node, lastLineIndent) {
const lastToken = sourceCode.getLastToken(node);
const endIndent = getNodeIndent(lastToken, true);
if ((endIndent.goodChar !== lastLineIndent || endIndent.badChar !== 0) && isNodeFirstInLine(node, true)) {
report(
node,
lastLineIndent,
endIndent.space,
endIndent.tab,
{ line: lastToken.loc.start.line, column: lastToken.loc.start.column },
true
);
}
} | [
"function",
"checkLastNodeLineIndent",
"(",
"node",
",",
"lastLineIndent",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"endIndent",
"=",
"getNodeIndent",
"(",
"lastToken",
",",
"true",
")",
";",
"if",... | Check last node line indent this detects, that block closed correctly
@param {ASTNode} node Node to examine
@param {int} lastLineIndent needed indent
@returns {void} | [
"Check",
"last",
"node",
"line",
"indent",
"this",
"detects",
"that",
"block",
"closed",
"correctly"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L432-L446 | train | Check last node line indent | [
30522,
3853,
4638,
8523,
2102,
3630,
9247,
3170,
22254,
4765,
1006,
13045,
1010,
2197,
4179,
22254,
4765,
1007,
1063,
9530,
3367,
2197,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
1007,
1025,
9530,
3367,
2203,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/features/JumpToDefManager.js | _doJumpToDef | function _doJumpToDef() {
var request = null,
result = new $.Deferred(),
jumpToDefProvider = null,
editor = EditorManager.getActiveEditor();
if (editor) {
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.canJumpToDef(editor)) {
jumpToDefProvider = item.provider;
return true;
}
});
if (jumpToDefProvider) {
request = jumpToDefProvider.doJumpToDef(editor);
if (request) {
request.done(function () {
result.resolve();
}).fail(function () {
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | javascript | function _doJumpToDef() {
var request = null,
result = new $.Deferred(),
jumpToDefProvider = null,
editor = EditorManager.getActiveEditor();
if (editor) {
// Find a suitable provider, if any
var language = editor.getLanguageForSelection(),
enabledProviders = _providerRegistrationHandler.getProvidersForLanguageId(language.getId());
enabledProviders.some(function (item, index) {
if (item.provider.canJumpToDef(editor)) {
jumpToDefProvider = item.provider;
return true;
}
});
if (jumpToDefProvider) {
request = jumpToDefProvider.doJumpToDef(editor);
if (request) {
request.done(function () {
result.resolve();
}).fail(function () {
result.reject();
});
} else {
result.reject();
}
} else {
result.reject();
}
} else {
result.reject();
}
return result.promise();
} | [
"function",
"_doJumpToDef",
"(",
")",
"{",
"var",
"request",
"=",
"null",
",",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"jumpToDefProvider",
"=",
"null",
",",
"editor",
"=",
"EditorManager",
".",
"getActiveEditor",
"(",
")",
";",
"if",
... | Asynchronously asks providers to handle jump-to-definition.
@return {!Promise} Resolved when the provider signals that it's done; rejected if no
provider responded or the provider that responded failed. | [
"Asynchronously",
"asks",
"providers",
"to",
"handle",
"jump",
"-",
"to",
"-",
"definition",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/features/JumpToDefManager.js#L44-L83 | train | Do a jump to definition | [
30522,
3853,
1035,
2079,
9103,
27718,
10244,
2546,
1006,
1007,
1063,
13075,
5227,
1027,
19701,
1010,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
5376,
3406,
3207,
22540,
12298,
18688,
1027,
19701,
1010,
3559,
1027,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue) {
return Expression.parameter(oPathValue, 0).then(function (oResult) {
return {
result : "expression",
type : "Edm.String",
value : oResult.type === "Edm.String"
// Note: odata.uriEncode() is V2, but safe for Edm.String!
? 'odata.uriEncode(' + Basics.resultToString(oResult, true, false) + ","
+ Basics.toJSON(oResult.type) + ")"
// Note: see _Helper.formatLiteral()
: 'String(' + Basics.resultToString(oResult, true, false) + ")"
};
});
} | javascript | function (oPathValue) {
return Expression.parameter(oPathValue, 0).then(function (oResult) {
return {
result : "expression",
type : "Edm.String",
value : oResult.type === "Edm.String"
// Note: odata.uriEncode() is V2, but safe for Edm.String!
? 'odata.uriEncode(' + Basics.resultToString(oResult, true, false) + ","
+ Basics.toJSON(oResult.type) + ")"
// Note: see _Helper.formatLiteral()
: 'String(' + Basics.resultToString(oResult, true, false) + ")"
};
});
} | [
"function",
"(",
"oPathValue",
")",
"{",
"return",
"Expression",
".",
"parameter",
"(",
"oPathValue",
",",
"0",
")",
".",
"then",
"(",
"function",
"(",
"oResult",
")",
"{",
"return",
"{",
"result",
":",
"\"expression\"",
",",
"type",
":",
"\"Edm.String\"",... | Handling of "14.5.3.1.3 Function odata.uriEncode".
@param {object} oPathValue
path and value information pointing to the parameter array (see Expression object)
@returns {sap.ui.base.SyncPromise}
a sync promise which resolves with the result object or is rejected with an error | [
"Handling",
"of",
"14",
".",
"5",
".",
"3",
".",
"1",
".",
"3",
"Function",
"odata",
".",
"uriEncode",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L758-L771 | train | Returns an object with the parameters of the given path | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1007,
1063,
2709,
3670,
1012,
16381,
1006,
6728,
8988,
10175,
5657,
1010,
1014,
1007,
1012,
2059,
1006,
3853,
1006,
10848,
23722,
2102,
1007,
1063,
2709,
1063,
2765,
1024,
1000,
3670,
1000,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | dist/extension/dataTool.js | quantile | function quantile(ascArr, p) {
var H = (ascArr.length - 1) * p + 1;
var h = Math.floor(H);
var v = +ascArr[h - 1];
var e = H - h;
return e ? v + e * (ascArr[h] - v) : v;
} | javascript | function quantile(ascArr, p) {
var H = (ascArr.length - 1) * p + 1;
var h = Math.floor(H);
var v = +ascArr[h - 1];
var e = H - h;
return e ? v + e * (ascArr[h] - v) : v;
} | [
"function",
"quantile",
"(",
"ascArr",
",",
"p",
")",
"{",
"var",
"H",
"=",
"(",
"ascArr",
".",
"length",
"-",
"1",
")",
"*",
"p",
"+",
"1",
";",
"var",
"h",
"=",
"Math",
".",
"floor",
"(",
"H",
")",
";",
"var",
"v",
"=",
"+",
"ascArr",
"["... | find a “nice” number approximately equal to x. Round the number if round = true,
take ceiling if round = false. The primary observation is that the “nicest”
numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
See "Nice Numbers for Graph Labels" of Graphic Gems.
@param {number} val Non-negative value.
@param {boolean} round
@return {number}
This code was copied from "d3.js"
<https://github.com/d3/d3/blob/9cc9a875e636a1dcf36cc1e07bdf77e1ad6e2c74/src/arrays/quantile.js>.
See the license statement at the head of this file.
@param {Array.<number>} ascArr | [
"find",
"a",
"“nice”",
"number",
"approximately",
"equal",
"to",
"x",
".",
"Round",
"the",
"number",
"if",
"round",
"=",
"true",
"take",
"ceiling",
"if",
"round",
"=",
"false",
".",
"The",
"primary",
"observation",
"is",
"that",
"the",
"“nicest”",
"numbers... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/dist/extension/dataTool.js#L684-L690 | train | returns the quantile of the array | [
30522,
3853,
24110,
15286,
1006,
2004,
10010,
2099,
1010,
1052,
1007,
1063,
13075,
1044,
1027,
1006,
2004,
10010,
2099,
1012,
3091,
1011,
1015,
1007,
1008,
1052,
1009,
1015,
1025,
13075,
1044,
1027,
8785,
1012,
2723,
1006,
1044,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/mvc/Controller.js | instantiateController | function instantiateController(ControllerClass, sName) {
var oController;
if (mRegistry[sName]) {
oController = new ControllerClass(sName);
} else {
oController = new ControllerClass();
}
if (!oController) {
throw new Error("Controller " + sName + " couldn't be instantiated");
}
return oController;
} | javascript | function instantiateController(ControllerClass, sName) {
var oController;
if (mRegistry[sName]) {
oController = new ControllerClass(sName);
} else {
oController = new ControllerClass();
}
if (!oController) {
throw new Error("Controller " + sName + " couldn't be instantiated");
}
return oController;
} | [
"function",
"instantiateController",
"(",
"ControllerClass",
",",
"sName",
")",
"{",
"var",
"oController",
";",
"if",
"(",
"mRegistry",
"[",
"sName",
"]",
")",
"{",
"oController",
"=",
"new",
"ControllerClass",
"(",
"sName",
")",
";",
"}",
"else",
"{",
"oC... | /*
Instantiation of a controller
@param {function} ControllerClass The controller constructor
@param {string} sName the controller name
@param {boolean} bAsync Load async or not
@return {sap.ui.core.mvc.Controller|Promise} A <code>Promise</code> in case of asynchronous extend
or the <code>controller</code> in case of synchronous extend | [
"/",
"*",
"Instantiation",
"of",
"a",
"controller"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/mvc/Controller.js#L344-L355 | train | Instantiate a controller | [
30522,
3853,
7107,
13143,
8663,
13181,
10820,
1006,
11486,
26266,
1010,
1055,
18442,
1007,
1063,
13075,
1051,
8663,
13181,
10820,
1025,
2065,
1006,
2720,
13910,
2923,
2854,
1031,
1055,
18442,
1033,
1007,
1063,
1051,
8663,
13181,
10820,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableAccRenderExtension.js | function(oRm, oTable, oRow, iRowIndex) {
if (!oTable._getAccExtension().getAccMode()) {
return;
}
var oRowSettings = oRow.getAggregation("_settings");
var sHighlightText = oRowSettings._getHighlightText();
_writeAccText(oRm, oRow.getId(), "highlighttext", sHighlightText);
} | javascript | function(oRm, oTable, oRow, iRowIndex) {
if (!oTable._getAccExtension().getAccMode()) {
return;
}
var oRowSettings = oRow.getAggregation("_settings");
var sHighlightText = oRowSettings._getHighlightText();
_writeAccText(oRm, oRow.getId(), "highlighttext", sHighlightText);
} | [
"function",
"(",
"oRm",
",",
"oTable",
",",
"oRow",
",",
"iRowIndex",
")",
"{",
"if",
"(",
"!",
"oTable",
".",
"_getAccExtension",
"(",
")",
".",
"getAccMode",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"oRowSettings",
"=",
"oRow",
".",
"getAggre... | Renders the default row highlight content.
@param {sap.ui.core.RenderManager} oRm The RenderManager that can be used for writing to the Render-Output-Buffer.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {sap.ui.table.Row} oRow Instance of the row.
@param {int} iRowIndex The index of the row.
@see sap.ui.table.TableRenderer#writeRowHighlightContent
@public | [
"Renders",
"the",
"default",
"row",
"highlight",
"content",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccRenderExtension.js#L203-L212 | train | Renders the highlight text of a row. | [
30522,
3853,
1006,
2030,
2213,
1010,
27178,
3085,
1010,
20298,
2860,
1010,
20868,
5004,
22254,
10288,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1012,
1035,
2131,
6305,
3401,
18413,
6132,
3258,
1006,
1007,
1012,
2131,
6305,
27487,
10244,
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... | |
SAP/openui5 | src/sap.m/src/sap/m/ViewSettingsDialog.js | restoreCustomTabContentAggregation | function restoreCustomTabContentAggregation(sAggregationName, oCustomTab) {
// Make sure page1 exists, as this method may be called on destroy(), after the page was destroyed
// Suppress creation of new page as the following logic is needed only when a page already exists
if (!this._getPage1(true)) {
return;
}
// only the 'customTabs' aggregation is manipulated with shenanigans
if (sAggregationName === 'customTabs' && oCustomTab) {
/* oCustomTab must be an instance of the "customTab" aggregation type and must be the last opened page */
if (oCustomTab.getMetadata().getName() === this.getMetadata().getManagedAggregation(sAggregationName).type &&
this._vContentPage === oCustomTab.getId()) {
/* the iContentPage property corresponds to the custom tab id - set the custom tab content aggregation
back to the custom tab instance */
var oPage1Content = this._getPage1().getContent();
oPage1Content.forEach(function (oContent) {
oCustomTab.addAggregation('content', oContent, true);
});
}
} else if (!sAggregationName && !oCustomTab) {
/* when these parameters are missing, cycle through all custom tabs and detect if any needs manipulation */
var oPage1Content = this._getPage1().getContent();
/* the vContentPage property corresponds to a custom tab id - set the custom tab content aggregation back
to the corresponding custom tab instance, so it can be reused later */
this.getCustomTabs().forEach(function (oCustomTab) {
if (this._vContentPage === oCustomTab.getId()) {
oPage1Content.forEach(function (oContent) {
oCustomTab.addAggregation('content', oContent, true);
});
}
}, this);
}
} | javascript | function restoreCustomTabContentAggregation(sAggregationName, oCustomTab) {
// Make sure page1 exists, as this method may be called on destroy(), after the page was destroyed
// Suppress creation of new page as the following logic is needed only when a page already exists
if (!this._getPage1(true)) {
return;
}
// only the 'customTabs' aggregation is manipulated with shenanigans
if (sAggregationName === 'customTabs' && oCustomTab) {
/* oCustomTab must be an instance of the "customTab" aggregation type and must be the last opened page */
if (oCustomTab.getMetadata().getName() === this.getMetadata().getManagedAggregation(sAggregationName).type &&
this._vContentPage === oCustomTab.getId()) {
/* the iContentPage property corresponds to the custom tab id - set the custom tab content aggregation
back to the custom tab instance */
var oPage1Content = this._getPage1().getContent();
oPage1Content.forEach(function (oContent) {
oCustomTab.addAggregation('content', oContent, true);
});
}
} else if (!sAggregationName && !oCustomTab) {
/* when these parameters are missing, cycle through all custom tabs and detect if any needs manipulation */
var oPage1Content = this._getPage1().getContent();
/* the vContentPage property corresponds to a custom tab id - set the custom tab content aggregation back
to the corresponding custom tab instance, so it can be reused later */
this.getCustomTabs().forEach(function (oCustomTab) {
if (this._vContentPage === oCustomTab.getId()) {
oPage1Content.forEach(function (oContent) {
oCustomTab.addAggregation('content', oContent, true);
});
}
}, this);
}
} | [
"function",
"restoreCustomTabContentAggregation",
"(",
"sAggregationName",
",",
"oCustomTab",
")",
"{",
"// Make sure page1 exists, as this method may be called on destroy(), after the page was destroyed",
"// Suppress creation of new page as the following logic is needed only when a page already ... | Handle the "content" aggregation of a custom tab, as the items in it might be transferred to the dialog page
instance.
@param {string} sAggregationName The string identifying the aggregation that the given object should be removed from
@param {object} oCustomTab Custom tab instance
@private | [
"Handle",
"the",
"content",
"aggregation",
"of",
"a",
"custom",
"tab",
"as",
"the",
"items",
"in",
"it",
"might",
"be",
"transferred",
"to",
"the",
"dialog",
"page",
"instance",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/ViewSettingsDialog.js#L3158-L3191 | train | Restores the content aggregation of a custom tab | [
30522,
3853,
9239,
7874,
20389,
2696,
9818,
28040,
12380,
13871,
2890,
12540,
1006,
7842,
13871,
2890,
12540,
18442,
1010,
1051,
7874,
20389,
2696,
2497,
1007,
1063,
1013,
1013,
2191,
2469,
3931,
2487,
6526,
1010,
2004,
2023,
4118,
2089,
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... |
catapult-project/catapult | dashboard/dashboard/spa/alerts-section.js | loadMore | function loadMore(batches, alertGroups, nextRequests, triagedRequests,
triagedMaxStartRevision, started) {
const minStartRevision = tr.b.math.Statistics.min(
alertGroups, group => tr.b.math.Statistics.min(
group.alerts, a => a.startRevision));
if (!triagedMaxStartRevision ||
(minStartRevision < triagedMaxStartRevision)) {
for (const request of triagedRequests) {
request.min_start_revision = minStartRevision;
if (triagedMaxStartRevision) {
request.max_start_revision = triagedMaxStartRevision;
}
batches.add(wrapRequest(request));
}
}
for (const next of nextRequests) {
// Always chase down cursors for triaged alerts.
// Limit the number of alertGroups displayed to prevent OOM.
if (next.bug_id === '*' ||
(alertGroups.length < ENOUGH_GROUPS &&
((performance.now() - started) < ENOUGH_LOADING_MS))) {
batches.add(wrapRequest(next));
}
}
return minStartRevision;
} | javascript | function loadMore(batches, alertGroups, nextRequests, triagedRequests,
triagedMaxStartRevision, started) {
const minStartRevision = tr.b.math.Statistics.min(
alertGroups, group => tr.b.math.Statistics.min(
group.alerts, a => a.startRevision));
if (!triagedMaxStartRevision ||
(minStartRevision < triagedMaxStartRevision)) {
for (const request of triagedRequests) {
request.min_start_revision = minStartRevision;
if (triagedMaxStartRevision) {
request.max_start_revision = triagedMaxStartRevision;
}
batches.add(wrapRequest(request));
}
}
for (const next of nextRequests) {
// Always chase down cursors for triaged alerts.
// Limit the number of alertGroups displayed to prevent OOM.
if (next.bug_id === '*' ||
(alertGroups.length < ENOUGH_GROUPS &&
((performance.now() - started) < ENOUGH_LOADING_MS))) {
batches.add(wrapRequest(next));
}
}
return minStartRevision;
} | [
"function",
"loadMore",
"(",
"batches",
",",
"alertGroups",
",",
"nextRequests",
",",
"triagedRequests",
",",
"triagedMaxStartRevision",
",",
"started",
")",
"{",
"const",
"minStartRevision",
"=",
"tr",
".",
"b",
".",
"math",
".",
"Statistics",
".",
"min",
"("... | This function may add requests to `batches`. See handleBatch for `nextRequests` and `triagedRequests`. | [
"This",
"function",
"may",
"add",
"requests",
"to",
"batches",
".",
"See",
"handleBatch",
"for",
"nextRequests",
"and",
"triagedRequests",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/alerts-section.js#L325-L353 | train | Load more requests from the nextRequests array. | [
30522,
3853,
7170,
5974,
1006,
14108,
2229,
1010,
9499,
17058,
2015,
1010,
2279,
2890,
15500,
2015,
1010,
13012,
18655,
2890,
15500,
2015,
1010,
13012,
18655,
17848,
14117,
7913,
17084,
1010,
2318,
1007,
1063,
9530,
3367,
8117,
14117,
7913,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/document/DocumentCommandHandlers.js | _doSaveAs | function _doSaveAs(doc, settings) {
var origPath,
saveAsDefaultPath,
defaultName,
result = new $.Deferred();
function _doSaveAfterSaveDialog(path) {
var newFile;
// Reconstruct old doc's editor's view state, & finally resolve overall promise
function _configureEditorAndResolve() {
var editor = EditorManager.getActiveEditor();
if (editor) {
if (settings) {
editor.setSelections(settings.selections);
editor.setScrollPos(settings.scrollPos.x, settings.scrollPos.y);
}
}
result.resolve(newFile);
}
// Replace old document with new one in open editor & workingset
function openNewFile() {
var fileOpenPromise;
if (FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER) {
// If selection is in the tree, leave workingset unchanged - even if orig file is in the list
fileOpenPromise = FileViewController
.openAndSelectDocument(path, FileViewController.PROJECT_MANAGER);
} else {
// If selection is in workingset, replace orig item in place with the new file
var info = MainViewManager.findInAllWorkingSets(doc.file.fullPath).shift();
// Remove old file from workingset; no redraw yet since there's a pause before the new file is opened
MainViewManager._removeView(info.paneId, doc.file, true);
// Add new file to workingset, and ensure we now redraw (even if index hasn't changed)
fileOpenPromise = handleFileAddToWorkingSetAndOpen({fullPath: path, paneId: info.paneId, index: info.index, forceRedraw: true});
}
// always configure editor after file is opened
fileOpenPromise.always(function () {
_configureEditorAndResolve();
});
}
// Same name as before - just do a regular Save
if (path === origPath) {
doSave(doc).then(result.resolve, result.reject);
return;
}
doc.isSaving = true; // mark that we're saving the document
// First, write document's current text to new file
if (doc.file._encoding && doc.file._encoding !== "UTF-8") {
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
encoding[path] = doc.file._encoding;
PreferencesManager.setViewState("encoding", encoding, context);
}
newFile = FileSystem.getFileForPath(path);
newFile._encoding = doc.file._encoding;
// Save as warns you when you're about to overwrite a file, so we
// explicitly allow "blind" writes to the filesystem in this case,
// ignoring warnings about the contents being modified outside of
// the editor.
FileUtils.writeText(newFile, doc.getText(true), true)
.done(function () {
// If there were unsaved changes before Save As, they don't stay with the old
// file anymore - so must revert the old doc to match disk content.
// Only do this if the doc was dirty: _doRevert on a file that is not dirty and
// not in the workingset has the side effect of adding it to the workingset.
if (doc.isDirty && !(doc.isUntitled())) {
// if the file is dirty it must be in the workingset
// _doRevert is side effect free in this case
_doRevert(doc).always(openNewFile);
} else {
openNewFile();
}
HealthLogger.fileSaved(doc);
})
.fail(function (error) {
_showSaveFileError(error, path)
.done(function () {
result.reject(error);
});
})
.always(function () {
// mark that we're done saving the document
doc.isSaving = false;
});
}
if (doc) {
origPath = doc.file.fullPath;
// If the document is an untitled document, we should default to project root.
if (doc.isUntitled()) {
// (Issue #4489) if we're saving an untitled document, go ahead and switch to this document
// in the editor, so that if we're, for example, saving several files (ie. Save All),
// then the user can visually tell which document we're currently prompting them to save.
var info = MainViewManager.findInAllWorkingSets(origPath).shift();
if (info) {
MainViewManager._open(info.paneId, doc.file);
}
// If the document is untitled, default to project root.
saveAsDefaultPath = ProjectManager.getProjectRoot().fullPath;
} else {
saveAsDefaultPath = FileUtils.getDirectoryPath(origPath);
}
defaultName = FileUtils.getBaseName(origPath);
var file = FileSystem.getFileForPath(origPath);
if (file instanceof InMemoryFile) {
var language = LanguageManager.getLanguageForPath(origPath);
if (language) {
var fileExtensions = language.getFileExtensions();
if (fileExtensions && fileExtensions.length > 0) {
defaultName += "." + fileExtensions[0];
}
}
}
FileSystem.showSaveDialog(Strings.SAVE_FILE_AS, saveAsDefaultPath, defaultName, function (err, selectedPath) {
if (!err) {
if (selectedPath) {
_doSaveAfterSaveDialog(selectedPath);
} else {
dispatchAppQuitCancelledEvent();
result.reject(USER_CANCELED);
}
} else {
result.reject(err);
}
});
} else {
result.reject();
}
return result.promise();
} | javascript | function _doSaveAs(doc, settings) {
var origPath,
saveAsDefaultPath,
defaultName,
result = new $.Deferred();
function _doSaveAfterSaveDialog(path) {
var newFile;
// Reconstruct old doc's editor's view state, & finally resolve overall promise
function _configureEditorAndResolve() {
var editor = EditorManager.getActiveEditor();
if (editor) {
if (settings) {
editor.setSelections(settings.selections);
editor.setScrollPos(settings.scrollPos.x, settings.scrollPos.y);
}
}
result.resolve(newFile);
}
// Replace old document with new one in open editor & workingset
function openNewFile() {
var fileOpenPromise;
if (FileViewController.getFileSelectionFocus() === FileViewController.PROJECT_MANAGER) {
// If selection is in the tree, leave workingset unchanged - even if orig file is in the list
fileOpenPromise = FileViewController
.openAndSelectDocument(path, FileViewController.PROJECT_MANAGER);
} else {
// If selection is in workingset, replace orig item in place with the new file
var info = MainViewManager.findInAllWorkingSets(doc.file.fullPath).shift();
// Remove old file from workingset; no redraw yet since there's a pause before the new file is opened
MainViewManager._removeView(info.paneId, doc.file, true);
// Add new file to workingset, and ensure we now redraw (even if index hasn't changed)
fileOpenPromise = handleFileAddToWorkingSetAndOpen({fullPath: path, paneId: info.paneId, index: info.index, forceRedraw: true});
}
// always configure editor after file is opened
fileOpenPromise.always(function () {
_configureEditorAndResolve();
});
}
// Same name as before - just do a regular Save
if (path === origPath) {
doSave(doc).then(result.resolve, result.reject);
return;
}
doc.isSaving = true; // mark that we're saving the document
// First, write document's current text to new file
if (doc.file._encoding && doc.file._encoding !== "UTF-8") {
var projectRoot = ProjectManager.getProjectRoot(),
context = {
location : {
scope: "user",
layer: "project",
layerID: projectRoot.fullPath
}
};
var encoding = PreferencesManager.getViewState("encoding", context);
encoding[path] = doc.file._encoding;
PreferencesManager.setViewState("encoding", encoding, context);
}
newFile = FileSystem.getFileForPath(path);
newFile._encoding = doc.file._encoding;
// Save as warns you when you're about to overwrite a file, so we
// explicitly allow "blind" writes to the filesystem in this case,
// ignoring warnings about the contents being modified outside of
// the editor.
FileUtils.writeText(newFile, doc.getText(true), true)
.done(function () {
// If there were unsaved changes before Save As, they don't stay with the old
// file anymore - so must revert the old doc to match disk content.
// Only do this if the doc was dirty: _doRevert on a file that is not dirty and
// not in the workingset has the side effect of adding it to the workingset.
if (doc.isDirty && !(doc.isUntitled())) {
// if the file is dirty it must be in the workingset
// _doRevert is side effect free in this case
_doRevert(doc).always(openNewFile);
} else {
openNewFile();
}
HealthLogger.fileSaved(doc);
})
.fail(function (error) {
_showSaveFileError(error, path)
.done(function () {
result.reject(error);
});
})
.always(function () {
// mark that we're done saving the document
doc.isSaving = false;
});
}
if (doc) {
origPath = doc.file.fullPath;
// If the document is an untitled document, we should default to project root.
if (doc.isUntitled()) {
// (Issue #4489) if we're saving an untitled document, go ahead and switch to this document
// in the editor, so that if we're, for example, saving several files (ie. Save All),
// then the user can visually tell which document we're currently prompting them to save.
var info = MainViewManager.findInAllWorkingSets(origPath).shift();
if (info) {
MainViewManager._open(info.paneId, doc.file);
}
// If the document is untitled, default to project root.
saveAsDefaultPath = ProjectManager.getProjectRoot().fullPath;
} else {
saveAsDefaultPath = FileUtils.getDirectoryPath(origPath);
}
defaultName = FileUtils.getBaseName(origPath);
var file = FileSystem.getFileForPath(origPath);
if (file instanceof InMemoryFile) {
var language = LanguageManager.getLanguageForPath(origPath);
if (language) {
var fileExtensions = language.getFileExtensions();
if (fileExtensions && fileExtensions.length > 0) {
defaultName += "." + fileExtensions[0];
}
}
}
FileSystem.showSaveDialog(Strings.SAVE_FILE_AS, saveAsDefaultPath, defaultName, function (err, selectedPath) {
if (!err) {
if (selectedPath) {
_doSaveAfterSaveDialog(selectedPath);
} else {
dispatchAppQuitCancelledEvent();
result.reject(USER_CANCELED);
}
} else {
result.reject(err);
}
});
} else {
result.reject();
}
return result.promise();
} | [
"function",
"_doSaveAs",
"(",
"doc",
",",
"settings",
")",
"{",
"var",
"origPath",
",",
"saveAsDefaultPath",
",",
"defaultName",
",",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"function",
"_doSaveAfterSaveDialog",
"(",
"path",
")",
"{",
"v... | Opens the native OS save as dialog and saves document.
The original document is reverted in case it was dirty.
Text selection and cursor position from the original document
are preserved in the new document.
When saving to the original document the document is saved as if save was called.
@param {Document} doc
@param {?{cursorPos:!Object, selection:!Object, scrollPos:!Object}} settings - properties of
the original document's editor that need to be carried over to the new document
i.e. scrollPos, cursorPos and text selection
@return {$.Promise} a promise that is resolved with the saved document's File. Rejected in
case of IO error (after error dialog dismissed), or if the Save dialog was canceled. | [
"Opens",
"the",
"native",
"OS",
"save",
"as",
"dialog",
"and",
"saves",
"document",
".",
"The",
"original",
"document",
"is",
"reverted",
"in",
"case",
"it",
"was",
"dirty",
".",
"Text",
"selection",
"and",
"cursor",
"position",
"from",
"the",
"original",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L892-L1039 | train | Save a document as a file | [
30522,
3853,
1035,
9998,
10696,
3022,
1006,
9986,
1010,
10906,
1007,
1063,
13075,
2030,
8004,
15069,
1010,
3828,
3022,
3207,
7011,
11314,
15069,
1010,
12398,
18442,
1010,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ExpressionParser.js | saveBindingAsPart | function saveBindingAsPart(oBinding, iStart, bTargetTypeAny) {
var bHasNonPrimitiveValue = false,
sKey,
oPrimitiveValueBinding,
i;
/*
* Sets the target type of the given binding to the default "any", if applicable.
*
* @param {object} oBinding
* A binding
*/
function setTargetType(oBinding) {
if (bTargetTypeAny) {
if (oBinding.parts) {
oBinding.parts.forEach(setTargetType);
// Note: targetType not allowed here, see BindingParser.mergeParts
} else {
oBinding.targetType = oBinding.targetType || "any";
}
}
}
for (sKey in oBinding) {
switch (typeof oBinding[sKey]) {
case "boolean":
case "number":
case "string":
case "undefined":
break;
default:
// binding has at least one property of non-primitive value
bHasNonPrimitiveValue = true;
}
}
setTargetType(oBinding);
if (bHasNonPrimitiveValue) {
// the binding must be a complex binding; property "type" (and poss. others) are
// newly created objects and thus incomparable -> parse again to have the names
oPrimitiveValueBinding = JSTokenizer.parseJS(sInput, iStart).result;
setTargetType(oPrimitiveValueBinding);
} else {
// only primitive values; easily comparable
oPrimitiveValueBinding = oBinding;
}
for (i = 0; i < aParts.length; i += 1) {
// Note: order of top-level properties must not matter for equality!
if (deepEqual(aPrimitiveValueBindings[i], oPrimitiveValueBinding)) {
return i;
}
}
aPrimitiveValueBindings[i] = oPrimitiveValueBinding;
aParts[i] = oBinding;
return i;
} | javascript | function saveBindingAsPart(oBinding, iStart, bTargetTypeAny) {
var bHasNonPrimitiveValue = false,
sKey,
oPrimitiveValueBinding,
i;
/*
* Sets the target type of the given binding to the default "any", if applicable.
*
* @param {object} oBinding
* A binding
*/
function setTargetType(oBinding) {
if (bTargetTypeAny) {
if (oBinding.parts) {
oBinding.parts.forEach(setTargetType);
// Note: targetType not allowed here, see BindingParser.mergeParts
} else {
oBinding.targetType = oBinding.targetType || "any";
}
}
}
for (sKey in oBinding) {
switch (typeof oBinding[sKey]) {
case "boolean":
case "number":
case "string":
case "undefined":
break;
default:
// binding has at least one property of non-primitive value
bHasNonPrimitiveValue = true;
}
}
setTargetType(oBinding);
if (bHasNonPrimitiveValue) {
// the binding must be a complex binding; property "type" (and poss. others) are
// newly created objects and thus incomparable -> parse again to have the names
oPrimitiveValueBinding = JSTokenizer.parseJS(sInput, iStart).result;
setTargetType(oPrimitiveValueBinding);
} else {
// only primitive values; easily comparable
oPrimitiveValueBinding = oBinding;
}
for (i = 0; i < aParts.length; i += 1) {
// Note: order of top-level properties must not matter for equality!
if (deepEqual(aPrimitiveValueBindings[i], oPrimitiveValueBinding)) {
return i;
}
}
aPrimitiveValueBindings[i] = oPrimitiveValueBinding;
aParts[i] = oBinding;
return i;
} | [
"function",
"saveBindingAsPart",
"(",
"oBinding",
",",
"iStart",
",",
"bTargetTypeAny",
")",
"{",
"var",
"bHasNonPrimitiveValue",
"=",
"false",
",",
"sKey",
",",
"oPrimitiveValueBinding",
",",
"i",
";",
"/*\n\t\t\t * Sets the target type of the given binding to the default ... | Saves the binding as a part. Reuses an existing part if the binding is identical.
@param {object} oBinding
the binding to save
@param {int} iStart
the binding's start index in the input string
@param {boolean} [bTargetTypeAny=false]
whether the binding's "targetType" should default to "any" (recursively, for all parts)
@returns {int}
the index at which it has been saved/found in aParts | [
"Saves",
"the",
"binding",
"as",
"a",
"part",
".",
"Reuses",
"an",
"existing",
"part",
"if",
"the",
"binding",
"is",
"identical",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ExpressionParser.js#L541-L595 | train | Saves the given binding as part of the given input string. | [
30522,
3853,
3828,
8428,
4667,
3022,
19362,
2102,
1006,
27885,
22254,
2075,
1010,
21541,
8445,
1010,
18411,
2906,
18150,
13874,
19092,
1007,
1063,
13075,
1038,
14949,
8540,
18098,
27605,
6024,
10175,
5657,
1027,
6270,
1010,
15315,
3240,
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... |
jhipster/generator-jhipster | generators/docker-prompts.js | askForAdminPassword | function askForAdminPassword() {
if (this.regenerate || this.serviceDiscoveryType !== 'eureka') return;
const done = this.async();
const prompts = [
{
type: 'input',
name: 'adminPassword',
message: 'Enter the admin password used to secure the JHipster Registry',
default: 'admin',
validate: input => (input.length < 5 ? 'The password must have at least 5 characters' : true)
}
];
this.prompt(prompts).then(props => {
this.adminPassword = props.adminPassword;
this.adminPasswordBase64 = getBase64Secret(this.adminPassword);
done();
});
} | javascript | function askForAdminPassword() {
if (this.regenerate || this.serviceDiscoveryType !== 'eureka') return;
const done = this.async();
const prompts = [
{
type: 'input',
name: 'adminPassword',
message: 'Enter the admin password used to secure the JHipster Registry',
default: 'admin',
validate: input => (input.length < 5 ? 'The password must have at least 5 characters' : true)
}
];
this.prompt(prompts).then(props => {
this.adminPassword = props.adminPassword;
this.adminPasswordBase64 = getBase64Secret(this.adminPassword);
done();
});
} | [
"function",
"askForAdminPassword",
"(",
")",
"{",
"if",
"(",
"this",
".",
"regenerate",
"||",
"this",
".",
"serviceDiscoveryType",
"!==",
"'eureka'",
")",
"return",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
... | Ask For Admin Password | [
"Ask",
"For",
"Admin",
"Password"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-prompts.js#L376-L396 | train | Ask For Admin Password | [
30522,
3853,
3198,
29278,
4215,
10020,
15194,
18351,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
19723,
24454,
3686,
1064,
1064,
2023,
1012,
22858,
2483,
3597,
27900,
13874,
999,
1027,
1027,
1005,
21142,
1005,
1007,
2709,
1025,
9530,
3367,
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... |
adobe/brackets | src/view/MainViewManager.js | traverseToNextViewInListOrder | function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
} | javascript | function traverseToNextViewInListOrder(direction) {
var file = getCurrentlyViewedFile(),
curPaneId = getActivePaneId(),
allFiles = [],
index;
getPaneIdList().forEach(function (paneId) {
var paneFiles = getWorkingSet(paneId).map(function (file) {
return { file: file, pane: paneId };
});
allFiles = allFiles.concat(paneFiles);
});
index = _.findIndex(allFiles, function (record) {
return (record.file === file && record.pane === curPaneId);
});
return ViewUtils.traverseViewArray(allFiles, index, direction);
} | [
"function",
"traverseToNextViewInListOrder",
"(",
"direction",
")",
"{",
"var",
"file",
"=",
"getCurrentlyViewedFile",
"(",
")",
",",
"curPaneId",
"=",
"getActivePaneId",
"(",
")",
",",
"allFiles",
"=",
"[",
"]",
",",
"index",
";",
"getPaneIdList",
"(",
")",
... | Get the next or previous file in list order.
@param {!number} direction - Must be 1 or -1 to traverse forward or backward
@return {?{file:File, paneId:string}} The File object of the next item in the traversal order or null if there aren't any files to traverse.
May return current file if there are no other files to traverse. | [
"Get",
"the",
"next",
"or",
"previous",
"file",
"in",
"list",
"order",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L949-L967 | train | traverseToNextViewInListOrder - Traverse to next view in list order | [
30522,
3853,
20811,
5524,
18413,
8584,
2378,
9863,
8551,
2121,
1006,
3257,
1007,
1063,
13075,
5371,
1027,
2131,
10841,
14343,
20630,
8584,
2098,
8873,
2571,
1006,
1007,
1010,
12731,
14536,
7231,
3593,
1027,
2131,
19620,
9739,
7416,
2094,
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... |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/ProfileDataGridTree.js | function()
{
if (this._savedChildren)
return;
this._savedSelfTime = this.selfTime;
this._savedTotalTime = this.totalTime;
this._savedNumberOfCalls = this.numberOfCalls;
this._savedChildren = this.children.slice();
} | javascript | function()
{
if (this._savedChildren)
return;
this._savedSelfTime = this.selfTime;
this._savedTotalTime = this.totalTime;
this._savedNumberOfCalls = this.numberOfCalls;
this._savedChildren = this.children.slice();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_savedChildren",
")",
"return",
";",
"this",
".",
"_savedSelfTime",
"=",
"this",
".",
"selfTime",
";",
"this",
".",
"_savedTotalTime",
"=",
"this",
".",
"totalTime",
";",
"this",
".",
"_savedNumberOfCalls... | When focusing and collapsing we modify lots of nodes in the tree. This allows us to restore them all to their original state when we revert. | [
"When",
"focusing",
"and",
"collapsing",
"we",
"modify",
"lots",
"of",
"nodes",
"in",
"the",
"tree",
".",
"This",
"allows",
"us",
"to",
"restore",
"them",
"all",
"to",
"their",
"original",
"state",
"when",
"we",
"revert",
"."
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/ProfileDataGridTree.js#L227-L237 | train | Save the parameters of the resource | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
5552,
19339,
7389,
1007,
2709,
1025,
2023,
1012,
1035,
5552,
11246,
6199,
14428,
1027,
2023,
1012,
2969,
7292,
1025,
2023,
1012,
1035,
5552,
3406,
9080,
7292,
1027,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
wuchangming/spy-debugger | buildin_modules/weinre/web/modjewel.js | modjewel_getModuleIdsRequired | function modjewel_getModuleIdsRequired(moduleId) {
var module = modjewel_getModule(moduleId)
if (null == module) return null
return module.moduleIdsRequired.slice()
} | javascript | function modjewel_getModuleIdsRequired(moduleId) {
var module = modjewel_getModule(moduleId)
if (null == module) return null
return module.moduleIdsRequired.slice()
} | [
"function",
"modjewel_getModuleIdsRequired",
"(",
"moduleId",
")",
"{",
"var",
"module",
"=",
"modjewel_getModule",
"(",
"moduleId",
")",
"if",
"(",
"null",
"==",
"module",
")",
"return",
"null",
"return",
"module",
".",
"moduleIdsRequired",
".",
"slice",
"(",
... | ---------------------------------------------------------------------------- get a list of module ids which have been required by the specified module id ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------",
"get",
"a",
"list",
"of",
"module",
"ids",
"which",
"have",
"been",
"required",
"by",
"the",
"specified",
"module",
"id",
"----------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/modjewel.js#L318-L323 | train | Returns the moduleIdsRequired array for a module | [
30522,
3853,
16913,
6460,
8545,
2140,
1035,
2131,
5302,
8566,
23057,
5104,
2890,
15549,
5596,
1006,
11336,
3593,
1007,
1063,
13075,
11336,
1027,
16913,
6460,
8545,
2140,
1035,
2131,
5302,
8566,
2571,
1006,
11336,
3593,
1007,
2065,
1006,
197... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | tools/eslint-fuzzer.js | fuzz | function fuzz(options) {
assert.strictEqual(typeof options, "object", "An options object must be provided");
assert.strictEqual(typeof options.count, "number", "The number of iterations (options.count) must be provided");
assert.strictEqual(typeof options.linter, "object", "An linter object (options.linter) must be provided");
const linter = options.linter;
const codeGenerator = options.codeGenerator || (genOptions => eslump.generateRandomJS(Object.assign({ comments: true, whitespace: true }, genOptions)));
const checkAutofixes = options.checkAutofixes !== false;
const progressCallback = options.progressCallback || (() => {});
/**
* Tries to isolate the smallest config that reproduces a problem
* @param {string} text The source text to lint
* @param {Object} config A config object that causes a crash or autofix error
* @param {("crash"|"autofix")} problemType The type of problem that occurred
* @returns {Object} A config object with only one rule enabled that produces the same crash or autofix error, if possible.
* Otherwise, the same as `config`
*/
function isolateBadConfig(text, config, problemType) {
for (const ruleId of Object.keys(config.rules)) {
const reducedConfig = Object.assign({}, config, { rules: { [ruleId]: config.rules[ruleId] } });
let fixResult;
try {
fixResult = linter.verifyAndFix(text, reducedConfig, {});
} catch (err) {
return reducedConfig;
}
if (fixResult.messages.length === 1 && fixResult.messages[0].fatal && problemType === "autofix") {
return reducedConfig;
}
}
return config;
}
/**
* Runs multipass autofix one pass at a time to find the last good source text before a fatal error occurs
* @param {string} originalText Syntactically valid source code that results in a syntax error or crash when autofixing with `config`
* @param {Object} config The config to lint with
* @returns {string} A possibly-modified version of originalText that results in the same syntax error or crash after only one pass
*/
function isolateBadAutofixPass(originalText, config) {
let lastGoodText = originalText;
let currentText = originalText;
do {
let messages;
try {
messages = linter.verify(currentText, config);
} catch (err) {
return lastGoodText;
}
if (messages.length === 1 && messages[0].fatal) {
return lastGoodText;
}
lastGoodText = currentText;
currentText = SourceCodeFixer.applyFixes(currentText, messages).output;
} while (lastGoodText !== currentText);
return lastGoodText;
}
const problems = [];
for (let i = 0; i < options.count; progressCallback(problems.length), i++) {
const sourceType = lodash.sample(["script", "module"]);
const text = codeGenerator({ sourceType });
const config = {
rules: lodash.mapValues(ruleConfigs, lodash.sample),
parserOptions: { sourceType, ecmaVersion: 2018 }
};
let autofixResult;
try {
if (checkAutofixes) {
autofixResult = linter.verifyAndFix(text, config, {});
} else {
linter.verify(text, config);
}
} catch (err) {
problems.push({ type: "crash", text, config: isolateBadConfig(text, config, "crash"), error: err.stack });
continue;
}
if (checkAutofixes && autofixResult.fixed && autofixResult.messages.length === 1 && autofixResult.messages[0].fatal) {
const lastGoodText = isolateBadAutofixPass(text, config);
problems.push({ type: "autofix", text: lastGoodText, config: isolateBadConfig(lastGoodText, config, "autofix"), error: autofixResult.messages[0] });
}
}
return problems;
} | javascript | function fuzz(options) {
assert.strictEqual(typeof options, "object", "An options object must be provided");
assert.strictEqual(typeof options.count, "number", "The number of iterations (options.count) must be provided");
assert.strictEqual(typeof options.linter, "object", "An linter object (options.linter) must be provided");
const linter = options.linter;
const codeGenerator = options.codeGenerator || (genOptions => eslump.generateRandomJS(Object.assign({ comments: true, whitespace: true }, genOptions)));
const checkAutofixes = options.checkAutofixes !== false;
const progressCallback = options.progressCallback || (() => {});
/**
* Tries to isolate the smallest config that reproduces a problem
* @param {string} text The source text to lint
* @param {Object} config A config object that causes a crash or autofix error
* @param {("crash"|"autofix")} problemType The type of problem that occurred
* @returns {Object} A config object with only one rule enabled that produces the same crash or autofix error, if possible.
* Otherwise, the same as `config`
*/
function isolateBadConfig(text, config, problemType) {
for (const ruleId of Object.keys(config.rules)) {
const reducedConfig = Object.assign({}, config, { rules: { [ruleId]: config.rules[ruleId] } });
let fixResult;
try {
fixResult = linter.verifyAndFix(text, reducedConfig, {});
} catch (err) {
return reducedConfig;
}
if (fixResult.messages.length === 1 && fixResult.messages[0].fatal && problemType === "autofix") {
return reducedConfig;
}
}
return config;
}
/**
* Runs multipass autofix one pass at a time to find the last good source text before a fatal error occurs
* @param {string} originalText Syntactically valid source code that results in a syntax error or crash when autofixing with `config`
* @param {Object} config The config to lint with
* @returns {string} A possibly-modified version of originalText that results in the same syntax error or crash after only one pass
*/
function isolateBadAutofixPass(originalText, config) {
let lastGoodText = originalText;
let currentText = originalText;
do {
let messages;
try {
messages = linter.verify(currentText, config);
} catch (err) {
return lastGoodText;
}
if (messages.length === 1 && messages[0].fatal) {
return lastGoodText;
}
lastGoodText = currentText;
currentText = SourceCodeFixer.applyFixes(currentText, messages).output;
} while (lastGoodText !== currentText);
return lastGoodText;
}
const problems = [];
for (let i = 0; i < options.count; progressCallback(problems.length), i++) {
const sourceType = lodash.sample(["script", "module"]);
const text = codeGenerator({ sourceType });
const config = {
rules: lodash.mapValues(ruleConfigs, lodash.sample),
parserOptions: { sourceType, ecmaVersion: 2018 }
};
let autofixResult;
try {
if (checkAutofixes) {
autofixResult = linter.verifyAndFix(text, config, {});
} else {
linter.verify(text, config);
}
} catch (err) {
problems.push({ type: "crash", text, config: isolateBadConfig(text, config, "crash"), error: err.stack });
continue;
}
if (checkAutofixes && autofixResult.fixed && autofixResult.messages.length === 1 && autofixResult.messages[0].fatal) {
const lastGoodText = isolateBadAutofixPass(text, config);
problems.push({ type: "autofix", text: lastGoodText, config: isolateBadConfig(lastGoodText, config, "autofix"), error: autofixResult.messages[0] });
}
}
return problems;
} | [
"function",
"fuzz",
"(",
"options",
")",
"{",
"assert",
".",
"strictEqual",
"(",
"typeof",
"options",
",",
"\"object\"",
",",
"\"An options object must be provided\"",
")",
";",
"assert",
".",
"strictEqual",
"(",
"typeof",
"options",
".",
"count",
",",
"\"number... | ------------------------------------------------------------------------------ Public API ------------------------------------------------------------------------------
Generates random JS code, runs ESLint on it, and returns a list of detected crashes or autofix bugs
@param {Object} options Config options for fuzzing
@param {number} options.count The number of fuzz iterations.
@param {Object} options.linter The linter object to test with.
@param {function(Object): string} [options.codeGenerator=eslump.generateRandomJS] A function to use to generate random
code. Accepts an object argument with a `sourceType` key, indicating the source type of the generated code. The object
might also be passed other keys.
@param {boolean} [options.checkAutofixes=true] `true` if the fuzzer should check for autofix bugs. The fuzzer runs
roughly 4 times slower with autofix checking enabled.
@param {function(number)} [options.progressCallback] A function that gets called once for each code sample, with the total number of errors found so far
@returns {Object[]} A list of problems found. Each problem has the following properties:
type (string): The type of problem. This is either "crash" (a rule crashes) or "autofix" (an autofix produces a syntax error)
text (string): The text that ESLint should be run on to reproduce the problem
config (object): The config object that should be used to reproduce the problem. The fuzzer will try to return a minimal
config (that only has one rule enabled), but this isn't always possible.
error (*) The problem that occurred. For crashes, this will be the error stack. For autofix bugs, this will be
the parsing error object that was thrown when parsing the autofixed code. | [
"------------------------------------------------------------------------------",
"Public",
"API",
"------------------------------------------------------------------------------",
"Generates",
"random",
"JS",
"code",
"runs",
"ESLint",
"on",
"it",
"and",
"returns",
"a",
"list",
"of",... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/eslint-fuzzer.js#L41-L138 | train | Fuzzes a source code from a source text. | [
30522,
3853,
11865,
13213,
1006,
7047,
1007,
1063,
20865,
1012,
9384,
2063,
26426,
1006,
2828,
11253,
7047,
1010,
1000,
4874,
1000,
1010,
1000,
2019,
7047,
4874,
2442,
2022,
3024,
1000,
1007,
1025,
20865,
1012,
9384,
2063,
26426,
1006,
2828... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js | function(sControllerName, vObject) {
var oResultConfig;
findConfig(CONFIG_CONTROLLER_REPLACEMENTS, vObject, function(oConfig) {
oResultConfig = oConfig[sControllerName];
return !!oResultConfig;
});
return oResultConfig;
} | javascript | function(sControllerName, vObject) {
var oResultConfig;
findConfig(CONFIG_CONTROLLER_REPLACEMENTS, vObject, function(oConfig) {
oResultConfig = oConfig[sControllerName];
return !!oResultConfig;
});
return oResultConfig;
} | [
"function",
"(",
"sControllerName",
",",
"vObject",
")",
"{",
"var",
"oResultConfig",
";",
"findConfig",
"(",
"CONFIG_CONTROLLER_REPLACEMENTS",
",",
"vObject",
",",
"function",
"(",
"oConfig",
")",
"{",
"oResultConfig",
"=",
"oConfig",
"[",
"sControllerName",
"]",... | returns the configuration of the controller replacement for the given
controller name
@private | [
"returns",
"the",
"configuration",
"of",
"the",
"controller",
"replacement",
"for",
"the",
"given",
"controller",
"name"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/CustomizingConfiguration.js#L199-L206 | train | Returns the configuration for the controller replacement | [
30522,
3853,
1006,
8040,
12162,
26611,
18442,
1010,
30524,
8873,
2290,
1025,
2424,
8663,
8873,
2290,
1006,
9530,
8873,
2290,
1035,
11486,
1035,
23936,
1010,
29536,
2497,
20614,
1010,
3853,
1006,
1051,
8663,
8873,
2290,
1007,
1063,
10848,
23... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.